payload-plugin-newsletter 0.25.9 → 0.25.11

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.
@@ -741,25 +741,8 @@ var createEmailSafeFeatures = (additionalBlocks) => {
741
741
  ItalicFeature(),
742
742
  UnderlineFeature(),
743
743
  StrikethroughFeature(),
744
- // Links with enhanced configuration
745
- LinkFeature({
746
- fields: [
747
- {
748
- name: "url",
749
- type: "text",
750
- required: true,
751
- admin: {
752
- description: "Enter the full URL (including https://)"
753
- }
754
- },
755
- {
756
- name: "newTab",
757
- type: "checkbox",
758
- label: "Open in new tab",
759
- defaultValue: false
760
- }
761
- ]
762
- }),
744
+ // Links - use default fields to ensure drawer UI works correctly
745
+ LinkFeature(),
763
746
  // Lists
764
747
  OrderedListFeature(),
765
748
  UnorderedListFeature(),
@@ -815,25 +798,8 @@ var createEmailLexicalEditor = (customBlocks = []) => {
815
798
  ItalicFeature(),
816
799
  UnderlineFeature(),
817
800
  StrikethroughFeature(),
818
- // Links with enhanced configuration
819
- LinkFeature({
820
- fields: [
821
- {
822
- name: "url",
823
- type: "text",
824
- required: true,
825
- admin: {
826
- description: "Enter the full URL (including https://)"
827
- }
828
- },
829
- {
830
- name: "newTab",
831
- type: "checkbox",
832
- label: "Open in new tab",
833
- defaultValue: false
834
- }
835
- ]
836
- }),
801
+ // Links - use default fields to ensure drawer UI works correctly
802
+ LinkFeature(),
837
803
  // Lists
838
804
  OrderedListFeature(),
839
805
  UnorderedListFeature(),
@@ -1401,7 +1367,7 @@ async function getBroadcastConfig(req, pluginConfig) {
1401
1367
  }
1402
1368
  return pluginConfig.providers?.broadcast || null;
1403
1369
  } catch (error) {
1404
- req.payload.logger.error("Failed to get broadcast config from settings:", error);
1370
+ req.payload.logger.error({ error: String(error) }, "Failed to get broadcast config from settings");
1405
1371
  return pluginConfig.providers?.broadcast || null;
1406
1372
  }
1407
1373
  }
