@tsed/formio 7.83.3 → 8.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/lib/esm/FormioModule.js.map +1 -1
  2. package/lib/esm/builder/FormioMapper.js.map +1 -1
  3. package/lib/esm/components/AlterActions.js.map +1 -1
  4. package/lib/esm/components/AlterAudit.js.map +1 -1
  5. package/lib/esm/components/AlterHost.js.map +1 -1
  6. package/lib/esm/components/AlterLog.js.map +1 -1
  7. package/lib/esm/components/AlterSkip.js.map +1 -1
  8. package/lib/esm/components/AlterTemplateExportSteps.js +1 -1
  9. package/lib/esm/components/AlterTemplateExportSteps.js.map +1 -1
  10. package/lib/esm/components/AlterTemplateImportSteps.js +1 -1
  11. package/lib/esm/components/AlterTemplateImportSteps.js.map +1 -1
  12. package/lib/esm/decorators/action.js.map +1 -1
  13. package/lib/esm/decorators/actionCtx.js.map +1 -1
  14. package/lib/esm/decorators/alter.js.map +1 -1
  15. package/lib/esm/decorators/on.js.map +1 -1
  16. package/lib/esm/decorators/useFormioAuth.js.map +1 -1
  17. package/lib/esm/domain/FormioModels.js.map +1 -1
  18. package/lib/esm/middlewares/FormioAuthMiddleware.js.map +1 -1
  19. package/lib/esm/services/FormioAuthService.js.map +1 -1
  20. package/lib/esm/services/FormioDatabase.js +1 -1
  21. package/lib/esm/services/FormioDatabase.js.map +1 -1
  22. package/lib/esm/services/FormioHooksService.js.map +1 -1
  23. package/lib/esm/services/FormioInstaller.js.map +1 -1
  24. package/lib/esm/services/FormioRepository.js.map +1 -1
  25. package/lib/esm/services/FormioService.js +1 -1
  26. package/lib/esm/services/FormioService.js.map +1 -1
  27. package/lib/types/decorators/actionCtx.d.ts +1 -1
  28. package/lib/types/domain/Formio.d.ts +26 -1
  29. package/lib/types/domain/FormioAction.d.ts +1 -1
  30. package/lib/types/domain/FormioBaseModel.d.ts +27 -1
  31. package/lib/types/domain/FormioCtxMapper.d.ts +1 -1
  32. package/lib/types/domain/FormioHooks.d.ts +26 -0
  33. package/lib/types/domain/FormioModels.d.ts +26 -1
  34. package/lib/types/domain/Resource.d.ts +1 -1
  35. package/lib/types/services/FormioAuthService.d.ts +11 -7
  36. package/lib/types/services/FormioDatabase.d.ts +36 -21
  37. package/lib/types/services/FormioHooksService.d.ts +1 -1
  38. package/lib/types/services/FormioRepository.d.ts +8 -3
  39. package/lib/types/services/FormioService.d.ts +25 -0
  40. package/package.json +26 -24
  41. package/vitest.config.mts +5 -5
  42. package/lib/cjs/FormioModule.js +0 -132
  43. package/lib/cjs/FormioModule.js.map +0 -1
  44. package/lib/cjs/builder/FormioMapper.js +0 -61
  45. package/lib/cjs/builder/FormioMapper.js.map +0 -1
  46. package/lib/cjs/components/AlterActions.js +0 -113
  47. package/lib/cjs/components/AlterActions.js.map +0 -1
  48. package/lib/cjs/components/AlterAudit.js +0 -16
  49. package/lib/cjs/components/AlterAudit.js.map +0 -1
  50. package/lib/cjs/components/AlterHost.js +0 -15
  51. package/lib/cjs/components/AlterHost.js.map +0 -1
  52. package/lib/cjs/components/AlterLog.js +0 -16
  53. package/lib/cjs/components/AlterLog.js.map +0 -1
  54. package/lib/cjs/components/AlterSkip.js +0 -32
  55. package/lib/cjs/components/AlterSkip.js.map +0 -1
  56. package/lib/cjs/components/AlterTemplateExportSteps.js +0 -52
  57. package/lib/cjs/components/AlterTemplateExportSteps.js.map +0 -1
  58. package/lib/cjs/components/AlterTemplateImportSteps.js +0 -45
  59. package/lib/cjs/components/AlterTemplateImportSteps.js.map +0 -1
  60. package/lib/cjs/decorators/action.js +0 -20
  61. package/lib/cjs/decorators/action.js.map +0 -1
  62. package/lib/cjs/decorators/actionCtx.js +0 -23
  63. package/lib/cjs/decorators/actionCtx.js.map +0 -1
  64. package/lib/cjs/decorators/alter.js +0 -20
  65. package/lib/cjs/decorators/alter.js.map +0 -1
  66. package/lib/cjs/decorators/on.js +0 -20
  67. package/lib/cjs/decorators/on.js.map +0 -1
  68. package/lib/cjs/decorators/useFormioAuth.js +0 -15
  69. package/lib/cjs/decorators/useFormioAuth.js.map +0 -1
  70. package/lib/cjs/domain/AlterHook.js +0 -3
  71. package/lib/cjs/domain/AlterHook.js.map +0 -1
  72. package/lib/cjs/domain/Formio.js +0 -3
  73. package/lib/cjs/domain/Formio.js.map +0 -1
  74. package/lib/cjs/domain/FormioAction.js +0 -3
  75. package/lib/cjs/domain/FormioAction.js.map +0 -1
  76. package/lib/cjs/domain/FormioActionsIndex.js +0 -3
  77. package/lib/cjs/domain/FormioActionsIndex.js.map +0 -1
  78. package/lib/cjs/domain/FormioAuth.js +0 -3
  79. package/lib/cjs/domain/FormioAuth.js.map +0 -1
  80. package/lib/cjs/domain/FormioBaseModel.js +0 -3
  81. package/lib/cjs/domain/FormioBaseModel.js.map +0 -1
  82. package/lib/cjs/domain/FormioConfig.js +0 -3
  83. package/lib/cjs/domain/FormioConfig.js.map +0 -1
  84. package/lib/cjs/domain/FormioCtxMapper.js +0 -3
  85. package/lib/cjs/domain/FormioCtxMapper.js.map +0 -1
  86. package/lib/cjs/domain/FormioDecodedToken.js +0 -3
  87. package/lib/cjs/domain/FormioDecodedToken.js.map +0 -1
  88. package/lib/cjs/domain/FormioErrors.js +0 -3
  89. package/lib/cjs/domain/FormioErrors.js.map +0 -1
  90. package/lib/cjs/domain/FormioHooks.js +0 -3
  91. package/lib/cjs/domain/FormioHooks.js.map +0 -1
  92. package/lib/cjs/domain/FormioJs.js +0 -3
  93. package/lib/cjs/domain/FormioJs.js.map +0 -1
  94. package/lib/cjs/domain/FormioModels.js +0 -5
  95. package/lib/cjs/domain/FormioModels.js.map +0 -1
  96. package/lib/cjs/domain/FormioRouter.js +0 -3
  97. package/lib/cjs/domain/FormioRouter.js.map +0 -1
  98. package/lib/cjs/domain/FormioSettings.js +0 -3
  99. package/lib/cjs/domain/FormioSettings.js.map +0 -1
  100. package/lib/cjs/domain/FormioTemplate.js +0 -3
  101. package/lib/cjs/domain/FormioTemplate.js.map +0 -1
  102. package/lib/cjs/domain/FormioTemplateUtil.js +0 -3
  103. package/lib/cjs/domain/FormioTemplateUtil.js.map +0 -1
  104. package/lib/cjs/domain/FormioUpdate.js +0 -3
  105. package/lib/cjs/domain/FormioUpdate.js.map +0 -1
  106. package/lib/cjs/domain/FormioUtils.js +0 -3
  107. package/lib/cjs/domain/FormioUtils.js.map +0 -1
  108. package/lib/cjs/domain/OnHook.js +0 -3
  109. package/lib/cjs/domain/OnHook.js.map +0 -1
  110. package/lib/cjs/domain/Resource.js +0 -3
  111. package/lib/cjs/domain/Resource.js.map +0 -1
  112. package/lib/cjs/index.js +0 -50
  113. package/lib/cjs/index.js.map +0 -1
  114. package/lib/cjs/middlewares/FormioAuthMiddleware.js +0 -41
  115. package/lib/cjs/middlewares/FormioAuthMiddleware.js.map +0 -1
  116. package/lib/cjs/package.json +0 -3
  117. package/lib/cjs/services/FormioAuthService.js +0 -182
  118. package/lib/cjs/services/FormioAuthService.js.map +0 -1
  119. package/lib/cjs/services/FormioDatabase.js +0 -140
  120. package/lib/cjs/services/FormioDatabase.js.map +0 -1
  121. package/lib/cjs/services/FormioHooksService.js +0 -81
  122. package/lib/cjs/services/FormioHooksService.js.map +0 -1
  123. package/lib/cjs/services/FormioInstaller.js +0 -44
  124. package/lib/cjs/services/FormioInstaller.js.map +0 -1
  125. package/lib/cjs/services/FormioRepository.js +0 -42
  126. package/lib/cjs/services/FormioRepository.js.map +0 -1
  127. package/lib/cjs/services/FormioService.js +0 -103
  128. package/lib/cjs/services/FormioService.js.map +0 -1
  129. package/lib/cjs/utils/isMongoId.js +0 -8
  130. package/lib/cjs/utils/isMongoId.js.map +0 -1
  131. package/lib/esm/package.json +0 -3
  132. package/lib/types-esm/FormioModule.d.ts +0 -24
  133. package/lib/types-esm/builder/FormioMapper.d.ts +0 -11
  134. package/lib/types-esm/components/AlterActions.d.ts +0 -18
  135. package/lib/types-esm/components/AlterAudit.d.ts +0 -5
  136. package/lib/types-esm/components/AlterHost.d.ts +0 -5
  137. package/lib/types-esm/components/AlterLog.d.ts +0 -5
  138. package/lib/types-esm/components/AlterSkip.d.ts +0 -7
  139. package/lib/types-esm/components/AlterTemplateExportSteps.d.ts +0 -12
  140. package/lib/types-esm/components/AlterTemplateImportSteps.d.ts +0 -11
  141. package/lib/types-esm/decorators/action.d.ts +0 -7
  142. package/lib/types-esm/decorators/actionCtx.d.ts +0 -23
  143. package/lib/types-esm/decorators/alter.d.ts +0 -6
  144. package/lib/types-esm/decorators/on.d.ts +0 -6
  145. package/lib/types-esm/decorators/useFormioAuth.d.ts +0 -6
  146. package/lib/types-esm/domain/AlterHook.d.ts +0 -3
  147. package/lib/types-esm/domain/Formio.d.ts +0 -112
  148. package/lib/types-esm/domain/FormioAction.d.ts +0 -20
  149. package/lib/types-esm/domain/FormioActionsIndex.d.ts +0 -15
  150. package/lib/types-esm/domain/FormioAuth.d.ts +0 -67
  151. package/lib/types-esm/domain/FormioBaseModel.d.ts +0 -11
  152. package/lib/types-esm/domain/FormioConfig.d.ts +0 -59
  153. package/lib/types-esm/domain/FormioCtxMapper.d.ts +0 -7
  154. package/lib/types-esm/domain/FormioDecodedToken.d.ts +0 -12
  155. package/lib/types-esm/domain/FormioErrors.d.ts +0 -53
  156. package/lib/types-esm/domain/FormioHooks.d.ts +0 -194
  157. package/lib/types-esm/domain/FormioJs.d.ts +0 -17
  158. package/lib/types-esm/domain/FormioModels.d.ts +0 -42
  159. package/lib/types-esm/domain/FormioRouter.d.ts +0 -7
  160. package/lib/types-esm/domain/FormioSettings.d.ts +0 -53
  161. package/lib/types-esm/domain/FormioTemplate.d.ts +0 -8
  162. package/lib/types-esm/domain/FormioTemplateUtil.d.ts +0 -13
  163. package/lib/types-esm/domain/FormioUpdate.d.ts +0 -19
  164. package/lib/types-esm/domain/FormioUtils.d.ts +0 -307
  165. package/lib/types-esm/domain/OnHook.d.ts +0 -3
  166. package/lib/types-esm/domain/Resource.d.ts +0 -18
  167. package/lib/types-esm/index.d.ts +0 -46
  168. package/lib/types-esm/middlewares/FormioAuthMiddleware.d.ts +0 -11
  169. package/lib/types-esm/services/FormioAuthService.d.ts +0 -84
  170. package/lib/types-esm/services/FormioDatabase.d.ts +0 -84
  171. package/lib/types-esm/services/FormioHooksService.d.ts +0 -17
  172. package/lib/types-esm/services/FormioInstaller.d.ts +0 -12
  173. package/lib/types-esm/services/FormioRepository.d.ts +0 -41
  174. package/lib/types-esm/services/FormioService.d.ts +0 -36
  175. package/lib/types-esm/utils/isMongoId.d.ts +0 -1
