@djangocfg/monitor 2.1.217 → 2.1.219
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/README.md +30 -0
- package/dist/client.cjs +425 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +50 -1
- package/dist/client.d.ts +50 -1
- package/dist/client.mjs +444 -2
- package/dist/client.mjs.map +1 -1
- package/dist/index.cjs +354 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +373 -1
- package/dist/index.mjs.map +1 -1
- package/dist/server.cjs +354 -3
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +373 -1
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -2
- package/src/client/MonitorProvider.tsx +2 -0
- package/src/client/index.ts +5 -1
- package/src/client/window.ts +117 -0
- package/src/.claude/.sidecar/activity.jsonl +0 -1
- package/src/.claude/.sidecar/map_cache.json +0 -38
- package/src/.claude/.sidecar/usage.json +0 -5
- package/src/.claude/project-map.md +0 -29
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,235 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js
|
|
34
|
+
var require_retry_operation = __commonJS({
|
|
35
|
+
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry_operation.js"(exports, module2) {
|
|
36
|
+
function RetryOperation(timeouts, options) {
|
|
37
|
+
if (typeof options === "boolean") {
|
|
38
|
+
options = { forever: options };
|
|
39
|
+
}
|
|
40
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
41
|
+
this._timeouts = timeouts;
|
|
42
|
+
this._options = options || {};
|
|
43
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
44
|
+
this._fn = null;
|
|
45
|
+
this._errors = [];
|
|
46
|
+
this._attempts = 1;
|
|
47
|
+
this._operationTimeout = null;
|
|
48
|
+
this._operationTimeoutCb = null;
|
|
49
|
+
this._timeout = null;
|
|
50
|
+
this._operationStart = null;
|
|
51
|
+
this._timer = null;
|
|
52
|
+
if (this._options.forever) {
|
|
53
|
+
this._cachedTimeouts = this._timeouts.slice(0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
__name(RetryOperation, "RetryOperation");
|
|
57
|
+
module2.exports = RetryOperation;
|
|
58
|
+
RetryOperation.prototype.reset = function() {
|
|
59
|
+
this._attempts = 1;
|
|
60
|
+
this._timeouts = this._originalTimeouts.slice(0);
|
|
61
|
+
};
|
|
62
|
+
RetryOperation.prototype.stop = function() {
|
|
63
|
+
if (this._timeout) {
|
|
64
|
+
clearTimeout(this._timeout);
|
|
65
|
+
}
|
|
66
|
+
if (this._timer) {
|
|
67
|
+
clearTimeout(this._timer);
|
|
68
|
+
}
|
|
69
|
+
this._timeouts = [];
|
|
70
|
+
this._cachedTimeouts = null;
|
|
71
|
+
};
|
|
72
|
+
RetryOperation.prototype.retry = function(err) {
|
|
73
|
+
if (this._timeout) {
|
|
74
|
+
clearTimeout(this._timeout);
|
|
75
|
+
}
|
|
76
|
+
if (!err) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
80
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
81
|
+
this._errors.push(err);
|
|
82
|
+
this._errors.unshift(new Error("RetryOperation timeout occurred"));
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
this._errors.push(err);
|
|
86
|
+
var timeout = this._timeouts.shift();
|
|
87
|
+
if (timeout === void 0) {
|
|
88
|
+
if (this._cachedTimeouts) {
|
|
89
|
+
this._errors.splice(0, this._errors.length - 1);
|
|
90
|
+
timeout = this._cachedTimeouts.slice(-1);
|
|
91
|
+
} else {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
var self = this;
|
|
96
|
+
this._timer = setTimeout(function() {
|
|
97
|
+
self._attempts++;
|
|
98
|
+
if (self._operationTimeoutCb) {
|
|
99
|
+
self._timeout = setTimeout(function() {
|
|
100
|
+
self._operationTimeoutCb(self._attempts);
|
|
101
|
+
}, self._operationTimeout);
|
|
102
|
+
if (self._options.unref) {
|
|
103
|
+
self._timeout.unref();
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
self._fn(self._attempts);
|
|
107
|
+
}, timeout);
|
|
108
|
+
if (this._options.unref) {
|
|
109
|
+
this._timer.unref();
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
113
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
114
|
+
this._fn = fn;
|
|
115
|
+
if (timeoutOps) {
|
|
116
|
+
if (timeoutOps.timeout) {
|
|
117
|
+
this._operationTimeout = timeoutOps.timeout;
|
|
118
|
+
}
|
|
119
|
+
if (timeoutOps.cb) {
|
|
120
|
+
this._operationTimeoutCb = timeoutOps.cb;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
var self = this;
|
|
124
|
+
if (this._operationTimeoutCb) {
|
|
125
|
+
this._timeout = setTimeout(function() {
|
|
126
|
+
self._operationTimeoutCb();
|
|
127
|
+
}, self._operationTimeout);
|
|
128
|
+
}
|
|
129
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
130
|
+
this._fn(this._attempts);
|
|
131
|
+
};
|
|
132
|
+
RetryOperation.prototype.try = function(fn) {
|
|
133
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
134
|
+
this.attempt(fn);
|
|
135
|
+
};
|
|
136
|
+
RetryOperation.prototype.start = function(fn) {
|
|
137
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
138
|
+
this.attempt(fn);
|
|
139
|
+
};
|
|
140
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
141
|
+
RetryOperation.prototype.errors = function() {
|
|
142
|
+
return this._errors;
|
|
143
|
+
};
|
|
144
|
+
RetryOperation.prototype.attempts = function() {
|
|
145
|
+
return this._attempts;
|
|
146
|
+
};
|
|
147
|
+
RetryOperation.prototype.mainError = function() {
|
|
148
|
+
if (this._errors.length === 0) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
var counts = {};
|
|
152
|
+
var mainError = null;
|
|
153
|
+
var mainErrorCount = 0;
|
|
154
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
155
|
+
var error = this._errors[i];
|
|
156
|
+
var message = error.message;
|
|
157
|
+
var count = (counts[message] || 0) + 1;
|
|
158
|
+
counts[message] = count;
|
|
159
|
+
if (count >= mainErrorCount) {
|
|
160
|
+
mainError = error;
|
|
161
|
+
mainErrorCount = count;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return mainError;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js
|
|
170
|
+
var require_retry = __commonJS({
|
|
171
|
+
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/lib/retry.js"(exports) {
|
|
172
|
+
var RetryOperation = require_retry_operation();
|
|
173
|
+
exports.operation = function(options) {
|
|
174
|
+
var timeouts = exports.timeouts(options);
|
|
175
|
+
return new RetryOperation(timeouts, {
|
|
176
|
+
forever: options && (options.forever || options.retries === Infinity),
|
|
177
|
+
unref: options && options.unref,
|
|
178
|
+
maxRetryTime: options && options.maxRetryTime
|
|
179
|
+
});
|
|
180
|
+
};
|
|
181
|
+
exports.timeouts = function(options) {
|
|
182
|
+
if (options instanceof Array) {
|
|
183
|
+
return [].concat(options);
|
|
184
|
+
}
|
|
185
|
+
var opts = {
|
|
186
|
+
retries: 10,
|
|
187
|
+
factor: 2,
|
|
188
|
+
minTimeout: 1 * 1e3,
|
|
189
|
+
maxTimeout: Infinity,
|
|
190
|
+
randomize: false
|
|
191
|
+
};
|
|
192
|
+
for (var key in options) {
|
|
193
|
+
opts[key] = options[key];
|
|
194
|
+
}
|
|
195
|
+
if (opts.minTimeout > opts.maxTimeout) {
|
|
196
|
+
throw new Error("minTimeout is greater than maxTimeout");
|
|
197
|
+
}
|
|
198
|
+
var timeouts = [];
|
|
199
|
+
for (var i = 0; i < opts.retries; i++) {
|
|
200
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
201
|
+
}
|
|
202
|
+
if (options && options.forever && !timeouts.length) {
|
|
203
|
+
timeouts.push(this.createTimeout(i, opts));
|
|
204
|
+
}
|
|
205
|
+
timeouts.sort(function(a, b) {
|
|
206
|
+
return a - b;
|
|
207
|
+
});
|
|
208
|
+
return timeouts;
|
|
209
|
+
};
|
|
210
|
+
exports.createTimeout = function(attempt, opts) {
|
|
211
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
212
|
+
var timeout = Math.round(random * Math.max(opts.minTimeout, 1) * Math.pow(opts.factor, attempt));
|
|
213
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
214
|
+
return timeout;
|
|
215
|
+
};
|
|
216
|
+
exports.wrap = function(obj, options, methods) {
|
|
217
|
+
if (options instanceof Array) {
|
|
218
|
+
methods = options;
|
|
219
|
+
options = null;
|
|
220
|
+
}
|
|
221
|
+
if (!methods) {
|
|
222
|
+
methods = [];
|
|
223
|
+
for (var key in obj) {
|
|
224
|
+
if (typeof obj[key] === "function") {
|
|
225
|
+
methods.push(key);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
for (var i = 0; i < methods.length; i++) {
|
|
230
|
+
var method = methods[i];
|
|
231
|
+
var original = obj[method];
|
|
232
|
+
obj[method] = (/* @__PURE__ */ __name(function retryWrapper(original2) {
|
|
233
|
+
var op = exports.operation(options);
|
|
234
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
235
|
+
var callback = args.pop();
|
|
236
|
+
args.push(function(err) {
|
|
237
|
+
if (op.retry(err)) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (err) {
|
|
241
|
+
arguments[0] = op.mainError();
|
|
242
|
+
}
|
|
243
|
+
callback.apply(this, arguments);
|
|
244
|
+
});
|
|
245
|
+
op.attempt(function() {
|
|
246
|
+
original2.apply(obj, args);
|
|
247
|
+
});
|
|
248
|
+
}, "retryWrapper")).bind(obj, original);
|
|
249
|
+
obj[method].options = options;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
// ../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js
|
|
256
|
+
var require_retry2 = __commonJS({
|
|
257
|
+
"../../node_modules/.pnpm/retry@0.13.1/node_modules/retry/index.js"(exports, module2) {
|
|
258
|
+
module2.exports = require_retry();
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
30
262
|
// src/index.ts
|
|
31
263
|
var index_exports = {};
|
|
32
264
|
__export(index_exports, {
|
|
@@ -350,8 +582,127 @@ __name(_APILogger, "APILogger");
|
|
|
350
582
|
var APILogger = _APILogger;
|
|
351
583
|
var defaultLogger = new APILogger();
|
|
352
584
|
|
|
585
|
+
// ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
586
|
+
var import_retry = __toESM(require_retry2(), 1);
|
|
587
|
+
|
|
588
|
+
// ../../node_modules/.pnpm/is-network-error@1.3.0/node_modules/is-network-error/index.js
|
|
589
|
+
var objectToString = Object.prototype.toString;
|
|
590
|
+
var isError = /* @__PURE__ */ __name((value) => objectToString.call(value) === "[object Error]", "isError");
|
|
591
|
+
var errorMessages = /* @__PURE__ */ new Set([
|
|
592
|
+
"network error",
|
|
593
|
+
// Chrome
|
|
594
|
+
"Failed to fetch",
|
|
595
|
+
// Chrome
|
|
596
|
+
"NetworkError when attempting to fetch resource.",
|
|
597
|
+
// Firefox
|
|
598
|
+
"The Internet connection appears to be offline.",
|
|
599
|
+
// Safari 16
|
|
600
|
+
"Network request failed",
|
|
601
|
+
// `cross-fetch`
|
|
602
|
+
"fetch failed",
|
|
603
|
+
// Undici (Node.js)
|
|
604
|
+
"terminated",
|
|
605
|
+
// Undici (Node.js)
|
|
606
|
+
" A network error occurred.",
|
|
607
|
+
// Bun (WebKit)
|
|
608
|
+
"Network connection lost"
|
|
609
|
+
// Cloudflare Workers (fetch)
|
|
610
|
+
]);
|
|
611
|
+
function isNetworkError(error) {
|
|
612
|
+
const isValid = error && isError(error) && error.name === "TypeError" && typeof error.message === "string";
|
|
613
|
+
if (!isValid) {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
const { message, stack } = error;
|
|
617
|
+
if (message === "Load failed") {
|
|
618
|
+
return stack === void 0 || "__sentry_captured__" in error;
|
|
619
|
+
}
|
|
620
|
+
if (message.startsWith("error sending request for url")) {
|
|
621
|
+
return true;
|
|
622
|
+
}
|
|
623
|
+
return errorMessages.has(message);
|
|
624
|
+
}
|
|
625
|
+
__name(isNetworkError, "isNetworkError");
|
|
626
|
+
|
|
627
|
+
// ../../node_modules/.pnpm/p-retry@6.2.1/node_modules/p-retry/index.js
|
|
628
|
+
var _AbortError = class _AbortError extends Error {
|
|
629
|
+
constructor(message) {
|
|
630
|
+
super();
|
|
631
|
+
if (message instanceof Error) {
|
|
632
|
+
this.originalError = message;
|
|
633
|
+
({ message } = message);
|
|
634
|
+
} else {
|
|
635
|
+
this.originalError = new Error(message);
|
|
636
|
+
this.originalError.stack = this.stack;
|
|
637
|
+
}
|
|
638
|
+
this.name = "AbortError";
|
|
639
|
+
this.message = message;
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
__name(_AbortError, "AbortError");
|
|
643
|
+
var AbortError = _AbortError;
|
|
644
|
+
var decorateErrorWithCounts = /* @__PURE__ */ __name((error, attemptNumber, options) => {
|
|
645
|
+
const retriesLeft = options.retries - (attemptNumber - 1);
|
|
646
|
+
error.attemptNumber = attemptNumber;
|
|
647
|
+
error.retriesLeft = retriesLeft;
|
|
648
|
+
return error;
|
|
649
|
+
}, "decorateErrorWithCounts");
|
|
650
|
+
async function pRetry(input, options) {
|
|
651
|
+
return new Promise((resolve, reject) => {
|
|
652
|
+
options = { ...options };
|
|
653
|
+
options.onFailedAttempt ?? (options.onFailedAttempt = () => {
|
|
654
|
+
});
|
|
655
|
+
options.shouldRetry ?? (options.shouldRetry = () => true);
|
|
656
|
+
options.retries ?? (options.retries = 10);
|
|
657
|
+
const operation = import_retry.default.operation(options);
|
|
658
|
+
const abortHandler = /* @__PURE__ */ __name(() => {
|
|
659
|
+
operation.stop();
|
|
660
|
+
reject(options.signal?.reason);
|
|
661
|
+
}, "abortHandler");
|
|
662
|
+
if (options.signal && !options.signal.aborted) {
|
|
663
|
+
options.signal.addEventListener("abort", abortHandler, { once: true });
|
|
664
|
+
}
|
|
665
|
+
const cleanUp = /* @__PURE__ */ __name(() => {
|
|
666
|
+
options.signal?.removeEventListener("abort", abortHandler);
|
|
667
|
+
operation.stop();
|
|
668
|
+
}, "cleanUp");
|
|
669
|
+
operation.attempt(async (attemptNumber) => {
|
|
670
|
+
try {
|
|
671
|
+
const result = await input(attemptNumber);
|
|
672
|
+
cleanUp();
|
|
673
|
+
resolve(result);
|
|
674
|
+
} catch (error) {
|
|
675
|
+
try {
|
|
676
|
+
if (!(error instanceof Error)) {
|
|
677
|
+
throw new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
|
|
678
|
+
}
|
|
679
|
+
if (error instanceof AbortError) {
|
|
680
|
+
throw error.originalError;
|
|
681
|
+
}
|
|
682
|
+
if (error instanceof TypeError && !isNetworkError(error)) {
|
|
683
|
+
throw error;
|
|
684
|
+
}
|
|
685
|
+
decorateErrorWithCounts(error, attemptNumber, options);
|
|
686
|
+
if (!await options.shouldRetry(error)) {
|
|
687
|
+
operation.stop();
|
|
688
|
+
reject(error);
|
|
689
|
+
}
|
|
690
|
+
await options.onFailedAttempt(error);
|
|
691
|
+
if (!operation.retry(error)) {
|
|
692
|
+
throw operation.mainError();
|
|
693
|
+
}
|
|
694
|
+
} catch (finalError) {
|
|
695
|
+
decorateErrorWithCounts(finalError, attemptNumber, options);
|
|
696
|
+
cleanUp();
|
|
697
|
+
reject(finalError);
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
__name(pRetry, "pRetry");
|
|
704
|
+
|
|
353
705
|
// src/_api/generated/cfg_monitor/retry.ts
|
|
354
|
-
var import_p_retry = __toESM(require("p-retry"), 1);
|
|
355
706
|
var DEFAULT_RETRY_CONFIG = {
|
|
356
707
|
retries: 3,
|
|
357
708
|
factor: 2,
|
|
@@ -380,13 +731,13 @@ function shouldRetry(error) {
|
|
|
380
731
|
__name(shouldRetry, "shouldRetry");
|
|
381
732
|
async function withRetry(fn, config) {
|
|
382
733
|
const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
|
|
383
|
-
return (
|
|
734
|
+
return pRetry(
|
|
384
735
|
async () => {
|
|
385
736
|
try {
|
|
386
737
|
return await fn();
|
|
387
738
|
} catch (error) {
|
|
388
739
|
if (!shouldRetry(error)) {
|
|
389
|
-
throw new
|
|
740
|
+
throw new AbortError(error);
|
|
390
741
|
}
|
|
391
742
|
throw error;
|
|
392
743
|
}
|