mailery 0.10.2 → 0.12.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
  import { Db } from 'mongodb';
2
- import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-CU_EApC6.cjs';
3
- export { s as NullProvider } from './null-CU_EApC6.cjs';
2
+ import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-CfzvqNEp.cjs';
3
+ export { s as NullProvider } from './null-CfzvqNEp.cjs';
4
4
  import 'zod';
5
5
  import 'handlebars';
6
6
  import 'ioredis';
@@ -118,6 +118,7 @@ interface TemplateSpec {
118
118
  plainText?: string;
119
119
  variablesSchema?: TemplateDoc['variablesSchema'];
120
120
  tags?: string[];
121
+ bodyFormat?: TemplateDoc['bodyFormat'];
121
122
  trackOpens?: boolean;
122
123
  trackClicks?: boolean;
123
124
  published?: boolean;
package/dist/testing.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Db } from 'mongodb';
2
- import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-CU_EApC6.js';
3
- export { s as NullProvider } from './null-CU_EApC6.js';
2
+ import { C as ContactAdapter, a as Contact, A as AdapterFilter, M as MailProvider, S as SendArgs, b as SendResult, N as NormalizedEvent, F as FlowStep, a2 as FlowTrigger, m as FlowGoal, U as TemplateKind, T as TemplateDoc, l as FlowDoc, D as DeliveryWindow, R as RunnerContext, d as Mailer, a3 as QueueDriverConfig } from './null-CfzvqNEp.js';
3
+ export { s as NullProvider } from './null-CfzvqNEp.js';
4
4
  import 'zod';
5
5
  import 'handlebars';
6
6
  import 'ioredis';
@@ -118,6 +118,7 @@ interface TemplateSpec {
118
118
  plainText?: string;
119
119
  variablesSchema?: TemplateDoc['variablesSchema'];
120
120
  tags?: string[];
121
+ bodyFormat?: TemplateDoc['bodyFormat'];
121
122
  trackOpens?: boolean;
122
123
  trackClicks?: boolean;
123
124
  published?: boolean;
package/dist/testing.js CHANGED
@@ -323,7 +323,10 @@ var init_sendgrid = __esm({
323
323
  replyTo: args.replyTo,
324
324
  subject: args.subject,
325
325
  text: args.text,
326
- html: args.html,
326
+ // Omit the key entirely rather than sending `html: undefined` — a
327
+ // text_only template must produce a single-part text/plain message, and
328
+ // an explicit undefined can still serialize into an empty HTML part.
329
+ ...args.html ? { html: args.html } : {},
327
330
  headers: args.headers,
328
331
  customArgs: args.messageMeta,
329
332
  trackingSettings: {
@@ -15843,7 +15846,8 @@ async function dispatchSend(sendId, ctx) {
15843
15846
  await markFailed(send._id, `render error: ${String(err?.message ?? err)}`, ctx);
15844
15847
  throw err;
15845
15848
  }
15846
- const tracking = applyTracking(rendered.html, {
15849
+ const textOnly = template.bodyFormat === "text_only";
15850
+ const tracking = textOnly ? { html: "", links: [] } : applyTracking(rendered.html, {
15847
15851
  sendId: String(send._id),
15848
15852
  publicUrl: ctx.config.publicUrl,
15849
15853
  trackOpens: template.trackOpens ?? ctx.config.trackOpens,
@@ -15855,7 +15859,9 @@ async function dispatchSend(sendId, ctx) {
15855
15859
  {
15856
15860
  $set: {
15857
15861
  links: tracking.links,
15858
- bodyHash: sha256(tracking.html),
15862
+ // Hash what actually goes out, so a text_only send's fingerprint
15863
+ // tracks the text body rather than an HTML part it never had.
15864
+ bodyHash: sha256(textOnly ? rendered.plainText : tracking.html),
15859
15865
  status: "sending",
15860
15866
  fromName: rendered.fromName,
15861
15867
  fromEmail: rendered.fromEmail,
@@ -15880,7 +15886,7 @@ async function dispatchSend(sendId, ctx) {
15880
15886
  fromEmail: rendered.fromEmail,
15881
15887
  replyTo: rendered.replyTo ?? void 0,
15882
15888
  subject: rendered.subject,
15883
- html: tracking.html,
15889
+ ...textOnly ? {} : { html: tracking.html },
15884
15890
  text: rendered.plainText,
15885
15891
  headers,
15886
15892
  messageMeta: { sendId: String(send._id) }
@@ -18118,6 +18124,7 @@ async function buildTemplate(spec) {
18118
18124
  variablesSchema: spec.variablesSchema ?? {},
18119
18125
  draft: null,
18120
18126
  tags: spec.tags ?? [],
18127
+ bodyFormat: spec.bodyFormat ?? "multipart",
18121
18128
  trackOpens: spec.trackOpens ?? false,
18122
18129
  trackClicks: spec.trackClicks ?? false,
18123
18130
  stats: {