@@ -1798,23 +1764,24 @@ async function populateBlockMediaFields(node, payload, config) {
1798
1764
  for (const field of blockConfig.fields) {
1799
1765
  if (field.type === "upload" && field.relationTo && node.fields[field.name]) {
1800
1766
  const fieldValue = node.fields[field.name];
1767
+ const collectionName = Array.isArray(field.relationTo) ? field.relationTo[0] : field.relationTo;
1801
1768
  if (typeof fieldValue === "string" && fieldValue.match(/^[a-f0-9]{24}$/i)) {
1802
1769
  try {
1803
1770
  const media = await payload.findByID({
1804
- collection: field.relationTo,
1771
+ collection: collectionName,
1805
1772
  id: fieldValue,
1806
1773
  depth: 0
1807
1774
  });
1808
1775
  if (media) {
1809
1776
  node.fields[field.name] = media;
1810
- payload.logger?.info(`Populated ${field.name} for block ${blockType}:`, {
1777
+ payload.logger?.info({
1811
1778
  mediaId: fieldValue,
1812
1779
  mediaUrl: media.url,
1813
1780
  filename: media.filename
1814
- });
1781
+ }, `Populated ${field.name} for block ${blockType}`);
1815
1782
  }
1816
1783
  } catch (error) {
1817
- payload.logger?.error(`Failed to populate ${field.name} for block ${blockType}:`, error);
1784
+ payload.logger?.error({ error: String(error) }, `Failed to populate ${field.name} for block ${blockType}`);
1818
1785
  }
1819
1786
  }
1820
1787
  }
@@ -1826,23 +1793,24 @@ async function populateBlockMediaFields(node, payload, config) {
1826
1793
  for (const arrayField of field.fields) {
1827
1794
  if (arrayField.type === "upload" && arrayField.relationTo && arrayItem[arrayField.name]) {
1828
1795
  const arrayFieldValue = arrayItem[arrayField.name];
1796
+ const arrayCollectionName = Array.isArray(arrayField.relationTo) ? arrayField.relationTo[0] : arrayField.relationTo;
1829
1797
  if (typeof arrayFieldValue === "string" && arrayFieldValue.match(/^[a-f0-9]{24}$/i)) {
1830
1798
  try {
1831
1799
  const media = await payload.findByID({
1832
- collection: arrayField.relationTo,
1800
+ collection: arrayCollectionName,
1833
1801
  id: arrayFieldValue,
1834
1802
  depth: 0
1835
1803
  });
1836
1804
  if (media) {
1837
1805
  arrayItem[arrayField.name] = media;
1838
- payload.logger?.info(`Populated array ${arrayField.name} for block ${blockType}:`, {
1806
+ payload.logger?.info({
1839
1807
  mediaId: arrayFieldValue,
1840
1808
  mediaUrl: media.url,
1841
1809
  filename: media.filename
1842
- });
1810
+ }, `Populated array ${arrayField.name} for block ${blockType}`);
1843
1811
  }
1844
1812
  } catch (error) {
1845
- payload.logger?.error(`Failed to populate array ${arrayField.name} for block ${blockType}:`, error);
1813
+ payload.logger?.error({ error: String(error) }, `Failed to populate array ${arrayField.name} for block ${blockType}`);
1846
1814
  }
1847
1815
  }
1848
1816
  }
@@ -1886,14 +1854,14 @@ async function populateRichTextUploads(content, payload) {
1886
1854
  });
1887
1855
  if (media) {
1888
1856
  node.value = media;
1889
- payload.logger?.info(`Populated rich text upload node:`, {
1857
+ payload.logger?.info({
1890
1858
  mediaId: node.value,
1891
1859
  mediaUrl: media.url,
1892
1860
  filename: media.filename
1893
- });
1861
+ }, "Populated rich text upload node");
1894
1862
  }
1895
1863
  } catch (error) {
1896
- payload.logger?.error(`Failed to populate rich text upload ${node.value}:`, error);
1864
+ payload.logger?.error({ error: String(error) }, `Failed to populate rich text upload ${node.value}`);
1897
1865
  }
1898
1866
  }
1899
1867
  if (node.children && Array.isArray(node.children)) {
@@ -2297,7 +2265,7 @@ var createBroadcastsCollection = (pluginConfig) => {
2297
2265
  return doc;
2298
2266
  }
2299
2267
  if (operation === "update") {
2300
- req.payload.logger.info("Broadcast afterChange update hook triggered", {
2268
+ req.payload.logger.info({
2301
2269
  operation,
2302
2270
  hasProviderId: !!doc.providerId,
2303
2271
  hasExternalId: !!doc.externalId,
@@ -2305,7 +2273,7 @@ var createBroadcastsCollection = (pluginConfig) => {
2305
2273
  publishStatus: doc._status,
2306
2274
  hasSubject: !!doc.subject,
2307
2275
  hasContent: !!doc.contentSection?.content
2308
- });
2276
+ }, "Broadcast afterChange update hook triggered");
2309
2277
  try {
2310
2278
  const providerConfig = await getBroadcastConfig(req, pluginConfig);
2311
2279
  if (!providerConfig || !providerConfig.token) {
@@ -2392,10 +2360,10 @@ var createBroadcastsCollection = (pluginConfig) => {
2392
2360
  if (JSON.stringify(doc.audienceIds) !== JSON.stringify(previousDoc?.audienceIds)) {
2393
2361
  updates.audienceIds = doc.audienceIds?.map((a) => a.audienceId);
2394
2362
  }
2395
- req.payload.logger.info("Syncing broadcast updates to provider", {
2363
+ req.payload.logger.info({
2396
2364
  providerId: doc.providerId,
2397
2365
  updates
2398
- });
2366
+ }, "Syncing broadcast updates to provider");
2399
2367
  await provider.update(doc.providerId, updates);
2400
2368
  req.payload.logger.info(`Broadcast ${doc.id} synced to provider successfully`);
2401
2369
  } else {
@@ -2417,18 +2385,18 @@ var createBroadcastsCollection = (pluginConfig) => {
2417
2385
  ...error.statusText
2418
2386
  });
2419
2387
  } else if (typeof error === "string") {
2420
- req.payload.logger.error("Error is a string:", error);
2388
+ req.payload.logger.error({ errorValue: error }, "Error is a string");
2421
2389
  } else if (error && typeof error === "object") {
2422
- req.payload.logger.error("Error is an object:", JSON.stringify(error, null, 2));
2390
+ req.payload.logger.error({ errorValue: JSON.stringify(error, null, 2) }, "Error is an object");
2423
2391
  } else {
2424
- req.payload.logger.error("Unknown error type:", typeof error);
2392
+ req.payload.logger.error({ errorType: typeof error }, "Unknown error type");
2425
2393
  }
2426
- req.payload.logger.error("Failed broadcast document (update operation):", {
2394
+ req.payload.logger.error({
2427
2395
  id: doc.id,
2428
2396
  subject: doc.subject,
2429
2397
  hasContent: !!doc.contentSection?.content,
2430
2398
  contentType: doc.contentSection?.content ? typeof doc.contentSection.content : "none"
2431
- });
2399
+ }, "Failed broadcast document (update operation)");
2432
2400
  }
2433
2401
  }
2434
2402
  return doc;
@@ -2474,7 +2442,7 @@ var createBroadcastsCollection = (pluginConfig) => {
2474
2442
  ...error.details
2475
2443
  });
2476
2444
  } else {
2477
- req.payload.logger.error(`Failed to send broadcast ${doc.id}:`, error);
2445
+ req.payload.logger.error({ error: String(error) }, `Failed to send broadcast ${doc.id}`);
2478
2446
  }
2479
2447
  await req.payload.update({
2480
2448
  collection: "broadcasts",
@@ -2517,7 +2485,7 @@ var createBroadcastsCollection = (pluginConfig) => {
2517
2485
  ...error.details
2518
2486
  });
2519
2487
  } else {
2520
- req.payload.logger.error("Failed to delete broadcast from provider:", error);
2488
+ req.payload.logger.error({ error: String(error) }, "Failed to delete broadcast from provider");
2521
2489
  }
2522
2490
  }
2523
2491
  return doc;