@@ -1,182 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormioAuthService = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("@tsed/core");
6
- const di_1 = require("@tsed/di");
7
- const exceptions_1 = require("@tsed/exceptions");
8
- const util_1 = require("util");
9
- const FormioDatabase_js_1 = require("./FormioDatabase.js");
10
- const FormioHooksService_js_1 = require("./FormioHooksService.js");
11
- const FormioService_js_1 = require("./FormioService.js");
12
- let FormioAuthService = class FormioAuthService {
13
- get currentUser() {
14
- return (0, util_1.promisify)(this.formio.auth.currentUser);
15
- }
16
- get getToken() {
17
- return this.formio.auth.getToken;
18
- }
19
- get tempToken() {
20
- return this.formio.auth.tempToken;
21
- }
22
- get logout() {
23
- return this.formio.auth.logout;
24
- }
25
- setCurrentUser(user, token, ctx) {
26
- const request = ctx.getRequest();
27
- const response = ctx.getResponse();
28
- request.submission.data = user.data;
29
- request.user = user;
30
- request.token = token.decoded;
31
- response.token = token.token;
32
- request["x-jwt-token"] = token.token;
33
- return this;
34
- }
35
- /**
36
- * Generate the payload token for the session
37
- * @param user
38
- * @param ctx
39
- */
40
- async generatePayloadToken(user, ctx) {
41
- const req = ctx.getRequest();
42
- const audit = this.formio.audit;
43
- let form;
44
- try {
45
- form = (await this.db.getForm(user.form));
46
- }
47
- catch (err) {
48
- audit("EAUTH_USERFORM", {
49
- ...req,
50
- userId: user._id
51
- }, user.form, err);
52
- throw err;
53
- }
54
- if (!form) {
55
- audit("EAUTH_USERFORM", {
56
- ...req,
57
- userId: user._id
58
- }, user.form, { message: "User form not found" });
59
- throw new exceptions_1.NotFound("User form not found.");
60
- }
61
- try {
62
- user = await this.hooks.alterAsync("user", user);
63
- }
64
- catch (err) {
65
- // istanbul ignore next
66
- ctx.logger.debug(err);
67
- }
68
- await this.hooks.alterAsync("login", user, req);
69
- // Allow anyone to hook and modify the token.
70
- const token = this.hooks.alter("token", {
71
- user: {
72
- _id: user._id
73
- },
74
- form: {
75
- _id: form?._id
76
- }
77
- }, form, req);
78
- const decoded = this.hooks.alter("tokenDecode", token, req);
79
- return {
80
- user,
81
- token: {
82
- token: this.getToken(token),
83
- decoded
84
- }
85
- };
86
- }
87
- /**
88
- * Generate session from the given authenticated user.
89
- * @param user
90
- * @param ctx
91
- */
92
- async generateSession(user, ctx) {
93
- try {
94
- const { user: userSession, token } = await this.generatePayloadToken(user, ctx);
95
- this.setCurrentUser(userSession, token, ctx);
96
- await this.currentUser(ctx.getRequest(), ctx.getResponse());
97
- }
98
- catch (err) {
99
- ctx.logger.error({ event: "Error on OAuthActions", error: err });
100
- throw new exceptions_1.Unauthorized(err.message);
101
- }
102
- }
103
- /**
104
- * Retrieve roles
105
- * @param req
106
- */
107
- async getRoles(req) {
108
- try {
109
- const query = this.hooks.alter("roleQuery", { deleted: { $eq: null } }, req);
110
- return await this.db.roleModel.find(query).sort({ title: 1 }).lean().exec();
111
- }
112
- catch (err) {
113
- throw new exceptions_1.BadRequest(this.formio.util.errorCodes.role.EROLESLOAD);
114
- }
115
- }
116
- /**
117
- * Update the role of the current user submission
118
- * @param _id
119
- * @param role
120
- * @param req
121
- */
122
- async updateUserRole(_id, role, req) {
123
- const query = this.hooks.alter("submissionQuery", {
124
- _id: this.formio.util.idToBson(_id),
125
- deleted: { $eq: null }
126
- }, req);
127
- const user = await this.db.submissionModel.findOne(query).exec();
128
- if (!user) {
129
- throw new exceptions_1.BadRequest("No Submission was found with the given setting `submission`.");
130
- }
131
- user.roles = [this.formio.util.idToBson(role)];
132
- if ((0, core_1.isFunction)(user.save)) {
133
- await user.save();
134
- }
135
- return user;
136
- }
137
- /**
138
- * Create a user submission in formio
139
- * @param user
140
- */
141
- async createUser(user) {
142
- const submission = new this.db.submissionModel({
143
- owner: null,
144
- deleted: null,
145
- roles: [],
146
- externalsIds: [],
147
- ...user,
148
- created: new Date().toISOString(),
149
- modified: new Date().toISOString()
150
- });
151
- user.form && (submission.form = this.db.idToBson(user.form));
152
- await submission.save();
153
- return submission.toObject();
154
- }
155
- /**
156
- * Update user submission in formio
157
- * @param user
158
- */
159
- async updateUser(user) {
160
- await this.db.submissionModel.updateOne({
161
- _id: user._id
162
- }, { $set: user });
163
- return user;
164
- }
165
- };
166
- tslib_1.__decorate([
167
- (0, di_1.Inject)(),
168
- tslib_1.__metadata("design:type", FormioService_js_1.FormioService)
169
- ], FormioAuthService.prototype, "formio", void 0);
170
- tslib_1.__decorate([
171
- (0, di_1.Inject)(),
172
- tslib_1.__metadata("design:type", FormioHooksService_js_1.FormioHooksService)
173
- ], FormioAuthService.prototype, "hooks", void 0);
174
- tslib_1.__decorate([
175
- (0, di_1.Inject)(),
176
- tslib_1.__metadata("design:type", FormioDatabase_js_1.FormioDatabase)
177
- ], FormioAuthService.prototype, "db", void 0);
178
- FormioAuthService = tslib_1.__decorate([
179
- (0, di_1.Injectable)()
180
- ], FormioAuthService);
181
- exports.FormioAuthService = FormioAuthService;
182
- //# sourceMappingURL=FormioAuthService.js.map
@@ -1 +0,0 @@
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,2DAAmD;AACnD,mEAA2D;AAC3D,yDAAiD;AAG1C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAU5B,IAAI,WAAW;QACb,OAAO,IAAA,gBAAS,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I,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;IAAC,IAAA,WAAM,GAAE;sCACD,gCAAa;iDAAC;AAEtB;IAAC,IAAA,WAAM,GAAE;sCACF,0CAAkB;gDAAC;AAE1B;IAAC,IAAA,WAAM,GAAE;sCACL,kCAAc;6CAAC;AARR,iBAAiB;IAD7B,IAAA,eAAU,GAAE;GACA,iBAAiB,CAqN7B;AArNY,8CAAiB"}
@@ -1,140 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormioDatabase = void 0;
4
- const tslib_1 = require("tslib");
5
- const core_1 = require("@tsed/core");
6
- const di_1 = require("@tsed/di");
7
- const omit_1 = tslib_1.__importDefault(require("lodash/omit"));
8
- const FormioMapper_js_1 = require("../builder/FormioMapper.js");
9
- const isMongoId_js_1 = require("../utils/isMongoId.js");
10
- const FormioService_js_1 = require("./FormioService.js");
11
- function toMap(list) {
12
- return (0, core_1.toMap)(list, (o) => [o._id.toString(), `$machineName:${o.name || o.machineName}`]);
13
- }
14
- let FormioDatabase = class FormioDatabase {
15
- get models() {
16
- return this.formio.mongoose.models;
17
- }
18
- get roleModel() {
19
- return this.models.role;
20
- }
21
- get formModel() {
22
- return this.models.form;
23
- }
24
- get actionModel() {
25
- return this.models.action;
26
- }
27
- get submissionModel() {
28
- return this.models.submission;
29
- }
30
- get tokenModel() {
31
- return this.models.token;
32
- }
33
- get actionItemModel() {
34
- return this.models.actionItem;
35
- }
36
- async getFormioMapper() {
37
- const [roles, forms, actions] = await Promise.all([
38
- this.roleModel.find({
39
- deleted: { $eq: null }
40
- }),
41
- this.formModel.find({
42
- deleted: { $eq: null }
43
- }),
44
- this.actionModel.find({
45
- deleted: { $eq: null }
46
- })
47
- ]);
48
- return new FormioMapper_js_1.FormioMapper({
49
- forms: toMap(forms),
50
- actions: toMap(actions),
51
- roles: toMap(roles)
52
- });
53
- }
54
- async hasForms() {
55
- return (await this.formModel.countDocuments()) > 0;
56
- }
57
- async hasForm(name) {
58
- return !!(await this.formModel.countDocuments({ name: { $eq: name } }));
59
- }
60
- getForm(nameOrId) {
61
- return this.formModel
62
- .findOne({
63
- deleted: { $eq: null },
64
- ...((0, isMongoId_js_1.isMongoId)(nameOrId)
65
- ? {
66
- _id: nameOrId
67
- }
68
- : { name: { $eq: nameOrId } })
69
- })
70
- .lean()
71
- .exec();
72
- }
73
- /**
74
- * Import form previously exported by export tool.
75
- * This method transform alias to a real mongoose _id
76
- * @param form
77
- * @param onCreate
78
- */
79
- async importFormIfNotExists(form, onCreate) {
80
- if (!(await this.hasForm(form.name))) {
81
- const createForm = await this.importForm(form);
82
- onCreate && (await onCreate(createForm));
83
- }
84
- return this.getForm(form.name);
85
- }
86
- /**
87
- * Import form previously exported by export tool.
88
- * This method transform alias to a real mongoose _id
89
- * @param form
90
- */
91
- async importForm(form) {
92
- const mapper = await this.getFormioMapper();
93
- return this.saveForm(mapper.mapToImport(form));
94
- }
95
- saveForm(form) {
96
- form = new this.formModel((0, omit_1.default)(form, ["__v"]));
97
- return this.formModel.findOneAndUpdate({ _id: form._id }, form, { upsert: true, new: true });
98
- }
99
- getSubmissions(query = {}) {
100
- return this.submissionModel.find({
101
- ...query,
102
- deleted: { $eq: null }
103
- });
104
- }
105
- /**
106
- * Import submission previously exported by export tool.
107
- * This method transform alias to a real mongoose _id
108
- * @param submission
109
- */
110
- async importSubmission(submission) {
111
- const mapper = await this.getFormioMapper();
112
- return this.saveSubmission(mapper.mapToImport(submission));
113
- }
114
- saveSubmission(submission) {
115
- submission = new this.submissionModel((0, omit_1.default)(submission, ["__v"]));
116
- return this.submissionModel.findOneAndUpdate({
117
- _id: submission._id
118
- }, submission, { new: true, upsert: true });
119
- }
120
- idToBson(form) {
121
- if ((0, core_1.isArray)(form)) {
122
- return { $in: form.map(this.formio.util.idToBson) };
123
- }
124
- else if ((0, core_1.isObject)(form)) {
125
- return this.formio.util.idToBson(form._id);
126
- }
127
- else if ((0, core_1.isString)(form)) {
128
- return this.formio.util.idToBson(form);
129
- }
130
- }
131
- };
132
- tslib_1.__decorate([
133
- (0, di_1.Inject)(),
134
- tslib_1.__metadata("design:type", FormioService_js_1.FormioService)
135
- ], FormioDatabase.prototype, "formio", void 0);
136
- FormioDatabase = tslib_1.__decorate([
137
- (0, di_1.Injectable)()
138
- ], FormioDatabase);
139
- exports.FormioDatabase = FormioDatabase;
140
- //# sourceMappingURL=FormioDatabase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormioDatabase.js","sourceRoot":"","sources":["../../../src/services/FormioDatabase.ts"],"names":[],"mappings":";;;;AAAA,qCAAsE;AACtE,iCAA4C;AAG5C,+DAA+B;AAE/B,gEAAwD;AACxD,wDAAgD;AAChD,yDAAiD;AAEjD,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,IAAI,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;AAC5H,CAAC;AAGM,IAAM,cAAc,GAApB,MAAM,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,MAAM,CAAC;IAC5B,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,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,cAAc;IAD1B,IAAA,eAAU,GAAE;GACA,cAAc,CAoJ1B;AApJY,wCAAc"}
@@ -1,81 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormioHooksService = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const util_1 = require("util");
7
- const FormioService_js_1 = require("./FormioService.js");
8
- let FormioHooksService = class FormioHooksService {
9
- get settings() {
10
- return this.formio.hook.settings;
11
- }
12
- get invoke() {
13
- return this.formio.hook.invoke;
14
- }
15
- get alter() {
16
- return this.formio.hook.alter;
17
- }
18
- get alterAsync() {
19
- return (0, util_1.promisify)(this.alter);
20
- }
21
- getHooks() {
22
- return {
23
- alter: this.getHooksProvider("alter"),
24
- on: this.getHooksProvider("on")
25
- };
26
- }
27
- getProviders(type) {
28
- return this.injector.getProviders(`formio:${type}`);
29
- }
30
- getHooksProvider(type) {
31
- return this.bindHooks(type, this.createHooks(type));
32
- }
33
- bindHooks(type, hooks) {
34
- return Object.entries(hooks).reduce((newHooks, [key, pool]) => {
35
- const wrap = (input, ...args) => {
36
- let last;
37
- for (const fn of pool) {
38
- const result = fn(input, ...args);
39
- if (type === "alter") {
40
- input = result;
41
- }
42
- else {
43
- last = result;
44
- }
45
- }
46
- return type === "alter" ? input : last;
47
- };
48
- return {
49
- ...newHooks,
50
- [key]: wrap
51
- };
52
- }, {});
53
- }
54
- createHooks(type) {
55
- return this.getProviders(type).reduce((hooks, provider) => {
56
- const instance = this.injector.invoke(provider.token);
57
- const name = provider.store.get(`formio:${type}:name`);
58
- const pool = hooks[name] || [];
59
- const hook = (...args) => instance[type === "alter" ? "transform" : "on"](...args.map((input) => {
60
- return input && input.$ctx ? input.$ctx : input;
61
- }));
62
- return {
63
- ...hooks,
64
- [name]: [].concat(pool, hook)
65
- };
66
- }, {});
67
- }
68
- };
69
- tslib_1.__decorate([
70
- (0, common_1.Inject)(),
71
- tslib_1.__metadata("design:type", common_1.InjectorService)
72
- ], FormioHooksService.prototype, "injector", void 0);
73
- tslib_1.__decorate([
74
- (0, common_1.Inject)(FormioService_js_1.FormioService),
75
- tslib_1.__metadata("design:type", FormioService_js_1.FormioService)
76
- ], FormioHooksService.prototype, "formio", void 0);
77
- FormioHooksService = tslib_1.__decorate([
78
- (0, common_1.Injectable)()
79
- ], FormioHooksService);
80
- exports.FormioHooksService = FormioHooksService;
81
- //# sourceMappingURL=FormioHooksService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormioHooksService.js","sourceRoot":"","sources":["../../../src/services/FormioHooksService.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AACjE,+BAA+B;AAE/B,yDAAiD;AAI1C,IAAM,kBAAkB,GAAxB,MAAM,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,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC;SAChC,CAAC;IACJ,CAAC;IAES,YAAY,CAAC,IAAoB;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;IAES,gBAAgB,CAAC,IAAoB;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACtD,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AW,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;AAjFC;IAAC,IAAA,eAAM,GAAE;sCACW,wBAAe;oDAAC;AAEpC;IAAC,IAAA,eAAM,EAAC,gCAAa,CAAC;sCACJ,gCAAa;kDAAC;AALrB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;GACA,kBAAkB,CAkF9B;AAlFY,gDAAkB"}
@@ -1,44 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormioInstaller = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const logger_1 = require("@tsed/logger");
7
- const FormioDatabase_js_1 = require("./FormioDatabase.js");
8
- let FormioInstaller = class FormioInstaller extends FormioDatabase_js_1.FormioDatabase {
9
- async install(template, root) {
10
- this.logger.info("Install formio template...");
11
- template = await this.formio.importTemplate(template);
12
- if (root) {
13
- this.logger.info("Create root user...");
14
- await this.createRootUser(root, template);
15
- }
16
- }
17
- async createRootUser(user, template) {
18
- const hash = await this.formio.encrypt(user.password);
19
- return new Promise((resolve, reject) => {
20
- this.formio.resources.submission.model.create({
21
- form: template.resources.admin._id,
22
- data: {
23
- email: user.email,
24
- password: hash
25
- },
26
- roles: [template.roles?.administrator._id].filter(Boolean)
27
- }, (err, item) => {
28
- if (err) {
29
- return reject(err);
30
- }
31
- resolve(item);
32
- });
33
- });
34
- }
35
- };
36
- tslib_1.__decorate([
37
- (0, di_1.Inject)(),
38
- tslib_1.__metadata("design:type", logger_1.Logger)
39
- ], FormioInstaller.prototype, "logger", void 0);
40
- FormioInstaller = tslib_1.__decorate([
41
- (0, di_1.Injectable)()
42
- ], FormioInstaller);
43
- exports.FormioInstaller = FormioInstaller;
44
- //# sourceMappingURL=FormioInstaller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormioInstaller.js","sourceRoot":"","sources":["../../../src/services/FormioInstaller.ts"],"names":[],"mappings":";;;;AAAA,iCAA4C;AAC5C,yCAAoC;AAGpC,2DAAmD;AAG5C,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,kCAAc;IAIjD,KAAK,CAAC,OAAO,CAAC,QAAwB,EAAE,IAAS;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC/C,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAEtD,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;YACxC,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SAC3C;IACH,CAAC;IAED,KAAK,CAAC,cAAc,CAAiB,IAAuC,EAAE,QAAwB;QACpG,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAC3C;gBACE,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG;gBAClC,IAAI,EAAE;oBACJ,KAAK,EAAE,IAAI,CAAC,KAAK;oBACjB,QAAQ,EAAE,IAAI;iBACf;gBACD,KAAK,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;aAC3D,EACD,CAAC,GAAY,EAAE,IAAS,EAAE,EAAE;gBAC1B,IAAI,GAAG,EAAE;oBACP,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;iBACpB;gBAED,OAAO,CAAC,IAAI,CAAC,CAAC;YAChB,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AApCC;IAAC,IAAA,WAAM,GAAE;sCACS,eAAM;+CAAC;AAFd,eAAe;IAD3B,IAAA,eAAU,GAAE;GACA,eAAe,CAqC3B;AArCY,0CAAe"}
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormioRepository = void 0;
4
- const tslib_1 = require("tslib");
5
- const di_1 = require("@tsed/di");
6
- const FormioDatabase_js_1 = require("./FormioDatabase.js");
7
- class FormioRepository {
8
- async getFormId() {
9
- if (!this.formId) {
10
- const form = await this.formioDatabase.formModel.findOne({ name: { $eq: this.formName } });
11
- if (form) {
12
- this.formId = form._id;
13
- }
14
- }
15
- return this.formId;
16
- }
17
- async saveSubmission(submission) {
18
- return this.formioDatabase.saveSubmission({
19
- ...submission,
20
- form: submission.form || (await this.getFormId())
21
- });
22
- }
23
- async getSubmissions(query = {}) {
24
- return this.formioDatabase.getSubmissions({
25
- ...query,
26
- form: await this.getFormId()
27
- });
28
- }
29
- async findOneSubmission(query) {
30
- return this.formioDatabase.submissionModel.findOne({
31
- form: await this.getFormId(),
32
- deleted: null,
33
- ...query
34
- });
35
- }
36
- }
37
- tslib_1.__decorate([
38
- (0, di_1.Inject)(),
39
- tslib_1.__metadata("design:type", FormioDatabase_js_1.FormioDatabase)
40
- ], FormioRepository.prototype, "formioDatabase", void 0);
41
- exports.FormioRepository = FormioRepository;
42
- //# sourceMappingURL=FormioRepository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormioRepository.js","sourceRoot":"","sources":["../../../src/services/FormioRepository.ts"],"names":[],"mappings":";;;;AACA,iCAAgC;AAGhC,2DAAmD;AAEnD,MAAsB,gBAAgB;IAQpC,KAAK,CAAC,SAAS;QACb,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,OAAO,CAAC,EAAC,IAAI,EAAE,EAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAC,EAAC,CAAC,CAAC;YAEvF,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;aACxB;SACF;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAkF;QACrG,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,QAAsE,EAAE;QAC3F,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAiB;YACxD,GAAG,KAAK;YACR,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,KAAU;QAChC,OAAO,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,OAAO,CAAC;YACjD,IAAI,EAAE,MAAM,IAAI,CAAC,SAAS,EAAE;YAC5B,OAAO,EAAE,IAAI;YACb,GAAG,KAAK;SACT,CAAQ,CAAC;IACZ,CAAC;CACF;AAxCC;IAAC,IAAA,WAAM,GAAE;sCACiB,kCAAc;wDAAC;AAF3C,4CAyCC"}
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FormioService = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@tsed/common");
6
- const util_1 = require("util");
7
- // @ts-ignore
8
- const formio_1 = tslib_1.__importDefault(require("formio"));
9
- // @ts-ignore
10
- const swagger_js_1 = tslib_1.__importDefault(require("formio/src/util/swagger.js"));
11
- // @ts-ignore
12
- const util_js_1 = tslib_1.__importDefault(require("formio/src/util/util.js"));
13
- let FormioService = class FormioService {
14
- get audit() {
15
- return this.formio.audit || (() => { });
16
- }
17
- get auth() {
18
- return this.formio.auth;
19
- }
20
- // istanbul ignore next
21
- get swagger() {
22
- return (...args) => new Promise((resolve) => (0, swagger_js_1.default)(...args, resolve));
23
- }
24
- get config() {
25
- return this.formio.config;
26
- }
27
- get db() {
28
- return this.formio.db;
29
- }
30
- get resources() {
31
- return this.formio.resources;
32
- }
33
- get mongoose() {
34
- return this.formio.mongoose;
35
- }
36
- get middleware() {
37
- return this.formio.middleware;
38
- }
39
- get schemas() {
40
- return this.formio.schemas;
41
- }
42
- get formio() {
43
- return this.router.formio;
44
- }
45
- get hook() {
46
- return this.formio.hook;
47
- }
48
- get util() {
49
- return this.formio.util;
50
- }
51
- get template() {
52
- return this.formio.template;
53
- }
54
- get Action() {
55
- return this.formio.Action;
56
- }
57
- exportTemplate(options = {}) {
58
- return (0, util_1.promisify)(this.formio.template.export)(options);
59
- }
60
- importTemplate(template) {
61
- return (0, util_1.promisify)(this.formio.template.import.template)(template);
62
- }
63
- encrypt(text) {
64
- return (0, util_1.promisify)(this.formio.encrypt)(text);
65
- }
66
- isInit() {
67
- return !!this.router;
68
- }
69
- // istanbul ignore next
70
- createRouter(options) {
71
- return (0, formio_1.default)(options);
72
- }
73
- init(options, hooks = {}) {
74
- if (options && Object.keys(options).length) {
75
- this.router = this.createRouter(this.mapConfiguration(options));
76
- this.bindLogger();
77
- return this.router.init(hooks);
78
- }
79
- }
80
- mapConfiguration(options) {
81
- const { injector } = this;
82
- const mongooseSettings = injector.settings.get("mongoose.0");
83
- if (mongooseSettings) {
84
- options.mongo = options.mongo || mongooseSettings.url;
85
- options.mongoConfig = options.mongoConfig || JSON.stringify(mongooseSettings.connectionOptions);
86
- }
87
- return options;
88
- }
89
- bindLogger() {
90
- const { injector } = this;
91
- util_js_1.default.log = injector.logger.info.bind(injector.logger);
92
- util_js_1.default.error = injector.logger.error.bind(injector.logger);
93
- }
94
- };
95
- tslib_1.__decorate([
96
- (0, common_1.Inject)(),
97
- tslib_1.__metadata("design:type", common_1.InjectorService)
98
- ], FormioService.prototype, "injector", void 0);
99
- FormioService = tslib_1.__decorate([
100
- (0, common_1.Injectable)()
101
- ], FormioService);
102
- exports.FormioService = FormioService;
103
- //# sourceMappingURL=FormioService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormioService.js","sourceRoot":"","sources":["../../../src/services/FormioService.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AAIjE,+BAA+B;AAQ/B,aAAa;AACb,4DAAkC;AAClC,aAAa;AACb,oFAAiD;AACjD,aAAa;AACb,8EAA2C;AAGpC,IAAM,aAAa,GAAnB,MAAM,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,IAAA,oBAAO,EAAC,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,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CACW,wBAAe;+CAAC;AAJzB,aAAa;IADzB,IAAA,mBAAU,GAAE;GACA,aAAa,CA+GzB;AA/GY,sCAAa"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isMongoId = void 0;
4
- function isMongoId(text) {
5
- return text.toString().match(/^[0-9a-fA-F]{24}$/);
6
- }
7
- exports.isMongoId = isMongoId;
8
- //# sourceMappingURL=isMongoId.js.map
@@ -1 +0,0 @@
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"}
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }