@sendgrid/helpers
Advanced tools
Comparing version 6.4.0 to 6.5.0
@@ -156,2 +156,4 @@ import {AttachmentData, AttachmentJSON} from "./attachment"; | ||
dynamicTemplateData?: { [key: string]: any }, | ||
hideWarnings?: boolean, | ||
} | ||
@@ -329,2 +331,7 @@ | ||
/** | ||
* Set hide warnings | ||
*/ | ||
setHideWarnings(hide: boolean): void; | ||
/** | ||
* To JSON | ||
@@ -331,0 +338,0 @@ */ |
@@ -26,2 +26,3 @@ 'use strict'; | ||
this.isDynamic = false; | ||
this.hideWarnings = false; | ||
this.personalizations = []; | ||
@@ -70,2 +71,3 @@ this.attachments = []; | ||
trackingSettings, substitutions, substitutionWrappers, dynamicTemplateData, isMultiple, | ||
hideWarnings, | ||
} = data; | ||
@@ -91,2 +93,3 @@ | ||
this.setTrackingSettings(trackingSettings); | ||
this.setHideWarnings(hideWarnings); | ||
@@ -251,3 +254,3 @@ if (this.isDynamic) { | ||
} | ||
else if (personalization.dynamicTemplateData) { | ||
else if (!this.isDynamic && personalization.dynamicTemplateData) { | ||
delete personalization.dynamicTemplateData; | ||
@@ -346,7 +349,9 @@ } | ||
// Check dynamic template for non-escaped characters and warn if found | ||
Object.values(dynamicTemplateData).forEach(value => { | ||
if (/['"&]/.test(value)) { | ||
console.warn(DYNAMIC_TEMPLATE_CHAR_WARNING); | ||
} | ||
}); | ||
if (!this.hideWarnings) { | ||
Object.values(dynamicTemplateData).forEach(value => { | ||
if (/['"&]/.test(value)) { | ||
console.warn(DYNAMIC_TEMPLATE_CHAR_WARNING); | ||
} | ||
}); | ||
} | ||
@@ -540,2 +545,15 @@ this.dynamicTemplateData = dynamicTemplateData; | ||
/** | ||
* Set hide warnings | ||
*/ | ||
setHideWarnings(hide) { | ||
if (typeof hide === 'undefined') { | ||
return; | ||
} | ||
if (typeof hide !== 'boolean') { | ||
throw new Error('Boolean expected for `hideWarnings`'); | ||
} | ||
this.hideWarnings = hide; | ||
} | ||
/** | ||
* To JSON | ||
@@ -542,0 +560,0 @@ */ |
@@ -10,3 +10,3 @@ import { EmailData, EmailJSON } from "./email-address"; | ||
substitutions?: { [key: string]: string }; | ||
dynamicTemplateData?: { [key: string]: string; }; | ||
dynamicTemplateData?: { [key: string]: any; }; | ||
customArgs?: { [key: string]: string }; | ||
@@ -116,3 +116,3 @@ sendAt?: number; | ||
*/ | ||
setDynamicTemplateData(dynamicTemplateData: { [key: string]: string }): void; | ||
setDynamicTemplateData(dynamicTemplateData: { [key: string]: any }): void; | ||
@@ -119,0 +119,0 @@ /** |
@@ -10,3 +10,3 @@ 'use strict'; | ||
const deepClone = require('../helpers/deep-clone'); | ||
const merge = require('deepmerge'); | ||
const deepMerge = require('deepmerge'); | ||
const wrapSubstitutions = require('../helpers/wrap-substitutions'); | ||
@@ -290,3 +290,3 @@ | ||
} | ||
this.dynamicTemplateData = merge(dynamicTemplateData, this.dynamicTemplateData); | ||
this.dynamicTemplateData = deepMerge(dynamicTemplateData, this.dynamicTemplateData); | ||
} | ||
@@ -293,0 +293,0 @@ |
const DYNAMIC_TEMPLATE_CHAR_WARNING = ` | ||
Content with characters ', " or & may need to be escaped with three brackets | ||
{{{ content }}} | ||
See https://sendgrid.com/docs/ui/sending-email/using-handlebars/ for more information.`; | ||
See https://sendgrid.com/docs/for-developers/sending-email/using-handlebars/ for more information.`; | ||
module.exports = { | ||
DYNAMIC_TEMPLATE_CHAR_WARNING, | ||
DYNAMIC_TEMPLATE_CHAR_WARNING | ||
}; |
{ | ||
"name": "@sendgrid/helpers", | ||
"description": "Twilio SendGrid NodeJS internal helpers", | ||
"version": "6.4.0", | ||
"version": "6.5.0", | ||
"author": "Twilio SendGrid <dx@sendgrid.com> (sendgrid.com)", | ||
@@ -35,3 +35,4 @@ "contributors": [ | ||
"deepmerge": "^2.1.1" | ||
} | ||
}, | ||
"gitHead": "37473ad95a20258196d7cf256ea391508872d65e" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132041
4416
1