washday-sdk 1.6.82 → 1.6.84
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.
|
@@ -29,7 +29,7 @@ export const getAxiosInstance = (env = 'PROD', clientId = '', clientSecret = '')
|
|
|
29
29
|
});
|
|
30
30
|
// Add interceptor to set token and other options for every request
|
|
31
31
|
axiosInstance.interceptors.request.use((config) => {
|
|
32
|
-
const { token, responseType
|
|
32
|
+
const { token, responseType, contentDisposition } = config.params || {};
|
|
33
33
|
const { Authorization } = config.headers || {};
|
|
34
34
|
let contentType = config.headers['Content-Type'];
|
|
35
35
|
if (contentType === null || contentType === undefined) {
|
|
@@ -44,6 +44,9 @@ export const getAxiosInstance = (env = 'PROD', clientId = '', clientSecret = '')
|
|
|
44
44
|
if (responseType) {
|
|
45
45
|
config.responseType = responseType;
|
|
46
46
|
}
|
|
47
|
+
else if (!config.responseType) {
|
|
48
|
+
config.responseType = 'json';
|
|
49
|
+
}
|
|
47
50
|
if (contentDisposition) {
|
|
48
51
|
config.headers['Content-Disposition'] = contentDisposition;
|
|
49
52
|
}
|
package/package.json
CHANGED
package/src/api/axiosInstance.ts
CHANGED
|
@@ -34,7 +34,7 @@ export const getAxiosInstance = (env: string = 'PROD', clientId: string = '', cl
|
|
|
34
34
|
// Add interceptor to set token and other options for every request
|
|
35
35
|
axiosInstance.interceptors.request.use(
|
|
36
36
|
(config) => {
|
|
37
|
-
const { token, responseType
|
|
37
|
+
const { token, responseType, contentDisposition } = config.params || {};
|
|
38
38
|
const { Authorization } = config.headers || {};
|
|
39
39
|
let contentType = config.headers['Content-Type'];
|
|
40
40
|
if (contentType === null || contentType === undefined) {
|
|
@@ -48,6 +48,8 @@ export const getAxiosInstance = (env: string = 'PROD', clientId: string = '', cl
|
|
|
48
48
|
}
|
|
49
49
|
if (responseType) {
|
|
50
50
|
config.responseType = responseType;
|
|
51
|
+
} else if (!config.responseType) {
|
|
52
|
+
config.responseType = 'json';
|
|
51
53
|
}
|
|
52
54
|
if (contentDisposition) {
|
|
53
55
|
config.headers['Content-Disposition'] = contentDisposition;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ILabelTicketStructure,
|
|
3
|
+
IOutsourcedOrderTicketStructure,
|
|
3
4
|
ITicketForLaundryStructure,
|
|
4
5
|
ITicketStructure,
|
|
5
6
|
TicketVisualPreset,
|
|
@@ -65,6 +66,22 @@ const ticketForLaundryStructure: ITicketForLaundryStructure = {
|
|
|
65
66
|
tax_id_label: "RFC",
|
|
66
67
|
};
|
|
67
68
|
|
|
69
|
+
const outsourcedOrderTicketStructure: IOutsourcedOrderTicketStructure = {
|
|
70
|
+
showTotalPieces: false,
|
|
71
|
+
showEmisionDate: true,
|
|
72
|
+
showEmisionTime: true,
|
|
73
|
+
showLegend: true,
|
|
74
|
+
showStorePhone: true,
|
|
75
|
+
ticketLegendText: "Sin información de precios",
|
|
76
|
+
printLogoOnTicket: false,
|
|
77
|
+
showStoreName: true,
|
|
78
|
+
showOrderNotes: false,
|
|
79
|
+
customerNameFontSize: "medium",
|
|
80
|
+
orderFolioFontSizePreset: "large",
|
|
81
|
+
ticketLineSpacingPreset: "medium",
|
|
82
|
+
showPartnerPhone: true,
|
|
83
|
+
};
|
|
84
|
+
|
|
68
85
|
if (ticketStructure.orderFolioFontSizePreset !== "large") {
|
|
69
86
|
throw new Error("Ticket structure folio preset was not preserved");
|
|
70
87
|
}
|
|
@@ -88,3 +105,24 @@ if (labelTicketStructure.tax_id !== "J-507138330") {
|
|
|
88
105
|
if (ticketForLaundryStructure.tax_id_label !== "RFC") {
|
|
89
106
|
throw new Error("Laundry ticket structure tax ID label was not preserved");
|
|
90
107
|
}
|
|
108
|
+
|
|
109
|
+
if ("ticketPrintFormat" in outsourcedOrderTicketStructure) {
|
|
110
|
+
throw new Error("Outsourced order ticket structure must not expose print format");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const field of [
|
|
114
|
+
"showCustomerName",
|
|
115
|
+
"showCustomerPhone",
|
|
116
|
+
"showCreatedByName",
|
|
117
|
+
"showDeliveryDate",
|
|
118
|
+
"showDeliveryTime",
|
|
119
|
+
"showPickupInfo",
|
|
120
|
+
"showServiceType",
|
|
121
|
+
"showIssuerTaxInfo",
|
|
122
|
+
"tax_id",
|
|
123
|
+
"tax_id_label",
|
|
124
|
+
]) {
|
|
125
|
+
if (field in outsourcedOrderTicketStructure) {
|
|
126
|
+
throw new Error(`Outsourced order ticket structure must not expose ${field}`);
|
|
127
|
+
}
|
|
128
|
+
}
|
package/src/interfaces/Store.ts
CHANGED
|
@@ -93,6 +93,7 @@ export interface IStore {
|
|
|
93
93
|
cashierBoxes?: ICashierBox,
|
|
94
94
|
ticketStructure?: ITicketStructure | null,
|
|
95
95
|
ticketForLaundryStructure?: ITicketForLaundryStructure | null,
|
|
96
|
+
outsourcedOrderTicketStructure?: IOutsourcedOrderTicketStructure | null,
|
|
96
97
|
labelTicketStructure?: ILabelTicketStructure | null,
|
|
97
98
|
publicReceiptConfig?: IPublicReceiptConfig,
|
|
98
99
|
storeReceptionValidationConfig?: IStoreReceptionValidationConfig,
|
|
@@ -331,6 +332,29 @@ export interface ITicketStructure {
|
|
|
331
332
|
}
|
|
332
333
|
|
|
333
334
|
export interface ILabelTicketStructure extends ITicketStructure {}
|
|
335
|
+
|
|
336
|
+
export interface IOutsourcedOrderTicketStructure {
|
|
337
|
+
showTotalPieces: Boolean,
|
|
338
|
+
showEmisionDate: Boolean,
|
|
339
|
+
showEmisionTime: Boolean,
|
|
340
|
+
showLegend: Boolean,
|
|
341
|
+
showStorePhone: Boolean,
|
|
342
|
+
ticketLegendText: String,
|
|
343
|
+
printLogoOnTicket: Boolean,
|
|
344
|
+
showStoreName: Boolean,
|
|
345
|
+
showOrderNotes: Boolean,
|
|
346
|
+
customerNameFontSize?: TicketVisualPreset,
|
|
347
|
+
orderFolioFontSizePreset?: TicketVisualPreset,
|
|
348
|
+
ticketLineSpacingPreset?: TicketVisualPreset,
|
|
349
|
+
showPartnerPhone?: Boolean,
|
|
350
|
+
showOutsourcedOrderFolio?: Boolean,
|
|
351
|
+
showOutsourcedStatus?: Boolean,
|
|
352
|
+
showOutsourcedSentDate?: Boolean,
|
|
353
|
+
showOutsourcedReceivedDate?: Boolean,
|
|
354
|
+
showOutsourcedExternalOrderId?: Boolean,
|
|
355
|
+
showPartnerNotes?: Boolean,
|
|
356
|
+
}
|
|
357
|
+
|
|
334
358
|
export interface ITicketForLaundryStructure {
|
|
335
359
|
showTotalPieces: Boolean,
|
|
336
360
|
showEmisionDate: Boolean,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const mockUse = jest.fn();
|
|
2
|
+
const mockCreate = jest.fn(() => ({
|
|
3
|
+
interceptors: {
|
|
4
|
+
request: {
|
|
5
|
+
use: mockUse,
|
|
6
|
+
},
|
|
7
|
+
},
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
jest.mock("axios", () => ({
|
|
11
|
+
__esModule: true,
|
|
12
|
+
default: {
|
|
13
|
+
create: mockCreate,
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
describe("SDK axios instance request interceptor", () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
mockUse.mockClear();
|
|
20
|
+
mockCreate.mockClear();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("preserves top-level responseType for binary downloads", async () => {
|
|
24
|
+
const { getAxiosInstance } = await import("../src/api/axiosInstance");
|
|
25
|
+
|
|
26
|
+
getAxiosInstance("DEV", "web-pos", "");
|
|
27
|
+
|
|
28
|
+
const requestInterceptor = mockUse.mock.calls[0][0];
|
|
29
|
+
const config = requestInterceptor({
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: "Bearer token-123",
|
|
32
|
+
},
|
|
33
|
+
responseType: "arraybuffer",
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
expect(config.responseType).toBe("arraybuffer");
|
|
37
|
+
});
|
|
38
|
+
});
|