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