@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,15 +7,15 @@ 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 { createLogger } from
|
|
11
|
-
import { join } from
|
|
12
|
-
import { EndpointSupplier } from
|
|
13
|
-
import { getFetchFn } from
|
|
14
|
-
import { makeRequest } from
|
|
15
|
-
import { redactUrl } from
|
|
16
|
-
import { requestWithRetries } from
|
|
17
|
-
import { Supplier } from
|
|
18
|
-
import { TIMEOUT } from
|
|
10
|
+
import { createLogger } from "../logging/logger.mjs";
|
|
11
|
+
import { join } from "../url/join.mjs";
|
|
12
|
+
import { EndpointSupplier } from "./EndpointSupplier.mjs";
|
|
13
|
+
import { getFetchFn } from "./getFetchFn.mjs";
|
|
14
|
+
import { makeRequest } from "./makeRequest.mjs";
|
|
15
|
+
import { redactUrl } from "./redactUrl.mjs";
|
|
16
|
+
import { requestWithRetries } from "./requestWithRetries.mjs";
|
|
17
|
+
import { Supplier } from "./Supplier.mjs";
|
|
18
|
+
import { TIMEOUT } from "./signals.mjs";
|
|
19
19
|
/**
|
|
20
20
|
* Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
|
|
21
21
|
* while mimicking the standard `fetch` API.
|
|
@@ -58,7 +58,7 @@ export function makePassthroughRequest(input, init, clientOptions, requestOption
|
|
|
58
58
|
const baseUrl = (_a = (clientOptions.baseUrl != null ? yield Supplier.get(clientOptions.baseUrl) : undefined)) !== null && _a !== void 0 ? _a : (clientOptions.environment != null ? yield Supplier.get(clientOptions.environment) : undefined);
|
|
59
59
|
// Determine the full URL
|
|
60
60
|
let fullUrl;
|
|
61
|
-
if (url.startsWith(
|
|
61
|
+
if (url.startsWith("http://") || url.startsWith("https://")) {
|
|
62
62
|
fullUrl = url;
|
|
63
63
|
}
|
|
64
64
|
else if (baseUrl != null) {
|
|
@@ -106,7 +106,7 @@ export function makePassthroughRequest(input, init, clientOptions, requestOption
|
|
|
106
106
|
mergedHeaders[key.toLowerCase()] = value;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b :
|
|
109
|
+
const method = (_b = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.method) !== null && _b !== void 0 ? _b : "GET";
|
|
110
110
|
const body = effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.body;
|
|
111
111
|
const timeoutInSeconds = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _c !== void 0 ? _c : clientOptions.timeoutInSeconds;
|
|
112
112
|
const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
|
|
@@ -114,7 +114,7 @@ export function makePassthroughRequest(input, init, clientOptions, requestOption
|
|
|
114
114
|
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;
|
|
115
115
|
const fetchFn = (_g = clientOptions.fetch) !== null && _g !== void 0 ? _g : (yield getFetchFn());
|
|
116
116
|
if (logger.isDebug()) {
|
|
117
|
-
logger.debug(
|
|
117
|
+
logger.debug("Making passthrough HTTP request", {
|
|
118
118
|
method,
|
|
119
119
|
url: redactUrl(fullUrl),
|
|
120
120
|
hasBody: body != null,
|
|
@@ -123,7 +123,7 @@ export function makePassthroughRequest(input, init, clientOptions, requestOption
|
|
|
123
123
|
let response;
|
|
124
124
|
try {
|
|
125
125
|
response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
return makeRequest(fetchFn, fullUrl, method, mergedHeaders, body !== null && body !== void 0 ? body : undefined, timeoutMs, abortSignal, (effectiveInit === null || effectiveInit === void 0 ? void 0 : effectiveInit.credentials) ===
|
|
126
|
+
return 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
|
|
127
127
|
false);
|
|
128
128
|
}), maxRetries, abortSignal);
|
|
129
129
|
}
|
|
@@ -135,7 +135,7 @@ export function makePassthroughRequest(input, init, clientOptions, requestOption
|
|
|
135
135
|
throw error;
|
|
136
136
|
}
|
|
137
137
|
if (logger.isDebug()) {
|
|
138
|
-
logger.debug(
|
|
138
|
+
logger.debug("Passthrough HTTP request completed", {
|
|
139
139
|
method,
|
|
140
140
|
url: redactUrl(fullUrl),
|
|
141
141
|
statusCode: response.status,
|
|
@@ -145,8 +145,8 @@ export function makePassthroughRequest(input, init, clientOptions, requestOption
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
function createTimeoutError() {
|
|
148
|
-
const error = new Error(
|
|
149
|
-
error.name =
|
|
148
|
+
const error = new Error("The request timed out.");
|
|
149
|
+
error.name = "TimeoutError";
|
|
150
150
|
return error;
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
@@ -7,7 +7,7 @@ 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 { anySignal, getTimeoutSignal, TIMEOUT } from
|
|
10
|
+
import { anySignal, getTimeoutSignal, TIMEOUT } from "./signals.mjs";
|
|
11
11
|
/**
|
|
12
12
|
* Cached result of checking whether the current runtime supports
|
|
13
13
|
* the `cache` option in `Request`. Some runtimes (e.g. Cloudflare Workers)
|
|
@@ -19,7 +19,7 @@ export function isCacheNoStoreSupported() {
|
|
|
19
19
|
return _cacheNoStoreSupported;
|
|
20
20
|
}
|
|
21
21
|
try {
|
|
22
|
-
new Request(
|
|
22
|
+
new Request("http://localhost", { cache: "no-store" });
|
|
23
23
|
_cacheNoStoreSupported = true;
|
|
24
24
|
}
|
|
25
25
|
catch (_a) {
|
|
@@ -61,9 +61,9 @@ export const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutM
|
|
|
61
61
|
const newSignals = anySignal(signals);
|
|
62
62
|
let response;
|
|
63
63
|
try {
|
|
64
|
-
response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ?
|
|
64
|
+
response = yield fetchFn(url, Object.assign({ method: method, headers, body: requestBody, signal: newSignals, credentials: withCredentials ? "include" : undefined,
|
|
65
65
|
// @ts-ignore
|
|
66
|
-
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache:
|
|
66
|
+
duplex }, (disableCache && isCacheNoStoreSupported() ? { cache: "no-store" } : {})));
|
|
67
67
|
}
|
|
68
68
|
catch (error) {
|
|
69
69
|
if (timeoutAbortId != null) {
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
export const SENSITIVE_QUERY_PARAMS = new Set([
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
"api_key",
|
|
3
|
+
"api-key",
|
|
4
|
+
"apikey",
|
|
5
|
+
"token",
|
|
6
|
+
"access_token",
|
|
7
|
+
"access-token",
|
|
8
|
+
"auth_token",
|
|
9
|
+
"auth-token",
|
|
10
|
+
"password",
|
|
11
|
+
"passwd",
|
|
12
|
+
"secret",
|
|
13
|
+
"api_secret",
|
|
14
|
+
"api-secret",
|
|
15
|
+
"apisecret",
|
|
16
|
+
"key",
|
|
17
|
+
"session",
|
|
18
|
+
"session_id",
|
|
19
|
+
"session-id",
|
|
20
20
|
]);
|
|
21
21
|
export function redactUrl(url) {
|
|
22
|
-
const protocolIndex = url.indexOf(
|
|
22
|
+
const protocolIndex = url.indexOf("://");
|
|
23
23
|
if (protocolIndex === -1)
|
|
24
24
|
return url;
|
|
25
25
|
const afterProtocol = protocolIndex + 3;
|
|
26
26
|
// Find the first delimiter that marks the end of the authority section
|
|
27
|
-
const pathStart = url.indexOf(
|
|
28
|
-
let queryStart = url.indexOf(
|
|
29
|
-
let fragmentStart = url.indexOf(
|
|
27
|
+
const pathStart = url.indexOf("/", afterProtocol);
|
|
28
|
+
let queryStart = url.indexOf("?", afterProtocol);
|
|
29
|
+
let fragmentStart = url.indexOf("#", afterProtocol);
|
|
30
30
|
const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
|
|
31
31
|
// Find the LAST @ before the delimiter (handles multiple @ in credentials)
|
|
32
32
|
let atIndex = -1;
|
|
33
33
|
for (let i = afterProtocol; i < firstDelimiter; i++) {
|
|
34
|
-
if (url[i] ===
|
|
34
|
+
if (url[i] === "@") {
|
|
35
35
|
atIndex = i;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -39,10 +39,10 @@ export function redactUrl(url) {
|
|
|
39
39
|
url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
|
|
40
40
|
}
|
|
41
41
|
// Recalculate queryStart since url might have changed
|
|
42
|
-
queryStart = url.indexOf(
|
|
42
|
+
queryStart = url.indexOf("?");
|
|
43
43
|
if (queryStart === -1)
|
|
44
44
|
return url;
|
|
45
|
-
fragmentStart = url.indexOf(
|
|
45
|
+
fragmentStart = url.indexOf("#", queryStart);
|
|
46
46
|
const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
|
|
47
47
|
const queryString = url.slice(queryStart + 1, queryEnd);
|
|
48
48
|
if (queryString.length === 0)
|
|
@@ -50,28 +50,28 @@ export function redactUrl(url) {
|
|
|
50
50
|
// FAST PATH: Quick check if any sensitive keywords present
|
|
51
51
|
// Using indexOf is faster than regex for simple substring matching
|
|
52
52
|
const lower = queryString.toLowerCase();
|
|
53
|
-
const hasSensitive = lower.includes(
|
|
54
|
-
lower.includes(
|
|
55
|
-
lower.includes(
|
|
56
|
-
lower.includes(
|
|
57
|
-
lower.includes(
|
|
58
|
-
lower.includes(
|
|
59
|
-
lower.includes(
|
|
53
|
+
const hasSensitive = lower.includes("token") ||
|
|
54
|
+
lower.includes("key") ||
|
|
55
|
+
lower.includes("password") ||
|
|
56
|
+
lower.includes("passwd") ||
|
|
57
|
+
lower.includes("secret") ||
|
|
58
|
+
lower.includes("session") ||
|
|
59
|
+
lower.includes("auth");
|
|
60
60
|
if (!hasSensitive) {
|
|
61
61
|
return url;
|
|
62
62
|
}
|
|
63
63
|
// SLOW PATH: Parse and redact
|
|
64
64
|
const redactedParams = [];
|
|
65
|
-
const params = queryString.split(
|
|
65
|
+
const params = queryString.split("&");
|
|
66
66
|
for (const param of params) {
|
|
67
|
-
const equalIndex = param.indexOf(
|
|
67
|
+
const equalIndex = param.indexOf("=");
|
|
68
68
|
if (equalIndex === -1) {
|
|
69
69
|
redactedParams.push(param);
|
|
70
70
|
continue;
|
|
71
71
|
}
|
|
72
72
|
const key = param.slice(0, equalIndex);
|
|
73
73
|
let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
|
|
74
|
-
if (!shouldRedact && key.includes(
|
|
74
|
+
if (!shouldRedact && key.includes("%")) {
|
|
75
75
|
try {
|
|
76
76
|
const decodedKey = decodeURIComponent(key);
|
|
77
77
|
shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
|
|
@@ -80,5 +80,5 @@ export function redactUrl(url) {
|
|
|
80
80
|
}
|
|
81
81
|
redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
|
|
82
82
|
}
|
|
83
|
-
return url.slice(0, queryStart + 1) + redactedParams.join(
|
|
83
|
+
return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd);
|
|
84
84
|
}
|
|
@@ -23,7 +23,7 @@ function addSymmetricJitter(delay) {
|
|
|
23
23
|
return delay * jitterMultiplier;
|
|
24
24
|
}
|
|
25
25
|
function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
26
|
-
const retryAfter = response.headers.get(
|
|
26
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
27
27
|
if (retryAfter) {
|
|
28
28
|
const retryAfterSeconds = parseInt(retryAfter, 10);
|
|
29
29
|
if (!Number.isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
|
|
@@ -37,7 +37,7 @@ function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
const rateLimitReset = response.headers.get(
|
|
40
|
+
const rateLimitReset = response.headers.get("X-RateLimit-Reset");
|
|
41
41
|
if (rateLimitReset) {
|
|
42
42
|
const resetTime = parseInt(rateLimitReset, 10);
|
|
43
43
|
if (!Number.isNaN(resetTime)) {
|
|
@@ -64,10 +64,10 @@ function sleep(ms, abortSignal) {
|
|
|
64
64
|
reject(abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.reason);
|
|
65
65
|
};
|
|
66
66
|
const timeoutId = setTimeout(() => {
|
|
67
|
-
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener(
|
|
67
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener("abort", onAbort);
|
|
68
68
|
resolve();
|
|
69
69
|
}, ms);
|
|
70
|
-
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener(
|
|
70
|
+
abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
export function requestWithRetries(requestFn_1) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const TIMEOUT =
|
|
1
|
+
export const TIMEOUT = "timeout";
|
|
2
2
|
export function getTimeoutSignal(timeoutMs) {
|
|
3
3
|
const controller = new AbortController();
|
|
4
4
|
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
@@ -12,7 +12,7 @@ export function anySignal(...args) {
|
|
|
12
12
|
controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
|
|
13
13
|
return controller.signal;
|
|
14
14
|
}
|
|
15
|
-
signal.addEventListener(
|
|
15
|
+
signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
|
|
16
16
|
signal: controller.signal,
|
|
17
17
|
});
|
|
18
18
|
// Re-check after adding listener: the signal may have aborted
|
|
@@ -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.mjs";
|
|
2
|
+
export * from "./base64.mjs";
|
|
3
|
+
export * from "./fetcher/index.mjs";
|
|
4
|
+
export * as logging from "./logging/index.mjs";
|
|
5
|
+
export * from "./runtime/index.mjs";
|
|
6
|
+
export * as url from "./url/index.mjs";
|
package/dist/esm/core/index.mjs
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.mjs";
|
|
2
|
+
export * from "./base64.mjs";
|
|
3
|
+
export * from "./fetcher/index.mjs";
|
|
4
|
+
export * as logging from "./logging/index.mjs";
|
|
5
|
+
export * from "./runtime/index.mjs";
|
|
6
|
+
export * as url from "./url/index.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./logger.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./logger.mjs";
|
|
@@ -16,7 +16,7 @@ export function mergeAdditionalBodyParameters(body, additionalBodyParameters) {
|
|
|
16
16
|
if (body == null) {
|
|
17
17
|
return Object.assign({}, additionalBodyParameters);
|
|
18
18
|
}
|
|
19
|
-
if (typeof body ===
|
|
19
|
+
if (typeof body === "object" && !Array.isArray(body)) {
|
|
20
20
|
return Object.assign(Object.assign({}, body), additionalBodyParameters);
|
|
21
21
|
}
|
|
22
22
|
return body;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getUserAgent, RUNTIME } from
|
|
1
|
+
export { getUserAgent, RUNTIME } from "./runtime.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getUserAgent, RUNTIME } from
|
|
1
|
+
export { getUserAgent, RUNTIME } from "./runtime.mjs";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const RUNTIME: Runtime;
|
|
5
5
|
export interface Runtime {
|
|
6
|
-
type:
|
|
6
|
+
type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd" | "edge-runtime";
|
|
7
7
|
version?: string;
|
|
8
8
|
parsedVersion?: number;
|
|
9
9
|
/**
|
|
@@ -7,10 +7,10 @@ function evaluateRuntime() {
|
|
|
7
7
|
/**
|
|
8
8
|
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
9
9
|
*/
|
|
10
|
-
const isBrowser = typeof window !==
|
|
10
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
11
11
|
if (isBrowser) {
|
|
12
12
|
return {
|
|
13
|
-
type:
|
|
13
|
+
type: "browser",
|
|
14
14
|
version: window.navigator.userAgent,
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -18,45 +18,43 @@ function evaluateRuntime() {
|
|
|
18
18
|
* A constant that indicates whether the environment the code is running is Cloudflare.
|
|
19
19
|
* https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
|
|
20
20
|
*/
|
|
21
|
-
const isCloudflare = typeof globalThis !==
|
|
21
|
+
const isCloudflare = typeof globalThis !== "undefined" && ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === "Cloudflare-Workers";
|
|
22
22
|
if (isCloudflare) {
|
|
23
23
|
return {
|
|
24
|
-
type:
|
|
24
|
+
type: "workerd",
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* A constant that indicates whether the environment the code is running is Edge Runtime.
|
|
29
29
|
* https://vercel.com/docs/functions/runtimes/edge-runtime#check-if-you're-running-on-the-edge-runtime
|
|
30
30
|
*/
|
|
31
|
-
const isEdgeRuntime = typeof EdgeRuntime ===
|
|
31
|
+
const isEdgeRuntime = typeof EdgeRuntime === "string";
|
|
32
32
|
if (isEdgeRuntime) {
|
|
33
33
|
return {
|
|
34
|
-
type:
|
|
34
|
+
type: "edge-runtime",
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* A constant that indicates whether the environment the code is running is a Web Worker.
|
|
39
39
|
*/
|
|
40
|
-
const isWebWorker = typeof self ===
|
|
41
|
-
typeof (self === null || self === void 0 ? void 0 : self.importScripts) ===
|
|
42
|
-
(((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) ===
|
|
43
|
-
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) ===
|
|
44
|
-
((_d = self.constructor) === null || _d === void 0 ? void 0 : _d.name) ===
|
|
40
|
+
const isWebWorker = typeof self === "object" &&
|
|
41
|
+
typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
|
|
42
|
+
(((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "DedicatedWorkerGlobalScope" ||
|
|
43
|
+
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "ServiceWorkerGlobalScope" ||
|
|
44
|
+
((_d = self.constructor) === null || _d === void 0 ? void 0 : _d.name) === "SharedWorkerGlobalScope");
|
|
45
45
|
if (isWebWorker) {
|
|
46
46
|
return {
|
|
47
|
-
type:
|
|
47
|
+
type: "web-worker",
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* A constant that indicates whether the environment the code is running is Deno.
|
|
52
52
|
* FYI Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
|
|
53
53
|
*/
|
|
54
|
-
const isDeno = typeof Deno !==
|
|
55
|
-
typeof Deno.version !== 'undefined' &&
|
|
56
|
-
typeof Deno.version.deno !== 'undefined';
|
|
54
|
+
const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
|
|
57
55
|
if (isDeno) {
|
|
58
56
|
return {
|
|
59
|
-
type:
|
|
57
|
+
type: "deno",
|
|
60
58
|
version: Deno.version.deno,
|
|
61
59
|
os: (_e = Deno.build) === null || _e === void 0 ? void 0 : _e.os,
|
|
62
60
|
arch: (_f = Deno.build) === null || _f === void 0 ? void 0 : _f.arch,
|
|
@@ -65,13 +63,13 @@ function evaluateRuntime() {
|
|
|
65
63
|
/**
|
|
66
64
|
* A constant that indicates whether the environment the code is running is Bun.sh.
|
|
67
65
|
*/
|
|
68
|
-
const isBun = typeof Bun !==
|
|
66
|
+
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
|
|
69
67
|
if (isBun) {
|
|
70
68
|
return {
|
|
71
|
-
type:
|
|
69
|
+
type: "bun",
|
|
72
70
|
version: Bun.version,
|
|
73
|
-
os: typeof process !==
|
|
74
|
-
arch: typeof process !==
|
|
71
|
+
os: typeof process !== "undefined" ? process.platform : undefined,
|
|
72
|
+
arch: typeof process !== "undefined" ? process.arch : undefined,
|
|
75
73
|
};
|
|
76
74
|
}
|
|
77
75
|
/**
|
|
@@ -79,10 +77,10 @@ function evaluateRuntime() {
|
|
|
79
77
|
* This check should come before Node.js detection since React Native may have a process polyfill.
|
|
80
78
|
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
81
79
|
*/
|
|
82
|
-
const isReactNative = typeof navigator !==
|
|
80
|
+
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
83
81
|
if (isReactNative) {
|
|
84
82
|
return {
|
|
85
|
-
type:
|
|
83
|
+
type: "react-native",
|
|
86
84
|
};
|
|
87
85
|
}
|
|
88
86
|
/**
|
|
@@ -92,19 +90,19 @@ function evaluateRuntime() {
|
|
|
92
90
|
* bundlers that perform static analysis on `process.versions` (e.g. Next.js
|
|
93
91
|
* Edge Runtime warns about Node.js APIs even when they are guarded).
|
|
94
92
|
*/
|
|
95
|
-
const _process = typeof process !==
|
|
96
|
-
const isNode = typeof _process !==
|
|
93
|
+
const _process = typeof process !== "undefined" ? process : undefined;
|
|
94
|
+
const isNode = typeof _process !== "undefined" && typeof ((_g = _process.versions) === null || _g === void 0 ? void 0 : _g.node) === "string";
|
|
97
95
|
if (isNode) {
|
|
98
96
|
return {
|
|
99
|
-
type:
|
|
97
|
+
type: "node",
|
|
100
98
|
version: _process.versions.node,
|
|
101
|
-
parsedVersion: Number(_process.versions.node.split(
|
|
99
|
+
parsedVersion: Number(_process.versions.node.split(".")[0]),
|
|
102
100
|
os: _process.platform,
|
|
103
101
|
arch: _process.arch,
|
|
104
102
|
};
|
|
105
103
|
}
|
|
106
104
|
return {
|
|
107
|
-
type:
|
|
105
|
+
type: "unknown",
|
|
108
106
|
};
|
|
109
107
|
}
|
|
110
108
|
/**
|
|
@@ -114,14 +112,14 @@ function evaluateRuntime() {
|
|
|
114
112
|
* to `undefined` so they are omitted from the User-Agent.
|
|
115
113
|
*/
|
|
116
114
|
const RUNTIME_DISPLAY_NAMES = {
|
|
117
|
-
node:
|
|
118
|
-
deno:
|
|
119
|
-
bun:
|
|
115
|
+
node: "Node",
|
|
116
|
+
deno: "Deno",
|
|
117
|
+
bun: "Bun",
|
|
120
118
|
browser: undefined,
|
|
121
|
-
|
|
122
|
-
|
|
119
|
+
"web-worker": undefined,
|
|
120
|
+
"react-native": undefined,
|
|
123
121
|
workerd: undefined,
|
|
124
|
-
|
|
122
|
+
"edge-runtime": undefined,
|
|
125
123
|
unknown: undefined,
|
|
126
124
|
};
|
|
127
125
|
/**
|
|
@@ -130,7 +128,7 @@ const RUNTIME_DISPLAY_NAMES = {
|
|
|
130
128
|
* consistent regardless of which runtime reports it (Node reports `x64`, others
|
|
131
129
|
* report `amd64` or `x86_64`).
|
|
132
130
|
*/
|
|
133
|
-
const X86_64_ARCH_ALIASES = new Set([
|
|
131
|
+
const X86_64_ARCH_ALIASES = new Set(["x64", "amd64", "x86_64"]);
|
|
134
132
|
/**
|
|
135
133
|
* Normalizes a CPU architecture token, collapsing the 64-bit x86 aliases
|
|
136
134
|
* (`x64`, `amd64`, `x86_64`) to `x86_64`. Other architectures are returned
|
|
@@ -140,7 +138,7 @@ function normalizeArch(arch) {
|
|
|
140
138
|
if (arch == null) {
|
|
141
139
|
return arch;
|
|
142
140
|
}
|
|
143
|
-
return X86_64_ARCH_ALIASES.has(arch.toLowerCase()) ?
|
|
141
|
+
return X86_64_ARCH_ALIASES.has(arch.toLowerCase()) ? "x86_64" : arch;
|
|
144
142
|
}
|
|
145
143
|
/**
|
|
146
144
|
* Percent-encodes the `@` and `/` characters in an npm package name so the
|
|
@@ -149,7 +147,7 @@ function normalizeArch(arch) {
|
|
|
149
147
|
* `@dummy/sdk` becomes `%40dummy%2Fsdk`).
|
|
150
148
|
*/
|
|
151
149
|
function encodeProductName(sdkName) {
|
|
152
|
-
return sdkName.replace(/@/g,
|
|
150
|
+
return sdkName.replace(/@/g, "%40").replace(/\//g, "%2F");
|
|
153
151
|
}
|
|
154
152
|
/**
|
|
155
153
|
* Builds a structured User-Agent string of the form
|
|
@@ -161,7 +159,7 @@ export function getUserAgent(sdkName, sdkVersion) {
|
|
|
161
159
|
let userAgent = `${encodeProductName(sdkName)}/${sdkVersion}`;
|
|
162
160
|
const platform = [RUNTIME.os, normalizeArch(RUNTIME.arch)].filter((part) => part != null && part.length > 0);
|
|
163
161
|
if (platform.length > 0) {
|
|
164
|
-
userAgent += ` (${platform.join(
|
|
162
|
+
userAgent += ` (${platform.join("; ")})`;
|
|
165
163
|
}
|
|
166
164
|
const runtimeName = RUNTIME_DISPLAY_NAMES[RUNTIME.type];
|
|
167
165
|
if (runtimeName != null) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toQueryString } from
|
|
1
|
+
import { toQueryString } from "./qs.mjs";
|
|
2
2
|
/**
|
|
3
3
|
* Creates a fluent builder for constructing URL query strings.
|
|
4
4
|
*
|
|
@@ -33,7 +33,7 @@ class QueryStringBuilder {
|
|
|
33
33
|
if (value === undefined || value === null) {
|
|
34
34
|
return this;
|
|
35
35
|
}
|
|
36
|
-
const serialized = toQueryString({ [key]: value }, { arrayFormat: (options === null || options === void 0 ? void 0 : options.style) ===
|
|
36
|
+
const serialized = toQueryString({ [key]: value }, { arrayFormat: (options === null || options === void 0 ? void 0 : options.style) === "comma" ? "comma" : "repeat" });
|
|
37
37
|
if (serialized.length > 0) {
|
|
38
38
|
this.parts.set(key, serialized);
|
|
39
39
|
}
|
|
@@ -62,7 +62,7 @@ class QueryStringBuilder {
|
|
|
62
62
|
if (value === undefined || value === null) {
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
|
-
const serialized = toQueryString({ [key]: value }, { arrayFormat:
|
|
65
|
+
const serialized = toQueryString({ [key]: value }, { arrayFormat: "repeat" });
|
|
66
66
|
if (serialized.length > 0) {
|
|
67
67
|
this.parts.set(key, serialized);
|
|
68
68
|
}
|
|
@@ -75,6 +75,6 @@ class QueryStringBuilder {
|
|
|
75
75
|
* Returns an empty string when no parameters were added.
|
|
76
76
|
*/
|
|
77
77
|
build() {
|
|
78
|
-
return [...this.parts.values()].join(
|
|
78
|
+
return [...this.parts.values()].join("&");
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export function encodePathParam(param, InvalidPathParameterError) {
|
|
2
2
|
if (param === null) {
|
|
3
|
-
return
|
|
3
|
+
return "null";
|
|
4
4
|
}
|
|
5
5
|
const typeofParam = typeof param;
|
|
6
6
|
switch (typeofParam) {
|
|
7
|
-
case
|
|
8
|
-
return
|
|
9
|
-
case
|
|
10
|
-
case
|
|
11
|
-
case
|
|
7
|
+
case "undefined":
|
|
8
|
+
return "undefined";
|
|
9
|
+
case "string":
|
|
10
|
+
case "number":
|
|
11
|
+
case "boolean":
|
|
12
12
|
break;
|
|
13
13
|
default:
|
|
14
14
|
param = String(param);
|
|
@@ -16,11 +16,9 @@ export function encodePathParam(param, InvalidPathParameterError) {
|
|
|
16
16
|
}
|
|
17
17
|
const encoded = encodeURIComponent(param);
|
|
18
18
|
// "." and ".." are dot segments: URL resolution would remove them and send the request to a different path.
|
|
19
|
-
if (encoded ===
|
|
19
|
+
if (encoded === "." || encoded === "..") {
|
|
20
20
|
const message = `Invalid path parameter "${encoded}": "." and ".." are not allowed because they change the request path.`;
|
|
21
|
-
throw InvalidPathParameterError != null
|
|
22
|
-
? new InvalidPathParameterError({ message })
|
|
23
|
-
: new Error(message);
|
|
21
|
+
throw InvalidPathParameterError != null ? new InvalidPathParameterError({ message }) : new Error(message);
|
|
24
22
|
}
|
|
25
23
|
return encoded;
|
|
26
24
|
}
|