@autofleet/sadot 0.0.1-beta.9 → 0.1.0
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/api/v1/definition/index.js +3 -3
- package/dist/api/v1/definition/index.js.map +1 -1
- package/dist/api/v1/definition/validations.js +5 -7
- package/dist/api/v1/definition/validations.js.map +1 -1
- package/dist/api/v1/index.js +1 -1
- package/dist/errors/index.js +46 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/hooks/create.js +5 -3
- package/dist/hooks/create.js.map +1 -1
- package/dist/hooks/enrich.js +110 -0
- package/dist/hooks/enrich.js.map +1 -0
- package/dist/hooks/find.js +3 -113
- package/dist/hooks/find.js.map +1 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/update.js +0 -10
- package/dist/hooks/update.js.map +1 -1
- package/dist/index.js +39 -16
- package/dist/index.js.map +1 -1
- package/dist/models/CustomFieldDefinition.js +21 -16
- package/dist/models/CustomFieldDefinition.js.map +1 -1
- package/dist/models/CustomFieldValue.js +5 -7
- package/dist/models/CustomFieldValue.js.map +1 -1
- package/dist/models/index.js +18 -5
- package/dist/models/index.js.map +1 -1
- package/dist/repository/definition.js +6 -10
- package/dist/repository/definition.js.map +1 -1
- package/dist/repository/value.js +2 -1
- package/dist/repository/value.js.map +1 -1
- package/dist/tests/mocks/{index.js → definition.mock.js} +3 -5
- package/dist/tests/mocks/definition.mock.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/validations/custom.js +25 -41
- package/dist/utils/validations/custom.js.map +1 -1
- package/dist/utils/validations/type.js +27 -9
- package/dist/utils/validations/type.js.map +1 -1
- package/dist/utils/validations/validators.js +34 -0
- package/dist/utils/validations/validators.js.map +1 -0
- package/package.json +1 -1
- package/src/api/v1/definition/index.ts +5 -5
- package/src/api/v1/definition/validations.ts +5 -23
- package/src/api/v1/index.ts +1 -1
- package/src/errors/index.ts +42 -0
- package/src/hooks/create.ts +5 -3
- package/src/hooks/enrich.ts +102 -0
- package/src/hooks/find.ts +1 -102
- package/src/hooks/index.ts +2 -1
- package/src/hooks/update.ts +0 -15
- package/src/index.ts +37 -15
- package/src/models/CustomFieldDefinition.ts +23 -16
- package/src/models/CustomFieldValue.ts +7 -7
- package/src/models/index.ts +21 -7
- package/src/repository/definition.ts +6 -10
- package/src/repository/value.ts +2 -1
- package/src/tests/mocks/{index.ts → definition.mock.ts} +2 -4
- package/src/types/index.ts +1 -3
- package/src/utils/validations/custom.ts +26 -44
- package/src/utils/validations/type.ts +21 -5
- package/src/utils/validations/validators.ts +34 -0
- package/dist/tests/mocks/index.js.map +0 -1
|
@@ -51,8 +51,8 @@ router.post('/', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
51
51
|
const { modelName } = req.params;
|
|
52
52
|
const modelType = toPascalCase(modelName);
|
|
53
53
|
try {
|
|
54
|
-
const validatedPayload = yield (0, validations_1.validateCustomFieldDefinitionCreation)(
|
|
55
|
-
const customFieldDefinition = yield DefinitionRepo.create(validatedPayload);
|
|
54
|
+
const validatedPayload = yield (0, validations_1.validateCustomFieldDefinitionCreation)(req.body);
|
|
55
|
+
const customFieldDefinition = yield DefinitionRepo.create(Object.assign(Object.assign({}, validatedPayload), { modelType }));
|
|
56
56
|
return res.status(201).json(customFieldDefinition);
|
|
57
57
|
}
|
|
58
58
|
catch (err) {
|
|
@@ -110,7 +110,7 @@ router.patch('/:customFieldDefinitionId', (req, res) => __awaiter(void 0, void 0
|
|
|
110
110
|
if (!customFieldDefinition) {
|
|
111
111
|
throw new errors_1.ResourceNotFoundError();
|
|
112
112
|
}
|
|
113
|
-
const updatedCustomFieldDefinition = yield DefinitionRepo.update(customFieldDefinitionId, validatedPayload);
|
|
113
|
+
const updatedCustomFieldDefinition = yield DefinitionRepo.update(customFieldDefinitionId, Object.assign(Object.assign({}, validatedPayload), { modelType }));
|
|
114
114
|
return res.status(200).json(updatedCustomFieldDefinition);
|
|
115
115
|
}
|
|
116
116
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/v1/definition/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA0D;AAC1D,qCAAiC;AAEjC,uDAAoC;AACpC,+EAAiE;AAEjE,+CAA2G;AAC3G,mEAA2C;AAE3C,MAAM,MAAM,GAAG,IAAA,gBAAM,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,MAAM,MAAM,GAAG,uBAAuB,CAAC;AAEvC,MAAM,YAAY,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;AAE3H;;GAEG;AACH,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAO,GAAY,EAAE,GAAa,EAAE,EAAE;IACrD,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAa,CAAC;IACxC,MAAM,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,IAAI;QACF,MAAM,gBAAgB,GAAgC,MACtD,IAAA,mDAAqC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/v1/definition/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA0D;AAC1D,qCAAiC;AAEjC,uDAAoC;AACpC,+EAAiE;AAEjE,+CAA2G;AAC3G,mEAA2C;AAE3C,MAAM,MAAM,GAAG,IAAA,gBAAM,EAAC,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7C,MAAM,MAAM,GAAG,uBAAuB,CAAC;AAEvC,MAAM,YAAY,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GAAG,CAAC,IAAI,CAAC,CAAC;QAE1G,MAAM,qBAAqB,GAAG,MAAM,cAAc,CAAC,WAAW,CAAC;YAC7D,EAAE,EAAE,uBAAuB;YAC3B,SAAS;SACV,CAAC,CAAC;QAEH,IAAI,CAAC,qBAAqB,EAAE;YAC1B,MAAM,IAAI,8BAAqB,EAAE,CAAC;SACnC;QAED,MAAM,4BAA4B,GAAG,MAAM,cAAc,CAAC,MAAM,CAC9D,uBAAuB,kCAClB,gBAAgB,KAAE,SAAS,IACjC,CAAC;QAEF,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;KAC3D;IAAC,OAAO,GAAG,EAAE;QACZ,gBAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAC;QAC7D,OAAO,IAAA,gBAAW,EAAC,GAAG,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,mBAAmB,MAAM,UAAU,EAAE,CAAC,CAAC;KAChF;AACH,CAAC,CAAA,CAAC,CAAC;AAEH,kBAAe,MAAM,CAAC"}
|
|
@@ -5,26 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validateCustomFieldDefinitionUpdate = exports.validateCustomFieldDefinitionCreation = void 0;
|
|
7
7
|
const joi_1 = __importDefault(require("@hapi/joi"));
|
|
8
|
-
const
|
|
8
|
+
const type_1 = require("../../../utils/validations/type");
|
|
9
9
|
const CustomFieldDefinitionCreationSchema = joi_1.default.object({
|
|
10
10
|
name: joi_1.default.string().required(),
|
|
11
11
|
displayName: joi_1.default.string().required(),
|
|
12
|
-
validation: joi_1.default.
|
|
13
|
-
fieldType: joi_1.default.string().valid(
|
|
12
|
+
validation: joi_1.default.any().required(),
|
|
13
|
+
fieldType: joi_1.default.string().valid(...Object.values(type_1.CustomFieldDefinitionType)).required(),
|
|
14
14
|
entityId: joi_1.default.string().guid().required(),
|
|
15
15
|
entityType: joi_1.default.string().required(),
|
|
16
|
-
modelType: joi_1.default.string().required(),
|
|
17
16
|
description: joi_1.default.string(),
|
|
18
17
|
required: joi_1.default.boolean(),
|
|
19
18
|
disabled: joi_1.default.boolean(),
|
|
20
19
|
});
|
|
21
20
|
const CustomFieldDefinitionUpdateSchema = joi_1.default.object({
|
|
22
21
|
displayName: joi_1.default.string(),
|
|
23
|
-
validation: joi_1.default.
|
|
24
|
-
fieldType: joi_1.default.string().valid(
|
|
22
|
+
validation: joi_1.default.any(),
|
|
23
|
+
fieldType: joi_1.default.string().valid(...Object.values(type_1.CustomFieldDefinitionType)),
|
|
25
24
|
entityId: joi_1.default.string().guid(),
|
|
26
25
|
entityType: joi_1.default.string(),
|
|
27
|
-
modelType: joi_1.default.string(),
|
|
28
26
|
description: joi_1.default.string(),
|
|
29
27
|
required: joi_1.default.boolean(),
|
|
30
28
|
disabled: joi_1.default.boolean(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../../../src/api/v1/definition/validations.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"validations.js","sourceRoot":"","sources":["../../../../src/api/v1/definition/validations.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,0DAA4E;AAE5E,MAAM,mCAAmC,GAAG,aAAG,CAAC,MAAM,CAAC;IACrD,IAAI,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,WAAW,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACpC,UAAU,EAAE,aAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,SAAS,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,gCAAyB,CAAC,CAAC,CAAC,QAAQ,EAAE;IACrF,QAAQ,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACxC,UAAU,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,WAAW,EAAE,aAAG,CAAC,MAAM,EAAE;IACzB,QAAQ,EAAE,aAAG,CAAC,OAAO,EAAE;IACvB,QAAQ,EAAE,aAAG,CAAC,OAAO,EAAE;CACxB,CAAC,CAAC;AAEH,MAAM,iCAAiC,GAAG,aAAG,CAAC,MAAM,CAAC;IACnD,WAAW,EAAE,aAAG,CAAC,MAAM,EAAE;IACzB,UAAU,EAAE,aAAG,CAAC,GAAG,EAAE;IACrB,SAAS,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,gCAAyB,CAAC,CAAC;IAC1E,QAAQ,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE;IAC7B,UAAU,EAAE,aAAG,CAAC,MAAM,EAAE;IACxB,WAAW,EAAE,aAAG,CAAC,MAAM,EAAE;IACzB,QAAQ,EAAE,aAAG,CAAC,OAAO,EAAE;IACvB,QAAQ,EAAE,aAAG,CAAC,OAAO,EAAE;CACxB,CAAC,CAAC;AAEI,MAAM,qCAAqC,GAAG,CAAC,OAAO,EAAE,EAAE,CAC/D,mCAAmC,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AADvE,QAAA,qCAAqC,yCACkC;AAE7E,MAAM,mCAAmC,GAAG,CAAC,OAAO,EAAE,EAAE,CAC7D,iCAAiC,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;AADrE,QAAA,mCAAmC,uCACkC"}
|
package/dist/api/v1/index.js
CHANGED
|
@@ -6,6 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const express_1 = require("express");
|
|
7
7
|
const definition_1 = __importDefault(require("./definition"));
|
|
8
8
|
const router = (0, express_1.Router)({ mergeParams: true });
|
|
9
|
-
router.use('
|
|
9
|
+
router.use('/custom-field-definitions/:modelName', definition_1.default);
|
|
10
10
|
exports.default = router;
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingDefinitionError = exports.InvalidValueError = exports.UnsupportedCustomValidationError = exports.UnsupportedCustomFieldTypeError = exports.MissingRequiredCustomFieldError = void 0;
|
|
4
|
+
/* eslint-disable max-classes-per-file */
|
|
5
|
+
const errors_1 = require("@autofleet/errors");
|
|
6
|
+
class MissingRequiredCustomFieldError extends errors_1.BadRequest {
|
|
7
|
+
constructor(missingFields) {
|
|
8
|
+
const err = new Error(`The following custom fields are required: ${missingFields.join(',')}`);
|
|
9
|
+
super([err], null, missingFields);
|
|
10
|
+
this.message = 'MISSING_REQUIRED_CUSTOM_FIELDS';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.MissingRequiredCustomFieldError = MissingRequiredCustomFieldError;
|
|
14
|
+
class UnsupportedCustomFieldTypeError extends errors_1.BadRequest {
|
|
15
|
+
constructor(fieldType) {
|
|
16
|
+
const err = new Error(`Type "${fieldType}" is not supported`);
|
|
17
|
+
super([err], null, null);
|
|
18
|
+
this.message = 'UNSUPPORTED_CUSTOM_FIELD_TYPE';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.UnsupportedCustomFieldTypeError = UnsupportedCustomFieldTypeError;
|
|
22
|
+
class UnsupportedCustomValidationError extends errors_1.BadRequest {
|
|
23
|
+
constructor(fieldType) {
|
|
24
|
+
const err = new Error(`Validation for "${fieldType}" is not supported`);
|
|
25
|
+
super([err], null, null);
|
|
26
|
+
this.message = 'UNSUPPORTED_CUSTOM_VALIDATION_TYPE';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.UnsupportedCustomValidationError = UnsupportedCustomValidationError;
|
|
30
|
+
class InvalidValueError extends errors_1.BadRequest {
|
|
31
|
+
constructor(value, fieldType) {
|
|
32
|
+
const err = new Error(`Invalid "${fieldType}" value ${JSON.stringify(value)}`);
|
|
33
|
+
super([err], null, null);
|
|
34
|
+
this.message = 'INVALID_VALUE';
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.InvalidValueError = InvalidValueError;
|
|
38
|
+
class MissingDefinitionError extends errors_1.BadRequest {
|
|
39
|
+
constructor(fieldNames) {
|
|
40
|
+
const err = new Error(`Missing custom field definition for field ${fieldNames.join(',')}`);
|
|
41
|
+
super([err], null, null);
|
|
42
|
+
this.message = 'MISSING_DEFINITION';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.MissingDefinitionError = MissingDefinitionError;
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,8CAA+C;AAE/C,MAAa,+BAAgC,SAAQ,mBAAU;IAC7D,YAAY,aAAuB;QACjC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,6CAA6C,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9F,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,gCAAgC,CAAC;IAClD,CAAC;CACF;AAND,0EAMC;AAED,MAAa,+BAAgC,SAAQ,mBAAU;IAC7D,YAAY,SAAiB;QAC3B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,SAAS,SAAS,oBAAoB,CAAC,CAAC;QAC9D,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,+BAA+B,CAAC;IACjD,CAAC;CACF;AAND,0EAMC;AAED,MAAa,gCAAiC,SAAQ,mBAAU;IAC9D,YAAY,SAAiB;QAC3B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,mBAAmB,SAAS,oBAAoB,CAAC,CAAC;QACxE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,oCAAoC,CAAC;IACtD,CAAC;CACF;AAND,4EAMC;AAED,MAAa,iBAAkB,SAAQ,mBAAU;IAC/C,YAAY,KAAU,EAAE,SAAiB;QACvC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,YAAY,SAAS,WAAW,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC/E,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,eAAe,CAAC;IACjC,CAAC;CACF;AAND,8CAMC;AAED,MAAa,sBAAuB,SAAQ,mBAAU;IACpD,YAAY,UAAoB;QAC9B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,6CAA6C,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3F,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,oBAAoB,CAAC;IACtC,CAAC;CACF;AAND,wDAMC"}
|
package/dist/hooks/create.js
CHANGED
|
@@ -35,6 +35,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
exports.beforeCreate = exports.beforeBulkCreate = void 0;
|
|
36
36
|
const ValueRepo = __importStar(require("../repository/value"));
|
|
37
37
|
const DefinitionRepo = __importStar(require("../repository/definition"));
|
|
38
|
+
const errors_1 = require("../errors");
|
|
38
39
|
/**
|
|
39
40
|
* A hook to create the custom fields when updating a model (more then one instance).
|
|
40
41
|
*/
|
|
@@ -58,15 +59,16 @@ const beforeCreate = (scopeAttributes) => (instance, options) => __awaiter(void
|
|
|
58
59
|
const { customFields } = instance;
|
|
59
60
|
if (customFieldsIdx > -1 && customFields) {
|
|
60
61
|
const fieldsNames = Object.keys(customFields);
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
const missingFields = requiredFieldsNames.filter((name) => !fieldsNames.includes(name));
|
|
63
|
+
if ((missingFields === null || missingFields === void 0 ? void 0 : missingFields.length) > 0) {
|
|
64
|
+
throw new errors_1.MissingRequiredCustomFieldError(missingFields);
|
|
63
65
|
}
|
|
64
66
|
yield ValueRepo.updateValues(modelType, instance.id, identifiers, customFields, { transaction: options.transaction });
|
|
65
67
|
// eslint-disable-next-line no-param-reassign
|
|
66
68
|
fields.splice(customFieldsIdx, 1);
|
|
67
69
|
}
|
|
68
70
|
else if ((requiredFieldsNames === null || requiredFieldsNames === void 0 ? void 0 : requiredFieldsNames.length) > 0) {
|
|
69
|
-
throw new
|
|
71
|
+
throw new errors_1.MissingRequiredCustomFieldError(requiredFieldsNames);
|
|
70
72
|
}
|
|
71
73
|
});
|
|
72
74
|
exports.beforeCreate = beforeCreate;
|
package/dist/hooks/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/hooks/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAiD;AACjD,yEAA2D;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/hooks/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAiD;AACjD,yEAA2D;AAC3D,sCAA4D;AAE5D;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAQ,EAAE;IAChD,sEAAsE;IACtE,6CAA6C;IAC7C,OAAO,CAAC,eAAe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Ae,EAAE,CAAC,CAAC,CAAC;KACnC;SAAM,IAAI,CAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,IAAG,CAAC,EAAE;QAC1C,MAAM,IAAI,wCAA+B,CAAC,mBAAmB,CAAC,CAAC;KAChE;AACH,CAAC,CAAA,CAAC;AAhCW,QAAA,YAAY,gBAgCvB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
/* eslint-disable no-param-reassign */
|
|
36
|
+
const ValueRepo = __importStar(require("../repository/value"));
|
|
37
|
+
const DefinitionRepo = __importStar(require("../repository/definition"));
|
|
38
|
+
/**
|
|
39
|
+
* Serialize custom fields value into the format of {[name] -> [fieldData]}
|
|
40
|
+
*/
|
|
41
|
+
const serializeCustomFields = (customFieldValues) => {
|
|
42
|
+
const customFields = customFieldValues.reduce((acc, cfv) => (Object.assign(Object.assign({}, acc), { [cfv.customFieldDefinition.name]: cfv.value })), {});
|
|
43
|
+
return customFields;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A hook to attach the custom fields when fetching a model instances.
|
|
47
|
+
*/
|
|
48
|
+
const enrichResults = (scopeAttributes) => (instancesOrInstance, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
if (((_a = options.originalAttributes) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
51
|
+
&& !((_c = (_b = options.originalAttributes) === null || _b === void 0 ? void 0 : _b.includes) === null || _c === void 0 ? void 0 : _c.call(_b, 'customFields'))) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const primaryKey = 'id';
|
|
55
|
+
let instances = Array.isArray(instancesOrInstance)
|
|
56
|
+
? instancesOrInstance
|
|
57
|
+
: [instancesOrInstance];
|
|
58
|
+
instances = instances.filter((instance) => !!instance);
|
|
59
|
+
const identifiers = instances.map((instance) => scopeAttributes
|
|
60
|
+
.map((attr) => instance[attr])).flat();
|
|
61
|
+
const uniqueIdentifiers = [...new Set(identifiers)].filter((identifier) => !!identifier);
|
|
62
|
+
const identifierCustomFieldDefinitionsMapping = {};
|
|
63
|
+
yield Promise.all(uniqueIdentifiers.map((identifier) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
const customFieldDefinitions = yield DefinitionRepo.findByEntityId(identifier, { transaction: options.transaction });
|
|
65
|
+
identifierCustomFieldDefinitionsMapping[identifier] = customFieldDefinitions;
|
|
66
|
+
})));
|
|
67
|
+
// Get the values per instates ids:
|
|
68
|
+
const instancesIds = instances.map((i) => i[primaryKey]);
|
|
69
|
+
const customFieldValues = yield ValueRepo.findValuesByModelIds(instancesIds, { transaction: options.transaction });
|
|
70
|
+
// Group fields by modelId
|
|
71
|
+
const valuesGroupByInstance = customFieldValues.reduce((acc, v) => {
|
|
72
|
+
const { modelId } = v;
|
|
73
|
+
if (!acc[modelId]) {
|
|
74
|
+
acc[modelId] = [];
|
|
75
|
+
}
|
|
76
|
+
acc[modelId].push(v);
|
|
77
|
+
return acc;
|
|
78
|
+
}, {});
|
|
79
|
+
// Attach custom fields to the instances
|
|
80
|
+
instances.forEach((instance) => {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
const customFields = {};
|
|
83
|
+
const { id } = instance;
|
|
84
|
+
const instanceValues = valuesGroupByInstance[id];
|
|
85
|
+
if (instanceValues) {
|
|
86
|
+
const serializedCustomFields = serializeCustomFields(instanceValues);
|
|
87
|
+
Object.assign(customFields, serializedCustomFields);
|
|
88
|
+
}
|
|
89
|
+
scopeAttributes.forEach((attribute) => {
|
|
90
|
+
const identifier = instance[attribute];
|
|
91
|
+
const customFieldDefinitions = identifierCustomFieldDefinitionsMapping[identifier];
|
|
92
|
+
if ((customFieldDefinitions === null || customFieldDefinitions === void 0 ? void 0 : customFieldDefinitions.length) > 0) {
|
|
93
|
+
customFieldDefinitions.forEach((customFieldDefinition) => {
|
|
94
|
+
if (customFields[customFieldDefinition.name] === undefined) {
|
|
95
|
+
customFields[customFieldDefinition.name] = null;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
instance.customFields = customFields;
|
|
101
|
+
(_b = (_a = options.attributesToRemove) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (attribute) => {
|
|
102
|
+
var _a;
|
|
103
|
+
(_a = instance.dataValues) === null || _a === void 0 ? true : delete _a[attribute];
|
|
104
|
+
// if raw:
|
|
105
|
+
instance === null || instance === void 0 ? true : delete instance[attribute];
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
exports.default = enrichResults;
|
|
110
|
+
//# sourceMappingURL=enrich.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrich.js","sourceRoot":"","sources":["../../src/hooks/enrich.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,+DAAiD;AACjD,yEAA2D;AAI3D;;GAEG;AACH,MAAM,qBAAqB,GAAG,CAAC,iBAAqC,EAA0B,EAAE;IAC9F,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,iCACvD,GAAG,KACN,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,KAAK,IAC3C,EAAE,EAAE,CAAC,CAAC;IACR,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AACF;;GAEG;AACH,MAAM,aAAa,GAAG,CAAC,eAAyB,EAAE,EAAE,CAAC,CACnD,mBAAgC,EAChC,OAAO,EACQ,EAAE;;IACjB,IACE,CAAA,MAAA,OAAO,CAAC,kBAAkB,0CAAE,MAAM,IAAG,CAAC;WACjC,CAAC,CAAA,MAAA,MAAA,OAAO,CAAC,kBAAkB,0CAAE,QAAQ,mDAAG,cAAc,CA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C,CAAC,CAAC;aACJ;QACH,CAAC,CAAC,CAAC;QACH,QAAQ,CAAC,YAAY,GAAG,YAAY,CAAC;QACrC,MAAA,MAAA,OAAO,CAAC,kBAAkB,0CAAE,OAAO,mDAAG,CAAC,SAAS,EAAE,EAAE;;YAC3C,MAAA,QAAQ,CAAC,UAAU,+CAAG,SAAS,CAAC,CAAC;YACxC,UAAU;YACH,QAAQ,aAAR,QAAQ,4BAAR,QAAQ,CAAG,SAAS,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,kBAAe,aAAa,CAAC"}
|
package/dist/hooks/find.js
CHANGED
|
@@ -1,52 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.enrichResults = exports.beforeFind = void 0;
|
|
39
2
|
/* eslint-disable no-param-reassign */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const logger_1 = __importDefault(require("../utils/logger"));
|
|
43
|
-
/**
|
|
44
|
-
* Serialize custom fields value into the format of {[name] -> [fieldData]}
|
|
45
|
-
*/
|
|
46
|
-
const serializeCustomFields = (customFieldValues) => {
|
|
47
|
-
const customFields = customFieldValues.reduce((acc, cfv) => (Object.assign(Object.assign({}, acc), { [cfv.customFieldDefinition.name]: cfv.value })), {});
|
|
48
|
-
return customFields;
|
|
49
|
-
};
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.beforeFind = void 0;
|
|
50
5
|
const doScopeAttributesMissing = (scopeAttributes, queryAttributes) => {
|
|
51
6
|
var _a;
|
|
52
7
|
const attributes = scopeAttributes
|
|
@@ -56,6 +11,7 @@ const doScopeAttributesMissing = (scopeAttributes, queryAttributes) => {
|
|
|
56
11
|
}
|
|
57
12
|
return attributes;
|
|
58
13
|
};
|
|
14
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
59
15
|
const beforeFind = (scopeAttributes) => (options) => {
|
|
60
16
|
const { attributes: queryAttributes } = options;
|
|
61
17
|
if (queryAttributes === null || queryAttributes === void 0 ? void 0 : queryAttributes.includes('customFields')) {
|
|
@@ -67,70 +23,4 @@ const beforeFind = (scopeAttributes) => (options) => {
|
|
|
67
23
|
}
|
|
68
24
|
};
|
|
69
25
|
exports.beforeFind = beforeFind;
|
|
70
|
-
/**
|
|
71
|
-
* A hook to attach the custom fields when fetching a model instances.
|
|
72
|
-
*/
|
|
73
|
-
const enrichResults = (scopeAttributes) => (instancesOrInstance, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
|
-
var _a, _b, _c;
|
|
75
|
-
if (((_a = options.originalAttributes) === null || _a === void 0 ? void 0 : _a.length) > 0
|
|
76
|
-
&& !((_c = (_b = options.originalAttributes) === null || _b === void 0 ? void 0 : _b.includes) === null || _c === void 0 ? void 0 : _c.call(_b, 'customFields'))) {
|
|
77
|
-
logger_1.default.info('No custom fields needed, returning', { options });
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const primaryKey = 'id';
|
|
81
|
-
let instances = Array.isArray(instancesOrInstance)
|
|
82
|
-
? instancesOrInstance
|
|
83
|
-
: [instancesOrInstance];
|
|
84
|
-
instances = instances.filter((instance) => !!instance);
|
|
85
|
-
const identifiers = instances.map((instance) => scopeAttributes
|
|
86
|
-
.map((attr) => instance[attr])).flat();
|
|
87
|
-
const uniqueIdentifiers = [...new Set(identifiers)].filter((identifier) => !!identifier);
|
|
88
|
-
const identifierCustomFieldDefinitionsMapping = {};
|
|
89
|
-
yield Promise.all(uniqueIdentifiers.map((identifier) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
-
const customFieldDefinitions = yield DefinitionRepo.findByEntityId(identifier, options.transaction);
|
|
91
|
-
identifierCustomFieldDefinitionsMapping[identifier] = customFieldDefinitions;
|
|
92
|
-
})));
|
|
93
|
-
// Get the values per instates ids:
|
|
94
|
-
const instancesIds = instances.map((i) => i[primaryKey]);
|
|
95
|
-
const customFieldValues = yield ValueRepo.findValuesByModelIds(instancesIds, { transaction: options.transaction });
|
|
96
|
-
// Group fields by modelId
|
|
97
|
-
const valuesGroupByInstance = customFieldValues.reduce((acc, v) => {
|
|
98
|
-
const { modelId } = v;
|
|
99
|
-
if (!acc[modelId]) {
|
|
100
|
-
acc[modelId] = [];
|
|
101
|
-
}
|
|
102
|
-
acc[modelId].push(v);
|
|
103
|
-
return acc;
|
|
104
|
-
}, {});
|
|
105
|
-
// Attach custom fields to the instances
|
|
106
|
-
instances.forEach((instance) => {
|
|
107
|
-
var _a, _b;
|
|
108
|
-
const customFields = {};
|
|
109
|
-
const { id } = instance;
|
|
110
|
-
const instanceValues = valuesGroupByInstance[id];
|
|
111
|
-
if (instanceValues) {
|
|
112
|
-
const serializedCustomFields = serializeCustomFields(instanceValues);
|
|
113
|
-
Object.assign(customFields, serializedCustomFields);
|
|
114
|
-
}
|
|
115
|
-
scopeAttributes.forEach((attribute) => {
|
|
116
|
-
const identifier = instance[attribute];
|
|
117
|
-
const customFieldDefinitions = identifierCustomFieldDefinitionsMapping[identifier];
|
|
118
|
-
if ((customFieldDefinitions === null || customFieldDefinitions === void 0 ? void 0 : customFieldDefinitions.length) > 0) {
|
|
119
|
-
customFieldDefinitions.forEach((customFieldDefinition) => {
|
|
120
|
-
if (customFields[customFieldDefinition.name] === undefined) {
|
|
121
|
-
customFields[customFieldDefinition.name] = null;
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
instance.customFields = customFields;
|
|
127
|
-
(_b = (_a = options.attributesToRemove) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (attribute) => {
|
|
128
|
-
var _a;
|
|
129
|
-
(_a = instance.dataValues) === null || _a === void 0 ? true : delete _a[attribute];
|
|
130
|
-
// if raw:
|
|
131
|
-
instance === null || instance === void 0 ? true : delete instance[attribute];
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
exports.enrichResults = enrichResults;
|
|
136
26
|
//# sourceMappingURL=find.js.map
|
package/dist/hooks/find.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/hooks/find.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/hooks/find.ts"],"names":[],"mappings":";AAAA,sCAAsC;;;AAEtC,MAAM,wBAAwB,GAAG,CAC/B,eAAyB,EACzB,eAAsC,EAC5B,EAAE;;IACZ,MAAM,UAAU,GAAG,eAAe;SAC/B,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,CAAA,MAAA,eAAe,CAAC,QAAQ,gEAAG,IAAI,CAAC,CAAA,EAAE;QACrC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACvB;IACD,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,wDAAwD;AACjD,MAAM,UAAU,GAAG,CAAC,eAAyB,EAAE,EAAE,CAAC,CAAC,OAAO,EAAQ,EAAE;IACzE,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAChD,IAAI,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,QAAQ,CAAC,cAAc,CAAC,EAAE;QAC7C,MAAM,sBAAsB,GAAG,wBAAwB,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QAC1F,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,MAAM,IAAG,CAAC,EAAE;YACtC,eAAe,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC,CAAC;YAChD,OAAO,CAAC,kBAAkB,GAAG,sBAAsB,CAAC;SACrD;KACF;AACH,CAAC,CAAC;AATW,QAAA,UAAU,cASrB"}
|
package/dist/hooks/index.js
CHANGED
|
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.workaround = exports.beforeCreate = exports.beforeBulkCreate = exports.beforeUpdate = exports.beforeBulkUpdate = exports.beforeFind = exports.enrichResults = void 0;
|
|
7
|
+
const enrich_1 = __importDefault(require("./enrich"));
|
|
8
|
+
exports.enrichResults = enrich_1.default;
|
|
7
9
|
const find_1 = require("./find");
|
|
8
|
-
Object.defineProperty(exports, "enrichResults", { enumerable: true, get: function () { return find_1.enrichResults; } });
|
|
9
10
|
Object.defineProperty(exports, "beforeFind", { enumerable: true, get: function () { return find_1.beforeFind; } });
|
|
10
11
|
const update_1 = require("./update");
|
|
11
12
|
Object.defineProperty(exports, "beforeBulkUpdate", { enumerable: true, get: function () { return update_1.beforeBulkUpdate; } });
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAqC;AAOnC,wBAPK,gBAAa,CAOL;AANf,iCAAoC;AAOlC,2FAPO,iBAAU,OAOP;AANZ,qCAA0D;AAOxD,iGAPO,yBAAgB,OAOP;AAChB,6FARyB,qBAAY,OAQzB;AAPd,qCAA0D;AAQxD,iGARO,yBAAgB,OAQP;AAChB,6FATyB,qBAAY,OASzB;AARd,8DAAsC;AASpC,qBATK,oBAAU,CASL"}
|
package/dist/hooks/update.js
CHANGED
|
@@ -34,7 +34,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
35
|
exports.beforeUpdate = exports.beforeBulkUpdate = void 0;
|
|
36
36
|
const ValueRepo = __importStar(require("../repository/value"));
|
|
37
|
-
const DefinitionRepo = __importStar(require("../repository/definition"));
|
|
38
37
|
/**
|
|
39
38
|
* A hook to update the custom fields when updating a model (more then one instance).
|
|
40
39
|
*/
|
|
@@ -52,22 +51,13 @@ const beforeUpdate = (scopeAttributes) => (instance, options) => __awaiter(void
|
|
|
52
51
|
const { fields } = options;
|
|
53
52
|
const modelType = instance.constructor.name;
|
|
54
53
|
const identifiers = scopeAttributes.map((attribute) => instance[attribute]);
|
|
55
|
-
// get all model's required definitions
|
|
56
|
-
const requiredNullFieldsNames = yield DefinitionRepo.getRequiredFields(modelType, instance.id, identifiers, true);
|
|
57
54
|
const customFieldsIdx = fields.indexOf('customFields');
|
|
58
55
|
if (customFieldsIdx > -1) {
|
|
59
56
|
const { customFields } = instance;
|
|
60
|
-
const fieldsNames = Object.keys(customFields);
|
|
61
|
-
if (requiredNullFieldsNames.some((name) => !fieldsNames.includes(name))) {
|
|
62
|
-
throw new Error('some fields are required');
|
|
63
|
-
}
|
|
64
57
|
yield ValueRepo.updateValues(modelType, instance.id, identifiers, customFields, { transaction: options.transaction });
|
|
65
58
|
// eslint-disable-next-line no-param-reassign
|
|
66
59
|
fields.splice(customFieldsIdx, 1);
|
|
67
60
|
}
|
|
68
|
-
else if ((requiredNullFieldsNames === null || requiredNullFieldsNames === void 0 ? void 0 : requiredNullFieldsNames.length) > 0) {
|
|
69
|
-
throw new Error('some fields are required');
|
|
70
|
-
}
|
|
71
61
|
});
|
|
72
62
|
exports.beforeUpdate = beforeUpdate;
|
|
73
63
|
//# sourceMappingURL=update.js.map
|
package/dist/hooks/update.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/hooks/update.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAiD;
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/hooks/update.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAiD;AAEjD;;GAEG;AACI,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAQ,EAAE;IAChD,sEAAsE;IACtE,6CAA6C;IAC7C,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;AACjC,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B;AAEF;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,eAAyB,EAAE,EAAE,CAAC,CACzD,QAAQ,EACR,OAAO,EACQ,EAAE;IACjB,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC;IAC5C,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5E,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACvD,IAAI,eAAe,GAAG,CAAC,CAAC,EAAE;QACxB,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC;QAClC,MAAM,SAAS,CAAC,YAAY,CAC1B,SAAS,EACT,QAAQ,CAAC,EAAE,EACX,WAAW,EACX,YAAY,EACZ,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CACrC,CAAC;QACF,6CAA6C;QAC7C,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;KACnC;AACH,CAAC,CAAA,CAAC;AArBW,QAAA,YAAY,gBAqBvB"}
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.disableCustomFields = void 0;
|
|
29
30
|
const sequelize_1 = require("sequelize");
|
|
30
31
|
const models_1 = require("./models");
|
|
31
32
|
const api_1 = __importDefault(require("./api"));
|
|
@@ -45,13 +46,13 @@ const addHooks = (models, getModel) => {
|
|
|
45
46
|
model.refreshAttributes();
|
|
46
47
|
// TODO: Uncomment after tests are passed
|
|
47
48
|
// model.addHook('afterFind', workaround);
|
|
48
|
-
model.addHook('beforeFind', (0, hooks_1.beforeFind)(scopeAttributes));
|
|
49
|
-
model.addHook('beforeBulkCreate', hooks_1.beforeBulkCreate);
|
|
50
|
-
model.addHook('beforeBulkUpdate', hooks_1.beforeBulkUpdate);
|
|
51
|
-
model.addHook('beforeCreate', (0, hooks_1.beforeCreate)(scopeAttributes));
|
|
52
|
-
model.addHook('beforeUpdate', (0, hooks_1.beforeUpdate)(scopeAttributes));
|
|
53
|
-
model.addHook('afterFind', (0, hooks_1.enrichResults)(scopeAttributes));
|
|
54
|
-
model.addHook('afterUpdate', (0, hooks_1.enrichResults)(scopeAttributes));
|
|
49
|
+
model.addHook('beforeFind', 'sadot-beforeFind', (0, hooks_1.beforeFind)(scopeAttributes));
|
|
50
|
+
model.addHook('beforeBulkCreate', 'sadot-beforeBulkCreate', hooks_1.beforeBulkCreate);
|
|
51
|
+
model.addHook('beforeBulkUpdate', 'sadot-beforeBulkUpdate', hooks_1.beforeBulkUpdate);
|
|
52
|
+
model.addHook('beforeCreate', 'sadot-beforeCreate', (0, hooks_1.beforeCreate)(scopeAttributes));
|
|
53
|
+
model.addHook('beforeUpdate', 'sadot-beforeUpdate', (0, hooks_1.beforeUpdate)(scopeAttributes));
|
|
54
|
+
model.addHook('afterFind', 'sadot-afterFind', (0, hooks_1.enrichResults)(scopeAttributes));
|
|
55
|
+
model.addHook('afterUpdate', 'sadot-afterUpdate', (0, hooks_1.enrichResults)(scopeAttributes));
|
|
55
56
|
}
|
|
56
57
|
catch (e) {
|
|
57
58
|
logger_1.default.error(`Could not add custom fields hook to model ${name}. `, e);
|
|
@@ -63,19 +64,41 @@ const addHooks = (models, getModel) => {
|
|
|
63
64
|
* @see {@link 'custom-fields/config'} for configurations
|
|
64
65
|
*/
|
|
65
66
|
const useCustomFields = (app, getModel, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
66
|
-
const {
|
|
67
|
-
// deepAfterFindWorkAround(sequelize);
|
|
67
|
+
const { models } = options;
|
|
68
68
|
if (app) {
|
|
69
69
|
app.use('/api', api_1.default);
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
yield (0, models_1.initTables)(moreInnerSequelize);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
yield (0, models_1.initTables)(innerSequelize);
|
|
77
|
-
}
|
|
71
|
+
const sequelize = (0, db_1.default)(options.databaseConfig);
|
|
72
|
+
yield (0, models_1.initTables)(sequelize, options.getUser);
|
|
78
73
|
addHooks(models, getModel);
|
|
79
74
|
});
|
|
80
75
|
exports.default = useCustomFields;
|
|
76
|
+
const removeHooks = (models, getModel) => {
|
|
77
|
+
models.forEach(({ name }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
78
|
+
try {
|
|
79
|
+
const model = getModel(name);
|
|
80
|
+
if (!model)
|
|
81
|
+
return;
|
|
82
|
+
if (model.rawAttributes.customFields) {
|
|
83
|
+
delete model.rawAttributes.customFields;
|
|
84
|
+
model.refreshAttributes();
|
|
85
|
+
}
|
|
86
|
+
// model.removeHook('afterFind', 'sadot-workaround');
|
|
87
|
+
model.removeHook('beforeFind', 'sadot-beforeFind');
|
|
88
|
+
model.removeHook('beforeBulkCreate', 'sadot-beforeBulkCreate');
|
|
89
|
+
model.removeHook('beforeBulkUpdate', 'sadot-beforeBulkUpdate');
|
|
90
|
+
model.removeHook('beforeCreate', 'sadot-beforeCreate');
|
|
91
|
+
model.removeHook('beforeUpdate', 'sadot-beforeUpdate');
|
|
92
|
+
model.removeHook('afterFind', 'sadot-afterFind');
|
|
93
|
+
model.removeHook('afterUpdate', 'sadot-afterUpdate');
|
|
94
|
+
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
logger_1.default.error(`Could not add custom fields hook to model ${name}. `, e);
|
|
97
|
+
}
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
100
|
+
const disableCustomFields = (models, getModel) => {
|
|
101
|
+
removeHooks(models, getModel);
|
|
102
|
+
};
|
|
103
|
+
exports.disableCustomFields = disableCustomFields;
|
|
81
104
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAsC;AACtC,qCAAsC;AACtC,gDAAwB;AACxB,mCAOiB;AACjB,oDAAgC;AAChC,4DAAoC;AAGpC,oEAAkD;AAElD,MAAM,QAAQ,GAAG,CAAC,MAAsB,EAAE,QAAsB,EAAE,EAAE;IAClE,MAAM,CAAC,OAAO,CAAC,CAAO,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE;QACjD,IAAI;YACF,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC7B,IAAI,CAAC,KAAK;gBAAE,OAAO;YACnB,KAAK,CAAC,aAAa,CAAC,YAAY,GAAG;gBACjC,IAAI,EAAE,qBAAS,CAAC,OAAO;aACxB,CAAC;YACF,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC1B,yCAAyC;YACzC,0CAA0C;YAC1C,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE,kBAAkB,EAAE,IAAA,kBAAU,EAAC,eAAe,CAAC,CAAC,CAAC;YAC7E,KAAK,CAAC,OAAO,CAAC,kBAAkB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