@autofleet/sadot 1.1.7-beta → 1.1.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/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorate.js +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/decorateMetadata.js +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/api/index.cjs +2 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.js +2 -12
- package/dist/api/index.js.map +1 -0
- package/dist/api/v1/definition/index.cjs +2 -0
- package/dist/api/v1/definition/index.cjs.map +1 -0
- package/dist/api/v1/definition/index.js +2 -116
- package/dist/api/v1/definition/index.js.map +1 -0
- package/dist/api/v1/definition/validations.cjs +2 -0
- package/dist/api/v1/definition/validations.cjs.map +1 -0
- package/dist/api/v1/definition/validations.js +2 -77
- package/dist/api/v1/definition/validations.js.map +1 -0
- package/dist/api/v1/errors.cjs +2 -0
- package/dist/api/v1/errors.cjs.map +1 -0
- package/dist/api/v1/errors.js +2 -12
- package/dist/api/v1/errors.js.map +1 -0
- package/dist/api/v1/index.cjs +2 -0
- package/dist/api/v1/index.cjs.map +1 -0
- package/dist/api/v1/index.js +2 -13
- package/dist/api/v1/index.js.map +1 -0
- package/dist/api/v1/validator/index.cjs +2 -0
- package/dist/api/v1/validator/index.cjs.map +1 -0
- package/dist/api/v1/validator/index.js +2 -143
- package/dist/api/v1/validator/index.js.map +1 -0
- package/dist/api/v1/validator/validations.cjs +2 -0
- package/dist/api/v1/validator/validations.cjs.map +1 -0
- package/dist/api/v1/validator/validations.d.cts +23 -0
- package/dist/api/v1/validator/validations.d.ts +23 -6
- package/dist/api/v1/validator/validations.js +2 -38
- package/dist/api/v1/validator/validations.js.map +1 -0
- package/dist/errors/index.cjs +3 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.js +3 -66
- package/dist/errors/index.js.map +1 -0
- package/dist/events/index.cjs +2 -0
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.js +2 -54
- package/dist/events/index.js.map +1 -0
- package/dist/hooks/enrich.cjs +2 -0
- package/dist/hooks/enrich.cjs.map +1 -0
- package/dist/hooks/enrich.js +2 -198
- package/dist/hooks/enrich.js.map +1 -0
- package/dist/hooks/find.cjs +2 -0
- package/dist/hooks/find.cjs.map +1 -0
- package/dist/hooks/find.js +2 -29
- package/dist/hooks/find.js.map +1 -0
- package/dist/hooks/hooks.cjs +2 -0
- package/dist/hooks/hooks.cjs.map +1 -0
- package/dist/hooks/hooks.js +2 -388
- package/dist/hooks/hooks.js.map +1 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.js +1 -17
- package/dist/hooks/utils/updateInstanceValues.cjs +2 -0
- package/dist/hooks/utils/updateInstanceValues.cjs.map +1 -0
- package/dist/hooks/utils/updateInstanceValues.js +2 -50
- package/dist/hooks/utils/updateInstanceValues.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +22 -12
- package/dist/index.js +2 -67
- package/dist/index.js.map +1 -0
- package/dist/models/CustomFieldDefinition.cjs +2 -0
- package/dist/models/CustomFieldDefinition.cjs.map +1 -0
- package/dist/models/CustomFieldDefinition.d.cts +31 -0
- package/dist/models/CustomFieldDefinition.d.ts +29 -23
- package/dist/models/CustomFieldDefinition.js +2 -192
- package/dist/models/CustomFieldDefinition.js.map +1 -0
- package/dist/models/CustomFieldEntries.cjs +2 -0
- package/dist/models/CustomFieldEntries.cjs.map +1 -0
- package/dist/models/CustomFieldEntries.d.cts +16 -0
- package/dist/models/CustomFieldEntries.d.ts +14 -13
- package/dist/models/CustomFieldEntries.js +2 -123
- package/dist/models/CustomFieldEntries.js.map +1 -0
- package/dist/models/CustomFieldValue.cjs +2 -0
- package/dist/models/CustomFieldValue.cjs.map +1 -0
- package/dist/models/CustomFieldValue.d.cts +22 -0
- package/dist/models/CustomFieldValue.d.ts +20 -14
- package/dist/models/CustomFieldValue.js +2 -151
- package/dist/models/CustomFieldValue.js.map +1 -0
- package/dist/models/CustomValidator.cjs +2 -0
- package/dist/models/CustomValidator.cjs.map +1 -0
- package/dist/models/CustomValidator.d.cts +19 -0
- package/dist/models/CustomValidator.d.ts +17 -15
- package/dist/models/CustomValidator.js +2 -98
- package/dist/models/CustomValidator.js.map +1 -0
- package/dist/models/index.cjs +2 -0
- package/dist/models/index.cjs.map +1 -0
- package/dist/models/index.d.cts +6 -0
- package/dist/models/index.d.ts +6 -18
- package/dist/models/index.js +2 -131
- package/dist/models/index.js.map +1 -0
- package/dist/models/tests/AssociatedTestModel.cjs +2 -0
- package/dist/models/tests/AssociatedTestModel.cjs.map +1 -0
- package/dist/models/tests/AssociatedTestModel.js +2 -71
- package/dist/models/tests/AssociatedTestModel.js.map +1 -0
- package/dist/models/tests/TestModel.cjs +2 -0
- package/dist/models/tests/TestModel.cjs.map +1 -0
- package/dist/models/tests/TestModel.js +2 -69
- package/dist/models/tests/TestModel.js.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs +2 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js +2 -53
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs +2 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.js +2 -47
- package/dist/models/tests/contextAwareModels/ContextTestModel.js.map +1 -0
- package/dist/repository/definition.cjs +2 -0
- package/dist/repository/definition.cjs.map +1 -0
- package/dist/repository/definition.js +2 -121
- package/dist/repository/definition.js.map +1 -0
- package/dist/repository/entries.cjs +2 -0
- package/dist/repository/entries.cjs.map +1 -0
- package/dist/repository/entries.js +2 -92
- package/dist/repository/entries.js.map +1 -0
- package/dist/repository/utils/formatValues.cjs +2 -0
- package/dist/repository/utils/formatValues.cjs.map +1 -0
- package/dist/repository/utils/formatValues.js +2 -16
- package/dist/repository/utils/formatValues.js.map +1 -0
- package/dist/repository/validator.cjs +2 -0
- package/dist/repository/validator.cjs.map +1 -0
- package/dist/repository/validator.js +2 -69
- package/dist/repository/validator.js.map +1 -0
- package/dist/repository/value.cjs +2 -0
- package/dist/repository/value.cjs.map +1 -0
- package/dist/repository/value.js +2 -124
- package/dist/repository/value.js.map +1 -0
- package/dist/scopes/filter.cjs +2 -0
- package/dist/scopes/filter.cjs.map +1 -0
- package/dist/scopes/filter.d.cts +23 -0
- package/dist/scopes/filter.d.ts +22 -29
- package/dist/scopes/filter.js +2 -75
- package/dist/scopes/filter.js.map +1 -0
- package/dist/scopes/helpers/filter.helpers.cjs +46 -0
- package/dist/scopes/helpers/filter.helpers.cjs.map +1 -0
- package/dist/scopes/helpers/filter.helpers.d.cts +17 -0
- package/dist/scopes/helpers/filter.helpers.d.ts +15 -40
- package/dist/scopes/helpers/filter.helpers.js +25 -183
- package/dist/scopes/helpers/filter.helpers.js.map +1 -0
- package/dist/scopes/index.cjs +1 -0
- package/dist/scopes/index.js +1 -6
- package/dist/types/index.d.cts +45 -0
- package/dist/types/index.d.ts +45 -46
- package/dist/utils/constants/index.cjs +2 -0
- package/dist/utils/constants/index.cjs.map +1 -0
- package/dist/utils/constants/index.d.cts +22 -0
- package/dist/utils/constants/index.d.ts +20 -17
- package/dist/utils/constants/index.js +2 -22
- package/dist/utils/constants/index.js.map +1 -0
- package/dist/utils/db/index.cjs +2 -0
- package/dist/utils/db/index.cjs.map +1 -0
- package/dist/utils/db/index.js +2 -24
- package/dist/utils/db/index.js.map +1 -0
- package/dist/utils/helpers/index.cjs +2 -0
- package/dist/utils/helpers/index.cjs.map +1 -0
- package/dist/utils/helpers/index.d.cts +31 -0
- package/dist/utils/helpers/index.d.ts +28 -23
- package/dist/utils/helpers/index.js +2 -40
- package/dist/utils/helpers/index.js.map +1 -0
- package/dist/utils/init.cjs +2 -0
- package/dist/utils/init.cjs.map +1 -0
- package/dist/utils/init.js +2 -112
- package/dist/utils/init.js.map +1 -0
- package/dist/utils/logger/index.cjs +2 -0
- package/dist/utils/logger/index.cjs.map +1 -0
- package/dist/utils/logger/index.js +2 -42
- package/dist/utils/logger/index.js.map +1 -0
- package/dist/utils/scopeAttributes.cjs +2 -0
- package/dist/utils/scopeAttributes.cjs.map +1 -0
- package/dist/utils/scopeAttributes.js +2 -11
- package/dist/utils/scopeAttributes.js.map +1 -0
- package/dist/utils/validations/index.cjs +2 -0
- package/dist/utils/validations/index.cjs.map +1 -0
- package/dist/utils/validations/index.js +2 -41
- package/dist/utils/validations/index.js.map +1 -0
- package/dist/utils/validations/schema/custom-fields.cjs +2 -0
- package/dist/utils/validations/schema/custom-fields.cjs.map +1 -0
- package/dist/utils/validations/schema/custom-fields.d.cts +7 -0
- package/dist/utils/validations/schema/custom-fields.d.ts +6 -2
- package/dist/utils/validations/schema/custom-fields.js +2 -9
- package/dist/utils/validations/schema/custom-fields.js.map +1 -0
- package/dist/utils/validations/schema/validator-schema.cjs +2 -0
- package/dist/utils/validations/schema/validator-schema.cjs.map +1 -0
- package/dist/utils/validations/schema/validator-schema.js +2 -95
- package/dist/utils/validations/schema/validator-schema.js.map +1 -0
- package/dist/utils/validations/validators/index.cjs +2 -0
- package/dist/utils/validations/validators/index.cjs.map +1 -0
- package/dist/utils/validations/validators/index.js +2 -40
- package/dist/utils/validations/validators/index.js.map +1 -0
- package/dist/utils/validations/validators/select.validator.cjs +2 -0
- package/dist/utils/validations/validators/select.validator.cjs.map +1 -0
- package/dist/utils/validations/validators/select.validator.js +2 -12
- package/dist/utils/validations/validators/select.validator.js.map +1 -0
- package/dist/utils/validations/validators/status.validator.cjs +2 -0
- package/dist/utils/validations/validators/status.validator.cjs.map +1 -0
- package/dist/utils/validations/validators/status.validator.js +2 -15
- package/dist/utils/validations/validators/status.validator.js.map +1 -0
- package/package.json +40 -39
- package/.nvmrc +0 -1
- package/dist/api/index.d.ts +0 -3
- package/dist/api/v1/definition/index.d.ts +0 -3
- package/dist/api/v1/definition/validations.d.ts +0 -2
- package/dist/api/v1/errors.d.ts +0 -4
- package/dist/api/v1/index.d.ts +0 -3
- package/dist/api/v1/validator/index.d.ts +0 -3
- package/dist/errors/index.d.ts +0 -24
- package/dist/events/index.d.ts +0 -5
- package/dist/hooks/create.d.ts +0 -10
- package/dist/hooks/create.js +0 -95
- package/dist/hooks/enrich.d.ts +0 -25
- package/dist/hooks/find.d.ts +0 -1
- package/dist/hooks/hooks.d.ts +0 -17
- package/dist/hooks/index.d.ts +0 -5
- package/dist/hooks/update.d.ts +0 -10
- package/dist/hooks/update.js +0 -49
- package/dist/hooks/utils/updateInstanceValues.d.ts +0 -15
- package/dist/hooks/workaround.d.ts +0 -10
- package/dist/hooks/workaround.js +0 -37
- package/dist/models/tests/AssociatedTestModel.d.ts +0 -12
- package/dist/models/tests/TestModel.d.ts +0 -12
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.d.ts +0 -10
- package/dist/models/tests/contextAwareModels/ContextTestModel.d.ts +0 -13
- package/dist/repository/definition.d.ts +0 -36
- package/dist/repository/entries.d.ts +0 -13
- package/dist/repository/utils/formatValues.d.ts +0 -3
- package/dist/repository/validator.d.ts +0 -28
- package/dist/repository/value.d.ts +0 -28
- package/dist/scopes/index.d.ts +0 -2
- package/dist/tests/api/test-api.d.ts +0 -2
- package/dist/tests/api/test-api.js +0 -38
- package/dist/tests/functional/searching/index.d.ts +0 -8
- package/dist/tests/functional/searching/index.js +0 -44
- package/dist/tests/helpers/commonHooks.d.ts +0 -6
- package/dist/tests/helpers/commonHooks.js +0 -62
- package/dist/tests/helpers/database-config.d.ts +0 -16
- package/dist/tests/helpers/database-config.js +0 -17
- package/dist/tests/helpers/index.d.ts +0 -7
- package/dist/tests/helpers/index.js +0 -33
- package/dist/tests/mocks/definition.mock.d.ts +0 -48
- package/dist/tests/mocks/definition.mock.js +0 -78
- package/dist/tests/mocks/events.mock.d.ts +0 -4
- package/dist/tests/mocks/events.mock.js +0 -21
- package/dist/tests/mocks/testModel.d.ts +0 -12
- package/dist/tests/mocks/testModel.js +0 -35
- package/dist/types/definition/index.d.ts +0 -25
- package/dist/types/definition/index.js +0 -2
- package/dist/types/entries/index.d.ts +0 -25
- package/dist/types/entries/index.js +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/value/index.d.ts +0 -15
- package/dist/types/value/index.js +0 -2
- package/dist/utils/db/index.d.ts +0 -4
- package/dist/utils/init.d.ts +0 -7
- package/dist/utils/logger/index.d.ts +0 -3
- package/dist/utils/scopeAttributes.d.ts +0 -2
- package/dist/utils/validations/index.d.ts +0 -8
- package/dist/utils/validations/schema/validator-schema.d.ts +0 -9
- package/dist/utils/validations/type.d.ts +0 -15
- package/dist/utils/validations/type.js +0 -2
- package/dist/utils/validations/validators/index.d.ts +0 -14
- package/dist/utils/validations/validators/select.validator.d.ts +0 -5
- package/dist/utils/validations/validators/status.validator.d.ts +0 -12
- package/src/api/index.ts +0 -10
- package/src/api/v1/definition/index.ts +0 -104
- package/src/api/v1/definition/validations.ts +0 -75
- package/src/api/v1/errors.ts +0 -13
- package/src/api/v1/index.ts +0 -11
- package/src/api/v1/validator/index.ts +0 -141
- package/src/api/v1/validator/validations.ts +0 -38
- package/src/errors/index.ts +0 -70
- package/src/events/index.ts +0 -63
- package/src/hooks/create.ts +0 -81
- package/src/hooks/enrich.ts +0 -255
- package/src/hooks/find.ts +0 -27
- package/src/hooks/hooks.ts +0 -479
- package/src/hooks/index.ts +0 -20
- package/src/hooks/update.ts +0 -55
- package/src/hooks/utils/updateInstanceValues.ts +0 -63
- package/src/hooks/workaround.ts +0 -47
- package/src/index.ts +0 -52
- package/src/models/CustomFieldDefinition.ts +0 -162
- package/src/models/CustomFieldEntries.ts +0 -81
- package/src/models/CustomFieldValue.ts +0 -118
- package/src/models/CustomValidator.ts +0 -78
- package/src/models/index.ts +0 -165
- package/src/models/tests/AssociatedTestModel.ts +0 -57
- package/src/models/tests/TestModel.ts +0 -54
- package/src/models/tests/contextAwareModels/ContextAwareTestModel.ts +0 -43
- package/src/models/tests/contextAwareModels/ContextTestModel.ts +0 -38
- package/src/repository/definition.ts +0 -175
- package/src/repository/entries.ts +0 -88
- package/src/repository/utils/formatValues.ts +0 -14
- package/src/repository/validator.ts +0 -119
- package/src/repository/value.ts +0 -116
- package/src/scopes/filter.ts +0 -100
- package/src/scopes/helpers/filter.helpers.ts +0 -227
- package/src/scopes/index.ts +0 -6
- package/src/tests/api/test-api.ts +0 -40
- package/src/tests/functional/searching/index.ts +0 -39
- package/src/tests/helpers/commonHooks.ts +0 -43
- package/src/tests/helpers/database-config.ts +0 -15
- package/src/tests/helpers/index.ts +0 -35
- package/src/tests/mocks/definition.mock.ts +0 -84
- package/src/tests/mocks/events.mock.ts +0 -21
- package/src/tests/mocks/testModel.ts +0 -37
- package/src/types/definition/index.ts +0 -24
- package/src/types/entries/index.ts +0 -27
- package/src/types/index.ts +0 -52
- package/src/types/value/index.ts +0 -14
- package/src/utils/constants/index.ts +0 -25
- package/src/utils/db/index.ts +0 -21
- package/src/utils/helpers/index.ts +0 -66
- package/src/utils/init.ts +0 -122
- package/src/utils/logger/index.ts +0 -14
- package/src/utils/scopeAttributes.ts +0 -12
- package/src/utils/validations/index.ts +0 -46
- package/src/utils/validations/schema/README.md +0 -93
- package/src/utils/validations/schema/custom-fields.ts +0 -8
- package/src/utils/validations/schema/validator-schema.ts +0 -106
- package/src/utils/validations/type.ts +0 -20
- package/src/utils/validations/validators/index.ts +0 -38
- package/src/utils/validations/validators/select.validator.ts +0 -12
- package/src/utils/validations/validators/status.validator.ts +0 -22
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -16
package/dist/errors/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadRequest } from '@autofleet/errors';
|
|
2
|
-
import type { ValidationError } from 'joi';
|
|
3
|
-
import type { EntriesValidationError } from '../types/entries';
|
|
4
|
-
export declare class MissingRequiredCustomFieldError extends BadRequest {
|
|
5
|
-
constructor(missingFields: string[]);
|
|
6
|
-
}
|
|
7
|
-
export declare class UnsupportedCustomFieldTypeError extends BadRequest {
|
|
8
|
-
constructor(fieldType: string);
|
|
9
|
-
}
|
|
10
|
-
export declare class UnsupportedCustomValidationError extends BadRequest {
|
|
11
|
-
constructor(fieldType: string);
|
|
12
|
-
}
|
|
13
|
-
export declare class InvalidFieldTypeError extends BadRequest {
|
|
14
|
-
constructor(fieldType: string);
|
|
15
|
-
}
|
|
16
|
-
export declare class InvalidValueError extends BadRequest {
|
|
17
|
-
constructor(value: any, fieldDefinitionName: string, joiValidationError: ValidationError);
|
|
18
|
-
}
|
|
19
|
-
export declare class InvalidEntriesError extends BadRequest {
|
|
20
|
-
constructor(modelId: string, validationErrors: EntriesValidationError[]);
|
|
21
|
-
}
|
|
22
|
-
export declare class MissingDefinitionError extends BadRequest {
|
|
23
|
-
constructor(fieldNames: string[]);
|
|
24
|
-
}
|
package/dist/events/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import Events from '@autofleet/events';
|
|
2
|
-
import type { CustomFieldDefinition, CustomFieldEntries, CustomFieldValue, CustomValidator } from '../models';
|
|
3
|
-
declare const events: Events;
|
|
4
|
-
export declare const sendDimEvent: (instance: CustomFieldDefinition | CustomFieldValue | CustomFieldEntries | CustomValidator) => void;
|
|
5
|
-
export default events;
|
package/dist/hooks/create.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CustomFieldOptions, ModelOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* A hook to create the custom fields when updating a model (more then one instance).
|
|
4
|
-
*/
|
|
5
|
-
export declare const beforeBulkCreate: (options: any) => void;
|
|
6
|
-
/**
|
|
7
|
-
* A hook to create the custom fields when updating a model instance.
|
|
8
|
-
* TODO - cleanup if update fail
|
|
9
|
-
*/
|
|
10
|
-
export declare const beforeCreate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
package/dist/hooks/create.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.beforeCreate = exports.beforeBulkCreate = void 0;
|
|
30
|
-
const logger_1 = __importDefault(require("../utils/logger"));
|
|
31
|
-
const DefinitionRepo = __importStar(require("../repository/definition"));
|
|
32
|
-
const errors_1 = require("../errors");
|
|
33
|
-
const scopeAttributes_1 = __importDefault(require("../utils/scopeAttributes"));
|
|
34
|
-
const updateInstanceValues_1 = __importDefault(require("./utils/updateInstanceValues"));
|
|
35
|
-
/**
|
|
36
|
-
* A hook to create the custom fields when updating a model (more then one instance).
|
|
37
|
-
*/
|
|
38
|
-
const beforeBulkCreate = (options) => {
|
|
39
|
-
// This will activate the beforeCreate hook on each updating instance.
|
|
40
|
-
// eslint-disable-next-line no-param-reassign
|
|
41
|
-
options.individualHooks = true;
|
|
42
|
-
};
|
|
43
|
-
exports.beforeBulkCreate = beforeBulkCreate;
|
|
44
|
-
/**
|
|
45
|
-
* A hook to create the custom fields when updating a model instance.
|
|
46
|
-
* TODO - cleanup if update fail
|
|
47
|
-
*/
|
|
48
|
-
const beforeCreate = (scopeAttributes, modelOptions = {}, sadotOptions = { useCustomFieldsEntries: false }) => async (instance, options) => {
|
|
49
|
-
logger_1.default.debug('sadot - before create hook');
|
|
50
|
-
const { fields } = options;
|
|
51
|
-
const { include, useEntityIdFromInclude } = modelOptions;
|
|
52
|
-
const modelType = instance.constructor.name;
|
|
53
|
-
const identifiers = (0, scopeAttributes_1.default)(instance, scopeAttributes);
|
|
54
|
-
const where = {
|
|
55
|
-
modelType,
|
|
56
|
-
disabled: false,
|
|
57
|
-
...(!useEntityIdFromInclude && { entityId: identifiers }),
|
|
58
|
-
};
|
|
59
|
-
const fieldDefinitions = await DefinitionRepo.findAll(where, { withDisabled: false, transaction: options.transaction, include: include?.(identifiers) });
|
|
60
|
-
const requiredFieldsNames = Array.from(new Set(fieldDefinitions.filter(({ required }) => required).map(({ name }) => name)));
|
|
61
|
-
const fieldsWithDefaultValue = fieldDefinitions.filter((def) => ![null, undefined].includes(def.defaultValue));
|
|
62
|
-
if (fieldsWithDefaultValue.length) {
|
|
63
|
-
// eslint-disable-next-line no-param-reassign
|
|
64
|
-
instance.customFields || (instance.customFields = {});
|
|
65
|
-
fieldsWithDefaultValue.filter((def) => (instance.customFields?.[def.name] === undefined)).forEach(({ name, defaultValue }) => {
|
|
66
|
-
// eslint-disable-next-line no-param-reassign
|
|
67
|
-
instance.customFields[name] = defaultValue;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const { customFields } = instance;
|
|
71
|
-
const fieldsNames = Object.keys(customFields ?? {});
|
|
72
|
-
const missingFields = requiredFieldsNames.filter((name) => !fieldsNames.includes(name));
|
|
73
|
-
if (missingFields?.length) {
|
|
74
|
-
throw new errors_1.MissingRequiredCustomFieldError(missingFields);
|
|
75
|
-
}
|
|
76
|
-
const customFieldsIdx = fields.indexOf('customFields');
|
|
77
|
-
if (customFieldsIdx === -1 || !customFields || !Object.keys(customFields).length) {
|
|
78
|
-
// After checking for required fields and fields with default values, and we have no custom fields.
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
await (0, updateInstanceValues_1.default)({
|
|
82
|
-
modelId: instance.id,
|
|
83
|
-
modelType,
|
|
84
|
-
identifiers,
|
|
85
|
-
customFields,
|
|
86
|
-
options: {
|
|
87
|
-
useCustomFieldsEntries: sadotOptions.useCustomFieldsEntries,
|
|
88
|
-
transaction: options.transaction,
|
|
89
|
-
modelOptions,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
// eslint-disable-next-line no-param-reassign
|
|
93
|
-
fields.splice(customFieldsIdx, 1);
|
|
94
|
-
};
|
|
95
|
-
exports.beforeCreate = beforeCreate;
|
package/dist/hooks/enrich.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type CustomFieldValue from '../models/CustomFieldValue';
|
|
2
|
-
import type { CustomFieldOptions, ModelOptions, TransactionOptions } from '../types';
|
|
3
|
-
type SupportedHookTypes = 'afterFind' | 'afterCreate' | 'afterUpdate';
|
|
4
|
-
type CustomFieldEntries = Record<string, any>;
|
|
5
|
-
interface GetValuesGroupByInstanceResponse {
|
|
6
|
-
[modelId: string]: CustomFieldValue[];
|
|
7
|
-
}
|
|
8
|
-
interface GetCustomFieldEntriesByInstanceIdResponse {
|
|
9
|
-
[modelId: string]: CustomFieldEntries;
|
|
10
|
-
}
|
|
11
|
-
export declare const getCustomFieldEntriesByInstanceId: ({ instancesIds, options, sadotOptions, }: {
|
|
12
|
-
instancesIds: string[];
|
|
13
|
-
options?: TransactionOptions;
|
|
14
|
-
sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;
|
|
15
|
-
}) => Promise<GetCustomFieldEntriesByInstanceIdResponse>;
|
|
16
|
-
export declare const getValuesGroupByInstance: ({ instancesIds, options, sadotOptions, }: {
|
|
17
|
-
instancesIds: string[];
|
|
18
|
-
options?: TransactionOptions;
|
|
19
|
-
sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;
|
|
20
|
-
}) => Promise<GetValuesGroupByInstanceResponse>;
|
|
21
|
-
/**
|
|
22
|
-
* A hook to attach the custom fields when fetching a model instances.
|
|
23
|
-
*/
|
|
24
|
-
declare const enrichResults: (modelType: string, scopeAttributes: string[], hookType?: SupportedHookTypes, modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instancesOrInstance: any | any[], options: TransactionOptions) => Promise<void>;
|
|
25
|
-
export default enrichResults;
|
package/dist/hooks/find.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const beforeFind: (scopeAttributes: string[]) => (options: any) => void;
|
package/dist/hooks/hooks.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CustomFieldOptions, ModelOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to handle validation and custom fields during creation
|
|
4
|
-
*/
|
|
5
|
-
export declare const beforeCreate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* Hook to handle validation and custom fields during update
|
|
8
|
-
*/
|
|
9
|
-
export declare const beforeUpdate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Hook to enable individual hooks for bulk create operations
|
|
12
|
-
*/
|
|
13
|
-
export declare const beforeBulkCreate: (options: any) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Hook to enable individual hooks for bulk update operations
|
|
16
|
-
*/
|
|
17
|
-
export declare const beforeBulkUpdate: (options: any) => void;
|
package/dist/hooks/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import enrichResults from './enrich';
|
|
2
|
-
import { beforeFind } from './find';
|
|
3
|
-
import workaround from './workaround';
|
|
4
|
-
import { beforeCreate, beforeUpdate, beforeBulkCreate, beforeBulkUpdate } from './hooks';
|
|
5
|
-
export { enrichResults, beforeFind, workaround, beforeCreate, beforeUpdate, beforeBulkCreate, beforeBulkUpdate, };
|
package/dist/hooks/update.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CustomFieldOptions, ModelOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* A hook to update the custom fields when updating a model (more then one instance).
|
|
4
|
-
*/
|
|
5
|
-
export declare const beforeBulkUpdate: (options: any) => void;
|
|
6
|
-
/**
|
|
7
|
-
* A hook to update the custom fields when updating a model instance.
|
|
8
|
-
* TODO - cleanup if update fail
|
|
9
|
-
*/
|
|
10
|
-
export declare const beforeUpdate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
package/dist/hooks/update.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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.beforeUpdate = exports.beforeBulkUpdate = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("../utils/logger"));
|
|
8
|
-
const scopeAttributes_1 = __importDefault(require("../utils/scopeAttributes"));
|
|
9
|
-
const updateInstanceValues_1 = __importDefault(require("./utils/updateInstanceValues"));
|
|
10
|
-
/**
|
|
11
|
-
* A hook to update the custom fields when updating a model (more then one instance).
|
|
12
|
-
*/
|
|
13
|
-
const beforeBulkUpdate = (options) => {
|
|
14
|
-
// This will activate the beforeUpdate hook on each updating instance.
|
|
15
|
-
// eslint-disable-next-line no-param-reassign
|
|
16
|
-
options.individualHooks = true;
|
|
17
|
-
};
|
|
18
|
-
exports.beforeBulkUpdate = beforeBulkUpdate;
|
|
19
|
-
/**
|
|
20
|
-
* A hook to update the custom fields when updating a model instance.
|
|
21
|
-
* TODO - cleanup if update fail
|
|
22
|
-
*/
|
|
23
|
-
const beforeUpdate = (scopeAttributes, modelOptions = {}, sadotOptions = { useCustomFieldsEntries: false }) => async (instance, options) => {
|
|
24
|
-
logger_1.default.debug('sadot - before update hook');
|
|
25
|
-
const { fields } = options;
|
|
26
|
-
const modelType = instance.constructor.name;
|
|
27
|
-
const identifiers = (0, scopeAttributes_1.default)(instance, scopeAttributes);
|
|
28
|
-
const customFieldsIdx = fields.indexOf('customFields');
|
|
29
|
-
if (customFieldsIdx > -1) {
|
|
30
|
-
const { customFields } = instance;
|
|
31
|
-
if (!Object.keys(customFields).length) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
await (0, updateInstanceValues_1.default)({
|
|
35
|
-
modelId: instance.id,
|
|
36
|
-
modelType,
|
|
37
|
-
identifiers,
|
|
38
|
-
customFields,
|
|
39
|
-
options: {
|
|
40
|
-
useCustomFieldsEntries: sadotOptions.useCustomFieldsEntries,
|
|
41
|
-
transaction: options.transaction,
|
|
42
|
-
modelOptions,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
// eslint-disable-next-line no-param-reassign
|
|
46
|
-
fields.splice(customFieldsIdx, 1);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.beforeUpdate = beforeUpdate;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Transaction } from 'sequelize';
|
|
2
|
-
import type { ModelOptions } from '../../types';
|
|
3
|
-
interface UpdateInstanceValuesParams {
|
|
4
|
-
modelId: string;
|
|
5
|
-
modelType: string;
|
|
6
|
-
identifiers: string[];
|
|
7
|
-
customFields: Record<string, any>;
|
|
8
|
-
options?: {
|
|
9
|
-
transaction?: Transaction;
|
|
10
|
-
modelOptions?: ModelOptions;
|
|
11
|
-
useCustomFieldsEntries?: boolean;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
declare const updateInstanceValues: ({ modelId, modelType, identifiers, customFields, options, }: UpdateInstanceValuesParams) => Promise<void>;
|
|
15
|
-
export default updateInstanceValues;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
package/dist/hooks/workaround.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Workaround to a bug in sequelize.🐛
|
|
4
|
-
*
|
|
5
|
-
* **afterFind hook** isn't working on nested (included) models.
|
|
6
|
-
* The solution here is to add a global afterFind hook,
|
|
7
|
-
* which manually calls the afterFind hook of each model, recursively
|
|
8
|
-
* https://github.com/sequelize/sequelize/issues/4627
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const handleChildrenAfterFindHook = async (instances, options, level = 0) => {
|
|
12
|
-
if (!instances)
|
|
13
|
-
return Promise.resolve();
|
|
14
|
-
if (Array.isArray(instances)) {
|
|
15
|
-
return Promise.all(instances.map((instance) => {
|
|
16
|
-
const { options: instanceOptions } = instance.constructor;
|
|
17
|
-
return handleChildrenAfterFindHook(instance, instanceOptions, level);
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
const instance = instances;
|
|
21
|
-
const { constructor } = instance;
|
|
22
|
-
/**
|
|
23
|
-
* Root model will have already run their "afterFind" hook.
|
|
24
|
-
* Only run children "afterFind" hooks.
|
|
25
|
-
*/
|
|
26
|
-
if (level >= 1) {
|
|
27
|
-
await constructor.runHooks('afterFind', instance, options);
|
|
28
|
-
}
|
|
29
|
-
const { associations } = constructor;
|
|
30
|
-
const associatedNames = Object.keys(instance).filter((attribute) => Object.keys(associations).includes(attribute));
|
|
31
|
-
if (associatedNames.length) {
|
|
32
|
-
const childInstances = associatedNames.map((name) => instance[name]);
|
|
33
|
-
return handleChildrenAfterFindHook(childInstances, options, level + 1);
|
|
34
|
-
}
|
|
35
|
-
return Promise.resolve();
|
|
36
|
-
};
|
|
37
|
-
exports.default = handleChildrenAfterFindHook;
|
|
@@ -1,12 +0,0 @@
|
|
|
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;
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
customFields?: any;
|
|
11
|
-
}
|
|
12
|
-
export default TestModel;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import ContextTestModel from './ContextTestModel';
|
|
3
|
-
declare class ContextAwareTestModel extends Model {
|
|
4
|
-
id: string;
|
|
5
|
-
contextId: string;
|
|
6
|
-
coolAttribute?: boolean;
|
|
7
|
-
customFields?: any;
|
|
8
|
-
context: ContextTestModel;
|
|
9
|
-
}
|
|
10
|
-
export default ContextAwareTestModel;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
declare enum EEntityTypes {
|
|
3
|
-
BUSINESS_MODEL = "businessModel",
|
|
4
|
-
CONTEXT = "context",
|
|
5
|
-
DEMAND_SOURCE = "demandSource",
|
|
6
|
-
FLEET = "fleet"
|
|
7
|
-
}
|
|
8
|
-
declare class ContextTestModel extends Model {
|
|
9
|
-
id: string;
|
|
10
|
-
entityId: string;
|
|
11
|
-
entityType: EEntityTypes;
|
|
12
|
-
}
|
|
13
|
-
export default ContextTestModel;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type Includeable, type Transaction, type FindOptions, type WhereOptions } from 'sequelize';
|
|
2
|
-
import { CustomFieldDefinition, type CustomFieldEntries } from '../models';
|
|
3
|
-
import type { CreateCustomFieldDefinition, UpdateCustomFieldDefinition } from '../types/definition';
|
|
4
|
-
import type { ModelOptions } from '../types';
|
|
5
|
-
export declare const create: (data: CreateCustomFieldDefinition) => Promise<CustomFieldDefinition>;
|
|
6
|
-
interface SadotFindOptions {
|
|
7
|
-
withDisabled?: boolean;
|
|
8
|
-
transaction?: Transaction;
|
|
9
|
-
include?: Includeable | Includeable[];
|
|
10
|
-
}
|
|
11
|
-
type SadotGetDefinitionsByEntityIdsOptions = FindOptions & {
|
|
12
|
-
modelOptions?: ModelOptions;
|
|
13
|
-
} & Pick<SadotFindOptions, 'withDisabled'>;
|
|
14
|
-
export declare const findAll: (where: WhereOptions, options?: SadotFindOptions) => Promise<CustomFieldDefinition[]>;
|
|
15
|
-
export declare const findByIds: (ids: string[], options?: SadotFindOptions) => Promise<CustomFieldDefinition[]>;
|
|
16
|
-
export declare const findById: (id: string, options?: Pick<SadotFindOptions, 'withDisabled'>) => Promise<CustomFieldDefinition | null>;
|
|
17
|
-
export declare const findByEntityIds: (modelType: string, entityIds: string[], options?: FindOptions & {
|
|
18
|
-
modelOptions?: ModelOptions;
|
|
19
|
-
}) => Promise<CustomFieldDefinition[]>;
|
|
20
|
-
export declare const findByWhere: (where: any) => Promise<CustomFieldDefinition | null>;
|
|
21
|
-
export declare const findDefinitionsByModels: (modelTypes: string[], options?: any) => Promise<CustomFieldDefinition[]>;
|
|
22
|
-
export declare const update: (id: string, data: UpdateCustomFieldDefinition) => Promise<CustomFieldDefinition>;
|
|
23
|
-
export declare const disable: (id: string) => Promise<[affectedCount: number]>;
|
|
24
|
-
export declare const destroy: (id: string) => Promise<number>;
|
|
25
|
-
/**
|
|
26
|
-
* Return the names of the required fields for a given model
|
|
27
|
-
*/
|
|
28
|
-
export declare const getRequiredFields: (modelType: string, modelId: string | string[], entityId: string | string[], modelOptions?: ModelOptions) => Promise<string[]>;
|
|
29
|
-
/**
|
|
30
|
-
* @returns A promise resolving with a dictionary of custom field definitions by name.
|
|
31
|
-
* @throws A {@link MissingDefinitionError} if any of the custom fields doesn't have a definition.
|
|
32
|
-
*/
|
|
33
|
-
export declare const getCustomFieldDefinitionsDictionary: (instances: CustomFieldEntries[], options?: SadotGetDefinitionsByEntityIdsOptions) => Promise<{
|
|
34
|
-
[definitionName: string]: CustomFieldDefinition;
|
|
35
|
-
}>;
|
|
36
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FindOptions, Includeable, Transaction } from 'sequelize';
|
|
2
|
-
import { CustomFieldEntries } from '../models';
|
|
3
|
-
import type { ModelOptions } from '../types';
|
|
4
|
-
type CustomFieldEntriesModelOptions = ModelOptions & {
|
|
5
|
-
include?: Includeable;
|
|
6
|
-
transaction?: Transaction;
|
|
7
|
-
};
|
|
8
|
-
export declare const findEntriesByModelId: (modelId: string, options?: CustomFieldEntriesModelOptions) => Promise<CustomFieldEntries>;
|
|
9
|
-
export declare const findEntriesByModelIds: (modelIds: string[], options?: CustomFieldEntriesModelOptions) => Promise<CustomFieldEntries[]>;
|
|
10
|
-
export declare const updateEntries: (modelId: string, modelType: string, customFields: Record<string, any>, identifiers: string[], options?: FindOptions & {
|
|
11
|
-
modelOptions?: ModelOptions;
|
|
12
|
-
}) => Promise<[CustomFieldEntries, boolean]>;
|
|
13
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { FindOptions, IncludeOptions, Transactionable } from 'sequelize';
|
|
2
|
-
import { CustomValidator } from '../models';
|
|
3
|
-
import type { ModelOptions } from '../types';
|
|
4
|
-
export interface FindValidatorOptions extends Transactionable {
|
|
5
|
-
withDisabled?: boolean;
|
|
6
|
-
attributes?: string[];
|
|
7
|
-
raw?: boolean;
|
|
8
|
-
include?: IncludeOptions[];
|
|
9
|
-
}
|
|
10
|
-
export interface ValidatorAttributes {
|
|
11
|
-
entityId: string;
|
|
12
|
-
entityType: string;
|
|
13
|
-
modelType: string;
|
|
14
|
-
schema: CustomValidator['schema'];
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
[key: string]: unknown;
|
|
17
|
-
}
|
|
18
|
-
export declare const create: (validatorAttributes: ValidatorAttributes, options?: Transactionable) => Promise<CustomValidator>;
|
|
19
|
-
export declare const findAll: (where?: {}, options?: FindOptions & {
|
|
20
|
-
modelOptions?: ModelOptions;
|
|
21
|
-
withDisabled?: boolean;
|
|
22
|
-
}) => Promise<CustomValidator[]>;
|
|
23
|
-
export declare const findAllByModelType: (modelType: string, entityId: string, options?: FindOptions & {
|
|
24
|
-
modelOptions?: ModelOptions;
|
|
25
|
-
withDisabled?: boolean;
|
|
26
|
-
}) => Promise<CustomValidator[]>;
|
|
27
|
-
export declare const update: (id: string, updates: Partial<ValidatorAttributes>, options?: Transactionable) => Promise<[number, CustomValidator[]]>;
|
|
28
|
-
export declare const disable: (id: string, options?: Transactionable) => Promise<[number, CustomValidator[]]>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { FindOptions } from 'sequelize';
|
|
2
|
-
import { CustomFieldValue } from '../models';
|
|
3
|
-
import type { CreateCustomFieldValue, ValuesToUpdate } from '../types/value';
|
|
4
|
-
import type { ModelOptions } from '../types';
|
|
5
|
-
export declare const findByModelIdAndDefinition: (modelId: string, customFieldDefinitionId: string) => Promise<CustomFieldValue[]>;
|
|
6
|
-
export declare const create: (data: CreateCustomFieldValue, withAssociations?: boolean) => Promise<CustomFieldValue>;
|
|
7
|
-
export declare const findAllValues: () => Promise<CustomFieldValue[]>;
|
|
8
|
-
/**
|
|
9
|
-
* Get all values for model instance id (with their definitions)
|
|
10
|
-
* @param modelId
|
|
11
|
-
* @returns CustomFieldValue[]
|
|
12
|
-
*/
|
|
13
|
-
export declare const findValuesByModelId: (modelId: string) => Promise<CustomFieldValue[]>;
|
|
14
|
-
/**
|
|
15
|
-
* Retrieves custom field values for given model IDs
|
|
16
|
-
* @param modelIds - An array of model IDs to query custom field values for.
|
|
17
|
-
* @param options - Optional configuration object.
|
|
18
|
-
*/
|
|
19
|
-
export declare const findValuesByModelIds: (modelIds: string[], options?: any) => Promise<CustomFieldValue[]>;
|
|
20
|
-
/**
|
|
21
|
-
* Try to update custom field values for a model instance.
|
|
22
|
-
* Create new value record if not exists, but fails if value's definition not exist.
|
|
23
|
-
* Return the updated values
|
|
24
|
-
*/
|
|
25
|
-
export declare const updateValues: (modelType: string, modelId: string, identifiers: string[], valuesToUpdate: ValuesToUpdate, options?: FindOptions & {
|
|
26
|
-
modelOptions?: ModelOptions;
|
|
27
|
-
}) => Promise<CustomFieldValue[]>;
|
|
28
|
-
export declare const deleteValue: (id: string, options?: any) => Promise<any>;
|
package/dist/scopes/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
const express_1 = __importDefault(require("express"));
|
|
7
|
-
const node_common_1 = require("@autofleet/node-common");
|
|
8
|
-
const logger_1 = __importDefault(require("../../utils/logger"));
|
|
9
|
-
const models_1 = require("../../models");
|
|
10
|
-
const app = (0, express_1.default)();
|
|
11
|
-
app.use(express_1.default.json());
|
|
12
|
-
const api = (0, node_common_1.Router)({ logger: logger_1.default });
|
|
13
|
-
api.get('/v1/test-models', async (req, res) => {
|
|
14
|
-
const testModels = await models_1.TestModel.findAll();
|
|
15
|
-
return res.json(testModels);
|
|
16
|
-
});
|
|
17
|
-
api.get('/v1/test-models/:testModelId', async (req, res) => {
|
|
18
|
-
const { params: { testModelId } } = req;
|
|
19
|
-
const testModel = await models_1.TestModel.findByPk(testModelId);
|
|
20
|
-
return res.json(testModel);
|
|
21
|
-
});
|
|
22
|
-
api.post('/v1/test-models', async (req, res) => {
|
|
23
|
-
const { body } = req;
|
|
24
|
-
const testModel = await models_1.TestModel.create(body);
|
|
25
|
-
return res.json(testModel);
|
|
26
|
-
});
|
|
27
|
-
api.patch('/v1/test-models/:testModelId', async (req, res) => {
|
|
28
|
-
const { body, params: { testModelId } } = req;
|
|
29
|
-
const testModel = await models_1.TestModel.update(body, {
|
|
30
|
-
where: {
|
|
31
|
-
id: testModelId,
|
|
32
|
-
},
|
|
33
|
-
returning: true,
|
|
34
|
-
});
|
|
35
|
-
return res.json(testModel[1][0]);
|
|
36
|
-
});
|
|
37
|
-
app.use('/api', api);
|
|
38
|
-
exports.default = app;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
interface CustomFieldsSearchTestFlowInput {
|
|
2
|
-
fieldType: string;
|
|
3
|
-
fieldValue: string | number;
|
|
4
|
-
searchTerm: string;
|
|
5
|
-
expectedNumberOfQueryResults: number;
|
|
6
|
-
}
|
|
7
|
-
declare const customFieldsSearchTestFlow: ({ fieldType, fieldValue, searchTerm, expectedNumberOfQueryResults, }: CustomFieldsSearchTestFlowInput) => Promise<void>;
|
|
8
|
-
export default customFieldsSearchTestFlow;
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const index_1 = require("../../../index");
|
|
27
|
-
const DefinitionRepo = __importStar(require("../../../repository/definition"));
|
|
28
|
-
const definition_mock_1 = require("../../mocks/definition.mock");
|
|
29
|
-
const testModel_1 = require("../../mocks/testModel");
|
|
30
|
-
const models_1 = require("../../../models");
|
|
31
|
-
const customFieldsSearchTestFlow = async ({ fieldType, fieldValue, searchTerm, expectedNumberOfQueryResults, }) => {
|
|
32
|
-
const definition = (0, definition_mock_1.createDefinition)({ fieldType, name: 'coolDefinition' });
|
|
33
|
-
await DefinitionRepo.create({ ...definition });
|
|
34
|
-
const [testModel1] = await (0, testModel_1.createTestModels)(definition.entityId, 2);
|
|
35
|
-
await testModel1.update({ customFields: { [definition.name]: fieldValue } });
|
|
36
|
-
const models = await models_1.TestModel.findAndCountAll({
|
|
37
|
-
...(0, index_1.generateCustomFieldSearchQueryPayload)(searchTerm, models_1.TestModel, definition.entityId),
|
|
38
|
-
});
|
|
39
|
-
expect(models.count).toBe(expectedNumberOfQueryResults);
|
|
40
|
-
if (expectedNumberOfQueryResults > 0) {
|
|
41
|
-
expect(models.rows[0].dataValues.id).toBe(testModel1.id);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
exports.default = customFieldsSearchTestFlow;
|