washday-sdk 1.6.79 → 1.6.80
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/package.json +1 -1
- package/src/api/index.ts +2 -0
- package/src/api/routes/get.ts +61 -0
- package/src/interfaces/Api.ts +2 -0
- package/src/interfaces/Company.ts +27 -0
- package/src/interfaces/Product.ts +16 -0
- package/test/routes.multistore.test.ts +61 -1
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -126,6 +126,8 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
126
126
|
updateRouteById: routesEndpoints.putModule.updateRouteById,
|
|
127
127
|
getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
|
|
128
128
|
getRoutes: routesEndpoints.getModule.getRoutes,
|
|
129
|
+
getRoutesPage: routesEndpoints.getModule.getRoutesPage,
|
|
130
|
+
getRoutesByStorePage: routesEndpoints.getModule.getRoutesByStorePage,
|
|
129
131
|
startRoute: routesEndpoints.postModule.startRoute,
|
|
130
132
|
reorderRouteOrders: routesEndpoints.patchModule.reorderRouteOrders,
|
|
131
133
|
});
|
package/src/api/routes/get.ts
CHANGED
|
@@ -18,6 +18,25 @@ export type RouteListQuery = {
|
|
|
18
18
|
createdTo?: string,
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
export type RoutePageQuery = RouteListQuery & {
|
|
22
|
+
pageNum?: number | string,
|
|
23
|
+
limit?: number | string,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type RouteStorePageQuery = {
|
|
27
|
+
pageNum?: number | string,
|
|
28
|
+
limit?: number | string,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type RouteListPageResponse = {
|
|
32
|
+
routes: IRoute[],
|
|
33
|
+
totalRowsCount: number,
|
|
34
|
+
totalPages: number,
|
|
35
|
+
pageNum: number,
|
|
36
|
+
limit: number,
|
|
37
|
+
hasNextPage: boolean,
|
|
38
|
+
};
|
|
39
|
+
|
|
21
40
|
//@deprecated
|
|
22
41
|
export const getOrdersForRoute = async function (this: WashdayClientInstance, params: {
|
|
23
42
|
store: string | undefined,
|
|
@@ -65,6 +84,26 @@ export const getRoutesByStore = async function (this: WashdayClientInstance, sto
|
|
|
65
84
|
}
|
|
66
85
|
};
|
|
67
86
|
|
|
87
|
+
export const getRoutesByStorePage = async function (
|
|
88
|
+
this: WashdayClientInstance,
|
|
89
|
+
storeId: string,
|
|
90
|
+
query: RouteStorePageQuery = {}
|
|
91
|
+
): Promise<{ data: { data: RouteListPageResponse } }> {
|
|
92
|
+
try {
|
|
93
|
+
const config = {
|
|
94
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
95
|
+
};
|
|
96
|
+
const queryParams = generateQueryParamsStr([
|
|
97
|
+
'pageNum',
|
|
98
|
+
'limit',
|
|
99
|
+
], query);
|
|
100
|
+
return await this.axiosInstance.get(`${GET_STORE_ROUTES_BY_ID.replace(':id', storeId)}?${queryParams}`, config);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('Error fetching getRoutesByStorePage:', error);
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
68
107
|
export const getRouteByIdV2 = async function (this: WashdayClientInstance, routeId: string): Promise<{ data: { data: IRoute } }> {
|
|
69
108
|
try {
|
|
70
109
|
const config = {
|
|
@@ -129,3 +168,25 @@ export const getRoutes = async function (this: WashdayClientInstance, query: Rou
|
|
|
129
168
|
throw error;
|
|
130
169
|
}
|
|
131
170
|
};
|
|
171
|
+
|
|
172
|
+
export const getRoutesPage = async function (this: WashdayClientInstance, query: RoutePageQuery = {}): Promise<{ data: { data: RouteListPageResponse } }> {
|
|
173
|
+
try {
|
|
174
|
+
const config = {
|
|
175
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
176
|
+
};
|
|
177
|
+
const queryParams = generateQueryParamsStr([
|
|
178
|
+
'scope',
|
|
179
|
+
'storeIds',
|
|
180
|
+
'status',
|
|
181
|
+
'driver',
|
|
182
|
+
'createdFrom',
|
|
183
|
+
'createdTo',
|
|
184
|
+
'pageNum',
|
|
185
|
+
'limit',
|
|
186
|
+
], query);
|
|
187
|
+
return await this.axiosInstance.get(`${GET_ROUTE}?${queryParams}`, config);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error('Error fetching getRoutesPage:', error);
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
};
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -128,6 +128,8 @@ export interface WashdayClientInstance {
|
|
|
128
128
|
updateRouteById: typeof routesEndpoints.putModule.updateRouteById,
|
|
129
129
|
getRoutesByDriver: typeof routesEndpoints.getModule.getRoutesByDriver,
|
|
130
130
|
getRoutes: typeof routesEndpoints.getModule.getRoutes,
|
|
131
|
+
getRoutesPage: typeof routesEndpoints.getModule.getRoutesPage,
|
|
132
|
+
getRoutesByStorePage: typeof routesEndpoints.getModule.getRoutesByStorePage,
|
|
131
133
|
startRoute: typeof routesEndpoints.postModule.startRoute,
|
|
132
134
|
reorderRouteOrders: typeof routesEndpoints.patchModule.reorderRouteOrders,
|
|
133
135
|
},
|
|
@@ -174,6 +174,13 @@ export interface ApplySubscriptionPlanChangeResponse {
|
|
|
174
174
|
|
|
175
175
|
export interface IStripeSettings {
|
|
176
176
|
planPriceId?: string | null;
|
|
177
|
+
/**
|
|
178
|
+
* Legacy/subscription billing CFDI fields.
|
|
179
|
+
* Operational Invoice Module usage billing should prefer
|
|
180
|
+
* InvoiceModuleProviderSettings.billingConfig.stripeSubscriptionItemId,
|
|
181
|
+
* then fall back to company.stripeSettings.stripeCFDISubItemID.
|
|
182
|
+
* Do not mix operational module country with subscription billing fiscal country.
|
|
183
|
+
*/
|
|
177
184
|
stripeCFDISubID: string | null;
|
|
178
185
|
stripeCFDISubItemID: string | null;
|
|
179
186
|
cfdiBillingMode?: CFDIBillingMode;
|
|
@@ -187,12 +194,27 @@ export interface IStripeSettings {
|
|
|
187
194
|
|
|
188
195
|
export interface ICompanyTaxInfo {
|
|
189
196
|
name?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Legacy CFDI issuer legal name.
|
|
199
|
+
* Forward replacement: InvoiceModuleIssuerProfile.cfdi.legalName.
|
|
200
|
+
* Still used as fallback for CFDI issuer/profile compatibility.
|
|
201
|
+
*/
|
|
190
202
|
legal_name?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Legacy CFDI issuer tax system.
|
|
205
|
+
* Forward replacement: InvoiceModuleIssuerProfile.cfdi.taxSystem.
|
|
206
|
+
* Still used as fallback for CFDI issuer/profile compatibility.
|
|
207
|
+
*/
|
|
191
208
|
tax_system?: string;
|
|
192
209
|
website?: string;
|
|
193
210
|
support_email?: string;
|
|
194
211
|
phone?: string;
|
|
195
212
|
address?: {
|
|
213
|
+
/**
|
|
214
|
+
* Legacy CFDI issuer postal code.
|
|
215
|
+
* Forward replacement: InvoiceModuleIssuerProfile.cfdi.zip.
|
|
216
|
+
* Still used as fallback for CFDI issuer/profile compatibility.
|
|
217
|
+
*/
|
|
196
218
|
zip?: string;
|
|
197
219
|
street?: string;
|
|
198
220
|
exterior?: string;
|
|
@@ -201,5 +223,10 @@ export interface ICompanyTaxInfo {
|
|
|
201
223
|
enabled: boolean;
|
|
202
224
|
email: string;
|
|
203
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* Legacy global-payment-method CFDI product defaults.
|
|
228
|
+
* Future target: provider/standard-specific Invoice Module settings.
|
|
229
|
+
* Keep until global CFDI settings are migrated.
|
|
230
|
+
*/
|
|
204
231
|
globalPaymentMethodCfdiSettings?: GlobalPaymentMethodCfdiSettings;
|
|
205
232
|
}
|
|
@@ -30,6 +30,10 @@ export interface IPriceOption {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface IProductCfdiInvoiceModuleSettings {
|
|
33
|
+
/**
|
|
34
|
+
* Forward per-standard fiscal metadata for Mexico CFDI.
|
|
35
|
+
* Current Mexico runtime should prefer these fields over legacy product invoice_* fields.
|
|
36
|
+
*/
|
|
33
37
|
description?: string,
|
|
34
38
|
productKey?: string,
|
|
35
39
|
unitKey?: string,
|
|
@@ -37,6 +41,9 @@ export interface IProductCfdiInvoiceModuleSettings {
|
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export interface IProductSunatInvoiceModuleSettings {
|
|
44
|
+
/**
|
|
45
|
+
* Forward per-standard fiscal metadata reserved/prepared for Peru SUNAT provider runtime.
|
|
46
|
+
*/
|
|
40
47
|
enabled?: boolean,
|
|
41
48
|
}
|
|
42
49
|
|
|
@@ -67,6 +74,15 @@ export interface IProduct {
|
|
|
67
74
|
store: IStore | string,
|
|
68
75
|
order: number,
|
|
69
76
|
productSupplies?: [IProductSupplies],
|
|
77
|
+
/**
|
|
78
|
+
* Legacy CFDI product fiscal metadata.
|
|
79
|
+
* Forward replacements:
|
|
80
|
+
* - invoiceModuleSettings.cfdi.description
|
|
81
|
+
* - invoiceModuleSettings.cfdi.productKey
|
|
82
|
+
* - invoiceModuleSettings.cfdi.unitKey
|
|
83
|
+
* - invoiceModuleSettings.cfdi.unitName
|
|
84
|
+
* Still used as fallback by CFDI builders/resolvers.
|
|
85
|
+
*/
|
|
70
86
|
invoice_description?: string,
|
|
71
87
|
invoice_product_key?: string,
|
|
72
88
|
invoice_product_unit_key?: string,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getRoutes, getRoutesByDriver } from "../src/api/routes/get";
|
|
1
|
+
import { getRoutes, getRoutesByDriver, getRoutesByStorePage, getRoutesPage } from "../src/api/routes/get";
|
|
2
2
|
import { createRouteV2 } from "../src/api/routes/post";
|
|
3
3
|
import { WashdayClient } from "../src";
|
|
4
4
|
|
|
@@ -95,6 +95,47 @@ describe("routes multi-store api", () => {
|
|
|
95
95
|
);
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
+
it("lists paginated company routes through the root routes endpoint", async () => {
|
|
99
|
+
const get = jest.fn().mockResolvedValue({ data: { data: { routes: [] } } });
|
|
100
|
+
const client = {
|
|
101
|
+
apiToken: "token-123",
|
|
102
|
+
axiosInstance: { get },
|
|
103
|
+
} as any;
|
|
104
|
+
|
|
105
|
+
await getRoutesPage.call(client, {
|
|
106
|
+
scope: "company",
|
|
107
|
+
pageNum: 1,
|
|
108
|
+
limit: 9,
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(get).toHaveBeenCalledWith(
|
|
112
|
+
"api/routes?scope=company&pageNum=1&limit=9",
|
|
113
|
+
{
|
|
114
|
+
headers: { Authorization: "Bearer token-123" },
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("lists paginated store routes through the store routes endpoint", async () => {
|
|
120
|
+
const get = jest.fn().mockResolvedValue({ data: { data: { routes: [] } } });
|
|
121
|
+
const client = {
|
|
122
|
+
apiToken: "token-123",
|
|
123
|
+
axiosInstance: { get },
|
|
124
|
+
} as any;
|
|
125
|
+
|
|
126
|
+
await getRoutesByStorePage.call(client, "store-a", {
|
|
127
|
+
pageNum: 2,
|
|
128
|
+
limit: 9,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
expect(get).toHaveBeenCalledWith(
|
|
132
|
+
"api/stores/store-a/routes?pageNum=2&limit=9",
|
|
133
|
+
{
|
|
134
|
+
headers: { Authorization: "Bearer token-123" },
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
});
|
|
138
|
+
|
|
98
139
|
it("exposes getRoutes through the WashdayClient routes module", async () => {
|
|
99
140
|
const get = jest.fn().mockResolvedValue({ data: { data: [] } });
|
|
100
141
|
const client = new WashdayClient("token-123", "DEV") as any;
|
|
@@ -108,4 +149,23 @@ describe("routes multi-store api", () => {
|
|
|
108
149
|
headers: { Authorization: "Bearer token-123" },
|
|
109
150
|
});
|
|
110
151
|
});
|
|
152
|
+
|
|
153
|
+
it("exposes paginated route list helpers through the WashdayClient routes module", async () => {
|
|
154
|
+
const get = jest.fn().mockResolvedValue({ data: { data: { routes: [] } } });
|
|
155
|
+
const client = new WashdayClient("token-123", "DEV") as any;
|
|
156
|
+
client.axiosInstance = { get };
|
|
157
|
+
|
|
158
|
+
expect(typeof client.routes.getRoutesPage).toBe("function");
|
|
159
|
+
expect(typeof client.routes.getRoutesByStorePage).toBe("function");
|
|
160
|
+
|
|
161
|
+
await client.routes.getRoutesPage({ scope: "company", pageNum: 0, limit: 9 });
|
|
162
|
+
await client.routes.getRoutesByStorePage("store-a", { pageNum: 0, limit: 9 });
|
|
163
|
+
|
|
164
|
+
expect(get).toHaveBeenNthCalledWith(1, "api/routes?scope=company&pageNum=0&limit=9", {
|
|
165
|
+
headers: { Authorization: "Bearer token-123" },
|
|
166
|
+
});
|
|
167
|
+
expect(get).toHaveBeenNthCalledWith(2, "api/stores/store-a/routes?pageNum=0&limit=9", {
|
|
168
|
+
headers: { Authorization: "Bearer token-123" },
|
|
169
|
+
});
|
|
170
|
+
});
|
|
111
171
|
});
|