@gymspace/shared 1.2.22 → 1.3.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/.tsbuildinfo +1 -0
- package/dist/index.d.mts +805 -782
- package/dist/index.d.ts +805 -782
- package/dist/index.js +254 -159
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +250 -160
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/constants/bulk-message-variables.ts +58 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/template-codes.constants.ts +13 -0
- package/src/events/bulk-messaging.events.ts +19 -47
- package/src/index.ts +7 -4
- package/src/types/whatsapp-templates.types.ts +16 -1
- package/src/utils/phone.utils.ts +65 -0
package/dist/index.js
CHANGED
|
@@ -10,113 +10,14 @@ var TemplateCode = {
|
|
|
10
10
|
MEMBERSHIP_EXPIRING: "MEMBERSHIP_EXPIRING",
|
|
11
11
|
PAYMENT_REMINDER: "PAYMENT_REMINDER",
|
|
12
12
|
BIRTHDAY: "BIRTHDAY",
|
|
13
|
-
PAYMENT_RECEIPT: "PAYMENT_RECEIPT"
|
|
13
|
+
PAYMENT_RECEIPT: "PAYMENT_RECEIPT",
|
|
14
|
+
SHARE_CATALOG: "SHARE_CATALOG"
|
|
14
15
|
};
|
|
15
16
|
var TemplateType = {
|
|
16
17
|
STATIC: "STATIC",
|
|
17
18
|
PROMPT: "PROMPT"
|
|
18
19
|
};
|
|
19
20
|
|
|
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
21
|
// src/constants/template-codes.constants.ts
|
|
121
22
|
var TEMPLATE_CODES = {
|
|
122
23
|
WELCOME: TemplateCode.WELCOME,
|
|
@@ -125,7 +26,8 @@ var TEMPLATE_CODES = {
|
|
|
125
26
|
MEMBERSHIP_EXPIRING: TemplateCode.MEMBERSHIP_EXPIRING,
|
|
126
27
|
PAYMENT_REMINDER: TemplateCode.PAYMENT_REMINDER,
|
|
127
28
|
BIRTHDAY: TemplateCode.BIRTHDAY,
|
|
128
|
-
PAYMENT_RECEIPT: TemplateCode.PAYMENT_RECEIPT
|
|
29
|
+
PAYMENT_RECEIPT: TemplateCode.PAYMENT_RECEIPT,
|
|
30
|
+
SHARE_CATALOG: TemplateCode.SHARE_CATALOG
|
|
129
31
|
};
|
|
130
32
|
var WHATSAPP_TEMPLATE_EVENTS = {
|
|
131
33
|
SEND_TEMPLATE: "whatsapp/template.send",
|
|
@@ -234,6 +136,18 @@ var TEMPLATE_METADATA = {
|
|
|
234
136
|
amount: "Q150.00",
|
|
235
137
|
paymentMethod: "Efectivo"
|
|
236
138
|
}
|
|
139
|
+
},
|
|
140
|
+
[TemplateCode.SHARE_CATALOG]: {
|
|
141
|
+
code: TemplateCode.SHARE_CATALOG,
|
|
142
|
+
title: "Compartir Cat\xE1logo",
|
|
143
|
+
description: "Mensaje para compartir cat\xE1logo de membres\xEDas",
|
|
144
|
+
icon: "Share2",
|
|
145
|
+
variables: ["clientName", "gymName", "urlCatalog"],
|
|
146
|
+
exampleValues: {
|
|
147
|
+
clientName: "Roberto G\xF3mez",
|
|
148
|
+
gymName: "GymSpace",
|
|
149
|
+
urlCatalog: "https://gymspace.app/catalog/gym-123"
|
|
150
|
+
}
|
|
237
151
|
}
|
|
238
152
|
};
|
|
239
153
|
|
|
@@ -433,8 +347,53 @@ var ACTIVITY_MESSAGE_VARIABLES = [
|
|
|
433
347
|
category: "activity",
|
|
434
348
|
required: false,
|
|
435
349
|
formatter: "number"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
name: "activityLocation",
|
|
353
|
+
placeholder: "{{activityLocation}}",
|
|
354
|
+
description: "Ubicaci\xF3n de la actividad",
|
|
355
|
+
example: "Av. Principal 123",
|
|
356
|
+
category: "activity",
|
|
357
|
+
required: false,
|
|
358
|
+
formatter: "text"
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: "timeUntilActivity",
|
|
362
|
+
placeholder: "{{timeUntilActivity}}",
|
|
363
|
+
description: "Tiempo restante hasta la actividad",
|
|
364
|
+
example: "2 horas",
|
|
365
|
+
category: "activity",
|
|
366
|
+
required: false,
|
|
367
|
+
formatter: "text"
|
|
436
368
|
}
|
|
437
369
|
];
|
|
370
|
+
var VARIABLE_CONTEXT_MAP = {
|
|
371
|
+
bulk: BULK_MESSAGE_VARIABLES,
|
|
372
|
+
activity: [...BULK_MESSAGE_VARIABLES, ...ACTIVITY_MESSAGE_VARIABLES],
|
|
373
|
+
event: BULK_MESSAGE_VARIABLES,
|
|
374
|
+
// Para futuros eventos
|
|
375
|
+
reminder: BULK_MESSAGE_VARIABLES
|
|
376
|
+
// Para futuros recordatorios
|
|
377
|
+
};
|
|
378
|
+
function getVariablesByContext(context) {
|
|
379
|
+
return VARIABLE_CONTEXT_MAP[context] || BULK_MESSAGE_VARIABLES;
|
|
380
|
+
}
|
|
381
|
+
function validateVariablesInContext(message, context) {
|
|
382
|
+
const variablePattern = /{{(\w+)}}/g;
|
|
383
|
+
const matches = message.matchAll(variablePattern);
|
|
384
|
+
const invalidVariables = [];
|
|
385
|
+
const validVariables = getVariablesByContext(context).map((v) => v.name);
|
|
386
|
+
for (const match of matches) {
|
|
387
|
+
const variableName = match[1];
|
|
388
|
+
if (!validVariables.includes(variableName)) {
|
|
389
|
+
invalidVariables.push(variableName);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return {
|
|
393
|
+
valid: invalidVariables.length === 0,
|
|
394
|
+
invalidVariables
|
|
395
|
+
};
|
|
396
|
+
}
|
|
438
397
|
var BULK_MESSAGE_VARIABLE_CATEGORIES = {
|
|
439
398
|
client: "Cliente",
|
|
440
399
|
gym: "Gimnasio",
|
|
@@ -627,6 +586,163 @@ var HEADERS = {
|
|
|
627
586
|
REQUEST_ID: "X-Request-Id"
|
|
628
587
|
};
|
|
629
588
|
|
|
589
|
+
// src/enums.ts
|
|
590
|
+
var UserType = /* @__PURE__ */ ((UserType2) => {
|
|
591
|
+
UserType2["OWNER"] = "owner";
|
|
592
|
+
UserType2["COLLABORATOR"] = "collaborator";
|
|
593
|
+
return UserType2;
|
|
594
|
+
})(UserType || {});
|
|
595
|
+
var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
|
|
596
|
+
SubscriptionStatus2["ACTIVE"] = "active";
|
|
597
|
+
SubscriptionStatus2["INACTIVE"] = "inactive";
|
|
598
|
+
SubscriptionStatus2["EXPIRED"] = "expired";
|
|
599
|
+
SubscriptionStatus2["PAUSED"] = "paused";
|
|
600
|
+
SubscriptionStatus2["PENDING_UPGRADE"] = "pending_upgrade";
|
|
601
|
+
return SubscriptionStatus2;
|
|
602
|
+
})(SubscriptionStatus || {});
|
|
603
|
+
var CollaboratorStatus = /* @__PURE__ */ ((CollaboratorStatus2) => {
|
|
604
|
+
CollaboratorStatus2["PENDING"] = "pending";
|
|
605
|
+
CollaboratorStatus2["ACTIVE"] = "active";
|
|
606
|
+
CollaboratorStatus2["INACTIVE"] = "inactive";
|
|
607
|
+
return CollaboratorStatus2;
|
|
608
|
+
})(CollaboratorStatus || {});
|
|
609
|
+
var InvitationStatus = /* @__PURE__ */ ((InvitationStatus2) => {
|
|
610
|
+
InvitationStatus2["PENDING"] = "pending";
|
|
611
|
+
InvitationStatus2["ACCEPTED"] = "accepted";
|
|
612
|
+
InvitationStatus2["CANCELLED"] = "cancelled";
|
|
613
|
+
InvitationStatus2["EXPIRED"] = "expired";
|
|
614
|
+
return InvitationStatus2;
|
|
615
|
+
})(InvitationStatus || {});
|
|
616
|
+
var ClientStatus = /* @__PURE__ */ ((ClientStatus2) => {
|
|
617
|
+
ClientStatus2["ACTIVE"] = "active";
|
|
618
|
+
ClientStatus2["INACTIVE"] = "inactive";
|
|
619
|
+
return ClientStatus2;
|
|
620
|
+
})(ClientStatus || {});
|
|
621
|
+
var PlanStatus = /* @__PURE__ */ ((PlanStatus2) => {
|
|
622
|
+
PlanStatus2["ACTIVE"] = "active";
|
|
623
|
+
PlanStatus2["INACTIVE"] = "inactive";
|
|
624
|
+
PlanStatus2["ARCHIVED"] = "archived";
|
|
625
|
+
return PlanStatus2;
|
|
626
|
+
})(PlanStatus || {});
|
|
627
|
+
var PlanType = /* @__PURE__ */ ((PlanType2) => {
|
|
628
|
+
PlanType2["BASIC"] = "BASIC";
|
|
629
|
+
PlanType2["PREMIUM"] = "PREMIUM";
|
|
630
|
+
PlanType2["ENTERPRISE"] = "ENTERPRISE";
|
|
631
|
+
return PlanType2;
|
|
632
|
+
})(PlanType || {});
|
|
633
|
+
var ContractStatus = /* @__PURE__ */ ((ContractStatus2) => {
|
|
634
|
+
ContractStatus2["PENDING"] = "pending";
|
|
635
|
+
ContractStatus2["ACTIVE"] = "active";
|
|
636
|
+
ContractStatus2["EXPIRING_SOON"] = "expiring_soon";
|
|
637
|
+
ContractStatus2["EXPIRED"] = "expired";
|
|
638
|
+
ContractStatus2["CANCELLED"] = "cancelled";
|
|
639
|
+
ContractStatus2["FOR_RENEW"] = "for_renew";
|
|
640
|
+
ContractStatus2["SUSPENDED"] = "suspended";
|
|
641
|
+
ContractStatus2["GRACE_PERIOD"] = "grace_period";
|
|
642
|
+
ContractStatus2["TERMINATED"] = "terminated";
|
|
643
|
+
return ContractStatus2;
|
|
644
|
+
})(ContractStatus || {});
|
|
645
|
+
var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
|
|
646
|
+
CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
|
|
647
|
+
CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
|
|
648
|
+
CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
|
|
649
|
+
CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
|
|
650
|
+
CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
|
|
651
|
+
CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
|
|
652
|
+
CancellationReason2["OTHER"] = "OTHER";
|
|
653
|
+
return CancellationReason2;
|
|
654
|
+
})(CancellationReason || {});
|
|
655
|
+
var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
|
|
656
|
+
SuspensionType2["VACATION"] = "vacation";
|
|
657
|
+
SuspensionType2["MEDICAL"] = "medical";
|
|
658
|
+
SuspensionType2["FINANCIAL"] = "financial";
|
|
659
|
+
SuspensionType2["OTHER"] = "other";
|
|
660
|
+
return SuspensionType2;
|
|
661
|
+
})(SuspensionType || {});
|
|
662
|
+
var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
|
|
663
|
+
PaymentFrequency2["MONTHLY"] = "monthly";
|
|
664
|
+
PaymentFrequency2["QUARTERLY"] = "quarterly";
|
|
665
|
+
PaymentFrequency2["ANNUAL"] = "annual";
|
|
666
|
+
return PaymentFrequency2;
|
|
667
|
+
})(PaymentFrequency || {});
|
|
668
|
+
var AssetStatus = /* @__PURE__ */ ((AssetStatus2) => {
|
|
669
|
+
AssetStatus2["ACTIVE"] = "active";
|
|
670
|
+
AssetStatus2["DELETED"] = "deleted";
|
|
671
|
+
return AssetStatus2;
|
|
672
|
+
})(AssetStatus || {});
|
|
673
|
+
var AssetCategory = /* @__PURE__ */ ((AssetCategory2) => {
|
|
674
|
+
AssetCategory2["MEDICAL_DOCUMENT"] = "medical_document";
|
|
675
|
+
AssetCategory2["IDENTIFICATION"] = "identification";
|
|
676
|
+
AssetCategory2["INSURANCE"] = "insurance";
|
|
677
|
+
AssetCategory2["CONTRACT_COPY"] = "contract_copy";
|
|
678
|
+
AssetCategory2["OTHER"] = "other";
|
|
679
|
+
return AssetCategory2;
|
|
680
|
+
})(AssetCategory || {});
|
|
681
|
+
var ContractAssetType = /* @__PURE__ */ ((ContractAssetType2) => {
|
|
682
|
+
ContractAssetType2["PAYMENT_RECEIPT"] = "payment_receipt";
|
|
683
|
+
ContractAssetType2["CONTRACT_DOCUMENT"] = "contract_document";
|
|
684
|
+
ContractAssetType2["IDENTIFICATION"] = "identification";
|
|
685
|
+
ContractAssetType2["OTHER"] = "other";
|
|
686
|
+
return ContractAssetType2;
|
|
687
|
+
})(ContractAssetType || {});
|
|
688
|
+
|
|
689
|
+
// src/events/whatsapp.events.ts
|
|
690
|
+
var WHATSAPP_EVENTS = {
|
|
691
|
+
MESSAGE_SEND: "whatsapp/message.send",
|
|
692
|
+
MESSAGE_RECEIVED: "whatsapp/message.received",
|
|
693
|
+
CONNECTION_UPDATE: "whatsapp/connection.update"
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
// src/events/bulk-messaging.events.ts
|
|
697
|
+
var BULK_MESSAGING_EVENTS = {
|
|
698
|
+
SEND_BULK_MESSAGES: "whatsapp/bulk-messages.send"
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
// src/events/activity.events.ts
|
|
702
|
+
var ACTIVITY_EVENTS = {
|
|
703
|
+
SEND_ACTIVITY_NOTIFICATION: "activity/notification.send"
|
|
704
|
+
};
|
|
705
|
+
var templateGenerationRequestSchema = zod.z.object({
|
|
706
|
+
templateCode: zod.z.string(),
|
|
707
|
+
templateMetadata: zod.z.object({
|
|
708
|
+
title: zod.z.string(),
|
|
709
|
+
description: zod.z.string(),
|
|
710
|
+
variables: zod.z.array(zod.z.string()),
|
|
711
|
+
exampleValues: zod.z.record(zod.z.string())
|
|
712
|
+
}),
|
|
713
|
+
userPrompt: zod.z.string().optional(),
|
|
714
|
+
language: zod.z.string().default("es")
|
|
715
|
+
});
|
|
716
|
+
var aiGeneratedTemplateSchema = zod.z.object({
|
|
717
|
+
message: zod.z.string().describe("Mensaje generado con variables en formato {{variable}}"),
|
|
718
|
+
tone: zod.z.enum(["professional", "friendly", "casual", "urgent"]).describe("Tono del mensaje"),
|
|
719
|
+
usedVariables: zod.z.array(zod.z.string()).describe("Variables utilizadas en el mensaje"),
|
|
720
|
+
suggestions: zod.z.array(zod.z.string()).optional().describe("Sugerencias adicionales")
|
|
721
|
+
});
|
|
722
|
+
var bulkMessageGenerationRequestSchema = zod.z.object({
|
|
723
|
+
prompt: zod.z.string().describe("Prompt or context for message generation"),
|
|
724
|
+
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).optional().describe("Tone of the message"),
|
|
725
|
+
includeVariables: zod.z.array(zod.z.string()).optional().describe("Variables to include in the message"),
|
|
726
|
+
additionalRequirements: zod.z.string().optional().describe("Additional requirements for the message"),
|
|
727
|
+
language: zod.z.string().default("es").describe("Language for generation")
|
|
728
|
+
});
|
|
729
|
+
var bulkMessageSchema = zod.z.object({
|
|
730
|
+
message: zod.z.string().describe("Generated message with variables"),
|
|
731
|
+
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).describe("Tone of the message"),
|
|
732
|
+
usedVariables: zod.z.array(zod.z.string()).describe("Variables used in the message"),
|
|
733
|
+
suggestions: zod.z.array(zod.z.string()).optional().describe("Additional message suggestions")
|
|
734
|
+
});
|
|
735
|
+
var activityNotificationGenerationRequestSchema = zod.z.object({
|
|
736
|
+
prompt: zod.z.string().describe("Prompt or context for notification generation"),
|
|
737
|
+
tone: zod.z.enum(["friendly", "formal", "urgent", "motivational", "reminder"]).optional().describe("Tone of the notification"),
|
|
738
|
+
currentMessage: zod.z.string().optional().describe("Current message to improve or use as reference"),
|
|
739
|
+
additionalRequirements: zod.z.string().optional().describe("Additional requirements for the notification"),
|
|
740
|
+
language: zod.z.string().default("es").describe("Language for generation")
|
|
741
|
+
});
|
|
742
|
+
var activityNotificationSchema = zod.z.object({
|
|
743
|
+
message: zod.z.string().describe("Generated notification message with activity variables")
|
|
744
|
+
});
|
|
745
|
+
|
|
630
746
|
// src/utils/roleHelpers.ts
|
|
631
747
|
var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
|
|
632
748
|
RoleNames2["ADMIN"] = "Admin";
|
|
@@ -718,63 +834,37 @@ function getRoleCapabilities(roleName) {
|
|
|
718
834
|
}
|
|
719
835
|
}
|
|
720
836
|
|
|
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
|
-
});
|
|
837
|
+
// src/utils/phone.utils.ts
|
|
838
|
+
function normalizePhoneForEvolution(phoneNumber) {
|
|
839
|
+
if (!phoneNumber) {
|
|
840
|
+
throw new Error("Phone number is required");
|
|
841
|
+
}
|
|
842
|
+
let cleaned = phoneNumber.replace(/[^\d+]/g, "");
|
|
843
|
+
if (cleaned.startsWith("+")) {
|
|
844
|
+
cleaned = cleaned.substring(1);
|
|
845
|
+
}
|
|
846
|
+
if (cleaned.length === 9) {
|
|
847
|
+
return `+51${cleaned}`;
|
|
848
|
+
}
|
|
849
|
+
if (cleaned.length === 11 && cleaned.startsWith("51")) {
|
|
850
|
+
return `+${cleaned}`;
|
|
851
|
+
}
|
|
852
|
+
if (cleaned.length === 12 && cleaned.startsWith("051")) {
|
|
853
|
+
return `+${cleaned.substring(1)}`;
|
|
854
|
+
}
|
|
855
|
+
if (!cleaned.startsWith("+")) {
|
|
856
|
+
return `+${cleaned}`;
|
|
857
|
+
}
|
|
858
|
+
return cleaned;
|
|
859
|
+
}
|
|
860
|
+
function isValidPeruvianPhone(phoneNumber) {
|
|
861
|
+
try {
|
|
862
|
+
const normalized = normalizePhoneForEvolution(phoneNumber);
|
|
863
|
+
return /^\+51[9]\d{8}$/.test(normalized);
|
|
864
|
+
} catch {
|
|
865
|
+
return false;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
778
868
|
|
|
779
869
|
exports.ACTIVITY_EVENTS = ACTIVITY_EVENTS;
|
|
780
870
|
exports.ACTIVITY_MESSAGE_VARIABLES = ACTIVITY_MESSAGE_VARIABLES;
|
|
@@ -808,6 +898,7 @@ exports.TEMPLATE_METADATA = TEMPLATE_METADATA;
|
|
|
808
898
|
exports.TemplateCode = TemplateCode;
|
|
809
899
|
exports.TemplateType = TemplateType;
|
|
810
900
|
exports.UserType = UserType;
|
|
901
|
+
exports.VARIABLE_CONTEXT_MAP = VARIABLE_CONTEXT_MAP;
|
|
811
902
|
exports.WHATSAPP_EVENTS = WHATSAPP_EVENTS;
|
|
812
903
|
exports.WHATSAPP_TEMPLATE_EVENTS = WHATSAPP_TEMPLATE_EVENTS;
|
|
813
904
|
exports.activityNotificationGenerationRequestSchema = activityNotificationGenerationRequestSchema;
|
|
@@ -819,8 +910,12 @@ exports.canAccessFeature = canAccessFeature;
|
|
|
819
910
|
exports.getRoleCapabilities = getRoleCapabilities;
|
|
820
911
|
exports.getRoleDescription = getRoleDescription;
|
|
821
912
|
exports.getRoleDisplayName = getRoleDisplayName;
|
|
913
|
+
exports.getVariablesByContext = getVariablesByContext;
|
|
822
914
|
exports.isAdminRole = isAdminRole;
|
|
823
915
|
exports.isEncargadoRole = isEncargadoRole;
|
|
916
|
+
exports.isValidPeruvianPhone = isValidPeruvianPhone;
|
|
917
|
+
exports.normalizePhoneForEvolution = normalizePhoneForEvolution;
|
|
824
918
|
exports.templateGenerationRequestSchema = templateGenerationRequestSchema;
|
|
919
|
+
exports.validateVariablesInContext = validateVariablesInContext;
|
|
825
920
|
//# sourceMappingURL=index.js.map
|
|
826
921
|
//# sourceMappingURL=index.js.map
|