@dimrev4/fitness-v3-backend 0.0.3

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 (51) hide show
  1. package/.openapi-generator/FILES +30 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +423 -0
  5. package/api.ts +1870 -0
  6. package/base.ts +86 -0
  7. package/common.ts +150 -0
  8. package/configuration.ts +115 -0
  9. package/dist/api.d.ts +1285 -0
  10. package/dist/api.js +970 -0
  11. package/dist/base.d.ts +66 -0
  12. package/dist/base.js +65 -0
  13. package/dist/common.d.ts +65 -0
  14. package/dist/common.js +161 -0
  15. package/dist/configuration.d.ts +91 -0
  16. package/dist/configuration.js +44 -0
  17. package/dist/esm/api.d.ts +1285 -0
  18. package/dist/esm/api.js +959 -0
  19. package/dist/esm/base.d.ts +66 -0
  20. package/dist/esm/base.js +60 -0
  21. package/dist/esm/common.d.ts +65 -0
  22. package/dist/esm/common.js +149 -0
  23. package/dist/esm/configuration.d.ts +91 -0
  24. package/dist/esm/configuration.js +40 -0
  25. package/dist/esm/index.d.ts +13 -0
  26. package/dist/esm/index.js +15 -0
  27. package/dist/index.d.ts +13 -0
  28. package/dist/index.js +31 -0
  29. package/docs/AuthV1Api.md +257 -0
  30. package/docs/ConfirmOtpRequestDto.md +22 -0
  31. package/docs/CreateMeasurementRequestDto.md +26 -0
  32. package/docs/DeleteMeasurementResponseDto.md +22 -0
  33. package/docs/GetMeResponseDto.md +20 -0
  34. package/docs/GetMeasurementsResponseDto.md +30 -0
  35. package/docs/GroupDto.md +28 -0
  36. package/docs/LoginRequestDto.md +22 -0
  37. package/docs/LoginResponseDto.md +22 -0
  38. package/docs/LogoutResponseDto.md +20 -0
  39. package/docs/MeasurementDto.md +36 -0
  40. package/docs/MeasurementsV1Api.md +414 -0
  41. package/docs/RegisterRequestDto.md +24 -0
  42. package/docs/RegisterResponseDto.md +20 -0
  43. package/docs/UpdateMeasurementRequestDto.md +24 -0
  44. package/docs/UserDetailsDto.md +32 -0
  45. package/docs/UserDto.md +30 -0
  46. package/docs/UserToGroupDetailsDto.md +42 -0
  47. package/git_push.sh +57 -0
  48. package/index.ts +18 -0
  49. package/package.json +38 -0
  50. package/tsconfig.esm.json +7 -0
  51. package/tsconfig.json +18 -0
