@storecraft/mailer-providers-http 1.0.0 → 1.0.2
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/README.md +17 -8
- package/index.js +4 -4
- package/mailchimp/README.md +2 -2
- package/mailchimp/adapter.js +3 -3
- package/mailchimp/adapter.utils.js +2 -2
- package/{resend/tsconfig.json → mailchimp/jsconfig.json} +1 -4
- package/mailchimp/tests/test.js +2 -2
- package/mailchimp/types.public.d.ts +6 -2
- package/mailgun/README.md +2 -2
- package/mailgun/adapter.js +5 -5
- package/mailgun/adapter.utils.js +2 -2
- package/{mailchimp/tsconfig.json → mailgun/jsconfig.json} +1 -4
- package/mailgun/tests/test.js +2 -2
- package/mailgun/types.public.d.ts +9 -4
- package/package.json +6 -6
- package/resend/README.md +2 -2
- package/resend/adapter.js +4 -4
- package/resend/adapter.utils.js +3 -3
- package/{sendgrid/tsconfig.json → resend/jsconfig.json} +1 -4
- package/resend/tests/test.js +2 -2
- package/resend/types.public.d.ts +5 -2
- package/sendgrid/README.md +2 -2
- package/sendgrid/adapter.js +4 -4
- package/sendgrid/adapter.utils.js +2 -2
- package/{mailgun/tsconfig.json → sendgrid/jsconfig.json} +1 -4
- package/sendgrid/tests/test.js +2 -2
- package/sendgrid/types.public.d.ts +6 -2
- package/tsconfig.json +1 -0
- package/mailchimp/index.js +0 -1
- package/mailgun/index.js +0 -1
- package/resend/index.js +0 -1
- package/sendgrid/index.js +0 -1
package/README.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# `storecraft` Official serverless http email providers
|
2
2
|
|
3
|
+
<div style="text-align:center">
|
4
|
+
<img src='https://storecraft.app/storecraft-color.svg'
|
5
|
+
width='90%' />
|
6
|
+
</div><hr/><br/>
|
7
|
+
|
3
8
|
Supports wellknown http-based `serverless` friendly `email` providers,
|
4
9
|
|
5
10
|
- [Sendgrid](https://docs.sendgrid.com/api-reference/mail-send/mail-send)
|
@@ -9,14 +14,18 @@ Supports wellknown http-based `serverless` friendly `email` providers,
|
|
9
14
|
|
10
15
|
> TODO: confirm tests
|
11
16
|
|
17
|
+
```bash
|
18
|
+
npm i @storecraft/mailer-providers-http
|
19
|
+
```
|
20
|
+
|
12
21
|
## Howto
|
13
22
|
|
14
23
|
### Sendgrid
|
15
24
|
|
16
25
|
```js
|
17
|
-
import {
|
26
|
+
import { SendGrid } from '@storecraft/mailer-providers-http/sendgrid';
|
18
27
|
|
19
|
-
const mailer = new
|
28
|
+
const mailer = new SendGrid(
|
20
29
|
{
|
21
30
|
apikey: process.env.SEND_GRID_SECRET
|
22
31
|
}
|
@@ -35,9 +44,9 @@ let { success, native_response } = await mailer.email({
|
|
35
44
|
|
36
45
|
### Resend
|
37
46
|
```js
|
38
|
-
import {
|
47
|
+
import { Resend } from '@storecraft/mailer-providers-http/resend';
|
39
48
|
|
40
|
-
const mailer = new
|
49
|
+
const mailer = new Resend(
|
41
50
|
{
|
42
51
|
apikey: process.env.RESEND_API_KEY
|
43
52
|
}
|
@@ -57,9 +66,9 @@ let { success, native_response } = await mailer.email({
|
|
57
66
|
### Mailchimp
|
58
67
|
|
59
68
|
```js
|
60
|
-
import {
|
69
|
+
import { MailChimp } from '@storecraft/mailer-providers-http/mailchimp';
|
61
70
|
|
62
|
-
const mailer = new
|
71
|
+
const mailer = new MailChimp(
|
63
72
|
{
|
64
73
|
apikey: process.env.MAILCHIMP_API_KEY
|
65
74
|
}
|
@@ -79,9 +88,9 @@ let { success, native_response } = await mailer.email({
|
|
79
88
|
### Mailgun
|
80
89
|
|
81
90
|
```js
|
82
|
-
import {
|
91
|
+
import { Mailgun } from '@storecraft/mailer-providers-http/mailgun';
|
83
92
|
|
84
|
-
const mailer = new
|
93
|
+
const mailer = new Mailgun(
|
85
94
|
{
|
86
95
|
apikey: process.env.MAILGUN_API_KEY
|
87
96
|
}
|
package/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
export * as mailchimp from './mailchimp/
|
2
|
-
export * as mailgun from './mailgun/
|
3
|
-
export * as resend from './resend/
|
4
|
-
export * as sendgrid from './sendgrid/
|
1
|
+
export * as mailchimp from './mailchimp/adapter.js'
|
2
|
+
export * as mailgun from './mailgun/adapter.js'
|
3
|
+
export * as resend from './resend/adapter.js'
|
4
|
+
export * as sendgrid from './sendgrid/adapter.js'
|
package/mailchimp/README.md
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
## Howto
|
5
5
|
|
6
6
|
```js
|
7
|
-
import {
|
7
|
+
import { MailChimp } from '@storecraft/mailer-mailchimp-http';
|
8
8
|
|
9
|
-
const mailer = new
|
9
|
+
const mailer = new MailChimp(
|
10
10
|
{
|
11
11
|
apikey: process.env.MAILCHIMP_API_KEY
|
12
12
|
}
|
package/mailchimp/adapter.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import { convert_to_base64 } from "./adapter.utils.js";
|
2
2
|
|
3
3
|
/**
|
4
|
-
* @typedef {import("./types.public.
|
5
|
-
* @typedef {import('@storecraft/core/
|
4
|
+
* @typedef {import("./types.public.d.ts").Config} Config
|
5
|
+
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
6
6
|
* @implements {mailer}
|
7
7
|
*
|
8
8
|
* mailer with mail-chimp / mandrill http api
|
9
9
|
*/
|
10
|
-
export class
|
10
|
+
export class MailChimp {
|
11
11
|
|
12
12
|
/** @type {Config} */ #_config;
|
13
13
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { base64 } from '@storecraft/core/
|
1
|
+
import { base64 } from '@storecraft/core/crypto'
|
2
2
|
|
3
3
|
/**
|
4
|
-
* @param {import('@storecraft/core/
|
4
|
+
* @param {import('@storecraft/core/mailer').MailObject["attachments"][0]["content"]} c
|
5
5
|
*/
|
6
6
|
export const convert_to_base64 = async (c) => {
|
7
7
|
if(c instanceof ArrayBuffer)
|
@@ -1,11 +1,8 @@
|
|
1
1
|
{
|
2
|
-
"compileOnSave": false,
|
3
2
|
"compilerOptions": {
|
4
|
-
"noEmit": true,
|
5
|
-
"allowJs": true,
|
6
3
|
"checkJs": true,
|
4
|
+
"maxNodeModuleJsDepth": 10,
|
7
5
|
"target": "ESNext",
|
8
|
-
"resolveJsonModule": true,
|
9
6
|
"moduleResolution": "NodeNext",
|
10
7
|
"module": "NodeNext",
|
11
8
|
"composite": true,
|
package/mailchimp/tests/test.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import 'dotenv/config';
|
2
2
|
import { test } from 'uvu';
|
3
3
|
import * as assert from 'uvu/assert';
|
4
|
-
import {
|
4
|
+
import { MailChimp } from '../adapter.js';
|
5
5
|
|
6
|
-
const mailer = new
|
6
|
+
const mailer = new MailChimp(
|
7
7
|
{
|
8
8
|
apikey: process.env.MAILCHIMP_API_KEY
|
9
9
|
}
|
package/mailgun/README.md
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
## Howto
|
5
5
|
|
6
6
|
```js
|
7
|
-
import {
|
7
|
+
import { Mailgun } from '@storecraft/mailer-mailgun-http';
|
8
8
|
|
9
|
-
const mailer = new
|
9
|
+
const mailer = new Mailgun(
|
10
10
|
{
|
11
11
|
apikey: process.env.MAILGUN_API_KEY
|
12
12
|
}
|
package/mailgun/adapter.js
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
import { base64 } from "@storecraft/core/
|
1
|
+
import { base64 } from "@storecraft/core/crypto";
|
2
2
|
import { address_to_friendly_name, convert_attachment_to_blob } from "./adapter.utils.js";
|
3
3
|
|
4
4
|
/**
|
5
|
-
* @typedef {import("./types.public.
|
6
|
-
* @typedef {import('@storecraft/core/
|
5
|
+
* @typedef {import("./types.public.d.ts").Config} Config
|
6
|
+
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
7
7
|
* @implements {mailer}
|
8
8
|
*
|
9
|
-
* mailer with mailgun http api
|
9
|
+
* @description mailer with mailgun http api
|
10
10
|
*/
|
11
|
-
export class
|
11
|
+
export class Mailgun {
|
12
12
|
|
13
13
|
/** @type {Config} */ #_config;
|
14
14
|
|
package/mailgun/adapter.utils.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
/**
|
3
3
|
*
|
4
|
-
* @param {import('@storecraft/core/
|
4
|
+
* @param {import('@storecraft/core/mailer').MailObject["attachments"][0]["content"]} c
|
5
5
|
*/
|
6
6
|
export const convert_attachment_to_blob = async c => {
|
7
7
|
if(c instanceof ArrayBuffer)
|
@@ -27,7 +27,7 @@ export const convert_attachment_to_blob = async c => {
|
|
27
27
|
|
28
28
|
/**
|
29
29
|
*
|
30
|
-
* @param {import('@storecraft/core/
|
30
|
+
* @param {import('@storecraft/core/mailer').MailAddress} a
|
31
31
|
*/
|
32
32
|
export const address_to_friendly_name = a => {
|
33
33
|
return a.name ? `${a.name} <${a.address}>` : a.address;
|
@@ -1,11 +1,8 @@
|
|
1
1
|
{
|
2
|
-
"compileOnSave": false,
|
3
2
|
"compilerOptions": {
|
4
|
-
"noEmit": true,
|
5
|
-
"allowJs": true,
|
6
3
|
"checkJs": true,
|
4
|
+
"maxNodeModuleJsDepth": 10,
|
7
5
|
"target": "ESNext",
|
8
|
-
"resolveJsonModule": true,
|
9
6
|
"moduleResolution": "NodeNext",
|
10
7
|
"module": "NodeNext",
|
11
8
|
"composite": true,
|
package/mailgun/tests/test.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import 'dotenv/config';
|
2
2
|
import { test } from 'uvu';
|
3
3
|
import * as assert from 'uvu/assert';
|
4
|
-
import {
|
4
|
+
import { Mailgun } from '../adapter.js';
|
5
5
|
|
6
|
-
const mailer = new
|
6
|
+
const mailer = new Mailgun(
|
7
7
|
{
|
8
8
|
apikey: process.env.MAILGUN_API_KEY,
|
9
9
|
domain_name: process.env.YOUR_DOMAIN_NAME
|
@@ -1,12 +1,17 @@
|
|
1
|
-
export
|
1
|
+
export { Mailgun } from './adapter.js';
|
2
2
|
|
3
3
|
/**
|
4
|
-
* config
|
4
|
+
* @description `mailgun` config
|
5
5
|
*/
|
6
6
|
export type Config = {
|
7
|
-
/**
|
7
|
+
/**
|
8
|
+
* @description your mailgun api key
|
9
|
+
*/
|
8
10
|
apikey: string,
|
9
|
-
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @description your registered domain name at `mailgun`
|
14
|
+
*/
|
10
15
|
domain_name: string;
|
11
16
|
};
|
12
17
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storecraft/mailer-providers-http",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"description": "Official Serverless Friendly e-mail adapters for storecraft",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": "Tomer Shalev (https://github.com/store-craft)",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"repository": {
|
9
9
|
"type": "git",
|
10
10
|
"url": "https://github.com/store-craft/storecraft.git",
|
11
|
-
"directory": "packages/mailer-providers-http"
|
11
|
+
"directory": "packages/mailers/mailer-providers-http"
|
12
12
|
},
|
13
13
|
"keywords": [
|
14
14
|
"commerce",
|
@@ -29,19 +29,19 @@
|
|
29
29
|
},
|
30
30
|
"./package.json": "./package.json",
|
31
31
|
"./mailchimp": {
|
32
|
-
"import": "./mailchimp/
|
32
|
+
"import": "./mailchimp/adapter.js",
|
33
33
|
"types": "./mailchimp/types.public.d.ts"
|
34
34
|
},
|
35
35
|
"./mailgun": {
|
36
|
-
"import": "./mailgun/
|
36
|
+
"import": "./mailgun/adapter.js",
|
37
37
|
"types": "./mailgun/types.public.d.ts"
|
38
38
|
},
|
39
39
|
"./resend": {
|
40
|
-
"import": "./resend/
|
40
|
+
"import": "./resend/adapter.js",
|
41
41
|
"types": "./resend/types.public.d.ts"
|
42
42
|
},
|
43
43
|
"./sendgrid": {
|
44
|
-
"import": "./sendgrid/
|
44
|
+
"import": "./sendgrid/adapter.js",
|
45
45
|
"types": "./sendgrid/types.public.d.ts"
|
46
46
|
}
|
47
47
|
},
|
package/resend/README.md
CHANGED
package/resend/adapter.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import { address_to_friendly_name, convert_to_base64 } from "./adapter.utils.js";
|
2
2
|
|
3
3
|
/**
|
4
|
-
* @typedef {import("./types.public.
|
5
|
-
* @typedef {import('@storecraft/core/
|
4
|
+
* @typedef {import("./types.public.d.ts").Config} Config
|
5
|
+
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
6
6
|
* @implements {mailer}
|
7
7
|
*
|
8
|
-
* mailer with Resend rest api
|
8
|
+
* @description mailer with Resend rest api
|
9
9
|
*/
|
10
|
-
export class
|
10
|
+
export class Resend {
|
11
11
|
|
12
12
|
/** @type {Config} */ #_config;
|
13
13
|
|
package/resend/adapter.utils.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import { base64 } from '@storecraft/core/
|
1
|
+
import { base64 } from '@storecraft/core/crypto'
|
2
2
|
|
3
3
|
/**
|
4
4
|
*
|
5
|
-
* @param {import('@storecraft/core/
|
5
|
+
* @param {import('@storecraft/core/mailer').MailObject["attachments"][0]["content"]} c
|
6
6
|
*/
|
7
7
|
export const convert_to_base64 = async (c) => {
|
8
8
|
if(c instanceof ArrayBuffer)
|
@@ -28,7 +28,7 @@ export const convert_to_base64 = async (c) => {
|
|
28
28
|
|
29
29
|
/**
|
30
30
|
*
|
31
|
-
* @param {import('@storecraft/core/
|
31
|
+
* @param {import('@storecraft/core/mailer').MailAddress} a
|
32
32
|
*/
|
33
33
|
export const address_to_friendly_name = a => {
|
34
34
|
return a.name ? `${a.name} <${a.address}>` : a.address;
|
@@ -1,11 +1,8 @@
|
|
1
1
|
{
|
2
|
-
"compileOnSave": false,
|
3
2
|
"compilerOptions": {
|
4
|
-
"noEmit": true,
|
5
|
-
"allowJs": true,
|
6
3
|
"checkJs": true,
|
4
|
+
"maxNodeModuleJsDepth": 10,
|
7
5
|
"target": "ESNext",
|
8
|
-
"resolveJsonModule": true,
|
9
6
|
"moduleResolution": "NodeNext",
|
10
7
|
"module": "NodeNext",
|
11
8
|
"composite": true,
|
package/resend/tests/test.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import 'dotenv/config';
|
2
2
|
import { test } from 'uvu';
|
3
3
|
import * as assert from 'uvu/assert';
|
4
|
-
import {
|
4
|
+
import { Resend } from '../adapter.js';
|
5
5
|
|
6
|
-
const mailer = new
|
6
|
+
const mailer = new Resend(
|
7
7
|
{
|
8
8
|
apikey: process.env.RESEND_API_KEY
|
9
9
|
}
|
package/resend/types.public.d.ts
CHANGED
package/sendgrid/README.md
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
## Howto
|
5
5
|
|
6
6
|
```js
|
7
|
-
import {
|
7
|
+
import { SendGrid } from '@storecraft/mailer-sendgrid-http';
|
8
8
|
|
9
|
-
const mailer = new
|
9
|
+
const mailer = new SendGrid(
|
10
10
|
{
|
11
11
|
apikey: process.env.SEND_GRID_SECRET
|
12
12
|
}
|
package/sendgrid/adapter.js
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
import { convert_to_base64 } from "./adapter.utils.js";
|
2
2
|
|
3
3
|
/**
|
4
|
-
* @typedef {import("./types.public.
|
5
|
-
* @typedef {import('@storecraft/core/
|
4
|
+
* @typedef {import("./types.public.d.ts").Config} Config
|
5
|
+
* @typedef {import('@storecraft/core/mailer').mailer<Config>} mailer
|
6
6
|
* @implements {mailer}
|
7
7
|
*
|
8
|
-
* mailer with sendgrid http api
|
8
|
+
* @description mailer with sendgrid http api
|
9
9
|
*/
|
10
|
-
export class
|
10
|
+
export class SendGrid {
|
11
11
|
|
12
12
|
/** @type {Config} */ #_config;
|
13
13
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import { base64 } from '@storecraft/core/
|
1
|
+
import { base64 } from '@storecraft/core/crypto'
|
2
2
|
|
3
3
|
/**
|
4
4
|
*
|
5
|
-
* @param {import('@storecraft/core/
|
5
|
+
* @param {import('@storecraft/core/mailer').MailObject["attachments"][0]["content"]} c
|
6
6
|
*/
|
7
7
|
export const convert_to_base64 = async (c) => {
|
8
8
|
if(c instanceof ArrayBuffer)
|
@@ -1,11 +1,8 @@
|
|
1
1
|
{
|
2
|
-
"compileOnSave": false,
|
3
2
|
"compilerOptions": {
|
4
|
-
"noEmit": true,
|
5
|
-
"allowJs": true,
|
6
3
|
"checkJs": true,
|
4
|
+
"maxNodeModuleJsDepth": 10,
|
7
5
|
"target": "ESNext",
|
8
|
-
"resolveJsonModule": true,
|
9
6
|
"moduleResolution": "NodeNext",
|
10
7
|
"module": "NodeNext",
|
11
8
|
"composite": true,
|
package/sendgrid/tests/test.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import 'dotenv/config';
|
2
2
|
import { test } from 'uvu';
|
3
3
|
import * as assert from 'uvu/assert';
|
4
|
-
import {
|
4
|
+
import { SendGrid } from '../adapter.js';
|
5
5
|
|
6
|
-
const mailer = new
|
6
|
+
const mailer = new SendGrid(
|
7
7
|
{
|
8
8
|
apikey: process.env.SEND_GRID_SECRET
|
9
9
|
}
|
package/tsconfig.json
CHANGED
package/mailchimp/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './adapter.js'
|
package/mailgun/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './adapter.js'
|
package/resend/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './adapter.js'
|
package/sendgrid/index.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from './adapter.js'
|