@autofleet/sadot 1.1.7-beta → 1.1.8
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/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.js +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/api/index.cjs +2 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.js +2 -12
- package/dist/api/index.js.map +1 -0
- package/dist/api/v1/definition/index.cjs +2 -0
- package/dist/api/v1/definition/index.cjs.map +1 -0
- package/dist/api/v1/definition/index.js +2 -116
- package/dist/api/v1/definition/index.js.map +1 -0
- package/dist/api/v1/definition/validations.cjs +2 -0
- package/dist/api/v1/definition/validations.cjs.map +1 -0
- package/dist/api/v1/definition/validations.js +2 -77
- package/dist/api/v1/definition/validations.js.map +1 -0
- package/dist/api/v1/errors.cjs +2 -0
- package/dist/api/v1/errors.cjs.map +1 -0
- package/dist/api/v1/errors.js +2 -12
- package/dist/api/v1/errors.js.map +1 -0
- package/dist/api/v1/index.cjs +2 -0
- package/dist/api/v1/index.cjs.map +1 -0
- package/dist/api/v1/index.js +2 -13
- package/dist/api/v1/index.js.map +1 -0
- package/dist/api/v1/validator/index.cjs +2 -0
- package/dist/api/v1/validator/index.cjs.map +1 -0
- package/dist/api/v1/validator/index.js +2 -143
- package/dist/api/v1/validator/index.js.map +1 -0
- package/dist/api/v1/validator/validations.cjs +2 -0
- package/dist/api/v1/validator/validations.cjs.map +1 -0
- package/dist/api/v1/validator/validations.d.cts +23 -0
- package/dist/api/v1/validator/validations.d.ts +23 -6
- package/dist/api/v1/validator/validations.js +2 -38
- package/dist/api/v1/validator/validations.js.map +1 -0
- package/dist/errors/index.cjs +3 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.js +3 -66
- package/dist/errors/index.js.map +1 -0
- package/dist/events/index.cjs +2 -0
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.js +2 -54
- package/dist/events/index.js.map +1 -0
- package/dist/hooks/enrich.cjs +2 -0
- package/dist/hooks/enrich.cjs.map +1 -0
- package/dist/hooks/enrich.js +2 -198
- package/dist/hooks/enrich.js.map +1 -0
- package/dist/hooks/find.cjs +2 -0
- package/dist/hooks/find.cjs.map +1 -0
- package/dist/hooks/find.js +2 -29
- package/dist/hooks/find.js.map +1 -0
- package/dist/hooks/hooks.cjs +2 -0
- package/dist/hooks/hooks.cjs.map +1 -0
- package/dist/hooks/hooks.js +2 -388
- package/dist/hooks/hooks.js.map +1 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.js +1 -17
- package/dist/hooks/utils/updateInstanceValues.cjs +2 -0
- package/dist/hooks/utils/updateInstanceValues.cjs.map +1 -0
- package/dist/hooks/utils/updateInstanceValues.js +2 -50
- package/dist/hooks/utils/updateInstanceValues.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +22 -12
- package/dist/index.js +2 -67
- package/dist/index.js.map +1 -0
- package/dist/models/CustomFieldDefinition.cjs +2 -0
- package/dist/models/CustomFieldDefinition.cjs.map +1 -0
- package/dist/models/CustomFieldDefinition.d.cts +31 -0
- package/dist/models/CustomFieldDefinition.d.ts +29 -23
- package/dist/models/CustomFieldDefinition.js +2 -192
- package/dist/models/CustomFieldDefinition.js.map +1 -0
- package/dist/models/CustomFieldEntries.cjs +2 -0
- package/dist/models/CustomFieldEntries.cjs.map +1 -0
- package/dist/models/CustomFieldEntries.d.cts +16 -0
- package/dist/models/CustomFieldEntries.d.ts +14 -13
- package/dist/models/CustomFieldEntries.js +2 -123
- package/dist/models/CustomFieldEntries.js.map +1 -0
- package/dist/models/CustomFieldValue.cjs +2 -0
- package/dist/models/CustomFieldValue.cjs.map +1 -0
- package/dist/models/CustomFieldValue.d.cts +22 -0
- package/dist/models/CustomFieldValue.d.ts +20 -14
- package/dist/models/CustomFieldValue.js +2 -151
- package/dist/models/CustomFieldValue.js.map +1 -0
- package/dist/models/CustomValidator.cjs +2 -0
- package/dist/models/CustomValidator.cjs.map +1 -0
- package/dist/models/CustomValidator.d.cts +19 -0
- package/dist/models/CustomValidator.d.ts +17 -15
- package/dist/models/CustomValidator.js +2 -98
- package/dist/models/CustomValidator.js.map +1 -0
- package/dist/models/index.cjs +2 -0
- package/dist/models/index.cjs.map +1 -0
- package/dist/models/index.d.cts +6 -0
- package/dist/models/index.d.ts +6 -18
- package/dist/models/index.js +2 -131
- package/dist/models/index.js.map +1 -0
- package/dist/models/tests/AssociatedTestModel.cjs +2 -0
- package/dist/models/tests/AssociatedTestModel.cjs.map +1 -0
- package/dist/models/tests/AssociatedTestModel.js +2 -71
- package/dist/models/tests/AssociatedTestModel.js.map +1 -0
- package/dist/models/tests/TestModel.cjs +2 -0
- package/dist/models/tests/TestModel.cjs.map +1 -0
- package/dist/models/tests/TestModel.js +2 -69
- package/dist/models/tests/TestModel.js.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs +2 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js +2 -53
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs +2 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.js +2 -47
- package/dist/models/tests/contextAwareModels/ContextTestModel.js.map +1 -0
- package/dist/repository/definition.cjs +2 -0
- package/dist/repository/definition.cjs.map +1 -0
- package/dist/repository/definition.js +2 -121
- package/dist/repository/definition.js.map +1 -0
- package/dist/repository/entries.cjs +2 -0
- package/dist/repository/entries.cjs.map +1 -0
- package/dist/repository/entries.js +2 -92
- package/dist/repository/entries.js.map +1 -0
- package/dist/repository/utils/formatValues.cjs +2 -0
- package/dist/repository/utils/formatValues.cjs.map +1 -0
- package/dist/repository/utils/formatValues.js +2 -16
- package/dist/repository/utils/formatValues.js.map +1 -0
- package/dist/repository/validator.cjs +2 -0
- package/dist/repository/validator.cjs.map +1 -0
- package/dist/repository/validator.js +2 -69
- package/dist/repository/validator.js.map +1 -0
- package/dist/repository/value.cjs +2 -0
- package/dist/repository/value.cjs.map +1 -0
- package/dist/repository/value.js +2 -124
- package/dist/repository/value.js.map +1 -0
- package/dist/scopes/filter.cjs +2 -0
- package/dist/scopes/filter.cjs.map +1 -0
- package/dist/scopes/filter.d.cts +23 -0
- package/dist/scopes/filter.d.ts +22 -29
- package/dist/scopes/filter.js +2 -75
- package/dist/scopes/filter.js.map +1 -0
- package/dist/scopes/helpers/filter.helpers.cjs +46 -0
- package/dist/scopes/helpers/filter.helpers.cjs.map +1 -0
- package/dist/scopes/helpers/filter.helpers.d.cts +17 -0
- package/dist/scopes/helpers/filter.helpers.d.ts +15 -40
- package/dist/scopes/helpers/filter.helpers.js +25 -183
- package/dist/scopes/helpers/filter.helpers.js.map +1 -0
- package/dist/scopes/index.cjs +1 -0
- package/dist/scopes/index.js +1 -6
- package/dist/types/index.d.cts +45 -0
- package/dist/types/index.d.ts +45 -46
- package/dist/utils/constants/index.cjs +2 -0
- package/dist/utils/constants/index.cjs.map +1 -0
- package/dist/utils/constants/index.d.cts +22 -0
- package/dist/utils/constants/index.d.ts +20 -17
- package/dist/utils/constants/index.js +2 -22
- package/dist/utils/constants/index.js.map +1 -0
- package/dist/utils/db/index.cjs +2 -0
- package/dist/utils/db/index.cjs.map +1 -0
- package/dist/utils/db/index.js +2 -24
- package/dist/utils/db/index.js.map +1 -0
- package/dist/utils/helpers/index.cjs +2 -0
- package/dist/utils/helpers/index.cjs.map +1 -0
- package/dist/utils/helpers/index.d.cts +31 -0
- package/dist/utils/helpers/index.d.ts +28 -23
- package/dist/utils/helpers/index.js +2 -40
- package/dist/utils/helpers/index.js.map +1 -0
- package/dist/utils/init.cjs +2 -0
- package/dist/utils/init.cjs.map +1 -0
- package/dist/utils/init.js +2 -112
- package/dist/utils/init.js.map +1 -0
- package/dist/utils/logger/index.cjs +2 -0
- package/dist/utils/logger/index.cjs.map +1 -0
- package/dist/utils/logger/index.js +2 -42
- package/dist/utils/logger/index.js.map +1 -0
- package/dist/utils/scopeAttributes.cjs +2 -0
- package/dist/utils/scopeAttributes.cjs.map +1 -0
- package/dist/utils/scopeAttributes.js +2 -11
- package/dist/utils/scopeAttributes.js.map +1 -0
- package/dist/utils/validations/index.cjs +2 -0
- package/dist/utils/validations/index.cjs.map +1 -0
- package/dist/utils/validations/index.js +2 -41
- package/dist/utils/validations/index.js.map +1 -0
- package/dist/utils/validations/schema/custom-fields.cjs +2 -0
- package/dist/utils/validations/schema/custom-fields.cjs.map +1 -0
- package/dist/utils/validations/schema/custom-fields.d.cts +7 -0
- package/dist/utils/validations/schema/custom-fields.d.ts +6 -2
- package/dist/utils/validations/schema/custom-fields.js +2 -9
- package/dist/utils/validations/schema/custom-fields.js.map +1 -0
- package/dist/utils/validations/schema/validator-schema.cjs +2 -0
- package/dist/utils/validations/schema/validator-schema.cjs.map +1 -0
- package/dist/utils/validations/schema/validator-schema.js +2 -95
- package/dist/utils/validations/schema/validator-schema.js.map +1 -0
- package/dist/utils/validations/validators/index.cjs +2 -0
- package/dist/utils/validations/validators/index.cjs.map +1 -0
- package/dist/utils/validations/validators/index.js +2 -40
- package/dist/utils/validations/validators/index.js.map +1 -0
- package/dist/utils/validations/validators/select.validator.cjs +2 -0
- package/dist/utils/validations/validators/select.validator.cjs.map +1 -0
- package/dist/utils/validations/validators/select.validator.js +2 -12
- package/dist/utils/validations/validators/select.validator.js.map +1 -0
- package/dist/utils/validations/validators/status.validator.cjs +2 -0
- package/dist/utils/validations/validators/status.validator.cjs.map +1 -0
- package/dist/utils/validations/validators/status.validator.js +2 -15
- package/dist/utils/validations/validators/status.validator.js.map +1 -0
- package/package.json +40 -39
- package/.nvmrc +0 -1
- package/dist/api/index.d.ts +0 -3
- package/dist/api/v1/definition/index.d.ts +0 -3
- package/dist/api/v1/definition/validations.d.ts +0 -2
- package/dist/api/v1/errors.d.ts +0 -4
- package/dist/api/v1/index.d.ts +0 -3
- package/dist/api/v1/validator/index.d.ts +0 -3
- package/dist/errors/index.d.ts +0 -24
- package/dist/events/index.d.ts +0 -5
- package/dist/hooks/create.d.ts +0 -10
- package/dist/hooks/create.js +0 -95
- package/dist/hooks/enrich.d.ts +0 -25
- package/dist/hooks/find.d.ts +0 -1
- package/dist/hooks/hooks.d.ts +0 -17
- package/dist/hooks/index.d.ts +0 -5
- package/dist/hooks/update.d.ts +0 -10
- package/dist/hooks/update.js +0 -49
- package/dist/hooks/utils/updateInstanceValues.d.ts +0 -15
- package/dist/hooks/workaround.d.ts +0 -10
- package/dist/hooks/workaround.js +0 -37
- package/dist/models/tests/AssociatedTestModel.d.ts +0 -12
- package/dist/models/tests/TestModel.d.ts +0 -12
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.d.ts +0 -10
- package/dist/models/tests/contextAwareModels/ContextTestModel.d.ts +0 -13
- package/dist/repository/definition.d.ts +0 -36
- package/dist/repository/entries.d.ts +0 -13
- package/dist/repository/utils/formatValues.d.ts +0 -3
- package/dist/repository/validator.d.ts +0 -28
- package/dist/repository/value.d.ts +0 -28
- package/dist/scopes/index.d.ts +0 -2
- package/dist/tests/api/test-api.d.ts +0 -2
- package/dist/tests/api/test-api.js +0 -38
- package/dist/tests/functional/searching/index.d.ts +0 -8
- package/dist/tests/functional/searching/index.js +0 -44
- package/dist/tests/helpers/commonHooks.d.ts +0 -6
- package/dist/tests/helpers/commonHooks.js +0 -62
- package/dist/tests/helpers/database-config.d.ts +0 -16
- package/dist/tests/helpers/database-config.js +0 -17
- package/dist/tests/helpers/index.d.ts +0 -7
- package/dist/tests/helpers/index.js +0 -33
- package/dist/tests/mocks/definition.mock.d.ts +0 -48
- package/dist/tests/mocks/definition.mock.js +0 -78
- package/dist/tests/mocks/events.mock.d.ts +0 -4
- package/dist/tests/mocks/events.mock.js +0 -21
- package/dist/tests/mocks/testModel.d.ts +0 -12
- package/dist/tests/mocks/testModel.js +0 -35
- package/dist/types/definition/index.d.ts +0 -25
- package/dist/types/definition/index.js +0 -2
- package/dist/types/entries/index.d.ts +0 -25
- package/dist/types/entries/index.js +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/value/index.d.ts +0 -15
- package/dist/types/value/index.js +0 -2
- package/dist/utils/db/index.d.ts +0 -4
- package/dist/utils/init.d.ts +0 -7
- package/dist/utils/logger/index.d.ts +0 -3
- package/dist/utils/scopeAttributes.d.ts +0 -2
- package/dist/utils/validations/index.d.ts +0 -8
- package/dist/utils/validations/schema/validator-schema.d.ts +0 -9
- package/dist/utils/validations/type.d.ts +0 -15
- package/dist/utils/validations/type.js +0 -2
- package/dist/utils/validations/validators/index.d.ts +0 -14
- package/dist/utils/validations/validators/select.validator.d.ts +0 -5
- package/dist/utils/validations/validators/status.validator.d.ts +0 -12
- package/src/api/index.ts +0 -10
- package/src/api/v1/definition/index.ts +0 -104
- package/src/api/v1/definition/validations.ts +0 -75
- package/src/api/v1/errors.ts +0 -13
- package/src/api/v1/index.ts +0 -11
- package/src/api/v1/validator/index.ts +0 -141
- package/src/api/v1/validator/validations.ts +0 -38
- package/src/errors/index.ts +0 -70
- package/src/events/index.ts +0 -63
- package/src/hooks/create.ts +0 -81
- package/src/hooks/enrich.ts +0 -255
- package/src/hooks/find.ts +0 -27
- package/src/hooks/hooks.ts +0 -479
- package/src/hooks/index.ts +0 -20
- package/src/hooks/update.ts +0 -55
- package/src/hooks/utils/updateInstanceValues.ts +0 -63
- package/src/hooks/workaround.ts +0 -47
- package/src/index.ts +0 -52
- package/src/models/CustomFieldDefinition.ts +0 -162
- package/src/models/CustomFieldEntries.ts +0 -81
- package/src/models/CustomFieldValue.ts +0 -118
- package/src/models/CustomValidator.ts +0 -78
- package/src/models/index.ts +0 -165
- package/src/models/tests/AssociatedTestModel.ts +0 -57
- package/src/models/tests/TestModel.ts +0 -54
- package/src/models/tests/contextAwareModels/ContextAwareTestModel.ts +0 -43
- package/src/models/tests/contextAwareModels/ContextTestModel.ts +0 -38
- package/src/repository/definition.ts +0 -175
- package/src/repository/entries.ts +0 -88
- package/src/repository/utils/formatValues.ts +0 -14
- package/src/repository/validator.ts +0 -119
- package/src/repository/value.ts +0 -116
- package/src/scopes/filter.ts +0 -100
- package/src/scopes/helpers/filter.helpers.ts +0 -227
- package/src/scopes/index.ts +0 -6
- package/src/tests/api/test-api.ts +0 -40
- package/src/tests/functional/searching/index.ts +0 -39
- package/src/tests/helpers/commonHooks.ts +0 -43
- package/src/tests/helpers/database-config.ts +0 -15
- package/src/tests/helpers/index.ts +0 -35
- package/src/tests/mocks/definition.mock.ts +0 -84
- package/src/tests/mocks/events.mock.ts +0 -21
- package/src/tests/mocks/testModel.ts +0 -37
- package/src/types/definition/index.ts +0 -24
- package/src/types/entries/index.ts +0 -27
- package/src/types/index.ts +0 -52
- package/src/types/value/index.ts +0 -14
- package/src/utils/constants/index.ts +0 -25
- package/src/utils/db/index.ts +0 -21
- package/src/utils/helpers/index.ts +0 -66
- package/src/utils/init.ts +0 -122
- package/src/utils/logger/index.ts +0 -14
- package/src/utils/scopeAttributes.ts +0 -12
- package/src/utils/validations/index.ts +0 -46
- package/src/utils/validations/schema/README.md +0 -93
- package/src/utils/validations/schema/custom-fields.ts +0 -8
- package/src/utils/validations/schema/validator-schema.ts +0 -106
- package/src/utils/validations/type.ts +0 -20
- package/src/utils/validations/validators/index.ts +0 -38
- package/src/utils/validations/validators/select.validator.ts +0 -12
- package/src/utils/validations/validators/status.validator.ts +0 -22
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -16
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CustomFieldOptions } from "../types/index.cjs";
|
|
2
|
+
import { ConditionValue } from "./helpers/filter.helpers.cjs";
|
|
3
|
+
import { customFields } from "@autofleet/common-types";
|
|
4
|
+
import { Literal } from "sequelize/types/utils";
|
|
5
|
+
|
|
6
|
+
//#region src/scopes/filter.d.ts
|
|
7
|
+
|
|
8
|
+
declare const customFieldsSortScope: (name: string, options?: Pick<CustomFieldOptions, "useCustomFieldsEntries">) => ({
|
|
9
|
+
replacementsMap,
|
|
10
|
+
scopeValue: sort
|
|
11
|
+
}: {
|
|
12
|
+
replacementsMap: Record<string, string>;
|
|
13
|
+
scopeValue: Record<string, ConditionValue>;
|
|
14
|
+
}) => {
|
|
15
|
+
attributes: {
|
|
16
|
+
include: (string | Literal)[][];
|
|
17
|
+
};
|
|
18
|
+
order: Literal[];
|
|
19
|
+
replacements: Record<string, string>;
|
|
20
|
+
} | Record<string, never>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { customFieldsSortScope };
|
|
23
|
+
//# sourceMappingURL=filter.d.cts.map
|
package/dist/scopes/filter.d.ts
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export declare const customFieldsFilterScope: (name: string, options?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => ({ replacementsMap: replacements, scopeValue: conditions }: customFieldsFilterScopeParams) => CustomFieldFilterOptions;
|
|
15
|
-
export declare const scopeName: "filterByCustomFields";
|
|
16
|
-
export declare const customFieldsSortScope: (name: string, options?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => ({ replacementsMap, scopeValue: sort }: {
|
|
17
|
-
replacementsMap: any;
|
|
18
|
-
scopeValue: any;
|
|
1
|
+
import { CustomFieldOptions } from "../types/index.js";
|
|
2
|
+
import { ConditionValue } from "./helpers/filter.helpers.js";
|
|
3
|
+
import { customFields } from "@autofleet/common-types";
|
|
4
|
+
import { Literal } from "sequelize/types/utils";
|
|
5
|
+
|
|
6
|
+
//#region src/scopes/filter.d.ts
|
|
7
|
+
|
|
8
|
+
declare const customFieldsSortScope: (name: string, options?: Pick<CustomFieldOptions, "useCustomFieldsEntries">) => ({
|
|
9
|
+
replacementsMap,
|
|
10
|
+
scopeValue: sort
|
|
11
|
+
}: {
|
|
12
|
+
replacementsMap: Record<string, string>;
|
|
13
|
+
scopeValue: Record<string, ConditionValue>;
|
|
19
14
|
}) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
export {};
|
|
15
|
+
attributes: {
|
|
16
|
+
include: (string | Literal)[][];
|
|
17
|
+
};
|
|
18
|
+
order: Literal[];
|
|
19
|
+
replacements: Record<string, string>;
|
|
20
|
+
} | Record<string, never>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { customFieldsSortScope };
|
|
23
|
+
//# sourceMappingURL=filter.d.ts.map
|
package/dist/scopes/filter.js
CHANGED
|
@@ -1,75 +1,2 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
exports.customFieldsSortScope = exports.scopeName = exports.customFieldsFilterScope = void 0;
|
|
4
|
-
/* eslint-disable import/prefer-default-export */
|
|
5
|
-
const sequelize_1 = require("sequelize");
|
|
6
|
-
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
7
|
-
const common_types_1 = require("@autofleet/common-types");
|
|
8
|
-
const helpers_1 = require("../utils/helpers");
|
|
9
|
-
const filter_helpers_1 = require("./helpers/filter.helpers");
|
|
10
|
-
const { CUSTOM_FIELDS_FILTER_SCOPE } = common_types_1.customFields;
|
|
11
|
-
/**
|
|
12
|
-
* A Sequelize scope for filtering models by custom fields.
|
|
13
|
-
* This scope builds a WHERE clause to be applied on the main query.
|
|
14
|
-
*
|
|
15
|
-
* @param name - The model type name used to join custom_field_definitions.
|
|
16
|
-
* @returns A function that takes conditions and returns the Sequelize options object.
|
|
17
|
-
*/
|
|
18
|
-
const customFieldsFilterScope = (name, options) => ({ replacementsMap: replacements, scopeValue: conditions }) => {
|
|
19
|
-
if (!conditions || Object.keys(conditions).length === 0) {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
const queryType = options?.useCustomFieldsEntries ? filter_helpers_1.SubQueryType.ENTRIES : filter_helpers_1.SubQueryType.VALUES;
|
|
23
|
-
const reverseReplacementsMap = new Map(Object.entries(replacements).map(([key, value]) => [value, key]));
|
|
24
|
-
// Build the WHERE clause for custom field filtering
|
|
25
|
-
const conditionsStrings = Object.entries(conditions).map(([key, condition]) => {
|
|
26
|
-
switch (queryType) {
|
|
27
|
-
case filter_helpers_1.SubQueryType.ENTRIES:
|
|
28
|
-
return (0, filter_helpers_1.formatConditionsForEntries)(key, condition, reverseReplacementsMap);
|
|
29
|
-
case filter_helpers_1.SubQueryType.VALUES:
|
|
30
|
-
return (0, filter_helpers_1.formatConditionsForValues)(key, condition, reverseReplacementsMap);
|
|
31
|
-
default:
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}).filter(Boolean);
|
|
35
|
-
if (conditionsStrings.length === 0) {
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
const subQuery = (0, filter_helpers_1.getFilterCustomFieldsSubQuery)(queryType, name, conditionsStrings);
|
|
39
|
-
return {
|
|
40
|
-
where: {
|
|
41
|
-
id: {
|
|
42
|
-
[sequelize_1.Op.in]: sequelize_typescript_1.Sequelize.literal(`(${subQuery})`),
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
replacements,
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
exports.customFieldsFilterScope = customFieldsFilterScope;
|
|
49
|
-
exports.scopeName = CUSTOM_FIELDS_FILTER_SCOPE;
|
|
50
|
-
const customFieldsSortScope = (name, options) => ({ replacementsMap, scopeValue: sort }) => {
|
|
51
|
-
if (!sort || sort.length === 0) {
|
|
52
|
-
return {};
|
|
53
|
-
}
|
|
54
|
-
const queryType = options?.useCustomFieldsEntries ? filter_helpers_1.SubQueryType.ENTRIES : filter_helpers_1.SubQueryType.VALUES;
|
|
55
|
-
const randomStr = (0, helpers_1.generateRandomString)();
|
|
56
|
-
const includes = Object.entries(sort).map(([key]) => {
|
|
57
|
-
const replacementKey = Object.keys(replacementsMap).find((randomString) => replacementsMap[randomString] === key);
|
|
58
|
-
return ([
|
|
59
|
-
sequelize_typescript_1.Sequelize.literal((0, filter_helpers_1.getSortCustomFieldsSubQuery)(queryType, name, replacementKey)),
|
|
60
|
-
randomStr,
|
|
61
|
-
]);
|
|
62
|
-
});
|
|
63
|
-
const orders = Object.entries(sort).map(([, sortObject]) => {
|
|
64
|
-
const direction = typeof sortObject === 'string' ? sortObject : Object.values(sortObject)[0];
|
|
65
|
-
return sequelize_typescript_1.Sequelize.literal(`"${randomStr}" ${direction || 'ASC'}`);
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
attributes: {
|
|
69
|
-
include: includes,
|
|
70
|
-
},
|
|
71
|
-
order: orders,
|
|
72
|
-
replacements: replacementsMap,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
exports.customFieldsSortScope = customFieldsSortScope;
|
|
1
|
+
import{generateRandomString as e}from"../utils/helpers/index.js";import{SubQueryType as t,formatConditionsForEntries as n,formatConditionsForValues as r,getFilterCustomFieldsSubQuery as i,getSortCustomFieldsSubQuery as a}from"./helpers/filter.helpers.js";import{Op as o}from"sequelize";import{Sequelize as s}from"sequelize-typescript";import{customFields as c}from"@autofleet/common-types";const l=(e,a)=>({replacementsMap:c,scopeValue:l})=>{if(!l||Object.keys(l).length===0)return{};let u=a?.useCustomFieldsEntries?t.ENTRIES:t.VALUES,d=new Map(Object.entries(c).map(([e,t])=>[t,e])),f=Object.entries(l).map(([e,i])=>{switch(u){case t.ENTRIES:return n(e,i,d);case t.VALUES:return r(e,i,d);default:return!1}}).filter(Boolean);if(f.length===0)return{};let p=i(u,e,f);return{where:{id:{[o.in]:s.literal(`(${p})`)}},replacements:c}};c.CUSTOM_FIELDS_FILTER_SCOPE;const u=(n,r)=>({replacementsMap:i,scopeValue:o})=>{if(!o||o.length===0)return{};let c=r?.useCustomFieldsEntries?t.ENTRIES:t.VALUES,l=e(),u=Object.entries(o).map(([e])=>{let t=Object.keys(i).find(t=>i[t]===e);return[s.literal(a(c,n,t)),l]}),d=Object.entries(o).map(([,e])=>{let t=typeof e==`string`?e:Object.values(e)[0];return s.literal(`"${l}" ${t||`ASC`}`)});return{attributes:{include:u},order:d,replacements:i}};export{l as customFieldsFilterScope,u as customFieldsSortScope};
|
|
2
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.js","names":["scopeName: typeof customFields.CUSTOM_FIELDS_FILTER_SCOPE"],"sources":["../../src/scopes/filter.ts"],"sourcesContent":["import { Op } from 'sequelize';\nimport type { Literal } from 'sequelize/types/utils';\nimport { Sequelize } from 'sequelize-typescript';\nimport { customFields } from '@autofleet/common-types';\nimport { generateRandomString } from '../utils/helpers';\nimport type { CustomFieldOptions } from '../types';\nimport {\n formatConditionsForEntries,\n formatConditionsForValues,\n getFilterCustomFieldsSubQuery,\n getSortCustomFieldsSubQuery,\n SubQueryType,\n type ConditionValue,\n type CustomFieldFilterOptions,\n} from './helpers/filter.helpers';\n\ninterface customFieldsFilterScopeParams {\n replacementsMap: Record<string, string>;\n scopeValue: Record<string, ConditionValue>;\n}\n\n/**\n * A Sequelize scope for filtering models by custom fields.\n * This scope builds a WHERE clause to be applied on the main query.\n *\n * @param name - The model type name used to join custom_field_definitions.\n * @returns A function that takes conditions and returns the Sequelize options object.\n */\nexport const customFieldsFilterScope = (\n name: string,\n options?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>,\n) => ({ replacementsMap: replacements, scopeValue: conditions }: customFieldsFilterScopeParams): CustomFieldFilterOptions => {\n if (!conditions || Object.keys(conditions).length === 0) {\n return {};\n }\n\n const queryType = options?.useCustomFieldsEntries ? SubQueryType.ENTRIES : SubQueryType.VALUES;\n const reverseReplacementsMap = new Map(Object.entries(replacements).map(([key, value]) => [value, key]));\n // Build the WHERE clause for custom field filtering\n const conditionsStrings = Object.entries(conditions).map(([key, condition]) => {\n switch (queryType) {\n case SubQueryType.ENTRIES:\n return formatConditionsForEntries(key, condition, reverseReplacementsMap);\n case SubQueryType.VALUES:\n return formatConditionsForValues(key, condition, reverseReplacementsMap);\n default:\n return false;\n }\n }).filter(Boolean);\n if (conditionsStrings.length === 0) {\n return {};\n }\n const subQuery = getFilterCustomFieldsSubQuery(queryType, name, conditionsStrings);\n\n return {\n where: {\n id: {\n [Op.in]: Sequelize.literal(`(${subQuery})`),\n },\n },\n replacements,\n };\n};\n\nexport const scopeName: typeof customFields.CUSTOM_FIELDS_FILTER_SCOPE = customFields.CUSTOM_FIELDS_FILTER_SCOPE;\n\nexport const customFieldsSortScope = (\n name: string,\n options?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>,\n) => ({ replacementsMap, scopeValue: sort }: { replacementsMap: Record<string, string>; scopeValue: Record<string, ConditionValue>; }): {\n attributes: { include: (string | Literal)[][]; };\n order: Literal[];\n replacements: Record<string, string>;\n} | Record<string, never> => {\n if (!sort || (sort as unknown as any[]).length === 0) {\n return {};\n }\n\n const queryType = options?.useCustomFieldsEntries ? SubQueryType.ENTRIES : SubQueryType.VALUES;\n const randomStr = generateRandomString();\n const includes = Object.entries(sort).map(([key]) => {\n const replacementKey = Object.keys(replacementsMap).find(\n randomString => replacementsMap[randomString] === key,\n );\n return ([\n Sequelize.literal(getSortCustomFieldsSubQuery(queryType, name, replacementKey!)),\n randomStr,\n ]);\n });\n\n const orders = Object.entries(sort).map(([, sortObject]) => {\n const direction = typeof sortObject === 'string' ? sortObject : Object.values(sortObject)[0];\n return Sequelize.literal(`\"${randomStr}\" ${direction || 'ASC'}`);\n });\n return {\n attributes: {\n include: includes,\n },\n order: orders,\n replacements: replacementsMap,\n };\n};\n"],"mappings":"sYA4BA,MAAa,GACX,EACA,KACI,CAAE,gBAAiB,EAAc,WAAY,KAA0E,CAC3H,GAAI,CAAC,GAAc,OAAO,KAAK,EAAW,CAAC,SAAW,EACpD,MAAO,EAAE,CAGX,IAAM,EAAY,GAAS,uBAAyB,EAAa,QAAU,EAAa,OAClF,EAAyB,IAAI,IAAI,OAAO,QAAQ,EAAa,CAAC,KAAK,CAAC,EAAK,KAAW,CAAC,EAAO,EAAI,CAAC,CAAC,CAElG,EAAoB,OAAO,QAAQ,EAAW,CAAC,KAAK,CAAC,EAAK,KAAe,CAC7E,OAAQ,EAAR,CACE,KAAK,EAAa,QAChB,OAAO,EAA2B,EAAK,EAAW,EAAuB,CAC3E,KAAK,EAAa,OAChB,OAAO,EAA0B,EAAK,EAAW,EAAuB,CAC1E,QACE,MAAO,KAEX,CAAC,OAAO,QAAQ,CAClB,GAAI,EAAkB,SAAW,EAC/B,MAAO,EAAE,CAEX,IAAM,EAAW,EAA8B,EAAW,EAAM,EAAkB,CAElF,MAAO,CACL,MAAO,CACL,GAAI,EACD,EAAG,IAAK,EAAU,QAAQ,IAAI,EAAS,GAAG,CAC5C,CACF,CACD,eACD,EAGsE,EAAa,2BAEtF,MAAa,GACX,EACA,KACI,CAAE,kBAAiB,WAAY,KAIR,CAC3B,GAAI,CAAC,GAAS,EAA0B,SAAW,EACjD,MAAO,EAAE,CAGX,IAAM,EAAY,GAAS,uBAAyB,EAAa,QAAU,EAAa,OAClF,EAAY,GAAsB,CAClC,EAAW,OAAO,QAAQ,EAAK,CAAC,KAAK,CAAC,KAAS,CACnD,IAAM,EAAiB,OAAO,KAAK,EAAgB,CAAC,KAClD,GAAgB,EAAgB,KAAkB,EACnD,CACD,MAAQ,CACN,EAAU,QAAQ,EAA4B,EAAW,EAAM,EAAgB,CAAC,CAChF,EACD,EACD,CAEI,EAAS,OAAO,QAAQ,EAAK,CAAC,KAAK,EAAG,KAAgB,CAC1D,IAAM,EAAY,OAAO,GAAe,SAAW,EAAa,OAAO,OAAO,EAAW,CAAC,GAC1F,OAAO,EAAU,QAAQ,IAAI,EAAU,IAAI,GAAa,QAAQ,EAChE,CACF,MAAO,CACL,WAAY,CACV,QAAS,EACV,CACD,MAAO,EACP,aAAc,EACf"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
let e=function(e){return e.VALUES=`values`,e.ENTRIES=`entries`,e}({});const t=e=>Array.isArray(e)&&typeof e[0]==`string`,n=e=>[`true`,`false`].includes(e.toString()),r=e=>e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`,i=(e,t)=>`to_jsonb(${e}::${t})`,a=e=>i(e,`text`),o=e=>i(e,`boolean`),s=e=>i(e,`numeric`),c=(e,t)=>r(t)?i(e,`timestamp`):e,l=` AND `,u=` OR `,d=`cd`,f=`cd.name`,p=`cv`,m=`cv.value`,h=`ce`,g=(e,t,i,a)=>{let o=`text`;r(e)?o=`date`:Number.isNaN(Number(e))?n(e)&&(o=`boolean`):o=`numeric`;let s=a.get(e);return`(jsonb_extract_path_text(ce.custom_fields, :${i})::${o}) ${t} :${s}`},_=e=>{let t=e;return n(e)?t=e===`true`:Number.isNaN(Number(e))||(t=Number(e)),t},v=(e,t)=>{let r=_(e),i=JSON.stringify({[t]:r}),a;return n(e)&&(a=`ce.custom_fields @> '${JSON.stringify({[t]:e})}'`),`
|
|
2
|
+
(
|
|
3
|
+
${a?`${a} OR`:``}
|
|
4
|
+
ce.custom_fields @> '${i}'
|
|
5
|
+
)
|
|
6
|
+
`},y=(t,n,r)=>{switch(t){case e.VALUES:return`
|
|
7
|
+
SELECT cv.model_id
|
|
8
|
+
FROM custom_field_values AS cv
|
|
9
|
+
INNER JOIN custom_field_definitions AS cd ON cv.custom_field_definition_id = cd.id
|
|
10
|
+
${l}cd.model_type = '${n}'
|
|
11
|
+
WHERE ${r.join(u)}
|
|
12
|
+
${l}cv.deleted_at IS NULL${l}cd.deleted_at IS NULL
|
|
13
|
+
GROUP BY cv.model_id
|
|
14
|
+
HAVING COUNT(DISTINCT cv.custom_field_definition_id) = ${r.length}
|
|
15
|
+
`.replace(/\n/g,``);case e.ENTRIES:return`
|
|
16
|
+
SELECT ce.model_id
|
|
17
|
+
FROM custom_field_entries ce
|
|
18
|
+
JOIN custom_field_definitions cfd
|
|
19
|
+
ON ce.model_type = cfd.model_type
|
|
20
|
+
AND ce.entity_id = cfd.entity_id
|
|
21
|
+
WHERE
|
|
22
|
+
cfd.deleted_at IS NULL AND
|
|
23
|
+
${r.join(l)}
|
|
24
|
+
`;default:throw Error(`Invalid query type`)}},b=(t,n,r)=>{switch(t){case e.VALUES:return`(
|
|
25
|
+
SELECT value
|
|
26
|
+
FROM (SELECT cv.model_id, cv.value
|
|
27
|
+
FROM custom_field_values AS cv INNER JOIN custom_field_definitions AS cd
|
|
28
|
+
ON cv.custom_field_definition_id = cd.id
|
|
29
|
+
${l}cd.model_type = '${n}'
|
|
30
|
+
WHERE cv.model_id = "${n}"."id"
|
|
31
|
+
${l}cd.name = :${r}
|
|
32
|
+
) AS CustomFieldAggregation
|
|
33
|
+
)
|
|
34
|
+
`;case e.ENTRIES:return`(
|
|
35
|
+
SELECT
|
|
36
|
+
customFields.value
|
|
37
|
+
FROM
|
|
38
|
+
custom_field_entries AS ce,
|
|
39
|
+
jsonb_each_text(custom_fields) AS customFields
|
|
40
|
+
WHERE
|
|
41
|
+
customFields.key = :${r}${l}
|
|
42
|
+
ce.model_type = '${n}'${l}
|
|
43
|
+
ce.model_id = "${n}"."id"
|
|
44
|
+
)
|
|
45
|
+
`;default:throw Error(`Invalid query type`)}},x=(e,r,i)=>{let d=i.get(e);if(!d)return!1;let f=`(cd.name = :${d})`;if(Array.isArray(r))return r.length===0?!1:t(r)?`(${f}${l}${m} IN (${r.flatMap(e=>{let t=i.get(e);return n(e)?[a(`:${t}`),o(`:${t}`)]:Number.isNaN(Number(e))?a(`:${t}`):s(`:${t}`)}).join(`,`)}))`:r.map(e=>{let t=a(`:${i.get(e.value)}`);return`(${f}${l}${c(m,e.value)} ${e.operator} ${t})`}).join(l);if(typeof r==`string`||typeof r==`number`){let e=i.get(r),t=Number.isNaN(Number(r))?a(`:${e}`):s(`:${e}`),d=n(r)?`${u}${m} = ${o(`:${e}`)}`:``;return`(${f}${l}(${c(m,r)} = ${t}${d}))`}if(r?.operator){let e=a(`:${i.get(r.value)}`);return`( ${f}${l}${c(m,r.value)} ${r.operator} ${e})`}return!1},S=(e,n,r)=>{let i=r.get(e);return i?Array.isArray(n)?n.length===0?!1:t(n)?`( ${n.map(t=>v(t,e)).join(`${u}\n`)})`:n.map(e=>g(e.value,e.operator,i,r)).join(l):typeof n==`string`||typeof n==`number`?v(n,e):n?.operator?g(n.value,n.operator,i,r):!1:!1};exports.SubQueryType=e,exports.formatConditionsForEntries=S,exports.formatConditionsForValues=x,exports.getFilterCustomFieldsSubQuery=y,exports.getSortCustomFieldsSubQuery=b;
|
|
46
|
+
//# sourceMappingURL=filter.helpers.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.helpers.cjs","names":["CD_NAME_COLUMN: `${typeof CD_TABLE_ALIAS}.name`","CV_VALUE_COLUMN: `${typeof CV_TABLE_ALIAS}.value`","formattedValue: string | number | boolean"],"sources":["../../../src/scopes/helpers/filter.helpers.ts"],"sourcesContent":["import type { WhereOptions } from 'sequelize';\n\n/**\n * Type representing possible condition values.\n * Currently supporting strings and arrays of strings.\n * More types to be added (TBA).\n */\nexport interface ConditionWithOperator {\n operator: string;\n value: string;\n}\nexport type ConditionValue = ConditionWithOperator | ConditionWithOperator[] | string | string[];\n\nexport interface CustomFieldSort {\n field: string;\n direction: 'ASC' | 'DESC';\n}\n\nexport interface CustomFieldFilterOptions {\n where?: WhereOptions;\n replacements?: Record<string, string>;\n}\n\nexport enum SubQueryType {\n VALUES = 'values',\n ENTRIES = 'entries',\n}\n\nexport const isConditionStringArray = (input: any): input is string[] => Array.isArray(input) && typeof input[0] === 'string';\nexport const isBooleanString = (input: string): boolean => ['true', 'false'].includes(input.toString());\nexport const isDate = (input: any): input is Date => input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';\n\nexport const castValueToJsonb = (value: string, type: string) => `to_jsonb(${value}::${type})`;\nexport const castValueToJsonbText = (value: string): string => castValueToJsonb(value, 'text');\nexport const castValueToJsonbBoolean = (value: string): string => castValueToJsonb(value, 'boolean');\nexport const castValueToJsonbNumeric = (value: string): string => castValueToJsonb(value, 'numeric');\nexport const castIfNeeded = (columnName: string, conditionValue: string): string => {\n if (isDate(conditionValue)) {\n return castValueToJsonb(columnName, 'timestamp');\n }\n return columnName;\n};\n\nexport const AND_DELIMITER = ' AND ';\nexport const OR_DELIMITER = ' OR ';\nexport const CD_TABLE_ALIAS = 'cd';\nexport const CD_NAME_COLUMN: `${typeof CD_TABLE_ALIAS}.name` = `${CD_TABLE_ALIAS}.name`;\nexport const CV_TABLE_ALIAS = 'cv';\nexport const CV_VALUE_COLUMN: `${typeof CV_TABLE_ALIAS}.value` = `${CV_TABLE_ALIAS}.value`;\nexport const CE_TABLE_ALIAS = 'ce';\n\nconst getSingleConditionWithOperator = (value: any, operator: string, replacementKey: string, reverseReplacementsMap: Map<string, string>) => {\n let type = 'text';\n if (isDate(value)) {\n type = 'date';\n } else if (!Number.isNaN(Number(value))) {\n type = 'numeric';\n } else if (isBooleanString(value)) {\n type = 'boolean';\n }\n const replacedValue = reverseReplacementsMap.get(value);\n\n return `(jsonb_extract_path_text(${CE_TABLE_ALIAS}.custom_fields, :${replacementKey})::${type}) ${operator} :${replacedValue}`;\n};\n\nconst getFormattedValue = (value: string) => {\n let formattedValue: string | number | boolean = value;\n if (isBooleanString(value)) {\n formattedValue = value === 'true';\n } else if (!Number.isNaN(Number(value))) {\n formattedValue = Number(value);\n }\n\n return formattedValue;\n};\n\nconst getJSONSubQuery = (value: string, key: string) => {\n const formattedValue = getFormattedValue(value);\n const jsonQuery = JSON.stringify({ [key]: formattedValue });\n let jsonQueryWithStringBoolean;\n if (isBooleanString(value)) {\n jsonQueryWithStringBoolean = `${CE_TABLE_ALIAS}.custom_fields @> '${JSON.stringify({ [key]: value })}'`;\n }\n return `\n (\n ${jsonQueryWithStringBoolean ? `${jsonQueryWithStringBoolean} OR` : ''}\n ${CE_TABLE_ALIAS}.custom_fields @> '${jsonQuery}'\n )\n `;\n};\n\nexport const getFilterCustomFieldsSubQuery = (queryType: SubQueryType, modelType: string, conditionsStrings: (string | boolean)[]): string => {\n switch (queryType) {\n case SubQueryType.VALUES:\n return `\n SELECT ${CV_TABLE_ALIAS}.model_id\n FROM custom_field_values AS ${CV_TABLE_ALIAS}\n INNER JOIN custom_field_definitions AS ${CD_TABLE_ALIAS} ON ${CV_TABLE_ALIAS}.custom_field_definition_id = ${CD_TABLE_ALIAS}.id\n ${AND_DELIMITER}${CD_TABLE_ALIAS}.model_type = '${modelType}'\n WHERE ${conditionsStrings.join(OR_DELIMITER)}\n ${AND_DELIMITER}${CV_TABLE_ALIAS}.deleted_at IS NULL${AND_DELIMITER}${CD_TABLE_ALIAS}.deleted_at IS NULL\n GROUP BY ${CV_TABLE_ALIAS}.model_id\n HAVING COUNT(DISTINCT ${CV_TABLE_ALIAS}.custom_field_definition_id) = ${conditionsStrings.length}\n `.replace(/\\n/g, '');\n case SubQueryType.ENTRIES:\n return `\n SELECT ce.model_id\n FROM custom_field_entries ce\n JOIN custom_field_definitions cfd\n ON ce.model_type = cfd.model_type\n AND ce.entity_id = cfd.entity_id\n WHERE\n cfd.deleted_at IS NULL AND\n ${conditionsStrings.join(AND_DELIMITER)}\n `;\n default:\n throw new Error('Invalid query type');\n }\n};\n\nexport const getSortCustomFieldsSubQuery = (queryType: SubQueryType, modelType: string, replacementKey: string): string => {\n switch (queryType) {\n case SubQueryType.VALUES:\n return `(\n SELECT value\n FROM (SELECT cv.model_id, cv.value\n FROM custom_field_values AS cv INNER JOIN custom_field_definitions AS cd\n ON cv.custom_field_definition_id = cd.id\n ${AND_DELIMITER}cd.model_type = '${modelType}'\n WHERE cv.model_id = \"${modelType}\".\"id\"\n ${AND_DELIMITER}cd.name = :${replacementKey}\n ) AS CustomFieldAggregation\n )\n `;\n case SubQueryType.ENTRIES:\n return `(\n SELECT\n customFields.value\n FROM\n custom_field_entries AS ${CE_TABLE_ALIAS},\n jsonb_each_text(custom_fields) AS customFields\n WHERE\n customFields.key = :${replacementKey}${AND_DELIMITER}\n ${CE_TABLE_ALIAS}.model_type = '${modelType}'${AND_DELIMITER}\n ${CE_TABLE_ALIAS}.model_id = \"${modelType}\".\"id\"\n )\n `;\n default:\n throw new Error('Invalid query type');\n }\n};\n\nexport const formatConditionsForValues = (key: string, condition: ConditionValue, reverseReplacementsMap: Map<string, string>): false | string => {\n const replacementKey = reverseReplacementsMap.get(key);\n if (!replacementKey) {\n return false;\n }\n\n const columnCondition = `(${CD_NAME_COLUMN} = :${replacementKey})`;\n if (Array.isArray(condition)) {\n if (condition.length === 0) {\n // if empty array, the condition is ignored\n return false;\n }\n\n if (isConditionStringArray(condition)) {\n const values = condition.flatMap((v) => {\n const valRandom = reverseReplacementsMap.get(v);\n if (isBooleanString(v)) {\n return [castValueToJsonbText(`:${valRandom}`), castValueToJsonbBoolean(`:${valRandom}`)];\n }\n if (!Number.isNaN(Number(v))) {\n return castValueToJsonbNumeric(`:${valRandom}`);\n }\n return castValueToJsonbText(`:${valRandom}`);\n }).join(',');\n return `(${columnCondition}${AND_DELIMITER}${CV_VALUE_COLUMN} IN (${values}))`;\n }\n return condition.map((c) => {\n const valRep = reverseReplacementsMap.get(c.value);\n const valueAsJsonb = castValueToJsonbText(`:${valRep}`);\n\n return `(${columnCondition}${AND_DELIMITER}${castIfNeeded(CV_VALUE_COLUMN, c.value)} ${c.operator} ${valueAsJsonb})`;\n }).join(AND_DELIMITER);\n }\n if (typeof condition === 'string' || typeof condition === 'number') {\n const conditionRep = reverseReplacementsMap.get(condition);\n const valueAsJsonb = !Number.isNaN(Number(condition)) ? castValueToJsonbNumeric(`:${conditionRep}`) : castValueToJsonbText(`:${conditionRep}`);\n const valueAsJsonbBoolean = isBooleanString(condition) ? `${OR_DELIMITER}${CV_VALUE_COLUMN} = ${castValueToJsonbBoolean(`:${conditionRep}`)}` : '';\n return `(${columnCondition}${AND_DELIMITER}(${castIfNeeded(CV_VALUE_COLUMN, condition)} = ${valueAsJsonb}${valueAsJsonbBoolean}))`;\n }\n if (condition?.operator) {\n const valueRep = reverseReplacementsMap.get(condition.value);\n const valueAsJsonb = castValueToJsonbText(`:${valueRep}`);\n return `( ${columnCondition}${AND_DELIMITER}${castIfNeeded(CV_VALUE_COLUMN, condition.value)} ${condition.operator} ${valueAsJsonb})`;\n }\n return false;\n};\n\nexport const formatConditionsForEntries = (key: string, condition: ConditionValue, reverseReplacementsMap: Map<string, string>): false | string => {\n const replacementKey = reverseReplacementsMap.get(key);\n if (!replacementKey) {\n return false;\n }\n\n if (Array.isArray(condition)) {\n if (condition.length === 0) {\n // if empty array, the condition is ignored\n return false;\n }\n\n if (isConditionStringArray(condition)) {\n const values = condition.map(value => getJSONSubQuery(value, key)).join(`${OR_DELIMITER}\\n`);\n return `( ${values})`;\n }\n return condition.map(c => getSingleConditionWithOperator(c.value, c.operator, replacementKey, reverseReplacementsMap)).join(AND_DELIMITER);\n }\n\n if (typeof condition === 'string' || typeof condition === 'number') {\n return getJSONSubQuery(condition, key);\n }\n\n if (condition?.operator) {\n return getSingleConditionWithOperator(condition.value, condition.operator, replacementKey, reverseReplacementsMap);\n }\n return false;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { WhereOptions } from "sequelize";
|
|
2
|
+
|
|
3
|
+
//#region src/scopes/helpers/filter.helpers.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Type representing possible condition values.
|
|
7
|
+
* Currently supporting strings and arrays of strings.
|
|
8
|
+
* More types to be added (TBA).
|
|
9
|
+
*/
|
|
10
|
+
interface ConditionWithOperator {
|
|
11
|
+
operator: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}
|
|
14
|
+
type ConditionValue = ConditionWithOperator | ConditionWithOperator[] | string | string[];
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ConditionValue };
|
|
17
|
+
//# sourceMappingURL=filter.helpers.d.cts.map
|
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { WhereOptions } from "sequelize";
|
|
2
|
+
|
|
3
|
+
//#region src/scopes/helpers/filter.helpers.d.ts
|
|
4
|
+
|
|
2
5
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
export type ConditionValue = ConditionWithOperator | ConditionWithOperator[] | string | string[];
|
|
12
|
-
export type CustomFieldSort = {
|
|
13
|
-
field: string;
|
|
14
|
-
direction: 'ASC' | 'DESC';
|
|
15
|
-
};
|
|
16
|
-
export type CustomFieldFilterOptions = {
|
|
17
|
-
where?: WhereOptions;
|
|
18
|
-
replacements?: Record<string, string>;
|
|
19
|
-
};
|
|
20
|
-
export declare enum SubQueryType {
|
|
21
|
-
VALUES = "values",
|
|
22
|
-
ENTRIES = "entries"
|
|
6
|
+
* Type representing possible condition values.
|
|
7
|
+
* Currently supporting strings and arrays of strings.
|
|
8
|
+
* More types to be added (TBA).
|
|
9
|
+
*/
|
|
10
|
+
interface ConditionWithOperator {
|
|
11
|
+
operator: string;
|
|
12
|
+
value: string;
|
|
23
13
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
export declare const castValueToJsonbText: (value: string) => string;
|
|
29
|
-
export declare const castValueToJsonbBoolean: (value: string) => string;
|
|
30
|
-
export declare const castValueToJsonbNumeric: (value: string) => string;
|
|
31
|
-
export declare const castIfNeeded: (columnName: string, conditionValue: string) => string;
|
|
32
|
-
export declare const AND_DELIMITER = " AND ";
|
|
33
|
-
export declare const OR_DELIMITER = " OR ";
|
|
34
|
-
export declare const CD_TABLE_ALIAS = "cd";
|
|
35
|
-
export declare const CD_NAME_COLUMN = "cd.name";
|
|
36
|
-
export declare const CV_TABLE_ALIAS = "cv";
|
|
37
|
-
export declare const CV_VALUE_COLUMN = "cv.value";
|
|
38
|
-
export declare const CE_TABLE_ALIAS = "ce";
|
|
39
|
-
export declare const getFilterCustomFieldsSubQuery: (queryType: SubQueryType, modelType: string, conditionsStrings: Array<string | boolean>) => string;
|
|
40
|
-
export declare const getSortCustomFieldsSubQuery: (queryType: SubQueryType, modelType: string, replacementKey: string) => string;
|
|
41
|
-
export declare const formatConditionsForValues: (key: string, condition: ConditionValue, reverseReplacementsMap: Map<string, string>) => string | false;
|
|
42
|
-
export declare const formatConditionsForEntries: (key: string, condition: ConditionValue, reverseReplacementsMap: Map<string, string>) => string | false;
|
|
14
|
+
type ConditionValue = ConditionWithOperator | ConditionWithOperator[] | string | string[];
|
|
15
|
+
//#endregion
|
|
16
|
+
export { ConditionValue };
|
|
17
|
+
//# sourceMappingURL=filter.helpers.d.ts.map
|
|
@@ -1,92 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatConditionsForEntries = exports.formatConditionsForValues = exports.getSortCustomFieldsSubQuery = exports.getFilterCustomFieldsSubQuery = exports.CE_TABLE_ALIAS = exports.CV_VALUE_COLUMN = exports.CV_TABLE_ALIAS = exports.CD_NAME_COLUMN = exports.CD_TABLE_ALIAS = exports.OR_DELIMITER = exports.AND_DELIMITER = exports.castIfNeeded = exports.castValueToJsonbNumeric = exports.castValueToJsonbBoolean = exports.castValueToJsonbText = exports.castValueToJsonb = exports.isDate = exports.isBooleanString = exports.isConditionStringArray = exports.SubQueryType = void 0;
|
|
4
|
-
var SubQueryType;
|
|
5
|
-
(function (SubQueryType) {
|
|
6
|
-
SubQueryType["VALUES"] = "values";
|
|
7
|
-
SubQueryType["ENTRIES"] = "entries";
|
|
8
|
-
})(SubQueryType || (exports.SubQueryType = SubQueryType = {}));
|
|
9
|
-
const isConditionStringArray = (input) => Array.isArray(input) && typeof input[0] === 'string';
|
|
10
|
-
exports.isConditionStringArray = isConditionStringArray;
|
|
11
|
-
const isBooleanString = (input) => ['true', 'false'].includes(input.toString());
|
|
12
|
-
exports.isBooleanString = isBooleanString;
|
|
13
|
-
const isDate = (input) => input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
|
14
|
-
exports.isDate = isDate;
|
|
15
|
-
const castValueToJsonb = (value, type) => `to_jsonb(${value}::${type})`;
|
|
16
|
-
exports.castValueToJsonb = castValueToJsonb;
|
|
17
|
-
const castValueToJsonbText = (value) => (0, exports.castValueToJsonb)(value, 'text');
|
|
18
|
-
exports.castValueToJsonbText = castValueToJsonbText;
|
|
19
|
-
const castValueToJsonbBoolean = (value) => (0, exports.castValueToJsonb)(value, 'boolean');
|
|
20
|
-
exports.castValueToJsonbBoolean = castValueToJsonbBoolean;
|
|
21
|
-
const castValueToJsonbNumeric = (value) => (0, exports.castValueToJsonb)(value, 'numeric');
|
|
22
|
-
exports.castValueToJsonbNumeric = castValueToJsonbNumeric;
|
|
23
|
-
const castIfNeeded = (columnName, conditionValue) => {
|
|
24
|
-
if ((0, exports.isDate)(conditionValue)) {
|
|
25
|
-
return (0, exports.castValueToJsonb)(columnName, 'timestamp');
|
|
26
|
-
}
|
|
27
|
-
return columnName;
|
|
28
|
-
};
|
|
29
|
-
exports.castIfNeeded = castIfNeeded;
|
|
30
|
-
exports.AND_DELIMITER = ' AND ';
|
|
31
|
-
exports.OR_DELIMITER = ' OR ';
|
|
32
|
-
exports.CD_TABLE_ALIAS = 'cd';
|
|
33
|
-
exports.CD_NAME_COLUMN = `${exports.CD_TABLE_ALIAS}.name`;
|
|
34
|
-
exports.CV_TABLE_ALIAS = 'cv';
|
|
35
|
-
exports.CV_VALUE_COLUMN = `${exports.CV_TABLE_ALIAS}.value`;
|
|
36
|
-
exports.CE_TABLE_ALIAS = 'ce';
|
|
37
|
-
const getSingleConditionWithOperator = (value, operator, replacementKey, reverseReplacementsMap) => {
|
|
38
|
-
let type = 'text';
|
|
39
|
-
if ((0, exports.isDate)(value)) {
|
|
40
|
-
type = 'date';
|
|
41
|
-
}
|
|
42
|
-
else if (!Number.isNaN(Number(value))) {
|
|
43
|
-
type = 'numeric';
|
|
44
|
-
}
|
|
45
|
-
else if ((0, exports.isBooleanString)(value)) {
|
|
46
|
-
type = 'boolean';
|
|
47
|
-
}
|
|
48
|
-
const replacedValue = reverseReplacementsMap.get(value);
|
|
49
|
-
return `(jsonb_extract_path_text(${exports.CE_TABLE_ALIAS}.custom_fields, :${replacementKey})::${type}) ${operator} :${replacedValue}`;
|
|
50
|
-
};
|
|
51
|
-
const getFormattedValue = (value) => {
|
|
52
|
-
let formattedValue = value;
|
|
53
|
-
if ((0, exports.isBooleanString)(value)) {
|
|
54
|
-
formattedValue = value === 'true';
|
|
55
|
-
}
|
|
56
|
-
else if (!Number.isNaN(Number(value))) {
|
|
57
|
-
formattedValue = Number(value);
|
|
58
|
-
}
|
|
59
|
-
return formattedValue;
|
|
60
|
-
};
|
|
61
|
-
const getJSONSubQuery = (value, key) => {
|
|
62
|
-
const formattedValue = getFormattedValue(value);
|
|
63
|
-
const jsonQuery = JSON.stringify({ [key]: formattedValue });
|
|
64
|
-
let jsonQueryWithStringBoolean;
|
|
65
|
-
if ((0, exports.isBooleanString)(value)) {
|
|
66
|
-
jsonQueryWithStringBoolean = `${exports.CE_TABLE_ALIAS}.custom_fields @> '${JSON.stringify({ [key]: value })}'`;
|
|
67
|
-
}
|
|
68
|
-
return `
|
|
1
|
+
let e=function(e){return e.VALUES=`values`,e.ENTRIES=`entries`,e}({});const t=e=>Array.isArray(e)&&typeof e[0]==`string`,n=e=>[`true`,`false`].includes(e.toString()),r=e=>e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`,i=(e,t)=>`to_jsonb(${e}::${t})`,a=e=>i(e,`text`),o=e=>i(e,`boolean`),s=e=>i(e,`numeric`),c=(e,t)=>r(t)?i(e,`timestamp`):e,l=` AND `,u=` OR `,d=`cv.value`,f=(e,t,i,a)=>{let o=`text`;r(e)?o=`date`:Number.isNaN(Number(e))?n(e)&&(o=`boolean`):o=`numeric`;let s=a.get(e);return`(jsonb_extract_path_text(ce.custom_fields, :${i})::${o}) ${t} :${s}`},p=e=>{let t=e;return n(e)?t=e===`true`:Number.isNaN(Number(e))||(t=Number(e)),t},m=(e,t)=>{let r=p(e),i=JSON.stringify({[t]:r}),a;return n(e)&&(a=`ce.custom_fields @> '${JSON.stringify({[t]:e})}'`),`
|
|
69
2
|
(
|
|
70
|
-
${
|
|
71
|
-
|
|
3
|
+
${a?`${a} OR`:``}
|
|
4
|
+
ce.custom_fields @> '${i}'
|
|
72
5
|
)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
WHERE ${conditionsStrings.join(exports.OR_DELIMITER)}
|
|
84
|
-
${exports.AND_DELIMITER}${exports.CV_TABLE_ALIAS}.deleted_at IS NULL${exports.AND_DELIMITER}${exports.CD_TABLE_ALIAS}.deleted_at IS NULL
|
|
85
|
-
GROUP BY ${exports.CV_TABLE_ALIAS}.model_id
|
|
86
|
-
HAVING COUNT(DISTINCT ${exports.CV_TABLE_ALIAS}.custom_field_definition_id) = ${conditionsStrings.length}
|
|
87
|
-
`.replace(/\n/g, '');
|
|
88
|
-
case SubQueryType.ENTRIES:
|
|
89
|
-
return `
|
|
6
|
+
`},h=(t,n,r)=>{switch(t){case e.VALUES:return`
|
|
7
|
+
SELECT cv.model_id
|
|
8
|
+
FROM custom_field_values AS cv
|
|
9
|
+
INNER JOIN custom_field_definitions AS cd ON cv.custom_field_definition_id = cd.id
|
|
10
|
+
${l}cd.model_type = '${n}'
|
|
11
|
+
WHERE ${r.join(u)}
|
|
12
|
+
${l}cv.deleted_at IS NULL${l}cd.deleted_at IS NULL
|
|
13
|
+
GROUP BY cv.model_id
|
|
14
|
+
HAVING COUNT(DISTINCT cv.custom_field_definition_id) = ${r.length}
|
|
15
|
+
`.replace(/\n/g,``);case e.ENTRIES:return`
|
|
90
16
|
SELECT ce.model_id
|
|
91
17
|
FROM custom_field_entries ce
|
|
92
18
|
JOIN custom_field_definitions cfd
|
|
@@ -94,111 +20,27 @@ const getFilterCustomFieldsSubQuery = (queryType, modelType, conditionsStrings)
|
|
|
94
20
|
AND ce.entity_id = cfd.entity_id
|
|
95
21
|
WHERE
|
|
96
22
|
cfd.deleted_at IS NULL AND
|
|
97
|
-
${
|
|
98
|
-
`;
|
|
99
|
-
default:
|
|
100
|
-
throw new Error('Invalid query type');
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
exports.getFilterCustomFieldsSubQuery = getFilterCustomFieldsSubQuery;
|
|
104
|
-
const getSortCustomFieldsSubQuery = (queryType, modelType, replacementKey) => {
|
|
105
|
-
switch (queryType) {
|
|
106
|
-
case SubQueryType.VALUES:
|
|
107
|
-
return `(
|
|
23
|
+
${r.join(l)}
|
|
24
|
+
`;default:throw Error(`Invalid query type`)}},g=(t,n,r)=>{switch(t){case e.VALUES:return`(
|
|
108
25
|
SELECT value
|
|
109
26
|
FROM (SELECT cv.model_id, cv.value
|
|
110
27
|
FROM custom_field_values AS cv INNER JOIN custom_field_definitions AS cd
|
|
111
28
|
ON cv.custom_field_definition_id = cd.id
|
|
112
|
-
${
|
|
113
|
-
WHERE cv.model_id = "${
|
|
114
|
-
${
|
|
29
|
+
${l}cd.model_type = '${n}'
|
|
30
|
+
WHERE cv.model_id = "${n}"."id"
|
|
31
|
+
${l}cd.name = :${r}
|
|
115
32
|
) AS CustomFieldAggregation
|
|
116
33
|
)
|
|
117
|
-
`;
|
|
118
|
-
case SubQueryType.ENTRIES:
|
|
119
|
-
return `(
|
|
34
|
+
`;case e.ENTRIES:return`(
|
|
120
35
|
SELECT
|
|
121
36
|
customFields.value
|
|
122
37
|
FROM
|
|
123
|
-
custom_field_entries AS
|
|
38
|
+
custom_field_entries AS ce,
|
|
124
39
|
jsonb_each_text(custom_fields) AS customFields
|
|
125
40
|
WHERE
|
|
126
|
-
customFields.key = :${
|
|
127
|
-
|
|
128
|
-
|
|
41
|
+
customFields.key = :${r}${l}
|
|
42
|
+
ce.model_type = '${n}'${l}
|
|
43
|
+
ce.model_id = "${n}"."id"
|
|
129
44
|
)
|
|
130
|
-
`;
|
|
131
|
-
|
|
132
|
-
throw new Error('Invalid query type');
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
exports.getSortCustomFieldsSubQuery = getSortCustomFieldsSubQuery;
|
|
136
|
-
const formatConditionsForValues = (key, condition, reverseReplacementsMap) => {
|
|
137
|
-
const replacementKey = reverseReplacementsMap.get(key);
|
|
138
|
-
if (!replacementKey) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
const columnCondition = `(${exports.CD_NAME_COLUMN} = :${replacementKey})`;
|
|
142
|
-
if (Array.isArray(condition)) {
|
|
143
|
-
if (condition.length === 0) {
|
|
144
|
-
// if empty array, the condition is ignored
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
if ((0, exports.isConditionStringArray)(condition)) {
|
|
148
|
-
const values = condition.flatMap((v) => {
|
|
149
|
-
const valRandom = reverseReplacementsMap.get(v);
|
|
150
|
-
if ((0, exports.isBooleanString)(v)) {
|
|
151
|
-
return [(0, exports.castValueToJsonbText)(`:${valRandom}`), (0, exports.castValueToJsonbBoolean)(`:${valRandom}`)];
|
|
152
|
-
}
|
|
153
|
-
if (!Number.isNaN(Number(v))) {
|
|
154
|
-
return (0, exports.castValueToJsonbNumeric)(`:${valRandom}`);
|
|
155
|
-
}
|
|
156
|
-
return (0, exports.castValueToJsonbText)(`:${valRandom}`);
|
|
157
|
-
}).join(',');
|
|
158
|
-
return `(${columnCondition}${exports.AND_DELIMITER}${exports.CV_VALUE_COLUMN} IN (${values}))`;
|
|
159
|
-
}
|
|
160
|
-
return condition.map((c) => {
|
|
161
|
-
const valRep = reverseReplacementsMap.get(c.value);
|
|
162
|
-
const valueAsJsonb = (0, exports.castValueToJsonbText)(`:${valRep}`);
|
|
163
|
-
return `(${columnCondition}${exports.AND_DELIMITER}${(0, exports.castIfNeeded)(exports.CV_VALUE_COLUMN, c.value)} ${c.operator} ${valueAsJsonb})`;
|
|
164
|
-
}).join(exports.AND_DELIMITER);
|
|
165
|
-
}
|
|
166
|
-
if (typeof condition === 'string' || typeof condition === 'number') {
|
|
167
|
-
const conditionRep = reverseReplacementsMap.get(condition);
|
|
168
|
-
const valueAsJsonb = !Number.isNaN(Number(condition)) ? (0, exports.castValueToJsonbNumeric)(`:${conditionRep}`) : (0, exports.castValueToJsonbText)(`:${conditionRep}`);
|
|
169
|
-
const valueAsJsonbBoolean = (0, exports.isBooleanString)(condition) ? `${exports.OR_DELIMITER}${exports.CV_VALUE_COLUMN} = ${(0, exports.castValueToJsonbBoolean)(`:${conditionRep}`)}` : '';
|
|
170
|
-
return `(${columnCondition}${exports.AND_DELIMITER}(${(0, exports.castIfNeeded)(exports.CV_VALUE_COLUMN, condition)} = ${valueAsJsonb}${valueAsJsonbBoolean}))`;
|
|
171
|
-
}
|
|
172
|
-
if (condition?.operator) {
|
|
173
|
-
const valueRep = reverseReplacementsMap.get(condition.value);
|
|
174
|
-
const valueAsJsonb = (0, exports.castValueToJsonbText)(`:${valueRep}`);
|
|
175
|
-
return `( ${columnCondition}${exports.AND_DELIMITER}${(0, exports.castIfNeeded)(exports.CV_VALUE_COLUMN, condition.value)} ${condition.operator} ${valueAsJsonb})`;
|
|
176
|
-
}
|
|
177
|
-
return false;
|
|
178
|
-
};
|
|
179
|
-
exports.formatConditionsForValues = formatConditionsForValues;
|
|
180
|
-
const formatConditionsForEntries = (key, condition, reverseReplacementsMap) => {
|
|
181
|
-
const replacementKey = reverseReplacementsMap.get(key);
|
|
182
|
-
if (!replacementKey) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
if (Array.isArray(condition)) {
|
|
186
|
-
if (condition.length === 0) {
|
|
187
|
-
// if empty array, the condition is ignored
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
if ((0, exports.isConditionStringArray)(condition)) {
|
|
191
|
-
const values = condition.map((value) => getJSONSubQuery(value, key)).join(`${exports.OR_DELIMITER}\n`);
|
|
192
|
-
return `( ${values})`;
|
|
193
|
-
}
|
|
194
|
-
return condition.map((c) => getSingleConditionWithOperator(c.value, c.operator, replacementKey, reverseReplacementsMap)).join(exports.AND_DELIMITER);
|
|
195
|
-
}
|
|
196
|
-
if (typeof condition === 'string' || typeof condition === 'number') {
|
|
197
|
-
return getJSONSubQuery(condition, key);
|
|
198
|
-
}
|
|
199
|
-
if (condition?.operator) {
|
|
200
|
-
return getSingleConditionWithOperator(condition.value, condition.operator, replacementKey, reverseReplacementsMap);
|
|
201
|
-
}
|
|
202
|
-
return false;
|
|
203
|
-
};
|
|
204
|
-
exports.formatConditionsForEntries = formatConditionsForEntries;
|
|
45
|
+
`;default:throw Error(`Invalid query type`)}},_=(e,r,i)=>{let f=i.get(e);if(!f)return!1;let p=`(cd.name = :${f})`;if(Array.isArray(r))return r.length===0?!1:t(r)?`(${p}${l}${d} IN (${r.flatMap(e=>{let t=i.get(e);return n(e)?[a(`:${t}`),o(`:${t}`)]:Number.isNaN(Number(e))?a(`:${t}`):s(`:${t}`)}).join(`,`)}))`:r.map(e=>{let t=a(`:${i.get(e.value)}`);return`(${p}${l}${c(d,e.value)} ${e.operator} ${t})`}).join(l);if(typeof r==`string`||typeof r==`number`){let e=i.get(r),t=Number.isNaN(Number(r))?a(`:${e}`):s(`:${e}`),f=n(r)?`${u}${d} = ${o(`:${e}`)}`:``;return`(${p}${l}(${c(d,r)} = ${t}${f}))`}if(r?.operator){let e=a(`:${i.get(r.value)}`);return`( ${p}${l}${c(d,r.value)} ${r.operator} ${e})`}return!1},v=(e,n,r)=>{let i=r.get(e);return i?Array.isArray(n)?n.length===0?!1:t(n)?`( ${n.map(t=>m(t,e)).join(`${u}\n`)})`:n.map(e=>f(e.value,e.operator,i,r)).join(l):typeof n==`string`||typeof n==`number`?m(n,e):n?.operator?f(n.value,n.operator,i,r):!1:!1};export{e as SubQueryType,v as formatConditionsForEntries,_ as formatConditionsForValues,h as getFilterCustomFieldsSubQuery,g as getSortCustomFieldsSubQuery};
|
|
46
|
+
//# sourceMappingURL=filter.helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter.helpers.js","names":["CD_NAME_COLUMN: `${typeof CD_TABLE_ALIAS}.name`","CV_VALUE_COLUMN: `${typeof CV_TABLE_ALIAS}.value`","formattedValue: string | number | boolean"],"sources":["../../../src/scopes/helpers/filter.helpers.ts"],"sourcesContent":["import type { WhereOptions } from 'sequelize';\n\n/**\n * Type representing possible condition values.\n * Currently supporting strings and arrays of strings.\n * More types to be added (TBA).\n */\nexport interface ConditionWithOperator {\n operator: string;\n value: string;\n}\nexport type ConditionValue = ConditionWithOperator | ConditionWithOperator[] | string | string[];\n\nexport interface CustomFieldSort {\n field: string;\n direction: 'ASC' | 'DESC';\n}\n\nexport interface CustomFieldFilterOptions {\n where?: WhereOptions;\n replacements?: Record<string, string>;\n}\n\nexport enum SubQueryType {\n VALUES = 'values',\n ENTRIES = 'entries',\n}\n\nexport const isConditionStringArray = (input: any): input is string[] => Array.isArray(input) && typeof input[0] === 'string';\nexport const isBooleanString = (input: string): boolean => ['true', 'false'].includes(input.toString());\nexport const isDate = (input: any): input is Date => input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';\n\nexport const castValueToJsonb = (value: string, type: string) => `to_jsonb(${value}::${type})`;\nexport const castValueToJsonbText = (value: string): string => castValueToJsonb(value, 'text');\nexport const castValueToJsonbBoolean = (value: string): string => castValueToJsonb(value, 'boolean');\nexport const castValueToJsonbNumeric = (value: string): string => castValueToJsonb(value, 'numeric');\nexport const castIfNeeded = (columnName: string, conditionValue: string): string => {\n if (isDate(conditionValue)) {\n return castValueToJsonb(columnName, 'timestamp');\n }\n return columnName;\n};\n\nexport const AND_DELIMITER = ' AND ';\nexport const OR_DELIMITER = ' OR ';\nexport const CD_TABLE_ALIAS = 'cd';\nexport const CD_NAME_COLUMN: `${typeof CD_TABLE_ALIAS}.name` = `${CD_TABLE_ALIAS}.name`;\nexport const CV_TABLE_ALIAS = 'cv';\nexport const CV_VALUE_COLUMN: `${typeof CV_TABLE_ALIAS}.value` = `${CV_TABLE_ALIAS}.value`;\nexport const CE_TABLE_ALIAS = 'ce';\n\nconst getSingleConditionWithOperator = (value: any, operator: string, replacementKey: string, reverseReplacementsMap: Map<string, string>) => {\n let type = 'text';\n if (isDate(value)) {\n type = 'date';\n } else if (!Number.isNaN(Number(value))) {\n type = 'numeric';\n } else if (isBooleanString(value)) {\n type = 'boolean';\n }\n const replacedValue = reverseReplacementsMap.get(value);\n\n return `(jsonb_extract_path_text(${CE_TABLE_ALIAS}.custom_fields, :${replacementKey})::${type}) ${operator} :${replacedValue}`;\n};\n\nconst getFormattedValue = (value: string) => {\n let formattedValue: string | number | boolean = value;\n if (isBooleanString(value)) {\n formattedValue = value === 'true';\n } else if (!Number.isNaN(Number(value))) {\n formattedValue = Number(value);\n }\n\n return formattedValue;\n};\n\nconst getJSONSubQuery = (value: string, key: string) => {\n const formattedValue = getFormattedValue(value);\n const jsonQuery = JSON.stringify({ [key]: formattedValue });\n let jsonQueryWithStringBoolean;\n if (isBooleanString(value)) {\n jsonQueryWithStringBoolean = `${CE_TABLE_ALIAS}.custom_fields @> '${JSON.stringify({ [key]: value })}'`;\n }\n return `\n (\n ${jsonQueryWithStringBoolean ? `${jsonQueryWithStringBoolean} OR` : ''}\n ${CE_TABLE_ALIAS}.custom_fields @> '${jsonQuery}'\n )\n `;\n};\n\nexport const getFilterCustomFieldsSubQuery = (queryType: SubQueryType, modelType: string, conditionsStrings: (string | boolean)[]): string => {\n switch (queryType) {\n case SubQueryType.VALUES:\n return `\n SELECT ${CV_TABLE_ALIAS}.model_id\n FROM custom_field_values AS ${CV_TABLE_ALIAS}\n INNER JOIN custom_field_definitions AS ${CD_TABLE_ALIAS} ON ${CV_TABLE_ALIAS}.custom_field_definition_id = ${CD_TABLE_ALIAS}.id\n ${AND_DELIMITER}${CD_TABLE_ALIAS}.model_type = '${modelType}'\n WHERE ${conditionsStrings.join(OR_DELIMITER)}\n ${AND_DELIMITER}${CV_TABLE_ALIAS}.deleted_at IS NULL${AND_DELIMITER}${CD_TABLE_ALIAS}.deleted_at IS NULL\n GROUP BY ${CV_TABLE_ALIAS}.model_id\n HAVING COUNT(DISTINCT ${CV_TABLE_ALIAS}.custom_field_definition_id) = ${conditionsStrings.length}\n `.replace(/\\n/g, '');\n case SubQueryType.ENTRIES:\n return `\n SELECT ce.model_id\n FROM custom_field_entries ce\n JOIN custom_field_definitions cfd\n ON ce.model_type = cfd.model_type\n AND ce.entity_id = cfd.entity_id\n WHERE\n cfd.deleted_at IS NULL AND\n ${conditionsStrings.join(AND_DELIMITER)}\n `;\n default:\n throw new Error('Invalid query type');\n }\n};\n\nexport const getSortCustomFieldsSubQuery = (queryType: SubQueryType, modelType: string, replacementKey: string): string => {\n switch (queryType) {\n case SubQueryType.VALUES:\n return `(\n SELECT value\n FROM (SELECT cv.model_id, cv.value\n FROM custom_field_values AS cv INNER JOIN custom_field_definitions AS cd\n ON cv.custom_field_definition_id = cd.id\n ${AND_DELIMITER}cd.model_type = '${modelType}'\n WHERE cv.model_id = \"${modelType}\".\"id\"\n ${AND_DELIMITER}cd.name = :${replacementKey}\n ) AS CustomFieldAggregation\n )\n `;\n case SubQueryType.ENTRIES:\n return `(\n SELECT\n customFields.value\n FROM\n custom_field_entries AS ${CE_TABLE_ALIAS},\n jsonb_each_text(custom_fields) AS customFields\n WHERE\n customFields.key = :${replacementKey}${AND_DELIMITER}\n ${CE_TABLE_ALIAS}.model_type = '${modelType}'${AND_DELIMITER}\n ${CE_TABLE_ALIAS}.model_id = \"${modelType}\".\"id\"\n )\n `;\n default:\n throw new Error('Invalid query type');\n }\n};\n\nexport const formatConditionsForValues = (key: string, condition: ConditionValue, reverseReplacementsMap: Map<string, string>): false | string => {\n const replacementKey = reverseReplacementsMap.get(key);\n if (!replacementKey) {\n return false;\n }\n\n const columnCondition = `(${CD_NAME_COLUMN} = :${replacementKey})`;\n if (Array.isArray(condition)) {\n if (condition.length === 0) {\n // if empty array, the condition is ignored\n return false;\n }\n\n if (isConditionStringArray(condition)) {\n const values = condition.flatMap((v) => {\n const valRandom = reverseReplacementsMap.get(v);\n if (isBooleanString(v)) {\n return [castValueToJsonbText(`:${valRandom}`), castValueToJsonbBoolean(`:${valRandom}`)];\n }\n if (!Number.isNaN(Number(v))) {\n return castValueToJsonbNumeric(`:${valRandom}`);\n }\n return castValueToJsonbText(`:${valRandom}`);\n }).join(',');\n return `(${columnCondition}${AND_DELIMITER}${CV_VALUE_COLUMN} IN (${values}))`;\n }\n return condition.map((c) => {\n const valRep = reverseReplacementsMap.get(c.value);\n const valueAsJsonb = castValueToJsonbText(`:${valRep}`);\n\n return `(${columnCondition}${AND_DELIMITER}${castIfNeeded(CV_VALUE_COLUMN, c.value)} ${c.operator} ${valueAsJsonb})`;\n }).join(AND_DELIMITER);\n }\n if (typeof condition === 'string' || typeof condition === 'number') {\n const conditionRep = reverseReplacementsMap.get(condition);\n const valueAsJsonb = !Number.isNaN(Number(condition)) ? castValueToJsonbNumeric(`:${conditionRep}`) : castValueToJsonbText(`:${conditionRep}`);\n const valueAsJsonbBoolean = isBooleanString(condition) ? `${OR_DELIMITER}${CV_VALUE_COLUMN} = ${castValueToJsonbBoolean(`:${conditionRep}`)}` : '';\n return `(${columnCondition}${AND_DELIMITER}(${castIfNeeded(CV_VALUE_COLUMN, condition)} = ${valueAsJsonb}${valueAsJsonbBoolean}))`;\n }\n if (condition?.operator) {\n const valueRep = reverseReplacementsMap.get(condition.value);\n const valueAsJsonb = castValueToJsonbText(`:${valueRep}`);\n return `( ${columnCondition}${AND_DELIMITER}${castIfNeeded(CV_VALUE_COLUMN, condition.value)} ${condition.operator} ${valueAsJsonb})`;\n }\n return false;\n};\n\nexport const formatConditionsForEntries = (key: string, condition: ConditionValue, reverseReplacementsMap: Map<string, string>): false | string => {\n const replacementKey = reverseReplacementsMap.get(key);\n if (!replacementKey) {\n return false;\n }\n\n if (Array.isArray(condition)) {\n if (condition.length === 0) {\n // if empty array, the condition is ignored\n return false;\n }\n\n if (isConditionStringArray(condition)) {\n const values = condition.map(value => getJSONSubQuery(value, key)).join(`${OR_DELIMITER}\\n`);\n return `( ${values})`;\n }\n return condition.map(c => getSingleConditionWithOperator(c.value, c.operator, replacementKey, reverseReplacementsMap)).join(AND_DELIMITER);\n }\n\n if (typeof condition === 'string' || typeof condition === 'number') {\n return getJSONSubQuery(condition, key);\n }\n\n if (condition?.operator) {\n return getSingleConditionWithOperator(condition.value, condition.operator, replacementKey, reverseReplacementsMap);\n }\n return false;\n};\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./filter.cjs`);
|
package/dist/scopes/index.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customFieldsFilterScope = void 0;
|
|
4
|
-
/* eslint-disable import/prefer-default-export */
|
|
5
|
-
const filter_1 = require("./filter");
|
|
6
|
-
Object.defineProperty(exports, "customFieldsFilterScope", { enumerable: true, get: function () { return filter_1.customFieldsFilterScope; } });
|
|
1
|
+
import{customFieldsFilterScope as e}from"./filter.js";export{};
|