@dapex-tech/elite-online-services 0.0.1 → 0.0.5

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.
Files changed (62) hide show
  1. package/core/ApiError.d.ts +10 -0
  2. package/core/ApiError.js +15 -0
  3. package/core/{ApiRequestOptions.ts → ApiRequestOptions.d.ts} +0 -4
  4. package/core/ApiRequestOptions.js +2 -0
  5. package/core/{ApiResult.ts → ApiResult.d.ts} +0 -4
  6. package/core/ApiResult.js +2 -0
  7. package/core/CancelablePromise.d.ts +20 -0
  8. package/core/CancelablePromise.js +116 -0
  9. package/core/{OpenAPI.ts → OpenAPI.d.ts} +2 -18
  10. package/core/OpenAPI.js +14 -0
  11. package/core/index.js +22 -0
  12. package/core/request.d.ts +30 -0
  13. package/core/{request.ts → request.js} +117 -145
  14. package/createClient.js +48 -0
  15. package/index.d.ts +6 -0
  16. package/index.js +22 -0
  17. package/models/{AdminDto.ts → AdminDto.d.ts} +0 -5
  18. package/models/AdminDto.js +2 -0
  19. package/models/{DriverDto.ts → DriverDto.d.ts} +0 -5
  20. package/models/DriverDto.js +2 -0
  21. package/models/{LoginDto.ts → LoginDto.d.ts} +0 -5
  22. package/models/LoginDto.js +2 -0
  23. package/models/{UserDto.ts → UserDto.d.ts} +0 -5
  24. package/models/UserDto.js +2 -0
  25. package/models/index.d.ts +4 -0
  26. package/models/index.js +20 -0
  27. package/package.json +1 -1
  28. package/services/AdminService.d.ts +42 -0
  29. package/services/{AdminService.ts → AdminService.js} +17 -32
  30. package/services/DriversService.d.ts +42 -0
  31. package/services/{DriversService.ts → DriversService.js} +17 -32
  32. package/services/LoginsService.d.ts +25 -0
  33. package/services/{LoginsService.ts → LoginsService.js} +13 -21
  34. package/services/MainService.d.ts +8 -0
  35. package/services/MainService.js +18 -0
  36. package/services/UsersService.d.ts +42 -0
  37. package/services/{UsersService.ts → UsersService.js} +17 -32
  38. package/services/index.js +21 -0
  39. package/socketService.js +99 -0
  40. package/tsconfig.json +14 -0
  41. package/types/{driver-location.entity.ts → driver-location.entity.d.ts} +5 -7
  42. package/types/driver-location.entity.js +2 -0
  43. package/types/index.js +18 -0
  44. package/types/user.entity.d.ts +5 -0
  45. package/types/user.entity.js +6 -0
  46. package/core/ApiError.ts +0 -25
  47. package/core/CancelablePromise.ts +0 -131
  48. package/createClient.ts +0 -12
  49. package/index.ts +0 -10
  50. package/models/CreateAdminDto.ts +0 -31
  51. package/models/CreateDriverDto.ts +0 -47
  52. package/models/CreateUserDto.ts +0 -27
  53. package/models/UpdateAdminDto.ts +0 -31
  54. package/models/UpdateDriverDto.ts +0 -47
  55. package/models/UpdateUserDto.ts +0 -27
  56. package/models/index.ts +0 -10
  57. package/services/MainService.ts +0 -19
  58. package/socketService.ts +0 -105
  59. package/types/user.entity.ts +0 -5
  60. /package/core/{index.ts → index.d.ts} +0 -0
  61. /package/services/{index.ts → index.d.ts} +0 -0
  62. /package/types/{index.ts → index.d.ts} +0 -0