@@ -0,0 +1,30 @@
1
+ .gitignore
2
+ .npmignore
3
+ README.md
4
+ api.ts
5
+ base.ts
6
+ common.ts
7
+ configuration.ts
8
+ docs/AuthV1Api.md
9
+ docs/ConfirmOtpRequestDto.md
10
+ docs/CreateMeasurementRequestDto.md
11
+ docs/DeleteMeasurementResponseDto.md
12
+ docs/GetMeResponseDto.md
13
+ docs/GetMeasurementsResponseDto.md
14
+ docs/GroupDto.md
15
+ docs/LoginRequestDto.md
16
+ docs/LoginResponseDto.md
17
+ docs/LogoutResponseDto.md
18
+ docs/MeasurementDto.md
19
+ docs/MeasurementsV1Api.md
20
+ docs/RegisterRequestDto.md
21
+ docs/RegisterResponseDto.md
22
+ docs/UpdateMeasurementRequestDto.md
23
+ docs/UserDetailsDto.md
24
+ docs/UserDto.md
25
+ docs/UserToGroupDetailsDto.md
26
+ git_push.sh
27
+ index.ts
28
+ package.json
29
+ tsconfig.esm.json
30
+ tsconfig.json
@@ -0,0 +1 @@
1
+ 7.14.0
@@ -0,0 +1,23 @@
1
+ # OpenAPI Generator Ignore
2
+ # Generated by openapi-generator https://github.com/openapitools/openapi-generator
3
+
4
+ # Use this file to prevent files from being overwritten by the generator.
5
+ # The patterns follow closely to .gitignore or .dockerignore.
6
+
7
+ # As an example, the C# client generator defines ApiClient.cs.
8
+ # You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9
+ #ApiClient.cs
10
+
11
+ # You can match any string of characters against a directory, file or extension with a single asterisk (*):
12
+ #foo/*/qux
13
+ # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14
+
15
+ # You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16
+ #foo/**/qux
17
+ # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18
+
19
+ # You can also negate patterns with an exclamation (!).
20
+ # For example, you can ignore all files in a docs folder with the file extension .md:
21
+ #docs/*.md
22
+ # Then explicitly reverse the ignore rule for a single file:
23
+ #!docs/README.md
package/README.md ADDED
@@ -0,0 +1,423 @@
1
+ # @dimrev4/user-core SDK
2
+
3
+ <p align="center">
4
+ <img src="https://img.shields.io/npm/v/@dimrev4/user-core" alt="npm version" />
5
+ <img src="https://img.shields.io/npm/dm/@dimrev4/user-core" alt="npm downloads" />
6
+ <img src="https://img.shields.io/github/license/dimRev/user-core" alt="license" />
7
+ <img src="https://img.shields.io/badge/TypeScript-100%25-blue" alt="TypeScript" />
8
+ </p>
9
+
10
+ TypeScript SDK for User Core API - Comprehensive client for user management, authentication, groups, and permissions in fitness applications.
11
+
12
+ ## ๐Ÿš€ Features
13
+
14
+ - ๐Ÿ” JWT Authentication, Registration, Logout
15
+
16
+ - ๐Ÿ‘ฅ Full User CRUD with self-service endpoints
17
+
18
+ - ๐Ÿข Group management with membership control
19
+
20
+ - ๐Ÿ›ก๏ธ Granular permissions (system + group-level)
21
+
22
+ - ๐Ÿ“Š Pagination, filtering, and sorting support
23
+
24
+ - ๐Ÿ’ช 100% TypeScript with full type safety
25
+
26
+ - โšก Axios-based with interceptors support
27
+
28
+ ## ๐Ÿ“ฆ Installation
29
+
30
+ ```bash
31
+ npm install @dimrev4/user-core
32
+ # or
33
+ yarn add @dimrev4/user-core
34
+ # or
35
+ pnpm add @dimrev4/user-core
36
+ ```
37
+
38
+ ## ๐Ÿ”ง Quick Start
39
+
40
+ ### 1. Setup
41
+
42
+ ```typescript
43
+ import {
44
+ Configuration,
45
+ AuthV1Api,
46
+ UserV1Api,
47
+ GroupV1Api,
48
+ } from '@dimrev4/user-core';
49
+
50
+ const config = new Configuration({
51
+ basePath: 'https://api.yourdomain.com',
52
+ });
53
+
54
+ const authApi = new AuthV1Api(config);
55
+ const userApi = new UserV1Api(config);
56
+ const groupApi = new GroupV1Api(config);
57
+ ```
58
+
59
+ ### 2. Authentication
60
+
61
+ ```typescript
62
+ // Login
63
+ const loginResponse = await authApi.authV1ControllerLogin({
64
+ email: 'user@example.com',
65
+ password: 'securePassword123!',
66
+ });
67
+
68
+ const { user, accessToken } = loginResponse.data;
69
+
70
+ // Create authenticated client
71
+ const authConfig = new Configuration({
72
+ basePath: 'https://api.yourdomain.com',
73
+ accessToken,
74
+ });
75
+
76
+ const authenticatedUserApi = new UserV1Api(authConfig);
77
+ ```
78
+
79
+ ### 3. User Management
80
+
81
+ ```typescript
82
+ // Get current user
83
+ const me = await authenticatedUserApi.userV1ControllerGetUserSelf();
84
+ console.log('Current user:', me.data.username);
85
+
86
+ // List users with pagination
87
+ const users = await authenticatedUserApi.userV1ControllerGetUsers({
88
+ limit: 10,
89
+ offset: 0,
90
+ orderBy: 'createdAt',
91
+ });
92
+
93
+ // Create user
94
+ const newUser = await authenticatedUserApi.userV1ControllerCreate({
95
+ email: 'newuser@company.com',
96
+ username: 'newuser',
97
+ password: 'SecurePass123!',
98
+ });
99
+ ```
100
+
101
+ ### 4. Group Management
102
+
103
+ ```typescript
104
+ // Create group
105
+ const group = await groupApi.groupV1ControllerCreate({
106
+ name: 'Development Team',
107
+ userId: 'creator-user-id',
108
+ });
109
+
110
+ const groupId = group.data.id;
111
+
112
+ // Add user to group
113
+ const groupMembersApi = new GroupV1Api(authConfig);
114
+ await groupMembersApi.groupMembersV1ControllerAddUserToGroup(
115
+ groupId,
116
+ 'user-id',
117
+ {
118
+ canCreate: true,
119
+ canRead: true,
120
+ canUpdate: true,
121
+ canDelete: false,
122
+ },
123
+ );
124
+ ```
125
+
126
+ ## ๐Ÿ—๏ธ API Overview
127
+
128
+ ### Authentication (AuthV1Api)
129
+
130
+ - POST /api/auth/v1/login - Authenticate user
131
+ - POST /api/auth/v1/register - Create new account
132
+ - POST /api/auth/v1/logout - Invalidate session
133
+ - POST /api/auth/v1/get-me - Get current user info
134
+
135
+ ### User Management (UserV1Api)
136
+
137
+ - GET /api/users/v1 - List users (paginated)
138
+ - GET /api/users/v1/self - Get current user
139
+ - GET /api/users/v1/{id} - Get user by ID
140
+ - POST /api/users/v1 - Create user
141
+ - PUT /api/users/v1/self - Update own profile
142
+ - DELETE /api/users/v1/self - Delete own account
143
+
144
+ ### Group Management (GroupV1Api)
145
+
146
+ - GET /api/groups/v1 - List all groups
147
+ - GET /api/groups/v1/self - Get user's groups
148
+ - POST /api/groups/v1 - Create group
149
+ - PUT /api/groups/v1/{id} - Update group
150
+ - DELETE /api/groups/v1/{id} - Delete group
151
+
152
+ ### Group Members (GroupMembersV1Api)
153
+
154
+ - POST /api/groups/members/v1/{groupId}/{userId} - Add user to group
155
+ - PUT /api/groups/members/v1/{groupId}/{userId} - Update permissions
156
+ - DELETE /api/groups/members/v1/{groupId}/{userId} - Remove user
157
+
158
+ ## ๐Ÿ” Permissions
159
+
160
+ ### System Permissions
161
+
162
+ ```json
163
+ {
164
+ "user": {
165
+ "readAll": true, // List all users
166
+ "readOne": true, // View specific user
167
+ "create": true, // Create users
168
+ "update": true, // Update any user
169
+ "delete": true // Delete any user
170
+ },
171
+ "group": {
172
+ "readAll": true, // List all groups
173
+ "create": true, // Create groups
174
+ "update": true, // Update groups
175
+ "delete": true // Delete groups
176
+ }
177
+ }
178
+ ```
179
+
180
+ ### Group Permissions
181
+
182
+ ```json
183
+ {
184
+ "isRoot": true, // Full group admin
185
+ "canCreate": true, // Create group content
186
+ "canRead": true, // View group content
187
+ "canUpdate": true, // Modify group content
188
+ "canDelete": true // Delete group content
189
+ }
190
+ ```
191
+
192
+ ## ๐Ÿงช Error Handling
193
+
194
+ ```typescript
195
+ import { AxiosError } from 'axios';
196
+
197
+ try {
198
+ const users = await authenticatedUserApi.userV1ControllerGetUsers();
199
+ } catch (error) {
200
+ if (error instanceof AxiosError) {
201
+ switch (error.response?.status) {
202
+ case 400:
203
+ console.error('Validation failed:', error.response.data.message);
204
+ break;
205
+ case 401:
206
+ console.error('Unauthorized:', error.response.data.message);
207
+ // Handle token refresh or redirect
208
+ break;
209
+ case 403:
210
+ console.error('Forbidden: Insufficient permissions');
211
+ break;
212
+ case 404:
213
+ console.error('Resource not found');
214
+ break;
215
+ case 409:
216
+ console.error('Conflict:', error.response.data.message);
217
+ break;
218
+ default:
219
+ console.error('API Error:', error.message);
220
+ }
221
+ }
222
+ }
223
+ ```
224
+
225
+ ## โš™๏ธ Advanced Configuration
226
+
227
+ ### Custom Axios Instance
228
+
229
+ ```typescript
230
+ import axios from 'axios';
231
+ import { Configuration, UserV1Api } from '@dimrev4/user-core';
232
+
233
+ const axiosInstance = axios.create({
234
+ timeout: 15000,
235
+ });
236
+
237
+ // Add auth token automatically
238
+ axiosInstance.interceptors.request.use((config) => {
239
+ const token = localStorage.getItem('access_token');
240
+ if (token) {
241
+ config.headers.Authorization = `Bearer ${token}`;
242
+ }
243
+ return config;
244
+ });
245
+
246
+ const config = new Configuration({});
247
+ const userApi = new UserV1Api(config, undefined, axiosInstance);
248
+ ```
249
+
250
+ ### Environment Setup
251
+
252
+ ```typescript
253
+ const config = new Configuration({
254
+ basePath:
255
+ process.env.NODE_ENV === 'production'
256
+ ? 'https://api.yourdomain.com'
257
+ : 'http://localhost:3000/api',
258
+ timeout: 10000,
259
+ accessToken: process.env.API_TOKEN,
260
+ });
261
+ ```
262
+
263
+ ## ๐ŸŒ Pagination & Filtering
264
+
265
+ ```typescript
266
+ const users = await authenticatedUserApi.userV1ControllerGetUsers({
267
+ // Pagination
268
+ offset: 0,
269
+ limit: 25,
270
+
271
+ // Filtering
272
+ username: 'john',
273
+ email: 'company.com',
274
+
275
+ // Sorting
276
+ orderBy: 'createdAt', // createdAt, updatedAt, username, email
277
+ });
278
+
279
+ console.log(`${users.data.totalItems} users found`);
280
+ console.log(`Page ${users.data.currentPage} of ${users.data.totalPages}`);
281
+ ```
282
+
283
+ ## ๐Ÿงช Testing
284
+
285
+ ### Mock with MSW
286
+
287
+ ```typescript
288
+ import { rest } from 'msw';
289
+ import { setupServer } from 'msw/node';
290
+ import { UserV1Api } from '@dimrev4/user-core';
291
+
292
+ const server = setupServer(
293
+ rest.get('*/api/users/v1/self', (req, res, ctx) => {
294
+ return res(
295
+ ctx.status(200),
296
+ ctx.json({
297
+ id: '1',
298
+ username: 'testuser',
299
+ email: 'test@example.com',
300
+ createdAt: new Date().toISOString(),
301
+ updatedAt: new Date().toISOString(),
302
+ deletedAt: null,
303
+ userToGroup: [],
304
+ }),
305
+ );
306
+ }),
307
+ );
308
+
309
+ beforeAll(() => server.listen());
310
+ afterAll(() => server.close());
311
+
312
+ test('gets current user', async () => {
313
+ const config = new Configuration({ basePath: 'http://localhost' });
314
+ const api = new UserV1Api(config);
315
+
316
+ const response = await api.userV1ControllerGetUserSelf();
317
+ expect(response.data.username).toBe('testuser');
318
+ });
319
+ ```
320
+
321
+ ## ๐Ÿšจ Common Issues
322
+
323
+ | Issue | Solution |
324
+ | ---------------------- | --------------------------------------- |
325
+ | 401 Unauthorized | Set accessToken in Configuration |
326
+ | 403 Forbidden | Check required permissions for endpoint |
327
+ | CORS Error | Configure API CORS or use proxy in dev |
328
+ | Token not sent | Use accessToken parameter in config |
329
+ | Validation Error (400) | Check request body against DTO schema |
330
+
331
+ ### Token Management Helper
332
+
333
+ ```typescript
334
+ class AuthManager {
335
+ static login(email: string, password: string, config: Configuration) {
336
+ const authApi = new AuthV1Api(config);
337
+ return authApi
338
+ .authV1ControllerLogin({ email, password })
339
+ .then((response) => {
340
+ config.accessToken = response.data.accessToken;
341
+ localStorage.setItem('access_token', response.data.accessToken);
342
+ return response.data.user;
343
+ });
344
+ }
345
+
346
+ static logout(config: Configuration) {
347
+ localStorage.removeItem('access_token');
348
+ config.accessToken = '';
349
+ }
350
+
351
+ static getAuthenticatedConfig(baseUrl: string): Configuration {
352
+ return new Configuration({
353
+ basePath: baseUrl,
354
+ accessToken: localStorage.getItem('access_token') || '',
355
+ });
356
+ }
357
+ }
358
+
359
+ // Usage
360
+ const config = AuthManager.getAuthenticatedConfig('https://api.example.com');
361
+ const userApi = new UserV1Api(config);
362
+ ```
363
+
364
+ ## ๐Ÿ“Š TypeScript Types
365
+
366
+ Key interfaces for type safety:
367
+
368
+ ```typescript
369
+ interface CreateUserRequestDto {
370
+ email: string;
371
+ username: string;
372
+ password: string;
373
+ }
374
+
375
+ interface UserDetailsDto {
376
+ id: string;
377
+ username: string;
378
+ email: string;
379
+ createdAt: string;
380
+ updatedAt: string;
381
+ deletedAt: string | null;
382
+ userToGroup: UserToGroupDetailsDto[];
383
+ }
384
+
385
+ interface GroupDetailsDto {
386
+ id: string;
387
+ name: string;
388
+ createdAt: string;
389
+ updatedAt: string;
390
+ deletedAt: string | null;
391
+ userToGroup: UserToGroupDetailsDto[];
392
+ }
393
+
394
+ interface UserToGroupDetailsDto {
395
+ groupId: string;
396
+ userId: string;
397
+ canCreate: boolean;
398
+ canRead: boolean;
399
+ canUpdate: boolean;
400
+ canDelete: boolean;
401
+ isRoot: boolean;
402
+ group: GroupDto;
403
+ user: UserDto;
404
+ }
405
+ ```
406
+
407
+ ## ๐Ÿ”— Resources
408
+
409
+ - API Docs: Available at /api endpoint (Swagger UI)
410
+ - Repository: GitHub
411
+ - Issues: GitHub Issues
412
+ - License: Unlicense
413
+
414
+ ## ๐Ÿค Contributing
415
+
416
+ 1. Fork the repository
417
+ 2. Update OpenAPI spec for new features
418
+ 3. Run npm run generate to rebuild SDK
419
+ 4. Submit pull request with tests
420
+
421
+ ---
422
+
423
+ Auto-generated from User Core API v0.0 | Last Updated: Oct 2025