@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.
@@ -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
- const CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL = ['id', 'name', 'entityId'];
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,
@@ -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
- const CUSTOM_VALIDATOR_ATTRIBUTES_TO_PULL = ['schema'];
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);
@@ -3,6 +3,7 @@ import { CustomValidator } from '../models';
3
3
  export interface FindValidatorOptions extends Transactionable {
4
4
  withDisabled?: boolean;
5
5
  attributes?: string[];
6
+ raw?: boolean;
6
7
  }
7
8
  export interface ValidatorAttributes {
8
9
  entityId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/sadot",
3
- "version": "0.13.3-beta.0",
3
+ "version": "0.13.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -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
- const CUSTOM_FIELD_DEFINITION_ATTRIBUTES_TO_PULL = ['id', 'name', 'entityId'];
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) {
@@ -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
- const CUSTOM_VALIDATOR_ATTRIBUTES_TO_PULL = ['schema'];
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) {
@@ -5,6 +5,7 @@ import { CustomValidator } from '../models';
5
5
  export interface FindValidatorOptions extends Transactionable {
6
6
  withDisabled?: boolean;
7
7
  attributes?: string[];
8
+ raw?: boolean;
8
9
  }
9
10
 
10
11
  // Make sure this interface is compatible with the Sequelize model