@typespec/ts-http-runtime 1.0.0-alpha.20241029.3 → 1.0.0-alpha.20241030.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/accessTokenCache.d.ts +1 -1
- package/dist/browser/accessTokenCache.d.ts.map +1 -1
- package/dist/browser/accessTokenCache.js.map +1 -1
- package/dist/browser/auth/tokenCredential.d.ts +2 -2
- package/dist/browser/auth/tokenCredential.d.ts.map +1 -1
- package/dist/browser/auth/tokenCredential.js.map +1 -1
- package/dist/browser/client/apiVersionPolicy.d.ts +2 -2
- package/dist/browser/client/apiVersionPolicy.d.ts.map +1 -1
- package/dist/browser/client/apiVersionPolicy.js.map +1 -1
- package/dist/browser/client/clientHelpers.d.ts +5 -5
- package/dist/browser/client/clientHelpers.d.ts.map +1 -1
- package/dist/browser/client/clientHelpers.js.map +1 -1
- package/dist/browser/client/common.d.ts +6 -6
- package/dist/browser/client/common.d.ts.map +1 -1
- package/dist/browser/client/common.js.map +1 -1
- package/dist/browser/client/getClient.d.ts +3 -3
- package/dist/browser/client/getClient.d.ts.map +1 -1
- package/dist/browser/client/getClient.js.map +1 -1
- package/dist/browser/client/keyCredentialAuthenticationPolicy.d.ts +2 -2
- package/dist/browser/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -1
- package/dist/browser/client/keyCredentialAuthenticationPolicy.js.map +1 -1
- package/dist/browser/client/multipart.d.ts +1 -1
- package/dist/browser/client/multipart.d.ts.map +1 -1
- package/dist/browser/client/multipart.js.map +1 -1
- package/dist/browser/client/operationOptionHelpers.d.ts +1 -1
- package/dist/browser/client/operationOptionHelpers.d.ts.map +1 -1
- package/dist/browser/client/operationOptionHelpers.js.map +1 -1
- package/dist/browser/client/restError.d.ts +1 -1
- package/dist/browser/client/restError.d.ts.map +1 -1
- package/dist/browser/client/restError.js.map +1 -1
- package/dist/browser/client/sendRequest.d.ts +3 -3
- package/dist/browser/client/sendRequest.d.ts.map +1 -1
- package/dist/browser/client/sendRequest.js.map +1 -1
- package/dist/browser/client/urlHelpers.d.ts +1 -1
- package/dist/browser/client/urlHelpers.d.ts.map +1 -1
- package/dist/browser/client/urlHelpers.js.map +1 -1
- package/dist/browser/fetchHttpClient.d.ts +1 -1
- package/dist/browser/fetchHttpClient.d.ts.map +1 -1
- package/dist/browser/fetchHttpClient.js.map +1 -1
- package/dist/browser/httpHeaders.d.ts +1 -1
- package/dist/browser/httpHeaders.d.ts.map +1 -1
- package/dist/browser/httpHeaders.js.map +1 -1
- package/dist/browser/interfaces.d.ts +2 -2
- package/dist/browser/interfaces.d.ts.map +1 -1
- package/dist/browser/interfaces.js.map +1 -1
- package/dist/browser/logger/logger.d.ts +1 -1
- package/dist/browser/logger/logger.d.ts.map +1 -1
- package/dist/browser/logger/logger.js.map +1 -1
- package/dist/browser/nodeHttpClient.d.ts +1 -1
- package/dist/browser/nodeHttpClient.d.ts.map +1 -1
- package/dist/browser/nodeHttpClient.js.map +1 -1
- package/dist/browser/pipeline.d.ts +1 -1
- package/dist/browser/pipeline.d.ts.map +1 -1
- package/dist/browser/pipeline.js.map +1 -1
- package/dist/browser/pipelineRequest.d.ts +3 -3
- package/dist/browser/pipelineRequest.d.ts.map +1 -1
- package/dist/browser/pipelineRequest.js.map +1 -1
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.d.ts +4 -4
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -1
- package/dist/browser/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
- package/dist/browser/policies/defaultRetryPolicy.d.ts +2 -2
- package/dist/browser/policies/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/browser/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/browser/policies/exponentialRetryPolicy.d.ts +1 -1
- package/dist/browser/policies/exponentialRetryPolicy.d.ts.map +1 -1
- package/dist/browser/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/browser/policies/formDataPolicy.d.ts +1 -1
- package/dist/browser/policies/formDataPolicy.d.ts.map +1 -1
- package/dist/browser/policies/formDataPolicy.js.map +1 -1
- package/dist/browser/policies/logPolicy.d.ts +2 -2
- package/dist/browser/policies/logPolicy.d.ts.map +1 -1
- package/dist/browser/policies/logPolicy.js.map +1 -1
- package/dist/browser/policies/multipartPolicy.d.ts +1 -1
- package/dist/browser/policies/multipartPolicy.d.ts.map +1 -1
- package/dist/browser/policies/multipartPolicy.js.map +1 -1
- package/dist/browser/policies/redirectPolicy.d.ts +1 -1
- package/dist/browser/policies/redirectPolicy.d.ts.map +1 -1
- package/dist/browser/policies/redirectPolicy.js.map +1 -1
- package/dist/browser/policies/retryPolicy.d.ts +3 -3
- package/dist/browser/policies/retryPolicy.d.ts.map +1 -1
- package/dist/browser/policies/retryPolicy.js.map +1 -1
- package/dist/browser/policies/systemErrorRetryPolicy.d.ts +1 -1
- package/dist/browser/policies/systemErrorRetryPolicy.d.ts.map +1 -1
- package/dist/browser/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/browser/policies/throttlingRetryPolicy.d.ts +1 -1
- package/dist/browser/policies/throttlingRetryPolicy.d.ts.map +1 -1
- package/dist/browser/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/browser/policies/tlsPolicy.d.ts +2 -2
- package/dist/browser/policies/tlsPolicy.d.ts.map +1 -1
- package/dist/browser/policies/tlsPolicy.js.map +1 -1
- package/dist/browser/policies/tracingPolicy.d.ts +1 -1
- package/dist/browser/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/browser/policies/tracingPolicy.js.map +1 -1
- package/dist/browser/policies/userAgentPolicy.d.ts +1 -1
- package/dist/browser/policies/userAgentPolicy.d.ts.map +1 -1
- package/dist/browser/policies/userAgentPolicy.js.map +1 -1
- package/dist/browser/restError.d.ts +1 -1
- package/dist/browser/restError.d.ts.map +1 -1
- package/dist/browser/restError.js.map +1 -1
- package/dist/browser/retryStrategies/exponentialRetryStrategy.d.ts +3 -3
- package/dist/browser/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -1
- package/dist/browser/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/browser/retryStrategies/retryStrategy.d.ts +3 -3
- package/dist/browser/retryStrategies/retryStrategy.d.ts.map +1 -1
- package/dist/browser/retryStrategies/retryStrategy.js.map +1 -1
- package/dist/browser/retryStrategies/throttlingRetryStrategy.d.ts +2 -2
- package/dist/browser/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -1
- package/dist/browser/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/browser/tracing/instrumenter.d.ts +1 -1
- package/dist/browser/tracing/instrumenter.d.ts.map +1 -1
- package/dist/browser/tracing/instrumenter.js.map +1 -1
- package/dist/browser/tracing/state-browser.d.mts.map +1 -1
- package/dist/browser/tracing/state-browser.mjs.map +1 -1
- package/dist/browser/tracing/state.d.ts +1 -1
- package/dist/browser/tracing/tracingClient.d.ts +1 -1
- package/dist/browser/tracing/tracingClient.d.ts.map +1 -1
- package/dist/browser/tracing/tracingClient.js.map +1 -1
- package/dist/browser/tracing/tracingContext.d.ts +1 -1
- package/dist/browser/tracing/tracingContext.d.ts.map +1 -1
- package/dist/browser/tracing/tracingContext.js.map +1 -1
- package/dist/browser/util/aborterUtils.d.ts +1 -1
- package/dist/browser/util/aborterUtils.d.ts.map +1 -1
- package/dist/browser/util/aborterUtils.js.map +1 -1
- package/dist/browser/util/createAbortablePromise.d.ts +1 -1
- package/dist/browser/util/createAbortablePromise.d.ts.map +1 -1
- package/dist/browser/util/createAbortablePromise.js.map +1 -1
- package/dist/browser/util/helpers.d.ts +2 -2
- package/dist/browser/util/helpers.d.ts.map +1 -1
- package/dist/browser/util/helpers.js.map +1 -1
- package/dist/browser/util/tokenCycler.d.ts +1 -1
- package/dist/browser/util/tokenCycler.d.ts.map +1 -1
- package/dist/browser/util/tokenCycler.js.map +1 -1
- package/dist/browser/xhrHttpClient.d.ts +1 -1
- package/dist/browser/xhrHttpClient.d.ts.map +1 -1
- package/dist/browser/xhrHttpClient.js.map +1 -1
- package/dist/commonjs/accessTokenCache.d.ts +1 -1
- package/dist/commonjs/accessTokenCache.d.ts.map +1 -1
- package/dist/commonjs/accessTokenCache.js.map +1 -1
- package/dist/commonjs/auth/tokenCredential.d.ts +2 -2
- package/dist/commonjs/auth/tokenCredential.d.ts.map +1 -1
- package/dist/commonjs/auth/tokenCredential.js.map +1 -1
- package/dist/commonjs/client/apiVersionPolicy.d.ts +2 -2
- package/dist/commonjs/client/apiVersionPolicy.d.ts.map +1 -1
- package/dist/commonjs/client/apiVersionPolicy.js.map +1 -1
- package/dist/commonjs/client/clientHelpers.d.ts +5 -5
- package/dist/commonjs/client/clientHelpers.d.ts.map +1 -1
- package/dist/commonjs/client/clientHelpers.js.map +1 -1
- package/dist/commonjs/client/common.d.ts +6 -6
- package/dist/commonjs/client/common.d.ts.map +1 -1
- package/dist/commonjs/client/common.js.map +1 -1
- package/dist/commonjs/client/getClient.d.ts +3 -3
- package/dist/commonjs/client/getClient.d.ts.map +1 -1
- package/dist/commonjs/client/getClient.js.map +1 -1
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.d.ts +2 -2
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -1
- package/dist/commonjs/client/keyCredentialAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/client/multipart.d.ts +1 -1
- package/dist/commonjs/client/multipart.d.ts.map +1 -1
- package/dist/commonjs/client/multipart.js.map +1 -1
- package/dist/commonjs/client/operationOptionHelpers.d.ts +1 -1
- package/dist/commonjs/client/operationOptionHelpers.d.ts.map +1 -1
- package/dist/commonjs/client/operationOptionHelpers.js.map +1 -1
- package/dist/commonjs/client/restError.d.ts +1 -1
- package/dist/commonjs/client/restError.d.ts.map +1 -1
- package/dist/commonjs/client/restError.js.map +1 -1
- package/dist/commonjs/client/sendRequest.d.ts +3 -3
- package/dist/commonjs/client/sendRequest.d.ts.map +1 -1
- package/dist/commonjs/client/sendRequest.js.map +1 -1
- package/dist/commonjs/client/urlHelpers.d.ts +1 -1
- package/dist/commonjs/client/urlHelpers.d.ts.map +1 -1
- package/dist/commonjs/client/urlHelpers.js.map +1 -1
- package/dist/commonjs/defaultHttpClient.d.ts +1 -1
- package/dist/commonjs/defaultHttpClient.d.ts.map +1 -1
- package/dist/commonjs/defaultHttpClient.js.map +1 -1
- package/dist/commonjs/fetchHttpClient.d.ts +1 -1
- package/dist/commonjs/fetchHttpClient.d.ts.map +1 -1
- package/dist/commonjs/fetchHttpClient.js.map +1 -1
- package/dist/commonjs/httpHeaders.d.ts +1 -1
- package/dist/commonjs/httpHeaders.d.ts.map +1 -1
- package/dist/commonjs/httpHeaders.js.map +1 -1
- package/dist/commonjs/interfaces.d.ts +2 -2
- package/dist/commonjs/interfaces.d.ts.map +1 -1
- package/dist/commonjs/interfaces.js.map +1 -1
- package/dist/commonjs/logger/logger.d.ts +1 -1
- package/dist/commonjs/logger/logger.d.ts.map +1 -1
- package/dist/commonjs/logger/logger.js.map +1 -1
- package/dist/commonjs/nodeHttpClient.d.ts +1 -1
- package/dist/commonjs/nodeHttpClient.d.ts.map +1 -1
- package/dist/commonjs/nodeHttpClient.js.map +1 -1
- package/dist/commonjs/pipeline.d.ts +1 -1
- package/dist/commonjs/pipeline.d.ts.map +1 -1
- package/dist/commonjs/pipeline.js.map +1 -1
- package/dist/commonjs/pipelineRequest.d.ts +3 -3
- package/dist/commonjs/pipelineRequest.d.ts.map +1 -1
- package/dist/commonjs/pipelineRequest.js.map +1 -1
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.d.ts +4 -4
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
- package/dist/commonjs/policies/decompressResponsePolicy.d.ts +1 -1
- package/dist/commonjs/policies/decompressResponsePolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/decompressResponsePolicy.js.map +1 -1
- package/dist/commonjs/policies/defaultRetryPolicy.d.ts +2 -2
- package/dist/commonjs/policies/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/exponentialRetryPolicy.d.ts +1 -1
- package/dist/commonjs/policies/exponentialRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/formDataPolicy.d.ts +1 -1
- package/dist/commonjs/policies/formDataPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
- package/dist/commonjs/policies/logPolicy.d.ts +2 -2
- package/dist/commonjs/policies/logPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/logPolicy.js.map +1 -1
- package/dist/commonjs/policies/multipartPolicy.d.ts +1 -1
- package/dist/commonjs/policies/multipartPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
- package/dist/commonjs/policies/redirectPolicy.d.ts +1 -1
- package/dist/commonjs/policies/redirectPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/redirectPolicy.js.map +1 -1
- package/dist/commonjs/policies/retryPolicy.d.ts +3 -3
- package/dist/commonjs/policies/retryPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/retryPolicy.js.map +1 -1
- package/dist/commonjs/policies/systemErrorRetryPolicy.d.ts +1 -1
- package/dist/commonjs/policies/systemErrorRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/throttlingRetryPolicy.d.ts +1 -1
- package/dist/commonjs/policies/throttlingRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/commonjs/policies/tlsPolicy.d.ts +2 -2
- package/dist/commonjs/policies/tlsPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/tlsPolicy.js.map +1 -1
- package/dist/commonjs/policies/tracingPolicy.d.ts +1 -1
- package/dist/commonjs/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/tracingPolicy.js.map +1 -1
- package/dist/commonjs/policies/userAgentPolicy.d.ts +1 -1
- package/dist/commonjs/policies/userAgentPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/userAgentPolicy.js.map +1 -1
- package/dist/commonjs/restError.d.ts +1 -1
- package/dist/commonjs/restError.d.ts.map +1 -1
- package/dist/commonjs/restError.js.map +1 -1
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.d.ts +3 -3
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -1
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/commonjs/retryStrategies/retryStrategy.d.ts +3 -3
- package/dist/commonjs/retryStrategies/retryStrategy.d.ts.map +1 -1
- package/dist/commonjs/retryStrategies/retryStrategy.js.map +1 -1
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.d.ts +2 -2
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -1
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/commonjs/tracing/instrumenter.d.ts +1 -1
- package/dist/commonjs/tracing/instrumenter.d.ts.map +1 -1
- package/dist/commonjs/tracing/instrumenter.js.map +1 -1
- package/dist/commonjs/tracing/tracingClient.d.ts +1 -1
- package/dist/commonjs/tracing/tracingClient.d.ts.map +1 -1
- package/dist/commonjs/tracing/tracingClient.js.map +1 -1
- package/dist/commonjs/tracing/tracingContext.d.ts +1 -1
- package/dist/commonjs/tracing/tracingContext.d.ts.map +1 -1
- package/dist/commonjs/tracing/tracingContext.js.map +1 -1
- package/dist/commonjs/util/aborterUtils.d.ts +1 -1
- package/dist/commonjs/util/aborterUtils.d.ts.map +1 -1
- package/dist/commonjs/util/aborterUtils.js.map +1 -1
- package/dist/commonjs/util/createAbortablePromise.d.ts +1 -1
- package/dist/commonjs/util/createAbortablePromise.d.ts.map +1 -1
- package/dist/commonjs/util/createAbortablePromise.js.map +1 -1
- package/dist/commonjs/util/helpers.d.ts +2 -2
- package/dist/commonjs/util/helpers.d.ts.map +1 -1
- package/dist/commonjs/util/helpers.js.map +1 -1
- package/dist/commonjs/util/tokenCycler.d.ts +1 -1
- package/dist/commonjs/util/tokenCycler.d.ts.map +1 -1
- package/dist/commonjs/util/tokenCycler.js.map +1 -1
- package/dist/commonjs/xhrHttpClient.d.ts +1 -1
- package/dist/commonjs/xhrHttpClient.d.ts.map +1 -1
- package/dist/commonjs/xhrHttpClient.js.map +1 -1
- package/dist/esm/accessTokenCache.d.ts +1 -1
- package/dist/esm/accessTokenCache.d.ts.map +1 -1
- package/dist/esm/accessTokenCache.js.map +1 -1
- package/dist/esm/auth/tokenCredential.d.ts +2 -2
- package/dist/esm/auth/tokenCredential.d.ts.map +1 -1
- package/dist/esm/auth/tokenCredential.js.map +1 -1
- package/dist/esm/client/apiVersionPolicy.d.ts +2 -2
- package/dist/esm/client/apiVersionPolicy.d.ts.map +1 -1
- package/dist/esm/client/apiVersionPolicy.js.map +1 -1
- package/dist/esm/client/clientHelpers.d.ts +5 -5
- package/dist/esm/client/clientHelpers.d.ts.map +1 -1
- package/dist/esm/client/clientHelpers.js.map +1 -1
- package/dist/esm/client/common.d.ts +6 -6
- package/dist/esm/client/common.d.ts.map +1 -1
- package/dist/esm/client/common.js.map +1 -1
- package/dist/esm/client/getClient.d.ts +3 -3
- package/dist/esm/client/getClient.d.ts.map +1 -1
- package/dist/esm/client/getClient.js.map +1 -1
- package/dist/esm/client/keyCredentialAuthenticationPolicy.d.ts +2 -2
- package/dist/esm/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -1
- package/dist/esm/client/keyCredentialAuthenticationPolicy.js.map +1 -1
- package/dist/esm/client/multipart.d.ts +1 -1
- package/dist/esm/client/multipart.d.ts.map +1 -1
- package/dist/esm/client/multipart.js.map +1 -1
- package/dist/esm/client/operationOptionHelpers.d.ts +1 -1
- package/dist/esm/client/operationOptionHelpers.d.ts.map +1 -1
- package/dist/esm/client/operationOptionHelpers.js.map +1 -1
- package/dist/esm/client/restError.d.ts +1 -1
- package/dist/esm/client/restError.d.ts.map +1 -1
- package/dist/esm/client/restError.js.map +1 -1
- package/dist/esm/client/sendRequest.d.ts +3 -3
- package/dist/esm/client/sendRequest.d.ts.map +1 -1
- package/dist/esm/client/sendRequest.js.map +1 -1
- package/dist/esm/client/urlHelpers.d.ts +1 -1
- package/dist/esm/client/urlHelpers.d.ts.map +1 -1
- package/dist/esm/client/urlHelpers.js.map +1 -1
- package/dist/esm/defaultHttpClient.d.ts +1 -1
- package/dist/esm/defaultHttpClient.d.ts.map +1 -1
- package/dist/esm/defaultHttpClient.js.map +1 -1
- package/dist/esm/fetchHttpClient.d.ts +1 -1
- package/dist/esm/fetchHttpClient.d.ts.map +1 -1
- package/dist/esm/fetchHttpClient.js.map +1 -1
- package/dist/esm/httpHeaders.d.ts +1 -1
- package/dist/esm/httpHeaders.d.ts.map +1 -1
- package/dist/esm/httpHeaders.js.map +1 -1
- package/dist/esm/interfaces.d.ts +2 -2
- package/dist/esm/interfaces.d.ts.map +1 -1
- package/dist/esm/interfaces.js.map +1 -1
- package/dist/esm/logger/logger.d.ts +1 -1
- package/dist/esm/logger/logger.d.ts.map +1 -1
- package/dist/esm/logger/logger.js.map +1 -1
- package/dist/esm/nodeHttpClient.d.ts +1 -1
- package/dist/esm/nodeHttpClient.d.ts.map +1 -1
- package/dist/esm/nodeHttpClient.js.map +1 -1
- package/dist/esm/pipeline.d.ts +1 -1
- package/dist/esm/pipeline.d.ts.map +1 -1
- package/dist/esm/pipeline.js.map +1 -1
- package/dist/esm/pipelineRequest.d.ts +3 -3
- package/dist/esm/pipelineRequest.d.ts.map +1 -1
- package/dist/esm/pipelineRequest.js.map +1 -1
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.d.ts +4 -4
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -1
- package/dist/esm/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
- package/dist/esm/policies/decompressResponsePolicy.d.ts +1 -1
- package/dist/esm/policies/decompressResponsePolicy.d.ts.map +1 -1
- package/dist/esm/policies/decompressResponsePolicy.js.map +1 -1
- package/dist/esm/policies/defaultRetryPolicy.d.ts +2 -2
- package/dist/esm/policies/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/esm/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/esm/policies/exponentialRetryPolicy.d.ts +1 -1
- package/dist/esm/policies/exponentialRetryPolicy.d.ts.map +1 -1
- package/dist/esm/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/esm/policies/formDataPolicy.d.ts +1 -1
- package/dist/esm/policies/formDataPolicy.d.ts.map +1 -1
- package/dist/esm/policies/formDataPolicy.js.map +1 -1
- package/dist/esm/policies/logPolicy.d.ts +2 -2
- package/dist/esm/policies/logPolicy.d.ts.map +1 -1
- package/dist/esm/policies/logPolicy.js.map +1 -1
- package/dist/esm/policies/multipartPolicy.d.ts +1 -1
- package/dist/esm/policies/multipartPolicy.d.ts.map +1 -1
- package/dist/esm/policies/multipartPolicy.js.map +1 -1
- package/dist/esm/policies/redirectPolicy.d.ts +1 -1
- package/dist/esm/policies/redirectPolicy.d.ts.map +1 -1
- package/dist/esm/policies/redirectPolicy.js.map +1 -1
- package/dist/esm/policies/retryPolicy.d.ts +3 -3
- package/dist/esm/policies/retryPolicy.d.ts.map +1 -1
- package/dist/esm/policies/retryPolicy.js.map +1 -1
- package/dist/esm/policies/systemErrorRetryPolicy.d.ts +1 -1
- package/dist/esm/policies/systemErrorRetryPolicy.d.ts.map +1 -1
- package/dist/esm/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/esm/policies/throttlingRetryPolicy.d.ts +1 -1
- package/dist/esm/policies/throttlingRetryPolicy.d.ts.map +1 -1
- package/dist/esm/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/esm/policies/tlsPolicy.d.ts +2 -2
- package/dist/esm/policies/tlsPolicy.d.ts.map +1 -1
- package/dist/esm/policies/tlsPolicy.js.map +1 -1
- package/dist/esm/policies/tracingPolicy.d.ts +1 -1
- package/dist/esm/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/esm/policies/tracingPolicy.js.map +1 -1
- package/dist/esm/policies/userAgentPolicy.d.ts +1 -1
- package/dist/esm/policies/userAgentPolicy.d.ts.map +1 -1
- package/dist/esm/policies/userAgentPolicy.js.map +1 -1
- package/dist/esm/restError.d.ts +1 -1
- package/dist/esm/restError.d.ts.map +1 -1
- package/dist/esm/restError.js.map +1 -1
- package/dist/esm/retryStrategies/exponentialRetryStrategy.d.ts +3 -3
- package/dist/esm/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -1
- package/dist/esm/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/esm/retryStrategies/retryStrategy.d.ts +3 -3
- package/dist/esm/retryStrategies/retryStrategy.d.ts.map +1 -1
- package/dist/esm/retryStrategies/retryStrategy.js.map +1 -1
- package/dist/esm/retryStrategies/throttlingRetryStrategy.d.ts +2 -2
- package/dist/esm/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -1
- package/dist/esm/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/esm/tracing/instrumenter.d.ts +1 -1
- package/dist/esm/tracing/instrumenter.d.ts.map +1 -1
- package/dist/esm/tracing/instrumenter.js.map +1 -1
- package/dist/esm/tracing/state.d.ts +1 -1
- package/dist/esm/tracing/state.d.ts.map +1 -1
- package/dist/esm/tracing/state.js.map +1 -1
- package/dist/esm/tracing/tracingClient.d.ts +1 -1
- package/dist/esm/tracing/tracingClient.d.ts.map +1 -1
- package/dist/esm/tracing/tracingClient.js.map +1 -1
- package/dist/esm/tracing/tracingContext.d.ts +1 -1
- package/dist/esm/tracing/tracingContext.d.ts.map +1 -1
- package/dist/esm/tracing/tracingContext.js.map +1 -1
- package/dist/esm/util/aborterUtils.d.ts +1 -1
- package/dist/esm/util/aborterUtils.d.ts.map +1 -1
- package/dist/esm/util/aborterUtils.js.map +1 -1
- package/dist/esm/util/createAbortablePromise.d.ts +1 -1
- package/dist/esm/util/createAbortablePromise.d.ts.map +1 -1
- package/dist/esm/util/createAbortablePromise.js.map +1 -1
- package/dist/esm/util/helpers.d.ts +2 -2
- package/dist/esm/util/helpers.d.ts.map +1 -1
- package/dist/esm/util/helpers.js.map +1 -1
- package/dist/esm/util/tokenCycler.d.ts +1 -1
- package/dist/esm/util/tokenCycler.d.ts.map +1 -1
- package/dist/esm/util/tokenCycler.js.map +1 -1
- package/dist/esm/xhrHttpClient.d.ts +1 -1
- package/dist/esm/xhrHttpClient.d.ts.map +1 -1
- package/dist/esm/xhrHttpClient.js.map +1 -1
- package/dist/react-native/accessTokenCache.d.ts +1 -1
- package/dist/react-native/accessTokenCache.d.ts.map +1 -1
- package/dist/react-native/accessTokenCache.js.map +1 -1
- package/dist/react-native/auth/tokenCredential.d.ts +2 -2
- package/dist/react-native/auth/tokenCredential.d.ts.map +1 -1
- package/dist/react-native/auth/tokenCredential.js.map +1 -1
- package/dist/react-native/client/apiVersionPolicy.d.ts +2 -2
- package/dist/react-native/client/apiVersionPolicy.d.ts.map +1 -1
- package/dist/react-native/client/apiVersionPolicy.js.map +1 -1
- package/dist/react-native/client/clientHelpers.d.ts +5 -5
- package/dist/react-native/client/clientHelpers.d.ts.map +1 -1
- package/dist/react-native/client/clientHelpers.js.map +1 -1
- package/dist/react-native/client/common.d.ts +6 -6
- package/dist/react-native/client/common.d.ts.map +1 -1
- package/dist/react-native/client/common.js.map +1 -1
- package/dist/react-native/client/getClient.d.ts +3 -3
- package/dist/react-native/client/getClient.d.ts.map +1 -1
- package/dist/react-native/client/getClient.js.map +1 -1
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.d.ts +2 -2
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.d.ts.map +1 -1
- package/dist/react-native/client/keyCredentialAuthenticationPolicy.js.map +1 -1
- package/dist/react-native/client/multipart.d.ts +1 -1
- package/dist/react-native/client/multipart.d.ts.map +1 -1
- package/dist/react-native/client/multipart.js.map +1 -1
- package/dist/react-native/client/operationOptionHelpers.d.ts +1 -1
- package/dist/react-native/client/operationOptionHelpers.d.ts.map +1 -1
- package/dist/react-native/client/operationOptionHelpers.js.map +1 -1
- package/dist/react-native/client/restError.d.ts +1 -1
- package/dist/react-native/client/restError.d.ts.map +1 -1
- package/dist/react-native/client/restError.js.map +1 -1
- package/dist/react-native/client/sendRequest.d.ts +3 -3
- package/dist/react-native/client/sendRequest.d.ts.map +1 -1
- package/dist/react-native/client/sendRequest.js.map +1 -1
- package/dist/react-native/client/urlHelpers.d.ts +1 -1
- package/dist/react-native/client/urlHelpers.d.ts.map +1 -1
- package/dist/react-native/client/urlHelpers.js.map +1 -1
- package/dist/react-native/fetchHttpClient.d.ts +1 -1
- package/dist/react-native/fetchHttpClient.d.ts.map +1 -1
- package/dist/react-native/fetchHttpClient.js.map +1 -1
- package/dist/react-native/httpHeaders.d.ts +1 -1
- package/dist/react-native/httpHeaders.d.ts.map +1 -1
- package/dist/react-native/httpHeaders.js.map +1 -1
- package/dist/react-native/interfaces.d.ts +2 -2
- package/dist/react-native/interfaces.d.ts.map +1 -1
- package/dist/react-native/interfaces.js.map +1 -1
- package/dist/react-native/logger/logger.d.ts +1 -1
- package/dist/react-native/logger/logger.d.ts.map +1 -1
- package/dist/react-native/logger/logger.js.map +1 -1
- package/dist/react-native/nodeHttpClient.d.ts +1 -1
- package/dist/react-native/nodeHttpClient.d.ts.map +1 -1
- package/dist/react-native/nodeHttpClient.js.map +1 -1
- package/dist/react-native/pipeline.d.ts +1 -1
- package/dist/react-native/pipeline.d.ts.map +1 -1
- package/dist/react-native/pipeline.js.map +1 -1
- package/dist/react-native/pipelineRequest.d.ts +3 -3
- package/dist/react-native/pipelineRequest.d.ts.map +1 -1
- package/dist/react-native/pipelineRequest.js.map +1 -1
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.d.ts +4 -4
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
- package/dist/react-native/policies/decompressResponsePolicy.d.ts +1 -1
- package/dist/react-native/policies/decompressResponsePolicy.d.ts.map +1 -1
- package/dist/react-native/policies/decompressResponsePolicy.js.map +1 -1
- package/dist/react-native/policies/defaultRetryPolicy.d.ts +2 -2
- package/dist/react-native/policies/defaultRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/defaultRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/exponentialRetryPolicy.d.ts +1 -1
- package/dist/react-native/policies/exponentialRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/exponentialRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/formDataPolicy.d.ts +1 -1
- package/dist/react-native/policies/formDataPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/formDataPolicy.js.map +1 -1
- package/dist/react-native/policies/logPolicy.d.ts +2 -2
- package/dist/react-native/policies/logPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/logPolicy.js.map +1 -1
- package/dist/react-native/policies/multipartPolicy.d.ts +1 -1
- package/dist/react-native/policies/multipartPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/multipartPolicy.js.map +1 -1
- package/dist/react-native/policies/redirectPolicy.d.ts +1 -1
- package/dist/react-native/policies/redirectPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/redirectPolicy.js.map +1 -1
- package/dist/react-native/policies/retryPolicy.d.ts +3 -3
- package/dist/react-native/policies/retryPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/retryPolicy.js.map +1 -1
- package/dist/react-native/policies/systemErrorRetryPolicy.d.ts +1 -1
- package/dist/react-native/policies/systemErrorRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/systemErrorRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/throttlingRetryPolicy.d.ts +1 -1
- package/dist/react-native/policies/throttlingRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/throttlingRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/tlsPolicy.d.ts +2 -2
- package/dist/react-native/policies/tlsPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/tlsPolicy.js.map +1 -1
- package/dist/react-native/policies/tracingPolicy.d.ts +1 -1
- package/dist/react-native/policies/tracingPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/tracingPolicy.js.map +1 -1
- package/dist/react-native/policies/userAgentPolicy.d.ts +1 -1
- package/dist/react-native/policies/userAgentPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/userAgentPolicy.js.map +1 -1
- package/dist/react-native/restError.d.ts +1 -1
- package/dist/react-native/restError.d.ts.map +1 -1
- package/dist/react-native/restError.js.map +1 -1
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.d.ts +3 -3
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.d.ts.map +1 -1
- package/dist/react-native/retryStrategies/exponentialRetryStrategy.js.map +1 -1
- package/dist/react-native/retryStrategies/retryStrategy.d.ts +3 -3
- package/dist/react-native/retryStrategies/retryStrategy.d.ts.map +1 -1
- package/dist/react-native/retryStrategies/retryStrategy.js.map +1 -1
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.d.ts +2 -2
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.d.ts.map +1 -1
- package/dist/react-native/retryStrategies/throttlingRetryStrategy.js.map +1 -1
- package/dist/react-native/tracing/instrumenter.d.ts +1 -1
- package/dist/react-native/tracing/instrumenter.d.ts.map +1 -1
- package/dist/react-native/tracing/instrumenter.js.map +1 -1
- package/dist/react-native/tracing/state.d.ts +1 -1
- package/dist/react-native/tracing/state.d.ts.map +1 -1
- package/dist/react-native/tracing/state.js.map +1 -1
- package/dist/react-native/tracing/tracingClient.d.ts +1 -1
- package/dist/react-native/tracing/tracingClient.d.ts.map +1 -1
- package/dist/react-native/tracing/tracingClient.js.map +1 -1
- package/dist/react-native/tracing/tracingContext.d.ts +1 -1
- package/dist/react-native/tracing/tracingContext.d.ts.map +1 -1
- package/dist/react-native/tracing/tracingContext.js.map +1 -1
- package/dist/react-native/util/aborterUtils.d.ts +1 -1
- package/dist/react-native/util/aborterUtils.d.ts.map +1 -1
- package/dist/react-native/util/aborterUtils.js.map +1 -1
- package/dist/react-native/util/createAbortablePromise.d.ts +1 -1
- package/dist/react-native/util/createAbortablePromise.d.ts.map +1 -1
- package/dist/react-native/util/createAbortablePromise.js.map +1 -1
- package/dist/react-native/util/helpers.d.ts +2 -2
- package/dist/react-native/util/helpers.d.ts.map +1 -1
- package/dist/react-native/util/helpers.js.map +1 -1
- package/dist/react-native/util/tokenCycler.d.ts +1 -1
- package/dist/react-native/util/tokenCycler.d.ts.map +1 -1
- package/dist/react-native/util/tokenCycler.js.map +1 -1
- package/dist/react-native/xhrHttpClient.d.ts +1 -1
- package/dist/react-native/xhrHttpClient.d.ts.map +1 -1
- package/dist/react-native/xhrHttpClient.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchHttpClient.js","sourceRoot":"","sources":["../../src/fetchHttpClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAQ9D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEjF;;GAEG;AACH,SAAS,MAAM,CAAC,IAAa;IAC3B,gFAAgF;IAChF,OAAO,CAAC,OAAO,IAAI,KAAK,UAAU,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,YAAY,IAAI,CAAC;AAC1F,CAAC;AAED;;;GAGG;AACH,MAAM,eAAe;IACnB;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,OAAwB;QAC/C,MAAM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AAM,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,0BAA0B,CAAC,cAA8B;IAChE,OAAO,cAAc,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,CAAC;AACxF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"./abort-controller/AbortError.js\";\nimport {\n HttpClient,\n HttpHeaders as PipelineHeaders,\n PipelineRequest,\n PipelineResponse,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { RestError } from \"./restError.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { isNodeReadableStream, isWebReadableStream } from \"./util/typeGuards.js\";\n\n/**\n * Checks if the body is a Blob or Blob-like\n */\nfunction isBlob(body: unknown): body is Blob {\n // File objects count as a type of Blob, so we want to use instanceof explicitly\n return (typeof Blob === \"function\" || typeof Blob === \"object\") && body instanceof Blob;\n}\n\n/**\n * A HttpClient implementation that uses window.fetch to send HTTP requests.\n * @internal\n */\nclass FetchHttpClient implements HttpClient {\n /**\n * Makes a request over an underlying transport layer and returns the response.\n * @param request - The request to be made.\n */\n public async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n const url = new URL(request.url);\n const isInsecure = url.protocol !== \"https:\";\n\n if (isInsecure && !request.allowInsecureConnection) {\n throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);\n }\n\n if (request.proxySettings) {\n throw new Error(\"HTTP proxy is not supported in browser environment\");\n }\n\n try {\n return await makeRequest(request);\n } catch (e: any) {\n throw getError(e, request);\n }\n }\n}\n\n/**\n * Sends a request\n */\nasync function makeRequest(request: PipelineRequest): Promise<PipelineResponse> {\n const { abortController, abortControllerCleanup } = setupAbortSignal(request);\n try {\n const headers = buildFetchHeaders(request.headers);\n const { streaming, body: requestBody } = buildRequestBody(request);\n const requestInit: RequestInit = {\n body: requestBody,\n method: request.method,\n headers: headers,\n signal: abortController.signal,\n // Cloudflare doesn't implement the full Fetch API spec\n // because of some of it doesn't make sense in the edge.\n // See https://github.com/cloudflare/workerd/issues/902\n ...(\"credentials\" in Request.prototype\n ? { credentials: request.withCredentials ? \"include\" : \"same-origin\" }\n : {}),\n ...(\"cache\" in Request.prototype ? { cache: \"no-store\" } : {}),\n };\n\n // According to https://fetch.spec.whatwg.org/#fetch-method,\n // init.duplex must be set when body is a ReadableStream object.\n // currently \"half\" is the only valid value.\n if (streaming) {\n (requestInit as any).duplex = \"half\";\n }\n /**\n * Developers of the future:\n * Do not set redirect: \"manual\" as part\n * of request options.\n * It will not work as you expect.\n */\n const response = await fetch(request.url, requestInit);\n // If we're uploading a blob, we need to fire the progress event manually\n if (isBlob(request.body) && request.onUploadProgress) {\n request.onUploadProgress({ loadedBytes: request.body.size });\n }\n return buildPipelineResponse(response, request, abortControllerCleanup);\n } catch (e) {\n abortControllerCleanup?.();\n throw e;\n }\n}\n\n/**\n * Creates a pipeline response from a Fetch response;\n */\nasync function buildPipelineResponse(\n httpResponse: Response,\n request: PipelineRequest,\n abortControllerCleanup?: () => void,\n): Promise<PipelineResponse> {\n const headers = buildPipelineHeaders(httpResponse);\n const response: PipelineResponse = {\n request,\n headers,\n status: httpResponse.status,\n };\n\n const bodyStream = isWebReadableStream(httpResponse.body)\n ? buildBodyStream(httpResponse.body, {\n onProgress: request.onDownloadProgress,\n onEnd: abortControllerCleanup,\n })\n : httpResponse.body;\n\n if (\n // Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code\n request.streamResponseStatusCodes?.has(Number.POSITIVE_INFINITY) ||\n request.streamResponseStatusCodes?.has(response.status)\n ) {\n if (request.enableBrowserStreams) {\n response.browserStreamBody = bodyStream ?? undefined;\n } else {\n const responseStream = new Response(bodyStream);\n response.blobBody = responseStream.blob();\n abortControllerCleanup?.();\n }\n } else {\n const responseStream = new Response(bodyStream);\n\n response.bodyAsText = await responseStream.text();\n abortControllerCleanup?.();\n }\n\n return response;\n}\n\nfunction setupAbortSignal(request: PipelineRequest): {\n abortController: AbortController;\n abortControllerCleanup: (() => void) | undefined;\n} {\n const abortController = new AbortController();\n\n // Cleanup function\n let abortControllerCleanup: (() => void) | undefined;\n\n /**\n * Attach an abort listener to the request\n */\n let abortListener: ((event: any) => void) | undefined;\n if (request.abortSignal) {\n if (request.abortSignal.aborted) {\n throw new AbortError(\"The operation was aborted.\");\n }\n\n abortListener = (event: Event) => {\n if (event.type === \"abort\") {\n abortController.abort();\n }\n };\n request.abortSignal.addEventListener(\"abort\", abortListener);\n abortControllerCleanup = () => {\n if (abortListener) {\n request.abortSignal?.removeEventListener(\"abort\", abortListener);\n }\n };\n }\n\n // If a timeout was passed, call the abort signal once the time elapses\n if (request.timeout > 0) {\n setTimeout(() => {\n abortController.abort();\n }, request.timeout);\n }\n\n return { abortController, abortControllerCleanup };\n}\n\n/**\n * Gets the specific error\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\nfunction getError(e: RestError, request: PipelineRequest): RestError {\n if (e && e?.name === \"AbortError\") {\n return e;\n } else {\n return new RestError(`Error sending request: ${e.message}`, {\n code: e?.code ?? RestError.REQUEST_SEND_ERROR,\n request,\n });\n }\n}\n\n/**\n * Converts PipelineRequest headers to Fetch headers\n */\nfunction buildFetchHeaders(pipelineHeaders: PipelineHeaders): Headers {\n const headers = new Headers();\n for (const [name, value] of pipelineHeaders) {\n headers.append(name, value);\n }\n\n return headers;\n}\n\nfunction buildPipelineHeaders(httpResponse: Response): PipelineHeaders {\n const responseHeaders = createHttpHeaders();\n for (const [name, value] of httpResponse.headers) {\n responseHeaders.set(name, value);\n }\n\n return responseHeaders;\n}\n\ninterface BuildRequestBodyResponse {\n body:\n | string\n | Blob\n | ReadableStream<Uint8Array>\n | ArrayBuffer\n | ArrayBufferView\n | FormData\n | null\n | undefined;\n streaming: boolean;\n}\n\nfunction buildRequestBody(request: PipelineRequest): BuildRequestBodyResponse {\n const body = typeof request.body === \"function\" ? request.body() : request.body;\n if (isNodeReadableStream(body)) {\n throw new Error(\"Node streams are not supported in browser environment.\");\n }\n\n return isWebReadableStream(body)\n ? { streaming: true, body: buildBodyStream(body, { onProgress: request.onUploadProgress }) }\n : { streaming: false, body };\n}\n\n/**\n * Reads the request/response original stream and stream it through a new\n * ReadableStream, this is done to be able to report progress in a way that\n * all modern browsers support. TransformStreams would be an alternative,\n * however they are not yet supported by all browsers i.e Firefox\n */\nfunction buildBodyStream(\n readableStream: ReadableStream<Uint8Array>,\n options: { onProgress?: (progress: TransferProgressEvent) => void; onEnd?: () => void } = {},\n): ReadableStream<Uint8Array> {\n let loadedBytes = 0;\n const { onProgress, onEnd } = options;\n\n // If the current browser supports pipeThrough we use a TransformStream\n // to report progress\n if (isTransformStreamSupported(readableStream)) {\n return readableStream.pipeThrough(\n new TransformStream({\n transform(chunk, controller) {\n if (chunk === null) {\n controller.terminate();\n return;\n }\n\n controller.enqueue(chunk);\n loadedBytes += chunk.length;\n if (onProgress) {\n onProgress({ loadedBytes });\n }\n },\n flush() {\n onEnd?.();\n },\n }),\n );\n } else {\n // If we can't use transform streams, wrap the original stream in a new readable stream\n // and use pull to enqueue each chunk and report progress.\n const reader = readableStream.getReader();\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await reader.read();\n // When no more data needs to be consumed, break the reading\n if (done || !value) {\n onEnd?.();\n // Close the stream\n controller.close();\n reader.releaseLock();\n return;\n }\n\n loadedBytes += value?.length ?? 0;\n\n // Enqueue the next data chunk into our target stream\n controller.enqueue(value);\n\n if (onProgress) {\n onProgress({ loadedBytes });\n }\n },\n cancel(reason?: string) {\n onEnd?.();\n return reader.cancel(reason);\n },\n });\n }\n}\n\n/**\n * Create a new HttpClient instance for the browser environment.\n * @internal\n */\nexport function createFetchHttpClient(): HttpClient {\n return new FetchHttpClient();\n}\n\nfunction isTransformStreamSupported(readableStream: ReadableStream): boolean {\n return readableStream.pipeThrough !== undefined && self.TransformStream !== undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetchHttpClient.js","sourceRoot":"","sources":["../../src/fetchHttpClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAQ9D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEjF;;GAEG;AACH,SAAS,MAAM,CAAC,IAAa;IAC3B,gFAAgF;IAChF,OAAO,CAAC,OAAO,IAAI,KAAK,UAAU,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,IAAI,IAAI,YAAY,IAAI,CAAC;AAC1F,CAAC;AAED;;;GAGG;AACH,MAAM,eAAe;IACnB;;;OAGG;IACI,KAAK,CAAC,WAAW,CAAC,OAAwB;QAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAE7C,IAAI,UAAU,IAAI,CAAC,OAAO,CAAC,uBAAuB,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,CAAC,GAAG,0CAA0C,CAAC,CAAC;QAC9F,CAAC;QAED,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,WAAW,CAAC,OAAO,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,MAAM,QAAQ,CAAC,CAAC,EAAE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B,KAAK,CAAC,IAAI,CAAC,UAAU;;gBACnB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC5C,4DAA4D;gBAC5D,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACnB,KAAK,aAAL,KAAK,uBAAL,KAAK,EAAI,CAAC;oBACV,mBAAmB;oBACnB,UAAU,CAAC,KAAK,EAAE,CAAC;oBACnB,MAAM,CAAC,WAAW,EAAE,CAAC;oBACrB,OAAO;gBACT,CAAC;gBAED,WAAW,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,mCAAI,CAAC,CAAC;gBAElC,qDAAqD;gBACrD,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;gBAE1B,IAAI,UAAU,EAAE,CAAC;oBACf,UAAU,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;YACD,MAAM,CAAC,MAAe;gBACpB,KAAK,aAAL,KAAK,uBAAL,KAAK,EAAI,CAAC;gBACV,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC/B,CAAC;SACF,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,OAAO,IAAI,eAAe,EAAE,CAAC;AAC/B,CAAC;AAED,SAAS,0BAA0B,CAAC,cAA8B;IAChE,OAAO,cAAc,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,eAAe,KAAK,SAAS,CAAC;AACxF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"./abort-controller/AbortError.js\";\nimport type {\n HttpClient,\n HttpHeaders as PipelineHeaders,\n PipelineRequest,\n PipelineResponse,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { RestError } from \"./restError.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { isNodeReadableStream, isWebReadableStream } from \"./util/typeGuards.js\";\n\n/**\n * Checks if the body is a Blob or Blob-like\n */\nfunction isBlob(body: unknown): body is Blob {\n // File objects count as a type of Blob, so we want to use instanceof explicitly\n return (typeof Blob === \"function\" || typeof Blob === \"object\") && body instanceof Blob;\n}\n\n/**\n * A HttpClient implementation that uses window.fetch to send HTTP requests.\n * @internal\n */\nclass FetchHttpClient implements HttpClient {\n /**\n * Makes a request over an underlying transport layer and returns the response.\n * @param request - The request to be made.\n */\n public async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n const url = new URL(request.url);\n const isInsecure = url.protocol !== \"https:\";\n\n if (isInsecure && !request.allowInsecureConnection) {\n throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);\n }\n\n if (request.proxySettings) {\n throw new Error(\"HTTP proxy is not supported in browser environment\");\n }\n\n try {\n return await makeRequest(request);\n } catch (e: any) {\n throw getError(e, request);\n }\n }\n}\n\n/**\n * Sends a request\n */\nasync function makeRequest(request: PipelineRequest): Promise<PipelineResponse> {\n const { abortController, abortControllerCleanup } = setupAbortSignal(request);\n try {\n const headers = buildFetchHeaders(request.headers);\n const { streaming, body: requestBody } = buildRequestBody(request);\n const requestInit: RequestInit = {\n body: requestBody,\n method: request.method,\n headers: headers,\n signal: abortController.signal,\n // Cloudflare doesn't implement the full Fetch API spec\n // because of some of it doesn't make sense in the edge.\n // See https://github.com/cloudflare/workerd/issues/902\n ...(\"credentials\" in Request.prototype\n ? { credentials: request.withCredentials ? \"include\" : \"same-origin\" }\n : {}),\n ...(\"cache\" in Request.prototype ? { cache: \"no-store\" } : {}),\n };\n\n // According to https://fetch.spec.whatwg.org/#fetch-method,\n // init.duplex must be set when body is a ReadableStream object.\n // currently \"half\" is the only valid value.\n if (streaming) {\n (requestInit as any).duplex = \"half\";\n }\n /**\n * Developers of the future:\n * Do not set redirect: \"manual\" as part\n * of request options.\n * It will not work as you expect.\n */\n const response = await fetch(request.url, requestInit);\n // If we're uploading a blob, we need to fire the progress event manually\n if (isBlob(request.body) && request.onUploadProgress) {\n request.onUploadProgress({ loadedBytes: request.body.size });\n }\n return buildPipelineResponse(response, request, abortControllerCleanup);\n } catch (e) {\n abortControllerCleanup?.();\n throw e;\n }\n}\n\n/**\n * Creates a pipeline response from a Fetch response;\n */\nasync function buildPipelineResponse(\n httpResponse: Response,\n request: PipelineRequest,\n abortControllerCleanup?: () => void,\n): Promise<PipelineResponse> {\n const headers = buildPipelineHeaders(httpResponse);\n const response: PipelineResponse = {\n request,\n headers,\n status: httpResponse.status,\n };\n\n const bodyStream = isWebReadableStream(httpResponse.body)\n ? buildBodyStream(httpResponse.body, {\n onProgress: request.onDownloadProgress,\n onEnd: abortControllerCleanup,\n })\n : httpResponse.body;\n\n if (\n // Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code\n request.streamResponseStatusCodes?.has(Number.POSITIVE_INFINITY) ||\n request.streamResponseStatusCodes?.has(response.status)\n ) {\n if (request.enableBrowserStreams) {\n response.browserStreamBody = bodyStream ?? undefined;\n } else {\n const responseStream = new Response(bodyStream);\n response.blobBody = responseStream.blob();\n abortControllerCleanup?.();\n }\n } else {\n const responseStream = new Response(bodyStream);\n\n response.bodyAsText = await responseStream.text();\n abortControllerCleanup?.();\n }\n\n return response;\n}\n\nfunction setupAbortSignal(request: PipelineRequest): {\n abortController: AbortController;\n abortControllerCleanup: (() => void) | undefined;\n} {\n const abortController = new AbortController();\n\n // Cleanup function\n let abortControllerCleanup: (() => void) | undefined;\n\n /**\n * Attach an abort listener to the request\n */\n let abortListener: ((event: any) => void) | undefined;\n if (request.abortSignal) {\n if (request.abortSignal.aborted) {\n throw new AbortError(\"The operation was aborted.\");\n }\n\n abortListener = (event: Event) => {\n if (event.type === \"abort\") {\n abortController.abort();\n }\n };\n request.abortSignal.addEventListener(\"abort\", abortListener);\n abortControllerCleanup = () => {\n if (abortListener) {\n request.abortSignal?.removeEventListener(\"abort\", abortListener);\n }\n };\n }\n\n // If a timeout was passed, call the abort signal once the time elapses\n if (request.timeout > 0) {\n setTimeout(() => {\n abortController.abort();\n }, request.timeout);\n }\n\n return { abortController, abortControllerCleanup };\n}\n\n/**\n * Gets the specific error\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters\nfunction getError(e: RestError, request: PipelineRequest): RestError {\n if (e && e?.name === \"AbortError\") {\n return e;\n } else {\n return new RestError(`Error sending request: ${e.message}`, {\n code: e?.code ?? RestError.REQUEST_SEND_ERROR,\n request,\n });\n }\n}\n\n/**\n * Converts PipelineRequest headers to Fetch headers\n */\nfunction buildFetchHeaders(pipelineHeaders: PipelineHeaders): Headers {\n const headers = new Headers();\n for (const [name, value] of pipelineHeaders) {\n headers.append(name, value);\n }\n\n return headers;\n}\n\nfunction buildPipelineHeaders(httpResponse: Response): PipelineHeaders {\n const responseHeaders = createHttpHeaders();\n for (const [name, value] of httpResponse.headers) {\n responseHeaders.set(name, value);\n }\n\n return responseHeaders;\n}\n\ninterface BuildRequestBodyResponse {\n body:\n | string\n | Blob\n | ReadableStream<Uint8Array>\n | ArrayBuffer\n | ArrayBufferView\n | FormData\n | null\n | undefined;\n streaming: boolean;\n}\n\nfunction buildRequestBody(request: PipelineRequest): BuildRequestBodyResponse {\n const body = typeof request.body === \"function\" ? request.body() : request.body;\n if (isNodeReadableStream(body)) {\n throw new Error(\"Node streams are not supported in browser environment.\");\n }\n\n return isWebReadableStream(body)\n ? { streaming: true, body: buildBodyStream(body, { onProgress: request.onUploadProgress }) }\n : { streaming: false, body };\n}\n\n/**\n * Reads the request/response original stream and stream it through a new\n * ReadableStream, this is done to be able to report progress in a way that\n * all modern browsers support. TransformStreams would be an alternative,\n * however they are not yet supported by all browsers i.e Firefox\n */\nfunction buildBodyStream(\n readableStream: ReadableStream<Uint8Array>,\n options: { onProgress?: (progress: TransferProgressEvent) => void; onEnd?: () => void } = {},\n): ReadableStream<Uint8Array> {\n let loadedBytes = 0;\n const { onProgress, onEnd } = options;\n\n // If the current browser supports pipeThrough we use a TransformStream\n // to report progress\n if (isTransformStreamSupported(readableStream)) {\n return readableStream.pipeThrough(\n new TransformStream({\n transform(chunk, controller) {\n if (chunk === null) {\n controller.terminate();\n return;\n }\n\n controller.enqueue(chunk);\n loadedBytes += chunk.length;\n if (onProgress) {\n onProgress({ loadedBytes });\n }\n },\n flush() {\n onEnd?.();\n },\n }),\n );\n } else {\n // If we can't use transform streams, wrap the original stream in a new readable stream\n // and use pull to enqueue each chunk and report progress.\n const reader = readableStream.getReader();\n return new ReadableStream({\n async pull(controller) {\n const { done, value } = await reader.read();\n // When no more data needs to be consumed, break the reading\n if (done || !value) {\n onEnd?.();\n // Close the stream\n controller.close();\n reader.releaseLock();\n return;\n }\n\n loadedBytes += value?.length ?? 0;\n\n // Enqueue the next data chunk into our target stream\n controller.enqueue(value);\n\n if (onProgress) {\n onProgress({ loadedBytes });\n }\n },\n cancel(reason?: string) {\n onEnd?.();\n return reader.cancel(reason);\n },\n });\n }\n}\n\n/**\n * Create a new HttpClient instance for the browser environment.\n * @internal\n */\nexport function createFetchHttpClient(): HttpClient {\n return new FetchHttpClient();\n}\n\nfunction isTransformStreamSupported(readableStream: ReadableStream): boolean {\n return readableStream.pipeThrough !== undefined && self.TransformStream !== undefined;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpHeaders, RawHttpHeadersInput } from "./interfaces.js";
|
|
1
|
+
import type { HttpHeaders, RawHttpHeadersInput } from "./interfaces.js";
|
|
2
2
|
/**
|
|
3
3
|
* Creates an object that satisfies the `HttpHeaders` interface.
|
|
4
4
|
* @param rawHeaders - A simple object representing initial headers
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpHeaders.d.ts","sourceRoot":"","sources":["../../src/httpHeaders.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAkB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"httpHeaders.d.ts","sourceRoot":"","sources":["../../src/httpHeaders.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAkB,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAiGxF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,CAAC,EAAE,mBAAmB,GAAG,WAAW,CAE/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpHeaders.js","sourceRoot":"","sources":["../../src/httpHeaders.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC;AAED,QAAQ,CAAC,CAAC,cAAc,CAAC,GAA6B;IACpD,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,MAAM,eAAe;IAGnB,YAAY,UAAiD;QAC3D,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;QAClD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACjD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,IAAY,EAAE,KAAgC;QACvD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACnF,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,IAAY;;QACrB,OAA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AC,CAAC;AACzC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { HttpHeaders, RawHttpHeaders, RawHttpHeadersInput } from \"./interfaces.js\";\n\ninterface HeaderEntry {\n name: string;\n value: string;\n}\n\nfunction normalizeName(name: string): string {\n return name.toLowerCase();\n}\n\nfunction* headerIterator(map: Map<string, HeaderEntry>): IterableIterator<[string, string]> {\n for (const entry of map.values()) {\n yield [entry.name, entry.value];\n }\n}\n\nclass HttpHeadersImpl implements HttpHeaders {\n private readonly _headersMap: Map<string, HeaderEntry>;\n\n constructor(rawHeaders?: RawHttpHeaders | RawHttpHeadersInput) {\n this._headersMap = new Map<string, HeaderEntry>();\n if (rawHeaders) {\n for (const headerName of Object.keys(rawHeaders)) {\n this.set(headerName, rawHeaders[headerName]);\n }\n }\n }\n\n /**\n * Set a header in this collection with the provided name and value. The name is\n * case-insensitive.\n * @param name - The name of the header to set. This value is case-insensitive.\n * @param value - The value of the header to set.\n */\n public set(name: string, value: string | number | boolean): void {\n this._headersMap.set(normalizeName(name), { name, value: String(value).trim() });\n }\n\n /**\n * Get the header value for the provided header name, or undefined if no header exists in this\n * collection with the provided name.\n * @param name - The name of the header. This value is case-insensitive.\n */\n public get(name: string): string | undefined {\n return this._headersMap.get(normalizeName(name))?.value;\n }\n\n /**\n * Get whether or not this header collection contains a header entry for the provided header name.\n * @param name - The name of the header to set. This value is case-insensitive.\n */\n public has(name: string): boolean {\n return this._headersMap.has(normalizeName(name));\n }\n\n /**\n * Remove the header with the provided headerName.\n * @param name - The name of the header to remove.\n */\n public delete(name: string): void {\n this._headersMap.delete(normalizeName(name));\n }\n\n /**\n * Get the JSON object representation of this HTTP header collection.\n */\n public toJSON(options: { preserveCase?: boolean } = {}): RawHttpHeaders {\n const result: RawHttpHeaders = {};\n if (options.preserveCase) {\n for (const entry of this._headersMap.values()) {\n result[entry.name] = entry.value;\n }\n } else {\n for (const [normalizedName, entry] of this._headersMap) {\n result[normalizedName] = entry.value;\n }\n }\n\n return result;\n }\n\n /**\n * Get the string representation of this HTTP header collection.\n */\n public toString(): string {\n return JSON.stringify(this.toJSON({ preserveCase: true }));\n }\n\n /**\n * Iterate over tuples of header [name, value] pairs.\n */\n [Symbol.iterator](): Iterator<[string, string]> {\n return headerIterator(this._headersMap);\n }\n}\n\n/**\n * Creates an object that satisfies the `HttpHeaders` interface.\n * @param rawHeaders - A simple object representing initial headers\n */\nexport function createHttpHeaders(rawHeaders?: RawHttpHeadersInput): HttpHeaders {\n return new HttpHeadersImpl(rawHeaders);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"httpHeaders.js","sourceRoot":"","sources":["../../src/httpHeaders.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;AAC5B,CAAC;AAED,QAAQ,CAAC,CAAC,cAAc,CAAC,GAA6B;IACpD,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,MAAM,eAAe;IAGnB,YAAY,UAAiD;QAC3D,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,EAAuB,CAAC;QAClD,IAAI,UAAU,EAAE,CAAC;YACf,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;gBACjD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,IAAY,EAAE,KAAgC;QACvD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MA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AC,CAAC;IAC1C,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAgC;IAChE,OAAO,IAAI,eAAe,CAAC,UAAU,CAAC,CAAC;AACzC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpHeaders, RawHttpHeaders, RawHttpHeadersInput } from \"./interfaces.js\";\n\ninterface HeaderEntry {\n name: string;\n value: string;\n}\n\nfunction normalizeName(name: string): string {\n return name.toLowerCase();\n}\n\nfunction* headerIterator(map: Map<string, HeaderEntry>): IterableIterator<[string, string]> {\n for (const entry of map.values()) {\n yield [entry.name, entry.value];\n }\n}\n\nclass HttpHeadersImpl implements HttpHeaders {\n private readonly _headersMap: Map<string, HeaderEntry>;\n\n constructor(rawHeaders?: RawHttpHeaders | RawHttpHeadersInput) {\n this._headersMap = new Map<string, HeaderEntry>();\n if (rawHeaders) {\n for (const headerName of Object.keys(rawHeaders)) {\n this.set(headerName, rawHeaders[headerName]);\n }\n }\n }\n\n /**\n * Set a header in this collection with the provided name and value. The name is\n * case-insensitive.\n * @param name - The name of the header to set. This value is case-insensitive.\n * @param value - The value of the header to set.\n */\n public set(name: string, value: string | number | boolean): void {\n this._headersMap.set(normalizeName(name), { name, value: String(value).trim() });\n }\n\n /**\n * Get the header value for the provided header name, or undefined if no header exists in this\n * collection with the provided name.\n * @param name - The name of the header. This value is case-insensitive.\n */\n public get(name: string): string | undefined {\n return this._headersMap.get(normalizeName(name))?.value;\n }\n\n /**\n * Get whether or not this header collection contains a header entry for the provided header name.\n * @param name - The name of the header to set. This value is case-insensitive.\n */\n public has(name: string): boolean {\n return this._headersMap.has(normalizeName(name));\n }\n\n /**\n * Remove the header with the provided headerName.\n * @param name - The name of the header to remove.\n */\n public delete(name: string): void {\n this._headersMap.delete(normalizeName(name));\n }\n\n /**\n * Get the JSON object representation of this HTTP header collection.\n */\n public toJSON(options: { preserveCase?: boolean } = {}): RawHttpHeaders {\n const result: RawHttpHeaders = {};\n if (options.preserveCase) {\n for (const entry of this._headersMap.values()) {\n result[entry.name] = entry.value;\n }\n } else {\n for (const [normalizedName, entry] of this._headersMap) {\n result[normalizedName] = entry.value;\n }\n }\n\n return result;\n }\n\n /**\n * Get the string representation of this HTTP header collection.\n */\n public toString(): string {\n return JSON.stringify(this.toJSON({ preserveCase: true }));\n }\n\n /**\n * Iterate over tuples of header [name, value] pairs.\n */\n [Symbol.iterator](): Iterator<[string, string]> {\n return headerIterator(this._headersMap);\n }\n}\n\n/**\n * Creates an object that satisfies the `HttpHeaders` interface.\n * @param rawHeaders - A simple object representing initial headers\n */\nexport function createHttpHeaders(rawHeaders?: RawHttpHeadersInput): HttpHeaders {\n return new HttpHeadersImpl(rawHeaders);\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbortSignalLike } from "./abort-controller/AbortSignalLike.js";
|
|
2
|
-
import { OperationTracingOptions } from "./tracing/interfaces.js";
|
|
1
|
+
import type { AbortSignalLike } from "./abort-controller/AbortSignalLike.js";
|
|
2
|
+
import type { OperationTracingOptions } from "./tracing/interfaces.js";
|
|
3
3
|
/**
|
|
4
4
|
* A HttpHeaders collection represented as a simple JSON object.
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAE9D;;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,MAAM,CAAC,GAAG,SAAS,CAAC;IAC1D;;;;;;;;;;OAUG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC;IAC5D;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;IAC9D;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,SAAS,CAAC;CACxE;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortSignalLike } from \"./abort-controller/AbortSignalLike.js\";\nimport { OperationTracingOptions } from \"./tracing/interfaces.js\";\n\n/**\n * A HttpHeaders collection represented as a simple JSON object.\n */\nexport type RawHttpHeaders = { [headerName: string]: string };\n\n/**\n * A HttpHeaders collection for input, represented as a simple JSON object.\n */\nexport type RawHttpHeadersInput = Record<string, string | number | boolean>;\n\n/**\n * Represents a set of HTTP headers on a request/response.\n * Header names are treated as case insensitive.\n */\nexport interface HttpHeaders extends Iterable<[string, string]> {\n /**\n * Returns the value of a specific header or undefined if not set.\n * @param name - The name of the header to retrieve.\n */\n get(name: string): string | undefined;\n /**\n * Returns true if the specified header exists.\n * @param name - The name of the header to check.\n */\n has(name: string): boolean;\n /**\n * Sets a specific header with a given value.\n * @param name - The name of the header to set.\n * @param value - The value to use for the header.\n */\n set(name: string, value: string | number | boolean): void;\n /**\n * Removes a specific header from the collection.\n * @param name - The name of the header to delete.\n */\n delete(name: string): void;\n /**\n * Accesses a raw JS object that acts as a simple map\n * of header names to values.\n */\n toJSON(options?: { preserveCase?: boolean }): RawHttpHeaders;\n}\n\n/**\n * A part of the request body in a multipart request.\n */\nexport interface BodyPart {\n /**\n * The headers for this part of the multipart request.\n */\n headers: HttpHeaders;\n\n /**\n * The body of this part of the multipart request.\n */\n body:\n | ((() => ReadableStream<Uint8Array>) | (() => NodeJS.ReadableStream))\n | ReadableStream<Uint8Array>\n | NodeJS.ReadableStream\n | Uint8Array\n | Blob;\n}\n\n/**\n * A request body consisting of multiple parts.\n */\nexport interface MultipartRequestBody {\n /**\n * The parts of the request body.\n */\n parts: BodyPart[];\n\n /**\n * The boundary separating each part of the request body.\n * If not specified, a random boundary will be generated.\n *\n * When specified, '--' will be prepended to the boundary in the request to ensure the boundary follows the specification.\n */\n boundary?: string;\n}\n\n/**\n * Types of bodies supported on the request.\n * NodeJS.ReadableStream and () =\\> NodeJS.ReadableStream is Node only.\n * Blob, ReadableStream<Uint8Array>, and () =\\> ReadableStream<Uint8Array> are browser only.\n */\nexport type RequestBodyType =\n | NodeJS.ReadableStream\n | (() => NodeJS.ReadableStream)\n | ReadableStream<Uint8Array>\n | (() => ReadableStream<Uint8Array>)\n | Blob\n | ArrayBuffer\n | ArrayBufferView\n | FormData\n | string\n | null;\n\n/**\n * An interface compatible with NodeJS's `http.Agent`.\n * We want to avoid publicly re-exporting the actual interface,\n * since it might vary across runtime versions.\n */\nexport interface Agent {\n /**\n * Destroy any sockets that are currently in use by the agent.\n */\n destroy(): void;\n /**\n * For agents with keepAlive enabled, this sets the maximum number of sockets that will be left open in the free state.\n */\n maxFreeSockets: number;\n /**\n * Determines how many concurrent sockets the agent can have open per origin.\n */\n maxSockets: number;\n /**\n * An object which contains queues of requests that have not yet been assigned to sockets.\n */\n requests: unknown;\n /**\n * An object which contains arrays of sockets currently in use by the agent.\n */\n sockets: unknown;\n}\n\n/**\n * Metadata about a request being made by the pipeline.\n */\nexport interface PipelineRequest {\n /**\n * The URL to make the request to.\n */\n url: string;\n\n /**\n * The HTTP method to use when making the request.\n */\n method: HttpMethods;\n\n /**\n * The HTTP headers to use when making the request.\n */\n headers: HttpHeaders;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n * If the request is terminated, an `AbortError` is thrown.\n * Defaults to 0, which disables the timeout.\n */\n timeout: number;\n\n /**\n * Indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests.\n * Defaults to false.\n */\n withCredentials: boolean;\n\n /**\n * A unique identifier for the request. Used for logging and tracing.\n */\n requestId: string;\n\n /**\n * The HTTP body content (if any)\n */\n body?: RequestBodyType;\n\n /**\n * Body for a multipart request.\n */\n multipartBody?: MultipartRequestBody;\n\n /**\n * To simulate a browser form post\n */\n formData?: FormDataMap;\n\n /**\n * A list of response status codes whose corresponding PipelineResponse body should be treated as a stream.\n * When streamResponseStatusCodes contains the value Number.POSITIVE_INFINITY any status would be treated as a stream.\n */\n streamResponseStatusCodes?: Set<number>;\n\n /**\n * Proxy configuration.\n */\n proxySettings?: ProxySettings;\n\n /**\n * If the connection should not be reused.\n */\n disableKeepAlive?: boolean;\n\n /**\n * Used to abort the request later.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Tracing options to use for any created Spans.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Callback which fires upon download progress. */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n\n /**\n * NODEJS ONLY\n *\n * A Node-only option to provide a custom `http.Agent`/`https.Agent`.\n * Does nothing when running in the browser.\n */\n agent?: Agent;\n\n /**\n * BROWSER ONLY\n *\n * A browser only option to enable browser Streams. If this option is set and a response is a stream\n * the response will have a property `browserStream` instead of `blobBody` which will be undefined.\n *\n * Default value is false\n */\n enableBrowserStreams?: boolean;\n\n /** Settings for configuring TLS authentication */\n tlsSettings?: TlsSettings;\n}\n\n/**\n * Metadata about a response received by the pipeline.\n */\nexport interface PipelineResponse {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP status code of the response.\n */\n status: number;\n /**\n * The HTTP response headers.\n */\n headers: HttpHeaders;\n\n /**\n * The response body as text (string format)\n */\n bodyAsText?: string | null;\n\n /**\n * BROWSER ONLY\n *\n * The response body as a browser Blob.\n * Always undefined in node.js.\n */\n blobBody?: Promise<Blob>;\n\n /**\n * BROWSER ONLY\n *\n * The response body as a browser ReadableStream.\n * Always undefined in node.js.\n */\n browserStreamBody?: ReadableStream<Uint8Array>;\n\n /**\n * NODEJS ONLY\n *\n * The response body as a node.js Readable stream.\n * Always undefined in the browser.\n */\n readableStreamBody?: NodeJS.ReadableStream;\n}\n\n/**\n * A simple interface for making a pipeline request and receiving a response.\n */\nexport type SendRequest = (request: PipelineRequest) => Promise<PipelineResponse>;\n\n/**\n * The required interface for a client that makes HTTP requests\n * on behalf of a pipeline.\n */\nexport interface HttpClient {\n /**\n * The method that makes the request and returns a response.\n */\n sendRequest: SendRequest;\n}\n\n/**\n * Fired in response to upload or download progress.\n */\nexport type TransferProgressEvent = {\n /**\n * The number of bytes loaded so far.\n */\n loadedBytes: number;\n};\n\n// UNBRANDED DIFFERENCE: HttpMethods are defined at the top level in unbranded instead of core-util since we don't\n// need to worry about creating a cyclic dependency\n/**\n * Supported HTTP methods to use when making requests.\n */\nexport type HttpMethods =\n | \"GET\"\n | \"PUT\"\n | \"POST\"\n | \"DELETE\"\n | \"PATCH\"\n | \"HEAD\"\n | \"OPTIONS\"\n | \"TRACE\";\n\n/**\n * Options to configure a proxy for outgoing requests (Node.js only).\n */\nexport interface ProxySettings {\n /**\n * The proxy's host address.\n */\n host: string;\n\n /**\n * The proxy host's port.\n */\n port: number;\n\n /**\n * The user name to authenticate with the proxy, if required.\n */\n username?: string;\n\n /**\n * The password to authenticate with the proxy, if required.\n */\n password?: string;\n}\n\n/**\n * Each form data entry can be a string, Blob, or a File. If you wish to pass a file with a name but do not have\n * access to the File class, you can use the createFile helper to create one.\n */\nexport type FormDataValue = string | Blob | File;\n\n/**\n * A simple object that provides form data, as if from a browser form.\n */\nexport type FormDataMap = { [key: string]: FormDataValue | FormDataValue[] };\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface PipelineRetryOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second). The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * Represents a certificate credential for authentication.\n */\nexport interface CertificateCredential {\n /**\n * Optionally override the trusted CA certificates. Default is to trust\n * the well-known CAs curated by Mozilla. Mozilla's CAs are completely\n * replaced when CAs are explicitly specified using this option.\n */\n ca?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Cert chains in PEM format. One cert chain should be provided per\n * private key. Each cert chain should consist of the PEM formatted\n * certificate for a provided private key, followed by the PEM\n * formatted intermediate certificates (if any), in order, and not\n * including the root CA (the root CA must be pre-known to the peer,\n * see ca). When providing multiple cert chains, they do not have to\n * be in the same order as their private keys in key. If the\n * intermediate certificates are not provided, the peer will not be\n * able to validate the certificate, and the handshake will fail.\n */\n cert?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Private keys in PEM format. PEM allows the option of private keys\n * being encrypted. Encrypted keys will be decrypted with\n * options.passphrase. Multiple keys using different algorithms can be\n * provided either as an array of unencrypted key strings or buffers,\n * or an array of objects in the form `{pem: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n key?: string | Buffer | Array<Buffer | KeyObject> | undefined;\n /**\n * Shared passphrase used for a single private key and/or a PFX.\n */\n passphrase?: string | undefined;\n /**\n * PFX or PKCS12 encoded private key and certificate chain. pfx is an\n * alternative to providing key and cert individually. PFX is usually\n * encrypted, if it is, passphrase will be used to decrypt it. Multiple\n * PFX can be provided either as an array of unencrypted PFX buffers,\n * or an array of objects in the form `{buf: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted PFX will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n pfx?: string | Buffer | Array<string | Buffer | PxfObject> | undefined;\n}\n\n/**\n * Represents a certificate for TLS authentication.\n */\nexport interface TlsSettings {\n /**\n * Optionally override the trusted CA certificates. Default is to trust\n * the well-known CAs curated by Mozilla. Mozilla's CAs are completely\n * replaced when CAs are explicitly specified using this option.\n */\n ca?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Cert chains in PEM format. One cert chain should be provided per\n * private key. Each cert chain should consist of the PEM formatted\n * certificate for a provided private key, followed by the PEM\n * formatted intermediate certificates (if any), in order, and not\n * including the root CA (the root CA must be pre-known to the peer,\n * see ca). When providing multiple cert chains, they do not have to\n * be in the same order as their private keys in key. If the\n * intermediate certificates are not provided, the peer will not be\n * able to validate the certificate, and the handshake will fail.\n */\n cert?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Private keys in PEM format. PEM allows the option of private keys\n * being encrypted. Encrypted keys will be decrypted with\n * options.passphrase. Multiple keys using different algorithms can be\n * provided either as an array of unencrypted key strings or buffers,\n * or an array of objects in the form `{pem: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n key?: string | Buffer | Array<Buffer | KeyObject> | undefined;\n /**\n * Shared passphrase used for a single private key and/or a PFX.\n */\n passphrase?: string | undefined;\n /**\n * PFX or PKCS12 encoded private key and certificate chain. pfx is an\n * alternative to providing key and cert individually. PFX is usually\n * encrypted, if it is, passphrase will be used to decrypt it. Multiple\n * PFX can be provided either as an array of unencrypted PFX buffers,\n * or an array of objects in the form `{buf: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted PFX will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n pfx?: string | Buffer | Array<string | Buffer | PxfObject> | undefined;\n}\n\n/**\n * An interface compatible with NodeJS's `tls.KeyObject`.\n * We want to avoid publicly re-exporting the actual interface,\n * since it might vary across runtime versions.\n */\nexport interface KeyObject {\n /**\n * Private keys in PEM format.\n */\n pem: string | Buffer;\n /**\n * Optional passphrase.\n */\n passphrase?: string | undefined;\n}\n\n/**\n * An interface compatible with NodeJS's `tls.PxfObject`.\n * We want to avoid publicly re-exporting the actual interface,\n * since it might vary across runtime versions.\n */\nexport interface PxfObject {\n /**\n * PFX or PKCS12 encoded private key and certificate chain.\n */\n buf: string | Buffer;\n /**\n * Optional passphrase.\n */\n passphrase?: string | undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"./abort-controller/AbortSignalLike.js\";\nimport type { OperationTracingOptions } from \"./tracing/interfaces.js\";\n\n/**\n * A HttpHeaders collection represented as a simple JSON object.\n */\nexport type RawHttpHeaders = { [headerName: string]: string };\n\n/**\n * A HttpHeaders collection for input, represented as a simple JSON object.\n */\nexport type RawHttpHeadersInput = Record<string, string | number | boolean>;\n\n/**\n * Represents a set of HTTP headers on a request/response.\n * Header names are treated as case insensitive.\n */\nexport interface HttpHeaders extends Iterable<[string, string]> {\n /**\n * Returns the value of a specific header or undefined if not set.\n * @param name - The name of the header to retrieve.\n */\n get(name: string): string | undefined;\n /**\n * Returns true if the specified header exists.\n * @param name - The name of the header to check.\n */\n has(name: string): boolean;\n /**\n * Sets a specific header with a given value.\n * @param name - The name of the header to set.\n * @param value - The value to use for the header.\n */\n set(name: string, value: string | number | boolean): void;\n /**\n * Removes a specific header from the collection.\n * @param name - The name of the header to delete.\n */\n delete(name: string): void;\n /**\n * Accesses a raw JS object that acts as a simple map\n * of header names to values.\n */\n toJSON(options?: { preserveCase?: boolean }): RawHttpHeaders;\n}\n\n/**\n * A part of the request body in a multipart request.\n */\nexport interface BodyPart {\n /**\n * The headers for this part of the multipart request.\n */\n headers: HttpHeaders;\n\n /**\n * The body of this part of the multipart request.\n */\n body:\n | ((() => ReadableStream<Uint8Array>) | (() => NodeJS.ReadableStream))\n | ReadableStream<Uint8Array>\n | NodeJS.ReadableStream\n | Uint8Array\n | Blob;\n}\n\n/**\n * A request body consisting of multiple parts.\n */\nexport interface MultipartRequestBody {\n /**\n * The parts of the request body.\n */\n parts: BodyPart[];\n\n /**\n * The boundary separating each part of the request body.\n * If not specified, a random boundary will be generated.\n *\n * When specified, '--' will be prepended to the boundary in the request to ensure the boundary follows the specification.\n */\n boundary?: string;\n}\n\n/**\n * Types of bodies supported on the request.\n * NodeJS.ReadableStream and () =\\> NodeJS.ReadableStream is Node only.\n * Blob, ReadableStream<Uint8Array>, and () =\\> ReadableStream<Uint8Array> are browser only.\n */\nexport type RequestBodyType =\n | NodeJS.ReadableStream\n | (() => NodeJS.ReadableStream)\n | ReadableStream<Uint8Array>\n | (() => ReadableStream<Uint8Array>)\n | Blob\n | ArrayBuffer\n | ArrayBufferView\n | FormData\n | string\n | null;\n\n/**\n * An interface compatible with NodeJS's `http.Agent`.\n * We want to avoid publicly re-exporting the actual interface,\n * since it might vary across runtime versions.\n */\nexport interface Agent {\n /**\n * Destroy any sockets that are currently in use by the agent.\n */\n destroy(): void;\n /**\n * For agents with keepAlive enabled, this sets the maximum number of sockets that will be left open in the free state.\n */\n maxFreeSockets: number;\n /**\n * Determines how many concurrent sockets the agent can have open per origin.\n */\n maxSockets: number;\n /**\n * An object which contains queues of requests that have not yet been assigned to sockets.\n */\n requests: unknown;\n /**\n * An object which contains arrays of sockets currently in use by the agent.\n */\n sockets: unknown;\n}\n\n/**\n * Metadata about a request being made by the pipeline.\n */\nexport interface PipelineRequest {\n /**\n * The URL to make the request to.\n */\n url: string;\n\n /**\n * The HTTP method to use when making the request.\n */\n method: HttpMethods;\n\n /**\n * The HTTP headers to use when making the request.\n */\n headers: HttpHeaders;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n * If the request is terminated, an `AbortError` is thrown.\n * Defaults to 0, which disables the timeout.\n */\n timeout: number;\n\n /**\n * Indicates whether the user agent should send cookies from the other domain in the case of cross-origin requests.\n * Defaults to false.\n */\n withCredentials: boolean;\n\n /**\n * A unique identifier for the request. Used for logging and tracing.\n */\n requestId: string;\n\n /**\n * The HTTP body content (if any)\n */\n body?: RequestBodyType;\n\n /**\n * Body for a multipart request.\n */\n multipartBody?: MultipartRequestBody;\n\n /**\n * To simulate a browser form post\n */\n formData?: FormDataMap;\n\n /**\n * A list of response status codes whose corresponding PipelineResponse body should be treated as a stream.\n * When streamResponseStatusCodes contains the value Number.POSITIVE_INFINITY any status would be treated as a stream.\n */\n streamResponseStatusCodes?: Set<number>;\n\n /**\n * Proxy configuration.\n */\n proxySettings?: ProxySettings;\n\n /**\n * If the connection should not be reused.\n */\n disableKeepAlive?: boolean;\n\n /**\n * Used to abort the request later.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Tracing options to use for any created Spans.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Callback which fires upon download progress. */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n\n /**\n * NODEJS ONLY\n *\n * A Node-only option to provide a custom `http.Agent`/`https.Agent`.\n * Does nothing when running in the browser.\n */\n agent?: Agent;\n\n /**\n * BROWSER ONLY\n *\n * A browser only option to enable browser Streams. If this option is set and a response is a stream\n * the response will have a property `browserStream` instead of `blobBody` which will be undefined.\n *\n * Default value is false\n */\n enableBrowserStreams?: boolean;\n\n /** Settings for configuring TLS authentication */\n tlsSettings?: TlsSettings;\n}\n\n/**\n * Metadata about a response received by the pipeline.\n */\nexport interface PipelineResponse {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP status code of the response.\n */\n status: number;\n /**\n * The HTTP response headers.\n */\n headers: HttpHeaders;\n\n /**\n * The response body as text (string format)\n */\n bodyAsText?: string | null;\n\n /**\n * BROWSER ONLY\n *\n * The response body as a browser Blob.\n * Always undefined in node.js.\n */\n blobBody?: Promise<Blob>;\n\n /**\n * BROWSER ONLY\n *\n * The response body as a browser ReadableStream.\n * Always undefined in node.js.\n */\n browserStreamBody?: ReadableStream<Uint8Array>;\n\n /**\n * NODEJS ONLY\n *\n * The response body as a node.js Readable stream.\n * Always undefined in the browser.\n */\n readableStreamBody?: NodeJS.ReadableStream;\n}\n\n/**\n * A simple interface for making a pipeline request and receiving a response.\n */\nexport type SendRequest = (request: PipelineRequest) => Promise<PipelineResponse>;\n\n/**\n * The required interface for a client that makes HTTP requests\n * on behalf of a pipeline.\n */\nexport interface HttpClient {\n /**\n * The method that makes the request and returns a response.\n */\n sendRequest: SendRequest;\n}\n\n/**\n * Fired in response to upload or download progress.\n */\nexport type TransferProgressEvent = {\n /**\n * The number of bytes loaded so far.\n */\n loadedBytes: number;\n};\n\n// UNBRANDED DIFFERENCE: HttpMethods are defined at the top level in unbranded instead of core-util since we don't\n// need to worry about creating a cyclic dependency\n/**\n * Supported HTTP methods to use when making requests.\n */\nexport type HttpMethods =\n | \"GET\"\n | \"PUT\"\n | \"POST\"\n | \"DELETE\"\n | \"PATCH\"\n | \"HEAD\"\n | \"OPTIONS\"\n | \"TRACE\";\n\n/**\n * Options to configure a proxy for outgoing requests (Node.js only).\n */\nexport interface ProxySettings {\n /**\n * The proxy's host address.\n */\n host: string;\n\n /**\n * The proxy host's port.\n */\n port: number;\n\n /**\n * The user name to authenticate with the proxy, if required.\n */\n username?: string;\n\n /**\n * The password to authenticate with the proxy, if required.\n */\n password?: string;\n}\n\n/**\n * Each form data entry can be a string, Blob, or a File. If you wish to pass a file with a name but do not have\n * access to the File class, you can use the createFile helper to create one.\n */\nexport type FormDataValue = string | Blob | File;\n\n/**\n * A simple object that provides form data, as if from a browser form.\n */\nexport type FormDataMap = { [key: string]: FormDataValue | FormDataValue[] };\n\n/**\n * Options that control how to retry failed requests.\n */\nexport interface PipelineRetryOptions {\n /**\n * The maximum number of retry attempts. Defaults to 3.\n */\n maxRetries?: number;\n\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second). The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n}\n\n/**\n * Represents a certificate credential for authentication.\n */\nexport interface CertificateCredential {\n /**\n * Optionally override the trusted CA certificates. Default is to trust\n * the well-known CAs curated by Mozilla. Mozilla's CAs are completely\n * replaced when CAs are explicitly specified using this option.\n */\n ca?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Cert chains in PEM format. One cert chain should be provided per\n * private key. Each cert chain should consist of the PEM formatted\n * certificate for a provided private key, followed by the PEM\n * formatted intermediate certificates (if any), in order, and not\n * including the root CA (the root CA must be pre-known to the peer,\n * see ca). When providing multiple cert chains, they do not have to\n * be in the same order as their private keys in key. If the\n * intermediate certificates are not provided, the peer will not be\n * able to validate the certificate, and the handshake will fail.\n */\n cert?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Private keys in PEM format. PEM allows the option of private keys\n * being encrypted. Encrypted keys will be decrypted with\n * options.passphrase. Multiple keys using different algorithms can be\n * provided either as an array of unencrypted key strings or buffers,\n * or an array of objects in the form `{pem: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n key?: string | Buffer | Array<Buffer | KeyObject> | undefined;\n /**\n * Shared passphrase used for a single private key and/or a PFX.\n */\n passphrase?: string | undefined;\n /**\n * PFX or PKCS12 encoded private key and certificate chain. pfx is an\n * alternative to providing key and cert individually. PFX is usually\n * encrypted, if it is, passphrase will be used to decrypt it. Multiple\n * PFX can be provided either as an array of unencrypted PFX buffers,\n * or an array of objects in the form `{buf: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted PFX will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n pfx?: string | Buffer | Array<string | Buffer | PxfObject> | undefined;\n}\n\n/**\n * Represents a certificate for TLS authentication.\n */\nexport interface TlsSettings {\n /**\n * Optionally override the trusted CA certificates. Default is to trust\n * the well-known CAs curated by Mozilla. Mozilla's CAs are completely\n * replaced when CAs are explicitly specified using this option.\n */\n ca?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Cert chains in PEM format. One cert chain should be provided per\n * private key. Each cert chain should consist of the PEM formatted\n * certificate for a provided private key, followed by the PEM\n * formatted intermediate certificates (if any), in order, and not\n * including the root CA (the root CA must be pre-known to the peer,\n * see ca). When providing multiple cert chains, they do not have to\n * be in the same order as their private keys in key. If the\n * intermediate certificates are not provided, the peer will not be\n * able to validate the certificate, and the handshake will fail.\n */\n cert?: string | Buffer | Array<string | Buffer> | undefined;\n /**\n * Private keys in PEM format. PEM allows the option of private keys\n * being encrypted. Encrypted keys will be decrypted with\n * options.passphrase. Multiple keys using different algorithms can be\n * provided either as an array of unencrypted key strings or buffers,\n * or an array of objects in the form `{pem: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n key?: string | Buffer | Array<Buffer | KeyObject> | undefined;\n /**\n * Shared passphrase used for a single private key and/or a PFX.\n */\n passphrase?: string | undefined;\n /**\n * PFX or PKCS12 encoded private key and certificate chain. pfx is an\n * alternative to providing key and cert individually. PFX is usually\n * encrypted, if it is, passphrase will be used to decrypt it. Multiple\n * PFX can be provided either as an array of unencrypted PFX buffers,\n * or an array of objects in the form `{buf: <string|buffer>[,passphrase: <string>]}`.\n * The object form can only occur in an array.object.passphrase is optional.\n * Encrypted PFX will be decrypted with object.passphrase if provided, or options.passphrase if it is not.\n */\n pfx?: string | Buffer | Array<string | Buffer | PxfObject> | undefined;\n}\n\n/**\n * An interface compatible with NodeJS's `tls.KeyObject`.\n * We want to avoid publicly re-exporting the actual interface,\n * since it might vary across runtime versions.\n */\nexport interface KeyObject {\n /**\n * Private keys in PEM format.\n */\n pem: string | Buffer;\n /**\n * Optional passphrase.\n */\n passphrase?: string | undefined;\n}\n\n/**\n * An interface compatible with NodeJS's `tls.PxfObject`.\n * We want to avoid publicly re-exporting the actual interface,\n * since it might vary across runtime versions.\n */\nexport interface PxfObject {\n /**\n * PFX or PKCS12 encoded private key and certificate chain.\n */\n buf: string | Buffer;\n /**\n * Optional passphrase.\n */\n passphrase?: string | undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":"AAGA,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAStC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,2BAAsD,CAAC;AAK3F;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;AAK/E;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,QAAQ,CAAC;AAenD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAgBjE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,uBAAuB,GAAG,SAAS,CAEjE;AASD;;GAEG;AAEH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,EAAE,QAAQ,CAAC;IAChB;;;;OAIG;IACH,OAAO,EAAE,QAAQ,CAAC;IAClB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;;;OAIG;IACH,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,CAS3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAA2B,CAAC;AAC7D,MAAM,eAAe,GACnB,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,IAAI,OAA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iBAAiB,GAAG,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IAED,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAE9B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,MAA+B;IACnD,OAAO,OAAO,CACZ,uBAAuB,IAAI,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,uBAAuB,CAAC,CACvF,CAAC;AACJ,CAAC;AAED,SAAS,yBAAyB,CAAC,QAAgB;IACjD,OAAO,2BAA2B,CAAC,QAAQ,CAAC,QAAe,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { Debugger } from \"./debug.js\";\nimport debug from \"./debug.js\";\nexport { Debugger } from \"./debug.js\";\n\nconst registeredLoggers = new Set<TypeSpecRuntimeDebugger>();\nconst logLevelFromEnv =\n (typeof process !== \"undefined\" && process.env && process.env.TYPESPEC_RUNTIME_LOG_LEVEL) ||\n undefined;\n\nlet typeSpecRuntimeLogLevel: TypeSpecRuntimeLogLevel | undefined;\n\n/**\n * The TypeSpecRuntimeLogger provides a mechanism for overriding where logs are output to.\n * By default, logs are sent to stderr.\n * Override the `log` method to redirect logs to another location.\n */\nexport const TypeSpecRuntimeLogger: TypeSpecRuntimeClientLogger = debug(\"typeSpecRuntime\");\nTypeSpecRuntimeLogger.log = (...args) => {\n debug.log(...args);\n};\n\n/**\n * The log levels supported by the logger.\n * The log levels in order of most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\nexport type TypeSpecRuntimeLogLevel = \"verbose\" | \"info\" | \"warning\" | \"error\";\nconst TYPESPEC_RUNTIME_LOG_LEVELS = [\"verbose\", \"info\", \"warning\", \"error\"];\n\ntype TypeSpecRuntimeDebugger = Debugger & { level: TypeSpecRuntimeLogLevel };\n\n/**\n * An TypeSpecRuntimeClientLogger is a function that can log to an appropriate severity level.\n */\nexport type TypeSpecRuntimeClientLogger = Debugger;\n\nif (logLevelFromEnv) {\n // avoid calling setLogLevel because we don't want a mis-set environment variable to crash\n if (isTypeSpecRuntimeLogLevel(logLevelFromEnv)) {\n setLogLevel(logLevelFromEnv);\n } else {\n console.error(\n `TYPESPEC_RUNTIME_LOG_LEVEL set to unknown log level '${logLevelFromEnv}'; logging is not enabled. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\n \", \",\n )}.`,\n );\n }\n}\n\n/**\n * Immediately enables logging at the specified log level. If no level is specified, logging is disabled.\n * @param level - The log level to enable for logging.\n * Options from most verbose to least verbose are:\n * - verbose\n * - info\n * - warning\n * - error\n */\nexport function setLogLevel(level?: TypeSpecRuntimeLogLevel): void {\n if (level && !isTypeSpecRuntimeLogLevel(level)) {\n throw new Error(\n `Unknown log level '${level}'. Acceptable values: ${TYPESPEC_RUNTIME_LOG_LEVELS.join(\",\")}`,\n );\n }\n typeSpecRuntimeLogLevel = level;\n\n const enabledNamespaces = [];\n for (const logger of registeredLoggers) {\n if (shouldEnable(logger)) {\n enabledNamespaces.push(logger.namespace);\n }\n }\n\n debug.enable(enabledNamespaces.join(\",\"));\n}\n\n/**\n * Retrieves the currently specified log level.\n */\nexport function getLogLevel(): TypeSpecRuntimeLogLevel | undefined {\n return typeSpecRuntimeLogLevel;\n}\n\nconst levelMap = {\n verbose: 400,\n info: 300,\n warning: 200,\n error: 100,\n};\n\n/**\n * Defines the methods available on the SDK-facing logger.\n */\n// eslint-disable-next-line @typescript-eslint/no-redeclare\nexport interface TypeSpecRuntimeLogger {\n /**\n * Used for failures the program is unlikely to recover from,\n * such as Out of Memory.\n */\n error: Debugger;\n /**\n * Used when a function fails to perform its intended task.\n * Usually this means the function will throw an exception.\n * Not used for self-healing events (e.g. automatic retry)\n */\n warning: Debugger;\n /**\n * Used when a function operates normally.\n */\n info: Debugger;\n /**\n * Used for detailed troubleshooting scenarios. This is\n * intended for use by developers / system administrators\n * for diagnosing specific failures.\n */\n verbose: Debugger;\n}\n\n/**\n * Creates a logger for use by the SDKs that inherits from `TypeSpecRuntimeLogger`.\n * @param namespace - The name of the SDK package.\n * @hidden\n */\nexport function createClientLogger(namespace: string): TypeSpecRuntimeLogger {\n const clientRootLogger: TypeSpecRuntimeClientLogger = TypeSpecRuntimeLogger.extend(namespace);\n patchLogMethod(TypeSpecRuntimeLogger, clientRootLogger);\n return {\n error: createLogger(clientRootLogger, \"error\"),\n warning: createLogger(clientRootLogger, \"warning\"),\n info: createLogger(clientRootLogger, \"info\"),\n verbose: createLogger(clientRootLogger, \"verbose\"),\n };\n}\n\nfunction patchLogMethod(\n parent: TypeSpecRuntimeClientLogger,\n child: TypeSpecRuntimeClientLogger | TypeSpecRuntimeDebugger,\n): void {\n child.log = (...args) => {\n parent.log(...args);\n };\n}\n\nfunction createLogger(\n parent: TypeSpecRuntimeClientLogger,\n level: TypeSpecRuntimeLogLevel,\n): TypeSpecRuntimeDebugger {\n const logger: TypeSpecRuntimeDebugger = Object.assign(parent.extend(level), {\n level,\n });\n\n patchLogMethod(parent, logger);\n\n if (shouldEnable(logger)) {\n const enabledNamespaces = debug.disable();\n debug.enable(enabledNamespaces + \",\" + logger.namespace);\n }\n\n registeredLoggers.add(logger);\n\n return logger;\n}\n\nfunction shouldEnable(logger: TypeSpecRuntimeDebugger): boolean {\n return Boolean(\n typeSpecRuntimeLogLevel && levelMap[logger.level] <= levelMap[typeSpecRuntimeLogLevel],\n );\n}\n\nfunction isTypeSpecRuntimeLogLevel(logLevel: string): logLevel is TypeSpecRuntimeLogLevel {\n return TYPESPEC_RUNTIME_LOG_LEVELS.includes(logLevel as any);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHttpClient.d.ts","sourceRoot":"","sources":["../../src/nodeHttpClient.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"nodeHttpClient.d.ts","sourceRoot":"","sources":["../../src/nodeH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,SAAS,CAAC,WAAW;iBAC5B,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,IAAqB;IACjD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;SAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,cAAc,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport * as zlib from \"node:zlib\";\nimport { Transform } from \"node:stream\";\nimport { AbortError } from \"./abort-controller/AbortError.js\";\nimport {\n HttpClient,\n HttpHeaders,\n PipelineRequest,\n PipelineResponse,\n RequestBodyType,\n TlsSettings,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { RestError } from \"./restError.js\";\nimport { IncomingMessage } from \"node:http\";\nimport { logger } from \"./log.js\";\n\nconst DEFAULT_TLS_SETTINGS = {};\n\nfunction isReadableStream(body: any): body is NodeJS.ReadableStream {\n return body && typeof body.pipe === \"function\";\n}\n\nfunction isStreamComplete(stream: NodeJS.ReadableStream): Promise<void> {\n if (stream.readable === false) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n const handler = (): void => {\n resolve();\n stream.removeListener(\"close\", handler);\n stream.removeListener(\"end\", handler);\n stream.removeListener(\"error\", handler);\n };\n\n stream.on(\"close\", handler);\n stream.on(\"end\", handler);\n stream.on(\"error\", handler);\n });\n}\n\nfunction isArrayBuffer(body: any): body is ArrayBuffer | ArrayBufferView {\n return body && typeof body.byteLength === \"number\";\n}\n\nclass ReportTransform extends Transform {\n private loadedBytes = 0;\n private progressCallback: (progress: TransferProgressEvent) => void;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n _transform(chunk: string | Buffer, _encoding: string, callback: Function): void {\n this.push(chunk);\n this.loadedBytes += chunk.length;\n try {\n this.progressCallback({ loadedBytes: this.loadedBytes });\n callback();\n } catch (e: any) {\n callback(e);\n }\n }\n\n constructor(progressCallback: (progress: TransferProgressEvent) => void) {\n super();\n this.progressCallback = progressCallback;\n }\n}\n\n/**\n * A HttpClient implementation that uses Node's \"https\" module to send HTTPS requests.\n * @internal\n */\nclass NodeHttpClient implements HttpClient {\n private cachedHttpAgent?: http.Agent;\n private cachedHttpsAgents: WeakMap<TlsSettings, https.Agent> = new WeakMap();\n\n /**\n * Makes a request over an underlying transport layer and returns the response.\n * @param request - The request to be made.\n */\n public async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n const abortController = new AbortController();\n let abortListener: ((event: any) => void) | undefined;\n if (request.abortSignal) {\n if (request.abortSignal.aborted) {\n throw new AbortError(\"The operation was aborted.\");\n }\n\n abortListener = (event: Event) => {\n if (event.type === \"abort\") {\n abortController.abort();\n }\n };\n request.abortSignal.addEventListener(\"abort\", abortListener);\n }\n\n if (request.timeout > 0) {\n setTimeout(() => {\n abortController.abort();\n }, request.timeout);\n }\n\n const acceptEncoding = request.headers.get(\"Accept-Encoding\");\n const shouldDecompress =\n acceptEncoding?.includes(\"gzip\") || acceptEncoding?.includes(\"deflate\");\n\n let body = typeof request.body === \"function\" ? request.body() : request.body;\n if (body && !request.headers.has(\"Content-Length\")) {\n const bodyLength = getBodyLength(body);\n if (bodyLength !== null) {\n request.headers.set(\"Content-Length\", bodyLength);\n }\n }\n\n let responseStream: NodeJS.ReadableStream | undefined;\n try {\n if (body && request.onUploadProgress) {\n const onUploadProgress = request.onUploadProgress;\n const uploadReportStream = new ReportTransform(onUploadProgress);\n uploadReportStream.on(\"error\", (e) => {\n logger.error(\"Error in upload progress\", e);\n });\n if (isReadableStream(body)) {\n body.pipe(uploadReportStream);\n } else {\n uploadReportStream.end(body);\n }\n\n body = uploadReportStream;\n }\n\n const res = await this.makeRequest(request, abortController, body);\n\n const headers = getResponseHeaders(res);\n\n const status = res.statusCode ?? 0;\n const response: PipelineResponse = {\n status,\n headers,\n request,\n };\n\n // Responses to HEAD must not have a body.\n // If they do return a body, that body must be ignored.\n if (request.method === \"HEAD\") {\n // call resume() and not destroy() to avoid closing the socket\n // and losing keep alive\n res.resume();\n return response;\n }\n\n responseStream = shouldDecompress ? getDecodedResponseStream(res, headers) : res;\n\n const onDownloadProgress = request.onDownloadProgress;\n if (onDownloadProgress) {\n const downloadReportStream = new ReportTransform(onDownloadProgress);\n downloadReportStream.on(\"error\", (e) => {\n logger.error(\"Error in download progress\", e);\n });\n responseStream.pipe(downloadReportStream);\n responseStream = downloadReportStream;\n }\n\n if (\n // Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code\n request.streamResponseStatusCodes?.has(Number.POSITIVE_INFINITY) ||\n request.streamResponseStatusCodes?.has(response.status)\n ) {\n response.readableStreamBody = responseStream;\n } else {\n response.bodyAsText = await streamToText(responseStream);\n }\n\n return response;\n } finally {\n // clean up event listener\n if (request.abortSignal && abortListener) {\n let uploadStreamDone = Promise.resolve();\n if (isReadableStream(body)) {\n uploadStreamDone = isStreamComplete(body);\n }\n let downloadStreamDone = Promise.resolve();\n if (isReadableStream(responseStream)) {\n downloadStreamDone = isStreamComplete(responseStream);\n }\n Promise.all([uploadStreamDone, downloadStreamDone])\n .then(() => {\n // eslint-disable-next-line promise/always-return\n if (abortListener) {\n request.abortSignal?.removeEventListener(\"abort\", abortListener);\n }\n })\n .catch((e) => {\n logger.warning(\"Error when cleaning up abortListener on httpRequest\", e);\n });\n }\n }\n }\n\n private makeRequest(\n request: PipelineRequest,\n abortController: AbortController,\n body?: RequestBodyType,\n ): Promise<http.IncomingMessage> {\n const url = new URL(request.url);\n\n const isInsecure = url.protocol !== \"https:\";\n\n if (isInsecure && !request.allowInsecureConnection) {\n throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);\n }\n\n const agent = (request.agent as http.Agent) ?? this.getOrCreateAgent(request, isInsecure);\n const options: http.RequestOptions = {\n agent,\n hostname: url.hostname,\n path: `${url.pathname}${url.search}`,\n port: url.port,\n method: request.method,\n headers: request.headers.toJSON({ preserveCase: true }),\n };\n\n return new Promise<http.IncomingMessage>((resolve, reject) => {\n const req = isInsecure ? http.request(options, resolve) : https.request(options, resolve);\n\n req.once(\"error\", (err: Error & { code?: string }) => {\n reject(\n new RestError(err.message, { code: err.code ?? RestError.REQUEST_SEND_ERROR, request }),\n );\n });\n\n abortController.signal.addEventListener(\"abort\", () => {\n const abortError = new AbortError(\"The operation was aborted.\");\n req.destroy(abortError);\n reject(abortError);\n });\n if (body && isReadableStream(body)) {\n body.pipe(req);\n } else if (body) {\n if (typeof body === \"string\" || Buffer.isBuffer(body)) {\n req.end(body);\n } else if (isArrayBuffer(body)) {\n req.end(ArrayBuffer.isView(body) ? Buffer.from(body.buffer) : Buffer.from(body));\n } else {\n logger.error(\"Unrecognized body type\", body);\n reject(new RestError(\"Unrecognized body type\"));\n }\n } else {\n // streams don't like \"undefined\" being passed as data\n req.end();\n }\n });\n }\n\n private getOrCreateAgent(request: PipelineRequest, isInsecure: boolean): http.Agent {\n const disableKeepAlive = request.disableKeepAlive;\n\n // Handle Insecure requests first\n if (isInsecure) {\n if (disableKeepAlive) {\n // keepAlive:false is the default so we don't need a custom Agent\n return http.globalAgent;\n }\n\n if (!this.cachedHttpAgent) {\n // If there is no cached agent create a new one and cache it.\n this.cachedHttpAgent = new http.Agent({ keepAlive: true });\n }\n return this.cachedHttpAgent;\n } else {\n if (disableKeepAlive && !request.tlsSettings) {\n // When there are no tlsSettings and keepAlive is false\n // we don't need a custom agent\n return https.globalAgent;\n }\n\n // We use the tlsSettings to index cached clients\n const tlsSettings = request.tlsSettings ?? DEFAULT_TLS_SETTINGS;\n\n // Get the cached agent or create a new one with the\n // provided values for keepAlive and tlsSettings\n let agent = this.cachedHttpsAgents.get(tlsSettings);\n\n if (agent && agent.options.keepAlive === !disableKeepAlive) {\n return agent;\n }\n\n logger.info(\"No cached TLS Agent exist, creating a new Agent\");\n agent = new https.Agent({\n // keepAlive is true if disableKeepAlive is false.\n keepAlive: !disableKeepAlive,\n // Since we are spreading, if no tslSettings were provided, nothing is added to the agent options.\n ...tlsSettings,\n });\n\n this.cachedHttpsAgents.set(tlsSettings, agent);\n return agent;\n }\n }\n}\n\nfunction getResponseHeaders(res: IncomingMessage): HttpHeaders {\n const headers = createHttpHeaders();\n for (const header of Object.keys(res.headers)) {\n const value = res.headers[header];\n if (Array.isArray(value)) {\n if (value.length > 0) {\n headers.set(header, value[0]);\n }\n } else if (value) {\n headers.set(header, value);\n }\n }\n return headers;\n}\n\nfunction getDecodedResponseStream(\n stream: IncomingMessage,\n headers: HttpHeaders,\n): NodeJS.ReadableStream {\n const contentEncoding = headers.get(\"Content-Encoding\");\n if (contentEncoding === \"gzip\") {\n const unzip = zlib.createGunzip();\n stream.pipe(unzip);\n return unzip;\n } else if (contentEncoding === \"deflate\") {\n const inflate = zlib.createInflate();\n stream.pipe(inflate);\n return inflate;\n }\n\n return stream;\n}\n\nfunction streamToText(stream: NodeJS.ReadableStream): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const buffer: Buffer[] = [];\n\n stream.on(\"data\", (chunk) => {\n if (Buffer.isBuffer(chunk)) {\n buffer.push(chunk);\n } else {\n buffer.push(Buffer.from(chunk));\n }\n });\n stream.on(\"end\", () => {\n resolve(Buffer.concat(buffer).toString(\"utf8\"));\n });\n stream.on(\"error\", (e) => {\n if (e && e?.name === \"AbortError\") {\n reject(e);\n } else {\n reject(\n new RestError(`Error reading response as text: ${e.message}`, {\n code: RestError.PARSE_ERROR,\n }),\n );\n }\n });\n });\n}\n\n/** @internal */\nexport function getBodyLength(body: RequestBodyType): number | null {\n if (!body) {\n return 0;\n } else if (Buffer.isBuffer(body)) {\n return body.length;\n } else if (isReadableStream(body)) {\n return null;\n } else if (isArrayBuffer(body)) {\n return body.byteLength;\n } else if (typeof body === \"string\") {\n return Buffer.from(body).length;\n } else {\n return null;\n }\n}\n\n/**\n * Create a new HttpClient instance for the NodeJS environment.\n * @internal\n */\nexport function createNodeHttpClient(): HttpClient {\n return new NodeHttpClient();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nodeHttpClient.js","sourceRoot":"","sources":["../../src/nodeHttpClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAU9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAEhC,SAAS,gBAAgB,CAAC,IAAS;IACjC,OAAO,IAAI,IAAI,OAAO,IAAI,CAAC,IAAI,KA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AC,CAAC;QAClD,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACvB,IAAI,CAAC,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,YAAY,EAAE,CAAC;gBAClC,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,MAAM,CACJ,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC,OAAO,EAAE,EAAE;oBAC5D,IAAI,EAAE,SAAS,CAAC,WAAW;iBAC5B,CAAC,CACH,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,IAAqB;IACjD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,CAAC;IACX,CAAC;SAAM,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;SAAM,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;SAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,OAAO,IAAI,cAAc,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport * as http from \"node:http\";\nimport * as https from \"node:https\";\nimport * as zlib from \"node:zlib\";\nimport { Transform } from \"node:stream\";\nimport { AbortError } from \"./abort-controller/AbortError.js\";\nimport type {\n HttpClient,\n HttpHeaders,\n PipelineRequest,\n PipelineResponse,\n RequestBodyType,\n TlsSettings,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { RestError } from \"./restError.js\";\nimport type { IncomingMessage } from \"node:http\";\nimport { logger } from \"./log.js\";\n\nconst DEFAULT_TLS_SETTINGS = {};\n\nfunction isReadableStream(body: any): body is NodeJS.ReadableStream {\n return body && typeof body.pipe === \"function\";\n}\n\nfunction isStreamComplete(stream: NodeJS.ReadableStream): Promise<void> {\n if (stream.readable === false) {\n return Promise.resolve();\n }\n\n return new Promise((resolve) => {\n const handler = (): void => {\n resolve();\n stream.removeListener(\"close\", handler);\n stream.removeListener(\"end\", handler);\n stream.removeListener(\"error\", handler);\n };\n\n stream.on(\"close\", handler);\n stream.on(\"end\", handler);\n stream.on(\"error\", handler);\n });\n}\n\nfunction isArrayBuffer(body: any): body is ArrayBuffer | ArrayBufferView {\n return body && typeof body.byteLength === \"number\";\n}\n\nclass ReportTransform extends Transform {\n private loadedBytes = 0;\n private progressCallback: (progress: TransferProgressEvent) => void;\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n _transform(chunk: string | Buffer, _encoding: string, callback: Function): void {\n this.push(chunk);\n this.loadedBytes += chunk.length;\n try {\n this.progressCallback({ loadedBytes: this.loadedBytes });\n callback();\n } catch (e: any) {\n callback(e);\n }\n }\n\n constructor(progressCallback: (progress: TransferProgressEvent) => void) {\n super();\n this.progressCallback = progressCallback;\n }\n}\n\n/**\n * A HttpClient implementation that uses Node's \"https\" module to send HTTPS requests.\n * @internal\n */\nclass NodeHttpClient implements HttpClient {\n private cachedHttpAgent?: http.Agent;\n private cachedHttpsAgents: WeakMap<TlsSettings, https.Agent> = new WeakMap();\n\n /**\n * Makes a request over an underlying transport layer and returns the response.\n * @param request - The request to be made.\n */\n public async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {\n const abortController = new AbortController();\n let abortListener: ((event: any) => void) | undefined;\n if (request.abortSignal) {\n if (request.abortSignal.aborted) {\n throw new AbortError(\"The operation was aborted.\");\n }\n\n abortListener = (event: Event) => {\n if (event.type === \"abort\") {\n abortController.abort();\n }\n };\n request.abortSignal.addEventListener(\"abort\", abortListener);\n }\n\n if (request.timeout > 0) {\n setTimeout(() => {\n abortController.abort();\n }, request.timeout);\n }\n\n const acceptEncoding = request.headers.get(\"Accept-Encoding\");\n const shouldDecompress =\n acceptEncoding?.includes(\"gzip\") || acceptEncoding?.includes(\"deflate\");\n\n let body = typeof request.body === \"function\" ? request.body() : request.body;\n if (body && !request.headers.has(\"Content-Length\")) {\n const bodyLength = getBodyLength(body);\n if (bodyLength !== null) {\n request.headers.set(\"Content-Length\", bodyLength);\n }\n }\n\n let responseStream: NodeJS.ReadableStream | undefined;\n try {\n if (body && request.onUploadProgress) {\n const onUploadProgress = request.onUploadProgress;\n const uploadReportStream = new ReportTransform(onUploadProgress);\n uploadReportStream.on(\"error\", (e) => {\n logger.error(\"Error in upload progress\", e);\n });\n if (isReadableStream(body)) {\n body.pipe(uploadReportStream);\n } else {\n uploadReportStream.end(body);\n }\n\n body = uploadReportStream;\n }\n\n const res = await this.makeRequest(request, abortController, body);\n\n const headers = getResponseHeaders(res);\n\n const status = res.statusCode ?? 0;\n const response: PipelineResponse = {\n status,\n headers,\n request,\n };\n\n // Responses to HEAD must not have a body.\n // If they do return a body, that body must be ignored.\n if (request.method === \"HEAD\") {\n // call resume() and not destroy() to avoid closing the socket\n // and losing keep alive\n res.resume();\n return response;\n }\n\n responseStream = shouldDecompress ? getDecodedResponseStream(res, headers) : res;\n\n const onDownloadProgress = request.onDownloadProgress;\n if (onDownloadProgress) {\n const downloadReportStream = new ReportTransform(onDownloadProgress);\n downloadReportStream.on(\"error\", (e) => {\n logger.error(\"Error in download progress\", e);\n });\n responseStream.pipe(downloadReportStream);\n responseStream = downloadReportStream;\n }\n\n if (\n // Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code\n request.streamResponseStatusCodes?.has(Number.POSITIVE_INFINITY) ||\n request.streamResponseStatusCodes?.has(response.status)\n ) {\n response.readableStreamBody = responseStream;\n } else {\n response.bodyAsText = await streamToText(responseStream);\n }\n\n return response;\n } finally {\n // clean up event listener\n if (request.abortSignal && abortListener) {\n let uploadStreamDone = Promise.resolve();\n if (isReadableStream(body)) {\n uploadStreamDone = isStreamComplete(body);\n }\n let downloadStreamDone = Promise.resolve();\n if (isReadableStream(responseStream)) {\n downloadStreamDone = isStreamComplete(responseStream);\n }\n Promise.all([uploadStreamDone, downloadStreamDone])\n .then(() => {\n // eslint-disable-next-line promise/always-return\n if (abortListener) {\n request.abortSignal?.removeEventListener(\"abort\", abortListener);\n }\n })\n .catch((e) => {\n logger.warning(\"Error when cleaning up abortListener on httpRequest\", e);\n });\n }\n }\n }\n\n private makeRequest(\n request: PipelineRequest,\n abortController: AbortController,\n body?: RequestBodyType,\n ): Promise<http.IncomingMessage> {\n const url = new URL(request.url);\n\n const isInsecure = url.protocol !== \"https:\";\n\n if (isInsecure && !request.allowInsecureConnection) {\n throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);\n }\n\n const agent = (request.agent as http.Agent) ?? this.getOrCreateAgent(request, isInsecure);\n const options: http.RequestOptions = {\n agent,\n hostname: url.hostname,\n path: `${url.pathname}${url.search}`,\n port: url.port,\n method: request.method,\n headers: request.headers.toJSON({ preserveCase: true }),\n };\n\n return new Promise<http.IncomingMessage>((resolve, reject) => {\n const req = isInsecure ? http.request(options, resolve) : https.request(options, resolve);\n\n req.once(\"error\", (err: Error & { code?: string }) => {\n reject(\n new RestError(err.message, { code: err.code ?? RestError.REQUEST_SEND_ERROR, request }),\n );\n });\n\n abortController.signal.addEventListener(\"abort\", () => {\n const abortError = new AbortError(\"The operation was aborted.\");\n req.destroy(abortError);\n reject(abortError);\n });\n if (body && isReadableStream(body)) {\n body.pipe(req);\n } else if (body) {\n if (typeof body === \"string\" || Buffer.isBuffer(body)) {\n req.end(body);\n } else if (isArrayBuffer(body)) {\n req.end(ArrayBuffer.isView(body) ? Buffer.from(body.buffer) : Buffer.from(body));\n } else {\n logger.error(\"Unrecognized body type\", body);\n reject(new RestError(\"Unrecognized body type\"));\n }\n } else {\n // streams don't like \"undefined\" being passed as data\n req.end();\n }\n });\n }\n\n private getOrCreateAgent(request: PipelineRequest, isInsecure: boolean): http.Agent {\n const disableKeepAlive = request.disableKeepAlive;\n\n // Handle Insecure requests first\n if (isInsecure) {\n if (disableKeepAlive) {\n // keepAlive:false is the default so we don't need a custom Agent\n return http.globalAgent;\n }\n\n if (!this.cachedHttpAgent) {\n // If there is no cached agent create a new one and cache it.\n this.cachedHttpAgent = new http.Agent({ keepAlive: true });\n }\n return this.cachedHttpAgent;\n } else {\n if (disableKeepAlive && !request.tlsSettings) {\n // When there are no tlsSettings and keepAlive is false\n // we don't need a custom agent\n return https.globalAgent;\n }\n\n // We use the tlsSettings to index cached clients\n const tlsSettings = request.tlsSettings ?? DEFAULT_TLS_SETTINGS;\n\n // Get the cached agent or create a new one with the\n // provided values for keepAlive and tlsSettings\n let agent = this.cachedHttpsAgents.get(tlsSettings);\n\n if (agent && agent.options.keepAlive === !disableKeepAlive) {\n return agent;\n }\n\n logger.info(\"No cached TLS Agent exist, creating a new Agent\");\n agent = new https.Agent({\n // keepAlive is true if disableKeepAlive is false.\n keepAlive: !disableKeepAlive,\n // Since we are spreading, if no tslSettings were provided, nothing is added to the agent options.\n ...tlsSettings,\n });\n\n this.cachedHttpsAgents.set(tlsSettings, agent);\n return agent;\n }\n }\n}\n\nfunction getResponseHeaders(res: IncomingMessage): HttpHeaders {\n const headers = createHttpHeaders();\n for (const header of Object.keys(res.headers)) {\n const value = res.headers[header];\n if (Array.isArray(value)) {\n if (value.length > 0) {\n headers.set(header, value[0]);\n }\n } else if (value) {\n headers.set(header, value);\n }\n }\n return headers;\n}\n\nfunction getDecodedResponseStream(\n stream: IncomingMessage,\n headers: HttpHeaders,\n): NodeJS.ReadableStream {\n const contentEncoding = headers.get(\"Content-Encoding\");\n if (contentEncoding === \"gzip\") {\n const unzip = zlib.createGunzip();\n stream.pipe(unzip);\n return unzip;\n } else if (contentEncoding === \"deflate\") {\n const inflate = zlib.createInflate();\n stream.pipe(inflate);\n return inflate;\n }\n\n return stream;\n}\n\nfunction streamToText(stream: NodeJS.ReadableStream): Promise<string> {\n return new Promise<string>((resolve, reject) => {\n const buffer: Buffer[] = [];\n\n stream.on(\"data\", (chunk) => {\n if (Buffer.isBuffer(chunk)) {\n buffer.push(chunk);\n } else {\n buffer.push(Buffer.from(chunk));\n }\n });\n stream.on(\"end\", () => {\n resolve(Buffer.concat(buffer).toString(\"utf8\"));\n });\n stream.on(\"error\", (e) => {\n if (e && e?.name === \"AbortError\") {\n reject(e);\n } else {\n reject(\n new RestError(`Error reading response as text: ${e.message}`, {\n code: RestError.PARSE_ERROR,\n }),\n );\n }\n });\n });\n}\n\n/** @internal */\nexport function getBodyLength(body: RequestBodyType): number | null {\n if (!body) {\n return 0;\n } else if (Buffer.isBuffer(body)) {\n return body.length;\n } else if (isReadableStream(body)) {\n return null;\n } else if (isArrayBuffer(body)) {\n return body.byteLength;\n } else if (typeof body === \"string\") {\n return Buffer.from(body).length;\n } else {\n return null;\n }\n}\n\n/**\n * Create a new HttpClient instance for the NodeJS environment.\n * @internal\n */\nexport function createNodeHttpClient(): HttpClient {\n return new NodeHttpClient();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/pipeline.ts"],"names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,CAAC,MAAM,CAAC;YAC1C,kEAAkE;YAClE,UAAU,EAAE,CAAC;YACb,6DAA6D;YAC7D,6BAA6B;YAC7B,0CAA0C;YAC1C,IAAI,MAAM,CAAC,MAAM,IAAI,mBAAmB,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;gBAC1D,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { HttpClient, PipelineRequest, PipelineResponse, SendRequest } from \"./interfaces.js\";\n\n/**\n * Policies are executed in phases.\n * The execution order is:\n * 1. Serialize Phase\n * 2. Policies not in a phase\n * 3. Deserialize Phase\n * 4. Retry Phase\n * 5. Sign Phase\n */\nexport type PipelinePhase = \"Deserialize\" | \"Serialize\" | \"Retry\" | \"Sign\";\n\nconst ValidPhaseNames = new Set<PipelinePhase>([\"Deserialize\", \"Serialize\", \"Retry\", \"Sign\"]);\n\n/**\n * Options when adding a policy to the pipeline.\n * Used to express dependencies on other policies.\n */\nexport interface AddPolicyOptions {\n /**\n * Policies that this policy must come before.\n */\n beforePolicies?: string[];\n /**\n * Policies that this policy must come after.\n */\n afterPolicies?: string[];\n /**\n * The phase that this policy must come after.\n */\n afterPhase?: PipelinePhase;\n /**\n * The phase this policy belongs to.\n */\n phase?: PipelinePhase;\n}\n\n/**\n * A pipeline policy manipulates a request as it travels through the pipeline.\n * It is conceptually a middleware that is allowed to modify the request before\n * it is made as well as the response when it is received.\n */\nexport interface PipelinePolicy {\n /**\n * The policy name. Must be a unique string in the pipeline.\n */\n name: string;\n /**\n * The main method to implement that manipulates a request/response.\n * @param request - The request being performed.\n * @param next - The next policy in the pipeline. Must be called to continue the pipeline.\n */\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse>;\n}\n\n/**\n * Represents a pipeline for making a HTTP request to a URL.\n * Pipelines can have multiple policies to manage manipulating each request\n * before and after it is made to the server.\n */\nexport interface Pipeline {\n /**\n * Add a new policy to the pipeline.\n * @param policy - A policy that manipulates a request.\n * @param options - A set of options for when the policy should run.\n */\n addPolicy(policy: PipelinePolicy, options?: AddPolicyOptions): void;\n /**\n * Remove a policy from the pipeline.\n * @param options - Options that let you specify which policies to remove.\n */\n removePolicy(options: { name?: string; phase?: PipelinePhase }): PipelinePolicy[];\n /**\n * Uses the pipeline to make a HTTP request.\n * @param httpClient - The HttpClient that actually performs the request.\n * @param request - The request to be made.\n */\n sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse>;\n /**\n * Returns the current set of policies in the pipeline in the order in which\n * they will be applied to the request. Later in the list is closer to when\n * the request is performed.\n */\n getOrderedPolicies(): PipelinePolicy[];\n /**\n * Duplicates this pipeline to allow for modifying an existing one without mutating it.\n */\n clone(): Pipeline;\n}\n\ninterface PipelineDescriptor {\n policy: PipelinePolicy;\n options: AddPolicyOptions;\n}\n\ninterface PolicyGraphNode {\n policy: PipelinePolicy;\n dependsOn: Set<PolicyGraphNode>;\n dependants: Set<PolicyGraphNode>;\n afterPhase?: Phase;\n}\n\ninterface Phase {\n name: PipelinePhase | \"None\";\n policies: Set<PolicyGraphNode>;\n hasRun: boolean;\n hasAfterPolicies: boolean;\n}\n\n/**\n * A private implementation of Pipeline.\n * Do not export this class from the package.\n * @internal\n */\nclass HttpPipeline implements Pipeline {\n private _policies: PipelineDescriptor[] = [];\n private _orderedPolicies?: PipelinePolicy[];\n\n private constructor(policies?: PipelineDescriptor[]) {\n this._policies = policies?.slice(0) ?? [];\n this._orderedPolicies = undefined;\n }\n\n public addPolicy(policy: PipelinePolicy, options: AddPolicyOptions = {}): void {\n if (options.phase && options.afterPhase) {\n throw new Error(\"Policies inside a phase cannot specify afterPhase.\");\n }\n if (options.phase && !ValidPhaseNames.has(options.phase)) {\n throw new Error(`Invalid phase name: ${options.phase}`);\n }\n if (options.afterPhase && !ValidPhaseNames.has(options.afterPhase)) {\n throw new Error(`Invalid afterPhase name: ${options.afterPhase}`);\n }\n this._policies.push({\n policy,\n options,\n });\n this._orderedPolicies = undefined;\n }\n\n public removePolicy(options: { name?: string; phase?: string }): PipelinePolicy[] {\n const removedPolicies: PipelinePolicy[] = [];\n\n this._policies = this._policies.filter((policyDescriptor) => {\n if (\n (options.name && policyDescriptor.policy.name === options.name) ||\n (options.phase && policyDescriptor.options.phase === options.phase)\n ) {\n removedPolicies.push(policyDescriptor.policy);\n return false;\n } else {\n return true;\n }\n });\n this._orderedPolicies = undefined;\n\n return removedPolicies;\n }\n\n public sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse> {\n const policies = this.getOrderedPolicies();\n\n const pipeline = policies.reduceRight<SendRequest>(\n (next, policy) => {\n return (req: PipelineRequest) => {\n return policy.sendRequest(req, next);\n };\n },\n (req: PipelineRequest) => httpClient.sendRequest(req),\n );\n\n return pipeline(request);\n }\n\n public getOrderedPolicies(): PipelinePolicy[] {\n if (!this._orderedPolicies) {\n this._orderedPolicies = this.orderPolicies();\n }\n return this._orderedPolicies;\n }\n\n public clone(): Pipeline {\n return new HttpPipeline(this._policies);\n }\n\n public static create(): Pipeline {\n return new HttpPipeline();\n }\n\n private orderPolicies(): PipelinePolicy[] {\n /**\n * The goal of this method is to reliably order pipeline policies\n * based on their declared requirements when they were added.\n *\n * Order is first determined by phase:\n *\n * 1. Serialize Phase\n * 2. Policies not in a phase\n * 3. Deserialize Phase\n * 4. Retry Phase\n * 5. Sign Phase\n *\n * Within each phase, policies are executed in the order\n * they were added unless they were specified to execute\n * before/after other policies or after a particular phase.\n *\n * To determine the final order, we will walk the policy list\n * in phase order multiple times until all dependencies are\n * satisfied.\n *\n * `afterPolicies` are the set of policies that must be\n * executed before a given policy. This requirement is\n * considered satisfied when each of the listed policies\n * have been scheduled.\n *\n * `beforePolicies` are the set of policies that must be\n * executed after a given policy. Since this dependency\n * can be expressed by converting it into a equivalent\n * `afterPolicies` declarations, they are normalized\n * into that form for simplicity.\n *\n * An `afterPhase` dependency is considered satisfied when all\n * policies in that phase have scheduled.\n *\n */\n const result: PipelinePolicy[] = [];\n\n // Track all policies we know about.\n const policyMap: Map<string, PolicyGraphNode> = new Map<string, PolicyGraphNode>();\n\n function createPhase(name: PipelinePhase | \"None\"): Phase {\n return {\n name,\n policies: new Set<PolicyGraphNode>(),\n hasRun: false,\n hasAfterPolicies: false,\n };\n }\n\n // Track policies for each phase.\n const serializePhase = createPhase(\"Serialize\");\n const noPhase = createPhase(\"None\");\n const deserializePhase = createPhase(\"Deserialize\");\n const retryPhase = createPhase(\"Retry\");\n const signPhase = createPhase(\"Sign\");\n\n // a list of phases in order\n const orderedPhases = [serializePhase, noPhase, deserializePhase, retryPhase, signPhase];\n\n // Small helper function to map phase name to each Phase\n function getPhase(phase: PipelinePhase | undefined): Phase {\n if (phase === \"Retry\") {\n return retryPhase;\n } else if (phase === \"Serialize\") {\n return serializePhase;\n } else if (phase === \"Deserialize\") {\n return deserializePhase;\n } else if (phase === \"Sign\") {\n return signPhase;\n } else {\n return noPhase;\n }\n }\n\n // First walk each policy and create a node to track metadata.\n for (const descriptor of this._policies) {\n const policy = descriptor.policy;\n const options = descriptor.options;\n const policyName = policy.name;\n if (policyMap.has(policyName)) {\n throw new Error(\"Duplicate policy names not allowed in pipeline\");\n }\n const node: PolicyGraphNode = {\n policy,\n dependsOn: new Set<PolicyGraphNode>(),\n dependants: new Set<PolicyGraphNode>(),\n };\n if (options.afterPhase) {\n node.afterPhase = getPhase(options.afterPhase);\n node.afterPhase.hasAfterPolicies = true;\n }\n policyMap.set(policyName, node);\n const phase = getPhase(options.phase);\n phase.policies.add(node);\n }\n\n // Now that each policy has a node, connect dependency references.\n for (const descriptor of this._policies) {\n const { policy, options } = descriptor;\n const policyName = policy.name;\n const node = policyMap.get(policyName);\n if (!node) {\n throw new Error(`Missing node for policy ${policyName}`);\n }\n\n if (options.afterPolicies) {\n for (const afterPolicyName of options.afterPolicies) {\n const afterNode = policyMap.get(afterPolicyName);\n if (afterNode) {\n // Linking in both directions helps later\n // when we want to notify dependants.\n node.dependsOn.add(afterNode);\n afterNode.dependants.add(node);\n }\n }\n }\n if (options.beforePolicies) {\n for (const beforePolicyName of options.beforePolicies) {\n const beforeNode = policyMap.get(beforePolicyName);\n if (beforeNode) {\n // To execute before another node, make it\n // depend on the current node.\n beforeNode.dependsOn.add(node);\n node.dependants.add(beforeNode);\n }\n }\n }\n }\n\n function walkPhase(phase: Phase): void {\n phase.hasRun = true;\n // Sets iterate in insertion order\n for (const node of phase.policies) {\n if (node.afterPhase && (!node.afterPhase.hasRun || node.afterPhase.policies.size)) {\n // If this node is waiting on a phase to complete,\n // we need to skip it for now.\n // Even if the phase is empty, we should wait for it\n // to be walked to avoid re-ordering policies.\n continue;\n }\n if (node.dependsOn.size === 0) {\n // If there's nothing else we're waiting for, we can\n // add this policy to the result list.\n result.push(node.policy);\n // Notify anything that depends on this policy that\n // the policy has been scheduled.\n for (const dependant of node.dependants) {\n dependant.dependsOn.delete(node);\n }\n policyMap.delete(node.policy.name);\n phase.policies.delete(node);\n }\n }\n }\n\n function walkPhases(): void {\n for (const phase of orderedPhases) {\n walkPhase(phase);\n // if the phase isn't complete\n if (phase.policies.size > 0 && phase !== noPhase) {\n if (!noPhase.hasRun) {\n // Try running noPhase to see if that unblocks this phase next tick.\n // This can happen if a phase that happens before noPhase\n // is waiting on a noPhase policy to complete.\n walkPhase(noPhase);\n }\n // Don't proceed to the next phase until this phase finishes.\n return;\n }\n\n if (phase.hasAfterPolicies) {\n // Run any policies unblocked by this phase\n walkPhase(noPhase);\n }\n }\n }\n\n // Iterate until we've put every node in the result list.\n let iteration = 0;\n while (policyMap.size > 0) {\n iteration++;\n const initialResultLength = result.length;\n // Keep walking each phase in order until we can order every node.\n walkPhases();\n // The result list *should* get at least one larger each time\n // after the first full pass.\n // Otherwise, we're going to loop forever.\n if (result.length <= initialResultLength && iteration > 1) {\n throw new Error(\"Cannot satisfy policy dependencies due to requirements cycle.\");\n }\n }\n\n return result;\n }\n}\n\n/**\n * Creates a totally empty pipeline.\n * Useful for testing or creating a custom one.\n */\nexport function createEmptyPipeline(): Pipeline {\n return HttpPipeline.create();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/pipeline.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAelC,MAAM,eAAe,GAAG,IAAI,GAAG,CAAgB,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAiG9F;;;;GAIG;AACH,MAAM,YAAY;IAIhB,YAAoB,QAA+B;;QAH3C,cAAS,GAAyB,EAAE,CAAC;QAI3C,IAAI,CAAC,SAAS,GAAG,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAC;QAC1C,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACpC,CAAC;IAEM,SAAS,CAAC,MAAsB,EAAE,UAA4B,EAAE;QACrE,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QACD,IAAI,OAAO,CAAC,KAAK,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,uBAAuB,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,IAAI,OAAO,CAAC,UAAU,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,KAAK,CAAC,4BAA4B,OAAO,C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AC3C,SAAS,CAAC,OAAO,CAAC,CAAC;gBACrB,CAAC;YACH,CAAC;QACH,CAAC;QAED,yDAAyD;QACzD,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,OAAO,SAAS,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC1B,SAAS,EAAE,CAAC;YACZ,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC;YAC1C,kEAAkE;YAClE,UAAU,EAAE,CAAC;YACb,6DAA6D;YAC7D,6BAA6B;YAC7B,0CAA0C;YAC1C,IAAI,MAAM,CAAC,MAAM,IAAI,mBAAmB,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;gBAC1D,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;YACnF,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, PipelineRequest, PipelineResponse, SendRequest } from \"./interfaces.js\";\n\n/**\n * Policies are executed in phases.\n * The execution order is:\n * 1. Serialize Phase\n * 2. Policies not in a phase\n * 3. Deserialize Phase\n * 4. Retry Phase\n * 5. Sign Phase\n */\nexport type PipelinePhase = \"Deserialize\" | \"Serialize\" | \"Retry\" | \"Sign\";\n\nconst ValidPhaseNames = new Set<PipelinePhase>([\"Deserialize\", \"Serialize\", \"Retry\", \"Sign\"]);\n\n/**\n * Options when adding a policy to the pipeline.\n * Used to express dependencies on other policies.\n */\nexport interface AddPolicyOptions {\n /**\n * Policies that this policy must come before.\n */\n beforePolicies?: string[];\n /**\n * Policies that this policy must come after.\n */\n afterPolicies?: string[];\n /**\n * The phase that this policy must come after.\n */\n afterPhase?: PipelinePhase;\n /**\n * The phase this policy belongs to.\n */\n phase?: PipelinePhase;\n}\n\n/**\n * A pipeline policy manipulates a request as it travels through the pipeline.\n * It is conceptually a middleware that is allowed to modify the request before\n * it is made as well as the response when it is received.\n */\nexport interface PipelinePolicy {\n /**\n * The policy name. Must be a unique string in the pipeline.\n */\n name: string;\n /**\n * The main method to implement that manipulates a request/response.\n * @param request - The request being performed.\n * @param next - The next policy in the pipeline. Must be called to continue the pipeline.\n */\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse>;\n}\n\n/**\n * Represents a pipeline for making a HTTP request to a URL.\n * Pipelines can have multiple policies to manage manipulating each request\n * before and after it is made to the server.\n */\nexport interface Pipeline {\n /**\n * Add a new policy to the pipeline.\n * @param policy - A policy that manipulates a request.\n * @param options - A set of options for when the policy should run.\n */\n addPolicy(policy: PipelinePolicy, options?: AddPolicyOptions): void;\n /**\n * Remove a policy from the pipeline.\n * @param options - Options that let you specify which policies to remove.\n */\n removePolicy(options: { name?: string; phase?: PipelinePhase }): PipelinePolicy[];\n /**\n * Uses the pipeline to make a HTTP request.\n * @param httpClient - The HttpClient that actually performs the request.\n * @param request - The request to be made.\n */\n sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse>;\n /**\n * Returns the current set of policies in the pipeline in the order in which\n * they will be applied to the request. Later in the list is closer to when\n * the request is performed.\n */\n getOrderedPolicies(): PipelinePolicy[];\n /**\n * Duplicates this pipeline to allow for modifying an existing one without mutating it.\n */\n clone(): Pipeline;\n}\n\ninterface PipelineDescriptor {\n policy: PipelinePolicy;\n options: AddPolicyOptions;\n}\n\ninterface PolicyGraphNode {\n policy: PipelinePolicy;\n dependsOn: Set<PolicyGraphNode>;\n dependants: Set<PolicyGraphNode>;\n afterPhase?: Phase;\n}\n\ninterface Phase {\n name: PipelinePhase | \"None\";\n policies: Set<PolicyGraphNode>;\n hasRun: boolean;\n hasAfterPolicies: boolean;\n}\n\n/**\n * A private implementation of Pipeline.\n * Do not export this class from the package.\n * @internal\n */\nclass HttpPipeline implements Pipeline {\n private _policies: PipelineDescriptor[] = [];\n private _orderedPolicies?: PipelinePolicy[];\n\n private constructor(policies?: PipelineDescriptor[]) {\n this._policies = policies?.slice(0) ?? [];\n this._orderedPolicies = undefined;\n }\n\n public addPolicy(policy: PipelinePolicy, options: AddPolicyOptions = {}): void {\n if (options.phase && options.afterPhase) {\n throw new Error(\"Policies inside a phase cannot specify afterPhase.\");\n }\n if (options.phase && !ValidPhaseNames.has(options.phase)) {\n throw new Error(`Invalid phase name: ${options.phase}`);\n }\n if (options.afterPhase && !ValidPhaseNames.has(options.afterPhase)) {\n throw new Error(`Invalid afterPhase name: ${options.afterPhase}`);\n }\n this._policies.push({\n policy,\n options,\n });\n this._orderedPolicies = undefined;\n }\n\n public removePolicy(options: { name?: string; phase?: string }): PipelinePolicy[] {\n const removedPolicies: PipelinePolicy[] = [];\n\n this._policies = this._policies.filter((policyDescriptor) => {\n if (\n (options.name && policyDescriptor.policy.name === options.name) ||\n (options.phase && policyDescriptor.options.phase === options.phase)\n ) {\n removedPolicies.push(policyDescriptor.policy);\n return false;\n } else {\n return true;\n }\n });\n this._orderedPolicies = undefined;\n\n return removedPolicies;\n }\n\n public sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse> {\n const policies = this.getOrderedPolicies();\n\n const pipeline = policies.reduceRight<SendRequest>(\n (next, policy) => {\n return (req: PipelineRequest) => {\n return policy.sendRequest(req, next);\n };\n },\n (req: PipelineRequest) => httpClient.sendRequest(req),\n );\n\n return pipeline(request);\n }\n\n public getOrderedPolicies(): PipelinePolicy[] {\n if (!this._orderedPolicies) {\n this._orderedPolicies = this.orderPolicies();\n }\n return this._orderedPolicies;\n }\n\n public clone(): Pipeline {\n return new HttpPipeline(this._policies);\n }\n\n public static create(): Pipeline {\n return new HttpPipeline();\n }\n\n private orderPolicies(): PipelinePolicy[] {\n /**\n * The goal of this method is to reliably order pipeline policies\n * based on their declared requirements when they were added.\n *\n * Order is first determined by phase:\n *\n * 1. Serialize Phase\n * 2. Policies not in a phase\n * 3. Deserialize Phase\n * 4. Retry Phase\n * 5. Sign Phase\n *\n * Within each phase, policies are executed in the order\n * they were added unless they were specified to execute\n * before/after other policies or after a particular phase.\n *\n * To determine the final order, we will walk the policy list\n * in phase order multiple times until all dependencies are\n * satisfied.\n *\n * `afterPolicies` are the set of policies that must be\n * executed before a given policy. This requirement is\n * considered satisfied when each of the listed policies\n * have been scheduled.\n *\n * `beforePolicies` are the set of policies that must be\n * executed after a given policy. Since this dependency\n * can be expressed by converting it into a equivalent\n * `afterPolicies` declarations, they are normalized\n * into that form for simplicity.\n *\n * An `afterPhase` dependency is considered satisfied when all\n * policies in that phase have scheduled.\n *\n */\n const result: PipelinePolicy[] = [];\n\n // Track all policies we know about.\n const policyMap: Map<string, PolicyGraphNode> = new Map<string, PolicyGraphNode>();\n\n function createPhase(name: PipelinePhase | \"None\"): Phase {\n return {\n name,\n policies: new Set<PolicyGraphNode>(),\n hasRun: false,\n hasAfterPolicies: false,\n };\n }\n\n // Track policies for each phase.\n const serializePhase = createPhase(\"Serialize\");\n const noPhase = createPhase(\"None\");\n const deserializePhase = createPhase(\"Deserialize\");\n const retryPhase = createPhase(\"Retry\");\n const signPhase = createPhase(\"Sign\");\n\n // a list of phases in order\n const orderedPhases = [serializePhase, noPhase, deserializePhase, retryPhase, signPhase];\n\n // Small helper function to map phase name to each Phase\n function getPhase(phase: PipelinePhase | undefined): Phase {\n if (phase === \"Retry\") {\n return retryPhase;\n } else if (phase === \"Serialize\") {\n return serializePhase;\n } else if (phase === \"Deserialize\") {\n return deserializePhase;\n } else if (phase === \"Sign\") {\n return signPhase;\n } else {\n return noPhase;\n }\n }\n\n // First walk each policy and create a node to track metadata.\n for (const descriptor of this._policies) {\n const policy = descriptor.policy;\n const options = descriptor.options;\n const policyName = policy.name;\n if (policyMap.has(policyName)) {\n throw new Error(\"Duplicate policy names not allowed in pipeline\");\n }\n const node: PolicyGraphNode = {\n policy,\n dependsOn: new Set<PolicyGraphNode>(),\n dependants: new Set<PolicyGraphNode>(),\n };\n if (options.afterPhase) {\n node.afterPhase = getPhase(options.afterPhase);\n node.afterPhase.hasAfterPolicies = true;\n }\n policyMap.set(policyName, node);\n const phase = getPhase(options.phase);\n phase.policies.add(node);\n }\n\n // Now that each policy has a node, connect dependency references.\n for (const descriptor of this._policies) {\n const { policy, options } = descriptor;\n const policyName = policy.name;\n const node = policyMap.get(policyName);\n if (!node) {\n throw new Error(`Missing node for policy ${policyName}`);\n }\n\n if (options.afterPolicies) {\n for (const afterPolicyName of options.afterPolicies) {\n const afterNode = policyMap.get(afterPolicyName);\n if (afterNode) {\n // Linking in both directions helps later\n // when we want to notify dependants.\n node.dependsOn.add(afterNode);\n afterNode.dependants.add(node);\n }\n }\n }\n if (options.beforePolicies) {\n for (const beforePolicyName of options.beforePolicies) {\n const beforeNode = policyMap.get(beforePolicyName);\n if (beforeNode) {\n // To execute before another node, make it\n // depend on the current node.\n beforeNode.dependsOn.add(node);\n node.dependants.add(beforeNode);\n }\n }\n }\n }\n\n function walkPhase(phase: Phase): void {\n phase.hasRun = true;\n // Sets iterate in insertion order\n for (const node of phase.policies) {\n if (node.afterPhase && (!node.afterPhase.hasRun || node.afterPhase.policies.size)) {\n // If this node is waiting on a phase to complete,\n // we need to skip it for now.\n // Even if the phase is empty, we should wait for it\n // to be walked to avoid re-ordering policies.\n continue;\n }\n if (node.dependsOn.size === 0) {\n // If there's nothing else we're waiting for, we can\n // add this policy to the result list.\n result.push(node.policy);\n // Notify anything that depends on this policy that\n // the policy has been scheduled.\n for (const dependant of node.dependants) {\n dependant.dependsOn.delete(node);\n }\n policyMap.delete(node.policy.name);\n phase.policies.delete(node);\n }\n }\n }\n\n function walkPhases(): void {\n for (const phase of orderedPhases) {\n walkPhase(phase);\n // if the phase isn't complete\n if (phase.policies.size > 0 && phase !== noPhase) {\n if (!noPhase.hasRun) {\n // Try running noPhase to see if that unblocks this phase next tick.\n // This can happen if a phase that happens before noPhase\n // is waiting on a noPhase policy to complete.\n walkPhase(noPhase);\n }\n // Don't proceed to the next phase until this phase finishes.\n return;\n }\n\n if (phase.hasAfterPolicies) {\n // Run any policies unblocked by this phase\n walkPhase(noPhase);\n }\n }\n }\n\n // Iterate until we've put every node in the result list.\n let iteration = 0;\n while (policyMap.size > 0) {\n iteration++;\n const initialResultLength = result.length;\n // Keep walking each phase in order until we can order every node.\n walkPhases();\n // The result list *should* get at least one larger each time\n // after the first full pass.\n // Otherwise, we're going to loop forever.\n if (result.length <= initialResultLength && iteration > 1) {\n throw new Error(\"Cannot satisfy policy dependencies due to requirements cycle.\");\n }\n }\n\n return result;\n }\n}\n\n/**\n * Creates a totally empty pipeline.\n * Useful for testing or creating a custom one.\n */\nexport function createEmptyPipeline(): Pipeline {\n return HttpPipeline.create();\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FormDataMap, HttpHeaders, HttpMethods, MultipartRequestBody, PipelineRequest, ProxySettings, RequestBodyType, TransferProgressEvent } from "./interfaces.js";
|
|
2
|
-
import { AbortSignalLike } from "./abort-controller/AbortSignalLike.js";
|
|
3
|
-
import { OperationTracingOptions } from "./tracing/interfaces.js";
|
|
1
|
+
import type { FormDataMap, HttpHeaders, HttpMethods, MultipartRequestBody, PipelineRequest, ProxySettings, RequestBodyType, TransferProgressEvent } from "./interfaces.js";
|
|
2
|
+
import type { AbortSignalLike } from "./abort-controller/AbortSignalLike.js";
|
|
3
|
+
import type { OperationTracingOptions } from "./tracing/interfaces.js";
|
|
4
4
|
/**
|
|
5
5
|
* Settings to initialize a request.
|
|
6
6
|
* Almost equivalent to Partial<PipelineRequest>, but url is mandatory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipelineRequest.d.ts","sourceRoot":"","sources":["../../src/pipelineRequest.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"pipelineRequest.d.ts","sourceRoot":"","sources":["../../src/pipelineRequest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW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