@vitalfit/sdk 0.3.7 → 0.3.9
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.cjs +245 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +170 -113
- package/dist/index.d.ts +170 -113
- package/dist/index.js +245 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -117,7 +117,8 @@ var Client = class {
|
|
|
117
117
|
url: config.url,
|
|
118
118
|
data: config.data,
|
|
119
119
|
params: config.params,
|
|
120
|
-
headers: {}
|
|
120
|
+
headers: {},
|
|
121
|
+
responseType: config.responseType
|
|
121
122
|
};
|
|
122
123
|
if (tokenToUse && axiosConfig.headers) {
|
|
123
124
|
axiosConfig.headers["Authorization"] = `Bearer ${tokenToUse}`;
|
|
@@ -171,6 +172,48 @@ var Client = class {
|
|
|
171
172
|
async delete(config) {
|
|
172
173
|
return this.call("delete", config);
|
|
173
174
|
}
|
|
175
|
+
async download(config) {
|
|
176
|
+
const tokenToUse = config.jwt || this.accessToken;
|
|
177
|
+
const axiosConfig = {
|
|
178
|
+
method: "get",
|
|
179
|
+
url: config.url,
|
|
180
|
+
params: config.params,
|
|
181
|
+
headers: {},
|
|
182
|
+
responseType: "blob"
|
|
183
|
+
};
|
|
184
|
+
if (tokenToUse && axiosConfig.headers) {
|
|
185
|
+
axiosConfig.headers["Authorization"] = `Bearer ${tokenToUse}`;
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
const response = await this.client.request(axiosConfig);
|
|
189
|
+
let filename;
|
|
190
|
+
const disposition = response.headers["content-disposition"];
|
|
191
|
+
if (disposition) {
|
|
192
|
+
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(
|
|
193
|
+
disposition
|
|
194
|
+
);
|
|
195
|
+
if (matches != null && matches[1]) {
|
|
196
|
+
filename = matches[1].replace(/['"]/g, "");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return { blob: response.data, filename };
|
|
200
|
+
} catch (error) {
|
|
201
|
+
if (axios.isAxiosError(error) && error.response?.data instanceof Blob) {
|
|
202
|
+
const errorText = await error.response.data.text();
|
|
203
|
+
try {
|
|
204
|
+
const errorJson = JSON.parse(errorText);
|
|
205
|
+
const errorMessage = errorJson.error || "Ocurri\xF3 un error inesperado";
|
|
206
|
+
throw new APIError([errorMessage], error.response.status);
|
|
207
|
+
} catch (e) {
|
|
208
|
+
throw new APIError(
|
|
209
|
+
["Error en la descarga del archivo"],
|
|
210
|
+
error.response.status
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
throw new Error(error);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
174
217
|
};
|
|
175
218
|
|
|
176
219
|
// src/services/auth.ts
|
|
@@ -248,14 +291,16 @@ var AuthService = class {
|
|
|
248
291
|
async login({
|
|
249
292
|
email,
|
|
250
293
|
password,
|
|
251
|
-
context
|
|
294
|
+
context,
|
|
295
|
+
device_token
|
|
252
296
|
}) {
|
|
253
297
|
const response = await this.client.post({
|
|
254
298
|
url: "/auth/login",
|
|
255
299
|
data: {
|
|
256
300
|
email,
|
|
257
301
|
password,
|
|
258
|
-
context
|
|
302
|
+
context,
|
|
303
|
+
device_token
|
|
259
304
|
}
|
|
260
305
|
});
|
|
261
306
|
return response;
|
|
@@ -357,6 +402,7 @@ var UserService = class {
|
|
|
357
402
|
this.deleteUser = this.deleteUser.bind(this);
|
|
358
403
|
this.resendActivateOtp = this.resendActivateOtp.bind(this);
|
|
359
404
|
this.UpgradePassword = this.UpgradePassword.bind(this);
|
|
405
|
+
this.blockUser = this.blockUser.bind(this);
|
|
360
406
|
this.createMedicalProfile = this.createMedicalProfile.bind(this);
|
|
361
407
|
this.getMedicalProfile = this.getMedicalProfile.bind(this);
|
|
362
408
|
this.updateMedicalProfile = this.updateMedicalProfile.bind(this);
|
|
@@ -457,6 +503,13 @@ var UserService = class {
|
|
|
457
503
|
}
|
|
458
504
|
});
|
|
459
505
|
}
|
|
506
|
+
async blockUser(userId, data, jwt) {
|
|
507
|
+
await this.client.put({
|
|
508
|
+
url: `/user/${userId}/block`,
|
|
509
|
+
jwt,
|
|
510
|
+
data
|
|
511
|
+
});
|
|
512
|
+
}
|
|
460
513
|
//medical
|
|
461
514
|
async createMedicalProfile(userId, data, jwt) {
|
|
462
515
|
await this.client.post({
|
|
@@ -644,6 +697,7 @@ var InstructorService = class {
|
|
|
644
697
|
this.deleteInstructor = this.deleteInstructor.bind(this);
|
|
645
698
|
this.addSpecialty = this.addSpecialty.bind(this);
|
|
646
699
|
this.removeSpecialty = this.removeSpecialty.bind(this);
|
|
700
|
+
this.getAssignedClients = this.getAssignedClients.bind(this);
|
|
647
701
|
this.addBranchInstructor = this.addBranchInstructor.bind(this);
|
|
648
702
|
this.removeBranchInstructor = this.removeBranchInstructor.bind(this);
|
|
649
703
|
this.getBranchInstructors = this.getBranchInstructors.bind(this);
|
|
@@ -710,6 +764,19 @@ var InstructorService = class {
|
|
|
710
764
|
jwt
|
|
711
765
|
});
|
|
712
766
|
}
|
|
767
|
+
async getAssignedClients(instructorId, jwt, { page = 1, limit = 10, sort = "desc", search } = {}) {
|
|
768
|
+
const response = await this.client.get({
|
|
769
|
+
url: `/instructor/${instructorId}/clients`,
|
|
770
|
+
jwt,
|
|
771
|
+
params: {
|
|
772
|
+
page,
|
|
773
|
+
limit,
|
|
774
|
+
sort,
|
|
775
|
+
search
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
return response;
|
|
779
|
+
}
|
|
713
780
|
async addBranchInstructor(branchId, instructorIDs, jwt) {
|
|
714
781
|
await this.client.post({
|
|
715
782
|
url: `/branches/${branchId}/instructor`,
|
|
@@ -1158,6 +1225,7 @@ var ProductsService = class {
|
|
|
1158
1225
|
this.createService = this.createService.bind(this);
|
|
1159
1226
|
this.getServices = this.getServices.bind(this);
|
|
1160
1227
|
this.getSummary = this.getSummary.bind(this);
|
|
1228
|
+
this.getClientBalances = this.getClientBalances.bind(this);
|
|
1161
1229
|
this.getServiceByID = this.getServiceByID.bind(this);
|
|
1162
1230
|
this.updateService = this.updateService.bind(this);
|
|
1163
1231
|
this.deleteService = this.deleteService.bind(this);
|
|
@@ -1202,6 +1270,16 @@ var ProductsService = class {
|
|
|
1202
1270
|
});
|
|
1203
1271
|
return response;
|
|
1204
1272
|
}
|
|
1273
|
+
async getClientBalances(jwt, userId) {
|
|
1274
|
+
const response = await this.client.get({
|
|
1275
|
+
url: "/services/balances",
|
|
1276
|
+
jwt,
|
|
1277
|
+
params: {
|
|
1278
|
+
user_id: userId
|
|
1279
|
+
}
|
|
1280
|
+
});
|
|
1281
|
+
return response;
|
|
1282
|
+
}
|
|
1205
1283
|
async getServiceByID(serviceId, jwt) {
|
|
1206
1284
|
const response = await this.client.get({
|
|
1207
1285
|
url: `/services/${serviceId}`,
|
|
@@ -1376,11 +1454,16 @@ var ScheduleService = class {
|
|
|
1376
1454
|
this.UpdateClass = this.UpdateClass.bind(this);
|
|
1377
1455
|
this.DeleteClass = this.DeleteClass.bind(this);
|
|
1378
1456
|
this.GetClassByID = this.GetClassByID.bind(this);
|
|
1457
|
+
this.GetClassesByInstructor = this.GetClassesByInstructor.bind(this);
|
|
1379
1458
|
}
|
|
1380
|
-
async ListBranchesClass(branchID, jwt) {
|
|
1459
|
+
async ListBranchesClass(branchID, jwt, month, year) {
|
|
1381
1460
|
const response = await this.client.get({
|
|
1382
1461
|
url: `/branches/${branchID}/schedule`,
|
|
1383
|
-
jwt
|
|
1462
|
+
jwt,
|
|
1463
|
+
params: {
|
|
1464
|
+
month,
|
|
1465
|
+
year
|
|
1466
|
+
}
|
|
1384
1467
|
});
|
|
1385
1468
|
return response;
|
|
1386
1469
|
}
|
|
@@ -1411,6 +1494,18 @@ var ScheduleService = class {
|
|
|
1411
1494
|
jwt
|
|
1412
1495
|
});
|
|
1413
1496
|
}
|
|
1497
|
+
async GetClassesByInstructor(jwt, userId, month, year) {
|
|
1498
|
+
const response = await this.client.get({
|
|
1499
|
+
url: "/schedule/instructor",
|
|
1500
|
+
jwt,
|
|
1501
|
+
params: {
|
|
1502
|
+
user_id: userId,
|
|
1503
|
+
month,
|
|
1504
|
+
year
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1507
|
+
return response;
|
|
1508
|
+
}
|
|
1414
1509
|
};
|
|
1415
1510
|
|
|
1416
1511
|
// src/services/packages.ts
|
|
@@ -1681,8 +1776,10 @@ var AccessService = class {
|
|
|
1681
1776
|
constructor(client) {
|
|
1682
1777
|
this.client = client;
|
|
1683
1778
|
this.checkIn = this.checkIn.bind(this);
|
|
1779
|
+
this.checkInManual = this.checkInManual.bind(this);
|
|
1684
1780
|
this.getClientAttendanceHistory = this.getClientAttendanceHistory.bind(this);
|
|
1685
1781
|
this.getClientServiceUsage = this.getClientServiceUsage.bind(this);
|
|
1782
|
+
this.getClassAttendanceHistory = this.getClassAttendanceHistory.bind(this);
|
|
1686
1783
|
}
|
|
1687
1784
|
async checkIn(jwt, data) {
|
|
1688
1785
|
const response = await this.client.post({
|
|
@@ -1692,6 +1789,14 @@ var AccessService = class {
|
|
|
1692
1789
|
});
|
|
1693
1790
|
return response;
|
|
1694
1791
|
}
|
|
1792
|
+
async checkInManual(jwt, data) {
|
|
1793
|
+
const response = await this.client.post({
|
|
1794
|
+
url: "/access/check-in/manual",
|
|
1795
|
+
jwt,
|
|
1796
|
+
data
|
|
1797
|
+
});
|
|
1798
|
+
return response;
|
|
1799
|
+
}
|
|
1695
1800
|
async getClientAttendanceHistory(jwt, userId, start, end, { page = 1, limit = 10, sort = "desc" } = {}) {
|
|
1696
1801
|
const response = await this.client.get({
|
|
1697
1802
|
url: `/clients/${userId}/attendance-history`,
|
|
@@ -1720,6 +1825,18 @@ var AccessService = class {
|
|
|
1720
1825
|
});
|
|
1721
1826
|
return response;
|
|
1722
1827
|
}
|
|
1828
|
+
async getClassAttendanceHistory(jwt, classId, start, end, status) {
|
|
1829
|
+
const response = await this.client.get({
|
|
1830
|
+
url: `/access/classes/${classId}/attendance`,
|
|
1831
|
+
jwt,
|
|
1832
|
+
params: {
|
|
1833
|
+
start_date: start,
|
|
1834
|
+
end_date: end,
|
|
1835
|
+
status
|
|
1836
|
+
}
|
|
1837
|
+
});
|
|
1838
|
+
return response;
|
|
1839
|
+
}
|
|
1723
1840
|
};
|
|
1724
1841
|
|
|
1725
1842
|
// src/services/reports.ts
|
|
@@ -2340,6 +2457,126 @@ var NotificationService = class {
|
|
|
2340
2457
|
}
|
|
2341
2458
|
};
|
|
2342
2459
|
|
|
2460
|
+
// src/services/exports.ts
|
|
2461
|
+
var ExportsService = class {
|
|
2462
|
+
client;
|
|
2463
|
+
constructor(client) {
|
|
2464
|
+
this.client = client;
|
|
2465
|
+
this.exportFinancialReport = this.exportFinancialReport.bind(this);
|
|
2466
|
+
this.exportClientsReport = this.exportClientsReport.bind(this);
|
|
2467
|
+
this.exportSalesReport = this.exportSalesReport.bind(this);
|
|
2468
|
+
this.exportClients = this.exportClients.bind(this);
|
|
2469
|
+
this.exportStaff = this.exportStaff.bind(this);
|
|
2470
|
+
this.exportInstructors = this.exportInstructors.bind(this);
|
|
2471
|
+
this.exportEquipmentTypes = this.exportEquipmentTypes.bind(this);
|
|
2472
|
+
this.exportBranchEquipment = this.exportBranchEquipment.bind(this);
|
|
2473
|
+
this.exportServices = this.exportServices.bind(this);
|
|
2474
|
+
this.exportBranchServices = this.exportBranchServices.bind(this);
|
|
2475
|
+
this.exportMembershipPlans = this.exportMembershipPlans.bind(this);
|
|
2476
|
+
this.exportPackages = this.exportPackages.bind(this);
|
|
2477
|
+
this.exportPaymentMethods = this.exportPaymentMethods.bind(this);
|
|
2478
|
+
}
|
|
2479
|
+
// Reports
|
|
2480
|
+
async exportFinancialReport(jwt, start, end, branchId) {
|
|
2481
|
+
return await this.client.download({
|
|
2482
|
+
url: "/reports/export/financial",
|
|
2483
|
+
jwt,
|
|
2484
|
+
params: {
|
|
2485
|
+
start,
|
|
2486
|
+
end,
|
|
2487
|
+
branch_id: branchId
|
|
2488
|
+
}
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2491
|
+
async exportClientsReport(jwt, start, end, branchId) {
|
|
2492
|
+
return await this.client.download({
|
|
2493
|
+
url: "/reports/export/clients",
|
|
2494
|
+
jwt,
|
|
2495
|
+
params: {
|
|
2496
|
+
start,
|
|
2497
|
+
end,
|
|
2498
|
+
branch_id: branchId
|
|
2499
|
+
}
|
|
2500
|
+
});
|
|
2501
|
+
}
|
|
2502
|
+
async exportSalesReport(jwt, start, end, branchId) {
|
|
2503
|
+
return await this.client.download({
|
|
2504
|
+
url: "/reports/export/sales",
|
|
2505
|
+
jwt,
|
|
2506
|
+
params: {
|
|
2507
|
+
start,
|
|
2508
|
+
end,
|
|
2509
|
+
branch_id: branchId
|
|
2510
|
+
}
|
|
2511
|
+
});
|
|
2512
|
+
}
|
|
2513
|
+
// Users & Staff
|
|
2514
|
+
async exportClients(jwt) {
|
|
2515
|
+
return await this.client.download({
|
|
2516
|
+
url: "/user/export/clients",
|
|
2517
|
+
jwt
|
|
2518
|
+
});
|
|
2519
|
+
}
|
|
2520
|
+
async exportStaff(jwt) {
|
|
2521
|
+
return await this.client.download({
|
|
2522
|
+
url: "/user/export/users",
|
|
2523
|
+
jwt
|
|
2524
|
+
});
|
|
2525
|
+
}
|
|
2526
|
+
async exportInstructors(jwt) {
|
|
2527
|
+
return await this.client.download({
|
|
2528
|
+
url: "/instructor/export",
|
|
2529
|
+
jwt
|
|
2530
|
+
});
|
|
2531
|
+
}
|
|
2532
|
+
// Inventory & Equipment
|
|
2533
|
+
async exportEquipmentTypes(jwt) {
|
|
2534
|
+
return await this.client.download({
|
|
2535
|
+
url: "/equipment-types/export",
|
|
2536
|
+
jwt
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
async exportBranchEquipment(branchId, jwt) {
|
|
2540
|
+
return await this.client.download({
|
|
2541
|
+
url: `/branches/${branchId}/equipment/export`,
|
|
2542
|
+
jwt
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
// Services & Products
|
|
2546
|
+
async exportServices(jwt) {
|
|
2547
|
+
return await this.client.download({
|
|
2548
|
+
url: "/services/export",
|
|
2549
|
+
jwt
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
async exportBranchServices(branchId, jwt) {
|
|
2553
|
+
return await this.client.download({
|
|
2554
|
+
url: `/branches/${branchId}/services/export`,
|
|
2555
|
+
jwt
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
// Memberships & Packages
|
|
2559
|
+
async exportMembershipPlans(jwt) {
|
|
2560
|
+
return await this.client.download({
|
|
2561
|
+
url: "/membership-plans/export",
|
|
2562
|
+
jwt
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
async exportPackages(jwt) {
|
|
2566
|
+
return await this.client.download({
|
|
2567
|
+
url: "/packages/export",
|
|
2568
|
+
jwt
|
|
2569
|
+
});
|
|
2570
|
+
}
|
|
2571
|
+
// Billing
|
|
2572
|
+
async exportPaymentMethods(jwt) {
|
|
2573
|
+
return await this.client.download({
|
|
2574
|
+
url: "/billing/payment-methods/export",
|
|
2575
|
+
jwt
|
|
2576
|
+
});
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2579
|
+
|
|
2343
2580
|
// src/types/auth.ts
|
|
2344
2581
|
var UserGender = /* @__PURE__ */ ((UserGender2) => {
|
|
2345
2582
|
UserGender2["male"] = "male";
|
|
@@ -2466,6 +2703,7 @@ var VitalFit = class _VitalFit {
|
|
|
2466
2703
|
policy;
|
|
2467
2704
|
audit;
|
|
2468
2705
|
notification;
|
|
2706
|
+
exports;
|
|
2469
2707
|
constructor(isDevMode, origin) {
|
|
2470
2708
|
this.client = new Client(isDevMode, origin);
|
|
2471
2709
|
this.auth = new AuthService(this.client);
|
|
@@ -2490,6 +2728,7 @@ var VitalFit = class _VitalFit {
|
|
|
2490
2728
|
this.policy = new PolicyService(this.client);
|
|
2491
2729
|
this.audit = new AuditService(this.client);
|
|
2492
2730
|
this.notification = new NotificationService(this.client);
|
|
2731
|
+
this.exports = new ExportsService(this.client);
|
|
2493
2732
|
}
|
|
2494
2733
|
static getInstance(isDevMode = false) {
|
|
2495
2734
|
if (!_VitalFit.instance) {
|
|
@@ -2498,7 +2737,7 @@ var VitalFit = class _VitalFit {
|
|
|
2498
2737
|
return _VitalFit.instance;
|
|
2499
2738
|
}
|
|
2500
2739
|
version() {
|
|
2501
|
-
return "0.3.
|
|
2740
|
+
return "0.3.9";
|
|
2502
2741
|
}
|
|
2503
2742
|
};
|
|
2504
2743
|
export {
|