@formio/appserver 2.11.0 → 2.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/modules/mongodb/db.d.ts +8 -2
- package/lib/modules/mongodb/db.js +43 -28
- package/package.json +5 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Collection, Document, Db, MongoClient, FindOneOptions } from 'mongodb';
|
|
2
2
|
import { Component, Submission } from '@formio/core';
|
|
3
|
-
import { ServerDB, DBConfig, AppServerForm, DatabaseIndexResponse } from '@formio/appserver-core';
|
|
3
|
+
import { ServerDB, DBConfig, AppServerForm, DatabaseIndexResponse, IndexQuery } from '@formio/appserver-core';
|
|
4
4
|
export declare class Database implements ServerDB {
|
|
5
5
|
config: DBConfig;
|
|
6
6
|
db: Db | null;
|
|
@@ -61,12 +61,18 @@ export declare class Database implements ServerDB {
|
|
|
61
61
|
* @returns
|
|
62
62
|
*/
|
|
63
63
|
removeIndexes(form: AppServerForm, indexes: string[]): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Get the index query from the url query.
|
|
66
|
+
* @param urlQuery
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
indexQuery(urlQuery: any): IndexQuery;
|
|
64
70
|
/**
|
|
65
71
|
* Fetch a list of submissions from a table/collection.
|
|
66
72
|
* @param {*} table
|
|
67
73
|
* @param {*} query
|
|
68
74
|
*/
|
|
69
|
-
index(form: AppServerForm,
|
|
75
|
+
index(form: AppServerForm, query: IndexQuery, collection?: Collection<Document> | null): Promise<DatabaseIndexResponse<Submission>>;
|
|
70
76
|
/**
|
|
71
77
|
* Perform a count of the amount of documents within a collection.
|
|
72
78
|
* @param form
|
|
@@ -427,40 +427,55 @@ class Database {
|
|
|
427
427
|
}
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
|
+
/**
|
|
431
|
+
* Get the index query from the url query.
|
|
432
|
+
* @param urlQuery
|
|
433
|
+
* @returns
|
|
434
|
+
*/
|
|
435
|
+
indexQuery(urlQuery) {
|
|
436
|
+
let skip = 0, limit = 10;
|
|
437
|
+
limit = urlQuery.limit || 10;
|
|
438
|
+
skip = urlQuery.skip || 0;
|
|
439
|
+
const sort = urlQuery.sort || { created: -1 };
|
|
440
|
+
const includeDeleted = urlQuery.includeDeleted || false;
|
|
441
|
+
let project = {};
|
|
442
|
+
if (urlQuery.select) {
|
|
443
|
+
if (typeof urlQuery.select === 'string') {
|
|
444
|
+
const fields = urlQuery.select.split(',');
|
|
445
|
+
fields.forEach((field) => {
|
|
446
|
+
project[field] = true;
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
Object.keys(urlQuery.select).forEach((field) => {
|
|
451
|
+
project[field] = true;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
delete urlQuery.limit;
|
|
456
|
+
delete urlQuery.skip;
|
|
457
|
+
delete urlQuery.sort;
|
|
458
|
+
delete urlQuery.select;
|
|
459
|
+
delete urlQuery.includeDeleted;
|
|
460
|
+
return {
|
|
461
|
+
limit,
|
|
462
|
+
skip,
|
|
463
|
+
sort,
|
|
464
|
+
includeDeleted,
|
|
465
|
+
project,
|
|
466
|
+
dbQuery: this.dbQuery(urlQuery)
|
|
467
|
+
};
|
|
468
|
+
}
|
|
430
469
|
/**
|
|
431
470
|
* Fetch a list of submissions from a table/collection.
|
|
432
471
|
* @param {*} table
|
|
433
472
|
* @param {*} query
|
|
434
473
|
*/
|
|
435
|
-
index(form_1) {
|
|
436
|
-
return __awaiter(this, arguments, void 0, function* (form,
|
|
437
|
-
let items = [],
|
|
474
|
+
index(form_1, query_1) {
|
|
475
|
+
return __awaiter(this, arguments, void 0, function* (form, query, collection = null) {
|
|
476
|
+
let items = [], count = 0;
|
|
477
|
+
const { limit, skip, sort, includeDeleted, project, dbQuery } = query;
|
|
438
478
|
try {
|
|
439
|
-
limit = urlQuery.limit || 10;
|
|
440
|
-
skip = urlQuery.skip || 0;
|
|
441
|
-
const sort = urlQuery.sort || { created: -1 };
|
|
442
|
-
const includeDeleted = urlQuery.includeDeleted || false;
|
|
443
|
-
let project = {};
|
|
444
|
-
if (urlQuery.select) {
|
|
445
|
-
if (typeof urlQuery.select === 'string') {
|
|
446
|
-
const fields = urlQuery.select.split(',');
|
|
447
|
-
fields.forEach((field) => {
|
|
448
|
-
project[field] = true;
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
else {
|
|
452
|
-
Object.keys(urlQuery.select).forEach((field) => {
|
|
453
|
-
project[field] = true;
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
delete urlQuery.limit;
|
|
458
|
-
delete urlQuery.skip;
|
|
459
|
-
delete urlQuery.sort;
|
|
460
|
-
delete urlQuery.select;
|
|
461
|
-
delete urlQuery.includeDeleted;
|
|
462
|
-
debug('db.index()', urlQuery);
|
|
463
|
-
const dbQuery = this.dbQuery(urlQuery);
|
|
464
479
|
items = (yield this.find(form, dbQuery, limit, skip, sort, project, collection, includeDeleted)) || [];
|
|
465
480
|
count = yield this.count(form, dbQuery, collection, includeDeleted);
|
|
466
481
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formio/appserver",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.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",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"clean": "rm -rf lib",
|
|
12
12
|
"build": "npm run clean && tsc",
|
|
13
|
+
"build:lib": "npm run clean && tsc; true",
|
|
13
14
|
"test": "mocha",
|
|
15
|
+
"dev": "tsc --watch --preserveWatchOutput",
|
|
14
16
|
"prepack": "npm run build"
|
|
15
17
|
},
|
|
16
18
|
"repository": {
|
|
@@ -31,7 +33,7 @@
|
|
|
31
33
|
],
|
|
32
34
|
"homepage": "https://github.com/formio/appserver#readme",
|
|
33
35
|
"dependencies": {
|
|
34
|
-
"@formio/appserver-core": "^2.11.
|
|
36
|
+
"@formio/appserver-core": "^2.11.2",
|
|
35
37
|
"@formio/core": "2.5.1-dev.291.6557e4e",
|
|
36
38
|
"async": "^3.2.6",
|
|
37
39
|
"bcryptjs": "^3.0.3",
|
|
@@ -50,7 +52,7 @@
|
|
|
50
52
|
"@types/jsonwebtoken": "^9.0.10",
|
|
51
53
|
"@types/lodash": "^4.17.23",
|
|
52
54
|
"@types/mocha": "^10.0.10",
|
|
53
|
-
"@types/node": "^25.
|
|
55
|
+
"@types/node": "^25.2.3",
|
|
54
56
|
"chai": "^6.2.2",
|
|
55
57
|
"cross-env": "^10.1.0",
|
|
56
58
|
"mocha": "^11.7.5",
|