@gymspace/sdk 1.3.4 → 1.4.1

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
@@ -2187,104 +2187,13 @@ var TemplateCode = {
2187
2187
  MEMBERSHIP_EXPIRING: "MEMBERSHIP_EXPIRING",
2188
2188
  PAYMENT_REMINDER: "PAYMENT_REMINDER",
2189
2189
  BIRTHDAY: "BIRTHDAY",
2190
- PAYMENT_RECEIPT: "PAYMENT_RECEIPT"
2190
+ PAYMENT_RECEIPT: "PAYMENT_RECEIPT",
2191
+ SHARE_CATALOG: "SHARE_CATALOG"
2191
2192
  };
2192
2193
  var TemplateType = {
2193
2194
  STATIC: "STATIC",
2194
2195
  PROMPT: "PROMPT"
2195
2196
  };
2196
- var UserType = /* @__PURE__ */ ((UserType2) => {
2197
- UserType2["OWNER"] = "owner";
2198
- UserType2["COLLABORATOR"] = "collaborator";
2199
- return UserType2;
2200
- })(UserType || {});
2201
- var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
2202
- SubscriptionStatus2["ACTIVE"] = "active";
2203
- SubscriptionStatus2["INACTIVE"] = "inactive";
2204
- SubscriptionStatus2["EXPIRED"] = "expired";
2205
- SubscriptionStatus2["PAUSED"] = "paused";
2206
- SubscriptionStatus2["PENDING_UPGRADE"] = "pending_upgrade";
2207
- return SubscriptionStatus2;
2208
- })(SubscriptionStatus || {});
2209
- var CollaboratorStatus = /* @__PURE__ */ ((CollaboratorStatus2) => {
2210
- CollaboratorStatus2["PENDING"] = "pending";
2211
- CollaboratorStatus2["ACTIVE"] = "active";
2212
- CollaboratorStatus2["INACTIVE"] = "inactive";
2213
- return CollaboratorStatus2;
2214
- })(CollaboratorStatus || {});
2215
- var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
2216
- InvitationStatus2["PENDING"] = "pending";
2217
- InvitationStatus2["ACCEPTED"] = "accepted";
2218
- InvitationStatus2["CANCELLED"] = "cancelled";
2219
- InvitationStatus2["EXPIRED"] = "expired";
2220
- return InvitationStatus2;
2221
- })(InvitationStatus || {});
2222
- var ClientStatus = /* @__PURE__ */ ((ClientStatus2) => {
2223
- ClientStatus2["ACTIVE"] = "active";
2224
- ClientStatus2["INACTIVE"] = "inactive";
2225
- return ClientStatus2;
2226
- })(ClientStatus || {});
2227
- var PlanStatus = /* @__PURE__ */ ((PlanStatus2) => {
2228
- PlanStatus2["ACTIVE"] = "active";
2229
- PlanStatus2["INACTIVE"] = "inactive";
2230
- PlanStatus2["ARCHIVED"] = "archived";
2231
- return PlanStatus2;
2232
- })(PlanStatus || {});
2233
- var ContractStatus = /* @__PURE__ */ ((ContractStatus2) => {
2234
- ContractStatus2["PENDING"] = "pending";
2235
- ContractStatus2["ACTIVE"] = "active";
2236
- ContractStatus2["EXPIRING_SOON"] = "expiring_soon";
2237
- ContractStatus2["EXPIRED"] = "expired";
2238
- ContractStatus2["CANCELLED"] = "cancelled";
2239
- ContractStatus2["FOR_RENEW"] = "for_renew";
2240
- ContractStatus2["SUSPENDED"] = "suspended";
2241
- ContractStatus2["GRACE_PERIOD"] = "grace_period";
2242
- ContractStatus2["TERMINATED"] = "terminated";
2243
- return ContractStatus2;
2244
- })(ContractStatus || {});
2245
- var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
2246
- CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
2247
- CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
2248
- CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
2249
- CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
2250
- CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
2251
- CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
2252
- CancellationReason2["OTHER"] = "OTHER";
2253
- return CancellationReason2;
2254
- })(CancellationReason || {});
2255
- var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
2256
- SuspensionType2["VACATION"] = "vacation";
2257
- SuspensionType2["MEDICAL"] = "medical";
2258
- SuspensionType2["FINANCIAL"] = "financial";
2259
- SuspensionType2["OTHER"] = "other";
2260
- return SuspensionType2;
2261
- })(SuspensionType || {});
2262
- var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
2263
- PaymentFrequency2["MONTHLY"] = "monthly";
2264
- PaymentFrequency2["QUARTERLY"] = "quarterly";
2265
- PaymentFrequency2["ANNUAL"] = "annual";
2266
- return PaymentFrequency2;
2267
- })(PaymentFrequency || {});
2268
- var AssetStatus = /* @__PURE__ */ ((AssetStatus2) => {
2269
- AssetStatus2["ACTIVE"] = "active";
2270
- AssetStatus2["DELETED"] = "deleted";
2271
- return AssetStatus2;
2272
- })(AssetStatus || {});
2273
- var AssetCategory = /* @__PURE__ */ ((AssetCategory2) => {
2274
- AssetCategory2["MEDICAL_DOCUMENT"] = "medical_document";
2275
- AssetCategory2["IDENTIFICATION"] = "identification";
2276
- AssetCategory2["INSURANCE"] = "insurance";
2277
- AssetCategory2["CONTRACT_COPY"] = "contract_copy";
2278
- AssetCategory2["OTHER"] = "other";
2279
- return AssetCategory2;
2280
- })(AssetCategory || {});
2281
- var ContractAssetType = /* @__PURE__ */ ((ContractAssetType2) => {
2282
- ContractAssetType2["PAYMENT_RECEIPT"] = "payment_receipt";
2283
- ContractAssetType2["CONTRACT_DOCUMENT"] = "contract_document";
2284
- ContractAssetType2["IDENTIFICATION"] = "identification";
2285
- ContractAssetType2["OTHER"] = "other";
2286
- return ContractAssetType2;
2287
- })(ContractAssetType || {});
2288
2197
  var TEMPLATE_CODES = {
2289
2198
  WELCOME: TemplateCode.WELCOME,
2290
2199
  MEMBERSHIP_PURCHASE: TemplateCode.MEMBERSHIP_PURCHASE,
@@ -2292,7 +2201,8 @@ var TEMPLATE_CODES = {
2292
2201
  MEMBERSHIP_EXPIRING: TemplateCode.MEMBERSHIP_EXPIRING,
2293
2202
  PAYMENT_REMINDER: TemplateCode.PAYMENT_REMINDER,
2294
2203
  BIRTHDAY: TemplateCode.BIRTHDAY,
2295
- PAYMENT_RECEIPT: TemplateCode.PAYMENT_RECEIPT
2204
+ PAYMENT_RECEIPT: TemplateCode.PAYMENT_RECEIPT,
2205
+ SHARE_CATALOG: TemplateCode.SHARE_CATALOG
2296
2206
  };
2297
2207
  var WHATSAPP_TEMPLATE_EVENTS = {
2298
2208
  SEND_TEMPLATE: "whatsapp/template.send",
@@ -2401,6 +2311,18 @@ var TEMPLATE_METADATA = {
2401
2311
  amount: "Q150.00",
2402
2312
  paymentMethod: "Efectivo"
2403
2313
  }
2314
+ },
2315
+ [TemplateCode.SHARE_CATALOG]: {
2316
+ code: TemplateCode.SHARE_CATALOG,
2317
+ title: "Compartir Cat\xE1logo",
2318
+ description: "Mensaje para compartir cat\xE1logo de membres\xEDas",
2319
+ icon: "Share2",
2320
+ variables: ["clientName", "gymName", "urlCatalog"],
2321
+ exampleValues: {
2322
+ clientName: "Roberto G\xF3mez",
2323
+ gymName: "GymSpace",
2324
+ urlCatalog: "https://gymspace.app/catalog/gym-123"
2325
+ }
2404
2326
  }
2405
2327
  };
