@tsed/formio 7.0.0-beta.8 → 7.0.0-rc.2
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/jest.config.js +14 -0
- package/lib/cjs/FormioModule.js +18 -14
- package/lib/cjs/FormioModule.js.map +1 -1
- package/lib/cjs/builder/FormioMapper.js +2 -1
- package/lib/cjs/builder/FormioMapper.js.map +1 -1
- package/lib/cjs/components/AlterActions.js +47 -41
- package/lib/cjs/components/AlterActions.js.map +1 -1
- package/lib/cjs/components/AlterSkip.js +2 -0
- package/lib/cjs/components/AlterSkip.js.map +1 -1
- package/lib/cjs/components/AlterTemplateExportSteps.js +1 -0
- package/lib/cjs/components/AlterTemplateExportSteps.js.map +1 -1
- package/lib/cjs/components/AlterTemplateImportSteps.js +1 -0
- package/lib/cjs/components/AlterTemplateImportSteps.js.map +1 -1
- package/lib/cjs/middlewares/FormioAuthMiddleware.js +1 -0
- package/lib/cjs/middlewares/FormioAuthMiddleware.js.map +1 -1
- package/lib/cjs/services/FormioAuthService.js +4 -1
- package/lib/cjs/services/FormioAuthService.js.map +1 -1
- package/lib/cjs/services/FormioDatabase.js +3 -2
- package/lib/cjs/services/FormioDatabase.js.map +1 -1
- package/lib/cjs/services/FormioHooksService.js +2 -0
- package/lib/cjs/services/FormioHooksService.js.map +1 -1
- package/lib/cjs/services/FormioInstaller.js +2 -7
- package/lib/cjs/services/FormioInstaller.js.map +1 -1
- package/lib/cjs/services/FormioRepository.js +2 -0
- package/lib/cjs/services/FormioRepository.js.map +1 -1
- package/lib/cjs/services/FormioService.js +2 -0
- package/lib/cjs/services/FormioService.js.map +1 -1
- package/lib/esm/FormioModule.js +18 -14
- package/lib/esm/FormioModule.js.map +1 -1
- package/lib/esm/builder/FormioMapper.js +2 -1
- package/lib/esm/builder/FormioMapper.js.map +1 -1
- package/lib/esm/components/AlterActions.js +47 -41
- package/lib/esm/components/AlterActions.js.map +1 -1
- package/lib/esm/components/AlterSkip.js +2 -0
- package/lib/esm/components/AlterSkip.js.map +1 -1
- package/lib/esm/components/AlterTemplateExportSteps.js +1 -0
- package/lib/esm/components/AlterTemplateExportSteps.js.map +1 -1
- package/lib/esm/components/AlterTemplateImportSteps.js +1 -0
- package/lib/esm/components/AlterTemplateImportSteps.js.map +1 -1
- package/lib/esm/middlewares/FormioAuthMiddleware.js +1 -0
- package/lib/esm/middlewares/FormioAuthMiddleware.js.map +1 -1
- package/lib/esm/services/FormioAuthService.js +4 -1
- package/lib/esm/services/FormioAuthService.js.map +1 -1
- package/lib/esm/services/FormioDatabase.js +3 -2
- package/lib/esm/services/FormioDatabase.js.map +1 -1
- package/lib/esm/services/FormioHooksService.js +2 -0
- package/lib/esm/services/FormioHooksService.js.map +1 -1
- package/lib/esm/services/FormioInstaller.js +2 -7
- package/lib/esm/services/FormioInstaller.js.map +1 -1
- package/lib/esm/services/FormioRepository.js +2 -0
- package/lib/esm/services/FormioRepository.js.map +1 -1
- package/lib/esm/services/FormioService.js +2 -0
- package/lib/esm/services/FormioService.js.map +1 -1
- package/lib/types/components/AlterActions.d.ts +2 -4
- package/lib/types/services/FormioAuthService.d.ts +23 -4
- package/lib/types/services/FormioDatabase.d.ts +24 -7
- package/lib/types/services/FormioInstaller.d.ts +0 -2
- package/lib/types/services/FormioRepository.d.ts +19 -2
- package/package.json +14 -11
- package/readme.md +3 -2
- package/.mocharc.js +0 -5
- package/.nycrc +0 -27
|
@@ -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/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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;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AAC,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
|
}
|
|
@@ -90,7 +91,7 @@ let FormioDatabase = class FormioDatabase {
|
|
|
90
91
|
return this.saveForm(mapper.mapToImport(form));
|
|
91
92
|
}
|
|
92
93
|
async saveForm(form) {
|
|
93
|
-
form = omit(form, ["__v"]);
|
|
94
|
+
form = new this.formModel(omit(form, ["__v"]));
|
|
94
95
|
return this.formModel.findOneAndUpdate({ _id: form._id }, form, { upsert: true, new: true });
|
|
95
96
|
}
|
|
96
97
|
async getSubmissions(query = {}) {
|
|
@@ -109,7 +110,7 @@ let FormioDatabase = class FormioDatabase {
|
|
|
109
110
|
return this.saveSubmission(mapper.mapToImport(submission));
|
|
110
111
|
}
|
|
111
112
|
async saveSubmission(submission) {
|
|
112
|
-
submission = omit(submission, ["__v"]);
|
|
113
|
+
submission = new this.submissionModel(omit(submission, ["__v"]));
|
|
113
114
|
return this.submissionModel.findOneAndUpdate({
|
|
114
115
|
_id: submission._id
|
|
115
116
|
}, submission, { new: true, upsert: true });
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services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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,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAEjE,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 = new this.formModel(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 = new this.submissionModel(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
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormioHooksService.js","sourceRoot":"","sources":["../../../src/services/FormioHooksService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAE/B,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAI9C,IAAa,kBAAkB,GAA/B,MAAa,kBAAkB;
|
|
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,CAAC;SAChC,CAAC;IACJ,CAAC;IAES,Y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AAC,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: [
|
|
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;
|
|
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,KAA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Y,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;
|
|
1
|
+
{"version":3,"file":"FormioRepository.js","sourceRoot":"","sources":["../../../src/services/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":["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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormioService.js","sourceRoot":"","sources":["../../../src/services/FormioService.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAIjE,OAAO,EAAC,SAAS,EAAC,MAAM,MAAM,CAAC;AAQ/B,aAAa;AACb,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,aAAa;AACb,OAAO,OAAO,MAAM,4BAA4B,CAAC;AACjD,aAAa;AACb,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAG3C,IAAa,aAAa,GAA1B,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"FormioService.js","sourceRoot":"","sources":["../../../src/services/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,EAAE,CAAC;YAElB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAChC;IACH,CAAC;IAES,gBAAgB,CAAC,OAAqB;QAC9C,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QACxB,MAAM,gBAAgB,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAA4B,YAAY,CAAC,CAAC;QAExF,IAAI,gBAAgB,EAAE;YACpB,OAAO,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,gBAAgB,CAAC,GAAG,CAAC;YACtD,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;SACjG;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAES,UAAU;QAClB,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;QAExB,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;CACF,CAAA;AA3GC;IADC,MAAM,EAAE;8BACW,eAAe;+CAAC;AAJzB,aAAa;IADzB,UAAU,EAAE;GACA,aAAa,CA+GzB;SA/GY,aAAa","sourcesContent":["import {Inject, Injectable, InjectorService} from \"@tsed/common\";\nimport {MongooseConnectionOptions} from \"@tsed/mongoose\";\nimport {Db} from \"mongodb\";\nimport {Mongoose} from \"mongoose\";\nimport {promisify} from \"util\";\nimport {Formio} from \"../domain/Formio\";\nimport {FormioConfig} from \"../domain/FormioConfig\";\nimport {FormioHook, FormioHooks} from \"../domain/FormioHooks\";\nimport {FormioSchemas} from \"../domain/FormioModels\";\nimport {FormioRouter} from \"../domain/FormioRouter\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioExportOptions} from \"../domain/FormioTemplateUtil\";\n// @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,7 +1,6 @@
|
|
|
1
1
|
import { InjectorService, Provider } from "@tsed/di";
|
|
2
2
|
import { PlatformParams } from "@tsed/platform-params";
|
|
3
3
|
import { PlatformResponseFilter } from "@tsed/platform-response-filter";
|
|
4
|
-
import { PlatformContext } from "@tsed/common";
|
|
5
4
|
import { AlterHook } from "../domain/AlterHook";
|
|
6
5
|
import { SetActionItemMessage } from "../domain/FormioAction";
|
|
7
6
|
import { FormioActions } from "../domain/FormioActionsIndex";
|
|
@@ -13,8 +12,7 @@ export declare class AlterActions implements AlterHook {
|
|
|
13
12
|
protected responseFilter: PlatformResponseFilter;
|
|
14
13
|
transform(actions: FormioActions): FormioActions;
|
|
15
14
|
protected getActions(): Provider<any>[];
|
|
16
|
-
protected createHandler(provider: Provider, propertyKey: string | symbol): (action: any, handler: string, method: string, req:
|
|
17
|
-
|
|
18
|
-
}, res: any, next: any, setActionItemMessage: SetActionItemMessage) => Promise<void>;
|
|
15
|
+
protected createHandler(provider: Provider, propertyKey: string | symbol): (action: any, handler: string, method: string, req: any, res: any, next: any, setActionItemMessage: SetActionItemMessage) => Promise<void>;
|
|
16
|
+
private onRequest;
|
|
19
17
|
private flush;
|
|
20
18
|
}
|
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
2
4
|
/// <reference types="mongoose/types/connection" />
|
|
3
5
|
/// <reference types="mongoose/types/cursor" />
|
|
4
6
|
/// <reference types="mongoose/types/document" />
|
|
5
7
|
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
6
13
|
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
7
17
|
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
8
24
|
/// <reference types="mongoose" />
|
|
25
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
9
26
|
import { PlatformContext, Req } from "@tsed/common";
|
|
10
27
|
import { FormioPayloadToken } from "../domain/FormioDecodedToken";
|
|
11
28
|
import { FormioSubmission, WithID } from "../domain/FormioModels";
|
|
@@ -41,7 +58,7 @@ export declare class FormioAuthService {
|
|
|
41
58
|
* @param req
|
|
42
59
|
*/
|
|
43
60
|
getRoles(req?: Req): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole & import("@tsed/mongoose").MongooseDocumentMethods<import("@tsed/formio-types/lib/types/domain/FormioRole").FormioRole>> & {
|
|
44
|
-
_id:
|
|
61
|
+
_id: import("mongoose").Types.ObjectId;
|
|
45
62
|
}>[]>;
|
|
46
63
|
/**
|
|
47
64
|
* Update the role of the current user submission
|
|
@@ -50,13 +67,15 @@ export declare class FormioAuthService {
|
|
|
50
67
|
* @param req
|
|
51
68
|
*/
|
|
52
69
|
updateUserRole(_id: string | any, role: string, req?: Req): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
|
|
53
|
-
_id:
|
|
70
|
+
_id: import("mongoose").Types.ObjectId;
|
|
54
71
|
}>;
|
|
55
72
|
/**
|
|
56
73
|
* Create a user submission in formio
|
|
57
74
|
* @param user
|
|
58
75
|
*/
|
|
59
|
-
createUser<User = any>(user: Partial<FormioSubmission<User>>): Promise<import("mongoose").LeanDocument<
|
|
76
|
+
createUser<User = any>(user: Partial<FormioSubmission<User>>): Promise<import("mongoose").LeanDocument<any> & Required<{
|
|
77
|
+
_id: unknown;
|
|
78
|
+
}>>;
|
|
60
79
|
/**
|
|
61
80
|
* Update user submission in formio
|
|
62
81
|
* @param user
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
2
4
|
/// <reference types="mongoose/types/connection" />
|
|
3
5
|
/// <reference types="mongoose/types/cursor" />
|
|
4
6
|
/// <reference types="mongoose/types/document" />
|
|
5
7
|
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
6
13
|
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
7
17
|
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
8
25
|
import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
|
|
9
26
|
import type { FilterQuery } from "mongoose";
|
|
10
27
|
import { FormioAction, FormioActionItem, FormioForm, FormioRole, FormioSubmission, FormioToken } from "@tsed/formio-types";
|
|
@@ -23,7 +40,7 @@ export declare class FormioDatabase {
|
|
|
23
40
|
hasForms(): Promise<boolean>;
|
|
24
41
|
hasForm(name: string): Promise<boolean>;
|
|
25
42
|
getForm(nameOrId: string): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
|
|
26
|
-
_id:
|
|
43
|
+
_id: import("mongoose").Types.ObjectId;
|
|
27
44
|
}> | null>;
|
|
28
45
|
/**
|
|
29
46
|
* Import form previously exported by export tool.
|
|
@@ -32,7 +49,7 @@ export declare class FormioDatabase {
|
|
|
32
49
|
* @param onCreate
|
|
33
50
|
*/
|
|
34
51
|
importFormIfNotExists(form: FormioForm, onCreate?: (form: FormioForm) => any): Promise<import("mongoose").LeanDocument<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
|
|
35
|
-
_id:
|
|
52
|
+
_id: import("mongoose").Types.ObjectId;
|
|
36
53
|
}> | null>;
|
|
37
54
|
/**
|
|
38
55
|
* Import form previously exported by export tool.
|
|
@@ -40,10 +57,10 @@ export declare class FormioDatabase {
|
|
|
40
57
|
* @param form
|
|
41
58
|
*/
|
|
42
59
|
importForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
|
|
43
|
-
_id:
|
|
60
|
+
_id: import("mongoose").Types.ObjectId;
|
|
44
61
|
}>;
|
|
45
62
|
saveForm(form: FormioForm): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioForm & import("@tsed/mongoose").MongooseDocumentMethods<FormioForm>> & {
|
|
46
|
-
_id:
|
|
63
|
+
_id: import("mongoose").Types.ObjectId;
|
|
47
64
|
}>;
|
|
48
65
|
getSubmissions<Data>(query?: FilterQuery<MongooseModel<FormioSubmission<Data>>>): Promise<MongooseDocument<FormioSubmission<Data>>[]>;
|
|
49
66
|
/**
|
|
@@ -54,10 +71,10 @@ export declare class FormioDatabase {
|
|
|
54
71
|
importSubmission<Data = any>(submission: Omit<Partial<FormioSubmission<Data>>, "form"> & {
|
|
55
72
|
form?: any;
|
|
56
73
|
}): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
|
|
57
|
-
_id:
|
|
74
|
+
_id: import("mongoose").Types.ObjectId;
|
|
58
75
|
}>;
|
|
59
76
|
saveSubmission<Data = any>(submission: Partial<FormioSubmission<Data>>): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
|
|
60
|
-
_id:
|
|
77
|
+
_id: import("mongoose").Types.ObjectId;
|
|
61
78
|
}>;
|
|
62
79
|
idToBson(form?: any): any;
|
|
63
80
|
}
|
|
@@ -2,9 +2,7 @@ import { Logger } from "@tsed/logger";
|
|
|
2
2
|
import { FormioSubmission } from "../domain/FormioModels";
|
|
3
3
|
import { FormioTemplate } from "../domain/FormioTemplate";
|
|
4
4
|
import { FormioDatabase } from "./FormioDatabase";
|
|
5
|
-
import { FormioService } from "./FormioService";
|
|
6
5
|
export declare class FormioInstaller extends FormioDatabase {
|
|
7
|
-
protected formio: FormioService;
|
|
8
6
|
protected logger: Logger;
|
|
9
7
|
install(template: FormioTemplate, root: any): Promise<void>;
|
|
10
8
|
createRootUser<User = unknown>(user: {
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
2
4
|
/// <reference types="mongoose/types/connection" />
|
|
3
5
|
/// <reference types="mongoose/types/cursor" />
|
|
4
6
|
/// <reference types="mongoose/types/document" />
|
|
5
7
|
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
6
13
|
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
7
17
|
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
8
25
|
import type { FilterQuery } from "mongoose";
|
|
9
26
|
import { MongooseDocument, MongooseModel } from "@tsed/mongoose";
|
|
10
27
|
import { FormioSubmission } from "../domain/FormioModels";
|
|
@@ -17,7 +34,7 @@ export declare abstract class FormioRepository<SubmissionData = any> {
|
|
|
17
34
|
saveSubmission(submission: Omit<Partial<FormioSubmission<SubmissionData>>, "form"> & {
|
|
18
35
|
form?: any;
|
|
19
36
|
}): Promise<import("@tsed/mongoose").MongooseMergedDocument<import("mongoose").Document<any, any, any> & FormioSubmission<any> & import("@tsed/mongoose").MongooseDocumentMethods<FormioSubmission<any>>> & {
|
|
20
|
-
_id:
|
|
37
|
+
_id: import("mongoose").Types.ObjectId;
|
|
21
38
|
}>;
|
|
22
39
|
getSubmissions(query?: FilterQuery<MongooseModel<FormioSubmission<SubmissionData>>>): Promise<MongooseDocument<FormioSubmission<SubmissionData>>[]>;
|
|
23
40
|
findOneSubmission(query: any): Promise<MongooseDocument<FormioSubmission<SubmissionData>> | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/formio",
|
|
3
|
-
"version": "7.0.0-
|
|
3
|
+
"version": "7.0.0-rc.2",
|
|
4
4
|
"description": "Formio package for Ts.ED framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"keywords": [
|
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
28
28
|
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\" -e \".benchmark.ts\"",
|
|
29
29
|
"start": "ts-node -r tsconfig-paths/register test/app/index.ts",
|
|
30
|
-
"test": "cross-env NODE_ENV=test
|
|
30
|
+
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@tsed/formio-types": "7.0.0-
|
|
34
|
-
"tslib": "2.
|
|
33
|
+
"@tsed/formio-types": "7.0.0-rc.2",
|
|
34
|
+
"tslib": "2.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@tsed/common": "7.0.0-
|
|
38
|
-
"@tsed/core": "7.0.0-
|
|
39
|
-
"@tsed/di": "7.0.0-
|
|
40
|
-
"@tsed/mongoose": "7.0.0-
|
|
37
|
+
"@tsed/common": "7.0.0-rc.2",
|
|
38
|
+
"@tsed/core": "7.0.0-rc.2",
|
|
39
|
+
"@tsed/di": "7.0.0-rc.2",
|
|
40
|
+
"@tsed/mongoose": "7.0.0-rc.2",
|
|
41
41
|
"@types/async": "3.2.12",
|
|
42
42
|
"express": "^4.17.1",
|
|
43
43
|
"formio": "^2.0.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"mongoose": "^6.1.7"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@tsed/common": "^7.0.0-
|
|
48
|
+
"@tsed/common": "^7.0.0-rc.2",
|
|
49
49
|
"express": "^4.17.1",
|
|
50
50
|
"formio": "^2.0.0",
|
|
51
51
|
"lodash": "^4.17.21",
|
|
@@ -61,7 +61,10 @@
|
|
|
61
61
|
"bugs": {
|
|
62
62
|
"url": "https://github.com/tsedio/tsed/issues"
|
|
63
63
|
},
|
|
64
|
-
"homepage": "https://github.com/tsedio/tsed/tree/
|
|
64
|
+
"homepage": "https://github.com/tsedio/tsed/tree/rc/packages/third-parties/formio",
|
|
65
65
|
"author": "Romain Lenzotti",
|
|
66
|
-
"license": "MIT"
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"tag": "rc"
|
|
69
|
+
}
|
|
67
70
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|
|
@@ -78,7 +79,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
78
79
|
|
|
79
80
|
The MIT License (MIT)
|
|
80
81
|
|
|
81
|
-
Copyright (c) 2016 -
|
|
82
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
82
83
|
|
|
83
84
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
84
85
|
|
package/.mocharc.js
DELETED
package/.nycrc
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"include": [
|
|
3
|
-
"src/**/*.ts"
|
|
4
|
-
],
|
|
5
|
-
"exclude": [
|
|
6
|
-
"**/*.d.ts",
|
|
7
|
-
"node_modules",
|
|
8
|
-
"**/interfaces/**",
|
|
9
|
-
"**/index.ts",
|
|
10
|
-
"**/*.spec.ts"
|
|
11
|
-
],
|
|
12
|
-
"extension": [
|
|
13
|
-
".ts"
|
|
14
|
-
],
|
|
15
|
-
"require": [],
|
|
16
|
-
"reporter": [
|
|
17
|
-
"text-summary",
|
|
18
|
-
"html",
|
|
19
|
-
"lcov",
|
|
20
|
-
"json"
|
|
21
|
-
],
|
|
22
|
-
"check-coverage": true,
|
|
23
|
-
"statements": 100,
|
|
24
|
-
"branches": 80.42,
|
|
25
|
-
"functions": 100,
|
|
26
|
-
"lines": 100
|
|
27
|
-
}
|