@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
|
@@ -26,30 +26,28 @@ const redactUrl_js_1 = require("./redactUrl.js");
|
|
|
26
26
|
const requestWithRetries_js_1 = require("./requestWithRetries.js");
|
|
27
27
|
const signals_js_1 = require("./signals.js");
|
|
28
28
|
const SENSITIVE_HEADERS = new Set([
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
29
|
+
"authorization",
|
|
30
|
+
"www-authenticate",
|
|
31
|
+
"x-api-key",
|
|
32
|
+
"api-key",
|
|
33
|
+
"apikey",
|
|
34
|
+
"x-api-token",
|
|
35
|
+
"x-auth-token",
|
|
36
|
+
"auth-token",
|
|
37
|
+
"cookie",
|
|
38
|
+
"set-cookie",
|
|
39
|
+
"proxy-authorization",
|
|
40
|
+
"proxy-authenticate",
|
|
41
|
+
"x-csrf-token",
|
|
42
|
+
"x-xsrf-token",
|
|
43
|
+
"x-session-token",
|
|
44
|
+
"x-access-token",
|
|
45
45
|
]);
|
|
46
46
|
function redactHeaders(headers) {
|
|
47
47
|
const filtered = {};
|
|
48
|
-
for (const [key, value] of headers instanceof Headers_js_1.Headers
|
|
49
|
-
? headers.entries()
|
|
50
|
-
: Object.entries(headers)) {
|
|
48
|
+
for (const [key, value] of headers instanceof Headers_js_1.Headers ? headers.entries() : Object.entries(headers)) {
|
|
51
49
|
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
52
|
-
filtered[key] =
|
|
50
|
+
filtered[key] = "[REDACTED]";
|
|
53
51
|
}
|
|
54
52
|
else {
|
|
55
53
|
filtered[key] = value;
|
|
@@ -63,7 +61,7 @@ function redactQueryParameters(queryParameters) {
|
|
|
63
61
|
}
|
|
64
62
|
const redacted = {};
|
|
65
63
|
for (const [key, value] of Object.entries(queryParameters)) {
|
|
66
|
-
redacted[key] = redactUrl_js_1.SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ?
|
|
64
|
+
redacted[key] = redactUrl_js_1.SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
67
65
|
}
|
|
68
66
|
return redacted;
|
|
69
67
|
}
|
|
@@ -71,24 +69,22 @@ function getHeaders(args) {
|
|
|
71
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
70
|
var _a;
|
|
73
71
|
const newHeaders = new Headers_js_1.Headers();
|
|
74
|
-
newHeaders.set(
|
|
75
|
-
?
|
|
76
|
-
: args.responseType ===
|
|
77
|
-
?
|
|
78
|
-
: args.responseType ===
|
|
79
|
-
?
|
|
80
|
-
:
|
|
72
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
73
|
+
? "application/json"
|
|
74
|
+
: args.responseType === "text"
|
|
75
|
+
? "text/plain"
|
|
76
|
+
: args.responseType === "sse"
|
|
77
|
+
? "text/event-stream"
|
|
78
|
+
: "*/*");
|
|
81
79
|
if (args.body !== undefined && args.contentType != null) {
|
|
82
|
-
newHeaders.set(
|
|
80
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
83
81
|
}
|
|
84
82
|
if (args.headers == null) {
|
|
85
83
|
return newHeaders;
|
|
86
84
|
}
|
|
87
85
|
for (const [key, value] of Object.entries(args.headers)) {
|
|
88
|
-
const result = yield EndpointSupplier_js_1.EndpointSupplier.get(value, {
|
|
89
|
-
|
|
90
|
-
});
|
|
91
|
-
if (typeof result === 'string') {
|
|
86
|
+
const result = yield EndpointSupplier_js_1.EndpointSupplier.get(value, { endpointMetadata: (_a = args.endpointMetadata) !== null && _a !== void 0 ? _a : {} });
|
|
87
|
+
if (typeof result === "string") {
|
|
92
88
|
newHeaders.set(key, result);
|
|
93
89
|
continue;
|
|
94
90
|
}
|
|
@@ -102,8 +98,8 @@ function getHeaders(args) {
|
|
|
102
98
|
}
|
|
103
99
|
function isJsonContentType(contentType) {
|
|
104
100
|
var _a, _b;
|
|
105
|
-
const mediaType = (_b = (_a = contentType === null || contentType === void 0 ? void 0 : contentType.split(
|
|
106
|
-
return
|
|
101
|
+
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 : "";
|
|
102
|
+
return mediaType === "application/json" || mediaType === "text/json" || mediaType.endsWith("+json");
|
|
107
103
|
}
|
|
108
104
|
function fetcherImpl(args) {
|
|
109
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -117,7 +113,7 @@ function fetcherImpl(args) {
|
|
|
117
113
|
}
|
|
118
114
|
const requestBody = yield (0, getRequestBody_js_1.getRequestBody)({
|
|
119
115
|
body: args.body,
|
|
120
|
-
type: (_a = args.requestType) !== null && _a !== void 0 ? _a :
|
|
116
|
+
type: (_a = args.requestType) !== null && _a !== void 0 ? _a : "other",
|
|
121
117
|
});
|
|
122
118
|
const fetchFn = (_b = args.fetchFn) !== null && _b !== void 0 ? _b : (yield (0, getFetchFn_js_1.getFetchFn)());
|
|
123
119
|
const headers = yield getHeaders(args);
|
|
@@ -130,12 +126,10 @@ function fetcherImpl(args) {
|
|
|
130
126
|
queryParameters: redactQueryParameters(args.queryParameters),
|
|
131
127
|
hasBody: requestBody != null,
|
|
132
128
|
};
|
|
133
|
-
logger.debug(
|
|
129
|
+
logger.debug("Making HTTP request", metadata);
|
|
134
130
|
}
|
|
135
131
|
// Bodies that are read in full here stay covered by the timeout; streamed bodies are read by the caller.
|
|
136
|
-
const keepTimeoutUntilBodyRead = args.responseType !==
|
|
137
|
-
args.responseType !== 'sse' &&
|
|
138
|
-
args.responseType !== 'binary-response';
|
|
132
|
+
const keepTimeoutUntilBodyRead = args.responseType !== "streaming" && args.responseType !== "sse" && args.responseType !== "binary-response";
|
|
139
133
|
const attemptResponses = [];
|
|
140
134
|
try {
|
|
141
135
|
const response = yield (0, requestWithRetries_js_1.requestWithRetries)(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -143,7 +137,7 @@ function fetcherImpl(args) {
|
|
|
143
137
|
for (const previousResponse of attemptResponses) {
|
|
144
138
|
(0, makeRequest_js_1.clearResponseTimeout)(previousResponse);
|
|
145
139
|
}
|
|
146
|
-
const attemptResponse = yield (0, makeRequest_js_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType ===
|
|
140
|
+
const attemptResponse = yield (0, makeRequest_js_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse", keepTimeoutUntilBodyRead);
|
|
147
141
|
attemptResponses.push(attemptResponse);
|
|
148
142
|
return attemptResponse;
|
|
149
143
|
}), args.maxRetries, args.abortSignal);
|
|
@@ -155,13 +149,13 @@ function fetcherImpl(args) {
|
|
|
155
149
|
statusCode: response.status,
|
|
156
150
|
responseHeaders: redactHeaders(response.headers),
|
|
157
151
|
};
|
|
158
|
-
logger.debug(
|
|
152
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
159
153
|
}
|
|
160
154
|
const body = yield (0, getResponseBody_js_1.getResponseBody)(response, args.responseType);
|
|
161
155
|
// Only a body the server labelled as JSON is an error here; void endpoints may return plain text.
|
|
162
156
|
if ((0, getResponseBody_js_1.isResponseBodyError)(body) &&
|
|
163
|
-
body.error.reason ===
|
|
164
|
-
isJsonContentType(response.headers.get(
|
|
157
|
+
body.error.reason === "non-json" &&
|
|
158
|
+
isJsonContentType(response.headers.get("Content-Type"))) {
|
|
165
159
|
return {
|
|
166
160
|
ok: false,
|
|
167
161
|
error: body.error,
|
|
@@ -183,12 +177,12 @@ function fetcherImpl(args) {
|
|
|
183
177
|
statusCode: response.status,
|
|
184
178
|
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
185
179
|
};
|
|
186
|
-
logger.error(
|
|
180
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
187
181
|
}
|
|
188
182
|
return {
|
|
189
183
|
ok: false,
|
|
190
184
|
error: {
|
|
191
|
-
reason:
|
|
185
|
+
reason: "status-code",
|
|
192
186
|
statusCode: response.status,
|
|
193
187
|
body: yield (0, getErrorResponseBody_js_1.getErrorResponseBody)(response),
|
|
194
188
|
},
|
|
@@ -203,31 +197,31 @@ function fetcherImpl(args) {
|
|
|
203
197
|
method: args.method,
|
|
204
198
|
url: (0, redactUrl_js_1.redactUrl)(url),
|
|
205
199
|
};
|
|
206
|
-
logger.error(
|
|
200
|
+
logger.error("HTTP request was aborted", metadata);
|
|
207
201
|
}
|
|
208
202
|
return {
|
|
209
203
|
ok: false,
|
|
210
204
|
error: {
|
|
211
|
-
reason:
|
|
212
|
-
errorMessage:
|
|
205
|
+
reason: "unknown",
|
|
206
|
+
errorMessage: "The user aborted a request",
|
|
213
207
|
cause: error,
|
|
214
208
|
},
|
|
215
209
|
rawResponse: RawResponse_js_1.abortRawResponse,
|
|
216
210
|
};
|
|
217
211
|
}
|
|
218
|
-
else if (error === signals_js_1.TIMEOUT || (error instanceof Error && error.name ===
|
|
212
|
+
else if (error === signals_js_1.TIMEOUT || (error instanceof Error && error.name === "AbortError")) {
|
|
219
213
|
if (logger.isError()) {
|
|
220
214
|
const metadata = {
|
|
221
215
|
method: args.method,
|
|
222
216
|
url: (0, redactUrl_js_1.redactUrl)(url),
|
|
223
217
|
timeoutMs: args.timeoutMs,
|
|
224
218
|
};
|
|
225
|
-
logger.error(
|
|
219
|
+
logger.error("HTTP request timed out", metadata);
|
|
226
220
|
}
|
|
227
221
|
return {
|
|
228
222
|
ok: false,
|
|
229
223
|
error: {
|
|
230
|
-
reason:
|
|
224
|
+
reason: "timeout",
|
|
231
225
|
cause: error,
|
|
232
226
|
},
|
|
233
227
|
rawResponse: RawResponse_js_1.abortRawResponse,
|
|
@@ -240,12 +234,12 @@ function fetcherImpl(args) {
|
|
|
240
234
|
url: (0, redactUrl_js_1.redactUrl)(url),
|
|
241
235
|
errorMessage: error.message,
|
|
242
236
|
};
|
|
243
|
-
logger.error(
|
|
237
|
+
logger.error("HTTP request failed with error", metadata);
|
|
244
238
|
}
|
|
245
239
|
return {
|
|
246
240
|
ok: false,
|
|
247
241
|
error: {
|
|
248
|
-
reason:
|
|
242
|
+
reason: "unknown",
|
|
249
243
|
errorMessage: error.message,
|
|
250
244
|
cause: error,
|
|
251
245
|
},
|
|
@@ -258,12 +252,12 @@ function fetcherImpl(args) {
|
|
|
258
252
|
url: (0, redactUrl_js_1.redactUrl)(url),
|
|
259
253
|
error: (0, json_js_1.toJson)(error),
|
|
260
254
|
};
|
|
261
|
-
logger.error(
|
|
255
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
262
256
|
}
|
|
263
257
|
return {
|
|
264
258
|
ok: false,
|
|
265
259
|
error: {
|
|
266
|
-
reason:
|
|
260
|
+
reason: "unknown",
|
|
267
261
|
errorMessage: (0, json_js_1.toJson)(error),
|
|
268
262
|
cause: error,
|
|
269
263
|
},
|
|
@@ -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
|
|
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
|
/**
|