filemail-sdk 9.4.3 → 9.4.4
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/src/client/healthMonitor/onlineChecker/onlineChecker.d.ts +4 -0
- package/dist/src/client/healthMonitor/onlineChecker/onlineChecker.d.ts.map +1 -1
- package/dist/src/client/healthMonitor/onlineChecker/onlineChecker.js +49 -2
- package/dist/src/client/healthMonitor/onlineChecker/onlineChecker.js.map +1 -1
- package/dist/src/client/loggers/utils/logHealthyStatus.d.ts.map +1 -1
- package/dist/src/client/loggers/utils/logHealthyStatus.js +40 -5
- package/dist/src/client/loggers/utils/logHealthyStatus.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,10 @@ export default abstract class OnlineChecker {
|
|
|
6
6
|
isFileServerReachable(fileServerBaseUrl: string): Promise<OnlineCheckerResult>;
|
|
7
7
|
protected isGoogleReachable(): Promise<OnlineCheckerResult>;
|
|
8
8
|
protected probe(url: string, timeoutInMs?: number): Promise<OnlineCheckerResult>;
|
|
9
|
+
private getProbeResponseDetails;
|
|
10
|
+
private tryGetResponseBody;
|
|
11
|
+
private enrichProbeError;
|
|
12
|
+
private getErrorObject;
|
|
9
13
|
}
|
|
10
14
|
export interface OnlineCheckerResult {
|
|
11
15
|
isOnline: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onlineChecker.d.ts","sourceRoot":"","sources":["../../../../../src/client/healthMonitor/onlineChecker/onlineChecker.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,aAAa;IACvC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEjB,UAAU,EAAE,MAAM;aAOd,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAEnD,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI9C,qBAAqB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;cAI3E,iBAAiB,IAAI,OAAO,CAAC,mBAAmB,CAAC;cAIjD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,SAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"onlineChecker.d.ts","sourceRoot":"","sources":["../../../../../src/client/healthMonitor/onlineChecker/onlineChecker.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,aAAa;IACvC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;gBAEjB,UAAU,EAAE,MAAM;aAOd,gBAAgB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAEnD,cAAc,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAI9C,qBAAqB,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;cAI3E,iBAAiB,IAAI,OAAO,CAAC,mBAAmB,CAAC;cAIjD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,SAAO,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAkBtE,uBAAuB;YAgBvB,kBAAkB;IAWhC,OAAO,CAAC,gBAAgB;IA8BxB,OAAO,CAAC,cAAc;CASzB;AAED,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,KAAK,CAAC;CACjB"}
|
|
@@ -20,11 +20,58 @@ export default class OnlineChecker {
|
|
|
20
20
|
const result = await fetch(url, { method: `GET`, mode: `no-cors`, cache: `no-store`, signal: timeoutSignal });
|
|
21
21
|
if (result.ok || result.type === `opaque`)
|
|
22
22
|
return { isOnline: true };
|
|
23
|
-
|
|
23
|
+
const response = await this.getProbeResponseDetails(result);
|
|
24
|
+
throw this.enrichProbeError(new Error(`Response returned ${result.status} status`), url, response);
|
|
24
25
|
}
|
|
25
26
|
catch (error) {
|
|
26
|
-
return { isOnline: false, error: error };
|
|
27
|
+
return { isOnline: false, error: this.enrichProbeError(error, url) };
|
|
27
28
|
}
|
|
28
29
|
}
|
|
30
|
+
async getProbeResponseDetails(response) {
|
|
31
|
+
const body = await this.tryGetResponseBody(response);
|
|
32
|
+
const headers = {};
|
|
33
|
+
response.headers.forEach((value, key) => {
|
|
34
|
+
headers[key] = value;
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
status: response.status,
|
|
38
|
+
statusText: response.statusText || undefined,
|
|
39
|
+
headers: Object.keys(headers).length > 0 ? headers : undefined,
|
|
40
|
+
body,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
async tryGetResponseBody(response) {
|
|
44
|
+
try {
|
|
45
|
+
const body = await response.text();
|
|
46
|
+
return body.length > 0 ? body : undefined;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
enrichProbeError(error, requestUrl, response) {
|
|
53
|
+
const errorToEnrich = this.getErrorObject(error);
|
|
54
|
+
try {
|
|
55
|
+
errorToEnrich.requestUrl ??= requestUrl;
|
|
56
|
+
if (response !== undefined && errorToEnrich.response === undefined)
|
|
57
|
+
errorToEnrich.response = response;
|
|
58
|
+
return errorToEnrich;
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
const wrappedError = new Error(errorToEnrich.message, { cause: errorToEnrich });
|
|
62
|
+
wrappedError.name = errorToEnrich.name;
|
|
63
|
+
wrappedError.requestUrl = requestUrl;
|
|
64
|
+
if (response !== undefined)
|
|
65
|
+
wrappedError.response = response;
|
|
66
|
+
return wrappedError;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
getErrorObject(error) {
|
|
70
|
+
if (error instanceof Error)
|
|
71
|
+
return error;
|
|
72
|
+
if (typeof error === `string`)
|
|
73
|
+
return new Error(error);
|
|
74
|
+
return new Error(`Unknown health monitor probe error`);
|
|
75
|
+
}
|
|
29
76
|
}
|
|
30
77
|
//# sourceMappingURL=onlineChecker.js.map
|
|
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AC,SAAS,CAAC;QAC9C,CAAC;QACD,MAAM,CAAC;YACH,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC;IAEO,gBAAgB,CAAC,KAAc,EAAE,UAAkB,EAAE,QAA+B;QACxF,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAG9C,CAAC;QAEF,IAAI,CAAC;YACD,aAAa,CAAC,UAAU,KAAK,UAAU,CAAC;YAExC,IAAI,QAAQ,KAAK,SAAS,IAAI,aAAa,CAAC,QAAQ,KAAK,SAAS;gBAC9D,aAAa,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEtC,OAAO,aAAa,CAAC;QACzB,CAAC;QACD,MAAM,CAAC;YACH,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAG7E,CAAC;YAEF,YAAY,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;YACvC,YAAY,CAAC,UAAU,GAAG,UAAU,CAAC;YAErC,IAAI,QAAQ,KAAK,SAAS;gBACtB,YAAY,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAErC,OAAO,YAAY,CAAC;QACxB,CAAC;IACL,CAAC;IAEO,cAAc,CAAC,KAAc;QACjC,IAAI,KAAK,YAAY,KAAK;YACtB,OAAO,KAAK,CAAC;QAEjB,IAAI,OAAO,KAAK,KAAK,QAAQ;YACzB,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;QAE5B,OAAO,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAC3D,CAAC;CACJ","sourcesContent":["export default abstract class OnlineChecker {\n protected apiBaseUrl: string;\n\n constructor(apiBaseUrl: string) {\n if (!apiBaseUrl || apiBaseUrl.length === 0)\n throw new Error(`Api Base URL is required`);\n\n this.apiBaseUrl = apiBaseUrl;\n }\n\n public abstract isInternetOnline(): Promise<OnlineCheckerResult>;\n\n public async isApiReachable(): Promise<OnlineCheckerResult> {\n return await this.probe(`${this.apiBaseUrl}/heartbeat?d=${Date.now()}`);\n }\n\n public async isFileServerReachable(fileServerBaseUrl: string): Promise<OnlineCheckerResult> {\n return await this.probe(`${fileServerBaseUrl}/up?d=${Date.now()}`);\n }\n\n protected async isGoogleReachable(): Promise<OnlineCheckerResult> {\n return await this.probe(`https://www.gstatic.com/generate_204?d=${Date.now()}`);\n }\n\n protected async probe(url: string, timeoutInMs = 4000): Promise<OnlineCheckerResult> {\n try {\n const timeoutSignal = AbortSignal.timeout(timeoutInMs);\n\n const result = await fetch(url, { method: `GET`, mode: `no-cors`, cache: `no-store`, signal: timeoutSignal });\n\n if (result.ok || result.type === `opaque`)\n return { isOnline: true };\n\n const response = await this.getProbeResponseDetails(result);\n\n throw this.enrichProbeError(new Error(`Response returned ${result.status} status`), url, response);\n }\n catch (error) {\n return { isOnline: false, error: this.enrichProbeError(error, url) };\n }\n }\n\n private async getProbeResponseDetails(response: Response): Promise<ProbeResponseDetails> {\n const body = await this.tryGetResponseBody(response);\n const headers: Record<string, string> = {};\n\n response.headers.forEach((value, key) => {\n headers[key] = value;\n });\n\n return {\n status: response.status,\n statusText: response.statusText || undefined,\n headers: Object.keys(headers).length > 0 ? headers : undefined,\n body,\n };\n }\n\n private async tryGetResponseBody(response: Response): Promise<string | undefined> {\n try {\n const body = await response.text();\n\n return body.length > 0 ? body : undefined;\n }\n catch {\n return undefined;\n }\n }\n\n private enrichProbeError(error: unknown, requestUrl: string, response?: ProbeResponseDetails): Error {\n const errorToEnrich = this.getErrorObject(error) as Error & {\n requestUrl?: string;\n response?: ProbeResponseDetails;\n };\n\n try {\n errorToEnrich.requestUrl ??= requestUrl;\n\n if (response !== undefined && errorToEnrich.response === undefined)\n errorToEnrich.response = response;\n\n return errorToEnrich;\n }\n catch {\n const wrappedError = new Error(errorToEnrich.message, { cause: errorToEnrich }) as Error & {\n requestUrl?: string;\n response?: ProbeResponseDetails;\n };\n\n wrappedError.name = errorToEnrich.name;\n wrappedError.requestUrl = requestUrl;\n\n if (response !== undefined)\n wrappedError.response = response;\n\n return wrappedError;\n }\n }\n\n private getErrorObject(error: unknown): Error {\n if (error instanceof Error)\n return error;\n\n if (typeof error === `string`)\n return new Error(error);\n\n return new Error(`Unknown health monitor probe error`);\n }\n}\n\nexport interface OnlineCheckerResult {\n isOnline: boolean,\n error?: Error,\n}\n\ninterface ProbeResponseDetails {\n status?: number,\n statusText?: string,\n headers?: Record<string, string>,\n body?: string,\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logHealthyStatus.d.ts","sourceRoot":"","sources":["../../../../../src/client/loggers/utils/logHealthyStatus.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,MAAM,uEAAuE,CAAC;AAClH,OAAO,+BAA+E,MAAM,yEAAyE,CAAC;AACtK,OAAO,MAAM,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"logHealthyStatus.d.ts","sourceRoot":"","sources":["../../../../../src/client/loggers/utils/logHealthyStatus.ts"],"names":[],"mappings":"AAAA,OAAO,6BAA6B,MAAM,uEAAuE,CAAC;AAClH,OAAO,+BAA+E,MAAM,yEAAyE,CAAC;AACtK,OAAO,MAAM,MAAM,cAAc,CAAC;AAGlC,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,6BAA6B,GAAG,+BAA+B,EAAE,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,QAWlM"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
import logEventPropertyName from "../../../utils/logging/logEventPropertyNames.js";
|
|
1
2
|
export default function logHealthyStatus(logger, isHealthy, event, logEntryMetadata = {}) {
|
|
2
3
|
const serializableEvent = makeEventSerializable(isHealthy, event);
|
|
3
|
-
|
|
4
|
+
const logAdditionalData = {
|
|
5
|
+
isHealthy,
|
|
6
|
+
event: serializableEvent,
|
|
7
|
+
...getFileServerErrorMetadata(serializableEvent),
|
|
8
|
+
...getTransferIdMetadata(serializableEvent, logEntryMetadata),
|
|
9
|
+
...logEntryMetadata,
|
|
10
|
+
};
|
|
11
|
+
logger.logInfo(`Transfer health status`, logAdditionalData);
|
|
4
12
|
}
|
|
5
13
|
function makeEventSerializable(isHealthy, event) {
|
|
6
14
|
if (isHealthy)
|
|
@@ -19,10 +27,37 @@ function makeEventSerializable(isHealthy, event) {
|
|
|
19
27
|
function makeReasonValueSerializable(value) {
|
|
20
28
|
return {
|
|
21
29
|
...value,
|
|
22
|
-
error: value.error === undefined ? undefined :
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
error: value.error === undefined ? undefined : makeErrorSerializable(value.error),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function makeErrorSerializable(error) {
|
|
34
|
+
const errorWithMetadata = error;
|
|
35
|
+
return {
|
|
36
|
+
name: error.name,
|
|
37
|
+
message: error.message,
|
|
38
|
+
code: errorWithMetadata.code,
|
|
39
|
+
requestUrl: errorWithMetadata.requestUrl,
|
|
40
|
+
response: errorWithMetadata.response,
|
|
26
41
|
};
|
|
27
42
|
}
|
|
43
|
+
function getFileServerErrorMetadata(event) {
|
|
44
|
+
if (!isSerializableUnhealthyEvent(event))
|
|
45
|
+
return {};
|
|
46
|
+
const fileServerError = event.reason.fileServer.error;
|
|
47
|
+
return {
|
|
48
|
+
...(fileServerError?.requestUrl ? { fileServerRequestUrl: fileServerError.requestUrl } : {}),
|
|
49
|
+
...(fileServerError?.response ? { fileServerResponse: fileServerError.response } : {}),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function getTransferIdMetadata(event, logEntryMetadata) {
|
|
53
|
+
if (logEntryMetadata[logEventPropertyName.TransferIdPropertyName] !== undefined)
|
|
54
|
+
return {};
|
|
55
|
+
const transferId = event.transferId;
|
|
56
|
+
if (typeof transferId !== `string` || transferId.length === 0)
|
|
57
|
+
return {};
|
|
58
|
+
return { [logEventPropertyName.TransferIdPropertyName]: transferId };
|
|
59
|
+
}
|
|
60
|
+
function isSerializableUnhealthyEvent(event) {
|
|
61
|
+
return `reason` in event;
|
|
62
|
+
}
|
|
28
63
|
//# sourceMappingURL=logHealthyStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logHealthyStatus.js","sourceRoot":"","sources":["../../../../../src/client/loggers/utils/logHealthyStatus.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logHealthyStatus.js","sourceRoot":"","sources":["../../../../../src/client/loggers/utils/logHealthyStatus.ts"],"names":[],"mappings":"AAGA,OAAO,oBAAoB,MAAM,iDAAiD,CAAC;AAEnF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,MAAc,EAAE,SAAkB,EAAE,KAAsE,EAAE,mBAA4C,EAAE;IAC/L,MAAM,iBAAiB,GAAG,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAClE,MAAM,iBAAiB,GAAG;QACtB,SAAS;QACT,KAAK,EAAE,iBAAiB;QACxB,GAAG,0BAA0B,CAAC,iBAAiB,CAAC;QAChD,GAAG,qBAAqB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC;QAC7D,GAAG,gBAAgB;KACtB,CAAC;IAEF,MAAM,CAAC,OAAO,CAAC,wBAAwB,EAAE,iBAAiB,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,qBAAqB,CAAC,SAAkB,EAAE,KAAsE;IACrH,IAAI,SAAS;QACT,OAAO,KAAsC,CAAC;IAElD,MAAM,cAAc,GAAG,KAAwC,CAAC;IAEhE,OAAO;QACH,GAAG,cAAc;QACjB,MAAM,EAAE;YACJ,GAAG,cAAc,CAAC,MAAM;YACxB,QAAQ,EAAE,2BAA2B,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC;YACrE,GAAG,EAAE,2BAA2B,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,CAAC;YAC3D,UAAU,EA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,CAAC,UAAU,CAAC;IAEnG,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QACzD,OAAO,EAAE,CAAC;IAEd,OAAO,EAAE,CAAC,oBAAoB,CAAC,sBAAsB,CAAC,EAAE,UAAU,EAAE,CAAC;AACzE,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAqC;IACvE,OAAO,QAAQ,IAAI,KAAK,CAAC;AAC7B,CAAC","sourcesContent":["import HealthMonitorHealthyEventArgs from \"../../healthMonitor/events/eventArgs/healthMonitorHealthyEventArgs.js\";\nimport HealthMonitorUnhealthyEventArgs, { HealthMonitorUnhealthyEventArgsReasonValue } from \"../../healthMonitor/events/eventArgs/healthMonitorUnhealthyEventArgs.js\";\nimport Logger from \"../logger.js\";\nimport logEventPropertyName from \"../../../utils/logging/logEventPropertyNames.js\";\n\nexport default function logHealthyStatus(logger: Logger, isHealthy: boolean, event: HealthMonitorHealthyEventArgs | HealthMonitorUnhealthyEventArgs, logEntryMetadata: Record<string, unknown> = {}) {\n const serializableEvent = makeEventSerializable(isHealthy, event);\n const logAdditionalData = {\n isHealthy,\n event: serializableEvent,\n ...getFileServerErrorMetadata(serializableEvent),\n ...getTransferIdMetadata(serializableEvent, logEntryMetadata),\n ...logEntryMetadata,\n };\n\n logger.logInfo(`Transfer health status`, logAdditionalData);\n}\n\nfunction makeEventSerializable(isHealthy: boolean, event: HealthMonitorHealthyEventArgs | HealthMonitorUnhealthyEventArgs): SerializableHealthMonitorEvent {\n if (isHealthy)\n return event as HealthMonitorHealthyEventArgs;\n\n const unhealthyEvent = event as HealthMonitorUnhealthyEventArgs;\n\n return {\n ...unhealthyEvent,\n reason: {\n ...unhealthyEvent.reason,\n internet: makeReasonValueSerializable(unhealthyEvent.reason.internet),\n api: makeReasonValueSerializable(unhealthyEvent.reason.api),\n fileServer: makeReasonValueSerializable(unhealthyEvent.reason.fileServer),\n },\n };\n}\n\nfunction makeReasonValueSerializable(value: HealthMonitorUnhealthyEventArgsReasonValue): SerializableHealthMonitorUnhealthyEventArgsReasonValue {\n return {\n ...value,\n error: value.error === undefined ? undefined : makeErrorSerializable(value.error),\n };\n}\n\nfunction makeErrorSerializable(error: Error): SerializableHealthMonitorError {\n const errorWithMetadata = error as Error & {\n code?: string;\n requestUrl?: string;\n response?: SerializableHealthMonitorErrorResponse;\n };\n\n return {\n name: error.name,\n message: error.message,\n code: errorWithMetadata.code,\n requestUrl: errorWithMetadata.requestUrl,\n response: errorWithMetadata.response,\n };\n}\n\nfunction getFileServerErrorMetadata(event: SerializableHealthMonitorEvent): Record<string, unknown> {\n if (!isSerializableUnhealthyEvent(event))\n return {};\n\n const fileServerError = event.reason.fileServer.error;\n\n return {\n ...(fileServerError?.requestUrl ? { fileServerRequestUrl: fileServerError.requestUrl } : {}),\n ...(fileServerError?.response ? { fileServerResponse: fileServerError.response } : {}),\n };\n}\n\nfunction getTransferIdMetadata(event: SerializableHealthMonitorEvent, logEntryMetadata: Record<string, unknown>): Record<string, unknown> {\n if (logEntryMetadata[logEventPropertyName.TransferIdPropertyName] !== undefined)\n return {};\n\n const transferId = (event as SerializableHealthMonitorEvent & { transferId?: unknown }).transferId;\n\n if (typeof transferId !== `string` || transferId.length === 0)\n return {};\n\n return { [logEventPropertyName.TransferIdPropertyName]: transferId };\n}\n\nfunction isSerializableUnhealthyEvent(event: SerializableHealthMonitorEvent): event is SerializableHealthMonitorUnhealthyEventArgs {\n return `reason` in event;\n}\n\ntype SerializableHealthMonitorEvent = HealthMonitorHealthyEventArgs | SerializableHealthMonitorUnhealthyEventArgs;\n\ninterface SerializableHealthMonitorUnhealthyEventArgs extends Omit<HealthMonitorUnhealthyEventArgs, `reason`> {\n reason: SerializableHealthMonitorUnhealthyEventArgsReason;\n}\n\ninterface SerializableHealthMonitorUnhealthyEventArgsReason {\n internet: SerializableHealthMonitorUnhealthyEventArgsReasonValue,\n api: SerializableHealthMonitorUnhealthyEventArgsReasonValue,\n fileServer: SerializableHealthMonitorUnhealthyEventArgsReasonValue,\n}\n\ninterface SerializableHealthMonitorUnhealthyEventArgsReasonValue extends Omit<HealthMonitorUnhealthyEventArgsReasonValue, `error`> {\n error?: SerializableHealthMonitorError,\n}\n\ninterface SerializableHealthMonitorError {\n name: string,\n message: string,\n code?: string | number,\n requestUrl?: string,\n response?: SerializableHealthMonitorErrorResponse,\n}\n\ninterface SerializableHealthMonitorErrorResponse {\n status?: number,\n statusText?: string,\n headers?: Record<string, string>,\n body?: unknown,\n}\n"]}
|