@autofleet/sadot 0.6.3-beta.1 → 0.6.3
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/dist/scopes/filter.js +6 -3
- package/package.json +3 -3
- package/src/scopes/filter.ts +6 -3
package/dist/scopes/filter.js
CHANGED
|
@@ -57,17 +57,20 @@ const customFieldsSortScope = (name) => (sort) => {
|
|
|
57
57
|
if (!sort || sort.length === 0) {
|
|
58
58
|
return {};
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
console.log('sort', sort);
|
|
61
|
+
console.log('name', name);
|
|
62
|
+
console.log('Object.entries(sort)', Object.entries(sort));
|
|
63
|
+
const includes = Object.entries(sort).map(([key]) => sequelize_typescript_1.Sequelize.literal(`(select CustomFieldAggregation.custom_fields->>'${key}'
|
|
61
64
|
from (SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields
|
|
62
65
|
FROM custom_field_values AS cv
|
|
63
66
|
INNER JOIN custom_field_definitions AS cd
|
|
64
|
-
ON cv.custom_field_definition_id = cd.id AND cd.model_type = '
|
|
67
|
+
ON cv.custom_field_definition_id = cd.id AND cd.model_type = '${name}'
|
|
65
68
|
where cv.model_id = "${name}"."id"
|
|
66
69
|
GROUP BY cv.model_id) AS CustomFieldAggregation) as "customFields.${key}"`));
|
|
67
70
|
const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields.${key}" ${value}`));
|
|
68
71
|
return {
|
|
69
72
|
attributes: {
|
|
70
|
-
include:
|
|
73
|
+
include: includes,
|
|
71
74
|
},
|
|
72
75
|
order: orders,
|
|
73
76
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/sadot",
|
|
3
|
-
"version": "0.6.3
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"linter": "./node_modules/.bin/eslint .",
|
|
10
10
|
"test": "jest --forceExit --runInBand",
|
|
11
11
|
"coverage": "jest --coverage --forceExit --runInBand && rm -rf ./coverage",
|
|
12
|
-
"build-to-local-repo": "npm run build && cp -r dist/*
|
|
12
|
+
"build-to-local-repo": "npm run build && cp -r dist/* ../$REPO/node_modules/$npm_package_name/dist",
|
|
13
13
|
"dev": "nodemon",
|
|
14
14
|
"watch": "npm-watch build-to-local-repo"
|
|
15
15
|
},
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@autofleet/common-types": "^1.7.
|
|
32
|
+
"@autofleet/common-types": "^1.7.42",
|
|
33
33
|
"@autofleet/errors": "^1.0.10",
|
|
34
34
|
"@autofleet/events": "^2.0.0",
|
|
35
35
|
"@autofleet/logger": "^2.0.5",
|
package/src/scopes/filter.ts
CHANGED
|
@@ -83,19 +83,22 @@ export const customFieldsSortScope = (
|
|
|
83
83
|
return {};
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
console.log('sort', sort);
|
|
87
|
+
console.log('name', name);
|
|
88
|
+
console.log('Object.entries(sort)', Object.entries(sort));
|
|
89
|
+
const includes = Object.entries(sort).map(([key]) =>
|
|
87
90
|
Sequelize.literal(`(select CustomFieldAggregation.custom_fields->>'${key}'
|
|
88
91
|
from (SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields
|
|
89
92
|
FROM custom_field_values AS cv
|
|
90
93
|
INNER JOIN custom_field_definitions AS cd
|
|
91
|
-
ON cv.custom_field_definition_id = cd.id AND cd.model_type = '
|
|
94
|
+
ON cv.custom_field_definition_id = cd.id AND cd.model_type = '${name}'
|
|
92
95
|
where cv.model_id = "${name}"."id"
|
|
93
96
|
GROUP BY cv.model_id) AS CustomFieldAggregation) as "customFields.${key}"`));
|
|
94
97
|
const orders = Object.entries(sort).map(([key, value]) => Sequelize.literal(`"customFields.${key}" ${value}`));
|
|
95
98
|
|
|
96
99
|
return {
|
|
97
100
|
attributes: {
|
|
98
|
-
include:
|
|
101
|
+
include: includes,
|
|
99
102
|
},
|
|
100
103
|
order: orders,
|
|
101
104
|
};
|