@autofleet/sadot 0.4.1 → 0.4.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/{src/scopes → scopes}/filter.js +13 -2
- package/package.json +1 -1
- package/src/scopes/filter.ts +14 -2
- package/tsconfig.json +3 -0
- package/dist/jest.config.d.ts +0 -12
- /package/dist/{src/api → api}/index.d.ts +0 -0
- /package/dist/{src/api → api}/index.js +0 -0
- /package/dist/{src/api → api}/v1/definition/index.d.ts +0 -0
- /package/dist/{src/api → api}/v1/definition/index.js +0 -0
- /package/dist/{src/api → api}/v1/definition/validations.d.ts +0 -0
- /package/dist/{src/api → api}/v1/definition/validations.js +0 -0
- /package/dist/{src/api → api}/v1/errors.d.ts +0 -0
- /package/dist/{src/api → api}/v1/errors.js +0 -0
- /package/dist/{src/api → api}/v1/index.d.ts +0 -0
- /package/dist/{src/api → api}/v1/index.js +0 -0
- /package/dist/{src/errors → errors}/index.d.ts +0 -0
- /package/dist/{src/errors → errors}/index.js +0 -0
- /package/dist/{src/events → events}/index.d.ts +0 -0
- /package/dist/{src/events → events}/index.js +0 -0
- /package/dist/{src/hooks → hooks}/create.d.ts +0 -0
- /package/dist/{src/hooks → hooks}/create.js +0 -0
- /package/dist/{src/hooks → hooks}/enrich.d.ts +0 -0
- /package/dist/{src/hooks → hooks}/enrich.js +0 -0
- /package/dist/{src/hooks → hooks}/find.d.ts +0 -0
- /package/dist/{src/hooks → hooks}/find.js +0 -0
- /package/dist/{src/hooks → hooks}/index.d.ts +0 -0
- /package/dist/{src/hooks → hooks}/index.js +0 -0
- /package/dist/{src/hooks → hooks}/update.d.ts +0 -0
- /package/dist/{src/hooks → hooks}/update.js +0 -0
- /package/dist/{src/hooks → hooks}/workaround.d.ts +0 -0
- /package/dist/{src/hooks → hooks}/workaround.js +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/models → models}/CustomFieldDefinition.d.ts +0 -0
- /package/dist/{src/models → models}/CustomFieldDefinition.js +0 -0
- /package/dist/{src/models → models}/CustomFieldValue.d.ts +0 -0
- /package/dist/{src/models → models}/CustomFieldValue.js +0 -0
- /package/dist/{src/models → models}/index.d.ts +0 -0
- /package/dist/{src/models → models}/index.js +0 -0
- /package/dist/{src/models → models}/tests/AssociatedTestModel.d.ts +0 -0
- /package/dist/{src/models → models}/tests/AssociatedTestModel.js +0 -0
- /package/dist/{src/models → models}/tests/TestModel.d.ts +0 -0
- /package/dist/{src/models → models}/tests/TestModel.js +0 -0
- /package/dist/{src/repository → repository}/definition.d.ts +0 -0
- /package/dist/{src/repository → repository}/definition.js +0 -0
- /package/dist/{src/repository → repository}/value.d.ts +0 -0
- /package/dist/{src/repository → repository}/value.js +0 -0
- /package/dist/{src/scopes → scopes}/filter.d.ts +0 -0
- /package/dist/{src/scopes → scopes}/index.d.ts +0 -0
- /package/dist/{src/scopes → scopes}/index.js +0 -0
- /package/dist/{src/tests → tests}/api/test-api.d.ts +0 -0
- /package/dist/{src/tests → tests}/api/test-api.js +0 -0
- /package/dist/{src/tests → tests}/helpers/database-config.d.ts +0 -0
- /package/dist/{src/tests → tests}/helpers/database-config.js +0 -0
- /package/dist/{src/tests → tests}/helpers/index.d.ts +0 -0
- /package/dist/{src/tests → tests}/helpers/index.js +0 -0
- /package/dist/{src/tests → tests}/mocks/definition.mock.d.ts +0 -0
- /package/dist/{src/tests → tests}/mocks/definition.mock.js +0 -0
- /package/dist/{src/tests → tests}/mocks/events.mock.d.ts +0 -0
- /package/dist/{src/tests → tests}/mocks/events.mock.js +0 -0
- /package/dist/{src/tests → tests}/mocks/testModel.d.ts +0 -0
- /package/dist/{src/tests → tests}/mocks/testModel.js +0 -0
- /package/dist/{src/types → types}/definition/index.d.ts +0 -0
- /package/dist/{src/types → types}/definition/index.js +0 -0
- /package/dist/{src/types → types}/index.d.ts +0 -0
- /package/dist/{src/types → types}/index.js +0 -0
- /package/dist/{src/types → types}/value/index.d.ts +0 -0
- /package/dist/{src/types → types}/value/index.js +0 -0
- /package/dist/{src/utils → utils}/constants/index.d.ts +0 -0
- /package/dist/{src/utils → utils}/constants/index.js +0 -0
- /package/dist/{src/utils → utils}/db/index.d.ts +0 -0
- /package/dist/{src/utils → utils}/db/index.js +0 -0
- /package/dist/{src/utils → utils}/init.d.ts +0 -0
- /package/dist/{src/utils → utils}/init.js +0 -0
- /package/dist/{src/utils → utils}/logger/index.d.ts +0 -0
- /package/dist/{src/utils → utils}/logger/index.js +0 -0
- /package/dist/{src/utils → utils}/validations/custom-fields.d.ts +0 -0
- /package/dist/{src/utils → utils}/validations/custom-fields.js +0 -0
- /package/dist/{src/utils → utils}/validations/custom.d.ts +0 -0
- /package/dist/{src/utils → utils}/validations/custom.js +0 -0
- /package/dist/{src/utils → utils}/validations/index.d.ts +0 -0
- /package/dist/{src/utils → utils}/validations/index.js +0 -0
- /package/dist/{src/utils → utils}/validations/type.d.ts +0 -0
- /package/dist/{src/utils → utils}/validations/type.js +0 -0
- /package/dist/{src/utils → utils}/validations/validators.d.ts +0 -0
- /package/dist/{src/utils → utils}/validations/validators.js +0 -0
|
@@ -13,16 +13,27 @@ const constants_1 = require("../utils/constants");
|
|
|
13
13
|
* @returns {Function} - A function that takes conditions and returns the Sequelize options object.
|
|
14
14
|
*/
|
|
15
15
|
const customFieldsFilterScope = (name) => (conditions) => {
|
|
16
|
+
if (!conditions || Object.keys(conditions).length === 0) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
16
19
|
// Build the WHERE clause for custom field filtering
|
|
17
|
-
const
|
|
20
|
+
const conditionsStrings = Object.entries(conditions)
|
|
18
21
|
.map(([key, value]) => {
|
|
19
22
|
if (Array.isArray(value)) {
|
|
23
|
+
if (value.length === 0) {
|
|
24
|
+
// if empty array, the condition is ignored
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
20
27
|
const values = value.map((v) => `'${v}'`).join(',');
|
|
21
28
|
return `custom_fields->>'${key}' IN (${values})`;
|
|
22
29
|
}
|
|
23
30
|
return `custom_fields->>'${key}' = '${value}'`;
|
|
24
31
|
})
|
|
25
|
-
.
|
|
32
|
+
.filter(Boolean);
|
|
33
|
+
if (conditionsStrings.length === 0) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
const customFieldConditions = conditionsStrings.join(' AND ');
|
|
26
37
|
const subQuery = `${'SELECT model_id FROM ('
|
|
27
38
|
+ 'SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields '
|
|
28
39
|
+ 'FROM custom_field_values AS cv '
|
package/package.json
CHANGED
package/src/scopes/filter.ts
CHANGED
|
@@ -29,18 +29,30 @@ export type CustomFieldFilterOptions = {
|
|
|
29
29
|
export const customFieldsFilterScope = (
|
|
30
30
|
name: string,
|
|
31
31
|
) => (conditions: Record<string, ConditionValue>): CustomFieldFilterOptions => {
|
|
32
|
+
if (!conditions || Object.keys(conditions).length === 0) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
32
35
|
// Build the WHERE clause for custom field filtering
|
|
33
|
-
const
|
|
36
|
+
const conditionsStrings = Object.entries(conditions)
|
|
34
37
|
.map(
|
|
35
38
|
([key, value]) => {
|
|
36
39
|
if (Array.isArray(value)) {
|
|
40
|
+
if (value.length === 0) {
|
|
41
|
+
// if empty array, the condition is ignored
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
37
44
|
const values = value.map((v) => `'${v}'`).join(',');
|
|
38
45
|
return `custom_fields->>'${key}' IN (${values})`;
|
|
39
46
|
}
|
|
40
47
|
return `custom_fields->>'${key}' = '${value}'`;
|
|
41
48
|
},
|
|
42
49
|
)
|
|
43
|
-
.
|
|
50
|
+
.filter(Boolean);
|
|
51
|
+
|
|
52
|
+
if (conditionsStrings.length === 0) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
const customFieldConditions = conditionsStrings.join(' AND ');
|
|
44
56
|
|
|
45
57
|
const subQuery = `${'SELECT model_id FROM ('
|
|
46
58
|
+ 'SELECT cv.model_id, jsonb_object_agg(cd.name, cv.value) AS custom_fields '
|
package/tsconfig.json
CHANGED
package/dist/jest.config.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const testEnvironment: string;
|
|
2
|
-
export const roots: string[];
|
|
3
|
-
export const transform: {
|
|
4
|
-
'^.+\\.tsx?$': string;
|
|
5
|
-
};
|
|
6
|
-
export const testRegex: string;
|
|
7
|
-
export const moduleFileExtensions: string[];
|
|
8
|
-
export namespace coverageThreshold {
|
|
9
|
-
namespace global {
|
|
10
|
-
const lines: number;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|