@spyglasshq/sdk 0.1.9 → 0.1.11
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/README.md +30 -14
- package/dist/cjs/BaseClient.d.ts +4 -4
- package/dist/cjs/BaseClient.js +7 -7
- package/dist/cjs/Client.d.ts +13 -13
- package/dist/cjs/Client.js +46 -64
- package/dist/cjs/api/client/index.d.ts +1 -1
- package/dist/cjs/api/client/requests/SearchBrandsRequest.d.ts +4 -4
- package/dist/cjs/api/client/requests/SearchBrandsRequest.js +6 -6
- package/dist/cjs/api/client/requests/SearchCreatorsRequest.d.ts +4 -4
- package/dist/cjs/api/client/requests/SearchCreatorsRequest.js +174 -174
- package/dist/cjs/api/client/requests/SearchMediaRequest.d.ts +6 -2
- package/dist/cjs/api/client/requests/SearchMediaRequest.js +227 -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 +67 -7
- package/dist/cjs/api/resources/account/client/Client.js +208 -42
- package/dist/cjs/api/resources/account/client/index.d.ts +1 -1
- package/dist/cjs/api/resources/account/client/requests/CampaignsAccountRequest.d.ts +18 -0
- package/dist/cjs/api/resources/account/client/requests/CampaignsAccountRequest.js +3 -0
- package/dist/cjs/api/resources/account/client/requests/CollabsAccountRequest.d.ts +12 -0
- package/dist/cjs/api/resources/account/client/requests/CollabsAccountRequest.js +3 -0
- package/dist/cjs/api/resources/account/client/requests/InsightsAccountRequest.d.ts +1 -1
- package/dist/cjs/api/resources/account/client/requests/LandingPagesAccountRequest.d.ts +2 -1
- package/dist/cjs/api/resources/account/client/requests/index.d.ts +7 -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/CampaignsAccountRequestDatePreset.d.ts +17 -0
- package/dist/cjs/api/resources/account/types/CampaignsAccountRequestDatePreset.js +20 -0
- package/dist/cjs/api/resources/account/types/CampaignsAccountRequestSortBy.d.ts +5 -0
- package/dist/cjs/api/resources/account/types/CampaignsAccountRequestSortBy.js +8 -0
- package/dist/cjs/api/resources/account/types/CampaignsAccountRequestType.d.ts +5 -0
- package/dist/cjs/api/resources/account/types/CampaignsAccountRequestType.js +8 -0
- package/dist/cjs/api/resources/account/types/CampaignsAccountResponse.d.ts +20 -0
- package/dist/cjs/api/resources/account/types/CampaignsAccountResponse.js +3 -0
- package/dist/cjs/api/resources/account/types/CollabsAccountResponse.d.ts +14 -0
- package/dist/cjs/api/resources/account/types/CollabsAccountResponse.js +3 -0
- 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 -12
- package/dist/cjs/api/resources/account/types/LandingPagesAccountRequestShowInactive.js +2 -2
- package/dist/cjs/api/resources/account/types/index.d.ts +12 -7
- package/dist/cjs/api/resources/account/types/index.js +5 -0
- 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 +50 -56
- 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 +35 -37
- 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 +8 -10
- 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 +13 -13
- package/dist/esm/Client.mjs +55 -73
- 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.d.mts +4 -4
- package/dist/esm/api/client/requests/SearchBrandsRequest.mjs +6 -6
- package/dist/esm/api/client/requests/SearchCreatorsRequest.d.mts +4 -4
- package/dist/esm/api/client/requests/SearchCreatorsRequest.mjs +174 -174
- package/dist/esm/api/client/requests/SearchMediaRequest.d.mts +6 -2
- package/dist/esm/api/client/requests/SearchMediaRequest.mjs +227 -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 +67 -7
- package/dist/esm/api/resources/account/client/Client.mjs +216 -50
- 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/CampaignsAccountRequest.d.mts +18 -0
- package/dist/esm/api/resources/account/client/requests/CampaignsAccountRequest.mjs +2 -0
- package/dist/esm/api/resources/account/client/requests/CollabsAccountRequest.d.mts +12 -0
- package/dist/esm/api/resources/account/client/requests/CollabsAccountRequest.mjs +2 -0
- package/dist/esm/api/resources/account/client/requests/InsightsAccountRequest.d.mts +1 -1
- package/dist/esm/api/resources/account/client/requests/LandingPagesAccountRequest.d.mts +2 -1
- package/dist/esm/api/resources/account/client/requests/index.d.mts +7 -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/CampaignsAccountRequestDatePreset.d.mts +17 -0
- package/dist/esm/api/resources/account/types/CampaignsAccountRequestDatePreset.mjs +17 -0
- package/dist/esm/api/resources/account/types/CampaignsAccountRequestSortBy.d.mts +5 -0
- package/dist/esm/api/resources/account/types/CampaignsAccountRequestSortBy.mjs +5 -0
- package/dist/esm/api/resources/account/types/CampaignsAccountRequestType.d.mts +5 -0
- package/dist/esm/api/resources/account/types/CampaignsAccountRequestType.mjs +5 -0
- package/dist/esm/api/resources/account/types/CampaignsAccountResponse.d.mts +20 -0
- package/dist/esm/api/resources/account/types/CampaignsAccountResponse.mjs +2 -0
- package/dist/esm/api/resources/account/types/CollabsAccountResponse.d.mts +14 -0
- package/dist/esm/api/resources/account/types/CollabsAccountResponse.mjs +2 -0
- 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 -12
- package/dist/esm/api/resources/account/types/LandingPagesAccountRequestShowInactive.mjs +2 -2
- package/dist/esm/api/resources/account/types/index.d.mts +12 -7
- package/dist/esm/api/resources/account/types/index.mjs +12 -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 +64 -70
- 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 +35 -37
- 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 +8 -10
- 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 +232 -91
|
@@ -7,45 +7,43 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { toJson } from
|
|
11
|
-
import { createLogger } from
|
|
12
|
-
import { createRequestUrl } from
|
|
13
|
-
import { EndpointSupplier } from
|
|
14
|
-
import { getErrorResponseBody } from
|
|
15
|
-
import { getFetchFn } from
|
|
16
|
-
import { getRequestBody } from
|
|
17
|
-
import { getResponseBody, isResponseBodyError } from
|
|
18
|
-
import { Headers } from
|
|
19
|
-
import { clearResponseTimeout, makeRequest } from
|
|
20
|
-
import { abortRawResponse, toRawResponse, unknownRawResponse } from
|
|
21
|
-
import { redactUrl, SENSITIVE_QUERY_PARAMS } from
|
|
22
|
-
import { requestWithRetries } from
|
|
23
|
-
import { TIMEOUT } from
|
|
10
|
+
import { toJson } from "../json.mjs";
|
|
11
|
+
import { createLogger } from "../logging/logger.mjs";
|
|
12
|
+
import { createRequestUrl } from "./createRequestUrl.mjs";
|
|
13
|
+
import { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
14
|
+
import { getErrorResponseBody } from "./getErrorResponseBody.mjs";
|
|
15
|
+
import { getFetchFn } from "./getFetchFn.mjs";
|
|
16
|
+
import { getRequestBody } from "./getRequestBody.mjs";
|
|
17
|
+
import { getResponseBody, isResponseBodyError } from "./getResponseBody.mjs";
|
|
18
|
+
import { Headers } from "./Headers.mjs";
|
|
19
|
+
import { clearResponseTimeout, makeRequest } from "./makeRequest.mjs";
|
|
20
|
+
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
21
|
+
import { redactUrl, SENSITIVE_QUERY_PARAMS } from "./redactUrl.mjs";
|
|
22
|
+
import { requestWithRetries } from "./requestWithRetries.mjs";
|
|
23
|
+
import { TIMEOUT } from "./signals.mjs";
|
|
24
24
|
const SENSITIVE_HEADERS = new Set([
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
"authorization",
|
|
26
|
+
"www-authenticate",
|
|
27
|
+
"x-api-key",
|
|
28
|
+
"api-key",
|
|
29
|
+
"apikey",
|
|
30
|
+
"x-api-token",
|
|
31
|
+
"x-auth-token",
|
|
32
|
+
"auth-token",
|
|
33
|
+
"cookie",
|
|
34
|
+
"set-cookie",
|
|
35
|
+
"proxy-authorization",
|
|
36
|
+
"proxy-authenticate",
|
|
37
|
+
"x-csrf-token",
|
|
38
|
+
"x-xsrf-token",
|
|
39
|
+
"x-session-token",
|
|
40
|
+
"x-access-token",
|
|
41
41
|
]);
|
|
42
42
|
function redactHeaders(headers) {
|
|
43
43
|
const filtered = {};
|
|
44
|
-
for (const [key, value] of headers instanceof Headers
|
|
45
|
-
? headers.entries()
|
|
46
|
-
: Object.entries(headers)) {
|
|
44
|
+
for (const [key, value] of headers instanceof Headers ? headers.entries() : Object.entries(headers)) {
|
|
47
45
|
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
48
|
-
filtered[key] =
|
|
46
|
+
filtered[key] = "[REDACTED]";
|
|
49
47
|
}
|
|
50
48
|
else {
|
|
51
49
|
filtered[key] = value;
|
|
@@ -59,7 +57,7 @@ function redactQueryParameters(queryParameters) {
|
|
|
59
57
|
}
|
|
60
58
|
const redacted = {};
|
|
61
59
|
for (const [key, value] of Object.entries(queryParameters)) {
|
|
62
|
-
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ?
|
|
60
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
63
61
|
}
|
|
64
62
|
return redacted;
|
|
65
63
|
}
|
|
@@ -67,24 +65,22 @@ function getHeaders(args) {
|
|
|
67
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
66
|
var _a;
|
|
69
67
|
const newHeaders = new Headers();
|
|
70
|
-
newHeaders.set(
|
|
71
|
-
?
|
|
72
|
-
: args.responseType ===
|
|
73
|
-
?
|
|
74
|
-
: args.responseType ===
|
|
75
|
-
?
|
|
76
|
-
:
|
|
68
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
69
|
+
? "application/json"
|
|
70
|
+
: args.responseType === "text"
|
|
71
|
+
? "text/plain"
|
|
72
|
+
: args.responseType === "sse"
|
|
73
|
+
? "text/event-stream"
|
|
74
|
+
: "*/*");
|
|
77
75
|
if (args.body !== undefined && args.contentType != null) {
|
|
78
|
-
newHeaders.set(
|
|
76
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
79
77
|
}
|
|
80
78
|
if (args.headers == null) {
|
|
81
79
|
return newHeaders;
|
|
82
80
|
}
|
|
83
81
|
for (const [key, value] of Object.entries(args.headers)) {
|
|
84
|
-
const result = yield EndpointSupplier.get(value, {
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
if (typeof result === 'string') {
|
|
82
|
+
const result = yield EndpointSupplier.get(value, { endpointMetadata: (_a = args.endpointMetadata) !== null && _a !== void 0 ? _a : {} });
|
|
83
|
+
if (typeof result === "string") {
|
|
88
84
|
newHeaders.set(key, result);
|
|
89
85
|
continue;
|
|
90
86
|
}
|
|
@@ -98,8 +94,8 @@ function getHeaders(args) {
|
|
|
98
94
|
}
|
|
99
95
|
function isJsonContentType(contentType) {
|
|
100
96
|
var _a, _b;
|
|
101
|
-
const mediaType = (_b = (_a = contentType === null || contentType === void 0 ? void 0 : contentType.split(
|
|
102
|
-
return
|
|
97
|
+
const mediaType = (_b = (_a = contentType === null || contentType === void 0 ? void 0 : contentType.split(";")[0]) === null || _a === void 0 ? void 0 : _a.trim().toLowerCase()) !== null && _b !== void 0 ? _b : "";
|
|
98
|
+
return mediaType === "application/json" || mediaType === "text/json" || mediaType.endsWith("+json");
|
|
103
99
|
}
|
|
104
100
|
export function fetcherImpl(args) {
|
|
105
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -113,7 +109,7 @@ export function fetcherImpl(args) {
|
|
|
113
109
|
}
|
|
114
110
|
const requestBody = yield getRequestBody({
|
|
115
111
|
body: args.body,
|
|
116
|
-
type: (_a = args.requestType) !== null && _a !== void 0 ? _a :
|
|
112
|
+
type: (_a = args.requestType) !== null && _a !== void 0 ? _a : "other",
|
|
117
113
|
});
|
|
118
114
|
const fetchFn = (_b = args.fetchFn) !== null && _b !== void 0 ? _b : (yield getFetchFn());
|
|
119
115
|
const headers = yield getHeaders(args);
|
|
@@ -126,12 +122,10 @@ export function fetcherImpl(args) {
|
|
|
126
122
|
queryParameters: redactQueryParameters(args.queryParameters),
|
|
127
123
|
hasBody: requestBody != null,
|
|
128
124
|
};
|
|
129
|
-
logger.debug(
|
|
125
|
+
logger.debug("Making HTTP request", metadata);
|
|
130
126
|
}
|
|
131
127
|
// Bodies that are read in full here stay covered by the timeout; streamed bodies are read by the caller.
|
|
132
|
-
const keepTimeoutUntilBodyRead = args.responseType !==
|
|
133
|
-
args.responseType !== 'sse' &&
|
|
134
|
-
args.responseType !== 'binary-response';
|
|
128
|
+
const keepTimeoutUntilBodyRead = args.responseType !== "streaming" && args.responseType !== "sse" && args.responseType !== "binary-response";
|
|
135
129
|
const attemptResponses = [];
|
|
136
130
|
try {
|
|
137
131
|
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -139,7 +133,7 @@ export function fetcherImpl(args) {
|
|
|
139
133
|
for (const previousResponse of attemptResponses) {
|
|
140
134
|
clearResponseTimeout(previousResponse);
|
|
141
135
|
}
|
|
142
|
-
const attemptResponse = yield makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType ===
|
|
136
|
+
const attemptResponse = yield makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse", keepTimeoutUntilBodyRead);
|
|
143
137
|
attemptResponses.push(attemptResponse);
|
|
144
138
|
return attemptResponse;
|
|
145
139
|
}), args.maxRetries, args.abortSignal);
|
|
@@ -151,13 +145,13 @@ export function fetcherImpl(args) {
|
|
|
151
145
|
statusCode: response.status,
|
|
152
146
|
responseHeaders: redactHeaders(response.headers),
|
|
153
147
|
};
|
|
154
|
-
logger.debug(
|
|
148
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
155
149
|
}
|
|
156
150
|
const body = yield getResponseBody(response, args.responseType);
|
|
157
151
|
// Only a body the server labelled as JSON is an error here; void endpoints may return plain text.
|
|
158
152
|
if (isResponseBodyError(body) &&
|
|
159
|
-
body.error.reason ===
|
|
160
|
-
isJsonContentType(response.headers.get(
|
|
153
|
+
body.error.reason === "non-json" &&
|
|
154
|
+
isJsonContentType(response.headers.get("Content-Type"))) {
|
|
161
155
|
return {
|
|
162
156
|
ok: false,
|
|
163
157
|
error: body.error,
|
|
@@ -179,12 +173,12 @@ export function fetcherImpl(args) {
|
|
|
179
173
|
statusCode: response.status,
|
|
180
174
|
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
181
175
|
};
|
|
182
|
-
logger.error(
|
|
176
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
183
177
|
}
|
|
184
178
|
return {
|
|
185
179
|
ok: false,
|
|
186
180
|
error: {
|
|
187
|
-
reason:
|
|
181
|
+
reason: "status-code",
|
|
188
182
|
statusCode: response.status,
|
|
189
183
|
body: yield getErrorResponseBody(response),
|
|
190
184
|
},
|
|
@@ -199,31 +193,31 @@ export function fetcherImpl(args) {
|
|
|
199
193
|
method: args.method,
|
|
200
194
|
url: redactUrl(url),
|
|
201
195
|
};
|
|
202
|
-
logger.error(
|
|
196
|
+
logger.error("HTTP request was aborted", metadata);
|
|
203
197
|
}
|
|
204
198
|
return {
|
|
205
199
|
ok: false,
|
|
206
200
|
error: {
|
|
207
|
-
reason:
|
|
208
|
-
errorMessage:
|
|
201
|
+
reason: "unknown",
|
|
202
|
+
errorMessage: "The user aborted a request",
|
|
209
203
|
cause: error,
|
|
210
204
|
},
|
|
211
205
|
rawResponse: abortRawResponse,
|
|
212
206
|
};
|
|
213
207
|
}
|
|
214
|
-
else if (error === TIMEOUT || (error instanceof Error && error.name ===
|
|
208
|
+
else if (error === TIMEOUT || (error instanceof Error && error.name === "AbortError")) {
|
|
215
209
|
if (logger.isError()) {
|
|
216
210
|
const metadata = {
|
|
217
211
|
method: args.method,
|
|
218
212
|
url: redactUrl(url),
|
|
219
213
|
timeoutMs: args.timeoutMs,
|
|
220
214
|
};
|
|
221
|
-
logger.error(
|
|
215
|
+
logger.error("HTTP request timed out", metadata);
|
|
222
216
|
}
|
|
223
217
|
return {
|
|
224
218
|
ok: false,
|
|
225
219
|
error: {
|
|
226
|
-
reason:
|
|
220
|
+
reason: "timeout",
|
|
227
221
|
cause: error,
|
|
228
222
|
},
|
|
229
223
|
rawResponse: abortRawResponse,
|
|
@@ -236,12 +230,12 @@ export function fetcherImpl(args) {
|
|
|
236
230
|
url: redactUrl(url),
|
|
237
231
|
errorMessage: error.message,
|
|
238
232
|
};
|
|
239
|
-
logger.error(
|
|
233
|
+
logger.error("HTTP request failed with error", metadata);
|
|
240
234
|
}
|
|
241
235
|
return {
|
|
242
236
|
ok: false,
|
|
243
237
|
error: {
|
|
244
|
-
reason:
|
|
238
|
+
reason: "unknown",
|
|
245
239
|
errorMessage: error.message,
|
|
246
240
|
cause: error,
|
|
247
241
|
},
|
|
@@ -254,12 +248,12 @@ export function fetcherImpl(args) {
|
|
|
254
248
|
url: redactUrl(url),
|
|
255
249
|
error: toJson(error),
|
|
256
250
|
};
|
|
257
|
-
logger.error(
|
|
251
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
258
252
|
}
|
|
259
253
|
return {
|
|
260
254
|
ok: false,
|
|
261
255
|
error: {
|
|
262
|
-
reason:
|
|
256
|
+
reason: "unknown",
|
|
263
257
|
errorMessage: toJson(error),
|
|
264
258
|
cause: error,
|
|
265
259
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
let Headers;
|
|
2
|
-
if (typeof globalThis.Headers !==
|
|
2
|
+
if (typeof globalThis.Headers !== "undefined") {
|
|
3
3
|
Headers = globalThis.Headers;
|
|
4
4
|
}
|
|
5
5
|
else {
|
|
@@ -12,21 +12,21 @@ else {
|
|
|
12
12
|
}
|
|
13
13
|
else if (Array.isArray(init)) {
|
|
14
14
|
for (const [key, value] of init) {
|
|
15
|
-
if (typeof key ===
|
|
15
|
+
if (typeof key === "string" && typeof value === "string") {
|
|
16
16
|
this.append(key, value);
|
|
17
17
|
}
|
|
18
18
|
else {
|
|
19
|
-
throw new TypeError(
|
|
19
|
+
throw new TypeError("Each header entry must be a [string, string] tuple");
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
24
|
for (const [key, value] of Object.entries(init)) {
|
|
25
|
-
if (typeof value ===
|
|
25
|
+
if (typeof value === "string") {
|
|
26
26
|
this.append(key, value);
|
|
27
27
|
}
|
|
28
28
|
else {
|
|
29
|
-
throw new TypeError(
|
|
29
|
+
throw new TypeError("Header values must be strings");
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -44,7 +44,7 @@ else {
|
|
|
44
44
|
get(name) {
|
|
45
45
|
const key = name.toLowerCase();
|
|
46
46
|
const values = this.headers.get(key);
|
|
47
|
-
return values ? values.join(
|
|
47
|
+
return values ? values.join(", ") : null;
|
|
48
48
|
}
|
|
49
49
|
has(name) {
|
|
50
50
|
const key = name.toLowerCase();
|
|
@@ -56,14 +56,14 @@ else {
|
|
|
56
56
|
}
|
|
57
57
|
forEach(callbackfn, thisArg) {
|
|
58
58
|
const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
|
|
59
|
-
this.headers.forEach((values, key) => boundCallback(values.join(
|
|
59
|
+
this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
|
|
60
60
|
}
|
|
61
61
|
getSetCookie() {
|
|
62
|
-
return this.headers.get(
|
|
62
|
+
return this.headers.get("set-cookie") || [];
|
|
63
63
|
}
|
|
64
64
|
*entries() {
|
|
65
65
|
for (const [key, values] of this.headers.entries()) {
|
|
66
|
-
yield [key, values.join(
|
|
66
|
+
yield [key, values.join(", ")];
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
*keys() {
|
|
@@ -71,7 +71,7 @@ else {
|
|
|
71
71
|
}
|
|
72
72
|
*values() {
|
|
73
73
|
for (const values of this.headers.values()) {
|
|
74
|
-
yield values.join(
|
|
74
|
+
yield values.join(", ");
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
[Symbol.iterator]() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WithRawResponse } from
|
|
1
|
+
import type { WithRawResponse } from "./RawResponse.mjs";
|
|
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
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Headers } from
|
|
1
|
+
import { Headers } from "./Headers.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* A raw response indicating that the request was aborted.
|
|
4
4
|
*/
|
|
@@ -6,9 +6,9 @@ export const abortRawResponse = {
|
|
|
6
6
|
headers: new Headers(),
|
|
7
7
|
redirected: false,
|
|
8
8
|
status: 499,
|
|
9
|
-
statusText:
|
|
10
|
-
type:
|
|
11
|
-
url:
|
|
9
|
+
statusText: "Client Closed Request",
|
|
10
|
+
type: "error",
|
|
11
|
+
url: "",
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* A raw response indicating an unknown error.
|
|
@@ -17,9 +17,9 @@ export const unknownRawResponse = {
|
|
|
17
17
|
headers: new Headers(),
|
|
18
18
|
redirected: false,
|
|
19
19
|
status: 0,
|
|
20
|
-
statusText:
|
|
21
|
-
type:
|
|
22
|
-
url:
|
|
20
|
+
statusText: "Unknown Error",
|
|
21
|
+
type: "error",
|
|
22
|
+
url: "",
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
25
25
|
* Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
export const Supplier = {
|
|
11
11
|
get: (supplier) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
-
if (typeof supplier ===
|
|
12
|
+
if (typeof supplier === "function") {
|
|
13
13
|
return supplier();
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toQueryString } from
|
|
1
|
+
import { toQueryString } from "../url/qs.mjs";
|
|
2
2
|
export function createRequestUrl(baseUrl, queryParameters) {
|
|
3
|
-
const queryString = toQueryString(queryParameters, { arrayFormat:
|
|
3
|
+
const queryString = toQueryString(queryParameters, { arrayFormat: "repeat" });
|
|
4
4
|
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
5
5
|
}
|
|
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { fromJson } from
|
|
11
|
-
import { getResponseBody, isResponseBodyError } from
|
|
10
|
+
import { fromJson } from "../json.mjs";
|
|
11
|
+
import { getResponseBody, isResponseBodyError } from "./getResponseBody.mjs";
|
|
12
12
|
/** Parses a JSON error body, falling back to the raw text so the status and body are never lost. */
|
|
13
13
|
function parseJsonErrorBody(text) {
|
|
14
14
|
if (text.length === 0) {
|
|
@@ -24,27 +24,27 @@ function parseJsonErrorBody(text) {
|
|
|
24
24
|
export function getErrorResponseBody(response) {
|
|
25
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
26
|
var _a, _b, _c;
|
|
27
|
-
let contentType = (_a = response.headers.get(
|
|
27
|
+
let contentType = (_a = response.headers.get("Content-Type")) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
28
28
|
if (contentType == null || contentType.length === 0) {
|
|
29
29
|
const body = yield getResponseBody(response);
|
|
30
30
|
if (isResponseBodyError(body)) {
|
|
31
|
-
return body.error.reason ===
|
|
31
|
+
return body.error.reason === "non-json" ? body.error.rawBody : undefined;
|
|
32
32
|
}
|
|
33
33
|
return body;
|
|
34
34
|
}
|
|
35
|
-
if (contentType.indexOf(
|
|
36
|
-
contentType = (_c = (_b = contentType.split(
|
|
35
|
+
if (contentType.indexOf(";") !== -1) {
|
|
36
|
+
contentType = (_c = (_b = contentType.split(";")[0]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : "";
|
|
37
37
|
}
|
|
38
38
|
switch (contentType) {
|
|
39
|
-
case
|
|
40
|
-
case
|
|
41
|
-
case
|
|
42
|
-
case
|
|
43
|
-
case
|
|
44
|
-
case
|
|
39
|
+
case "application/hal+json":
|
|
40
|
+
case "application/json":
|
|
41
|
+
case "application/ld+json":
|
|
42
|
+
case "application/problem+json":
|
|
43
|
+
case "application/vnd.api+json":
|
|
44
|
+
case "text/json":
|
|
45
45
|
return parseJsonErrorBody(yield response.text());
|
|
46
46
|
default:
|
|
47
|
-
if (contentType.startsWith(
|
|
47
|
+
if (contentType.startsWith("application/vnd.") && contentType.endsWith("+json")) {
|
|
48
48
|
return parseJsonErrorBody(yield response.text());
|
|
49
49
|
}
|
|
50
50
|
// 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
|
|
7
|
+
export declare function getRequestBody({ body, type }: GetRequestBody.Args): Promise<BodyInit | undefined>;
|
|
@@ -7,14 +7,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { toJson } from
|
|
11
|
-
import { toQueryString } from
|
|
10
|
+
import { toJson } from "../json.mjs";
|
|
11
|
+
import { toQueryString } from "../url/qs.mjs";
|
|
12
12
|
export function getRequestBody(_a) {
|
|
13
|
-
return __awaiter(this, arguments, void 0, function* ({ body, type
|
|
14
|
-
if (type ===
|
|
15
|
-
return toQueryString(body, { arrayFormat:
|
|
13
|
+
return __awaiter(this, arguments, void 0, function* ({ body, type }) {
|
|
14
|
+
if (type === "form") {
|
|
15
|
+
return toQueryString(body, { arrayFormat: "repeat", encode: true });
|
|
16
16
|
}
|
|
17
|
-
if (type.includes(
|
|
17
|
+
if (type.includes("json")) {
|
|
18
18
|
return toJson(body);
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { fromJson } from
|
|
11
|
-
import { getBinaryResponse } from
|
|
10
|
+
import { fromJson } from "../json.mjs";
|
|
11
|
+
import { getBinaryResponse } from "./BinaryResponse.mjs";
|
|
12
12
|
// Pins the upstream Response so undici's FinalizationRegistry can't GC it and cancel the body stream.
|
|
13
13
|
function retainResponse(target, response) {
|
|
14
|
-
Object.defineProperty(target,
|
|
14
|
+
Object.defineProperty(target, "__fern_response_ref", {
|
|
15
15
|
value: response,
|
|
16
16
|
enumerable: false,
|
|
17
17
|
configurable: true,
|
|
@@ -29,36 +29,36 @@ function responseBodyError(error) {
|
|
|
29
29
|
* as opposed to a parsed JSON body that happens to have the same shape.
|
|
30
30
|
*/
|
|
31
31
|
export function isResponseBodyError(value) {
|
|
32
|
-
return typeof value ===
|
|
32
|
+
return typeof value === "object" && value != null && responseBodyErrors.has(value);
|
|
33
33
|
}
|
|
34
34
|
export function getResponseBody(response, responseType) {
|
|
35
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
36
|
switch (responseType) {
|
|
37
|
-
case
|
|
37
|
+
case "binary-response":
|
|
38
38
|
return getBinaryResponse(response);
|
|
39
|
-
case
|
|
39
|
+
case "blob":
|
|
40
40
|
return yield response.blob();
|
|
41
|
-
case
|
|
41
|
+
case "arrayBuffer":
|
|
42
42
|
return yield response.arrayBuffer();
|
|
43
|
-
case
|
|
43
|
+
case "sse":
|
|
44
44
|
if (response.body == null) {
|
|
45
45
|
return responseBodyError({
|
|
46
|
-
reason:
|
|
46
|
+
reason: "body-is-null",
|
|
47
47
|
statusCode: response.status,
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
retainResponse(response.body, response);
|
|
51
51
|
return response.body;
|
|
52
|
-
case
|
|
52
|
+
case "streaming":
|
|
53
53
|
if (response.body == null) {
|
|
54
54
|
return responseBodyError({
|
|
55
|
-
reason:
|
|
55
|
+
reason: "body-is-null",
|
|
56
56
|
statusCode: response.status,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
retainResponse(response.body, response);
|
|
60
60
|
return response.body;
|
|
61
|
-
case
|
|
61
|
+
case "text":
|
|
62
62
|
return yield response.text();
|
|
63
63
|
}
|
|
64
64
|
// if responseType is "json" or not specified, try to parse as JSON
|
|
@@ -70,7 +70,7 @@ export function getResponseBody(response, responseType) {
|
|
|
70
70
|
}
|
|
71
71
|
catch (_err) {
|
|
72
72
|
return responseBodyError({
|
|
73
|
-
reason:
|
|
73
|
+
reason: "non-json",
|
|
74
74
|
statusCode: response.status,
|
|
75
75
|
rawBody: text,
|
|
76
76
|
});
|
|
@@ -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.mjs";
|
|
2
|
+
export type { BinaryResponse } from "./BinaryResponse.mjs";
|
|
3
|
+
export type { EndpointMetadata } from "./EndpointMetadata.mjs";
|
|
4
|
+
export { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
5
|
+
export type { Fetcher, FetchFunction } from "./Fetcher.mjs";
|
|
6
|
+
export { fetcher } from "./Fetcher.mjs";
|
|
7
|
+
export { getHeader } from "./getHeader.mjs";
|
|
8
|
+
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
9
|
+
export type { PassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
10
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
11
|
+
export type { RawResponse, WithRawResponse } from "./RawResponse.mjs";
|
|
12
|
+
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
13
|
+
export { Supplier } from "./Supplier.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { EndpointSupplier } from
|
|
2
|
-
export { fetcher } from
|
|
3
|
-
export { getHeader } from
|
|
4
|
-
export { HttpResponsePromise } from
|
|
5
|
-
export { makePassthroughRequest } from
|
|
6
|
-
export { abortRawResponse, toRawResponse, unknownRawResponse } from
|
|
7
|
-
export { Supplier } from
|
|
1
|
+
export { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
2
|
+
export { fetcher } from "./Fetcher.mjs";
|
|
3
|
+
export { getHeader } from "./getHeader.mjs";
|
|
4
|
+
export { HttpResponsePromise } from "./HttpResponsePromise.mjs";
|
|
5
|
+
export { makePassthroughRequest } from "./makePassthroughRequest.mjs";
|
|
6
|
+
export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.mjs";
|
|
7
|
+
export { Supplier } from "./Supplier.mjs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type LogConfig, type Logger } from
|
|
2
|
-
import { Supplier } from
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.mjs";
|
|
2
|
+
import { Supplier } from "./Supplier.mjs";
|
|
3
3
|
export declare namespace PassthroughRequest {
|
|
4
4
|
/**
|
|
5
5
|
* Per-request options that can override the SDK client defaults.
|