@gymspace/shared 1.2.21 → 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 +557 -521
- package/dist/index.d.ts +557 -521
- package/dist/index.js +268 -162
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +260 -163
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/constants/bulk-message-variables.ts +82 -22
- package/src/constants.ts +5 -0
- package/src/enums.ts +6 -0
- package/src/events/bulk-messaging.events.ts +19 -47
- package/src/index.ts +7 -4
- package/src/schemas/activity-notification.schema.ts +24 -0
- package/src/schemas/index.ts +1 -0
- package/src/types.ts +3 -0
- package/src/utils/phone.utils.ts +65 -0
package/dist/index.js
CHANGED
|
@@ -17,100 +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 ContractStatus = /* @__PURE__ */ ((ContractStatus2) => {
|
|
59
|
-
ContractStatus2["PENDING"] = "pending";
|
|
60
|
-
ContractStatus2["ACTIVE"] = "active";
|
|
61
|
-
ContractStatus2["EXPIRING_SOON"] = "expiring_soon";
|
|
62
|
-
ContractStatus2["EXPIRED"] = "expired";
|
|
63
|
-
ContractStatus2["CANCELLED"] = "cancelled";
|
|
64
|
-
ContractStatus2["FOR_RENEW"] = "for_renew";
|
|
65
|
-
ContractStatus2["SUSPENDED"] = "suspended";
|
|
66
|
-
ContractStatus2["GRACE_PERIOD"] = "grace_period";
|
|
67
|
-
ContractStatus2["TERMINATED"] = "terminated";
|
|
68
|
-
return ContractStatus2;
|
|
69
|
-
})(ContractStatus || {});
|
|
70
|
-
var CancellationReason = /* @__PURE__ */ ((CancellationReason2) => {
|
|
71
|
-
CancellationReason2["PRICE_TOO_HIGH"] = "PRICE_TOO_HIGH";
|
|
72
|
-
CancellationReason2["NOT_USING_SERVICE"] = "NOT_USING_SERVICE";
|
|
73
|
-
CancellationReason2["MOVING_LOCATION"] = "MOVING_LOCATION";
|
|
74
|
-
CancellationReason2["FINANCIAL_ISSUES"] = "FINANCIAL_ISSUES";
|
|
75
|
-
CancellationReason2["SERVICE_DISSATISFACTION"] = "SERVICE_DISSATISFACTION";
|
|
76
|
-
CancellationReason2["TEMPORARY_BREAK"] = "TEMPORARY_BREAK";
|
|
77
|
-
CancellationReason2["OTHER"] = "OTHER";
|
|
78
|
-
return CancellationReason2;
|
|
79
|
-
})(CancellationReason || {});
|
|
80
|
-
var SuspensionType = /* @__PURE__ */ ((SuspensionType2) => {
|
|
81
|
-
SuspensionType2["VACATION"] = "vacation";
|
|
82
|
-
SuspensionType2["MEDICAL"] = "medical";
|
|
83
|
-
SuspensionType2["FINANCIAL"] = "financial";
|
|
84
|
-
SuspensionType2["OTHER"] = "other";
|
|
85
|
-
return SuspensionType2;
|
|
86
|
-
})(SuspensionType || {});
|
|
87
|
-
var PaymentFrequency = /* @__PURE__ */ ((PaymentFrequency2) => {
|
|
88
|
-
PaymentFrequency2["MONTHLY"] = "monthly";
|
|
89
|
-
PaymentFrequency2["QUARTERLY"] = "quarterly";
|
|
90
|
-
PaymentFrequency2["ANNUAL"] = "annual";
|
|
91
|
-
return PaymentFrequency2;
|
|
92
|
-
})(PaymentFrequency || {});
|
|
93
|
-
var AssetStatus = /* @__PURE__ */ ((AssetStatus2) => {
|
|
94
|
-
AssetStatus2["ACTIVE"] = "active";
|
|
95
|
-
AssetStatus2["DELETED"] = "deleted";
|
|
96
|
-
return AssetStatus2;
|
|
97
|
-
})(AssetStatus || {});
|
|
98
|
-
var AssetCategory = /* @__PURE__ */ ((AssetCategory2) => {
|
|
99
|
-
AssetCategory2["MEDICAL_DOCUMENT"] = "medical_document";
|
|
100
|
-
AssetCategory2["IDENTIFICATION"] = "identification";
|
|
101
|
-
AssetCategory2["INSURANCE"] = "insurance";
|
|
102
|
-
AssetCategory2["CONTRACT_COPY"] = "contract_copy";
|
|
103
|
-
AssetCategory2["OTHER"] = "other";
|
|
104
|
-
return AssetCategory2;
|
|
105
|
-
})(AssetCategory || {});
|
|
106
|
-
var ContractAssetType = /* @__PURE__ */ ((ContractAssetType2) => {
|
|
107
|
-
ContractAssetType2["PAYMENT_RECEIPT"] = "payment_receipt";
|
|
108
|
-
ContractAssetType2["CONTRACT_DOCUMENT"] = "contract_document";
|
|
109
|
-
ContractAssetType2["IDENTIFICATION"] = "identification";
|
|
110
|
-
ContractAssetType2["OTHER"] = "other";
|
|
111
|
-
return ContractAssetType2;
|
|
112
|
-
})(ContractAssetType || {});
|
|
113
|
-
|
|
114
20
|
// src/constants/template-codes.constants.ts
|
|
115
21
|
var TEMPLATE_CODES = {
|
|
116
22
|
WELCOME: TemplateCode.WELCOME,
|
|
@@ -335,7 +241,36 @@ var BULK_MESSAGE_VARIABLES = [
|
|
|
335
241
|
required: false,
|
|
336
242
|
formatter: "currency"
|
|
337
243
|
},
|
|
338
|
-
// Variables de
|
|
244
|
+
// Variables de Fecha/Hora
|
|
245
|
+
{
|
|
246
|
+
name: "date",
|
|
247
|
+
placeholder: "{{date}}",
|
|
248
|
+
description: "Fecha actual",
|
|
249
|
+
example: "15/10/2024",
|
|
250
|
+
category: "datetime",
|
|
251
|
+
required: false,
|
|
252
|
+
formatter: "date"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: "time",
|
|
256
|
+
placeholder: "{{time}}",
|
|
257
|
+
description: "Hora actual",
|
|
258
|
+
example: "14:30",
|
|
259
|
+
category: "datetime",
|
|
260
|
+
required: false,
|
|
261
|
+
formatter: "text"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: "dayOfWeek",
|
|
265
|
+
placeholder: "{{dayOfWeek}}",
|
|
266
|
+
description: "D\xEDa de la semana",
|
|
267
|
+
example: "Lunes",
|
|
268
|
+
category: "datetime",
|
|
269
|
+
required: false,
|
|
270
|
+
formatter: "text"
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
var ACTIVITY_MESSAGE_VARIABLES = [
|
|
339
274
|
{
|
|
340
275
|
name: "activityName",
|
|
341
276
|
placeholder: "{{activityName}}",
|
|
@@ -399,35 +334,52 @@ var BULK_MESSAGE_VARIABLES = [
|
|
|
399
334
|
required: false,
|
|
400
335
|
formatter: "number"
|
|
401
336
|
},
|
|
402
|
-
// Variables de Fecha/Hora
|
|
403
337
|
{
|
|
404
|
-
name: "
|
|
405
|
-
placeholder: "{{
|
|
406
|
-
description: "
|
|
407
|
-
example: "
|
|
408
|
-
category: "
|
|
409
|
-
required: false,
|
|
410
|
-
formatter: "date"
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
name: "time",
|
|
414
|
-
placeholder: "{{time}}",
|
|
415
|
-
description: "Hora actual",
|
|
416
|
-
example: "14:30",
|
|
417
|
-
category: "datetime",
|
|
338
|
+
name: "activityLocation",
|
|
339
|
+
placeholder: "{{activityLocation}}",
|
|
340
|
+
description: "Ubicaci\xF3n de la actividad",
|
|
341
|
+
example: "Av. Principal 123",
|
|
342
|
+
category: "activity",
|
|
418
343
|
required: false,
|
|
419
344
|
formatter: "text"
|
|
420
345
|
},
|
|
421
346
|
{
|
|
422
|
-
name: "
|
|
423
|
-
placeholder: "{{
|
|
424
|
-
description: "
|
|
425
|
-
example: "
|
|
426
|
-
category: "
|
|
347
|
+
name: "timeUntilActivity",
|
|
348
|
+
placeholder: "{{timeUntilActivity}}",
|
|
349
|
+
description: "Tiempo restante hasta la actividad",
|
|
350
|
+
example: "2 horas",
|
|
351
|
+
category: "activity",
|
|
427
352
|
required: false,
|
|
428
353
|
formatter: "text"
|
|
429
354
|
}
|
|
430
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
|
+
}
|
|
431
383
|
var BULK_MESSAGE_VARIABLE_CATEGORIES = {
|
|
432
384
|
client: "Cliente",
|
|
433
385
|
gym: "Gimnasio",
|
|
@@ -532,6 +484,10 @@ var PERMISSIONS = {
|
|
|
532
484
|
COMMISSIONS_RULES_DELETE: "COMMISSIONS_RULES_DELETE",
|
|
533
485
|
COMMISSIONS_CALCULATIONS_READ: "COMMISSIONS_CALCULATIONS_READ",
|
|
534
486
|
COMMISSIONS_REPORTS_VIEW: "COMMISSIONS_REPORTS_VIEW",
|
|
487
|
+
// Catalog
|
|
488
|
+
CATALOG_READ: "CATALOG_READ",
|
|
489
|
+
CATALOG_UPDATE: "CATALOG_UPDATE",
|
|
490
|
+
CATALOG_MANAGE: "CATALOG_MANAGE",
|
|
535
491
|
// Special permissions
|
|
536
492
|
SUPER_ADMIN: "SUPER_ADMIN",
|
|
537
493
|
OWNER: "OWNER",
|
|
@@ -616,6 +572,163 @@ var HEADERS = {
|
|
|
616
572
|
REQUEST_ID: "X-Request-Id"
|
|
617
573
|
};
|
|
618
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
|
+
|
|
619
732
|
// src/utils/roleHelpers.ts
|
|
620
733
|
var RoleNames = /* @__PURE__ */ ((RoleNames2) => {
|
|
621
734
|
RoleNames2["ADMIN"] = "Admin";
|
|
@@ -707,55 +820,40 @@ function getRoleCapabilities(roleName) {
|
|
|
707
820
|
}
|
|
708
821
|
}
|
|
709
822
|
|
|
710
|
-
// src/
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
usedVariables: zod.z.array(zod.z.string()).describe("Variables utilizadas en el mensaje"),
|
|
742
|
-
suggestions: zod.z.array(zod.z.string()).optional().describe("Sugerencias adicionales")
|
|
743
|
-
});
|
|
744
|
-
var bulkMessageGenerationRequestSchema = zod.z.object({
|
|
745
|
-
prompt: zod.z.string().describe("Prompt or context for message generation"),
|
|
746
|
-
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).optional().describe("Tone of the message"),
|
|
747
|
-
includeVariables: zod.z.array(zod.z.string()).optional().describe("Variables to include in the message"),
|
|
748
|
-
additionalRequirements: zod.z.string().optional().describe("Additional requirements for the message"),
|
|
749
|
-
language: zod.z.string().default("es").describe("Language for generation")
|
|
750
|
-
});
|
|
751
|
-
var bulkMessageSchema = zod.z.object({
|
|
752
|
-
message: zod.z.string().describe("Generated message with variables"),
|
|
753
|
-
tone: zod.z.enum(["promotional", "informational", "reminder", "greeting", "friendly"]).describe("Tone of the message"),
|
|
754
|
-
usedVariables: zod.z.array(zod.z.string()).describe("Variables used in the message"),
|
|
755
|
-
suggestions: zod.z.array(zod.z.string()).optional().describe("Additional message suggestions")
|
|
756
|
-
});
|
|
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
|
+
}
|
|
757
854
|
|
|
758
855
|
exports.ACTIVITY_EVENTS = ACTIVITY_EVENTS;
|
|
856
|
+
exports.ACTIVITY_MESSAGE_VARIABLES = ACTIVITY_MESSAGE_VARIABLES;
|
|
759
857
|
exports.AssetCategory = AssetCategory;
|
|
760
858
|
exports.AssetStatus = AssetStatus;
|
|
761
859
|
exports.BULK_MESSAGE_VARIABLES = BULK_MESSAGE_VARIABLES;
|
|
@@ -775,6 +873,7 @@ exports.PAGINATION_DEFAULTS = PAGINATION_DEFAULTS;
|
|
|
775
873
|
exports.PERMISSIONS = PERMISSIONS;
|
|
776
874
|
exports.PaymentFrequency = PaymentFrequency;
|
|
777
875
|
exports.PlanStatus = PlanStatus;
|
|
876
|
+
exports.PlanType = PlanType;
|
|
778
877
|
exports.ROLE_NAMES = ROLE_NAMES;
|
|
779
878
|
exports.ROLE_PERMISSIONS = ROLE_PERMISSIONS;
|
|
780
879
|
exports.RoleNames = RoleNames;
|
|
@@ -785,8 +884,11 @@ exports.TEMPLATE_METADATA = TEMPLATE_METADATA;
|
|
|
785
884
|
exports.TemplateCode = TemplateCode;
|
|
786
885
|
exports.TemplateType = TemplateType;
|
|
787
886
|
exports.UserType = UserType;
|
|
887
|
+
exports.VARIABLE_CONTEXT_MAP = VARIABLE_CONTEXT_MAP;
|
|
788
888
|
exports.WHATSAPP_EVENTS = WHATSAPP_EVENTS;
|
|
789
889
|
exports.WHATSAPP_TEMPLATE_EVENTS = WHATSAPP_TEMPLATE_EVENTS;
|
|
890
|
+
exports.activityNotificationGenerationRequestSchema = activityNotificationGenerationRequestSchema;
|
|
891
|
+
exports.activityNotificationSchema = activityNotificationSchema;
|
|
790
892
|
exports.aiGeneratedTemplateSchema = aiGeneratedTemplateSchema;
|
|
791
893
|
exports.bulkMessageGenerationRequestSchema = bulkMessageGenerationRequestSchema;
|
|
792
894
|
exports.bulkMessageSchema = bulkMessageSchema;
|
|
@@ -794,8 +896,12 @@ exports.canAccessFeature = canAccessFeature;
|
|
|
794
896
|
exports.getRoleCapabilities = getRoleCapabilities;
|
|
795
897
|
exports.getRoleDescription = getRoleDescription;
|
|
796
898
|
exports.getRoleDisplayName = getRoleDisplayName;
|
|
899
|
+
exports.getVariablesByContext = getVariablesByContext;
|
|
797
900
|
exports.isAdminRole = isAdminRole;
|
|
798
901
|
exports.isEncargadoRole = isEncargadoRole;
|
|
902
|
+
exports.isValidPeruvianPhone = isValidPeruvianPhone;
|
|
903
|
+
exports.normalizePhoneForEvolution = normalizePhoneForEvolution;
|
|
799
904
|
exports.templateGenerationRequestSchema = templateGenerationRequestSchema;
|
|
905
|
+
exports.validateVariablesInContext = validateVariablesInContext;
|
|
800
906
|
//# sourceMappingURL=index.js.map
|
|
801
907
|
//# sourceMappingURL=index.js.map
|