@tsed/formio 7.0.0-beta.2 → 7.0.0-beta.20
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 +39 -35
- package/lib/cjs/FormioModule.js.map +1 -1
- package/lib/cjs/builder/FormioMapper.js +13 -4
- package/lib/cjs/builder/FormioMapper.js.map +1 -1
- package/lib/cjs/components/AlterActions.js +83 -32
- package/lib/cjs/components/AlterActions.js.map +1 -1
- package/lib/cjs/components/AlterAudit.js +1 -1
- package/lib/cjs/components/AlterAudit.js.map +1 -1
- package/lib/cjs/components/AlterHost.js +1 -1
- package/lib/cjs/components/AlterLog.js +1 -1
- package/lib/cjs/components/AlterSkip.js +7 -5
- package/lib/cjs/components/AlterSkip.js.map +1 -1
- package/lib/cjs/components/AlterTemplateExportSteps.js +6 -5
- package/lib/cjs/components/AlterTemplateExportSteps.js.map +1 -1
- package/lib/cjs/components/AlterTemplateImportSteps.js +6 -5
- package/lib/cjs/components/AlterTemplateImportSteps.js.map +1 -1
- package/lib/cjs/domain/FormioHooks.js.map +1 -1
- package/lib/cjs/domain/FormioModels.js +1 -1
- package/lib/cjs/domain/FormioModels.js.map +1 -1
- package/lib/cjs/domain/Resource.js.map +1 -1
- package/lib/cjs/index.js +46 -42
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/middlewares/FormioAuthMiddleware.js +9 -8
- package/lib/cjs/middlewares/FormioAuthMiddleware.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/FormioAuthService.js +11 -8
- package/lib/cjs/services/FormioAuthService.js.map +1 -1
- package/lib/cjs/services/FormioDatabase.js +48 -10
- package/lib/cjs/services/FormioDatabase.js.map +1 -1
- package/lib/cjs/services/FormioHooksService.js +7 -5
- package/lib/cjs/services/FormioHooksService.js.map +1 -1
- package/lib/cjs/services/FormioInstaller.js +5 -10
- package/lib/cjs/services/FormioInstaller.js.map +1 -1
- package/lib/cjs/services/FormioRepository.js +44 -0
- package/lib/cjs/services/FormioRepository.js.map +1 -0
- package/lib/cjs/services/FormioService.js +15 -10
- package/lib/cjs/services/FormioService.js.map +1 -1
- package/lib/esm/FormioModule.js +29 -25
- package/lib/esm/FormioModule.js.map +1 -1
- package/lib/esm/builder/FormioMapper.js +13 -4
- package/lib/esm/builder/FormioMapper.js.map +1 -1
- package/lib/esm/components/AlterActions.js +81 -30
- package/lib/esm/components/AlterActions.js.map +1 -1
- package/lib/esm/components/AlterAudit.js +1 -1
- package/lib/esm/components/AlterAudit.js.map +1 -1
- package/lib/esm/components/AlterHost.js +1 -1
- package/lib/esm/components/AlterLog.js +1 -1
- package/lib/esm/components/AlterSkip.js +3 -1
- package/lib/esm/components/AlterSkip.js.map +1 -1
- package/lib/esm/components/AlterTemplateExportSteps.js +4 -3
- package/lib/esm/components/AlterTemplateExportSteps.js.map +1 -1
- package/lib/esm/components/AlterTemplateImportSteps.js +4 -3
- package/lib/esm/components/AlterTemplateImportSteps.js.map +1 -1
- package/lib/esm/decorators/useFormioAuth.js +1 -1
- package/lib/esm/domain/FormioHooks.js.map +1 -1
- package/lib/esm/domain/Resource.js.map +1 -1
- package/lib/esm/index.js +46 -42
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/middlewares/FormioAuthMiddleware.js +2 -1
- package/lib/esm/middlewares/FormioAuthMiddleware.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/FormioAuthService.js +7 -4
- package/lib/esm/services/FormioAuthService.js.map +1 -1
- package/lib/esm/services/FormioDatabase.js +48 -10
- package/lib/esm/services/FormioDatabase.js.map +1 -1
- package/lib/esm/services/FormioHooksService.js +3 -1
- package/lib/esm/services/FormioHooksService.js.map +1 -1
- package/lib/esm/services/FormioInstaller.js +3 -8
- package/lib/esm/services/FormioInstaller.js.map +1 -1
- package/lib/esm/services/FormioRepository.js +40 -0
- package/lib/esm/services/FormioRepository.js.map +1 -0
- package/lib/esm/services/FormioService.js +8 -3
- package/lib/esm/services/FormioService.js.map +1 -1
- package/lib/types/components/AlterActions.d.ts +7 -4
- package/lib/types/components/AlterAudit.d.ts +2 -2
- package/lib/types/domain/FormioHooks.d.ts +1 -1
- package/lib/types/domain/Resource.d.ts +2 -2
- package/lib/types/index.d.ts +22 -14
- package/lib/types/services/FormioAuthService.d.ts +33 -3
- package/lib/types/services/FormioDatabase.d.ts +64 -8
- package/lib/types/services/FormioInstaller.d.ts +0 -2
- package/lib/types/services/FormioRepository.d.ts +41 -0
- package/package.json +26 -17
- package/readme.md +8 -11
- package/tsconfig.compile.esm.json +1 -12
- package/.mocharc.js +0 -5
- package/.nycrc +0 -26
package/jest.config.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// For a detailed explanation regarding each configuration property, visit:
|
|
2
|
+
// https://jestjs.io/docs/en/configuration.html
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
...require("@tsed/jest-config")(__dirname, "formio"),
|
|
6
|
+
coverageThreshold: {
|
|
7
|
+
global: {
|
|
8
|
+
statements: 100,
|
|
9
|
+
branches: 90.74,
|
|
10
|
+
functions: 100,
|
|
11
|
+
lines: 100
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
package/lib/cjs/FormioModule.js
CHANGED
|
@@ -17,6 +17,16 @@ const FormioHooksService_1 = require("./services/FormioHooksService");
|
|
|
17
17
|
const FormioInstaller_1 = require("./services/FormioInstaller");
|
|
18
18
|
const FormioService_1 = require("./services/FormioService");
|
|
19
19
|
let FormioModule = class FormioModule {
|
|
20
|
+
formio;
|
|
21
|
+
hooks;
|
|
22
|
+
installer;
|
|
23
|
+
app;
|
|
24
|
+
injector;
|
|
25
|
+
settings;
|
|
26
|
+
baseUrl;
|
|
27
|
+
skipInstall;
|
|
28
|
+
template;
|
|
29
|
+
root;
|
|
20
30
|
$onInit() {
|
|
21
31
|
return this.init((0, core_1.deepClone)(this.settings));
|
|
22
32
|
}
|
|
@@ -25,8 +35,7 @@ let FormioModule = class FormioModule {
|
|
|
25
35
|
}
|
|
26
36
|
async $onRoutesInit() {
|
|
27
37
|
if (this.formio.isInit()) {
|
|
28
|
-
|
|
29
|
-
router.use(this.baseUrl, this.formio.middleware.restrictRequestTypes, this.formio.router);
|
|
38
|
+
this.app.use(this.baseUrl, this.formio.middleware.restrictRequestTypes, this.formio.router);
|
|
30
39
|
if (await this.shouldInstall()) {
|
|
31
40
|
await this.installer.install(this.template, this.root);
|
|
32
41
|
}
|
|
@@ -46,17 +55,11 @@ let FormioModule = class FormioModule {
|
|
|
46
55
|
Object.entries(spec.paths).forEach(([path, methods]) => {
|
|
47
56
|
Object.entries(methods).forEach(([method, operation]) => {
|
|
48
57
|
routes.push({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
className: "formio",
|
|
55
|
-
methodClassName: operation.operationId,
|
|
56
|
-
parameters: [],
|
|
57
|
-
rawBody: false
|
|
58
|
-
};
|
|
59
|
-
}
|
|
58
|
+
method,
|
|
59
|
+
name: operation.operationId,
|
|
60
|
+
url: (0, common_1.normalizePath)(baseUrl, path.replace(/\/{(.*)}/gi, "/:$1")),
|
|
61
|
+
className: "formio",
|
|
62
|
+
methodClassName: operation.operationId
|
|
60
63
|
});
|
|
61
64
|
});
|
|
62
65
|
});
|
|
@@ -65,8 +68,9 @@ let FormioModule = class FormioModule {
|
|
|
65
68
|
}
|
|
66
69
|
// istanbul ignore next
|
|
67
70
|
async $onReady() {
|
|
68
|
-
if (this.formio.isInit() && this.injector.settings
|
|
71
|
+
if (this.formio.isInit() && "getBestHost" in this.injector.settings) {
|
|
69
72
|
const { injector } = this;
|
|
73
|
+
// @ts-ignore
|
|
70
74
|
const host = injector.settings.getBestHost();
|
|
71
75
|
const url = host.toString();
|
|
72
76
|
injector.logger.info(`Form.io API is available on ${url}${this.baseUrl || "/"}`);
|
|
@@ -77,47 +81,47 @@ let FormioModule = class FormioModule {
|
|
|
77
81
|
return this.template && !(hasForms || this.skipInstall);
|
|
78
82
|
}
|
|
79
83
|
};
|
|
80
|
-
|
|
84
|
+
tslib_1.__decorate([
|
|
81
85
|
(0, common_1.Inject)(),
|
|
82
|
-
|
|
86
|
+
tslib_1.__metadata("design:type", FormioService_1.FormioService)
|
|
83
87
|
], FormioModule.prototype, "formio", void 0);
|
|
84
|
-
|
|
88
|
+
tslib_1.__decorate([
|
|
85
89
|
(0, common_1.Inject)(),
|
|
86
|
-
|
|
90
|
+
tslib_1.__metadata("design:type", FormioHooksService_1.FormioHooksService)
|
|
87
91
|
], FormioModule.prototype, "hooks", void 0);
|
|
88
|
-
|
|
92
|
+
tslib_1.__decorate([
|
|
89
93
|
(0, common_1.Inject)(),
|
|
90
|
-
|
|
94
|
+
tslib_1.__metadata("design:type", FormioInstaller_1.FormioInstaller)
|
|
91
95
|
], FormioModule.prototype, "installer", void 0);
|
|
92
|
-
|
|
96
|
+
tslib_1.__decorate([
|
|
93
97
|
(0, common_1.Inject)(),
|
|
94
|
-
|
|
98
|
+
tslib_1.__metadata("design:type", common_1.PlatformApplication)
|
|
95
99
|
], FormioModule.prototype, "app", void 0);
|
|
96
|
-
|
|
100
|
+
tslib_1.__decorate([
|
|
97
101
|
(0, common_1.Inject)(),
|
|
98
|
-
|
|
102
|
+
tslib_1.__metadata("design:type", common_1.InjectorService)
|
|
99
103
|
], FormioModule.prototype, "injector", void 0);
|
|
100
|
-
|
|
104
|
+
tslib_1.__decorate([
|
|
101
105
|
(0, common_1.Constant)("formio", {}),
|
|
102
|
-
|
|
106
|
+
tslib_1.__metadata("design:type", Object)
|
|
103
107
|
], FormioModule.prototype, "settings", void 0);
|
|
104
|
-
|
|
108
|
+
tslib_1.__decorate([
|
|
105
109
|
(0, common_1.Constant)("formio.baseUrl", "/"),
|
|
106
|
-
|
|
110
|
+
tslib_1.__metadata("design:type", String)
|
|
107
111
|
], FormioModule.prototype, "baseUrl", void 0);
|
|
108
|
-
|
|
112
|
+
tslib_1.__decorate([
|
|
109
113
|
(0, common_1.Constant)("formio.skipInstall", false),
|
|
110
|
-
|
|
114
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
111
115
|
], FormioModule.prototype, "skipInstall", void 0);
|
|
112
|
-
|
|
116
|
+
tslib_1.__decorate([
|
|
113
117
|
(0, common_1.Constant)("formio.template"),
|
|
114
|
-
|
|
118
|
+
tslib_1.__metadata("design:type", Object)
|
|
115
119
|
], FormioModule.prototype, "template", void 0);
|
|
116
|
-
|
|
120
|
+
tslib_1.__decorate([
|
|
117
121
|
(0, common_1.Constant)("formio.root"),
|
|
118
|
-
|
|
122
|
+
tslib_1.__metadata("design:type", Object)
|
|
119
123
|
], FormioModule.prototype, "root", void 0);
|
|
120
|
-
FormioModule =
|
|
124
|
+
FormioModule = tslib_1.__decorate([
|
|
121
125
|
(0, di_1.Module)({
|
|
122
126
|
imports: [
|
|
123
127
|
FormioService_1.FormioService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormioModule.js","sourceRoot":"","sources":["../../src/FormioModule.ts"],"names":[],"mappings":";;;;AAAA,yCASsB;AACtB,qCAAqC;AACrC,iCAAgC;AAChC,4DAAuD;AACvD,wDAAmD;AACnD,sDAAiD;AACjD,oDAA+C;AAC/C,sDAAiD;AACjD,oFAA+E;AAC/E,oFAA+E;AAG/E,oEAA+D;AAC/D,sEAAiE;AACjE,gEAA2D;AAC3D,4DAAuD;AAgBvD,IAAa,YAAY,GAAzB,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"FormioModule.js","sourceRoot":"","sources":["../../src/FormioModule.ts"],"names":[],"mappings":";;;;AAAA,yCASsB;AACtB,qCAAqC;AACrC,iCAAgC;AAChC,4DAAuD;AACvD,wDAAmD;AACnD,sDAAiD;AACjD,oDAA+C;AAC/C,sDAAiD;AACjD,oFAA+E;AAC/E,oFAA+E;AAG/E,oEAA+D;AAC/D,sEAAiE;AACjE,gEAA2D;AAC3D,4DAAuD;AAgBvD,IAAa,Y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IAAI,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC;CACF,CAAA;AA9FC;IADC,IAAA,eAAM,GAAE;sCACS,6BAAa;4CAAC;AAGhC;IADC,IAAA,eAAM,GAAE;sCACQ,uCAAkB;2CAAC;AAGpC;IADC,IAAA,eAAM,GAAE;sCACY,iCAAe;+CAAC;AAGrC;IADC,IAAA,eAAM,GAAE;sCACM,4BAAmB;yCAAC;AAGnC;IADC,IAAA,eAAM,GAAE;sCACW,wBAAe;8CAAC;AAGpC;IADC,IAAA,iBAAQ,EAAC,QAAQ,EAAE,EAAE,CAAC;;8CACU;AAGjC;IADC,IAAA,iBAAQ,EAAC,gBAAgB,EAAE,GAAG,CAAC;;6CACN;AAG1B;IADC,IAAA,iBAAQ,EAAC,oBAAoB,EAAE,KAAK,CAAC;;iDACP;AAG/B;IADC,IAAA,iBAAQ,EAAC,iBAAiB,CAAC;;8CACQ;AAGpC;IADC,IAAA,iBAAQ,EAAC,aAAa,CAAC;;0CACH;AA7BV,YAAY;IAdxB,IAAA,WAAM,EAAC;QACN,OAAO,EAAE;YACP,6BAAa;YACb,uCAAkB;YAClB,qCAAiB;YACjB,2BAAY;YACZ,qBAAS;YACT,uBAAU;YACV,mBAAQ;YACR,qBAAS;YACT,mDAAwB;YACxB,mDAAwB;SACzB;KACF,CAAC;GACW,YAAY,CAgGxB;AAhGY,oCAAY","sourcesContent":["import {\n Constant,\n Inject,\n InjectorService,\n normalizePath,\n OnReady,\n OnRoutesInit,\n PlatformApplication,\n PlatformRouteDetails\n} from \"@tsed/common\";\nimport {deepClone} from \"@tsed/core\";\nimport {Module} from \"@tsed/di\";\nimport {AlterActions} from \"./components/AlterActions\";\nimport {AlterAudit} from \"./components/AlterAudit\";\nimport {AlterHost} from \"./components/AlterHost\";\nimport {AlterLog} from \"./components/AlterLog\";\nimport {AlterSkip} from \"./components/AlterSkip\";\nimport {AlterTemplateExportSteps} from \"./components/AlterTemplateExportSteps\";\nimport {AlterTemplateImportSteps} from \"./components/AlterTemplateImportSteps\";\nimport {FormioConfig} from \"./domain/FormioConfig\";\nimport {FormioTemplate} from \"./domain/FormioTemplate\";\nimport {FormioAuthService} from \"./services/FormioAuthService\";\nimport {FormioHooksService} from \"./services/FormioHooksService\";\nimport {FormioInstaller} from \"./services/FormioInstaller\";\nimport {FormioService} from \"./services/FormioService\";\n\n@Module({\n imports: [\n FormioService,\n FormioHooksService,\n FormioAuthService,\n AlterActions,\n AlterHost,\n AlterAudit,\n AlterLog,\n AlterSkip,\n AlterTemplateImportSteps,\n AlterTemplateExportSteps\n ]\n})\nexport class FormioModule implements OnRoutesInit, OnReady {\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected hooks: FormioHooksService;\n\n @Inject()\n protected installer: FormioInstaller;\n\n @Inject()\n protected app: PlatformApplication;\n\n @Inject()\n protected injector: InjectorService;\n\n @Constant(\"formio\", {})\n protected settings: FormioConfig;\n\n @Constant(\"formio.baseUrl\", \"/\")\n protected baseUrl: string;\n\n @Constant(\"formio.skipInstall\", false)\n protected skipInstall: boolean;\n\n @Constant(\"formio.template\")\n protected template?: FormioTemplate;\n\n @Constant(\"formio.root\")\n protected root?: any;\n\n $onInit() {\n return this.init(deepClone(this.settings));\n }\n\n async init(options: FormioConfig) {\n return this.formio.init(options, this.hooks.getHooks());\n }\n\n async $onRoutesInit() {\n if (this.formio.isInit()) {\n this.app.use(this.baseUrl, this.formio.middleware.restrictRequestTypes, this.formio.router);\n\n if (await this.shouldInstall()) {\n await this.installer.install(this.template!, this.root);\n }\n }\n }\n\n async $logRoutes(routes: PlatformRouteDetails[]): Promise<PlatformRouteDetails[]> {\n if (this.formio.isInit()) {\n const spec = (await this.formio.swagger(\n {\n $ctx: {\n request: {\n protocol: \"http\",\n host: \"localhost\"\n }\n }\n },\n this.formio.router\n )) as any;\n const {baseUrl} = this;\n\n Object.entries(spec.paths).forEach(([path, methods]: [string, any]) => {\n Object.entries(methods).forEach(([method, operation]: [string, any]) => {\n routes.push({\n method,\n name: operation.operationId,\n url: normalizePath(baseUrl, path.replace(/\\/{(.*)}/gi, \"/:$1\")),\n className: \"formio\",\n methodClassName: operation.operationId\n });\n });\n });\n }\n\n return routes;\n }\n\n // istanbul ignore next\n async $onReady(): Promise<void> {\n if (this.formio.isInit() && \"getBestHost\" in this.injector.settings) {\n const {injector} = this;\n // @ts-ignore\n const host = injector.settings.getBestHost();\n const url = host.toString();\n\n injector.logger.info(`Form.io API is available on ${url}${this.baseUrl || \"/\"}`);\n }\n }\n\n protected async shouldInstall() {\n const hasForms = await this.installer.hasForms();\n return this.template && !(hasForms || this.skipInstall);\n }\n}\n"]}
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FormioMapper = void 0;
|
|
4
4
|
class FormioMapper {
|
|
5
|
+
ctxData;
|
|
5
6
|
constructor(ctxData) {
|
|
6
7
|
this.ctxData = ctxData;
|
|
7
8
|
}
|
|
8
9
|
find(key) {
|
|
9
10
|
const store = Object.values(this.ctxData).find((store) => store.get(key));
|
|
10
|
-
return store
|
|
11
|
+
return store?.get(key);
|
|
11
12
|
}
|
|
12
13
|
findId(data) {
|
|
13
14
|
const key = String(data).startsWith("$machineName:") ? String(data) : `$machineName:${String(data)}`;
|
|
@@ -17,7 +18,7 @@ class FormioMapper {
|
|
|
17
18
|
findMachineName(data) {
|
|
18
19
|
const key = String(data);
|
|
19
20
|
const item = this.find(key);
|
|
20
|
-
return item ? `$machineName:${item.machineName}` : undefined;
|
|
21
|
+
return item ? `$machineName:${item.name || item.machineName}` : undefined;
|
|
21
22
|
}
|
|
22
23
|
mapToExport(data) {
|
|
23
24
|
return this.mapData(data, this.findMachineName.bind(this));
|
|
@@ -38,13 +39,21 @@ class FormioMapper {
|
|
|
38
39
|
if (key) {
|
|
39
40
|
return key;
|
|
40
41
|
}
|
|
41
|
-
if (typeof data === "object" && !(data instanceof Date)) {
|
|
42
|
-
|
|
42
|
+
if (typeof data === "object" && !("_bsontype" in data) && !(data instanceof Date)) {
|
|
43
|
+
const isForm = data.path && data.type;
|
|
44
|
+
const mapped = Object.entries(data).reduce((obj, [key, value]) => {
|
|
43
45
|
return {
|
|
44
46
|
...obj,
|
|
45
47
|
[key]: this.mapData(value, resolver)
|
|
46
48
|
};
|
|
47
49
|
}, {});
|
|
50
|
+
return isForm
|
|
51
|
+
? {
|
|
52
|
+
...mapped,
|
|
53
|
+
name: data.name,
|
|
54
|
+
machineName: data.machineName || data.name
|
|
55
|
+
}
|
|
56
|
+
: mapped;
|
|
48
57
|
}
|
|
49
58
|
return data;
|
|
50
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormioMapper.js","sourceRoot":"","sources":["../../../src/builder/FormioMapper.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"FormioMapper.js","sourceRoot":"","sources":["../../../src/builder/FormioMapper.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAY;IACF;IAArB,YAAqB,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;IAAG,CAAC;IAEjD,IAAI,CAAC,GAAW;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAE1E,OAAO,KAAK,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,gBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACrG,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,C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AY,IAAI,CAAC,EAAE;YACjF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC;YACtC,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;gBAC/D,OAAO;oBACL,GAAG,GAAG;oBACN,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC;iBACrC,CAAC;YACJ,CAAC,EAAE,EAAE,CAAC,CAAC;YAEP,OAAO,MAAM;gBACX,CAAC,CAAC;oBACE,GAAG,MAAM;oBACT,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI;iBAC3C;gBACH,CAAC,CAAC,MAAM,CAAC;SACZ;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AApED,oCAoEC","sourcesContent":["import {FormioCtxMapper} from \"../domain/FormioCtxMapper\";\n\nexport class FormioMapper {\n constructor(readonly ctxData: FormioCtxMapper) {}\n\n find(key: string) {\n const store = Object.values(this.ctxData).find((store) => store.get(key));\n\n return store?.get(key);\n }\n\n findId(data: string) {\n const key = String(data).startsWith(\"$machineName:\") ? String(data) : `$machineName:${String(data)}`;\n const item = this.find(key);\n\n return item ? item._id : undefined;\n }\n\n findMachineName(data: any) {\n const key = String(data);\n const item: any = this.find(key);\n\n return item ? `$machineName:${item.name || item.machineName}` : undefined;\n }\n\n mapToExport(data: any) {\n return this.mapData(data, this.findMachineName.bind(this));\n }\n\n mapToImport(data: any) {\n return this.mapData(data, this.findId.bind(this));\n }\n\n mapData(data: any, resolver: any): any {\n if (!data) {\n return data;\n }\n\n if (Array.isArray(data)) {\n return data.map((item) => {\n return this.mapData(item, resolver);\n });\n }\n\n const key = resolver(data, this.ctxData);\n\n if (key) {\n return key;\n }\n\n if (typeof data === \"object\" && !(\"_bsontype\" in data) && !(data instanceof Date)) {\n const isForm = data.path && data.type;\n const mapped = Object.entries(data).reduce((obj, [key, value]) => {\n return {\n ...obj,\n [key]: this.mapData(value, resolver)\n };\n }, {});\n\n return isForm\n ? {\n ...mapped,\n name: data.name,\n machineName: data.machineName || data.name\n }\n : mapped;\n }\n\n return data;\n }\n}\n"]}
|
|
@@ -3,63 +3,114 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AlterActions = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@tsed/common");
|
|
6
|
+
const core_1 = require("@tsed/core");
|
|
6
7
|
const di_1 = require("@tsed/di");
|
|
8
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
9
|
+
const platform_response_filter_1 = require("@tsed/platform-response-filter");
|
|
10
|
+
const schema_1 = require("@tsed/schema");
|
|
7
11
|
const alter_1 = require("../decorators/alter");
|
|
8
12
|
const FormioService_1 = require("../services/FormioService");
|
|
9
13
|
let AlterActions = class AlterActions {
|
|
14
|
+
injector;
|
|
15
|
+
formio;
|
|
16
|
+
params;
|
|
17
|
+
responseFilter;
|
|
10
18
|
transform(actions) {
|
|
11
19
|
const { Action } = this.formio;
|
|
12
20
|
return this.getActions().reduce((actions, provider) => {
|
|
13
|
-
var _a;
|
|
14
21
|
const instance = this.injector.invoke(provider.token);
|
|
15
22
|
const options = provider.store.get("formio:action");
|
|
16
|
-
const resolveHandler = this.
|
|
23
|
+
const resolveHandler = this.createHandler(provider, "resolve");
|
|
17
24
|
return {
|
|
18
25
|
...actions,
|
|
19
|
-
[options.name]:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
next(null, opts);
|
|
26
|
+
[options.name]: class extends Action {
|
|
27
|
+
static access = options.access;
|
|
28
|
+
static async info(req, res, next) {
|
|
29
|
+
let opts = { ...options };
|
|
30
|
+
if (instance.info) {
|
|
31
|
+
opts = await instance.info(opts, req, res);
|
|
26
32
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
next(null, opts);
|
|
34
|
+
}
|
|
35
|
+
static async settingsForm(req, res, next) {
|
|
36
|
+
next(null, await instance.settingsForm(req, res));
|
|
37
|
+
}
|
|
38
|
+
resolve(handler, method, req, res, next, setActionItemMessage) {
|
|
39
|
+
resolveHandler(this, handler, method, req, res, next, setActionItemMessage);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
36
42
|
};
|
|
37
43
|
}, actions);
|
|
38
44
|
}
|
|
39
45
|
getActions() {
|
|
40
46
|
return this.injector.getProviders("formio:action");
|
|
41
47
|
}
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
48
|
+
createHandler(provider, propertyKey) {
|
|
49
|
+
const compiledHandler = this.params.compileHandler({
|
|
50
|
+
token: provider.token,
|
|
51
|
+
propertyKey
|
|
52
|
+
});
|
|
53
|
+
return async (action, handler, method, req, res, next, setActionItemMessage) => {
|
|
54
|
+
const { $ctx } = req;
|
|
55
|
+
if ($ctx) {
|
|
56
|
+
$ctx.set("ACTION_CTX", { handler, method, setActionItemMessage, action });
|
|
57
|
+
$ctx.endpoint = schema_1.EndpointMetadata.get(provider.useClass, "resolve");
|
|
58
|
+
try {
|
|
59
|
+
if (await this.onRequest(compiledHandler, $ctx)) {
|
|
60
|
+
next();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (er) {
|
|
64
|
+
next(er);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
51
67
|
};
|
|
52
68
|
}
|
|
69
|
+
async onRequest(handler, $ctx) {
|
|
70
|
+
const resolver = new core_1.AnyToPromise();
|
|
71
|
+
const { state, data, status, headers } = await resolver.call(() => handler({ $ctx }));
|
|
72
|
+
if (state === core_1.AnyToPromiseStatus.RESOLVED) {
|
|
73
|
+
if (status) {
|
|
74
|
+
$ctx.response.status(status);
|
|
75
|
+
}
|
|
76
|
+
if (headers) {
|
|
77
|
+
$ctx.response.setHeaders(headers);
|
|
78
|
+
}
|
|
79
|
+
if (data !== undefined) {
|
|
80
|
+
$ctx.data = data;
|
|
81
|
+
return await this.flush($ctx.data, $ctx);
|
|
82
|
+
}
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async flush(data, $ctx) {
|
|
87
|
+
const { response } = $ctx;
|
|
88
|
+
if (!$ctx.isDone()) {
|
|
89
|
+
(0, common_1.setResponseHeaders)($ctx);
|
|
90
|
+
data = await this.responseFilter.serialize(data, $ctx);
|
|
91
|
+
data = await this.responseFilter.transform(data, $ctx);
|
|
92
|
+
response.body(data);
|
|
93
|
+
}
|
|
94
|
+
return response;
|
|
95
|
+
}
|
|
53
96
|
};
|
|
54
|
-
|
|
97
|
+
tslib_1.__decorate([
|
|
55
98
|
(0, di_1.Inject)(),
|
|
56
|
-
|
|
99
|
+
tslib_1.__metadata("design:type", di_1.InjectorService)
|
|
57
100
|
], AlterActions.prototype, "injector", void 0);
|
|
58
|
-
|
|
101
|
+
tslib_1.__decorate([
|
|
59
102
|
(0, di_1.Inject)(),
|
|
60
|
-
|
|
103
|
+
tslib_1.__metadata("design:type", FormioService_1.FormioService)
|
|
61
104
|
], AlterActions.prototype, "formio", void 0);
|
|
62
|
-
|
|
105
|
+
tslib_1.__decorate([
|
|
106
|
+
(0, di_1.Inject)(),
|
|
107
|
+
tslib_1.__metadata("design:type", platform_params_1.PlatformParams)
|
|
108
|
+
], AlterActions.prototype, "params", void 0);
|
|
109
|
+
tslib_1.__decorate([
|
|
110
|
+
(0, di_1.Inject)(),
|
|
111
|
+
tslib_1.__metadata("design:type", platform_response_filter_1.PlatformResponseFilter)
|
|
112
|
+
], AlterActions.prototype, "responseFilter", void 0);
|
|
113
|
+
AlterActions = tslib_1.__decorate([
|
|
63
114
|
(0, alter_1.Alter)("actions")
|
|
64
115
|
], AlterActions);
|
|
65
116
|
exports.AlterActions = AlterActions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"AlterActions.js","sourceRoot":"","sources":["../../../src/components/AlterActions.ts"],"names":[],"mappings":";;;;AAAA,yCAAiE;AACjE,qCAA4D;AAC5D,iCAA2D;AAE3D,2DAAqD;AACrD,6EAAsE;AACtE,yCAA8C;AAC9C,+CAA0C;AAI1C,6DAAwD;AAGxD,IAAa,YAAY,GAAzB,MAAa,YAAY;IAEb,QAAQ,CAAkB;IAG1B,MAAM,CAAgB;IAGtB,MAAM,CAAiB;IAGvB,cAAc,CAAyB;IAEjD,SAAS,CAAC,OAAsB;QAC9B,MAAM,EAAC,MAAM,EAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAE7B,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;YACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC3D,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAmB,eAAe,CAAC,CAAC;YACtE,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YAE/D,OAAO;gBACL,GAAG,OAAO;gBACV,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAM,SAAQ,MAAM;oBAClC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;oBAE/B,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,GAAQ,EAAE,GAAQ,E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AAE,EAAE;YAClB,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;YAEzB,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAC9D,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;YAE9D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACrB;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AAvHC;IADC,IAAA,WAAM,GAAE;sCACW,oBAAe;8CAAC;AAGpC;IADC,IAAA,WAAM,GAAE;sCACS,6BAAa;4CAAC;AAGhC;IADC,IAAA,WAAM,GAAE;sCACS,gCAAc;4CAAC;AAGjC;IADC,IAAA,WAAM,GAAE;sCACiB,iDAAsB;oDAAC;AAXtC,YAAY;IADxB,IAAA,aAAK,EAAC,SAAS,CAAC;GACJ,YAAY,CAyHxB;AAzHY,oCAAY","sourcesContent":["import {PlatformContext, setResponseHeaders} from \"@tsed/common\";\nimport {AnyToPromise, AnyToPromiseStatus} from \"@tsed/core\";\nimport {Inject, InjectorService, Provider} from \"@tsed/di\";\nimport {FormioActionInfo} from \"@tsed/formio-types\";\nimport {PlatformParams} from \"@tsed/platform-params\";\nimport {PlatformResponseFilter} from \"@tsed/platform-response-filter\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {SetActionItemMessage} from \"../domain/FormioAction\";\nimport {FormioActions} from \"../domain/FormioActionsIndex\";\nimport {FormioService} from \"../services/FormioService\";\n\n@Alter(\"actions\")\nexport class AlterActions implements AlterHook {\n @Inject()\n protected injector: InjectorService;\n\n @Inject()\n protected formio: FormioService;\n\n @Inject()\n protected params: PlatformParams;\n\n @Inject()\n protected responseFilter: PlatformResponseFilter;\n\n transform(actions: FormioActions): FormioActions {\n const {Action} = this.formio;\n\n return this.getActions().reduce((actions, provider) => {\n const instance = this.injector.invoke<any>(provider.token);\n const options = provider.store.get<FormioActionInfo>(\"formio:action\");\n const resolveHandler = this.createHandler(provider, \"resolve\");\n\n return {\n ...actions,\n [options.name]: class extends Action {\n static access = options.access;\n\n static async info(req: any, res: any, next: Function) {\n let opts = {...options};\n\n if (instance.info) {\n opts = await instance.info(opts, req, res);\n }\n\n next(null, opts);\n }\n\n static async settingsForm(req: any, res: any, next: Function) {\n next(null, await instance.settingsForm(req, res));\n }\n\n resolve(handler: string, method: string, req: any, res: any, next: Function, setActionItemMessage: SetActionItemMessage): void {\n resolveHandler(this, handler, method, req, res, next, setActionItemMessage);\n }\n }\n };\n }, actions);\n }\n\n protected getActions() {\n return this.injector.getProviders(\"formio:action\");\n }\n\n protected createHandler(provider: Provider, propertyKey: string | symbol) {\n const compiledHandler = this.params.compileHandler({\n token: provider.token,\n propertyKey\n });\n\n return async (\n action: any,\n handler: string,\n method: string,\n req: any,\n res: any,\n next: any,\n setActionItemMessage: SetActionItemMessage\n ) => {\n const {$ctx} = req;\n\n if ($ctx) {\n $ctx.set(\"ACTION_CTX\", {handler, method, setActionItemMessage, action});\n $ctx.endpoint = EndpointMetadata.get(provider.useClass, \"resolve\");\n\n try {\n if (await this.onRequest(compiledHandler, $ctx)) {\n next();\n }\n } catch (er) {\n next(er);\n }\n }\n };\n }\n\n private async onRequest(handler: any, $ctx: PlatformContext) {\n const resolver = new AnyToPromise();\n const {state, data, status, headers} = await resolver.call(() => handler({$ctx}));\n\n if (state === AnyToPromiseStatus.RESOLVED) {\n if (status) {\n $ctx.response.status(status);\n }\n\n if (headers) {\n $ctx.response.setHeaders(headers);\n }\n\n if (data !== undefined) {\n $ctx.data = data;\n\n return await this.flush($ctx.data, $ctx);\n }\n\n return true;\n }\n }\n\n private async flush(data: any, $ctx: PlatformContext) {\n const {response} = $ctx;\n\n if (!$ctx.isDone()) {\n setResponseHeaders($ctx);\n\n data = await this.responseFilter.serialize(data, $ctx as any);\n data = await this.responseFilter.transform(data, $ctx as any);\n\n response.body(data);\n }\n\n return response;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlterAudit.js","sourceRoot":"","sources":["../../../src/components/AlterAudit.ts"],"names":[],"mappings":";;;;AACA,+CAA0C;AAI1C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,SAAS,CAAC,IAAW,EAAE,KAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"AlterAudit.js","sourceRoot":"","sources":["../../../src/components/AlterAudit.ts"],"names":[],"mappings":";;;;AACA,+CAA0C;AAI1C,IAAa,UAAU,GAAvB,MAAa,UAAU;IACrB,SAAS,CAAC,IAAW,EAAE,KAAa,EAAE,GAAc;QAClD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AALY,UAAU;IADtB,IAAA,aAAK,EAAC,OAAO,CAAC;GACF,UAAU,CAKtB;AALY,gCAAU","sourcesContent":["import {DIContext} from \"@tsed/di\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"audit\")\nexport class AlterAudit implements AlterHook {\n transform(info: any[], event: string, ctx: DIContext): boolean {\n ctx.logger.info({event, info});\n return false;\n }\n}\n"]}
|
|
@@ -8,7 +8,7 @@ let AlterHost = class AlterHost {
|
|
|
8
8
|
return `${ctx.request.protocol}://${ctx.request.host}${baseUrl}`;
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
-
AlterHost =
|
|
11
|
+
AlterHost = tslib_1.__decorate([
|
|
12
12
|
(0, alter_1.Alter)("host")
|
|
13
13
|
], AlterHost);
|
|
14
14
|
exports.AlterHost = AlterHost;
|
|
@@ -6,6 +6,8 @@ const common_1 = require("@tsed/common");
|
|
|
6
6
|
const common_2 = require("@tsed/common");
|
|
7
7
|
const alter_1 = require("../decorators/alter");
|
|
8
8
|
let AlterSkip = class AlterSkip {
|
|
9
|
+
baseUrl;
|
|
10
|
+
whiteList;
|
|
9
11
|
transform(value, ctx) {
|
|
10
12
|
if (value) {
|
|
11
13
|
return true;
|
|
@@ -17,15 +19,15 @@ let AlterSkip = class AlterSkip {
|
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
tslib_1.__decorate([
|
|
21
23
|
(0, common_1.Constant)("formio.baseUrl", "/"),
|
|
22
|
-
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
23
25
|
], AlterSkip.prototype, "baseUrl", void 0);
|
|
24
|
-
|
|
26
|
+
tslib_1.__decorate([
|
|
25
27
|
(0, common_1.Constant)("formio.whiteList", ["/spec.json"]),
|
|
26
|
-
|
|
28
|
+
tslib_1.__metadata("design:type", Array)
|
|
27
29
|
], AlterSkip.prototype, "whiteList", void 0);
|
|
28
|
-
AlterSkip =
|
|
30
|
+
AlterSkip = tslib_1.__decorate([
|
|
29
31
|
(0, alter_1.Alter)("skip")
|
|
30
32
|
], AlterSkip);
|
|
31
33
|
exports.AlterSkip = AlterSkip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlterSkip.js","sourceRoot":"","sources":["../../../src/components/AlterSkip.ts"],"names":[],"mappings":";;;;AAAA,yCAAuD;AACvD,yCAA2C;AAC3C,+CAA0C;AAI1C,IAAa,SAAS,GAAtB,MAAa,SAAS;
|
|
1
|
+
{"version":3,"file":"AlterSkip.js","sourceRoot":"","sources":["../../../src/components/AlterSkip.ts"],"names":[],"mappings":";;;;AAAA,yCAAuD;AACvD,yCAA2C;AAC3C,+CAA0C;AAI1C,IAAa,SAAS,GAAtB,MAAa,SAAS;IAEpB,OAAO,CAAS;IAGhB,SAAS,CAAW;IAEpB,SAAS,CAAC,KAAU,EAAE,GAAoB;QACxC,IAAI,KAAK,EAAE;YACT,OAAO,IAAI,CAAC;SACb;QAED,MAAM,EAAC,OAAO,EAAC,GAAG,GAAG,CAAC;QACtB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEtC,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;YACrC,OAAO,IAAA,sBAAa,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjBC;IADC,IAAA,iBAAQ,EAAC,gBAAgB,EAAE,GAAG,CAAC;;0CAChB;AAGhB;IADC,IAAA,iBAAQ,EAAC,kBAAkB,EAAE,CAAC,YAAY,CAAC,CAAC;;4CACzB;AALT,SAAS;IADrB,IAAA,aAAK,EAAC,MAAM,CAAC;GACD,SAAS,CAmBrB;AAnBY,8BAAS","sourcesContent":["import {Constant, PlatformContext} from \"@tsed/common\";\nimport {normalizePath} from \"@tsed/common\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\n\n@Alter(\"skip\")\nexport class AlterSkip implements AlterHook {\n @Constant(\"formio.baseUrl\", \"/\")\n baseUrl: string;\n\n @Constant(\"formio.whiteList\", [\"/spec.json\"])\n whiteList: string[];\n\n transform(value: any, ctx: PlatformContext): any {\n if (value) {\n return true;\n }\n\n const {request} = ctx;\n const url = request.url.split(\"?\")[0];\n\n return !!this.whiteList.find((entry) => {\n return normalizePath(this.baseUrl, entry) === url;\n });\n }\n}\n"]}
|
|
@@ -6,10 +6,11 @@ const core_1 = require("@tsed/core");
|
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
7
|
const alter_1 = require("../decorators/alter");
|
|
8
8
|
const FormioDatabase_1 = require("../services/FormioDatabase");
|
|
9
|
-
const
|
|
9
|
+
const async_1 = tslib_1.__importDefault(require("async"));
|
|
10
10
|
let AlterTemplateExportSteps = class AlterTemplateExportSteps {
|
|
11
|
+
database;
|
|
11
12
|
transform(queue, template, map, options) {
|
|
12
|
-
queue.push(
|
|
13
|
+
queue.push(async_1.default.apply(this.exportSubmissions.bind(this), template, map, options));
|
|
13
14
|
return queue;
|
|
14
15
|
}
|
|
15
16
|
async exportSubmissions(template, map, options, next) {
|
|
@@ -41,11 +42,11 @@ let AlterTemplateExportSteps = class AlterTemplateExportSteps {
|
|
|
41
42
|
}, {});
|
|
42
43
|
}
|
|
43
44
|
};
|
|
44
|
-
|
|
45
|
+
tslib_1.__decorate([
|
|
45
46
|
(0, di_1.Inject)(),
|
|
46
|
-
|
|
47
|
+
tslib_1.__metadata("design:type", FormioDatabase_1.FormioDatabase)
|
|
47
48
|
], AlterTemplateExportSteps.prototype, "database", void 0);
|
|
48
|
-
AlterTemplateExportSteps =
|
|
49
|
+
AlterTemplateExportSteps = tslib_1.__decorate([
|
|
49
50
|
(0, alter_1.Alter)("templateExportSteps")
|
|
50
51
|
], AlterTemplateExportSteps);
|
|
51
52
|
exports.AlterTemplateExportSteps = AlterTemplateExportSteps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlterTemplateExportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateExportSteps.ts"],"names":[],"mappings":";;;;AAAA,qCAAoC;AACpC,iCAAgC;AAGhC,+CAA0C;AAI1C,+DAA0D;
|
|
1
|
+
{"version":3,"file":"AlterTemplateExportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateExportSteps.ts"],"names":[],"mappings":";;;;AAAA,qCAAoC;AACpC,iCAAgC;AAGhC,+CAA0C;AAI1C,+DAA0D;AAC1D,0DAA0B;AAG1B,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAiB;IAEnC,SAAS,CAAC,KAAY,EAAE,QAAwB,EAAE,GAAQ,EAAE,OAAY;QACtE,KAAK,CAAC,IAAI,CAAC,eAAK,CAAC,KAAK,CAAC,IAAI,CAA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CAAC,IAAI,CAAC;gBACZ,GAAG,UAAU;gBACb,OAAO,EAAE,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE;gBACtC,QAAQ,EAAE,QAAQ,IAAI,QAAQ,CAAC,QAAQ,EAAE;gBACzC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC;gBACzC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;gBAChD,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;aAC/B,CAAC,CAAC;YAEH,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAE,CAAC,CAAC;IACX,CAAC;CACF,CAAA;AA1CC;IADC,IAAA,WAAM,GAAE;sCACW,+BAAc;0DAAC;AAFxB,wBAAwB;IADpC,IAAA,aAAK,EAAC,qBAAqB,CAAC;GAChB,wBAAwB,CA4CpC;AA5CY,4DAAwB","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {Inject} from \"@tsed/di\";\nimport {MongooseDocument} from \"@tsed/mongoose\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"../services/FormioDatabase\";\nimport async from \"async\";\n\n@Alter(\"templateExportSteps\")\nexport class AlterTemplateExportSteps implements AlterHook {\n @Inject()\n protected database: FormioDatabase;\n\n transform(queue: any[], template: FormioTemplate, map: any, options: any): any {\n queue.push(async.apply(this.exportSubmissions.bind(this), template, map, options));\n\n return queue;\n }\n\n protected async exportSubmissions(template: FormioTemplate, map: any, options: any, next: any) {\n const [mapper, submissions] = await Promise.all([\n this.database.getFormioMapper(),\n this.database.submissionModel.find({\n deleted: {$eq: null}\n })\n ]);\n\n template.submissions = await this.mapSubmissions(submissions, mapper);\n\n next(null, template);\n }\n\n protected mapSubmissions(submissions: MongooseDocument<FormioSubmission>[], mapper: FormioMapper) {\n return submissions\n .map((submission) => submission.toObject())\n .reduce((acc: any, {_id, created, updated, modified, __v, owner, roles, form, metadata, ...submission}) => {\n const machineName = mapper.mapToExport(form.toString());\n const key = machineName.replace(\"$machineName:\", \"\");\n\n acc[key] = getValue(acc, key, []);\n\n acc[key].push({\n ...submission,\n created: created && created.toString(),\n modified: modified && modified.toString(),\n data: mapper.mapToExport(submission.data),\n roles: mapper.mapToExport(roles).filter(Boolean),\n form: mapper.mapToExport(form)\n });\n\n return acc;\n }, {});\n }\n}\n"]}
|
|
@@ -5,10 +5,11 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const di_1 = require("@tsed/di");
|
|
6
6
|
const alter_1 = require("../decorators/alter");
|
|
7
7
|
const FormioDatabase_1 = require("../services/FormioDatabase");
|
|
8
|
-
const
|
|
8
|
+
const async_1 = tslib_1.__importDefault(require("async"));
|
|
9
9
|
let AlterTemplateImportSteps = class AlterTemplateImportSteps {
|
|
10
|
+
database;
|
|
10
11
|
transform(queue, install, template) {
|
|
11
|
-
queue.push(
|
|
12
|
+
queue.push(async_1.default.apply(this.importSubmissions.bind(this), template));
|
|
12
13
|
return queue;
|
|
13
14
|
}
|
|
14
15
|
async importSubmissions(template, done) {
|
|
@@ -34,11 +35,11 @@ let AlterTemplateImportSteps = class AlterTemplateImportSteps {
|
|
|
34
35
|
return value;
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
|
-
|
|
38
|
+
tslib_1.__decorate([
|
|
38
39
|
(0, di_1.Inject)(),
|
|
39
|
-
|
|
40
|
+
tslib_1.__metadata("design:type", FormioDatabase_1.FormioDatabase)
|
|
40
41
|
], AlterTemplateImportSteps.prototype, "database", void 0);
|
|
41
|
-
AlterTemplateImportSteps =
|
|
42
|
+
AlterTemplateImportSteps = tslib_1.__decorate([
|
|
42
43
|
(0, alter_1.Alter)("templateImportSteps")
|
|
43
44
|
], AlterTemplateImportSteps);
|
|
44
45
|
exports.AlterTemplateImportSteps = AlterTemplateImportSteps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlterTemplateImportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateImportSteps.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAEhC,+CAA0C;AAI1C,+DAA0D;
|
|
1
|
+
{"version":3,"file":"AlterTemplateImportSteps.js","sourceRoot":"","sources":["../../../src/components/AlterTemplateImportSteps.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAEhC,+CAA0C;AAI1C,+DAA0D;AAC1D,0DAA0B;AAG1B,IAAa,wBAAwB,GAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAiB;IAEnC,SAAS,CAAC,KAAY,EAAE,OAAiB,EAAE,QAAiC;QAC1E,KAAK,CAAC,IAAI,CAAC,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;QAErE,OAAO,KAAK,CAAC;IACf,CAAC;IAES,KAAK,CAAC,iBAAiB,CAAC,QAAiC,EAAE,IAAS;QAC5E,IAAI,QAAQ,IAAI,QAAQ,CAAC,WAAW,EAAE;YACpC,wBAAwB;YACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YAEnD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;YACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;YAErD,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE;gBAC3B,KAAK,MAAM,UAAU,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;oBACjC,MAAM,IAAI,CAAC,gBAAgB,CAAC,EAAC,GAAG,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,EAAC,EAAE,OAAO,CAAC,CAAC;iBAC1F;aACF;SACF;QAED,IAAI,EAAE,CAAC;IACT,CAAC;IAES,KAAK,CAAC,gBAAgB,CAAC,UAAqC,EAAE,MAAoB;QAC1F,MAAM,KAAK,GAAG;YACZ,GAAG,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC;YACjC,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;SAChF,CAAC;QAEF,MAAM,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAElD,OAAO,KAAK,CAAC;IACf,CAAC;CACF,CAAA;AApCC;IADC,IAAA,WAAM,GAAE;sCACW,+BAAc;0DAAC;AAFxB,wBAAwB;IADpC,IAAA,aAAK,EAAC,qBAAqB,CAAC;GAChB,wBAAwB,CAsCpC;AAtCY,4DAAwB","sourcesContent":["import {Inject} from \"@tsed/di\";\nimport {FormioMapper} from \"../builder/FormioMapper\";\nimport {Alter} from \"../decorators/alter\";\nimport {AlterHook} from \"../domain/AlterHook\";\nimport {FormioSubmission} from \"../domain/FormioModels\";\nimport {FormioTemplate} from \"../domain/FormioTemplate\";\nimport {FormioDatabase} from \"../services/FormioDatabase\";\nimport async from \"async\";\n\n@Alter(\"templateImportSteps\")\nexport class AlterTemplateImportSteps implements AlterHook {\n @Inject()\n protected database: FormioDatabase;\n\n transform(queue: any[], install: Function, template: Partial<FormioTemplate>): any {\n queue.push(async.apply(this.importSubmissions.bind(this), template));\n\n return queue;\n }\n\n protected async importSubmissions(template: Partial<FormioTemplate>, done: any) {\n if (template && template.submissions) {\n // clean all submissions\n await this.database.submissionModel.deleteMany({});\n\n const ctxData = await this.database.getFormioMapper();\n const entries = Object.entries(template.submissions);\n\n for (const entry of entries) {\n for (const submission of entry[1]) {\n await this.importSubmission({...submission, form: submission.form || entry[0]}, ctxData);\n }\n }\n }\n\n done();\n }\n\n protected async importSubmission(submission: Partial<FormioSubmission>, mapper: FormioMapper) {\n const value = {\n ...mapper.mapToImport(submission),\n roles: [...new Set(mapper.mapToImport(submission.roles || []))].filter(Boolean)\n };\n\n await this.database.submissionModel.create(value);\n\n return value;\n }\n}\n"]}
|