@formio/appserver 2.11.2 → 2.12.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.
|
@@ -107,7 +107,7 @@ exports.RoleAction = {
|
|
|
107
107
|
executor(form, action, handler, method) {
|
|
108
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
109
|
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
-
var _a, _b;
|
|
110
|
+
var _a, _b, _c;
|
|
111
111
|
debug('Role Action');
|
|
112
112
|
// Check the submission for the submissionId.
|
|
113
113
|
if (action.settings.association !== 'existing' && action.settings.association !== 'new') {
|
|
@@ -134,7 +134,7 @@ exports.RoleAction = {
|
|
|
134
134
|
return res.status(400).send('Missing submission for RoleAction association of "existing:. Form must have a resource field named "submission".');
|
|
135
135
|
}
|
|
136
136
|
// Determine the resources based on the current request.
|
|
137
|
-
let resource = res.resource ?
|
|
137
|
+
let resource = ((_c = res.resource) === null || _c === void 0 ? void 0 : _c.item) || req.submission || req.body;
|
|
138
138
|
let role = form.project.roleId(action.settings.role);
|
|
139
139
|
if (!resource.roles) {
|
|
140
140
|
resource.roles = [];
|
|
@@ -215,7 +215,7 @@ exports.SaveAction = {
|
|
|
215
215
|
let childSub = { data: {} };
|
|
216
216
|
if (action.settings.mapping) {
|
|
217
217
|
try {
|
|
218
|
-
childSub = appserver_core_1.Utils.evaluate(action.settings.mapping, appserver_core_1.Utils.evalContext(form,
|
|
218
|
+
childSub = appserver_core_1.Utils.evaluate(action.settings.mapping, appserver_core_1.Utils.evalContext(form, submission, req.auth, req.headers, req.findQuery), 'body');
|
|
219
219
|
}
|
|
220
220
|
catch (err) {
|
|
221
221
|
console.log(`Error in mapping transform: ${err.message}`);
|
|
@@ -234,7 +234,7 @@ exports.SaveAction = {
|
|
|
234
234
|
childSub.metadata = submission.metadata;
|
|
235
235
|
if (action.settings.transform) {
|
|
236
236
|
try {
|
|
237
|
-
childSub.data = appserver_core_1.Utils.evaluate(action.settings.transform, appserver_core_1.Utils.evalContext(form, req.body, req.auth, req.headers, req.findQuery), 'data');
|
|
237
|
+
childSub.data = appserver_core_1.Utils.evaluate(action.settings.transform, appserver_core_1.Utils.evalContext(form, req.submission || req.body, req.auth, req.headers, req.findQuery), 'data');
|
|
238
238
|
}
|
|
239
239
|
catch (err) {
|
|
240
240
|
console.log(`Error in submission transform: ${err.message}`);
|
|
@@ -246,15 +246,16 @@ exports.SaveAction = {
|
|
|
246
246
|
childResponse(action, req, res, form, submission) {
|
|
247
247
|
var _a, _b;
|
|
248
248
|
if ((_a = res.resource) === null || _a === void 0 ? void 0 : _a.item) {
|
|
249
|
+
const submission = req.submission || req.body;
|
|
249
250
|
// Set the action in the property.
|
|
250
251
|
if ((_b = action.settings) === null || _b === void 0 ? void 0 : _b.property) {
|
|
251
|
-
(0, set_1.default)(
|
|
252
|
+
(0, set_1.default)(submission.data, action.settings.property, res.resource.item);
|
|
252
253
|
}
|
|
253
254
|
// Save the reference in the external ids.
|
|
254
255
|
if (req.method === 'POST' && res.resource.item._id) {
|
|
255
256
|
// Save the external resource in the external ids.
|
|
256
|
-
|
|
257
|
-
|
|
257
|
+
submission.externalIds = submission.externalIds || [];
|
|
258
|
+
submission.externalIds.push({
|
|
258
259
|
type: 'resource',
|
|
259
260
|
resource: action.settings.resource,
|
|
260
261
|
id: res.resource.item._id.toString()
|
|
@@ -263,7 +264,7 @@ exports.SaveAction = {
|
|
|
263
264
|
// Allow for a response mapping.
|
|
264
265
|
if (action.settings.response) {
|
|
265
266
|
try {
|
|
266
|
-
res.resource.item = appserver_core_1.Utils.evaluate(action.settings.response, Object.assign(Object.assign({}, appserver_core_1.Utils.evalContext(form,
|
|
267
|
+
res.resource.item = appserver_core_1.Utils.evaluate(action.settings.response, Object.assign(Object.assign({}, appserver_core_1.Utils.evalContext(form, submission, req.auth, req.headers, req.findQuery)), { response: res.resource.item }), 'response');
|
|
267
268
|
}
|
|
268
269
|
catch (err) {
|
|
269
270
|
console.log(`Error in mapping transform: ${err.message}`);
|
|
@@ -276,7 +277,7 @@ exports.SaveAction = {
|
|
|
276
277
|
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
277
278
|
var _a;
|
|
278
279
|
debug('Save Action');
|
|
279
|
-
if (req.skipSave || !req.body || (req.method !== 'POST' && req.method !== 'PUT')) {
|
|
280
|
+
if (req.skipSave || !(req.submission || req.body) || (req.method !== 'POST' && req.method !== 'PUT')) {
|
|
280
281
|
debug('Skipping save action');
|
|
281
282
|
return next();
|
|
282
283
|
}
|
|
@@ -9,7 +9,6 @@ export declare class Database implements ServerDB {
|
|
|
9
9
|
currentCollection: Collection<Document> | null;
|
|
10
10
|
defaultCollection: Collection<Document> | null;
|
|
11
11
|
prefix: string;
|
|
12
|
-
authQuery: any;
|
|
13
12
|
constructor(config: DBConfig);
|
|
14
13
|
ObjectId(id: any): any;
|
|
15
14
|
collectionName(name: string): string;
|
|
@@ -23,7 +22,6 @@ export declare class Database implements ServerDB {
|
|
|
23
22
|
save(collectionName: string, item: any): Promise<any | null>;
|
|
24
23
|
saveOne(collectionName: string, item: any): Promise<any>;
|
|
25
24
|
load(collectionName: string, dbQuery?: {}): Promise<any | null>;
|
|
26
|
-
indexAuth(query: any): void;
|
|
27
25
|
getQueryValue(name: string, value: string, selector: string): string | boolean | Date | null;
|
|
28
26
|
/**
|
|
29
27
|
* Converts the url query to query parameters.
|
|
@@ -30,7 +30,6 @@ class Database {
|
|
|
30
30
|
constructor(config) {
|
|
31
31
|
this.config = config;
|
|
32
32
|
this.prefix = '';
|
|
33
|
-
this.authQuery = null;
|
|
34
33
|
this.db = null;
|
|
35
34
|
this.client = null; // Add this line
|
|
36
35
|
this.currentCollectionName = 'submissions';
|
|
@@ -165,10 +164,6 @@ class Database {
|
|
|
165
164
|
return item;
|
|
166
165
|
});
|
|
167
166
|
}
|
|
168
|
-
// Provides a suplemental query for authentication purposes.
|
|
169
|
-
indexAuth(query) {
|
|
170
|
-
this.authQuery = query || null;
|
|
171
|
-
}
|
|
172
167
|
getQueryValue(name, value, selector) {
|
|
173
168
|
if (name === 'created' || name === 'modified') {
|
|
174
169
|
return new Date(value);
|
|
@@ -267,10 +262,6 @@ class Database {
|
|
|
267
262
|
return;
|
|
268
263
|
}
|
|
269
264
|
});
|
|
270
|
-
// If an authQuery is provided, merge it in.
|
|
271
|
-
if (this.authQuery && (0, lodash_1.isPlainObject)(this.authQuery)) {
|
|
272
|
-
return (0, lodash_1.merge)(dbQuery, this.authQuery);
|
|
273
|
-
}
|
|
274
265
|
// Return the dbQuery.
|
|
275
266
|
return dbQuery;
|
|
276
267
|
}
|
|
@@ -434,8 +425,8 @@ class Database {
|
|
|
434
425
|
*/
|
|
435
426
|
indexQuery(urlQuery) {
|
|
436
427
|
let skip = 0, limit = 10;
|
|
437
|
-
limit = urlQuery.limit || 10;
|
|
438
|
-
skip = urlQuery.skip || 0;
|
|
428
|
+
limit = parseInt(urlQuery.limit) || 10;
|
|
429
|
+
skip = parseInt(urlQuery.skip) || 0;
|
|
439
430
|
const sort = urlQuery.sort || { created: -1 };
|
|
440
431
|
const includeDeleted = urlQuery.includeDeleted || false;
|
|
441
432
|
let project = {};
|
|
@@ -595,7 +586,12 @@ class Database {
|
|
|
595
586
|
if (!collection) {
|
|
596
587
|
return [];
|
|
597
588
|
}
|
|
598
|
-
return yield collection.find(this.query(form, dbQuery, includeDeleted))
|
|
589
|
+
return yield collection.find(this.query(form, dbQuery, includeDeleted))
|
|
590
|
+
.limit(parseInt(limit.toString()))
|
|
591
|
+
.skip(parseInt(skip.toString()))
|
|
592
|
+
.sort(sort)
|
|
593
|
+
.project(select)
|
|
594
|
+
.toArray();
|
|
599
595
|
}
|
|
600
596
|
catch (err) {
|
|
601
597
|
error(err.message);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/appserver",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0-rc.2",
|
|
4
4
|
"description": "A highly performant and extensible Application Server for Form.io Multi-Tenant Deployments.",
|
|
5
5
|
"main": "lib/server.js",
|
|
6
6
|
"types": "lib/server.d.ts",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
],
|
|
34
34
|
"homepage": "https://github.com/formio/appserver#readme",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@formio/appserver-core": "^2.
|
|
36
|
+
"@formio/appserver-core": "^2.12.0-rc.2",
|
|
37
37
|
"@formio/core": "2.5.1-dev.291.6557e4e",
|
|
38
38
|
"async": "^3.2.6",
|
|
39
39
|
"bcryptjs": "^3.0.3",
|
|
40
40
|
"debug": "^4.4.3",
|
|
41
|
-
"dotenv": "^17.2.
|
|
41
|
+
"dotenv": "^17.2.4",
|
|
42
42
|
"express": "^5.2.1",
|
|
43
43
|
"jsonwebtoken": "^9.0.3",
|
|
44
44
|
"lodash": "^4.17.23",
|
|
45
|
-
"mongodb": "^7.
|
|
45
|
+
"mongodb": "^7.1.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/async": "^3.2.25",
|