@spyglasshq/sdk 0.1.5 → 0.1.7
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/cjs/BaseClient.d.ts +4 -4
- package/dist/cjs/BaseClient.js +7 -7
- package/dist/cjs/Client.d.ts +7 -7
- package/dist/cjs/Client.js +58 -40
- package/dist/cjs/api/client/index.d.ts +1 -1
- package/dist/cjs/api/client/requests/SearchBrandsRequest.js +6 -6
- package/dist/cjs/api/client/requests/SearchCreatorsRequest.js +174 -174
- package/dist/cjs/api/client/requests/SearchMediaRequest.d.ts +2 -2
- package/dist/cjs/api/client/requests/SearchMediaRequest.js +223 -223
- package/dist/cjs/api/client/requests/index.d.ts +5 -5
- package/dist/cjs/api/errors/BadRequestError.d.ts +3 -3
- package/dist/cjs/api/errors/BadRequestError.js +2 -2
- package/dist/cjs/api/errors/ContentTooLargeError.d.ts +3 -3
- package/dist/cjs/api/errors/ContentTooLargeError.js +2 -2
- package/dist/cjs/api/errors/ForbiddenError.d.ts +3 -3
- package/dist/cjs/api/errors/ForbiddenError.js +2 -2
- package/dist/cjs/api/errors/InternalServerError.d.ts +3 -3
- package/dist/cjs/api/errors/InternalServerError.js +2 -2
- package/dist/cjs/api/errors/MethodNotAllowedError.d.ts +3 -3
- package/dist/cjs/api/errors/MethodNotAllowedError.js +2 -2
- package/dist/cjs/api/errors/NotFoundError.d.ts +3 -3
- package/dist/cjs/api/errors/NotFoundError.js +2 -2
- package/dist/cjs/api/errors/PaymentRequiredError.d.ts +3 -3
- package/dist/cjs/api/errors/PaymentRequiredError.js +2 -2
- package/dist/cjs/api/errors/TooManyRequestsError.d.ts +3 -3
- package/dist/cjs/api/errors/TooManyRequestsError.js +2 -2
- package/dist/cjs/api/errors/UnauthorizedError.d.ts +3 -3
- package/dist/cjs/api/errors/UnauthorizedError.js +2 -2
- package/dist/cjs/api/errors/index.d.ts +9 -9
- package/dist/cjs/api/index.d.ts +4 -4
- package/dist/cjs/api/resources/account/client/Client.d.ts +4 -4
- package/dist/cjs/api/resources/account/client/Client.js +38 -23
- package/dist/cjs/api/resources/account/client/index.d.ts +1 -1
- package/dist/cjs/api/resources/account/client/requests/InsightsAccountRequest.d.ts +1 -1
- package/dist/cjs/api/resources/account/client/requests/LandingPagesAccountRequest.d.ts +1 -1
- package/dist/cjs/api/resources/account/client/requests/index.d.ts +5 -5
- package/dist/cjs/api/resources/account/exports.d.ts +2 -2
- package/dist/cjs/api/resources/account/index.d.ts +2 -2
- package/dist/cjs/api/resources/account/types/GetAccountResponse.d.ts +3 -3
- package/dist/cjs/api/resources/account/types/IndexAccountResponse.js +2 -2
- package/dist/cjs/api/resources/account/types/IndexStatusAccountResponse.js +2 -2
- package/dist/cjs/api/resources/account/types/InsightsAccountRequestType.js +4 -4
- package/dist/cjs/api/resources/account/types/InsightsAccountResponse.d.ts +2 -2
- package/dist/cjs/api/resources/account/types/LandingPagesAccountRequestShowInactive.js +2 -2
- package/dist/cjs/api/resources/account/types/index.d.ts +7 -7
- package/dist/cjs/api/resources/index.d.ts +3 -3
- package/dist/cjs/api/types/Error_.js +11 -11
- package/dist/cjs/api/types/SearchBrandsResponse.js +1 -1
- package/dist/cjs/api/types/SearchCreatorsResponse.js +1 -1
- package/dist/cjs/api/types/SearchMediaResponse.js +26 -26
- package/dist/cjs/api/types/index.d.ts +7 -7
- package/dist/cjs/auth/BearerAuthProvider.d.ts +1 -1
- package/dist/cjs/auth/BearerAuthProvider.js +2 -2
- package/dist/cjs/auth/index.d.ts +1 -1
- package/dist/cjs/core/auth/AuthProvider.d.ts +2 -2
- package/dist/cjs/core/auth/AuthProvider.js +3 -3
- package/dist/cjs/core/auth/BasicAuth.js +7 -7
- package/dist/cjs/core/auth/BearerToken.js +1 -1
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +2 -2
- package/dist/cjs/core/auth/index.d.ts +5 -5
- package/dist/cjs/core/base64.js +4 -4
- package/dist/cjs/core/exports.d.ts +1 -1
- package/dist/cjs/core/fetcher/APIResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +4 -4
- package/dist/cjs/core/fetcher/BinaryResponse.js +1 -1
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
- package/dist/cjs/core/fetcher/EndpointSupplier.js +1 -1
- package/dist/cjs/core/fetcher/Fetcher.d.ts +11 -11
- package/dist/cjs/core/fetcher/Fetcher.js +56 -50
- package/dist/cjs/core/fetcher/Headers.js +10 -10
- package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +2 -2
- package/dist/cjs/core/fetcher/RawResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/RawResponse.js +6 -6
- package/dist/cjs/core/fetcher/Supplier.js +1 -1
- package/dist/cjs/core/fetcher/createRequestUrl.js +1 -1
- package/dist/cjs/core/fetcher/getErrorResponseBody.js +11 -11
- package/dist/cjs/core/fetcher/getRequestBody.d.ts +2 -2
- package/dist/cjs/core/fetcher/getRequestBody.js +4 -4
- package/dist/cjs/core/fetcher/getResponseBody.d.ts +2 -2
- package/dist/cjs/core/fetcher/getResponseBody.js +11 -11
- package/dist/cjs/core/fetcher/index.d.ts +13 -13
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +2 -2
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +7 -7
- package/dist/cjs/core/fetcher/makeRequest.js +3 -3
- package/dist/cjs/core/fetcher/redactUrl.js +36 -36
- package/dist/cjs/core/fetcher/requestWithRetries.js +4 -4
- package/dist/cjs/core/fetcher/signals.js +2 -2
- package/dist/cjs/core/index.d.ts +6 -6
- package/dist/cjs/core/logging/exports.d.ts +1 -1
- package/dist/cjs/core/logging/index.d.ts +1 -1
- package/dist/cjs/core/logging/logger.js +4 -4
- package/dist/cjs/core/requestBody.js +1 -1
- package/dist/cjs/core/runtime/index.d.ts +1 -1
- package/dist/cjs/core/runtime/runtime.d.ts +1 -1
- package/dist/cjs/core/runtime/runtime.js +37 -35
- package/dist/cjs/core/url/QueryStringBuilder.d.ts +1 -1
- package/dist/cjs/core/url/QueryStringBuilder.js +3 -3
- package/dist/cjs/core/url/encodePathParam.js +10 -8
- package/dist/cjs/core/url/index.d.ts +4 -4
- package/dist/cjs/core/url/join.js +11 -11
- package/dist/cjs/core/url/qs.d.ts +1 -1
- package/dist/cjs/core/url/qs.js +14 -14
- package/dist/cjs/environments.js +1 -1
- package/dist/cjs/errors/SpyglassError.d.ts +1 -1
- package/dist/cjs/errors/SpyglassError.js +3 -3
- package/dist/cjs/errors/SpyglassTimeoutError.d.ts +1 -1
- package/dist/cjs/errors/SpyglassTimeoutError.js +1 -1
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +1 -1
- package/dist/cjs/errors/handleNonStatusCodeError.js +5 -5
- package/dist/cjs/errors/index.d.ts +2 -2
- package/dist/cjs/exports.d.ts +1 -1
- package/dist/cjs/index.d.ts +6 -6
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +4 -4
- package/dist/esm/BaseClient.mjs +10 -10
- package/dist/esm/Client.d.mts +7 -7
- package/dist/esm/Client.mjs +67 -49
- package/dist/esm/api/client/index.d.mts +1 -1
- package/dist/esm/api/client/index.mjs +1 -1
- package/dist/esm/api/client/requests/SearchBrandsRequest.mjs +6 -6
- package/dist/esm/api/client/requests/SearchCreatorsRequest.mjs +174 -174
- package/dist/esm/api/client/requests/SearchMediaRequest.d.mts +2 -2
- package/dist/esm/api/client/requests/SearchMediaRequest.mjs +223 -223
- package/dist/esm/api/client/requests/index.d.mts +5 -5
- package/dist/esm/api/client/requests/index.mjs +3 -3
- package/dist/esm/api/errors/BadRequestError.d.mts +3 -3
- package/dist/esm/api/errors/BadRequestError.mjs +3 -3
- package/dist/esm/api/errors/ContentTooLargeError.d.mts +3 -3
- package/dist/esm/api/errors/ContentTooLargeError.mjs +3 -3
- package/dist/esm/api/errors/ForbiddenError.d.mts +3 -3
- package/dist/esm/api/errors/ForbiddenError.mjs +3 -3
- package/dist/esm/api/errors/InternalServerError.d.mts +3 -3
- package/dist/esm/api/errors/InternalServerError.mjs +3 -3
- package/dist/esm/api/errors/MethodNotAllowedError.d.mts +3 -3
- package/dist/esm/api/errors/MethodNotAllowedError.mjs +3 -3
- package/dist/esm/api/errors/NotFoundError.d.mts +3 -3
- package/dist/esm/api/errors/NotFoundError.mjs +3 -3
- package/dist/esm/api/errors/PaymentRequiredError.d.mts +3 -3
- package/dist/esm/api/errors/PaymentRequiredError.mjs +3 -3
- package/dist/esm/api/errors/TooManyRequestsError.d.mts +3 -3
- package/dist/esm/api/errors/TooManyRequestsError.mjs +3 -3
- package/dist/esm/api/errors/UnauthorizedError.d.mts +3 -3
- package/dist/esm/api/errors/UnauthorizedError.mjs +3 -3
- package/dist/esm/api/errors/index.d.mts +9 -9
- package/dist/esm/api/errors/index.mjs +9 -9
- package/dist/esm/api/index.d.mts +4 -4
- package/dist/esm/api/index.mjs +4 -4
- package/dist/esm/api/resources/account/client/Client.d.mts +4 -4
- package/dist/esm/api/resources/account/client/Client.mjs +46 -31
- package/dist/esm/api/resources/account/client/index.d.mts +1 -1
- package/dist/esm/api/resources/account/client/index.mjs +1 -1
- package/dist/esm/api/resources/account/client/requests/InsightsAccountRequest.d.mts +1 -1
- package/dist/esm/api/resources/account/client/requests/LandingPagesAccountRequest.d.mts +1 -1
- package/dist/esm/api/resources/account/client/requests/index.d.mts +5 -5
- package/dist/esm/api/resources/account/exports.d.mts +2 -2
- package/dist/esm/api/resources/account/exports.mjs +2 -2
- package/dist/esm/api/resources/account/index.d.mts +2 -2
- package/dist/esm/api/resources/account/index.mjs +2 -2
- package/dist/esm/api/resources/account/types/GetAccountResponse.d.mts +3 -3
- package/dist/esm/api/resources/account/types/IndexAccountResponse.mjs +2 -2
- package/dist/esm/api/resources/account/types/IndexStatusAccountResponse.mjs +2 -2
- package/dist/esm/api/resources/account/types/InsightsAccountRequestType.mjs +4 -4
- package/dist/esm/api/resources/account/types/InsightsAccountResponse.d.mts +2 -2
- package/dist/esm/api/resources/account/types/LandingPagesAccountRequestShowInactive.mjs +2 -2
- package/dist/esm/api/resources/account/types/index.d.mts +7 -7
- package/dist/esm/api/resources/account/types/index.mjs +7 -7
- package/dist/esm/api/resources/index.d.mts +3 -3
- package/dist/esm/api/resources/index.mjs +3 -3
- package/dist/esm/api/types/Error_.mjs +11 -11
- package/dist/esm/api/types/SearchBrandsResponse.mjs +1 -1
- package/dist/esm/api/types/SearchCreatorsResponse.mjs +1 -1
- package/dist/esm/api/types/SearchMediaResponse.mjs +26 -26
- package/dist/esm/api/types/index.d.mts +7 -7
- package/dist/esm/api/types/index.mjs +7 -7
- package/dist/esm/auth/BearerAuthProvider.d.mts +1 -1
- package/dist/esm/auth/BearerAuthProvider.mjs +4 -4
- package/dist/esm/auth/index.d.mts +1 -1
- package/dist/esm/auth/index.mjs +1 -1
- package/dist/esm/core/auth/AuthProvider.d.mts +2 -2
- package/dist/esm/core/auth/AuthProvider.mjs +3 -3
- package/dist/esm/core/auth/BasicAuth.mjs +8 -8
- package/dist/esm/core/auth/BearerToken.mjs +1 -1
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +2 -2
- package/dist/esm/core/auth/index.d.mts +5 -5
- package/dist/esm/core/auth/index.mjs +4 -4
- package/dist/esm/core/base64.mjs +4 -4
- package/dist/esm/core/exports.d.mts +1 -1
- package/dist/esm/core/exports.mjs +1 -1
- package/dist/esm/core/fetcher/APIResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +4 -4
- package/dist/esm/core/fetcher/BinaryResponse.mjs +1 -1
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
- package/dist/esm/core/fetcher/EndpointSupplier.mjs +1 -1
- package/dist/esm/core/fetcher/Fetcher.d.mts +11 -11
- package/dist/esm/core/fetcher/Fetcher.mjs +70 -64
- package/dist/esm/core/fetcher/Headers.mjs +10 -10
- package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +2 -2
- package/dist/esm/core/fetcher/RawResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/RawResponse.mjs +7 -7
- package/dist/esm/core/fetcher/Supplier.mjs +1 -1
- package/dist/esm/core/fetcher/createRequestUrl.mjs +2 -2
- package/dist/esm/core/fetcher/getErrorResponseBody.mjs +13 -13
- package/dist/esm/core/fetcher/getRequestBody.d.mts +2 -2
- package/dist/esm/core/fetcher/getRequestBody.mjs +6 -6
- package/dist/esm/core/fetcher/getResponseBody.d.mts +2 -2
- package/dist/esm/core/fetcher/getResponseBody.mjs +13 -13
- package/dist/esm/core/fetcher/index.d.mts +13 -13
- package/dist/esm/core/fetcher/index.mjs +7 -7
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +2 -2
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +16 -16
- package/dist/esm/core/fetcher/makeRequest.mjs +4 -4
- package/dist/esm/core/fetcher/redactUrl.mjs +36 -36
- package/dist/esm/core/fetcher/requestWithRetries.mjs +4 -4
- package/dist/esm/core/fetcher/signals.mjs +2 -2
- package/dist/esm/core/index.d.mts +6 -6
- package/dist/esm/core/index.mjs +6 -6
- package/dist/esm/core/logging/exports.d.mts +1 -1
- package/dist/esm/core/logging/exports.mjs +1 -1
- package/dist/esm/core/logging/index.d.mts +1 -1
- package/dist/esm/core/logging/index.mjs +1 -1
- package/dist/esm/core/logging/logger.mjs +4 -4
- package/dist/esm/core/requestBody.mjs +1 -1
- package/dist/esm/core/runtime/index.d.mts +1 -1
- package/dist/esm/core/runtime/index.mjs +1 -1
- package/dist/esm/core/runtime/runtime.d.mts +1 -1
- package/dist/esm/core/runtime/runtime.mjs +37 -35
- package/dist/esm/core/url/QueryStringBuilder.d.mts +1 -1
- package/dist/esm/core/url/QueryStringBuilder.mjs +4 -4
- package/dist/esm/core/url/encodePathParam.mjs +10 -8
- package/dist/esm/core/url/index.d.mts +4 -4
- package/dist/esm/core/url/index.mjs +4 -4
- package/dist/esm/core/url/join.mjs +11 -11
- package/dist/esm/core/url/qs.d.mts +1 -1
- package/dist/esm/core/url/qs.mjs +14 -14
- package/dist/esm/environments.mjs +1 -1
- package/dist/esm/errors/SpyglassError.d.mts +1 -1
- package/dist/esm/errors/SpyglassError.mjs +4 -4
- package/dist/esm/errors/SpyglassTimeoutError.d.mts +1 -1
- package/dist/esm/errors/SpyglassTimeoutError.mjs +2 -2
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +1 -1
- package/dist/esm/errors/handleNonStatusCodeError.mjs +6 -6
- package/dist/esm/errors/index.d.mts +2 -2
- package/dist/esm/errors/index.mjs +2 -2
- package/dist/esm/exports.d.mts +1 -1
- package/dist/esm/exports.mjs +1 -1
- package/dist/esm/index.d.mts +6 -6
- package/dist/esm/index.mjs +5 -5
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +91 -91
- package/reference.md +85 -84
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Headers = void 0;
|
|
4
4
|
let Headers;
|
|
5
|
-
if (typeof globalThis.Headers !==
|
|
5
|
+
if (typeof globalThis.Headers !== 'undefined') {
|
|
6
6
|
exports.Headers = Headers = globalThis.Headers;
|
|
7
7
|
}
|
|
8
8
|
else {
|
|
@@ -15,21 +15,21 @@ else {
|
|
|
15
15
|
}
|
|
16
16
|
else if (Array.isArray(init)) {
|
|
17
17
|
for (const [key, value] of init) {
|
|
18
|
-
if (typeof key ===
|
|
18
|
+
if (typeof key === 'string' && typeof value === 'string') {
|
|
19
19
|
this.append(key, value);
|
|
20
20
|
}
|
|
21
21
|
else {
|
|
22
|
-
throw new TypeError(
|
|
22
|
+
throw new TypeError('Each header entry must be a [string, string] tuple');
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
for (const [key, value] of Object.entries(init)) {
|
|
28
|
-
if (typeof value ===
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
29
|
this.append(key, value);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
throw new TypeError(
|
|
32
|
+
throw new TypeError('Header values must be strings');
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -47,7 +47,7 @@ else {
|
|
|
47
47
|
get(name) {
|
|
48
48
|
const key = name.toLowerCase();
|
|
49
49
|
const values = this.headers.get(key);
|
|
50
|
-
return values ? values.join(
|
|
50
|
+
return values ? values.join(', ') : null;
|
|
51
51
|
}
|
|
52
52
|
has(name) {
|
|
53
53
|
const key = name.toLowerCase();
|
|
@@ -59,14 +59,14 @@ else {
|
|
|
59
59
|
}
|
|
60
60
|
forEach(callbackfn, thisArg) {
|
|
61
61
|
const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
|
|
62
|
-
this.headers.forEach((values, key) => boundCallback(values.join(
|
|
62
|
+
this.headers.forEach((values, key) => boundCallback(values.join(', '), key, this));
|
|
63
63
|
}
|
|
64
64
|
getSetCookie() {
|
|
65
|
-
return this.headers.get(
|
|
65
|
+
return this.headers.get('set-cookie') || [];
|
|
66
66
|
}
|
|
67
67
|
*entries() {
|
|
68
68
|
for (const [key, values] of this.headers.entries()) {
|
|
69
|
-
yield [key, values.join(
|
|
69
|
+
yield [key, values.join(', ')];
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
*keys() {
|
|
@@ -74,7 +74,7 @@ else {
|
|
|
74
74
|
}
|
|
75
75
|
*values() {
|
|
76
76
|
for (const values of this.headers.values()) {
|
|
77
|
-
yield values.join(
|
|
77
|
+
yield values.join(', ');
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
[Symbol.iterator]() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WithRawResponse } from
|
|
1
|
+
import type { WithRawResponse } from './RawResponse.js';
|
|
2
2
|
/**
|
|
3
3
|
* A promise that returns the parsed response and lets you retrieve the raw response too.
|
|
4
4
|
*/
|
|
@@ -20,7 +20,7 @@ export declare class HttpResponsePromise<T> extends Promise<T> {
|
|
|
20
20
|
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
21
21
|
* @returns A function that returns an `HttpResponsePromise` instance.
|
|
22
22
|
*/
|
|
23
|
-
static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>[
|
|
23
|
+
static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>['data']>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
|
|
24
24
|
/**
|
|
25
25
|
* Creates an `HttpResponsePromise` from an existing promise.
|
|
26
26
|
*
|
|
@@ -10,9 +10,9 @@ exports.abortRawResponse = {
|
|
|
10
10
|
headers: new Headers_js_1.Headers(),
|
|
11
11
|
redirected: false,
|
|
12
12
|
status: 499,
|
|
13
|
-
statusText:
|
|
14
|
-
type:
|
|
15
|
-
url:
|
|
13
|
+
statusText: 'Client Closed Request',
|
|
14
|
+
type: 'error',
|
|
15
|
+
url: '',
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* A raw response indicating an unknown error.
|
|
@@ -21,9 +21,9 @@ exports.unknownRawResponse = {
|
|
|
21
21
|
headers: new Headers_js_1.Headers(),
|
|
22
22
|
redirected: false,
|
|
23
23
|
status: 0,
|
|
24
|
-
statusText:
|
|
25
|
-
type:
|
|
26
|
-
url:
|
|
24
|
+
statusText: 'Unknown Error',
|
|
25
|
+
type: 'error',
|
|
26
|
+
url: '',
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
29
|
* Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.Supplier = void 0;
|
|
13
13
|
exports.Supplier = {
|
|
14
14
|
get: (supplier) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
-
if (typeof supplier ===
|
|
15
|
+
if (typeof supplier === 'function') {
|
|
16
16
|
return supplier();
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createRequestUrl = createRequestUrl;
|
|
4
4
|
const qs_js_1 = require("../url/qs.js");
|
|
5
5
|
function createRequestUrl(baseUrl, queryParameters) {
|
|
6
|
-
const queryString = (0, qs_js_1.toQueryString)(queryParameters, { arrayFormat:
|
|
6
|
+
const queryString = (0, qs_js_1.toQueryString)(queryParameters, { arrayFormat: 'repeat' });
|
|
7
7
|
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
8
8
|
}
|
|
@@ -27,27 +27,27 @@ function parseJsonErrorBody(text) {
|
|
|
27
27
|
function getErrorResponseBody(response) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
29
|
var _a, _b, _c;
|
|
30
|
-
let contentType = (_a = response.headers.get(
|
|
30
|
+
let contentType = (_a = response.headers.get('Content-Type')) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
31
31
|
if (contentType == null || contentType.length === 0) {
|
|
32
32
|
const body = yield (0, getResponseBody_js_1.getResponseBody)(response);
|
|
33
33
|
if ((0, getResponseBody_js_1.isResponseBodyError)(body)) {
|
|
34
|
-
return body.error.reason ===
|
|
34
|
+
return body.error.reason === 'non-json' ? body.error.rawBody : undefined;
|
|
35
35
|
}
|
|
36
36
|
return body;
|
|
37
37
|
}
|
|
38
|
-
if (contentType.indexOf(
|
|
39
|
-
contentType = (_c = (_b = contentType.split(
|
|
38
|
+
if (contentType.indexOf(';') !== -1) {
|
|
39
|
+
contentType = (_c = (_b = contentType.split(';')[0]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
40
40
|
}
|
|
41
41
|
switch (contentType) {
|
|
42
|
-
case
|
|
43
|
-
case
|
|
44
|
-
case
|
|
45
|
-
case
|
|
46
|
-
case
|
|
47
|
-
case
|
|
42
|
+
case 'application/hal+json':
|
|
43
|
+
case 'application/json':
|
|
44
|
+
case 'application/ld+json':
|
|
45
|
+
case 'application/problem+json':
|
|
46
|
+
case 'application/vnd.api+json':
|
|
47
|
+
case 'text/json':
|
|
48
48
|
return parseJsonErrorBody(yield response.text());
|
|
49
49
|
default:
|
|
50
|
-
if (contentType.startsWith(
|
|
50
|
+
if (contentType.startsWith('application/vnd.') && contentType.endsWith('+json')) {
|
|
51
51
|
return parseJsonErrorBody(yield response.text());
|
|
52
52
|
}
|
|
53
53
|
// Fallback to plain text if content type is not recognized
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare namespace GetRequestBody {
|
|
2
2
|
interface Args {
|
|
3
3
|
body: unknown;
|
|
4
|
-
type:
|
|
4
|
+
type: 'json' | 'file' | 'bytes' | 'form' | 'other';
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
export declare function getRequestBody({ body, type }: GetRequestBody.Args): Promise<BodyInit | undefined>;
|
|
7
|
+
export declare function getRequestBody({ body, type, }: GetRequestBody.Args): Promise<BodyInit | undefined>;
|
|
@@ -13,11 +13,11 @@ exports.getRequestBody = getRequestBody;
|
|
|
13
13
|
const json_js_1 = require("../json.js");
|
|
14
14
|
const qs_js_1 = require("../url/qs.js");
|
|
15
15
|
function getRequestBody(_a) {
|
|
16
|
-
return __awaiter(this, arguments, void 0, function* ({ body, type }) {
|
|
17
|
-
if (type ===
|
|
18
|
-
return (0, qs_js_1.toQueryString)(body, { arrayFormat:
|
|
16
|
+
return __awaiter(this, arguments, void 0, function* ({ body, type, }) {
|
|
17
|
+
if (type === 'form') {
|
|
18
|
+
return (0, qs_js_1.toQueryString)(body, { arrayFormat: 'repeat', encode: true });
|
|
19
19
|
}
|
|
20
|
-
if (type.includes(
|
|
20
|
+
if (type.includes('json')) {
|
|
21
21
|
return (0, json_js_1.toJson)(body);
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
@@ -15,7 +15,7 @@ const json_js_1 = require("../json.js");
|
|
|
15
15
|
const BinaryResponse_js_1 = require("./BinaryResponse.js");
|
|
16
16
|
// Pins the upstream Response so undici's FinalizationRegistry can't GC it and cancel the body stream.
|
|
17
17
|
function retainResponse(target, response) {
|
|
18
|
-
Object.defineProperty(target,
|
|
18
|
+
Object.defineProperty(target, '__fern_response_ref', {
|
|
19
19
|
value: response,
|
|
20
20
|
enumerable: false,
|
|
21
21
|
configurable: true,
|
|
@@ -33,36 +33,36 @@ function responseBodyError(error) {
|
|
|
33
33
|
* as opposed to a parsed JSON body that happens to have the same shape.
|
|
34
34
|
*/
|
|
35
35
|
function isResponseBodyError(value) {
|
|
36
|
-
return typeof value ===
|
|
36
|
+
return typeof value === 'object' && value != null && responseBodyErrors.has(value);
|
|
37
37
|
}
|
|
38
38
|
function getResponseBody(response, responseType) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
switch (responseType) {
|
|
41
|
-
case
|
|
41
|
+
case 'binary-response':
|
|
42
42
|
return (0, BinaryResponse_js_1.getBinaryResponse)(response);
|
|
43
|
-
case
|
|
43
|
+
case 'blob':
|
|
44
44
|
return yield response.blob();
|
|
45
|
-
case
|
|
45
|
+
case 'arrayBuffer':
|
|
46
46
|
return yield response.arrayBuffer();
|
|
47
|
-
case
|
|
47
|
+
case 'sse':
|
|
48
48
|
if (response.body == null) {
|
|
49
49
|
return responseBodyError({
|
|
50
|
-
reason:
|
|
50
|
+
reason: 'body-is-null',
|
|
51
51
|
statusCode: response.status,
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
retainResponse(response.body, response);
|
|
55
55
|
return response.body;
|
|
56
|
-
case
|
|
56
|
+
case 'streaming':
|
|
57
57
|
if (response.body == null) {
|
|
58
58
|
return responseBodyError({
|
|
59
|
-
reason:
|
|
59
|
+
reason: 'body-is-null',
|
|
60
60
|
statusCode: response.status,
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
retainResponse(response.body, response);
|
|
64
64
|
return response.body;
|
|
65
|
-
case
|
|
65
|
+
case 'text':
|
|
66
66
|
return yield response.text();
|
|
67
67
|
}
|
|
68
68
|
// if responseType is "json" or not specified, try to parse as JSON
|
|
@@ -74,7 +74,7 @@ function getResponseBody(response, responseType) {
|
|
|
74
74
|
}
|
|
75
75
|
catch (_err) {
|
|
76
76
|
return responseBodyError({
|
|
77
|
-
reason:
|
|
77
|
+
reason: 'non-json',
|
|
78
78
|
statusCode: response.status,
|
|
79
79
|
rawBody: text,
|
|
80
80
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type { APIResponse } from
|
|
2
|
-
export type { BinaryResponse } from
|
|
3
|
-
export type { EndpointMetadata } from
|
|
4
|
-
export { EndpointSupplier } from
|
|
5
|
-
export type { Fetcher, FetchFunction } from
|
|
6
|
-
export { fetcher } from
|
|
7
|
-
export { getHeader } from
|
|
8
|
-
export { HttpResponsePromise } from
|
|
9
|
-
export type { PassthroughRequest } from
|
|
10
|
-
export { makePassthroughRequest } from
|
|
11
|
-
export type { RawResponse, WithRawResponse } from
|
|
12
|
-
export { abortRawResponse, toRawResponse, unknownRawResponse } from
|
|
13
|
-
export { Supplier } from
|
|
1
|
+
export type { APIResponse } from './APIResponse.js';
|
|
2
|
+
export type { BinaryResponse } from './BinaryResponse.js';
|
|
3
|
+
export type { EndpointMetadata } from './EndpointMetadata.js';
|
|
4
|
+
export { EndpointSupplier } from './EndpointSupplier.js';
|
|
5
|
+
export type { Fetcher, FetchFunction } from './Fetcher.js';
|
|
6
|
+
export { fetcher } from './Fetcher.js';
|
|
7
|
+
export { getHeader } from './getHeader.js';
|
|
8
|
+
export { HttpResponsePromise } from './HttpResponsePromise.js';
|
|
9
|
+
export type { PassthroughRequest } from './makePassthroughRequest.js';
|
|
10
|
+
export { makePassthroughRequest } from './makePassthroughRequest.js';
|
|
11
|
+
export type { RawResponse, WithRawResponse } from './RawResponse.js';
|
|
12
|
+
export { abortRawResponse, toRawResponse, unknownRawResponse } from './RawResponse.js';
|
|
13
|
+
export { Supplier } from './Supplier.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type LogConfig, type Logger } from
|
|
2
|
-
import { Supplier } from
|
|
1
|
+
import { type LogConfig, type Logger } from '../logging/logger.js';
|
|
2
|
+
import { Supplier } from './Supplier.js';
|
|
3
3
|
export declare namespace PassthroughRequest {
|
|
4
4
|
/**
|
|
5
5
|
* Per-request options that can override the SDK client defaults.
|
|
@@ -61,7 +61,7 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
61
61
|
const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier_js_1.Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier_js_1.Supplier.get(clientOptions.environment) : undefined);
|
|
62
62
|
// Determine the full URL
|
|
63
63
|
let fullUrl;
|
|
64
|
-
if (url.startsWith(
|
|
64
|
+
if (url.startsWith('http://') || url.startsWith('https://')) {
|
|
65
65
|
fullUrl = url;
|
|
66
66
|
}
|
|
67
67
|
else if (baseUrl != null) {
|
|
@@ -109,7 +109,7 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
109
109
|
mergedHeaders[key.toLowerCase()] = value;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b :
|
|
112
|
+
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : 'GET';
|
|
113
113
|
const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
|
|
114
114
|
const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
|
|
115
115
|
const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
|
|
@@ -117,7 +117,7 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
117
117
|
const abortSignal = (_f = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal) !== null && _e !== void 0 ? _e : effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.signal) !== null && _f !== void 0 ? _f : undefined;
|
|
118
118
|
const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield (0, getFetchFn_js_1.getFetchFn)());
|
|
119
119
|
if (logger.isDebug()) {
|
|
120
|
-
logger.debug(
|
|
120
|
+
logger.debug('Making passthrough HTTP request', {
|
|
121
121
|
method,
|
|
122
122
|
url: (0, redactUrl_js_1.redactUrl)(fullUrl),
|
|
123
123
|
hasBody: body != null,
|
|
@@ -126,7 +126,7 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
126
126
|
let response;
|
|
127
127
|
try {
|
|
128
128
|
response = yield (0, requestWithRetries_js_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
return (0, makeRequest_js_1.makeRequest)(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) ===
|
|
129
|
+
return (0, makeRequest_js_1.makeRequest)(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) === 'include', undefined, // duplex
|
|
130
130
|
false);
|
|
131
131
|
}), maxRetries, abortSignal);
|
|
132
132
|
}
|
|
@@ -138,7 +138,7 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
138
138
|
throw error;
|
|
139
139
|
}
|
|
140
140
|
if (logger.isDebug()) {
|
|
141
|
-
logger.debug(
|
|
141
|
+
logger.debug('Passthrough HTTP request completed', {
|
|
142
142
|
method,
|
|
143
143
|
url: (0, redactUrl_js_1.redactUrl)(fullUrl),
|
|
144
144
|
statusCode: response.status,
|
|
@@ -148,8 +148,8 @@ function makePassthroughRequest(input, init, clientOptions, requestOptions) {
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
function createTimeoutError() {
|
|
151
|
-
const error = new Error(
|
|
152
|
-
error.name =
|
|
151
|
+
const error = new Error('The request timed out.');
|
|
152
|
+
error.name = 'TimeoutError';
|
|
153
153
|
return error;
|
|
154
154
|
}
|
|
155
155
|
/**
|
|
@@ -25,7 +25,7 @@ function isCacheNoStoreSupported() {
|
|
|
25
25
|
return _cacheNoStoreSupported;
|
|
26
26
|
}
|
|
27
27
|
try {
|
|
28
|
-
new Request(
|
|
28
|
+
new Request('http://localhost', { cache: 'no-store' });
|
|
29
29
|
_cacheNoStoreSupported = true;
|
|
30
30
|
}
|
|
31
31
|
catch (_a) {
|
|
@@ -67,9 +67,9 @@ const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abor
|
|
|
67
67
|
const newSignals = (0, signals_js_1.anySignal)(signals);
|
|
68
68
|
let response;
|
|
69
69
|
try {
|
|
70
|
-
response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ?
|
|
70
|
+
response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ? 'include' : undefined,
|
|
71
71
|
// @ts-ignore
|
|
72
|
-
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache:
|
|
72
|
+
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache: 'no-store' } : {})));
|
|
73
73
|
}
|
|
74
74
|
catch (error) {
|
|
75
75
|
if (timeoutAbortId != null) {
|
|
@@ -3,39 +3,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SENSITIVE_QUERY_PARAMS = void 0;
|
|
4
4
|
exports.redactUrl = redactUrl;
|
|
5
5
|
exports.SENSITIVE_QUERY_PARAMS = new Set([
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
6
|
+
'api_key',
|
|
7
|
+
'api-key',
|
|
8
|
+
'apikey',
|
|
9
|
+
'token',
|
|
10
|
+
'access_token',
|
|
11
|
+
'access-token',
|
|
12
|
+
'auth_token',
|
|
13
|
+
'auth-token',
|
|
14
|
+
'password',
|
|
15
|
+
'passwd',
|
|
16
|
+
'secret',
|
|
17
|
+
'api_secret',
|
|
18
|
+
'api-secret',
|
|
19
|
+
'apisecret',
|
|
20
|
+
'key',
|
|
21
|
+
'session',
|
|
22
|
+
'session_id',
|
|
23
|
+
'session-id',
|
|
24
24
|
]);
|
|
25
25
|
function redactUrl(url) {
|
|
26
|
-
const protocolIndex = url.indexOf(
|
|
26
|
+
const protocolIndex = url.indexOf('://');
|
|
27
27
|
if (protocolIndex === -1)
|
|
28
28
|
return url;
|
|
29
29
|
const afterProtocol = protocolIndex + 3;
|
|
30
30
|
// Find the first delimiter that marks the end of the authority section
|
|
31
|
-
const pathStart = url.indexOf(
|
|
32
|
-
let queryStart = url.indexOf(
|
|
33
|
-
let fragmentStart = url.indexOf(
|
|
31
|
+
const pathStart = url.indexOf('/', afterProtocol);
|
|
32
|
+
let queryStart = url.indexOf('?', afterProtocol);
|
|
33
|
+
let fragmentStart = url.indexOf('#', afterProtocol);
|
|
34
34
|
const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
|
|
35
35
|
// Find the LAST @ before the delimiter (handles multiple @ in credentials)
|
|
36
36
|
let atIndex = -1;
|
|
37
37
|
for (let i = afterProtocol; i < firstDelimiter; i++) {
|
|
38
|
-
if (url[i] ===
|
|
38
|
+
if (url[i] === '@') {
|
|
39
39
|
atIndex = i;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -43,10 +43,10 @@ function redactUrl(url) {
|
|
|
43
43
|
url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
|
|
44
44
|
}
|
|
45
45
|
// Recalculate queryStart since url might have changed
|
|
46
|
-
queryStart = url.indexOf(
|
|
46
|
+
queryStart = url.indexOf('?');
|
|
47
47
|
if (queryStart === -1)
|
|
48
48
|
return url;
|
|
49
|
-
fragmentStart = url.indexOf(
|
|
49
|
+
fragmentStart = url.indexOf('#', queryStart);
|
|
50
50
|
const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
|
|
51
51
|
const queryString = url.slice(queryStart + 1, queryEnd);
|
|
52
52
|
if (queryString.length === 0)
|
|
@@ -54,28 +54,28 @@ function redactUrl(url) {
|
|
|
54
54
|
// FAST PATH: Quick check if any sensitive keywords present
|
|
55
55
|
// Using indexOf is faster than regex for simple substring matching
|
|
56
56
|
const lower = queryString.toLowerCase();
|
|
57
|
-
const hasSensitive = lower.includes(
|
|
58
|
-
lower.includes(
|
|
59
|
-
lower.includes(
|
|
60
|
-
lower.includes(
|
|
61
|
-
lower.includes(
|
|
62
|
-
lower.includes(
|
|
63
|
-
lower.includes(
|
|
57
|
+
const hasSensitive = lower.includes('token') ||
|
|
58
|
+
lower.includes('key') ||
|
|
59
|
+
lower.includes('password') ||
|
|
60
|
+
lower.includes('passwd') ||
|
|
61
|
+
lower.includes('secret') ||
|
|
62
|
+
lower.includes('session') ||
|
|
63
|
+
lower.includes('auth');
|
|
64
64
|
if (!hasSensitive) {
|
|
65
65
|
return url;
|
|
66
66
|
}
|
|
67
67
|
// SLOW PATH: Parse and redact
|
|
68
68
|
const redactedParams = [];
|
|
69
|
-
const params = queryString.split(
|
|
69
|
+
const params = queryString.split('&');
|
|
70
70
|
for (const param of params) {
|
|
71
|
-
const equalIndex = param.indexOf(
|
|
71
|
+
const equalIndex = param.indexOf('=');
|
|
72
72
|
if (equalIndex === -1) {
|
|
73
73
|
redactedParams.push(param);
|
|
74
74
|
continue;
|
|
75
75
|
}
|
|
76
76
|
const key = param.slice(0, equalIndex);
|
|
77
77
|
let shouldRedact = exports.SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
|
|
78
|
-
if (!shouldRedact && key.includes(
|
|
78
|
+
if (!shouldRedact && key.includes('%')) {
|
|
79
79
|
try {
|
|
80
80
|
const decodedKey = decodeURIComponent(key);
|
|
81
81
|
shouldRedact = exports.SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
|
|
@@ -84,5 +84,5 @@ function redactUrl(url) {
|
|
|
84
84
|
}
|
|
85
85
|
redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
|
|
86
86
|
}
|
|
87
|
-
return url.slice(0, queryStart + 1) + redactedParams.join(
|
|
87
|
+
return url.slice(0, queryStart + 1) + redactedParams.join('&') + url.slice(queryEnd);
|
|
88
88
|
}
|
|
@@ -26,7 +26,7 @@ function addSymmetricJitter(delay) {
|
|
|
26
26
|
return delay * jitterMultiplier;
|
|
27
27
|
}
|
|
28
28
|
function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
29
|
-
const retryAfter = response.headers.get(
|
|
29
|
+
const retryAfter = response.headers.get('Retry-After');
|
|
30
30
|
if (retryAfter) {
|
|
31
31
|
const retryAfterSeconds = parseInt(retryAfter, 10);
|
|
32
32
|
if (!Number.isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
|
|
@@ -40,7 +40,7 @@ function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
const rateLimitReset = response.headers.get(
|
|
43
|
+
const rateLimitReset = response.headers.get('X-RateLimit-Reset');
|
|
44
44
|
if (rateLimitReset) {
|
|
45
45
|
const resetTime = parseInt(rateLimitReset, 10);
|
|
46
46
|
if (!Number.isNaN(resetTime)) {
|
|
@@ -67,10 +67,10 @@ function sleep(ms, abortSignal) {
|
|
|
67
67
|
reject(abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.reason);
|
|
68
68
|
};
|
|
69
69
|
const timeoutId = setTimeout(() => {
|
|
70
|
-
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener(
|
|
70
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', onAbort);
|
|
71
71
|
resolve();
|
|
72
72
|
}, ms);
|
|
73
|
-
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener(
|
|
73
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
function requestWithRetries(requestFn_1) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TIMEOUT = void 0;
|
|
4
4
|
exports.getTimeoutSignal = getTimeoutSignal;
|
|
5
5
|
exports.anySignal = anySignal;
|
|
6
|
-
exports.TIMEOUT =
|
|
6
|
+
exports.TIMEOUT = 'timeout';
|
|
7
7
|
function getTimeoutSignal(timeoutMs) {
|
|
8
8
|
const controller = new AbortController();
|
|
9
9
|
const abortId = setTimeout(() => controller.abort(exports.TIMEOUT), timeoutMs);
|
|
@@ -17,7 +17,7 @@ function anySignal(...args) {
|
|
|
17
17
|
controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
|
|
18
18
|
return controller.signal;
|
|
19
19
|
}
|
|
20
|
-
signal.addEventListener(
|
|
20
|
+
signal.addEventListener('abort', () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
|
|
21
21
|
signal: controller.signal,
|
|
22
22
|
});
|
|
23
23
|
// Re-check after adding listener: the signal may have aborted
|
package/dist/cjs/core/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * as logging from
|
|
5
|
-
export * from
|
|
6
|
-
export * as url from
|
|
1
|
+
export * from './auth/index.js';
|
|
2
|
+
export * from './base64.js';
|
|
3
|
+
export * from './fetcher/index.js';
|
|
4
|
+
export * as logging from './logging/index.js';
|
|
5
|
+
export * from './runtime/index.js';
|
|
6
|
+
export * as url from './url/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from './logger.js';
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Logger = exports.ConsoleLogger = exports.LogLevel = void 0;
|
|
4
4
|
exports.createLogger = createLogger;
|
|
5
5
|
exports.LogLevel = {
|
|
6
|
-
Debug:
|
|
7
|
-
Info:
|
|
8
|
-
Warn:
|
|
9
|
-
Error:
|
|
6
|
+
Debug: 'debug',
|
|
7
|
+
Info: 'info',
|
|
8
|
+
Warn: 'warn',
|
|
9
|
+
Error: 'error',
|
|
10
10
|
};
|
|
11
11
|
const logLevelMap = {
|
|
12
12
|
[exports.LogLevel.Debug]: 1,
|
|
@@ -19,7 +19,7 @@ function mergeAdditionalBodyParameters(body, additionalBodyParameters) {
|
|
|
19
19
|
if (body == null) {
|
|
20
20
|
return Object.assign({}, additionalBodyParameters);
|
|
21
21
|
}
|
|
22
|
-
if (typeof body ===
|
|
22
|
+
if (typeof body === 'object' && !Array.isArray(body)) {
|
|
23
23
|
return Object.assign(Object.assign({}, body), additionalBodyParameters);
|
|
24
24
|
}
|
|
25
25
|
return body;
|