payload-plugin-newsletter 0.25.5 → 0.25.7

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,19 @@
1
+ ## [0.25.7] - 2025-08-19
2
+
3
+ ### Fixed
4
+ - Fixed TypeScript type errors in error handling code
5
+ - Resolved all linting errors (warnings remain but don't block the build)
6
+ - Simplified error logging to avoid type conversion issues
7
+
8
+ ## [0.25.6] - 2025-08-19
9
+
10
+ ### Changed
11
+ - Enhanced error logging for Broadcast API provider to diagnose connection issues
12
+ - Added detailed response logging for successful and failed API calls
13
+ - Improved error messages to show actual API responses
14
+ - Added logging for GET requests after broadcast creation
15
+ - Better JSON parsing error handling with response body details
16
+
1
17
  ## [0.25.5] - 2025-08-18
2
18
 
3
19
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BroadcastApiProvider
3
- } from "./chunk-XVMYJQRQ.js";
3
+ } from "./chunk-KZDNTLVF.js";
4
4
  export {
5
5
  BroadcastApiProvider
6
6
  };
@@ -157,6 +157,7 @@ var BroadcastApiProvider = class extends BaseBroadcastProvider {
157
157
  }
158
158
  async get(id) {
159
159
  try {
160
+ console.log("[BroadcastApiProvider] Getting broadcast with ID:", id);
160
161
  const response = await fetch(`${this.apiUrl}/api/v1/broadcasts/${id}`, {
161
162
  method: "GET",
162
163
  headers: {
@@ -231,7 +232,18 @@ var BroadcastApiProvider = class extends BaseBroadcastProvider {
231
232
  }
232
233
  throw new Error(`Broadcast API error: ${response.status} - ${errorText}`);
233
234
  }
234
- const result = await response.json();
235
+ const responseText = await response.text();
236
+ console.log("[BroadcastApiProvider] Success response body:", responseText);
237
+ let result;
238
+ try {
239
+ result = JSON.parse(responseText);
240
+ } catch {
241
+ throw new Error(`Failed to parse response as JSON: ${responseText}`);
242
+ }
243
+ console.log("[BroadcastApiProvider] Parsed result:", result);
244
+ if (!result.id) {
245
+ throw new Error(`Response missing expected 'id' field: ${JSON.stringify(result)}`);
246
+ }
235
247
  return this.get(result.id.toString());
236
248
  } catch (error) {
237
249
  if (error instanceof BroadcastProviderError) throw error;
@@ -229,6 +229,7 @@ var init_broadcast2 = __esm({
229
229
  }
230
230
  async get(id) {
231
231
  try {
232
+ console.log("[BroadcastApiProvider] Getting broadcast with ID:", id);
232
233
  const response = await fetch(`${this.apiUrl}/api/v1/broadcasts/${id}`, {
233
234
  method: "GET",
234
235
  headers: {
@@ -303,7 +304,18 @@ var init_broadcast2 = __esm({
303
304
  }
304
305
  throw new Error(`Broadcast API error: ${response.status} - ${errorText}`);
305
306
  }
306
- const result = await response.json();
307
+ const responseText = await response.text();
308
+ console.log("[BroadcastApiProvider] Success response body:", responseText);
309
+ let result;
310
+ try {
311
+ result = JSON.parse(responseText);
312
+ } catch {
313
+ throw new Error(`Failed to parse response as JSON: ${responseText}`);
314
+ }
315
+ console.log("[BroadcastApiProvider] Parsed result:", result);
316
+ if (!result.id) {
317
+ throw new Error(`Response missing expected 'id' field: ${JSON.stringify(result)}`);
318
+ }
307
319
  return this.get(result.id.toString());
308
320
  } catch (error) {
309
321
  if (error instanceof BroadcastProviderError) throw error;
@@ -2350,7 +2362,16 @@ var createBroadcastsCollection = (pluginConfig) => {
2350
2362
  providerData: providerBroadcast.providerData
2351
2363
  };
2352
2364
  } catch (error) {
2353
- req.payload.logger.error("Failed to create broadcast in provider during initial creation:", error);
2365
+ req.payload.logger.error("Failed to create broadcast in provider during initial creation:");
2366
+ if (error instanceof Error) {
2367
+ req.payload.logger.error("Error details:", {
2368
+ message: error.message,
2369
+ stack: error.stack,
2370
+ name: error.name
2371
+ });
2372
+ } else {
2373
+ req.payload.logger.error("Raw error:", error);
2374
+ }
2354
2375
  return doc;
2355
2376
  }
2356
2377
  }