meet-my-ride 1.0.3 → 1.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.
package/dist/client.d.ts CHANGED
@@ -2,7 +2,7 @@ import { UserService } from "./users";
2
2
  export declare class MeetMyRideClient {
3
3
  private baseUrl;
4
4
  private apiKey?;
5
- private http;
5
+ private readonly http;
6
6
  user: UserService;
7
7
  constructor(baseUrl: string, apiKey?: string | undefined);
8
8
  /**
@@ -1,14 +1,23 @@
1
1
  import { AxiosInstance } from "axios";
2
+ import { UserLogin, UserRegister, User, UserUpdate, UserRefreshResponse, AuthResponse, UserRegisterResponse, VerifyEmailResponse } from "./user.types";
2
3
  export declare class UserService {
3
4
  private http;
4
5
  private updateToken;
5
6
  constructor(http: AxiosInstance, updateToken: (token: string) => void);
6
- getAll(): Promise<any>;
7
- getById(userId: string): Promise<any>;
8
- update(userId: string, data: any): Promise<any>;
9
- delete(userId: string): Promise<any>;
10
- register(data: any): Promise<any>;
11
- login(data: any): Promise<any>;
12
- refresh(refreshToken: string): Promise<any>;
13
- verifyEmail(code: string): Promise<any>;
7
+ /** GET /api/Users */
8
+ getAll(): Promise<User[]>;
9
+ /** GET /api/Users/{userId} */
10
+ getById(userId: string): Promise<User>;
11
+ /** PUT /api/Users/{userId} */
12
+ update(userId: string, data: UserUpdate): Promise<User>;
13
+ /** DELETE /api/Users/{userId} */
14
+ delete(userId: string): Promise<void>;
15
+ /** POST /api/Users/register */
16
+ register(data: UserRegister): Promise<UserRegisterResponse>;
17
+ /** POST /api/Users/login */
18
+ login(data: UserLogin): Promise<AuthResponse>;
19
+ /** POST /api/Users/refresh */
20
+ refresh(refreshToken: string): Promise<UserRefreshResponse>;
21
+ /** POST /api/Users/verify-email */
22
+ verifyEmail(userId: string, token: string): Promise<VerifyEmailResponse>;
14
23
  }
@@ -6,41 +6,58 @@ class UserService {
6
6
  this.http = http;
7
7
  this.updateToken = updateToken;
8
8
  }
9
- getAll() {
10
- return this.http.get("/api/Users").then(r => r.data);
11
- }
12
- getById(userId) {
13
- return this.http.get(`/api/Users/${userId}`).then(r => r.data);
14
- }
15
- update(userId, data) {
16
- return this.http.put(`/api/Users/${userId}`, data).then(r => r.data);
17
- }
18
- delete(userId) {
19
- return this.http.delete(`/api/Users/${userId}`).then(r => r.data);
20
- }
21
- register(data) {
22
- return this.http.post("/api/Users/register", data).then(r => r.data);
23
- }
24
- login(data) {
25
- return this.http.post("/api/Users/login", data).then(response => {
26
- var _a;
27
- if ((_a = response.data) === null || _a === void 0 ? void 0 : _a.token) {
28
- this.updateToken(response.data.token);
29
- }
30
- return response.data;
9
+ /** GET /api/Users */
10
+ async getAll() {
11
+ const response = await this.http.get("/api/Users");
12
+ return response.data;
13
+ }
14
+ /** GET /api/Users/{userId} */
15
+ async getById(userId) {
16
+ const response = await this.http.get(`/api/Users/${userId}`);
17
+ return response.data;
18
+ }
19
+ /** PUT /api/Users/{userId} */
20
+ async update(userId, data) {
21
+ const response = await this.http.put(`/api/Users/${userId}`, data);
22
+ return response.data;
23
+ }
24
+ /** DELETE /api/Users/{userId} */
25
+ async delete(userId) {
26
+ await this.http.delete(`/api/Users/${userId}`);
27
+ }
28
+ /** POST /api/Users/register */
29
+ async register(data) {
30
+ const response = await this.http.post("/api/Users/register", data);
31
+ return response.data;
32
+ }
33
+ /** POST /api/Users/login */
34
+ async login(data) {
35
+ const response = await this.http.post("/api/Users/login", data);
36
+ const resData = response.data;
37
+ // Only update token if it exists
38
+ if (resData.accessToken) {
39
+ this.updateToken(resData.accessToken);
40
+ }
41
+ return resData;
42
+ }
43
+ /** POST /api/Users/refresh */
44
+ async refresh(refreshToken) {
45
+ const response = await this.http.post("/api/Users/refresh", {
46
+ refreshToken
31
47
  });
32
- }
33
- refresh(refreshToken) {
34
- return this.http.post("/api/Users/refresh", { refreshToken }).then(r => {
35
- var _a;
36
- if ((_a = r.data) === null || _a === void 0 ? void 0 : _a.token) {
37
- this.updateToken(r.data.token);
38
- }
39
- return r.data;
48
+ const resData = response.data;
49
+ if (resData.accessToken) {
50
+ this.updateToken(resData.accessToken);
51
+ }
52
+ return resData;
53
+ }
54
+ /** POST /api/Users/verify-email */
55
+ async verifyEmail(userId, token) {
56
+ const response = await this.http.post("/api/Users/verifyEmail", {
57
+ userId,
58
+ token
40
59
  });
41
- }
42
- verifyEmail(code) {
43
- return this.http.post("/api/Users/verify-email", { code }).then(r => r.data);
60
+ return response.data;
44
61
  }
45
62
  }
46
63
  exports.UserService = UserService;
@@ -0,0 +1,47 @@
1
+ export interface User {
2
+ id: string;
3
+ email: string;
4
+ emailVerified?: string;
5
+ firstName: string;
6
+ lastName: string;
7
+ username: string;
8
+ }
9
+ export interface UserLogin {
10
+ email: string;
11
+ password: string;
12
+ }
13
+ export interface AuthResponse {
14
+ user: User;
15
+ accessToken?: string;
16
+ refreshToken?: string;
17
+ }
18
+ export interface UserRegister {
19
+ email: string;
20
+ password: string;
21
+ firstName: string;
22
+ lastName: string;
23
+ username: string;
24
+ }
25
+ export interface UserRegisterResponse {
26
+ id: string;
27
+ username: string;
28
+ firstName: string;
29
+ lastName: string;
30
+ email: string;
31
+ }
32
+ export interface UserUpdate {
33
+ email?: string;
34
+ firstName?: string;
35
+ lastName?: string;
36
+ password?: string;
37
+ username?: string;
38
+ }
39
+ export interface UserRefreshResponse {
40
+ accessToken: string;
41
+ refreshToken?: string;
42
+ expiresIn?: number;
43
+ }
44
+ export interface VerifyEmailResponse {
45
+ message: string;
46
+ isVerified: boolean;
47
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // user.types.ts
3
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meet-my-ride",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Private library for the MeetMyRide applications",
5
5
  "repository": {
6
6
  "type": "git",