@dapex-tech/elite-online-services 0.0.12 → 0.0.14
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 +1 -0
- package/models/AdminCreateDto.d.ts +26 -0
- package/models/AdminCreateDto.js +2 -0
- package/models/AdminDto.d.ts +0 -8
- package/models/AdminLoginResponseDto.d.ts +38 -0
- package/models/AdminLoginResponseDto.js +2 -0
- package/models/AdminUpdateDto.d.ts +2 -2
- package/models/CustomerDto.d.ts +2 -38
- package/models/CustomerLoginDto.d.ts +1 -1
- package/models/CustomerLoginResponseDto.d.ts +38 -0
- package/models/CustomerLoginResponseDto.js +2 -0
- package/models/CustomerRegisterDto.d.ts +26 -0
- package/models/CustomerRegisterDto.js +2 -0
- package/models/CustomerTripActions.d.ts +3 -0
- package/models/CustomerTripActions.js +11 -0
- package/models/DriverCreateDto.d.ts +42 -0
- package/models/DriverCreateDto.js +2 -0
- package/models/DriverDto.d.ts +0 -4
- package/models/DriverLoginResponseDto.d.ts +58 -0
- package/models/DriverLoginResponseDto.js +2 -0
- package/models/DriverTripActions.d.ts +2 -1
- package/models/DriverTripActions.js +1 -0
- package/models/DriverUpdateDto.d.ts +0 -8
- package/models/MessageResponseDto.d.ts +6 -0
- package/models/MessageResponseDto.js +2 -0
- package/models/TokensDto.d.ts +10 -0
- package/models/TokensDto.js +2 -0
- package/models/TripDto.d.ts +6 -6
- package/models/UpdateFcmTokenDto.d.ts +6 -0
- package/models/UpdateFcmTokenDto.js +2 -0
- package/models/index.d.ts +10 -0
- package/models/index.js +10 -0
- package/package.json +1 -1
- package/services/AdminAuthService.d.ts +20 -16
- package/services/AdminAuthService.js +9 -31
- package/services/AdminCustomerService.d.ts +12 -10
- package/services/AdminCustomerService.js +5 -23
- package/services/AdminDriversService.d.ts +2 -2
- package/services/AdminDriversService.js +0 -18
- package/services/AdminService.d.ts +12 -10
- package/services/AdminService.js +5 -23
- package/services/AdminTripsService.d.ts +14 -14
- package/services/AdminTripsService.js +7 -36
- package/services/CustomerLocationsService.d.ts +3 -2
- package/services/CustomerLocationsService.js +1 -13
- package/services/CustomerTripsService.d.ts +19 -17
- package/services/CustomerTripsService.js +12 -43
- package/services/CustomersAuthService.d.ts +25 -23
- package/services/CustomersAuthService.js +10 -47
- package/services/CustomersService.d.ts +14 -4
- package/services/CustomersService.js +17 -7
- package/services/DriverAuthService.d.ts +18 -14
- package/services/DriverAuthService.js +7 -29
- package/services/DriverTripsService.d.ts +12 -12
- package/services/DriverTripsService.js +6 -29
- package/services/DriversService.d.ts +18 -8
- package/services/DriversService.js +19 -17
- package/services/HealthService.d.ts +23 -0
- package/services/HealthService.js +34 -0
- package/services/MainService.d.ts +6 -1
- package/services/MainService.js +12 -2
- package/services/index.d.ts +1 -0
- package/services/index.js +1 -0
- package/socketService.bak.d.ts +54 -0
- package/socketService.bak.js +99 -0
- package/socketService.d.ts +19 -45
- package/socketService.js +84 -57
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/realtime/driver-execute-trip-action.d.ts +5 -0
- package/types/realtime/driver-execute-trip-action.js +2 -0
- package/types/realtime/driver-status.d.ts +8 -0
- package/types/realtime/driver-status.js +2 -0
- package/types/realtime/index.d.ts +2 -0
- package/types/realtime/index.js +18 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SocketServiceBak = void 0;
|
|
4
|
+
const socket_io_client_1 = require("socket.io-client");
|
|
5
|
+
class SocketServiceBak {
|
|
6
|
+
/*
|
|
7
|
+
constructor(baseUrl: string) {
|
|
8
|
+
this.socket = io(baseUrl, { transports: ['websocket'] });
|
|
9
|
+
}
|
|
10
|
+
*/
|
|
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
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.SocketServiceBak = SocketServiceBak;
|
package/socketService.d.ts
CHANGED
|
@@ -1,54 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DriverStatus } from './types';
|
|
2
2
|
export declare class SocketService {
|
|
3
3
|
private socket;
|
|
4
|
-
|
|
4
|
+
private token;
|
|
5
|
+
private constructor();
|
|
6
|
+
splitSocketUrl(baseUrl: string): {
|
|
7
|
+
url: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
static getInstance(): Promise<SocketService>;
|
|
11
|
+
setToken(token: string): void;
|
|
12
|
+
clearToken(): void;
|
|
5
13
|
connect(): void;
|
|
6
14
|
disconnect(): void;
|
|
7
15
|
isConnected(): boolean;
|
|
8
|
-
isActive(): boolean;
|
|
9
16
|
on<T = any>(event: string, cb: (data: T) => void): void;
|
|
10
17
|
off(event: string, cb?: (...args: any[]) => void): void;
|
|
11
18
|
emit<T = any>(event: string, data: T): void;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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;
|
|
19
|
+
onConnected(cb: (data: any) => void): void;
|
|
20
|
+
offConnected(cb?: (data: any) => void): void;
|
|
21
|
+
onDisconnected(cb: (data: any) => void): void;
|
|
22
|
+
offDisconnected(cb?: (data: any) => void): void;
|
|
23
|
+
onDriverStatusUpdate(cb: (data: DriverStatus) => void): void;
|
|
24
|
+
offDriverStatusUpdate(cb?: (data: DriverStatus) => void): void;
|
|
25
|
+
onTripUpdate(cb: (data: any) => void): void;
|
|
26
|
+
offTripUpdate(cb?: (data: any) => void): void;
|
|
27
|
+
emitDriverStatusUpdate(data: DriverStatus): void;
|
|
54
28
|
}
|
package/socketService.js
CHANGED
|
@@ -2,18 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SocketService = void 0;
|
|
4
4
|
const socket_io_client_1 = require("socket.io-client");
|
|
5
|
+
const OpenAPI_1 = require("./core/OpenAPI");
|
|
6
|
+
let instance = null;
|
|
5
7
|
class SocketService {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
constructor(baseUrl, token) {
|
|
12
|
-
this.socket = (0, socket_io_client_1.io)(baseUrl, {
|
|
8
|
+
constructor(baseUrl) {
|
|
9
|
+
const { url, path } = this.splitSocketUrl(baseUrl);
|
|
10
|
+
this.socket = (0, socket_io_client_1.io)(url, {
|
|
11
|
+
path,
|
|
13
12
|
transports: ['websocket'],
|
|
14
|
-
|
|
13
|
+
autoConnect: false,
|
|
15
14
|
});
|
|
16
15
|
}
|
|
16
|
+
splitSocketUrl(baseUrl) {
|
|
17
|
+
// Absolute URL (prod)
|
|
18
|
+
if (/^https?:\/\//i.test(baseUrl)) {
|
|
19
|
+
const u = new URL(baseUrl);
|
|
20
|
+
return {
|
|
21
|
+
url: u.origin,
|
|
22
|
+
path: u.pathname,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// Relative URL (dev)
|
|
26
|
+
return {
|
|
27
|
+
url: '/',
|
|
28
|
+
path: baseUrl,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static async getInstance() {
|
|
32
|
+
if (!instance) {
|
|
33
|
+
const url = `${OpenAPI_1.OpenAPI.BASE}/realtime`;
|
|
34
|
+
instance = new SocketService(url);
|
|
35
|
+
}
|
|
36
|
+
return instance;
|
|
37
|
+
}
|
|
38
|
+
setToken(token) {
|
|
39
|
+
this.token = token;
|
|
40
|
+
this.socket.auth = { token };
|
|
41
|
+
// always force re-auth
|
|
42
|
+
if (this.socket.connected) {
|
|
43
|
+
this.socket.disconnect();
|
|
44
|
+
}
|
|
45
|
+
this.socket.connect();
|
|
46
|
+
}
|
|
47
|
+
clearToken() {
|
|
48
|
+
this.token = undefined;
|
|
49
|
+
if (!this.socket || !this.socket.auth)
|
|
50
|
+
return;
|
|
51
|
+
this.socket.auth = {};
|
|
52
|
+
this.disconnect();
|
|
53
|
+
}
|
|
17
54
|
connect() {
|
|
18
55
|
this.socket.connect();
|
|
19
56
|
}
|
|
@@ -23,9 +60,6 @@ class SocketService {
|
|
|
23
60
|
isConnected() {
|
|
24
61
|
return this.socket.connected;
|
|
25
62
|
}
|
|
26
|
-
isActive() {
|
|
27
|
-
return this.socket.active;
|
|
28
|
-
}
|
|
29
63
|
on(event, cb) {
|
|
30
64
|
this.socket.on(event, cb);
|
|
31
65
|
}
|
|
@@ -40,60 +74,53 @@ class SocketService {
|
|
|
40
74
|
emit(event, data) {
|
|
41
75
|
this.socket.emit(event, data);
|
|
42
76
|
}
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
this.
|
|
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);
|
|
77
|
+
// Additional methods for specific events can be added here
|
|
78
|
+
onConnected(cb) {
|
|
79
|
+
this.socket.on('connected', cb);
|
|
73
80
|
}
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
offConnected(cb) {
|
|
82
|
+
if (cb) {
|
|
83
|
+
this.socket.off('connected', cb);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.socket.removeAllListeners('connected');
|
|
87
|
+
}
|
|
76
88
|
}
|
|
77
|
-
|
|
78
|
-
this.on('
|
|
89
|
+
onDisconnected(cb) {
|
|
90
|
+
this.socket.on('disconnected', cb);
|
|
79
91
|
}
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
offDisconnected(cb) {
|
|
93
|
+
if (cb) {
|
|
94
|
+
this.socket.off('disconnected', cb);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
this.socket.removeAllListeners('disconnected');
|
|
98
|
+
}
|
|
82
99
|
}
|
|
83
|
-
|
|
84
|
-
this.
|
|
100
|
+
onDriverStatusUpdate(cb) {
|
|
101
|
+
this.socket.on('driverStatusUpdate', cb);
|
|
85
102
|
}
|
|
86
|
-
|
|
87
|
-
|
|
103
|
+
offDriverStatusUpdate(cb) {
|
|
104
|
+
if (cb) {
|
|
105
|
+
this.socket.off('driverStatusUpdate', cb);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.socket.removeAllListeners('driverStatusUpdate');
|
|
109
|
+
}
|
|
88
110
|
}
|
|
89
|
-
|
|
90
|
-
this.
|
|
111
|
+
onTripUpdate(cb) {
|
|
112
|
+
this.socket.on('tripUpdate', cb);
|
|
91
113
|
}
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
offTripUpdate(cb) {
|
|
115
|
+
if (cb) {
|
|
116
|
+
this.socket.off('tripUpdate', cb);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.socket.removeAllListeners('tripUpdate');
|
|
120
|
+
}
|
|
94
121
|
}
|
|
95
|
-
|
|
96
|
-
this.
|
|
122
|
+
emitDriverStatusUpdate(data) {
|
|
123
|
+
this.emit('driverStatusUpdate', { ...data });
|
|
97
124
|
}
|
|
98
125
|
}
|
|
99
126
|
exports.SocketService = SocketService;
|
package/types/index.d.ts
CHANGED
package/types/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./driver-location.entity"), exports);
|
|
18
18
|
__exportStar(require("./user.entity"), exports);
|
|
19
|
+
__exportStar(require("./realtime"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./driver-execute-trip-action"), exports);
|
|
18
|
+
__exportStar(require("./driver-status"), exports);
|