2406
2328
  var BULK_MESSAGE_VARIABLES = [
@@ -2533,24 +2455,124 @@ var BULK_MESSAGE_VARIABLES = [
2533
2455
  category: "datetime",
2534
2456
  required: false,
2535
2457
  formatter: "text"
2458
+ }
2459
+ ];
2460
+ var ACTIVITY_MESSAGE_VARIABLES = [
2461
+ {
2462
+ name: "activityName",
2463
+ placeholder: "{{activityName}}",
2464
+ description: "Nombre de la actividad",
2465
+ example: "Yoga Matutino",
2466
+ category: "activity",
2467
+ required: false,
2468
+ formatter: "text"
2536
2469
  },
2537
- // Variables Personalizadas
2538
2470
  {
2539
- name: "customField",
2540
- placeholder: "{{customField}}",
2541
- description: "Campo personalizado del cliente",
2542
- example: "Valor personalizado",
2543
- category: "custom",
2471
+ name: "activityDescription",
2472
+ placeholder: "{{activityDescription}}",
2473
+ description: "Descripci\xF3n de la actividad",
2474
+ example: "Sesi\xF3n de yoga para principiantes",
2475
+ category: "activity",
2476
+ required: false,
2477
+ formatter: "text"
2478
+ },
2479
+ {
2480
+ name: "activityStartDate",
2481
+ placeholder: "{{activityStartDate}}",
2482
+ description: "Fecha de inicio de la actividad",
2483
+ example: "15/10/2024",
2484
+ category: "activity",
2485
+ required: false,
2486
+ formatter: "date"
2487
+ },
2488
+ {
2489
+ name: "activityStartTime",
2490
+ placeholder: "{{activityStartTime}}",
2491
+ description: "Hora de inicio de la actividad",
2492
+ example: "08:00",
2493
+ category: "activity",
2494
+ required: false,
2495
+ formatter: "text"
2496
+ },
2497
+ {
2498
+ name: "activityStartDateTime",
2499
+ placeholder: "{{activityStartDateTime}}",
2500
+ description: "Fecha y hora de inicio de la actividad",
2501
+ example: "15/10/2024 08:00",
2502
+ category: "activity",
2503
+ required: false,
2504
+ formatter: "datetime"
2505
+ },
2506
+ {
2507
+ name: "activityDuration",
2508
+ placeholder: "{{activityDuration}}",
2509
+ description: "Duraci\xF3n de la actividad en minutos",
2510
+ example: "60",
2511
+ category: "activity",
2512
+ required: false,
2513
+ formatter: "number"
2514
+ },
2515
+ {
2516
+ name: "activityMaxParticipants",
2517
+ placeholder: "{{activityMaxParticipants}}",
2518
+ description: "N\xFAmero m\xE1ximo de participantes",
2519
+ example: "20",
2520
+ category: "activity",
2521
+ required: false,
2522
+ formatter: "number"
2523
+ },
2524
+ {
2525
+ name: "activityLocation",
2526
+ placeholder: "{{activityLocation}}",
2527
+ description: "Ubicaci\xF3n de la actividad",
2528
+ example: "Av. Principal 123",
2529
+ category: "activity",
2530
+ required: false,
2531
+ formatter: "text"
2532
+ },
2533
+ {
2534
+ name: "timeUntilActivity",
2535
+ placeholder: "{{timeUntilActivity}}",
2536
+ description: "Tiempo restante hasta la actividad",
2537
+ example: "2 horas",
2538
+ category: "activity",
2544
2539
  required: false,
2545
2540
  formatter: "text"
2546
2541
  }
2547
2542
  ];
