@autofleet/sadot 0.13.5-beta.1 → 0.13.5
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/utils/init.js +4 -2
- package/package.json +2 -2
- package/src/utils/init.ts +3 -2
package/dist/utils/init.js
CHANGED
|
@@ -73,7 +73,9 @@ exports.removeHooks = removeHooks;
|
|
|
73
73
|
/**
|
|
74
74
|
* Necessary associations for the {@link customFieldsFilterScope} scope
|
|
75
75
|
*/
|
|
76
|
-
const addAssociations = (model, modelName) => {
|
|
76
|
+
const addAssociations = (model, modelName, options) => {
|
|
77
|
+
if (options?.useCustomFieldsEntries)
|
|
78
|
+
return;
|
|
77
79
|
model.hasMany(models_1.CustomFieldValue, { foreignKey: 'modelId', as: 'customFieldValue' });
|
|
78
80
|
// TBC: maybe can be removed
|
|
79
81
|
models_1.CustomFieldValue.belongsTo(model, { foreignKey: 'modelId', as: modelName });
|
|
@@ -90,7 +92,7 @@ const addScopes = (models, getModel, options = { useCustomFieldsEntries: false }
|
|
|
90
92
|
return;
|
|
91
93
|
}
|
|
92
94
|
// Necessary associations for the filtering scope
|
|
93
|
-
addAssociations(model, name);
|
|
95
|
+
addAssociations(model, name, options);
|
|
94
96
|
// Add filter scope
|
|
95
97
|
model.addScope(CUSTOM_FIELDS_FILTER_SCOPE, (0, scopes_1.customFieldsFilterScope)(name, options));
|
|
96
98
|
model.addScope(custom_fields_1.CUSTOM_FIELDS_SORT_SCOPE, (0, filter_1.customFieldsSortScope)(name, options));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/sadot",
|
|
3
|
-
"version": "0.13.5
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"typescript": "^5.3.3"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@autofleet/errors": "^3
|
|
63
|
+
"@autofleet/errors": "^3",
|
|
64
64
|
"@autofleet/logger": "^4",
|
|
65
65
|
"@autofleet/node-common": "^4",
|
|
66
66
|
"@autofleet/sheilta": "^2",
|
package/src/utils/init.ts
CHANGED
|
@@ -84,7 +84,8 @@ export const removeHooks = (models: Models[], getModel: ModelFetcher): void => {
|
|
|
84
84
|
/**
|
|
85
85
|
* Necessary associations for the {@link customFieldsFilterScope} scope
|
|
86
86
|
*/
|
|
87
|
-
const addAssociations = (model: ModelCtor, modelName: string): void => {
|
|
87
|
+
const addAssociations = (model: ModelCtor, modelName: string, options: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>): void => {
|
|
88
|
+
if (options?.useCustomFieldsEntries) return;
|
|
88
89
|
model.hasMany(CustomFieldValue, { foreignKey: 'modelId', as: 'customFieldValue' });
|
|
89
90
|
// TBC: maybe can be removed
|
|
90
91
|
CustomFieldValue.belongsTo(model, { foreignKey: 'modelId', as: modelName });
|
|
@@ -102,7 +103,7 @@ export const addScopes = (models: Models[], getModel: ModelFetcher, options: Pic
|
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
104
105
|
// Necessary associations for the filtering scope
|
|
105
|
-
addAssociations(model, name);
|
|
106
|
+
addAssociations(model, name, options);
|
|
106
107
|
// Add filter scope
|
|
107
108
|
model.addScope(CUSTOM_FIELDS_FILTER_SCOPE, customFieldsFilterScope(name, options));
|
|
108
109
|
model.addScope(CUSTOM_FIELDS_SORT_SCOPE, customFieldsSortScope(name, options));
|