@djangocfg/monitor 2.1.359 → 2.1.361
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 +68 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +68 -1
- package/dist/client.mjs.map +1 -1
- package/dist/index.cjs +67 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +67 -0
- package/dist/index.mjs.map +1 -1
- package/dist/server.cjs +67 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +67 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_monitor/openapi.json +197 -0
- package/src/_api/generated/helpers/auth.ts +27 -2
- package/src/_api/generated/openapi.json +197 -0
package/dist/client.cjs
CHANGED
|
@@ -100,6 +100,65 @@ __name(ensureSessionCookie, "ensureSessionCookie");
|
|
|
100
100
|
// src/client/store/index.ts
|
|
101
101
|
var import_vanilla = require("zustand/vanilla");
|
|
102
102
|
|
|
103
|
+
// src/_api/generated/helpers/errors.ts
|
|
104
|
+
var _APIError = class _APIError extends Error {
|
|
105
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
106
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
107
|
+
this.statusCode = statusCode;
|
|
108
|
+
this.statusText = statusText;
|
|
109
|
+
this.response = response;
|
|
110
|
+
this.url = url;
|
|
111
|
+
this.name = "APIError";
|
|
112
|
+
}
|
|
113
|
+
get details() {
|
|
114
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
115
|
+
return this.response;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
get fieldErrors() {
|
|
120
|
+
const details = this.details;
|
|
121
|
+
if (!details) return null;
|
|
122
|
+
const fieldErrors = {};
|
|
123
|
+
for (const [key, value] of Object.entries(details)) {
|
|
124
|
+
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
125
|
+
}
|
|
126
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
127
|
+
}
|
|
128
|
+
get errorMessage() {
|
|
129
|
+
const details = this.details;
|
|
130
|
+
if (!details) return this.message;
|
|
131
|
+
if (details.detail) {
|
|
132
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
133
|
+
}
|
|
134
|
+
if (details.error) return String(details.error);
|
|
135
|
+
if (details.message) return String(details.message);
|
|
136
|
+
const fieldErrors = this.fieldErrors;
|
|
137
|
+
if (fieldErrors) {
|
|
138
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
139
|
+
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
140
|
+
}
|
|
141
|
+
return this.message;
|
|
142
|
+
}
|
|
143
|
+
get isValidationError() {
|
|
144
|
+
return this.statusCode === 400;
|
|
145
|
+
}
|
|
146
|
+
get isAuthError() {
|
|
147
|
+
return this.statusCode === 401;
|
|
148
|
+
}
|
|
149
|
+
get isPermissionError() {
|
|
150
|
+
return this.statusCode === 403;
|
|
151
|
+
}
|
|
152
|
+
get isNotFoundError() {
|
|
153
|
+
return this.statusCode === 404;
|
|
154
|
+
}
|
|
155
|
+
get isServerError() {
|
|
156
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
__name(_APIError, "APIError");
|
|
160
|
+
var APIError = _APIError;
|
|
161
|
+
|
|
103
162
|
// src/_api/generated/helpers/auth.ts
|
|
104
163
|
var ACCESS_KEY = "cfg.access_token";
|
|
105
164
|
var REFRESH_KEY = "cfg.refresh_token";
|
|
@@ -178,6 +237,7 @@ function defaultBaseUrl() {
|
|
|
178
237
|
}
|
|
179
238
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
180
239
|
function defaultApiKey() {
|
|
240
|
+
if (isBrowser) return null;
|
|
181
241
|
try {
|
|
182
242
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
183
243
|
return process.env.NEXT_PUBLIC_API_KEY;
|
|
@@ -342,6 +402,13 @@ function installAuthOnClient(client2) {
|
|
|
342
402
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
343
403
|
return request;
|
|
344
404
|
});
|
|
405
|
+
client2.interceptors.error.use((err, res, req) => {
|
|
406
|
+
if (err instanceof APIError) return err;
|
|
407
|
+
const url = req?.url ?? "";
|
|
408
|
+
const status = res?.status ?? 0;
|
|
409
|
+
const statusText = res?.statusText ?? "";
|
|
410
|
+
return new APIError(status, statusText, err, url);
|
|
411
|
+
});
|
|
345
412
|
client2.interceptors.response.use(async (response, request) => {
|
|
346
413
|
if (response.status !== 401) return response;
|
|
347
414
|
if (request.headers.get(RETRY_MARKER)) {
|
|
@@ -1416,7 +1483,7 @@ __name(sendBatch, "sendBatch");
|
|
|
1416
1483
|
// src/client/utils/env.ts
|
|
1417
1484
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
1418
1485
|
var isProduction = !isDevelopment;
|
|
1419
|
-
var MONITOR_VERSION = "2.1.
|
|
1486
|
+
var MONITOR_VERSION = "2.1.361";
|
|
1420
1487
|
|
|
1421
1488
|
// src/client/constants.ts
|
|
1422
1489
|
var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;
|