payload-plugin-newsletter 0.25.7 → 0.25.8

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 CHANGED
@@ -1,3 +1,14 @@
1
+ ## [0.25.8] - 2025-08-19
2
+
3
+ ### Fixed
4
+ - Added check to prevent double broadcast creation if externalId/providerId already exists
5
+ - Enhanced logging to show document status and existing IDs during creation
6
+ - Added logging for GET broadcast response to diagnose sync issues
7
+ - Helps identify root cause of duplicate broadcast creation
8
+
9
+ ### Changed
10
+ - More descriptive hook logging to distinguish between sync and publish hooks
11
+
1
12
  ## [0.25.7] - 2025-08-19
2
13
 
3
14
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BroadcastApiProvider
3
- } from "./chunk-KZDNTLVF.js";
3
+ } from "./chunk-KETHRCG7.js";
4
4
  export {
5
5
  BroadcastApiProvider
6
6
  };
@@ -177,6 +177,7 @@ var BroadcastApiProvider = class extends BaseBroadcastProvider {
177
177
  throw new Error(`Broadcast API error: ${response.status} - ${error}`);
178
178
  }
179
179
  const broadcast = await response.json();
180
+ console.log("[BroadcastApiProvider] GET response:", broadcast);
180
181
  return this.transformBroadcastFromApi(broadcast);
181
182
  } catch (error) {
182
183
  if (error instanceof BroadcastProviderError) throw error;
@@ -249,6 +249,7 @@ var init_broadcast2 = __esm({
249
249
  throw new Error(`Broadcast API error: ${response.status} - ${error}`);
250
250
  }
251
251
  const broadcast = await response.json();
252
+ console.log("[BroadcastApiProvider] GET response:", broadcast);
252
253
  return this.transformBroadcastFromApi(broadcast);
253
254
  } catch (error) {
254
255
  if (error instanceof BroadcastProviderError) throw error;
@@ -2306,12 +2307,22 @@ var createBroadcastsCollection = (pluginConfig) => {
2306
2307
  if (!hasProviders) return doc;
2307
2308
  if (operation === "create") {
2308
2309
  try {
2309
- req.payload.logger.info("Broadcast afterChange create hook - doc info:", {
2310
+ req.payload.logger.info("Broadcast afterChange CREATE hook (sync) - doc info:", {
2310
2311
  docId: doc.id,
2311
2312
  docIdType: typeof doc.id,
2312
2313
  hasDoc: !!doc,
2313
- operation
2314
+ operation,
2315
+ status: doc._status,
2316
+ hasExternalId: !!doc.externalId,
2317
+ hasProviderId: !!doc.providerId
2314
2318
  });
2319
+ if (doc.externalId || doc.providerId) {
2320
+ req.payload.logger.info("Broadcast already has provider IDs, skipping creation", {
2321
+ externalId: doc.externalId,
2322
+ providerId: doc.providerId
2323
+ });
2324
+ return doc;
2325
+ }
2315
2326
  const providerConfig = await getBroadcastConfig(req, pluginConfig);
2316
2327
  if (!providerConfig || !providerConfig.token) {
2317
2328
  req.payload.logger.error("Broadcast provider not configured in Newsletter Settings or environment variables");