@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.mjs CHANGED
@@ -188,6 +188,26 @@ var ApiClient = class {
188
188
  }
189
189
  };
190
190
 
191
+ // src/utils/agent-fetch.ts
192
+ function createAgentFetch(apiClient, customFetch) {
193
+ const fetchFn = customFetch || fetch;
194
+ return async (path, options) => {
195
+ const fullUrl = `${apiClient.getBaseUrl()}/agent${path}`;
196
+ const axiosInstance = apiClient.axiosInstance;
197
+ const gymId = axiosInstance?.defaults?.headers?.common?.["X-Gym-Id"];
198
+ const headers = {
199
+ "Content-Type": "application/json",
200
+ ...apiClient.getAccessToken() && { Authorization: `Bearer ${apiClient.getAccessToken()}` },
201
+ ...gymId && { "X-Gym-Id": gymId },
202
+ ...options?.headers || {}
203
+ };
204
+ return fetchFn(fullUrl, {
205
+ ...options,
206
+ headers
207
+ });
208
+ };
209
+ }
210
+
191
211
  // src/resources/base.ts
192
212
  var BaseResource = class {
193
213
  constructor(client) {
@@ -380,11 +400,11 @@ var CollaboratorsResource = class extends BaseResource {
380
400
  async update(id, data, options) {
381
401
  return this.client.patch(`${this.basePath}/${id}`, data, options);
382
402
  }
383
- async updateRole(id, roleId, options) {
384
- return this.client.patch(`${this.basePath}/${id}/role`, { roleId }, options);
403
+ async updateRole(id, data, options) {
404
+ return this.client.patch(`${this.basePath}/${id}/role`, data, options);
385
405
  }
386
- async updateStatus(id, status, options) {
387
- return this.client.patch(`${this.basePath}/${id}/status`, { status }, options);
406
+ async updateStatus(id, data, options) {
407
+ return this.client.patch(`${this.basePath}/${id}/status`, data, options);
388
408
  }
389
409
  async getActivity(id, params, options) {
390
410
  return this.client.get(`${this.basePath}/${id}/activity`, params, options);
@@ -430,7 +450,7 @@ var ClientsResource = class extends BaseResource {
430
450
  return this.client.post(this.basePath, data, options);
431
451
  }
432
452
  async searchClients(params, options) {
433
- return this.paginate(this.basePath, params, options);
453
+ return this.client.get(this.basePath, params, options);
434
454
  }
435
455
  async getClient(id, options) {
436
456
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
@@ -445,20 +465,24 @@ var ClientsResource = class extends BaseResource {
445
465
  return this.client.get(`${this.basePath}/${id}/stats`, void 0, options);
446
466
  }
447
467
  async getClientStat(id, statKey, options) {
448
- return this.client.get(`${this.basePath}/${id}/stats/${statKey}`, void 0, options);
468
+ return this.client.get(
469
+ `${this.basePath}/${id}/stats/${statKey}`,
470
+ void 0,
471
+ options
472
+ );
449
473
  }
450
474
  async getClientStatsByCategory(id, category, options) {
451
- return this.client.get(`${this.basePath}/${id}/stats/category/${category}`, void 0, options);
475
+ return this.client.get(
476
+ `${this.basePath}/${id}/stats/category/${category}`,
477
+ void 0,
478
+ options
479
+ );
452
480
  }
453
481
  async getAvailableStats(options) {
454
482
  return this.client.get(`${this.basePath}/stats/available`, void 0, options);
455
483
  }
456
484
  async searchClientsForCheckIn(params, options) {
457
- return this.client.get(
458
- `${this.basePath}/search/check-in`,
459
- params,
460
- options
461
- );
485
+ return this.client.get(`${this.basePath}/search/check-in`, params, options);
462
486
  }
463
487
  };
464
488
 
@@ -508,11 +532,7 @@ var ContractsResource = class extends BaseResource {
508
532
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
509
533
  }
510
534
  async getClientContracts(clientId, options) {
511
- return this.client.get(
512
- `${this.basePath}/client/${clientId}`,
513
- void 0,
514
- options
515
- );
535
+ return this.client.get(`${this.basePath}/client/${clientId}`, void 0, options);
516
536
  }
517
537
  async renewContract(id, data, options) {
518
538
  return this.client.post(`${this.basePath}/${id}/renew`, data, options);
@@ -523,6 +543,13 @@ var ContractsResource = class extends BaseResource {
523
543
  async cancelContract(id, data, options) {
524
544
  return this.client.put(`${this.basePath}/${id}/cancel`, data, options);
525
545
  }
546
+ async resendWhatsAppNotification(contractId, options) {
547
+ return this.client.post(
548
+ `${this.basePath}/${contractId}/resend-whatsapp`,
549
+ {},
550
+ options
551
+ );
552
+ }
526
553
  };
527
554
 
528
555
  // src/resources/dashboard.ts
@@ -586,6 +613,14 @@ var DashboardResource = class extends BaseResource {
586
613
  ...params
587
614
  });
588
615
  }
616
+ /**
617
+ * Get detailed list of check-ins within date range
618
+ * @param params Optional date range parameters (defaults to current day)
619
+ * @returns Detailed list of check-ins with client and registeredBy information
620
+ */
621
+ async getCheckInsList(params) {
622
+ return this.client.get("/dashboard/check-ins/list", params);
623
+ }
589
624
  };
590
625
 
591
626
  // src/resources/evaluations.ts
@@ -1024,7 +1059,11 @@ var SalesResource = class extends BaseResource {
1024
1059
  return this.client.put(`${this.basePath}/${id}`, data, options);
1025
1060
  }
1026
1061
  async updatePaymentStatus(id, paymentStatus, options) {
1027
- return this.client.put(`${this.basePath}/${id}/payment-status`, { paymentStatus }, options);
1062
+ return this.client.put(
1063
+ `${this.basePath}/${id}/payment-status`,
1064
+ { paymentStatus },
1065
+ options
1066
+ );
1028
1067
  }
1029
1068
  async paySale(id, data, options) {
1030
1069
  return this.client.post(`${this.basePath}/${id}/payment`, data, options);
@@ -1046,11 +1085,7 @@ var SalesResource = class extends BaseResource {
1046
1085
  const params = { limit };
1047
1086
  if (startDate) params.startDate = startDate;
1048
1087
  if (endDate) params.endDate = endDate;
1049
- return this.client.get(
1050
- `${this.basePath}/top-products`,
1051
- params,
1052
- options
1053
- );
1088
+ return this.client.get(`${this.basePath}/top-products`, params, options);
1054
1089
  }
1055
1090
  async getSalesByCustomer(startDate, endDate, options) {
1056
1091
  const params = {};
@@ -1062,6 +1097,13 @@ var SalesResource = class extends BaseResource {
1062
1097
  options
1063
1098
  );
1064
1099
  }
1100
+ async resendWhatsAppNotification(saleId, options) {
1101
+ return this.client.post(
1102
+ `${this.basePath}/${saleId}/resend-whatsapp`,
1103
+ {},
1104
+ options
1105
+ );
1106
+ }
1065
1107
  };
1066
1108
 
1067
1109
  // src/resources/suppliers.ts
@@ -1272,6 +1314,129 @@ var PaymentMethodsResource = class extends BaseResource {
1272
1314
  }
1273
1315
  };
1274
1316
 
1317
+ // src/resources/whatsapp.ts
1318
+ var WhatsAppResource = class extends BaseResource {
1319
+ constructor() {
1320
+ super(...arguments);
1321
+ this.basePath = "whatsapp";
1322
+ }
1323
+ /**
1324
+ * Get WhatsApp configuration for the current gym
1325
+ */
1326
+ async getConfig(options) {
1327
+ return this.client.get(`${this.basePath}/config`, void 0, options);
1328
+ }
1329
+ /**
1330
+ * Initialize WhatsApp connection
1331
+ * Returns QR code if needed
1332
+ */
1333
+ async initializeConnection(options) {
1334
+ return this.client.post(
1335
+ `${this.basePath}/initialize`,
1336
+ {},
1337
+ options
1338
+ );
1339
+ }
1340
+ /**
1341
+ * Update WhatsApp configuration
1342
+ */
1343
+ async updateConfig(data, options) {
1344
+ return this.client.put(`${this.basePath}/config`, data, options);
1345
+ }
1346
+ /**
1347
+ * Get WhatsApp connection status
1348
+ */
1349
+ async getConnectionStatus(options) {
1350
+ return this.client.get(
1351
+ `${this.basePath}/connection-status`,
1352
+ void 0,
1353
+ options
1354
+ );
1355
+ }
1356
+ /**
1357
+ * Send a WhatsApp message
1358
+ */
1359
+ async sendMessage(data, options) {
1360
+ return this.client.post(`${this.basePath}/send-message`, data, options);
1361
+ }
1362
+ /**
1363
+ * Get WhatsApp messages with pagination and filters
1364
+ */
1365
+ async getMessages(params, options) {
1366
+ return this.paginate(`${this.basePath}/messages`, params, options);
1367
+ }
1368
+ /**
1369
+ * Get a specific WhatsApp message by ID
1370
+ */
1371
+ async getMessage(id, options) {
1372
+ return this.client.get(`${this.basePath}/messages/${id}`, void 0, options);
1373
+ }
1374
+ async listContacts(options) {
1375
+ return this.client.get(`${this.basePath}/contacts`, void 0, options);
1376
+ }
1377
+ /**
1378
+ * Disconnect WhatsApp instance
1379
+ * Logs out from WhatsApp without deleting the instance
1380
+ */
1381
+ async disconnect(options) {
1382
+ return this.client.post(`${this.basePath}/disconnect`, {}, options);
1383
+ }
1384
+ };
1385
+
1386
+ // src/resources/whatsapp-templates.ts
1387
+ var WhatsAppTemplatesResource = class extends BaseResource {
1388
+ constructor() {
1389
+ super(...arguments);
1390
+ this.basePath = "whatsapp/templates";
1391
+ }
1392
+ /**
1393
+ * Create a new WhatsApp template
1394
+ */
1395
+ async create(data, options) {
1396
+ return this.client.post(this.basePath, data, options);
1397
+ }
1398
+ /**
1399
+ * Get all WhatsApp templates with pagination and filters
1400
+ */
1401
+ async findAll(params, options) {
1402
+ return this.paginate(this.basePath, params, options);
1403
+ }
1404
+ /**
1405
+ * Get a specific WhatsApp template by ID
1406
+ */
1407
+ async findOne(id, options) {
1408
+ return this.client.get(`${this.basePath}/${id}`, void 0, options);
1409
+ }
1410
+ /**
1411
+ * Get a WhatsApp template by code
1412
+ */
1413
+ async findByCode(code, options) {
1414
+ return this.client.get(`${this.basePath}/code/${code}`, void 0, options);
1415
+ }
1416
+ /**
1417
+ * Update a WhatsApp template
1418
+ */
1419
+ async update(id, data, options) {
1420
+ return this.client.put(`${this.basePath}/${id}`, data, options);
1421
+ }
1422
+ /**
1423
+ * Delete a WhatsApp template
1424
+ */
1425
+ async remove(id, options) {
1426
+ return this.client.delete(`${this.basePath}/${id}`, options);
1427
+ }
1428
+ /**
1429
+ * Preview a template with variables
1430
+ */
1431
+ async preview(id, variables, options) {
1432
+ return this.client.post(
1433
+ `${this.basePath}/${id}/preview`,
1434
+ variables,
1435
+ options
1436
+ );
1437
+ }
1438
+ };
1439
+
1275
1440
  // src/sdk.ts
1276
1441
  var GymSpaceSdk = class {
1277
1442
  constructor(config) {
@@ -1302,6 +1467,8 @@ var GymSpaceSdk = class {
1302
1467
  this.subscriptionPlans = new SubscriptionPlansResource(this.client);
1303
1468
  this.adminSubscriptionManagement = new AdminSubscriptionManagementResource(this.client);
1304
1469
  this.paymentMethods = new PaymentMethodsResource(this.client);
1470
+ this.whatsapp = new WhatsAppResource(this.client);
1471
+ this.whatsappTemplates = new WhatsAppTemplatesResource(this.client);
1305
1472
  }
1306
1473
  /**
1307
1474
  * Set the authentication token
@@ -1333,6 +1500,21 @@ var GymSpaceSdk = class {
1333
1500
  clearAuth() {
1334
1501
  this.client.clearAuth();
1335
1502
  }
1503
+ /**
1504
+ * Set Expo fetch for React Native environments
1505
+ * Should be called once during app initialization
1506
+ */
1507
+ setExpoFetch(fetchFn) {
1508
+ this.expoFetch = fetchFn;
1509
+ }
1510
+ /**
1511
+ * Create a fetch function for agent endpoints
1512
+ * Uses the /agent/* proxy that includes request context
1513
+ * Automatically uses Expo fetch if set
1514
+ */
1515
+ createAgentFetch() {
1516
+ return createAgentFetch(this.client, this.expoFetch);
1517
+ }
1336
1518
  /**
1337
1519
  * Get the underlying API client
1338
1520
  */
@@ -1364,6 +1546,7 @@ var CollaboratorStatus = /* @__PURE__ */ ((CollaboratorStatus2) => {
1364
1546
  var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
1365
1547
  InvitationStatus2["PENDING"] = "pending";
1366
1548
  InvitationStatus2["ACCEPTED"] = "accepted";
1549
+ InvitationStatus2["CANCELLED"] = "cancelled";
1367
1550
  InvitationStatus2["EXPIRED"] = "expired";
1368
1551
  return InvitationStatus2;
1369
1552
  })(InvitationStatus || {});
@@ -1533,10 +1716,14 @@ var PERMISSIONS = {
1533
1716
  PAYMENT_METHODS_CREATE: "PAYMENT_METHODS_CREATE",
1534
1717
  PAYMENT_METHODS_READ: "PAYMENT_METHODS_READ",
1535
1718
  PAYMENT_METHODS_UPDATE: "PAYMENT_METHODS_UPDATE",
1536
- PAYMENT_METHODS_DELETE: "PAYMENT_METHODS_DELETE"
1719
+ PAYMENT_METHODS_DELETE: "PAYMENT_METHODS_DELETE",
1720
+ // Special permissions
1721
+ SUPER_ADMIN: "SUPER_ADMIN",
1722
+ OWNER: "OWNER",
1723
+ All: "ALL"
1537
1724
  };
1538
1725
  var ROLE_PERMISSIONS = {
1539
- OWNER: Object.values(PERMISSIONS),
1726
+ ADMIN: Object.values(PERMISSIONS),
1540
1727
  MANAGER: [
1541
1728
  PERMISSIONS.GYMS_READ,
1542
1729
  PERMISSIONS.COLLABORATORS_READ,
@@ -1576,26 +1763,6 @@ var ROLE_PERMISSIONS = {
1576
1763
  PERMISSIONS.PAYMENT_METHODS_READ,
1577
1764
  PERMISSIONS.PAYMENT_METHODS_UPDATE,
1578
1765
  PERMISSIONS.PAYMENT_METHODS_DELETE
1579
- ],
1580
- STAFF: [
1581
- PERMISSIONS.CLIENTS_READ,
1582
- PERMISSIONS.CHECKINS_CREATE,
1583
- PERMISSIONS.CHECKINS_READ,
1584
- PERMISSIONS.PRODUCTS_READ,
1585
- PERMISSIONS.PRODUCT_CATEGORIES_READ,
1586
- PERMISSIONS.SALES_CREATE,
1587
- PERMISSIONS.SALES_READ,
1588
- PERMISSIONS.PAYMENT_METHODS_READ
1589
- ],
1590
- ADVISOR: [
1591
- PERMISSIONS.CLIENTS_READ,
1592
- PERMISSIONS.EVALUATIONS_CREATE,
1593
- PERMISSIONS.EVALUATIONS_READ,
1594
- PERMISSIONS.EVALUATIONS_UPDATE,
1595
- PERMISSIONS.ASSETS_CREATE,
1596
- PERMISSIONS.ASSETS_READ,
1597
- PERMISSIONS.FILES_CREATE,
1598
- PERMISSIONS.FILES_READ
1599
1766
  ]
1600
1767
  };
1601
1768
  var CACHE_TTL = {
@@ -1632,6 +1799,95 @@ var HEADERS = {
1632
1799
  GYM_ID: "X-Gym-Id",
1633
1800
  REQUEST_ID: "X-Request-Id"
1634
1801
  };
1802
+ var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
1803
+ RoleNames2["ADMIN"] = "Admin";
1804
+ RoleNames2["ENCARGADO"] = "Encargado";
1805
+ RoleNames2["OWNER"] = "OWNER";
1806
+ return RoleNames2;
1807
+ })(RoleNames || {});
1808
+ var ROLE_NAMES = RoleNames;
1809
+ function isAdminRole(roleName) {
1810
+ return roleName === "Admin";
1811
+ }
1812
+ function isEncargadoRole(roleName) {
1813
+ return roleName === "Encargado";
1814
+ }
1815
+ function canAccessFeature(userRole, allowedRoles) {
1816
+ if (!userRole) return false;
1817
+ if (userRole === "OWNER") return true;
1818
+ return allowedRoles.includes(userRole);
1819
+ }
1820
+ function getRoleDisplayName(roleName) {
1821
+ if (!roleName) return "";
1822
+ switch (roleName) {
1823
+ case "Admin":
1824
+ return "Administrador";
1825
+ case "Encargado":
1826
+ return "Encargado";
1827
+ case "OWNER":
1828
+ return "Propietario";
1829
+ default:
1830
+ return roleName;
1831
+ }
1832
+ }
1833
+ function getRoleDescription(roleName) {
1834
+ if (!roleName) return "";
1835
+ switch (roleName) {
1836
+ case "Admin":
1837
+ return "Acceso completo a todas las funcionalidades del gimnasio, gesti\xF3n de colaboradores y configuraci\xF3n";
1838
+ case "Encargado":
1839
+ return "Gesti\xF3n diaria del gimnasio: clientes, contratos, check-ins y reportes";
1840
+ case "OWNER":
1841
+ return "Acceso completo a todas las funcionalidades, organizaci\xF3n y suscripci\xF3n";
1842
+ default:
1843
+ return "";
1844
+ }
1845
+ }
1846
+ function getRoleCapabilities(roleName) {
1847
+ if (!roleName) return [];
1848
+ switch (roleName) {
1849
+ case "OWNER":
1850
+ return [
1851
+ "Acceso completo a todas las funcionalidades",
1852
+ "Gesti\xF3n de organizaci\xF3n",
1853
+ "Gesti\xF3n de suscripci\xF3n y facturaci\xF3n",
1854
+ "Gesti\xF3n completa de clientes",
1855
+ "Gesti\xF3n completa de contratos",
1856
+ "Gesti\xF3n de colaboradores",
1857
+ "Configuraci\xF3n del gimnasio",
1858
+ "Gesti\xF3n de planes",
1859
+ "Gesti\xF3n de proveedores",
1860
+ "Gesti\xF3n de m\xE9todos de pago",
1861
+ "Reportes y estad\xEDsticas",
1862
+ "Gesti\xF3n de inventario",
1863
+ "Check-ins"
1864
+ ];
1865
+ case "Admin":
1866
+ return [
1867
+ "Gesti\xF3n completa de clientes",
1868
+ "Gesti\xF3n completa de contratos",
1869
+ "Gesti\xF3n de colaboradores",
1870
+ "Configuraci\xF3n del gimnasio",
1871
+ "Gesti\xF3n de planes",
1872
+ "Gesti\xF3n de proveedores",
1873
+ "Gesti\xF3n de m\xE9todos de pago",
1874
+ "Reportes y estad\xEDsticas",
1875
+ "Gesti\xF3n de inventario",
1876
+ "Check-ins"
1877
+ ];
1878
+ case "Encargado":
1879
+ return [
1880
+ "Gesti\xF3n de clientes (ver, crear, editar)",
1881
+ "Creaci\xF3n y renovaci\xF3n de contratos",
1882
+ "Check-ins",
1883
+ "Ver reportes",
1884
+ "Gesti\xF3n de inventario",
1885
+ "Ventas"
1886
+ ];
1887
+ default:
1888
+ return [];
1889
+ }
1890
+ }
1635
1891
 
1636
1892
  // src/models/onboarding.ts
1637
1893
  var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
@@ -1642,6 +1898,6 @@ var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
1642
1898
  return OnboardingStep2;
1643
1899
  })(OnboardingStep || {});
1644
1900
 
1645
- export { AdminSubscriptionManagementResource, ApiClient, AssetCategory, AssetStatus, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, CACHE_TTL, CheckInsResource, ClientStatus, ClientsResource, CollaboratorStatus, CollaboratorsResource, CommentType, ContractAssetType, ContractStatus, ContractsResource, DATE_FORMATS, DashboardResource, EvaluationAssetCategory, EvaluationAssetStage, EvaluationStatus, EvaluationType, EvaluationsResource, FILE_LIMITS, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, InvitationStatus, InvitationsResource, LeadStatus, LeadsResource, MembershipPlansResource, NetworkError, NotFoundError, OnboardingResource, OnboardingStep, OrganizationsResource, PAGINATION_DEFAULTS, PERMISSIONS, PaymentFrequency, PaymentMethodsResource, PlanStatus, ProductsResource, PublicCatalogResource, ROLE_PERMISSIONS, RolesResource, SalesResource, SubscriptionPlansResource, SubscriptionStatus, SubscriptionsResource, SuppliersResource, UserType, UsersResource, ValidationError };
1901
+ export { AdminSubscriptionManagementResource, ApiClient, AssetCategory, AssetStatus, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, CACHE_TTL, CheckInsResource, ClientStatus, ClientsResource, CollaboratorStatus, CollaboratorsResource, CommentType, ContractAssetType, ContractStatus, ContractsResource, DATE_FORMATS, DashboardResource, EvaluationAssetCategory, EvaluationAssetStage, EvaluationStatus, EvaluationType, EvaluationsResource, FILE_LIMITS, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, InvitationStatus, InvitationsResource, LeadStatus, LeadsResource, MembershipPlansResource, NetworkError, NotFoundError, OnboardingResource, OnboardingStep, OrganizationsResource, PAGINATION_DEFAULTS, PERMISSIONS, PaymentFrequency, PaymentMethodsResource, PlanStatus, ProductsResource, PublicCatalogResource, ROLE_NAMES, ROLE_PERMISSIONS, RoleNames, RolesResource, SalesResource, SubscriptionPlansResource, SubscriptionStatus, SubscriptionsResource, SuppliersResource, UserType, UsersResource, ValidationError, WhatsAppResource, WhatsAppTemplatesResource, canAccessFeature, getRoleCapabilities, getRoleDescription, getRoleDisplayName, isAdminRole, isEncargadoRole };
1646
1902
  //# sourceMappingURL=index.mjs.map
1647
1903
  //# sourceMappingURL=index.mjs.map