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/collections.js
CHANGED
|
@@ -1556,77 +1556,47 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
1556
1556
|
req.payload.logger.info("Still missing required fields for provider sync");
|
|
1557
1557
|
return doc;
|
|
1558
1558
|
}
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
req.payload.logger.info("Skipping provider sync - content is empty after conversion");
|
|
1564
|
-
return doc;
|
|
1565
|
-
}
|
|
1566
|
-
const createData = {
|
|
1567
|
-
name: doc.subject,
|
|
1568
|
-
subject: doc.subject,
|
|
1569
|
-
preheader: doc.contentSection?.preheader,
|
|
1570
|
-
content: htmlContent,
|
|
1571
|
-
trackOpens: doc.settings?.trackOpens,
|
|
1572
|
-
trackClicks: doc.settings?.trackClicks,
|
|
1573
|
-
replyTo: doc.settings?.replyTo || providerConfig.replyTo,
|
|
1574
|
-
audienceIds: doc.audienceIds?.map((a) => a.audienceId)
|
|
1575
|
-
};
|
|
1576
|
-
req.payload.logger.info("Creating broadcast with data:", {
|
|
1577
|
-
name: createData.name,
|
|
1578
|
-
subject: createData.subject,
|
|
1579
|
-
preheader: createData.preheader || "NONE",
|
|
1580
|
-
contentLength: htmlContent ? htmlContent.length : 0,
|
|
1581
|
-
contentPreview: htmlContent ? htmlContent.substring(0, 100) + "..." : "EMPTY",
|
|
1582
|
-
apiUrl: providerConfig.apiUrl,
|
|
1583
|
-
hasToken: !!providerConfig.token
|
|
1584
|
-
});
|
|
1585
|
-
const providerBroadcast = await provider.create(createData);
|
|
1586
|
-
await req.payload.update({
|
|
1587
|
-
collection: "broadcasts",
|
|
1588
|
-
id: doc.id,
|
|
1589
|
-
data: {
|
|
1590
|
-
providerId: providerBroadcast.id,
|
|
1591
|
-
providerData: providerBroadcast.providerData
|
|
1592
|
-
},
|
|
1593
|
-
req
|
|
1594
|
-
});
|
|
1595
|
-
req.payload.logger.info(`Broadcast ${doc.id} created in provider successfully (deferred)`);
|
|
1596
|
-
return {
|
|
1597
|
-
...doc,
|
|
1598
|
-
providerId: providerBroadcast.id,
|
|
1599
|
-
providerData: providerBroadcast.providerData
|
|
1600
|
-
};
|
|
1601
|
-
} catch (error) {
|
|
1602
|
-
req.payload.logger.error("Raw error from broadcast provider (deferred create):");
|
|
1603
|
-
req.payload.logger.error(error);
|
|
1604
|
-
if (error instanceof Error) {
|
|
1605
|
-
req.payload.logger.error("Error is instance of Error:", {
|
|
1606
|
-
message: error.message,
|
|
1607
|
-
stack: error.stack,
|
|
1608
|
-
name: error.name,
|
|
1609
|
-
...error.details,
|
|
1610
|
-
...error.response,
|
|
1611
|
-
...error.data,
|
|
1612
|
-
...error.status,
|
|
1613
|
-
...error.statusText
|
|
1614
|
-
});
|
|
1615
|
-
} else if (typeof error === "string") {
|
|
1616
|
-
req.payload.logger.error("Error is a string:", error);
|
|
1617
|
-
} else if (error && typeof error === "object") {
|
|
1618
|
-
req.payload.logger.error("Error is an object:", JSON.stringify(error, null, 2));
|
|
1619
|
-
} else {
|
|
1620
|
-
req.payload.logger.error("Unknown error type:", typeof error);
|
|
1621
|
-
}
|
|
1622
|
-
req.payload.logger.error("Failed broadcast document (deferred create):", {
|
|
1623
|
-
id: doc.id,
|
|
1624
|
-
subject: doc.subject,
|
|
1625
|
-
hasContent: !!doc.contentSection?.content,
|
|
1626
|
-
contentType: doc.contentSection?.content ? typeof doc.contentSection.content : "none"
|
|
1627
|
-
});
|
|
1559
|
+
req.payload.logger.info("Creating broadcast in provider (deferred from initial create)...");
|
|
1560
|
+
const htmlContent = await convertToEmailSafeHtml(doc.contentSection?.content);
|
|
1561
|
+
if (!htmlContent || htmlContent.trim() === "") {
|
|
1562
|
+
req.payload.logger.info("Skipping provider sync - content is empty after conversion");
|
|
1628
1563
|
return doc;
|
|
1629
1564
|
}
|
|
1565
|
+
const createData = {
|
|
1566
|
+
name: doc.subject,
|
|
1567
|
+
subject: doc.subject,
|
|
1568
|
+
preheader: doc.contentSection?.preheader,
|
|
1569
|
+
content: htmlContent,
|
|
1570
|
+
trackOpens: doc.settings?.trackOpens,
|
|
1571
|
+
trackClicks: doc.settings?.trackClicks,
|
|
1572
|
+
replyTo: doc.settings?.replyTo || providerConfig.replyTo,
|
|
1573
|
+
audienceIds: doc.audienceIds?.map((a) => a.audienceId)
|
|
1574
|
+
};
|
|
1575
|
+
req.payload.logger.info("Creating broadcast with data:", {
|
|
1576
|
+
name: createData.name,
|
|
1577
|
+
subject: createData.subject,
|
|
1578
|
+
preheader: createData.preheader || "NONE",
|
|
1579
|
+
contentLength: htmlContent ? htmlContent.length : 0,
|
|
1580
|
+
contentPreview: htmlContent ? htmlContent.substring(0, 100) + "..." : "EMPTY",
|
|
1581
|
+
apiUrl: providerConfig.apiUrl,
|
|
1582
|
+
hasToken: !!providerConfig.token
|
|
1583
|
+
});
|
|
1584
|
+
const providerBroadcast = await provider.create(createData);
|
|
1585
|
+
await req.payload.update({
|
|
1586
|
+
collection: "broadcasts",
|
|
1587
|
+
id: doc.id,
|
|
1588
|
+
data: {
|
|
1589
|
+
providerId: providerBroadcast.id,
|
|
1590
|
+
providerData: providerBroadcast.providerData
|
|
1591
|
+
},
|
|
1592
|
+
req
|
|
1593
|
+
});
|
|
1594
|
+
req.payload.logger.info(`Broadcast ${doc.id} created in provider successfully (deferred)`);
|
|
1595
|
+
return {
|
|
1596
|
+
...doc,
|
|
1597
|
+
providerId: providerBroadcast.id,
|
|
1598
|
+
providerData: providerBroadcast.providerData
|
|
1599
|
+
};
|
|
1630
1600
|
}
|
|
1631
1601
|
if (doc.providerId) {
|
|
1632
1602
|
const capabilities = provider.getCapabilities();
|
|
@@ -1671,16 +1641,32 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
1671
1641
|
}
|
|
1672
1642
|
}
|
|
1673
1643
|
} catch (error) {
|
|
1644
|
+
req.payload.logger.error("Raw error from broadcast update operation:");
|
|
1645
|
+
req.payload.logger.error(error);
|
|
1674
1646
|
if (error instanceof Error) {
|
|
1675
|
-
req.payload.logger.error("
|
|
1647
|
+
req.payload.logger.error("Error is instance of Error:", {
|
|
1676
1648
|
message: error.message,
|
|
1677
1649
|
stack: error.stack,
|
|
1678
1650
|
name: error.name,
|
|
1679
|
-
...error.details
|
|
1651
|
+
...error.details,
|
|
1652
|
+
...error.response,
|
|
1653
|
+
...error.data,
|
|
1654
|
+
...error.status,
|
|
1655
|
+
...error.statusText
|
|
1680
1656
|
});
|
|
1657
|
+
} else if (typeof error === "string") {
|
|
1658
|
+
req.payload.logger.error("Error is a string:", error);
|
|
1659
|
+
} else if (error && typeof error === "object") {
|
|
1660
|
+
req.payload.logger.error("Error is an object:", JSON.stringify(error, null, 2));
|
|
1681
1661
|
} else {
|
|
1682
|
-
req.payload.logger.error("
|
|
1662
|
+
req.payload.logger.error("Unknown error type:", typeof error);
|
|
1683
1663
|
}
|
|
1664
|
+
req.payload.logger.error("Failed broadcast document (update operation):", {
|
|
1665
|
+
id: doc.id,
|
|
1666
|
+
subject: doc.subject,
|
|
1667
|
+
hasContent: !!doc.contentSection?.content,
|
|
1668
|
+
contentType: doc.contentSection?.content ? typeof doc.contentSection.content : "none"
|
|
1669
|
+
});
|
|
1684
1670
|
}
|
|
1685
1671
|
}
|
|
1686
1672
|
return doc;
|