@gymspace/sdk 1.2.5 → 1.2.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.js CHANGED
@@ -194,6 +194,26 @@ var ApiClient = class {
194
194
  }
195
195
  };
196
196
 
197
+ // src/utils/agent-fetch.ts
198
+ function createAgentFetch(apiClient, customFetch) {
199
+ const fetchFn = customFetch || fetch;
200
+ return async (path, options) => {
201
+ const fullUrl = `${apiClient.getBaseUrl()}/agent${path}`;
202
+ const axiosInstance = apiClient.axiosInstance;
203
+ const gymId = axiosInstance?.defaults?.headers?.common?.["X-Gym-Id"];
204
+ const headers = {
205
+ "Content-Type": "application/json",
206
+ ...apiClient.getAccessToken() && { Authorization: `Bearer ${apiClient.getAccessToken()}` },
207
+ ...gymId && { "X-Gym-Id": gymId },
208
+ ...options?.headers || {}
209
+ };
210
+ return fetchFn(fullUrl, {
211
+ ...options,
212
+ headers
213
+ });
214
+ };
215
+ }
216
+
197
217
  // src/resources/base.ts
198
218
  var BaseResource = class {
199
219
  constructor(client) {
@@ -386,11 +406,11 @@ var CollaboratorsResource = class extends BaseResource {
386
406
  async update(id, data, options) {
387
407
  return this.client.patch(`${this.basePath}/${id}`, data, options);
388
408
  }
389
- async updateRole(id, roleId, options) {
390
- return this.client.patch(`${this.basePath}/${id}/role`, { roleId }, options);
409
+ async updateRole(id, data, options) {
410
+ return this.client.patch(`${this.basePath}/${id}/role`, data, options);
391
411
  }
392
- async updateStatus(id, status, options) {
393
- return this.client.patch(`${this.basePath}/${id}/status`, { status }, options);
412
+ async updateStatus(id, data, options) {
413
+ return this.client.patch(`${this.basePath}/${id}/status`, data, options);
394
414
  }
395
415
  async getActivity(id, params, options) {
396
416
  return this.client.get(`${this.basePath}/${id}/activity`, params, options);
@@ -436,7 +456,7 @@ var ClientsResource = class extends BaseResource {
436
456
  return this.client.post(this.basePath, data, options);
437
457
  }
438
458
  async searchClients(params, options) {
439
- return this.paginate(this.basePath, params, options);
459
+ return this.client.get(this.basePath, params, options);
440
460
  }
441
461
  async getClient(id, options) {
442
462
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
@@ -451,20 +471,24 @@ var ClientsResource = class extends BaseResource {
451
471
  return this.client.get(`${this.basePath}/${id}/stats`, void 0, options);
452
472
  }
453
473
  async getClientStat(id, statKey, options) {
454
- return this.client.get(`${this.basePath}/${id}/stats/${statKey}`, void 0, options);
474
+ return this.client.get(
475
+ `${this.basePath}/${id}/stats/${statKey}`,
476
+ void 0,
477
+ options
478
+ );
455
479
  }
456
480
  async getClientStatsByCategory(id, category, options) {
457
- return this.client.get(`${this.basePath}/${id}/stats/category/${category}`, void 0, options);
481
+ return this.client.get(
482
+ `${this.basePath}/${id}/stats/category/${category}`,
483
+ void 0,
484
+ options
485
+ );
458
486
  }
459
487
  async getAvailableStats(options) {
460
488
  return this.client.get(`${this.basePath}/stats/available`, void 0, options);
461
489
  }
462
490
  async searchClientsForCheckIn(params, options) {
463
- return this.client.get(
464
- `${this.basePath}/search/check-in`,
465
- params,
466
- options
467
- );
491
+ return this.client.get(`${this.basePath}/search/check-in`, params, options);
468
492
  }
469
493
  };
470
494
 
@@ -514,11 +538,7 @@ var ContractsResource = class extends BaseResource {
514
538
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
515
539
  }
516
540
  async getClientContracts(clientId, options) {
517
- return this.client.get(
518
- `${this.basePath}/client/${clientId}`,
519
- void 0,
520
- options
521
- );
541
+ return this.client.get(`${this.basePath}/client/${clientId}`, void 0, options);
522
542
  }
523
543
  async renewContract(id, data, options) {
524
544
  return this.client.post(`${this.basePath}/${id}/renew`, data, options);
@@ -529,6 +549,13 @@ var ContractsResource = class extends BaseResource {
529
549
  async cancelContract(id, data, options) {
530
550
  return this.client.put(`${this.basePath}/${id}/cancel`, data, options);
531
551
  }
552
+ async resendWhatsAppNotification(contractId, options) {
553
+ return this.client.post(
554
+ `${this.basePath}/${contractId}/resend-whatsapp`,
555
+ {},
556
+ options
557
+ );
558
+ }
532
559
  };
533
560
 
534
561
  // src/resources/dashboard.ts
@@ -592,6 +619,14 @@ var DashboardResource = class extends BaseResource {
592
619
  ...params
593
620
  });
594
621
  }
622
+ /**
623
+ * Get detailed list of check-ins within date range
624
+ * @param params Optional date range parameters (defaults to current day)
625
+ * @returns Detailed list of check-ins with client and registeredBy information
626
+ */
627
+ async getCheckInsList(params) {
628
+ return this.client.get("/dashboard/check-ins/list", params);
629
+ }
595
630
  };
596
631
 
597
632
  // src/resources/evaluations.ts
@@ -1030,7 +1065,11 @@ var SalesResource = class extends BaseResource {
1030
1065
  return this.client.put(`${this.basePath}/${id}`, data, options);
1031
1066
  }
1032
1067
  async updatePaymentStatus(id, paymentStatus, options) {
1033
- return this.client.put(`${this.basePath}/${id}/payment-status`, { paymentStatus }, options);
1068
+ return this.client.put(
1069
+ `${this.basePath}/${id}/payment-status`,
1070
+ { paymentStatus },
1071
+ options
1072
+ );
1034
1073
  }
1035
1074
  async paySale(id, data, options) {
1036
1075
  return this.client.post(`${this.basePath}/${id}/payment`, data, options);
@@ -1052,11 +1091,7 @@ var SalesResource = class extends BaseResource {
1052
1091
  const params = { limit };
1053
1092
  if (startDate) params.startDate = startDate;
1054
1093
  if (endDate) params.endDate = endDate;
1055
- return this.client.get(
1056
- `${this.basePath}/top-products`,
1057
- params,
1058
- options
1059
- );
1094
+ return this.client.get(`${this.basePath}/top-products`, params, options);
1060
1095
  }
1061
1096
  async getSalesByCustomer(startDate, endDate, options) {
1062
1097
  const params = {};
@@ -1068,6 +1103,13 @@ var SalesResource = class extends BaseResource {
1068
1103
  options
1069
1104
  );
1070
1105
  }
1106
+ async resendWhatsAppNotification(saleId, options) {
1107
+ return this.client.post(
1108
+ `${this.basePath}/${saleId}/resend-whatsapp`,
1109
+ {},
1110
+ options
1111
+ );
1112
+ }
1071
1113
  };
1072
1114
 
1073
1115
  // src/resources/suppliers.ts
@@ -1278,6 +1320,129 @@ var PaymentMethodsResource = class extends BaseResource {
1278
1320
  }
1279
1321
  };
1280
1322
 
1323
+ // src/resources/whatsapp.ts
1324
+ var WhatsAppResource = class extends BaseResource {
1325
+ constructor() {
1326
+ super(...arguments);
1327
+ this.basePath = "whatsapp";
1328
+ }
1329
+ /**
1330
+ * Get WhatsApp configuration for the current gym
1331
+ */
1332
+ async getConfig(options) {
1333
+ return this.client.get(`${this.basePath}/config`, void 0, options);
1334
+ }
1335
+ /**
1336
+ * Initialize WhatsApp connection
1337
+ * Returns QR code if needed
1338
+ */
1339
+ async initializeConnection(options) {
1340
+ return this.client.post(
1341
+ `${this.basePath}/initialize`,
1342
+ {},
1343
+ options
1344
+ );
1345
+ }
1346
+ /**
1347
+ * Update WhatsApp configuration
1348
+ */
1349
+ async updateConfig(data, options) {
1350
+ return this.client.put(`${this.basePath}/config`, data, options);
1351
+ }
1352
+ /**
1353
+ * Get WhatsApp connection status
1354
+ */
1355
+ async getConnectionStatus(options) {
1356
+ return this.client.get(
1357
+ `${this.basePath}/connection-status`,
1358
+ void 0,
1359
+ options
1360
+ );
1361
+ }
1362
+ /**
1363
+ * Send a WhatsApp message
1364
+ */
1365
+ async sendMessage(data, options) {
1366
+ return this.client.post(`${this.basePath}/send-message`, data, options);
1367
+ }
1368
+ /**
1369
+ * Get WhatsApp messages with pagination and filters
1370
+ */
1371
+ async getMessages(params, options) {
1372
+ return this.paginate(`${this.basePath}/messages`, params, options);
1373
+ }
1374
+ /**
1375
+ * Get a specific WhatsApp message by ID
1376
+ */
1377
+ async getMessage(id, options) {
1378
+ return this.client.get(`${this.basePath}/messages/${id}`, void 0, options);
1379
+ }
1380
+ async listContacts(options) {
1381
+ return this.client.get(`${this.basePath}/contacts`, void 0, options);
1382
+ }
1383
+ /**
1384
+ * Disconnect WhatsApp instance
1385
+ * Logs out from WhatsApp without deleting the instance
1386
+ */
1387
+ async disconnect(options) {
1388
+ return this.client.post(`${this.basePath}/disconnect`, {}, options);
1389
+ }
1390
+ };
1391
+
1392
+ // src/resources/whatsapp-templates.ts
1393
+ var WhatsAppTemplatesResource = class extends BaseResource {
1394
+ constructor() {
1395
+ super(...arguments);
1396
+ this.basePath = "whatsapp/templates";
1397
+ }
1398
+ /**
1399
+ * Create a new WhatsApp template
1400
+ */
1401
+ async create(data, options) {
1402
+ return this.client.post(this.basePath, data, options);
1403
+ }
1404
+ /**
1405
+ * Get all WhatsApp templates with pagination and filters
1406
+ */
1407
+ async findAll(params, options) {
1408
+ return this.paginate(this.basePath, params, options);
1409
+ }
1410
+ /**
1411
+ * Get a specific WhatsApp template by ID
1412
+ */
1413
+ async findOne(id, options) {
1414
+ return this.client.get(`${this.basePath}/${id}`, void 0, options);
1415
+ }
1416
+ /**
1417
+ * Get a WhatsApp template by code
1418
+ */
1419
+ async findByCode(code, options) {
1420
+ return this.client.get(`${this.basePath}/code/${code}`, void 0, options);
1421
+ }
1422
+ /**
1423
+ * Update a WhatsApp template
1424
+ */
1425
+ async update(id, data, options) {
1426
+ return this.client.put(`${this.basePath}/${id}`, data, options);
1427
+ }
1428
+ /**
1429
+ * Delete a WhatsApp template
1430
+ */
1431
+ async remove(id, options) {
1432
+ return this.client.delete(`${this.basePath}/${id}`, options);
1433
+ }
1434
+ /**
1435
+ * Preview a template with variables
1436
+ */
1437
+ async preview(id, variables, options) {
1438
+ return this.client.post(
1439
+ `${this.basePath}/${id}/preview`,
1440
+ variables,
1441
+ options
1442
+ );
1443
+ }
1444
+ };
1445
+
1281
1446
  // src/sdk.ts
1282
1447
  var GymSpaceSdk = class {
1283
1448
  constructor(config) {
@@ -1308,6 +1473,8 @@ var GymSpaceSdk = class {
1308
1473
  this.subscriptionPlans = new SubscriptionPlansResource(this.client);
1309
1474
  this.adminSubscriptionManagement = new AdminSubscriptionManagementResource(this.client);
1310
1475
  this.paymentMethods = new PaymentMethodsResource(this.client);
1476
+ this.whatsapp = new WhatsAppResource(this.client);
1477
+ this.whatsappTemplates = new WhatsAppTemplatesResource(this.client);
1311
1478
  }
1312
1479
  /**
1313
1480
  * Set the authentication token
@@ -1339,6 +1506,21 @@ var GymSpaceSdk = class {
1339
1506
  clearAuth() {
1340
1507
  this.client.clearAuth();
1341
1508
  }
1509
+ /**
1510
+ * Set Expo fetch for React Native environments
1511
+ * Should be called once during app initialization
1512
+ */
1513
+ setExpoFetch(fetchFn) {
1514
+ this.expoFetch = fetchFn;
1515
+ }
1516
+ /**
1517
+ * Create a fetch function for agent endpoints
1518
+ * Uses the /agent/* proxy that includes request context
1519
+ * Automatically uses Expo fetch if set
1520
+ */
1521
+ createAgentFetch() {
1522
+ return createAgentFetch(this.client, this.expoFetch);
1523
+ }
1342
1524
  /**
1343
1525
  * Get the underlying API client
1344
1526
  */
@@ -1370,6 +1552,7 @@ var CollaboratorStatus = /* @__PURE__ */ ((CollaboratorStatus2) => {
1370
1552
  var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
1371
1553
  InvitationStatus2["PENDING"] = "pending";
1372
1554
  InvitationStatus2["ACCEPTED"] = "accepted";
1555
+ InvitationStatus2["CANCELLED"] = "cancelled";
1373
1556
  InvitationStatus2["EXPIRED"] = "expired";
1374
1557
  return InvitationStatus2;
1375
1558
  })(InvitationStatus || {});
@@ -1539,10 +1722,14 @@ var PERMISSIONS = {
1539
1722
  PAYMENT_METHODS_CREATE: "PAYMENT_METHODS_CREATE",
1540
1723
  PAYMENT_METHODS_READ: "PAYMENT_METHODS_READ",
1541
1724
  PAYMENT_METHODS_UPDATE: "PAYMENT_METHODS_UPDATE",
1542
- PAYMENT_METHODS_DELETE: "PAYMENT_METHODS_DELETE"
1725
+ PAYMENT_METHODS_DELETE: "PAYMENT_METHODS_DELETE",
1726
+ // Special permissions
1727
+ SUPER_ADMIN: "SUPER_ADMIN",
1728
+ OWNER: "OWNER",
1729
+ All: "ALL"
1543
1730
  };
1544
1731
  var ROLE_PERMISSIONS = {
1545
- OWNER: Object.values(PERMISSIONS),
1732
+ ADMIN: Object.values(PERMISSIONS),
1546
1733
  MANAGER: [
1547
1734
  PERMISSIONS.GYMS_READ,
1548
1735
  PERMISSIONS.COLLABORATORS_READ,
@@ -1582,26 +1769,6 @@ var ROLE_PERMISSIONS = {
1582
1769
  PERMISSIONS.PAYMENT_METHODS_READ,
1583
1770
  PERMISSIONS.PAYMENT_METHODS_UPDATE,
1584
1771
  PERMISSIONS.PAYMENT_METHODS_DELETE
1585
- ],
1586
- STAFF: [
1587
- PERMISSIONS.CLIENTS_READ,
1588
- PERMISSIONS.CHECKINS_CREATE,
1589
- PERMISSIONS.CHECKINS_READ,
1590
- PERMISSIONS.PRODUCTS_READ,
1591
- PERMISSIONS.PRODUCT_CATEGORIES_READ,
1592
- PERMISSIONS.SALES_CREATE,
1593
- PERMISSIONS.SALES_READ,
1594
- PERMISSIONS.PAYMENT_METHODS_READ
1595
- ],
1596
- ADVISOR: [
1597
- PERMISSIONS.CLIENTS_READ,
1598
- PERMISSIONS.EVALUATIONS_CREATE,
1599
- PERMISSIONS.EVALUATIONS_READ,
1600
- PERMISSIONS.EVALUATIONS_UPDATE,
1601
- PERMISSIONS.ASSETS_CREATE,
1602
- PERMISSIONS.ASSETS_READ,
1603
- PERMISSIONS.FILES_CREATE,
1604
- PERMISSIONS.FILES_READ
1605
1772
  ]
1606
1773
  };
1607
1774
  var CACHE_TTL = {
@@ -1638,6 +1805,95 @@ var HEADERS = {
1638
1805
  GYM_ID: "X-Gym-Id",
1639
1806
  REQUEST_ID: "X-Request-Id"
1640
1807
  };
1808
+ var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
1809
+ RoleNames2["ADMIN"] = "Admin";
1810
+ RoleNames2["ENCARGADO"] = "Encargado";
1811
+ RoleNames2["OWNER"] = "OWNER";
1812
+ return RoleNames2;
1813
+ })(RoleNames || {});
1814
+ var ROLE_NAMES = RoleNames;
1815
+ function isAdminRole(roleName) {
1816
+ return roleName === "Admin";
1817
+ }
1818
+ function isEncargadoRole(roleName) {
1819
+ return roleName === "Encargado";
1820
+ }
1821
+ function canAccessFeature(userRole, allowedRoles) {
1822
+ if (!userRole) return false;
1823
+ if (userRole === "OWNER") return true;
1824
+ return allowedRoles.includes(userRole);
1825
+ }
1826
+ function getRoleDisplayName(roleName) {
1827
+ if (!roleName) return "";
1828
+ switch (roleName) {
1829
+ case "Admin":
1830
+ return "Administrador";
1831
+ case "Encargado":
1832
+ return "Encargado";
1833
+ case "OWNER":
1834
+ return "Propietario";
1835
+ default:
1836
+ return roleName;
1837
+ }
1838
+ }
1839
+ function getRoleDescription(roleName) {
1840
+ if (!roleName) return "";
1841
+ switch (roleName) {
1842
+ case "Admin":
1843
+ return "Acceso completo a todas las funcionalidades del gimnasio, gesti\xF3n de colaboradores y configuraci\xF3n";
1844
+ case "Encargado":
1845
+ return "Gesti\xF3n diaria del gimnasio: clientes, contratos, check-ins y reportes";
1846
+ case "OWNER":
1847
+ return "Acceso completo a todas las funcionalidades, organizaci\xF3n y suscripci\xF3n";
1848
+ default:
1849
+ return "";
1850
+ }
1851
+ }
1852
+ function getRoleCapabilities(roleName) {
1853
+ if (!roleName) return [];
1854
+ switch (roleName) {
1855
+ case "OWNER":
1856
+ return [
1857
+ "Acceso completo a todas las funcionalidades",
1858
+ "Gesti\xF3n de organizaci\xF3n",
1859
+ "Gesti\xF3n de suscripci\xF3n y facturaci\xF3n",
1860
+ "Gesti\xF3n completa de clientes",
1861
+ "Gesti\xF3n completa de contratos",
1862
+ "Gesti\xF3n de colaboradores",
1863
+ "Configuraci\xF3n del gimnasio",
1864
+ "Gesti\xF3n de planes",
1865
+ "Gesti\xF3n de proveedores",
1866
+ "Gesti\xF3n de m\xE9todos de pago",
1867
+ "Reportes y estad\xEDsticas",
1868
+ "Gesti\xF3n de inventario",
1869
+ "Check-ins"
1870
+ ];
1871
+ case "Admin":
1872
+ return [
1873
+ "Gesti\xF3n completa de clientes",
1874
+ "Gesti\xF3n completa de contratos",
1875
+ "Gesti\xF3n de colaboradores",
1876
+ "Configuraci\xF3n del gimnasio",
1877
+ "Gesti\xF3n de planes",
1878
+ "Gesti\xF3n de proveedores",
1879
+ "Gesti\xF3n de m\xE9todos de pago",
1880
+ "Reportes y estad\xEDsticas",
1881
+ "Gesti\xF3n de inventario",
1882
+ "Check-ins"
1883
+ ];
1884
+ case "Encargado":
1885
+ return [
1886
+ "Gesti\xF3n de clientes (ver, crear, editar)",
1887
+ "Creaci\xF3n y renovaci\xF3n de contratos",
1888
+ "Check-ins",
1889
+ "Ver reportes",
1890
+ "Gesti\xF3n de inventario",
1891
+ "Ventas"
1892
+ ];
1893
+ default:
1894
+ return [];
1895
+ }
1896
+ }
1641
1897
 
1642
1898
  // src/models/onboarding.ts
1643
1899
  var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
@@ -1697,7 +1953,9 @@ exports.PaymentMethodsResource = PaymentMethodsResource;
1697
1953
  exports.PlanStatus = PlanStatus;
1698
1954
  exports.ProductsResource = ProductsResource;
1699
1955
  exports.PublicCatalogResource = PublicCatalogResource;
1956
+ exports.ROLE_NAMES = ROLE_NAMES;
1700
1957
  exports.ROLE_PERMISSIONS = ROLE_PERMISSIONS;
1958
+ exports.RoleNames = RoleNames;
1701
1959
  exports.RolesResource = RolesResource;
1702
1960
  exports.SalesResource = SalesResource;
1703
1961
  exports.SubscriptionPlansResource = SubscriptionPlansResource;
@@ -1707,5 +1965,13 @@ exports.SuppliersResource = SuppliersResource;
1707
1965
  exports.UserType = UserType;
1708
1966
  exports.UsersResource = UsersResource;
1709
1967
  exports.ValidationError = ValidationError;
1968
+ exports.WhatsAppResource = WhatsAppResource;
1969
+ exports.WhatsAppTemplatesResource = WhatsAppTemplatesResource;
1970
+ exports.canAccessFeature = canAccessFeature;
1971
+ exports.getRoleCapabilities = getRoleCapabilities;
1972
+ exports.getRoleDescription = getRoleDescription;
1973
+ exports.getRoleDisplayName = getRoleDisplayName;
1974
+ exports.isAdminRole = isAdminRole;
1975
+ exports.isEncargadoRole = isEncargadoRole;
1710
1976
  //# sourceMappingURL=index.js.map
1711
1977
  //# sourceMappingURL=index.js.map