@storecraft/mailer-providers-http 1.0.10 → 1.0.11

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.
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * @import { Config } from './types.public.js'
3
+ * @import { ENV } from '@storecraft/core';
3
4
  * @import { mailer } from '@storecraft/core/mailer'
4
5
  * @import {
5
6
  * Mailchimp_sendmail, Mailchimp_sendmail_message_attachment
@@ -8,6 +9,7 @@
8
9
 
9
10
  import { convert_to_base64 } from "./adapter.utils.js";
10
11
 
12
+
11
13
  /**
12
14
  * @description mailer with mail-chimp / mandrill http api
13
15
  *
@@ -15,6 +17,11 @@ import { convert_to_base64 } from "./adapter.utils.js";
15
17
  */
16
18
  export class MailChimp {
17
19
 
20
+ /** @satisfies {ENV<Config>} */
21
+ static EnvConfig = /** @type{const} */ ({
22
+ apikey: 'MAILCHIMP_API_KEY'
23
+ });
24
+
18
25
  /** @type {Config} */ #_config;
19
26
 
20
27
  /**
@@ -27,6 +34,11 @@ export class MailChimp {
27
34
 
28
35
  get config() { return this.#_config; }
29
36
 
37
+ /** @type {mailer<Config>["onInit"]} */
38
+ onInit = (app) => {
39
+ this.config.apikey ??= app.platform.env[MailChimp.EnvConfig.apikey];
40
+ };
41
+
30
42
  /**
31
43
  *
32
44
  * @type {mailer["email"]}
@@ -6,9 +6,9 @@ export { MailChimp } from './adapter.js';
6
6
  export type Config = {
7
7
 
8
8
  /**
9
- * @description Your API Key
9
+ * @description Your API Key, if missing, it will be inferred from environment variable `MAILCHIMP_API_KEY`
10
10
  */
11
- apikey: string,
11
+ apikey?: string,
12
12
 
13
13
  };
14
14
 
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * @import { Config } from './types.public.js'
3
3
  * @import { mailer } from '@storecraft/core/mailer'
4
+ * @import { ENV } from '@storecraft/core';
4
5
  * @import {
5
6
  * } from './types.private.js'
6
7
  */
7
8
  import { base64 } from "@storecraft/core/crypto";
8
9
  import { address_to_friendly_name, convert_attachment_to_blob } from "./adapter.utils.js";
9
10
 
11
+
10
12
  /**
11
13
  * @implements {mailer<Config>}
12
14
  *
@@ -14,6 +16,11 @@ import { address_to_friendly_name, convert_attachment_to_blob } from "./adapter.
14
16
  */
15
17
  export class Mailgun {
16
18
 
19
+ /** @satisfies {ENV<Config>} */
20
+ static EnvConfig = /** @type{const} */ ({
21
+ apikey: 'MAILGUN_API_KEY'
22
+ });
23
+
17
24
  /** @type {Config} */ #_config;
18
25
 
19
26
  /**
@@ -26,6 +33,11 @@ export class Mailgun {
26
33
 
27
34
  get config() { return this.#_config; }
28
35
 
36
+ /** @type {mailer<Config>["onInit"]} */
37
+ onInit = (app) => {
38
+ this.config.apikey ??= app.platform.env[Mailgun.EnvConfig.apikey];
39
+ };
40
+
29
41
  /**
30
42
  *
31
43
  * @type {mailer["email"]}
@@ -4,10 +4,10 @@ export { Mailgun } from './adapter.js';
4
4
  * @description `mailgun` config
5
5
  */
6
6
  export type Config = {
7
- /**
8
- * @description your mailgun api key
7
+ /**
8
+ * @description Your API Key, if missing, it will be inferred from environment variable `MAILGUN_API_KEY`
9
9
  */
10
- apikey: string,
10
+ apikey?: string,
11
11
 
12
12
  /**
13
13
  * @description your registered domain name at `mailgun`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storecraft/mailer-providers-http",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
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)",
package/resend/adapter.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * @import { Config } from './types.public.js'
3
3
  * @import { mailer } from '@storecraft/core/mailer'
4
+ * @import { ENV } from '@storecraft/core';
4
5
  * @import { Resend_sendmail, Resend_sendmail_attachment } from './types.private.js'
5
6
  */
6
7
 
@@ -13,18 +14,29 @@ import { address_to_friendly_name, convert_to_base64 } from "./adapter.utils.js"
13
14
  */
14
15
  export class Resend {
15
16
 
17
+ /** @satisfies {ENV<Config>} */
18
+ static EnvConfig = /** @type{const} */ ({
19
+ apikey: 'RESEND_API_KEY'
20
+ });
21
+
16
22
  /** @type {Config} */ #_config;
17
23
 
18
24
  /**
19
25
  *
20
26
  * @param {Config} config
21
27
  */
22
- constructor(config) {
28
+ constructor(config={}) {
23
29
  this.#_config = config;
24
30
  }
25
31
 
26
32
  get config() { return this.#_config; }
27
33
 
34
+
35
+ /** @type {mailer<Config>["onInit"]} */
36
+ onInit = (app) => {
37
+ this.config.apikey ??= app.platform.env[Resend.EnvConfig.apikey];
38
+ };
39
+
28
40
  /**
29
41
  *
30
42
  * @type {mailer["email"]}
@@ -5,8 +5,8 @@ export { Resend } from './adapter.js';
5
5
  */
6
6
  export type Config = {
7
7
  /**
8
- * @description Your API Key
8
+ * @description Your API Key, if missing, it will be inferred from environment variable `RESEND_API_KEY`
9
9
  */
10
- apikey: string,
10
+ apikey?: string,
11
11
  };
12
12
 
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * @import { Config } from './types.public.js'
3
+ * @import { ENV } from '@storecraft/core';
3
4
  * @import { mailer } from '@storecraft/core/mailer'
4
5
  * @import { SendgridV3_sendmail } from './types.private.js'
5
6
  */
@@ -12,18 +13,28 @@ import { convert_to_base64 } from "./adapter.utils.js";
12
13
  */
13
14
  export class SendGrid {
14
15
 
16
+ /** @satisfies {ENV<Config>} */
17
+ static EnvConfig = /** @type{const} */ ({
18
+ apikey: 'SENDGRID_API_KEY'
19
+ });
20
+
15
21
  /** @type {Config} */ #_config;
16
22
 
17
23
  /**
18
24
  *
19
25
  * @param {Config} config
20
26
  */
21
- constructor(config) {
27
+ constructor(config={}) {
22
28
  this.#_config = config;
23
29
  }
24
30
 
25
31
  get config() { return this.#_config; }
26
32
 
33
+ /** @type {mailer<Config>["onInit"]} */
34
+ onInit = (app) => {
35
+ this.config.apikey ??= app.platform.env[SendGrid.EnvConfig.apikey];
36
+ };
37
+
27
38
  /**
28
39
  *
29
40
  * @type {mailer["email"]}
@@ -6,9 +6,9 @@ export { SendGrid } from './adapter.js';
6
6
  export type Config = {
7
7
 
8
8
  /**
9
- * @description Your API Key
9
+ * @description Your API Key, if missing, it will be inferred from environment variable `SENDGRID_API_KEY`
10
10
  */
11
- apikey: string,
11
+ apikey?: string,
12
12
 
13
13
  };
14
14