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