@formio/appserver 1.2.7 → 1.2.8

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.
@@ -1,4 +1,3 @@
1
- /// <reference types="express" />
2
1
  declare const _default: {
3
2
  save: {
4
3
  readonly info: {
@@ -188,6 +188,25 @@ exports.SaveAction = {
188
188
  description: "Available variables are submission and data (data is already transformed by simple mappings)."
189
189
  }
190
190
  ]
191
+ },
192
+ {
193
+ type: 'panel',
194
+ title: 'Response Mapping',
195
+ key: 'responseMappingPanel',
196
+ components: [
197
+ {
198
+ input: true,
199
+ label: "Response Mapping",
200
+ key: "response",
201
+ placeholder: "/** Example Code **/\nresponse = submission;",
202
+ rows: 8,
203
+ defaultValue: "",
204
+ persistent: true,
205
+ editor: "ace",
206
+ type: "textarea",
207
+ description: "Manually perform a mapping of the response being made back to the client. The 'body' is the res.body sent to the client. You can use any standard evaluation context variables (form, submission, etc)."
208
+ }
209
+ ]
191
210
  }
192
211
  ];
193
212
  });
@@ -262,6 +281,15 @@ exports.SaveAction = {
262
281
  id: res.resource.item._id.toString()
263
282
  });
264
283
  }
284
+ // Allow for a response mapping.
285
+ if (action.settings.response) {
286
+ try {
287
+ res.resource.item = scope.utils.evaluate(action.settings.response, scope.utils.evalContext(Object.assign(Object.assign({}, scope), { response: res.resource.item }), req, res), 'response');
288
+ }
289
+ catch (err) {
290
+ console.log(`Error in mapping transform: ${err.message}`);
291
+ }
292
+ }
265
293
  }
266
294
  },
267
295
  executor(scope) {
package/lib/server.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="express" />
2
1
  import { Server as CoreServer } from '@formio/appserver-core';
3
2
  import { Database, Auth } from "./modules";
4
3
  import Actions from "./actions";
@@ -1,21 +1,27 @@
1
1
  import { Request, Response } from 'express';
2
2
  import { FormScope } from './form';
3
+ import { ServerScope } from './server';
4
+ import { ProjectScope } from './project';
3
5
  export interface SubmissionResponse extends Response {
4
6
  resource?: any;
5
7
  proxyRes: (res: any) => void;
6
8
  }
9
+ export interface SubmissionScope extends FormScope {
10
+ submission: any;
11
+ }
7
12
  export interface SubmissionRequest extends Request {
8
13
  user: any;
9
14
  token: any;
10
15
  scope: any;
11
16
  admin: any;
12
17
  headers: any;
18
+ serverScope: ServerScope;
19
+ projectScope: ProjectScope;
20
+ formScope: FormScope;
21
+ submissionScope: SubmissionScope;
13
22
  childRequests: number;
14
23
  skipSave: boolean;
15
24
  }
16
- export interface SubmissionScope extends FormScope {
17
- submission: any;
18
- }
19
25
  export interface ProcessScope extends SubmissionScope {
20
26
  component: any;
21
27
  row: any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/appserver",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "A highly performant and extensible Application Server for Form.io Multi-Tenant Deployments.",
5
5
  "main": "server.js",
6
6
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  "homepage": "https://github.com/formio/appserver#readme",
31
31
  "dependencies": {
32
32
  "@formio/appserver-auth-jwt": "^1.0.1",
33
- "@formio/appserver-core": "^1.4.7",
33
+ "@formio/appserver-core": "^1.4.8",
34
34
  "@formio/appserver-db-mongodb": "^1.0.4",
35
35
  "@formio/appserver-types": "^1.2.5",
36
36
  "async": "^3.2.4",