@apicircle/core 1.0.4 → 1.0.6
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/{chunk-L5DQT7V6.js → chunk-PUXJFN2Z.js} +3 -3
- package/dist/{chunk-L5DQT7V6.js.map → chunk-PUXJFN2Z.js.map} +1 -1
- package/dist/index.cjs +10 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/workspace/file-backed.cjs +2 -2
- package/dist/workspace/file-backed.cjs.map +1 -1
- package/dist/workspace/file-backed.js +1 -1
- package/dist/workspace/registry.cjs +2 -2
- package/dist/workspace/registry.cjs.map +1 -1
- package/dist/workspace/registry.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2943,6 +2943,9 @@ function resolveLocation(from, location) {
|
|
|
2943
2943
|
return null;
|
|
2944
2944
|
}
|
|
2945
2945
|
}
|
|
2946
|
+
function isBrowserRuntime() {
|
|
2947
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
2948
|
+
}
|
|
2946
2949
|
async function executeRequest(req, opts = {}) {
|
|
2947
2950
|
const fetchImpl = opts.fetchImpl ?? globalThis.fetch;
|
|
2948
2951
|
const timeoutMs = opts.timeoutMs === void 0 ? DEFAULT_TIMEOUT_MS : opts.timeoutMs;
|
|
@@ -2967,6 +2970,7 @@ async function executeRequest(req, opts = {}) {
|
|
|
2967
2970
|
() => controller.abort(new Error(`Request timed out after ${timeoutMs}ms`)),
|
|
2968
2971
|
timeoutMs
|
|
2969
2972
|
);
|
|
2973
|
+
const redirectMode = isBrowserRuntime() ? "follow" : "manual";
|
|
2970
2974
|
let currentUrl = builtRequest.url;
|
|
2971
2975
|
let currentHeaders = { ...builtRequest.headers };
|
|
2972
2976
|
let currentMethod = builtRequest.method;
|
|
@@ -2976,7 +2980,7 @@ async function executeRequest(req, opts = {}) {
|
|
|
2976
2980
|
headers: currentHeaders,
|
|
2977
2981
|
body: currentBody,
|
|
2978
2982
|
signal: controller.signal,
|
|
2979
|
-
redirect:
|
|
2983
|
+
redirect: redirectMode
|
|
2980
2984
|
});
|
|
2981
2985
|
let redirectCount = 0;
|
|
2982
2986
|
while (REDIRECT_STATUSES.has(response.status) && redirectCount < MAX_REDIRECTS) {
|
|
@@ -3002,7 +3006,7 @@ async function executeRequest(req, opts = {}) {
|
|
|
3002
3006
|
headers: currentHeaders,
|
|
3003
3007
|
body: currentBody,
|
|
3004
3008
|
signal: controller.signal,
|
|
3005
|
-
redirect:
|
|
3009
|
+
redirect: redirectMode
|
|
3006
3010
|
});
|
|
3007
3011
|
redirectCount++;
|
|
3008
3012
|
}
|
|
@@ -4476,10 +4480,10 @@ function collectAttachmentSlots(synced) {
|
|
|
4476
4480
|
for (const server of Object.values(synced.mockServers ?? {})) {
|
|
4477
4481
|
for (const endpoint of server.endpoints) {
|
|
4478
4482
|
collectMockResponseAttachment(endpoint.defaultResponse, seen);
|
|
4479
|
-
for (const rule of endpoint.requestValidation) {
|
|
4483
|
+
for (const rule of endpoint.requestValidation ?? []) {
|
|
4480
4484
|
collectMockResponseAttachment(rule.failResponse, seen);
|
|
4481
4485
|
}
|
|
4482
|
-
for (const rule of endpoint.responseRules) {
|
|
4486
|
+
for (const rule of endpoint.responseRules ?? []) {
|
|
4483
4487
|
collectMockResponseAttachment(rule.response, seen);
|
|
4484
4488
|
}
|
|
4485
4489
|
}
|
|
@@ -4498,10 +4502,10 @@ function collectAttachmentSlots(synced) {
|
|
|
4498
4502
|
return [...seen.values()];
|
|
4499
4503
|
}
|
|
4500
4504
|
function collectMockResponseAttachment(response, seen) {
|
|
4501
|
-
collectMockResponseBodyAttachment(response
|
|
4505
|
+
collectMockResponseBodyAttachment(response?.body, seen);
|
|
4502
4506
|
}
|
|
4503
4507
|
function collectMockResponseBodyAttachment(body, seen) {
|
|
4504
|
-
if (body
|
|
4508
|
+
if (body?.type !== "binary") return;
|
|
4505
4509
|
const ref = body.attachment;
|
|
4506
4510
|
if (!ref?.slotId || seen.has(ref.slotId)) return;
|
|
4507
4511
|
seen.set(ref.slotId, {
|