@djangocfg/monitor 2.1.322 → 2.1.331
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 +945 -1136
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +32 -46
- package/dist/client.d.ts +32 -46
- package/dist/client.mjs +945 -1147
- package/dist/client.mjs.map +1 -1
- package/dist/index.cjs +908 -1108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -46
- package/dist/index.d.ts +32 -46
- package/dist/index.mjs +901 -1112
- package/dist/index.mjs.map +1 -1
- package/dist/server.cjs +904 -1102
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +32 -46
- package/dist/server.d.ts +32 -46
- package/dist/server.mjs +896 -1105
- package/dist/server.mjs.map +1 -1
- package/package.json +7 -2
- package/src/_api/BaseClient.ts +1 -1
- package/src/_api/generated/_cfg_monitor/api.ts +120 -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 +29 -0
- package/src/_api/generated/_cfg_monitor/schemas/EventTypeEnum.ts +9 -0
- package/src/_api/generated/_cfg_monitor/schemas/FrontendEventIngestRequest.ts +27 -0
- 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 +5 -0
- package/src/_api/generated/_cfg_monitor/types.gen.ts +5 -0
- package/src/_api/generated/client/client.gen.ts +280 -0
- package/src/_api/generated/client/index.ts +25 -0
- package/src/_api/generated/client/types.gen.ts +217 -0
- package/src/_api/generated/client/utils.gen.ts +318 -0
- package/src/_api/generated/client.gen.ts +16 -0
- package/src/_api/generated/core/auth.gen.ts +41 -0
- package/src/_api/generated/core/bodySerializer.gen.ts +82 -0
- package/src/_api/generated/core/params.gen.ts +169 -0
- package/src/_api/generated/core/pathSerializer.gen.ts +171 -0
- package/src/_api/generated/core/queryKeySerializer.gen.ts +117 -0
- package/src/_api/generated/core/serverSentEvents.gen.ts +242 -0
- package/src/_api/generated/core/types.gen.ts +104 -0
- package/src/_api/generated/core/utils.gen.ts +140 -0
- package/src/_api/generated/helpers/errors.ts +70 -0
- package/src/_api/generated/helpers/index.ts +25 -0
- package/src/_api/generated/helpers/logger.ts +123 -0
- package/src/_api/generated/helpers/storage.ts +83 -0
- package/src/_api/generated/helpers/validation-events.ts +52 -0
- package/src/_api/generated/index.ts +22 -0
- package/src/_api/generated/sdk.gen.ts +55 -0
- package/src/_api/generated/types.gen.ts +79 -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/FrontendEventIngestRequest.schema.ts +0 -34
- 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/index.ts +0 -317
- 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.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/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/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
|
-
|
|
20
|
+
// src/_api/generated/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);
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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;
|
|
75
|
-
}
|
|
76
|
-
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
77
|
-
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
78
|
-
this._errors.push(err);
|
|
79
|
-
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
this._errors.push(err);
|
|
83
|
-
var timeout = this._timeouts.shift();
|
|
84
|
-
if (timeout === void 0) {
|
|
85
|
-
if (this._cachedTimeouts) {
|
|
86
|
-
this._errors.splice(0, this._errors.length - 1);
|
|
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/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);
|
|
272
|
+
// src/_api/generated/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);
|
|
181
285
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
189
|
-
for (var key in options) {
|
|
190
|
-
opts[key] = options[key];
|
|
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";
|
|
191
292
|
}
|
|
192
|
-
|
|
193
|
-
|
|
293
|
+
const value = path[name];
|
|
294
|
+
if (value === void 0 || value === null) {
|
|
295
|
+
continue;
|
|
194
296
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
297
|
+
if (Array.isArray(value)) {
|
|
298
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
299
|
+
continue;
|
|
198
300
|
}
|
|
199
|
-
if (
|
|
200
|
-
|
|
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;
|
|
201
313
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
return timeout;
|
|
212
|
-
};
|
|
213
|
-
exports.wrap = function(obj, options, methods) {
|
|
214
|
-
if (options instanceof Array) {
|
|
215
|
-
methods = options;
|
|
216
|
-
options = null;
|
|
314
|
+
if (style === "matrix") {
|
|
315
|
+
url = url.replace(
|
|
316
|
+
match,
|
|
317
|
+
`;${serializePrimitiveParam({
|
|
318
|
+
name,
|
|
319
|
+
value
|
|
320
|
+
})}`
|
|
321
|
+
);
|
|
322
|
+
continue;
|
|
217
323
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
324
|
+
const replaceValue = encodeURIComponent(
|
|
325
|
+
style === "label" ? `.${value}` : value
|
|
326
|
+
);
|
|
327
|
+
url = url.replace(match, replaceValue);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
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;
|
|
362
|
+
}
|
|
363
|
+
if (hasBody) {
|
|
364
|
+
return options.body;
|
|
365
|
+
}
|
|
366
|
+
return void 0;
|
|
367
|
+
}
|
|
368
|
+
__name(getValidRequestBody, "getValidRequestBody");
|
|
369
|
+
|
|
370
|
+
// src/_api/generated/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;
|
|
375
|
+
}
|
|
376
|
+
if (auth.scheme === "bearer") {
|
|
377
|
+
return `Bearer ${token}`;
|
|
378
|
+
}
|
|
379
|
+
if (auth.scheme === "basic") {
|
|
380
|
+
return `Basic ${btoa(token)}`;
|
|
381
|
+
}
|
|
382
|
+
return token;
|
|
383
|
+
}, "getAuthToken");
|
|
384
|
+
|
|
385
|
+
// src/_api/generated/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;
|
|
224
397
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (op.retry(err)) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
if (err) {
|
|
238
|
-
arguments[0] = op.mainError();
|
|
239
|
-
}
|
|
240
|
-
callback.apply(this, arguments);
|
|
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
|
|
241
407
|
});
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
244
424
|
});
|
|
245
|
-
|
|
246
|
-
|
|
425
|
+
if (serializedPrimitive) search.push(serializedPrimitive);
|
|
426
|
+
}
|
|
247
427
|
}
|
|
248
|
-
}
|
|
428
|
+
}
|
|
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;
|
|
249
458
|
}
|
|
250
|
-
})
|
|
251
|
-
|
|
252
|
-
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
|
|
253
|
-
var require_retry2 = __commonJS({
|
|
254
|
-
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module) {
|
|
255
|
-
module.exports = require_retry();
|
|
459
|
+
if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
|
|
460
|
+
return true;
|
|
256
461
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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;
|
|
471
|
+
}
|
|
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
|
+
}
|
|
274
492
|
}
|
|
275
|
-
};
|
|
276
|
-
__name(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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);
|
|
289
529
|
}
|
|
290
|
-
})
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
530
|
+
} else if (value !== void 0) {
|
|
531
|
+
mergedHeaders.set(
|
|
532
|
+
key,
|
|
533
|
+
typeof value === "object" ? JSON.stringify(value) : value
|
|
534
|
+
);
|
|
294
535
|
}
|
|
295
536
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
537
|
+
}
|
|
538
|
+
return mergedHeaders;
|
|
539
|
+
}, "mergeHeaders");
|
|
540
|
+
var _Interceptors = class _Interceptors {
|
|
541
|
+
constructor() {
|
|
542
|
+
__publicField(this, "fns", []);
|
|
543
|
+
}
|
|
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;
|
|
306
551
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
316
|
-
if (response.status !== 204) {
|
|
317
|
-
if (responseType === "blob") {
|
|
318
|
-
data = await response.blob();
|
|
319
|
-
} else if (responseType === "text") {
|
|
320
|
-
data = await response.text();
|
|
321
|
-
} else if (responseType === "json") {
|
|
322
|
-
data = await response.json();
|
|
323
|
-
} else if (contentType.includes("application/json")) {
|
|
324
|
-
data = await response.json();
|
|
325
|
-
} else if (contentType.startsWith("text/")) {
|
|
326
|
-
data = await response.text();
|
|
327
|
-
} else {
|
|
328
|
-
data = await response.blob();
|
|
329
|
-
}
|
|
552
|
+
}
|
|
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;
|
|
330
560
|
}
|
|
331
|
-
|
|
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
|
-
};
|
|
561
|
+
return this.fns.indexOf(id);
|
|
341
562
|
}
|
|
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"
|
|
342
596
|
};
|
|
343
|
-
__name(
|
|
344
|
-
|
|
597
|
+
var createConfig = /* @__PURE__ */ __name((override = {}) => ({
|
|
598
|
+
...jsonBodySerializer,
|
|
599
|
+
headers: defaultHeaders,
|
|
600
|
+
parseAs: "auto",
|
|
601
|
+
querySerializer: defaultQuerySerializer,
|
|
602
|
+
...override
|
|
603
|
+
}), "createConfig");
|
|
345
604
|
|
|
346
|
-
// src/_api/generated/
|
|
347
|
-
var
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
* Returns: { "field_name": ["error1", "error2"], ... }
|
|
369
|
-
*/
|
|
370
|
-
get fieldErrors() {
|
|
371
|
-
const details = this.details;
|
|
372
|
-
if (!details) return null;
|
|
373
|
-
const fieldErrors = {};
|
|
374
|
-
for (const [key, value] of Object.entries(details)) {
|
|
375
|
-
if (Array.isArray(value)) {
|
|
376
|
-
fieldErrors[key] = value;
|
|
377
|
-
}
|
|
605
|
+
// src/_api/generated/client/client.gen.ts
|
|
606
|
+
var createClient = /* @__PURE__ */ __name((config = {}) => {
|
|
607
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
608
|
+
const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
|
|
609
|
+
const setConfig = /* @__PURE__ */ __name((config2) => {
|
|
610
|
+
_config = mergeConfigs(_config, config2);
|
|
611
|
+
return getConfig();
|
|
612
|
+
}, "setConfig");
|
|
613
|
+
const interceptors = createInterceptors();
|
|
614
|
+
const beforeRequest = /* @__PURE__ */ __name(async (options) => {
|
|
615
|
+
const opts = {
|
|
616
|
+
..._config,
|
|
617
|
+
...options,
|
|
618
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
619
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
620
|
+
serializedBody: void 0
|
|
621
|
+
};
|
|
622
|
+
if (opts.security) {
|
|
623
|
+
await setAuthParams({
|
|
624
|
+
...opts,
|
|
625
|
+
security: opts.security
|
|
626
|
+
});
|
|
378
627
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Get single error message from DRF.
|
|
383
|
-
* Checks for "detail", "message", or first field error.
|
|
384
|
-
*/
|
|
385
|
-
get errorMessage() {
|
|
386
|
-
const details = this.details;
|
|
387
|
-
if (!details) return this.message;
|
|
388
|
-
if (details.detail) {
|
|
389
|
-
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
628
|
+
if (opts.requestValidator) {
|
|
629
|
+
await opts.requestValidator(opts);
|
|
390
630
|
}
|
|
391
|
-
if (
|
|
392
|
-
|
|
631
|
+
if (opts.body !== void 0 && opts.bodySerializer) {
|
|
632
|
+
opts.serializedBody = opts.bodySerializer(opts.body);
|
|
393
633
|
}
|
|
394
|
-
if (
|
|
395
|
-
|
|
634
|
+
if (opts.body === void 0 || opts.serializedBody === "") {
|
|
635
|
+
opts.headers.delete("Content-Type");
|
|
396
636
|
}
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
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 ?? _config.throwOnError;
|
|
643
|
+
const responseStyle = options.responseStyle ?? _config.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
|
+
}
|
|
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 {
|
|
402
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({ ..._config, ...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/client.gen.ts
|
|
804
|
+
var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
|
|
805
|
+
|
|
806
|
+
// src/_api/generated/helpers/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;
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
setItem(key, value) {
|
|
817
|
+
if (typeof window === "undefined") return;
|
|
818
|
+
try {
|
|
819
|
+
window.localStorage.setItem(key, value);
|
|
820
|
+
} catch {
|
|
403
821
|
}
|
|
404
|
-
return this.message;
|
|
405
822
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
+
}
|
|
409
836
|
}
|
|
410
|
-
|
|
411
|
-
|
|
837
|
+
};
|
|
838
|
+
__name(_LocalStorageAdapter, "LocalStorageAdapter");
|
|
839
|
+
var LocalStorageAdapter = _LocalStorageAdapter;
|
|
840
|
+
var _MemoryStorageAdapter = class _MemoryStorageAdapter {
|
|
841
|
+
constructor() {
|
|
842
|
+
__publicField(this, "store", /* @__PURE__ */ new Map());
|
|
412
843
|
}
|
|
413
|
-
|
|
414
|
-
return this.
|
|
844
|
+
getItem(key) {
|
|
845
|
+
return this.store.get(key) ?? null;
|
|
415
846
|
}
|
|
416
|
-
|
|
417
|
-
|
|
847
|
+
setItem(key, value) {
|
|
848
|
+
this.store.set(key, value);
|
|
418
849
|
}
|
|
419
|
-
|
|
420
|
-
|
|
850
|
+
removeItem(key) {
|
|
851
|
+
this.store.delete(key);
|
|
421
852
|
}
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
var APIError = _APIError;
|
|
425
|
-
var _NetworkError = class _NetworkError extends Error {
|
|
426
|
-
constructor(message, url, originalError) {
|
|
427
|
-
super(message);
|
|
428
|
-
this.url = url;
|
|
429
|
-
this.originalError = originalError;
|
|
430
|
-
this.name = "NetworkError";
|
|
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/helpers/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,14 @@ __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
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Get CSRF token from cookies (for SessionAuthentication).
|
|
793
|
-
*
|
|
794
|
-
* Returns null if cookie doesn't exist (JWT-only auth).
|
|
795
|
-
*/
|
|
796
|
-
getCsrfToken() {
|
|
797
|
-
const name = "csrftoken";
|
|
798
|
-
const value = `; ${document.cookie}`;
|
|
799
|
-
const parts = value.split(`; ${name}=`);
|
|
800
|
-
if (parts.length === 2) {
|
|
801
|
-
return parts.pop()?.split(";").shift() || null;
|
|
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
|
-
}
|
|
970
|
-
}
|
|
971
|
-
const networkError = error instanceof Error ? new NetworkError(error.message, url, error) : new NetworkError("Unknown error", url);
|
|
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
|
-
}
|
|
990
|
-
}
|
|
991
|
-
};
|
|
992
|
-
__name(_APIClient, "APIClient");
|
|
993
|
-
var APIClient = _APIClient;
|
|
994
|
-
|
|
995
|
-
// src/_api/generated/cfg_monitor/storage.ts
|
|
996
|
-
var _LocalStorageAdapter = class _LocalStorageAdapter {
|
|
997
|
-
constructor(logger) {
|
|
998
|
-
__publicField(this, "logger");
|
|
999
|
-
this.logger = logger;
|
|
1000
|
-
}
|
|
1001
|
-
getItem(key) {
|
|
1002
|
-
try {
|
|
1003
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
1004
|
-
const value = localStorage.getItem(key);
|
|
1005
|
-
this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
1006
|
-
return value;
|
|
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");
|
|
1033
|
-
}
|
|
1034
|
-
} catch (error) {
|
|
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`);
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
__name(_MemoryStorageAdapter, "MemoryStorageAdapter");
|
|
1062
|
-
var MemoryStorageAdapter = _MemoryStorageAdapter;
|
|
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
|
-
});
|
|
1108
|
-
|
|
1109
|
-
// src/_api/generated/cfg_monitor/index.ts
|
|
1110
|
-
var TOKEN_KEY = "auth_token";
|
|
1111
|
-
var REFRESH_TOKEN_KEY = "refresh_token";
|
|
953
|
+
// src/_api/generated/_cfg_monitor/api.ts
|
|
954
|
+
var ACCESS_KEY = "cfg.access_token";
|
|
955
|
+
var REFRESH_KEY = "cfg.refresh_token";
|
|
1112
956
|
function detectLocale() {
|
|
1113
957
|
try {
|
|
1114
958
|
if (typeof document !== "undefined") {
|
|
1115
|
-
const
|
|
1116
|
-
if (
|
|
959
|
+
const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
960
|
+
if (m) return decodeURIComponent(m[1]);
|
|
1117
961
|
}
|
|
1118
962
|
if (typeof navigator !== "undefined" && navigator.language) {
|
|
1119
963
|
return navigator.language;
|
|
@@ -1124,144 +968,70 @@ function detectLocale() {
|
|
|
1124
968
|
}
|
|
1125
969
|
__name(detectLocale, "detectLocale");
|
|
1126
970
|
var _API = class _API {
|
|
1127
|
-
constructor(baseUrl,
|
|
971
|
+
constructor(baseUrl, opts = {}) {
|
|
1128
972
|
__publicField(this, "baseUrl");
|
|
1129
|
-
__publicField(this, "_client");
|
|
1130
|
-
__publicField(this, "_token", null);
|
|
1131
|
-
__publicField(this, "_refreshToken", null);
|
|
1132
|
-
__publicField(this, "_locale", null);
|
|
1133
973
|
__publicField(this, "storage");
|
|
1134
|
-
__publicField(this, "
|
|
1135
|
-
|
|
1136
|
-
__publicField(this, "
|
|
1137
|
-
this.baseUrl = baseUrl;
|
|
1138
|
-
this.
|
|
1139
|
-
|
|
1140
|
-
this.
|
|
1141
|
-
this.
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
}
|
|
1152
|
-
_loadTokensFromStorage() {
|
|
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")
|
|
974
|
+
__publicField(this, "locale");
|
|
975
|
+
__publicField(this, "apiKey");
|
|
976
|
+
__publicField(this, "logger");
|
|
977
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
978
|
+
this.storage = opts.storage ?? new LocalStorageAdapter();
|
|
979
|
+
this.logger = new APILogger(opts.logger);
|
|
980
|
+
this.locale = opts.locale ?? null;
|
|
981
|
+
this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
|
|
982
|
+
const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
|
|
983
|
+
client.setConfig({ baseUrl: this.baseUrl, credentials });
|
|
984
|
+
client.interceptors.request.use((request) => {
|
|
985
|
+
const access = this.getToken();
|
|
986
|
+
if (access) request.headers.set("Authorization", `Bearer ${access}`);
|
|
987
|
+
const locale = this.locale ?? detectLocale();
|
|
988
|
+
if (locale) request.headers.set("Accept-Language", locale);
|
|
989
|
+
if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
|
|
990
|
+
return request;
|
|
1162
991
|
});
|
|
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
992
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
993
|
+
// ── Base URL ────────────────────────────────────────────────────────────
|
|
994
|
+
getBaseUrl() {
|
|
995
|
+
return this.baseUrl;
|
|
996
|
+
}
|
|
997
|
+
setBaseUrl(url) {
|
|
998
|
+
this.baseUrl = url.replace(/\/$/, "");
|
|
999
|
+
client.setConfig({ baseUrl: this.baseUrl });
|
|
1000
|
+
}
|
|
1001
|
+
// ── Tokens ──────────────────────────────────────────────────────────────
|
|
1185
1002
|
getToken() {
|
|
1186
|
-
return this.storage.getItem(
|
|
1003
|
+
return this.storage.getItem(ACCESS_KEY);
|
|
1004
|
+
}
|
|
1005
|
+
setToken(token) {
|
|
1006
|
+
if (token) this.storage.setItem(ACCESS_KEY, token);
|
|
1007
|
+
else this.storage.removeItem(ACCESS_KEY);
|
|
1187
1008
|
}
|
|
1188
|
-
/**
|
|
1189
|
-
* Get current refresh token
|
|
1190
|
-
*/
|
|
1191
1009
|
getRefreshToken() {
|
|
1192
|
-
return this.storage.getItem(
|
|
1193
|
-
}
|
|
1194
|
-
/**
|
|
1195
|
-
* Set JWT token and refresh token
|
|
1196
|
-
* @param token - JWT access token
|
|
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();
|
|
1207
|
-
}
|
|
1208
|
-
/**
|
|
1209
|
-
* Clear all tokens
|
|
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();
|
|
1217
|
-
}
|
|
1218
|
-
/**
|
|
1219
|
-
* Check if user is authenticated
|
|
1220
|
-
*/
|
|
1221
|
-
isAuthenticated() {
|
|
1222
|
-
return !!this.getToken();
|
|
1010
|
+
return this.storage.getItem(REFRESH_KEY);
|
|
1223
1011
|
}
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
*/
|
|
1228
|
-
setBaseUrl(url) {
|
|
1229
|
-
this.baseUrl = url;
|
|
1230
|
-
this._reinitClients();
|
|
1012
|
+
setRefreshToken(token) {
|
|
1013
|
+
if (token) this.storage.setItem(REFRESH_KEY, token);
|
|
1014
|
+
else this.storage.removeItem(REFRESH_KEY);
|
|
1231
1015
|
}
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
getBaseUrl() {
|
|
1236
|
-
return this.baseUrl;
|
|
1016
|
+
clearToken() {
|
|
1017
|
+
this.storage.removeItem(ACCESS_KEY);
|
|
1018
|
+
this.storage.removeItem(REFRESH_KEY);
|
|
1237
1019
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
1241
|
-
*/
|
|
1242
|
-
setLocale(locale) {
|
|
1243
|
-
this._locale = locale;
|
|
1020
|
+
isAuthenticated() {
|
|
1021
|
+
return this.getToken() !== null;
|
|
1244
1022
|
}
|
|
1245
|
-
|
|
1246
|
-
* Get current locale
|
|
1247
|
-
*/
|
|
1023
|
+
// ── Locale / API key ────────────────────────────────────────────────────
|
|
1248
1024
|
getLocale() {
|
|
1249
|
-
return this.
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
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";
|
|
1025
|
+
return this.locale ?? detectLocale();
|
|
1026
|
+
}
|
|
1027
|
+
setLocale(locale) {
|
|
1028
|
+
this.locale = locale;
|
|
1029
|
+
}
|
|
1030
|
+
getApiKey() {
|
|
1031
|
+
return this.apiKey;
|
|
1032
|
+
}
|
|
1033
|
+
setApiKey(key) {
|
|
1034
|
+
this.apiKey = key;
|
|
1265
1035
|
}
|
|
1266
1036
|
};
|
|
1267
1037
|
__name(_API, "API");
|
|
@@ -1269,8 +1039,27 @@ var API = _API;
|
|
|
1269
1039
|
|
|
1270
1040
|
// src/_api/BaseClient.ts
|
|
1271
1041
|
var monitorApi = new API("", { storage: new MemoryStorageAdapter() });
|
|
1042
|
+
|
|
1043
|
+
// src/_api/generated/types.gen.ts
|
|
1044
|
+
var EventTypeEnum = /* @__PURE__ */ ((EventTypeEnum2) => {
|
|
1045
|
+
EventTypeEnum2["JS_ERROR"] = "JS_ERROR";
|
|
1046
|
+
EventTypeEnum2["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
1047
|
+
EventTypeEnum2["ERROR"] = "ERROR";
|
|
1048
|
+
EventTypeEnum2["WARNING"] = "WARNING";
|
|
1049
|
+
EventTypeEnum2["PAGE_VIEW"] = "PAGE_VIEW";
|
|
1050
|
+
EventTypeEnum2["PERFORMANCE"] = "PERFORMANCE";
|
|
1051
|
+
EventTypeEnum2["CONSOLE"] = "CONSOLE";
|
|
1052
|
+
return EventTypeEnum2;
|
|
1053
|
+
})(EventTypeEnum || {});
|
|
1054
|
+
var LevelEnum = /* @__PURE__ */ ((LevelEnum2) => {
|
|
1055
|
+
LevelEnum2["ERROR"] = "error";
|
|
1056
|
+
LevelEnum2["WARNING"] = "warning";
|
|
1057
|
+
LevelEnum2["INFO"] = "info";
|
|
1058
|
+
LevelEnum2["DEBUG"] = "debug";
|
|
1059
|
+
return LevelEnum2;
|
|
1060
|
+
})(LevelEnum || {});
|
|
1272
1061
|
export {
|
|
1273
|
-
|
|
1274
|
-
|
|
1062
|
+
LevelEnum as EventLevel,
|
|
1063
|
+
EventTypeEnum as EventType
|
|
1275
1064
|
};
|
|
1276
1065
|
//# sourceMappingURL=index.mjs.map
|