@cadenza.io/service 2.17.73 → 2.17.75
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/browser/index.js +36 -3
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/index.mjs +36 -3
- package/dist/browser/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +71 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -3633,13 +3633,14 @@ var RestController = class _RestController {
|
|
|
3633
3633
|
this.diagnosticsErrorHistoryLimit = 100;
|
|
3634
3634
|
this.diagnosticsMaxClientEntries = 500;
|
|
3635
3635
|
this.destroyedDiagnosticsTtlMs = 15 * 6e4;
|
|
3636
|
-
this.fetchDataWithTimeout = async
|
|
3636
|
+
this.fetchDataWithTimeout = async (url, requestInit, timeoutMs) => {
|
|
3637
3637
|
if (typeof globalThis.fetch !== "function") {
|
|
3638
3638
|
throw new Error("Browser REST controller requires global fetch.");
|
|
3639
3639
|
}
|
|
3640
3640
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
3641
3641
|
const response = await globalThis.fetch(url, { ...requestInit, signal });
|
|
3642
|
-
|
|
3642
|
+
const parsedResponse = await this.parseFetchResponse(response);
|
|
3643
|
+
return parsedResponse.data;
|
|
3643
3644
|
};
|
|
3644
3645
|
CadenzaService.createMetaTask(
|
|
3645
3646
|
"Collect fetch transport diagnostics",
|
|
@@ -3985,6 +3986,38 @@ var RestController = class _RestController {
|
|
|
3985
3986
|
return String(error);
|
|
3986
3987
|
}
|
|
3987
3988
|
}
|
|
3989
|
+
async parseFetchResponse(response) {
|
|
3990
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
3991
|
+
const rawText = await response.text();
|
|
3992
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
3993
|
+
if (rawText.length === 0) {
|
|
3994
|
+
return {
|
|
3995
|
+
ok: response.ok,
|
|
3996
|
+
status: response.status,
|
|
3997
|
+
statusText: response.statusText,
|
|
3998
|
+
headers,
|
|
3999
|
+
data: {}
|
|
4000
|
+
};
|
|
4001
|
+
}
|
|
4002
|
+
if (!contentType.toLowerCase().includes("application/json")) {
|
|
4003
|
+
throw new Error(
|
|
4004
|
+
`Expected JSON response from ${response.url ?? "remote service"} but received ${contentType || "unknown content type"} (HTTP ${response.status}). Body preview: ${rawText.slice(0, 200)}`
|
|
4005
|
+
);
|
|
4006
|
+
}
|
|
4007
|
+
try {
|
|
4008
|
+
return {
|
|
4009
|
+
ok: response.ok,
|
|
4010
|
+
status: response.status,
|
|
4011
|
+
statusText: response.statusText,
|
|
4012
|
+
headers,
|
|
4013
|
+
data: JSON.parse(rawText)
|
|
4014
|
+
};
|
|
4015
|
+
} catch (error) {
|
|
4016
|
+
throw new Error(
|
|
4017
|
+
`Failed to parse JSON response from ${response.url ?? "remote service"} (HTTP ${response.status}). Body preview: ${rawText.slice(0, 200)}. Parse error: ${this.getErrorMessage(error)}`
|
|
4018
|
+
);
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
3988
4021
|
recordFetchClientError(fetchId, serviceName, url, error) {
|
|
3989
4022
|
const state = this.ensureFetchClientDiagnostics(fetchId, serviceName, url);
|
|
3990
4023
|
const message = this.getErrorMessage(error);
|
|
@@ -7186,7 +7219,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7186
7219
|
});
|
|
7187
7220
|
const signalName = resolveSignalNameFromSyncContext(ctx);
|
|
7188
7221
|
if (!signalName) {
|
|
7189
|
-
return
|
|
7222
|
+
return false;
|
|
7190
7223
|
}
|
|
7191
7224
|
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
7192
7225
|
if (!signalObservers?.has(signalName)) {
|