@autofleet/sadot 0.6.5 → 0.6.6

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.
@@ -30,7 +30,7 @@ export declare const customFieldsSortScope: (name: string) => (sort: CustomField
30
30
  order?: undefined;
31
31
  } | {
32
32
  attributes: {
33
- include: import("sequelize/types/utils").Literal[];
33
+ include: (string | import("sequelize/types/utils").Literal)[][];
34
34
  };
35
35
  order: import("sequelize/types/utils").Literal[];
36
36
  };
@@ -73,17 +73,24 @@ const customFieldsSortScope = (name) => (sort) => {
73
73
  if (!sort || sort.length === 0) {
74
74
  return {};
75
75
  }
76
- console.log('sort', sort);
77
- console.log('name', name);
78
- console.log('Object.entries(sort)', Object.entries(sort));
79
- const includes = Object.entries(sort).map(([key]) => sequelize_typescript_1.Sequelize.literal(`(select CustomFieldAggregation.custom_fields->>'${key}'
80
- from (SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields
81
- FROM custom_field_values AS cv
82
- INNER JOIN custom_field_definitions AS cd
83
- ON cv.custom_field_definition_id = cd.id AND cd.model_type = '${name}'
84
- where cv.model_id = "${name}"."id"
85
- GROUP BY cv.model_id) AS CustomFieldAggregation) as "customFields.${key}"`));
86
- const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields.${key}" ${value}`));
76
+ const includes = Object.entries(sort).map(([key]) => ([
77
+ sequelize_typescript_1.Sequelize.literal(`(
78
+ SELECT custom_fields->>'${key}'
79
+ FROM (
80
+ SELECT
81
+ cv.model_id,
82
+ jsonb_object_agg(cd.name, cv.value) AS custom_fields
83
+ FROM custom_field_values AS cv
84
+ INNER JOIN custom_field_definitions AS cd
85
+ ON cv.custom_field_definition_id = cd.id
86
+ AND cd.model_type = '${name}'
87
+ WHERE cv.model_id = "${name}"."id"
88
+ GROUP BY cv.model_id
89
+ ) AS CustomFieldAggregation
90
+ )`),
91
+ `customFields_${key}`,
92
+ ]));
93
+ const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields_${key}" ${value}`));
87
94
  return {
88
95
  attributes: {
89
96
  include: includes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -101,20 +101,26 @@ export const customFieldsSortScope = (
101
101
  if (!sort || sort.length === 0) {
102
102
  return {};
103
103
  }
104
-
105
- console.log('sort', sort);
106
- console.log('name', name);
107
- console.log('Object.entries(sort)', Object.entries(sort));
108
104
  const includes = Object.entries(sort).map(([key]) =>
109
- Sequelize.literal(`(select CustomFieldAggregation.custom_fields->>'${key}'
110
- from (SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields
111
- FROM custom_field_values AS cv
112
- INNER JOIN custom_field_definitions AS cd
113
- ON cv.custom_field_definition_id = cd.id AND cd.model_type = '${name}'
114
- where cv.model_id = "${name}"."id"
115
- GROUP BY cv.model_id) AS CustomFieldAggregation) as "customFields.${key}"`));
116
- const orders = Object.entries(sort).map(([key, value]) => Sequelize.literal(`"customFields.${key}" ${value}`));
105
+ ([
106
+ Sequelize.literal(`(
107
+ SELECT custom_fields->>'${key}'
108
+ FROM (
109
+ SELECT
110
+ cv.model_id,
111
+ jsonb_object_agg(cd.name, cv.value) AS custom_fields
112
+ FROM custom_field_values AS cv
113
+ INNER JOIN custom_field_definitions AS cd
114
+ ON cv.custom_field_definition_id = cd.id
115
+ AND cd.model_type = '${name}'
116
+ WHERE cv.model_id = "${name}"."id"
117
+ GROUP BY cv.model_id
118
+ ) AS CustomFieldAggregation
119
+ )`),
120
+ `customFields_${key}`,
121
+ ]));
117
122
 
123
+ const orders = Object.entries(sort).map(([key, value]) => Sequelize.literal(`"customFields_${key}" ${value}`));
118
124
  return {
119
125
  attributes: {
120
126
  include: includes,