@autofleet/sadot 0.6.3-beta.2 → 0.6.4-beta.1

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.
@@ -26,7 +26,7 @@ export declare const customFieldsSortScope: (name: string) => (sort: CustomField
26
26
  order?: undefined;
27
27
  } | {
28
28
  attributes: {
29
- include: import("sequelize/types/utils").Literal[];
29
+ include: (string | import("sequelize/types/utils").Literal)[][];
30
30
  };
31
31
  order: import("sequelize/types/utils").Literal[];
32
32
  };
@@ -57,17 +57,24 @@ const customFieldsSortScope = (name) => (sort) => {
57
57
  if (!sort || sort.length === 0) {
58
58
  return {};
59
59
  }
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}'
64
- from (SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields
65
- FROM custom_field_values AS cv
66
- INNER JOIN custom_field_definitions AS cd
67
- ON cv.custom_field_definition_id = cd.id AND cd.model_type = '${name}'
68
- where cv.model_id = "${name}"."id"
69
- GROUP BY cv.model_id) AS CustomFieldAggregation) as "customFields.${key}"`));
70
- const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields.${key}" ${value}`));
60
+ const includes = Object.entries(sort).map(([key]) => ([
61
+ sequelize_typescript_1.Sequelize.literal(`(
62
+ SELECT custom_fields->>'${key}'
63
+ FROM (
64
+ SELECT
65
+ cv.model_id,
66
+ jsonb_object_agg(cd.name, cv.value) AS custom_fields
67
+ FROM custom_field_values AS cv
68
+ INNER JOIN custom_field_definitions AS cd
69
+ ON cv.custom_field_definition_id = cd.id
70
+ AND cd.model_type = '${name}'
71
+ WHERE cv.model_id = "${name}"."id"
72
+ GROUP BY cv.model_id
73
+ ) AS CustomFieldAggregation
74
+ )`),
75
+ `customFields_${key}`,
76
+ ]));
77
+ const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields_${key}" ${value}`));
71
78
  return {
72
79
  attributes: {
73
80
  include: includes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.6.3-beta.2",
3
+ "version": "0.6.4-beta.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -82,20 +82,26 @@ export const customFieldsSortScope = (
82
82
  if (!sort || sort.length === 0) {
83
83
  return {};
84
84
  }
85
-
86
- console.log('sort', sort);
87
- console.log('name', name);
88
- console.log('Object.entries(sort)', Object.entries(sort));
89
85
  const includes = Object.entries(sort).map(([key]) =>
90
- Sequelize.literal(`(select CustomFieldAggregation.custom_fields->>'${key}'
91
- from (SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields
92
- FROM custom_field_values AS cv
93
- INNER JOIN custom_field_definitions AS cd
94
- ON cv.custom_field_definition_id = cd.id AND cd.model_type = '${name}'
95
- where cv.model_id = "${name}"."id"
96
- GROUP BY cv.model_id) AS CustomFieldAggregation) as "customFields.${key}"`));
97
- const orders = Object.entries(sort).map(([key, value]) => Sequelize.literal(`"customFields.${key}" ${value}`));
86
+ ([
87
+ Sequelize.literal(`(
88
+ SELECT custom_fields->>'${key}'
89
+ FROM (
90
+ SELECT
91
+ cv.model_id,
92
+ jsonb_object_agg(cd.name, cv.value) AS custom_fields
93
+ FROM custom_field_values AS cv
94
+ INNER JOIN custom_field_definitions AS cd
95
+ ON cv.custom_field_definition_id = cd.id
96
+ AND cd.model_type = '${name}'
97
+ WHERE cv.model_id = "${name}"."id"
98
+ GROUP BY cv.model_id
99
+ ) AS CustomFieldAggregation
100
+ )`),
101
+ `customFields_${key}`,
102
+ ]));
98
103
 
104
+ const orders = Object.entries(sort).map(([key, value]) => Sequelize.literal(`"customFields_${key}" ${value}`));
99
105
  return {
100
106
  attributes: {
101
107
  include: includes,