2543
+ var VARIABLE_CONTEXT_MAP = {
2544
+ bulk: BULK_MESSAGE_VARIABLES,
2545
+ activity: [...BULK_MESSAGE_VARIABLES, ...ACTIVITY_MESSAGE_VARIABLES],
2546
+ event: BULK_MESSAGE_VARIABLES,
2547
+ // Para futuros eventos
2548
+ reminder: BULK_MESSAGE_VARIABLES
2549
+ // Para futuros recordatorios
2550
+ };
2551
+ function getVariablesByContext(context) {
2552
+ return VARIABLE_CONTEXT_MAP[context] || BULK_MESSAGE_VARIABLES;
2553
+ }
2554
+ function validateVariablesInContext(message, context) {
2555
+ const variablePattern = /{{(\w+)}}/g;
2556
+ const matches = message.matchAll(variablePattern);
2557
+ const invalidVariables = [];
2558
+ const validVariables = getVariablesByContext(context).map((v) => v.name);
2559
+ for (const match of matches) {
2560
+ const variableName = match[1];
2561
+ if (!validVariables.includes(variableName)) {
2562
+ invalidVariables.push(variableName);
2563
+ }
2564
+ }
2565
+ return {
2566
+ valid: invalidVariables.length === 0,
2567
+ invalidVariables
2568
+ };
2569
+ }
2548
2570
  var BULK_MESSAGE_VARIABLE_CATEGORIES = {
2549
2571
  client: "Cliente",
2550
2572
  gym: "Gimnasio",
2551
2573
  membership: "Membres\xEDa",
2552
- datetime: "Fecha/Hora",
2553
- custom: "Personalizado"
2574
+ activity: "Actividad",
2575
+ datetime: "Fecha/Hora"
2554
2576
  };
