@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,339 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ProductImage,
|
|
3
|
-
type ProductVirtuals,
|
|
4
|
-
type UnitOfMeasure,
|
|
5
|
-
type VatTax,
|
|
6
|
-
type VatTaxZone,
|
|
7
|
-
type ProductPromotionVirtuals,
|
|
8
|
-
type ProductBaseVirtuals,
|
|
9
|
-
type ProductSheet,
|
|
10
|
-
} from '../../../shared/entities/stock';
|
|
11
|
-
import * as IShared from '../../../shared/interface';
|
|
12
|
-
import * as IDocumentLine from '../../supply/documentLine/interfaces';
|
|
13
|
-
|
|
14
|
-
export const Route = 'product_sheets';
|
|
15
|
-
|
|
16
|
-
export const UpperName = 'ProductsSheets';
|
|
17
|
-
|
|
18
|
-
export const LowerName = UpperName[0].toLowerCase() + UpperName.substring(1);
|
|
19
|
-
|
|
20
|
-
export type IProductPromotionVirtuals = ProductPromotionVirtuals;
|
|
21
|
-
|
|
22
|
-
export type IProductVirtuals = ProductVirtuals;
|
|
23
|
-
|
|
24
|
-
export type IProductBaseVirtuals = ProductBaseVirtuals;
|
|
25
|
-
|
|
26
|
-
export type Entity = ProductSheet;
|
|
27
|
-
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
export type IProductsForSheetsResponse = Record<string, any>;
|
|
30
|
-
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
-
export type IProductFromSheetsValues = Record<string, any>;
|
|
33
|
-
|
|
34
|
-
export type IProductSheetState = 'Ativa' | 'NaoVemMais' | 'VemTemporariamente';
|
|
35
|
-
|
|
36
|
-
export const ProductStateEnum: {
|
|
37
|
-
Ativa: 'Ativa';
|
|
38
|
-
NaoVemMais: 'NaoVemMais';
|
|
39
|
-
VemTemporariamente: 'VemTemporariamente';
|
|
40
|
-
} = {
|
|
41
|
-
Ativa: 'Ativa',
|
|
42
|
-
NaoVemMais: 'NaoVemMais',
|
|
43
|
-
VemTemporariamente: 'VemTemporariamente',
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const ProductStateLabels: Record<keyof typeof ProductStateEnum, string> = {
|
|
47
|
-
Ativa: 'Ativa',
|
|
48
|
-
NaoVemMais: 'Nao Vem Mais',
|
|
49
|
-
VemTemporariamente: 'Vem Temporariamente',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export type IProductState = (typeof ProductStateEnum)[keyof typeof ProductStateEnum];
|
|
53
|
-
|
|
54
|
-
export const productState = Object.keys(ProductStateEnum);
|
|
55
|
-
|
|
56
|
-
export const ProductTypeEnum: {
|
|
57
|
-
Encomenda: 'Encomenda';
|
|
58
|
-
Stock: 'Stock';
|
|
59
|
-
Servico: 'Servico';
|
|
60
|
-
Producao: 'Producao';
|
|
61
|
-
Portes: 'Portes';
|
|
62
|
-
RM: 'RM';
|
|
63
|
-
Montagem: 'Montagem';
|
|
64
|
-
} = {
|
|
65
|
-
Encomenda: 'Encomenda',
|
|
66
|
-
Stock: 'Stock',
|
|
67
|
-
Servico: 'Servico',
|
|
68
|
-
Producao: 'Producao',
|
|
69
|
-
Portes: 'Portes',
|
|
70
|
-
RM: 'RM',
|
|
71
|
-
Montagem: 'Montagem',
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
export type IProductType = (typeof ProductTypeEnum)[keyof typeof ProductTypeEnum];
|
|
75
|
-
|
|
76
|
-
export const productTypes = Object.keys(ProductTypeEnum);
|
|
77
|
-
|
|
78
|
-
export interface ICreateRequest {
|
|
79
|
-
// create fields
|
|
80
|
-
id?: string;
|
|
81
|
-
reference?: string;
|
|
82
|
-
origin_id?: string | null;
|
|
83
|
-
id_provider?: number;
|
|
84
|
-
provider_ref?: string | null;
|
|
85
|
-
name?: string | null;
|
|
86
|
-
designation: string | null;
|
|
87
|
-
state?: IProductSheetState; // defaults to Ativa
|
|
88
|
-
type?: IProductType; // defaults to stock
|
|
89
|
-
type_of_inventory?: string; // defaults to 'M'
|
|
90
|
-
external_id?: string;
|
|
91
|
-
vat_tax_id?: string; // defaults to 'Normal'
|
|
92
|
-
weight?: number | null;
|
|
93
|
-
width?: number | null;
|
|
94
|
-
height?: number | null;
|
|
95
|
-
length?: number | null;
|
|
96
|
-
diameter?: number | null;
|
|
97
|
-
price_cost?: number; // can be undefined if price_sale & margin are numbers
|
|
98
|
-
price_sale?: number; // can be undefined if price_cost & margin are numbers
|
|
99
|
-
max_discount?: number; // replaces no_discount
|
|
100
|
-
unit_of_measure_quantity_id?: string; // defaults to configured quantity unit of measure
|
|
101
|
-
cabide_product_color?: string | null;
|
|
102
|
-
imported_from_sheets?: boolean;
|
|
103
|
-
values?: IProductsForSheetsResponse;
|
|
104
|
-
maintenances?: string;
|
|
105
|
-
compositions?: string;
|
|
106
|
-
attributes?: string;
|
|
107
|
-
created_by?: string;
|
|
108
|
-
updated_by?: string;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface IUpdateRequest {
|
|
112
|
-
designation?: string;
|
|
113
|
-
provider_ref?: string;
|
|
114
|
-
type?: IProductType;
|
|
115
|
-
unit_of_measure_quantity_notation?: string;
|
|
116
|
-
state?: IProductSheetState;
|
|
117
|
-
price_cost?: number;
|
|
118
|
-
price_sale?: number;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export interface IFindProductSheetByReference {
|
|
122
|
-
selector: string;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
interface IProductSheetEntityBase extends Omit<Entity, 'values'> {
|
|
126
|
-
unit_of_measure_quantity: UnitOfMeasure;
|
|
127
|
-
vat_tax: VatTax & {
|
|
128
|
-
vat_tax_zones: VatTaxZone[];
|
|
129
|
-
};
|
|
130
|
-
promotions: ProductPromotionVirtuals[];
|
|
131
|
-
product_images: ProductImage[];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export interface IProductSheetEntity extends IProductSheetEntityBase {
|
|
135
|
-
base_virtual: ProductBaseVirtuals | null;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export interface IProductCabideColors {
|
|
139
|
-
id: string;
|
|
140
|
-
reference: string;
|
|
141
|
-
cabide_product_color: string;
|
|
142
|
-
thumbnail: string | null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export interface IProductSheetCabideEntity {
|
|
146
|
-
reference: string;
|
|
147
|
-
designation: string;
|
|
148
|
-
provider: number;
|
|
149
|
-
hanger: string;
|
|
150
|
-
pattern: string;
|
|
151
|
-
type: string;
|
|
152
|
-
price_cost: number;
|
|
153
|
-
shipping: number;
|
|
154
|
-
margin: number;
|
|
155
|
-
tax_value: number;
|
|
156
|
-
price_sale_less_3m: number;
|
|
157
|
-
price_sale_greater_3m: number;
|
|
158
|
-
price_sale_piece: number;
|
|
159
|
-
width: number;
|
|
160
|
-
unit_of_measure_quantity_id: string;
|
|
161
|
-
unit_of_measure_quantity_notation: string;
|
|
162
|
-
composition: string;
|
|
163
|
-
maintenance: string;
|
|
164
|
-
attributes: string;
|
|
165
|
-
estimated_delivery: string;
|
|
166
|
-
existing_colors: IProductCabideColors[];
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export interface IBasicSearchRequest extends IShared.IPaginationRequest {
|
|
170
|
-
search_value: string | null;
|
|
171
|
-
active?: boolean;
|
|
172
|
-
inactive?: boolean;
|
|
173
|
-
dnt_come_anymore?: boolean;
|
|
174
|
-
types?: string;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface IBasicSearchResponse {
|
|
178
|
-
id: string;
|
|
179
|
-
reference: string;
|
|
180
|
-
designation: string;
|
|
181
|
-
price: number;
|
|
182
|
-
promotion_price: number | null;
|
|
183
|
-
thumbnail?: string | null;
|
|
184
|
-
stock: number;
|
|
185
|
-
updated_at: Date;
|
|
186
|
-
state: IProductSheetState;
|
|
187
|
-
inactive: boolean;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export interface IEntityMinified {
|
|
191
|
-
id: string;
|
|
192
|
-
id_provider: number;
|
|
193
|
-
reference: string;
|
|
194
|
-
designation: string;
|
|
195
|
-
price_sale: number;
|
|
196
|
-
price_cost: number;
|
|
197
|
-
tax: number;
|
|
198
|
-
multimedia_id: string | null;
|
|
199
|
-
integer_only: boolean;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export interface IPrintLabelQueryRequest {
|
|
203
|
-
token: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export interface IFindByReferenceRequest {
|
|
207
|
-
reference: string; // partial search term (virtual reference)
|
|
208
|
-
allowProviderWildcard?: boolean; // allow searching for products with undefined provider "0-" (default false)
|
|
209
|
-
id_provider?: number; // limit search to this provider number
|
|
210
|
-
available?: boolean; // limit search to products with available stock
|
|
211
|
-
type?: IProductType; // limit search to product of this type
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export interface IValidateByReferenceRequest extends IFindByReferenceRequest {
|
|
215
|
-
billing_country_id?: string;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
export interface IFindSimilarProductsByNameRequest {
|
|
219
|
-
name: string;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export interface IFindSimilarProductsByNameResponse {
|
|
223
|
-
id: string;
|
|
224
|
-
reference: string;
|
|
225
|
-
thumbnail: string | null;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export interface IFindByProductTypeRequest {
|
|
229
|
-
id_provider: number;
|
|
230
|
-
type: IProductType;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export interface IFindByProductTypeResponse {
|
|
234
|
-
id: string;
|
|
235
|
-
reference: string;
|
|
236
|
-
price: number;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export interface ICheckStockByIdsRequest {
|
|
240
|
-
ids: string[];
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export interface ICheckStockByIdsResponse {
|
|
244
|
-
id: string;
|
|
245
|
-
reference: string;
|
|
246
|
-
available: number;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
export interface IFindReferenceAndIdForMobileResponse {
|
|
250
|
-
id: string;
|
|
251
|
-
reference: string;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export interface IFindDataForMobileResponse {
|
|
255
|
-
id: string;
|
|
256
|
-
reference: string;
|
|
257
|
-
designation: string;
|
|
258
|
-
type: IProductType;
|
|
259
|
-
state: IProductSheetState;
|
|
260
|
-
thumbnail: string | null;
|
|
261
|
-
attributes: string;
|
|
262
|
-
compositions: string;
|
|
263
|
-
unit_of_measure_quantity: Pick<UnitOfMeasure, 'notation' | 'integer_only'>;
|
|
264
|
-
promotions: IDocumentLine.IPromotions[];
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
export interface IFindStockForMobileResponse {
|
|
268
|
-
virtual: Pick<
|
|
269
|
-
IProductVirtuals,
|
|
270
|
-
'price_sale' | 'available' | 'ordered_quantity' | 'prison' | 'reserved' | 'total' | 'inativa'
|
|
271
|
-
>;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export type IFindForMobileRequest =
|
|
275
|
-
| {
|
|
276
|
-
reference: string;
|
|
277
|
-
id?: never;
|
|
278
|
-
}
|
|
279
|
-
| {
|
|
280
|
-
reference?: never;
|
|
281
|
-
id: string;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
export interface IProductLocation {
|
|
285
|
-
location_number: number;
|
|
286
|
-
product_id: string[];
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
export interface IRepository {
|
|
290
|
-
basicSearch(
|
|
291
|
-
params: IBasicSearchRequest,
|
|
292
|
-
): Promise<IShared.IPaginationResponse<IBasicSearchResponse>>;
|
|
293
|
-
|
|
294
|
-
findReferenceAndIdForMobile(
|
|
295
|
-
params: IFindForMobileRequest,
|
|
296
|
-
): Promise<IFindReferenceAndIdForMobileResponse | null>;
|
|
297
|
-
|
|
298
|
-
findDataForMobile(params: IShared.IFindByIdRequest): Promise<IFindDataForMobileResponse | null>;
|
|
299
|
-
|
|
300
|
-
findStockForMobile(params: IShared.IFindByIdRequest): Promise<IFindStockForMobileResponse | null>;
|
|
301
|
-
|
|
302
|
-
validateByRef(selector: IValidateByReferenceRequest): Promise<IEntityMinified | null>;
|
|
303
|
-
|
|
304
|
-
findSimilarProductsByName(
|
|
305
|
-
params: IFindSimilarProductsByNameRequest,
|
|
306
|
-
): Promise<IFindSimilarProductsByNameResponse[]>;
|
|
307
|
-
|
|
308
|
-
findByProductType(params: IFindByProductTypeRequest): Promise<IFindByProductTypeResponse[]>;
|
|
309
|
-
|
|
310
|
-
findById(selector: IShared.IFindByIdRequest): Promise<IProductSheetEntity>;
|
|
311
|
-
|
|
312
|
-
findPreArtigo(selector: IFindProductSheetByReference): Promise<IProductSheetCabideEntity | null>;
|
|
313
|
-
|
|
314
|
-
updatePricesFromPreArtigo(): Promise<void>;
|
|
315
|
-
|
|
316
|
-
findByIdWithStock(selector: IShared.IFindByIdRequest): Promise<ProductVirtuals>;
|
|
317
|
-
|
|
318
|
-
googleSheetsFieldsByRef(selector: IFindByReferenceRequest): Promise<string>;
|
|
319
|
-
|
|
320
|
-
findRowPositionOnSheetsWithColumns(params: IFindProductSheetByReference): Promise<string | null>;
|
|
321
|
-
|
|
322
|
-
checkStockByIds(data: ICheckStockByIdsRequest): Promise<ICheckStockByIdsResponse[]>;
|
|
323
|
-
|
|
324
|
-
create(data: ICreateRequest): Promise<string>;
|
|
325
|
-
|
|
326
|
-
update(params: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<void>;
|
|
327
|
-
|
|
328
|
-
updateGoogleSheetsLinesProduct(data: IShared.IFindByIdRequest[]): Promise<void>;
|
|
329
|
-
|
|
330
|
-
deleteOne(params: IShared.IFindByIdRequest): Promise<void>;
|
|
331
|
-
|
|
332
|
-
updateDbFromSheets(): Promise<void>;
|
|
333
|
-
|
|
334
|
-
partialLocation(data: IProductLocation): Promise<void>;
|
|
335
|
-
|
|
336
|
-
fullLocation(data: IProductLocation): Promise<void>;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import joi from 'joi';
|
|
2
|
-
import { messages } from '../../../shared/messages';
|
|
3
|
-
import * as IShared from '../../../shared/interface';
|
|
4
|
-
import {
|
|
5
|
-
IBasicSearchRequest,
|
|
6
|
-
IFindByProductTypeRequest,
|
|
7
|
-
IFindByReferenceRequest,
|
|
8
|
-
IValidateByReferenceRequest,
|
|
9
|
-
productTypes,
|
|
10
|
-
productState,
|
|
11
|
-
IFindForMobileRequest,
|
|
12
|
-
type IUpdateRequest,
|
|
13
|
-
ICheckStockByIdsRequest,
|
|
14
|
-
ICreateRequest,
|
|
15
|
-
IPrintLabelQueryRequest,
|
|
16
|
-
IFindProductSheetByReference,
|
|
17
|
-
IProductLocation,
|
|
18
|
-
} from './interface';
|
|
19
|
-
|
|
20
|
-
const printLabelQueryKeys: IShared.IRouteRequest<IPrintLabelQueryRequest> = {
|
|
21
|
-
token: joi.string().required(),
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const printLabelQuery = joi.object().keys(printLabelQueryKeys).messages(messages);
|
|
25
|
-
|
|
26
|
-
export const checkStockByIdsBody = joi
|
|
27
|
-
.object<ICheckStockByIdsRequest>()
|
|
28
|
-
.keys({ ids: joi.array().items(joi.string().uuid().required()).required() })
|
|
29
|
-
.messages(messages);
|
|
30
|
-
|
|
31
|
-
const basicSearchQueryKeys: IShared.IRouteRequest<IBasicSearchRequest> = {
|
|
32
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
33
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
34
|
-
active: joi.boolean().default(false).optional(),
|
|
35
|
-
inactive: joi.boolean().default(false).optional(),
|
|
36
|
-
search_value: joi.string().allow('', null).optional(),
|
|
37
|
-
dnt_come_anymore: joi.boolean().default(false).optional(),
|
|
38
|
-
types: joi.string().optional(),
|
|
39
|
-
};
|
|
40
|
-
export const basicSearchQuery = joi.object().keys(basicSearchQueryKeys).messages(messages);
|
|
41
|
-
|
|
42
|
-
const findByRefKeys: IShared.IRouteRequest<IFindByReferenceRequest> = {
|
|
43
|
-
reference: joi.string().required(),
|
|
44
|
-
id_provider: joi.number().integer().positive().optional(),
|
|
45
|
-
available: joi.boolean().optional(),
|
|
46
|
-
allowProviderWildcard: joi.boolean().optional(),
|
|
47
|
-
type: joi
|
|
48
|
-
.string()
|
|
49
|
-
.valid(...productTypes)
|
|
50
|
-
.optional(),
|
|
51
|
-
};
|
|
52
|
-
export const findByRef = joi.object().keys(findByRefKeys).messages(messages);
|
|
53
|
-
|
|
54
|
-
const validateByRefKeys: IShared.IRouteRequest<IValidateByReferenceRequest> = {
|
|
55
|
-
...findByRefKeys,
|
|
56
|
-
billing_country_id: joi.string().uuid().optional(),
|
|
57
|
-
};
|
|
58
|
-
export const validateByRef = joi.object().keys(validateByRefKeys).messages(messages);
|
|
59
|
-
|
|
60
|
-
const findByProductTypeKeys: IShared.IRouteRequest<IFindByProductTypeRequest> = {
|
|
61
|
-
id_provider: joi.number().positive().required(),
|
|
62
|
-
type: joi
|
|
63
|
-
.string()
|
|
64
|
-
.valid(...productTypes)
|
|
65
|
-
.required(),
|
|
66
|
-
};
|
|
67
|
-
export const findByProductTypeParams = joi.object().keys(findByProductTypeKeys).messages(messages);
|
|
68
|
-
|
|
69
|
-
// create body validation
|
|
70
|
-
const createBodyKeys: IShared.IRouteRequest<ICreateRequest> = {
|
|
71
|
-
id: joi.string().uuid().optional(),
|
|
72
|
-
origin_id: joi.string().empty('').optional(),
|
|
73
|
-
id_provider: joi.number().integer().positive().allow(0).optional(),
|
|
74
|
-
provider_ref: joi.string().empty('').optional(),
|
|
75
|
-
name: joi.string().empty('').optional(),
|
|
76
|
-
designation: joi.string().empty('').optional(),
|
|
77
|
-
type: joi
|
|
78
|
-
.string()
|
|
79
|
-
.valid(...productTypes)
|
|
80
|
-
.optional(),
|
|
81
|
-
external_id: joi.string().empty('').optional(),
|
|
82
|
-
vat_tax_id: joi.string().uuid().empty('').optional(),
|
|
83
|
-
weight: joi.number().positive().allow(0).allow(null, '').optional(),
|
|
84
|
-
width: joi.number().positive().allow(0).allow(null, '').optional(),
|
|
85
|
-
height: joi.number().positive().allow(0).allow(null, '').optional(),
|
|
86
|
-
length: joi.number().positive().allow(0).allow(null, '').optional(),
|
|
87
|
-
diameter: joi.number().positive().allow(0).allow(null, '').optional(),
|
|
88
|
-
price_cost: joi.number().positive().allow(0).optional(),
|
|
89
|
-
price_sale: joi.number().positive().allow(0).optional(),
|
|
90
|
-
unit_of_measure_quantity_id: joi.string().uuid().empty('').optional(),
|
|
91
|
-
cabide_product_color: joi.string().allow(null, '').optional(),
|
|
92
|
-
imported_from_sheets: joi.boolean().optional(),
|
|
93
|
-
reference: joi.string().optional(),
|
|
94
|
-
state: joi
|
|
95
|
-
.string()
|
|
96
|
-
.valid(...productState)
|
|
97
|
-
.optional(),
|
|
98
|
-
type_of_inventory: joi.string().optional(),
|
|
99
|
-
max_discount: joi.number().positive().allow(0).min(0).max(100).optional(),
|
|
100
|
-
values: joi.object().optional(),
|
|
101
|
-
maintenances: joi.string().optional(),
|
|
102
|
-
compositions: joi.string().optional(),
|
|
103
|
-
attributes: joi.string().optional(),
|
|
104
|
-
};
|
|
105
|
-
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
106
|
-
|
|
107
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
108
|
-
designation: joi.string().empty('').optional(),
|
|
109
|
-
provider_ref: joi.string().empty('').optional(),
|
|
110
|
-
type: joi
|
|
111
|
-
.string()
|
|
112
|
-
.valid(...productTypes)
|
|
113
|
-
.optional(),
|
|
114
|
-
price_cost: joi.number().positive().allow(0).optional(),
|
|
115
|
-
price_sale: joi.number().positive().allow(0).optional(),
|
|
116
|
-
unit_of_measure_quantity_notation: joi.string().empty('').optional(),
|
|
117
|
-
state: joi
|
|
118
|
-
.string()
|
|
119
|
-
.valid(...productState)
|
|
120
|
-
.optional(),
|
|
121
|
-
};
|
|
122
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
123
|
-
|
|
124
|
-
export const findForMobileQuery = joi
|
|
125
|
-
.object<IFindForMobileRequest>()
|
|
126
|
-
.keys({
|
|
127
|
-
id: joi.string().uuid().optional(),
|
|
128
|
-
reference: joi.string().optional(),
|
|
129
|
-
})
|
|
130
|
-
.xor('id', 'reference')
|
|
131
|
-
.messages(messages);
|
|
132
|
-
|
|
133
|
-
export const findProductSheetByReferenceQuery = joi
|
|
134
|
-
.object<IFindProductSheetByReference>()
|
|
135
|
-
.keys({
|
|
136
|
-
selector: joi.string().required(),
|
|
137
|
-
})
|
|
138
|
-
.messages(messages);
|
|
139
|
-
|
|
140
|
-
export const productLocationBody = joi
|
|
141
|
-
.object<IProductLocation>()
|
|
142
|
-
.keys({
|
|
143
|
-
location_number: joi.number().required(),
|
|
144
|
-
product_id: joi.array().items(joi.string().uuid()).required(),
|
|
145
|
-
})
|
|
146
|
-
.messages(messages);
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import { ProductImage } from '../../../shared/entities/stock';
|
|
3
|
-
|
|
4
|
-
export type Entity = ProductImage;
|
|
5
|
-
export const Route = 'product_image';
|
|
6
|
-
export const UpperName = 'ProductImage';
|
|
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
|
-
// omit any unnecessary fields
|
|
15
|
-
export type IFindByOwnerIdResponse = Omit<IFindDetailedResponse, ''>;
|
|
16
|
-
|
|
17
|
-
export type IFindRequest = Record<string, unknown>;
|
|
18
|
-
|
|
19
|
-
// omit any unnecessary fields
|
|
20
|
-
export type IFindResponse = Omit<IFindDetailedResponse, ''>;
|
|
21
|
-
|
|
22
|
-
export const ImageTypeEnum: {
|
|
23
|
-
thumbnail: 'thumbnail';
|
|
24
|
-
site: 'site';
|
|
25
|
-
} = {
|
|
26
|
-
thumbnail: 'thumbnail',
|
|
27
|
-
site: 'site',
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type IImageType = (typeof ImageTypeEnum)[keyof typeof ImageTypeEnum];
|
|
31
|
-
|
|
32
|
-
export const imageTypes = Object.keys(ImageTypeEnum);
|
|
33
|
-
|
|
34
|
-
export interface IFindPaginatedRequest extends IFindRequest, IShared.IPaginationRequest {}
|
|
35
|
-
|
|
36
|
-
export type IFindWithPaginationResponse = IShared.IPaginationResponse<
|
|
37
|
-
Omit<IFindDetailedResponse, ''>
|
|
38
|
-
>;
|
|
39
|
-
|
|
40
|
-
export interface ICreateRequest {
|
|
41
|
-
// create fields
|
|
42
|
-
product_id: string;
|
|
43
|
-
product_sheet_id?: string;
|
|
44
|
-
multimedia_id: string;
|
|
45
|
-
type: IImageType;
|
|
46
|
-
created_by?: string | null;
|
|
47
|
-
updated_by?: string | null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface IUpdateRequest {
|
|
51
|
-
// updatable fields
|
|
52
|
-
product_id?: string;
|
|
53
|
-
multimedia_id?: string;
|
|
54
|
-
type?: IImageType;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface IRepository {
|
|
58
|
-
findById(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse | null>;
|
|
59
|
-
|
|
60
|
-
findByOwnerId(params: IShared.IFindByOwnerIdRequest): Promise<IFindByOwnerIdResponse[]>;
|
|
61
|
-
find(selector: IFindRequest): Promise<IFindResponse[]>;
|
|
62
|
-
findPaginated(selector: IFindPaginatedRequest): Promise<IFindWithPaginationResponse>;
|
|
63
|
-
|
|
64
|
-
create(data: ICreateRequest): Promise<Entity>;
|
|
65
|
-
update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<Entity | null>;
|
|
66
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<Entity | null>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,52 +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
|
-
imageTypes,
|
|
10
|
-
} from './interface';
|
|
11
|
-
|
|
12
|
-
// create body validation
|
|
13
|
-
const createBodyKeys: IShared.IRouteRequestWithStamps<ICreateRequest> = {
|
|
14
|
-
type: joi
|
|
15
|
-
.string()
|
|
16
|
-
.valid(...imageTypes)
|
|
17
|
-
.required(),
|
|
18
|
-
product_id: joi.string().uuid().required(),
|
|
19
|
-
product_sheet_id: joi.string().uuid().optional(),
|
|
20
|
-
multimedia_id: joi.string().uuid().required(),
|
|
21
|
-
created_by: joi.string().uuid().optional(),
|
|
22
|
-
updated_by: joi.string().uuid().optional(),
|
|
23
|
-
};
|
|
24
|
-
export const createBody = joi
|
|
25
|
-
.object()
|
|
26
|
-
.keys(createBodyKeys)
|
|
27
|
-
.xor('product_id', 'product_sheet_id')
|
|
28
|
-
.messages(messages);
|
|
29
|
-
|
|
30
|
-
// update body validation
|
|
31
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
32
|
-
type: joi
|
|
33
|
-
.string()
|
|
34
|
-
.valid(...imageTypes)
|
|
35
|
-
.optional(),
|
|
36
|
-
product_id: joi.string().uuid().optional(),
|
|
37
|
-
multimedia_id: joi.string().uuid().optional(),
|
|
38
|
-
};
|
|
39
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
40
|
-
|
|
41
|
-
const findQueryKeys: IShared.IRouteRequest<IFindRequest> = {};
|
|
42
|
-
export const findQuery = joi.object().keys(findQueryKeys).messages(messages);
|
|
43
|
-
|
|
44
|
-
// find with pagination query validation
|
|
45
|
-
const findWithPaginationQueryKeys: IShared.IRouteRequest<IFindPaginatedRequest> = {
|
|
46
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
47
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
48
|
-
};
|
|
49
|
-
export const findWithPaginationQuery = joi
|
|
50
|
-
.object()
|
|
51
|
-
.keys(findWithPaginationQueryKeys)
|
|
52
|
-
.messages(messages);
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import * as IShared from '../../../shared/interface';
|
|
2
|
-
import { Promotion } from '../../../shared/entities/stock';
|
|
3
|
-
|
|
4
|
-
export type Entity = Promotion;
|
|
5
|
-
export const Route = 'promotion';
|
|
6
|
-
export const UpperName = 'Promotion';
|
|
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
|
-
// omit any unnecessary fields
|
|
15
|
-
export type IFindByOwnerIdResponse = Omit<IFindDetailedResponse, ''>;
|
|
16
|
-
|
|
17
|
-
export type IFindRequest = Record<string, unknown>;
|
|
18
|
-
|
|
19
|
-
// omit any unnecessary fields
|
|
20
|
-
export type IFindResponse = Omit<IFindDetailedResponse, ''>;
|
|
21
|
-
|
|
22
|
-
export interface IFindPaginatedRequest extends IFindRequest, IShared.IPaginationRequest {}
|
|
23
|
-
|
|
24
|
-
export type IFindWithPaginationResponse = IShared.IPaginationResponse<
|
|
25
|
-
Omit<IFindDetailedResponse, ''>
|
|
26
|
-
>;
|
|
27
|
-
|
|
28
|
-
export interface ICreateRequest {
|
|
29
|
-
// create fields
|
|
30
|
-
name: string;
|
|
31
|
-
initial_date: Date;
|
|
32
|
-
final_date: Date;
|
|
33
|
-
active_for_purchases_above?: number;
|
|
34
|
-
free_shipping_for_purchases_above?: number | null;
|
|
35
|
-
discount: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface IUpdateRequest {
|
|
39
|
-
// updatable fields
|
|
40
|
-
name?: string;
|
|
41
|
-
initial_date?: Date;
|
|
42
|
-
final_date?: Date;
|
|
43
|
-
active_for_purchases_above?: number;
|
|
44
|
-
free_shipping_for_purchases_above?: number | null;
|
|
45
|
-
discount?: number;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface IRepository {
|
|
49
|
-
findById(selector: IShared.IFindByIdRequest): Promise<IFindByIdResponse | null>;
|
|
50
|
-
|
|
51
|
-
findByOwnerId(params: IShared.IFindByOwnerIdRequest): Promise<IFindByOwnerIdResponse[]>;
|
|
52
|
-
findMinified(params?: IShared.IFindMinifiedRequest): Promise<IShared.IFindMinifiedResponse[]>;
|
|
53
|
-
find(selector: IFindRequest): Promise<IFindResponse[]>;
|
|
54
|
-
findPaginated(selector: IFindPaginatedRequest): Promise<IFindWithPaginationResponse>;
|
|
55
|
-
|
|
56
|
-
create(data: ICreateRequest): Promise<Entity>;
|
|
57
|
-
update(selector: IShared.IFindByIdRequest, data: IUpdateRequest): Promise<Entity | null>;
|
|
58
|
-
deleteOne(selector: IShared.IFindByIdRequest): Promise<Entity | null>;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type IController = IShared.IEntityWithUserToken<IRepository>;
|
|
@@ -1,39 +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
|
-
initial_date: joi.date().required(),
|
|
10
|
-
final_date: joi.date().required(),
|
|
11
|
-
active_for_purchases_above: joi.number().integer().positive().allow(0).optional(),
|
|
12
|
-
free_shipping_for_purchases_above: joi.number().integer().positive().allow(0, null).optional(),
|
|
13
|
-
discount: joi.number().positive().max(100).required(),
|
|
14
|
-
};
|
|
15
|
-
export const createBody = joi.object().keys(createBodyKeys).messages(messages);
|
|
16
|
-
|
|
17
|
-
// update body validation
|
|
18
|
-
const updateBodyKeys: IShared.IRouteRequest<IUpdateRequest> = {
|
|
19
|
-
name: joi.string().optional(),
|
|
20
|
-
initial_date: joi.date().optional(),
|
|
21
|
-
final_date: joi.date().optional(),
|
|
22
|
-
active_for_purchases_above: joi.number().integer().positive().allow(0).optional(),
|
|
23
|
-
free_shipping_for_purchases_above: joi.number().integer().positive().allow(0, null).optional(),
|
|
24
|
-
discount: joi.number().positive().max(100).optional(),
|
|
25
|
-
};
|
|
26
|
-
export const updateBody = joi.object().keys(updateBodyKeys).messages(messages);
|
|
27
|
-
|
|
28
|
-
const findQueryKeys: IShared.IRouteRequest<IFindRequest> = {};
|
|
29
|
-
export const findQuery = joi.object().keys(findQueryKeys).messages(messages);
|
|
30
|
-
|
|
31
|
-
// find with pagination query validation
|
|
32
|
-
const findWithPaginationQueryKeys: IShared.IRouteRequest<IFindPaginatedRequest> = {
|
|
33
|
-
per_page: joi.number().integer().positive().default(10).optional(),
|
|
34
|
-
current_page: joi.number().integer().positive().default(1).optional(),
|
|
35
|
-
};
|
|
36
|
-
export const findWithPaginationQuery = joi
|
|
37
|
-
.object()
|
|
38
|
-
.keys(findWithPaginationQueryKeys)
|
|
39
|
-
.messages(messages);
|