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