payload-plugin-newsletter 0.25.4 → 0.25.6
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 +17 -0
- package/dist/{broadcast-VMCYSZRY.js → broadcast-7DI2WOB3.js} +1 -1
- package/dist/{chunk-XVMYJQRQ.js → chunk-LLPN5SQN.js} +13 -1
- package/dist/collections.cjs +36 -12
- package/dist/collections.cjs.map +1 -1
- package/dist/collections.js +36 -12
- package/dist/collections.js.map +1 -1
- package/dist/server.js +30 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [0.25.6] - 2025-08-19
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
- Enhanced error logging for Broadcast API provider to diagnose connection issues
|
|
5
|
+
- Added detailed response logging for successful and failed API calls
|
|
6
|
+
- Improved error messages to show actual API responses
|
|
7
|
+
- Added logging for GET requests after broadcast creation
|
|
8
|
+
- Better JSON parsing error handling with response body details
|
|
9
|
+
|
|
10
|
+
## [0.25.5] - 2025-08-18
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
- Fixed "document not found" error when creating broadcasts by removing unnecessary update call during creation
|
|
14
|
+
- The afterChange hook now properly returns the modified document instead of trying to update it
|
|
15
|
+
- Added debug logging to help diagnose provider sync issues
|
|
16
|
+
- Ensures smooth broadcast creation without transaction conflicts
|
|
17
|
+
|
|
1
18
|
## [0.25.4] - 2025-08-18
|
|
2
19
|
|
|
3
20
|
### Fixed
|
|
@@ -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
|
|
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 (e) {
|
|
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;
|
package/dist/collections.cjs
CHANGED
|
@@ -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
|
|
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 (e) {
|
|
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;
|
|
@@ -2294,6 +2306,12 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
2294
2306
|
if (!hasProviders) return doc;
|
|
2295
2307
|
if (operation === "create") {
|
|
2296
2308
|
try {
|
|
2309
|
+
req.payload.logger.info("Broadcast afterChange create hook - doc info:", {
|
|
2310
|
+
docId: doc.id,
|
|
2311
|
+
docIdType: typeof doc.id,
|
|
2312
|
+
hasDoc: !!doc,
|
|
2313
|
+
operation
|
|
2314
|
+
});
|
|
2297
2315
|
const providerConfig = await getBroadcastConfig(req, pluginConfig);
|
|
2298
2316
|
if (!providerConfig || !providerConfig.token) {
|
|
2299
2317
|
req.payload.logger.error("Broadcast provider not configured in Newsletter Settings or environment variables");
|
|
@@ -2329,16 +2347,11 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
2329
2347
|
hasActualContent: !!doc.contentSection?.content
|
|
2330
2348
|
});
|
|
2331
2349
|
const providerBroadcast = await provider.create(createData);
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
externalId: providerBroadcast.id,
|
|
2338
|
-
// Set externalId to match providerId for webhook lookup
|
|
2339
|
-
providerData: providerBroadcast.providerData
|
|
2340
|
-
},
|
|
2341
|
-
req
|
|
2350
|
+
req.payload.logger.info("Provider broadcast created:", {
|
|
2351
|
+
providerBroadcastId: providerBroadcast.id,
|
|
2352
|
+
providerBroadcastIdType: typeof providerBroadcast.id,
|
|
2353
|
+
docId: doc.id,
|
|
2354
|
+
docIdType: typeof doc.id
|
|
2342
2355
|
});
|
|
2343
2356
|
req.payload.logger.info(`Broadcast ${doc.id} created in provider with ID ${providerBroadcast.id}`);
|
|
2344
2357
|
return {
|
|
@@ -2349,7 +2362,18 @@ var createBroadcastsCollection = (pluginConfig) => {
|
|
|
2349
2362
|
providerData: providerBroadcast.providerData
|
|
2350
2363
|
};
|
|
2351
2364
|
} catch (error) {
|
|
2352
|
-
req.payload.logger.error("Failed to create broadcast in provider during initial creation:"
|
|
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
|
+
// Check for any additional properties
|
|
2372
|
+
...error
|
|
2373
|
+
});
|
|
2374
|
+
} else {
|
|
2375
|
+
req.payload.logger.error("Raw error:", error);
|
|
2376
|
+
}
|
|
2353
2377
|
return doc;
|
|
2354
2378
|
}
|
|
2355
2379
|
}
|