@detectant-api/sdk 0.0.1 → 0.0.3
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 +111 -0
- package/dist/cjs/BaseClient.d.ts +54 -0
- package/dist/cjs/BaseClient.js +77 -0
- package/dist/cjs/Client.d.ts +86 -0
- package/dist/cjs/Client.js +255 -0
- package/dist/cjs/api/client/index.d.ts +1 -0
- package/dist/cjs/api/client/index.js +17 -0
- package/dist/cjs/api/client/requests/CreateScanBatchRequest.d.ts +5 -0
- package/dist/cjs/api/client/requests/CreateScanBatchRequest.js +3 -0
- package/dist/cjs/api/client/requests/CreateScanRequest.d.ts +5 -0
- package/dist/cjs/api/client/requests/CreateScanRequest.js +3 -0
- package/dist/cjs/api/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/client/requests/index.js +2 -0
- package/dist/cjs/api/errors/BadRequestError.d.ts +7 -0
- package/dist/cjs/api/errors/BadRequestError.js +54 -0
- package/dist/cjs/api/errors/ContentTooLargeError.d.ts +7 -0
- package/dist/cjs/api/errors/ContentTooLargeError.js +54 -0
- package/dist/cjs/api/errors/ForbiddenError.d.ts +7 -0
- package/dist/cjs/api/errors/ForbiddenError.js +54 -0
- package/dist/cjs/api/errors/InternalServerError.d.ts +7 -0
- package/dist/cjs/api/errors/InternalServerError.js +54 -0
- package/dist/cjs/api/errors/NotFoundError.d.ts +7 -0
- package/dist/cjs/api/errors/NotFoundError.js +54 -0
- package/dist/cjs/api/errors/ServiceUnavailableError.d.ts +5 -0
- package/dist/cjs/api/errors/ServiceUnavailableError.js +54 -0
- package/dist/cjs/api/errors/TooManyRequestsError.d.ts +7 -0
- package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
- package/dist/cjs/api/errors/UnauthorizedError.d.ts +7 -0
- package/dist/cjs/api/errors/UnauthorizedError.js +54 -0
- package/dist/cjs/api/errors/index.d.ts +8 -0
- package/dist/cjs/api/errors/index.js +24 -0
- package/dist/cjs/api/index.d.ts +4 -0
- package/dist/cjs/api/index.js +20 -0
- package/dist/cjs/api/resources/health/client/Client.d.ts +43 -0
- package/dist/cjs/api/resources/health/client/Client.js +152 -0
- package/dist/cjs/api/resources/health/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/health/client/index.js +2 -0
- package/dist/cjs/api/resources/health/exports.d.ts +2 -0
- package/dist/cjs/api/resources/health/exports.js +21 -0
- package/dist/cjs/api/resources/health/index.d.ts +1 -0
- package/dist/cjs/api/resources/health/index.js +17 -0
- package/dist/cjs/api/resources/index.d.ts +3 -0
- package/dist/cjs/api/resources/index.js +42 -0
- package/dist/cjs/api/resources/scans/client/Client.d.ts +54 -0
- package/dist/cjs/api/resources/scans/client/Client.js +196 -0
- package/dist/cjs/api/resources/scans/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/scans/client/index.js +17 -0
- package/dist/cjs/api/resources/scans/client/requests/GetScanRequest.d.ts +10 -0
- package/dist/cjs/api/resources/scans/client/requests/GetScanRequest.js +3 -0
- package/dist/cjs/api/resources/scans/client/requests/ListScansRequest.d.ts +18 -0
- package/dist/cjs/api/resources/scans/client/requests/ListScansRequest.js +3 -0
- package/dist/cjs/api/resources/scans/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/scans/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/scans/exports.d.ts +2 -0
- package/dist/cjs/api/resources/scans/exports.js +21 -0
- package/dist/cjs/api/resources/scans/index.d.ts +1 -0
- package/dist/cjs/api/resources/scans/index.js +17 -0
- package/dist/cjs/api/types/ApiError.d.ts +8 -0
- package/dist/cjs/api/types/ApiError.js +3 -0
- package/dist/cjs/api/types/ErrorResponse.d.ts +4 -0
- package/dist/cjs/api/types/ErrorResponse.js +3 -0
- package/dist/cjs/api/types/HealthResponse.d.ts +10 -0
- package/dist/cjs/api/types/HealthResponse.js +11 -0
- package/dist/cjs/api/types/Scan.d.ts +32 -0
- package/dist/cjs/api/types/Scan.js +17 -0
- package/dist/cjs/api/types/ScanBatchResponse.d.ts +5 -0
- package/dist/cjs/api/types/ScanBatchResponse.js +3 -0
- package/dist/cjs/api/types/ScanBatchResult.d.ts +13 -0
- package/dist/cjs/api/types/ScanBatchResult.js +3 -0
- package/dist/cjs/api/types/ScanFailure.d.ts +11 -0
- package/dist/cjs/api/types/ScanFailure.js +11 -0
- package/dist/cjs/api/types/ScanList.d.ts +7 -0
- package/dist/cjs/api/types/ScanList.js +3 -0
- package/dist/cjs/api/types/TypeAnalysis.d.ts +26 -0
- package/dist/cjs/api/types/TypeAnalysis.js +20 -0
- package/dist/cjs/api/types/TypeAnalysisReason.d.ts +13 -0
- package/dist/cjs/api/types/TypeAnalysisReason.js +12 -0
- package/dist/cjs/api/types/TypeDeclaration.d.ts +6 -0
- package/dist/cjs/api/types/TypeDeclaration.js +3 -0
- package/dist/cjs/api/types/TypeIdentification.d.ts +6 -0
- package/dist/cjs/api/types/TypeIdentification.js +3 -0
- package/dist/cjs/api/types/index.d.ts +12 -0
- package/dist/cjs/api/types/index.js +28 -0
- package/dist/cjs/auth/HeaderAuthProvider.d.ts +20 -0
- package/dist/cjs/auth/HeaderAuthProvider.js +80 -0
- package/dist/cjs/auth/index.d.ts +1 -0
- package/dist/cjs/auth/index.js +5 -0
- package/dist/cjs/core/auth/AuthProvider.d.ts +8 -0
- package/dist/cjs/core/auth/AuthProvider.js +9 -0
- package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
- package/dist/cjs/core/auth/AuthRequest.js +2 -0
- package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
- package/dist/cjs/core/auth/BasicAuth.js +33 -0
- package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
- package/dist/cjs/core/auth/BearerToken.js +16 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
- package/dist/cjs/core/auth/index.d.ts +5 -0
- package/dist/cjs/core/auth/index.js +11 -0
- package/dist/cjs/core/base64.d.ts +2 -0
- package/dist/cjs/core/base64.js +26 -0
- package/dist/cjs/core/exports.d.ts +2 -0
- package/dist/cjs/core/exports.js +18 -0
- package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/cjs/core/fetcher/APIResponse.js +2 -0
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +19 -0
- package/dist/cjs/core/fetcher/BinaryResponse.js +17 -0
- package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
- package/dist/cjs/core/fetcher/Fetcher.d.ts +56 -0
- package/dist/cjs/core/fetcher/Fetcher.js +244 -0
- package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
- package/dist/cjs/core/fetcher/Headers.js +84 -0
- package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
- package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/cjs/core/fetcher/RawResponse.js +44 -0
- package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
- package/dist/cjs/core/fetcher/Supplier.js +22 -0
- package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/cjs/core/fetcher/createRequestUrl.js +8 -0
- package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/cjs/core/fetcher/getErrorResponseBody.js +45 -0
- package/dist/cjs/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/cjs/core/fetcher/getFetchFn.js +17 -0
- package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
- package/dist/cjs/core/fetcher/getHeader.js +11 -0
- package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/cjs/core/fetcher/getRequestBody.js +27 -0
- package/dist/cjs/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/cjs/core/fetcher/getResponseBody.js +80 -0
- package/dist/cjs/core/fetcher/index.d.ts +13 -0
- package/dist/cjs/core/fetcher/index.js +19 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +157 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -0
- package/dist/cjs/core/fetcher/makeRequest.js +61 -0
- package/dist/cjs/core/fetcher/redactUrl.d.ts +2 -0
- package/dist/cjs/core/fetcher/redactUrl.js +88 -0
- package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/cjs/core/fetcher/requestWithRetries.js +70 -0
- package/dist/cjs/core/fetcher/signals.d.ts +5 -0
- package/dist/cjs/core/fetcher/signals.js +32 -0
- package/dist/cjs/core/file/exports.d.ts +1 -0
- package/dist/cjs/core/file/exports.js +2 -0
- package/dist/cjs/core/file/file.d.ts +10 -0
- package/dist/cjs/core/file/file.js +225 -0
- package/dist/cjs/core/file/index.d.ts +2 -0
- package/dist/cjs/core/file/index.js +18 -0
- package/dist/cjs/core/file/types.d.ts +66 -0
- package/dist/cjs/core/file/types.js +2 -0
- package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
- package/dist/cjs/core/form-data-utils/FormDataWrapper.js +188 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
- package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
- package/dist/cjs/core/form-data-utils/index.js +20 -0
- package/dist/cjs/core/headers.d.ts +2 -0
- package/dist/cjs/core/headers.js +31 -0
- package/dist/cjs/core/index.d.ts +8 -0
- package/dist/cjs/core/index.js +47 -0
- package/dist/cjs/core/json.d.ts +15 -0
- package/dist/cjs/core/json.js +24 -0
- package/dist/cjs/core/logging/exports.d.ts +18 -0
- package/dist/cjs/core/logging/exports.js +45 -0
- package/dist/cjs/core/logging/index.d.ts +1 -0
- package/dist/cjs/core/logging/index.js +17 -0
- package/dist/cjs/core/logging/logger.d.ts +126 -0
- package/dist/cjs/core/logging/logger.js +144 -0
- package/dist/cjs/core/requestBody.d.ts +12 -0
- package/dist/cjs/core/requestBody.js +26 -0
- package/dist/cjs/core/runtime/index.d.ts +1 -0
- package/dist/cjs/core/runtime/index.js +6 -0
- package/dist/cjs/core/runtime/runtime.d.ts +28 -0
- package/dist/cjs/core/runtime/runtime.js +176 -0
- package/dist/cjs/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/cjs/core/url/QueryStringBuilder.js +83 -0
- package/dist/cjs/core/url/encodePathParam.d.ts +1 -0
- package/dist/cjs/core/url/encodePathParam.js +21 -0
- package/dist/cjs/core/url/index.d.ts +4 -0
- package/dist/cjs/core/url/index.js +11 -0
- package/dist/cjs/core/url/join.d.ts +1 -0
- package/dist/cjs/core/url/join.js +68 -0
- package/dist/cjs/core/url/qs.d.ts +7 -0
- package/dist/cjs/core/url/qs.js +76 -0
- package/dist/cjs/environments.d.ts +4 -0
- package/dist/cjs/environments.js +7 -0
- package/dist/cjs/errors/DetectantApiError.d.ts +15 -0
- package/dist/cjs/errors/DetectantApiError.js +39 -0
- package/dist/cjs/errors/DetectantApiTimeoutError.d.ts +6 -0
- package/dist/cjs/errors/DetectantApiTimeoutError.js +52 -0
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
- package/dist/cjs/errors/index.d.ts +2 -0
- package/dist/cjs/errors/index.js +7 -0
- package/dist/cjs/exports.d.ts +1 -0
- package/dist/cjs/exports.js +17 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +48 -0
- package/dist/cjs/version.d.ts +1 -0
- package/dist/cjs/version.js +4 -0
- package/dist/esm/BaseClient.d.mts +54 -0
- package/dist/esm/BaseClient.mjs +40 -0
- package/dist/esm/Client.d.mts +86 -0
- package/dist/esm/Client.mjs +218 -0
- package/dist/esm/api/client/index.d.mts +1 -0
- package/dist/esm/api/client/index.mjs +1 -0
- package/dist/esm/api/client/requests/CreateScanBatchRequest.d.mts +5 -0
- package/dist/esm/api/client/requests/CreateScanBatchRequest.mjs +2 -0
- package/dist/esm/api/client/requests/CreateScanRequest.d.mts +5 -0
- package/dist/esm/api/client/requests/CreateScanRequest.mjs +2 -0
- package/dist/esm/api/client/requests/index.d.mts +2 -0
- package/dist/esm/api/client/requests/index.mjs +1 -0
- package/dist/esm/api/errors/BadRequestError.d.mts +7 -0
- package/dist/esm/api/errors/BadRequestError.mjs +17 -0
- package/dist/esm/api/errors/ContentTooLargeError.d.mts +7 -0
- package/dist/esm/api/errors/ContentTooLargeError.mjs +17 -0
- package/dist/esm/api/errors/ForbiddenError.d.mts +7 -0
- package/dist/esm/api/errors/ForbiddenError.mjs +17 -0
- package/dist/esm/api/errors/InternalServerError.d.mts +7 -0
- package/dist/esm/api/errors/InternalServerError.mjs +17 -0
- package/dist/esm/api/errors/NotFoundError.d.mts +7 -0
- package/dist/esm/api/errors/NotFoundError.mjs +17 -0
- package/dist/esm/api/errors/ServiceUnavailableError.d.mts +5 -0
- package/dist/esm/api/errors/ServiceUnavailableError.mjs +17 -0
- package/dist/esm/api/errors/TooManyRequestsError.d.mts +7 -0
- package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
- package/dist/esm/api/errors/UnauthorizedError.d.mts +7 -0
- package/dist/esm/api/errors/UnauthorizedError.mjs +17 -0
- package/dist/esm/api/errors/index.d.mts +8 -0
- package/dist/esm/api/errors/index.mjs +8 -0
- package/dist/esm/api/index.d.mts +4 -0
- package/dist/esm/api/index.mjs +4 -0
- package/dist/esm/api/resources/health/client/Client.d.mts +43 -0
- package/dist/esm/api/resources/health/client/Client.mjs +115 -0
- package/dist/esm/api/resources/health/client/index.d.mts +1 -0
- package/dist/esm/api/resources/health/client/index.mjs +1 -0
- package/dist/esm/api/resources/health/exports.d.mts +2 -0
- package/dist/esm/api/resources/health/exports.mjs +3 -0
- package/dist/esm/api/resources/health/index.d.mts +1 -0
- package/dist/esm/api/resources/health/index.mjs +1 -0
- package/dist/esm/api/resources/index.d.mts +3 -0
- package/dist/esm/api/resources/index.mjs +3 -0
- package/dist/esm/api/resources/scans/client/Client.d.mts +54 -0
- package/dist/esm/api/resources/scans/client/Client.mjs +159 -0
- package/dist/esm/api/resources/scans/client/index.d.mts +1 -0
- package/dist/esm/api/resources/scans/client/index.mjs +1 -0
- package/dist/esm/api/resources/scans/client/requests/GetScanRequest.d.mts +10 -0
- package/dist/esm/api/resources/scans/client/requests/GetScanRequest.mjs +2 -0
- package/dist/esm/api/resources/scans/client/requests/ListScansRequest.d.mts +18 -0
- package/dist/esm/api/resources/scans/client/requests/ListScansRequest.mjs +2 -0
- package/dist/esm/api/resources/scans/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/scans/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/scans/exports.d.mts +2 -0
- package/dist/esm/api/resources/scans/exports.mjs +3 -0
- package/dist/esm/api/resources/scans/index.d.mts +1 -0
- package/dist/esm/api/resources/scans/index.mjs +1 -0
- package/dist/esm/api/types/ApiError.d.mts +8 -0
- package/dist/esm/api/types/ApiError.mjs +2 -0
- package/dist/esm/api/types/ErrorResponse.d.mts +4 -0
- package/dist/esm/api/types/ErrorResponse.mjs +2 -0
- package/dist/esm/api/types/HealthResponse.d.mts +10 -0
- package/dist/esm/api/types/HealthResponse.mjs +8 -0
- package/dist/esm/api/types/Scan.d.mts +32 -0
- package/dist/esm/api/types/Scan.mjs +14 -0
- package/dist/esm/api/types/ScanBatchResponse.d.mts +5 -0
- package/dist/esm/api/types/ScanBatchResponse.mjs +2 -0
- package/dist/esm/api/types/ScanBatchResult.d.mts +13 -0
- package/dist/esm/api/types/ScanBatchResult.mjs +2 -0
- package/dist/esm/api/types/ScanFailure.d.mts +11 -0
- package/dist/esm/api/types/ScanFailure.mjs +8 -0
- package/dist/esm/api/types/ScanList.d.mts +7 -0
- package/dist/esm/api/types/ScanList.mjs +2 -0
- package/dist/esm/api/types/TypeAnalysis.d.mts +26 -0
- package/dist/esm/api/types/TypeAnalysis.mjs +17 -0
- package/dist/esm/api/types/TypeAnalysisReason.d.mts +13 -0
- package/dist/esm/api/types/TypeAnalysisReason.mjs +9 -0
- package/dist/esm/api/types/TypeDeclaration.d.mts +6 -0
- package/dist/esm/api/types/TypeDeclaration.mjs +2 -0
- package/dist/esm/api/types/TypeIdentification.d.mts +6 -0
- package/dist/esm/api/types/TypeIdentification.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +12 -0
- package/dist/esm/api/types/index.mjs +12 -0
- package/dist/esm/auth/HeaderAuthProvider.d.mts +20 -0
- package/dist/esm/auth/HeaderAuthProvider.mjs +43 -0
- package/dist/esm/auth/index.d.mts +1 -0
- package/dist/esm/auth/index.mjs +1 -0
- package/dist/esm/core/auth/AuthProvider.d.mts +8 -0
- package/dist/esm/core/auth/AuthProvider.mjs +6 -0
- package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
- package/dist/esm/core/auth/AuthRequest.mjs +1 -0
- package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
- package/dist/esm/core/auth/BasicAuth.mjs +30 -0
- package/dist/esm/core/auth/BearerToken.d.mts +7 -0
- package/dist/esm/core/auth/BearerToken.mjs +13 -0
- package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
- package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
- package/dist/esm/core/auth/index.d.mts +5 -0
- package/dist/esm/core/auth/index.mjs +4 -0
- package/dist/esm/core/base64.d.mts +2 -0
- package/dist/esm/core/base64.mjs +22 -0
- package/dist/esm/core/exports.d.mts +2 -0
- package/dist/esm/core/exports.mjs +2 -0
- package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
- package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +19 -0
- package/dist/esm/core/fetcher/BinaryResponse.mjs +14 -0
- package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
- package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
- package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
- package/dist/esm/core/fetcher/Fetcher.d.mts +56 -0
- package/dist/esm/core/fetcher/Fetcher.mjs +240 -0
- package/dist/esm/core/fetcher/Headers.d.mts +2 -0
- package/dist/esm/core/fetcher/Headers.mjs +82 -0
- package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
- package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
- package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
- package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
- package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
- package/dist/esm/core/fetcher/Supplier.mjs +19 -0
- package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
- package/dist/esm/core/fetcher/createRequestUrl.mjs +5 -0
- package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
- package/dist/esm/core/fetcher/getErrorResponseBody.mjs +42 -0
- package/dist/esm/core/fetcher/getFetchFn.d.mts +1 -0
- package/dist/esm/core/fetcher/getFetchFn.mjs +14 -0
- package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
- package/dist/esm/core/fetcher/getHeader.mjs +8 -0
- package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
- package/dist/esm/core/fetcher/getRequestBody.mjs +24 -0
- package/dist/esm/core/fetcher/getResponseBody.d.mts +1 -0
- package/dist/esm/core/fetcher/getResponseBody.mjs +77 -0
- package/dist/esm/core/fetcher/index.d.mts +13 -0
- package/dist/esm/core/fetcher/index.mjs +7 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +154 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +6 -0
- package/dist/esm/core/fetcher/makeRequest.mjs +55 -0
- package/dist/esm/core/fetcher/redactUrl.d.mts +2 -0
- package/dist/esm/core/fetcher/redactUrl.mjs +84 -0
- package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
- package/dist/esm/core/fetcher/requestWithRetries.mjs +67 -0
- package/dist/esm/core/fetcher/signals.d.mts +5 -0
- package/dist/esm/core/fetcher/signals.mjs +28 -0
- package/dist/esm/core/file/exports.d.mts +1 -0
- package/dist/esm/core/file/exports.mjs +1 -0
- package/dist/esm/core/file/file.d.mts +10 -0
- package/dist/esm/core/file/file.mjs +188 -0
- package/dist/esm/core/file/index.d.mts +2 -0
- package/dist/esm/core/file/index.mjs +2 -0
- package/dist/esm/core/file/types.d.mts +66 -0
- package/dist/esm/core/file/types.mjs +1 -0
- package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
- package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +150 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
- package/dist/esm/core/form-data-utils/index.d.mts +2 -0
- package/dist/esm/core/form-data-utils/index.mjs +2 -0
- package/dist/esm/core/headers.d.mts +2 -0
- package/dist/esm/core/headers.mjs +27 -0
- package/dist/esm/core/index.d.mts +8 -0
- package/dist/esm/core/index.mjs +8 -0
- package/dist/esm/core/json.d.mts +15 -0
- package/dist/esm/core/json.mjs +19 -0
- package/dist/esm/core/logging/exports.d.mts +18 -0
- package/dist/esm/core/logging/exports.mjs +9 -0
- package/dist/esm/core/logging/index.d.mts +1 -0
- package/dist/esm/core/logging/index.mjs +1 -0
- package/dist/esm/core/logging/logger.d.mts +126 -0
- package/dist/esm/core/logging/logger.mjs +138 -0
- package/dist/esm/core/requestBody.d.mts +12 -0
- package/dist/esm/core/requestBody.mjs +23 -0
- package/dist/esm/core/runtime/index.d.mts +1 -0
- package/dist/esm/core/runtime/index.mjs +1 -0
- package/dist/esm/core/runtime/runtime.d.mts +28 -0
- package/dist/esm/core/runtime/runtime.mjs +172 -0
- package/dist/esm/core/url/QueryStringBuilder.d.mts +47 -0
- package/dist/esm/core/url/QueryStringBuilder.mjs +80 -0
- package/dist/esm/core/url/encodePathParam.d.mts +1 -0
- package/dist/esm/core/url/encodePathParam.mjs +18 -0
- package/dist/esm/core/url/index.d.mts +4 -0
- package/dist/esm/core/url/index.mjs +4 -0
- package/dist/esm/core/url/join.d.mts +1 -0
- package/dist/esm/core/url/join.mjs +65 -0
- package/dist/esm/core/url/qs.d.mts +7 -0
- package/dist/esm/core/url/qs.mjs +73 -0
- package/dist/esm/environments.d.mts +4 -0
- package/dist/esm/environments.mjs +4 -0
- package/dist/esm/errors/DetectantApiError.d.mts +15 -0
- package/dist/esm/errors/DetectantApiError.mjs +35 -0
- package/dist/esm/errors/DetectantApiTimeoutError.d.mts +6 -0
- package/dist/esm/errors/DetectantApiTimeoutError.mjs +15 -0
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
- package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
- package/dist/esm/errors/index.d.mts +2 -0
- package/dist/esm/errors/index.mjs +2 -0
- package/dist/esm/exports.d.mts +1 -0
- package/dist/esm/exports.mjs +1 -0
- package/dist/esm/index.d.mts +6 -0
- package/dist/esm/index.mjs +5 -0
- package/dist/esm/version.d.mts +1 -0
- package/dist/esm/version.mjs +1 -0
- package/package.json +91 -1
- package/reference.md +380 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = exports.ConsoleLogger = exports.LogLevel = void 0;
|
|
4
|
+
exports.createLogger = createLogger;
|
|
5
|
+
exports.LogLevel = {
|
|
6
|
+
Debug: "debug",
|
|
7
|
+
Info: "info",
|
|
8
|
+
Warn: "warn",
|
|
9
|
+
Error: "error",
|
|
10
|
+
};
|
|
11
|
+
const logLevelMap = {
|
|
12
|
+
[exports.LogLevel.Debug]: 1,
|
|
13
|
+
[exports.LogLevel.Info]: 2,
|
|
14
|
+
[exports.LogLevel.Warn]: 3,
|
|
15
|
+
[exports.LogLevel.Error]: 4,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Default console-based logger implementation.
|
|
19
|
+
*/
|
|
20
|
+
class ConsoleLogger {
|
|
21
|
+
debug(message, ...args) {
|
|
22
|
+
console.debug(message, ...args);
|
|
23
|
+
}
|
|
24
|
+
info(message, ...args) {
|
|
25
|
+
console.info(message, ...args);
|
|
26
|
+
}
|
|
27
|
+
warn(message, ...args) {
|
|
28
|
+
console.warn(message, ...args);
|
|
29
|
+
}
|
|
30
|
+
error(message, ...args) {
|
|
31
|
+
console.error(message, ...args);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.ConsoleLogger = ConsoleLogger;
|
|
35
|
+
/**
|
|
36
|
+
* Logger class that provides level-based logging functionality.
|
|
37
|
+
*/
|
|
38
|
+
class Logger {
|
|
39
|
+
/**
|
|
40
|
+
* Creates a new logger instance.
|
|
41
|
+
* @param config - Logger configuration
|
|
42
|
+
*/
|
|
43
|
+
constructor(config) {
|
|
44
|
+
this.level = logLevelMap[config.level];
|
|
45
|
+
this.logger = config.logger;
|
|
46
|
+
this.silent = config.silent;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Checks if a log level should be output based on configuration.
|
|
50
|
+
* @param level - The log level to check
|
|
51
|
+
* @returns True if the level should be logged
|
|
52
|
+
*/
|
|
53
|
+
shouldLog(level) {
|
|
54
|
+
return !this.silent && this.level <= logLevelMap[level];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Checks if debug logging is enabled.
|
|
58
|
+
* @returns True if debug logs should be output
|
|
59
|
+
*/
|
|
60
|
+
isDebug() {
|
|
61
|
+
return this.shouldLog(exports.LogLevel.Debug);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Logs a debug message if debug logging is enabled.
|
|
65
|
+
* @param message - The message to log
|
|
66
|
+
* @param args - Additional arguments to log
|
|
67
|
+
*/
|
|
68
|
+
debug(message, ...args) {
|
|
69
|
+
if (this.isDebug()) {
|
|
70
|
+
this.logger.debug(message, ...args);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Checks if info logging is enabled.
|
|
75
|
+
* @returns True if info logs should be output
|
|
76
|
+
*/
|
|
77
|
+
isInfo() {
|
|
78
|
+
return this.shouldLog(exports.LogLevel.Info);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Logs an info message if info logging is enabled.
|
|
82
|
+
* @param message - The message to log
|
|
83
|
+
* @param args - Additional arguments to log
|
|
84
|
+
*/
|
|
85
|
+
info(message, ...args) {
|
|
86
|
+
if (this.isInfo()) {
|
|
87
|
+
this.logger.info(message, ...args);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Checks if warning logging is enabled.
|
|
92
|
+
* @returns True if warning logs should be output
|
|
93
|
+
*/
|
|
94
|
+
isWarn() {
|
|
95
|
+
return this.shouldLog(exports.LogLevel.Warn);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Logs a warning message if warning logging is enabled.
|
|
99
|
+
* @param message - The message to log
|
|
100
|
+
* @param args - Additional arguments to log
|
|
101
|
+
*/
|
|
102
|
+
warn(message, ...args) {
|
|
103
|
+
if (this.isWarn()) {
|
|
104
|
+
this.logger.warn(message, ...args);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Checks if error logging is enabled.
|
|
109
|
+
* @returns True if error logs should be output
|
|
110
|
+
*/
|
|
111
|
+
isError() {
|
|
112
|
+
return this.shouldLog(exports.LogLevel.Error);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Logs an error message if error logging is enabled.
|
|
116
|
+
* @param message - The message to log
|
|
117
|
+
* @param args - Additional arguments to log
|
|
118
|
+
*/
|
|
119
|
+
error(message, ...args) {
|
|
120
|
+
if (this.isError()) {
|
|
121
|
+
this.logger.error(message, ...args);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.Logger = Logger;
|
|
126
|
+
function createLogger(config) {
|
|
127
|
+
var _a, _b, _c;
|
|
128
|
+
if (config == null) {
|
|
129
|
+
return defaultLogger;
|
|
130
|
+
}
|
|
131
|
+
if (config instanceof Logger) {
|
|
132
|
+
return config;
|
|
133
|
+
}
|
|
134
|
+
config = config !== null && config !== void 0 ? config : {};
|
|
135
|
+
(_a = config.level) !== null && _a !== void 0 ? _a : (config.level = exports.LogLevel.Info);
|
|
136
|
+
(_b = config.logger) !== null && _b !== void 0 ? _b : (config.logger = new ConsoleLogger());
|
|
137
|
+
(_c = config.silent) !== null && _c !== void 0 ? _c : (config.silent = true);
|
|
138
|
+
return new Logger(config);
|
|
139
|
+
}
|
|
140
|
+
const defaultLogger = new Logger({
|
|
141
|
+
level: exports.LogLevel.Info,
|
|
142
|
+
logger: new ConsoleLogger(),
|
|
143
|
+
silent: true,
|
|
144
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Spreads caller-supplied `additionalBodyParameters` (from `requestOptions.additionalBodyParameters`)
|
|
3
|
+
* on top of the request body. Caller-supplied properties win over the endpoint body. When no
|
|
4
|
+
* additional body parameters are provided, the original body is returned unchanged so serialization
|
|
5
|
+
* is unaffected.
|
|
6
|
+
*
|
|
7
|
+
* The merge only applies to plain-object (JSON object) bodies. When the body is `null`/`undefined`
|
|
8
|
+
* the additional parameters become the body; when the body is an array or a primitive JSON value it
|
|
9
|
+
* is returned unchanged, since object properties cannot be spread into it. This mirrors the Python
|
|
10
|
+
* SDK, which only merges additional body parameters into mapping bodies.
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergeAdditionalBodyParameters(body: unknown, additionalBodyParameters: Record<string, unknown> | undefined): unknown;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeAdditionalBodyParameters = mergeAdditionalBodyParameters;
|
|
4
|
+
/**
|
|
5
|
+
* Spreads caller-supplied `additionalBodyParameters` (from `requestOptions.additionalBodyParameters`)
|
|
6
|
+
* on top of the request body. Caller-supplied properties win over the endpoint body. When no
|
|
7
|
+
* additional body parameters are provided, the original body is returned unchanged so serialization
|
|
8
|
+
* is unaffected.
|
|
9
|
+
*
|
|
10
|
+
* The merge only applies to plain-object (JSON object) bodies. When the body is `null`/`undefined`
|
|
11
|
+
* the additional parameters become the body; when the body is an array or a primitive JSON value it
|
|
12
|
+
* is returned unchanged, since object properties cannot be spread into it. This mirrors the Python
|
|
13
|
+
* SDK, which only merges additional body parameters into mapping bodies.
|
|
14
|
+
*/
|
|
15
|
+
function mergeAdditionalBodyParameters(body, additionalBodyParameters) {
|
|
16
|
+
if (additionalBodyParameters == null) {
|
|
17
|
+
return body;
|
|
18
|
+
}
|
|
19
|
+
if (body == null) {
|
|
20
|
+
return Object.assign({}, additionalBodyParameters);
|
|
21
|
+
}
|
|
22
|
+
if (typeof body === "object" && !Array.isArray(body)) {
|
|
23
|
+
return Object.assign(Object.assign({}, body), additionalBodyParameters);
|
|
24
|
+
}
|
|
25
|
+
return body;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getUserAgent, RUNTIME } from "./runtime.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIME = exports.getUserAgent = void 0;
|
|
4
|
+
var runtime_js_1 = require("./runtime.js");
|
|
5
|
+
Object.defineProperty(exports, "getUserAgent", { enumerable: true, get: function () { return runtime_js_1.getUserAgent; } });
|
|
6
|
+
Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return runtime_js_1.RUNTIME; } });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A constant that indicates which environment and version the SDK is running in.
|
|
3
|
+
*/
|
|
4
|
+
export declare const RUNTIME: Runtime;
|
|
5
|
+
export interface Runtime {
|
|
6
|
+
type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd" | "edge-runtime";
|
|
7
|
+
version?: string;
|
|
8
|
+
parsedVersion?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The operating system the SDK is running on, when it can be determined
|
|
11
|
+
* (e.g. "linux", "darwin", "win32" on server runtimes). Undefined in
|
|
12
|
+
* environments where the OS is not observable (e.g. browsers).
|
|
13
|
+
*/
|
|
14
|
+
os?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The CPU architecture the SDK is running on, when it can be determined
|
|
17
|
+
* (e.g. "x64", "arm64" on server runtimes). Undefined in environments where
|
|
18
|
+
* the architecture is not observable (e.g. browsers).
|
|
19
|
+
*/
|
|
20
|
+
arch?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Builds a structured User-Agent string of the form
|
|
24
|
+
* `{sdkName}/{sdkVersion} ({os}; {arch}) {runtime}/{runtimeVersion}`
|
|
25
|
+
* where the platform group and runtime segment are omitted gracefully when the
|
|
26
|
+
* underlying values cannot be determined (e.g. in a browser).
|
|
27
|
+
*/
|
|
28
|
+
export declare function getUserAgent(sdkName: string, sdkVersion: string): string;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIME = void 0;
|
|
4
|
+
exports.getUserAgent = getUserAgent;
|
|
5
|
+
/**
|
|
6
|
+
* A constant that indicates which environment and version the SDK is running in.
|
|
7
|
+
*/
|
|
8
|
+
exports.RUNTIME = evaluateRuntime();
|
|
9
|
+
function evaluateRuntime() {
|
|
10
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
11
|
+
/**
|
|
12
|
+
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
13
|
+
*/
|
|
14
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
15
|
+
if (isBrowser) {
|
|
16
|
+
return {
|
|
17
|
+
type: "browser",
|
|
18
|
+
version: window.navigator.userAgent,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A constant that indicates whether the environment the code is running is Cloudflare.
|
|
23
|
+
* https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
|
|
24
|
+
*/
|
|
25
|
+
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";
|
|
26
|
+
if (isCloudflare) {
|
|
27
|
+
return {
|
|
28
|
+
type: "workerd",
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A constant that indicates whether the environment the code is running is Edge Runtime.
|
|
33
|
+
* https://vercel.com/docs/functions/runtimes/edge-runtime#check-if-you're-running-on-the-edge-runtime
|
|
34
|
+
*/
|
|
35
|
+
const isEdgeRuntime = typeof EdgeRuntime === "string";
|
|
36
|
+
if (isEdgeRuntime) {
|
|
37
|
+
return {
|
|
38
|
+
type: "edge-runtime",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A constant that indicates whether the environment the code is running is a Web Worker.
|
|
43
|
+
*/
|
|
44
|
+
const isWebWorker = typeof self === "object" &&
|
|
45
|
+
typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
|
|
46
|
+
(((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "DedicatedWorkerGlobalScope" ||
|
|
47
|
+
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "ServiceWorkerGlobalScope" ||
|
|
48
|
+
((_d = self.constructor) === null || _d === void 0 ? void 0 : _d.name) === "SharedWorkerGlobalScope");
|
|
49
|
+
if (isWebWorker) {
|
|
50
|
+
return {
|
|
51
|
+
type: "web-worker",
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A constant that indicates whether the environment the code is running is Deno.
|
|
56
|
+
* FYI Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
|
|
57
|
+
*/
|
|
58
|
+
const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
|
|
59
|
+
if (isDeno) {
|
|
60
|
+
return {
|
|
61
|
+
type: "deno",
|
|
62
|
+
version: Deno.version.deno,
|
|
63
|
+
os: (_e = Deno.build) === null || _e === void 0 ? void 0 : _e.os,
|
|
64
|
+
arch: (_f = Deno.build) === null || _f === void 0 ? void 0 : _f.arch,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A constant that indicates whether the environment the code is running is Bun.sh.
|
|
69
|
+
*/
|
|
70
|
+
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
|
|
71
|
+
if (isBun) {
|
|
72
|
+
return {
|
|
73
|
+
type: "bun",
|
|
74
|
+
version: Bun.version,
|
|
75
|
+
os: typeof process !== "undefined" ? process.platform : undefined,
|
|
76
|
+
arch: typeof process !== "undefined" ? process.arch : undefined,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
81
|
+
* This check should come before Node.js detection since React Native may have a process polyfill.
|
|
82
|
+
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
83
|
+
*/
|
|
84
|
+
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
85
|
+
if (isReactNative) {
|
|
86
|
+
return {
|
|
87
|
+
type: "react-native",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
92
|
+
*
|
|
93
|
+
* We assign `process` to a local variable first to avoid being flagged by
|
|
94
|
+
* bundlers that perform static analysis on `process.versions` (e.g. Next.js
|
|
95
|
+
* Edge Runtime warns about Node.js APIs even when they are guarded).
|
|
96
|
+
*/
|
|
97
|
+
const _process = typeof process !== "undefined" ? process : undefined;
|
|
98
|
+
const isNode = typeof _process !== "undefined" && typeof ((_g = _process.versions) === null || _g === void 0 ? void 0 : _g.node) === "string";
|
|
99
|
+
if (isNode) {
|
|
100
|
+
return {
|
|
101
|
+
type: "node",
|
|
102
|
+
version: _process.versions.node,
|
|
103
|
+
parsedVersion: Number(_process.versions.node.split(".")[0]),
|
|
104
|
+
os: _process.platform,
|
|
105
|
+
arch: _process.arch,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return {
|
|
109
|
+
type: "unknown",
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Display names for the language runtimes whose version is meaningful to encode
|
|
114
|
+
* in a User-Agent. Environments where a version string is not useful (e.g.
|
|
115
|
+
* browsers, where `version` is the full navigator UA) are intentionally mapped
|
|
116
|
+
* to `undefined` so they are omitted from the User-Agent.
|
|
117
|
+
*/
|
|
118
|
+
const RUNTIME_DISPLAY_NAMES = {
|
|
119
|
+
node: "Node",
|
|
120
|
+
deno: "Deno",
|
|
121
|
+
bun: "Bun",
|
|
122
|
+
browser: undefined,
|
|
123
|
+
"web-worker": undefined,
|
|
124
|
+
"react-native": undefined,
|
|
125
|
+
workerd: undefined,
|
|
126
|
+
"edge-runtime": undefined,
|
|
127
|
+
unknown: undefined,
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* CPU architecture aliases that all refer to 64-bit x86. They are normalized to
|
|
131
|
+
* the single canonical token `x86_64` so the User-Agent architecture label is
|
|
132
|
+
* consistent regardless of which runtime reports it (Node reports `x64`, others
|
|
133
|
+
* report `amd64` or `x86_64`).
|
|
134
|
+
*/
|
|
135
|
+
const X86_64_ARCH_ALIASES = new Set(["x64", "amd64", "x86_64"]);
|
|
136
|
+
/**
|
|
137
|
+
* Normalizes a CPU architecture token, collapsing the 64-bit x86 aliases
|
|
138
|
+
* (`x64`, `amd64`, `x86_64`) to `x86_64`. Other architectures are returned
|
|
139
|
+
* unchanged.
|
|
140
|
+
*/
|
|
141
|
+
function normalizeArch(arch) {
|
|
142
|
+
if (arch == null) {
|
|
143
|
+
return arch;
|
|
144
|
+
}
|
|
145
|
+
return X86_64_ARCH_ALIASES.has(arch.toLowerCase()) ? "x86_64" : arch;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Percent-encodes the `@` and `/` characters in an npm package name so the
|
|
149
|
+
* User-Agent product token stays within the RFC 7230 token grammar. The
|
|
150
|
+
* original scoped package name can be recovered by URL-decoding (e.g.
|
|
151
|
+
* `@dummy/sdk` becomes `%40dummy%2Fsdk`).
|
|
152
|
+
*/
|
|
153
|
+
function encodeProductName(sdkName) {
|
|
154
|
+
return sdkName.replace(/@/g, "%40").replace(/\//g, "%2F");
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Builds a structured User-Agent string of the form
|
|
158
|
+
* `{sdkName}/{sdkVersion} ({os}; {arch}) {runtime}/{runtimeVersion}`
|
|
159
|
+
* where the platform group and runtime segment are omitted gracefully when the
|
|
160
|
+
* underlying values cannot be determined (e.g. in a browser).
|
|
161
|
+
*/
|
|
162
|
+
function getUserAgent(sdkName, sdkVersion) {
|
|
163
|
+
let userAgent = `${encodeProductName(sdkName)}/${sdkVersion}`;
|
|
164
|
+
const platform = [exports.RUNTIME.os, normalizeArch(exports.RUNTIME.arch)].filter((part) => part != null && part.length > 0);
|
|
165
|
+
if (platform.length > 0) {
|
|
166
|
+
userAgent += ` (${platform.join("; ")})`;
|
|
167
|
+
}
|
|
168
|
+
const runtimeName = RUNTIME_DISPLAY_NAMES[exports.RUNTIME.type];
|
|
169
|
+
if (runtimeName != null) {
|
|
170
|
+
userAgent += ` ${runtimeName}`;
|
|
171
|
+
if (exports.RUNTIME.version != null && exports.RUNTIME.version.length > 0) {
|
|
172
|
+
userAgent += `/${exports.RUNTIME.version}`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return userAgent;
|
|
176
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a fluent builder for constructing URL query strings.
|
|
3
|
+
*
|
|
4
|
+
* Each `.add()` call serializes its value immediately (like C#'s builder),
|
|
5
|
+
* so no format tracking is needed — the style is applied at add-time.
|
|
6
|
+
*
|
|
7
|
+
* Usage (generated code):
|
|
8
|
+
*
|
|
9
|
+
* const qs = core.url.queryBuilder()
|
|
10
|
+
* .add("limit", limit)
|
|
11
|
+
* .add("tags", tags, { style: "comma" }) // explode: false
|
|
12
|
+
* .mergeAdditional(requestOptions?.queryParams)
|
|
13
|
+
* .build();
|
|
14
|
+
*/
|
|
15
|
+
export declare function queryBuilder(): QueryStringBuilder;
|
|
16
|
+
declare class QueryStringBuilder {
|
|
17
|
+
private parts;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a query parameter, serializing it immediately.
|
|
20
|
+
*
|
|
21
|
+
* By default arrays use "repeat" format (`key=a&key=b`).
|
|
22
|
+
* Pass `{ style: "comma" }` for OpenAPI `explode: false` parameters
|
|
23
|
+
* to get comma-separated values (`key=a,b,c`).
|
|
24
|
+
*
|
|
25
|
+
* Null / undefined values are silently skipped.
|
|
26
|
+
*/
|
|
27
|
+
add(key: string, value: unknown, options?: {
|
|
28
|
+
style?: "comma";
|
|
29
|
+
}): this;
|
|
30
|
+
/**
|
|
31
|
+
* Adds multiple query parameters at once from a record.
|
|
32
|
+
* All parameters use the default "repeat" array format.
|
|
33
|
+
* Null / undefined values are silently skipped.
|
|
34
|
+
*/
|
|
35
|
+
addMany(params: Record<string, unknown>): this;
|
|
36
|
+
/**
|
|
37
|
+
* Merges additional query parameters supplied at call-time via
|
|
38
|
+
* `requestOptions.queryParams`. Overrides existing keys (last-write-wins).
|
|
39
|
+
*/
|
|
40
|
+
mergeAdditional(additionalParams?: Record<string, unknown>): this;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the assembled query string (without the leading `?`).
|
|
43
|
+
* Returns an empty string when no parameters were added.
|
|
44
|
+
*/
|
|
45
|
+
build(): string;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.queryBuilder = queryBuilder;
|
|
4
|
+
const qs_js_1 = require("./qs.js");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a fluent builder for constructing URL query strings.
|
|
7
|
+
*
|
|
8
|
+
* Each `.add()` call serializes its value immediately (like C#'s builder),
|
|
9
|
+
* so no format tracking is needed — the style is applied at add-time.
|
|
10
|
+
*
|
|
11
|
+
* Usage (generated code):
|
|
12
|
+
*
|
|
13
|
+
* const qs = core.url.queryBuilder()
|
|
14
|
+
* .add("limit", limit)
|
|
15
|
+
* .add("tags", tags, { style: "comma" }) // explode: false
|
|
16
|
+
* .mergeAdditional(requestOptions?.queryParams)
|
|
17
|
+
* .build();
|
|
18
|
+
*/
|
|
19
|
+
function queryBuilder() {
|
|
20
|
+
return new QueryStringBuilder();
|
|
21
|
+
}
|
|
22
|
+
class QueryStringBuilder {
|
|
23
|
+
constructor() {
|
|
24
|
+
this.parts = new Map();
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Adds a query parameter, serializing it immediately.
|
|
28
|
+
*
|
|
29
|
+
* By default arrays use "repeat" format (`key=a&key=b`).
|
|
30
|
+
* Pass `{ style: "comma" }` for OpenAPI `explode: false` parameters
|
|
31
|
+
* to get comma-separated values (`key=a,b,c`).
|
|
32
|
+
*
|
|
33
|
+
* Null / undefined values are silently skipped.
|
|
34
|
+
*/
|
|
35
|
+
add(key, value, options) {
|
|
36
|
+
if (value === undefined || value === null) {
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
const serialized = (0, qs_js_1.toQueryString)({ [key]: value }, { arrayFormat: (options === null || options === void 0 ? void 0 : options.style) === "comma" ? "comma" : "repeat" });
|
|
40
|
+
if (serialized.length > 0) {
|
|
41
|
+
this.parts.set(key, serialized);
|
|
42
|
+
}
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Adds multiple query parameters at once from a record.
|
|
47
|
+
* All parameters use the default "repeat" array format.
|
|
48
|
+
* Null / undefined values are silently skipped.
|
|
49
|
+
*/
|
|
50
|
+
addMany(params) {
|
|
51
|
+
if (params != null) {
|
|
52
|
+
for (const [key, value] of Object.entries(params)) {
|
|
53
|
+
this.add(key, value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Merges additional query parameters supplied at call-time via
|
|
60
|
+
* `requestOptions.queryParams`. Overrides existing keys (last-write-wins).
|
|
61
|
+
*/
|
|
62
|
+
mergeAdditional(additionalParams) {
|
|
63
|
+
if (additionalParams != null) {
|
|
64
|
+
for (const [key, value] of Object.entries(additionalParams)) {
|
|
65
|
+
if (value === undefined || value === null) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const serialized = (0, qs_js_1.toQueryString)({ [key]: value }, { arrayFormat: "repeat" });
|
|
69
|
+
if (serialized.length > 0) {
|
|
70
|
+
this.parts.set(key, serialized);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Returns the assembled query string (without the leading `?`).
|
|
78
|
+
* Returns an empty string when no parameters were added.
|
|
79
|
+
*/
|
|
80
|
+
build() {
|
|
81
|
+
return [...this.parts.values()].join("&");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodePathParam(param: unknown): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodePathParam = encodePathParam;
|
|
4
|
+
function encodePathParam(param) {
|
|
5
|
+
if (param === null) {
|
|
6
|
+
return "null";
|
|
7
|
+
}
|
|
8
|
+
const typeofParam = typeof param;
|
|
9
|
+
switch (typeofParam) {
|
|
10
|
+
case "undefined":
|
|
11
|
+
return "undefined";
|
|
12
|
+
case "string":
|
|
13
|
+
case "number":
|
|
14
|
+
case "boolean":
|
|
15
|
+
break;
|
|
16
|
+
default:
|
|
17
|
+
param = String(param);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
return encodeURIComponent(param);
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toQueryString = exports.queryBuilder = exports.join = exports.encodePathParam = void 0;
|
|
4
|
+
var encodePathParam_js_1 = require("./encodePathParam.js");
|
|
5
|
+
Object.defineProperty(exports, "encodePathParam", { enumerable: true, get: function () { return encodePathParam_js_1.encodePathParam; } });
|
|
6
|
+
var join_js_1 = require("./join.js");
|
|
7
|
+
Object.defineProperty(exports, "join", { enumerable: true, get: function () { return join_js_1.join; } });
|
|
8
|
+
var QueryStringBuilder_js_1 = require("./QueryStringBuilder.js");
|
|
9
|
+
Object.defineProperty(exports, "queryBuilder", { enumerable: true, get: function () { return QueryStringBuilder_js_1.queryBuilder; } });
|
|
10
|
+
var qs_js_1 = require("./qs.js");
|
|
11
|
+
Object.defineProperty(exports, "toQueryString", { enumerable: true, get: function () { return qs_js_1.toQueryString; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function join(base: string, ...segments: string[]): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.join = join;
|
|
4
|
+
function join(base, ...segments) {
|
|
5
|
+
if (!base) {
|
|
6
|
+
return "";
|
|
7
|
+
}
|
|
8
|
+
if (segments.length === 0) {
|
|
9
|
+
return base;
|
|
10
|
+
}
|
|
11
|
+
if (base.includes("://")) {
|
|
12
|
+
let url;
|
|
13
|
+
try {
|
|
14
|
+
url = new URL(base);
|
|
15
|
+
}
|
|
16
|
+
catch (_a) {
|
|
17
|
+
return joinPath(base, ...segments);
|
|
18
|
+
}
|
|
19
|
+
const lastSegment = segments[segments.length - 1];
|
|
20
|
+
const shouldPreserveTrailingSlash = lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.endsWith("/");
|
|
21
|
+
for (const segment of segments) {
|
|
22
|
+
const cleanSegment = trimSlashes(segment);
|
|
23
|
+
if (cleanSegment) {
|
|
24
|
+
url.pathname = joinPathSegments(url.pathname, cleanSegment);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (shouldPreserveTrailingSlash && !url.pathname.endsWith("/")) {
|
|
28
|
+
url.pathname += "/";
|
|
29
|
+
}
|
|
30
|
+
return url.toString();
|
|
31
|
+
}
|
|
32
|
+
return joinPath(base, ...segments);
|
|
33
|
+
}
|
|
34
|
+
function joinPath(base, ...segments) {
|
|
35
|
+
if (segments.length === 0) {
|
|
36
|
+
return base;
|
|
37
|
+
}
|
|
38
|
+
let result = base;
|
|
39
|
+
const lastSegment = segments[segments.length - 1];
|
|
40
|
+
const shouldPreserveTrailingSlash = lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.endsWith("/");
|
|
41
|
+
for (const segment of segments) {
|
|
42
|
+
const cleanSegment = trimSlashes(segment);
|
|
43
|
+
if (cleanSegment) {
|
|
44
|
+
result = joinPathSegments(result, cleanSegment);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (shouldPreserveTrailingSlash && !result.endsWith("/")) {
|
|
48
|
+
result += "/";
|
|
49
|
+
}
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
function joinPathSegments(left, right) {
|
|
53
|
+
if (left.endsWith("/")) {
|
|
54
|
+
return left + right;
|
|
55
|
+
}
|
|
56
|
+
return `${left}/${right}`;
|
|
57
|
+
}
|
|
58
|
+
function trimSlashes(str) {
|
|
59
|
+
if (!str)
|
|
60
|
+
return str;
|
|
61
|
+
let start = 0;
|
|
62
|
+
let end = str.length;
|
|
63
|
+
if (str.startsWith("/"))
|
|
64
|
+
start = 1;
|
|
65
|
+
if (str.endsWith("/"))
|
|
66
|
+
end = str.length - 1;
|
|
67
|
+
return start === 0 && end === str.length ? str : str.slice(start, end);
|
|
68
|
+
}
|