2555
2577
  var PERMISSIONS = {
2556
2578
  // Organizations
@@ -2637,6 +2659,20 @@ var PERMISSIONS = {
2637
2659
  TAGS_READ: "TAGS_READ",
2638
2660
  TAGS_UPDATE: "TAGS_UPDATE",
2639
2661
  TAGS_DELETE: "TAGS_DELETE",
2662
+ // Commissions
2663
+ COMMISSIONS_CONFIG_CREATE: "COMMISSIONS_CONFIG_CREATE",
2664
+ COMMISSIONS_CONFIG_READ: "COMMISSIONS_CONFIG_READ",
2665
+ COMMISSIONS_CONFIG_UPDATE: "COMMISSIONS_CONFIG_UPDATE",
2666
+ COMMISSIONS_RULES_CREATE: "COMMISSIONS_RULES_CREATE",
2667
+ COMMISSIONS_RULES_READ: "COMMISSIONS_RULES_READ",
2668
+ COMMISSIONS_RULES_UPDATE: "COMMISSIONS_RULES_UPDATE",
2669
+ COMMISSIONS_RULES_DELETE: "COMMISSIONS_RULES_DELETE",
2670
+ COMMISSIONS_CALCULATIONS_READ: "COMMISSIONS_CALCULATIONS_READ",
2671
+ COMMISSIONS_REPORTS_VIEW: "COMMISSIONS_REPORTS_VIEW",
2672
+ // Catalog
2673
+ CATALOG_READ: "CATALOG_READ",
2674
+ CATALOG_UPDATE: "CATALOG_UPDATE",
2675
+ CATALOG_MANAGE: "CATALOG_MANAGE",
2640
2676
  // Special permissions
2641
2677
  SUPER_ADMIN: "SUPER_ADMIN",
2642
2678
  OWNER: "OWNER",
@@ -2679,7 +2715,9 @@ var ROLE_PERMISSIONS = {
2679
2715
  PERMISSIONS.PAYMENT_METHODS_CREATE,
2680
2716
  PERMISSIONS.PAYMENT_METHODS_READ,
2681
2717
  PERMISSIONS.PAYMENT_METHODS_UPDATE,
2682
- PERMISSIONS.PAYMENT_METHODS_DELETE
2718
+ PERMISSIONS.PAYMENT_METHODS_DELETE,
2719
+ PERMISSIONS.COMMISSIONS_RULES_READ,
2720
+ PERMISSIONS.COMMISSIONS_CALCULATIONS_READ
2683
2721
  ]
2684
2722
  };
2685
2723
  var CACHE_TTL = {
@@ -2693,7 +2731,11 @@ var CACHE_TTL = {
2693
2731
  // 5 minutes
2694
2732
  DASHBOARD: 18e4,
2695
2733
  // 3 minutes
2696
- WHATSAPP_MESSAGE_STATUS: 3e5
2734
+ WHATSAPP_MESSAGE_STATUS: 3e5,
2735
+ // 5 minutes
2736
+ ONBOARDING_STATUS: 36e5,
2737
+ // 1 hour
2738
+ ONBOARDING_LOCK: 3e5
2697
2739
  // 5 minutes
2698
2740
  };
2699
2741
  var FILE_LIMITS = {
@@ -2718,6 +2760,155 @@ var HEADERS = {
2718
2760
  GYM_ID: "X-Gym-Id",
2719
2761
  REQUEST_ID: "X-Request-Id"
2720
2762
  };
2763
+ var UserType = /* @__PURE__ */ ((UserType2) => {
2764
+ UserType2["OWNER"] = "owner";
2765
+ UserType2["COLLABORATOR"] = "collaborator";
2766
+ return UserType2;
2767
+ })(UserType || {});
2768
+ var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
2769
+ SubscriptionStatus2["ACTIVE"] = "active";
2770
+ SubscriptionStatus2["INACTIVE"] = "inactive";
2771
+ SubscriptionStatus2["EXPIRED"] = "expired";
2772
+ SubscriptionStatus2["PAUSED"] = "paused";
2773
+ SubscriptionStatus2["PENDING_UPGRADE"] = "pending_upgrade";
2774
+ return SubscriptionStatus2;
2775
+ })(SubscriptionStatus || {});
2776
+ var CollaboratorStatus = /* @__PURE__ */ ((CollaboratorStatus2) => {
2777
+ CollaboratorStatus2["PENDING"] = "pending";
2778
+ CollaboratorStatus2["ACTIVE"] = "active";
2779
+ CollaboratorStatus2["INACTIVE"] = "inactive";
2780
+ return CollaboratorStatus2;
2781
+ })(CollaboratorStatus || {});
2782
+ var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
2783
+ InvitationStatus2["PENDING"] = "pending";
2784
+ InvitationStatus2["ACCEPTED"] = "accepted";
2785
+ InvitationStatus2["CANCELLED"] = "cancelled";
2786
+ InvitationStatus2["EXPIRED"] = "expired";
2787
+ return InvitationStatus2;
2788
+ })(InvitationStatus || {});
2789
+ var ClientStatus = /* @__PURE__ */ ((ClientStatus2) => {
2790
+ ClientStatus2["ACTIVE"] = "active";
2791
+ ClientStatus2["INACTIVE"] = "inactive";
2792
+ return ClientStatus2;
2793
+ })(ClientStatus || {});
2794
+ var PlanStatus = /* @__PURE__ */ ((PlanStatus2) => {
2795
+ PlanStatus2["ACTIVE"] = "active";
2796
+ PlanStatus2["INACTIVE"] = "inactive";
2797
+ PlanStatus2["ARCHIVED"] = "archived";
2798
+ return PlanStatus2;
2799
+ })(PlanStatus || {});
2800
+ var PlanType = /* @__PURE__ */ ((PlanType2) => {
2801
+ PlanType2["BASIC"] = "BASIC";
2802
+ PlanType2["PREMIUM"] = "PREMIUM";
2803
+ PlanType2["ENTERPRISE"] = "ENTERPRISE";
2804
+ return PlanType2;
2805
+ })(PlanType || {});
2806
+ var ContractStatus = /* @__PURE__ */ ((ContractStatus2) => {
2807
+ ContractStatus2["PENDING"] = "pending";
2808
+ ContractStatus2["ACTIVE"] = "active";
2809
+ ContractStatus2["EXPIRING_SOON"] = "expiring_soon";
2810
+ ContractStatus2["EXPIRED"] = "expired";
2811
+ ContractStatus2["CANCELLED"] = "cancelled";
2812
+ ContractStatus2["FOR_RENEW"] = "for_renew";
2813
+ ContractStatus2["SUSPENDED"] = "suspended";
2814
+ ContractStatus2["GRACE_PERIOD"] = "grace_period";
2815
+ ContractStatus2["TERMINATED"] = "terminated";
2816
+ return ContractStatus2;
2817
+ })(ContractStatus || {});
2818
+ var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
2819
+ CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
2820
+ CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
2821
+ CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
2822
+ CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
2823
+ CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
2824
+ CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
2825
+ CancellationReason2["OTHER"] = "OTHER";
2826
+ return CancellationReason2;
2827
+ })(CancellationReason || {});
2828
+ var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
2829
+ SuspensionType2["VACATION"] = "vacation";
2830
+ SuspensionType2["MEDICAL"] = "medical";
2831
+ SuspensionType2["FINANCIAL"] = "financial";
2832
+ SuspensionType2["OTHER"] = "other";
2833
+ return SuspensionType2;
2834
+ })(SuspensionType || {});
2835
+ var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
2836
+ PaymentFrequency2["MONTHLY"] = "monthly";
2837
+ PaymentFrequency2["QUARTERLY"] = "quarterly";
2838
+ PaymentFrequency2["ANNUAL"] = "annual";
2839
+ return PaymentFrequency2;
2840
+ })(PaymentFrequency || {});
2841
+ var AssetStatus = /* @__PURE__ */ ((AssetStatus2) => {
2842
+ AssetStatus2["ACTIVE"] = "active";
2843
+ AssetStatus2["DELETED"] = "deleted";
2844
+ return AssetStatus2;
2845
+ })(AssetStatus || {});
2846
+ var AssetCategory = /* @__PURE__ */ ((AssetCategory2) => {
2847
+ AssetCategory2["MEDICAL_DOCUMENT"] = "medical_document";
2848
+ AssetCategory2["IDENTIFICATION"] = "identification";
2849
+ AssetCategory2["INSURANCE"] = "insurance";
2850
+ AssetCategory2["CONTRACT_COPY"] = "contract_copy";
2851
+ AssetCategory2["OTHER"] = "other";
2852
+ return AssetCategory2;
2853
+ })(AssetCategory || {});
2854
+ var ContractAssetType = /* @__PURE__ */ ((ContractAssetType2) => {
2855
+ ContractAssetType2["PAYMENT_RECEIPT"] = "payment_receipt";
2856
+ ContractAssetType2["CONTRACT_DOCUMENT"] = "contract_document";
2857
+ ContractAssetType2["IDENTIFICATION"] = "identification";
2858
+ ContractAssetType2["OTHER"] = "other";
2859
+ return ContractAssetType2;
2860
+ })(ContractAssetType || {});
2861
+ var WHATSAPP_EVENTS = {
2862
+ MESSAGE_SEND: "whatsapp/message.send",
2863
+ MESSAGE_RECEIVED: "whatsapp/message.received",
2864
+ CONNECTION_UPDATE: "whatsapp/connection.update"
2865
+ };
2866
+ var BULK_MESSAGING_EVENTS = {
2867
+ SEND_BULK_MESSAGES: "whatsapp/bulk-messages.send"
2868
+ };
2869
+ var ACTIVITY_EVENTS = {
2870
+ SEND_ACTIVITY_NOTIFICATION: "activity/notification.send"
2871
+ };
2872
+ var templateGenerationRequestSchema = zod.z.object({
2873
+ templateCode: zod.z.string(),
2874
+ templateMetadata: zod.z.object({
2875
+ title: zod.z.string(),
2876
+ description: zod.z.string(),
2877
+ variables: zod.z.array(zod.z.string()),
2878
+ exampleValues: zod.z.record(zod.z.string())
2879
+ }),
2880
+ userPrompt: zod.z.string().optional(),
2881
+ language: zod.z.string().default("es")
2882
+ });
2883
+ var aiGeneratedTemplateSchema = zod.z.object({
2884
+ message: zod.z.string().describe("Mensaje generado con variables en formato {{variable}}"),
2885
+ tone: zod.z.enum(["professional", "friendly", "casual", "urgent"]).describe("Tono del mensaje"),
2886
+ usedVariables: zod.z.array(zod.z.string()).describe("Variables utilizadas en el mensaje"),
2887
+ suggestions: zod.z.array(zod.z.string()).optional().describe("Sugerencias adicionales")
2888
+ });
2889
+ var bulkMessageGenerationRequestSchema = zod.z.object({
2890
+ prompt: zod.z.string().describe("Prompt or context for message generation"),
2891
+ tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).optional().describe("Tone of the message"),
2892
+ includeVariables: zod.z.array(zod.z.string()).optional().describe("Variables to include in the message"),
2893
+ additionalRequirements: zod.z.string().optional().describe("Additional requirements for the message"),
2894
+ language: zod.z.string().default("es").describe("Language for generation")
2895
+ });
2896
+ var bulkMessageSchema = zod.z.object({
2897
+ message: zod.z.string().describe("Generated message with variables"),
2898
+ tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).describe("Tone of the message"),
2899
+ usedVariables: zod.z.array(zod.z.string()).describe("Variables used in the message"),
2900
+ suggestions: zod.z.array(zod.z.string()).optional().describe("Additional message suggestions")
2901
+ });
2902
+ var activityNotificationGenerationRequestSchema = zod.z.object({
2903
+ prompt: zod.z.string().describe("Prompt or context for notification generation"),
2904
+ tone: zod.z.enum(["friendly", "formal", "urgent", "motivational", "reminder"]).optional().describe("Tone of the notification"),
2905
+ currentMessage: zod.z.string().optional().describe("Current message to improve or use as reference"),
2906
+ additionalRequirements: zod.z.string().optional().describe("Additional requirements for the notification"),
2907
+ language: zod.z.string().default("es").describe("Language for generation")
2908
+ });
2909
+ var activityNotificationSchema = zod.z.object({
2910
+ message: zod.z.string().describe("Generated notification message with activity variables")
2911
+ });
2721
2912
  var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
