payload-plugin-newsletter 0.25.6 → 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.
@@ -227,6 +227,7 @@ var init_broadcast2 = __esm({
227
227
  throw new Error(`Broadcast API error: ${response.status} - ${error}`);
228
228
  }
229
229
  const broadcast = await response.json();
230
+ console.log("[BroadcastApiProvider] GET response:", broadcast);
230
231
  return this.transformBroadcastFromApi(broadcast);
231
232
  } catch (error) {
232
233
  if (error instanceof BroadcastProviderError) throw error;
@@ -287,7 +288,7 @@ var init_broadcast2 = __esm({
287
288
  let result;
288
289
  try {
289
290
  result = JSON.parse(responseText);
290
- } catch (e) {
291
+ } catch {
291
292
  throw new Error(`Failed to parse response as JSON: ${responseText}`);
292
293
  }
293
294
  console.log("[BroadcastApiProvider] Parsed result:", result);
@@ -2293,12 +2294,22 @@ var createBroadcastsCollection = (pluginConfig) => {
2293
2294
  if (!hasProviders) return doc;
2294
2295
  if (operation === "create") {
2295
2296
  try {
2296
- req.payload.logger.info("Broadcast afterChange create hook - doc info:", {
2297
+ req.payload.logger.info("Broadcast afterChange CREATE hook (sync) - doc info:", {
2297
2298
  docId: doc.id,
2298
2299
  docIdType: typeof doc.id,
2299
2300
  hasDoc: !!doc,
2300
- operation
2301
+ operation,
2302
+ status: doc._status,
2303
+ hasExternalId: !!doc.externalId,
2304
+ hasProviderId: !!doc.providerId
2301
2305
  });
2306
+ if (doc.externalId || doc.providerId) {
2307
+ req.payload.logger.info("Broadcast already has provider IDs, skipping creation", {
2308
+ externalId: doc.externalId,
2309
+ providerId: doc.providerId
2310
+ });
2311
+ return doc;
2312
+ }
2302
2313
  const providerConfig = await getBroadcastConfig(req, pluginConfig);
2303
2314
  if (!providerConfig || !providerConfig.token) {
2304
2315
  req.payload.logger.error("Broadcast provider not configured in Newsletter Settings or environment variables");
@@ -2354,9 +2365,7 @@ var createBroadcastsCollection = (pluginConfig) => {
2354
2365
  req.payload.logger.error("Error details:", {
2355
2366
  message: error.message,
2356
2367
  stack: error.stack,
2357
- name: error.name,
2358
- // Check for any additional properties
2359
- ...error
2368
+ name: error.name
2360
2369
  });
2361
2370
  } else {
2362
2371
  req.payload.logger.error("Raw error:", error);