@nomalism-com/api 0.36.28 → 0.37.1

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.
Files changed (128) hide show
  1. package/dist/index.cjs +0 -7
  2. package/dist/index.d.ts +2 -3
  3. package/dist/index.js +0 -7
  4. package/package.json +17 -21
  5. package/.editorconfig +0 -9
  6. package/.prettierrc +0 -7
  7. package/eslint.config.mjs +0 -39
  8. package/package-lock.json +0 -4616
  9. package/src/index.ts +0 -3
  10. package/src/main.ts +0 -805
  11. package/src/modules/document/billOfLading.ts +0 -24
  12. package/src/modules/document/inventario.ts +0 -21
  13. package/src/modules/document/materialEntrance.ts +0 -81
  14. package/src/modules/document/order.ts +0 -52
  15. package/src/modules/document/productionOrder.ts +0 -23
  16. package/src/modules/document/proforma.ts +0 -22
  17. package/src/modules/document/propostaFornecedor.ts +0 -24
  18. package/src/modules/document/propostaSheets.ts +0 -87
  19. package/src/modules/document/providerCreditNoteFromReturn.ts +0 -32
  20. package/src/modules/document/providerFinancialCreditNote.ts +0 -32
  21. package/src/modules/document/providerServiceInvoice.ts +0 -23
  22. package/src/modules/document/purchase.ts +0 -40
  23. package/src/modules/document/quebra.ts +0 -41
  24. package/src/modules/document/returnToProvider.ts +0 -37
  25. package/src/modules/document/transformado.ts +0 -27
  26. package/src/modules/document/upfrontReturn.ts +0 -25
  27. package/src/modules/documentManagement/multimedia.ts +0 -39
  28. package/src/modules/integration/emailLog.ts +0 -43
  29. package/src/modules/integration/emailTemplate.ts +0 -44
  30. package/src/modules/integration/emailTemplateAttachment.ts +0 -26
  31. package/src/modules/integration/emailVerification.ts +0 -34
  32. package/src/modules/integration/googleFilePermission.ts +0 -43
  33. package/src/modules/integration/googleSheets.ts +0 -47
  34. package/src/modules/integration/observation.ts +0 -55
  35. package/src/modules/integration/observationType.ts +0 -53
  36. package/src/modules/integration/projectInfo.ts +0 -21
  37. package/src/modules/integration/settings.ts +0 -48
  38. package/src/modules/print/npc.ts +0 -39
  39. package/src/modules/print/printer.ts +0 -48
  40. package/src/modules/print/schedulePrintJob.ts +0 -45
  41. package/src/modules/stock/chat.ts +0 -54
  42. package/src/modules/stock/chatRapidMessage.ts +0 -48
  43. package/src/modules/stock/dashboard.ts +0 -24
  44. package/src/modules/stock/file.ts +0 -45
  45. package/src/modules/stock/location.ts +0 -74
  46. package/src/modules/stock/prison.ts +0 -46
  47. package/src/modules/stock/productGoogleSheets.ts +0 -175
  48. package/src/modules/stock/productImage.ts +0 -67
  49. package/src/modules/stock/promotion.ts +0 -107
  50. package/src/modules/stock/promotionAssoc.ts +0 -69
  51. package/src/modules/stock/queryList.ts +0 -72
  52. package/src/modules/stock/queryParameter.ts +0 -56
  53. package/src/modules/stock/recurrentTasks.ts +0 -25
  54. package/src/modules/stock/returnReason.ts +0 -42
  55. package/src/modules/stock/savedEmPicking.ts +0 -35
  56. package/src/modules/stock/savedProviderProposal.ts +0 -42
  57. package/src/modules/stock/schedule.ts +0 -21
  58. package/src/modules/stock/sideMenu.ts +0 -45
  59. package/src/modules/stock/stockMovement.ts +0 -56
  60. package/src/modules/stock/tag.ts +0 -37
  61. package/src/modules/stock/task.ts +0 -57
  62. package/src/modules/stock/taskMessage.ts +0 -33
  63. package/src/modules/stock/taskRead.ts +0 -25
  64. package/src/modules/stock/typeOfLocation.ts +0 -78
  65. package/src/modules/stock/unitOfMeasure.ts +0 -78
  66. package/src/modules/stock/vatTax.ts +0 -74
  67. package/src/modules/stock/vatTaxZone.ts +0 -78
  68. package/src/modules/supply/clientCurrentAccount.ts +0 -71
  69. package/src/modules/supply/documentHeader.ts +0 -195
  70. package/src/modules/supply/documentHeaderHistory.ts +0 -24
  71. package/src/modules/supply/documentLine.ts +0 -75
  72. package/src/modules/supply/documentLineAssoc.ts +0 -57
  73. package/src/modules/supply/documentLineMt.ts +0 -28
  74. package/src/modules/supply/documentLineNote.ts +0 -35
  75. package/src/modules/supply/documentLineRm.ts +0 -28
  76. package/src/modules/supply/documentSet.ts +0 -56
  77. package/src/modules/supply/documentType.ts +0 -60
  78. package/src/modules/supply/externalDocumentHeader.ts +0 -96
  79. package/src/modules/supply/externalDocumentType.ts +0 -29
  80. package/src/modules/supply/orderManagement.ts +0 -33
  81. package/src/modules/supply/payment.ts +0 -156
  82. package/src/modules/supply/preSale.ts +0 -72
  83. package/src/modules/supply/preSaleProduct.ts +0 -29
  84. package/src/modules/supply/providerCurrentAccount.ts +0 -26
  85. package/src/modules/supply/startDocumentHeaderLastUpdate.ts +0 -24
  86. package/src/modules/supply/vatValidation.ts +0 -26
  87. package/src/modules/supply/workflow.ts +0 -53
  88. package/src/modules/tickets/channel.ts +0 -54
  89. package/src/modules/tickets/clt.ts +0 -50
  90. package/src/modules/tickets/language.ts +0 -56
  91. package/src/modules/tickets/tickets.ts +0 -41
  92. package/src/modules/user/bankData.ts +0 -67
  93. package/src/modules/user/chatSubscriber.ts +0 -49
  94. package/src/modules/user/clientType.ts +0 -67
  95. package/src/modules/user/clients.ts +0 -89
  96. package/src/modules/user/commissioner.ts +0 -81
  97. package/src/modules/user/country.ts +0 -77
  98. package/src/modules/user/deliveryMethods.ts +0 -60
  99. package/src/modules/user/favorites.ts +0 -39
  100. package/src/modules/user/groupPermission.ts +0 -45
  101. package/src/modules/user/language.ts +0 -68
  102. package/src/modules/user/logout.ts +0 -20
  103. package/src/modules/user/maturityDates.ts +0 -60
  104. package/src/modules/user/password.ts +0 -25
  105. package/src/modules/user/paymentMethods.ts +0 -60
  106. package/src/modules/user/permission.ts +0 -43
  107. package/src/modules/user/persona.ts +0 -92
  108. package/src/modules/user/provider.ts +0 -90
  109. package/src/modules/user/providerType.ts +0 -70
  110. package/src/modules/user/purchaseCondition.ts +0 -69
  111. package/src/modules/user/reasonForExemption.ts +0 -69
  112. package/src/modules/user/refreshToken.ts +0 -24
  113. package/src/modules/user/segmentsArea.ts +0 -67
  114. package/src/modules/user/sessions.ts +0 -22
  115. package/src/modules/user/shippings.ts +0 -65
  116. package/src/modules/user/storeOperator.ts +0 -56
  117. package/src/modules/user/swift.ts +0 -65
  118. package/src/modules/user/tenant.ts +0 -42
  119. package/src/modules/user/theme.ts +0 -21
  120. package/src/modules/user/user.ts +0 -79
  121. package/src/modules/user/userPermission.ts +0 -40
  122. package/src/modules/user/userPositions.ts +0 -69
  123. package/src/modules/user/vehicles.ts +0 -42
  124. package/src/modules/user/zipCode.ts +0 -28
  125. package/src/modules/view/adminPanel.ts +0 -24
  126. package/src/modules/view/errorLog.ts +0 -21
  127. package/tsconfig.json +0 -18
  128. package/tsup.config.ts +0 -13
