@vitalfit/sdk 0.0.2
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/index.d.mts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +285 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +245 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +33 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
type ClientConfig = {
|
|
2
|
+
url: string;
|
|
3
|
+
jwt?: string;
|
|
4
|
+
data?: object;
|
|
5
|
+
params?: object;
|
|
6
|
+
};
|
|
7
|
+
declare class Client {
|
|
8
|
+
private client;
|
|
9
|
+
jwt?: string;
|
|
10
|
+
constructor(isDevMode: boolean, origin?: string);
|
|
11
|
+
call(method: string, config: ClientConfig): Promise<Response>;
|
|
12
|
+
get(config: ClientConfig): Promise<Response | {
|
|
13
|
+
data: any[];
|
|
14
|
+
count: number;
|
|
15
|
+
next: string | null;
|
|
16
|
+
previous: string | null;
|
|
17
|
+
}>;
|
|
18
|
+
post(config: ClientConfig): Promise<Response>;
|
|
19
|
+
put(config: ClientConfig): Promise<Response>;
|
|
20
|
+
patch(config: ClientConfig): Promise<Response>;
|
|
21
|
+
delete(config: ClientConfig): Promise<Response>;
|
|
22
|
+
setJWT(jwt: string): void;
|
|
23
|
+
removeJWT(): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type PaginationRequest = {
|
|
27
|
+
page?: number;
|
|
28
|
+
limit?: number;
|
|
29
|
+
q?: string;
|
|
30
|
+
};
|
|
31
|
+
type Pagination<T> = {
|
|
32
|
+
data: T[];
|
|
33
|
+
count: number;
|
|
34
|
+
next: string | null;
|
|
35
|
+
previous: string | null;
|
|
36
|
+
};
|
|
37
|
+
type UUIDModel = {
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
type BaseModel = UUIDModel & {
|
|
41
|
+
createdAt: string;
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
deletedAt: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare enum UserGender {
|
|
47
|
+
MALE = "male",
|
|
48
|
+
FEMALE = "female"
|
|
49
|
+
}
|
|
50
|
+
type LoginRequest = {
|
|
51
|
+
email: string;
|
|
52
|
+
password: string;
|
|
53
|
+
context?: string;
|
|
54
|
+
};
|
|
55
|
+
type LoginResponse = {
|
|
56
|
+
accessToken: string;
|
|
57
|
+
};
|
|
58
|
+
type SignUpRequest = {
|
|
59
|
+
firstName: string;
|
|
60
|
+
lastName: string;
|
|
61
|
+
email: string;
|
|
62
|
+
password: string;
|
|
63
|
+
documentId: string;
|
|
64
|
+
phoneNumber?: string | null;
|
|
65
|
+
birthDate: string;
|
|
66
|
+
gender?: UserGender | null;
|
|
67
|
+
profilePictureUrl?: string | null;
|
|
68
|
+
roleName?: string | null;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type ClientProfile = {
|
|
72
|
+
user_id: string;
|
|
73
|
+
qr_code: string;
|
|
74
|
+
scoring: number;
|
|
75
|
+
status: string;
|
|
76
|
+
block_justification: string;
|
|
77
|
+
category: string;
|
|
78
|
+
created_at: string;
|
|
79
|
+
updated_at: string;
|
|
80
|
+
deleted_at: string | null;
|
|
81
|
+
};
|
|
82
|
+
type Role = {
|
|
83
|
+
role_id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
level: number;
|
|
86
|
+
description: string;
|
|
87
|
+
created_at: string;
|
|
88
|
+
updated_at: string;
|
|
89
|
+
};
|
|
90
|
+
type User = {
|
|
91
|
+
user_id: string;
|
|
92
|
+
first_name: string;
|
|
93
|
+
last_name: string;
|
|
94
|
+
email: string;
|
|
95
|
+
phone: string;
|
|
96
|
+
identity_document: string;
|
|
97
|
+
birth_date: string;
|
|
98
|
+
gender: string;
|
|
99
|
+
profile_picture_url: string;
|
|
100
|
+
is_validated: boolean;
|
|
101
|
+
ClientProfile: ClientProfile;
|
|
102
|
+
role_id: string;
|
|
103
|
+
role: Role;
|
|
104
|
+
created_at: string;
|
|
105
|
+
updated_at: string;
|
|
106
|
+
deleted_at: string | null;
|
|
107
|
+
};
|
|
108
|
+
type UserApiResponse = {
|
|
109
|
+
user: User;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
declare class AuthService {
|
|
113
|
+
private client;
|
|
114
|
+
constructor(client: Client);
|
|
115
|
+
login({ email, password, context }: LoginRequest): Promise<LoginResponse>;
|
|
116
|
+
logout(): void;
|
|
117
|
+
saveJWT(jwt: string): void;
|
|
118
|
+
signUp(signUpData: SignUpRequest): Promise<void>;
|
|
119
|
+
signUpStaff(signUpData: SignUpRequest): Promise<void>;
|
|
120
|
+
forgotPassword(email: string): Promise<void>;
|
|
121
|
+
resetPassword(otp: string, password: string, repeatPassword: string): Promise<void>;
|
|
122
|
+
verifyEmail(otp: string): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class UserService {
|
|
126
|
+
client: Client;
|
|
127
|
+
constructor(client: Client);
|
|
128
|
+
WhoAmI(): Promise<UserApiResponse>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare class APIError extends Error {
|
|
132
|
+
status: number;
|
|
133
|
+
messages: string[];
|
|
134
|
+
constructor(messages: string[], status: number);
|
|
135
|
+
}
|
|
136
|
+
declare const isAPIError: (error: unknown) => error is APIError;
|
|
137
|
+
|
|
138
|
+
declare class VitalFit {
|
|
139
|
+
private static instance;
|
|
140
|
+
client: Client;
|
|
141
|
+
auth: AuthService;
|
|
142
|
+
user: UserService;
|
|
143
|
+
constructor(isDevMode: boolean, origin?: string);
|
|
144
|
+
static getInstance(isDevMode?: boolean): VitalFit;
|
|
145
|
+
version(): string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { APIError, type BaseModel, type ClientProfile, type LoginRequest, type LoginResponse, type Pagination, type PaginationRequest, type Role, type SignUpRequest, type UUIDModel, type User, type UserApiResponse, UserGender, VitalFit, isAPIError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
type ClientConfig = {
|
|
2
|
+
url: string;
|
|
3
|
+
jwt?: string;
|
|
4
|
+
data?: object;
|
|
5
|
+
params?: object;
|
|
6
|
+
};
|
|
7
|
+
declare class Client {
|
|
8
|
+
private client;
|
|
9
|
+
jwt?: string;
|
|
10
|
+
constructor(isDevMode: boolean, origin?: string);
|
|
11
|
+
call(method: string, config: ClientConfig): Promise<Response>;
|
|
12
|
+
get(config: ClientConfig): Promise<Response | {
|
|
13
|
+
data: any[];
|
|
14
|
+
count: number;
|
|
15
|
+
next: string | null;
|
|
16
|
+
previous: string | null;
|
|
17
|
+
}>;
|
|
18
|
+
post(config: ClientConfig): Promise<Response>;
|
|
19
|
+
put(config: ClientConfig): Promise<Response>;
|
|
20
|
+
patch(config: ClientConfig): Promise<Response>;
|
|
21
|
+
delete(config: ClientConfig): Promise<Response>;
|
|
22
|
+
setJWT(jwt: string): void;
|
|
23
|
+
removeJWT(): void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
type PaginationRequest = {
|
|
27
|
+
page?: number;
|
|
28
|
+
limit?: number;
|
|
29
|
+
q?: string;
|
|
30
|
+
};
|
|
31
|
+
type Pagination<T> = {
|
|
32
|
+
data: T[];
|
|
33
|
+
count: number;
|
|
34
|
+
next: string | null;
|
|
35
|
+
previous: string | null;
|
|
36
|
+
};
|
|
37
|
+
type UUIDModel = {
|
|
38
|
+
id: string;
|
|
39
|
+
};
|
|
40
|
+
type BaseModel = UUIDModel & {
|
|
41
|
+
createdAt: string;
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
deletedAt: string | null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
declare enum UserGender {
|
|
47
|
+
MALE = "male",
|
|
48
|
+
FEMALE = "female"
|
|
49
|
+
}
|
|
50
|
+
type LoginRequest = {
|
|
51
|
+
email: string;
|
|
52
|
+
password: string;
|
|
53
|
+
context?: string;
|
|
54
|
+
};
|
|
55
|
+
type LoginResponse = {
|
|
56
|
+
accessToken: string;
|
|
57
|
+
};
|
|
58
|
+
type SignUpRequest = {
|
|
59
|
+
firstName: string;
|
|
60
|
+
lastName: string;
|
|
61
|
+
email: string;
|
|
62
|
+
password: string;
|
|
63
|
+
documentId: string;
|
|
64
|
+
phoneNumber?: string | null;
|
|
65
|
+
birthDate: string;
|
|
66
|
+
gender?: UserGender | null;
|
|
67
|
+
profilePictureUrl?: string | null;
|
|
68
|
+
roleName?: string | null;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
type ClientProfile = {
|
|
72
|
+
user_id: string;
|
|
73
|
+
qr_code: string;
|
|
74
|
+
scoring: number;
|
|
75
|
+
status: string;
|
|
76
|
+
block_justification: string;
|
|
77
|
+
category: string;
|
|
78
|
+
created_at: string;
|
|
79
|
+
updated_at: string;
|
|
80
|
+
deleted_at: string | null;
|
|
81
|
+
};
|
|
82
|
+
type Role = {
|
|
83
|
+
role_id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
level: number;
|
|
86
|
+
description: string;
|
|
87
|
+
created_at: string;
|
|
88
|
+
updated_at: string;
|
|
89
|
+
};
|
|
90
|
+
type User = {
|
|
91
|
+
user_id: string;
|
|
92
|
+
first_name: string;
|
|
93
|
+
last_name: string;
|
|
94
|
+
email: string;
|
|
95
|
+
phone: string;
|
|
96
|
+
identity_document: string;
|
|
97
|
+
birth_date: string;
|
|
98
|
+
gender: string;
|
|
99
|
+
profile_picture_url: string;
|
|
100
|
+
is_validated: boolean;
|
|
101
|
+
ClientProfile: ClientProfile;
|
|
102
|
+
role_id: string;
|
|
103
|
+
role: Role;
|
|
104
|
+
created_at: string;
|
|
105
|
+
updated_at: string;
|
|
106
|
+
deleted_at: string | null;
|
|
107
|
+
};
|
|
108
|
+
type UserApiResponse = {
|
|
109
|
+
user: User;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
declare class AuthService {
|
|
113
|
+
private client;
|
|
114
|
+
constructor(client: Client);
|
|
115
|
+
login({ email, password, context }: LoginRequest): Promise<LoginResponse>;
|
|
116
|
+
logout(): void;
|
|
117
|
+
saveJWT(jwt: string): void;
|
|
118
|
+
signUp(signUpData: SignUpRequest): Promise<void>;
|
|
119
|
+
signUpStaff(signUpData: SignUpRequest): Promise<void>;
|
|
120
|
+
forgotPassword(email: string): Promise<void>;
|
|
121
|
+
resetPassword(otp: string, password: string, repeatPassword: string): Promise<void>;
|
|
122
|
+
verifyEmail(otp: string): Promise<void>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare class UserService {
|
|
126
|
+
client: Client;
|
|
127
|
+
constructor(client: Client);
|
|
128
|
+
WhoAmI(): Promise<UserApiResponse>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
declare class APIError extends Error {
|
|
132
|
+
status: number;
|
|
133
|
+
messages: string[];
|
|
134
|
+
constructor(messages: string[], status: number);
|
|
135
|
+
}
|
|
136
|
+
declare const isAPIError: (error: unknown) => error is APIError;
|
|
137
|
+
|
|
138
|
+
declare class VitalFit {
|
|
139
|
+
private static instance;
|
|
140
|
+
client: Client;
|
|
141
|
+
auth: AuthService;
|
|
142
|
+
user: UserService;
|
|
143
|
+
constructor(isDevMode: boolean, origin?: string);
|
|
144
|
+
static getInstance(isDevMode?: boolean): VitalFit;
|
|
145
|
+
version(): string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { APIError, type BaseModel, type ClientProfile, type LoginRequest, type LoginResponse, type Pagination, type PaginationRequest, type Role, type SignUpRequest, type UUIDModel, type User, type UserApiResponse, UserGender, VitalFit, isAPIError };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
APIError: () => APIError,
|
|
34
|
+
UserGender: () => UserGender,
|
|
35
|
+
VitalFit: () => VitalFit,
|
|
36
|
+
isAPIError: () => isAPIError
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(index_exports);
|
|
39
|
+
|
|
40
|
+
// src/client.ts
|
|
41
|
+
var import_axios = __toESM(require("axios"));
|
|
42
|
+
|
|
43
|
+
// src/settings.ts
|
|
44
|
+
var BASE_URL = "";
|
|
45
|
+
var DEV_URL = "https://api-rm8x.onrender.com/v1";
|
|
46
|
+
|
|
47
|
+
// src/errors/errors.ts
|
|
48
|
+
var APIError = class extends Error {
|
|
49
|
+
status;
|
|
50
|
+
messages;
|
|
51
|
+
constructor(messages, status) {
|
|
52
|
+
super(messages.join(", "));
|
|
53
|
+
this.status = status;
|
|
54
|
+
this.messages = messages;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var isAPIError = (error) => {
|
|
58
|
+
return error instanceof APIError;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// src/client.ts
|
|
62
|
+
var Client = class {
|
|
63
|
+
client;
|
|
64
|
+
jwt;
|
|
65
|
+
constructor(isDevMode, origin) {
|
|
66
|
+
let headers = {
|
|
67
|
+
"Content-Type": "application/json"
|
|
68
|
+
};
|
|
69
|
+
if (origin) {
|
|
70
|
+
headers["Origin"] = origin;
|
|
71
|
+
}
|
|
72
|
+
this.client = import_axios.default.create({
|
|
73
|
+
baseURL: isDevMode ? DEV_URL : BASE_URL,
|
|
74
|
+
headers
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async call(method, config) {
|
|
78
|
+
if (config.jwt) {
|
|
79
|
+
this.client.interceptors.request.use((axiosConfig) => {
|
|
80
|
+
if (axiosConfig.headers) {
|
|
81
|
+
axiosConfig.headers["Authorization"] = `Bearer ${config.jwt}`;
|
|
82
|
+
}
|
|
83
|
+
return axiosConfig;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
const response = await this.client.request({
|
|
88
|
+
method,
|
|
89
|
+
url: config.url,
|
|
90
|
+
data: config.data,
|
|
91
|
+
params: config.params
|
|
92
|
+
});
|
|
93
|
+
this.client.interceptors.request.clear();
|
|
94
|
+
return response.data;
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (import_axios.default.isAxiosError(error)) {
|
|
97
|
+
const errorMessage = error.response?.data?.error;
|
|
98
|
+
if (typeof errorMessage === "string") {
|
|
99
|
+
throw new APIError([errorMessage], error.response?.status ?? 500);
|
|
100
|
+
}
|
|
101
|
+
throw new APIError(["Ocurri\xF3 un error inesperado"], error.response?.status ?? 500);
|
|
102
|
+
}
|
|
103
|
+
throw new Error(error);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async get(config) {
|
|
107
|
+
const isPaginated = config.params && "page" in config.params;
|
|
108
|
+
if (isPaginated) {
|
|
109
|
+
const response = await this.call("get", config);
|
|
110
|
+
if ("results" in response) {
|
|
111
|
+
const data = response;
|
|
112
|
+
return {
|
|
113
|
+
data: data.data,
|
|
114
|
+
count: data.count,
|
|
115
|
+
next: data.next,
|
|
116
|
+
previous: data.previous
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
throw new Error("Expected Pagination response");
|
|
120
|
+
} else {
|
|
121
|
+
const data = await this.call("get", config);
|
|
122
|
+
return data;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
async post(config) {
|
|
126
|
+
const data = await this.call("post", config);
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
async put(config) {
|
|
130
|
+
const data = await this.call("put", config);
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
async patch(config) {
|
|
134
|
+
const data = await this.call("patch", config);
|
|
135
|
+
return data;
|
|
136
|
+
}
|
|
137
|
+
async delete(config) {
|
|
138
|
+
const data = await this.call("delete", config);
|
|
139
|
+
return data;
|
|
140
|
+
}
|
|
141
|
+
setJWT(jwt) {
|
|
142
|
+
this.jwt = jwt;
|
|
143
|
+
}
|
|
144
|
+
removeJWT() {
|
|
145
|
+
this.jwt = void 0;
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// src/services/auth.ts
|
|
150
|
+
var AuthService = class {
|
|
151
|
+
client;
|
|
152
|
+
constructor(client) {
|
|
153
|
+
this.client = client;
|
|
154
|
+
this.login = this.login.bind(this);
|
|
155
|
+
this.signUp = this.signUp.bind(this);
|
|
156
|
+
this.signUpStaff = this.signUpStaff.bind(this);
|
|
157
|
+
this.forgotPassword = this.forgotPassword.bind(this);
|
|
158
|
+
this.resetPassword = this.resetPassword.bind(this);
|
|
159
|
+
this.verifyEmail = this.verifyEmail.bind(this);
|
|
160
|
+
this.logout = this.logout.bind(this);
|
|
161
|
+
this.saveJWT = this.saveJWT.bind(this);
|
|
162
|
+
}
|
|
163
|
+
async login({ email, password, context }) {
|
|
164
|
+
const response = await this.client.post({
|
|
165
|
+
url: "/auth/login",
|
|
166
|
+
data: {
|
|
167
|
+
email,
|
|
168
|
+
password,
|
|
169
|
+
context
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
return response;
|
|
173
|
+
}
|
|
174
|
+
logout() {
|
|
175
|
+
this.client.removeJWT();
|
|
176
|
+
}
|
|
177
|
+
saveJWT(jwt) {
|
|
178
|
+
this.client.setJWT(jwt);
|
|
179
|
+
}
|
|
180
|
+
async signUp(signUpData) {
|
|
181
|
+
const birthDateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
182
|
+
if (signUpData.roleName != "client") {
|
|
183
|
+
throw new Error("Only clients can sign up using this method");
|
|
184
|
+
}
|
|
185
|
+
if (!birthDateRegex.test(signUpData.birthDate)) {
|
|
186
|
+
throw new Error(
|
|
187
|
+
"Birth date must be in the format YYYY-MM-DD"
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
await this.client.post({
|
|
191
|
+
url: "/auth/register",
|
|
192
|
+
data: signUpData
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async signUpStaff(signUpData) {
|
|
196
|
+
const birthDateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
197
|
+
if (!birthDateRegex.test(signUpData.birthDate)) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
"Birth date must be in the format YYYY-MM-DD"
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
await this.client.post({
|
|
203
|
+
url: "/auth/register-staff",
|
|
204
|
+
data: signUpData
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
async forgotPassword(email) {
|
|
208
|
+
await this.client.post({
|
|
209
|
+
url: "/auth/password/forgot",
|
|
210
|
+
data: {
|
|
211
|
+
email
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
async resetPassword(otp, password, repeatPassword) {
|
|
216
|
+
await this.client.post({
|
|
217
|
+
url: "/auth/password/reset",
|
|
218
|
+
data: {
|
|
219
|
+
otp,
|
|
220
|
+
password,
|
|
221
|
+
repeatPassword
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async verifyEmail(otp) {
|
|
226
|
+
await this.client.post({
|
|
227
|
+
url: "/auth/activate",
|
|
228
|
+
data: {
|
|
229
|
+
otp
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// src/services/user.ts
|
|
236
|
+
var UserService = class {
|
|
237
|
+
client;
|
|
238
|
+
constructor(client) {
|
|
239
|
+
this.client = client;
|
|
240
|
+
this.WhoAmI = this.WhoAmI.bind(this);
|
|
241
|
+
}
|
|
242
|
+
async WhoAmI() {
|
|
243
|
+
const response = await this.client.get({
|
|
244
|
+
url: "/user/whoami"
|
|
245
|
+
});
|
|
246
|
+
return response;
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// src/types/auth.ts
|
|
251
|
+
var UserGender = /* @__PURE__ */ ((UserGender2) => {
|
|
252
|
+
UserGender2["MALE"] = "male";
|
|
253
|
+
UserGender2["FEMALE"] = "female";
|
|
254
|
+
return UserGender2;
|
|
255
|
+
})(UserGender || {});
|
|
256
|
+
|
|
257
|
+
// src/index.ts
|
|
258
|
+
var VitalFit = class _VitalFit {
|
|
259
|
+
static instance;
|
|
260
|
+
client;
|
|
261
|
+
auth;
|
|
262
|
+
user;
|
|
263
|
+
constructor(isDevMode, origin) {
|
|
264
|
+
this.client = new Client(isDevMode, origin);
|
|
265
|
+
this.auth = new AuthService(this.client);
|
|
266
|
+
this.user = new UserService(this.client);
|
|
267
|
+
}
|
|
268
|
+
static getInstance(isDevMode = false) {
|
|
269
|
+
if (!_VitalFit.instance) {
|
|
270
|
+
_VitalFit.instance = new _VitalFit(isDevMode);
|
|
271
|
+
}
|
|
272
|
+
return _VitalFit.instance;
|
|
273
|
+
}
|
|
274
|
+
version() {
|
|
275
|
+
return "0.0.1";
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
279
|
+
0 && (module.exports = {
|
|
280
|
+
APIError,
|
|
281
|
+
UserGender,
|
|
282
|
+
VitalFit,
|
|
283
|
+
isAPIError
|
|
284
|
+
});
|
|
285
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/client.ts","../src/settings.ts","../src/errors/errors.ts","../src/services/auth.ts","../src/services/user.ts","../src/types/auth.ts"],"sourcesContent":["import { Client } from './client'\nimport { AuthService, UserService} from './services'\n\n\n\nexport class VitalFit {\n private static instance: VitalFit\n client: Client\n auth: AuthService\n user: UserService\n \n\n constructor(isDevMode: boolean, origin?: string) {\n this.client = new Client(isDevMode, origin)\n this.auth= new AuthService(this.client)\n this.user= new UserService(this.client)\n \n }\n\n static getInstance(isDevMode = false): VitalFit {\n if (!VitalFit.instance) {\n VitalFit.instance = new VitalFit(isDevMode)\n }\n return VitalFit.instance\n }\n\n version(): string {\n return '0.0.1'\n }\n}\n\nexport * from './types'\nexport * from './errors'","import axios, { type AxiosInstance } from 'axios'\nimport { BASE_URL, DEV_URL } from './settings'\nimport { APIError } from './errors'\nimport type { Pagination } from './types'\n\nexport type ClientConfig = {\n url: string\n jwt?: string\n data?: object\n params?: object\n}\n\nexport class Client {\n private client: AxiosInstance\n jwt?: string\n\n constructor(isDevMode: boolean, origin?: string) {\n let headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n }\n if (origin) {\n headers['Origin'] = origin\n }\n this.client = axios.create({\n baseURL: isDevMode ? DEV_URL : BASE_URL,\n headers,\n })\n }\n\n async call(method: string, config: ClientConfig): Promise<Response> {\n if (config.jwt) {\n this.client.interceptors.request.use((axiosConfig) => {\n if (axiosConfig.headers) {\n axiosConfig.headers['Authorization'] = `Bearer ${config.jwt}`\n }\n return axiosConfig\n })\n }\n try {\n const response = await this.client.request({\n method: method,\n url: config.url,\n data: config.data,\n params: config.params,\n })\n this.client.interceptors.request.clear()\n return response.data\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: unknown) {\n if (axios.isAxiosError(error)) {\n // Adaptado para el formato de error de la API de Go: { \"error\": \"mensaje\" }\n const errorMessage = error.response?.data?.error\n if (typeof errorMessage === 'string') {\n throw new APIError([errorMessage], error.response?.status ?? 500)\n }\n throw new APIError(['Ocurrió un error inesperado'], error.response?.status ?? 500)\n }\n throw new Error(error as string)\n }\n }\n\n async get(config: ClientConfig) {\n const isPaginated = config.params && 'page' in config.params\n if (isPaginated) {\n const response = await this.call('get', config)\n if ('results' in response) {\n const data: Pagination<any> = response as unknown as Pagination<any>\n return {\n data: data.data,\n count: data.count,\n next: data.next,\n previous: data.previous,\n }\n }\n throw new Error('Expected Pagination response')\n } else {\n const data = await this.call('get', config)\n return data\n }\n }\n\n async post(config: ClientConfig) {\n const data = await this.call('post', config)\n return data\n }\n\n async put(config: ClientConfig) {\n const data = await this.call('put', config)\n return data\n }\n\n async patch(config: ClientConfig) {\n const data = await this.call('patch', config)\n return data\n }\n\n async delete(config: ClientConfig) {\n const data = await this.call('delete', config)\n return data\n }\n\n setJWT(jwt: string) {\n this.jwt = jwt\n }\n\n removeJWT() {\n this.jwt = undefined\n }\n}","export const BASE_URL = ''\nexport const DEV_URL = 'https://api-rm8x.onrender.com/v1'","export class APIError extends Error {\n status: number\n messages: string[]\n constructor(messages: string[], status: number) {\n super(messages.join(', '))\n this.status = status\n this.messages = messages\n }\n}\n\nexport const isAPIError = (error: unknown): error is APIError => {\n return error instanceof APIError\n}\n\n\n","import { Client } from '../client'\nimport type {\n LoginRequest,\n LoginResponse,\n SignUpRequest,\n} from '../types'\n\nexport class AuthService {\n private client: Client\n constructor(client: Client) {\n this.client = client\n this.login = this.login.bind(this)\n this.signUp = this.signUp.bind(this)\n this.signUpStaff = this.signUpStaff.bind(this)\n this.forgotPassword = this.forgotPassword.bind(this)\n this.resetPassword = this.resetPassword.bind(this)\n this.verifyEmail = this.verifyEmail.bind(this)\n\n this.logout = this.logout.bind(this)\n this.saveJWT = this.saveJWT.bind(this)\n }\n\n async login({ email, password, context}: LoginRequest): Promise<LoginResponse> {\n const response = await this.client.post({\n url: '/auth/login',\n data: {\n email,\n password,\n context\n },\n })\n return response as unknown as LoginResponse\n }\n\n logout(): void {\n this.client.removeJWT()\n }\n\n saveJWT(jwt: string): void {\n this.client.setJWT(jwt)\n }\n\n async signUp(signUpData: SignUpRequest): Promise<void> {\n const birthDateRegex = /^\\d{4}-\\d{2}-\\d{2}$/\n if (signUpData.roleName !='client'){\n throw new Error('Only clients can sign up using this method')\n }\n if (!birthDateRegex.test(signUpData.birthDate)) {\n throw new Error(\n 'Birth date must be in the format YYYY-MM-DD',\n )\n }\n await this.client.post({\n url: '/auth/register',\n data: signUpData,\n })\n }\n\n\n async signUpStaff(signUpData: SignUpRequest): Promise<void> {\n const birthDateRegex = /^\\d{4}-\\d{2}-\\d{2}$/\n if (!birthDateRegex.test(signUpData.birthDate)) {\n throw new Error(\n 'Birth date must be in the format YYYY-MM-DD',\n )\n }\n await this.client.post({\n url: '/auth/register-staff',\n data: signUpData,\n })\n }\n async forgotPassword(email: string): Promise<void> {\n await this.client.post({\n url: '/auth/password/forgot',\n data: {\n email,\n },\n })\n }\n\n async resetPassword(otp: string, password: string, repeatPassword: string): Promise<void> {\n await this.client.post({\n url: '/auth/password/reset',\n data: {\n otp,\n password,\n repeatPassword,\n },\n })\n }\n\n async verifyEmail(otp: string): Promise<void> {\n await this.client.post({\n url: '/auth/activate',\n data: {\n otp,\n },\n })\n }\n\n\n}\n","import { Client } from \"@/client\";\nimport type { UserApiResponse } from \"@/types\";\n\nexport class UserService {\n client: Client;\n constructor(client: Client) {\n this.client = client;\n this.WhoAmI = this.WhoAmI.bind(this);\n }\n async WhoAmI(): Promise<UserApiResponse> {\n const response = await this.client.get({\n url: '/user/whoami',\n });\n return response as unknown as any;\n }\n}","export enum UserGender {\n MALE = 'male',\n FEMALE = 'female',\n}\n\nexport type LoginRequest = {\n email: string\n password: string\n context?: string\n}\n\nexport type LoginResponse = {\n accessToken: string\n}\n\nexport type SignUpRequest = {\n firstName: string\n lastName: string\n email: string\n password: string\n documentId: string\n phoneNumber?: string | null\n birthDate: string\n gender?: UserGender | null\n profilePictureUrl?: string | null\n roleName?: string | null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0C;;;ACAnC,IAAM,WAAW;AACjB,IAAM,UAAU;;;ACDhB,IAAM,WAAN,cAAuB,MAAM;AAAA,EAClC;AAAA,EACA;AAAA,EACA,YAAY,UAAoB,QAAgB;AAC9C,UAAM,SAAS,KAAK,IAAI,CAAC;AACzB,SAAK,SAAS;AACd,SAAK,WAAW;AAAA,EAClB;AACF;AAEO,IAAM,aAAa,CAAC,UAAsC;AAC/D,SAAO,iBAAiB;AAC1B;;;AFAO,IAAM,SAAN,MAAa;AAAA,EACV;AAAA,EACR;AAAA,EAEA,YAAY,WAAoB,QAAiB;AAC/C,QAAI,UAAkC;AAAA,MACpC,gBAAgB;AAAA,IAClB;AACA,QAAI,QAAQ;AACV,cAAQ,QAAQ,IAAI;AAAA,IACtB;AACA,SAAK,SAAS,aAAAA,QAAM,OAAO;AAAA,MACzB,SAAS,YAAY,UAAU;AAAA,MAC/B;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,KAAK,QAAgB,QAAyC;AAClE,QAAI,OAAO,KA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,WAAW,MAAM,KAAK,OAAO,IAAI;AAAA,MACnC,KAAK;AAAA,IACT,CAAC;AACD,WAAO;AAAA,EACX;AACJ;;;ACfO,IAAK,aAAL,kBAAKC,gBAAL;AACL,EAAAA,YAAA,UAAO;AACP,EAAAA,YAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;;;ANKL,IAAM,WAAN,MAAM,UAAS;AAAA,EACpB,OAAe;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EAGA,YAAY,WAAoB,QAAiB;AAC/C,SAAK,SAAS,IAAI,OAAO,WAAW,MAAM;AAC1C,SAAK,OAAM,IAAI,YAAY,KAAK,MAAM;AACtC,SAAK,OAAM,IAAI,YAAY,KAAK,MAAM;AAAA,EAExC;AAAA,EAEA,OAAO,YAAY,YAAY,OAAiB;AAC9C,QAAI,CAAC,UAAS,UAAU;AACtB,gBAAS,WAAW,IAAI,UAAS,SAAS;AAAA,IAC5C;AACA,WAAO,UAAS;AAAA,EAClB;AAAA,EAEA,UAAkB;AAChB,WAAO;AAAA,EACT;AACF;","names":["axios","UserGender"]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
|
|
4
|
+
// src/settings.ts
|
|
5
|
+
var BASE_URL = "";
|
|
6
|
+
var DEV_URL = "https://api-rm8x.onrender.com/v1";
|
|
7
|
+
|
|
8
|
+
// src/errors/errors.ts
|
|
9
|
+
var APIError = class extends Error {
|
|
10
|
+
status;
|
|
11
|
+
messages;
|
|
12
|
+
constructor(messages, status) {
|
|
13
|
+
super(messages.join(", "));
|
|
14
|
+
this.status = status;
|
|
15
|
+
this.messages = messages;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
var isAPIError = (error) => {
|
|
19
|
+
return error instanceof APIError;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// src/client.ts
|
|
23
|
+
var Client = class {
|
|
24
|
+
client;
|
|
25
|
+
jwt;
|
|
26
|
+
constructor(isDevMode, origin) {
|
|
27
|
+
let headers = {
|
|
28
|
+
"Content-Type": "application/json"
|
|
29
|
+
};
|
|
30
|
+
if (origin) {
|
|
31
|
+
headers["Origin"] = origin;
|
|
32
|
+
}
|
|
33
|
+
this.client = axios.create({
|
|
34
|
+
baseURL: isDevMode ? DEV_URL : BASE_URL,
|
|
35
|
+
headers
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async call(method, config) {
|
|
39
|
+
if (config.jwt) {
|
|
40
|
+
this.client.interceptors.request.use((axiosConfig) => {
|
|
41
|
+
if (axiosConfig.headers) {
|
|
42
|
+
axiosConfig.headers["Authorization"] = `Bearer ${config.jwt}`;
|
|
43
|
+
}
|
|
44
|
+
return axiosConfig;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const response = await this.client.request({
|
|
49
|
+
method,
|
|
50
|
+
url: config.url,
|
|
51
|
+
data: config.data,
|
|
52
|
+
params: config.params
|
|
53
|
+
});
|
|
54
|
+
this.client.interceptors.request.clear();
|
|
55
|
+
return response.data;
|
|
56
|
+
} catch (error) {
|
|
57
|
+
if (axios.isAxiosError(error)) {
|
|
58
|
+
const errorMessage = error.response?.data?.error;
|
|
59
|
+
if (typeof errorMessage === "string") {
|
|
60
|
+
throw new APIError([errorMessage], error.response?.status ?? 500);
|
|
61
|
+
}
|
|
62
|
+
throw new APIError(["Ocurri\xF3 un error inesperado"], error.response?.status ?? 500);
|
|
63
|
+
}
|
|
64
|
+
throw new Error(error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async get(config) {
|
|
68
|
+
const isPaginated = config.params && "page" in config.params;
|
|
69
|
+
if (isPaginated) {
|
|
70
|
+
const response = await this.call("get", config);
|
|
71
|
+
if ("results" in response) {
|
|
72
|
+
const data = response;
|
|
73
|
+
return {
|
|
74
|
+
data: data.data,
|
|
75
|
+
count: data.count,
|
|
76
|
+
next: data.next,
|
|
77
|
+
previous: data.previous
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
throw new Error("Expected Pagination response");
|
|
81
|
+
} else {
|
|
82
|
+
const data = await this.call("get", config);
|
|
83
|
+
return data;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async post(config) {
|
|
87
|
+
const data = await this.call("post", config);
|
|
88
|
+
return data;
|
|
89
|
+
}
|
|
90
|
+
async put(config) {
|
|
91
|
+
const data = await this.call("put", config);
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
async patch(config) {
|
|
95
|
+
const data = await this.call("patch", config);
|
|
96
|
+
return data;
|
|
97
|
+
}
|
|
98
|
+
async delete(config) {
|
|
99
|
+
const data = await this.call("delete", config);
|
|
100
|
+
return data;
|
|
101
|
+
}
|
|
102
|
+
setJWT(jwt) {
|
|
103
|
+
this.jwt = jwt;
|
|
104
|
+
}
|
|
105
|
+
removeJWT() {
|
|
106
|
+
this.jwt = void 0;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/services/auth.ts
|
|
111
|
+
var AuthService = class {
|
|
112
|
+
client;
|
|
113
|
+
constructor(client) {
|
|
114
|
+
this.client = client;
|
|
115
|
+
this.login = this.login.bind(this);
|
|
116
|
+
this.signUp = this.signUp.bind(this);
|
|
117
|
+
this.signUpStaff = this.signUpStaff.bind(this);
|
|
118
|
+
this.forgotPassword = this.forgotPassword.bind(this);
|
|
119
|
+
this.resetPassword = this.resetPassword.bind(this);
|
|
120
|
+
this.verifyEmail = this.verifyEmail.bind(this);
|
|
121
|
+
this.logout = this.logout.bind(this);
|
|
122
|
+
this.saveJWT = this.saveJWT.bind(this);
|
|
123
|
+
}
|
|
124
|
+
async login({ email, password, context }) {
|
|
125
|
+
const response = await this.client.post({
|
|
126
|
+
url: "/auth/login",
|
|
127
|
+
data: {
|
|
128
|
+
email,
|
|
129
|
+
password,
|
|
130
|
+
context
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
return response;
|
|
134
|
+
}
|
|
135
|
+
logout() {
|
|
136
|
+
this.client.removeJWT();
|
|
137
|
+
}
|
|
138
|
+
saveJWT(jwt) {
|
|
139
|
+
this.client.setJWT(jwt);
|
|
140
|
+
}
|
|
141
|
+
async signUp(signUpData) {
|
|
142
|
+
const birthDateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
143
|
+
if (signUpData.roleName != "client") {
|
|
144
|
+
throw new Error("Only clients can sign up using this method");
|
|
145
|
+
}
|
|
146
|
+
if (!birthDateRegex.test(signUpData.birthDate)) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
"Birth date must be in the format YYYY-MM-DD"
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
await this.client.post({
|
|
152
|
+
url: "/auth/register",
|
|
153
|
+
data: signUpData
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async signUpStaff(signUpData) {
|
|
157
|
+
const birthDateRegex = /^\d{4}-\d{2}-\d{2}$/;
|
|
158
|
+
if (!birthDateRegex.test(signUpData.birthDate)) {
|
|
159
|
+
throw new Error(
|
|
160
|
+
"Birth date must be in the format YYYY-MM-DD"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
await this.client.post({
|
|
164
|
+
url: "/auth/register-staff",
|
|
165
|
+
data: signUpData
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
async forgotPassword(email) {
|
|
169
|
+
await this.client.post({
|
|
170
|
+
url: "/auth/password/forgot",
|
|
171
|
+
data: {
|
|
172
|
+
email
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
async resetPassword(otp, password, repeatPassword) {
|
|
177
|
+
await this.client.post({
|
|
178
|
+
url: "/auth/password/reset",
|
|
179
|
+
data: {
|
|
180
|
+
otp,
|
|
181
|
+
password,
|
|
182
|
+
repeatPassword
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
async verifyEmail(otp) {
|
|
187
|
+
await this.client.post({
|
|
188
|
+
url: "/auth/activate",
|
|
189
|
+
data: {
|
|
190
|
+
otp
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
// src/services/user.ts
|
|
197
|
+
var UserService = class {
|
|
198
|
+
client;
|
|
199
|
+
constructor(client) {
|
|
200
|
+
this.client = client;
|
|
201
|
+
this.WhoAmI = this.WhoAmI.bind(this);
|
|
202
|
+
}
|
|
203
|
+
async WhoAmI() {
|
|
204
|
+
const response = await this.client.get({
|
|
205
|
+
url: "/user/whoami"
|
|
206
|
+
});
|
|
207
|
+
return response;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/types/auth.ts
|
|
212
|
+
var UserGender = /* @__PURE__ */ ((UserGender2) => {
|
|
213
|
+
UserGender2["MALE"] = "male";
|
|
214
|
+
UserGender2["FEMALE"] = "female";
|
|
215
|
+
return UserGender2;
|
|
216
|
+
})(UserGender || {});
|
|
217
|
+
|
|
218
|
+
// src/index.ts
|
|
219
|
+
var VitalFit = class _VitalFit {
|
|
220
|
+
static instance;
|
|
221
|
+
client;
|
|
222
|
+
auth;
|
|
223
|
+
user;
|
|
224
|
+
constructor(isDevMode, origin) {
|
|
225
|
+
this.client = new Client(isDevMode, origin);
|
|
226
|
+
this.auth = new AuthService(this.client);
|
|
227
|
+
this.user = new UserService(this.client);
|
|
228
|
+
}
|
|
229
|
+
static getInstance(isDevMode = false) {
|
|
230
|
+
if (!_VitalFit.instance) {
|
|
231
|
+
_VitalFit.instance = new _VitalFit(isDevMode);
|
|
232
|
+
}
|
|
233
|
+
return _VitalFit.instance;
|
|
234
|
+
}
|
|
235
|
+
version() {
|
|
236
|
+
return "0.0.1";
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
export {
|
|
240
|
+
APIError,
|
|
241
|
+
UserGender,
|
|
242
|
+
VitalFit,
|
|
243
|
+
isAPIError
|
|
244
|
+
};
|
|
245
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/settings.ts","../src/errors/errors.ts","../src/services/auth.ts","../src/services/user.ts","../src/types/auth.ts","../src/index.ts"],"sourcesContent":["import axios, { type AxiosInstance } from 'axios'\nimport { BASE_URL, DEV_URL } from './settings'\nimport { APIError } from './errors'\nimport type { Pagination } from './types'\n\nexport type ClientConfig = {\n url: string\n jwt?: string\n data?: object\n params?: object\n}\n\nexport class Client {\n private client: AxiosInstance\n jwt?: string\n\n constructor(isDevMode: boolean, origin?: string) {\n let headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n }\n if (origin) {\n headers['Origin'] = origin\n }\n this.client = axios.create({\n baseURL: isDevMode ? DEV_URL : BASE_URL,\n headers,\n })\n }\n\n async call(method: string, config: ClientConfig): Promise<Response> {\n if (config.jwt) {\n this.client.interceptors.request.use((axiosConfig) => {\n if (axiosConfig.headers) {\n axiosConfig.headers['Authorization'] = `Bearer ${config.jwt}`\n }\n return axiosConfig\n })\n }\n try {\n const response = await this.client.request({\n method: method,\n url: config.url,\n data: config.data,\n params: config.params,\n })\n this.client.interceptors.request.clear()\n return response.data\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: unknown) {\n if (axios.isAxiosError(error)) {\n // Adaptado para el formato de error de la API de Go: { \"error\": \"mensaje\" }\n const errorMessage = error.response?.data?.error\n if (typeof errorMessage === 'string') {\n throw new APIError([errorMessage], error.response?.status ?? 500)\n }\n throw new APIError(['Ocurrió un error inesperado'], error.response?.status ?? 500)\n }\n throw new Error(error as string)\n }\n }\n\n async get(config: ClientConfig) {\n const isPaginated = config.params && 'page' in config.params\n if (isPaginated) {\n const response = await this.call('get', config)\n if ('results' in response) {\n const data: Pagination<any> = response as unknown as Pagination<any>\n return {\n data: data.data,\n count: data.count,\n next: data.next,\n previous: data.previous,\n }\n }\n throw new Error('Expected Pagination response')\n } else {\n const data = await this.call('get', config)\n return data\n }\n }\n\n async post(config: ClientConfig) {\n const data = await this.call('post', config)\n return data\n }\n\n async put(config: ClientConfig) {\n const data = await this.call('put', config)\n return data\n }\n\n async patch(config: ClientConfig) {\n const data = await this.call('patch', config)\n return data\n }\n\n async delete(config: ClientConfig) {\n const data = await this.call('delete', config)\n return data\n }\n\n setJWT(jwt: string) {\n this.jwt = jwt\n }\n\n removeJWT() {\n this.jwt = undefined\n }\n}","export const BASE_URL = ''\nexport const DEV_URL = 'https://api-rm8x.onrender.com/v1'","export class APIError extends Error {\n status: number\n messages: string[]\n constructor(messages: string[], status: number) {\n super(messages.join(', '))\n this.status = status\n this.messages = messages\n }\n}\n\nexport const isAPIError = (error: unknown): error is APIError => {\n return error instanceof APIError\n}\n\n\n","import { Client } from '../client'\nimport type {\n LoginRequest,\n LoginResponse,\n SignUpRequest,\n} from '../types'\n\nexport class AuthService {\n private client: Client\n constructor(client: Client) {\n this.client = client\n this.login = this.login.bind(this)\n this.signUp = this.signUp.bind(this)\n this.signUpStaff = this.signUpStaff.bind(this)\n this.forgotPassword = this.forgotPassword.bind(this)\n this.resetPassword = this.resetPassword.bind(this)\n this.verifyEmail = this.verifyEmail.bind(this)\n\n this.logout = this.logout.bind(this)\n this.saveJWT = this.saveJWT.bind(this)\n }\n\n async login({ email, password, context}: LoginRequest): Promise<LoginResponse> {\n const response = await this.client.post({\n url: '/auth/login',\n data: {\n email,\n password,\n context\n },\n })\n return response as unknown as LoginResponse\n }\n\n logout(): void {\n this.client.removeJWT()\n }\n\n saveJWT(jwt: string): void {\n this.client.setJWT(jwt)\n }\n\n async signUp(signUpData: SignUpRequest): Promise<void> {\n const birthDateRegex = /^\\d{4}-\\d{2}-\\d{2}$/\n if (signUpData.roleName !='client'){\n throw new Error('Only clients can sign up using this method')\n }\n if (!birthDateRegex.test(signUpData.birthDate)) {\n throw new Error(\n 'Birth date must be in the format YYYY-MM-DD',\n )\n }\n await this.client.post({\n url: '/auth/register',\n data: signUpData,\n })\n }\n\n\n async signUpStaff(signUpData: SignUpRequest): Promise<void> {\n const birthDateRegex = /^\\d{4}-\\d{2}-\\d{2}$/\n if (!birthDateRegex.test(signUpData.birthDate)) {\n throw new Error(\n 'Birth date must be in the format YYYY-MM-DD',\n )\n }\n await this.client.post({\n url: '/auth/register-staff',\n data: signUpData,\n })\n }\n async forgotPassword(email: string): Promise<void> {\n await this.client.post({\n url: '/auth/password/forgot',\n data: {\n email,\n },\n })\n }\n\n async resetPassword(otp: string, password: string, repeatPassword: string): Promise<void> {\n await this.client.post({\n url: '/auth/password/reset',\n data: {\n otp,\n password,\n repeatPassword,\n },\n })\n }\n\n async verifyEmail(otp: string): Promise<void> {\n await this.client.post({\n url: '/auth/activate',\n data: {\n otp,\n },\n })\n }\n\n\n}\n","import { Client } from \"@/client\";\nimport type { UserApiResponse } from \"@/types\";\n\nexport class UserService {\n client: Client;\n constructor(client: Client) {\n this.client = client;\n this.WhoAmI = this.WhoAmI.bind(this);\n }\n async WhoAmI(): Promise<UserApiResponse> {\n const response = await this.client.get({\n url: '/user/whoami',\n });\n return response as unknown as any;\n }\n}","export enum UserGender {\n MALE = 'male',\n FEMALE = 'female',\n}\n\nexport type LoginRequest = {\n email: string\n password: string\n context?: string\n}\n\nexport type LoginResponse = {\n accessToken: string\n}\n\nexport type SignUpRequest = {\n firstName: string\n lastName: string\n email: string\n password: string\n documentId: string\n phoneNumber?: string | null\n birthDate: string\n gender?: UserGender | null\n profilePictureUrl?: string | null\n roleName?: string | null\n}\n","import { Client } from './client'\nimport { AuthService, UserService} from './services'\n\n\n\nexport class VitalFit {\n private static instance: VitalFit\n client: Client\n auth: AuthService\n user: UserService\n \n\n constructor(isDevMode: boolean, origin?: string) {\n this.client = new Client(isDevMode, origin)\n this.auth= new AuthService(this.client)\n this.user= new UserService(this.client)\n \n }\n\n static getInstance(isDevMode = false): VitalFit {\n if (!VitalFit.instance) {\n VitalFit.instance = new VitalFit(isDevMode)\n }\n return VitalFit.instance\n }\n\n version(): string {\n return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AW,IAAI,UAAS,SAAS;AAAA,IAC5C;AACA,WAAO,UAAS;AAAA,EAClB;AAAA,EAEA,UAAkB;AAChB,WAAO;AAAA,EACT;AACF;","names":["UserGender"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vitalfit/sdk",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "VitalFit Core API SDK",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"homepage": "https://github.com/VitalFitTeam/vitalfit-sdk",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/VitalFitTeam/vitalfit-sdk.git"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsup"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"author": "vitalfitdcyt <vitalfitdcyt@gmail.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"type": "commonjs",
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"ts-node": "^10.9.2",
|
|
27
|
+
"tsup": "^8.5.0",
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"axios": "^1.12.2"
|
|
32
|
+
}
|
|
33
|
+
}
|