@dapex-tech/elite-online-services 0.0.7 → 0.0.10
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/createClient.d.ts +19 -0
- package/createClient.js +1 -2
- package/models/AdminDto.d.ts +18 -6
- package/models/{LoginDto.d.ts → AdminLoginDto.d.ts} +1 -1
- package/models/AdminUpdateDto.d.ts +0 -4
- package/models/CustomerDto.d.ts +66 -0
- package/models/{CreateUserLocationDto.d.ts → CustomerLocationCreateDto.d.ts} +2 -2
- package/models/CustomerLocationDto.d.ts +34 -0
- package/models/{UpdateUserLocationDto.d.ts → CustomerLocationUpdateDto.d.ts} +2 -2
- package/models/CustomerLoginDto.d.ts +18 -0
- package/models/{UserDto.d.ts → CustomerUpdatedDto.d.ts} +5 -5
- package/models/{VerifyUserAccountDto.d.ts → CustomerVerifyAccountDto.d.ts} +5 -1
- package/models/DriverDto.d.ts +16 -4
- package/models/{EmailPhoneLoginDto.d.ts → DriverLoginDto.d.ts} +2 -6
- package/models/DriverTripActions.d.ts +10 -0
- package/models/DriverTripActions.js +18 -0
- package/models/DriverUpdateDto.d.ts +6 -6
- package/models/GenerateResetCodeDto.d.ts +6 -2
- package/models/GenerateVerificationCodeDto.d.ts +10 -0
- package/models/PaymentDto.d.ts +18 -0
- package/models/ResetPasswordDto.d.ts +14 -0
- package/models/TripAssignDriverDto.d.ts +6 -0
- package/models/TripDto.d.ts +108 -0
- package/models/TripLocationPointDto.d.ts +26 -0
- package/models/TripUpdateDriverAssignmentModeDto.d.ts +6 -0
- package/models/TripUpdateDto.d.ts +38 -0
- package/models/TripUpdateTripsStatusDto.d.ts +6 -0
- package/models/ValidateResetCodeDto.d.ts +14 -0
- package/models/ValidateResetCodeDto.js +2 -0
- package/models/index.d.ts +20 -18
- package/models/index.js +20 -18
- package/package.json +1 -1
- package/services/AdminAuthService.d.ts +28 -3
- package/services/AdminAuthService.js +57 -1
- package/services/AdminCustomerService.d.ts +50 -0
- package/services/AdminCustomerService.js +119 -0
- package/services/AdminDriversService.d.ts +51 -0
- package/services/AdminDriversService.js +122 -0
- package/services/AdminService.d.ts +0 -44
- package/services/AdminService.js +0 -100
- package/services/AdminTripsService.d.ts +59 -0
- package/services/AdminTripsService.js +150 -0
- package/services/CustomerLocationsService.d.ts +41 -0
- package/services/CustomerLocationsService.js +93 -0
- package/services/CustomerTripsService.d.ts +63 -0
- package/services/CustomerTripsService.js +162 -0
- package/services/CustomersAuthService.d.ts +88 -0
- package/services/{UserAuthService.js → CustomersAuthService.js} +24 -21
- package/services/CustomersService.d.ts +17 -0
- package/services/CustomersService.js +41 -0
- package/services/DriverAuthService.d.ts +6 -6
- package/services/DriverAuthService.js +1 -1
- package/services/DriverTripsService.d.ts +49 -0
- package/services/DriverTripsService.js +121 -0
- package/services/DriversService.d.ts +9 -53
- package/services/DriversService.js +14 -132
- package/services/MainService.d.ts +5 -0
- package/services/MainService.js +10 -0
- package/services/index.d.ts +8 -3
- package/services/index.js +8 -3
- package/socketService.d.ts +54 -0
- package/socketService.js +91 -96
- package/models/CreateServiceOrderDto.d.ts +0 -46
- package/models/CreateStreetPickupDto.d.ts +0 -10
- package/models/GenerateUserResetCodeDto.d.ts +0 -6
- package/models/GenerateUserVerificationCodeDto.d.ts +0 -6
- package/models/ResetDriverPasswordDto.d.ts +0 -10
- package/models/ResetUserPasswordDto.d.ts +0 -10
- package/models/UpdateDriverStatusDto.d.ts +0 -10
- package/models/UpdateDriverTripStatusDto.d.ts +0 -14
- package/models/UpdateTripStatusDto.d.ts +0 -10
- package/models/UserUpdatedDto.d.ts +0 -18
- package/models/ValidateDriverResetCodeDto.d.ts +0 -10
- package/models/ValidateUserResetCodeDto.d.ts +0 -10
- package/services/CatalogsService.d.ts +0 -67
- package/services/CatalogsService.js +0 -142
- package/services/UserAuthService.d.ts +0 -85
- package/services/UsersService.d.ts +0 -81
- package/services/UsersService.js +0 -198
- /package/models/{CreateServiceOrderDto.js → AdminLoginDto.js} +0 -0
- /package/models/{CreateStreetPickupDto.js → CustomerDto.js} +0 -0
- /package/models/{CreateUserLocationDto.js → CustomerLocationCreateDto.js} +0 -0
- /package/models/{EmailPhoneLoginDto.js → CustomerLocationDto.js} +0 -0
- /package/models/{GenerateUserResetCodeDto.js → CustomerLocationUpdateDto.js} +0 -0
- /package/models/{GenerateUserVerificationCodeDto.js → CustomerLoginDto.js} +0 -0
- /package/models/{LoginDto.js → CustomerUpdatedDto.js} +0 -0
- /package/models/{ResetDriverPasswordDto.js → CustomerVerifyAccountDto.js} +0 -0
- /package/models/{ResetUserPasswordDto.js → DriverLoginDto.js} +0 -0
- /package/models/{UpdateDriverStatusDto.js → GenerateVerificationCodeDto.js} +0 -0
- /package/models/{UpdateDriverTripStatusDto.js → PaymentDto.js} +0 -0
- /package/models/{UpdateTripStatusDto.js → ResetPasswordDto.js} +0 -0
- /package/models/{UpdateUserLocationDto.js → TripAssignDriverDto.js} +0 -0
- /package/models/{UserDto.js → TripDto.js} +0 -0
- /package/models/{UserUpdatedDto.js → TripLocationPointDto.js} +0 -0
- /package/models/{ValidateDriverResetCodeDto.js → TripUpdateDriverAssignmentModeDto.js} +0 -0
- /package/models/{ValidateUserResetCodeDto.js → TripUpdateDto.js} +0 -0
- /package/models/{VerifyUserAccountDto.js → TripUpdateTripsStatusDto.js} +0 -0
|
@@ -5,115 +5,28 @@ const OpenAPI_1 = require("../core/OpenAPI");
|
|
|
5
5
|
const request_1 = require("../core/request");
|
|
6
6
|
class DriversService {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param requestBody
|
|
10
|
-
* @returns any Driver created successfully.
|
|
11
|
-
* @throws ApiError
|
|
12
|
-
*/
|
|
13
|
-
static create(requestBody) {
|
|
14
|
-
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
15
|
-
method: 'POST',
|
|
16
|
-
url: '/drivers',
|
|
17
|
-
body: requestBody,
|
|
18
|
-
mediaType: 'application/json',
|
|
19
|
-
errors: {
|
|
20
|
-
401: `Unauthorized`,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get all drivers
|
|
26
|
-
* @param search Text to search for in name, surname, phone number, license or type
|
|
27
|
-
* @param order Sorting options
|
|
28
|
-
* @returns any List of drivers
|
|
29
|
-
* @throws ApiError
|
|
30
|
-
*/
|
|
31
|
-
static findAll(search, order) {
|
|
32
|
-
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
33
|
-
method: 'GET',
|
|
34
|
-
url: '/drivers',
|
|
35
|
-
query: {
|
|
36
|
-
'search': search,
|
|
37
|
-
'order': order,
|
|
38
|
-
},
|
|
39
|
-
errors: {
|
|
40
|
-
401: `Unauthorized`,
|
|
41
|
-
},
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Get driver last location by ID
|
|
46
|
-
* @param id
|
|
47
|
-
* @returns any Driver last location retrieved successfully.
|
|
48
|
-
* @throws ApiError
|
|
49
|
-
*/
|
|
50
|
-
static getLastLocation(id) {
|
|
51
|
-
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
52
|
-
method: 'GET',
|
|
53
|
-
url: '/drivers/last-location/{id}',
|
|
54
|
-
path: {
|
|
55
|
-
'id': id,
|
|
56
|
-
},
|
|
57
|
-
errors: {
|
|
58
|
-
401: `Unauthorized`,
|
|
59
|
-
404: `Driver not found`,
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Get a single driver by ID
|
|
65
|
-
* @param id
|
|
66
|
-
* @returns any Driver found
|
|
67
|
-
* @throws ApiError
|
|
68
|
-
*/
|
|
69
|
-
static findById(id) {
|
|
70
|
-
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
71
|
-
method: 'GET',
|
|
72
|
-
url: '/drivers/{id}',
|
|
73
|
-
path: {
|
|
74
|
-
'id': id,
|
|
75
|
-
},
|
|
76
|
-
errors: {
|
|
77
|
-
401: `Unauthorized`,
|
|
78
|
-
404: `Driver not found`,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Update a driver by ID
|
|
84
|
-
* @param id
|
|
8
|
+
* Update the current driver
|
|
85
9
|
* @param requestBody
|
|
86
10
|
* @returns any Driver updated successfully.
|
|
87
11
|
* @throws ApiError
|
|
88
12
|
*/
|
|
89
|
-
static update(
|
|
13
|
+
static update(requestBody) {
|
|
90
14
|
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
91
15
|
method: 'PATCH',
|
|
92
|
-
url: '/drivers/
|
|
93
|
-
path: {
|
|
94
|
-
'id': id,
|
|
95
|
-
},
|
|
16
|
+
url: '/drivers/me',
|
|
96
17
|
body: requestBody,
|
|
97
18
|
mediaType: 'application/json',
|
|
98
|
-
errors: {
|
|
99
|
-
401: `Unauthorized`,
|
|
100
|
-
404: `Driver not found`,
|
|
101
|
-
},
|
|
102
19
|
});
|
|
103
20
|
}
|
|
104
21
|
/**
|
|
105
|
-
* Delete
|
|
106
|
-
* @param id
|
|
22
|
+
* Delete the current driver
|
|
107
23
|
* @returns any Driver deleted successfully.
|
|
108
24
|
* @throws ApiError
|
|
109
25
|
*/
|
|
110
|
-
static remove(
|
|
26
|
+
static remove() {
|
|
111
27
|
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
112
28
|
method: 'DELETE',
|
|
113
|
-
url: '/drivers/
|
|
114
|
-
path: {
|
|
115
|
-
'id': id,
|
|
116
|
-
},
|
|
29
|
+
url: '/drivers/me',
|
|
117
30
|
errors: {
|
|
118
31
|
401: `Unauthorized`,
|
|
119
32
|
404: `Driver not found`,
|
|
@@ -121,18 +34,14 @@ class DriversService {
|
|
|
121
34
|
});
|
|
122
35
|
}
|
|
123
36
|
/**
|
|
124
|
-
* Update
|
|
125
|
-
* @param id
|
|
37
|
+
* Update the current driver online status
|
|
126
38
|
* @returns any Driver online status updated successfully.
|
|
127
39
|
* @throws ApiError
|
|
128
40
|
*/
|
|
129
|
-
static updateOnlineStatus(
|
|
41
|
+
static updateOnlineStatus() {
|
|
130
42
|
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
131
43
|
method: 'PATCH',
|
|
132
|
-
url: '/drivers/online-status
|
|
133
|
-
path: {
|
|
134
|
-
'id': id,
|
|
135
|
-
},
|
|
44
|
+
url: '/drivers/online-status',
|
|
136
45
|
errors: {
|
|
137
46
|
401: `Unauthorized`,
|
|
138
47
|
404: `Driver not found`,
|
|
@@ -140,18 +49,14 @@ class DriversService {
|
|
|
140
49
|
});
|
|
141
50
|
}
|
|
142
51
|
/**
|
|
143
|
-
* Deactivate
|
|
144
|
-
* @param id
|
|
52
|
+
* Deactivate the current driver account
|
|
145
53
|
* @returns any Driver account deactivated successfully.
|
|
146
54
|
* @throws ApiError
|
|
147
55
|
*/
|
|
148
|
-
static deactivateAccount(
|
|
56
|
+
static deactivateAccount() {
|
|
149
57
|
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
150
58
|
method: 'PATCH',
|
|
151
|
-
url: '/drivers/deactivate-account
|
|
152
|
-
path: {
|
|
153
|
-
'id': id,
|
|
154
|
-
},
|
|
59
|
+
url: '/drivers/deactivate-account',
|
|
155
60
|
errors: {
|
|
156
61
|
401: `Unauthorized`,
|
|
157
62
|
404: `Driver not found`,
|
|
@@ -160,41 +65,18 @@ class DriversService {
|
|
|
160
65
|
}
|
|
161
66
|
/**
|
|
162
67
|
* Update a driver account status by ID
|
|
163
|
-
* @param id
|
|
164
68
|
* @returns any Driver account status updated successfully.
|
|
165
69
|
* @throws ApiError
|
|
166
70
|
*/
|
|
167
|
-
static updateAccountStatus(
|
|
71
|
+
static updateAccountStatus() {
|
|
168
72
|
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
169
73
|
method: 'PATCH',
|
|
170
|
-
url: '/drivers/account-status
|
|
171
|
-
path: {
|
|
172
|
-
'id': id,
|
|
173
|
-
},
|
|
74
|
+
url: '/drivers/account-status',
|
|
174
75
|
errors: {
|
|
175
76
|
401: `Unauthorized`,
|
|
176
77
|
404: `Driver not found`,
|
|
177
78
|
},
|
|
178
79
|
});
|
|
179
80
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Update trip status, drivers are only allowed to update the status to IN_PROGRESS or COMPLETED.
|
|
182
|
-
* @param requestBody
|
|
183
|
-
* @returns any Trip status updated successfully
|
|
184
|
-
* @throws ApiError
|
|
185
|
-
*/
|
|
186
|
-
static updateTripStatus(requestBody) {
|
|
187
|
-
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
188
|
-
method: 'PATCH',
|
|
189
|
-
url: '/drivers/trips/status',
|
|
190
|
-
body: requestBody,
|
|
191
|
-
mediaType: 'application/json',
|
|
192
|
-
errors: {
|
|
193
|
-
400: `Bad Request`,
|
|
194
|
-
401: `Unauthorized`,
|
|
195
|
-
404: `Service order not found`,
|
|
196
|
-
},
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
81
|
}
|
|
200
82
|
exports.DriversService = DriversService;
|
package/services/MainService.js
CHANGED
|
@@ -14,5 +14,15 @@ class MainService {
|
|
|
14
14
|
url: '/',
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* @returns any
|
|
19
|
+
* @throws ApiError
|
|
20
|
+
*/
|
|
21
|
+
static healthCheck() {
|
|
22
|
+
return (0, request_1.request)(OpenAPI_1.OpenAPI, {
|
|
23
|
+
method: 'GET',
|
|
24
|
+
url: '/health',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
exports.MainService = MainService;
|
package/services/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
export * from './AdminAuthService';
|
|
2
|
+
export * from './AdminCustomerService';
|
|
3
|
+
export * from './AdminDriversService';
|
|
2
4
|
export * from './AdminService';
|
|
3
|
-
export * from './
|
|
5
|
+
export * from './AdminTripsService';
|
|
6
|
+
export * from './CustomerLocationsService';
|
|
7
|
+
export * from './CustomerTripsService';
|
|
8
|
+
export * from './CustomersAuthService';
|
|
9
|
+
export * from './CustomersService';
|
|
4
10
|
export * from './DriverAuthService';
|
|
11
|
+
export * from './DriverTripsService';
|
|
5
12
|
export * from './DriversService';
|
|
6
13
|
export * from './MainService';
|
|
7
|
-
export * from './UserAuthService';
|
|
8
|
-
export * from './UsersService';
|
package/services/index.js
CHANGED
|
@@ -15,10 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AdminAuthService"), exports);
|
|
18
|
+
__exportStar(require("./AdminCustomerService"), exports);
|
|
19
|
+
__exportStar(require("./AdminDriversService"), exports);
|
|
18
20
|
__exportStar(require("./AdminService"), exports);
|
|
19
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./AdminTripsService"), exports);
|
|
22
|
+
__exportStar(require("./CustomerLocationsService"), exports);
|
|
23
|
+
__exportStar(require("./CustomerTripsService"), exports);
|
|
24
|
+
__exportStar(require("./CustomersAuthService"), exports);
|
|
25
|
+
__exportStar(require("./CustomersService"), exports);
|
|
20
26
|
__exportStar(require("./DriverAuthService"), exports);
|
|
27
|
+
__exportStar(require("./DriverTripsService"), exports);
|
|
21
28
|
__exportStar(require("./DriversService"), exports);
|
|
22
29
|
__exportStar(require("./MainService"), exports);
|
|
23
|
-
__exportStar(require("./UserAuthService"), exports);
|
|
24
|
-
__exportStar(require("./UsersService"), exports);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DriverLocationMap, DriverLocationWithClientID } from './types';
|
|
2
|
+
export declare class SocketService {
|
|
3
|
+
private socket;
|
|
4
|
+
constructor(baseUrl: string, token?: string);
|
|
5
|
+
connect(): void;
|
|
6
|
+
disconnect(): void;
|
|
7
|
+
isConnected(): boolean;
|
|
8
|
+
isActive(): boolean;
|
|
9
|
+
on<T = any>(event: string, cb: (data: T) => void): void;
|
|
10
|
+
off(event: string, cb?: (...args: any[]) => void): void;
|
|
11
|
+
emit<T = any>(event: string, data: T): void;
|
|
12
|
+
sendMessage(message: string): void;
|
|
13
|
+
onMessageReceived(cb: (data: {
|
|
14
|
+
text: string;
|
|
15
|
+
}) => void): void;
|
|
16
|
+
offMessageReceived(cb: (data: {
|
|
17
|
+
text: string;
|
|
18
|
+
}) => void): void;
|
|
19
|
+
updateLocation(data: DriverLocationWithClientID): void;
|
|
20
|
+
onLocationUpdated(cb: (data: DriverLocationMap) => void): void;
|
|
21
|
+
offLocationUpdated(cb: (data: DriverLocationMap) => void): void;
|
|
22
|
+
onAllLocations(cb: (data: DriverLocationMap) => void): void;
|
|
23
|
+
offAllLocations(cb: (data: DriverLocationMap) => void): void;
|
|
24
|
+
sendHeartbeat(clientID: string): void;
|
|
25
|
+
onHeartbeatReceived(cb: (data: {
|
|
26
|
+
clientID: string;
|
|
27
|
+
timestamp: number;
|
|
28
|
+
}) => void): void;
|
|
29
|
+
offHeartbeatReceived(cb: (data: {
|
|
30
|
+
clientID: string;
|
|
31
|
+
timestamp: number;
|
|
32
|
+
}) => void): void;
|
|
33
|
+
onAllHeartbeats(cb: (data: {
|
|
34
|
+
[clientID: string]: number;
|
|
35
|
+
}) => void): void;
|
|
36
|
+
offAllHeartbeats(cb: (data: {
|
|
37
|
+
[clientID: string]: number;
|
|
38
|
+
}) => void): void;
|
|
39
|
+
updateServiceOrderStatus(orderID: string, status: number): void;
|
|
40
|
+
onServiceOrderStatusUpdated(callback: (data: {
|
|
41
|
+
orderID: string;
|
|
42
|
+
status: number;
|
|
43
|
+
}) => void): void;
|
|
44
|
+
offServiceOrderStatusUpdated(callback: (data: {
|
|
45
|
+
orderID: string;
|
|
46
|
+
status: number;
|
|
47
|
+
}) => void): void;
|
|
48
|
+
onAllServiceOrderStatuses(callback: (statuses: {
|
|
49
|
+
[orderID: string]: number;
|
|
50
|
+
}) => void): void;
|
|
51
|
+
offAllServiceOrderStatuses(callback: (statuses: {
|
|
52
|
+
[orderID: string]: number;
|
|
53
|
+
}) => void): void;
|
|
54
|
+
}
|
package/socketService.js
CHANGED
|
@@ -1,104 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SocketService = void 0;
|
|
4
|
-
const socket_io_client_1 = require(
|
|
4
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
5
5
|
class SocketService {
|
|
6
|
-
|
|
6
|
+
/*
|
|
7
7
|
constructor(baseUrl: string) {
|
|
8
8
|
this.socket = io(baseUrl, { transports: ['websocket'] });
|
|
9
9
|
}
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
this.on('connected', callback);
|
|
99
|
-
}
|
|
100
|
-
offConnected(callback) {
|
|
101
|
-
this.off('connected', callback);
|
|
102
|
-
}
|
|
11
|
+
constructor(baseUrl, token) {
|
|
12
|
+
this.socket = (0, socket_io_client_1.io)(baseUrl, {
|
|
13
|
+
transports: ['websocket'],
|
|
14
|
+
auth: token ? { token } : undefined, // ✅ send token if available
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
connect() {
|
|
18
|
+
this.socket.connect();
|
|
19
|
+
}
|
|
20
|
+
disconnect() {
|
|
21
|
+
this.socket.disconnect();
|
|
22
|
+
}
|
|
23
|
+
isConnected() {
|
|
24
|
+
return this.socket.connected;
|
|
25
|
+
}
|
|
26
|
+
isActive() {
|
|
27
|
+
return this.socket.active;
|
|
28
|
+
}
|
|
29
|
+
on(event, cb) {
|
|
30
|
+
this.socket.on(event, cb);
|
|
31
|
+
}
|
|
32
|
+
off(event, cb) {
|
|
33
|
+
if (cb) {
|
|
34
|
+
this.socket.off(event, cb);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.socket.removeAllListeners(event);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
emit(event, data) {
|
|
41
|
+
this.socket.emit(event, data);
|
|
42
|
+
}
|
|
43
|
+
// Custom methods
|
|
44
|
+
sendMessage(message) {
|
|
45
|
+
this.emit('message', { text: message });
|
|
46
|
+
}
|
|
47
|
+
onMessageReceived(cb) {
|
|
48
|
+
this.on('messageReceived', cb);
|
|
49
|
+
}
|
|
50
|
+
offMessageReceived(cb) {
|
|
51
|
+
this.off('messageReceived', cb);
|
|
52
|
+
}
|
|
53
|
+
updateLocation(data) {
|
|
54
|
+
this.emit('updateLocation', { ...data });
|
|
55
|
+
}
|
|
56
|
+
onLocationUpdated(cb) {
|
|
57
|
+
this.on('locationUpdated', cb);
|
|
58
|
+
}
|
|
59
|
+
offLocationUpdated(cb) {
|
|
60
|
+
this.off('locationUpdated', cb);
|
|
61
|
+
}
|
|
62
|
+
onAllLocations(cb) {
|
|
63
|
+
this.on('allLocations', cb);
|
|
64
|
+
}
|
|
65
|
+
offAllLocations(cb) {
|
|
66
|
+
this.off('allLocations', cb);
|
|
67
|
+
}
|
|
68
|
+
sendHeartbeat(clientID) {
|
|
69
|
+
this.emit('heartbeat', { clientID });
|
|
70
|
+
}
|
|
71
|
+
onHeartbeatReceived(cb) {
|
|
72
|
+
this.on('heartbeatReceived', cb);
|
|
73
|
+
}
|
|
74
|
+
offHeartbeatReceived(cb) {
|
|
75
|
+
this.off('heartbeatReceived', cb);
|
|
76
|
+
}
|
|
77
|
+
onAllHeartbeats(cb) {
|
|
78
|
+
this.on('allHeartbeats', cb);
|
|
79
|
+
}
|
|
80
|
+
offAllHeartbeats(cb) {
|
|
81
|
+
this.off('allHeartbeats', cb);
|
|
82
|
+
}
|
|
83
|
+
updateServiceOrderStatus(orderID, status) {
|
|
84
|
+
this.emit('serviceOrderStatusUpdate', { orderID, status });
|
|
85
|
+
}
|
|
86
|
+
onServiceOrderStatusUpdated(callback) {
|
|
87
|
+
this.on('serviceOrderStatusUpdated', callback);
|
|
88
|
+
}
|
|
89
|
+
offServiceOrderStatusUpdated(callback) {
|
|
90
|
+
this.off('serviceOrderStatusUpdated', callback);
|
|
91
|
+
}
|
|
92
|
+
onAllServiceOrderStatuses(callback) {
|
|
93
|
+
this.on('allServiceOrderStatuses', callback);
|
|
94
|
+
}
|
|
95
|
+
offAllServiceOrderStatuses(callback) {
|
|
96
|
+
this.off('allServiceOrderStatuses', callback);
|
|
97
|
+
}
|
|
103
98
|
}
|
|
104
99
|
exports.SocketService = SocketService;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export type CreateServiceOrderDto = {
|
|
2
|
-
/**
|
|
3
|
-
* Driver ID
|
|
4
|
-
*/
|
|
5
|
-
driver_id?: number;
|
|
6
|
-
/**
|
|
7
|
-
* User ID
|
|
8
|
-
*/
|
|
9
|
-
user_id?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Admin ID
|
|
12
|
-
*/
|
|
13
|
-
admin_id?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Service order status
|
|
16
|
-
*/
|
|
17
|
-
status: string;
|
|
18
|
-
/**
|
|
19
|
-
* Trip source
|
|
20
|
-
*/
|
|
21
|
-
trip_source: string;
|
|
22
|
-
/**
|
|
23
|
-
* Driver assignment mode
|
|
24
|
-
*/
|
|
25
|
-
driver_assignment_mode: string;
|
|
26
|
-
/**
|
|
27
|
-
* Origin location
|
|
28
|
-
*/
|
|
29
|
-
origin?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Destination location
|
|
32
|
-
*/
|
|
33
|
-
destination?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Started at timestamp
|
|
36
|
-
*/
|
|
37
|
-
started_at?: string;
|
|
38
|
-
/**
|
|
39
|
-
* Completed at timestamp
|
|
40
|
-
*/
|
|
41
|
-
completed_at?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Total amount
|
|
44
|
-
*/
|
|
45
|
-
total?: number;
|
|
46
|
-
};
|