@gymspace/sdk 1.9.1 → 1.9.4

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
@@ -49,6 +49,9 @@ var NetworkError = class extends GymSpaceError {
49
49
  var ApiClient = class {
50
50
  constructor(config) {
51
51
  this.refreshToken = null;
52
+ this.rememberMe = null;
53
+ this.isRefreshing = false;
54
+ this.failedRequestsQueue = [];
52
55
  this.config = config;
53
56
  this.axiosInstance = axios.create({
54
57
  baseURL: config.baseURL,
@@ -113,6 +116,74 @@ var ApiClient = class {
113
116
  return response;
114
117
  },
115
118
  async (error) => {
119
+ if (error.response?.status === 401) {
120
+ const originalRequest = error.config;
121
+ if (originalRequest?.skipAuth) {
122
+ throw this.handleError(error);
123
+ }
124
+ if (this.isRefreshing && this.refreshToken) {
125
+ return new Promise((resolve, reject) => {
126
+ this.failedRequestsQueue.push({
127
+ resolve: (token) => {
128
+ if (originalRequest) {
129
+ originalRequest.headers["Authorization"] = `Bearer ${token}`;
130
+ this.axiosInstance.request(originalRequest).then(resolve).catch(reject);
131
+ } else {
132
+ reject(error);
133
+ }
134
+ },
135
+ reject: (err) => {
136
+ reject(err);
137
+ }
138
+ });
139
+ });
140
+ }
141
+ if (this.refreshToken) {
142
+ this.isRefreshing = true;
143
+ try {
144
+ console.log("Access token expired, attempting refresh...");
145
+ const response = await axios.post(
146
+ `${this.config.baseURL}/auth/members/refresh`,
147
+ { refresh_token: this.refreshToken },
148
+ { headers: { "Content-Type": "application/json" } }
149
+ );
150
+ const { accessToken: newAccessToken, refreshToken: newRefreshToken } = response.data;
151
+ console.log("Token refresh successful");
152
+ this.setAuthToken(newAccessToken);
153
+ if (newRefreshToken) {
154
+ this.setRefreshToken(newRefreshToken);
155
+ }
156
+ if (this.onTokenRefreshed) {
157
+ this.onTokenRefreshed(newAccessToken, newRefreshToken);
158
+ }
159
+ this.failedRequestsQueue.forEach((request) => {
160
+ request.resolve(newAccessToken);
161
+ });
162
+ this.failedRequestsQueue = [];
163
+ if (originalRequest) {
164
+ originalRequest.headers["Authorization"] = `Bearer ${newAccessToken}`;
165
+ return this.axiosInstance.request(originalRequest);
166
+ }
167
+ throw error;
168
+ } catch (refreshError) {
169
+ console.error("Token refresh failed:", refreshError.message);
170
+ this.failedRequestsQueue.forEach((request) => {
171
+ request.reject(refreshError);
172
+ });
173
+ this.failedRequestsQueue = [];
174
+ this.clearAuth();
175
+ const authError = new AuthenticationError(
176
+ refreshError.response?.data?.message || "Token refresh failed"
177
+ );
178
+ if (this.onAuthFailure) {
179
+ this.onAuthFailure(authError);
180
+ }
181
+ throw authError;
182
+ } finally {
183
+ this.isRefreshing = false;
184
+ }
185
+ }
186
+ }
116
187
  throw this.handleError(error);
117
188
  }
118
189
  );
@@ -163,6 +234,9 @@ var ApiClient = class {
163
234
  if (options?.gymId) {
164
235
  headers["X-Gym-Id"] = options.gymId;
165
236
  }
237
+ if (options?.gymContextMode) {
238
+ headers["X-Gym-Context-Mode"] = options.gymContextMode;
239
+ }
166
240
  return { headers };
167
241
  }
168
242
  async request(method, path, data, options) {
@@ -207,6 +281,18 @@ var ApiClient = class {
207
281
  getRefreshToken() {
208
282
  return this.refreshToken;
209
283
  }
284
+ /**
285
+ * Set rememberMe preference from login response
286
+ */
287
+ setRememberMe(value) {
288
+ this.rememberMe = value;
289
+ }
290
+ /**
291
+ * Get rememberMe preference
292
+ */
293
+ getRememberMe() {
294
+ return this.rememberMe;
295
+ }
210
296
  /**
211
297
  * Set callback for when tokens are refreshed by backend
212
298
  */
@@ -219,18 +305,53 @@ var ApiClient = class {
219
305
  getOnTokenRefreshed() {
220
306
  return this.onTokenRefreshed;
221
307
  }
308
+ /**
309
+ * Set callback for when authentication fails irrecoverably
310
+ */
311
+ setOnAuthFailure(callback) {
312
+ this.onAuthFailure = callback;
313
+ }
222
314
  setGymId(gymId) {
223
315
  this.axiosInstance.defaults.headers.common["X-Gym-Id"] = gymId;
224
316
  }
225
317
  clearAuth() {
226
318
  delete this.config.apiKey;
227
319
  this.refreshToken = null;
320
+ this.rememberMe = null;
228
321
  delete this.axiosInstance.defaults.headers.common["Authorization"];
229
322
  delete this.axiosInstance.defaults.headers.common["X-Gym-Id"];
230
323
  }
231
324
  getBaseUrl() {
232
325
  return this.config.baseURL;
233
326
  }
327
+ /**
328
+ * Get config for creating scoped SDK instances
329
+ * Exposes minimal config needed without exposing internal structure
330
+ */
331
+ getConfigForScoped() {
332
+ return {
333
+ baseURL: this.config.baseURL,
334
+ apiKey: this.config.apiKey,
335
+ refreshToken: this.refreshToken,
336
+ headers: this.config.headers
337
+ };
338
+ }
339
+ /**
340
+ * Get axios instance defaults for scoped SDK
341
+ */
342
+ getAxiosDefaults() {
343
+ return { ...this.axiosInstance.defaults.headers.common };
344
+ }
345
+ /**
346
+ * Set common headers on axios instance (for scoped SDK setup)
347
+ */
348
+ setCommonHeaders(headers) {
349
+ Object.entries(headers).forEach(([key, value]) => {
350
+ if (value !== void 0) {
351
+ this.axiosInstance.defaults.headers.common[key] = value;
352
+ }
353
+ });
354
+ }
234
355
  };
235
356
 
236
357
  // src/utils/agent-fetch.ts
@@ -298,8 +419,12 @@ var AuthResource = class extends BaseResource {
298
419
  async registerOwner(data, options) {
299
420
  return this.client.post(`${this.basePath}/register/owner`, data, options);
300
421
  }
301
- async login(data, options) {
302
- return this.client.post(`${this.basePath}/login`, data, options);
422
+ async login(data, options, rememberMe) {
423
+ return this.client.post(
424
+ `${this.basePath}/login`,
425
+ { ...data, rememberMe },
426
+ options
427
+ );
303
428
  }
304
429
  async refreshToken(refreshToken, options) {
305
430
  return this.client.post(
@@ -366,6 +491,39 @@ var AuthResource = class extends BaseResource {
366
491
  options
367
492
  );
368
493
  }
494
+ /**
495
+ * Member login with PIN
496
+ * POST /auth/members/pin/login
497
+ */
498
+ async memberPinLogin(data, options) {
499
+ return this.client.post(
500
+ `${this.basePath}/members/pin/login`,
501
+ data,
502
+ options
503
+ );
504
+ }
505
+ /**
506
+ * Consume member invite and set initial PIN
507
+ * POST /auth/members/invite/consume
508
+ */
509
+ async consumeMemberInvite(data, options) {
510
+ return this.client.post(
511
+ `${this.basePath}/members/invite/consume`,
512
+ data,
513
+ options
514
+ );
515
+ }
516
+ /**
517
+ * Refresh member access token
518
+ * POST /auth/members/refresh
519
+ */
520
+ async refreshMemberToken(refreshToken, options) {
521
+ return this.client.post(
522
+ `${this.basePath}/members/refresh`,
523
+ { refresh_token: refreshToken },
524
+ options
525
+ );
526
+ }
369
527
  };
370
528
 
371
529
  // src/resources/organizations.ts
@@ -593,6 +751,16 @@ var ClientsResource = class extends BaseResource {
593
751
  async searchClientsForCheckIn(params, options) {
594
752
  return this.client.get(`${this.basePath}/search/check-in`, params, options);
595
753
  }
754
+ async searchGlobal(params, options) {
755
+ return this.client.post(`${this.basePath}/search-global`, params, options);
756
+ }
757
+ async importFromGym(params, options) {
758
+ return this.client.post(
759
+ `${this.basePath}/import-from-gym`,
760
+ params,
761
+ options
762
+ );
763
+ }
596
764
  };
597
765
 
598
766
  // src/resources/membership-plans.ts
@@ -640,9 +808,40 @@ var ContractsResource = class extends BaseResource {
640
808
  async getContract(id, options) {
641
809
  return this.client.get(`${this.basePath}/${id}`, void 0, options);
642
810
  }
811
+ async getContractInstallments(id, options) {
812
+ return this.client.get(
813
+ `${this.basePath}/${id}/installments`,
814
+ void 0,
815
+ options
816
+ );
817
+ }
818
+ async getContractPayments(id, options) {
819
+ return this.client.get(
820
+ `${this.basePath}/${id}/payments`,
821
+ void 0,
822
+ options
823
+ );
824
+ }
825
+ async registerContractPayment(id, data, options) {
826
+ return this.client.post(
827
+ `${this.basePath}/${id}/payments`,
828
+ data,
829
+ options
830
+ );
831
+ }
832
+ async sendInstallmentReminder(id, installmentId, options) {
833
+ return this.client.post(
834
+ `${this.basePath}/${id}/installments/${installmentId}/send-reminder`,
835
+ {},
836
+ options
837
+ );
838
+ }
643
839
  async getClientContracts(clientId, options) {
644
840
  return this.client.get(`${this.basePath}/client/${clientId}`, void 0, options);
645
841
  }
842
+ async getMyContracts(options) {
843
+ return this.client.get("auth/members/me/contracts", void 0, options);
844
+ }
646
845
  async renewContract(id, data, options) {
647
846
  return this.client.post(`${this.basePath}/${id}/renew`, data, options);
648
847
  }
@@ -717,6 +916,14 @@ var DashboardResource = class extends BaseResource {
717
916
  async getDebts(params) {
718
917
  return this.client.get("/dashboard/debts", params);
719
918
  }
919
+ /**
920
+ * Get total collections within date range
921
+ * @param params Optional date range parameters
922
+ * @returns Collections data for the specified period
923
+ */
924
+ async getCollections(params) {
925
+ return this.client.get("/dashboard/collections", params);
926
+ }
720
927
  /**
721
928
  * Get check-ins count within date range
722
929
  * @param params Optional date range parameters
@@ -822,6 +1029,21 @@ var CheckInsResource = class extends BaseResource {
822
1029
  options
823
1030
  );
824
1031
  }
1032
+ /**
1033
+ * Creates a check-in for an external client (from another gym in the same organization).
1034
+ *
1035
+ * **Permissions Required:**
1036
+ * - Gym owners with full gym access
1037
+ * - Active collaborators with CHECKINS_CREATE permission
1038
+ *
1039
+ * @param data - The external check-in data including document value
1040
+ * @param options - Optional request configuration
1041
+ * @returns The created check-in record with external client details
1042
+ * @throws {ValidationError} When client is not found or contract doesn't allow access
1043
+ */
1044
+ async createExternal(data, options) {
1045
+ return this.client.post(`${this.basePath}/external`, data, options);
1046
+ }
825
1047
  };
826
1048
 
827
1049
  // src/resources/invitations.ts
@@ -2373,8 +2595,68 @@ var PromoCodesResource = class extends BaseResource {
2373
2595
  }
2374
2596
  };
2375
2597
 
2598
+ // src/resources/members.ts
2599
+ var MembersResource = class extends BaseResource {
2600
+ /**
2601
+ * Create and send member invite
2602
+ * POST /admin/members/clients/:id/invites
2603
+ */
2604
+ async createInvite(clientId, data, options) {
2605
+ return this.client.post(
2606
+ `admin/members/clients/${clientId}/invites`,
2607
+ data,
2608
+ options
2609
+ );
2610
+ }
2611
+ /**
2612
+ * Validate member invite token
2613
+ * GET /members/invites/validate/:token
2614
+ */
2615
+ async validateInvite(token, options) {
2616
+ return this.client.get(
2617
+ `members/invites/validate/${token}`,
2618
+ void 0,
2619
+ options
2620
+ );
2621
+ }
2622
+ /**
2623
+ * Generate QR token for member check-ins
2624
+ * GET /admin/members/check-in-qr
2625
+ */
2626
+ async generateQrToken(options) {
2627
+ return this.client.get("admin/members/check-in-qr", void 0, options);
2628
+ }
2629
+ /**
2630
+ * Self check-in with QR token
2631
+ * POST /members/checkins
2632
+ */
2633
+ async checkIn(data, options) {
2634
+ return this.client.post("members/checkins", data, options);
2635
+ }
2636
+ };
2637
+
2638
+ // src/resources/receivables.ts
2639
+ var ReceivablesResource = class extends BaseResource {
2640
+ /**
2641
+ * Get paginated list of pending contract installments with filtering, sorting, and organization scope support.
2642
+ * @param params Optional query parameters for filtering, pagination, and sorting
2643
+ * @returns Paginated list of installment receivables with summary
2644
+ */
2645
+ async getInstallmentReceivables(params) {
2646
+ return this.client.get("/receivables/installments", params);
2647
+ }
2648
+ /**
2649
+ * Get paginated list of unpaid sales with filtering, sorting, and organization scope support.
2650
+ * @param params Optional query parameters for filtering, pagination, and sorting
2651
+ * @returns Paginated list of sale receivables with summary
2652
+ */
2653
+ async getSaleReceivables(params) {
2654
+ return this.client.get("/receivables/sales", params);
2655
+ }
2656
+ };
2657
+
2376
2658
  // src/sdk.ts
2377
- var GymSpaceSdk = class {
2659
+ var GymSpaceSdk = class _GymSpaceSdk {
2378
2660
  constructor(config) {
2379
2661
  this.client = new ApiClient(config);
2380
2662
  this.auth = new AuthResource(this.client);
@@ -2416,6 +2698,8 @@ var GymSpaceSdk = class {
2416
2698
  this.credits = new CreditsResource(this.client);
2417
2699
  this.pricingPackages = new PricingPackagesResource(this.client);
2418
2700
  this.promoCodes = new PromoCodesResource(this.client);
2701
+ this.members = new MembersResource(this.client);
2702
+ this.receivables = new ReceivablesResource(this.client);
2419
2703
  }
2420
2704
  /**
2421
2705
  * Set the authentication token
@@ -2474,7 +2758,44 @@ var GymSpaceSdk = class {
2474
2758
  getClient() {
2475
2759
  return this.client;
2476
2760
  }
2761
+ /**
2762
+ * Create a scoped SDK instance that sends X-Gym-Id and X-Gym-Context-Mode: scoped
2763
+ * for all requests WITHOUT modifying the global gym context.
2764
+ *
2765
+ * Usage:
2766
+ * const scopedSdk = sdk.withGymId('gym-123');
2767
+ * const sales = await scopedSdk.sales.searchSales({ ... });
2768
+ */
2769
+ withGymId(gymId) {
2770
+ const config = this.client.getConfigForScoped();
2771
+ const defaults = this.client.getAxiosDefaults();
2772
+ const scopedSdk = new _GymSpaceSdk({
2773
+ baseURL: config.baseURL,
2774
+ apiKey: config.apiKey,
2775
+ refreshToken: config.refreshToken
2776
+ });
2777
+ if (defaults && typeof defaults === "object") {
2778
+ const headers = {};
2779
+ Object.entries(defaults).forEach(([key, value]) => {
2780
+ if (typeof value === "string") {
2781
+ headers[key] = value;
2782
+ }
2783
+ });
2784
+ scopedSdk.client.setCommonHeaders(headers);
2785
+ }
2786
+ const originalRequest = scopedSdk.client.request.bind(scopedSdk.client);
2787
+ scopedSdk.client.request = (method, path, data, options) => {
2788
+ return originalRequest(method, path, data, {
2789
+ ...options,
2790
+ gymId,
2791
+ gymContextMode: "scoped"
2792
+ });
2793
+ };
2794
+ return scopedSdk;
2795
+ }
2477
2796
  };
2797
+
2798
+ // ../shared/src/types/whatsapp-templates.types.ts
2478
2799
  var TemplateCode = {
2479
2800
  WELCOME: "WELCOME",
2480
2801
  MEMBERSHIP_PURCHASE: "MEMBERSHIP_PURCHASE",
@@ -2484,12 +2805,16 @@ var TemplateCode = {
2484
2805
  BIRTHDAY: "BIRTHDAY",
2485
2806
  PAYMENT_RECEIPT: "PAYMENT_RECEIPT",
2486
2807
  SHARE_CATALOG: "SHARE_CATALOG",
2487
- SALE_PAYMENT_REMINDER: "SALE_PAYMENT_REMINDER"
2808
+ SALE_PAYMENT_REMINDER: "SALE_PAYMENT_REMINDER",
2809
+ MEMBER_INVITE: "MEMBER_INVITE",
2810
+ CONTRACT_INSTALLMENT_REMINDER: "CONTRACT_INSTALLMENT_REMINDER"
2488
2811
  };
2489
2812
  var TemplateType = {
2490
2813
  STATIC: "STATIC",
2491
2814
  PROMPT: "PROMPT"
2492
2815
  };
2816
+
2817
+ // ../shared/src/constants/template-codes.constants.ts
2493
2818
  var TEMPLATE_CODES = {
2494
2819
  WELCOME: TemplateCode.WELCOME,
2495
2820
  MEMBERSHIP_PURCHASE: TemplateCode.MEMBERSHIP_PURCHASE,
@@ -2499,7 +2824,9 @@ var TEMPLATE_CODES = {
2499
2824
  BIRTHDAY: TemplateCode.BIRTHDAY,
2500
2825
  PAYMENT_RECEIPT: TemplateCode.PAYMENT_RECEIPT,
2501
2826
  SHARE_CATALOG: TemplateCode.SHARE_CATALOG,
2502
- SALE_PAYMENT_REMINDER: TemplateCode.SALE_PAYMENT_REMINDER
2827
+ SALE_PAYMENT_REMINDER: TemplateCode.SALE_PAYMENT_REMINDER,
2828
+ MEMBER_INVITE: TemplateCode.MEMBER_INVITE,
2829
+ CONTRACT_INSTALLMENT_REMINDER: TemplateCode.CONTRACT_INSTALLMENT_REMINDER
2503
2830
  };
2504
2831
  var WHATSAPP_TEMPLATE_EVENTS = {
2505
2832
  SEND_TEMPLATE: "whatsapp/template.send",
@@ -2656,8 +2983,48 @@ var TEMPLATE_METADATA = {
2656
2983
  ],
2657
2984
  currency: "S/ "
2658
2985
  }
2986
+ },
2987
+ [TemplateCode.MEMBER_INVITE]: {
2988
+ code: TemplateCode.MEMBER_INVITE,
2989
+ title: "Invitaci\xF3n Portal de Miembros",
2990
+ description: "Invitaci\xF3n para que el socio se registre en el portal",
2991
+ icon: "UserPlus",
2992
+ variables: ["clientName", "gymName", "inviteCode", "inviteUrl", "expiryDate"],
2993
+ exampleValues: {
2994
+ clientName: "Juan P\xE9rez",
2995
+ gymName: "GymSpace",
2996
+ inviteCode: "123456",
2997
+ inviteUrl: "https://gymspace.app/members/invite/abc-123",
2998
+ expiryDate: "20/02/2024"
2999
+ }
3000
+ },
3001
+ [TemplateCode.CONTRACT_INSTALLMENT_REMINDER]: {
3002
+ code: TemplateCode.CONTRACT_INSTALLMENT_REMINDER,
3003
+ title: "Recordatorio de Cuota de Contrato",
3004
+ description: "Recordatorio de pago para cuotas de membres\xEDa",
3005
+ icon: "DollarSign",
3006
+ variables: [
3007
+ "clientName",
3008
+ "planName",
3009
+ "contractNumber",
3010
+ "installmentNumber",
3011
+ "dueDate",
3012
+ "amount",
3013
+ "outstandingAmount"
3014
+ ],
3015
+ exampleValues: {
3016
+ clientName: "Mar\xEDa L\xF3pez",
3017
+ planName: "Premium",
3018
+ contractNumber: "#202512340001",
3019
+ installmentNumber: "2",
3020
+ dueDate: "25/02/2024",
3021
+ amount: "S/ 150.00",
3022
+ outstandingAmount: "S/ 300.00"
3023
+ }
2659
3024
  }
2660
3025
  };
3026
+
3027
+ // ../shared/src/constants/bulk-message-variables.ts
2661
3028
  var BULK_MESSAGE_VARIABLES = [
2662
3029
  // Variables de Cliente
2663
3030
  {
@@ -2687,6 +3054,33 @@ var BULK_MESSAGE_VARIABLES = [
2687
3054
  required: false,
2688
3055
  formatter: "text"
2689
3056
  },
3057
+ {
3058
+ name: "registrationDate",
3059
+ placeholder: "{{registrationDate}}",
3060
+ description: "Fecha de registro del cliente",
3061
+ example: "15/10/2024",
3062
+ category: "client",
3063
+ required: false,
3064
+ formatter: "date"
3065
+ },
3066
+ {
3067
+ name: "birthDate",
3068
+ placeholder: "{{birthDate}}",
3069
+ description: "Fecha de nacimiento del cliente",
3070
+ example: "15/10/1990",
3071
+ category: "client",
3072
+ required: false,
3073
+ formatter: "date"
3074
+ },
3075
+ {
3076
+ name: "age",
3077
+ placeholder: "{{age}}",
3078
+ description: "Edad del cliente",
3079
+ example: "34",
3080
+ category: "client",
3081
+ required: false,
3082
+ formatter: "number"
3083
+ },
2690
3084
  // Variables de Gimnasio
2691
3085
  {
2692
3086
  name: "gymName",
@@ -2761,6 +3155,60 @@ var BULK_MESSAGE_VARIABLES = [
2761
3155
  required: false,
2762
3156
  formatter: "currency"
2763
3157
  },
3158
+ {
3159
+ name: "startDate",
3160
+ placeholder: "{{startDate}}",
3161
+ description: "Fecha de inicio de membres\xEDa",
3162
+ example: "15/10/2024",
3163
+ category: "membership",
3164
+ required: false,
3165
+ formatter: "date"
3166
+ },
3167
+ {
3168
+ name: "endDate",
3169
+ placeholder: "{{endDate}}",
3170
+ description: "Fecha de fin de membres\xEDa",
3171
+ example: "15/11/2024",
3172
+ category: "membership",
3173
+ required: false,
3174
+ formatter: "date"
3175
+ },
3176
+ {
3177
+ name: "newEndDate",
3178
+ placeholder: "{{newEndDate}}",
3179
+ description: "Nueva fecha de vencimiento por renovaci\xF3n",
3180
+ example: "15/12/2024",
3181
+ category: "membership",
3182
+ required: false,
3183
+ formatter: "date"
3184
+ },
3185
+ {
3186
+ name: "paymentFrequency",
3187
+ placeholder: "{{paymentFrequency}}",
3188
+ description: "Frecuencia de pago",
3189
+ example: "Mensual",
3190
+ category: "membership",
3191
+ required: false,
3192
+ formatter: "text"
3193
+ },
3194
+ {
3195
+ name: "daysRemaining",
3196
+ placeholder: "{{daysRemaining}}",
3197
+ description: "D\xEDas restantes",
3198
+ example: "15",
3199
+ category: "membership",
3200
+ required: false,
3201
+ formatter: "number"
3202
+ },
3203
+ {
3204
+ name: "dueDate",
3205
+ placeholder: "{{dueDate}}",
3206
+ description: "Fecha de vencimiento de pago",
3207
+ example: "15/10/2024",
3208
+ category: "membership",
3209
+ required: false,
3210
+ formatter: "date"
3211
+ },
2764
3212
  // Variables de Fecha/Hora
2765
3213
  {
2766
3214
  name: "date",
@@ -2915,6 +3363,8 @@ var BULK_MESSAGE_VARIABLE_CATEGORIES = {
2915
3363
  activity: "Actividad",
2916
3364
  datetime: "Fecha/Hora"
2917
3365
  };
3366
+
3367
+ // ../shared/src/constants.ts
2918
3368
  var PERMISSIONS = {
2919
3369
  // Organizations
2920
3370
  ORGANIZATIONS_CREATE: "ORGANIZATIONS_CREATE",
@@ -2940,8 +3390,14 @@ var PERMISSIONS = {
2940
3390
  CONTRACTS_CREATE: "CONTRACTS_CREATE",
2941
3391
  CONTRACTS_READ: "CONTRACTS_READ",
2942
3392
  CONTRACTS_UPDATE: "CONTRACTS_UPDATE",
3393
+ CONTRACTS_DELETE: "CONTRACTS_DELETE",
2943
3394
  CONTRACTS_APPROVE: "CONTRACTS_APPROVE",
2944
3395
  CONTRACTS_CANCEL: "CONTRACTS_CANCEL",
3396
+ // Membership Plans
3397
+ MEMBERSHIP_PLANS_CREATE: "MEMBERSHIP_PLANS_CREATE",
3398
+ MEMBERSHIP_PLANS_READ: "MEMBERSHIP_PLANS_READ",
3399
+ MEMBERSHIP_PLANS_UPDATE: "MEMBERSHIP_PLANS_UPDATE",
3400
+ MEMBERSHIP_PLANS_DELETE: "MEMBERSHIP_PLANS_DELETE",
2945
3401
  // Check-ins
2946
3402
  CHECKINS_CREATE: "CHECKINS_CREATE",
2947
3403
  CHECKINS_READ: "CHECKINS_READ",
@@ -3019,6 +3475,12 @@ var PERMISSIONS = {
3019
3475
  CATALOG_READ: "CATALOG_READ",
3020
3476
  CATALOG_UPDATE: "CATALOG_UPDATE",
3021
3477
  CATALOG_MANAGE: "CATALOG_MANAGE",
3478
+ // Credits
3479
+ CREDITS_READ: "CREDITS_READ",
3480
+ CREDITS_MANAGE: "CREDITS_MANAGE",
3481
+ CREDITS_ADJUST: "CREDITS_ADJUST",
3482
+ // Members
3483
+ MEMBERS_PORTAL_ACCESS: "MEMBERS_PORTAL_ACCESS",
3022
3484
  // Special permissions
3023
3485
  SUPER_ADMIN: "SUPER_ADMIN",
3024
3486
  OWNER: "OWNER",
@@ -3106,6 +3568,8 @@ var HEADERS = {
3106
3568
  GYM_ID: "X-Gym-Id",
3107
3569
  REQUEST_ID: "X-Request-Id"
3108
3570
  };
3571
+
3572
+ // ../shared/src/enums.ts
3109
3573
  var UserType = /* @__PURE__ */ ((UserType2) => {
3110
3574
  UserType2["OWNER"] = "owner";
3111
3575
  UserType2["COLLABORATOR"] = "collaborator";
@@ -3184,6 +3648,14 @@ var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
3184
3648
  PaymentFrequency2["ANNUAL"] = "annual";
3185
3649
  return PaymentFrequency2;
3186
3650
  })(PaymentFrequency || {});
3651
+ var ContractInstallmentStatus = /* @__PURE__ */ ((ContractInstallmentStatus2) => {
3652
+ ContractInstallmentStatus2["PENDING"] = "pending";
3653
+ ContractInstallmentStatus2["PARTIALLY_PAID"] = "partially_paid";
3654
+ ContractInstallmentStatus2["PAID"] = "paid";
3655
+ ContractInstallmentStatus2["OVERDUE"] = "overdue";
3656
+ ContractInstallmentStatus2["CANCELLED"] = "cancelled";
3657
+ return ContractInstallmentStatus2;
3658
+ })(ContractInstallmentStatus || {});
3187
3659
  var AssetStatus = /* @__PURE__ */ ((AssetStatus2) => {
3188
3660
  AssetStatus2["ACTIVE"] = "active";
3189
3661
  AssetStatus2["DELETED"] = "deleted";
@@ -3214,15 +3686,26 @@ var MessageStatus = /* @__PURE__ */ ((MessageStatus2) => {
3214
3686
  MessageStatus2["CANCELLED"] = "cancelled";
3215
3687
  return MessageStatus2;
3216
3688
  })(MessageStatus || {});
3689
+ var FeatureType = /* @__PURE__ */ ((FeatureType2) => {
3690
+ FeatureType2["AI_GENERATION"] = "ai_generation";
3691
+ FeatureType2["BULK_WHATSAPP"] = "bulk_whatsapp";
3692
+ return FeatureType2;
3693
+ })(FeatureType || {});
3694
+
3695
+ // ../shared/src/events/whatsapp.events.ts
3217
3696
  var WHATSAPP_EVENTS = {
3218
3697
  MESSAGE_SEND: "whatsapp/message.send",
3219
3698
  MESSAGE_RETRY: "whatsapp/message.retry",
3220
3699
  MESSAGE_RECEIVED: "whatsapp/message.received",
3221
3700
  CONNECTION_UPDATE: "whatsapp/connection.update"
3222
3701
  };
3702
+
3703
+ // ../shared/src/events/bulk-messaging.events.ts
3223
3704
  var BULK_MESSAGING_EVENTS = {
3224
3705
  SEND_BULK_MESSAGES: "whatsapp/bulk-messages.send"
3225
3706
  };
3707
+
3708
+ // ../shared/src/events/activity.events.ts
3226
3709
  var ACTIVITY_EVENTS = {
3227
3710
  SEND_ACTIVITY_NOTIFICATION: "activity/notification.send"
3228
3711
  };
@@ -3266,6 +3749,8 @@ var activityNotificationGenerationRequestSchema = z.object({
3266
3749
  var activityNotificationSchema = z.object({
3267
3750
  message: z.string().describe("Generated notification message with activity variables")
3268
3751
  });
3752
+
3753
+ // ../shared/src/utils/roleHelpers.ts
3269
3754
  var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
3270
3755
  RoleNames2["ADMIN"] = "Admin";
3271
3756
  RoleNames2["ENCARGADO"] = "Encargado";
@@ -3274,24 +3759,24 @@ var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
3274
3759
  })(RoleNames || {});
3275
3760
  var ROLE_NAMES = RoleNames;
3276
3761
  function isAdminRole(roleName) {
3277
- return roleName === "Admin";
3762
+ return roleName === "Admin" /* ADMIN */;
3278
3763
  }
3279
3764
  function isEncargadoRole(roleName) {
3280
- return roleName === "Encargado";
3765
+ return roleName === "Encargado" /* ENCARGADO */;
3281
3766
  }
3282
3767
  function canAccessFeature(userRole, allowedRoles) {
3283
3768
  if (!userRole) return false;
3284
- if (userRole === "OWNER") return true;
3769
+ if (userRole === "OWNER" /* OWNER */) return true;
3285
3770
  return allowedRoles.includes(userRole);
3286
3771
  }
3287
3772
  function getRoleDisplayName(roleName) {
3288
3773
  if (!roleName) return "";
3289
3774
  switch (roleName) {
3290
- case "Admin":
3775
+ case "Admin" /* ADMIN */:
3291
3776
  return "Administrador";
3292
- case "Encargado":
3777
+ case "Encargado" /* ENCARGADO */:
3293
3778
  return "Encargado";
3294
- case "OWNER":
3779
+ case "OWNER" /* OWNER */:
3295
3780
  return "Propietario";
3296
3781
  default:
3297
3782
  return roleName;
@@ -3300,11 +3785,11 @@ function getRoleDisplayName(roleName) {
3300
3785
  function getRoleDescription(roleName) {
3301
3786
  if (!roleName) return "";
3302
3787
  switch (roleName) {
3303
- case "Admin":
3788
+ case "Admin" /* ADMIN */:
3304
3789
  return "Acceso completo a todas las funcionalidades del gimnasio, gesti\xF3n de colaboradores y configuraci\xF3n";
3305
- case "Encargado":
3790
+ case "Encargado" /* ENCARGADO */:
3306
3791
  return "Gesti\xF3n diaria del gimnasio: clientes, contratos, check-ins y reportes";
3307
- case "OWNER":
3792
+ case "OWNER" /* OWNER */:
3308
3793
  return "Acceso completo a todas las funcionalidades, organizaci\xF3n y suscripci\xF3n";
3309
3794
  default:
3310
3795
  return "";
@@ -3313,7 +3798,7 @@ function getRoleDescription(roleName) {
3313
3798
  function getRoleCapabilities(roleName) {
3314
3799
  if (!roleName) return [];
3315
3800
  switch (roleName) {
3316
- case "OWNER":
3801
+ case "OWNER" /* OWNER */:
3317
3802
  return [
3318
3803
  "Acceso completo a todas las funcionalidades",
3319
3804
  "Gesti\xF3n de organizaci\xF3n",
@@ -3329,7 +3814,7 @@ function getRoleCapabilities(roleName) {
3329
3814
  "Gesti\xF3n de inventario",
3330
3815
  "Check-ins"
3331
3816
  ];
3332
- case "Admin":
3817
+ case "Admin" /* ADMIN */:
3333
3818
  return [
3334
3819
  "Gesti\xF3n completa de clientes",
3335
3820
  "Gesti\xF3n completa de contratos",
@@ -3342,7 +3827,7 @@ function getRoleCapabilities(roleName) {
3342
3827
  "Gesti\xF3n de inventario",
3343
3828
  "Check-ins"
3344
3829
  ];
3345
- case "Encargado":
3830
+ case "Encargado" /* ENCARGADO */:
3346
3831
  return [
3347
3832
  "Gesti\xF3n de clientes (ver, crear, editar)",
3348
3833
  "Creaci\xF3n y renovaci\xF3n de contratos",
@@ -3355,6 +3840,16 @@ function getRoleCapabilities(roleName) {
3355
3840
  return [];
3356
3841
  }
3357
3842
  }
3843
+
3844
+ // ../shared/src/types/bulk-message.types.ts
3845
+ var MAX_MESSAGES_PER_CAMPAIGN = 10;
3846
+ var MAX_IMAGES_PER_CAMPAIGN = 5;
3847
+ var MAX_CAPTION_LENGTH = 1024;
3848
+ var INTER_MESSAGE_DELAY_MS = 500;
3849
+ var SUPPORTED_MESSAGE_TYPES = ["text", "image"];
3850
+ var ALLOWED_IMAGE_MIMES = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
3851
+
3852
+ // ../shared/src/utils/phone.utils.ts
3358
3853
  function normalizePhoneForEvolution(phoneNumber) {
3359
3854
  if (!phoneNumber) {
3360
3855
  throw new Error("Phone number is required");
@@ -3420,13 +3915,6 @@ var LeadGender = /* @__PURE__ */ ((LeadGender2) => {
3420
3915
  return LeadGender2;
3421
3916
  })(LeadGender || {});
3422
3917
 
3423
- // src/models/credits.ts
3424
- var FeatureType = /* @__PURE__ */ ((FeatureType2) => {
3425
- FeatureType2["AI_GENERATION"] = "ai_generation";
3426
- FeatureType2["BULK_WHATSAPP"] = "bulk_whatsapp";
3427
- return FeatureType2;
3428
- })(FeatureType || {});
3429
-
3430
3918
  // src/models/promo-codes.ts
3431
3919
  var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
3432
3920
  DiscountType2["PERCENTAGE"] = "PERCENTAGE";
@@ -3434,6 +3922,6 @@ var DiscountType = /* @__PURE__ */ ((DiscountType2) => {
3434
3922
  return DiscountType2;
3435
3923
  })(DiscountType || {});
3436
3924
 
3437
- export { ACTIVITY_EVENTS, ACTIVITY_MESSAGE_VARIABLES, ActivitiesResource, AdminCatalogResource, AdminSubscriptionManagementResource, ApiClient, AssetCategory, AssetStatus, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, BULK_MESSAGE_VARIABLES, BULK_MESSAGE_VARIABLE_CATEGORIES, BULK_MESSAGING_EVENTS, BulkMessagingResource, CACHE_TTL, CancellationReason, CheckInsResource, ClientStatus, ClientsResource, CollaboratorStatus, CollaboratorsResource, CommissionCalculationsResource, CommissionChangeType, CommissionConfigResource, CommissionEntityType, CommissionPromotionsResource, CommissionReportsResource, CommissionRuleType, CommissionRulesResource, CommissionStatus, ContractAssetType, ContractStatus, ContractsResource, CreditsResource, DATE_FORMATS, DashboardResource, DiscountType, FILE_LIMITS, FeatureType, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, InvitationStatus, InvitationsResource, LeadGender, MembershipPlansResource, MessageStatus, MessagesResource, NetworkError, NotFoundError, OnboardingCacheStatus, OnboardingResource, OnboardingStep, OrganizationsResource, PAGINATION_DEFAULTS, PERMISSIONS, PaymentFrequency, PaymentMethodsResource, PlanStatus, PlanType, PricingPackagesResource, ProductsResource, PromoCodesResource, PublicCatalogResource, ROLE_NAMES, ROLE_PERMISSIONS, RoleNames, RolesResource, SalesResource, SubscriptionPlansResource, SubscriptionStatus, SubscriptionsResource, SuppliersResource, SuspensionType, TEMPLATE_CODES, TEMPLATE_METADATA, TagsResource, TemplateCode, TemplateType, UserType, UsersResource, VARIABLE_CONTEXT_MAP, ValidationError, WHATSAPP_EVENTS, WHATSAPP_TEMPLATE_EVENTS, WhatsAppResource, WhatsAppTemplatesResource, activityNotificationGenerationRequestSchema, activityNotificationSchema, aiGeneratedTemplateSchema, bulkMessageGenerationRequestSchema, bulkMessageSchema, canAccessFeature, getRoleCapabilities, getRoleDescription, getRoleDisplayName, getVariablesByContext, isAdminRole, isEncargadoRole, isValidPeruvianPhone, normalizePhoneForEvolution, templateGenerationRequestSchema, validateVariablesInContext };
3925
+ export { ACTIVITY_EVENTS, ACTIVITY_MESSAGE_VARIABLES, ALLOWED_IMAGE_MIMES, ActivitiesResource, AdminCatalogResource, AdminSubscriptionManagementResource, ApiClient, AssetCategory, AssetStatus, AssetsResource, AuthResource, AuthenticationError, AuthorizationError, BULK_MESSAGE_VARIABLES, BULK_MESSAGE_VARIABLE_CATEGORIES, BULK_MESSAGING_EVENTS, BulkMessagingResource, CACHE_TTL, CancellationReason, CheckInsResource, ClientStatus, ClientsResource, CollaboratorStatus, CollaboratorsResource, CommissionCalculationsResource, CommissionChangeType, CommissionConfigResource, CommissionEntityType, CommissionPromotionsResource, CommissionReportsResource, CommissionRuleType, CommissionRulesResource, CommissionStatus, ContractAssetType, ContractInstallmentStatus, ContractStatus, ContractsResource, CreditsResource, DATE_FORMATS, DashboardResource, DiscountType, FILE_LIMITS, FeatureType, FilesResource, GymSpaceError, GymSpaceSdk, GymsResource, HEADERS, HealthResource, INTER_MESSAGE_DELAY_MS, InvitationStatus, InvitationsResource, LeadGender, MAX_CAPTION_LENGTH, MAX_IMAGES_PER_CAMPAIGN, MAX_MESSAGES_PER_CAMPAIGN, MembersResource, MembershipPlansResource, MessageStatus, MessagesResource, NetworkError, NotFoundError, OnboardingCacheStatus, OnboardingResource, OnboardingStep, OrganizationsResource, PAGINATION_DEFAULTS, PERMISSIONS, PaymentFrequency, PaymentMethodsResource, PlanStatus, PlanType, PricingPackagesResource, ProductsResource, PromoCodesResource, PublicCatalogResource, ROLE_NAMES, ROLE_PERMISSIONS, ReceivablesResource, RoleNames, RolesResource, SUPPORTED_MESSAGE_TYPES, SalesResource, SubscriptionPlansResource, SubscriptionStatus, SubscriptionsResource, SuppliersResource, SuspensionType, TEMPLATE_CODES, TEMPLATE_METADATA, TagsResource, TemplateCode, TemplateType, UserType, UsersResource, VARIABLE_CONTEXT_MAP, ValidationError, WHATSAPP_EVENTS, WHATSAPP_TEMPLATE_EVENTS, WhatsAppResource, WhatsAppTemplatesResource, activityNotificationGenerationRequestSchema, activityNotificationSchema, aiGeneratedTemplateSchema, bulkMessageGenerationRequestSchema, bulkMessageSchema, canAccessFeature, getRoleCapabilities, getRoleDescription, getRoleDisplayName, getVariablesByContext, isAdminRole, isEncargadoRole, isValidPeruvianPhone, normalizePhoneForEvolution, templateGenerationRequestSchema, validateVariablesInContext };
3438
3926
  //# sourceMappingURL=index.mjs.map
3439
3927
  //# sourceMappingURL=index.mjs.map