@autofleet/sadot 0.6.6 → 0.6.7

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.
@@ -75,19 +75,16 @@ const customFieldsSortScope = (name) => (sort) => {
75
75
  }
76
76
  const includes = Object.entries(sort).map(([key]) => ([
77
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
- )`),
78
+ SELECT value
79
+ FROM (SELECT cv.model_id, cv.value
80
+ FROM custom_field_values AS cv INNER JOIN custom_field_definitions AS cd
81
+ ON cv.custom_field_definition_id = cd.id
82
+ AND cd.model_type = '${name}'
83
+ WHERE cv.model_id = "${name}"."id"
84
+ AND cd.name = '${key}'
85
+ ) AS CustomFieldAggregation
86
+ )
87
+ `),
91
88
  `customFields_${key}`,
92
89
  ]));
93
90
  const orders = Object.entries(sort).map(([key, value]) => sequelize_typescript_1.Sequelize.literal(`"customFields_${key}" ${value}`));
@@ -11,7 +11,8 @@ export declare enum CustomFieldDefinitionType {
11
11
  TEXT = "text",
12
12
  IMAGE = "image",
13
13
  SELECT = "select",
14
- STATUS = "status"
14
+ STATUS = "status",
15
+ FILE = "file"
15
16
  }
16
17
  export {
17
18
  /** @deprecated Use the value from `@autofleet/common-types` instead */
@@ -18,4 +18,5 @@ var CustomFieldDefinitionType;
18
18
  CustomFieldDefinitionType["IMAGE"] = "image";
19
19
  CustomFieldDefinitionType["SELECT"] = "select";
20
20
  CustomFieldDefinitionType["STATUS"] = "status";
21
+ CustomFieldDefinitionType["FILE"] = "file";
21
22
  })(CustomFieldDefinitionType || (exports.CustomFieldDefinitionType = CustomFieldDefinitionType = {}));
@@ -30,4 +30,11 @@ exports.validators = {
30
30
  [constants_1.CustomFieldDefinitionType.IMAGE]: (value) => (!joi_1.default.array().min(1).unique()
31
31
  .items(joi_1.default.string().uri())
32
32
  .validate(value).error),
33
+ [constants_1.CustomFieldDefinitionType.FILE]: (value) => (!joi_1.default.array().min(1).unique().items(joi_1.default.object({
34
+ name: joi_1.default.string().required(),
35
+ type: joi_1.default.string(),
36
+ size: joi_1.default.string(),
37
+ addedBy: joi_1.default.string().uuid(),
38
+ }))
39
+ .validate(value).error),
33
40
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -60,4 +60,4 @@
60
60
  },
61
61
  "author": "Autofleet",
62
62
  "license": "ISC"
63
- }
63
+ }
@@ -104,19 +104,16 @@ export const customFieldsSortScope = (
104
104
  const includes = Object.entries(sort).map(([key]) =>
105
105
  ([
106
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
- )`),
107
+ SELECT value
108
+ FROM (SELECT cv.model_id, cv.value
109
+ FROM custom_field_values AS cv INNER JOIN custom_field_definitions AS cd
110
+ ON cv.custom_field_definition_id = cd.id
111
+ AND cd.model_type = '${name}'
112
+ WHERE cv.model_id = "${name}"."id"
113
+ AND cd.name = '${key}'
114
+ ) AS CustomFieldAggregation
115
+ )
116
+ `),
120
117
  `customFields_${key}`,
121
118
  ]));
122
119
 
@@ -16,6 +16,7 @@ export enum CustomFieldDefinitionType {
16
16
  IMAGE = 'image',
17
17
  SELECT = 'select',
18
18
  STATUS = 'status',
19
+ FILE = 'file',
19
20
  }
20
21
 
21
22
  export {
@@ -28,4 +28,11 @@ export const validators: Validators = {
28
28
  [CustomFieldDefinitionType.IMAGE]: (value) => (!Joi.array().min(1).unique()
29
29
  .items(Joi.string().uri())
30
30
  .validate(value).error),
31
+ [CustomFieldDefinitionType.FILE]: (value) => (!Joi.array().min(1).unique().items(Joi.object({
32
+ name: Joi.string().required(),
33
+ type: Joi.string(),
34
+ size: Joi.string(),
35
+ addedBy: Joi.string().uuid(),
36
+ }))
37
+ .validate(value).error),
31
38
  };