@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.
- package/dist/scopes/filter.js +10 -13
- package/dist/utils/constants/index.d.ts +2 -1
- package/dist/utils/constants/index.js +1 -0
- package/dist/utils/validations/validators/index.js +7 -0
- package/package.json +2 -2
- package/src/scopes/filter.ts +10 -13
- package/src/utils/constants/index.ts +1 -0
- package/src/utils/validations/validators/index.ts +7 -0
package/dist/scopes/filter.js
CHANGED
|
@@ -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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
package/src/scopes/filter.ts
CHANGED
|
@@ -104,19 +104,16 @@ export const customFieldsSortScope = (
|
|
|
104
104
|
const includes = Object.entries(sort).map(([key]) =>
|
|
105
105
|
([
|
|
106
106
|
Sequelize.literal(`(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
|
@@ -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
|
};
|