@djangocfg/api 1.2.39 → 1.2.40
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/dist/index.cjs +29 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +29 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/cfg/generated/client.ts +38 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.40",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "DjangoCFG",
|
|
6
6
|
"url": "https://djangocfg.com"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@types/node": "^22.15.3",
|
|
69
69
|
"@types/react": "19.2.2",
|
|
70
70
|
"@types/react-dom": "19.2.1",
|
|
71
|
-
"@djangocfg/typescript-config": "^1.2.
|
|
71
|
+
"@djangocfg/typescript-config": "^1.2.40",
|
|
72
72
|
"react": "^19.1.0",
|
|
73
73
|
"react-dom": "^19.1.0",
|
|
74
74
|
"tsup": "^8.5.0",
|
|
@@ -347,6 +347,44 @@ export class APIClient {
|
|
|
347
347
|
throw error;
|
|
348
348
|
}
|
|
349
349
|
|
|
350
|
+
// Detect CORS errors and dispatch event
|
|
351
|
+
const isCORSError = error instanceof TypeError &&
|
|
352
|
+
(error.message.toLowerCase().includes('cors') ||
|
|
353
|
+
error.message.toLowerCase().includes('failed to fetch') ||
|
|
354
|
+
error.message.toLowerCase().includes('network request failed'));
|
|
355
|
+
|
|
356
|
+
if (typeof window !== 'undefined') {
|
|
357
|
+
try {
|
|
358
|
+
if (isCORSError) {
|
|
359
|
+
// Dispatch CORS-specific error event
|
|
360
|
+
window.dispatchEvent(new CustomEvent('cors-error', {
|
|
361
|
+
detail: {
|
|
362
|
+
url: url,
|
|
363
|
+
method: method,
|
|
364
|
+
error: error instanceof Error ? error.message : String(error),
|
|
365
|
+
timestamp: new Date(),
|
|
366
|
+
},
|
|
367
|
+
bubbles: true,
|
|
368
|
+
cancelable: false,
|
|
369
|
+
}));
|
|
370
|
+
} else {
|
|
371
|
+
// Dispatch generic network error event
|
|
372
|
+
window.dispatchEvent(new CustomEvent('network-error', {
|
|
373
|
+
detail: {
|
|
374
|
+
url: url,
|
|
375
|
+
method: method,
|
|
376
|
+
error: error instanceof Error ? error.message : String(error),
|
|
377
|
+
timestamp: new Date(),
|
|
378
|
+
},
|
|
379
|
+
bubbles: true,
|
|
380
|
+
cancelable: false,
|
|
381
|
+
}));
|
|
382
|
+
}
|
|
383
|
+
} catch (eventError) {
|
|
384
|
+
// Silently fail - event dispatch should never crash the app
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
350
388
|
// Wrap other errors as NetworkError
|
|
351
389
|
const networkError = error instanceof Error
|
|
352
390
|
? new NetworkError(error.message, url, error)
|