@autofleet/sadot 0.0.1-beta.9 → 0.0.2-beta
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/jest.config.d.ts +12 -0
- package/dist/src/api/index.d.ts +2 -0
- package/dist/{api → src/api}/index.js +0 -1
- package/dist/src/api/v1/definition/index.d.ts +2 -0
- package/dist/{api → src/api}/v1/definition/index.js +23 -27
- package/dist/src/api/v1/definition/validations.d.ts +2 -0
- package/dist/{api → src/api}/v1/definition/validations.js +10 -10
- package/dist/src/api/v1/errors.d.ts +2 -0
- package/dist/{api → src/api}/v1/errors.js +0 -1
- package/dist/src/api/v1/index.d.ts +2 -0
- package/dist/{api → src/api}/v1/index.js +1 -2
- package/dist/src/errors/index.d.ts +16 -0
- package/dist/src/errors/index.js +45 -0
- package/dist/src/events/index.d.ts +4 -0
- package/dist/{events → src/events}/index.js +21 -2
- package/dist/src/hooks/create.d.ts +9 -0
- package/dist/{hooks → src/hooks}/create.js +14 -17
- package/dist/src/hooks/enrich.d.ts +5 -0
- package/dist/src/hooks/enrich.js +118 -0
- package/dist/src/hooks/find.d.ts +1 -0
- package/dist/src/hooks/find.js +29 -0
- package/dist/src/hooks/index.d.ts +6 -0
- package/dist/{hooks → src/hooks}/index.js +2 -2
- package/dist/src/hooks/update.d.ts +9 -0
- package/dist/{hooks → src/hooks}/update.js +7 -22
- package/dist/src/hooks/workaround.d.ts +10 -0
- package/dist/{hooks → src/hooks}/workaround.js +3 -13
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.js +105 -0
- package/dist/src/models/CustomFieldDefinition.d.ts +23 -0
- package/dist/{models → src/models}/CustomFieldDefinition.js +22 -18
- package/dist/src/models/CustomFieldValue.d.ts +15 -0
- package/dist/{models → src/models}/CustomFieldValue.js +24 -40
- package/dist/src/models/index.d.ts +8 -0
- package/dist/src/models/index.js +87 -0
- package/dist/src/models/tests/AssociatedTestModel.d.ts +12 -0
- package/dist/{models → src/models}/tests/AssociatedTestModel.js +0 -1
- package/dist/src/models/tests/TestModel.d.ts +11 -0
- package/dist/{models → src/models}/tests/TestModel.js +0 -1
- package/dist/src/repository/definition.d.ts +17 -0
- package/dist/src/repository/definition.js +80 -0
- package/dist/src/repository/value.d.ts +24 -0
- package/dist/{repository → src/repository}/value.js +22 -30
- package/dist/src/tests/api/test-api.d.ts +2 -0
- package/dist/{tests → src/tests}/api/test-api.js +12 -22
- package/dist/src/tests/helpers/database-config.d.ts +15 -0
- package/dist/{tests → src/tests}/helpers/database-config.js +0 -1
- package/dist/src/tests/helpers/index.d.ts +2 -0
- package/dist/src/tests/helpers/index.js +18 -0
- package/dist/src/tests/mocks/definition.mock.d.ts +37 -0
- package/dist/{tests/mocks/index.js → src/tests/mocks/definition.mock.js} +20 -17
- package/dist/src/tests/mocks/events.mock.d.ts +3 -0
- package/dist/{tests → src/tests}/mocks/events.mock.js +0 -1
- package/dist/src/tests/mocks/testModel.d.ts +12 -0
- package/dist/{tests → src/tests}/mocks/testModel.js +4 -14
- package/dist/src/types/definition/index.d.ts +23 -0
- package/dist/{types → src/types}/definition/index.js +0 -1
- package/dist/src/types/index.d.ts +13 -0
- package/dist/{types → src/types}/index.js +0 -1
- package/dist/src/types/value/index.d.ts +15 -0
- package/dist/{types → src/types}/value/index.js +0 -1
- package/dist/src/utils/constants/index.d.ts +1 -0
- package/dist/src/utils/constants/index.js +5 -0
- package/dist/src/utils/db/index.d.ts +4 -0
- package/dist/{utils → src/utils}/db/index.js +8 -1
- package/dist/src/utils/logger/index.d.ts +2 -0
- package/dist/{utils → src/utils}/logger/index.js +2 -2
- package/dist/src/utils/validations/custom-fields.d.ts +2 -0
- package/dist/{utils → src/utils}/validations/custom-fields.js +0 -1
- package/dist/src/utils/validations/custom.d.ts +15 -0
- package/dist/src/utils/validations/custom.js +42 -0
- package/dist/src/utils/validations/index.d.ts +2 -0
- package/dist/{utils → src/utils}/validations/index.js +0 -1
- package/dist/src/utils/validations/type.d.ts +18 -0
- package/dist/src/utils/validations/type.js +50 -0
- package/dist/src/utils/validations/validators.d.ts +12 -0
- package/dist/src/utils/validations/validators.js +33 -0
- package/package.json +3 -1
- package/src/api/v1/definition/index.ts +15 -8
- package/src/api/v1/definition/validations.ts +11 -25
- package/src/api/v1/index.ts +1 -1
- package/src/errors/index.ts +42 -0
- package/src/events/index.ts +23 -1
- package/src/hooks/create.ts +7 -3
- package/src/hooks/enrich.ts +125 -0
- package/src/hooks/find.ts +2 -101
- package/src/hooks/index.ts +2 -1
- package/src/hooks/update.ts +2 -15
- package/src/index.ts +52 -17
- package/src/models/CustomFieldDefinition.ts +23 -16
- package/src/models/CustomFieldValue.ts +7 -7
- package/src/models/index.ts +72 -16
- package/src/repository/definition.ts +26 -33
- package/src/repository/value.ts +4 -2
- package/src/tests/mocks/{index.ts → definition.mock.ts} +2 -4
- package/src/types/index.ts +4 -6
- package/src/utils/constants/index.ts +2 -0
- package/src/utils/db/index.ts +7 -0
- package/src/utils/logger/index.ts +3 -1
- package/src/utils/validations/custom.ts +26 -44
- package/src/utils/validations/type.ts +23 -6
- package/src/utils/validations/validators.ts +34 -0
- package/tsconfig.json +9 -25
- package/dist/api/index.js.map +0 -1
- package/dist/api/v1/definition/index.js.map +0 -1
- package/dist/api/v1/definition/validations.js.map +0 -1
- package/dist/api/v1/errors.js.map +0 -1
- package/dist/api/v1/index.js.map +0 -1
- package/dist/events/index.js.map +0 -1
- package/dist/hooks/create.js.map +0 -1
- package/dist/hooks/find.js +0 -136
- package/dist/hooks/find.js.map +0 -1
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/update.js.map +0 -1
- package/dist/hooks/workaround.js.map +0 -1
- package/dist/index.js +0 -81
- package/dist/index.js.map +0 -1
- package/dist/models/CustomFieldDefinition.js.map +0 -1
- package/dist/models/CustomFieldValue.js.map +0 -1
- package/dist/models/index.js +0 -50
- package/dist/models/index.js.map +0 -1
- package/dist/models/tests/AssociatedTestModel.js.map +0 -1
- package/dist/models/tests/TestModel.js.map +0 -1
- package/dist/repository/definition.js +0 -101
- package/dist/repository/definition.js.map +0 -1
- package/dist/repository/value.js.map +0 -1
- package/dist/tests/api/test-api.js.map +0 -1
- package/dist/tests/helpers/database-config.js.map +0 -1
- package/dist/tests/helpers/index.js +0 -28
- package/dist/tests/helpers/index.js.map +0 -1
- package/dist/tests/mocks/events.mock.js.map +0 -1
- package/dist/tests/mocks/index.js.map +0 -1
- package/dist/tests/mocks/testModel.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/types/definition/index.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/types/value/index.js.map +0 -1
- package/dist/utils/db/index.js.map +0 -1
- package/dist/utils/logger/index.js.map +0 -1
- package/dist/utils/validations/custom-fields.js.map +0 -1
- package/dist/utils/validations/custom.js +0 -59
- package/dist/utils/validations/custom.js.map +0 -1
- package/dist/utils/validations/index.js.map +0 -1
- package/dist/utils/validations/type.js +0 -32
- package/dist/utils/validations/type.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workaround to a bug in sequelize.🐛
|
|
3
|
+
*
|
|
4
|
+
* **afterFind hook** isn't working on nested (included) models.
|
|
5
|
+
* The solution here is to add a global afterFind hook,
|
|
6
|
+
* which manually calls the afterFind hook of each model, recursively
|
|
7
|
+
* https://github.com/sequelize/sequelize/issues/4627
|
|
8
|
+
*/
|
|
9
|
+
declare const handleChildrenAfterFindHook: (instances: any, options: any, level?: number) => any;
|
|
10
|
+
export default handleChildrenAfterFindHook;
|
|
@@ -7,17 +7,8 @@
|
|
|
7
7
|
* which manually calls the afterFind hook of each model, recursively
|
|
8
8
|
* https://github.com/sequelize/sequelize/issues/4627
|
|
9
9
|
*/
|
|
10
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
11
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
12
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
13
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
14
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
15
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
16
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
const handleChildrenAfterFindHook = (instances, options, level = 0) =>
|
|
11
|
+
const handleChildrenAfterFindHook = async (instances, options, level = 0) => {
|
|
21
12
|
if (!instances)
|
|
22
13
|
return Promise.resolve();
|
|
23
14
|
if (Array.isArray(instances)) {
|
|
@@ -33,7 +24,7 @@ const handleChildrenAfterFindHook = (instances, options, level = 0) => __awaiter
|
|
|
33
24
|
* Only run children "afterFind" hooks.
|
|
34
25
|
*/
|
|
35
26
|
if (level >= 1) {
|
|
36
|
-
|
|
27
|
+
await constructor.runHooks('afterFind', instance, options);
|
|
37
28
|
}
|
|
38
29
|
const { associations } = constructor;
|
|
39
30
|
const associatedNames = Object.keys(instance).filter((attribute) => Object.keys(associations).includes(attribute));
|
|
@@ -42,6 +33,5 @@ const handleChildrenAfterFindHook = (instances, options, level = 0) => __awaiter
|
|
|
42
33
|
return handleChildrenAfterFindHook(childInstances, options, level + 1);
|
|
43
34
|
}
|
|
44
35
|
return Promise.resolve();
|
|
45
|
-
}
|
|
36
|
+
};
|
|
46
37
|
exports.default = handleChildrenAfterFindHook;
|
|
47
|
-
//# sourceMappingURL=workaround.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Application } from 'express';
|
|
2
|
+
import { Sequelize } from 'sequelize-typescript';
|
|
3
|
+
import { CustomFieldOptions, ModelFetcher } from './types';
|
|
4
|
+
export * from './utils/validations/custom-fields';
|
|
5
|
+
/**
|
|
6
|
+
* Adding custom fields enrichment to the models inside the MODELS_FILE_NAME json file
|
|
7
|
+
* @see {@link 'custom-fields/config'} for configurations
|
|
8
|
+
*/
|
|
9
|
+
declare const useCustomFields: (app: Application | null, getModel: ModelFetcher, options: CustomFieldOptions) => Promise<Sequelize>;
|
|
10
|
+
export default useCustomFields;
|
|
11
|
+
export declare const disableCustomFields: (models: any, getModel: any) => void;
|
|
@@ -0,0 +1,105 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.disableCustomFields = void 0;
|
|
21
|
+
const sequelize_1 = require("sequelize");
|
|
22
|
+
const models_1 = require("./models");
|
|
23
|
+
const api_1 = __importDefault(require("./api"));
|
|
24
|
+
const hooks_1 = require("./hooks");
|
|
25
|
+
const db_1 = __importDefault(require("./utils/db"));
|
|
26
|
+
const logger_1 = __importDefault(require("./utils/logger"));
|
|
27
|
+
__exportStar(require("./utils/validations/custom-fields"), exports);
|
|
28
|
+
const addHooks = (models, getModel) => {
|
|
29
|
+
models.forEach(async ({ name, scopeAttributes }) => {
|
|
30
|
+
try {
|
|
31
|
+
const model = getModel(name);
|
|
32
|
+
if (!model) {
|
|
33
|
+
logger_1.default.warn('sadot - tried to addHooks to a model that does not exist yet', {
|
|
34
|
+
name,
|
|
35
|
+
scopeAttributes,
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
model.rawAttributes.customFields = {
|
|
40
|
+
type: sequelize_1.DataTypes.VIRTUAL,
|
|
41
|
+
};
|
|
42
|
+
model.refreshAttributes();
|
|
43
|
+
// TODO: Uncomment after tests are passed
|
|
44
|
+
// model.addHook('afterFind', workaround);
|
|
45
|
+
model.addHook('beforeFind', 'sadot-beforeFind', (0, hooks_1.beforeFind)(scopeAttributes));
|
|
46
|
+
model.addHook('beforeBulkCreate', 'sadot-beforeBulkCreate', hooks_1.beforeBulkCreate);
|
|
47
|
+
model.addHook('beforeBulkUpdate', 'sadot-beforeBulkUpdate', hooks_1.beforeBulkUpdate);
|
|
48
|
+
model.addHook('beforeCreate', 'sadot-beforeCreate', (0, hooks_1.beforeCreate)(scopeAttributes));
|
|
49
|
+
model.addHook('beforeUpdate', 'sadot-beforeUpdate', (0, hooks_1.beforeUpdate)(scopeAttributes));
|
|
50
|
+
model.addHook('afterFind', 'sadot-afterFind', (0, hooks_1.enrichResults)(name, scopeAttributes));
|
|
51
|
+
model.addHook('afterUpdate', 'sadot-afterUpdate', (0, hooks_1.enrichResults)(name, scopeAttributes));
|
|
52
|
+
model.addHook('afterCreate', 'sadot-afterCreate', (0, hooks_1.enrichResults)(name, scopeAttributes));
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
logger_1.default.error(`Could not add custom fields hook to model ${name}. `, e);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Adding custom fields enrichment to the models inside the MODELS_FILE_NAME json file
|
|
61
|
+
* @see {@link 'custom-fields/config'} for configurations
|
|
62
|
+
*/
|
|
63
|
+
const useCustomFields = async (app, getModel, options) => {
|
|
64
|
+
const { models } = options;
|
|
65
|
+
if (app) {
|
|
66
|
+
app.use('/api', api_1.default);
|
|
67
|
+
}
|
|
68
|
+
const sequelize = (0, db_1.default)(options.databaseConfig);
|
|
69
|
+
if (process.env.NODE_ENV === 'test') {
|
|
70
|
+
await (0, models_1.initTestModels)(sequelize);
|
|
71
|
+
}
|
|
72
|
+
addHooks(models, getModel);
|
|
73
|
+
await (0, models_1.initTables)(sequelize, options.getUser);
|
|
74
|
+
logger_1.default.debug('sadot - custom fields finished initializing with models', models);
|
|
75
|
+
return sequelize;
|
|
76
|
+
};
|
|
77
|
+
exports.default = useCustomFields;
|
|
78
|
+
const removeHooks = (models, getModel) => {
|
|
79
|
+
models.forEach(async ({ name }) => {
|
|
80
|
+
try {
|
|
81
|
+
const model = getModel(name);
|
|
82
|
+
if (!model)
|
|
83
|
+
return;
|
|
84
|
+
if (model.rawAttributes.customFields) {
|
|
85
|
+
delete model.rawAttributes.customFields;
|
|
86
|
+
model.refreshAttributes();
|
|
87
|
+
}
|
|
88
|
+
// model.removeHook('afterFind', 'sadot-workaround');
|
|
89
|
+
model.removeHook('beforeFind', 'sadot-beforeFind');
|
|
90
|
+
model.removeHook('beforeBulkCreate', 'sadot-beforeBulkCreate');
|
|
91
|
+
model.removeHook('beforeBulkUpdate', 'sadot-beforeBulkUpdate');
|
|
92
|
+
model.removeHook('beforeCreate', 'sadot-beforeCreate');
|
|
93
|
+
model.removeHook('beforeUpdate', 'sadot-beforeUpdate');
|
|
94
|
+
model.removeHook('afterFind', 'sadot-afterFind');
|
|
95
|
+
model.removeHook('afterUpdate', 'sadot-afterUpdate');
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
logger_1.default.error(`Could not add custom fields hook to model ${name}. `, e);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const disableCustomFields = (models, getModel) => {
|
|
103
|
+
removeHooks(models, getModel);
|
|
104
|
+
};
|
|
105
|
+
exports.disableCustomFields = disableCustomFields;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Model } from 'sequelize-typescript';
|
|
2
|
+
import { CustomFieldDefinitionType } from '../utils/validations/type';
|
|
3
|
+
import { CustomFieldValue } from '.';
|
|
4
|
+
declare class CustomFieldDefinition extends Model {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
displayName?: string;
|
|
8
|
+
fieldType: CustomFieldDefinitionType;
|
|
9
|
+
validation?: any;
|
|
10
|
+
entityId: string; /** Client association entity id */
|
|
11
|
+
entityType: string; /** Client association entity type (demand source / fleet / etc.) */
|
|
12
|
+
modelType: string; /** Model type. e.g. Vehicle / StopPoint / etc. */
|
|
13
|
+
description?: string;
|
|
14
|
+
required?: boolean;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
createdAt?: Date;
|
|
17
|
+
updatedAt?: Date;
|
|
18
|
+
deletedAt?: Date;
|
|
19
|
+
values: CustomFieldValue[];
|
|
20
|
+
static displayNameDefaultValue(instance: CustomFieldDefinition): void;
|
|
21
|
+
static afterSaveHandler(instance: CustomFieldDefinition, options: any): void;
|
|
22
|
+
}
|
|
23
|
+
export default CustomFieldDefinition;
|
|
@@ -9,28 +9,17 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CustomFieldDefinitionType = void 0;
|
|
13
12
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
13
|
+
/* eslint-disable indent */
|
|
14
14
|
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
15
|
+
const custom_1 = require("../utils/validations/custom");
|
|
16
|
+
const type_1 = require("../utils/validations/type");
|
|
15
17
|
const _1 = require(".");
|
|
16
18
|
const events_1 = require("../events");
|
|
17
|
-
|
|
18
|
-
* Supported custom field types
|
|
19
|
-
*/
|
|
20
|
-
// eslint-disable-next-line no-shadow
|
|
21
|
-
var CustomFieldDefinitionType;
|
|
22
|
-
(function (CustomFieldDefinitionType) {
|
|
23
|
-
CustomFieldDefinitionType["NUMBER"] = "number";
|
|
24
|
-
CustomFieldDefinitionType["BOOLEAN"] = "boolean";
|
|
25
|
-
CustomFieldDefinitionType["DATE"] = "date";
|
|
26
|
-
CustomFieldDefinitionType["DATETIME"] = "datetime";
|
|
27
|
-
CustomFieldDefinitionType["TEXT"] = "text";
|
|
28
|
-
CustomFieldDefinitionType["IMAGE"] = "image";
|
|
29
|
-
CustomFieldDefinitionType["ENUM"] = "enum";
|
|
30
|
-
})(CustomFieldDefinitionType = exports.CustomFieldDefinitionType || (exports.CustomFieldDefinitionType = {}));
|
|
19
|
+
const errors_1 = require("../errors");
|
|
31
20
|
let CustomFieldDefinition = class CustomFieldDefinition extends sequelize_typescript_1.Model {
|
|
32
21
|
static displayNameDefaultValue(instance) {
|
|
33
|
-
if (!
|
|
22
|
+
if (!instance?.displayName) {
|
|
34
23
|
// eslint-disable-next-line no-param-reassign
|
|
35
24
|
instance.displayName = instance.name;
|
|
36
25
|
}
|
|
@@ -67,6 +56,11 @@ __decorate([
|
|
|
67
56
|
__metadata("design:type", String)
|
|
68
57
|
], CustomFieldDefinition.prototype, "displayName", void 0);
|
|
69
58
|
__decorate([
|
|
59
|
+
(0, sequelize_typescript_1.Is)('SupportedType', (value) => {
|
|
60
|
+
if (!Object.values(type_1.CustomFieldDefinitionType).includes(value)) {
|
|
61
|
+
throw new errors_1.UnsupportedCustomFieldTypeError(`"${value}" is not a supported type.`);
|
|
62
|
+
}
|
|
63
|
+
}),
|
|
70
64
|
(0, sequelize_typescript_1.Column)({
|
|
71
65
|
type: sequelize_typescript_1.DataType.STRING,
|
|
72
66
|
allowNull: false,
|
|
@@ -152,10 +146,20 @@ CustomFieldDefinition = __decorate([
|
|
|
152
146
|
(0, sequelize_typescript_1.DefaultScope)(() => ({ where: { disabled: false } })),
|
|
153
147
|
(0, sequelize_typescript_1.Table)({
|
|
154
148
|
indexes: [
|
|
155
|
-
{
|
|
149
|
+
{
|
|
150
|
+
name: 'unique_name_model_type',
|
|
151
|
+
fields: ['model_type', 'entity_id', 'name'],
|
|
152
|
+
unique: true,
|
|
153
|
+
},
|
|
156
154
|
],
|
|
157
155
|
timestamps: true,
|
|
156
|
+
validate: {
|
|
157
|
+
validationByType() {
|
|
158
|
+
if (!(0, custom_1.validateValidation)(this.fieldType, this.validation)) {
|
|
159
|
+
throw new errors_1.UnsupportedCustomValidationError(`Validation provided for "${this.fieldType}" is not supported`);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
},
|
|
158
163
|
})
|
|
159
164
|
], CustomFieldDefinition);
|
|
160
165
|
exports.default = CustomFieldDefinition;
|
|
161
|
-
//# sourceMappingURL=CustomFieldDefinition.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Model } from 'sequelize-typescript';
|
|
2
|
+
import { CustomFieldDefinition } from '.';
|
|
3
|
+
declare class CustomFieldValue extends Model {
|
|
4
|
+
modelId: string;
|
|
5
|
+
customFieldDefinitionId: string;
|
|
6
|
+
value: any;
|
|
7
|
+
createdAt?: Date;
|
|
8
|
+
updatedAt?: Date;
|
|
9
|
+
deletedAt?: Date;
|
|
10
|
+
customFieldDefinition: CustomFieldDefinition;
|
|
11
|
+
static validateValues(instances: CustomFieldValue[]): Promise<void>;
|
|
12
|
+
static validateValue(instance: CustomFieldValue): Promise<void>;
|
|
13
|
+
static afterSaveHandler(instance: CustomFieldValue, options: any): void;
|
|
14
|
+
}
|
|
15
|
+
export default CustomFieldValue;
|
|
@@ -31,61 +31,46 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
33
|
};
|
|
34
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
35
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
36
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
38
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
39
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
40
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
34
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
44
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
36
|
};
|
|
46
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
38
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
39
|
+
/* eslint-disable indent */
|
|
48
40
|
const sequelize_typescript_1 = require("sequelize-typescript");
|
|
49
41
|
const events_1 = require("../events");
|
|
50
42
|
const _1 = require(".");
|
|
51
43
|
const validations_1 = __importDefault(require("../utils/validations"));
|
|
52
44
|
const CustomFieldDefinitionRepo = __importStar(require("../repository/definition"));
|
|
53
|
-
const
|
|
45
|
+
const errors_1 = require("../errors");
|
|
54
46
|
let CustomFieldValue = class CustomFieldValue extends sequelize_typescript_1.Model {
|
|
55
|
-
static validateValues(instances) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const { validation, fieldType, } = definitions
|
|
66
|
-
.find((definition) => definition.id === instance.customFieldDefinitionId);
|
|
67
|
-
const isValid = (0, validations_1.default)(instance.value, fieldType, validation);
|
|
68
|
-
if (!isValid) {
|
|
69
|
-
throw new Error('Invalid value');
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
static validateValue(instance) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
logger_1.default.info('CustomFieldValue BeforeCreate/BeforeUpdate', { instance });
|
|
77
|
-
const { customFieldDefinitionId } = instance;
|
|
78
|
-
// eslint-disable-next-line max-len
|
|
79
|
-
const cfd = yield CustomFieldDefinitionRepo.findById(customFieldDefinitionId, { withDisabled: true });
|
|
80
|
-
const { validation, fieldType } = cfd;
|
|
47
|
+
static async validateValues(instances) {
|
|
48
|
+
const ids = instances.map((instance) => instance.customFieldDefinitionId);
|
|
49
|
+
const uniqueIds = [...new Set(ids)];
|
|
50
|
+
const definitions = await CustomFieldDefinitionRepo.findByIds(uniqueIds, { withDisabled: true });
|
|
51
|
+
if (!definitions || definitions.length !== uniqueIds.length) {
|
|
52
|
+
throw new Error('Definitions not found');
|
|
53
|
+
}
|
|
54
|
+
instances.forEach((instance) => {
|
|
55
|
+
const { validation, fieldType, } = definitions
|
|
56
|
+
.find((definition) => definition.id === instance.customFieldDefinitionId);
|
|
81
57
|
const isValid = (0, validations_1.default)(instance.value, fieldType, validation);
|
|
82
58
|
if (!isValid) {
|
|
83
|
-
throw new
|
|
59
|
+
throw new errors_1.InvalidValueError(instance.value, fieldType);
|
|
84
60
|
}
|
|
85
61
|
});
|
|
86
62
|
}
|
|
63
|
+
static async validateValue(instance) {
|
|
64
|
+
const { customFieldDefinitionId } = instance;
|
|
65
|
+
// eslint-disable-next-line max-len
|
|
66
|
+
const cfd = await CustomFieldDefinitionRepo.findById(customFieldDefinitionId, { withDisabled: true });
|
|
67
|
+
const { validation, fieldType } = cfd;
|
|
68
|
+
const isValid = (0, validations_1.default)(instance.value, fieldType, validation);
|
|
69
|
+
if (!isValid) {
|
|
70
|
+
throw new errors_1.InvalidValueError(instance.value, fieldType);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
87
73
|
static afterSaveHandler(instance, options) {
|
|
88
|
-
logger_1.default.info('CustomFieldValue afterSave', { instance });
|
|
89
74
|
if (options.transaction) {
|
|
90
75
|
options.transaction.afterCommit(() => (0, events_1.sendDimEvent)(instance[0]));
|
|
91
76
|
}
|
|
@@ -114,7 +99,7 @@ __decorate([
|
|
|
114
99
|
__decorate([
|
|
115
100
|
(0, sequelize_typescript_1.Column)({
|
|
116
101
|
type: sequelize_typescript_1.DataType.JSONB,
|
|
117
|
-
allowNull:
|
|
102
|
+
allowNull: true,
|
|
118
103
|
}),
|
|
119
104
|
__metadata("design:type", Object)
|
|
120
105
|
], CustomFieldValue.prototype, "value", void 0);
|
|
@@ -161,4 +146,3 @@ CustomFieldValue = __decorate([
|
|
|
161
146
|
})
|
|
162
147
|
], CustomFieldValue);
|
|
163
148
|
exports.default = CustomFieldValue;
|
|
164
|
-
//# sourceMappingURL=CustomFieldValue.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Sequelize } from 'sequelize-typescript';
|
|
2
|
+
import CustomFieldDefinition from './CustomFieldDefinition';
|
|
3
|
+
import CustomFieldValue from './CustomFieldValue';
|
|
4
|
+
import TestModel from './tests/TestModel';
|
|
5
|
+
import AssociatedTestModel from './tests/AssociatedTestModel';
|
|
6
|
+
declare const initTables: (sequelize: Sequelize, getUser: any) => Promise<void>;
|
|
7
|
+
declare const initTestModels: (sequelize: Sequelize) => Promise<void>;
|
|
8
|
+
export { CustomFieldValue, CustomFieldDefinition, TestModel, AssociatedTestModel, initTables, initTestModels, };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.initTestModels = exports.initTables = exports.AssociatedTestModel = exports.TestModel = exports.CustomFieldDefinition = exports.CustomFieldValue = void 0;
|
|
7
|
+
/* eslint-disable no-param-reassign */
|
|
8
|
+
const sequelize_1 = require("sequelize");
|
|
9
|
+
const logger_1 = __importDefault(require("../utils/logger"));
|
|
10
|
+
const CustomFieldDefinition_1 = __importDefault(require("./CustomFieldDefinition"));
|
|
11
|
+
exports.CustomFieldDefinition = CustomFieldDefinition_1.default;
|
|
12
|
+
const CustomFieldValue_1 = __importDefault(require("./CustomFieldValue"));
|
|
13
|
+
exports.CustomFieldValue = CustomFieldValue_1.default;
|
|
14
|
+
const TestModel_1 = __importDefault(require("./tests/TestModel"));
|
|
15
|
+
exports.TestModel = TestModel_1.default;
|
|
16
|
+
const AssociatedTestModel_1 = __importDefault(require("./tests/AssociatedTestModel"));
|
|
17
|
+
exports.AssociatedTestModel = AssociatedTestModel_1.default;
|
|
18
|
+
const productionModels = [CustomFieldDefinition_1.default, CustomFieldValue_1.default];
|
|
19
|
+
const testModels = [TestModel_1.default, AssociatedTestModel_1.default];
|
|
20
|
+
const SADOT_MIGRATION_PREFIX = 'sadot-migration';
|
|
21
|
+
const SCHEMA_VERSION = 1;
|
|
22
|
+
const CUSTOM_FIELDS_SCHEMA_VERSION = `${SADOT_MIGRATION_PREFIX}_${SCHEMA_VERSION}`;
|
|
23
|
+
const initTables = async (sequelize, getUser) => {
|
|
24
|
+
logger_1.default.info('custom-fields: initialize custom-fields tables');
|
|
25
|
+
// Detect models and import them to the orm
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
27
|
+
if (!sequelize.addModels) {
|
|
28
|
+
throw new Error('sequelize instance must have addModels function');
|
|
29
|
+
}
|
|
30
|
+
sequelize.addModels(productionModels);
|
|
31
|
+
CustomFieldDefinition_1.default.addScope('userScope', () => {
|
|
32
|
+
const user = getUser();
|
|
33
|
+
if (user?.permissions) {
|
|
34
|
+
return {
|
|
35
|
+
where: {
|
|
36
|
+
entityId: [
|
|
37
|
+
...Object.keys(user.permissions.fleets),
|
|
38
|
+
...Object.keys(user.permissions.businessModels),
|
|
39
|
+
...Object.keys(user.permissions.demandSources),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
});
|
|
46
|
+
logger_1.default.info('custom-fields: models added');
|
|
47
|
+
const SequelizeMeta = sequelize.define('SequelizeMeta', {
|
|
48
|
+
name: {
|
|
49
|
+
type: sequelize_1.DataTypes.STRING,
|
|
50
|
+
allowNull: false,
|
|
51
|
+
unique: true,
|
|
52
|
+
primaryKey: true,
|
|
53
|
+
autoIncrement: false,
|
|
54
|
+
},
|
|
55
|
+
}, {
|
|
56
|
+
tableName: 'SequelizeMeta',
|
|
57
|
+
timestamps: false,
|
|
58
|
+
schema: 'public',
|
|
59
|
+
});
|
|
60
|
+
const migrations = await SequelizeMeta.findAll({ raw: true });
|
|
61
|
+
const currentSadotSchemaVersion = migrations
|
|
62
|
+
.reverse().find((m) => m.name.includes(SADOT_MIGRATION_PREFIX));
|
|
63
|
+
if (!currentSadotSchemaVersion
|
|
64
|
+
|| currentSadotSchemaVersion.name !== CUSTOM_FIELDS_SCHEMA_VERSION) {
|
|
65
|
+
await CustomFieldDefinition_1.default.sync({ alter: true });
|
|
66
|
+
await CustomFieldValue_1.default.sync({ alter: true });
|
|
67
|
+
await SequelizeMeta.create({ name: CUSTOM_FIELDS_SCHEMA_VERSION });
|
|
68
|
+
logger_1.default.info('custom-fields: models synced');
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.initTables = initTables;
|
|
72
|
+
const initTestModels = async (sequelize) => {
|
|
73
|
+
logger_1.default.info('custom-fields: initialize custom-fields test models');
|
|
74
|
+
// Detect models and import them to the orm
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
76
|
+
if (!sequelize.addModels) {
|
|
77
|
+
throw new Error('sequelize instance must have addModels function');
|
|
78
|
+
}
|
|
79
|
+
sequelize.addModels(testModels);
|
|
80
|
+
await sequelize.dropSchema('custom-fields', { logging: false });
|
|
81
|
+
await sequelize.createSchema('custom-fields', { logging: false });
|
|
82
|
+
logger_1.default.info('custom-fields: test models added');
|
|
83
|
+
await TestModel_1.default.sync({ alter: true });
|
|
84
|
+
await AssociatedTestModel_1.default.sync({ alter: true });
|
|
85
|
+
logger_1.default.info('custom-fields: test models synced');
|
|
86
|
+
};
|
|
87
|
+
exports.initTestModels = initTestModels;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Model } from 'sequelize-typescript';
|
|
2
|
+
import TestModel from './TestModel';
|
|
3
|
+
declare class AssociatedTestModel extends Model {
|
|
4
|
+
id: string;
|
|
5
|
+
testModelId: string;
|
|
6
|
+
fleetId: string;
|
|
7
|
+
businessModelId: string;
|
|
8
|
+
demandSourceId: string;
|
|
9
|
+
anotherAttribute?: boolean;
|
|
10
|
+
testModel: TestModel;
|
|
11
|
+
}
|
|
12
|
+
export default AssociatedTestModel;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Model } from 'sequelize-typescript';
|
|
2
|
+
import AssociatedTestModel from './AssociatedTestModel';
|
|
3
|
+
declare class TestModel extends Model {
|
|
4
|
+
id: string;
|
|
5
|
+
fleetId: string;
|
|
6
|
+
businessModelId: string;
|
|
7
|
+
demandSourceId: string;
|
|
8
|
+
coolAttribute?: boolean;
|
|
9
|
+
associatedModels: AssociatedTestModel[];
|
|
10
|
+
}
|
|
11
|
+
export default TestModel;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CustomFieldDefinition } from '../models';
|
|
2
|
+
import type { CreateCustomFieldDefinition, UpdateCustomFieldDefinition } from '../types/definition';
|
|
3
|
+
export declare const create: (data: CreateCustomFieldDefinition) => Promise<CustomFieldDefinition>;
|
|
4
|
+
export declare const findAll: (where: any, options?: any) => Promise<CustomFieldDefinition[]>;
|
|
5
|
+
export declare const findByIds: (ids: string[], options?: any) => Promise<CustomFieldDefinition[]>;
|
|
6
|
+
export declare const findById: (id: string, options?: any) => Promise<CustomFieldDefinition | null>;
|
|
7
|
+
export declare const findByEntityId: (entityId: string, options?: any) => Promise<CustomFieldDefinition[]>;
|
|
8
|
+
export declare const findByEntityIds: (modelType: string, entityIds: string[], options?: any) => Promise<CustomFieldDefinition[]>;
|
|
9
|
+
export declare const findByWhere: (where: any) => Promise<CustomFieldDefinition | null>;
|
|
10
|
+
export declare const findDefinitionsByModels: (modelTypes: string[], options?: any) => Promise<CustomFieldDefinition[]>;
|
|
11
|
+
export declare const update: (id: string, data: UpdateCustomFieldDefinition) => Promise<CustomFieldDefinition>;
|
|
12
|
+
export declare const disable: (id: string) => Promise<any>;
|
|
13
|
+
export declare const destroy: (id: string) => Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Return the names of the required fields for a given model
|
|
16
|
+
*/
|
|
17
|
+
export declare const getRequiredFields: (modelType: string, modelId: string | string[], entityId: string | string[]) => Promise<string[]>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRequiredFields = exports.destroy = exports.disable = exports.update = exports.findDefinitionsByModels = exports.findByWhere = exports.findByEntityIds = exports.findByEntityId = exports.findById = exports.findByIds = exports.findAll = exports.create = void 0;
|
|
4
|
+
const sequelize_1 = require("sequelize");
|
|
5
|
+
const models_1 = require("../models");
|
|
6
|
+
const create = (data) => models_1.CustomFieldDefinition.create(data);
|
|
7
|
+
exports.create = create;
|
|
8
|
+
const findAll = (where, options = { withDisabled: false }) => {
|
|
9
|
+
const queryModel = options.withDisabled
|
|
10
|
+
? models_1.CustomFieldDefinition.unscoped()
|
|
11
|
+
: models_1.CustomFieldDefinition;
|
|
12
|
+
return queryModel.scope('userScope').findAll({
|
|
13
|
+
where,
|
|
14
|
+
transaction: options.transaction,
|
|
15
|
+
raw: true,
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.findAll = findAll;
|
|
19
|
+
const findByIds = (ids, options = { withDisabled: false }) => (0, exports.findAll)({ id: { [sequelize_1.Op.in]: ids } }, options);
|
|
20
|
+
exports.findByIds = findByIds;
|
|
21
|
+
const findById = (id, options = { withDisabled: false }) => {
|
|
22
|
+
const { withDisabled } = options;
|
|
23
|
+
if (withDisabled) {
|
|
24
|
+
return models_1.CustomFieldDefinition.unscoped().scope('userScope').findByPk(id);
|
|
25
|
+
}
|
|
26
|
+
return models_1.CustomFieldDefinition.scope('userScope').findByPk(id);
|
|
27
|
+
};
|
|
28
|
+
exports.findById = findById;
|
|
29
|
+
const findByEntityId = async (entityId, options = {}) => models_1.CustomFieldDefinition.findAll({
|
|
30
|
+
where: { entityId },
|
|
31
|
+
transaction: options.transaction,
|
|
32
|
+
});
|
|
33
|
+
exports.findByEntityId = findByEntityId;
|
|
34
|
+
const findByEntityIds = async (modelType, entityIds, options = {}) => models_1.CustomFieldDefinition.findAll({
|
|
35
|
+
where: {
|
|
36
|
+
modelType,
|
|
37
|
+
entityId: entityIds,
|
|
38
|
+
},
|
|
39
|
+
transaction: options.transaction,
|
|
40
|
+
raw: true,
|
|
41
|
+
});
|
|
42
|
+
exports.findByEntityIds = findByEntityIds;
|
|
43
|
+
const findByWhere = (where) => models_1.CustomFieldDefinition.scope('userScope').findOne({
|
|
44
|
+
where,
|
|
45
|
+
});
|
|
46
|
+
exports.findByWhere = findByWhere;
|
|
47
|
+
const findDefinitionsByModels = async (modelTypes, options) => {
|
|
48
|
+
const query = { modelType: { [sequelize_1.Op.in]: modelTypes } };
|
|
49
|
+
return models_1.CustomFieldDefinition.findAll({
|
|
50
|
+
where: query,
|
|
51
|
+
transaction: options?.transaction,
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
exports.findDefinitionsByModels = findDefinitionsByModels;
|
|
55
|
+
const update = async (id, data) => {
|
|
56
|
+
const updatedDefinition = (await models_1.CustomFieldDefinition.scope('userScope').update(data, {
|
|
57
|
+
where: { id },
|
|
58
|
+
returning: true,
|
|
59
|
+
individualHooks: true,
|
|
60
|
+
}))[1][0];
|
|
61
|
+
return updatedDefinition;
|
|
62
|
+
};
|
|
63
|
+
exports.update = update;
|
|
64
|
+
const disable = (id) => models_1.CustomFieldDefinition.update({ disabled: true }, { where: { id } });
|
|
65
|
+
exports.disable = disable;
|
|
66
|
+
const destroy = (id) => models_1.CustomFieldDefinition.destroy({ where: { id } });
|
|
67
|
+
exports.destroy = destroy;
|
|
68
|
+
/**
|
|
69
|
+
* Return the names of the required fields for a given model
|
|
70
|
+
*/
|
|
71
|
+
const getRequiredFields = async (modelType, modelId, entityId) => {
|
|
72
|
+
const entityIds = Array.isArray(entityId) ? entityId : [entityId];
|
|
73
|
+
const requiredFields = await models_1.CustomFieldDefinition.findAll({
|
|
74
|
+
where: { required: true, modelType, entityId: { [sequelize_1.Op.in]: entityIds } },
|
|
75
|
+
logging: true,
|
|
76
|
+
});
|
|
77
|
+
const requiredFieldsNames = requiredFields.map((definition) => definition.name);
|
|
78
|
+
return [...new Set(requiredFieldsNames)];
|
|
79
|
+
};
|
|
80
|
+
exports.getRequiredFields = getRequiredFields;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CustomFieldValue } from '../models';
|
|
2
|
+
import { CreateCustomFieldValue, ValuesToUpdate } from '../types/value';
|
|
3
|
+
export declare const findByModelIdAndDefinition: (modelId: string, customFieldDefinitionId: string) => Promise<CustomFieldValue[]>;
|
|
4
|
+
export declare const create: (data: CreateCustomFieldValue, withAssociations?: boolean) => Promise<CustomFieldValue>;
|
|
5
|
+
export declare const findAllValues: () => Promise<CustomFieldValue[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Get all values for model instance id (with their definitions)
|
|
8
|
+
* @param modelId
|
|
9
|
+
* @returns CustomFieldValue[]
|
|
10
|
+
*/
|
|
11
|
+
export declare const findValuesByModelId: (modelId: string) => Promise<CustomFieldValue[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves custom field values for given model IDs
|
|
14
|
+
* @param modelIds - An array of model IDs to query custom field values for.
|
|
15
|
+
* @param options - Optional configuration object.
|
|
16
|
+
*/
|
|
17
|
+
export declare const findValuesByModelIds: (modelIds: string[], options?: any) => Promise<CustomFieldValue[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Try to update custom field values for a model instance.
|
|
20
|
+
* Create new value record if not exists, but fails if value's definition not exist.
|
|
21
|
+
* Return the updated values
|
|
22
|
+
*/
|
|
23
|
+
export declare const updateValues: (modelType: string, modelId: string, identifiers: string[], valuesToUpdate: ValuesToUpdate, options?: any) => Promise<CustomFieldValue[]>;
|
|
24
|
+
export declare const deleteValue: (id: string, options?: any) => Promise<any>;
|