@blackcode_sa/metaestetics-api 1.5.50 → 1.5.52
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/admin/index.d.mts +35 -37
- package/dist/admin/index.d.ts +35 -37
- package/dist/admin/index.js +109 -222
- package/dist/admin/index.mjs +109 -222
- package/package.json +1 -1
- package/src/admin/mailing/base.mailing.service.ts +99 -273
- package/src/admin/mailing/practitionerInvite/practitionerInvite.mailing.ts +64 -30
package/dist/admin/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Timestamp } from 'firebase/firestore';
|
|
2
2
|
import * as admin from 'firebase-admin';
|
|
3
3
|
import { Timestamp as Timestamp$1 } from 'firebase-admin/firestore';
|
|
4
|
-
import * as mailgun from 'mailgun-js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Enum for element types in documentation templates
|
|
@@ -1507,50 +1506,37 @@ declare class PatientAggregationService {
|
|
|
1507
1506
|
}
|
|
1508
1507
|
|
|
1509
1508
|
/**
|
|
1510
|
-
*
|
|
1511
|
-
* This
|
|
1509
|
+
* Minimal interface for the new mailgun.js client's messages API
|
|
1510
|
+
* This helps avoid a direct dependency on mailgun.js in the API package if not desired,
|
|
1511
|
+
* or provides clearer typing if it is.
|
|
1512
1512
|
*/
|
|
1513
|
-
interface
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1513
|
+
interface NewMailgunMessagesAPI$1 {
|
|
1514
|
+
create(domain: string, data: any): Promise<any>;
|
|
1515
|
+
}
|
|
1516
|
+
interface NewMailgunClient$1 {
|
|
1517
|
+
messages: NewMailgunMessagesAPI$1;
|
|
1518
1518
|
}
|
|
1519
1519
|
/**
|
|
1520
1520
|
* Base mailing service class that provides common functionality for all mailing services
|
|
1521
|
+
* This version is updated to expect a mailgun.js v10+ client.
|
|
1521
1522
|
*/
|
|
1522
1523
|
declare class BaseMailingService {
|
|
1523
1524
|
protected db: FirebaseFirestore.Firestore;
|
|
1524
|
-
protected mailgunClient:
|
|
1525
|
-
protected isNewMailgunClient: boolean;
|
|
1525
|
+
protected mailgunClient: NewMailgunClient$1;
|
|
1526
1526
|
/**
|
|
1527
1527
|
* Constructor for BaseMailingService
|
|
1528
1528
|
* @param firestore Firestore instance provided by the caller
|
|
1529
|
-
* @param mailgunClient Mailgun client instance provided by the caller
|
|
1530
|
-
*/
|
|
1531
|
-
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient: mailgun.Mailgun | MailgunClientCompat);
|
|
1532
|
-
/**
|
|
1533
|
-
* Validates that the Mailgun client is configured correctly
|
|
1534
|
-
* Particularly checks for EU region configuration
|
|
1529
|
+
* @param mailgunClient Mailgun client instance (mailgun.js v10+) provided by the caller
|
|
1535
1530
|
*/
|
|
1536
|
-
|
|
1531
|
+
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient: NewMailgunClient$1);
|
|
1537
1532
|
/**
|
|
1538
|
-
* Sends an email using Mailgun
|
|
1539
|
-
* @param
|
|
1533
|
+
* Sends an email using the new Mailgun client API.
|
|
1534
|
+
* @param domain The Mailgun domain to send from (e.g., mg.metaesthetics.net)
|
|
1535
|
+
* @param data Email data to send, compatible with mailgun.js messages.create API
|
|
1540
1536
|
* @returns Promise with the sending result
|
|
1541
1537
|
*/
|
|
1542
|
-
protected sendEmail(
|
|
1543
|
-
|
|
1544
|
-
* Tries to get domain from mailgun client options
|
|
1545
|
-
* @returns Domain string or undefined
|
|
1546
|
-
*/
|
|
1547
|
-
private getDomainFromOptions;
|
|
1548
|
-
/**
|
|
1549
|
-
* Extracts domain from an email address
|
|
1550
|
-
* @param email Email address
|
|
1551
|
-
* @returns Domain part or undefined
|
|
1552
|
-
*/
|
|
1553
|
-
private getDomainFromEmail;
|
|
1538
|
+
protected sendEmail(domain: string, // The new API requires the domain as the first argument to messages.create
|
|
1539
|
+
data: any): Promise<any>;
|
|
1554
1540
|
/**
|
|
1555
1541
|
* Logs email sending attempt to Firestore for tracking
|
|
1556
1542
|
* @param emailData Email data that was sent
|
|
@@ -1571,6 +1557,12 @@ declare class BaseMailingService {
|
|
|
1571
1557
|
protected renderTemplate(template: string, variables: Record<string, string>): string;
|
|
1572
1558
|
}
|
|
1573
1559
|
|
|
1560
|
+
interface NewMailgunMessagesAPI {
|
|
1561
|
+
create(domain: string, data: any): Promise<any>;
|
|
1562
|
+
}
|
|
1563
|
+
interface NewMailgunClient {
|
|
1564
|
+
messages: NewMailgunMessagesAPI;
|
|
1565
|
+
}
|
|
1574
1566
|
/**
|
|
1575
1567
|
* Interface for the data required to send a practitioner invitation email
|
|
1576
1568
|
*/
|
|
@@ -1600,36 +1592,42 @@ interface PractitionerInviteEmailData {
|
|
|
1600
1592
|
registrationUrl?: string;
|
|
1601
1593
|
customSubject?: string;
|
|
1602
1594
|
fromAddress?: string;
|
|
1595
|
+
mailgunDomain?: string;
|
|
1603
1596
|
};
|
|
1604
1597
|
}
|
|
1605
1598
|
/**
|
|
1606
|
-
* Service for sending practitioner invitation emails
|
|
1599
|
+
* Service for sending practitioner invitation emails, updated for mailgun.js v10+
|
|
1607
1600
|
*/
|
|
1608
1601
|
declare class PractitionerInviteMailingService extends BaseMailingService {
|
|
1609
1602
|
private readonly DEFAULT_REGISTRATION_URL;
|
|
1610
1603
|
private readonly DEFAULT_SUBJECT;
|
|
1611
|
-
private readonly
|
|
1604
|
+
private readonly DEFAULT_MAILGUN_DOMAIN;
|
|
1612
1605
|
/**
|
|
1613
1606
|
* Constructor for PractitionerInviteMailingService
|
|
1614
1607
|
* @param firestore Firestore instance provided by the caller
|
|
1615
|
-
* @param mailgunClient Mailgun client instance provided by the caller
|
|
1608
|
+
* @param mailgunClient Mailgun client instance (mailgun.js v10+) provided by the caller
|
|
1616
1609
|
*/
|
|
1617
|
-
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient:
|
|
1610
|
+
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient: NewMailgunClient);
|
|
1618
1611
|
/**
|
|
1619
1612
|
* Sends a practitioner invitation email
|
|
1620
1613
|
* @param data The practitioner invitation data
|
|
1621
1614
|
* @returns Promise resolved when email is sent
|
|
1622
1615
|
*/
|
|
1623
|
-
sendInvitationEmail(data: PractitionerInviteEmailData): Promise<
|
|
1616
|
+
sendInvitationEmail(data: PractitionerInviteEmailData): Promise<any>;
|
|
1624
1617
|
/**
|
|
1625
1618
|
* Handles the practitioner token creation event from Cloud Functions
|
|
1626
1619
|
* Fetches necessary data using defined types and collection constants,
|
|
1627
1620
|
* and sends the invitation email.
|
|
1628
1621
|
* @param tokenData The fully typed token object including its id
|
|
1629
1622
|
* @param fromAddress The 'from' email address to use, obtained from config
|
|
1623
|
+
* @param mailgunDomain The mailgun domain to use for sending
|
|
1630
1624
|
* @returns Promise resolved when the email is sent
|
|
1631
1625
|
*/
|
|
1632
|
-
handleTokenCreationEvent(tokenData: PractitionerToken,
|
|
1626
|
+
handleTokenCreationEvent(tokenData: PractitionerToken, mailgunConfig: {
|
|
1627
|
+
fromAddress: string;
|
|
1628
|
+
domain: string;
|
|
1629
|
+
registrationUrl?: string;
|
|
1630
|
+
}): Promise<void>;
|
|
1633
1631
|
}
|
|
1634
1632
|
|
|
1635
1633
|
/**
|
package/dist/admin/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Timestamp } from 'firebase/firestore';
|
|
2
2
|
import * as admin from 'firebase-admin';
|
|
3
3
|
import { Timestamp as Timestamp$1 } from 'firebase-admin/firestore';
|
|
4
|
-
import * as mailgun from 'mailgun-js';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Enum for element types in documentation templates
|
|
@@ -1507,50 +1506,37 @@ declare class PatientAggregationService {
|
|
|
1507
1506
|
}
|
|
1508
1507
|
|
|
1509
1508
|
/**
|
|
1510
|
-
*
|
|
1511
|
-
* This
|
|
1509
|
+
* Minimal interface for the new mailgun.js client's messages API
|
|
1510
|
+
* This helps avoid a direct dependency on mailgun.js in the API package if not desired,
|
|
1511
|
+
* or provides clearer typing if it is.
|
|
1512
1512
|
*/
|
|
1513
|
-
interface
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1513
|
+
interface NewMailgunMessagesAPI$1 {
|
|
1514
|
+
create(domain: string, data: any): Promise<any>;
|
|
1515
|
+
}
|
|
1516
|
+
interface NewMailgunClient$1 {
|
|
1517
|
+
messages: NewMailgunMessagesAPI$1;
|
|
1518
1518
|
}
|
|
1519
1519
|
/**
|
|
1520
1520
|
* Base mailing service class that provides common functionality for all mailing services
|
|
1521
|
+
* This version is updated to expect a mailgun.js v10+ client.
|
|
1521
1522
|
*/
|
|
1522
1523
|
declare class BaseMailingService {
|
|
1523
1524
|
protected db: FirebaseFirestore.Firestore;
|
|
1524
|
-
protected mailgunClient:
|
|
1525
|
-
protected isNewMailgunClient: boolean;
|
|
1525
|
+
protected mailgunClient: NewMailgunClient$1;
|
|
1526
1526
|
/**
|
|
1527
1527
|
* Constructor for BaseMailingService
|
|
1528
1528
|
* @param firestore Firestore instance provided by the caller
|
|
1529
|
-
* @param mailgunClient Mailgun client instance provided by the caller
|
|
1530
|
-
*/
|
|
1531
|
-
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient: mailgun.Mailgun | MailgunClientCompat);
|
|
1532
|
-
/**
|
|
1533
|
-
* Validates that the Mailgun client is configured correctly
|
|
1534
|
-
* Particularly checks for EU region configuration
|
|
1529
|
+
* @param mailgunClient Mailgun client instance (mailgun.js v10+) provided by the caller
|
|
1535
1530
|
*/
|
|
1536
|
-
|
|
1531
|
+
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient: NewMailgunClient$1);
|
|
1537
1532
|
/**
|
|
1538
|
-
* Sends an email using Mailgun
|
|
1539
|
-
* @param
|
|
1533
|
+
* Sends an email using the new Mailgun client API.
|
|
1534
|
+
* @param domain The Mailgun domain to send from (e.g., mg.metaesthetics.net)
|
|
1535
|
+
* @param data Email data to send, compatible with mailgun.js messages.create API
|
|
1540
1536
|
* @returns Promise with the sending result
|
|
1541
1537
|
*/
|
|
1542
|
-
protected sendEmail(
|
|
1543
|
-
|
|
1544
|
-
* Tries to get domain from mailgun client options
|
|
1545
|
-
* @returns Domain string or undefined
|
|
1546
|
-
*/
|
|
1547
|
-
private getDomainFromOptions;
|
|
1548
|
-
/**
|
|
1549
|
-
* Extracts domain from an email address
|
|
1550
|
-
* @param email Email address
|
|
1551
|
-
* @returns Domain part or undefined
|
|
1552
|
-
*/
|
|
1553
|
-
private getDomainFromEmail;
|
|
1538
|
+
protected sendEmail(domain: string, // The new API requires the domain as the first argument to messages.create
|
|
1539
|
+
data: any): Promise<any>;
|
|
1554
1540
|
/**
|
|
1555
1541
|
* Logs email sending attempt to Firestore for tracking
|
|
1556
1542
|
* @param emailData Email data that was sent
|
|
@@ -1571,6 +1557,12 @@ declare class BaseMailingService {
|
|
|
1571
1557
|
protected renderTemplate(template: string, variables: Record<string, string>): string;
|
|
1572
1558
|
}
|
|
1573
1559
|
|
|
1560
|
+
interface NewMailgunMessagesAPI {
|
|
1561
|
+
create(domain: string, data: any): Promise<any>;
|
|
1562
|
+
}
|
|
1563
|
+
interface NewMailgunClient {
|
|
1564
|
+
messages: NewMailgunMessagesAPI;
|
|
1565
|
+
}
|
|
1574
1566
|
/**
|
|
1575
1567
|
* Interface for the data required to send a practitioner invitation email
|
|
1576
1568
|
*/
|
|
@@ -1600,36 +1592,42 @@ interface PractitionerInviteEmailData {
|
|
|
1600
1592
|
registrationUrl?: string;
|
|
1601
1593
|
customSubject?: string;
|
|
1602
1594
|
fromAddress?: string;
|
|
1595
|
+
mailgunDomain?: string;
|
|
1603
1596
|
};
|
|
1604
1597
|
}
|
|
1605
1598
|
/**
|
|
1606
|
-
* Service for sending practitioner invitation emails
|
|
1599
|
+
* Service for sending practitioner invitation emails, updated for mailgun.js v10+
|
|
1607
1600
|
*/
|
|
1608
1601
|
declare class PractitionerInviteMailingService extends BaseMailingService {
|
|
1609
1602
|
private readonly DEFAULT_REGISTRATION_URL;
|
|
1610
1603
|
private readonly DEFAULT_SUBJECT;
|
|
1611
|
-
private readonly
|
|
1604
|
+
private readonly DEFAULT_MAILGUN_DOMAIN;
|
|
1612
1605
|
/**
|
|
1613
1606
|
* Constructor for PractitionerInviteMailingService
|
|
1614
1607
|
* @param firestore Firestore instance provided by the caller
|
|
1615
|
-
* @param mailgunClient Mailgun client instance provided by the caller
|
|
1608
|
+
* @param mailgunClient Mailgun client instance (mailgun.js v10+) provided by the caller
|
|
1616
1609
|
*/
|
|
1617
|
-
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient:
|
|
1610
|
+
constructor(firestore: FirebaseFirestore.Firestore, mailgunClient: NewMailgunClient);
|
|
1618
1611
|
/**
|
|
1619
1612
|
* Sends a practitioner invitation email
|
|
1620
1613
|
* @param data The practitioner invitation data
|
|
1621
1614
|
* @returns Promise resolved when email is sent
|
|
1622
1615
|
*/
|
|
1623
|
-
sendInvitationEmail(data: PractitionerInviteEmailData): Promise<
|
|
1616
|
+
sendInvitationEmail(data: PractitionerInviteEmailData): Promise<any>;
|
|
1624
1617
|
/**
|
|
1625
1618
|
* Handles the practitioner token creation event from Cloud Functions
|
|
1626
1619
|
* Fetches necessary data using defined types and collection constants,
|
|
1627
1620
|
* and sends the invitation email.
|
|
1628
1621
|
* @param tokenData The fully typed token object including its id
|
|
1629
1622
|
* @param fromAddress The 'from' email address to use, obtained from config
|
|
1623
|
+
* @param mailgunDomain The mailgun domain to use for sending
|
|
1630
1624
|
* @returns Promise resolved when the email is sent
|
|
1631
1625
|
*/
|
|
1632
|
-
handleTokenCreationEvent(tokenData: PractitionerToken,
|
|
1626
|
+
handleTokenCreationEvent(tokenData: PractitionerToken, mailgunConfig: {
|
|
1627
|
+
fromAddress: string;
|
|
1628
|
+
domain: string;
|
|
1629
|
+
registrationUrl?: string;
|
|
1630
|
+
}): Promise<void>;
|
|
1633
1631
|
}
|
|
1634
1632
|
|
|
1635
1633
|
/**
|