fix(mailgun): Normalize package scope and modernize Mailgun client: rename package to @apiclient.xyz/mailgun, update dependencies, refactor HTTP handling, fix types, update TS config and CI, refresh docs and tests

This commit is contained in:
2025-10-13 20:20:24 +00:00
parent 7a66f97700
commit cc62c24e7b
16 changed files with 10930 additions and 13401 deletions

View File

@@ -1,22 +1,22 @@
import { expect, tap } from '@pushrocks/tapbundle';
import { Qenv } from '@pushrocks/qenv';
import * as smartmail from '@pushrocks/smartmail';
import { expect, tap } from '@push.rocks/tapbundle';
import { Qenv } from '@push.rocks/qenv';
import * as smartmail from '@push.rocks/smartmail';
const testQenv = new Qenv('./', './.nogit');
import * as mailgun from '../ts/index.js';
import { IMailgunMessage } from '../ts/index.js';
import { type IMailgunMessage } from '../ts/index.js';
let testMailgunAccount: mailgun.MailgunAccount;
let testSmartmail: smartmail.Smartmail<IMailgunMessage>;
tap.test('should create a mailgun account', async () => {
testMailgunAccount = new mailgun.MailgunAccount({
apiToken: testQenv.getEnvVarOnDemand('MAILGUN_API_TOKEN'),
apiToken: await testQenv.getEnvVarOnDemand('MAILGUN_API_TOKEN'),
region: 'eu',
});
await testMailgunAccount.addSmtpCredentials(
testQenv.getEnvVarOnDemand('MAILGUN_SMTP_CREDENTIALS')
await testQenv.getEnvVarOnDemand('MAILGUN_SMTP_CREDENTIALS'),
);
expect(testMailgunAccount).toBeInstanceOf(mailgun.MailgunAccount);
});
@@ -31,7 +31,10 @@ tap.test('should create a smartmail', async () => {
});
tap.test('should send a smartmail', async () => {
await testMailgunAccount.sendSmartMail(testSmartmail, 'Sandbox Team <sandbox@mail.git.zone>');
await testMailgunAccount.sendSmartMail(
testSmartmail,
'Sandbox Team <sandbox@mail.git.zone>',
);
});
tap.test('should send a smartmail with empty body', async () => {
@@ -42,13 +45,13 @@ tap.test('should send a smartmail with empty body', async () => {
});
await testMailgunAccount.sendSmartMail(
emptyBodySmartmail,
'Sandbox Team <sandbox@mail.git.zone>'
'Sandbox Team <sandbox@mail.git.zone>',
);
});
tap.test('should retrieve a mail using a retrieval url', async () => {
const result = await testMailgunAccount.retrieveSmartMailFromMessageUrl(
'https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA=='
'https://sw.api.mailgun.net/v3/domains/mail.lossless.one/messages/AgMFnnnAKC8xp_dDa79LyoxhloxtaVmnRA==',
);
console.log(result);
@@ -56,7 +59,10 @@ tap.test('should retrieve a mail using a retrieval url', async () => {
if (false) {
result.options.subject = 'hi there. This is a testmail with attachment';
result.options.from = 'noreply@mail.lossless.com';
await testMailgunAccount.sendSmartMail(result, 'Sandbox Team <sandbox@mail.git.zone>');
await testMailgunAccount.sendSmartMail(
result,
'Sandbox Team <sandbox@mail.git.zone>',
);
}
});