washday-sdk 1.6.44 → 1.6.45
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/api/index.js +3 -0
- package/dist/api/routes/get.js +14 -0
- package/dist/api/routes/index.js +1 -0
- package/dist/api/routes/patch.js +24 -0
- package/dist/api/routes/put.js +14 -0
- package/dist/interfaces/Route.js +1 -0
- package/package.json +1 -1
- package/src/api/index.ts +3 -0
- package/src/api/routes/get.ts +15 -4
- package/src/api/routes/index.ts +2 -1
- package/src/api/routes/patch.ts +21 -0
- package/src/api/routes/put.ts +14 -0
- package/src/interfaces/Api.ts +3 -0
- package/src/interfaces/Order.ts +10 -0
- package/src/interfaces/Route.ts +69 -0
package/dist/api/index.js
CHANGED
|
@@ -95,11 +95,14 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
|
|
|
95
95
|
getRoutesByStore: routesEndpoints.getModule.getRoutesByStore,
|
|
96
96
|
createRouteV2: routesEndpoints.postModule.createRouteV2,
|
|
97
97
|
getRouteByIdV2: routesEndpoints.getModule.getRouteByIdV2,
|
|
98
|
+
getClosePreview: routesEndpoints.getModule.getClosePreview,
|
|
98
99
|
deleteRouteById: routesEndpoints.deleteModule.deleteRouteById,
|
|
99
100
|
closeRouteById: routesEndpoints.putModule.closeRouteById,
|
|
101
|
+
closeRouteByIdV2: routesEndpoints.putModule.closeRouteByIdV2,
|
|
100
102
|
updateRouteById: routesEndpoints.putModule.updateRouteById,
|
|
101
103
|
getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
|
|
102
104
|
startRoute: routesEndpoints.postModule.startRoute,
|
|
105
|
+
reorderRouteOrders: routesEndpoints.patchModule.reorderRouteOrders,
|
|
103
106
|
});
|
|
104
107
|
this.publics = bindMethods(this, {
|
|
105
108
|
getOrderPublicReceipt: publicsEndpoints.getModule.getOrderPublicReceipt,
|
package/dist/api/routes/get.js
CHANGED
|
@@ -75,6 +75,20 @@ export const getRouteByIdV2 = function (routeId) {
|
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
|
+
export const getClosePreview = function (routeId) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
try {
|
|
81
|
+
const config = {
|
|
82
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
83
|
+
};
|
|
84
|
+
return yield this.axiosInstance.get(`${GET_ROUTE}/${routeId}/close-preview`, config);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error('Error fetching getClosePreview:', error);
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
};
|
|
78
92
|
export const getRoutesByDriver = function (query) {
|
|
79
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
94
|
try {
|
package/dist/api/routes/index.js
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
const GET_ROUTE = "api/routes";
|
|
11
|
+
export const reorderRouteOrders = function (routeId, data) {
|
|
12
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
13
|
+
try {
|
|
14
|
+
const config = {
|
|
15
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
16
|
+
};
|
|
17
|
+
return yield this.axiosInstance.patch(`${GET_ROUTE}/${routeId}/orders/reorder`, data, config);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Error fetching reorderRouteOrders:', error);
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
package/dist/api/routes/put.js
CHANGED
|
@@ -37,6 +37,20 @@ export const closeRouteById = function (routeId) {
|
|
|
37
37
|
}
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
+
export const closeRouteByIdV2 = function (routeId, data) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
try {
|
|
43
|
+
const config = {
|
|
44
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
45
|
+
};
|
|
46
|
+
return yield this.axiosInstance.put(`${GET_ROUTE}/${routeId}/close`, data || {}, config);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('Error fetching closeRouteByIdV2:', error);
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|
|
40
54
|
export const updateRouteById = function (routeId, data) {
|
|
41
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
56
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/src/api/index.ts
CHANGED
|
@@ -102,11 +102,14 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
|
|
|
102
102
|
getRoutesByStore: routesEndpoints.getModule.getRoutesByStore,
|
|
103
103
|
createRouteV2: routesEndpoints.postModule.createRouteV2,
|
|
104
104
|
getRouteByIdV2: routesEndpoints.getModule.getRouteByIdV2,
|
|
105
|
+
getClosePreview: routesEndpoints.getModule.getClosePreview,
|
|
105
106
|
deleteRouteById: routesEndpoints.deleteModule.deleteRouteById,
|
|
106
107
|
closeRouteById: routesEndpoints.putModule.closeRouteById,
|
|
108
|
+
closeRouteByIdV2: routesEndpoints.putModule.closeRouteByIdV2,
|
|
107
109
|
updateRouteById: routesEndpoints.putModule.updateRouteById,
|
|
108
110
|
getRoutesByDriver: routesEndpoints.getModule.getRoutesByDriver,
|
|
109
111
|
startRoute: routesEndpoints.postModule.startRoute,
|
|
112
|
+
reorderRouteOrders: routesEndpoints.patchModule.reorderRouteOrders,
|
|
110
113
|
});
|
|
111
114
|
this.publics = bindMethods(this, {
|
|
112
115
|
getOrderPublicReceipt: publicsEndpoints.getModule.getOrderPublicReceipt,
|
package/src/api/routes/get.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
-
import {
|
|
2
|
+
import { IRoute, IRouteClosePreview } from "../../interfaces/Route";
|
|
3
3
|
import { generateQueryParamsStr } from "../../utils/apiUtils";
|
|
4
4
|
import axiosInstance from "../axiosInstance";
|
|
5
5
|
const GET_SET_ROUTES_ORDERS = 'api/routes/orders';
|
|
@@ -54,7 +54,7 @@ export const getRoutesByStore = async function (this: WashdayClientInstance, sto
|
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
export const getRouteByIdV2 = async function (this: WashdayClientInstance, routeId: string): Promise<
|
|
57
|
+
export const getRouteByIdV2 = async function (this: WashdayClientInstance, routeId: string): Promise<{ data: { data: IRoute } }> {
|
|
58
58
|
try {
|
|
59
59
|
const config = {
|
|
60
60
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
@@ -66,9 +66,21 @@ export const getRouteByIdV2 = async function (this: WashdayClientInstance, route
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
export const getClosePreview = async function (this: WashdayClientInstance, routeId: string): Promise<{ data: { data: IRouteClosePreview } }> {
|
|
70
|
+
try {
|
|
71
|
+
const config = {
|
|
72
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
73
|
+
};
|
|
74
|
+
return await this.axiosInstance.get(`${GET_ROUTE}/${routeId}/close-preview`, config);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('Error fetching getClosePreview:', error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
69
81
|
export const getRoutesByDriver = async function (this: WashdayClientInstance, query: {
|
|
70
82
|
status?: string,
|
|
71
|
-
}): Promise<
|
|
83
|
+
}): Promise<{ data: { data: IRoute[] } }> {
|
|
72
84
|
try {
|
|
73
85
|
const config = {
|
|
74
86
|
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
@@ -83,4 +95,3 @@ export const getRoutesByDriver = async function (this: WashdayClientInstance, qu
|
|
|
83
95
|
}
|
|
84
96
|
};
|
|
85
97
|
|
|
86
|
-
|
package/src/api/routes/index.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { WashdayClientInstance } from "../../interfaces/Api";
|
|
2
|
+
|
|
3
|
+
const GET_ROUTE = "api/routes";
|
|
4
|
+
|
|
5
|
+
export const reorderRouteOrders = async function (
|
|
6
|
+
this: WashdayClientInstance,
|
|
7
|
+
routeId: string,
|
|
8
|
+
data: {
|
|
9
|
+
orders: Array<{ orderId: string; sortOrder: number }>,
|
|
10
|
+
}
|
|
11
|
+
): Promise<any> {
|
|
12
|
+
try {
|
|
13
|
+
const config = {
|
|
14
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
15
|
+
};
|
|
16
|
+
return await this.axiosInstance.patch(`${GET_ROUTE}/${routeId}/orders/reorder`, data, config);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error('Error fetching reorderRouteOrders:', error);
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
package/src/api/routes/put.ts
CHANGED
|
@@ -29,6 +29,20 @@ export const closeRouteById = async function (this: WashdayClientInstance, route
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
export const closeRouteByIdV2 = async function (this: WashdayClientInstance, routeId: string, data?: {
|
|
33
|
+
confirmAutoCompletePendingOrders?: boolean,
|
|
34
|
+
}): Promise<any> {
|
|
35
|
+
try {
|
|
36
|
+
const config = {
|
|
37
|
+
headers: { Authorization: `Bearer ${this.apiToken}` }
|
|
38
|
+
};
|
|
39
|
+
return await this.axiosInstance.put(`${GET_ROUTE}/${routeId}/close`, data || {}, config);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error('Error fetching closeRouteByIdV2:', error);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
32
46
|
export const updateRouteById = async function (this: WashdayClientInstance, routeId: string, data: {
|
|
33
47
|
driver?: string,
|
|
34
48
|
}): Promise<any> {
|
package/src/interfaces/Api.ts
CHANGED
|
@@ -103,11 +103,14 @@ export interface WashdayClientInstance {
|
|
|
103
103
|
getRoutesByStore: typeof routesEndpoints.getModule.getRoutesByStore,
|
|
104
104
|
createRouteV2: typeof routesEndpoints.postModule.createRouteV2,
|
|
105
105
|
getRouteByIdV2: typeof routesEndpoints.getModule.getRouteByIdV2,
|
|
106
|
+
getClosePreview: typeof routesEndpoints.getModule.getClosePreview,
|
|
106
107
|
deleteRouteById: typeof routesEndpoints.deleteModule.deleteRouteById,
|
|
107
108
|
closeRouteById: typeof routesEndpoints.putModule.closeRouteById,
|
|
109
|
+
closeRouteByIdV2: typeof routesEndpoints.putModule.closeRouteByIdV2,
|
|
108
110
|
updateRouteById: typeof routesEndpoints.putModule.updateRouteById,
|
|
109
111
|
getRoutesByDriver: typeof routesEndpoints.getModule.getRoutesByDriver,
|
|
110
112
|
startRoute: typeof routesEndpoints.postModule.startRoute,
|
|
113
|
+
reorderRouteOrders: typeof routesEndpoints.patchModule.reorderRouteOrders,
|
|
111
114
|
},
|
|
112
115
|
publics: {
|
|
113
116
|
getOrderPublicReceipt: typeof publicsEndpoints.getModule.getOrderPublicReceipt,
|
package/src/interfaces/Order.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IOrderProduct, IProduct } from "./Product";
|
|
|
3
3
|
import { ICashierBox, IStore, IStoreDiscount, ITaxConfig } from "./Store";
|
|
4
4
|
import { IUser } from "./User";
|
|
5
5
|
import { OrderProductLineStatus } from "../enum";
|
|
6
|
+
import { RouteOrderCompletionSource } from "./Route";
|
|
6
7
|
|
|
7
8
|
interface IDeliveryInfo {
|
|
8
9
|
date: Date,
|
|
@@ -45,6 +46,13 @@ export interface IOrderPaymentLines {
|
|
|
45
46
|
facturapiPaymentInvoiceID?: string | null,
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
export interface IOrderPhaseCompletion {
|
|
50
|
+
source: RouteOrderCompletionSource,
|
|
51
|
+
confirmedAt?: Date | null,
|
|
52
|
+
confirmedBy?: IUser | string | null,
|
|
53
|
+
routeId?: string | null,
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
export interface IOrder {
|
|
49
57
|
delivery: boolean,
|
|
50
58
|
pickup: boolean,
|
|
@@ -90,6 +98,8 @@ export interface IOrder {
|
|
|
90
98
|
status: string,
|
|
91
99
|
pickupRoute: string | null,
|
|
92
100
|
deliveryRoute: string | null,
|
|
101
|
+
pickupCompletion?: IOrderPhaseCompletion | null,
|
|
102
|
+
deliveryCompletion?: IOrderPhaseCompletion | null,
|
|
93
103
|
sequence?: string | null,
|
|
94
104
|
notifyBy: string,
|
|
95
105
|
stripePaymentIntentId?: string | null,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { IOrder } from "./Order";
|
|
2
|
+
import { IStore } from "./Store";
|
|
3
|
+
import { IUser } from "./User";
|
|
4
|
+
|
|
5
|
+
export type RouteStatus = "created" | "in_progress" | "finished" | "cancelled";
|
|
6
|
+
export type RouteOrderType = "pickup" | "delivery" | "legacy_unknown";
|
|
7
|
+
export type RouteOrderResult =
|
|
8
|
+
| "pending"
|
|
9
|
+
| "completed"
|
|
10
|
+
| "failed_attempt"
|
|
11
|
+
| "cancelled"
|
|
12
|
+
| "legacy_unknown";
|
|
13
|
+
export type RouteOrderCompletionSource =
|
|
14
|
+
| "driver_confirmed"
|
|
15
|
+
| "route_close_sweep"
|
|
16
|
+
| "legacy_unknown";
|
|
17
|
+
|
|
18
|
+
export interface IRouteOrder {
|
|
19
|
+
_id?: string;
|
|
20
|
+
order: IOrder | string;
|
|
21
|
+
type: RouteOrderType;
|
|
22
|
+
sortOrder: number;
|
|
23
|
+
active: boolean;
|
|
24
|
+
result: RouteOrderResult;
|
|
25
|
+
assignedAt: Date | string;
|
|
26
|
+
assignedBy?: IUser | string | null;
|
|
27
|
+
startedAt?: Date | string | null;
|
|
28
|
+
resolvedAt?: Date | string | null;
|
|
29
|
+
resolvedBy?: IUser | string | null;
|
|
30
|
+
completionSource?: RouteOrderCompletionSource | null;
|
|
31
|
+
completionConfirmedAt?: Date | string | null;
|
|
32
|
+
completionConfirmedBy?: IUser | string | null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface IRoute {
|
|
36
|
+
_id: string;
|
|
37
|
+
routeSequence?: number;
|
|
38
|
+
closedDate?: Date | string | null;
|
|
39
|
+
createdBy: IUser | string;
|
|
40
|
+
createdDate?: Date | string;
|
|
41
|
+
driver: IUser | string;
|
|
42
|
+
isActive: boolean;
|
|
43
|
+
orders: IRouteOrder[];
|
|
44
|
+
status: RouteStatus | string;
|
|
45
|
+
store: IStore | string;
|
|
46
|
+
startedDate?: Date | string | null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface IRouteClosePreviewPendingOrder {
|
|
50
|
+
routeOrderId: string;
|
|
51
|
+
orderId: string;
|
|
52
|
+
type: RouteOrderType;
|
|
53
|
+
sequence?: string | number | null;
|
|
54
|
+
status?: string | null;
|
|
55
|
+
willBecome?: string | null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface IRouteClosePreview {
|
|
59
|
+
routeId: string;
|
|
60
|
+
canClose: boolean;
|
|
61
|
+
summary: {
|
|
62
|
+
confirmed: number;
|
|
63
|
+
failed: number;
|
|
64
|
+
cancelled: number;
|
|
65
|
+
pendingActive: number;
|
|
66
|
+
};
|
|
67
|
+
pendingActiveOrders: IRouteClosePreviewPendingOrder[];
|
|
68
|
+
requiresExplicitConfirmation: boolean;
|
|
69
|
+
}
|