package/core/ApiError.ts DELETED
@@ -1,25 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- import type { ApiRequestOptions } from './ApiRequestOptions';
6
- import type { ApiResult } from './ApiResult';
7
-
8
- export class ApiError extends Error {
9
- public readonly url: string;
10
- public readonly status: number;
11
- public readonly statusText: string;
12
- public readonly body: any;
13
- public readonly request: ApiRequestOptions;
14
-
15
- constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
16
- super(message);
17
-
18
- this.name = 'ApiError';
19
- this.url = response.url;
20
- this.status = response.status;
21
- this.statusText = response.statusText;
22
- this.body = response.body;
23
- this.request = request;
24
- }
25
- }
@@ -1,131 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- export class CancelError extends Error {
6
-
7
- constructor(message: string) {
8
- super(message);
9
- this.name = 'CancelError';
10
- }
11
-
12
- public get isCancelled(): boolean {
13
- return true;
14
- }
15
- }
16
-
17
- export interface OnCancel {
18
- readonly isResolved: boolean;
19
- readonly isRejected: boolean;
20
- readonly isCancelled: boolean;
21
-
22
- (cancelHandler: () => void): void;
23
- }
24
-
25
- export class CancelablePromise<T> implements Promise<T> {
26
- #isResolved: boolean;
27
- #isRejected: boolean;
28
- #isCancelled: boolean;
29
- readonly #cancelHandlers: (() => void)[];
30
- readonly #promise: Promise<T>;
31
- #resolve?: (value: T | PromiseLike<T>) => void;
32
- #reject?: (reason?: any) => void;
33
-
34
- constructor(
35
- executor: (
36
- resolve: (value: T | PromiseLike<T>) => void,
37
- reject: (reason?: any) => void,
38
- onCancel: OnCancel
39
- ) => void
40
- ) {
41
- this.#isResolved = false;
42
- this.#isRejected = false;
43
- this.#isCancelled = false;
44
- this.#cancelHandlers = [];
45
- this.#promise = new Promise<T>((resolve, reject) => {
46
- this.#resolve = resolve;
47
- this.#reject = reject;
48
-
49
- const onResolve = (value: T | PromiseLike<T>): void => {
50
- if (this.#isResolved || this.#isRejected || this.#isCancelled) {
51
- return;
52
- }
53
- this.#isResolved = true;
54
- if (this.#resolve) this.#resolve(value);
55
- };
56
-
57
- const onReject = (reason?: any): void => {
58
- if (this.#isResolved || this.#isRejected || this.#isCancelled) {
59
- return;
60
- }
61
- this.#isRejected = true;
62
- if (this.#reject) this.#reject(reason);
63
- };
64
-
65
- const onCancel = (cancelHandler: () => void): void => {
66
- if (this.#isResolved || this.#isRejected || this.#isCancelled) {
67
- return;
68
- }
69
- this.#cancelHandlers.push(cancelHandler);
70
- };
71
-
72
- Object.defineProperty(onCancel, 'isResolved', {
73
- get: (): boolean => this.#isResolved,
74
- });
75
-
76
- Object.defineProperty(onCancel, 'isRejected', {
77
- get: (): boolean => this.#isRejected,
78
- });
79
-
80
- Object.defineProperty(onCancel, 'isCancelled', {
81
- get: (): boolean => this.#isCancelled,
82
- });
83
-
84
- return executor(onResolve, onReject, onCancel as OnCancel);
85
- });
86
- }
87
-
88
- get [Symbol.toStringTag]() {
89
- return "Cancellable Promise";
90
- }
91
-
92
- public then<TResult1 = T, TResult2 = never>(
93
- onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
94
- onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
95
- ): Promise<TResult1 | TResult2> {
96
- return this.#promise.then(onFulfilled, onRejected);
97
- }
98
-
99
- public catch<TResult = never>(
100
- onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null
101
- ): Promise<T | TResult> {
102
- return this.#promise.catch(onRejected);
103
- }
104
-
105
- public finally(onFinally?: (() => void) | null): Promise<T> {
106
- return this.#promise.finally(onFinally);
107
- }
108
-
109
- public cancel(): void {
110
- if (this.#isResolved || this.#isRejected || this.#isCancelled) {
111
- return;
112
- }
113
- this.#isCancelled = true;
114
- if (this.#cancelHandlers.length) {
115
- try {
116
- for (const cancelHandler of this.#cancelHandlers) {
117
- cancelHandler();
118
- }
119
- } catch (error) {
120
- console.warn('Cancellation threw an error', error);
121
- return;
122
- }
123
- }
124
- this.#cancelHandlers.length = 0;
125
- if (this.#reject) this.#reject(new CancelError('Request aborted'));
126
- }
127
-
128
- public get isCancelled(): boolean {
129
- return this.#isCancelled;
130
- }
131
- }
package/createClient.ts DELETED
@@ -1,12 +0,0 @@
1
- import { OpenAPI } from './core/OpenAPI';
2
- import * as services from './services';
3
-
4
- /**
5
- * Crea un cliente SDK con la URL base configurada
6
- */
7
- export function createClient(baseUrl?: string) {
8
- OpenAPI.BASE = baseUrl || process.env.API_URL || 'http://localhost:3000';
9
- return {
10
- ...services, // todos los servicios agrupados
11
- };
12
- }
package/index.ts DELETED
@@ -1,10 +0,0 @@
1
-
2
- export * from './models';
3
- export * from './core';
4
- export * from './services';
5
- export * from './types';
6
-
7
- export * from './createClient';
8
- export * from './socketService';
9
-
10
-
@@ -1,31 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- export type CreateAdminDto = {
6
- /**
7
- * Admin First Name
8
- */
9
- first_name: string;
10
- /**
11
- * Admin Last Name
12
- */
13
- last_name: string;
14
- /**
15
- * Admin Phone Number
16
- */
17
- phone: string;
18
- /**
19
- * Admin Email
20
- */
21
- email: string;
22
- /**
23
- * Admin Password
24
- */
25
- password: string;
26
- /**
27
- * Admin Role ID
28
- */
29
- role_id: number;
30
- };
31
-
@@ -1,47 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- export type CreateDriverDto = {
6
- /**
7
- * Driver First Name
8
- */
9
- first_name: string;
10
- /**
11
- * Driver Last Name
12
- */
13
- last_name: string;
14
- /**
15
- * Driver Phone Number (10 dígitos)
16
- */
17
- phone: string;
18
- /**
19
- * Driver Email
20
- */
21
- email: string;
22
- /**
23
- * Driver Password (6-20 caracteres)
24
- */
25
- password: string;
26
- /**
27
- * Driver License Number
28
- */
29
- license: string;
30
- /**
31
- * Driver Type (e.g., internal, external)
32
- */
33
- type: string;
34
- /**
35
- * Driver State (activo/inactivo)
36
- */
37
- state?: boolean;
38
- /**
39
- * Last Location
40
- */
41
- last_location?: string;
42
- /**
43
- * Last Heartbeat
44
- */
45
- last_heartbeat?: string;
46
- };
47
-
@@ -1,27 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- export type CreateUserDto = {
6
- /**
7
- * User First Name
8
- */
9
- first_name: string;
10
- /**
11
- * User Last Name
12
- */
13
- last_name: string;
14
- /**
15
- * User Email
16
- */
17
- email: string;
18
- /**
19
- * User Password
20
- */
21
- password: string;
22
- /**
23
- * User Phone Number
24
- */
25
- phone: string;
26
- };
27
-
@@ -1,31 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- export type UpdateAdminDto = {
6
- /**
7
- * Admin First Name Updated
8
- */
9
- first_name: string;
10
- /**
11
- * Admin Last Name Updated
12
- */
13
- last_name: string;
14
- /**
15
- * Admin Phone Number Updated
16
- */
17
- phone: string;
18
- /**
19
- * Admin Email Updated
20
- */
21
- email: string;
22
- /**
23
- * Admin Password Updated
24
- */
25
- password: string;
26
- /**
27
- * Admin Role ID Updated
28
- */
29
- role_id: number;
30
- };
31
-
@@ -1,47 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- export type UpdateDriverDto = {
6
- /**
7
- * Driver First Name
8
- */
9
- first_name?: string;
10
- /**
11
- * Driver Last Name
12
- */
13
- last_name?: string;
14
- /**
15
- * Driver Phone Number (10 dígitos)
16
- */
17
- phone?: string;
18
- /**
19
- * Driver Email
20
- */
21
- email?: string;
22
- /**
23
- * Driver Password (6-20 caracteres)
24
- */
25
- password?: string;
26
- /**
27
- * Driver License Number
28
- */
29
- license?: string;
30
- /**
31
- * Driver Type (e.g., internal, external)
32
- */
33
- type?: string;
34
- /**
35
- * Driver State (activo/inactivo)
36
- */
37
- state?: boolean;
38
- /**
39
- * Last Location
40
- */
41
- last_location?: string;
42
- /**
43
- * Last Heartbeat
44
- */
45
- last_heartbeat?: string;
46
- };
47
-
@@ -1,27 +0,0 @@
1
- /* generated using openapi-typescript-codegen -- do not edit */
2
- /* istanbul ignore file */
3
- /* tslint:disable */
4
- /* eslint-disable */
5
- export type UpdateUserDto = {
6
- /**
7
- * First name of the user
8
- */
9
- first_name?: string;
10
- /**
11
- * Last name of the user
12
- */
13
- last_name?: string;
14
- /**
15
- * Phone number (10 digits)
16
- */
17
- phone?: string;
18
- /**
19
- * Unique email
20
- */
21
- email?: string;
22
- /**
23
- * Password (6-20 characters)
24
- */
25
- password?: string;
26
- };
27
-
package/models/index.ts DELETED
@@ -1,10 +0,0 @@
1
- export * from './AdminDto';
2
- export * from './CreateAdminDto';
3
- export * from './CreateDriverDto';
4
- export * from './CreateUserDto';
5
- export * from './DriverDto';
6
- export * from './LoginDto';
7
- export * from './UpdateAdminDto';
8
- export * from './UpdateDriverDto';
9
- export * from './UpdateUserDto';
10
- export * from './UserDto';
@@ -1,19 +0,0 @@
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
- }
package/socketService.ts DELETED
@@ -1,105 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- export class User {
2
- id: number;
3
- name: string;
4
- email: string;
5
- }
File without changes
File without changes
File without changes