@storecraft/mailer-providers-http 1.0.8 → 1.0.10
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/mailchimp/adapter.js +12 -6
- package/mailchimp/adapter.utils.js +4 -1
- package/mailgun/adapter.js +7 -3
- package/mailgun/adapter.utils.js +5 -2
- package/package.json +1 -1
- package/resend/adapter.js +10 -6
- package/resend/adapter.utils.js +5 -2
- package/sendgrid/adapter.js +8 -5
- package/sendgrid/adapter.utils.js +4 -1
package/mailchimp/adapter.js
CHANGED
@@ -1,11 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* @import { Config } from './types.public.js'
|
3
|
+
* @import { mailer } from '@storecraft/core/mailer'
|
4
|
+
* @import {
|
5
|
+
* Mailchimp_sendmail, Mailchimp_sendmail_message_attachment
|
6
|
+
* } from './types.private.js'
|
7
|
+
*/
|
8
|
+
|
1
9
|
import { convert_to_base64 } from "./adapter.utils.js";
|
2
10
|
|
3
11
|
/**
|
4
|
-
* @
|
5
|
-
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
6
|
-
* @implements {mailer}
|
12
|
+
* @description mailer with mail-chimp / mandrill http api
|
7
13
|
*
|
8
|
-
* mailer
|
14
|
+
* @implements {mailer<Config>}
|
9
15
|
*/
|
10
16
|
export class MailChimp {
|
11
17
|
|
@@ -27,7 +33,7 @@ export class MailChimp {
|
|
27
33
|
*/
|
28
34
|
async email(o) {
|
29
35
|
|
30
|
-
/** @type {
|
36
|
+
/** @type {Mailchimp_sendmail} */
|
31
37
|
const body = {
|
32
38
|
key: this.config.apikey,
|
33
39
|
message: {
|
@@ -40,7 +46,7 @@ export class MailChimp {
|
|
40
46
|
attachments: o.attachments && await Promise.all(
|
41
47
|
o.attachments.map(
|
42
48
|
/**
|
43
|
-
* @returns {Promise<
|
49
|
+
* @returns {Promise<Mailchimp_sendmail_message_attachment>}
|
44
50
|
*/
|
45
51
|
async a => ({
|
46
52
|
type: a.content_type,
|
@@ -1,7 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* @import { MailObject } from '@storecraft/core/mailer'
|
3
|
+
*/
|
1
4
|
import { base64 } from '@storecraft/core/crypto'
|
2
5
|
|
3
6
|
/**
|
4
|
-
* @param {
|
7
|
+
* @param {MailObject["attachments"][0]["content"]} c
|
5
8
|
*/
|
6
9
|
export const convert_to_base64 = async (c) => {
|
7
10
|
if(c instanceof ArrayBuffer)
|
package/mailgun/adapter.js
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* @import { Config } from './types.public.js'
|
3
|
+
* @import { mailer } from '@storecraft/core/mailer'
|
4
|
+
* @import {
|
5
|
+
* } from './types.private.js'
|
6
|
+
*/
|
1
7
|
import { base64 } from "@storecraft/core/crypto";
|
2
8
|
import { address_to_friendly_name, convert_attachment_to_blob } from "./adapter.utils.js";
|
3
9
|
|
4
10
|
/**
|
5
|
-
* @
|
6
|
-
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
7
|
-
* @implements {mailer}
|
11
|
+
* @implements {mailer<Config>}
|
8
12
|
*
|
9
13
|
* @description mailer with mailgun http api
|
10
14
|
*/
|
package/mailgun/adapter.utils.js
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
/**
|
2
|
+
* @import { MailAddress, MailObject } from '@storecraft/core/mailer'
|
3
|
+
*/
|
1
4
|
|
2
5
|
/**
|
3
6
|
*
|
4
|
-
* @param {
|
7
|
+
* @param {MailObject["attachments"][0]["content"]} c
|
5
8
|
*/
|
6
9
|
export const convert_attachment_to_blob = async c => {
|
7
10
|
if(c instanceof ArrayBuffer)
|
@@ -27,7 +30,7 @@ export const convert_attachment_to_blob = async c => {
|
|
27
30
|
|
28
31
|
/**
|
29
32
|
*
|
30
|
-
* @param {
|
33
|
+
* @param {MailAddress} a
|
31
34
|
*/
|
32
35
|
export const address_to_friendly_name = a => {
|
33
36
|
return a.name ? `${a.name} <${a.address}>` : a.address;
|
package/package.json
CHANGED
package/resend/adapter.js
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
* @import { Config } from './types.public.js'
|
3
|
+
* @import { mailer } from '@storecraft/core/mailer'
|
4
|
+
* @import { Resend_sendmail, Resend_sendmail_attachment } from './types.private.js'
|
5
|
+
*/
|
6
|
+
|
1
7
|
import { address_to_friendly_name, convert_to_base64 } from "./adapter.utils.js";
|
2
8
|
|
3
9
|
/**
|
4
|
-
* @typedef {import("./types.public.d.ts").Config} Config
|
5
|
-
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
6
|
-
* @implements {mailer}
|
7
|
-
*
|
8
10
|
* @description mailer with Resend rest api
|
11
|
+
*
|
12
|
+
* @implements {mailer<Config>}
|
9
13
|
*/
|
10
14
|
export class Resend {
|
11
15
|
|
@@ -27,7 +31,7 @@ export class Resend {
|
|
27
31
|
*/
|
28
32
|
async email(o) {
|
29
33
|
|
30
|
-
/** @type {
|
34
|
+
/** @type {Resend_sendmail} */
|
31
35
|
const body = {
|
32
36
|
from: address_to_friendly_name(o.from),
|
33
37
|
to: o.to.map(t => t.address),
|
@@ -37,7 +41,7 @@ export class Resend {
|
|
37
41
|
attachments: o.attachments && await Promise.all(
|
38
42
|
o.attachments.map(
|
39
43
|
/**
|
40
|
-
* @returns {Promise<
|
44
|
+
* @returns {Promise<Resend_sendmail_attachment>}
|
41
45
|
*/
|
42
46
|
async a => (
|
43
47
|
{
|
package/resend/adapter.utils.js
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* @import { MailAddress, mailer, MailObject } from '@storecraft/core/mailer'
|
3
|
+
*/
|
1
4
|
import { base64 } from '@storecraft/core/crypto'
|
2
5
|
|
3
6
|
/**
|
4
7
|
*
|
5
|
-
* @param {
|
8
|
+
* @param {MailObject["attachments"][0]["content"]} c
|
6
9
|
*/
|
7
10
|
export const convert_to_base64 = async (c) => {
|
8
11
|
if(c instanceof ArrayBuffer)
|
@@ -28,7 +31,7 @@ export const convert_to_base64 = async (c) => {
|
|
28
31
|
|
29
32
|
/**
|
30
33
|
*
|
31
|
-
* @param {
|
34
|
+
* @param {MailAddress} a
|
32
35
|
*/
|
33
36
|
export const address_to_friendly_name = a => {
|
34
37
|
return a.name ? `${a.name} <${a.address}>` : a.address;
|
package/sendgrid/adapter.js
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* @import { Config } from './types.public.js'
|
3
|
+
* @import { mailer } from '@storecraft/core/mailer'
|
4
|
+
* @import { SendgridV3_sendmail } from './types.private.js'
|
5
|
+
*/
|
1
6
|
import { convert_to_base64 } from "./adapter.utils.js";
|
2
7
|
|
3
8
|
/**
|
4
|
-
* @typedef {import("./types.public.d.ts").Config} Config
|
5
|
-
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
6
|
-
* @implements {mailer}
|
7
|
-
*
|
8
9
|
* @description mailer with sendgrid http api
|
10
|
+
*
|
11
|
+
* @implements {mailer<Config>}
|
9
12
|
*/
|
10
13
|
export class SendGrid {
|
11
14
|
|
@@ -27,7 +30,7 @@ export class SendGrid {
|
|
27
30
|
*/
|
28
31
|
async email(o) {
|
29
32
|
|
30
|
-
/** @type {
|
33
|
+
/** @type {SendgridV3_sendmail} */
|
31
34
|
const body = {
|
32
35
|
content: [
|
33
36
|
{
|
@@ -1,8 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* @import { mailer, MailObject } from '@storecraft/core/mailer'
|
3
|
+
*/
|
1
4
|
import { base64 } from '@storecraft/core/crypto'
|
2
5
|
|
3
6
|
/**
|
4
7
|
*
|
5
|
-
* @param {
|
8
|
+
* @param {MailObject["attachments"][0]["content"]} c
|
6
9
|
*/
|
7
10
|
export const convert_to_base64 = async (c) => {
|
8
11
|
if(c instanceof ArrayBuffer)
|