@gymspace/sdk 1.2.8 → 1.2.11
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 +54 -183
- package/dist/index.d.ts +54 -183
- package/dist/index.js +45 -78
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +36 -4
- package/src/models/check-ins.ts +6 -4
- package/src/models/dashboard.ts +26 -1
- package/src/models/index.ts +0 -2
- package/src/models/onboarding.ts +0 -17
- package/src/models/payment-methods.ts +2 -2
- package/src/models/products.ts +2 -10
- package/src/resources/admin-subscription-management.ts +1 -1
- package/src/resources/dashboard.ts +11 -1
- package/src/resources/index.ts +0 -2
- package/src/resources/payment-methods.ts +3 -3
- package/src/resources/products.ts +21 -31
- package/src/sdk.ts +7 -6
- package/src/models/evaluations.ts +0 -91
- package/src/models/leads.ts +0 -52
- package/src/resources/evaluations.ts +0 -63
- package/src/resources/leads.ts +0 -48
package/dist/index.mjs
CHANGED
|
@@ -68,7 +68,7 @@ var ApiClient = class {
|
|
|
68
68
|
if (this.config.apiKey && config.headers) {
|
|
69
69
|
config.headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
70
70
|
}
|
|
71
|
-
if (this.refreshToken && config.
|
|
71
|
+
if (this.refreshToken && this.config.apiKey && config.headers) {
|
|
72
72
|
config.headers["X-Refresh-Token"] = this.refreshToken;
|
|
73
73
|
}
|
|
74
74
|
return config;
|
|
@@ -79,6 +79,18 @@ var ApiClient = class {
|
|
|
79
79
|
);
|
|
80
80
|
this.axiosInstance.interceptors.response.use(
|
|
81
81
|
(response) => {
|
|
82
|
+
const newAccessToken = response.headers["x-new-access-token"];
|
|
83
|
+
const newRefreshToken = response.headers["x-new-refresh-token"];
|
|
84
|
+
if (newAccessToken) {
|
|
85
|
+
console.log("Tokens refreshed by backend, updating SDK...");
|
|
86
|
+
this.setAuthToken(newAccessToken);
|
|
87
|
+
if (newRefreshToken) {
|
|
88
|
+
this.setRefreshToken(newRefreshToken);
|
|
89
|
+
}
|
|
90
|
+
if (this.onTokenRefreshed) {
|
|
91
|
+
this.onTokenRefreshed(newAccessToken, newRefreshToken);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
82
94
|
return response;
|
|
83
95
|
},
|
|
84
96
|
async (error) => {
|
|
@@ -174,6 +186,18 @@ var ApiClient = class {
|
|
|
174
186
|
getRefreshToken() {
|
|
175
187
|
return this.refreshToken;
|
|
176
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Set callback for when tokens are refreshed by backend
|
|
191
|
+
*/
|
|
192
|
+
setOnTokenRefreshed(callback) {
|
|
193
|
+
this.onTokenRefreshed = callback;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get the token refresh callback
|
|
197
|
+
*/
|
|
198
|
+
getOnTokenRefreshed() {
|
|
199
|
+
return this.onTokenRefreshed;
|
|
200
|
+
}
|
|
177
201
|
setGymId(gymId) {
|
|
178
202
|
this.axiosInstance.defaults.headers.common["X-Gym-Id"] = gymId;
|
|
179
203
|
}
|
|
@@ -613,42 +637,13 @@ var DashboardResource = class extends BaseResource {
|
|
|
613
637
|
...params
|
|
614
638
|
});
|
|
615
639
|
}
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
this.
|
|
623
|
-
}
|
|
624
|
-
async createEvaluation(data, options) {
|
|
625
|
-
return this.client.post(this.basePath, data, options);
|
|
626
|
-
}
|
|
627
|
-
async getEvaluation(id, options) {
|
|
628
|
-
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
629
|
-
}
|
|
630
|
-
async updateEvaluation(id, data, options) {
|
|
631
|
-
return this.client.put(`${this.basePath}/${id}`, data, options);
|
|
632
|
-
}
|
|
633
|
-
async deleteEvaluation(id, options) {
|
|
634
|
-
return this.client.delete(`${this.basePath}/${id}`, options);
|
|
635
|
-
}
|
|
636
|
-
async getClientEvaluations(clientId, params, options) {
|
|
637
|
-
return this.paginate(
|
|
638
|
-
`${this.basePath}/client/${clientId}`,
|
|
639
|
-
params,
|
|
640
|
-
options
|
|
641
|
-
);
|
|
642
|
-
}
|
|
643
|
-
async getGymEvaluationStats(options) {
|
|
644
|
-
return this.client.get(`${this.basePath}/gym/stats`, void 0, options);
|
|
645
|
-
}
|
|
646
|
-
async generateEvaluationReport(id, options) {
|
|
647
|
-
return this.client.get(
|
|
648
|
-
`${this.basePath}/${id}/report`,
|
|
649
|
-
void 0,
|
|
650
|
-
options
|
|
651
|
-
);
|
|
640
|
+
/**
|
|
641
|
+
* Get detailed list of check-ins within date range
|
|
642
|
+
* @param params Optional date range parameters (defaults to current day)
|
|
643
|
+
* @returns Detailed list of check-ins with client and registeredBy information
|
|
644
|
+
*/
|
|
645
|
+
async getCheckInsList(params) {
|
|
646
|
+
return this.client.get("/dashboard/check-ins/list", params);
|
|
652
647
|
}
|
|
653
648
|
};
|
|
654
649
|
|
|
@@ -712,36 +707,6 @@ var InvitationsResource = class extends BaseResource {
|
|
|
712
707
|
}
|
|
713
708
|
};
|
|
714
709
|
|
|
715
|
-
// src/resources/leads.ts
|
|
716
|
-
var LeadsResource = class extends BaseResource {
|
|
717
|
-
constructor() {
|
|
718
|
-
super(...arguments);
|
|
719
|
-
this.basePath = "leads";
|
|
720
|
-
}
|
|
721
|
-
async createLead(data, options) {
|
|
722
|
-
return this.client.post(this.basePath, data, options);
|
|
723
|
-
}
|
|
724
|
-
async searchLeads(params, options) {
|
|
725
|
-
return this.paginate(this.basePath, params, options);
|
|
726
|
-
}
|
|
727
|
-
async getLead(id, options) {
|
|
728
|
-
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
729
|
-
}
|
|
730
|
-
async updateLead(id, data, options) {
|
|
731
|
-
return this.client.put(`${this.basePath}/${id}`, data, options);
|
|
732
|
-
}
|
|
733
|
-
async getLeadStats(options) {
|
|
734
|
-
return this.client.get(`${this.basePath}/stats/gym`, void 0, options);
|
|
735
|
-
}
|
|
736
|
-
async convertLead(id, options) {
|
|
737
|
-
return this.client.post(
|
|
738
|
-
`${this.basePath}/${id}/convert`,
|
|
739
|
-
void 0,
|
|
740
|
-
options
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
|
|
745
710
|
// src/resources/assets.ts
|
|
746
711
|
var AssetsResource = class extends BaseResource {
|
|
747
712
|
/**
|
|
@@ -1003,7 +968,7 @@ var ProductsResource = class extends BaseResource {
|
|
|
1003
968
|
return this.client.post(`${this.basePath}/services`, data, options);
|
|
1004
969
|
}
|
|
1005
970
|
async searchProducts(params, options) {
|
|
1006
|
-
return this.
|
|
971
|
+
return this.client.get(this.basePath, params, options);
|
|
1007
972
|
}
|
|
1008
973
|
async getProduct(id, options) {
|
|
1009
974
|
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
@@ -1021,15 +986,15 @@ var ProductsResource = class extends BaseResource {
|
|
|
1021
986
|
return this.client.patch(`${this.basePath}/${id}/stock`, data, options);
|
|
1022
987
|
}
|
|
1023
988
|
async getLowStockProducts(threshold = 10, options) {
|
|
989
|
+
return this.client.get(`${this.basePath}/low-stock`, { threshold }, options);
|
|
990
|
+
}
|
|
991
|
+
async getProductStockMovements(id, options) {
|
|
1024
992
|
return this.client.get(
|
|
1025
|
-
`${this.basePath}/
|
|
1026
|
-
|
|
993
|
+
`${this.basePath}/${id}/stock-movements`,
|
|
994
|
+
void 0,
|
|
1027
995
|
options
|
|
1028
996
|
);
|
|
1029
997
|
}
|
|
1030
|
-
async getProductStockMovements(id, options) {
|
|
1031
|
-
return this.client.get(`${this.basePath}/${id}/stock-movements`, void 0, options);
|
|
1032
|
-
}
|
|
1033
998
|
};
|
|
1034
999
|
|
|
1035
1000
|
// src/resources/sales.ts
|
|
@@ -1287,7 +1252,7 @@ var PaymentMethodsResource = class extends BaseResource {
|
|
|
1287
1252
|
return this.client.post(this.basePath, data, options);
|
|
1288
1253
|
}
|
|
1289
1254
|
async searchPaymentMethods(params, options) {
|
|
1290
|
-
return this.
|
|
1255
|
+
return this.client.get(this.basePath, params, options);
|
|
1291
1256
|
}
|
|
1292
1257
|
async getPaymentMethod(id, options) {
|
|
1293
1258
|
return this.client.get(`${this.basePath}/${id}`, void 0, options);
|
|
@@ -1442,10 +1407,8 @@ var GymSpaceSdk = class {
|
|
|
1442
1407
|
this.membershipPlans = new MembershipPlansResource(this.client);
|
|
1443
1408
|
this.contracts = new ContractsResource(this.client);
|
|
1444
1409
|
this.dashboard = new DashboardResource(this.client);
|
|
1445
|
-
this.evaluations = new EvaluationsResource(this.client);
|
|
1446
1410
|
this.checkIns = new CheckInsResource(this.client);
|
|
1447
1411
|
this.invitations = new InvitationsResource(this.client);
|
|
1448
|
-
this.leads = new LeadsResource(this.client);
|
|
1449
1412
|
this.assets = new AssetsResource(this.client);
|
|
1450
1413
|
this.files = new FilesResource(this.client);
|
|
1451
1414
|
this.publicCatalog = new PublicCatalogResource(this.client);
|
|
@@ -1507,6 +1470,12 @@ var GymSpaceSdk = class {
|
|
|
1507
1470
|
createAgentFetch() {
|
|
1508
1471
|
return createAgentFetch(this.client, this.expoFetch);
|
|
1509
1472
|
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Set callback for when tokens are refreshed by backend
|
|
1475
|
+
*/
|
|
1476
|
+
setOnTokenRefreshed(callback) {
|
|
1477
|
+
this.client.setOnTokenRefreshed(callback);
|
|
1478
|
+
}
|
|
1510
1479
|
/**
|
|
1511
1480
|
* Get the underlying API client
|
|
1512
1481
|
*/
|
|
@@ -1890,6 +1859,6 @@ var OnboardingStep = /* @__PURE__ */ ((OnboardingStep2) => {
|
|
|
1890
1859
|
return OnboardingStep2;
|
|
1891
1860
|
})(OnboardingStep || {});
|
|
1892
1861
|
|
|
1893
|
-
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,
|
|
1862
|
+
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, FILE_LIMITS, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, InvitationStatus, InvitationsResource, LeadStatus, 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 };
|
|
1894
1863
|
//# sourceMappingURL=index.mjs.map
|
|
1895
1864
|
//# sourceMappingURL=index.mjs.map
|