payload-plugin-newsletter 0.16.9 → 0.16.10
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/CHANGELOG.md +15 -0
- package/dist/collections.cjs +58 -72
- package/dist/collections.cjs.map +1 -1
- package/dist/collections.js +58 -72
- package/dist/collections.js.map +1 -1
- package/dist/index.cjs +58 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +58 -72
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4506,77 +4506,47 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
4506
4506
|
req.payload.logger.info("Still missing required fields for provider sync");
|
|
4507
4507
|
return doc;
|
|
4508
4508
|
}
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
req.payload.logger.info("Skipping provider sync - content is empty after conversion");
|
|
4514
|
-
return doc;
|
|
4515
|
-
}
|
|
4516
|
-
const createData = {
|
|
4517
|
-
name: doc.subject,
|
|
4518
|
-
subject: doc.subject,
|
|
4519
|
-
preheader: doc.contentSection?.preheader,
|
|
4520
|
-
content: htmlContent,
|
|
4521
|
-
trackOpens: doc.settings?.trackOpens,
|
|
4522
|
-
trackClicks: doc.settings?.trackClicks,
|
|
4523
|
-
replyTo: doc.settings?.replyTo || providerConfig.replyTo,
|
|
4524
|
-
audienceIds: doc.audienceIds?.map((a) => a.audienceId)
|
|
4525
|
-
};
|
|
4526
|
-
req.payload.logger.info("Creating broadcast with data:", {
|
|
4527
|
-
name: createData.name,
|
|
4528
|
-
subject: createData.subject,
|
|
4529
|
-
preheader: createData.preheader || "NONE",
|
|
4530
|
-
contentLength: htmlContent ? htmlContent.length : 0,
|
|
4531
|
-
contentPreview: htmlContent ? htmlContent.substring(0, 100) + "..." : "EMPTY",
|
|
4532
|
-
apiUrl: providerConfig.apiUrl,
|
|
4533
|
-
hasToken: !!providerConfig.token
|
|
4534
|
-
});
|
|
4535
|
-
const providerBroadcast = await provider.create(createData);
|
|
4536
|
-
await req.payload.update({
|
|
4537
|
-
collection: "broadcasts",
|
|
4538
|
-
id: doc.id,
|
|
4539
|
-
data: {
|
|
4540
|
-
providerId: providerBroadcast.id,
|
|
4541
|
-
providerData: providerBroadcast.providerData
|
|
4542
|
-
},
|
|
4543
|
-
req
|
|
4544
|
-
});
|
|
4545
|
-
req.payload.logger.info(`Broadcast ${doc.id} created in provider successfully (deferred)`);
|
|
4546
|
-
return {
|
|
4547
|
-
...doc,
|
|
4548
|
-
providerId: providerBroadcast.id,
|
|
4549
|
-
providerData: providerBroadcast.providerData
|
|
4550
|
-
};
|
|
4551
|
-
} catch (error) {
|
|
4552
|
-
req.payload.logger.error("Raw error from broadcast provider (deferred create):");
|
|
4553
|
-
req.payload.logger.error(error);
|
|
4554
|
-
if (error instanceof Error) {
|
|
4555
|
-
req.payload.logger.error("Error is instance of Error:", {
|
|
4556
|
-
message: error.message,
|
|
4557
|
-
stack: error.stack,
|
|
4558
|
-
name: error.name,
|
|
4559
|
-
...error.details,
|
|
4560
|
-
...error.response,
|
|
4561
|
-
...error.data,
|
|
4562
|
-
...error.status,
|
|
4563
|
-
...error.statusText
|
|
4564
|
-
});
|
|
4565
|
-
} else if (typeof error === "string") {
|
|
4566
|
-
req.payload.logger.error("Error is a string:", error);
|
|
4567
|
-
} else if (error && typeof error === "object") {
|
|
4568
|
-
req.payload.logger.error("Error is an object:", JSON.stringify(error, null, 2));
|
|
4569
|
-
} else {
|
|
4570
|
-
req.payload.logger.error("Unknown error type:", typeof error);
|
|
4571
|
-
}
|
|
4572
|
-
req.payload.logger.error("Failed broadcast document (deferred create):", {
|
|
4573
|
-
id: doc.id,
|
|
4574
|
-
subject: doc.subject,
|
|
4575
|
-
hasContent: !!doc.contentSection?.content,
|
|
4576
|
-
contentType: doc.contentSection?.content ? typeof doc.contentSection.content : "none"
|
|
4577
|
-
});
|
|
4509
|
+
req.payload.logger.info("Creating broadcast in provider (deferred from initial create)...");
|
|
4510
|
+
const htmlContent = await convertToEmailSafeHtml(doc.contentSection?.content);
|
|
4511
|
+
if (!htmlContent || htmlContent.trim() === "") {
|
|
4512
|
+
req.payload.logger.info("Skipping provider sync - content is empty after conversion");
|
|
4578
4513
|
return doc;
|
|
4579
4514
|
}
|
|
4515
|
+
const createData = {
|
|
4516
|
+
name: doc.subject,
|
|
4517
|
+
subject: doc.subject,
|
|
4518
|
+
preheader: doc.contentSection?.preheader,
|
|
4519
|
+
content: htmlContent,
|
|
4520
|
+
trackOpens: doc.settings?.trackOpens,
|
|
4521
|
+
trackClicks: doc.settings?.trackClicks,
|
|
4522
|
+
replyTo: doc.settings?.replyTo || providerConfig.replyTo,
|
|
4523
|
+
audienceIds: doc.audienceIds?.map((a) => a.audienceId)
|
|
4524
|
+
};
|
|
4525
|
+
req.payload.logger.info("Creating broadcast with data:", {
|
|
4526
|
+
name: createData.name,
|
|
4527
|
+
subject: createData.subject,
|
|
4528
|
+
preheader: createData.preheader || "NONE",
|
|
4529
|
+
contentLength: htmlContent ? htmlContent.length : 0,
|
|
4530
|
+
contentPreview: htmlContent ? htmlContent.substring(0, 100) + "..." : "EMPTY",
|
|
4531
|
+
apiUrl: providerConfig.apiUrl,
|
|
4532
|
+
hasToken: !!providerConfig.token
|
|
4533
|
+
});
|
|
4534
|
+
const providerBroadcast = await provider.create(createData);
|
|
4535
|
+
await req.payload.update({
|
|
4536
|
+
collection: "broadcasts",
|
|
4537
|
+
id: doc.id,
|
|
4538
|
+
data: {
|
|
4539
|
+
providerId: providerBroadcast.id,
|
|
4540
|
+
providerData: providerBroadcast.providerData
|
|
4541
|
+
},
|
|
4542
|
+
req
|
|
4543
|
+
});
|
|
4544
|
+
req.payload.logger.info(`Broadcast ${doc.id} created in provider successfully (deferred)`);
|
|
4545
|
+
return {
|
|
4546
|
+
...doc,
|
|
4547
|
+
providerId: providerBroadcast.id,
|
|
4548
|
+
providerData: providerBroadcast.providerData
|
|
4549
|
+
};
|
|
4580
4550
|
}
|
|
4581
4551
|
if (doc.providerId) {
|
|
4582
4552
|
const capabilities = provider.getCapabilities();
|
|
@@ -4621,16 +4591,32 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
4621
4591
|
}
|
|
4622
4592
|
}
|
|
4623
4593
|
} catch (error) {
|
|
4594
|
+
req.payload.logger.error("Raw error from broadcast update operation:");
|
|
4595
|
+
req.payload.logger.error(error);
|
|
4624
4596
|
if (error instanceof Error) {
|
|
4625
|
-
req.payload.logger.error("
|
|
4597
|
+
req.payload.logger.error("Error is instance of Error:", {
|
|
4626
4598
|
message: error.message,
|
|
4627
4599
|
stack: error.stack,
|
|
4628
4600
|
name: error.name,
|
|
4629
|
-
...error.details
|
|
4601
|
+
...error.details,
|
|
4602
|
+
...error.response,
|
|
4603
|
+
...error.data,
|
|
4604
|
+
...error.status,
|
|
4605
|
+
...error.statusText
|
|
4630
4606
|
});
|
|
4607
|
+
} else if (typeof error === "string") {
|
|
4608
|
+
req.payload.logger.error("Error is a string:", error);
|
|
4609
|
+
} else if (error && typeof error === "object") {
|
|
4610
|
+
req.payload.logger.error("Error is an object:", JSON.stringify(error, null, 2));
|
|
4631
4611
|
} else {
|
|
4632
|
-
req.payload.logger.error("
|
|
4612
|
+
req.payload.logger.error("Unknown error type:", typeof error);
|
|
4633
4613
|
}
|
|
4614
|
+
req.payload.logger.error("Failed broadcast document (update operation):", {
|
|
4615
|
+
id: doc.id,
|
|
4616
|
+
subject: doc.subject,
|
|
4617
|
+
hasContent: !!doc.contentSection?.content,
|
|
4618
|
+
contentType: doc.contentSection?.content ? typeof doc.contentSection.content : "none"
|
|
4619
|
+
});
|
|
4634
4620
|
}
|
|
4635
4621
|
}
|
|
4636
4622
|
return doc;
|