@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.mjs
CHANGED
|
@@ -3582,13 +3582,14 @@ var RestController = class _RestController {
|
|
|
3582
3582
|
this.diagnosticsErrorHistoryLimit = 100;
|
|
3583
3583
|
this.diagnosticsMaxClientEntries = 500;
|
|
3584
3584
|
this.destroyedDiagnosticsTtlMs = 15 * 6e4;
|
|
3585
|
-
this.fetchDataWithTimeout = async
|
|
3585
|
+
this.fetchDataWithTimeout = async (url, requestInit, timeoutMs) => {
|
|
3586
3586
|
if (typeof globalThis.fetch !== "function") {
|
|
3587
3587
|
throw new Error("Browser REST controller requires global fetch.");
|
|
3588
3588
|
}
|
|
3589
3589
|
const signal = AbortSignal.timeout(timeoutMs);
|
|
3590
3590
|
const response = await globalThis.fetch(url, { ...requestInit, signal });
|
|
3591
|
-
|
|
3591
|
+
const parsedResponse = await this.parseFetchResponse(response);
|
|
3592
|
+
return parsedResponse.data;
|
|
3592
3593
|
};
|
|
3593
3594
|
CadenzaService.createMetaTask(
|
|
3594
3595
|
"Collect fetch transport diagnostics",
|
|
@@ -3934,6 +3935,38 @@ var RestController = class _RestController {
|
|
|
3934
3935
|
return String(error);
|
|
3935
3936
|
}
|
|
3936
3937
|
}
|
|
3938
|
+
async parseFetchResponse(response) {
|
|
3939
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
3940
|
+
const rawText = await response.text();
|
|
3941
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
3942
|
+
if (rawText.length === 0) {
|
|
3943
|
+
return {
|
|
3944
|
+
ok: response.ok,
|
|
3945
|
+
status: response.status,
|
|
3946
|
+
statusText: response.statusText,
|
|
3947
|
+
headers,
|
|
3948
|
+
data: {}
|
|
3949
|
+
};
|
|
3950
|
+
}
|
|
3951
|
+
if (!contentType.toLowerCase().includes("application/json")) {
|
|
3952
|
+
throw new Error(
|
|
3953
|
+
`Expected JSON response from ${response.url ?? "remote service"} but received ${contentType || "unknown content type"} (HTTP ${response.status}). Body preview: ${rawText.slice(0, 200)}`
|
|
3954
|
+
);
|
|
3955
|
+
}
|
|
3956
|
+
try {
|
|
3957
|
+
return {
|
|
3958
|
+
ok: response.ok,
|
|
3959
|
+
status: response.status,
|
|
3960
|
+
statusText: response.statusText,
|
|
3961
|
+
headers,
|
|
3962
|
+
data: JSON.parse(rawText)
|
|
3963
|
+
};
|
|
3964
|
+
} catch (error) {
|
|
3965
|
+
throw new Error(
|
|
3966
|
+
`Failed to parse JSON response from ${response.url ?? "remote service"} (HTTP ${response.status}). Body preview: ${rawText.slice(0, 200)}. Parse error: ${this.getErrorMessage(error)}`
|
|
3967
|
+
);
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3937
3970
|
recordFetchClientError(fetchId, serviceName, url, error) {
|
|
3938
3971
|
const state = this.ensureFetchClientDiagnostics(fetchId, serviceName, url);
|
|
3939
3972
|
const message = this.getErrorMessage(error);
|
|
@@ -7137,7 +7170,7 @@ var GraphSyncController = class _GraphSyncController {
|
|
|
7137
7170
|
});
|
|
7138
7171
|
const signalName = resolveSignalNameFromSyncContext(ctx);
|
|
7139
7172
|
if (!signalName) {
|
|
7140
|
-
return
|
|
7173
|
+
return false;
|
|
7141
7174
|
}
|
|
7142
7175
|
const signalObservers = CadenzaService.signalBroker.signalObservers;
|
|
7143
7176
|
if (!signalObservers?.has(signalName)) {
|