@strapi/email 5.59.0 → 5.60.0

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,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var _ = require('lodash');
3
+ var lodash = require('lodash');
4
4
  var utils = require('@strapi/utils');
5
5
 
6
6
  const { ApplicationError } = utils.errors;
@@ -59,7 +59,7 @@ const { ApplicationError } = utils.errors;
59
59
  // Get pool idle status if provider supports it
60
60
  const isIdle = typeof provider?.isIdle === 'function' ? provider.isIdle() : undefined;
61
61
  ctx.send({
62
- config: _.pick(config, [
62
+ config: lodash.pick(config, [
63
63
  'provider',
64
64
  'settings.defaultFrom',
65
65
  'settings.defaultReplyTo',
@@ -1 +1 @@
1
- {"version":3,"file":"email.js","sources":["../../../server/src/controllers/email.ts"],"sourcesContent":["import { pick } from 'lodash';\nimport { errors } from '@strapi/utils';\n\nimport type Koa from 'koa';\nimport type {} from 'koa-body';\nimport type { EmailConfig, SendOptions } from '../types';\n\nconst { ApplicationError } = errors;\n\n/**\n * Email.js controller\n *\n * @description: A set of functions called \"actions\" of the `email` plugin.\n */\nconst emailController = {\n async send(ctx: Koa.Context) {\n const options = ctx.request.body as SendOptions;\n\n try {\n await strapi.plugin('email').service('email').send(options);\n } catch (error) {\n if (error instanceof Error) {\n if ('statusCode' in error && error.statusCode === 400) {\n throw new ApplicationError(error.message);\n } else {\n throw new Error(`Couldn't send email: ${error.message}.`);\n }\n }\n }\n\n // Send 200 `ok`\n ctx.send({});\n },\n\n async test(ctx: Koa.Context) {\n const { to } = ctx.request.body as Pick<SendOptions, 'to'>;\n\n if (!to) {\n throw new ApplicationError('No recipient(s) are given');\n }\n\n const email: SendOptions = {\n to,\n subject: `Strapi test mail to: ${to}`,\n text: `Great! You have correctly configured the Strapi email plugin with the ${strapi.config.get(\n 'plugin::email.provider'\n )} provider. \\r\\nFor documentation on how to use the email plugin checkout: https://docs.strapi.io/developer-docs/latest/plugins/email.html`,\n };\n\n try {\n await strapi.plugin('email').service('email').send(email);\n } catch (error) {\n if (error instanceof Error) {\n if ('statusCode' in error && error.statusCode === 400) {\n throw new ApplicationError(error.message);\n } else {\n throw new Error(`Couldn't send test email: ${error.message}.`);\n }\n }\n }\n\n // Send 200 `ok`\n ctx.send({});\n },\n\n async getSettings(ctx: Koa.Context) {\n const config: EmailConfig = strapi.plugin('email').service('email').getProviderSettings();\n const provider = strapi.plugin('email').provider;\n\n // Check if provider supports verify method\n const supportsVerify = typeof provider?.verify === 'function';\n\n // Get capabilities from provider (e.g. SMTP host, auth type, features)\n const capabilities =\n typeof provider?.getCapabilities === 'function' ? provider.getCapabilities() : undefined;\n\n // Get pool idle status if provider supports it\n const isIdle = typeof provider?.isIdle === 'function' ? provider.isIdle() : undefined;\n\n ctx.send({\n config: pick(config, [\n 'provider',\n 'settings.defaultFrom',\n 'settings.defaultReplyTo',\n 'settings.testAddress',\n ]),\n supportsVerify,\n ...(capabilities ? { capabilities } : {}),\n ...(isIdle !== undefined ? { isIdle } : {}),\n });\n },\n\n async verify(ctx: Koa.Context) {\n const provider = strapi.plugin('email').provider;\n\n if (!provider?.verify || typeof provider.verify !== 'function') {\n throw new ApplicationError('This email provider does not support connection verification');\n }\n\n try {\n await provider.verify();\n ctx.send({ success: true, message: 'SMTP connection verified successfully' });\n } catch (error) {\n if (error instanceof Error) {\n throw new ApplicationError(`Connection verification failed: ${error.message}`);\n }\n throw new ApplicationError('Connection verification failed');\n }\n },\n};\n\nexport default emailController;\n"],"names":["ApplicationError","errors","emailController","send","ctx","options","request","body","strapi","plugin","service","error","Error","statusCode","message","test","to","email","subject","text","config","get","getSettings","getProviderSettings","provider","supportsVerify","verify","capabilities","getCapabilities","undefined","isIdle","pick","success"],"mappings":";;;;;AAOA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B;;;;AAIC,UACKC,eAAAA,GAAkB;AACtB,IAAA,MAAMC,MAAKC,GAAgB,EAAA;AACzB,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GAAY;AAAEC,gBAAAA;AAAO,aAAA,GAAI;AAC1C,SAAA,CAAA;AACF,IAAA,CAAA;AAEA,IAAA,MAAMJ,QAAOtB,GAAgB,EAAA;AAC3B,QAAA,MAAMoB,QAAAA,GAAWhB,MAAAA,CAAOC,MAAM,CAAC,SAASe,QAAQ;AAEhD,QAAA,IAAI,CAACA,QAAAA,EAAUE,MAAAA,IAAU,OAAOF,QAAAA,CAASE,MAAM,KAAK,UAAA,EAAY;AAC9D,YAAA,MAAM,IAAI1B,gBAAAA,CAAiB,8DAAA,CAAA;AAC7B,QAAA;QAEA,IAAI;AACF,YAAA,MAAMwB,SAASE,MAAM,EAAA;AACrBtB,YAAAA,GAAAA,CAAID,IAAI,CAAC;gBAAE6B,OAAAA,EAAS,IAAA;gBAAMlB,OAAAA,EAAS;AAAwC,aAAA,CAAA;AAC7E,QAAA,CAAA,CAAE,OAAOH,KAAAA,EAAO;AACd,YAAA,IAAIA,iBAAiBC,KAAAA,EAAO;AAC1B,gBAAA,MAAM,IAAIZ,gBAAAA,CAAiB,CAAC,gCAAgC,EAAEW,KAAAA,CAAMG,OAAO,CAAA,CAAE,CAAA;AAC/E,YAAA;AACA,YAAA,MAAM,IAAId,gBAAAA,CAAiB,gCAAA,CAAA;AAC7B,QAAA;AACF,IAAA;AACF;;;;"}
1
+ {"version":3,"file":"email.js","sources":["../../../server/src/controllers/email.ts"],"sourcesContent":["import { pick } from 'lodash';\nimport { errors } from '@strapi/utils';\n\nimport type Koa from 'koa';\nimport type {} from 'koa-body';\nimport type { EmailConfig, SendOptions } from '../types';\n\nconst { ApplicationError } = errors;\n\n/**\n * Email.js controller\n *\n * @description: A set of functions called \"actions\" of the `email` plugin.\n */\nconst emailController = {\n async send(ctx: Koa.Context) {\n const options = ctx.request.body as SendOptions;\n\n try {\n await strapi.plugin('email').service('email').send(options);\n } catch (error) {\n if (error instanceof Error) {\n if ('statusCode' in error && error.statusCode === 400) {\n throw new ApplicationError(error.message);\n } else {\n throw new Error(`Couldn't send email: ${error.message}.`);\n }\n }\n }\n\n // Send 200 `ok`\n ctx.send({});\n },\n\n async test(ctx: Koa.Context) {\n const { to } = ctx.request.body as Pick<SendOptions, 'to'>;\n\n if (!to) {\n throw new ApplicationError('No recipient(s) are given');\n }\n\n const email: SendOptions = {\n to,\n subject: `Strapi test mail to: ${to}`,\n text: `Great! You have correctly configured the Strapi email plugin with the ${strapi.config.get(\n 'plugin::email.provider'\n )} provider. \\r\\nFor documentation on how to use the email plugin checkout: https://docs.strapi.io/developer-docs/latest/plugins/email.html`,\n };\n\n try {\n await strapi.plugin('email').service('email').send(email);\n } catch (error) {\n if (error instanceof Error) {\n if ('statusCode' in error && error.statusCode === 400) {\n throw new ApplicationError(error.message);\n } else {\n throw new Error(`Couldn't send test email: ${error.message}.`);\n }\n }\n }\n\n // Send 200 `ok`\n ctx.send({});\n },\n\n async getSettings(ctx: Koa.Context) {\n const config: EmailConfig = strapi.plugin('email').service('email').getProviderSettings();\n const provider = strapi.plugin('email').provider;\n\n // Check if provider supports verify method\n const supportsVerify = typeof provider?.verify === 'function';\n\n // Get capabilities from provider (e.g. SMTP host, auth type, features)\n const capabilities =\n typeof provider?.getCapabilities === 'function' ? provider.getCapabilities() : undefined;\n\n // Get pool idle status if provider supports it\n const isIdle = typeof provider?.isIdle === 'function' ? provider.isIdle() : undefined;\n\n ctx.send({\n config: pick(config, [\n 'provider',\n 'settings.defaultFrom',\n 'settings.defaultReplyTo',\n 'settings.testAddress',\n ]),\n supportsVerify,\n ...(capabilities ? { capabilities } : {}),\n ...(isIdle !== undefined ? { isIdle } : {}),\n });\n },\n\n async verify(ctx: Koa.Context) {\n const provider = strapi.plugin('email').provider;\n\n if (!provider?.verify || typeof provider.verify !== 'function') {\n throw new ApplicationError('This email provider does not support connection verification');\n }\n\n try {\n await provider.verify();\n ctx.send({ success: true, message: 'SMTP connection verified successfully' });\n } catch (error) {\n if (error instanceof Error) {\n throw new ApplicationError(`Connection verification failed: ${error.message}`);\n }\n throw new ApplicationError('Connection verification failed');\n }\n },\n};\n\nexport default emailController;\n"],"names":["ApplicationError","errors","emailController","send","ctx","options","request","body","strapi","plugin","service","error","Error","statusCode","message","test","to","email","subject","text","config","get","getSettings","getProviderSettings","provider","supportsVerify","verify","capabilities","getCapabilities","undefined","isIdle","pick","success"],"mappings":";;;;;AAOA,MAAM,EAAEA,gBAAgB,EAAE,GAAGC,YAAAA;AAE7B;;;;AAIC,UACKC,eAAAA,GAAkB;AACtB,IAAA,MAAMC,MAAKC,GAAgB,EAAA;AACzB,QAAA,MAAMC,OAAAA,GAAUD,GAAAA,CAAIE,OAAO,CAACC,IAAI;QAEhC,IAAI;YACF,MAAMC,MAAAA,CAAOC,MAAM,CAAC,OAAA,CAAA,CAASC,OAAO,CAAC,OAAA,CAAA,CAASP,IAAI,CAACE,OAAAA,CAAAA;AACrD,QAAA,CAAA,CAAE,OAAOM,KAAAA,EAAO;AACd,YAAA,IAAIA,iBAAiBC,KAAAA,EAAO;AAC1B,gBAAA,IAAI,YAAA,IAAgBD,KAAAA,IAASA,KAAAA,CAAME,UAAU,KAAK,GAAA,EAAK;oBACrD,MAAM,IAAIb,gBAAAA,CAAiBW,KAAAA,CAAMG,OAAO,CAAA;gBAC1C,CAAA,MAAO;oBACL,MAAM,IAAIF,MAAM,CAAC,qBAAqB,EAAED,KAAAA,CAAMG,OAAO,CAAC,CAAC,CAAC,CAAA;AAC1D,gBAAA;AACF,YAAA;AACF,QAAA;;QAGAV,GAAAA,CAAID,IAAI,CAAC,EAAC,CAAA;AACZ,IAAA,CAAA;AAEA,IAAA,MAAMY,MAAKX,GAAgB,EAAA;AACzB,QAAA,MAAM,EAAEY,EAAE,EAAE,GAAGZ,GAAAA,CAAIE,OAAO,CAACC,IAAI;AAE/B,QAAA,IAAI,CAACS,EAAAA,EAAI;AACP,YAAA,MAAM,IAAIhB,gBAAAA,CAAiB,2BAAA,CAAA;AAC7B,QAAA;AAEA,QAAA,MAAMiB,KAAAA,GAAqB;AACz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');
4
+ var lodash = require('lodash');
5
5
 
6
6
  const { RateLimitError } = utils.errors;
7
7
  var rateLimit = ((config, { strapi })=>async (ctx, next)=>{
@@ -14,8 +14,8 @@ var rateLimit = ((config, { strapi })=>async (ctx, next)=>{
14
14
  // TODO: TS - Do the dynamic import
15
15
  // eslint-disable-next-line @typescript-eslint/no-var-requires
16
16
  const rateLimit = require('koa2-ratelimit').RateLimit;
17
- const requestEmail = _.get(ctx, 'request.body.email');
18
- const userEmail = _.isString(requestEmail) ? requestEmail.toLowerCase() : 'unknownEmail';
17
+ const requestEmail = lodash.get(ctx, 'request.body.email');
18
+ const userEmail = lodash.isString(requestEmail) ? requestEmail.toLowerCase() : 'unknownEmail';
19
19
  const loadConfig = {
20
20
  interval: {
21
21
  min: 5
@@ -1 +1 @@
1
- {"version":3,"file":"rateLimit.js","sources":["../../../server/src/middlewares/rateLimit.ts"],"sourcesContent":["import type { Context, Next } from 'koa';\nimport { errors } from '@strapi/utils';\nimport { get, isString } from 'lodash';\nimport type { Core } from '@strapi/types';\n\nconst { RateLimitError } = errors;\n\nexport default (config: any, { strapi }: { strapi: Core.Strapi }) =>\n async (ctx: Context, next: Next) => {\n const pluginConfig = strapi.config.get('plugin::email') as any;\n const rateLimitConfig = {\n enabled: true,\n ...pluginConfig.ratelimit,\n };\n\n if (rateLimitConfig.enabled === true) {\n // TODO: TS - Do the dynamic import\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const rateLimit = require('koa2-ratelimit').RateLimit;\n\n const requestEmail = get(ctx, 'request.body.email');\n const userEmail = isString(requestEmail) ? requestEmail.toLowerCase() : 'unknownEmail';\n\n const loadConfig = {\n interval: { min: 5 },\n max: 5,\n prefixKey: `${userEmail}`,\n handler() {\n throw new RateLimitError();\n },\n ...rateLimitConfig,\n ...config,\n };\n\n return rateLimit.middleware(loadConfig)(ctx, next);\n }\n\n return next();\n };\n"],"names":["RateLimitError","errors","config","strapi","ctx","next","pluginConfig","get","rateLimitConfig","enabled","ratelimit","rateLimit","require","RateLimit","requestEmail","userEmail","isString","toLowerCase","loadConfig","interval","min","max","prefixKey","handler","middleware"],"mappings":";;;;;AAKA,MAAM,EAAEA,cAAc,EAAE,GAAGC,YAAAA;AAE3B,gBAAe,CAAA,CAACC,MAAAA,EAAa,EAAEC,MAAM,EAA2B,GAC9D,OAAOC,GAAAA,EAAcC,IAAAA,GAAAA;AACnB,QAAA,MAAMC,YAAAA,GAAeH,MAAAA,CAAOD,MAAM,CAACK,GAAG,CAAC,eAAA,CAAA;AACvC,QAAA,MAAMC,eAAAA,GAAkB;YACtBC,OAAAA,EAAS,IAAA;AACT,YAAA,GAAGH,aAAaI;AAClB,SAAA;QAEA,IAAIF,eAAAA,CAAgBC,OAAO,KAAK,IAAA,EAAM;;;YAGpC,MAAME,SAAAA,GAAYC,OAAAA,CAAQ,gBAAA,CAAA,CAAkBC,SAAS;YAErD,MAAMC,YAAAA,GAAeP,MAAIH,GAAAA,EAAK,oBAAA,CAAA;AAC9B,YAAA,MAAMW,SAAAA,GAAYC,UAAAA,CAASF,YAAAA,CAAAA,GAAgBA,YAAAA,CAAaG,WAAW,EAAA,GAAK,cAAA;AAExE,YAAA,MAAMC,UAAAA,GAAa;gBACjBC,QAAAA,EAAU;oBAAEC,GAAAA,EAAK;AAAE,iBAAA;gBACnBC,GAAAA,EAAK,CAAA;AACLC,gBAAAA,SAAAA,EAAW,GAAGP,SAAAA,CAAAA,CAAW;AACzBQ,gBAAAA,OAAAA,CAAAA,GAAAA;AACE,oBAAA,MAAM,IAAIvB,cAAAA,EAAAA;AACZ,gBAAA,CAAA;AACA,gBAAA,GAAGQ,eAAe;AAClB,gBAAA,GAAGN;AACL,aAAA;AAEA,YAAA,OAAOS,SAAAA,CAAUa,UAAU,CAACN,UAAAA,CAAAA,CAAYd,GAAAA,EAAKC,IAAAA,CAAAA;AAC/C,QAAA;QAEA,OAAOA,IAAAA,EAAAA;AACT,IAAA,CAAA;;;;"}
1
+ {"version":3,"file":"rateLimit.js","sources":["../../../server/src/middlewares/rateLimit.ts"],"sourcesContent":["import type { Context, Next } from 'koa';\nimport { errors } from '@strapi/utils';\nimport { get, isString } from 'lodash';\nimport type { Core } from '@strapi/types';\n\nconst { RateLimitError } = errors;\n\nexport default (config: any, { strapi }: { strapi: Core.Strapi }) =>\n async (ctx: Context, next: Next) => {\n const pluginConfig = strapi.config.get('plugin::email') as any;\n const rateLimitConfig = {\n enabled: true,\n ...pluginConfig.ratelimit,\n };\n\n if (rateLimitConfig.enabled === true) {\n // TODO: TS - Do the dynamic import\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const rateLimit = require('koa2-ratelimit').RateLimit;\n\n const requestEmail = get(ctx, 'request.body.email');\n const userEmail = isString(requestEmail) ? requestEmail.toLowerCase() : 'unknownEmail';\n\n const loadConfig = {\n interval: { min: 5 },\n max: 5,\n prefixKey: `${userEmail}`,\n handler() {\n throw new RateLimitError();\n },\n ...rateLimitConfig,\n ...config,\n };\n\n return rateLimit.middleware(loadConfig)(ctx, next);\n }\n\n return next();\n };\n"],"names":["RateLimitError","errors","config","strapi","ctx","next","pluginConfig","get","rateLimitConfig","enabled","ratelimit","rateLimit","require","RateLimit","requestEmail","userEmail","isString","toLowerCase","loadConfig","interval","min","max","prefixKey","handler","middleware"],"mappings":";;;;;AAKA,MAAM,EAAEA,cAAc,EAAE,GAAGC,YAAAA;AAE3B,gBAAe,CAAA,CAACC,MAAAA,EAAa,EAAEC,MAAM,EAA2B,GAC9D,OAAOC,GAAAA,EAAcC,IAAAA,GAAAA;AACnB,QAAA,MAAMC,YAAAA,GAAeH,MAAAA,CAAOD,MAAM,CAACK,GAAG,CAAC,eAAA,CAAA;AACvC,QAAA,MAAMC,eAAAA,GAAkB;YACtBC,OAAAA,EAAS,IAAA;AACT,YAAA,GAAGH,aAAaI;AAClB,SAAA;QAEA,IAAIF,eAAAA,CAAgBC,OAAO,KAAK,IAAA,EAAM;;;YAGpC,MAAME,SAAAA,GAAYC,OAAAA,CAAQ,gBAAA,CAAA,CAAkBC,SAAS;YAErD,MAAMC,YAAAA,GAAeP,WAAIH,GAAAA,EAAK,oBAAA,CAAA;AAC9B,YAAA,MAAMW,SAAAA,GAAYC,eAAAA,CAASF,YAAAA,CAAAA,GAAgBA,YAAAA,CAAaG,WAAW,EAAA,GAAK,cAAA;AAExE,YAAA,MAAMC,UAAAA,GAAa;gBACjBC,QAAAA,EAAU;oBAAEC,GAAAA,EAAK;AAAE,iBAAA;gBACnBC,GAAAA,EAAK,CAAA;AACLC,gBAAAA,SAAAA,EAAW,GAAGP,SAAAA,CAAAA,CAAW;AACzBQ,gBAAAA,OAAAA,CAAAA,GAAAA;AACE,oBAAA,MAAM,IAAIvB,cAAAA,EAAAA;AACZ,gBAAA,CAAA;AACA,gBAAA,GAAGQ,eAAe;AAClB,gBAAA,GAAGN;AACL,aAAA;AAEA,YAAA,OAAOS,SAAAA,CAAUa,UAAU,CAACN,UAAAA,CAAAA,CAAYd,GAAAA,EAAKC,IAAAA,CAAAA;AAC/C,QAAA;QAEA,OAAOA,IAAAA,EAAAA;AACT,IAAA,CAAA;;;;"}
@@ -1,28 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var _ = require('lodash');
3
+ var lodash = require('lodash');
4
4
  var utils = require('@strapi/utils');
5
5
 
6
- function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
-
24
- var ___namespace = /*#__PURE__*/_interopNamespace(_);
25
-
26
6
  const { createStrictInterpolationRegExp } = utils.template;
27
7
  const getProviderSettings = ()=>strapi.config.get('plugin::email');
28
8
  const send = async (options)=>strapi.plugin('email').provider.send(options);
@@ -38,14 +18,14 @@ const send = async (options)=>strapi.plugin('email').provider.send(options);
38
18
  'text',
39
19
  'html'
40
20
  ];
41
- const missingAttributes = ___namespace.difference(attributes, Object.keys(emailTemplate));
21
+ const missingAttributes = lodash.difference(attributes, Object.keys(emailTemplate));
42
22
  if (missingAttributes.length > 0) {
43
23
  throw new Error(`Following attributes are missing from your email template : ${missingAttributes.join(', ')}`);
44
24
  }
45
25
  const allowedInterpolationVariables = utils.objects.keysDeep(data);
46
26
  const interpolate = createStrictInterpolationRegExp(allowedInterpolationVariables, 'g');
47
27
  const templatedAttributes = attributes.reduce((compiled, attribute)=>emailTemplate[attribute] ? Object.assign(compiled, {
48
- [attribute]: ___namespace.template(emailTemplate[attribute], {
28
+ [attribute]: lodash.template(emailTemplate[attribute], {
49
29
  interpolate
50
30
  })(data)
51
31
  }) : compiled, {});
@@ -1 +1 @@
1
- {"version":3,"file":"email.js","sources":["../../../server/src/services/email.ts"],"sourcesContent":["import * as _ from 'lodash';\nimport { objects, template } from '@strapi/utils';\n\nimport type {\n EmailConfig,\n EmailOptions,\n EmailTemplate,\n EmailTemplateData,\n SendOptions,\n} from '../types';\n\nconst { createStrictInterpolationRegExp } = template;\n\nconst getProviderSettings = (): EmailConfig => strapi.config.get('plugin::email');\n\nconst send = async (options: SendOptions) => strapi.plugin('email').provider.send(options);\n\n/**\n * fill subject, text and html using lodash template\n * @param {object} emailOptions - to, from and replyto...\n * @param {object} emailTemplate - object containing attributes to fill\n * @param {object} data - data used to fill the template\n * @returns {{ subject, text, subject }}\n */\nconst sendTemplatedEmail = (\n emailOptions: EmailOptions,\n emailTemplate: EmailTemplate,\n data: EmailTemplateData\n) => {\n const attributes = ['subject', 'text', 'html'];\n const missingAttributes = _.difference(attributes, Object.keys(emailTemplate));\n\n if (missingAttributes.length > 0) {\n throw new Error(\n `Following attributes are missing from your email template : ${missingAttributes.join(', ')}`\n );\n }\n\n const allowedInterpolationVariables = objects.keysDeep(data);\n const interpolate = createStrictInterpolationRegExp(allowedInterpolationVariables, 'g');\n\n const templatedAttributes = attributes.reduce(\n (compiled, attribute) =>\n emailTemplate[attribute]\n ? Object.assign(compiled, {\n [attribute]: _.template(emailTemplate[attribute], {\n interpolate,\n })(data),\n })\n : compiled,\n {}\n );\n\n return strapi.plugin('email').provider.send({ ...emailOptions, ...templatedAttributes });\n};\n\nconst emailService = () => ({\n getProviderSettings,\n send,\n sendTemplatedEmail,\n});\n\nexport default emailService;\n"],"names":["createStrictInterpolationRegExp","template","getProviderSettings","strapi","config","get","send","options","plugin","provider","sendTemplatedEmail","emailOptions","emailTemplate","data","attributes","missingAttributes","_","difference","Object","keys","length","Error","join","allowedInterpolationVariables","objects","keysDeep","interpolate","templatedAttributes","reduce","compiled","attribute","assign","emailService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAWA,MAAM,EAAEA,+BAA+B,EAAE,GAAGC,cAAAA;AAE5C,MAAMC,sBAAsB,IAAmBC,MAAAA,CAAOC,MAAM,CAACC,GAAG,CAAC,eAAA,CAAA;AAEjE,MAAMC,IAAAA,GAAO,OAAOC,OAAAA,GAAyBJ,MAAAA,CAAOK,MAAM,CAAC,OAAA,CAAA,CAASC,QAAQ,CAACH,IAAI,CAACC,OAAAA,CAAAA;AAElF;;;;;;AAMC,IACD,MAAMG,kBAAAA,GAAqB,CACzBC,YAAAA,EACAC,aAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,MAAMC,UAAAA,GAAa;AAAC,QAAA,SAAA;AAAW,QAAA,MAAA;AAAQ,QAAA;AAAO,KAAA;AAC9C,IAAA,MAAMC,oBAAoBC,YAAAA,CAAEC,UAAU,CAACH,UAAAA,EAAYI,MAAAA,CAAOC,IAAI,CAACP,aAAAA,CAAAA,CAAAA;IAE/D,IAAIG,iBAAAA,CAAkBK,MAAM,GAAG,CAAA,EAAG;QAChC,MAAM,IAAIC,MACR,CAAC,4DAA4D,EAAEN,iBAAAA,CAAkBO,IAAI,CAAC,IAAA,CAAA,CAAA,CAAO,CAAA;AAEjG,IAAA;IAEA,MAAMC,6BAAAA,GAAgCC,aAAAA,CAAQC,QAAQ,CAACZ,IAAAA,CAAAA;IACvD,MAAMa,WAAAA,GAAc1B,gCAAgCuB,6BAAAA,EAA+B,GAAA,CAAA;AAEnF,IAAA,MAAMI,mBAAAA,GAAsBb,UAAAA,CAAWc,MAAM,CAC3C,CAACC,QAAAA,EAAUC,SAAAA,GACTlB,aAAa,CAACkB,SAAAA,CAAU,GACpBZ,MAAAA,CAAOa,MAAM,CAACF,QAAAA,EAAU;YACtB,CAACC,SAAAA,GAAYd,YAAAA,CAAEf,QAAQ,CAACW,aAAa,CAACkB,UAAU,EAAE;AAChDJ,gBAAAA;aACF,CAAA,CAAGb,IAAAA;AACL,SAAA,CAAA,GACAgB,UACN,EAAC,CAAA;AAGH,IAAA,OAAO1B,OAAOK,MAAM,CAAC,SAASC,QAAQ,CAACH,IAAI,CAAC;AAAE,QAAA,GAAGK,YAAY;AAAE,QAAA,GAAGgB;AAAoB,KAAA,CAAA;AACxF,CAAA;AAEA,MAAMK,YAAAA,GAAe,KAAO;AAC1B9B,QAAAA,mBAAAA;AACAI,QAAAA,IAAAA;AACAI,QAAAA;KACF;;;;"}
1
+ {"version":3,"file":"email.js","sources":["../../../server/src/services/email.ts"],"sourcesContent":["import { difference, template as lodashTemplate } from 'lodash';\nimport { objects, template } from '@strapi/utils';\n\nimport type {\n EmailConfig,\n EmailOptions,\n EmailTemplate,\n EmailTemplateData,\n SendOptions,\n} from '../types';\n\nconst { createStrictInterpolationRegExp } = template;\n\nconst getProviderSettings = (): EmailConfig => strapi.config.get('plugin::email');\n\nconst send = async (options: SendOptions) => strapi.plugin('email').provider.send(options);\n\n/**\n * fill subject, text and html using lodash template\n * @param {object} emailOptions - to, from and replyto...\n * @param {object} emailTemplate - object containing attributes to fill\n * @param {object} data - data used to fill the template\n * @returns {{ subject, text, subject }}\n */\nconst sendTemplatedEmail = (\n emailOptions: EmailOptions,\n emailTemplate: EmailTemplate,\n data: EmailTemplateData\n) => {\n const attributes = ['subject', 'text', 'html'];\n const missingAttributes = difference(attributes, Object.keys(emailTemplate));\n\n if (missingAttributes.length > 0) {\n throw new Error(\n `Following attributes are missing from your email template : ${missingAttributes.join(', ')}`\n );\n }\n\n const allowedInterpolationVariables = objects.keysDeep(data);\n const interpolate = createStrictInterpolationRegExp(allowedInterpolationVariables, 'g');\n\n const templatedAttributes = attributes.reduce(\n (compiled, attribute) =>\n emailTemplate[attribute]\n ? Object.assign(compiled, {\n [attribute]: lodashTemplate(emailTemplate[attribute], {\n interpolate,\n })(data),\n })\n : compiled,\n {}\n );\n\n return strapi.plugin('email').provider.send({ ...emailOptions, ...templatedAttributes });\n};\n\nconst emailService = () => ({\n getProviderSettings,\n send,\n sendTemplatedEmail,\n});\n\nexport default emailService;\n"],"names":["createStrictInterpolationRegExp","template","getProviderSettings","strapi","config","get","send","options","plugin","provider","sendTemplatedEmail","emailOptions","emailTemplate","data","attributes","missingAttributes","difference","Object","keys","length","Error","join","allowedInterpolationVariables","objects","keysDeep","interpolate","templatedAttributes","reduce","compiled","attribute","assign","lodashTemplate","emailService"],"mappings":";;;;;AAWA,MAAM,EAAEA,+BAA+B,EAAE,GAAGC,cAAAA;AAE5C,MAAMC,sBAAsB,IAAmBC,MAAAA,CAAOC,MAAM,CAACC,GAAG,CAAC,eAAA,CAAA;AAEjE,MAAMC,IAAAA,GAAO,OAAOC,OAAAA,GAAyBJ,MAAAA,CAAOK,MAAM,CAAC,OAAA,CAAA,CAASC,QAAQ,CAACH,IAAI,CAACC,OAAAA,CAAAA;AAElF;;;;;;AAMC,IACD,MAAMG,kBAAAA,GAAqB,CACzBC,YAAAA,EACAC,aAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,MAAMC,UAAAA,GAAa;AAAC,QAAA,SAAA;AAAW,QAAA,MAAA;AAAQ,QAAA;AAAO,KAAA;AAC9C,IAAA,MAAMC,iBAAAA,GAAoBC,iBAAAA,CAAWF,UAAAA,EAAYG,MAAAA,CAAOC,IAAI,CAACN,aAAAA,CAAAA,CAAAA;IAE7D,IAAIG,iBAAAA,CAAkBI,MAAM,GAAG,CAAA,EAAG;QAChC,MAAM,IAAIC,MACR,CAAC,4DAA4D,EAAEL,iBAAAA,CAAkBM,IAAI,CAAC,IAAA,CAAA,CAAA,CAAO,CAAA;AAEjG,IAAA;IAEA,MAAMC,6BAAAA,GAAgCC,aAAAA,CAAQC,QAAQ,CAACX,IAAAA,CAAAA;IACvD,MAAMY,WAAAA,GAAczB,gCAAgCsB,6BAAAA,EAA+B,GAAA,CAAA;AAEnF,IAAA,MAAMI,mBAAAA,GAAsBZ,UAAAA,CAAWa,MAAM,CAC3C,CAACC,QAAAA,EAAUC,SAAAA,GACTjB,aAAa,CAACiB,SAAAA,CAAU,GACpBZ,MAAAA,CAAOa,MAAM,CAACF,QAAAA,EAAU;AACtB,YAAA,CAACC,YAAYE,eAAAA,CAAenB,aAAa,CAACiB,UAAU,EAAE;AACpDJ,gBAAAA;aACF,CAAA,CAAGZ,IAAAA;AACL,SAAA,CAAA,GACAe,UACN,EAAC,CAAA;AAGH,IAAA,OAAOzB,OAAOK,MAAM,CAAC,SAASC,QAAQ,CAACH,IAAI,CAAC;AAAE,QAAA,GAAGK,YAAY;AAAE,QAAA,GAAGe;AAAoB,KAAA,CAAA;AACxF,CAAA;AAEA,MAAMM,YAAAA,GAAe,KAAO;AAC1B9B,QAAAA,mBAAAA;AACAI,QAAAA,IAAAA;AACAI,QAAAA;KACF;;;;"}
@@ -1,4 +1,4 @@
1
- import * as _ from 'lodash';
1
+ import { difference, template as template$1 } from 'lodash';
2
2
  import { template, objects } from '@strapi/utils';
3
3
 
4
4
  const { createStrictInterpolationRegExp } = template;
@@ -16,14 +16,14 @@ const send = async (options)=>strapi.plugin('email').provider.send(options);
16
16
  'text',
17
17
  'html'
18
18
  ];
19
- const missingAttributes = _.difference(attributes, Object.keys(emailTemplate));
19
+ const missingAttributes = difference(attributes, Object.keys(emailTemplate));
20
20
  if (missingAttributes.length > 0) {
21
21
  throw new Error(`Following attributes are missing from your email template : ${missingAttributes.join(', ')}`);
22
22
  }
23
23
  const allowedInterpolationVariables = objects.keysDeep(data);
24
24
  const interpolate = createStrictInterpolationRegExp(allowedInterpolationVariables, 'g');
25
25
  const templatedAttributes = attributes.reduce((compiled, attribute)=>emailTemplate[attribute] ? Object.assign(compiled, {
26
- [attribute]: _.template(emailTemplate[attribute], {
26
+ [attribute]: template$1(emailTemplate[attribute], {
27
27
  interpolate
28
28
  })(data)
29
29
  }) : compiled, {});
@@ -1 +1 @@
1
- {"version":3,"file":"email.mjs","sources":["../../../server/src/services/email.ts"],"sourcesContent":["import * as _ from 'lodash';\nimport { objects, template } from '@strapi/utils';\n\nimport type {\n EmailConfig,\n EmailOptions,\n EmailTemplate,\n EmailTemplateData,\n SendOptions,\n} from '../types';\n\nconst { createStrictInterpolationRegExp } = template;\n\nconst getProviderSettings = (): EmailConfig => strapi.config.get('plugin::email');\n\nconst send = async (options: SendOptions) => strapi.plugin('email').provider.send(options);\n\n/**\n * fill subject, text and html using lodash template\n * @param {object} emailOptions - to, from and replyto...\n * @param {object} emailTemplate - object containing attributes to fill\n * @param {object} data - data used to fill the template\n * @returns {{ subject, text, subject }}\n */\nconst sendTemplatedEmail = (\n emailOptions: EmailOptions,\n emailTemplate: EmailTemplate,\n data: EmailTemplateData\n) => {\n const attributes = ['subject', 'text', 'html'];\n const missingAttributes = _.difference(attributes, Object.keys(emailTemplate));\n\n if (missingAttributes.length > 0) {\n throw new Error(\n `Following attributes are missing from your email template : ${missingAttributes.join(', ')}`\n );\n }\n\n const allowedInterpolationVariables = objects.keysDeep(data);\n const interpolate = createStrictInterpolationRegExp(allowedInterpolationVariables, 'g');\n\n const templatedAttributes = attributes.reduce(\n (compiled, attribute) =>\n emailTemplate[attribute]\n ? Object.assign(compiled, {\n [attribute]: _.template(emailTemplate[attribute], {\n interpolate,\n })(data),\n })\n : compiled,\n {}\n );\n\n return strapi.plugin('email').provider.send({ ...emailOptions, ...templatedAttributes });\n};\n\nconst emailService = () => ({\n getProviderSettings,\n send,\n sendTemplatedEmail,\n});\n\nexport default emailService;\n"],"names":["createStrictInterpolationRegExp","template","getProviderSettings","strapi","config","get","send","options","plugin","provider","sendTemplatedEmail","emailOptions","emailTemplate","data","attributes","missingAttributes","_","difference","Object","keys","length","Error","join","allowedInterpolationVariables","objects","keysDeep","interpolate","templatedAttributes","reduce","compiled","attribute","assign","emailService"],"mappings":";;;AAWA,MAAM,EAAEA,+BAA+B,EAAE,GAAGC,QAAAA;AAE5C,MAAMC,sBAAsB,IAAmBC,MAAAA,CAAOC,MAAM,CAACC,GAAG,CAAC,eAAA,CAAA;AAEjE,MAAMC,IAAAA,GAAO,OAAOC,OAAAA,GAAyBJ,MAAAA,CAAOK,MAAM,CAAC,OAAA,CAAA,CAASC,QAAQ,CAACH,IAAI,CAACC,OAAAA,CAAAA;AAElF;;;;;;AAMC,IACD,MAAMG,kBAAAA,GAAqB,CACzBC,YAAAA,EACAC,aAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,MAAMC,UAAAA,GAAa;AAAC,QAAA,SAAA;AAAW,QAAA,MAAA;AAAQ,QAAA;AAAO,KAAA;AAC9C,IAAA,MAAMC,oBAAoBC,CAAAA,CAAEC,UAAU,CAACH,UAAAA,EAAYI,MAAAA,CAAOC,IAAI,CAACP,aAAAA,CAAAA,CAAAA;IAE/D,IAAIG,iBAAAA,CAAkBK,MAAM,GAAG,CAAA,EAAG;QAChC,MAAM,IAAIC,MACR,CAAC,4DAA4D,EAAEN,iBAAAA,CAAkBO,IAAI,CAAC,IAAA,CAAA,CAAA,CAAO,CAAA;AAEjG,IAAA;IAEA,MAAMC,6BAAAA,GAAgCC,OAAAA,CAAQC,QAAQ,CAACZ,IAAAA,CAAAA;IACvD,MAAMa,WAAAA,GAAc1B,gCAAgCuB,6BAAAA,EAA+B,GAAA,CAAA;AAEnF,IAAA,MAAMI,mBAAAA,GAAsBb,UAAAA,CAAWc,MAAM,CAC3C,CAACC,QAAAA,EAAUC,SAAAA,GACTlB,aAAa,CAACkB,SAAAA,CAAU,GACpBZ,MAAAA,CAAOa,MAAM,CAACF,QAAAA,EAAU;YACtB,CAACC,SAAAA,GAAYd,CAAAA,CAAEf,QAAQ,CAACW,aAAa,CAACkB,UAAU,EAAE;AAChDJ,gBAAAA;aACF,CAAA,CAAGb,IAAAA;AACL,SAAA,CAAA,GACAgB,UACN,EAAC,CAAA;AAGH,IAAA,OAAO1B,OAAOK,MAAM,CAAC,SAASC,QAAQ,CAACH,IAAI,CAAC;AAAE,QAAA,GAAGK,YAAY;AAAE,QAAA,GAAGgB;AAAoB,KAAA,CAAA;AACxF,CAAA;AAEA,MAAMK,YAAAA,GAAe,KAAO;AAC1B9B,QAAAA,mBAAAA;AACAI,QAAAA,IAAAA;AACAI,QAAAA;KACF;;;;"}
1
+ {"version":3,"file":"email.mjs","sources":["../../../server/src/services/email.ts"],"sourcesContent":["import { difference, template as lodashTemplate } from 'lodash';\nimport { objects, template } from '@strapi/utils';\n\nimport type {\n EmailConfig,\n EmailOptions,\n EmailTemplate,\n EmailTemplateData,\n SendOptions,\n} from '../types';\n\nconst { createStrictInterpolationRegExp } = template;\n\nconst getProviderSettings = (): EmailConfig => strapi.config.get('plugin::email');\n\nconst send = async (options: SendOptions) => strapi.plugin('email').provider.send(options);\n\n/**\n * fill subject, text and html using lodash template\n * @param {object} emailOptions - to, from and replyto...\n * @param {object} emailTemplate - object containing attributes to fill\n * @param {object} data - data used to fill the template\n * @returns {{ subject, text, subject }}\n */\nconst sendTemplatedEmail = (\n emailOptions: EmailOptions,\n emailTemplate: EmailTemplate,\n data: EmailTemplateData\n) => {\n const attributes = ['subject', 'text', 'html'];\n const missingAttributes = difference(attributes, Object.keys(emailTemplate));\n\n if (missingAttributes.length > 0) {\n throw new Error(\n `Following attributes are missing from your email template : ${missingAttributes.join(', ')}`\n );\n }\n\n const allowedInterpolationVariables = objects.keysDeep(data);\n const interpolate = createStrictInterpolationRegExp(allowedInterpolationVariables, 'g');\n\n const templatedAttributes = attributes.reduce(\n (compiled, attribute) =>\n emailTemplate[attribute]\n ? Object.assign(compiled, {\n [attribute]: lodashTemplate(emailTemplate[attribute], {\n interpolate,\n })(data),\n })\n : compiled,\n {}\n );\n\n return strapi.plugin('email').provider.send({ ...emailOptions, ...templatedAttributes });\n};\n\nconst emailService = () => ({\n getProviderSettings,\n send,\n sendTemplatedEmail,\n});\n\nexport default emailService;\n"],"names":["createStrictInterpolationRegExp","template","getProviderSettings","strapi","config","get","send","options","plugin","provider","sendTemplatedEmail","emailOptions","emailTemplate","data","attributes","missingAttributes","difference","Object","keys","length","Error","join","allowedInterpolationVariables","objects","keysDeep","interpolate","templatedAttributes","reduce","compiled","attribute","assign","lodashTemplate","emailService"],"mappings":";;;AAWA,MAAM,EAAEA,+BAA+B,EAAE,GAAGC,QAAAA;AAE5C,MAAMC,sBAAsB,IAAmBC,MAAAA,CAAOC,MAAM,CAACC,GAAG,CAAC,eAAA,CAAA;AAEjE,MAAMC,IAAAA,GAAO,OAAOC,OAAAA,GAAyBJ,MAAAA,CAAOK,MAAM,CAAC,OAAA,CAAA,CAASC,QAAQ,CAACH,IAAI,CAACC,OAAAA,CAAAA;AAElF;;;;;;AAMC,IACD,MAAMG,kBAAAA,GAAqB,CACzBC,YAAAA,EACAC,aAAAA,EACAC,IAAAA,GAAAA;AAEA,IAAA,MAAMC,UAAAA,GAAa;AAAC,QAAA,SAAA;AAAW,QAAA,MAAA;AAAQ,QAAA;AAAO,KAAA;AAC9C,IAAA,MAAMC,iBAAAA,GAAoBC,UAAAA,CAAWF,UAAAA,EAAYG,MAAAA,CAAOC,IAAI,CAACN,aAAAA,CAAAA,CAAAA;IAE7D,IAAIG,iBAAAA,CAAkBI,MAAM,GAAG,CAAA,EAAG;QAChC,MAAM,IAAIC,MACR,CAAC,4DAA4D,EAAEL,iBAAAA,CAAkBM,IAAI,CAAC,IAAA,CAAA,CAAA,CAAO,CAAA;AAEjG,IAAA;IAEA,MAAMC,6BAAAA,GAAgCC,OAAAA,CAAQC,QAAQ,CAACX,IAAAA,CAAAA;IACvD,MAAMY,WAAAA,GAAczB,gCAAgCsB,6BAAAA,EAA+B,GAAA,CAAA;AAEnF,IAAA,MAAMI,mBAAAA,GAAsBZ,UAAAA,CAAWa,MAAM,CAC3C,CAACC,QAAAA,EAAUC,SAAAA,GACTjB,aAAa,CAACiB,SAAAA,CAAU,GACpBZ,MAAAA,CAAOa,MAAM,CAACF,QAAAA,EAAU;AACtB,YAAA,CAACC,YAAYE,UAAAA,CAAenB,aAAa,CAACiB,UAAU,EAAE;AACpDJ,gBAAAA;aACF,CAAA,CAAGZ,IAAAA;AACL,SAAA,CAAA,GACAe,UACN,EAAC,CAAA;AAGH,IAAA,OAAOzB,OAAOK,MAAM,CAAC,SAASC,QAAQ,CAACH,IAAI,CAAC;AAAE,QAAA,GAAGK,YAAY;AAAE,QAAA,GAAGe;AAAoB,KAAA,CAAA;AACxF,CAAA;AAEA,MAAMM,YAAAA,GAAe,KAAO;AAC1B9B,QAAAA,mBAAAA;AACAI,QAAAA,IAAAA;AACAI,QAAAA;KACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/email",
3
- "version": "5.59.0",
3
+ "version": "5.60.0",
4
4
  "description": "Easily configure your Strapi application to send emails.",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -66,8 +66,8 @@
66
66
  "dependencies": {
67
67
  "@strapi/design-system": "2.2.4",
68
68
  "@strapi/icons": "2.2.4",
69
- "@strapi/provider-email-sendmail": "5.59.0",
70
- "@strapi/utils": "5.59.0",
69
+ "@strapi/provider-email-sendmail": "5.60.0",
70
+ "@strapi/utils": "5.60.0",
71
71
  "koa2-ratelimit": "^1.1.3",
72
72
  "lodash": "4.18.1",
73
73
  "react-intl": "6.6.2",
@@ -76,8 +76,8 @@
76
76
  "zod": "4.4.3"
77
77
  },
78
78
  "devDependencies": {
79
- "@strapi/admin": "5.59.0",
80
- "@strapi/types": "5.59.0",
79
+ "@strapi/admin": "5.60.0",
80
+ "@strapi/types": "5.60.0",
81
81
  "@testing-library/dom": "10.4.1",
82
82
  "@testing-library/jest-dom": "6.9.1",
83
83
  "@testing-library/react": "16.3.2",
@@ -93,7 +93,7 @@
93
93
  "react-router-dom": "6.30.6",
94
94
  "styled-components": "6.4.1",
95
95
  "vitest": "catalog:",
96
- "vitest-config": "5.59.0"
96
+ "vitest-config": "5.60.0"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "@strapi/admin": "^5.0.0",