2722
2913
  RoleNames2["ADMIN"] = "Admin";
2723
2914
  RoleNames2["ENCARGADO"] = "Encargado";
@@ -2807,48 +2998,36 @@ function getRoleCapabilities(roleName) {
2807
2998
  return [];
2808
2999
  }
2809
3000
  }
2810
- var WHATSAPP_EVENTS = {
2811
- MESSAGE_SEND: "whatsapp/message.send",
2812
- MESSAGE_RECEIVED: "whatsapp/message.received",
2813
- CONNECTION_UPDATE: "whatsapp/connection.update"
2814
- };
2815
- var BULK_MESSAGING_EVENTS = {
2816
- GENERATE_BULK_MESSAGE: "whatsapp/bulk-message.generate",
2817
- SEND_BULK_MESSAGES: "whatsapp/bulk-messages.send"
2818
- };
2819
- var ACTIVITY_EVENTS = {
2820
- SEND_ACTIVITY_NOTIFICATION: "activity/notification.send"
2821
- };
2822
- var templateGenerationRequestSchema = zod.z.object({
2823
- templateCode: zod.z.string(),
2824
- templateMetadata: zod.z.object({
2825
- title: zod.z.string(),
2826
- description: zod.z.string(),
2827
- variables: zod.z.array(zod.z.string()),
2828
- exampleValues: zod.z.record(zod.z.string())
2829
- }),
2830
- userPrompt: zod.z.string().optional(),
2831
- language: zod.z.string().default("es")
2832
- });
2833
- var aiGeneratedTemplateSchema = zod.z.object({
2834
- message: zod.z.string().describe("Mensaje generado con variables en formato {{variable}}"),
2835
- tone: zod.z.enum(["professional", "friendly", "casual", "urgent"]).describe("Tono del mensaje"),
2836
- usedVariables: zod.z.array(zod.z.string()).describe("Variables utilizadas en el mensaje"),
2837
- suggestions: zod.z.array(zod.z.string()).optional().describe("Sugerencias adicionales")
2838
- });
2839
- var bulkMessageGenerationRequestSchema = zod.z.object({
2840
- prompt: zod.z.string().describe("Prompt or context for message generation"),
2841
- tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).optional().describe("Tone of the message"),
2842
- includeVariables: zod.z.array(zod.z.string()).optional().describe("Variables to include in the message"),
2843
- additionalRequirements: zod.z.string().optional().describe("Additional requirements for the message"),
2844
- language: zod.z.string().default("es").describe("Language for generation")
2845
- });
2846
- var bulkMessageSchema = zod.z.object({
2847
- message: zod.z.string().describe("Generated message with variables"),
2848
- tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).describe("Tone of the message"),
2849
- usedVariables: zod.z.array(zod.z.string()).describe("Variables used in the message"),
2850
- suggestions: zod.z.array(zod.z.string()).optional().describe("Additional message suggestions")
2851
- });
3001
+ function normalizePhoneForEvolution(phoneNumber) {
3002
+ if (!phoneNumber) {
3003
+ throw new Error("Phone number is required");
3004
+ }
3005
+ let cleaned = phoneNumber.replace(/[^\d+]/g, "");
3006
+ if (cleaned.startsWith("+")) {
3007
+ cleaned = cleaned.substring(1);
3008
+ }
3009
+ if (cleaned.length === 9) {
3010
+ return `+51${cleaned}`;
3011
+ }
3012
+ if (cleaned.length === 11 && cleaned.startsWith("51")) {
3013
+ return `+${cleaned}`;
3014
+ }
3015
+ if (cleaned.length === 12 && cleaned.startsWith("051")) {
3016
+ return `+${cleaned.substring(1)}`;
3017
+ }
3018
+ if (!cleaned.startsWith("+")) {
3019
+ return `+${cleaned}`;
3020
+ }
3021
+ return cleaned;
3022
+ }
3023
+ function isValidPeruvianPhone(phoneNumber) {
3024
+ try {
3025
+ const normalized = normalizePhoneForEvolution(phoneNumber);
3026
+ return /^\+51[9]\d{8}$/.test(normalized);
3027
+ } catch {
3028
+ return false;
3029
+ }
3030
+ }
2852
3031
 
