@autofleet/sadot 0.7.10-beta.6 → 0.7.10-beta.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/errors/index.js
CHANGED
|
@@ -39,18 +39,12 @@ class InvalidValueError extends errors_1.BadRequest {
|
|
|
39
39
|
constructor(value, fieldDefinitionName, joiValidationError) {
|
|
40
40
|
const formattedErrorMessage = joiValidationError.message
|
|
41
41
|
.replace(/"/g, '')
|
|
42
|
-
.replace('value', fieldDefinitionName);
|
|
42
|
+
.replace('value', `'${fieldDefinitionName}'`);
|
|
43
43
|
const formattedValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
field: fieldDefinitionName,
|
|
47
|
-
value: formattedValue,
|
|
48
|
-
message: formattedErrorMessage,
|
|
49
|
-
};
|
|
50
|
-
const detailedMessage = JSON.stringify(errorJson, null, 2);
|
|
51
|
-
const err = new Error(detailedMessage);
|
|
44
|
+
const invalidValueMessage = `Invalid Value on field '${fieldDefinitionName}'. ${formattedErrorMessage}. received: '${formattedValue}'`;
|
|
45
|
+
const err = new Error(invalidValueMessage);
|
|
52
46
|
super([err], null, null);
|
|
53
|
-
this.message =
|
|
47
|
+
this.message = invalidValueMessage;
|
|
54
48
|
}
|
|
55
49
|
}
|
|
56
50
|
exports.InvalidValueError = InvalidValueError;
|
|
@@ -41,5 +41,6 @@ export declare const coolFieldDefinition3: {
|
|
|
41
41
|
export declare const booleanField: (modelType: string) => CreateCustomFieldDefinition;
|
|
42
42
|
export declare const selectField: (modelType: string, options: any) => CreateCustomFieldDefinition;
|
|
43
43
|
export declare const statusField: (modelType: string, options: any) => CreateCustomFieldDefinition;
|
|
44
|
+
export declare const fileField: (modelType: string) => CreateCustomFieldDefinition;
|
|
44
45
|
export declare const createDefinition: (defaults: Partial<CustomFieldDefinitionDTO>) => CreateCustomFieldDefinition;
|
|
45
46
|
export declare const createDefinitions: (defaults: Partial<CustomFieldDefinitionDTO>, length?: number) => CreateCustomFieldDefinition[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createDefinitions = exports.createDefinition = exports.statusField = exports.selectField = exports.booleanField = exports.coolFieldDefinition3 = exports.coolFieldDefinition2 = exports.coolFieldDefinition = exports.contextAwareFieldDefinition = void 0;
|
|
3
|
+
exports.createDefinitions = exports.createDefinition = exports.fileField = exports.statusField = exports.selectField = exports.booleanField = exports.coolFieldDefinition3 = exports.coolFieldDefinition2 = exports.coolFieldDefinition = exports.contextAwareFieldDefinition = void 0;
|
|
4
4
|
const node_crypto_1 = require("node:crypto");
|
|
5
5
|
exports.contextAwareFieldDefinition = {
|
|
6
6
|
name: 'cool field',
|
|
@@ -49,6 +49,14 @@ const statusField = (modelType, options) => ({
|
|
|
49
49
|
entityType: 'fleetId',
|
|
50
50
|
});
|
|
51
51
|
exports.statusField = statusField;
|
|
52
|
+
const fileField = (modelType) => ({
|
|
53
|
+
name: 'file',
|
|
54
|
+
modelType,
|
|
55
|
+
fieldType: 'file',
|
|
56
|
+
entityId: (0, node_crypto_1.randomUUID)(),
|
|
57
|
+
entityType: 'fleetId',
|
|
58
|
+
});
|
|
59
|
+
exports.fileField = fileField;
|
|
52
60
|
// eslint-disable-next-line max-len
|
|
53
61
|
const createDefinition = (defaults) => ({
|
|
54
62
|
name: defaults?.name || `def_${(0, node_crypto_1.randomUUID)()}`,
|
package/package.json
CHANGED
package/src/errors/index.ts
CHANGED
|
@@ -38,22 +38,15 @@ export class InvalidValueError extends BadRequest {
|
|
|
38
38
|
constructor(value: any, fieldDefinitionName: string, joiValidationError: ValidationError) {
|
|
39
39
|
const formattedErrorMessage = joiValidationError.message
|
|
40
40
|
.replace(/"/g, '')
|
|
41
|
-
.replace('value', fieldDefinitionName);
|
|
41
|
+
.replace('value', `'${fieldDefinitionName}'`);
|
|
42
42
|
|
|
43
43
|
const formattedValue = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
error: 'INVALID_CUSTOM_FIELD_VALUE',
|
|
47
|
-
field: fieldDefinitionName,
|
|
48
|
-
value: formattedValue,
|
|
49
|
-
message: formattedErrorMessage,
|
|
50
|
-
};
|
|
45
|
+
const invalidValueMessage = `Invalid Value on field '${fieldDefinitionName}'. ${formattedErrorMessage}. received: '${formattedValue}'`;
|
|
51
46
|
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const err = new Error(detailedMessage);
|
|
47
|
+
const err = new Error(invalidValueMessage);
|
|
55
48
|
super([err], null, null);
|
|
56
|
-
this.message =
|
|
49
|
+
this.message = invalidValueMessage;
|
|
57
50
|
}
|
|
58
51
|
}
|
|
59
52
|
|
|
@@ -52,6 +52,14 @@ export const statusField = (modelType: string, options): CreateCustomFieldDefini
|
|
|
52
52
|
entityType: 'fleetId',
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
+
export const fileField = (modelType: string): CreateCustomFieldDefinition => ({
|
|
56
|
+
name: 'file',
|
|
57
|
+
modelType,
|
|
58
|
+
fieldType: 'file',
|
|
59
|
+
entityId: uuidv4(),
|
|
60
|
+
entityType: 'fleetId',
|
|
61
|
+
});
|
|
62
|
+
|
|
55
63
|
// eslint-disable-next-line max-len
|
|
56
64
|
export const createDefinition = (defaults: Partial<CustomFieldDefinitionDTO>): CreateCustomFieldDefinition => ({
|
|
57
65
|
name: defaults?.name || `def_${uuidv4()}`,
|