@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/.npmrc.publish +2 -0
- package/.release.config.js +17 -0
- package/README.md +176 -0
- package/core/ApiError.ts +25 -0
- package/core/ApiRequestOptions.ts +17 -0
- package/core/ApiResult.ts +11 -0
- package/core/CancelablePromise.ts +131 -0
- package/core/OpenAPI.ts +32 -0
- package/core/index.ts +6 -0
- package/core/request.ts +322 -0
- package/createClient.ts +12 -0
- package/index.ts +10 -0
- package/models/AdminDto.ts +31 -0
- package/models/CreateAdminDto.ts +31 -0
- package/models/CreateDriverDto.ts +47 -0
- package/models/CreateUserDto.ts +27 -0
- package/models/DriverDto.ts +47 -0
- package/models/LoginDto.ts +15 -0
- package/models/UpdateAdminDto.ts +31 -0
- package/models/UpdateDriverDto.ts +47 -0
- package/models/UpdateUserDto.ts +27 -0
- package/models/UserDto.ts +27 -0
- package/models/index.ts +10 -0
- package/package.json +24 -0
- package/services/AdminService.ts +122 -0
- package/services/DriversService.ts +122 -0
- package/services/LoginsService.ts +67 -0
- package/services/MainService.ts +19 -0
- package/services/UsersService.ts +123 -0
- package/services/index.ts +5 -0
- package/socketService.ts +105 -0
- package/types/driver-location.entity.ts +13 -0
- package/types/index.ts +2 -0
- package/types/user.entity.ts +5 -0
package/.npmrc.publish
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
branches: ['main'],
|
|
3
|
+
tagFormat: 'sdk-v${version}',
|
|
4
|
+
plugins: [
|
|
5
|
+
'@semantic-release/commit-analyzer',
|
|
6
|
+
'@semantic-release/release-notes-generator',
|
|
7
|
+
[
|
|
8
|
+
'@semantic-release/npm',
|
|
9
|
+
{
|
|
10
|
+
pkgRoot: 'sdk',
|
|
11
|
+
npmPublish: true,
|
|
12
|
+
access: 'public',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
'@semantic-release/github',
|
|
16
|
+
],
|
|
17
|
+
};
|
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# 📦 @dapex-tech/elite-online-services
|
|
2
|
+
|
|
3
|
+
A client library to connect with the **Elite Online App**.
|
|
4
|
+
This package provides a simple interface to request information from the **Elite Online REST API**.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🛠 API Coverage
|
|
9
|
+
|
|
10
|
+
This client includes typed interfaces for the Elite Online REST API, including:
|
|
11
|
+
|
|
12
|
+
- **MainService** → Core endpoints of Elite Online App
|
|
13
|
+
- **SocketService** → Real-time events (if enabled)
|
|
14
|
+
- **CancelablePromise** → Control async requests
|
|
15
|
+
- **Request utilities** → Custom API requests
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🚀 Installation
|
|
20
|
+
|
|
21
|
+
Using **npm**:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @dapex-tech/elite-online-services
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Using **Yarn**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add @dapex-tech/elite-online-services
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🔑 Authentication
|
|
36
|
+
|
|
37
|
+
Before making requests, configure the client with your **API key** or **auth token** (depending on how the Elite Online App issues credentials).
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { OpenAPI } from '@dapex-tech/elite-online-services';
|
|
41
|
+
|
|
42
|
+
OpenAPI.TOKEN = 'your_api_token_here';
|
|
43
|
+
OpenAPI.BASE = 'https://api.eliteonlineapp.com';
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 📘 Usage Example
|
|
49
|
+
|
|
50
|
+
### Import the client
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { MainService } from '@dapex-tech/elite-online-services';
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Make a request
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
async function run() {
|
|
60
|
+
try {
|
|
61
|
+
const data = await MainService.getUserProfile({ userId: 123 });
|
|
62
|
+
console.log('User profile:', data);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('API error:', error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
run();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🔌 Socket Usage
|
|
74
|
+
|
|
75
|
+
This package includes a `SocketService` class that wraps **socket.io-client** and provides convenient methods to work with real-time events.
|
|
76
|
+
|
|
77
|
+
### Import and Connect
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { SocketService } from '@dapex-tech/elite-online-services';
|
|
81
|
+
|
|
82
|
+
const socket = new SocketService('https://your-api-base-url');
|
|
83
|
+
|
|
84
|
+
// Connect to the socket
|
|
85
|
+
socket.connect();
|
|
86
|
+
|
|
87
|
+
// Disconnect when done
|
|
88
|
+
// socket.disconnect();
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Sending and Receiving Messages
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
// Send a message
|
|
95
|
+
socket.sendMessage('Hello world!');
|
|
96
|
+
|
|
97
|
+
// Listen for incoming messages
|
|
98
|
+
socket.onMessageReceived((data) => {
|
|
99
|
+
console.log('Message received:', data.text);
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Updating and Listening to Location Events
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
// Emit a location update
|
|
107
|
+
socket.updateLocation({ lat: 35.9185, lng: -110.7258, clientID: '12345' });
|
|
108
|
+
|
|
109
|
+
// Listen for location updates from the server
|
|
110
|
+
socket.onLocationUpdated((data) => {
|
|
111
|
+
console.log('Location updated:', data);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Listen for all active client locations
|
|
115
|
+
socket.onAllLocations((locations) => {
|
|
116
|
+
console.log('All locations:', locations);
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Removing Listeners
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
// Remove a specific listener
|
|
124
|
+
socket.offMessageReceived(myMessageHandler);
|
|
125
|
+
|
|
126
|
+
// Or remove all listeners for an event
|
|
127
|
+
socket.off('locationUpdated');
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## ⚙️ Configuration
|
|
133
|
+
|
|
134
|
+
You can configure global client settings via `OpenAPI`:
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
import { OpenAPI } from '@dapex-tech/elite-online-services';
|
|
138
|
+
|
|
139
|
+
OpenAPI.BASE = 'https://api.eliteonlineapp.com';
|
|
140
|
+
OpenAPI.TOKEN = 'my-secret-token';
|
|
141
|
+
OpenAPI.WITH_CREDENTIALS = true;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 📄 TypeScript Support
|
|
147
|
+
|
|
148
|
+
The client is written in **TypeScript**, so you get full type definitions out of the box.
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
import { ApiResult } from '@dapex-tech/elite-online-services';
|
|
152
|
+
|
|
153
|
+
const result: ApiResult = {
|
|
154
|
+
ok: true,
|
|
155
|
+
status: 200,
|
|
156
|
+
body: { message: 'success' },
|
|
157
|
+
};
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 🤝 Contributing
|
|
163
|
+
|
|
164
|
+
Contributions are welcome!
|
|
165
|
+
|
|
166
|
+
1. Fork the repo
|
|
167
|
+
2. Create a feature branch (`git checkout -b feature/my-feature`)
|
|
168
|
+
3. Commit your changes (`git commit -m 'Add new feature'`)
|
|
169
|
+
4. Push to your branch (`git push origin feature/my-feature`)
|
|
170
|
+
5. Open a Pull Request
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 📜 License
|
|
175
|
+
|
|
176
|
+
[MIT](./LICENSE) © 2025 Dapex Tech
|
package/core/ApiError.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export type ApiRequestOptions = {
|
|
6
|
+
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly path?: Record<string, any>;
|
|
9
|
+
readonly cookies?: Record<string, any>;
|
|
10
|
+
readonly headers?: Record<string, any>;
|
|
11
|
+
readonly query?: Record<string, any>;
|
|
12
|
+
readonly formData?: Record<string, any>;
|
|
13
|
+
readonly body?: any;
|
|
14
|
+
readonly mediaType?: string;
|
|
15
|
+
readonly responseHeader?: string;
|
|
16
|
+
readonly errors?: Record<number, string>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export type ApiResult = {
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly ok: boolean;
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly statusText: string;
|
|
10
|
+
readonly body: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
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/core/OpenAPI.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
|
|
7
|
+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
8
|
+
type Headers = Record<string, string>;
|
|
9
|
+
|
|
10
|
+
export type OpenAPIConfig = {
|
|
11
|
+
BASE: string;
|
|
12
|
+
VERSION: string;
|
|
13
|
+
WITH_CREDENTIALS: boolean;
|
|
14
|
+
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
|
15
|
+
TOKEN?: string | Resolver<string> | undefined;
|
|
16
|
+
USERNAME?: string | Resolver<string> | undefined;
|
|
17
|
+
PASSWORD?: string | Resolver<string> | undefined;
|
|
18
|
+
HEADERS?: Headers | Resolver<Headers> | undefined;
|
|
19
|
+
ENCODE_PATH?: ((path: string) => string) | undefined;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const OpenAPI: OpenAPIConfig = {
|
|
23
|
+
BASE: '',
|
|
24
|
+
VERSION: '1.0',
|
|
25
|
+
WITH_CREDENTIALS: false,
|
|
26
|
+
CREDENTIALS: 'include',
|
|
27
|
+
TOKEN: undefined,
|
|
28
|
+
USERNAME: undefined,
|
|
29
|
+
PASSWORD: undefined,
|
|
30
|
+
HEADERS: undefined,
|
|
31
|
+
ENCODE_PATH: undefined,
|
|
32
|
+
};
|