@gymspace/shared 1.2.22 → 1.3.0
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/.tsbuildinfo +1 -0
- package/dist/index.d.mts +518 -520
- package/dist/index.d.ts +518 -520
- package/dist/index.js +238 -157
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +234 -158
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/constants/bulk-message-variables.ts +58 -0
- package/src/events/bulk-messaging.events.ts +19 -47
- package/src/index.ts +7 -4
- package/src/utils/phone.utils.ts +65 -0
package/dist/index.js
CHANGED
|
@@ -17,106 +17,6 @@ var TemplateType = {
|
|
|
17
17
|
PROMPT: "PROMPT"
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
// src/enums.ts
|
|
21
|
-
var UserType = /* @__PURE__ */ ((UserType2) => {
|
|
22
|
-
UserType2["OWNER"] = "owner";
|
|
23
|
-
UserType2["COLLABORATOR"] = "collaborator";
|
|
24
|
-
return UserType2;
|
|
25
|
-
})(UserType || {});
|
|
26
|
-
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
27
|
-
SubscriptionStatus2["ACTIVE"] = "active";
|
|
28
|
-
SubscriptionStatus2["INACTIVE"] = "inactive";
|
|
29
|
-
SubscriptionStatus2["EXPIRED"] = "expired";
|
|
30
|
-
SubscriptionStatus2["PAUSED"] = "paused";
|
|
31
|
-
SubscriptionStatus2["PENDING_UPGRADE"] = "pending_upgrade";
|
|
32
|
-
return SubscriptionStatus2;
|
|
33
|
-
})(SubscriptionStatus || {});
|
|
34
|
-
var CollaboratorStatus = /* @__PURE__ */ ((CollaboratorStatus2) => {
|
|
35
|
-
CollaboratorStatus2["PENDING"] = "pending";
|
|
36
|
-
CollaboratorStatus2["ACTIVE"] = "active";
|
|
37
|
-
CollaboratorStatus2["INACTIVE"] = "inactive";
|
|
38
|
-
return CollaboratorStatus2;
|
|
39
|
-
})(CollaboratorStatus || {});
|
|
40
|
-
var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
|
|
41
|
-
InvitationStatus2["PENDING"] = "pending";
|
|
42
|
-
InvitationStatus2["ACCEPTED"] = "accepted";
|
|
43
|
-
InvitationStatus2["CANCELLED"] = "cancelled";
|
|
44
|
-
InvitationStatus2["EXPIRED"] = "expired";
|
|
45
|
-
return InvitationStatus2;
|
|
46
|
-
})(InvitationStatus || {});
|
|
47
|
-
var ClientStatus = /* @__PURE__ */ ((ClientStatus2) => {
|
|
48
|
-
ClientStatus2["ACTIVE"] = "active";
|
|
49
|
-
ClientStatus2["INACTIVE"] = "inactive";
|
|
50
|
-
return ClientStatus2;
|
|
51
|
-
})(ClientStatus || {});
|
|
52
|
-
var PlanStatus = /* @__PURE__ */ ((PlanStatus2) => {
|
|
53
|
-
PlanStatus2["ACTIVE"] = "active";
|
|
54
|
-
PlanStatus2["INACTIVE"] = "inactive";
|
|
55
|
-
PlanStatus2["ARCHIVED"] = "archived";
|
|
56
|
-
return PlanStatus2;
|
|
57
|
-
})(PlanStatus || {});
|
|
58
|
-
var PlanType = /* @__PURE__ */ ((PlanType2) => {
|
|
59
|
-
PlanType2["BASIC"] = "BASIC";
|
|
60
|
-
PlanType2["PREMIUM"] = "PREMIUM";
|
|
61
|
-
PlanType2["ENTERPRISE"] = "ENTERPRISE";
|
|
62
|
-
return PlanType2;
|
|
63
|
-
})(PlanType || {});
|
|
64
|
-
var ContractStatus = /* @__PURE__ */ ((ContractStatus2) => {
|
|
65
|
-
ContractStatus2["PENDING"] = "pending";
|
|
66
|
-
ContractStatus2["ACTIVE"] = "active";
|
|
67
|
-
ContractStatus2["EXPIRING_SOON"] = "expiring_soon";
|
|
68
|
-
ContractStatus2["EXPIRED"] = "expired";
|
|
69
|
-
ContractStatus2["CANCELLED"] = "cancelled";
|
|
70
|
-
ContractStatus2["FOR_RENEW"] = "for_renew";
|
|
71
|
-
ContractStatus2["SUSPENDED"] = "suspended";
|
|
72
|
-
ContractStatus2["GRACE_PERIOD"] = "grace_period";
|
|
73
|
-
ContractStatus2["TERMINATED"] = "terminated";
|
|
74
|
-
return ContractStatus2;
|
|
75
|
-
})(ContractStatus || {});
|
|
76
|
-
var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
|
|
77
|
-
CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
|
|
78
|
-
CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
|
|
79
|
-
CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
|
|
80
|
-
CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
|
|
81
|
-
CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
|
|
82
|
-
CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
|
|
83
|
-
CancellationReason2["OTHER"] = "OTHER";
|
|
84
|
-
return CancellationReason2;
|
|
85
|
-
})(CancellationReason || {});
|
|
86
|
-
var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
|
|
87
|
-
SuspensionType2["VACATION"] = "vacation";
|
|
88
|
-
SuspensionType2["MEDICAL"] = "medical";
|
|
89
|
-
SuspensionType2["FINANCIAL"] = "financial";
|
|
90
|
-
SuspensionType2["OTHER"] = "other";
|
|
91
|
-
return SuspensionType2;
|
|
92
|
-
})(SuspensionType || {});
|
|
93
|
-
var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
|
|
94
|
-
PaymentFrequency2["MONTHLY"] = "monthly";
|
|
95
|
-
PaymentFrequency2["QUARTERLY"] = "quarterly";
|
|
96
|
-
PaymentFrequency2["ANNUAL"] = "annual";
|
|
97
|
-
return PaymentFrequency2;
|
|
98
|
-
})(PaymentFrequency || {});
|
|
99
|
-
var AssetStatus = /* @__PURE__ */ ((AssetStatus2) => {
|
|
100
|
-
AssetStatus2["ACTIVE"] = "active";
|
|
101
|
-
AssetStatus2["DELETED"] = "deleted";
|
|
102
|
-
return AssetStatus2;
|
|
103
|
-
})(AssetStatus || {});
|
|
104
|
-
var AssetCategory = /* @__PURE__ */ ((AssetCategory2) => {
|
|
105
|
-
AssetCategory2["MEDICAL_DOCUMENT"] = "medical_document";
|
|
106
|
-
AssetCategory2["IDENTIFICATION"] = "identification";
|
|
107
|
-
AssetCategory2["INSURANCE"] = "insurance";
|
|
108
|
-
AssetCategory2["CONTRACT_COPY"] = "contract_copy";
|
|
109
|
-
AssetCategory2["OTHER"] = "other";
|
|
110
|
-
return AssetCategory2;
|
|
111
|
-
})(AssetCategory || {});
|
|
112
|
-
var ContractAssetType = /* @__PURE__ */ ((ContractAssetType2) => {
|
|
113
|
-
ContractAssetType2["PAYMENT_RECEIPT"] = "payment_receipt";
|
|
114
|
-
ContractAssetType2["CONTRACT_DOCUMENT"] = "contract_document";
|
|
115
|
-
ContractAssetType2["IDENTIFICATION"] = "identification";
|
|
116
|
-
ContractAssetType2["OTHER"] = "other";
|
|
117
|
-
return ContractAssetType2;
|
|
118
|
-
})(ContractAssetType || {});
|
|
119
|
-
|
|
120
20
|
// src/constants/template-codes.constants.ts
|
|
121
21
|
var TEMPLATE_CODES = {
|
|
122
22
|
WELCOME: TemplateCode.WELCOME,
|
|
@@ -433,8 +333,53 @@ var ACTIVITY_MESSAGE_VARIABLES = [
|
|
|
433
333
|
category: "activity",
|
|
434
334
|
required: false,
|
|
435
335
|
formatter: "number"
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "activityLocation",
|
|
339
|
+
placeholder: "{{activityLocation}}",
|
|
340
|
+
description: "Ubicaci\xF3n de la actividad",
|
|
341
|
+
example: "Av. Principal 123",
|
|
342
|
+
category: "activity",
|
|
343
|
+
required: false,
|
|
344
|
+
formatter: "text"
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
name: "timeUntilActivity",
|
|
348
|
+
placeholder: "{{timeUntilActivity}}",
|
|
349
|
+
description: "Tiempo restante hasta la actividad",
|
|
350
|
+
example: "2 horas",
|
|
351
|
+
category: "activity",
|
|
352
|
+
required: false,
|
|
353
|
+
formatter: "text"
|
|
436
354
|
}
|
|
437
355
|
];
|
|
356
|
+
var VARIABLE_CONTEXT_MAP = {
|
|
357
|
+
bulk: BULK_MESSAGE_VARIABLES,
|
|
358
|
+
activity: [...BULK_MESSAGE_VARIABLES, ...ACTIVITY_MESSAGE_VARIABLES],
|
|
359
|
+
event: BULK_MESSAGE_VARIABLES,
|
|
360
|
+
// Para futuros eventos
|
|
361
|
+
reminder: BULK_MESSAGE_VARIABLES
|
|
362
|
+
// Para futuros recordatorios
|
|
363
|
+
};
|
|
364
|
+
function getVariablesByContext(context) {
|
|
365
|
+
return VARIABLE_CONTEXT_MAP[context] || BULK_MESSAGE_VARIABLES;
|
|
366
|
+
}
|
|
367
|
+
function validateVariablesInContext(message, context) {
|
|
368
|
+
const variablePattern = /{{(\w+)}}/g;
|
|
369
|
+
const matches = message.matchAll(variablePattern);
|
|
370
|
+
const invalidVariables = [];
|
|
371
|
+
const validVariables = getVariablesByContext(context).map((v) => v.name);
|
|
372
|
+
for (const match of matches) {
|
|
373
|
+
const variableName = match[1];
|
|
374
|
+
if (!validVariables.includes(variableName)) {
|
|
375
|
+
invalidVariables.push(variableName);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return {
|
|
379
|
+
valid: invalidVariables.length === 0,
|
|
380
|
+
invalidVariables
|
|
381
|
+
};
|
|
382
|
+
}
|
|
438
383
|
var BULK_MESSAGE_VARIABLE_CATEGORIES = {
|
|
439
384
|
client: "Cliente",
|
|
440
385
|
gym: "Gimnasio",
|
|
@@ -627,6 +572,163 @@ var HEADERS = {
|
|
|
627
572
|
REQUEST_ID: "X-Request-Id"
|
|
628
573
|
};
|
|
629
574
|
|
|
575
|
+
// src/enums.ts
|
|
576
|
+
var UserType = /* @__PURE__ */ ((UserType2) => {
|
|
577
|
+
UserType2["OWNER"] = "owner";
|
|
578
|
+
UserType2["COLLABORATOR"] = "collaborator";
|
|
579
|
+
return UserType2;
|
|
580
|
+
})(UserType || {});
|
|
581
|
+
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
582
|
+
SubscriptionStatus2["ACTIVE"] = "active";
|
|
583
|
+
SubscriptionStatus2["INACTIVE"] = "inactive";
|
|
584
|
+
SubscriptionStatus2["EXPIRED"] = "expired";
|
|
585
|
+
SubscriptionStatus2["PAUSED"] = "paused";
|
|
586
|
+
SubscriptionStatus2["PENDING_UPGRADE"] = "pending_upgrade";
|
|
587
|
+
return SubscriptionStatus2;
|
|
588
|
+
})(SubscriptionStatus || {});
|
|
589
|
+
var CollaboratorStatus = /* @__PURE__ */ ((CollaboratorStatus2) => {
|
|
590
|
+
CollaboratorStatus2["PENDING"] = "pending";
|
|
591
|
+
CollaboratorStatus2["ACTIVE"] = "active";
|
|
592
|
+
CollaboratorStatus2["INACTIVE"] = "inactive";
|
|
593
|
+
return CollaboratorStatus2;
|
|
594
|
+
})(CollaboratorStatus || {});
|
|
595
|
+
var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
|
|
596
|
+
InvitationStatus2["PENDING"] = "pending";
|
|
597
|
+
InvitationStatus2["ACCEPTED"] = "accepted";
|
|
598
|
+
InvitationStatus2["CANCELLED"] = "cancelled";
|
|
599
|
+
InvitationStatus2["EXPIRED"] = "expired";
|
|
600
|
+
return InvitationStatus2;
|
|
601
|
+
})(InvitationStatus || {});
|
|
602
|
+
var ClientStatus = /* @__PURE__ */ ((ClientStatus2) => {
|
|
603
|
+
ClientStatus2["ACTIVE"] = "active";
|
|
604
|
+
ClientStatus2["INACTIVE"] = "inactive";
|
|
605
|
+
return ClientStatus2;
|
|
606
|
+
})(ClientStatus || {});
|
|
607
|
+
var PlanStatus = /* @__PURE__ */ ((PlanStatus2) => {
|
|
608
|
+
PlanStatus2["ACTIVE"] = "active";
|
|
609
|
+
PlanStatus2["INACTIVE"] = "inactive";
|
|
610
|
+
PlanStatus2["ARCHIVED"] = "archived";
|
|
611
|
+
return PlanStatus2;
|
|
612
|
+
})(PlanStatus || {});
|
|
613
|
+
var PlanType = /* @__PURE__ */ ((PlanType2) => {
|
|
614
|
+
PlanType2["BASIC"] = "BASIC";
|
|
615
|
+
PlanType2["PREMIUM"] = "PREMIUM";
|
|
616
|
+
PlanType2["ENTERPRISE"] = "ENTERPRISE";
|
|
617
|
+
return PlanType2;
|
|
618
|
+
})(PlanType || {});
|
|
619
|
+
var ContractStatus = /* @__PURE__ */ ((ContractStatus2) => {
|
|
620
|
+
ContractStatus2["PENDING"] = "pending";
|
|
621
|
+
ContractStatus2["ACTIVE"] = "active";
|
|
622
|
+
ContractStatus2["EXPIRING_SOON"] = "expiring_soon";
|
|
623
|
+
ContractStatus2["EXPIRED"] = "expired";
|
|
624
|
+
ContractStatus2["CANCELLED"] = "cancelled";
|
|
625
|
+
ContractStatus2["FOR_RENEW"] = "for_renew";
|
|
626
|
+
ContractStatus2["SUSPENDED"] = "suspended";
|
|
627
|
+
ContractStatus2["GRACE_PERIOD"] = "grace_period";
|
|
628
|
+
ContractStatus2["TERMINATED"] = "terminated";
|
|
629
|
+
return ContractStatus2;
|
|
630
|
+
})(ContractStatus || {});
|
|
631
|
+
var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
|
|
632
|
+
CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
|
|
633
|
+
CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
|
|
634
|
+
CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
|
|
635
|
+
CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
|
|
636
|
+
CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
|
|
637
|
+
CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
|
|
638
|
+
CancellationReason2["OTHER"] = "OTHER";
|
|
639
|
+
return CancellationReason2;
|
|
640
|
+
})(CancellationReason || {});
|
|
641
|
+
var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
|
|
642
|
+
SuspensionType2["VACATION"] = "vacation";
|
|
643
|
+
SuspensionType2["MEDICAL"] = "medical";
|
|
644
|
+
SuspensionType2["FINANCIAL"] = "financial";
|
|
645
|
+
SuspensionType2["OTHER"] = "other";
|
|
646
|
+
return SuspensionType2;
|
|
647
|
+
})(SuspensionType || {});
|
|
648
|
+
var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
|
|
649
|
+
PaymentFrequency2["MONTHLY"] = "monthly";
|
|
650
|
+
PaymentFrequency2["QUARTERLY"] = "quarterly";
|
|
651
|
+
PaymentFrequency2["ANNUAL"] = "annual";
|
|
652
|
+
return PaymentFrequency2;
|
|
653
|
+
})(PaymentFrequency || {});
|
|
654
|
+
var AssetStatus = /* @__PURE__ */ ((AssetStatus2) => {
|
|
655
|
+
AssetStatus2["ACTIVE"] = "active";
|
|
656
|
+
AssetStatus2["DELETED"] = "deleted";
|
|
657
|
+
return AssetStatus2;
|
|
658
|
+
})(AssetStatus || {});
|
|
659
|
+
var AssetCategory = /* @__PURE__ */ ((AssetCategory2) => {
|
|
660
|
+
AssetCategory2["MEDICAL_DOCUMENT"] = "medical_document";
|
|
661
|
+
AssetCategory2["IDENTIFICATION"] = "identification";
|
|
662
|
+
AssetCategory2["INSURANCE"] = "insurance";
|
|
663
|
+
AssetCategory2["CONTRACT_COPY"] = "contract_copy";
|
|
664
|
+
AssetCategory2["OTHER"] = "other";
|
|
665
|
+
return AssetCategory2;
|
|
666
|
+
})(AssetCategory || {});
|
|
667
|
+
var ContractAssetType = /* @__PURE__ */ ((ContractAssetType2) => {
|
|
668
|
+
ContractAssetType2["PAYMENT_RECEIPT"] = "payment_receipt";
|
|
669
|
+
ContractAssetType2["CONTRACT_DOCUMENT"] = "contract_document";
|
|
670
|
+
ContractAssetType2["IDENTIFICATION"] = "identification";
|
|
671
|
+
ContractAssetType2["OTHER"] = "other";
|
|
672
|
+
return ContractAssetType2;
|
|
673
|
+
})(ContractAssetType || {});
|
|
674
|
+
|
|
675
|
+
// src/events/whatsapp.events.ts
|
|
676
|
+
var WHATSAPP_EVENTS = {
|
|
677
|
+
MESSAGE_SEND: "whatsapp/message.send",
|
|
678
|
+
MESSAGE_RECEIVED: "whatsapp/message.received",
|
|
679
|
+
CONNECTION_UPDATE: "whatsapp/connection.update"
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
// src/events/bulk-messaging.events.ts
|
|
683
|
+
var BULK_MESSAGING_EVENTS = {
|
|
684
|
+
SEND_BULK_MESSAGES: "whatsapp/bulk-messages.send"
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
// src/events/activity.events.ts
|
|
688
|
+
var ACTIVITY_EVENTS = {
|
|
689
|
+
SEND_ACTIVITY_NOTIFICATION: "activity/notification.send"
|
|
690
|
+
};
|
|
691
|
+
var templateGenerationRequestSchema = zod.z.object({
|
|
692
|
+
templateCode: zod.z.string(),
|
|
693
|
+
templateMetadata: zod.z.object({
|
|
694
|
+
title: zod.z.string(),
|
|
695
|
+
description: zod.z.string(),
|
|
696
|
+
variables: zod.z.array(zod.z.string()),
|
|
697
|
+
exampleValues: zod.z.record(zod.z.string())
|
|
698
|
+
}),
|
|
699
|
+
userPrompt: zod.z.string().optional(),
|
|
700
|
+
language: zod.z.string().default("es")
|
|
701
|
+
});
|
|
702
|
+
var aiGeneratedTemplateSchema = zod.z.object({
|
|
703
|
+
message: zod.z.string().describe("Mensaje generado con variables en formato {{variable}}"),
|
|
704
|
+
tone: zod.z.enum(["professional", "friendly", "casual", "urgent"]).describe("Tono del mensaje"),
|
|
705
|
+
usedVariables: zod.z.array(zod.z.string()).describe("Variables utilizadas en el mensaje"),
|
|
706
|
+
suggestions: zod.z.array(zod.z.string()).optional().describe("Sugerencias adicionales")
|
|
707
|
+
});
|
|
708
|
+
var bulkMessageGenerationRequestSchema = zod.z.object({
|
|
709
|
+
prompt: zod.z.string().describe("Prompt or context for message generation"),
|
|
710
|
+
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).optional().describe("Tone of the message"),
|
|
711
|
+
includeVariables: zod.z.array(zod.z.string()).optional().describe("Variables to include in the message"),
|
|
712
|
+
additionalRequirements: zod.z.string().optional().describe("Additional requirements for the message"),
|
|
713
|
+
language: zod.z.string().default("es").describe("Language for generation")
|
|
714
|
+
});
|
|
715
|
+
var bulkMessageSchema = zod.z.object({
|
|
716
|
+
message: zod.z.string().describe("Generated message with variables"),
|
|
717
|
+
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).describe("Tone of the message"),
|
|
718
|
+
usedVariables: zod.z.array(zod.z.string()).describe("Variables used in the message"),
|
|
719
|
+
suggestions: zod.z.array(zod.z.string()).optional().describe("Additional message suggestions")
|
|
720
|
+
});
|
|
721
|
+
var activityNotificationGenerationRequestSchema = zod.z.object({
|
|
722
|
+
prompt: zod.z.string().describe("Prompt or context for notification generation"),
|
|
723
|
+
tone: zod.z.enum(["friendly", "formal", "urgent", "motivational", "reminder"]).optional().describe("Tone of the notification"),
|
|
724
|
+
currentMessage: zod.z.string().optional().describe("Current message to improve or use as reference"),
|
|
725
|
+
additionalRequirements: zod.z.string().optional().describe("Additional requirements for the notification"),
|
|
726
|
+
language: zod.z.string().default("es").describe("Language for generation")
|
|
727
|
+
});
|
|
728
|
+
var activityNotificationSchema = zod.z.object({
|
|
729
|
+
message: zod.z.string().describe("Generated notification message with activity variables")
|
|
730
|
+
});
|
|
731
|
+
|
|
630
732
|
// src/utils/roleHelpers.ts
|
|
631
733
|
var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
|
|
632
734
|
RoleNames2["ADMIN"] = "Admin";
|
|
@@ -718,63 +820,37 @@ function getRoleCapabilities(roleName) {
|
|
|
718
820
|
}
|
|
719
821
|
}
|
|
720
822
|
|
|
721
|
-
// src/
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
usedVariables: zod.z.array(zod.z.string()).describe("Variables utilizadas en el mensaje"),
|
|
753
|
-
suggestions: zod.z.array(zod.z.string()).optional().describe("Sugerencias adicionales")
|
|
754
|
-
});
|
|
755
|
-
var bulkMessageGenerationRequestSchema = zod.z.object({
|
|
756
|
-
prompt: zod.z.string().describe("Prompt or context for message generation"),
|
|
757
|
-
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).optional().describe("Tone of the message"),
|
|
758
|
-
includeVariables: zod.z.array(zod.z.string()).optional().describe("Variables to include in the message"),
|
|
759
|
-
additionalRequirements: zod.z.string().optional().describe("Additional requirements for the message"),
|
|
760
|
-
language: zod.z.string().default("es").describe("Language for generation")
|
|
761
|
-
});
|
|
762
|
-
var bulkMessageSchema = zod.z.object({
|
|
763
|
-
message: zod.z.string().describe("Generated message with variables"),
|
|
764
|
-
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).describe("Tone of the message"),
|
|
765
|
-
usedVariables: zod.z.array(zod.z.string()).describe("Variables used in the message"),
|
|
766
|
-
suggestions: zod.z.array(zod.z.string()).optional().describe("Additional message suggestions")
|
|
767
|
-
});
|
|
768
|
-
var activityNotificationGenerationRequestSchema = zod.z.object({
|
|
769
|
-
prompt: zod.z.string().describe("Prompt or context for notification generation"),
|
|
770
|
-
tone: zod.z.enum(["friendly", "formal", "urgent", "motivational", "reminder"]).optional().describe("Tone of the notification"),
|
|
771
|
-
currentMessage: zod.z.string().optional().describe("Current message to improve or use as reference"),
|
|
772
|
-
additionalRequirements: zod.z.string().optional().describe("Additional requirements for the notification"),
|
|
773
|
-
language: zod.z.string().default("es").describe("Language for generation")
|
|
774
|
-
});
|
|
775
|
-
var activityNotificationSchema = zod.z.object({
|
|
776
|
-
message: zod.z.string().describe("Generated notification message with activity variables")
|
|
777
|
-
});
|
|
823
|
+
// src/utils/phone.utils.ts
|
|
824
|
+
function normalizePhoneForEvolution(phoneNumber) {
|
|
825
|
+
if (!phoneNumber) {
|
|
826
|
+
throw new Error("Phone number is required");
|
|
827
|
+
}
|
|
828
|
+
let cleaned = phoneNumber.replace(/[^\d+]/g, "");
|
|
829
|
+
if (cleaned.startsWith("+")) {
|
|
830
|
+
cleaned = cleaned.substring(1);
|
|
831
|
+
}
|
|
832
|
+
if (cleaned.length === 9) {
|
|
833
|
+
return `+51${cleaned}`;
|
|
834
|
+
}
|
|
835
|
+
if (cleaned.length === 11 && cleaned.startsWith("51")) {
|
|
836
|
+
return `+${cleaned}`;
|
|
837
|
+
}
|
|
838
|
+
if (cleaned.length === 12 && cleaned.startsWith("051")) {
|
|
839
|
+
return `+${cleaned.substring(1)}`;
|
|
840
|
+
}
|
|
841
|
+
if (!cleaned.startsWith("+")) {
|
|
842
|
+
return `+${cleaned}`;
|
|
843
|
+
}
|
|
844
|
+
return cleaned;
|
|
845
|
+
}
|
|
846
|
+
function isValidPeruvianPhone(phoneNumber) {
|
|
847
|
+
try {
|
|
848
|
+
const normalized = normalizePhoneForEvolution(phoneNumber);
|
|
849
|
+
return /^\+51[9]\d{8}$/.test(normalized);
|
|
850
|
+
} catch {
|
|
851
|
+
return false;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
778
854
|
|
|
779
855
|
exports.ACTIVITY_EVENTS = ACTIVITY_EVENTS;
|
|
780
856
|
exports.ACTIVITY_MESSAGE_VARIABLES = ACTIVITY_MESSAGE_VARIABLES;
|
|
@@ -808,6 +884,7 @@ exports.TEMPLATE_METADATA = TEMPLATE_METADATA;
|
|
|
808
884
|
exports.TemplateCode = TemplateCode;
|
|
809
885
|
exports.TemplateType = TemplateType;
|
|
810
886
|
exports.UserType = UserType;
|
|
887
|
+
exports.VARIABLE_CONTEXT_MAP = VARIABLE_CONTEXT_MAP;
|
|
811
888
|
exports.WHATSAPP_EVENTS = WHATSAPP_EVENTS;
|
|
812
889
|
exports.WHATSAPP_TEMPLATE_EVENTS = WHATSAPP_TEMPLATE_EVENTS;
|
|
813
890
|
exports.activityNotificationGenerationRequestSchema = activityNotificationGenerationRequestSchema;
|
|
@@ -819,8 +896,12 @@ exports.canAccessFeature = canAccessFeature;
|
|
|
819
896
|
exports.getRoleCapabilities = getRoleCapabilities;
|
|
820
897
|
exports.getRoleDescription = getRoleDescription;
|
|
821
898
|
exports.getRoleDisplayName = getRoleDisplayName;
|
|
899
|
+
exports.getVariablesByContext = getVariablesByContext;
|
|
822
900
|
exports.isAdminRole = isAdminRole;
|
|
823
901
|
exports.isEncargadoRole = isEncargadoRole;
|
|
902
|
+
exports.isValidPeruvianPhone = isValidPeruvianPhone;
|
|
903
|
+
exports.normalizePhoneForEvolution = normalizePhoneForEvolution;
|
|
824
904
|
exports.templateGenerationRequestSchema = templateGenerationRequestSchema;
|
|
905
|
+
exports.validateVariablesInContext = validateVariablesInContext;
|
|
825
906
|
//# sourceMappingURL=index.js.map
|
|
826
907
|
//# sourceMappingURL=index.js.map
|