not-node 6.5.9 → 6.5.11
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/package.json
CHANGED
|
@@ -13,8 +13,13 @@ const extractors = Object.freeze({
|
|
|
13
13
|
[ACTION_DATA_TYPES.SORTER]: (result, req, thisSchema) => {
|
|
14
14
|
result.sorter = notFilter.sorter.process(req, thisSchema);
|
|
15
15
|
},
|
|
16
|
-
[ACTION_DATA_TYPES.SEARCH]: (result, req, thisSchema) => {
|
|
17
|
-
result.search = notFilter.search.process(
|
|
16
|
+
[ACTION_DATA_TYPES.SEARCH]: (result, req, thisSchema, formOptions) => {
|
|
17
|
+
result.search = notFilter.search.process(
|
|
18
|
+
req,
|
|
19
|
+
thisSchema,
|
|
20
|
+
{},
|
|
21
|
+
formOptions
|
|
22
|
+
);
|
|
18
23
|
},
|
|
19
24
|
[ACTION_DATA_TYPES.FILTER]: (result, req, thisSchema) => {
|
|
20
25
|
result.filter = notFilter.filter.process(req, thisSchema);
|
|
@@ -44,13 +49,15 @@ module.exports = (form, req) => {
|
|
|
44
49
|
}
|
|
45
50
|
if (thisSchema) {
|
|
46
51
|
let result = {};
|
|
52
|
+
const formOptions = form.getExtractorsOptions();
|
|
47
53
|
const routeActionDataTypes = form.getActionDataDataTypes(req);
|
|
48
54
|
Object.values(ACTION_DATA_TYPES).forEach((dataType) => {
|
|
49
55
|
if (
|
|
50
56
|
routeActionDataTypes.includes(dataType) &&
|
|
57
|
+
// @ts-ignore
|
|
51
58
|
Object.hasOwn(extractors, dataType)
|
|
52
59
|
) {
|
|
53
|
-
extractors[dataType](result, req, thisSchema);
|
|
60
|
+
extractors[dataType](result, req, thisSchema, formOptions);
|
|
54
61
|
}
|
|
55
62
|
});
|
|
56
63
|
|
package/src/form/form.js
CHANGED
|
@@ -13,6 +13,7 @@ module.exports = class ListAndCountAction {
|
|
|
13
13
|
const result = await logic
|
|
14
14
|
.getModel()
|
|
15
15
|
.listAndCount(skip, size, sorter, filter, search, populate);
|
|
16
|
+
result.list = result.list.map((item) => item.toObject());
|
|
16
17
|
logic.logAction(actionName, identity, {});
|
|
17
18
|
return result;
|
|
18
19
|
} catch (e) {
|
package/src/model/default.js
CHANGED
|
@@ -283,6 +283,14 @@ function listAllAndPopulate(populate) {
|
|
|
283
283
|
return query.exec();
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
const getPageNumber = (skip, size) => {
|
|
287
|
+
if (skip === 0) {
|
|
288
|
+
return 0;
|
|
289
|
+
} else {
|
|
290
|
+
return Math.floor(skip / size); //
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
|
|
286
294
|
/**
|
|
287
295
|
* List record in collection and populates, with count of total founded records
|
|
288
296
|
* By default sorts by _id in DESC
|
|
@@ -305,11 +313,12 @@ async function listAndCount(skip, size, sorter, filter, search, populate = []) {
|
|
|
305
313
|
),
|
|
306
314
|
countQuery = this.countWithFilter(search || filter);
|
|
307
315
|
const [list, count] = await Promise.all([listQuery, countQuery]);
|
|
316
|
+
|
|
308
317
|
return {
|
|
309
318
|
list,
|
|
310
319
|
skip,
|
|
311
320
|
count,
|
|
312
|
-
page:
|
|
321
|
+
page: getPageNumber(skip, size),
|
|
313
322
|
pages: Math.ceil(count / size),
|
|
314
323
|
};
|
|
315
324
|
}
|
package/src/types.js
CHANGED
package/test/model/default.js
CHANGED
|
@@ -907,7 +907,7 @@ module.exports = ({
|
|
|
907
907
|
expect(res.list).to.be.deep.equal([1, 2, 3, 4]);
|
|
908
908
|
expect(res.count).to.be.equal(24);
|
|
909
909
|
expect(res.skip).to.be.equal(skip);
|
|
910
|
-
expect(res.page).to.be.equal(
|
|
910
|
+
expect(res.page).to.be.equal(1);
|
|
911
911
|
expect(res.pages).to.be.equal(2);
|
|
912
912
|
});
|
|
913
913
|
});
|
package/.eslintrc.json
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"parserOptions": {
|
|
3
|
-
"requireConfigFile": false,
|
|
4
|
-
"sourceType": "module",
|
|
5
|
-
"allowImportExportEverywhere": false,
|
|
6
|
-
"ecmaFeatures": {
|
|
7
|
-
"globalReturn": false
|
|
8
|
-
},
|
|
9
|
-
"ecmaVersion": "latest"
|
|
10
|
-
},
|
|
11
|
-
"env": {
|
|
12
|
-
"es6": true,
|
|
13
|
-
"node": true,
|
|
14
|
-
"mongo": true,
|
|
15
|
-
"mocha": true
|
|
16
|
-
},
|
|
17
|
-
"extends": [
|
|
18
|
-
"eslint:recommended",
|
|
19
|
-
"plugin:node/recommended",
|
|
20
|
-
"plugin:sonarjs/recommended"
|
|
21
|
-
],
|
|
22
|
-
"rules": {
|
|
23
|
-
"node/exports-style": ["error", "module.exports"],
|
|
24
|
-
"node/file-extension-in-import": ["error", "always"],
|
|
25
|
-
"node/prefer-global/buffer": ["error", "always"],
|
|
26
|
-
"node/prefer-global/console": ["error", "always"],
|
|
27
|
-
"node/prefer-global/process": ["error", "always"],
|
|
28
|
-
"node/prefer-global/url-search-params": ["error", "always"],
|
|
29
|
-
"node/prefer-global/url": ["error", "always"],
|
|
30
|
-
"node/no-unpublished-require": "warn",
|
|
31
|
-
"indent": ["error", 4, { "SwitchCase": 1 }],
|
|
32
|
-
"linebreak-style": ["error", "unix"],
|
|
33
|
-
"semi": ["error", "always"],
|
|
34
|
-
"no-useless-escape": [0]
|
|
35
|
-
}
|
|
36
|
-
}
|