@dapex-tech/elite-online-services 0.0.0-development

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 ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@dapex-tech/elite-online-services",
3
+ "version": "0.0.0-development",
4
+ "main": "./index.js",
5
+ "types": "./index.d.ts",
6
+ "private": false,
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "files": [
11
+ "*"
12
+ ],
13
+ "peerDependencies": {
14
+ "socket.io-client": "^4.8.1"
15
+ },
16
+ "devDependencies": {
17
+ "@types/socket.io-client": "^3.0.0",
18
+ "typescript": "^5.0.0"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/Dapex-Tech/EliteOnlineServices.git"
23
+ }
24
+ }
@@ -0,0 +1,122 @@
1
+ /* generated using openapi-typescript-codegen -- do not edit */
2
+ /* istanbul ignore file */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ import type { AdminDto } from '../models/AdminDto';
6
+ import type { CancelablePromise } from '../core/CancelablePromise';
7
+ import { OpenAPI } from '../core/OpenAPI';
8
+ import { request as __request } from '../core/request';
9
+ export class AdminService {
10
+ /**
11
+ * Create a new admin
12
+ * @param requestBody
13
+ * @returns any Admin created successfully.
14
+ * @throws ApiError
15
+ */
16
+ public static create(
17
+ requestBody: AdminDto,
18
+ ): CancelablePromise<any> {
19
+ return __request(OpenAPI, {
20
+ method: 'POST',
21
+ url: '/admins',
22
+ body: requestBody,
23
+ mediaType: 'application/json',
24
+ errors: {
25
+ 401: `Unauthorized`,
26
+ },
27
+ });
28
+ }
29
+ /**
30
+ * Get all admins
31
+ * @param search
32
+ * @param orderBy
33
+ * @param order
34
+ * @returns any List of admins
35
+ * @throws ApiError
36
+ */
37
+ public static findAll(
38
+ search: string,
39
+ orderBy: string,
40
+ order: string,
41
+ ): CancelablePromise<any> {
42
+ return __request(OpenAPI, {
43
+ method: 'GET',
44
+ url: '/admins',
45
+ query: {
46
+ 'search': search,
47
+ 'orderBy': orderBy,
48
+ 'order': order,
49
+ },
50
+ errors: {
51
+ 401: `Unauthorized`,
52
+ },
53
+ });
54
+ }
55
+ /**
56
+ * Get a single admin by ID
57
+ * @param id
58
+ * @returns any Admin found
59
+ * @throws ApiError
60
+ */
61
+ public static findOne(
62
+ id: number,
63
+ ): CancelablePromise<any> {
64
+ return __request(OpenAPI, {
65
+ method: 'GET',
66
+ url: '/admins/{id}',
67
+ path: {
68
+ 'id': id,
69
+ },
70
+ errors: {
71
+ 401: `Unauthorized`,
72
+ 404: `Admin not found`,
73
+ },
74
+ });
75
+ }
76
+ /**
77
+ * Update an admin by ID
78
+ * @param id
79
+ * @param requestBody
80
+ * @returns any Admin updated successfully.
81
+ * @throws ApiError
82
+ */
83
+ public static update(
84
+ id: number,
85
+ requestBody: AdminDto,
86
+ ): CancelablePromise<any> {
87
+ return __request(OpenAPI, {
88
+ method: 'PUT',
89
+ url: '/admins/{id}',
90
+ path: {
91
+ 'id': id,
92
+ },
93
+ body: requestBody,
94
+ mediaType: 'application/json',
95
+ errors: {
96
+ 401: `Unauthorized`,
97
+ 404: `Admin not found`,
98
+ },
99
+ });
100
+ }
101
+ /**
102
+ * Delete an admin by ID
103
+ * @param id
104
+ * @returns any Admin deleted successfully.
105
+ * @throws ApiError
106
+ */
107
+ public static remove(
108
+ id: number,
109
+ ): CancelablePromise<any> {
110
+ return __request(OpenAPI, {
111
+ method: 'DELETE',
112
+ url: '/admins/{id}',
113
+ path: {
114
+ 'id': id,
115
+ },
116
+ errors: {
117
+ 401: `Unauthorized`,
118
+ 404: `Admin not found`,
119
+ },
120
+ });
121
+ }
122
+ }
@@ -0,0 +1,122 @@
1
+ /* generated using openapi-typescript-codegen -- do not edit */
2
+ /* istanbul ignore file */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ import type { DriverDto } from '../models/DriverDto';
6
+ import type { CancelablePromise } from '../core/CancelablePromise';
7
+ import { OpenAPI } from '../core/OpenAPI';
8
+ import { request as __request } from '../core/request';
9
+ export class DriversService {
10
+ /**
11
+ * Create a new driver
12
+ * @param requestBody
13
+ * @returns any Driver created successfully.
14
+ * @throws ApiError
15
+ */
16
+ public static create(
17
+ requestBody: DriverDto,
18
+ ): CancelablePromise<any> {
19
+ return __request(OpenAPI, {
20
+ method: 'POST',
21
+ url: '/drivers',
22
+ body: requestBody,
23
+ mediaType: 'application/json',
24
+ errors: {
25
+ 401: `Unauthorized`,
26
+ },
27
+ });
28
+ }
29
+ /**
30
+ * Get all drivers
31
+ * @param search
32
+ * @param orderBy
33
+ * @param order
34
+ * @returns any List of drivers
35
+ * @throws ApiError
36
+ */
37
+ public static findAll(
38
+ search: string,
39
+ orderBy: string,
40
+ order: string,
41
+ ): CancelablePromise<any> {
42
+ return __request(OpenAPI, {
43
+ method: 'GET',
44
+ url: '/drivers',
45
+ query: {
46
+ 'search': search,
47
+ 'orderBy': orderBy,
48
+ 'order': order,
49
+ },
50
+ errors: {
51
+ 401: `Unauthorized`,
52
+ },
53
+ });
54
+ }
55
+ /**
56
+ * Get a single driver by ID
57
+ * @param id
58
+ * @returns any Driver found
59
+ * @throws ApiError
60
+ */
61
+ public static findOne(
62
+ id: number,
63
+ ): CancelablePromise<any> {
64
+ return __request(OpenAPI, {
65
+ method: 'GET',
66
+ url: '/drivers/{id}',
67
+ path: {
68
+ 'id': id,
69
+ },
70
+ errors: {
71
+ 401: `Unauthorized`,
72
+ 404: `Driver not found`,
73
+ },
74
+ });
75
+ }
76
+ /**
77
+ * Update a driver by ID
78
+ * @param id
79
+ * @param requestBody
80
+ * @returns any Driver updated successfully.
81
+ * @throws ApiError
82
+ */
83
+ public static update(
84
+ id: number,
85
+ requestBody: DriverDto,
86
+ ): CancelablePromise<any> {
87
+ return __request(OpenAPI, {
88
+ method: 'PUT',
89
+ url: '/drivers/{id}',
90
+ path: {
91
+ 'id': id,
92
+ },
93
+ body: requestBody,
94
+ mediaType: 'application/json',
95
+ errors: {
96
+ 401: `Unauthorized`,
97
+ 404: `Driver not found`,
98
+ },
99
+ });
100
+ }
101
+ /**
102
+ * Delete a driver by ID
103
+ * @param id
104
+ * @returns any Driver deleted successfully.
105
+ * @throws ApiError
106
+ */
107
+ public static remove(
108
+ id: number,
109
+ ): CancelablePromise<any> {
110
+ return __request(OpenAPI, {
111
+ method: 'DELETE',
112
+ url: '/drivers/{id}',
113
+ path: {
114
+ 'id': id,
115
+ },
116
+ errors: {
117
+ 401: `Unauthorized`,
118
+ 404: `Driver not found`,
119
+ },
120
+ });
121
+ }
122
+ }
@@ -0,0 +1,67 @@
1
+ /* generated using openapi-typescript-codegen -- do not edit */
2
+ /* istanbul ignore file */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ import type { LoginDto } from '../models/LoginDto';
6
+ import type { CancelablePromise } from '../core/CancelablePromise';
7
+ import { OpenAPI } from '../core/OpenAPI';
8
+ import { request as __request } from '../core/request';
9
+ export class LoginsService {
10
+ /**
11
+ * User Login
12
+ * @param requestBody
13
+ * @returns any Login successful
14
+ * @throws ApiError
15
+ */
16
+ public static login(
17
+ requestBody: LoginDto,
18
+ ): CancelablePromise<any> {
19
+ return __request(OpenAPI, {
20
+ method: 'POST',
21
+ url: '/auth/users/login',
22
+ body: requestBody,
23
+ mediaType: 'application/json',
24
+ errors: {
25
+ 401: `Invalid credentials`,
26
+ },
27
+ });
28
+ }
29
+ /**
30
+ * Admin Login
31
+ * @param requestBody
32
+ * @returns any Login successful
33
+ * @throws ApiError
34
+ */
35
+ public static login1(
36
+ requestBody: LoginDto,
37
+ ): CancelablePromise<any> {
38
+ return __request(OpenAPI, {
39
+ method: 'POST',
40
+ url: '/auth/admins/login',
41
+ body: requestBody,
42
+ mediaType: 'application/json',
43
+ errors: {
44
+ 401: `Invalid credentials`,
45
+ },
46
+ });
47
+ }
48
+ /**
49
+ * Driver Login
50
+ * @param requestBody
51
+ * @returns any Login successful
52
+ * @throws ApiError
53
+ */
54
+ public static login2(
55
+ requestBody: LoginDto,
56
+ ): CancelablePromise<any> {
57
+ return __request(OpenAPI, {
58
+ method: 'POST',
59
+ url: '/auth/drivers/login',
60
+ body: requestBody,
61
+ mediaType: 'application/json',
62
+ errors: {
63
+ 401: `Invalid credentials`,
64
+ },
65
+ });
66
+ }
67
+ }
@@ -0,0 +1,19 @@
1
+ /* generated using openapi-typescript-codegen -- do not edit */
2
+ /* istanbul ignore file */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ import type { CancelablePromise } from '../core/CancelablePromise';
6
+ import { OpenAPI } from '../core/OpenAPI';
7
+ import { request as __request } from '../core/request';
8
+ export class MainService {
9
+ /**
10
+ * @returns any
11
+ * @throws ApiError
12
+ */
13
+ public static getHello(): CancelablePromise<any> {
14
+ return __request(OpenAPI, {
15
+ method: 'GET',
16
+ url: '/',
17
+ });
18
+ }
19
+ }
@@ -0,0 +1,123 @@
1
+ /* generated using openapi-typescript-codegen -- do not edit */
2
+ /* istanbul ignore file */
3
+ /* tslint:disable */
4
+ /* eslint-disable */
5
+ import type { UserDto } from '../models/UserDto';
6
+ import type { CancelablePromise } from '../core/CancelablePromise';
7
+ import { OpenAPI } from '../core/OpenAPI';
8
+ import { request as __request } from '../core/request';
9
+ export class UsersService {
10
+ /**
11
+ * Create a new user
12
+ * @param requestBody
13
+ * @returns any User created successfully.
14
+ * @throws ApiError
15
+ */
16
+ public static create(
17
+ requestBody: UserDto,
18
+ ): CancelablePromise<any> {
19
+ return __request(OpenAPI, {
20
+ method: 'POST',
21
+ url: '/users',
22
+ body: requestBody,
23
+ mediaType: 'application/json',
24
+ errors: {
25
+ 400: `Invalid data.`,
26
+ 401: `Unauthorized`,
27
+ },
28
+ });
29
+ }
30
+ /**
31
+ * Get all users
32
+ * @param search
33
+ * @param orderBy
34
+ * @param order
35
+ * @returns any List of users.
36
+ * @throws ApiError
37
+ */
38
+ public static findAll(
39
+ search: string,
40
+ orderBy: string,
41
+ order: string,
42
+ ): CancelablePromise<any> {
43
+ return __request(OpenAPI, {
44
+ method: 'GET',
45
+ url: '/users',
46
+ query: {
47
+ 'search': search,
48
+ 'orderBy': orderBy,
49
+ 'order': order,
50
+ },
51
+ errors: {
52
+ 401: `Unauthorized`,
53
+ },
54
+ });
55
+ }
56
+ /**
57
+ * Get a user by ID
58
+ * @param id
59
+ * @returns any User found.
60
+ * @throws ApiError
61
+ */
62
+ public static findOne(
63
+ id: number,
64
+ ): CancelablePromise<any> {
65
+ return __request(OpenAPI, {
66
+ method: 'GET',
67
+ url: '/users/{id}',
68
+ path: {
69
+ 'id': id,
70
+ },
71
+ errors: {
72
+ 401: `Unauthorized`,
73
+ 404: `User not found.`,
74
+ },
75
+ });
76
+ }
77
+ /**
78
+ * Update a user by ID
79
+ * @param id
80
+ * @param requestBody
81
+ * @returns any User updated successfully.
82
+ * @throws ApiError
83
+ */
84
+ public static update(
85
+ id: number,
86
+ requestBody: UserDto,
87
+ ): CancelablePromise<any> {
88
+ return __request(OpenAPI, {
89
+ method: 'PUT',
90
+ url: '/users/{id}',
91
+ path: {
92
+ 'id': id,
93
+ },
94
+ body: requestBody,
95
+ mediaType: 'application/json',
96
+ errors: {
97
+ 401: `Unauthorized`,
98
+ 404: `User not found.`,
99
+ },
100
+ });
101
+ }
102
+ /**
103
+ * Delete a user by ID
104
+ * @param id
105
+ * @returns any User deleted successfully.
106
+ * @throws ApiError
107
+ */
108
+ public static remove(
109
+ id: number,
110
+ ): CancelablePromise<any> {
111
+ return __request(OpenAPI, {
112
+ method: 'DELETE',
113
+ url: '/users/{id}',
114
+ path: {
115
+ 'id': id,
116
+ },
117
+ errors: {
118
+ 401: `Unauthorized`,
119
+ 404: `User not found.`,
120
+ },
121
+ });
122
+ }
123
+ }
@@ -0,0 +1,5 @@
1
+ export * from './AdminService';
2
+ export * from './DriversService';
3
+ export * from './LoginsService';
4
+ export * from './MainService';
5
+ export * from './UsersService';
@@ -0,0 +1,105 @@
1
+ import { io, Socket } from 'socket.io-client';
2
+ import { DriverLocationMap, DriverLocationWithClientID } from './types';
3
+
4
+ export class SocketService {
5
+ private socket: Socket;
6
+
7
+ /*
8
+ constructor(baseUrl: string) {
9
+ this.socket = io(baseUrl, { transports: ['websocket'] });
10
+ }
11
+ */
12
+
13
+ constructor(baseUrl: string, token?: string) {
14
+ this.socket = io(baseUrl, {
15
+ transports: ['websocket'],
16
+ auth: token ? { token } : undefined, // ✅ send token if available
17
+ });
18
+ }
19
+
20
+ connect() {
21
+ this.socket.connect();
22
+ }
23
+
24
+ disconnect() {
25
+ this.socket.disconnect();
26
+ }
27
+
28
+ isConnected(): boolean {
29
+ return this.socket.connected;
30
+ }
31
+
32
+ isActive(): boolean {
33
+ return this.socket.active;
34
+ }
35
+
36
+ on<T = any>(event: string, cb: (data: T) => void) {
37
+ this.socket.on(event, cb);
38
+ }
39
+
40
+ off(event: string, cb?: (...args: any[]) => void) {
41
+ if (cb) {
42
+ this.socket.off(event, cb);
43
+ } else {
44
+ this.socket.removeAllListeners(event);
45
+ }
46
+ }
47
+
48
+ emit<T = any>(event: string, data: T) {
49
+ this.socket.emit(event, data);
50
+ }
51
+
52
+ // Métodos personalizados
53
+ sendMessage(message: string) {
54
+ this.emit('message', { text: message });
55
+ }
56
+
57
+ onMessageReceived(cb: (data: { text: string }) => void) {
58
+ this.on('messageReceived', cb);
59
+ }
60
+
61
+ offMessageReceived(cb: (data: { text: string }) => void) {
62
+ this.off('messageReceived', cb);
63
+ }
64
+
65
+ updateLocation(data: DriverLocationWithClientID) {
66
+ this.emit('updateLocation', { ...data });
67
+ }
68
+
69
+ onLocationUpdated(cb: (data: DriverLocationMap) => void) {
70
+ this.on('locationUpdated', cb);
71
+ }
72
+
73
+ offLocationUpdated(cb: (data: DriverLocationMap) => void) {
74
+ this.off('locationUpdated', cb);
75
+ }
76
+
77
+ onAllLocations(cb: (data: DriverLocationMap) => void) {
78
+ this.on('allLocations', cb);
79
+ }
80
+
81
+ offAllLocations(cb: (data: DriverLocationMap) => void) {
82
+ this.off('allLocations', cb);
83
+ }
84
+
85
+ sendHeartbeat(clientID: string) {
86
+ this.emit('heartbeat', { clientID });
87
+ }
88
+
89
+ onHeartbeatReceived(cb: (data: { clientID: string; timestamp: number }) => void) {
90
+ this.on('heartbeatReceived', cb);
91
+ }
92
+
93
+ offHeartbeatReceived(cb: (data: { clientID: string; timestamp: number }) => void) {
94
+ this.off('heartbeatReceived', cb);
95
+ }
96
+
97
+ onAllHeartbeats(cb: (data: { [clientID: string]: number }) => void) {
98
+ this.on('allHeartbeats', cb);
99
+ }
100
+
101
+ offAllHeartbeats(cb: (data: { [clientID: string]: number }) => void) {
102
+ this.off('allHeartbeats', cb);
103
+ }
104
+
105
+ }
@@ -0,0 +1,13 @@
1
+ export interface DriverLocation {
2
+ lat: number;
3
+ lng: number;
4
+ at?: Date;
5
+ }
6
+
7
+ export interface DriverLocationWithClientID extends DriverLocation {
8
+ clientID: string;
9
+ }
10
+
11
+ export interface DriverLocationMap {
12
+ [clientID: string]: DriverLocation;
13
+ }
package/types/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './driver-location.entity';
2
+ export * from './user.entity';
@@ -0,0 +1,5 @@
1
+ export class User {
2
+ id: number;
3
+ name: string;
4
+ email: string;
5
+ }