@djangocfg/monitor 2.1.359 → 2.1.360
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/client.cjs +67 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +67 -1
- package/dist/client.mjs.map +1 -1
- package/dist/index.cjs +66 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +66 -0
- package/dist/index.mjs.map +1 -1
- package/dist/server.cjs +66 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +66 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/helpers/auth.ts +14 -0
package/dist/client.mjs
CHANGED
|
@@ -66,6 +66,65 @@ __name(ensureSessionCookie, "ensureSessionCookie");
|
|
|
66
66
|
// src/client/store/index.ts
|
|
67
67
|
import { createStore } from "zustand/vanilla";
|
|
68
68
|
|
|
69
|
+
// src/_api/generated/helpers/errors.ts
|
|
70
|
+
var _APIError = class _APIError extends Error {
|
|
71
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
72
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
73
|
+
this.statusCode = statusCode;
|
|
74
|
+
this.statusText = statusText;
|
|
75
|
+
this.response = response;
|
|
76
|
+
this.url = url;
|
|
77
|
+
this.name = "APIError";
|
|
78
|
+
}
|
|
79
|
+
get details() {
|
|
80
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
81
|
+
return this.response;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
get fieldErrors() {
|
|
86
|
+
const details = this.details;
|
|
87
|
+
if (!details) return null;
|
|
88
|
+
const fieldErrors = {};
|
|
89
|
+
for (const [key, value] of Object.entries(details)) {
|
|
90
|
+
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
91
|
+
}
|
|
92
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
93
|
+
}
|
|
94
|
+
get errorMessage() {
|
|
95
|
+
const details = this.details;
|
|
96
|
+
if (!details) return this.message;
|
|
97
|
+
if (details.detail) {
|
|
98
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
99
|
+
}
|
|
100
|
+
if (details.error) return String(details.error);
|
|
101
|
+
if (details.message) return String(details.message);
|
|
102
|
+
const fieldErrors = this.fieldErrors;
|
|
103
|
+
if (fieldErrors) {
|
|
104
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
105
|
+
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
106
|
+
}
|
|
107
|
+
return this.message;
|
|
108
|
+
}
|
|
109
|
+
get isValidationError() {
|
|
110
|
+
return this.statusCode === 400;
|
|
111
|
+
}
|
|
112
|
+
get isAuthError() {
|
|
113
|
+
return this.statusCode === 401;
|
|
114
|
+
}
|
|
115
|
+
get isPermissionError() {
|
|
116
|
+
return this.statusCode === 403;
|
|
117
|
+
}
|
|
118
|
+
get isNotFoundError() {
|
|
119
|
+
return this.statusCode === 404;
|
|
120
|
+
}
|
|
121
|
+
get isServerError() {
|
|
122
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
__name(_APIError, "APIError");
|
|
126
|
+
var APIError = _APIError;
|
|
127
|
+
|
|
69
128
|
// src/_api/generated/helpers/auth.ts
|
|
70
129
|
var ACCESS_KEY = "cfg.access_token";
|
|
71
130
|
var REFRESH_KEY = "cfg.refresh_token";
|
|
@@ -308,6 +367,13 @@ function installAuthOnClient(client2) {
|
|
|
308
367
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
309
368
|
return request;
|
|
310
369
|
});
|
|
370
|
+
client2.interceptors.error.use((err, res, req) => {
|
|
371
|
+
if (err instanceof APIError) return err;
|
|
372
|
+
const url = req?.url ?? "";
|
|
373
|
+
const status = res?.status ?? 0;
|
|
374
|
+
const statusText = res?.statusText ?? "";
|
|
375
|
+
return new APIError(status, statusText, err, url);
|
|
376
|
+
});
|
|
311
377
|
client2.interceptors.response.use(async (response, request) => {
|
|
312
378
|
if (response.status !== 401) return response;
|
|
313
379
|
if (request.headers.get(RETRY_MARKER)) {
|
|
@@ -1382,7 +1448,7 @@ __name(sendBatch, "sendBatch");
|
|
|
1382
1448
|
// src/client/utils/env.ts
|
|
1383
1449
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
1384
1450
|
var isProduction = !isDevelopment;
|
|
1385
|
-
var MONITOR_VERSION = "2.1.
|
|
1451
|
+
var MONITOR_VERSION = "2.1.360";
|
|
1386
1452
|
|
|
1387
1453
|
// src/client/constants.ts
|
|
1388
1454
|
var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;
|