@nomalism-com/types 0.37.7 → 0.37.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/index.cjs +2 -4
- package/dist/index.js +2 -4
- package/dist/modules/supply/documentSet/interface.d.ts +0 -2
- package/dist/shared/entities/stock.d.ts +0 -1
- package/package.json +4 -1
- package/.editorconfig +0 -9
- package/.prettierrc +0 -7
- package/eslint.config.mjs +0 -39
- package/package-lock.json +0 -4327
- package/src/index.ts +0 -3
- package/src/main.ts +0 -672
- package/src/modules/document/billOfLading/interfaces.ts +0 -26
- package/src/modules/document/billOfLading/route.schema.ts +0 -32
- package/src/modules/document/inventario/interface.ts +0 -19
- package/src/modules/document/inventario/route.schema.ts +0 -16
- package/src/modules/document/materialEntrance/interfaces.ts +0 -207
- package/src/modules/document/materialEntrance/route.schema.ts +0 -53
- package/src/modules/document/order/interfaces.ts +0 -172
- package/src/modules/document/order/route.schema.ts +0 -61
- package/src/modules/document/productionOrder/interfaces.ts +0 -12
- package/src/modules/document/productionOrder/route.schema.ts +0 -13
- package/src/modules/document/proforma/interfaces.ts +0 -15
- package/src/modules/document/proforma/route.schema.ts +0 -14
- package/src/modules/document/propostaFornecedor/interfaces.ts +0 -17
- package/src/modules/document/propostaFornecedor/route.schema.ts +0 -21
- package/src/modules/document/propostaSheets/interface.ts +0 -113
- package/src/modules/document/propostaSheets/route.schema.ts +0 -45
- package/src/modules/document/providerCreditNoteFromReturn/interfaces.ts +0 -48
- package/src/modules/document/providerCreditNoteFromReturn/route.schema.ts +0 -41
- package/src/modules/document/providerFinancialCreditNote/interfaces.ts +0 -36
- package/src/modules/document/providerFinancialCreditNote/route.schema.ts +0 -40
- package/src/modules/document/providerServiceInvoice/interfaces.ts +0 -20
- package/src/modules/document/providerServiceInvoice/route.schema.ts +0 -26
- package/src/modules/document/purchase/interfaces.ts +0 -112
- package/src/modules/document/purchase/route.schema.ts +0 -51
- package/src/modules/document/quebra/interfaces.ts +0 -46
- package/src/modules/document/quebra/route.schema.ts +0 -25
- package/src/modules/document/returnToProvider/interface.ts +0 -59
- package/src/modules/document/returnToProvider/route.schema.ts +0 -27
- package/src/modules/document/transformado/interfaces.ts +0 -31
- package/src/modules/document/transformado/route.schema.ts +0 -26
- package/src/modules/document/upfrontReturn/interfaces.ts +0 -17
- package/src/modules/document/upfrontReturn/route.schema.ts +0 -11
- package/src/modules/documentManagement/multimedia/interfaces.ts +0 -22
- package/src/modules/documentManagement/multimedia/route.schema.ts +0 -9
- package/src/modules/integration/emailLog/interfaces.ts +0 -111
- package/src/modules/integration/emailLog/route.schema.ts +0 -18
- package/src/modules/integration/emailTemplate/interfaces.ts +0 -55
- package/src/modules/integration/emailTemplate/route.schema.ts +0 -95
- package/src/modules/integration/emailTemplateAttachment/interfaces.ts +0 -22
- package/src/modules/integration/emailTemplateAttachment/route.schema.ts +0 -12
- package/src/modules/integration/emailVerification/interfaces.ts +0 -30
- package/src/modules/integration/emailVerification/route.schema.ts +0 -34
- package/src/modules/integration/googleFilePermission/interfaces.ts +0 -32
- package/src/modules/integration/googleFilePermission/route.schema.ts +0 -15
- package/src/modules/integration/googleSheets/interfaces.ts +0 -98
- package/src/modules/integration/googleSheets/route.schema.ts +0 -52
- package/src/modules/integration/observation/interfaces.ts +0 -61
- package/src/modules/integration/observation/route.schema.ts +0 -40
- package/src/modules/integration/observationType/interfaces.ts +0 -37
- package/src/modules/integration/observationType/route.schema.ts +0 -17
- package/src/modules/integration/projectInfo/interfaces.ts +0 -26
- package/src/modules/integration/projectInfo/route.schema.ts +0 -18
- package/src/modules/integration/settings/interfaces.ts +0 -31
- package/src/modules/integration/settings/route.schema.ts +0 -24
- package/src/modules/print/npc/interfaces.ts +0 -34
- package/src/modules/print/npc/route.schema.ts +0 -21
- package/src/modules/print/printer/interfaces.ts +0 -47
- package/src/modules/print/printer/route.schema.ts +0 -60
- package/src/modules/print/schedulePrintJob/interfaces.ts +0 -48
- package/src/modules/print/schedulePrintJob/route.schema.ts +0 -39
- package/src/modules/stock/chat/interfaces.ts +0 -82
- package/src/modules/stock/chat/route.schema.ts +0 -28
- package/src/modules/stock/chatRapidMessage/interface.ts +0 -31
- package/src/modules/stock/chatRapidMessage/route.schema.ts +0 -18
- package/src/modules/stock/dashboard/interface.ts +0 -25
- package/src/modules/stock/dashboard/route.schema.ts +0 -11
- package/src/modules/stock/file/interface.ts +0 -37
- package/src/modules/stock/file/route.schema.ts +0 -37
- package/src/modules/stock/location/interface.ts +0 -77
- package/src/modules/stock/location/route.schema.ts +0 -57
- package/src/modules/stock/prison/interface.ts +0 -70
- package/src/modules/stock/prison/route.schema.ts +0 -50
- package/src/modules/stock/productGoogleSheets/interface.ts +0 -339
- package/src/modules/stock/productGoogleSheets/route.schema.ts +0 -146
- package/src/modules/stock/productImage/interface.ts +0 -69
- package/src/modules/stock/productImage/route.schema.ts +0 -52
- package/src/modules/stock/promotion/interface.ts +0 -61
- package/src/modules/stock/promotion/route.schema.ts +0 -39
- package/src/modules/stock/promotionAssoc/interface.ts +0 -62
- package/src/modules/stock/promotionAssoc/route.schema.ts +0 -35
- package/src/modules/stock/queryList/interfaces.ts +0 -56
- package/src/modules/stock/queryList/route.schema.ts +0 -37
- package/src/modules/stock/queryParameter/interfaces.ts +0 -72
- package/src/modules/stock/queryParameter/route.schema.ts +0 -36
- package/src/modules/stock/recurrentTasks/interface.ts +0 -12
- package/src/modules/stock/returnReason/interfaces.ts +0 -23
- package/src/modules/stock/returnReason/route.schema.ts +0 -14
- package/src/modules/stock/savedEmPicking/interfaces.ts +0 -37
- package/src/modules/stock/savedEmPicking/route.schema.ts +0 -113
- package/src/modules/stock/savedProviderProposal/interfaces.ts +0 -32
- package/src/modules/stock/savedProviderProposal/route.schema.ts +0 -16
- package/src/modules/stock/sideMenu/interface.ts +0 -48
- package/src/modules/stock/sideMenu/route.schema.ts +0 -20
- package/src/modules/stock/stockMovement/interface.ts +0 -78
- package/src/modules/stock/stockMovement/route.schema.ts +0 -34
- package/src/modules/stock/tag/interface.ts +0 -36
- package/src/modules/stock/tag/route.schema.ts +0 -30
- package/src/modules/stock/task/interface.ts +0 -126
- package/src/modules/stock/task/route.schema.ts +0 -48
- package/src/modules/stock/taskMessage/interface.ts +0 -18
- package/src/modules/stock/taskMessage/route.schema.ts +0 -19
- package/src/modules/stock/taskRead/interface.ts +0 -17
- package/src/modules/stock/taskRead/route.schema.ts +0 -18
- package/src/modules/stock/typeOfLocation/interface.ts +0 -51
- package/src/modules/stock/typeOfLocation/route.schema.ts +0 -29
- package/src/modules/stock/unitOfMeasure/interface.ts +0 -64
- package/src/modules/stock/unitOfMeasure/route.schema.ts +0 -41
- package/src/modules/stock/vatTax/interface.ts +0 -55
- package/src/modules/stock/vatTax/route.schema.ts +0 -33
- package/src/modules/stock/vatTaxZone/interface.ts +0 -63
- package/src/modules/stock/vatTaxZone/route.schema.ts +0 -42
- package/src/modules/stock/vatValidation/interfaces.ts +0 -10
- package/src/modules/stock/vatValidation/route.schema.ts +0 -8
- package/src/modules/stock/workflow/interfaces.ts +0 -64
- package/src/modules/stock/workflow/route.schema.ts +0 -28
- package/src/modules/supply/batch/interface.ts +0 -0
- package/src/modules/supply/documentHeader/interfaces.ts +0 -497
- package/src/modules/supply/documentHeader/route.schema.ts +0 -371
- package/src/modules/supply/documentHeaderHistory/interfaces.ts +0 -15
- package/src/modules/supply/documentLine/interfaces.ts +0 -210
- package/src/modules/supply/documentLine/route.schema.ts +0 -108
- package/src/modules/supply/documentLineAssoc/interfaces.ts +0 -52
- package/src/modules/supply/documentLineAssoc/route.schema.ts +0 -16
- package/src/modules/supply/documentLineMT/interface.ts +0 -27
- package/src/modules/supply/documentLineMT/route.schema.ts +0 -18
- package/src/modules/supply/documentLineNote/interfaces.ts +0 -53
- package/src/modules/supply/documentLineNote/route.schema.ts +0 -19
- package/src/modules/supply/documentLineRM/interface.ts +0 -34
- package/src/modules/supply/documentLineRM/route.schema.ts +0 -25
- package/src/modules/supply/documentSet/interface.ts +0 -31
- package/src/modules/supply/documentSet/route.schema.ts +0 -20
- package/src/modules/supply/documentType/interfaces.ts +0 -214
- package/src/modules/supply/documentType/route.schema.ts +0 -75
- package/src/modules/supply/externalDocumentHeader/interface.ts +0 -120
- package/src/modules/supply/externalDocumentHeader/route.schema.ts +0 -79
- package/src/modules/supply/externalDocumentType/interface.ts +0 -14
- package/src/modules/supply/orderManagement/interface.ts +0 -49
- package/src/modules/supply/orderManagement/route.schema.ts +0 -0
- package/src/modules/supply/payment/interface.ts +0 -229
- package/src/modules/supply/payment/route.schema.ts +0 -122
- package/src/modules/supply/preSale/interface.ts +0 -92
- package/src/modules/supply/preSale/route.schema.ts +0 -75
- package/src/modules/supply/preSaleProduct/interface.ts +0 -16
- package/src/modules/supply/preSaleProduct/route.schema.ts +0 -7
- package/src/modules/supply/schedule/interface.ts +0 -47
- package/src/modules/supply/schedule/route.schema.ts +0 -14
- package/src/modules/supply/startDocumentHeaderLastUpdate/interface.ts +0 -15
- package/src/modules/tickets/channel/interfaces.ts +0 -35
- package/src/modules/tickets/channel/route.schema.ts +0 -24
- package/src/modules/tickets/clt/interfaces.ts +0 -26
- package/src/modules/tickets/clt/route.schema.ts +0 -24
- package/src/modules/tickets/language/interfaces.ts +0 -25
- package/src/modules/tickets/language/route.schema.ts +0 -28
- package/src/modules/tickets/tickets/interfaces.ts +0 -80
- package/src/modules/tickets/tickets/route.schema.ts +0 -19
- package/src/modules/user/bankData/interface.ts +0 -64
- package/src/modules/user/bankData/route.schema.ts +0 -40
- package/src/modules/user/chatSubscribers/interfaces.ts +0 -34
- package/src/modules/user/chatSubscribers/route.schema.ts +0 -12
- package/src/modules/user/clientType/interface.ts +0 -47
- package/src/modules/user/clientType/route.schema.ts +0 -31
- package/src/modules/user/clients/interface.ts +0 -138
- package/src/modules/user/clients/route.schema.ts +0 -87
- package/src/modules/user/commissioner/interface.ts +0 -110
- package/src/modules/user/commissioner/route.schema.ts +0 -65
- package/src/modules/user/country/interface.ts +0 -54
- package/src/modules/user/country/route.schema.ts +0 -36
- package/src/modules/user/deliveryMethods/interfaces.ts +0 -28
- package/src/modules/user/deliveryMethods/route.schema.ts +0 -15
- package/src/modules/user/favorites/interfaces.ts +0 -28
- package/src/modules/user/favorites/route.schema.ts +0 -19
- package/src/modules/user/groupPermissions/interface.ts +0 -32
- package/src/modules/user/groupPermissions/route.schema.ts +0 -11
- package/src/modules/user/language/interface.ts +0 -47
- package/src/modules/user/language/route.schema.ts +0 -28
- package/src/modules/user/maturityDates/interfaces.ts +0 -31
- package/src/modules/user/maturityDates/route.schema.ts +0 -18
- package/src/modules/user/password/interfaces.ts +0 -21
- package/src/modules/user/password/route.schema.ts +0 -22
- package/src/modules/user/paymentMethods/interfaces.ts +0 -72
- package/src/modules/user/paymentMethods/route.schema.ts +0 -27
- package/src/modules/user/permissions/interface.ts +0 -34
- package/src/modules/user/permissions/route.schema.ts +0 -11
- package/src/modules/user/persona/interface.ts +0 -157
- package/src/modules/user/persona/route.schema.ts +0 -101
- package/src/modules/user/providerType/interface.ts +0 -47
- package/src/modules/user/providerType/route.schema.ts +0 -28
- package/src/modules/user/providers/interface.ts +0 -130
- package/src/modules/user/providers/route.schema.ts +0 -85
- package/src/modules/user/purchaseConditions/interface.ts +0 -58
- package/src/modules/user/purchaseConditions/route.schema.ts +0 -33
- package/src/modules/user/reasonForExemption/interface.ts +0 -53
- package/src/modules/user/reasonForExemption/route.schema.ts +0 -34
- package/src/modules/user/refreshToken/interface.ts +0 -19
- package/src/modules/user/refreshToken/route.schema.ts +0 -10
- package/src/modules/user/segmentsArea/interface.ts +0 -49
- package/src/modules/user/segmentsArea/route.schema.ts +0 -30
- package/src/modules/user/sessions/interface.ts +0 -24
- package/src/modules/user/sessions/route.schema.ts +0 -10
- package/src/modules/user/shippings/interface.ts +0 -57
- package/src/modules/user/shippings/route.schema.ts +0 -35
- package/src/modules/user/storeOperator/interface.ts +0 -42
- package/src/modules/user/storeOperator/route.schema.ts +0 -45
- package/src/modules/user/swift/interface.ts +0 -55
- package/src/modules/user/swift/route.schema.ts +0 -36
- package/src/modules/user/tenant/interface.ts +0 -59
- package/src/modules/user/tenant/route.schema.ts +0 -46
- package/src/modules/user/theme/interfaces.ts +0 -21
- package/src/modules/user/theme/route.schema.ts +0 -19
- package/src/modules/user/userPermissions/interface.ts +0 -28
- package/src/modules/user/userPermissions/route.schema.ts +0 -12
- package/src/modules/user/userPositions/interface.ts +0 -47
- package/src/modules/user/userPositions/route.schema.ts +0 -29
- package/src/modules/user/userTokens/interface.ts +0 -41
- package/src/modules/user/userTokens/route.schema.ts +0 -17
- package/src/modules/user/users/interface.ts +0 -177
- package/src/modules/user/users/route.schema.ts +0 -58
- package/src/modules/user/vehicles/interfaces.ts +0 -31
- package/src/modules/user/vehicles/route.schema.ts +0 -17
- package/src/modules/user/zipCode/interfaces.ts +0 -27
- package/src/modules/user/zipCode/route.schema.ts +0 -26
- package/src/modules/view/adminPanel/interfaces.ts +0 -180
- package/src/modules/view/errorLog/interfaces.ts +0 -36
- package/src/modules/view/errorLog/route.schema.ts +0 -25
- package/src/shared/entities/documentManagement.ts +0 -16
- package/src/shared/entities/integration.ts +0 -136
- package/src/shared/entities/print.ts +0 -49
- package/src/shared/entities/stock.ts +0 -1248
- package/src/shared/entities/tickets.ts +0 -82
- package/src/shared/entities/user.ts +0 -540
- package/src/shared/errors/documentManagementErrors.ts +0 -13
- package/src/shared/errors/integrationErrors.ts +0 -44
- package/src/shared/errors/stockErrors.ts +0 -267
- package/src/shared/errors/userErrors.ts +0 -108
- package/src/shared/errors/viewErrors.ts +0 -6
- package/src/shared/interface.ts +0 -548
- package/src/shared/messages.ts +0 -141
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -10
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ChatSubscriber } from './../../../shared/entities/user';
|
|
2
|
-
import * as IShared from '../../../shared/interface';
|
|
3
|
-
|
|
4
|
-
export type Entity = ChatSubscriber;
|
|
5
|
-
export const Route = 'chat_subscriber';
|
|
6
|
-
export const UpperName = 'ChatSubscriber';
|
|
7
|
-
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
8
|
-
|
|
9
|
-
export interface ICreateOrUpdateRequest {
|
|
10
|
-
owner_id: string;
|
|
11
|
-
document_header_id: string;
|
|
12
|
-
personas_ids: string[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type IFindByIdResponse = {
|
|
16
|
-
persona_id: string;
|
|
17
|
-
name: string;
|
|
18
|
-
email: string;
|
|
19
|
-
phone_number: string | null;
|
|
20
|
-
}[];
|
|
21
|
-
|
|
22
|
-
export interface IRepository {
|
|
23
|
-
createOrUpdate(data: ICreateOrUpdateRequest): Promise<Entity[]>;
|
|
24
|
-
|
|
25
|
-
findByOwnerId(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse>;
|
|
26
|
-
|
|
27
|
-
findByDocumentHeaderId(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse>;
|
|
28
|
-
|
|
29
|
-
findByPersonaId(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse>;
|
|
30
|
-
|
|
31
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import { ICreateOrUpdateRequest } from './interfaces';
|
|
5
|
-
|
|
6
|
-
// create body validation
|
|
7
|
-
const createOrUpdateBodyKeys: IShared.IRouteRequest<ICreateOrUpdateRequest> = {
|
|
8
|
-
owner_id: joi.string().uuid().required(),
|
|
9
|
-
document_header_id: joi.string().uuid().required(),
|
|
10
|
-
personas_ids: joi.array().items(joi.string().optional()).required(),
|
|
11
|
-
};
|
|
12
|
-
export const createOrUpdateBody = joi.object().keys(createOrUpdateBodyKeys).messages(messages);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import { ClientType } from '../../../shared/entities/user';
|
|
3
|
-
|
|
4
|
-
export type Entity = ClientType;
|
|
5
|
-
export const Route = 'client_type';
|
|
6
|
-
export const UpperName = 'ClientType';
|
|
7
|
-
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
8
|
-
|
|
9
|
-
type IFindDetailedResponse = Entity;
|
|
10
|
-
|
|
11
|
-
// omit any unnecessary fields
|
|
12
|
-
export type IFindByIdResponse = Omit<IFindDetailedResponse, ''>;
|
|
13
|
-
|
|
14
|
-
export type IFindRequest = Record<string, unknown>;
|
|
15
|
-
|
|
16
|
-
// omit any unnecessary fields
|
|
17
|
-
export type IFindResponse = Omit<IFindDetailedResponse, ''>;
|
|
18
|
-
|
|
19
|
-
export interface IFindPaginatedRequest extends IFindRequest, IShared.IPaginationRequest {}
|
|
20
|
-
|
|
21
|
-
export type IFindWithPaginationResponse = IShared.IPaginationResponse<
|
|
22
|
-
Omit<IFindDetailedResponse, ''>
|
|
23
|
-
>;
|
|
24
|
-
|
|
25
|
-
export interface ICreateRequest {
|
|
26
|
-
// create fields
|
|
27
|
-
name: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface IUpdateRequest {
|
|
31
|
-
// updatable fields
|
|
32
|
-
name?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface IRepository {
|
|
36
|
-
findById(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse | null>;
|
|
37
|
-
|
|
38
|
-
findMinified(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
39
|
-
find(selector: IFindRequest): Promise<IFindResponse[]>;
|
|
40
|
-
findPaginated(selector: IFindPaginatedRequest): Promise<IFindWithPaginationResponse>;
|
|
41
|
-
|
|
42
|
-
create(data: ICreateRequest): Promise<Entity>;
|
|
43
|
-
update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<Entity | null>;
|
|
44
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<Entity | null>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import { IFindRequest, IFindPaginatedRequest, ICreateRequest, IUpdateRequest } from './interface';
|
|
5
|
-
|
|
6
|
-
// create body validation
|
|
7
|
-
const createBodyKeys: IShared.IRouteRequest<ICreateRequest> = {
|
|
8
|
-
name: joi.string().required(),
|
|
9
|
-
};
|
|
10
|
-
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
11
|
-
|
|
12
|
-
// update body validation
|
|
13
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
14
|
-
name: joi.string().required(),
|
|
15
|
-
};
|
|
16
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
17
|
-
const findQueryKeys: IShared.IRouteRequest<IFindRequest> = {};
|
|
18
|
-
export const findQuery = joi.object().keys(findQueryKeys).messages(messages);
|
|
19
|
-
|
|
20
|
-
// find with pagination query validation
|
|
21
|
-
const findWithPaginationQueryKeys: IShared.IRouteRequest<IFindPaginatedRequest> = {
|
|
22
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
23
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
24
|
-
};
|
|
25
|
-
export const findWithPaginationQuery = joi
|
|
26
|
-
.object()
|
|
27
|
-
.keys(findWithPaginationQueryKeys)
|
|
28
|
-
.messages(messages);
|
|
29
|
-
export const clientTypePostSchema = joi.object().keys({
|
|
30
|
-
name: joi.string().required(),
|
|
31
|
-
});
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import {
|
|
3
|
-
Clients,
|
|
4
|
-
Users,
|
|
5
|
-
Country,
|
|
6
|
-
ReasonForExemption,
|
|
7
|
-
ClientType,
|
|
8
|
-
SegmentsArea,
|
|
9
|
-
Language,
|
|
10
|
-
Vehicles,
|
|
11
|
-
DeliveryMethods,
|
|
12
|
-
MaturityDates,
|
|
13
|
-
PaymentMethods,
|
|
14
|
-
Persona,
|
|
15
|
-
} from '../../../shared/entities/user';
|
|
16
|
-
import type { IChatType } from '../../stock/chat/interfaces';
|
|
17
|
-
|
|
18
|
-
export type Entity = Clients;
|
|
19
|
-
export const Route = 'client';
|
|
20
|
-
export const UpperName = 'Clients';
|
|
21
|
-
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
22
|
-
|
|
23
|
-
interface IMainPersona extends Persona {
|
|
24
|
-
country: Country | null;
|
|
25
|
-
reason_for_exemption: ReasonForExemption | null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
interface IFindDetailedResponse extends Entity {
|
|
29
|
-
user: Users;
|
|
30
|
-
main_persona: IMainPersona;
|
|
31
|
-
client_type: ClientType | null;
|
|
32
|
-
segments_area: SegmentsArea | null;
|
|
33
|
-
country: Country | null;
|
|
34
|
-
language: Language | null;
|
|
35
|
-
default_payment_method: PaymentMethods | null;
|
|
36
|
-
default_maturity_date: MaturityDates | null;
|
|
37
|
-
default_delivery_method: DeliveryMethods | null;
|
|
38
|
-
default_vehicle: Vehicles | null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// omit any unnecessary fields
|
|
42
|
-
export type IFindByIdResponse = Omit<IFindDetailedResponse, ''>;
|
|
43
|
-
|
|
44
|
-
// omit any unnecessary fields
|
|
45
|
-
export type IFindByOwnerIdResponse = Omit<
|
|
46
|
-
IFindDetailedResponse,
|
|
47
|
-
| 'user'
|
|
48
|
-
| 'main_persona'
|
|
49
|
-
| 'client_type'
|
|
50
|
-
| 'segments_area'
|
|
51
|
-
| 'country'
|
|
52
|
-
| 'language'
|
|
53
|
-
| 'default_payment_method'
|
|
54
|
-
| 'default_maturity_date'
|
|
55
|
-
| 'default_delivery_method'
|
|
56
|
-
| 'default_vehicle'
|
|
57
|
-
>;
|
|
58
|
-
|
|
59
|
-
export interface IFindByQueryRequest {
|
|
60
|
-
number?: number[];
|
|
61
|
-
id?: string[];
|
|
62
|
-
nif?: string | null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export interface IFindRequest {}
|
|
66
|
-
|
|
67
|
-
// omit any unnecessary fields
|
|
68
|
-
export type IFindResponse = Omit<IFindDetailedResponse, ''>;
|
|
69
|
-
|
|
70
|
-
export interface IFindPaginatedRequest extends IFindRequest, IShared.IPaginationRequest {}
|
|
71
|
-
|
|
72
|
-
export type IFindWithPaginationResponse = IShared.IPaginationResponse<
|
|
73
|
-
Omit<IFindDetailedResponse, ''>
|
|
74
|
-
>;
|
|
75
|
-
|
|
76
|
-
export type ICreateMainPersona = Pick<Persona, 'nif' | 'name' | 'email' | 'telephone'>;
|
|
77
|
-
|
|
78
|
-
export interface ICreateRequest {
|
|
79
|
-
user_id?: string;
|
|
80
|
-
main_persona: ICreateMainPersona;
|
|
81
|
-
deferred_payment?: boolean;
|
|
82
|
-
default_discount?: number;
|
|
83
|
-
exemption_reason_id?: string | null;
|
|
84
|
-
newsletter?: boolean;
|
|
85
|
-
inactive?: boolean;
|
|
86
|
-
country_id?: string | null;
|
|
87
|
-
language_id?: string | null;
|
|
88
|
-
client_type_id?: string | null;
|
|
89
|
-
segments_area_id?: string | null;
|
|
90
|
-
default_payment_method_id?: string | null;
|
|
91
|
-
default_maturity_date_id?: string | null;
|
|
92
|
-
default_delivery_method_id?: string | null;
|
|
93
|
-
default_vehicle_id?: string | null;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface IUpdateRequest {
|
|
97
|
-
// updatable fields
|
|
98
|
-
chat_type?: IChatType;
|
|
99
|
-
nif?: string | null;
|
|
100
|
-
country_id?: string | null;
|
|
101
|
-
language_id?: string | null;
|
|
102
|
-
client_type_id?: string | null;
|
|
103
|
-
newsletter?: boolean;
|
|
104
|
-
inactive?: boolean;
|
|
105
|
-
segments_area_id?: string | null;
|
|
106
|
-
main_persona_id?: string;
|
|
107
|
-
contact_persona_id?: string;
|
|
108
|
-
default_discount?: number;
|
|
109
|
-
default_payment_method_id?: string | null;
|
|
110
|
-
default_maturity_date_id?: string | null;
|
|
111
|
-
default_delivery_method_id?: string | null;
|
|
112
|
-
default_vehicle_id?: string | null;
|
|
113
|
-
deferred_payment?: boolean;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export interface IRepository {
|
|
117
|
-
findById(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse | null>;
|
|
118
|
-
|
|
119
|
-
findByOwnerId(params: IShared.IFindByOwnerIdRequest): Promise<IFindByOwnerIdResponse[]>;
|
|
120
|
-
|
|
121
|
-
findMinified(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
122
|
-
|
|
123
|
-
findByQuery(params: IFindByQueryRequest): Promise<IFindResponse[]>;
|
|
124
|
-
|
|
125
|
-
find(selector: IFindRequest): Promise<IFindResponse[]>;
|
|
126
|
-
|
|
127
|
-
findPaginated(selector: IFindPaginatedRequest): Promise<IFindWithPaginationResponse>;
|
|
128
|
-
|
|
129
|
-
create(data: ICreateRequest): Promise<IFindResponse>;
|
|
130
|
-
|
|
131
|
-
createOrUpdate(data: ICreateRequest): Promise<IFindResponse>;
|
|
132
|
-
|
|
133
|
-
update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<IFindResponse | null>;
|
|
134
|
-
|
|
135
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<IFindResponse | null>;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import {
|
|
5
|
-
IFindPaginatedRequest,
|
|
6
|
-
ICreateRequest,
|
|
7
|
-
IUpdateRequest,
|
|
8
|
-
IFindByQueryRequest,
|
|
9
|
-
ICreateMainPersona,
|
|
10
|
-
} from './interface';
|
|
11
|
-
import { chatTypes } from '../../stock/chat/interfaces';
|
|
12
|
-
|
|
13
|
-
const createMainPersonaKeys: IShared.IRouteRequest<ICreateMainPersona> = {
|
|
14
|
-
name: joi.string().allow(null, '').empty('').optional(),
|
|
15
|
-
nif: joi.string().allow(null, '').empty('').optional(),
|
|
16
|
-
email: joi
|
|
17
|
-
.string()
|
|
18
|
-
.email({ tlds: { allow: false } })
|
|
19
|
-
.allow(null, '')
|
|
20
|
-
.empty('')
|
|
21
|
-
.optional(),
|
|
22
|
-
telephone: joi.string().allow(null, '').empty('').optional(),
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// create body validation
|
|
26
|
-
const createBodyKeys: IShared.IRouteRequest<ICreateRequest> = {
|
|
27
|
-
user_id: joi.string().uuid().optional(),
|
|
28
|
-
|
|
29
|
-
main_persona: joi.object().keys(createMainPersonaKeys).optional(),
|
|
30
|
-
|
|
31
|
-
deferred_payment: joi.boolean().default(false).optional(),
|
|
32
|
-
default_discount: joi.number().positive().allow(0).default(0).max(100).optional(),
|
|
33
|
-
exemption_reason_id: joi.string().uuid().allow(null).optional(),
|
|
34
|
-
|
|
35
|
-
inactive: joi.boolean().default(false).optional(),
|
|
36
|
-
newsletter: joi.boolean().default(false).optional(),
|
|
37
|
-
|
|
38
|
-
country_id: joi.string().uuid().allow(null).optional(),
|
|
39
|
-
language_id: joi.string().uuid().allow(null).optional(),
|
|
40
|
-
client_type_id: joi.string().uuid().allow(null).optional(),
|
|
41
|
-
segments_area_id: joi.string().uuid().allow(null).optional(),
|
|
42
|
-
default_payment_method_id: joi.string().uuid().allow(null).optional(),
|
|
43
|
-
default_maturity_date_id: joi.string().uuid().allow(null).optional(),
|
|
44
|
-
default_delivery_method_id: joi.string().uuid().allow(null).optional(),
|
|
45
|
-
default_vehicle_id: joi.string().uuid().allow(null).optional(),
|
|
46
|
-
};
|
|
47
|
-
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
48
|
-
|
|
49
|
-
// update body validation
|
|
50
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
51
|
-
chat_type: joi
|
|
52
|
-
.string()
|
|
53
|
-
.valid(...chatTypes)
|
|
54
|
-
.optional(),
|
|
55
|
-
main_persona_id: joi.string().uuid().optional(),
|
|
56
|
-
contact_persona_id: joi.string().uuid().optional(),
|
|
57
|
-
nif: joi.string().allow(null).optional(),
|
|
58
|
-
country_id: joi.string().uuid().allow(null).optional(),
|
|
59
|
-
language_id: joi.string().uuid().allow(null).optional(),
|
|
60
|
-
client_type_id: joi.string().uuid().allow(null).optional(),
|
|
61
|
-
newsletter: joi.boolean().optional(),
|
|
62
|
-
inactive: joi.boolean().optional(),
|
|
63
|
-
segments_area_id: joi.string().uuid().allow(null).optional(),
|
|
64
|
-
default_discount: joi.number().positive().allow(0).max(100).optional(),
|
|
65
|
-
default_payment_method_id: joi.string().uuid().allow(null).optional(),
|
|
66
|
-
default_maturity_date_id: joi.string().uuid().allow(null).optional(),
|
|
67
|
-
default_delivery_method_id: joi.string().uuid().allow(null).optional(),
|
|
68
|
-
default_vehicle_id: joi.string().uuid().allow(null).optional(),
|
|
69
|
-
deferred_payment: joi.boolean().optional(),
|
|
70
|
-
};
|
|
71
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
72
|
-
const findQueryKeys: IShared.IRouteRequest<IFindByQueryRequest> = {
|
|
73
|
-
number: joi.array().items(joi.number().positive().required()).optional(),
|
|
74
|
-
id: joi.array().items(joi.string().uuid().required()).optional(),
|
|
75
|
-
nif: joi.string().optional(),
|
|
76
|
-
};
|
|
77
|
-
export const findQuery = joi.object().keys(findQueryKeys).messages(messages);
|
|
78
|
-
|
|
79
|
-
// find with pagination query validation
|
|
80
|
-
const findWithPaginationQueryKeys: IShared.IRouteRequest<IFindPaginatedRequest> = {
|
|
81
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
82
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
83
|
-
};
|
|
84
|
-
export const findWithPaginationQuery = joi
|
|
85
|
-
.object()
|
|
86
|
-
.keys(findWithPaginationQueryKeys)
|
|
87
|
-
.messages(messages);
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import {
|
|
3
|
-
type Commissioner,
|
|
4
|
-
type Users,
|
|
5
|
-
type Country,
|
|
6
|
-
type Language,
|
|
7
|
-
type PaymentMethods,
|
|
8
|
-
type DeliveryMethods,
|
|
9
|
-
type MaturityDates,
|
|
10
|
-
type Vehicles,
|
|
11
|
-
type Persona,
|
|
12
|
-
type ReasonForExemption,
|
|
13
|
-
} from '../../../shared/entities/user';
|
|
14
|
-
import type { IChatType } from '../../stock/chat/interfaces';
|
|
15
|
-
|
|
16
|
-
export type Entity = Commissioner;
|
|
17
|
-
export const Route = 'commissioner';
|
|
18
|
-
export const UpperName = 'Commissioner';
|
|
19
|
-
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
20
|
-
|
|
21
|
-
interface IMainPersona extends Persona {
|
|
22
|
-
country: Country | null;
|
|
23
|
-
reason_for_exemption: ReasonForExemption | null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
interface IFindDetailedResponse extends Entity {
|
|
27
|
-
user: Users;
|
|
28
|
-
main_persona: IMainPersona;
|
|
29
|
-
country: Country | null;
|
|
30
|
-
language: Language | null;
|
|
31
|
-
default_payment_method: PaymentMethods | null;
|
|
32
|
-
default_maturity_date: MaturityDates | null;
|
|
33
|
-
default_delivery_method: DeliveryMethods | null;
|
|
34
|
-
default_vehicle: Vehicles | null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// omit any unnecessary fields
|
|
38
|
-
export type IFindByIdResponse = Omit<IFindDetailedResponse, ''>;
|
|
39
|
-
|
|
40
|
-
// omit any unnecessary fields
|
|
41
|
-
export type IFindByOwnerIdResponse = Omit<
|
|
42
|
-
IFindDetailedResponse,
|
|
43
|
-
| 'user'
|
|
44
|
-
| 'main_persona'
|
|
45
|
-
| 'country'
|
|
46
|
-
| 'language'
|
|
47
|
-
| 'default_payment_method'
|
|
48
|
-
| 'default_maturity_date'
|
|
49
|
-
| 'default_delivery_method'
|
|
50
|
-
| 'default_vehicle'
|
|
51
|
-
>;
|
|
52
|
-
|
|
53
|
-
export type IFindRequest = Record<string, unknown>;
|
|
54
|
-
|
|
55
|
-
// omit any unnecessary fields
|
|
56
|
-
export type IFindResponse = Omit<IFindDetailedResponse, ''>;
|
|
57
|
-
|
|
58
|
-
export interface IFindPaginatedRequest extends IFindRequest, IShared.IPaginationRequest {}
|
|
59
|
-
|
|
60
|
-
export type IFindWithPaginationResponse = IShared.IPaginationResponse<
|
|
61
|
-
Omit<IFindDetailedResponse, ''>
|
|
62
|
-
>;
|
|
63
|
-
|
|
64
|
-
export type ICreateMainPersona = Pick<Persona, 'nif' | 'name' | 'email' | 'telephone'>;
|
|
65
|
-
|
|
66
|
-
export interface ICreateRequest {
|
|
67
|
-
// create fields
|
|
68
|
-
user_id: string;
|
|
69
|
-
|
|
70
|
-
default_percentage?: number;
|
|
71
|
-
// exemption_reason_id?: string | null; // todo
|
|
72
|
-
|
|
73
|
-
main_persona: ICreateMainPersona;
|
|
74
|
-
country_id?: string | null;
|
|
75
|
-
language_id?: string | null;
|
|
76
|
-
default_payment_method_id?: string | null;
|
|
77
|
-
default_maturity_date_id?: string | null;
|
|
78
|
-
default_delivery_method_id?: string | null;
|
|
79
|
-
default_vehicle_id?: string | null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export interface IUpdateRequest {
|
|
83
|
-
// updatable fields
|
|
84
|
-
chat_type?: IChatType;
|
|
85
|
-
default_percentage?: number;
|
|
86
|
-
// exemption_reason_id?: string | null; // todo
|
|
87
|
-
main_persona_id?: string;
|
|
88
|
-
contact_persona_id?: string;
|
|
89
|
-
country_id?: string | null;
|
|
90
|
-
language_id?: string | null;
|
|
91
|
-
default_payment_method_id?: string | null;
|
|
92
|
-
default_maturity_date_id?: string | null;
|
|
93
|
-
default_delivery_method_id?: string | null;
|
|
94
|
-
default_vehicle_id?: string | null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export interface IRepository {
|
|
98
|
-
findById(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse | null>;
|
|
99
|
-
|
|
100
|
-
findByOwnerId(params: IShared.IFindByOwnerIdRequest): Promise<IFindByOwnerIdResponse[]>;
|
|
101
|
-
findMinified(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
102
|
-
find(selector: IFindRequest): Promise<IFindResponse[]>;
|
|
103
|
-
findPaginated(selector: IFindPaginatedRequest): Promise<IFindWithPaginationResponse>;
|
|
104
|
-
|
|
105
|
-
create(data: ICreateRequest): Promise<IFindResponse>;
|
|
106
|
-
update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<IFindResponse | null>;
|
|
107
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<IFindResponse | null>;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import {
|
|
5
|
-
IFindRequest,
|
|
6
|
-
IFindPaginatedRequest,
|
|
7
|
-
ICreateRequest,
|
|
8
|
-
IUpdateRequest,
|
|
9
|
-
ICreateMainPersona,
|
|
10
|
-
} from './interface';
|
|
11
|
-
import { chatTypes } from '../../stock/chat/interfaces';
|
|
12
|
-
|
|
13
|
-
const createMainPersonaKeys: IShared.IRouteRequest<ICreateMainPersona> = {
|
|
14
|
-
name: joi.string().optional(),
|
|
15
|
-
nif: joi.string().allow(null).optional(),
|
|
16
|
-
email: joi
|
|
17
|
-
.string()
|
|
18
|
-
.email({ tlds: { allow: false } })
|
|
19
|
-
.optional(),
|
|
20
|
-
telephone: joi.string().optional(),
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// create body validation
|
|
24
|
-
const createBodyKeys: IShared.IRouteRequest<ICreateRequest> = {
|
|
25
|
-
user_id: joi.string().uuid().required(),
|
|
26
|
-
default_percentage: joi.number().positive().allow(0).default(0).optional(),
|
|
27
|
-
main_persona: joi.object().keys(createMainPersonaKeys).required(),
|
|
28
|
-
country_id: joi.string().uuid().allow(null).optional(),
|
|
29
|
-
language_id: joi.string().uuid().allow(null).optional(),
|
|
30
|
-
default_payment_method_id: joi.string().uuid().allow(null).optional(),
|
|
31
|
-
default_maturity_date_id: joi.string().uuid().allow(null).optional(),
|
|
32
|
-
default_delivery_method_id: joi.string().uuid().allow(null).optional(),
|
|
33
|
-
default_vehicle_id: joi.string().uuid().allow(null).optional(),
|
|
34
|
-
};
|
|
35
|
-
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
36
|
-
|
|
37
|
-
// update body validation
|
|
38
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
39
|
-
chat_type: joi
|
|
40
|
-
.string()
|
|
41
|
-
.valid(...chatTypes)
|
|
42
|
-
.optional(),
|
|
43
|
-
default_percentage: joi.number().positive().allow(0).optional(),
|
|
44
|
-
main_persona_id: joi.string().uuid().optional(),
|
|
45
|
-
contact_persona_id: joi.string().uuid().optional(),
|
|
46
|
-
country_id: joi.string().uuid().allow(null).optional(),
|
|
47
|
-
language_id: joi.string().uuid().allow(null).optional(),
|
|
48
|
-
default_payment_method_id: joi.string().uuid().allow(null).optional(),
|
|
49
|
-
default_maturity_date_id: joi.string().uuid().allow(null).optional(),
|
|
50
|
-
default_delivery_method_id: joi.string().uuid().allow(null).optional(),
|
|
51
|
-
default_vehicle_id: joi.string().uuid().allow(null).optional(),
|
|
52
|
-
};
|
|
53
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
54
|
-
const findQueryKeys: IShared.IRouteRequest<IFindRequest> = {};
|
|
55
|
-
export const findQuery = joi.object().keys(findQueryKeys).messages(messages);
|
|
56
|
-
|
|
57
|
-
// find with pagination query validation
|
|
58
|
-
const findWithPaginationQueryKeys: IShared.IRouteRequest<IFindPaginatedRequest> = {
|
|
59
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
60
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
61
|
-
};
|
|
62
|
-
export const findWithPaginationQuery = joi
|
|
63
|
-
.object()
|
|
64
|
-
.keys(findWithPaginationQueryKeys)
|
|
65
|
-
.messages(messages);
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import { Country } from '../../../shared/entities/user';
|
|
3
|
-
|
|
4
|
-
export type Entity = Country;
|
|
5
|
-
export const Route = 'country';
|
|
6
|
-
export const UpperName = 'Country';
|
|
7
|
-
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
8
|
-
|
|
9
|
-
type IFindDetailedResponse = Entity;
|
|
10
|
-
|
|
11
|
-
// omit any unnecessary fields
|
|
12
|
-
export type IFindByIdResponse = Omit<IFindDetailedResponse, ''>;
|
|
13
|
-
|
|
14
|
-
export type IFindRequest = {
|
|
15
|
-
name?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// omit any unnecessary fields
|
|
19
|
-
export type IFindResponse = Omit<IFindDetailedResponse, ''>;
|
|
20
|
-
|
|
21
|
-
export interface IFindPaginatedRequest extends IFindRequest, IShared.IPaginationRequest {}
|
|
22
|
-
|
|
23
|
-
export type IFindWithPaginationResponse = IShared.IPaginationResponse<
|
|
24
|
-
Omit<IFindDetailedResponse, ''>
|
|
25
|
-
>;
|
|
26
|
-
|
|
27
|
-
export interface ICreateRequest {
|
|
28
|
-
// create fields
|
|
29
|
-
name: string;
|
|
30
|
-
alpha2: string;
|
|
31
|
-
external_id: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface IUpdateRequest {
|
|
35
|
-
// updatable fields
|
|
36
|
-
name?: string;
|
|
37
|
-
alpha2?: string;
|
|
38
|
-
external_id?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface IRepository {
|
|
42
|
-
findById(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse | null>;
|
|
43
|
-
|
|
44
|
-
findMinified(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
45
|
-
findByAlpha2(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
46
|
-
find(selector: IFindRequest): Promise<IFindResponse[]>;
|
|
47
|
-
findPaginated(selector: IFindPaginatedRequest): Promise<IFindWithPaginationResponse>;
|
|
48
|
-
|
|
49
|
-
create(data: ICreateRequest): Promise<Entity>;
|
|
50
|
-
update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<Entity | null>;
|
|
51
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<Entity | null>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import { IFindRequest, IFindPaginatedRequest, ICreateRequest, IUpdateRequest } from './interface';
|
|
5
|
-
|
|
6
|
-
// create body validation
|
|
7
|
-
const createBodyKeys: IShared.IRouteRequest<ICreateRequest> = {
|
|
8
|
-
name: joi.string().required(),
|
|
9
|
-
alpha2: joi.string().required(),
|
|
10
|
-
external_id: joi.string().required(),
|
|
11
|
-
};
|
|
12
|
-
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
13
|
-
|
|
14
|
-
// update body validation
|
|
15
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
16
|
-
name: joi.string().optional(),
|
|
17
|
-
alpha2: joi.string().optional(),
|
|
18
|
-
external_id: joi.string().optional(),
|
|
19
|
-
};
|
|
20
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
21
|
-
const findQueryKeys: IShared.IRouteRequest<IFindRequest> = {
|
|
22
|
-
name: joi.string().optional(),
|
|
23
|
-
};
|
|
24
|
-
export const findQuery = joi.object().keys(findQueryKeys).messages(messages);
|
|
25
|
-
|
|
26
|
-
// find with pagination query validation
|
|
27
|
-
const findWithPaginationQueryKeys: IShared.IRouteRequest<IFindPaginatedRequest> = {
|
|
28
|
-
...findQueryKeys,
|
|
29
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
30
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const findWithPaginationQuery = joi
|
|
34
|
-
.object()
|
|
35
|
-
.keys(findWithPaginationQueryKeys)
|
|
36
|
-
.messages(messages);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import { DeliveryMethods } from '../../../shared/entities/user';
|
|
3
|
-
|
|
4
|
-
export type Entity = DeliveryMethods;
|
|
5
|
-
export const Route = 'delivery_methods';
|
|
6
|
-
export const UpperName = 'DeliveryMethods';
|
|
7
|
-
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
8
|
-
|
|
9
|
-
export interface ICreateRequest {
|
|
10
|
-
delivery_method_id: number;
|
|
11
|
-
name: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface IUpdateRequest {
|
|
15
|
-
delivery_method_id?: number;
|
|
16
|
-
name?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface IRepository {
|
|
20
|
-
create(data: ICreateRequest): Promise<Entity>;
|
|
21
|
-
find(): Promise<Entity[]>;
|
|
22
|
-
findMinified(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
23
|
-
findById(selector: IShared.IFindByIdRequest): Promise<Entity | null>;
|
|
24
|
-
update(selector: IShared.IFindByIdRequest, body: IUpdateRequest): Promise<Entity | null>;
|
|
25
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<Entity | null>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import { ICreateRequest, IUpdateRequest } from './interfaces';
|
|
5
|
-
|
|
6
|
-
const createBodyKeys: IShared.IRouteRequest<ICreateRequest> = {
|
|
7
|
-
name: joi.string().required(),
|
|
8
|
-
delivery_method_id: joi.number().integer().required(),
|
|
9
|
-
};
|
|
10
|
-
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
11
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
12
|
-
name: joi.string(),
|
|
13
|
-
delivery_method_id: joi.number().integer(),
|
|
14
|
-
};
|
|
15
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|