2853
3032
  // src/models/commissions.ts
2854
3033
  var CommissionRuleType = /* @__PURE__ */ ((CommissionRuleType2) => {
@@ -2885,6 +3064,7 @@ var LeadGender = /* @__PURE__ */ ((LeadGender2) => {
2885
3064
  })(LeadGender || {});
2886
3065
 
2887
3066
  exports.ACTIVITY_EVENTS = ACTIVITY_EVENTS;
3067
+ exports.ACTIVITY_MESSAGE_VARIABLES = ACTIVITY_MESSAGE_VARIABLES;
2888
3068
  exports.ActivitiesResource = ActivitiesResource;
2889
3069
  exports.AdminCatalogResource = AdminCatalogResource;
2890
3070
  exports.AdminSubscriptionManagementResource = AdminSubscriptionManagementResource;
@@ -2942,6 +3122,7 @@ exports.PERMISSIONS = PERMISSIONS;
2942
3122
  exports.PaymentFrequency = PaymentFrequency;
2943
3123
  exports.PaymentMethodsResource = PaymentMethodsResource;
2944
3124
  exports.PlanStatus = PlanStatus;
3125
+ exports.PlanType = PlanType;
2945
3126
  exports.ProductsResource = ProductsResource;
2946
3127
  exports.PublicCatalogResource = PublicCatalogResource;
2947
3128
  exports.ROLE_NAMES = ROLE_NAMES;
@@ -2961,11 +3142,14 @@ exports.TemplateCode = TemplateCode;
2961
3142
  exports.TemplateType = TemplateType;
2962
3143
  exports.UserType = UserType;
2963
3144
  exports.UsersResource = UsersResource;
3145
+ exports.VARIABLE_CONTEXT_MAP = VARIABLE_CONTEXT_MAP;
2964
3146
  exports.ValidationError = ValidationError;
2965
3147
  exports.WHATSAPP_EVENTS = WHATSAPP_EVENTS;
2966
3148
  exports.WHATSAPP_TEMPLATE_EVENTS = WHATSAPP_TEMPLATE_EVENTS;
2967
3149
  exports.WhatsAppResource = WhatsAppResource;
2968
3150
  exports.WhatsAppTemplatesResource = WhatsAppTemplatesResource;
3151
+ exports.activityNotificationGenerationRequestSchema = activityNotificationGenerationRequestSchema;
3152
+ exports.activityNotificationSchema = activityNotificationSchema;
2969
3153
  exports.aiGeneratedTemplateSchema = aiGeneratedTemplateSchema;
2970
3154
  exports.bulkMessageGenerationRequestSchema = bulkMessageGenerationRequestSchema;
2971
3155
  exports.bulkMessageSchema = bulkMessageSchema;
@@ -2973,8 +3157,12 @@ exports.canAccessFeature = canAccessFeature;
2973
3157
  exports.getRoleCapabilities = getRoleCapabilities;
2974
3158
  exports.getRoleDescription = getRoleDescription;
2975
3159
  exports.getRoleDisplayName = getRoleDisplayName;
3160
+ exports.getVariablesByContext = getVariablesByContext;
2976
3161
  exports.isAdminRole = isAdminRole;
2977
3162
  exports.isEncargadoRole = isEncargadoRole;
3163
+ exports.isValidPeruvianPhone = isValidPeruvianPhone;
3164
+ exports.normalizePhoneForEvolution = normalizePhoneForEvolution;
2978
3165
  exports.templateGenerationRequestSchema = templateGenerationRequestSchema;
3166
+ exports.validateVariablesInContext = validateVariablesInContext;
2979
3167
  //# sourceMappingURL=index.js.map
2980
3168
  //# sourceMappingURL=index.js.map