@djangocfg/monitor 2.1.322 → 2.1.327
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 +956 -1126
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -39
- package/dist/client.d.ts +25 -39
- package/dist/client.mjs +956 -1137
- package/dist/client.mjs.map +1 -1
- package/dist/index.cjs +934 -1092
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -39
- package/dist/index.d.ts +25 -39
- package/dist/index.mjs +927 -1096
- package/dist/index.mjs.map +1 -1
- package/dist/server.cjs +915 -1092
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +25 -39
- package/dist/server.d.ts +25 -39
- package/dist/server.mjs +907 -1095
- package/dist/server.mjs.map +1 -1
- package/package.json +7 -2
- package/src/_api/generated/_shared/errors.ts +70 -0
- package/src/_api/generated/_shared/index.ts +25 -0
- package/src/_api/generated/_shared/logger.ts +123 -0
- package/src/_api/generated/_shared/storage.ts +83 -0
- package/src/_api/generated/_shared/validation-events.ts +52 -0
- package/src/_api/generated/cfg_monitor/api.ts +122 -0
- package/src/_api/generated/cfg_monitor/client/client.gen.ts +280 -0
- package/src/_api/generated/cfg_monitor/client/index.ts +25 -0
- package/src/_api/generated/cfg_monitor/client/types.gen.ts +217 -0
- package/src/_api/generated/cfg_monitor/client/utils.gen.ts +318 -0
- package/src/_api/generated/cfg_monitor/client.gen.ts +16 -0
- package/src/_api/generated/cfg_monitor/core/auth.gen.ts +41 -0
- package/src/_api/generated/cfg_monitor/core/bodySerializer.gen.ts +82 -0
- package/src/_api/generated/cfg_monitor/core/params.gen.ts +169 -0
- package/src/_api/generated/cfg_monitor/core/pathSerializer.gen.ts +171 -0
- package/src/_api/generated/cfg_monitor/core/queryKeySerializer.gen.ts +117 -0
- package/src/_api/generated/cfg_monitor/core/serverSentEvents.gen.ts +242 -0
- package/src/_api/generated/cfg_monitor/core/types.gen.ts +104 -0
- package/src/_api/generated/cfg_monitor/core/utils.gen.ts +140 -0
- package/src/_api/generated/cfg_monitor/events.ts +198 -0
- package/src/_api/generated/cfg_monitor/hooks/index.ts +4 -0
- package/src/_api/generated/cfg_monitor/hooks/useCfgMonitorIngestCreate.ts +24 -0
- package/src/_api/generated/cfg_monitor/index.ts +26 -314
- package/src/_api/generated/cfg_monitor/schemas/EventTypeEnum.ts +9 -0
- package/src/_api/generated/cfg_monitor/{_utils/schemas/FrontendEventIngestRequest.schema.ts → schemas/FrontendEventIngestRequest.ts} +12 -19
- package/src/_api/generated/cfg_monitor/schemas/IngestBatchRequest.ts +12 -0
- package/src/_api/generated/cfg_monitor/schemas/LevelEnum.ts +9 -0
- package/src/_api/generated/cfg_monitor/schemas/index.ts +7 -0
- package/src/_api/generated/cfg_monitor/sdk.gen.ts +55 -0
- package/src/_api/generated/cfg_monitor/types.gen.ts +79 -0
- package/src/_api/generated/index.ts +22 -0
- package/src/_api/index.ts +2 -2
- package/src/client/capture/console.ts +2 -3
- package/src/client/transport/ingest.ts +21 -17
- package/src/server/index.ts +3 -2
- package/src/_api/generated/cfg_monitor/CLAUDE.md +0 -60
- package/src/_api/generated/cfg_monitor/_utils/fetchers/index.ts +0 -30
- package/src/_api/generated/cfg_monitor/_utils/fetchers/monitor.ts +0 -51
- package/src/_api/generated/cfg_monitor/_utils/hooks/index.ts +0 -30
- package/src/_api/generated/cfg_monitor/_utils/hooks/monitor.ts +0 -43
- package/src/_api/generated/cfg_monitor/_utils/schemas/IngestBatchRequest.schema.ts +0 -20
- package/src/_api/generated/cfg_monitor/_utils/schemas/index.ts +0 -22
- package/src/_api/generated/cfg_monitor/api-instance.ts +0 -181
- package/src/_api/generated/cfg_monitor/client.ts +0 -330
- package/src/_api/generated/cfg_monitor/enums.ts +0 -34
- package/src/_api/generated/cfg_monitor/errors.ts +0 -123
- package/src/_api/generated/cfg_monitor/http.ts +0 -160
- package/src/_api/generated/cfg_monitor/logger.ts +0 -261
- package/src/_api/generated/cfg_monitor/monitor/client.ts +0 -26
- package/src/_api/generated/cfg_monitor/monitor/index.ts +0 -4
- package/src/_api/generated/cfg_monitor/monitor/models.ts +0 -47
- package/src/_api/generated/cfg_monitor/retry.ts +0 -177
- package/src/_api/generated/cfg_monitor/schema.json +0 -181
- package/src/_api/generated/cfg_monitor/storage.ts +0 -163
- package/src/_api/generated/cfg_monitor/validation-events.ts +0 -135
package/dist/client.cjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
-
};
|
|
13
8
|
var __export = (target, all) => {
|
|
14
9
|
for (var name in all)
|
|
15
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -22,251 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
22
17
|
}
|
|
23
18
|
return to;
|
|
24
19
|
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
-
mod
|
|
32
|
-
));
|
|
33
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
21
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
35
22
|
|
|
36
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
|
|
37
|
-
var require_retry_operation = __commonJS({
|
|
38
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module2) {
|
|
39
|
-
function RetryOperation(timeouts, options) {
|
|
40
|
-
if (typeof options === "boolean") {
|
|
41
|
-
options = { forever: options };
|
|
42
|
-
}
|
|
43
|
-
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
44
|
-
this._timeouts = timeouts;
|
|
45
|
-
this._options = options || {};
|
|
46
|
-
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
47
|
-
this._fn = null;
|
|
48
|
-
this._errors = [];
|
|
49
|
-
this._attempts = 1;
|
|
50
|
-
this._operationTimeout = null;
|
|
51
|
-
this._operationTimeoutCb = null;
|
|
52
|
-
this._timeout = null;
|
|
53
|
-
this._operationStart = null;
|
|
54
|
-
this._timer = null;
|
|
55
|
-
if (this._options.forever) {
|
|
56
|
-
this._cachedTimeouts = this._timeouts.slice(0);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
__name(RetryOperation, "RetryOperation");
|
|
60
|
-
module2.exports = RetryOperation;
|
|
61
|
-
RetryOperation.prototype.reset = function() {
|
|
62
|
-
this._attempts = 1;
|
|
63
|
-
this._timeouts = this._originalTimeouts.slice(0);
|
|
64
|
-
};
|
|
65
|
-
RetryOperation.prototype.stop = function() {
|
|
66
|
-
if (this._timeout) {
|
|
67
|
-
clearTimeout(this._timeout);
|
|
68
|
-
}
|
|
69
|
-
if (this._timer) {
|
|
70
|
-
clearTimeout(this._timer);
|
|
71
|
-
}
|
|
72
|
-
this._timeouts = [];
|
|
73
|
-
this._cachedTimeouts = null;
|
|
74
|
-
};
|
|
75
|
-
RetryOperation.prototype.retry = function(err) {
|
|
76
|
-
if (this._timeout) {
|
|
77
|
-
clearTimeout(this._timeout);
|
|
78
|
-
}
|
|
79
|
-
if (!err) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
83
|
-
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
84
|
-
this._errors.push(err);
|
|
85
|
-
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
this._errors.push(err);
|
|
89
|
-
var timeout = this._timeouts.shift();
|
|
90
|
-
if (timeout === void 0) {
|
|
91
|
-
if (this._cachedTimeouts) {
|
|
92
|
-
this._errors.splice(0, this._errors.length - 1);
|
|
93
|
-
timeout = this._cachedTimeouts.slice(-1);
|
|
94
|
-
} else {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
var self = this;
|
|
99
|
-
this._timer = setTimeout(function() {
|
|
100
|
-
self._attempts++;
|
|
101
|
-
if (self._operationTimeoutCb) {
|
|
102
|
-
self._timeout = setTimeout(function() {
|
|
103
|
-
self._operationTimeoutCb(self._attempts);
|
|
104
|
-
}, self._operationTimeout);
|
|
105
|
-
if (self._options.unref) {
|
|
106
|
-
self._timeout.unref();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
self._fn(self._attempts);
|
|
110
|
-
}, timeout);
|
|
111
|
-
if (this._options.unref) {
|
|
112
|
-
this._timer.unref();
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
};
|
|
116
|
-
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
117
|
-
this._fn = fn;
|
|
118
|
-
if (timeoutOps) {
|
|
119
|
-
if (timeoutOps.timeout) {
|
|
120
|
-
this._operationTimeout = timeoutOps.timeout;
|
|
121
|
-
}
|
|
122
|
-
if (timeoutOps.cb) {
|
|
123
|
-
this._operationTimeoutCb = timeoutOps.cb;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
var self = this;
|
|
127
|
-
if (this._operationTimeoutCb) {
|
|
128
|
-
this._timeout = setTimeout(function() {
|
|
129
|
-
self._operationTimeoutCb();
|
|
130
|
-
}, self._operationTimeout);
|
|
131
|
-
}
|
|
132
|
-
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
133
|
-
this._fn(this._attempts);
|
|
134
|
-
};
|
|
135
|
-
RetryOperation.prototype.try = function(fn) {
|
|
136
|
-
console.log("Using RetryOperation.try() is deprecated");
|
|
137
|
-
this.attempt(fn);
|
|
138
|
-
};
|
|
139
|
-
RetryOperation.prototype.start = function(fn) {
|
|
140
|
-
console.log("Using RetryOperation.start() is deprecated");
|
|
141
|
-
this.attempt(fn);
|
|
142
|
-
};
|
|
143
|
-
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
144
|
-
RetryOperation.prototype.errors = function() {
|
|
145
|
-
return this._errors;
|
|
146
|
-
};
|
|
147
|
-
RetryOperation.prototype.attempts = function() {
|
|
148
|
-
return this._attempts;
|
|
149
|
-
};
|
|
150
|
-
RetryOperation.prototype.mainError = function() {
|
|
151
|
-
if (this._errors.length === 0) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
var counts = {};
|
|
155
|
-
var mainError = null;
|
|
156
|
-
var mainErrorCount = 0;
|
|
157
|
-
for (var i = 0; i < this._errors.length; i++) {
|
|
158
|
-
var error = this._errors[i];
|
|
159
|
-
var message = error.message;
|
|
160
|
-
var count = (counts[message] || 0) + 1;
|
|
161
|
-
counts[message] = count;
|
|
162
|
-
if (count >= mainErrorCount) {
|
|
163
|
-
mainError = error;
|
|
164
|
-
mainErrorCount = count;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return mainError;
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
|
|
173
|
-
var require_retry = __commonJS({
|
|
174
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
|
|
175
|
-
var RetryOperation = require_retry_operation();
|
|
176
|
-
exports.operation = function(options) {
|
|
177
|
-
var timeouts = exports.timeouts(options);
|
|
178
|
-
return new RetryOperation(timeouts, {
|
|
179
|
-
forever: options && (options.forever || options.retries === Infinity),
|
|
180
|
-
unref: options && options.unref,
|
|
181
|
-
maxRetryTime: options && options.maxRetryTime
|
|
182
|
-
});
|
|
183
|
-
};
|
|
184
|
-
exports.timeouts = function(options) {
|
|
185
|
-
if (options instanceof Array) {
|
|
186
|
-
return [].concat(options);
|
|
187
|
-
}
|
|
188
|
-
var opts = {
|
|
189
|
-
retries: 10,
|
|
190
|
-
factor: 2,
|
|
191
|
-
minTimeout: 1 * 1e3,
|
|
192
|
-
maxTimeout: Infinity,
|
|
193
|
-
randomize: false
|
|
194
|
-
};
|
|
195
|
-
for (var key in options) {
|
|
196
|
-
opts[key] = options[key];
|
|
197
|
-
}
|
|
198
|
-
if (opts.minTimeout > opts.maxTimeout) {
|
|
199
|
-
throw new Error("minTimeout is greater than maxTimeout");
|
|
200
|
-
}
|
|
201
|
-
var timeouts = [];
|
|
202
|
-
for (var i = 0; i < opts.retries; i++) {
|
|
203
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
204
|
-
}
|
|
205
|
-
if (options && options.forever && !timeouts.length) {
|
|
206
|
-
timeouts.push(this.createTimeout(i, opts));
|
|
207
|
-
}
|
|
208
|
-
timeouts.sort(function(a, b) {
|
|
209
|
-
return a - b;
|
|
210
|
-
});
|
|
211
|
-
return timeouts;
|
|
212
|
-
};
|
|
213
|
-
exports.createTimeout = function(attempt, opts) {
|
|
214
|
-
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
215
|
-
var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
|
|
216
|
-
timeout = Math.min(timeout, opts.maxTimeout);
|
|
217
|
-
return timeout;
|
|
218
|
-
};
|
|
219
|
-
exports.wrap = function(obj, options, methods) {
|
|
220
|
-
if (options instanceof Array) {
|
|
221
|
-
methods = options;
|
|
222
|
-
options = null;
|
|
223
|
-
}
|
|
224
|
-
if (!methods) {
|
|
225
|
-
methods = [];
|
|
226
|
-
for (var key in obj) {
|
|
227
|
-
if (typeof obj[key] === "function") {
|
|
228
|
-
methods.push(key);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
for (var i = 0; i < methods.length; i++) {
|
|
233
|
-
var method = methods[i];
|
|
234
|
-
var original = obj[method];
|
|
235
|
-
obj[method] = (/* @__PURE__ */ __name(function retryWrapper(original2) {
|
|
236
|
-
var op = exports.operation(options);
|
|
237
|
-
var args = Array.prototype.slice.call(arguments, 1);
|
|
238
|
-
var callback = args.pop();
|
|
239
|
-
args.push(function(err) {
|
|
240
|
-
if (op.retry(err)) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
if (err) {
|
|
244
|
-
arguments[0] = op.mainError();
|
|
245
|
-
}
|
|
246
|
-
callback.apply(this, arguments);
|
|
247
|
-
});
|
|
248
|
-
op.attempt(function() {
|
|
249
|
-
original2.apply(obj, args);
|
|
250
|
-
});
|
|
251
|
-
}, "retryWrapper")).bind(obj, original);
|
|
252
|
-
obj[method].options = options;
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
|
|
259
|
-
var require_retry2 = __commonJS({
|
|
260
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module2) {
|
|
261
|
-
module2.exports = require_retry();
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
|
|
265
23
|
// src/client/index.ts
|
|
266
24
|
var client_exports = {};
|
|
267
25
|
__export(client_exports, {
|
|
268
|
-
EventLevel: () =>
|
|
269
|
-
EventType: () =>
|
|
26
|
+
EventLevel: () => LevelEnum,
|
|
27
|
+
EventType: () => EventTypeEnum,
|
|
270
28
|
FrontendMonitor: () => FrontendMonitor,
|
|
271
29
|
MONITOR_VERSION: () => MONITOR_VERSION,
|
|
272
30
|
MonitorProvider: () => MonitorProvider,
|
|
@@ -342,200 +100,864 @@ __name(ensureSessionCookie, "ensureSessionCookie");
|
|
|
342
100
|
// src/client/store/index.ts
|
|
343
101
|
var import_vanilla = require("zustand/vanilla");
|
|
344
102
|
|
|
345
|
-
// src/_api/generated/cfg_monitor/
|
|
346
|
-
var
|
|
347
|
-
|
|
348
|
-
__publicField(this, "client");
|
|
349
|
-
this.client = client;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Ingest browser events
|
|
353
|
-
*
|
|
354
|
-
* Accepts a batch of up to 50 frontend events. No authentication required
|
|
355
|
-
* — anonymous visitors can send events.
|
|
356
|
-
*/
|
|
357
|
-
async ingestCreate(data) {
|
|
358
|
-
const response = await this.client.request("POST", "/cfg/monitor/ingest/", { body: data });
|
|
359
|
-
return response;
|
|
360
|
-
}
|
|
103
|
+
// src/_api/generated/cfg_monitor/core/bodySerializer.gen.ts
|
|
104
|
+
var jsonBodySerializer = {
|
|
105
|
+
bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
|
|
361
106
|
};
|
|
362
|
-
__name(_Monitor, "Monitor");
|
|
363
|
-
var Monitor = _Monitor;
|
|
364
107
|
|
|
365
|
-
// src/_api/generated/cfg_monitor/
|
|
366
|
-
var
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
108
|
+
// src/_api/generated/cfg_monitor/core/params.gen.ts
|
|
109
|
+
var extraPrefixesMap = {
|
|
110
|
+
$body_: "body",
|
|
111
|
+
$headers_: "headers",
|
|
112
|
+
$path_: "path",
|
|
113
|
+
$query_: "query"
|
|
114
|
+
};
|
|
115
|
+
var extraPrefixes = Object.entries(extraPrefixesMap);
|
|
116
|
+
|
|
117
|
+
// src/_api/generated/cfg_monitor/core/serverSentEvents.gen.ts
|
|
118
|
+
function createSseClient({
|
|
119
|
+
onRequest,
|
|
120
|
+
onSseError,
|
|
121
|
+
onSseEvent,
|
|
122
|
+
responseTransformer,
|
|
123
|
+
responseValidator,
|
|
124
|
+
sseDefaultRetryDelay,
|
|
125
|
+
sseMaxRetryAttempts,
|
|
126
|
+
sseMaxRetryDelay,
|
|
127
|
+
sseSleepFn,
|
|
128
|
+
url,
|
|
129
|
+
...options
|
|
130
|
+
}) {
|
|
131
|
+
let lastEventId;
|
|
132
|
+
const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
133
|
+
const createStream = /* @__PURE__ */ __name(async function* () {
|
|
134
|
+
let retryDelay = sseDefaultRetryDelay ?? 3e3;
|
|
135
|
+
let attempt = 0;
|
|
136
|
+
const signal = options.signal ?? new AbortController().signal;
|
|
137
|
+
while (true) {
|
|
138
|
+
if (signal.aborted) break;
|
|
139
|
+
attempt++;
|
|
140
|
+
const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
|
|
141
|
+
if (lastEventId !== void 0) {
|
|
142
|
+
headers.set("Last-Event-ID", lastEventId);
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
const requestInit = {
|
|
146
|
+
redirect: "follow",
|
|
147
|
+
...options,
|
|
148
|
+
body: options.serializedBody,
|
|
149
|
+
headers,
|
|
150
|
+
signal
|
|
151
|
+
};
|
|
152
|
+
let request = new Request(url, requestInit);
|
|
153
|
+
if (onRequest) {
|
|
154
|
+
request = await onRequest(url, requestInit);
|
|
375
155
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
156
|
+
const _fetch = options.fetch ?? globalThis.fetch;
|
|
157
|
+
const response = await _fetch(request);
|
|
158
|
+
if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
|
|
159
|
+
if (!response.body) throw new Error("No body in SSE response");
|
|
160
|
+
const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
|
|
161
|
+
let buffer = "";
|
|
162
|
+
const abortHandler = /* @__PURE__ */ __name(() => {
|
|
163
|
+
try {
|
|
164
|
+
reader.cancel();
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
}, "abortHandler");
|
|
168
|
+
signal.addEventListener("abort", abortHandler);
|
|
169
|
+
try {
|
|
170
|
+
while (true) {
|
|
171
|
+
const { done, value } = await reader.read();
|
|
172
|
+
if (done) break;
|
|
173
|
+
buffer += value;
|
|
174
|
+
buffer = buffer.replace(/\r\n?/g, "\n");
|
|
175
|
+
const chunks = buffer.split("\n\n");
|
|
176
|
+
buffer = chunks.pop() ?? "";
|
|
177
|
+
for (const chunk of chunks) {
|
|
178
|
+
const lines = chunk.split("\n");
|
|
179
|
+
const dataLines = [];
|
|
180
|
+
let eventName;
|
|
181
|
+
for (const line of lines) {
|
|
182
|
+
if (line.startsWith("data:")) {
|
|
183
|
+
dataLines.push(line.replace(/^data:\s*/, ""));
|
|
184
|
+
} else if (line.startsWith("event:")) {
|
|
185
|
+
eventName = line.replace(/^event:\s*/, "");
|
|
186
|
+
} else if (line.startsWith("id:")) {
|
|
187
|
+
lastEventId = line.replace(/^id:\s*/, "");
|
|
188
|
+
} else if (line.startsWith("retry:")) {
|
|
189
|
+
const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
|
|
190
|
+
if (!Number.isNaN(parsed)) {
|
|
191
|
+
retryDelay = parsed;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
let data;
|
|
196
|
+
let parsedJson = false;
|
|
197
|
+
if (dataLines.length) {
|
|
198
|
+
const rawData = dataLines.join("\n");
|
|
199
|
+
try {
|
|
200
|
+
data = JSON.parse(rawData);
|
|
201
|
+
parsedJson = true;
|
|
202
|
+
} catch {
|
|
203
|
+
data = rawData;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (parsedJson) {
|
|
207
|
+
if (responseValidator) {
|
|
208
|
+
await responseValidator(data);
|
|
209
|
+
}
|
|
210
|
+
if (responseTransformer) {
|
|
211
|
+
data = await responseTransformer(data);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
onSseEvent?.({
|
|
215
|
+
data,
|
|
216
|
+
event: eventName,
|
|
217
|
+
id: lastEventId,
|
|
218
|
+
retry: retryDelay
|
|
219
|
+
});
|
|
220
|
+
if (dataLines.length) {
|
|
221
|
+
yield data;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} finally {
|
|
226
|
+
signal.removeEventListener("abort", abortHandler);
|
|
227
|
+
reader.releaseLock();
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
} catch (error) {
|
|
231
|
+
onSseError?.(error);
|
|
232
|
+
if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
|
|
236
|
+
await sleep(backoff);
|
|
380
237
|
}
|
|
381
238
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
239
|
+
}, "createStream");
|
|
240
|
+
const stream = createStream();
|
|
241
|
+
return { stream };
|
|
242
|
+
}
|
|
243
|
+
__name(createSseClient, "createSseClient");
|
|
244
|
+
|
|
245
|
+
// src/_api/generated/cfg_monitor/core/pathSerializer.gen.ts
|
|
246
|
+
var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
|
|
247
|
+
switch (style) {
|
|
248
|
+
case "label":
|
|
249
|
+
return ".";
|
|
250
|
+
case "matrix":
|
|
251
|
+
return ";";
|
|
252
|
+
case "simple":
|
|
253
|
+
return ",";
|
|
254
|
+
default:
|
|
255
|
+
return "&";
|
|
256
|
+
}
|
|
257
|
+
}, "separatorArrayExplode");
|
|
258
|
+
var separatorArrayNoExplode = /* @__PURE__ */ __name((style) => {
|
|
259
|
+
switch (style) {
|
|
260
|
+
case "form":
|
|
261
|
+
return ",";
|
|
262
|
+
case "pipeDelimited":
|
|
263
|
+
return "|";
|
|
264
|
+
case "spaceDelimited":
|
|
265
|
+
return "%20";
|
|
266
|
+
default:
|
|
267
|
+
return ",";
|
|
268
|
+
}
|
|
269
|
+
}, "separatorArrayNoExplode");
|
|
270
|
+
var separatorObjectExplode = /* @__PURE__ */ __name((style) => {
|
|
271
|
+
switch (style) {
|
|
272
|
+
case "label":
|
|
273
|
+
return ".";
|
|
274
|
+
case "matrix":
|
|
275
|
+
return ";";
|
|
276
|
+
case "simple":
|
|
277
|
+
return ",";
|
|
278
|
+
default:
|
|
279
|
+
return "&";
|
|
280
|
+
}
|
|
281
|
+
}, "separatorObjectExplode");
|
|
282
|
+
var serializeArrayParam = /* @__PURE__ */ __name(({
|
|
283
|
+
allowReserved,
|
|
284
|
+
explode,
|
|
285
|
+
name,
|
|
286
|
+
style,
|
|
287
|
+
value
|
|
288
|
+
}) => {
|
|
289
|
+
if (!explode) {
|
|
290
|
+
const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
|
|
291
|
+
switch (style) {
|
|
292
|
+
case "label":
|
|
293
|
+
return `.${joinedValues2}`;
|
|
294
|
+
case "matrix":
|
|
295
|
+
return `;${name}=${joinedValues2}`;
|
|
296
|
+
case "simple":
|
|
297
|
+
return joinedValues2;
|
|
298
|
+
default:
|
|
299
|
+
return `${name}=${joinedValues2}`;
|
|
392
300
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
// Include Django session cookies
|
|
399
|
-
});
|
|
400
|
-
let data = null;
|
|
401
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
402
|
-
if (response.status !== 204) {
|
|
403
|
-
if (responseType === "blob") {
|
|
404
|
-
data = await response.blob();
|
|
405
|
-
} else if (responseType === "text") {
|
|
406
|
-
data = await response.text();
|
|
407
|
-
} else if (responseType === "json") {
|
|
408
|
-
data = await response.json();
|
|
409
|
-
} else if (contentType.includes("application/json")) {
|
|
410
|
-
data = await response.json();
|
|
411
|
-
} else if (contentType.startsWith("text/")) {
|
|
412
|
-
data = await response.text();
|
|
413
|
-
} else {
|
|
414
|
-
data = await response.blob();
|
|
415
|
-
}
|
|
301
|
+
}
|
|
302
|
+
const separator = separatorArrayExplode(style);
|
|
303
|
+
const joinedValues = value.map((v) => {
|
|
304
|
+
if (style === "label" || style === "simple") {
|
|
305
|
+
return allowReserved ? v : encodeURIComponent(v);
|
|
416
306
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
307
|
+
return serializePrimitiveParam({
|
|
308
|
+
allowReserved,
|
|
309
|
+
name,
|
|
310
|
+
value: v
|
|
420
311
|
});
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
312
|
+
}).join(separator);
|
|
313
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
314
|
+
}, "serializeArrayParam");
|
|
315
|
+
var serializePrimitiveParam = /* @__PURE__ */ __name(({
|
|
316
|
+
allowReserved,
|
|
317
|
+
name,
|
|
318
|
+
value
|
|
319
|
+
}) => {
|
|
320
|
+
if (value === void 0 || value === null) {
|
|
321
|
+
return "";
|
|
322
|
+
}
|
|
323
|
+
if (typeof value === "object") {
|
|
324
|
+
throw new Error(
|
|
325
|
+
"Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
|
|
326
|
+
);
|
|
427
327
|
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
var
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
328
|
+
return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
|
|
329
|
+
}, "serializePrimitiveParam");
|
|
330
|
+
var serializeObjectParam = /* @__PURE__ */ __name(({
|
|
331
|
+
allowReserved,
|
|
332
|
+
explode,
|
|
333
|
+
name,
|
|
334
|
+
style,
|
|
335
|
+
value,
|
|
336
|
+
valueOnly
|
|
337
|
+
}) => {
|
|
338
|
+
if (value instanceof Date) {
|
|
339
|
+
return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
|
|
340
|
+
}
|
|
341
|
+
if (style !== "deepObject" && !explode) {
|
|
342
|
+
let values = [];
|
|
343
|
+
Object.entries(value).forEach(([key, v]) => {
|
|
344
|
+
values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
|
|
345
|
+
});
|
|
346
|
+
const joinedValues2 = values.join(",");
|
|
347
|
+
switch (style) {
|
|
348
|
+
case "form":
|
|
349
|
+
return `${name}=${joinedValues2}`;
|
|
350
|
+
case "label":
|
|
351
|
+
return `.${joinedValues2}`;
|
|
352
|
+
case "matrix":
|
|
353
|
+
return `;${name}=${joinedValues2}`;
|
|
354
|
+
default:
|
|
355
|
+
return joinedValues2;
|
|
439
356
|
}
|
|
440
357
|
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
358
|
+
const separator = separatorObjectExplode(style);
|
|
359
|
+
const joinedValues = Object.entries(value).map(
|
|
360
|
+
([key, v]) => serializePrimitiveParam({
|
|
361
|
+
allowReserved,
|
|
362
|
+
name: style === "deepObject" ? `${name}[${key}]` : key,
|
|
363
|
+
value: v
|
|
364
|
+
})
|
|
365
|
+
).join(separator);
|
|
366
|
+
return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
|
|
367
|
+
}, "serializeObjectParam");
|
|
444
368
|
|
|
445
|
-
// src/_api/generated/cfg_monitor/
|
|
446
|
-
var
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
369
|
+
// src/_api/generated/cfg_monitor/core/utils.gen.ts
|
|
370
|
+
var PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
371
|
+
var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
|
|
372
|
+
let url = _url;
|
|
373
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
374
|
+
if (matches) {
|
|
375
|
+
for (const match of matches) {
|
|
376
|
+
let explode = false;
|
|
377
|
+
let name = match.substring(1, match.length - 1);
|
|
378
|
+
let style = "simple";
|
|
379
|
+
if (name.endsWith("*")) {
|
|
380
|
+
explode = true;
|
|
381
|
+
name = name.substring(0, name.length - 1);
|
|
382
|
+
}
|
|
383
|
+
if (name.startsWith(".")) {
|
|
384
|
+
name = name.substring(1);
|
|
385
|
+
style = "label";
|
|
386
|
+
} else if (name.startsWith(";")) {
|
|
387
|
+
name = name.substring(1);
|
|
388
|
+
style = "matrix";
|
|
389
|
+
}
|
|
390
|
+
const value = path[name];
|
|
391
|
+
if (value === void 0 || value === null) {
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
if (Array.isArray(value)) {
|
|
395
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (typeof value === "object") {
|
|
399
|
+
url = url.replace(
|
|
400
|
+
match,
|
|
401
|
+
serializeObjectParam({
|
|
402
|
+
explode,
|
|
403
|
+
name,
|
|
404
|
+
style,
|
|
405
|
+
value,
|
|
406
|
+
valueOnly: true
|
|
407
|
+
})
|
|
408
|
+
);
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (style === "matrix") {
|
|
412
|
+
url = url.replace(
|
|
413
|
+
match,
|
|
414
|
+
`;${serializePrimitiveParam({
|
|
415
|
+
name,
|
|
416
|
+
value
|
|
417
|
+
})}`
|
|
418
|
+
);
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
const replaceValue = encodeURIComponent(
|
|
422
|
+
style === "label" ? `.${value}` : value
|
|
423
|
+
);
|
|
424
|
+
url = url.replace(match, replaceValue);
|
|
425
|
+
}
|
|
454
426
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
427
|
+
return url;
|
|
428
|
+
}, "defaultPathSerializer");
|
|
429
|
+
var getUrl = /* @__PURE__ */ __name(({
|
|
430
|
+
baseUrl,
|
|
431
|
+
path,
|
|
432
|
+
query,
|
|
433
|
+
querySerializer,
|
|
434
|
+
url: _url
|
|
435
|
+
}) => {
|
|
436
|
+
const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
|
|
437
|
+
let url = (baseUrl ?? "") + pathUrl;
|
|
438
|
+
if (path) {
|
|
439
|
+
url = defaultPathSerializer({ path, url });
|
|
440
|
+
}
|
|
441
|
+
let search = query ? querySerializer(query) : "";
|
|
442
|
+
if (search.startsWith("?")) {
|
|
443
|
+
search = search.substring(1);
|
|
444
|
+
}
|
|
445
|
+
if (search) {
|
|
446
|
+
url += `?${search}`;
|
|
447
|
+
}
|
|
448
|
+
return url;
|
|
449
|
+
}, "getUrl");
|
|
450
|
+
function getValidRequestBody(options) {
|
|
451
|
+
const hasBody = options.body !== void 0;
|
|
452
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
453
|
+
if (isSerializedBody) {
|
|
454
|
+
if ("serializedBody" in options) {
|
|
455
|
+
const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
|
|
456
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
462
457
|
}
|
|
463
|
-
return null;
|
|
458
|
+
return options.body !== "" ? options.body : null;
|
|
464
459
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
460
|
+
if (hasBody) {
|
|
461
|
+
return options.body;
|
|
462
|
+
}
|
|
463
|
+
return void 0;
|
|
464
|
+
}
|
|
465
|
+
__name(getValidRequestBody, "getValidRequestBody");
|
|
466
|
+
|
|
467
|
+
// src/_api/generated/cfg_monitor/core/auth.gen.ts
|
|
468
|
+
var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
|
|
469
|
+
const token = typeof callback === "function" ? await callback(auth) : callback;
|
|
470
|
+
if (!token) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (auth.scheme === "bearer") {
|
|
474
|
+
return `Bearer ${token}`;
|
|
475
|
+
}
|
|
476
|
+
if (auth.scheme === "basic") {
|
|
477
|
+
return `Basic ${btoa(token)}`;
|
|
478
|
+
}
|
|
479
|
+
return token;
|
|
480
|
+
}, "getAuthToken");
|
|
481
|
+
|
|
482
|
+
// src/_api/generated/cfg_monitor/client/utils.gen.ts
|
|
483
|
+
var createQuerySerializer = /* @__PURE__ */ __name(({
|
|
484
|
+
parameters = {},
|
|
485
|
+
...args
|
|
486
|
+
} = {}) => {
|
|
487
|
+
const querySerializer = /* @__PURE__ */ __name((queryParams) => {
|
|
488
|
+
const search = [];
|
|
489
|
+
if (queryParams && typeof queryParams === "object") {
|
|
490
|
+
for (const name in queryParams) {
|
|
491
|
+
const value = queryParams[name];
|
|
492
|
+
if (value === void 0 || value === null) {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
const options = parameters[name] || args;
|
|
496
|
+
if (Array.isArray(value)) {
|
|
497
|
+
const serializedArray = serializeArrayParam({
|
|
498
|
+
allowReserved: options.allowReserved,
|
|
499
|
+
explode: true,
|
|
500
|
+
name,
|
|
501
|
+
style: "form",
|
|
502
|
+
value,
|
|
503
|
+
...options.array
|
|
504
|
+
});
|
|
505
|
+
if (serializedArray) search.push(serializedArray);
|
|
506
|
+
} else if (typeof value === "object") {
|
|
507
|
+
const serializedObject = serializeObjectParam({
|
|
508
|
+
allowReserved: options.allowReserved,
|
|
509
|
+
explode: true,
|
|
510
|
+
name,
|
|
511
|
+
style: "deepObject",
|
|
512
|
+
value,
|
|
513
|
+
...options.object
|
|
514
|
+
});
|
|
515
|
+
if (serializedObject) search.push(serializedObject);
|
|
516
|
+
} else {
|
|
517
|
+
const serializedPrimitive = serializePrimitiveParam({
|
|
518
|
+
allowReserved: options.allowReserved,
|
|
519
|
+
name,
|
|
520
|
+
value
|
|
521
|
+
});
|
|
522
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
523
|
+
}
|
|
476
524
|
}
|
|
477
525
|
}
|
|
478
|
-
return
|
|
526
|
+
return search.join("&");
|
|
527
|
+
}, "querySerializer");
|
|
528
|
+
return querySerializer;
|
|
529
|
+
}, "createQuerySerializer");
|
|
530
|
+
var getParseAs = /* @__PURE__ */ __name((contentType) => {
|
|
531
|
+
if (!contentType) {
|
|
532
|
+
return "stream";
|
|
533
|
+
}
|
|
534
|
+
const cleanContent = contentType.split(";")[0]?.trim();
|
|
535
|
+
if (!cleanContent) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
|
|
539
|
+
return "json";
|
|
540
|
+
}
|
|
541
|
+
if (cleanContent === "multipart/form-data") {
|
|
542
|
+
return "formData";
|
|
543
|
+
}
|
|
544
|
+
if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
|
|
545
|
+
return "blob";
|
|
546
|
+
}
|
|
547
|
+
if (cleanContent.startsWith("text/")) {
|
|
548
|
+
return "text";
|
|
549
|
+
}
|
|
550
|
+
return;
|
|
551
|
+
}, "getParseAs");
|
|
552
|
+
var checkForExistence = /* @__PURE__ */ __name((options, name) => {
|
|
553
|
+
if (!name) {
|
|
554
|
+
return false;
|
|
479
555
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
556
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
557
|
+
return true;
|
|
558
|
+
}
|
|
559
|
+
return false;
|
|
560
|
+
}, "checkForExistence");
|
|
561
|
+
var setAuthParams = /* @__PURE__ */ __name(async ({
|
|
562
|
+
security,
|
|
563
|
+
...options
|
|
564
|
+
}) => {
|
|
565
|
+
for (const auth of security) {
|
|
566
|
+
if (checkForExistence(options, auth.name)) {
|
|
567
|
+
continue;
|
|
489
568
|
}
|
|
490
|
-
|
|
491
|
-
|
|
569
|
+
const token = await getAuthToken(auth, options.auth);
|
|
570
|
+
if (!token) {
|
|
571
|
+
continue;
|
|
492
572
|
}
|
|
493
|
-
|
|
494
|
-
|
|
573
|
+
const name = auth.name ?? "Authorization";
|
|
574
|
+
switch (auth.in) {
|
|
575
|
+
case "query":
|
|
576
|
+
if (!options.query) {
|
|
577
|
+
options.query = {};
|
|
578
|
+
}
|
|
579
|
+
options.query[name] = token;
|
|
580
|
+
break;
|
|
581
|
+
case "cookie":
|
|
582
|
+
options.headers.append("Cookie", `${name}=${token}`);
|
|
583
|
+
break;
|
|
584
|
+
case "header":
|
|
585
|
+
default:
|
|
586
|
+
options.headers.set(name, token);
|
|
587
|
+
break;
|
|
495
588
|
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
589
|
+
}
|
|
590
|
+
}, "setAuthParams");
|
|
591
|
+
var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
|
|
592
|
+
baseUrl: options.baseUrl,
|
|
593
|
+
path: options.path,
|
|
594
|
+
query: options.query,
|
|
595
|
+
querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
|
|
596
|
+
url: options.url
|
|
597
|
+
}), "buildUrl");
|
|
598
|
+
var mergeConfigs = /* @__PURE__ */ __name((a, b) => {
|
|
599
|
+
const config = { ...a, ...b };
|
|
600
|
+
if (config.baseUrl?.endsWith("/")) {
|
|
601
|
+
config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
|
|
602
|
+
}
|
|
603
|
+
config.headers = mergeHeaders(a.headers, b.headers);
|
|
604
|
+
return config;
|
|
605
|
+
}, "mergeConfigs");
|
|
606
|
+
var headersEntries = /* @__PURE__ */ __name((headers) => {
|
|
607
|
+
const entries = [];
|
|
608
|
+
headers.forEach((value, key) => {
|
|
609
|
+
entries.push([key, value]);
|
|
610
|
+
});
|
|
611
|
+
return entries;
|
|
612
|
+
}, "headersEntries");
|
|
613
|
+
var mergeHeaders = /* @__PURE__ */ __name((...headers) => {
|
|
614
|
+
const mergedHeaders = new Headers();
|
|
615
|
+
for (const header of headers) {
|
|
616
|
+
if (!header) {
|
|
617
|
+
continue;
|
|
618
|
+
}
|
|
619
|
+
const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
|
|
620
|
+
for (const [key, value] of iterator) {
|
|
621
|
+
if (value === null) {
|
|
622
|
+
mergedHeaders.delete(key);
|
|
623
|
+
} else if (Array.isArray(value)) {
|
|
624
|
+
for (const v of value) {
|
|
625
|
+
mergedHeaders.append(key, v);
|
|
626
|
+
}
|
|
627
|
+
} else if (value !== void 0) {
|
|
628
|
+
mergedHeaders.set(
|
|
629
|
+
key,
|
|
630
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
631
|
+
);
|
|
501
632
|
}
|
|
502
633
|
}
|
|
503
|
-
return this.message;
|
|
504
634
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
635
|
+
return mergedHeaders;
|
|
636
|
+
}, "mergeHeaders");
|
|
637
|
+
var _Interceptors = class _Interceptors {
|
|
638
|
+
constructor() {
|
|
639
|
+
__publicField(this, "fns", []);
|
|
640
|
+
}
|
|
641
|
+
clear() {
|
|
642
|
+
this.fns = [];
|
|
508
643
|
}
|
|
509
|
-
|
|
510
|
-
|
|
644
|
+
eject(id) {
|
|
645
|
+
const index = this.getInterceptorIndex(id);
|
|
646
|
+
if (this.fns[index]) {
|
|
647
|
+
this.fns[index] = null;
|
|
648
|
+
}
|
|
511
649
|
}
|
|
512
|
-
|
|
513
|
-
|
|
650
|
+
exists(id) {
|
|
651
|
+
const index = this.getInterceptorIndex(id);
|
|
652
|
+
return Boolean(this.fns[index]);
|
|
514
653
|
}
|
|
515
|
-
|
|
516
|
-
|
|
654
|
+
getInterceptorIndex(id) {
|
|
655
|
+
if (typeof id === "number") {
|
|
656
|
+
return this.fns[id] ? id : -1;
|
|
657
|
+
}
|
|
658
|
+
return this.fns.indexOf(id);
|
|
659
|
+
}
|
|
660
|
+
update(id, fn) {
|
|
661
|
+
const index = this.getInterceptorIndex(id);
|
|
662
|
+
if (this.fns[index]) {
|
|
663
|
+
this.fns[index] = fn;
|
|
664
|
+
return id;
|
|
665
|
+
}
|
|
666
|
+
return false;
|
|
517
667
|
}
|
|
518
|
-
|
|
519
|
-
|
|
668
|
+
use(fn) {
|
|
669
|
+
this.fns.push(fn);
|
|
670
|
+
return this.fns.length - 1;
|
|
520
671
|
}
|
|
521
672
|
};
|
|
522
|
-
__name(
|
|
523
|
-
var
|
|
524
|
-
var
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
673
|
+
__name(_Interceptors, "Interceptors");
|
|
674
|
+
var Interceptors = _Interceptors;
|
|
675
|
+
var createInterceptors = /* @__PURE__ */ __name(() => ({
|
|
676
|
+
error: new Interceptors(),
|
|
677
|
+
request: new Interceptors(),
|
|
678
|
+
response: new Interceptors()
|
|
679
|
+
}), "createInterceptors");
|
|
680
|
+
var defaultQuerySerializer = createQuerySerializer({
|
|
681
|
+
allowReserved: false,
|
|
682
|
+
array: {
|
|
683
|
+
explode: true,
|
|
684
|
+
style: "form"
|
|
685
|
+
},
|
|
686
|
+
object: {
|
|
687
|
+
explode: true,
|
|
688
|
+
style: "deepObject"
|
|
530
689
|
}
|
|
690
|
+
});
|
|
691
|
+
var defaultHeaders = {
|
|
692
|
+
"Content-Type": "application/json"
|
|
531
693
|
};
|
|
532
|
-
__name(
|
|
533
|
-
|
|
694
|
+
var createConfig = /* @__PURE__ */ __name((override = {}) => ({
|
|
695
|
+
...jsonBodySerializer,
|
|
696
|
+
headers: defaultHeaders,
|
|
697
|
+
parseAs: "auto",
|
|
698
|
+
querySerializer: defaultQuerySerializer,
|
|
699
|
+
...override
|
|
700
|
+
}), "createConfig");
|
|
534
701
|
|
|
535
|
-
// src/_api/generated/cfg_monitor/
|
|
702
|
+
// src/_api/generated/cfg_monitor/client/client.gen.ts
|
|
703
|
+
var createClient = /* @__PURE__ */ __name((config = {}) => {
|
|
704
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
705
|
+
const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
|
|
706
|
+
const setConfig = /* @__PURE__ */ __name((config2) => {
|
|
707
|
+
_config = mergeConfigs(_config, config2);
|
|
708
|
+
return getConfig();
|
|
709
|
+
}, "setConfig");
|
|
710
|
+
const interceptors = createInterceptors();
|
|
711
|
+
const beforeRequest = /* @__PURE__ */ __name(async (options) => {
|
|
712
|
+
const opts = {
|
|
713
|
+
..._config,
|
|
714
|
+
...options,
|
|
715
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
716
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
717
|
+
serializedBody: void 0
|
|
718
|
+
};
|
|
719
|
+
if (opts.security) {
|
|
720
|
+
await setAuthParams({
|
|
721
|
+
...opts,
|
|
722
|
+
security: opts.security
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
if (opts.requestValidator) {
|
|
726
|
+
await opts.requestValidator(opts);
|
|
727
|
+
}
|
|
728
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
729
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
730
|
+
}
|
|
731
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
732
|
+
opts.headers.delete("Content-Type");
|
|
733
|
+
}
|
|
734
|
+
const resolvedOpts = opts;
|
|
735
|
+
const url = buildUrl(resolvedOpts);
|
|
736
|
+
return { opts: resolvedOpts, url };
|
|
737
|
+
}, "beforeRequest");
|
|
738
|
+
const request = /* @__PURE__ */ __name(async (options) => {
|
|
739
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
740
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
741
|
+
let request2;
|
|
742
|
+
let response;
|
|
743
|
+
try {
|
|
744
|
+
const { opts, url } = await beforeRequest(options);
|
|
745
|
+
const requestInit = {
|
|
746
|
+
redirect: "follow",
|
|
747
|
+
...opts,
|
|
748
|
+
body: getValidRequestBody(opts)
|
|
749
|
+
};
|
|
750
|
+
request2 = new Request(url, requestInit);
|
|
751
|
+
for (const fn of interceptors.request.fns) {
|
|
752
|
+
if (fn) {
|
|
753
|
+
request2 = await fn(request2, opts);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
const _fetch = opts.fetch;
|
|
757
|
+
response = await _fetch(request2);
|
|
758
|
+
for (const fn of interceptors.response.fns) {
|
|
759
|
+
if (fn) {
|
|
760
|
+
response = await fn(response, request2, opts);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
const result = {
|
|
764
|
+
request: request2,
|
|
765
|
+
response
|
|
766
|
+
};
|
|
767
|
+
if (response.ok) {
|
|
768
|
+
const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
|
|
769
|
+
if (response.status === 204 || response.headers.get("Content-Length") === "0") {
|
|
770
|
+
let emptyData;
|
|
771
|
+
switch (parseAs) {
|
|
772
|
+
case "arrayBuffer":
|
|
773
|
+
case "blob":
|
|
774
|
+
case "text":
|
|
775
|
+
emptyData = await response[parseAs]();
|
|
776
|
+
break;
|
|
777
|
+
case "formData":
|
|
778
|
+
emptyData = new FormData();
|
|
779
|
+
break;
|
|
780
|
+
case "stream":
|
|
781
|
+
emptyData = response.body;
|
|
782
|
+
break;
|
|
783
|
+
case "json":
|
|
784
|
+
default:
|
|
785
|
+
emptyData = {};
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
return opts.responseStyle === "data" ? emptyData : {
|
|
789
|
+
data: emptyData,
|
|
790
|
+
...result
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
let data;
|
|
794
|
+
switch (parseAs) {
|
|
795
|
+
case "arrayBuffer":
|
|
796
|
+
case "blob":
|
|
797
|
+
case "formData":
|
|
798
|
+
case "text":
|
|
799
|
+
data = await response[parseAs]();
|
|
800
|
+
break;
|
|
801
|
+
case "json": {
|
|
802
|
+
const text = await response.text();
|
|
803
|
+
data = text ? JSON.parse(text) : {};
|
|
804
|
+
break;
|
|
805
|
+
}
|
|
806
|
+
case "stream":
|
|
807
|
+
return opts.responseStyle === "data" ? response.body : {
|
|
808
|
+
data: response.body,
|
|
809
|
+
...result
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
if (parseAs === "json") {
|
|
813
|
+
if (opts.responseValidator) {
|
|
814
|
+
await opts.responseValidator(data);
|
|
815
|
+
}
|
|
816
|
+
if (opts.responseTransformer) {
|
|
817
|
+
data = await opts.responseTransformer(data);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return opts.responseStyle === "data" ? data : {
|
|
821
|
+
data,
|
|
822
|
+
...result
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
const textError = await response.text();
|
|
826
|
+
let jsonError;
|
|
827
|
+
try {
|
|
828
|
+
jsonError = JSON.parse(textError);
|
|
829
|
+
} catch {
|
|
830
|
+
}
|
|
831
|
+
throw jsonError ?? textError;
|
|
832
|
+
} catch (error) {
|
|
833
|
+
let finalError = error;
|
|
834
|
+
for (const fn of interceptors.error.fns) {
|
|
835
|
+
if (fn) {
|
|
836
|
+
finalError = await fn(finalError, response, request2, options);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
finalError = finalError || {};
|
|
840
|
+
if (throwOnError) {
|
|
841
|
+
throw finalError;
|
|
842
|
+
}
|
|
843
|
+
return responseStyle === "data" ? void 0 : {
|
|
844
|
+
error: finalError,
|
|
845
|
+
request: request2,
|
|
846
|
+
response
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
}, "request");
|
|
850
|
+
const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
|
|
851
|
+
const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
|
|
852
|
+
const { opts, url } = await beforeRequest(options);
|
|
853
|
+
return createSseClient({
|
|
854
|
+
...opts,
|
|
855
|
+
body: opts.body,
|
|
856
|
+
method,
|
|
857
|
+
onRequest: /* @__PURE__ */ __name(async (url2, init) => {
|
|
858
|
+
let request2 = new Request(url2, init);
|
|
859
|
+
for (const fn of interceptors.request.fns) {
|
|
860
|
+
if (fn) {
|
|
861
|
+
request2 = await fn(request2, opts);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
return request2;
|
|
865
|
+
}, "onRequest"),
|
|
866
|
+
serializedBody: getValidRequestBody(opts),
|
|
867
|
+
url
|
|
868
|
+
});
|
|
869
|
+
}, "makeSseFn");
|
|
870
|
+
const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
|
|
871
|
+
return {
|
|
872
|
+
buildUrl: _buildUrl,
|
|
873
|
+
connect: makeMethodFn("CONNECT"),
|
|
874
|
+
delete: makeMethodFn("DELETE"),
|
|
875
|
+
get: makeMethodFn("GET"),
|
|
876
|
+
getConfig,
|
|
877
|
+
head: makeMethodFn("HEAD"),
|
|
878
|
+
interceptors,
|
|
879
|
+
options: makeMethodFn("OPTIONS"),
|
|
880
|
+
patch: makeMethodFn("PATCH"),
|
|
881
|
+
post: makeMethodFn("POST"),
|
|
882
|
+
put: makeMethodFn("PUT"),
|
|
883
|
+
request,
|
|
884
|
+
setConfig,
|
|
885
|
+
sse: {
|
|
886
|
+
connect: makeSseFn("CONNECT"),
|
|
887
|
+
delete: makeSseFn("DELETE"),
|
|
888
|
+
get: makeSseFn("GET"),
|
|
889
|
+
head: makeSseFn("HEAD"),
|
|
890
|
+
options: makeSseFn("OPTIONS"),
|
|
891
|
+
patch: makeSseFn("PATCH"),
|
|
892
|
+
post: makeSseFn("POST"),
|
|
893
|
+
put: makeSseFn("PUT"),
|
|
894
|
+
trace: makeSseFn("TRACE")
|
|
895
|
+
},
|
|
896
|
+
trace: makeMethodFn("TRACE")
|
|
897
|
+
};
|
|
898
|
+
}, "createClient");
|
|
899
|
+
|
|
900
|
+
// src/_api/generated/cfg_monitor/client.gen.ts
|
|
901
|
+
var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
|
|
902
|
+
|
|
903
|
+
// src/_api/generated/_shared/storage.ts
|
|
904
|
+
var _LocalStorageAdapter = class _LocalStorageAdapter {
|
|
905
|
+
getItem(key) {
|
|
906
|
+
if (typeof window === "undefined") return null;
|
|
907
|
+
try {
|
|
908
|
+
return window.localStorage.getItem(key);
|
|
909
|
+
} catch {
|
|
910
|
+
return null;
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
setItem(key, value) {
|
|
914
|
+
if (typeof window === "undefined") return;
|
|
915
|
+
try {
|
|
916
|
+
window.localStorage.setItem(key, value);
|
|
917
|
+
} catch {
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
removeItem(key) {
|
|
921
|
+
if (typeof window === "undefined") return;
|
|
922
|
+
try {
|
|
923
|
+
window.localStorage.removeItem(key);
|
|
924
|
+
} catch {
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
clear() {
|
|
928
|
+
if (typeof window === "undefined") return;
|
|
929
|
+
try {
|
|
930
|
+
window.localStorage.clear();
|
|
931
|
+
} catch {
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
__name(_LocalStorageAdapter, "LocalStorageAdapter");
|
|
936
|
+
var LocalStorageAdapter = _LocalStorageAdapter;
|
|
937
|
+
var _MemoryStorageAdapter = class _MemoryStorageAdapter {
|
|
938
|
+
constructor() {
|
|
939
|
+
__publicField(this, "store", /* @__PURE__ */ new Map());
|
|
940
|
+
}
|
|
941
|
+
getItem(key) {
|
|
942
|
+
return this.store.get(key) ?? null;
|
|
943
|
+
}
|
|
944
|
+
setItem(key, value) {
|
|
945
|
+
this.store.set(key, value);
|
|
946
|
+
}
|
|
947
|
+
removeItem(key) {
|
|
948
|
+
this.store.delete(key);
|
|
949
|
+
}
|
|
950
|
+
clear() {
|
|
951
|
+
this.store.clear();
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
__name(_MemoryStorageAdapter, "MemoryStorageAdapter");
|
|
955
|
+
var MemoryStorageAdapter = _MemoryStorageAdapter;
|
|
956
|
+
|
|
957
|
+
// src/_api/generated/_shared/logger.ts
|
|
536
958
|
var import_consola = require("consola");
|
|
537
959
|
var DEFAULT_CONFIG = {
|
|
538
|
-
enabled: process.env.NODE_ENV !== "production",
|
|
960
|
+
enabled: typeof process !== "undefined" && process.env.NODE_ENV !== "production",
|
|
539
961
|
logRequests: true,
|
|
540
962
|
logResponses: true,
|
|
541
963
|
logErrors: true,
|
|
@@ -558,127 +980,65 @@ var _APILogger = class _APILogger {
|
|
|
558
980
|
level: this.config.enabled ? 4 : 0
|
|
559
981
|
});
|
|
560
982
|
}
|
|
561
|
-
/**
|
|
562
|
-
* Enable logging
|
|
563
|
-
*/
|
|
564
983
|
enable() {
|
|
565
984
|
this.config.enabled = true;
|
|
566
985
|
}
|
|
567
|
-
/**
|
|
568
|
-
* Disable logging
|
|
569
|
-
*/
|
|
570
986
|
disable() {
|
|
571
987
|
this.config.enabled = false;
|
|
572
988
|
}
|
|
573
|
-
/**
|
|
574
|
-
* Update configuration
|
|
575
|
-
*/
|
|
576
989
|
setConfig(config) {
|
|
577
990
|
this.config = { ...this.config, ...config };
|
|
578
991
|
}
|
|
579
|
-
/**
|
|
580
|
-
* Filter sensitive headers
|
|
581
|
-
*/
|
|
582
992
|
filterHeaders(headers) {
|
|
583
993
|
if (!headers) return {};
|
|
584
994
|
const filtered = {};
|
|
585
995
|
Object.keys(headers).forEach((key) => {
|
|
586
|
-
|
|
587
|
-
if (SENSITIVE_HEADERS.includes(lowerKey)) {
|
|
588
|
-
filtered[key] = "***";
|
|
589
|
-
} else {
|
|
590
|
-
filtered[key] = headers[key] || "";
|
|
591
|
-
}
|
|
996
|
+
filtered[key] = SENSITIVE_HEADERS.includes(key.toLowerCase()) ? "***" : headers[key] || "";
|
|
592
997
|
});
|
|
593
998
|
return filtered;
|
|
594
999
|
}
|
|
595
|
-
/**
|
|
596
|
-
* Log request
|
|
597
|
-
*/
|
|
598
1000
|
logRequest(request) {
|
|
599
1001
|
if (!this.config.enabled || !this.config.logRequests) return;
|
|
600
1002
|
const { method, url, headers, body } = request;
|
|
601
1003
|
this.consola.start(`${method} ${url}`);
|
|
602
|
-
if (this.config.logHeaders && headers)
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
if (this.config.logBodies && body) {
|
|
606
|
-
this.consola.debug("Body:", body);
|
|
607
|
-
}
|
|
1004
|
+
if (this.config.logHeaders && headers) this.consola.debug("Headers:", this.filterHeaders(headers));
|
|
1005
|
+
if (this.config.logBodies && body) this.consola.debug("Body:", body);
|
|
608
1006
|
}
|
|
609
|
-
/**
|
|
610
|
-
* Log response
|
|
611
|
-
*/
|
|
612
1007
|
logResponse(request, response) {
|
|
613
1008
|
if (!this.config.enabled || !this.config.logResponses) return;
|
|
614
1009
|
const { method, url } = request;
|
|
615
1010
|
const { status, statusText, data, duration } = response;
|
|
616
|
-
|
|
617
|
-
this.consola.
|
|
618
|
-
`${method} ${url} ${status} ${statusText} (${duration}ms)`
|
|
619
|
-
);
|
|
620
|
-
if (this.config.logBodies && data) {
|
|
621
|
-
this.consola.debug("Response:", data);
|
|
622
|
-
}
|
|
1011
|
+
this.consola.success(`${method} ${url} ${status} ${statusText} (${duration}ms)`);
|
|
1012
|
+
if (this.config.logBodies && data) this.consola.debug("Response:", data);
|
|
623
1013
|
}
|
|
624
|
-
/**
|
|
625
|
-
* Log error
|
|
626
|
-
*/
|
|
627
1014
|
logError(request, error) {
|
|
628
1015
|
if (!this.config.enabled || !this.config.logErrors) return;
|
|
629
1016
|
const { method, url } = request;
|
|
630
1017
|
const { message, statusCode, fieldErrors, duration } = error;
|
|
631
|
-
this.consola.error(
|
|
632
|
-
`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
|
|
633
|
-
);
|
|
1018
|
+
this.consola.error(`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`);
|
|
634
1019
|
this.consola.error("Message:", message);
|
|
635
1020
|
if (fieldErrors && Object.keys(fieldErrors).length > 0) {
|
|
636
1021
|
this.consola.error("Field Errors:");
|
|
637
1022
|
Object.entries(fieldErrors).forEach(([field, errors]) => {
|
|
638
|
-
errors.forEach((err) => {
|
|
639
|
-
this.consola.error(` \u2022 ${field}: ${err}`);
|
|
640
|
-
});
|
|
1023
|
+
errors.forEach((err) => this.consola.error(` \u2022 ${field}: ${err}`));
|
|
641
1024
|
});
|
|
642
1025
|
}
|
|
643
1026
|
}
|
|
644
|
-
/**
|
|
645
|
-
* Log general info
|
|
646
|
-
*/
|
|
647
1027
|
info(message, ...args) {
|
|
648
|
-
if (
|
|
649
|
-
this.consola.info(message, ...args);
|
|
1028
|
+
if (this.config.enabled) this.consola.info(message, ...args);
|
|
650
1029
|
}
|
|
651
|
-
/**
|
|
652
|
-
* Log warning
|
|
653
|
-
*/
|
|
654
1030
|
warn(message, ...args) {
|
|
655
|
-
if (
|
|
656
|
-
this.consola.warn(message, ...args);
|
|
1031
|
+
if (this.config.enabled) this.consola.warn(message, ...args);
|
|
657
1032
|
}
|
|
658
|
-
/**
|
|
659
|
-
* Log error
|
|
660
|
-
*/
|
|
661
1033
|
error(message, ...args) {
|
|
662
|
-
if (
|
|
663
|
-
this.consola.error(message, ...args);
|
|
1034
|
+
if (this.config.enabled) this.consola.error(message, ...args);
|
|
664
1035
|
}
|
|
665
|
-
/**
|
|
666
|
-
* Log debug
|
|
667
|
-
*/
|
|
668
1036
|
debug(message, ...args) {
|
|
669
|
-
if (
|
|
670
|
-
this.consola.debug(message, ...args);
|
|
1037
|
+
if (this.config.enabled) this.consola.debug(message, ...args);
|
|
671
1038
|
}
|
|
672
|
-
/**
|
|
673
|
-
* Log success
|
|
674
|
-
*/
|
|
675
1039
|
success(message, ...args) {
|
|
676
|
-
if (
|
|
677
|
-
this.consola.success(message, ...args);
|
|
1040
|
+
if (this.config.enabled) this.consola.success(message, ...args);
|
|
678
1041
|
}
|
|
679
|
-
/**
|
|
680
|
-
* Create a sub-logger with prefix
|
|
681
|
-
*/
|
|
682
1042
|
withTag(tag) {
|
|
683
1043
|
return this.consola.withTag(tag);
|
|
684
1044
|
}
|
|
@@ -687,532 +1047,54 @@ __name(_APILogger, "APILogger");
|
|
|
687
1047
|
var APILogger = _APILogger;
|
|
688
1048
|
var defaultLogger = new APILogger();
|
|
689
1049
|
|
|
690
|
-
//
|
|
691
|
-
var
|
|
692
|
-
|
|
693
|
-
// ../../node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js
|
|
694
|
-
var objectToString = Object.prototype.toString;
|
|
695
|
-
var isError = /* @__PURE__ */ __name((value) => objectToString.call(value) === "[object Error]", "isError");
|
|
696
|
-
var errorMessages = /* @__PURE__ */ new Set([
|
|
697
|
-
"network error",
|
|
698
|
-
// Chrome
|
|
699
|
-
"Failed to fetch",
|
|
700
|
-
// Chrome
|
|
701
|
-
"NetworkError when attempting to fetch resource.",
|
|
702
|
-
// Firefox
|
|
703
|
-
"The Internet connection appears to be offline.",
|
|
704
|
-
// Safari 16
|
|
705
|
-
"Network request failed",
|
|
706
|
-
// `cross-fetch`
|
|
707
|
-
"fetch failed",
|
|
708
|
-
// Undici (Node.js)
|
|
709
|
-
"terminated",
|
|
710
|
-
// Undici (Node.js)
|
|
711
|
-
" A network error occurred.",
|
|
712
|
-
// Bun (WebKit)
|
|
713
|
-
"Network connection lost"
|
|
714
|
-
// Cloudflare Workers (fetch)
|
|
715
|
-
]);
|
|
716
|
-
function isNetworkError(error) {
|
|
717
|
-
const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
|
|
718
|
-
if (!isValid) {
|
|
719
|
-
return false;
|
|
720
|
-
}
|
|
721
|
-
const { message, stack } = error;
|
|
722
|
-
if (message === "Load failed") {
|
|
723
|
-
return stack === void 0 || "__sentry_captured__" in error;
|
|
724
|
-
}
|
|
725
|
-
if (message.startsWith("error sending request for url")) {
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
return errorMessages.has(message);
|
|
729
|
-
}
|
|
730
|
-
__name(isNetworkError, "isNetworkError");
|
|
731
|
-
|
|
732
|
-
// ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
733
|
-
var _AbortError = class _AbortError extends Error {
|
|
734
|
-
constructor(message) {
|
|
735
|
-
super();
|
|
736
|
-
if (message instanceof Error) {
|
|
737
|
-
this.originalError = message;
|
|
738
|
-
({ message } = message);
|
|
739
|
-
} else {
|
|
740
|
-
this.originalError = new Error(message);
|
|
741
|
-
this.originalError.stack = this.stack;
|
|
742
|
-
}
|
|
743
|
-
this.name = "AbortError";
|
|
744
|
-
this.message = message;
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
__name(_AbortError, "AbortError");
|
|
748
|
-
var AbortError = _AbortError;
|
|
749
|
-
var decorateErrorWithCounts = /* @__PURE__ */ __name((error, attemptNumber, options) => {
|
|
750
|
-
const retriesLeft = options.retries - (attemptNumber - 1);
|
|
751
|
-
error.attemptNumber = attemptNumber;
|
|
752
|
-
error.retriesLeft = retriesLeft;
|
|
753
|
-
return error;
|
|
754
|
-
}, "decorateErrorWithCounts");
|
|
755
|
-
async function pRetry(input, options) {
|
|
756
|
-
return new Promise((resolve, reject) => {
|
|
757
|
-
options = { ...options };
|
|
758
|
-
options.onFailedAttempt ?? (options.onFailedAttempt = () => {
|
|
759
|
-
});
|
|
760
|
-
options.shouldRetry ?? (options.shouldRetry = () => true);
|
|
761
|
-
options.retries ?? (options.retries = 10);
|
|
762
|
-
const operation = import_retry.default.operation(options);
|
|
763
|
-
const abortHandler = /* @__PURE__ */ __name(() => {
|
|
764
|
-
operation.stop();
|
|
765
|
-
reject(options.signal?.reason);
|
|
766
|
-
}, "abortHandler");
|
|
767
|
-
if (options.signal && !options.signal.aborted) {
|
|
768
|
-
options.signal.addEventListener("abort", abortHandler, { once: true });
|
|
769
|
-
}
|
|
770
|
-
const cleanUp = /* @__PURE__ */ __name(() => {
|
|
771
|
-
options.signal?.removeEventListener("abort", abortHandler);
|
|
772
|
-
operation.stop();
|
|
773
|
-
}, "cleanUp");
|
|
774
|
-
operation.attempt(async (attemptNumber) => {
|
|
775
|
-
try {
|
|
776
|
-
const result = await input(attemptNumber);
|
|
777
|
-
cleanUp();
|
|
778
|
-
resolve(result);
|
|
779
|
-
} catch (error) {
|
|
780
|
-
try {
|
|
781
|
-
if (!(error instanceof Error)) {
|
|
782
|
-
throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
|
|
783
|
-
}
|
|
784
|
-
if (error instanceof AbortError) {
|
|
785
|
-
throw error.originalError;
|
|
786
|
-
}
|
|
787
|
-
if (error instanceof TypeError && !isNetworkError(error)) {
|
|
788
|
-
throw error;
|
|
789
|
-
}
|
|
790
|
-
decorateErrorWithCounts(error, attemptNumber, options);
|
|
791
|
-
if (!await options.shouldRetry(error)) {
|
|
792
|
-
operation.stop();
|
|
793
|
-
reject(error);
|
|
794
|
-
}
|
|
795
|
-
await options.onFailedAttempt(error);
|
|
796
|
-
if (!operation.retry(error)) {
|
|
797
|
-
throw operation.mainError();
|
|
798
|
-
}
|
|
799
|
-
} catch (finalError) {
|
|
800
|
-
decorateErrorWithCounts(finalError, attemptNumber, options);
|
|
801
|
-
cleanUp();
|
|
802
|
-
reject(finalError);
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
});
|
|
806
|
-
});
|
|
807
|
-
}
|
|
808
|
-
__name(pRetry, "pRetry");
|
|
809
|
-
|
|
810
|
-
// src/_api/generated/cfg_monitor/retry.ts
|
|
811
|
-
var DEFAULT_RETRY_CONFIG = {
|
|
812
|
-
retries: 3,
|
|
813
|
-
factor: 2,
|
|
814
|
-
minTimeout: 1e3,
|
|
815
|
-
maxTimeout: 6e4,
|
|
816
|
-
randomize: true,
|
|
817
|
-
onFailedAttempt: /* @__PURE__ */ __name(() => {
|
|
818
|
-
}, "onFailedAttempt")
|
|
819
|
-
};
|
|
820
|
-
function shouldRetry(error) {
|
|
821
|
-
if (error instanceof NetworkError) {
|
|
822
|
-
return true;
|
|
823
|
-
}
|
|
824
|
-
if (error instanceof APIError) {
|
|
825
|
-
const status = error.statusCode;
|
|
826
|
-
if (status >= 500 && status < 600) {
|
|
827
|
-
return true;
|
|
828
|
-
}
|
|
829
|
-
if (status === 429) {
|
|
830
|
-
return true;
|
|
831
|
-
}
|
|
832
|
-
return false;
|
|
833
|
-
}
|
|
834
|
-
return true;
|
|
835
|
-
}
|
|
836
|
-
__name(shouldRetry, "shouldRetry");
|
|
837
|
-
async function withRetry(fn, config) {
|
|
838
|
-
const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
|
839
|
-
return pRetry(
|
|
840
|
-
async () => {
|
|
841
|
-
try {
|
|
842
|
-
return await fn();
|
|
843
|
-
} catch (error) {
|
|
844
|
-
if (!shouldRetry(error)) {
|
|
845
|
-
throw new AbortError(error);
|
|
846
|
-
}
|
|
847
|
-
throw error;
|
|
848
|
-
}
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
retries: finalConfig.retries,
|
|
852
|
-
factor: finalConfig.factor,
|
|
853
|
-
minTimeout: finalConfig.minTimeout,
|
|
854
|
-
maxTimeout: finalConfig.maxTimeout,
|
|
855
|
-
randomize: finalConfig.randomize,
|
|
856
|
-
onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
|
|
857
|
-
const pRetryError = error;
|
|
858
|
-
finalConfig.onFailedAttempt({
|
|
859
|
-
error: pRetryError,
|
|
860
|
-
attemptNumber: pRetryError.attemptNumber,
|
|
861
|
-
retriesLeft: pRetryError.retriesLeft
|
|
862
|
-
});
|
|
863
|
-
} : void 0
|
|
864
|
-
}
|
|
865
|
-
);
|
|
866
|
-
}
|
|
867
|
-
__name(withRetry, "withRetry");
|
|
868
|
-
|
|
869
|
-
// src/_api/generated/cfg_monitor/client.ts
|
|
870
|
-
var _APIClient = class _APIClient {
|
|
871
|
-
constructor(baseUrl, options) {
|
|
872
|
-
__publicField(this, "baseUrl");
|
|
873
|
-
__publicField(this, "httpClient");
|
|
874
|
-
__publicField(this, "logger", null);
|
|
875
|
-
__publicField(this, "retryConfig", null);
|
|
876
|
-
__publicField(this, "tokenGetter", null);
|
|
877
|
-
// Sub-clients
|
|
878
|
-
__publicField(this, "monitor");
|
|
879
|
-
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
880
|
-
this.httpClient = options?.httpClient || new FetchAdapter();
|
|
881
|
-
this.tokenGetter = options?.tokenGetter || null;
|
|
882
|
-
if (options?.loggerConfig !== void 0) {
|
|
883
|
-
this.logger = new APILogger(options.loggerConfig);
|
|
884
|
-
}
|
|
885
|
-
if (options?.retryConfig !== void 0) {
|
|
886
|
-
this.retryConfig = options.retryConfig;
|
|
887
|
-
}
|
|
888
|
-
this.monitor = new Monitor(this);
|
|
889
|
-
}
|
|
1050
|
+
// src/_api/generated/cfg_monitor/sdk.gen.ts
|
|
1051
|
+
var _Cfg = class _Cfg {
|
|
890
1052
|
/**
|
|
891
|
-
*
|
|
1053
|
+
* Ingest browser events
|
|
892
1054
|
*
|
|
893
|
-
*
|
|
894
|
-
*/
|
|
895
|
-
getCsrfToken() {
|
|
896
|
-
const name = "csrftoken";
|
|
897
|
-
const value = `; ${document.cookie}`;
|
|
898
|
-
const parts = value.split(`; ${name}=`);
|
|
899
|
-
if (parts.length === 2) {
|
|
900
|
-
return parts.pop()?.split(";").shift() || null;
|
|
901
|
-
}
|
|
902
|
-
return null;
|
|
903
|
-
}
|
|
904
|
-
/**
|
|
905
|
-
* Get the base URL for building streaming/download URLs.
|
|
906
|
-
*/
|
|
907
|
-
getBaseUrl() {
|
|
908
|
-
return this.baseUrl;
|
|
909
|
-
}
|
|
910
|
-
/**
|
|
911
|
-
* Get JWT token for URL authentication (used in streaming endpoints).
|
|
912
|
-
* Returns null if no token getter is configured or no token is available.
|
|
1055
|
+
* Accepts a batch of up to 50 frontend events. No authentication required — anonymous visitors can send events.
|
|
913
1056
|
*/
|
|
914
|
-
|
|
915
|
-
return
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
async request(method, path, options) {
|
|
922
|
-
if (this.retryConfig) {
|
|
923
|
-
return withRetry(() => this._makeRequest(method, path, options), {
|
|
924
|
-
...this.retryConfig,
|
|
925
|
-
onFailedAttempt: /* @__PURE__ */ __name((info) => {
|
|
926
|
-
if (this.logger) {
|
|
927
|
-
this.logger.warn(
|
|
928
|
-
`Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
|
|
929
|
-
);
|
|
930
|
-
}
|
|
931
|
-
this.retryConfig?.onFailedAttempt?.(info);
|
|
932
|
-
}, "onFailedAttempt")
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
return this._makeRequest(method, path, options);
|
|
936
|
-
}
|
|
937
|
-
/**
|
|
938
|
-
* Internal request method (without retry wrapper).
|
|
939
|
-
* Used by request() method with optional retry logic.
|
|
940
|
-
*/
|
|
941
|
-
async _makeRequest(method, path, options) {
|
|
942
|
-
const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
|
|
943
|
-
const startTime = Date.now();
|
|
944
|
-
const headers = {
|
|
945
|
-
...options?.headers || {}
|
|
946
|
-
};
|
|
947
|
-
if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
|
|
948
|
-
headers["Content-Type"] = "application/json";
|
|
949
|
-
}
|
|
950
|
-
if (!headers["Authorization"]) {
|
|
951
|
-
const token = this.getToken();
|
|
952
|
-
if (token) {
|
|
953
|
-
headers["Authorization"] = `Bearer ${token}`;
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
if (this.logger) {
|
|
957
|
-
this.logger.logRequest({
|
|
958
|
-
method,
|
|
959
|
-
url,
|
|
960
|
-
headers,
|
|
961
|
-
body: options?.formData || options?.body,
|
|
962
|
-
timestamp: startTime
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
try {
|
|
966
|
-
const response = await this.httpClient.request({
|
|
967
|
-
method,
|
|
968
|
-
url,
|
|
969
|
-
headers,
|
|
970
|
-
params: options?.params,
|
|
971
|
-
body: options?.body,
|
|
972
|
-
formData: options?.formData,
|
|
973
|
-
binaryBody: options?.binaryBody,
|
|
974
|
-
responseType: options?.responseType
|
|
975
|
-
});
|
|
976
|
-
const duration = Date.now() - startTime;
|
|
977
|
-
if (response.status >= 400) {
|
|
978
|
-
const error = new APIError(
|
|
979
|
-
response.status,
|
|
980
|
-
response.statusText,
|
|
981
|
-
response.data,
|
|
982
|
-
url
|
|
983
|
-
);
|
|
984
|
-
if (this.logger) {
|
|
985
|
-
this.logger.logError(
|
|
986
|
-
{
|
|
987
|
-
method,
|
|
988
|
-
url,
|
|
989
|
-
headers,
|
|
990
|
-
body: options?.formData || options?.body,
|
|
991
|
-
timestamp: startTime
|
|
992
|
-
},
|
|
993
|
-
{
|
|
994
|
-
message: error.message,
|
|
995
|
-
statusCode: response.status,
|
|
996
|
-
duration,
|
|
997
|
-
timestamp: Date.now()
|
|
998
|
-
}
|
|
999
|
-
);
|
|
1000
|
-
}
|
|
1001
|
-
throw error;
|
|
1002
|
-
}
|
|
1003
|
-
if (this.logger) {
|
|
1004
|
-
this.logger.logResponse(
|
|
1005
|
-
{
|
|
1006
|
-
method,
|
|
1007
|
-
url,
|
|
1008
|
-
headers,
|
|
1009
|
-
body: options?.formData || options?.body,
|
|
1010
|
-
timestamp: startTime
|
|
1011
|
-
},
|
|
1012
|
-
{
|
|
1013
|
-
status: response.status,
|
|
1014
|
-
statusText: response.statusText,
|
|
1015
|
-
data: response.data,
|
|
1016
|
-
duration,
|
|
1017
|
-
timestamp: Date.now()
|
|
1018
|
-
}
|
|
1019
|
-
);
|
|
1020
|
-
}
|
|
1021
|
-
return response.data;
|
|
1022
|
-
} catch (error) {
|
|
1023
|
-
const duration = Date.now() - startTime;
|
|
1024
|
-
if (error instanceof APIError) {
|
|
1025
|
-
throw error;
|
|
1057
|
+
static cfgMonitorIngestCreate(options) {
|
|
1058
|
+
return (options.client ?? client).post({
|
|
1059
|
+
url: "/cfg/monitor/ingest/",
|
|
1060
|
+
...options,
|
|
1061
|
+
headers: {
|
|
1062
|
+
"Content-Type": "application/json",
|
|
1063
|
+
...options.headers
|
|
1026
1064
|
}
|
|
1027
|
-
|
|
1028
|
-
if (error instanceof TypeError && typeof window !== "undefined") {
|
|
1029
|
-
try {
|
|
1030
|
-
const isCrossOrigin = (() => {
|
|
1031
|
-
try {
|
|
1032
|
-
return new URL(url).origin !== window.location.origin;
|
|
1033
|
-
} catch {
|
|
1034
|
-
return false;
|
|
1035
|
-
}
|
|
1036
|
-
})();
|
|
1037
|
-
if (isCrossOrigin) {
|
|
1038
|
-
const entries = performance.getEntriesByName(url, "resource");
|
|
1039
|
-
if (entries.length > 0) {
|
|
1040
|
-
const last = entries[entries.length - 1];
|
|
1041
|
-
possiblyCors = "responseStatus" in last && last.responseStatus === 0;
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
} catch {
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
if (this.logger) {
|
|
1048
|
-
this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
|
|
1049
|
-
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
1050
|
-
if (possiblyCors) {
|
|
1051
|
-
this.logger.error(` \u2192 Possibly blocked by CORS policy (configure CORS on the server)`);
|
|
1052
|
-
}
|
|
1053
|
-
}
|
|
1054
|
-
if (typeof window !== "undefined") {
|
|
1055
|
-
try {
|
|
1056
|
-
window.dispatchEvent(new CustomEvent("network-error", {
|
|
1057
|
-
detail: {
|
|
1058
|
-
url,
|
|
1059
|
-
method,
|
|
1060
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1061
|
-
possibly_cors: possiblyCors,
|
|
1062
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
1063
|
-
},
|
|
1064
|
-
bubbles: true,
|
|
1065
|
-
cancelable: false
|
|
1066
|
-
}));
|
|
1067
|
-
} catch {
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
const networkError = error instanceof Error ? new NetworkError(error.message, url, error) : new NetworkError("Unknown error", url);
|
|
1071
|
-
if (this.logger) {
|
|
1072
|
-
this.logger.logError(
|
|
1073
|
-
{
|
|
1074
|
-
method,
|
|
1075
|
-
url,
|
|
1076
|
-
headers,
|
|
1077
|
-
body: options?.formData || options?.body,
|
|
1078
|
-
timestamp: startTime
|
|
1079
|
-
},
|
|
1080
|
-
{
|
|
1081
|
-
message: networkError.message,
|
|
1082
|
-
duration,
|
|
1083
|
-
timestamp: Date.now()
|
|
1084
|
-
}
|
|
1085
|
-
);
|
|
1086
|
-
}
|
|
1087
|
-
throw networkError;
|
|
1088
|
-
}
|
|
1065
|
+
});
|
|
1089
1066
|
}
|
|
1090
1067
|
};
|
|
1091
|
-
__name(
|
|
1092
|
-
var
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
}
|
|
1107
|
-
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
1108
|
-
} catch (error) {
|
|
1109
|
-
this.logger?.error("LocalStorage.getItem failed:", error);
|
|
1110
|
-
}
|
|
1111
|
-
return null;
|
|
1112
|
-
}
|
|
1113
|
-
setItem(key, value) {
|
|
1114
|
-
try {
|
|
1115
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
1116
|
-
localStorage.setItem(key, value);
|
|
1117
|
-
this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
|
|
1118
|
-
} else {
|
|
1119
|
-
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
1120
|
-
}
|
|
1121
|
-
} catch (error) {
|
|
1122
|
-
this.logger?.error("LocalStorage.setItem failed:", error);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
removeItem(key) {
|
|
1126
|
-
try {
|
|
1127
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
1128
|
-
localStorage.removeItem(key);
|
|
1129
|
-
this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
|
|
1130
|
-
} else {
|
|
1131
|
-
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
1068
|
+
__name(_Cfg, "Cfg");
|
|
1069
|
+
var Cfg = _Cfg;
|
|
1070
|
+
var _Monitor = class _Monitor {
|
|
1071
|
+
/**
|
|
1072
|
+
* Ingest browser events
|
|
1073
|
+
*
|
|
1074
|
+
* Accepts a batch of up to 50 frontend events. No authentication required — anonymous visitors can send events.
|
|
1075
|
+
*/
|
|
1076
|
+
static cfgMonitorIngestCreate(options) {
|
|
1077
|
+
return (options.client ?? client).post({
|
|
1078
|
+
url: "/cfg/monitor/ingest/",
|
|
1079
|
+
...options,
|
|
1080
|
+
headers: {
|
|
1081
|
+
"Content-Type": "application/json",
|
|
1082
|
+
...options.headers
|
|
1132
1083
|
}
|
|
1133
|
-
}
|
|
1134
|
-
this.logger?.error("LocalStorage.removeItem failed:", error);
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1137
|
-
};
|
|
1138
|
-
__name(_LocalStorageAdapter, "LocalStorageAdapter");
|
|
1139
|
-
var LocalStorageAdapter = _LocalStorageAdapter;
|
|
1140
|
-
var _MemoryStorageAdapter = class _MemoryStorageAdapter {
|
|
1141
|
-
constructor(logger) {
|
|
1142
|
-
__publicField(this, "storage", /* @__PURE__ */ new Map());
|
|
1143
|
-
__publicField(this, "logger");
|
|
1144
|
-
this.logger = logger;
|
|
1145
|
-
}
|
|
1146
|
-
getItem(key) {
|
|
1147
|
-
const value = this.storage.get(key) || null;
|
|
1148
|
-
this.logger?.debug(`MemoryStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
1149
|
-
return value;
|
|
1150
|
-
}
|
|
1151
|
-
setItem(key, value) {
|
|
1152
|
-
this.storage.set(key, value);
|
|
1153
|
-
this.logger?.debug(`MemoryStorage.setItem("${key}"): success`);
|
|
1154
|
-
}
|
|
1155
|
-
removeItem(key) {
|
|
1156
|
-
this.storage.delete(key);
|
|
1157
|
-
this.logger?.debug(`MemoryStorage.removeItem("${key}"): success`);
|
|
1084
|
+
});
|
|
1158
1085
|
}
|
|
1159
1086
|
};
|
|
1160
|
-
__name(
|
|
1161
|
-
var
|
|
1162
|
-
|
|
1163
|
-
// src/_api/generated/cfg_monitor/enums.ts
|
|
1164
|
-
var FrontendEventIngestRequestEventType = /* @__PURE__ */ ((FrontendEventIngestRequestEventType2) => {
|
|
1165
|
-
FrontendEventIngestRequestEventType2["JS_ERROR"] = "JS_ERROR";
|
|
1166
|
-
FrontendEventIngestRequestEventType2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
1167
|
-
FrontendEventIngestRequestEventType2["ERROR"] = "ERROR";
|
|
1168
|
-
FrontendEventIngestRequestEventType2["WARNING"] = "WARNING";
|
|
1169
|
-
FrontendEventIngestRequestEventType2["PAGE_VIEW"] = "PAGE_VIEW";
|
|
1170
|
-
FrontendEventIngestRequestEventType2["PERFORMANCE"] = "PERFORMANCE";
|
|
1171
|
-
FrontendEventIngestRequestEventType2["CONSOLE"] = "CONSOLE";
|
|
1172
|
-
return FrontendEventIngestRequestEventType2;
|
|
1173
|
-
})(FrontendEventIngestRequestEventType || {});
|
|
1174
|
-
var FrontendEventIngestRequestLevel = /* @__PURE__ */ ((FrontendEventIngestRequestLevel2) => {
|
|
1175
|
-
FrontendEventIngestRequestLevel2["ERROR"] = "error";
|
|
1176
|
-
FrontendEventIngestRequestLevel2["WARNING"] = "warning";
|
|
1177
|
-
FrontendEventIngestRequestLevel2["INFO"] = "info";
|
|
1178
|
-
FrontendEventIngestRequestLevel2["DEBUG"] = "debug";
|
|
1179
|
-
return FrontendEventIngestRequestLevel2;
|
|
1180
|
-
})(FrontendEventIngestRequestLevel || {});
|
|
1181
|
-
|
|
1182
|
-
// src/_api/generated/cfg_monitor/_utils/schemas/FrontendEventIngestRequest.schema.ts
|
|
1183
|
-
var import_zod = require("zod");
|
|
1184
|
-
var FrontendEventIngestRequestSchema = import_zod.z.object({
|
|
1185
|
-
event_type: import_zod.z.nativeEnum(FrontendEventIngestRequestEventType),
|
|
1186
|
-
message: import_zod.z.string().min(1).max(5e3),
|
|
1187
|
-
level: import_zod.z.nativeEnum(FrontendEventIngestRequestLevel).optional(),
|
|
1188
|
-
stack_trace: import_zod.z.string().max(1e4).optional(),
|
|
1189
|
-
url: import_zod.z.string().max(2e3).optional(),
|
|
1190
|
-
fingerprint: import_zod.z.string().max(64).optional(),
|
|
1191
|
-
http_status: import_zod.z.number().int().nullable().optional(),
|
|
1192
|
-
http_method: import_zod.z.string().max(10).optional(),
|
|
1193
|
-
http_url: import_zod.z.string().max(2e3).optional(),
|
|
1194
|
-
session_id: import_zod.z.string().max(64).optional(),
|
|
1195
|
-
user_agent: import_zod.z.string().max(500).optional(),
|
|
1196
|
-
build_id: import_zod.z.string().max(100).optional(),
|
|
1197
|
-
environment: import_zod.z.string().max(20).optional(),
|
|
1198
|
-
extra: import_zod.z.record(import_zod.z.string(), import_zod.z.any()).optional(),
|
|
1199
|
-
project_name: import_zod.z.string().max(100).optional()
|
|
1200
|
-
});
|
|
1201
|
-
|
|
1202
|
-
// src/_api/generated/cfg_monitor/_utils/schemas/IngestBatchRequest.schema.ts
|
|
1203
|
-
var import_zod2 = require("zod");
|
|
1204
|
-
var IngestBatchRequestSchema = import_zod2.z.object({
|
|
1205
|
-
events: import_zod2.z.array(FrontendEventIngestRequestSchema)
|
|
1206
|
-
});
|
|
1087
|
+
__name(_Monitor, "Monitor");
|
|
1088
|
+
var Monitor = _Monitor;
|
|
1207
1089
|
|
|
1208
|
-
// src/_api/generated/cfg_monitor/
|
|
1209
|
-
var
|
|
1210
|
-
var
|
|
1090
|
+
// src/_api/generated/cfg_monitor/api.ts
|
|
1091
|
+
var ACCESS_KEY = "cfg.access_token";
|
|
1092
|
+
var REFRESH_KEY = "cfg.refresh_token";
|
|
1211
1093
|
function detectLocale() {
|
|
1212
1094
|
try {
|
|
1213
1095
|
if (typeof document !== "undefined") {
|
|
1214
|
-
const
|
|
1215
|
-
if (
|
|
1096
|
+
const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
1097
|
+
if (m) return decodeURIComponent(m[1]);
|
|
1216
1098
|
}
|
|
1217
1099
|
if (typeof navigator !== "undefined" && navigator.language) {
|
|
1218
1100
|
return navigator.language;
|
|
@@ -1223,144 +1105,72 @@ function detectLocale() {
|
|
|
1223
1105
|
}
|
|
1224
1106
|
__name(detectLocale, "detectLocale");
|
|
1225
1107
|
var _API = class _API {
|
|
1226
|
-
constructor(baseUrl,
|
|
1108
|
+
constructor(baseUrl, opts = {}) {
|
|
1227
1109
|
__publicField(this, "baseUrl");
|
|
1228
|
-
__publicField(this, "_client");
|
|
1229
|
-
__publicField(this, "_token", null);
|
|
1230
|
-
__publicField(this, "_refreshToken", null);
|
|
1231
|
-
__publicField(this, "_locale", null);
|
|
1232
1110
|
__publicField(this, "storage");
|
|
1233
|
-
__publicField(this, "
|
|
1234
|
-
|
|
1235
|
-
__publicField(this, "
|
|
1236
|
-
this
|
|
1237
|
-
this
|
|
1238
|
-
|
|
1239
|
-
this.storage =
|
|
1240
|
-
this.
|
|
1241
|
-
this.
|
|
1242
|
-
this.
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
this._token = this.storage.getItem(TOKEN_KEY);
|
|
1253
|
-
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
|
|
1254
|
-
}
|
|
1255
|
-
_reinitClients() {
|
|
1256
|
-
this._client = new APIClient(this.baseUrl, {
|
|
1257
|
-
httpClient: this.options?.httpClient,
|
|
1258
|
-
retryConfig: this.options?.retryConfig,
|
|
1259
|
-
loggerConfig: this.options?.loggerConfig,
|
|
1260
|
-
tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
|
|
1111
|
+
__publicField(this, "locale");
|
|
1112
|
+
__publicField(this, "apiKey");
|
|
1113
|
+
__publicField(this, "logger");
|
|
1114
|
+
__publicField(this, "cfg", Cfg);
|
|
1115
|
+
__publicField(this, "monitor", Monitor);
|
|
1116
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
1117
|
+
this.storage = opts.storage ?? new LocalStorageAdapter();
|
|
1118
|
+
this.logger = new APILogger(opts.logger);
|
|
1119
|
+
this.locale = opts.locale ?? null;
|
|
1120
|
+
this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
|
|
1121
|
+
const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
|
|
1122
|
+
client.setConfig({ baseUrl: this.baseUrl, credentials });
|
|
1123
|
+
client.interceptors.request.use((request) => {
|
|
1124
|
+
const access = this.getToken();
|
|
1125
|
+
if (access) request.headers.set("Authorization", `Bearer ${access}`);
|
|
1126
|
+
const locale = this.locale ?? detectLocale();
|
|
1127
|
+
if (locale) request.headers.set("Accept-Language", locale);
|
|
1128
|
+
if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
|
|
1129
|
+
return request;
|
|
1261
1130
|
});
|
|
1262
|
-
this._injectAuthHeader();
|
|
1263
|
-
this.monitor = this._client.monitor;
|
|
1264
|
-
}
|
|
1265
|
-
_injectAuthHeader() {
|
|
1266
|
-
const originalRequest = this._client.request.bind(this._client);
|
|
1267
|
-
this._client.request = async (method, path, options) => {
|
|
1268
|
-
const token = this.getToken();
|
|
1269
|
-
const locale = this._locale || detectLocale();
|
|
1270
|
-
const mergedOptions = {
|
|
1271
|
-
...options,
|
|
1272
|
-
headers: {
|
|
1273
|
-
...options?.headers || {},
|
|
1274
|
-
...token ? { "Authorization": `Bearer ${token}` } : {},
|
|
1275
|
-
...locale ? { "Accept-Language": locale } : {}
|
|
1276
|
-
}
|
|
1277
|
-
};
|
|
1278
|
-
return originalRequest(method, path, mergedOptions);
|
|
1279
|
-
};
|
|
1280
1131
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1132
|
+
// ── Base URL ────────────────────────────────────────────────────────────
|
|
1133
|
+
getBaseUrl() {
|
|
1134
|
+
return this.baseUrl;
|
|
1135
|
+
}
|
|
1136
|
+
setBaseUrl(url) {
|
|
1137
|
+
this.baseUrl = url.replace(/\/$/, "");
|
|
1138
|
+
client.setConfig({ baseUrl: this.baseUrl });
|
|
1139
|
+
}
|
|
1140
|
+
// ── Tokens ──────────────────────────────────────────────────────────────
|
|
1284
1141
|
getToken() {
|
|
1285
|
-
return this.storage.getItem(
|
|
1142
|
+
return this.storage.getItem(ACCESS_KEY);
|
|
1143
|
+
}
|
|
1144
|
+
setToken(token) {
|
|
1145
|
+
if (token) this.storage.setItem(ACCESS_KEY, token);
|
|
1146
|
+
else this.storage.removeItem(ACCESS_KEY);
|
|
1286
1147
|
}
|
|
1287
|
-
/**
|
|
1288
|
-
* Get current refresh token
|
|
1289
|
-
*/
|
|
1290
1148
|
getRefreshToken() {
|
|
1291
|
-
return this.storage.getItem(
|
|
1149
|
+
return this.storage.getItem(REFRESH_KEY);
|
|
1292
1150
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
* @param refreshToken - JWT refresh token (optional)
|
|
1297
|
-
*/
|
|
1298
|
-
setToken(token, refreshToken) {
|
|
1299
|
-
this._token = token;
|
|
1300
|
-
this.storage.setItem(TOKEN_KEY, token);
|
|
1301
|
-
if (refreshToken) {
|
|
1302
|
-
this._refreshToken = refreshToken;
|
|
1303
|
-
this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
|
|
1304
|
-
}
|
|
1305
|
-
this._reinitClients();
|
|
1151
|
+
setRefreshToken(token) {
|
|
1152
|
+
if (token) this.storage.setItem(REFRESH_KEY, token);
|
|
1153
|
+
else this.storage.removeItem(REFRESH_KEY);
|
|
1306
1154
|
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
clearTokens() {
|
|
1311
|
-
this._token = null;
|
|
1312
|
-
this._refreshToken = null;
|
|
1313
|
-
this.storage.removeItem(TOKEN_KEY);
|
|
1314
|
-
this.storage.removeItem(REFRESH_TOKEN_KEY);
|
|
1315
|
-
this._reinitClients();
|
|
1155
|
+
clearToken() {
|
|
1156
|
+
this.storage.removeItem(ACCESS_KEY);
|
|
1157
|
+
this.storage.removeItem(REFRESH_KEY);
|
|
1316
1158
|
}
|
|
1317
|
-
/**
|
|
1318
|
-
* Check if user is authenticated
|
|
1319
|
-
*/
|
|
1320
1159
|
isAuthenticated() {
|
|
1321
|
-
return
|
|
1322
|
-
}
|
|
1323
|
-
/**
|
|
1324
|
-
* Update base URL and reinitialize clients
|
|
1325
|
-
* @param url - New base URL
|
|
1326
|
-
*/
|
|
1327
|
-
setBaseUrl(url) {
|
|
1328
|
-
this.baseUrl = url;
|
|
1329
|
-
this._reinitClients();
|
|
1160
|
+
return this.getToken() !== null;
|
|
1330
1161
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
getBaseUrl() {
|
|
1335
|
-
return this.baseUrl;
|
|
1162
|
+
// ── Locale / API key ────────────────────────────────────────────────────
|
|
1163
|
+
getLocale() {
|
|
1164
|
+
return this.locale ?? detectLocale();
|
|
1336
1165
|
}
|
|
1337
|
-
/**
|
|
1338
|
-
* Set locale for Accept-Language header
|
|
1339
|
-
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
1340
|
-
*/
|
|
1341
1166
|
setLocale(locale) {
|
|
1342
|
-
this.
|
|
1167
|
+
this.locale = locale;
|
|
1343
1168
|
}
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
*/
|
|
1347
|
-
getLocale() {
|
|
1348
|
-
return this._locale;
|
|
1169
|
+
getApiKey() {
|
|
1170
|
+
return this.apiKey;
|
|
1349
1171
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
* @returns Path to the OpenAPI schema JSON file
|
|
1353
|
-
*
|
|
1354
|
-
* Note: The OpenAPI schema is available in the schema.json file.
|
|
1355
|
-
* You can load it dynamically using:
|
|
1356
|
-
* ```typescript
|
|
1357
|
-
* const schema = await fetch('./schema.json').then(r => r.json());
|
|
1358
|
-
* // or using fs in Node.js:
|
|
1359
|
-
* // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
|
|
1360
|
-
* ```
|
|
1361
|
-
*/
|
|
1362
|
-
getSchemaPath() {
|
|
1363
|
-
return "./schema.json";
|
|
1172
|
+
setApiKey(key) {
|
|
1173
|
+
this.apiKey = key;
|
|
1364
1174
|
}
|
|
1365
1175
|
};
|
|
1366
1176
|
__name(_API, "API");
|
|
@@ -1373,30 +1183,50 @@ function configureMonitorApi(baseUrl) {
|
|
|
1373
1183
|
}
|
|
1374
1184
|
__name(configureMonitorApi, "configureMonitorApi");
|
|
1375
1185
|
|
|
1186
|
+
// src/_api/generated/cfg_monitor/types.gen.ts
|
|
1187
|
+
var EventTypeEnum = /* @__PURE__ */ ((EventTypeEnum2) => {
|
|
1188
|
+
EventTypeEnum2["JS_ERROR"] = "JS_ERROR";
|
|
1189
|
+
EventTypeEnum2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
1190
|
+
EventTypeEnum2["ERROR"] = "ERROR";
|
|
1191
|
+
EventTypeEnum2["WARNING"] = "WARNING";
|
|
1192
|
+
EventTypeEnum2["PAGE_VIEW"] = "PAGE_VIEW";
|
|
1193
|
+
EventTypeEnum2["PERFORMANCE"] = "PERFORMANCE";
|
|
1194
|
+
EventTypeEnum2["CONSOLE"] = "CONSOLE";
|
|
1195
|
+
return EventTypeEnum2;
|
|
1196
|
+
})(EventTypeEnum || {});
|
|
1197
|
+
var LevelEnum = /* @__PURE__ */ ((LevelEnum2) => {
|
|
1198
|
+
LevelEnum2["ERROR"] = "error";
|
|
1199
|
+
LevelEnum2["WARNING"] = "warning";
|
|
1200
|
+
LevelEnum2["INFO"] = "info";
|
|
1201
|
+
LevelEnum2["DEBUG"] = "debug";
|
|
1202
|
+
return LevelEnum2;
|
|
1203
|
+
})(LevelEnum || {});
|
|
1204
|
+
|
|
1205
|
+
// src/_api/index.ts
|
|
1206
|
+
var INGEST_PATH = "/cfg/monitor/ingest/";
|
|
1207
|
+
|
|
1376
1208
|
// src/client/transport/ingest.ts
|
|
1377
|
-
var monitorApiBeacon = new API("", {
|
|
1378
|
-
storage: new MemoryStorageAdapter(),
|
|
1379
|
-
httpClient: new KeepAliveFetchAdapter()
|
|
1380
|
-
});
|
|
1381
|
-
function syncBeaconBaseUrl() {
|
|
1382
|
-
monitorApiBeacon.setBaseUrl(monitorApi.getBaseUrl());
|
|
1383
|
-
}
|
|
1384
|
-
__name(syncBeaconBaseUrl, "syncBeaconBaseUrl");
|
|
1385
1209
|
async function sendBatch(batch, useBeacon = false) {
|
|
1386
1210
|
if (batch.events.length === 0) return;
|
|
1387
|
-
if (useBeacon) {
|
|
1388
|
-
|
|
1389
|
-
await
|
|
1390
|
-
|
|
1391
|
-
|
|
1211
|
+
if (useBeacon && typeof fetch !== "undefined") {
|
|
1212
|
+
const baseUrl = monitorApi.getBaseUrl();
|
|
1213
|
+
await fetch(`${baseUrl}${INGEST_PATH}`, {
|
|
1214
|
+
method: "POST",
|
|
1215
|
+
headers: { "Content-Type": "application/json" },
|
|
1216
|
+
body: JSON.stringify(batch),
|
|
1217
|
+
keepalive: true,
|
|
1218
|
+
credentials: "include"
|
|
1219
|
+
});
|
|
1220
|
+
return;
|
|
1392
1221
|
}
|
|
1222
|
+
await Monitor.cfgMonitorIngestCreate({ body: batch, throwOnError: true });
|
|
1393
1223
|
}
|
|
1394
1224
|
__name(sendBatch, "sendBatch");
|
|
1395
1225
|
|
|
1396
1226
|
// src/client/utils/env.ts
|
|
1397
1227
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
1398
1228
|
var isProduction = !isDevelopment;
|
|
1399
|
-
var MONITOR_VERSION = "2.1.
|
|
1229
|
+
var MONITOR_VERSION = "2.1.327";
|
|
1400
1230
|
|
|
1401
1231
|
// src/client/constants.ts
|
|
1402
1232
|
var MONITOR_INGEST_PATTERN = /cfg\/monitor\/ingest/;
|