@@ -1,45 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.File.IRepository {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async findByOwnerId(
19
- params: Nomalism.shared.IFindByOwnerIdRequest,
20
- ): Promise<Nomalism.File.Entity[]> {
21
- const response = await this.api.get(`${this.route}by_owner`, {
22
- params,
23
- });
24
- return response.data;
25
- }
26
-
27
- async create(body: Nomalism.File.ICreateRequest): Promise<Nomalism.File.Entity> {
28
- const response = await this.api.post(`${this.publicRoute}`, body);
29
- return response.data;
30
- }
31
-
32
- async update(
33
- { id }: Nomalism.shared.IFindByIdRequest,
34
- body: Nomalism.File.IUpdateRequest,
35
- ): Promise<void> {
36
- await this.api.put(`${this.publicRoute}${id}`, body);
37
- }
38
-
39
- async deleteOne(
40
- selector: Nomalism.shared.IFindByIdRequest,
41
- ): Promise<Nomalism.File.Entity | null> {
42
- const response = await this.api.delete(`${this.route}${selector.id}`);
43
- return response.data;
44
- }
45
- }
@@ -1,74 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.Location.IRepository {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async find(params: Nomalism.Location.IFindRequest): Promise<Nomalism.Location.IFindResponse[]> {
19
- const response = await this.api.get(`${this.route}`, { params });
20
- return response.data;
21
- }
22
-
23
- async findPaginated(
24
- params: Nomalism.Location.IFindPaginatedRequest,
25
- ): Promise<Nomalism.shared.IPaginationResponse<Nomalism.Location.IFindResponse>> {
26
- const response = await this.api.get(`${this.route}paginated`, { params });
27
- return response.data;
28
- }
29
-
30
- async findMinified(
31
- params?: Nomalism.shared.IFindMinifiedRequest,
32
- ): Promise<Nomalism.shared.IFindMinifiedResponse[]> {
33
- const response = await this.api.get(`${this.route}minified`, {
34
- params,
35
- });
36
- return response.data;
37
- }
38
-
39
- async findByOwnerId(
40
- params: Nomalism.shared.IFindByOwnerIdRequest,
41
- ): Promise<Nomalism.Location.IFindResponse[]> {
42
- const response = await this.api.get(`${this.route}by_owner`, {
43
- params,
44
- });
45
- return response.data;
46
- }
47
-
48
- async findById(
49
- selector: Nomalism.shared.IFindByIdRequest,
50
- ): Promise<Nomalism.Location.IFindResponse | null> {
51
- const response = await this.api.get(`${this.route}${selector.id}`);
52
- return response.data;
53
- }
54
-
55
- async create(body: Nomalism.Location.ICreateRequest): Promise<Nomalism.Location.IFindResponse> {
56
- const response = await this.api.post(`${this.route}`, body);
57
- return response.data;
58
- }
59
-
60
- async update(
61
- selector: Nomalism.shared.IFindByIdRequest,
62
- body: Nomalism.Location.IUpdateRequest,
63
- ): Promise<Nomalism.Location.IFindResponse | null> {
64
- const response = await this.api.put(`${this.route}${selector.id}`, body);
65
- return response.data;
66
- }
67
-
68
- async deleteOne(
69
- selector: Nomalism.shared.IFindByIdRequest,
70
- ): Promise<Nomalism.Location.IFindResponse | null> {
71
- const response = await this.api.delete(`${this.route}${selector.id}`);
72
- return response.data;
73
- }
74
- }
@@ -1,46 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.Prison.IApi {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async putLineInPrison(data: Nomalism.shared.IFindByIdRequest): Promise<void> {
19
- const response = await this.api.post(`${this.route}put_in_prison`, data);
20
- return response.data;
21
- }
22
-
23
- async removeLineFromPrison(data: Nomalism.shared.IFindByIdRequest): Promise<void> {
24
- const response = await this.api.post(`${this.route}remove_from_prison`, data);
25
- return response.data;
26
- }
27
-
28
- async findLinesInPrison(): Promise<Nomalism.Prison.IFindLinesInPrisonResponse[]> {
29
- const response = await this.api.get(`${this.route}in_prison`, {});
30
- return response.data;
31
- }
32
-
33
- async findLinesInPrisonProviders(): Promise<Nomalism.shared.IFindMinifiedResponse[]> {
34
- const response = await this.api.get(`${this.route}in_prison_providers`, {});
35
- return response.data;
36
- }
37
-
38
- async checkLinesInPrison(data: Nomalism.Prison.ICheckLinesInPrisonRequest): Promise<void> {
39
- await this.api.post(`${this.route}check_in_prison`, data);
40
- }
41
-
42
- async createLinesInPrison(data: Nomalism.Prison.ICreateLinesInPrisonRequest): Promise<string[]> {
43
- const response = await this.api.post(`${this.route}create_lines`, data);
44
- return response.data;
45
- }
46
- }
@@ -1,175 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.ProductGoogleSheets.IRepository {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async basicSearch(
19
- params: Nomalism.ProductGoogleSheets.IBasicSearchRequest,
20
- ): Promise<
21
- Nomalism.shared.IPaginationResponse<Nomalism.ProductGoogleSheets.IBasicSearchResponse>
22
- > {
23
- const response = await this.api.get(`${this.route}basic_search`, {
24
- params,
25
- });
26
- return response.data;
27
- }
28
-
29
- async findReferenceAndIdForMobile(
30
- params: Nomalism.ProductGoogleSheets.IFindForMobileRequest,
31
- ): Promise<Nomalism.ProductGoogleSheets.IFindReferenceAndIdForMobileResponse | null> {
32
- const response = await this.api.get(`${this.route}reference_and_id_mobile`, {
33
- params,
34
- });
35
- return response.data;
36
- }
37
-
38
- async findDataForMobile(
39
- params: Nomalism.shared.IFindByIdRequest,
40
- ): Promise<Nomalism.ProductGoogleSheets.IFindDataForMobileResponse | null> {
41
- const response = await this.api.get(`${this.route}data_mobile/${params.id}`);
42
- return response.data;
43
- }
44
-
45
- async findStockForMobile(
46
- params: Nomalism.shared.IFindByIdRequest,
47
- ): Promise<Nomalism.ProductGoogleSheets.IFindStockForMobileResponse | null> {
48
- const response = await this.api.get(`${this.route}stock_mobile/${params.id}`);
49
- return response.data;
50
- }
51
-
52
- async findPreArtigo(
53
- params: Nomalism.ProductGoogleSheets.IFindProductSheetByReference,
54
- ): Promise<Nomalism.ProductGoogleSheets.IProductSheetCabideEntity | null> {
55
- const response = await this.api.get(`${this.route}pre_artigo`, {
56
- params,
57
- });
58
- return response.data;
59
- }
60
-
61
- async updatePricesFromPreArtigo(): Promise<void> {
62
- await this.api.get(`${this.route}update_prices_from_pre_artigo`);
63
- }
64
-
65
- async validateByRef(
66
- params: Nomalism.ProductGoogleSheets.IValidateByReferenceRequest,
67
- ): Promise<Nomalism.ProductGoogleSheets.IEntityMinified | null> {
68
- const response = await this.api.get(`${this.route}validate_by_ref`, {
69
- params,
70
- });
71
- return response.data;
72
- }
73
-
74
- async findSimilarProductsByName(
75
- params: Nomalism.ProductGoogleSheets.IFindSimilarProductsByNameRequest,
76
- ): Promise<Nomalism.ProductGoogleSheets.IFindSimilarProductsByNameResponse[]> {
77
- const response = await this.api.get(`${this.route}similar_products`, {
78
- params,
79
- });
80
- return response.data;
81
- }
82
-
83
- async findByProductType(
84
- params: Nomalism.ProductGoogleSheets.IFindByProductTypeRequest,
85
- ): Promise<Nomalism.ProductGoogleSheets.IFindByProductTypeResponse[]> {
86
- const response = await this.api.get(`${this.route}by_product_type`, {
87
- params,
88
- });
89
-
90
- return response.data;
91
- }
92
-
93
- async findById({
94
- id,
95
- }: Nomalism.shared.IFindByIdRequest): Promise<Nomalism.ProductGoogleSheets.IProductSheetEntity> {
96
- const response = await this.api.get(`${this.route}${id}`);
97
- return response.data;
98
- }
99
-
100
- async findByIdWithStock({
101
- id,
102
- }: Nomalism.shared.IFindByIdRequest): Promise<Nomalism.ProductGoogleSheets.IProductVirtuals> {
103
- const response = await this.api.get(`${this.route}${id}/with_stock`);
104
- return response.data;
105
- }
106
-
107
- async updateGoogleSheetsLinesProduct(body: Nomalism.shared.IFindByIdRequest[]): Promise<void> {
108
- const response = await this.api.put(`${this.route}update_google_sheets_lines_product`, body);
109
- return response.data;
110
- }
111
-
112
- async googleSheetsFieldsByRef(
113
- params: Nomalism.ProductGoogleSheets.IFindByReferenceRequest,
114
- ): Promise<string> {
115
- const response = await this.api.get(
116
- `${this.route}google_sheets_fields_by_ref/${params.reference}`,
117
- );
118
- return response.data;
119
- }
120
-
121
- async findRowPositionOnSheetsWithColumns(
122
- params: Nomalism.ProductGoogleSheets.IFindProductSheetByReference,
123
- ): Promise<string> {
124
- const response = await this.api.get(`${this.route}sheet_row_and_columns/${params.selector}`);
125
- return response.data;
126
- }
127
-
128
- async checkStockByIds(
129
- data: Nomalism.ProductGoogleSheets.ICheckStockByIdsRequest,
130
- ): Promise<Nomalism.ProductGoogleSheets.ICheckStockByIdsResponse[]> {
131
- const response = await this.api.post(`${this.route}check_stock_by_ids`, data);
132
- return response.data;
133
- }
134
-
135
- async create(body: Nomalism.ProductGoogleSheets.ICreateRequest): Promise<string> {
136
- const response = await this.api.post(`${this.route}`, body);
137
- return response.data;
138
- }
139
-
140
- async update(
141
- { id }: Nomalism.shared.IFindByIdRequest,
142
- body: Nomalism.ProductGoogleSheets.IUpdateRequest,
143
- ): Promise<void> {
144
- await this.api.put(`${this.route}${id}`, body);
145
- }
146
-
147
- async deleteOne(selector: Nomalism.shared.IFindByIdRequest): Promise<void> {
148
- await this.api.delete(`${this.route}${selector.id}`);
149
- }
150
-
151
- printLabelToPdfUrl({ id }: Nomalism.shared.IFindByIdRequest, token: string): string {
152
- const qs = new URLSearchParams();
153
- qs.set('token', token);
154
- return `${this.publicRoute}print_label_pdf/${id}?${qs.toString()}`;
155
- }
156
-
157
- printLabelToPdfBulk(ids: string[], token: string): string {
158
- const qs = new URLSearchParams();
159
- qs.set('token', token);
160
- qs.set('ids', ids.join(','));
161
- return `${this.publicRoute}print_label_pdf/bulk?${qs.toString()}`;
162
- }
163
-
164
- async updateDbFromSheets(): Promise<void> {
165
- await this.api.post(`${this.route}update_db_from_sheets`);
166
- }
167
-
168
- async partialLocation(body: Nomalism.ProductGoogleSheets.IProductLocation): Promise<void> {
169
- await this.api.post(`${this.route}partial_location`, body);
170
- }
171
-
172
- async fullLocation(body: Nomalism.ProductGoogleSheets.IProductLocation): Promise<void> {
173
- await this.api.post(`${this.route}full_location`, body);
174
- }
175
- }
@@ -1,67 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.ProductImage.IRepository {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async find(
19
- params: Nomalism.ProductImage.IFindRequest,
20
- ): Promise<Nomalism.ProductImage.IFindResponse[]> {
21
- const response = await this.api.get(`${this.route}`, { params });
22
- return response.data;
23
- }
24
-
25
- async findPaginated(
26
- params: Nomalism.ProductImage.IFindPaginatedRequest,
27
- ): Promise<Nomalism.shared.IPaginationResponse<Nomalism.ProductImage.IFindResponse>> {
28
- const response = await this.api.get(`${this.route}paginated`, { params });
29
- return response.data;
30
- }
31
-
32
- async findByOwnerId(
33
- params: Nomalism.shared.IFindByOwnerIdRequest,
34
- ): Promise<Nomalism.ProductImage.IFindResponse[]> {
35
- const response = await this.api.get(`${this.route}by_owner`, {
36
- params,
37
- });
38
- return response.data;
39
- }
40
-
41
- async findById(
42
- selector: Nomalism.shared.IFindByIdRequest,
43
- ): Promise<Nomalism.ProductImage.IFindResponse | null> {
44
- const response = await this.api.get(`${this.route}${selector.id}`);
45
- return response.data;
46
- }
47
-
48
- async create(body: Nomalism.ProductImage.ICreateRequest): Promise<Nomalism.ProductImage.Entity> {
49
- const response = await this.api.post(`${this.route}`, body);
50
- return response.data;
51
- }
52
-
53
- async update(
54
- selector: Nomalism.shared.IFindByIdRequest,
55
- body: Nomalism.ProductImage.IUpdateRequest,
56
- ): Promise<Nomalism.ProductImage.Entity | null> {
57
- const response = await this.api.put(`${this.route}${selector.id}`, body);
58
- return response.data;
59
- }
60
-
61
- async deleteOne(
62
- selector: Nomalism.shared.IFindByIdRequest,
63
- ): Promise<Nomalism.ProductImage.Entity | null> {
64
- const response = await this.api.delete(`${this.route}${selector.id}`);
65
- return response.data;
66
- }
67
- }
@@ -1,107 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.Promotion.IRepository {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async find(params: Nomalism.Promotion.IFindRequest): Promise<Nomalism.Promotion.IFindResponse[]> {
19
- const response = await this.api.get(`${this.route}`, { params });
20
- return response.data;
21
- }
22
-
23
- async findPaginated(
24
- params: Nomalism.Promotion.IFindPaginatedRequest,
25
- ): Promise<Nomalism.shared.IPaginationResponse<Nomalism.Promotion.IFindResponse>> {
26
- const response = await this.api.get(`${this.route}paginated`, { params });
27
- return response.data;
28
- }
29
-
30
- async findMinified(
31
- params?: Nomalism.shared.IFindMinifiedRequest,
32
- ): Promise<Nomalism.shared.IFindMinifiedResponse[]> {
33
- const response = await this.api.get(`${this.route}minified`, {
34
- params,
35
- });
36
- return response.data;
37
- }
38
-
39
- async findByOwnerId(
40
- params: Nomalism.shared.IFindByOwnerIdRequest,
41
- ): Promise<Nomalism.Promotion.IFindResponse[]> {
42
- const response = await this.api.get(`${this.route}by_owner`, {
43
- params,
44
- });
45
-
46
- return response.data;
47
- }
48
-
49
- async findById(
50
- selector: Nomalism.shared.IFindByIdRequest,
51
- ): Promise<Nomalism.Promotion.IFindResponse | null> {
52
- const response = await this.api.get(`${this.route}${selector.id}`);
53
- return response.data;
54
- }
55
-
56
- async create(body: Nomalism.Promotion.ICreateRequest): Promise<Nomalism.Promotion.Entity> {
57
- const response = await this.api.post(`${this.route}`, body);
58
- return response.data;
59
- }
60
-
61
- async update(
62
- selector: Nomalism.shared.IFindByIdRequest,
63
- body: Nomalism.Promotion.IUpdateRequest,
64
- ): Promise<Nomalism.Promotion.Entity | null> {
65
- const response = await this.api.put(`${this.route}${selector.id}`, body);
66
- return response.data;
67
- }
68
-
69
- async deleteOne(
70
- selector: Nomalism.shared.IFindByIdRequest,
71
- ): Promise<Nomalism.Promotion.Entity | null> {
72
- const response = await this.api.delete(`${this.route}${selector.id}`);
73
- return response.data;
74
- }
75
-
76
- getBestDiscount(
77
- promotions: Pick<
78
- Nomalism.ProductGoogleSheets.IProductPromotionVirtuals,
79
- 'exclusive_to_location_id' | 'exclusive_to_client_id' | 'discount'
80
- >[],
81
- discount?: number,
82
- location_id?: string,
83
- client_id?: string,
84
- product_no_discount?: boolean,
85
- ) {
86
- const highestPromoDiscount = promotions
87
- .filter((promotion) => {
88
- const locationEligible = promotion.exclusive_to_location_id
89
- ? promotion.exclusive_to_location_id === location_id
90
- : true;
91
-
92
- const clientEligible = promotion.exclusive_to_client_id
93
- ? promotion.exclusive_to_client_id === client_id
94
- : true;
95
-
96
- return locationEligible && clientEligible;
97
- })
98
- .reduce(
99
- (highest, promotion) => (promotion.discount > highest ? promotion.discount : highest),
100
- 0,
101
- );
102
-
103
- const clientDiscount = product_no_discount ? 0 : discount || 0;
104
-
105
- return highestPromoDiscount > clientDiscount ? highestPromoDiscount : clientDiscount;
106
- }
107
- }
@@ -1,69 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.PromotionAssoc.IRepository {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async find(
19
- params: Nomalism.PromotionAssoc.IFindRequest,
20
- ): Promise<Nomalism.PromotionAssoc.IFindResponse[]> {
21
- const response = await this.api.get(`${this.route}`, { params });
22
- return response.data;
23
- }
24
-
25
- async findPaginated(
26
- params: Nomalism.PromotionAssoc.IFindPaginatedRequest,
27
- ): Promise<Nomalism.shared.IPaginationResponse<Nomalism.PromotionAssoc.IFindResponse>> {
28
- const response = await this.api.get(`${this.route}paginated`, { params });
29
- return response.data;
30
- }
31
-
32
- async findByOwnerId(
33
- params: Nomalism.shared.IFindByOwnerIdRequest,
34
- ): Promise<Nomalism.PromotionAssoc.IFindByOwnerIdResponse[]> {
35
- const response = await this.api.get(`${this.route}by_owner`, {
36
- params,
37
- });
38
- return response.data;
39
- }
40
-
41
- async findById(
42
- selector: Nomalism.shared.IFindByIdRequest,
43
- ): Promise<Nomalism.PromotionAssoc.IFindResponse | null> {
44
- const response = await this.api.get(`${this.route}${selector.id}`);
45
- return response.data;
46
- }
47
-
48
- async create(
49
- body: Nomalism.PromotionAssoc.ICreateRequest,
50
- ): Promise<Nomalism.PromotionAssoc.IFindByOwnerIdResponse> {
51
- const response = await this.api.post(`${this.route}`, body);
52
- return response.data;
53
- }
54
-
55
- async update(
56
- selector: Nomalism.shared.IFindByIdRequest,
57
- body: Nomalism.PromotionAssoc.IUpdateRequest,
58
- ): Promise<Nomalism.PromotionAssoc.IFindByOwnerIdResponse | null> {
59
- const response = await this.api.put(`${this.route}${selector.id}`, body);
60
- return response.data;
61
- }
62
-
63
- async deleteOne(
64
- selector: Nomalism.shared.IFindByIdRequest,
65
- ): Promise<Nomalism.PromotionAssoc.IFindByOwnerIdResponse | null> {
66
- const response = await this.api.delete(`${this.route}${selector.id}`);
67
- return response.data;
68
- }
69
- }
@@ -1,72 +0,0 @@
1
- import Nomalism from '@nomalism-com/types';
2
- import { AxiosInstance } from 'axios';
3
- import { IModuleConstructor } from '../../main';
4
-
5
- export default class Repository implements Nomalism.QueryList.IRepository {
6
- public route: string;
7
-
8
- public publicRoute: string;
9
-
10
- private api: AxiosInstance;
11
-
12
- constructor({ api, route, publicRoute }: IModuleConstructor) {
13
- this.api = api;
14
- this.route = route;
15
- this.publicRoute = publicRoute;
16
- }
17
-
18
- async find(): Promise<Nomalism.QueryList.IFindResponse[]> {
19
- const response = await this.api.get(`${this.route}`);
20
- return response.data;
21
- }
22
-
23
- async findById(
24
- selector: Nomalism.shared.IFindByIdRequest,
25
- ): Promise<Nomalism.QueryList.IFindResponse | null> {
26
- const response = await this.api.get(`${this.route}${selector.id}`);
27
- return response.data;
28
- }
29
-
30
- async create(body: Nomalism.QueryList.ICreateRequest): Promise<Nomalism.QueryList.IFindResponse> {
31
- const response = await this.api.post(`${this.route}`, body);
32
- return response.data;
33
- }
34
-
35
- async update(
36
- selector: Nomalism.shared.IFindByIdRequest,
37
- body: Nomalism.QueryList.IUpdateRequest,
38
- ): Promise<Nomalism.QueryList.IFindResponse | null> {
39
- const response = await this.api.put(`${this.route}${selector.id}`, body);
40
- return response.data;
41
- }
42
-
43
- async deleteOne(selector: Nomalism.shared.IFindByIdRequest): Promise<void> {
44
- const response = await this.api.delete(`${this.route}${selector.id}`);
45
- return response.data;
46
- }
47
-
48
- async execute(
49
- params: Nomalism.QueryList.IExecuteRequest,
50
- ): Promise<Nomalism.QueryList.IExecuteResponse> {
51
- const response = await this.api.get(`${this.route}execute`, { params });
52
- return response.data;
53
- }
54
-
55
- getQueryExecuteUrl({ query_id, output, token, ...data }: Nomalism.QueryList.IExecuteRequest) {
56
- const qs = new URLSearchParams();
57
-
58
- qs.set('query_id', query_id);
59
- qs.set('output', output);
60
- if (token) {
61
- qs.set('token', token);
62
- }
63
-
64
- Object.entries(data).forEach(([key, value]) => {
65
- if (typeof value === 'undefined') return;
66
- if (value === null) return;
67
- qs.set(key, value.toString());
68
- });
69
-
70
- return `${this.route}execute?${qs.toString()}`;
71
- }
72
- }