@autofleet/sadot 0.13.3-beta.0 → 0.13.4
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/hooks/enrich.js
CHANGED
|
@@ -32,7 +32,20 @@ const ValueRepo = __importStar(require("../repository/value"));
|
|
|
32
32
|
const DefinitionRepo = __importStar(require("../repository/definition"));
|
|
33
33
|
const EntriesRepo = __importStar(require("../repository/entries"));
|
|
34
34
|
const scopeAttributes_1 = __importDefault(require("../utils/scopeAttributes"));
|
|
35
|
-
|
|
35
|
+
// Include all required fields for proper functioning
|
|
36
|
+
const CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL = [
|
|
37
|
+
'id',
|
|
38
|
+
'name',
|
|
39
|
+
'entityId',
|
|
40
|
+
'fieldType',
|
|
41
|
+
'displayName',
|
|
42
|
+
'validation',
|
|
43
|
+
'entityType',
|
|
44
|
+
'modelType',
|
|
45
|
+
'required',
|
|
46
|
+
'disabled',
|
|
47
|
+
'defaultValue',
|
|
48
|
+
];
|
|
36
49
|
const getCustomFieldEntriesByInstanceId = async ({ instancesIds, options, sadotOptions, }) => {
|
|
37
50
|
if (!sadotOptions.useCustomFieldsEntries) {
|
|
38
51
|
return {};
|
|
@@ -116,6 +129,7 @@ const enrichResults = (modelType, scopeAttributes, hookType, modelOptions = {},
|
|
|
116
129
|
instances.forEach((instance) => {
|
|
117
130
|
instance.customFields = {};
|
|
118
131
|
});
|
|
132
|
+
return;
|
|
119
133
|
}
|
|
120
134
|
if (modelOptions?.include && modelOptions.useEntityIdFromInclude) {
|
|
121
135
|
// if we pass useEntityIdFromInclude,
|
package/dist/hooks/hooks.js
CHANGED
|
@@ -38,7 +38,8 @@ const errors_2 = require("../errors");
|
|
|
38
38
|
const scopeAttributes_1 = __importDefault(require("../utils/scopeAttributes"));
|
|
39
39
|
const updateInstanceValues_1 = __importDefault(require("./utils/updateInstanceValues"));
|
|
40
40
|
const constants_1 = require("../utils/constants");
|
|
41
|
-
|
|
41
|
+
// Include all required fields for proper validation
|
|
42
|
+
const CUSTOM_VALIDATOR_ATTRIBUTES_TO_PULL = ['id', 'schema', 'modelType', 'entityId', 'disabled'];
|
|
42
43
|
// Initialize Ajv with relaxed settings to avoid warnings
|
|
43
44
|
const ajv = new ajv_1.default({
|
|
44
45
|
allErrors: true,
|
|
@@ -120,6 +121,7 @@ const validateModel = async (instance, options, scopeAttributes, isCreate = fals
|
|
|
120
121
|
validatorsPromise = ValidatorRepo.findAllByModelType(modelType, entityId, {
|
|
121
122
|
transaction: options.transaction,
|
|
122
123
|
attributes: CUSTOM_VALIDATOR_ATTRIBUTES_TO_PULL,
|
|
124
|
+
raw: true,
|
|
123
125
|
});
|
|
124
126
|
if (options.transaction) {
|
|
125
127
|
options?.transaction?.validationsCache.set(cacheKey, validatorsPromise);
|
package/package.json
CHANGED
package/src/hooks/enrich.ts
CHANGED
|
@@ -8,7 +8,20 @@ import type { SerializedCustomFields } from '../types/definition';
|
|
|
8
8
|
import type { CustomFieldOptions, ModelOptions, TransactionOptions } from '../types';
|
|
9
9
|
import applyScopeToInstance from '../utils/scopeAttributes';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// Include all required fields for proper functioning
|
|
12
|
+
const CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL = [
|
|
13
|
+
'id',
|
|
14
|
+
'name',
|
|
15
|
+
'entityId',
|
|
16
|
+
'fieldType',
|
|
17
|
+
'displayName',
|
|
18
|
+
'validation',
|
|
19
|
+
'entityType',
|
|
20
|
+
'modelType',
|
|
21
|
+
'required',
|
|
22
|
+
'disabled',
|
|
23
|
+
'defaultValue',
|
|
24
|
+
];
|
|
12
25
|
|
|
13
26
|
type SupportedHookTypes = 'afterFind' | 'afterCreate' | 'afterUpdate';
|
|
14
27
|
|
|
@@ -162,6 +175,7 @@ const enrichResults = (
|
|
|
162
175
|
instances.forEach((instance) => {
|
|
163
176
|
instance.customFields = {};
|
|
164
177
|
});
|
|
178
|
+
return;
|
|
165
179
|
}
|
|
166
180
|
|
|
167
181
|
if (modelOptions?.include && modelOptions.useEntityIdFromInclude) {
|
package/src/hooks/hooks.ts
CHANGED
|
@@ -13,7 +13,8 @@ import updateInstanceValues from './utils/updateInstanceValues';
|
|
|
13
13
|
import { CustomFieldDefinitionType } from '../utils/constants';
|
|
14
14
|
import type { CustomFieldDefinition } from '../models';
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// Include all required fields for proper validation
|
|
17
|
+
const CUSTOM_VALIDATOR_ATTRIBUTES_TO_PULL = ['id', 'schema', 'modelType', 'entityId', 'disabled'];
|
|
17
18
|
|
|
18
19
|
// Initialize Ajv with relaxed settings to avoid warnings
|
|
19
20
|
const ajv = new Ajv({
|
|
@@ -123,6 +124,7 @@ const validateModel = async (
|
|
|
123
124
|
{
|
|
124
125
|
transaction: options.transaction,
|
|
125
126
|
attributes: CUSTOM_VALIDATOR_ATTRIBUTES_TO_PULL,
|
|
127
|
+
raw: true,
|
|
126
128
|
},
|
|
127
129
|
);
|
|
128
130
|
if (options.transaction) {
|