@typespec/ts-http-runtime 0.3.4-alpha.20260302.3 → 0.3.4
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/client/sendRequest.d.ts +10 -1
- package/dist/browser/client/sendRequest.js +8 -2
- package/dist/browser/client/sendRequest.js.map +1 -1
- package/dist/browser/defaultHttpClient.d.ts +1 -1
- package/dist/browser/defaultHttpClient.js +1 -1
- package/dist/browser/defaultHttpClient.js.map +1 -0
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +0 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/logger/log.d.ts +1 -1
- package/dist/browser/logger/log.js +1 -1
- package/dist/browser/logger/log.js.map +1 -0
- package/dist/browser/pipelineRequest.d.ts +1 -1
- package/dist/browser/pipelineRequest.js.map +1 -1
- package/dist/browser/policies/decompressResponsePolicy.d.ts +3 -2
- package/dist/browser/policies/decompressResponsePolicy.js +1 -4
- package/dist/browser/policies/decompressResponsePolicy.js.map +1 -0
- package/dist/browser/policies/internal.d.ts +7 -7
- package/dist/browser/policies/internal.js +2 -2
- package/dist/browser/policies/internal.js.map +1 -1
- package/dist/browser/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/browser/policies/proxyPolicy.common.js +2 -2
- package/dist/browser/policies/proxyPolicy.common.js.map +1 -1
- package/dist/browser/policies/proxyPolicy.d.ts +1 -1
- package/dist/browser/policies/proxyPolicy.js +1 -1
- package/dist/browser/policies/proxyPolicy.js.map +1 -0
- package/dist/browser/policies/redirectPolicy.d.ts +7 -0
- package/dist/browser/policies/redirectPolicy.js +13 -4
- package/dist/browser/policies/redirectPolicy.js.map +1 -1
- package/dist/browser/util/bytesEncoding.d.ts +1 -1
- package/dist/browser/util/bytesEncoding.js +1 -1
- package/dist/browser/util/bytesEncoding.js.map +1 -0
- package/dist/browser/util/concat.common.d.ts +1 -2
- package/dist/browser/util/concat.common.js.map +1 -1
- package/dist/browser/util/concat.d.ts +1 -1
- package/dist/browser/util/concat.js +1 -1
- package/dist/browser/util/concat.js.map +1 -0
- package/dist/browser/util/inspect.d.ts +1 -1
- package/dist/browser/util/inspect.js +1 -1
- package/dist/browser/util/inspect.js.map +1 -0
- package/dist/browser/util/sha256.d.ts +1 -1
- package/dist/browser/util/sha256.js +1 -1
- package/dist/browser/util/sha256.js.map +1 -0
- package/dist/browser/util/userAgentPlatform.d.ts +1 -1
- package/dist/browser/util/userAgentPlatform.js +1 -1
- package/dist/browser/util/userAgentPlatform.js.map +1 -0
- package/dist/browser/util/uuidUtils.d.ts +1 -1
- package/dist/browser/util/uuidUtils.js +1 -1
- package/dist/browser/util/uuidUtils.js.map +1 -0
- package/dist/commonjs/abort-controller/AbortError.js +30 -40
- package/dist/commonjs/abort-controller/AbortError.js.map +7 -1
- package/dist/commonjs/auth/credentials.js +36 -25
- package/dist/commonjs/auth/credentials.js.map +7 -1
- package/dist/commonjs/auth/oauth2Flows.js +15 -5
- package/dist/commonjs/auth/oauth2Flows.js.map +7 -1
- package/dist/commonjs/auth/schemes.js +15 -5
- package/dist/commonjs/auth/schemes.js.map +7 -1
- package/dist/commonjs/client/apiVersionPolicy.js +39 -25
- package/dist/commonjs/client/apiVersionPolicy.js.map +7 -1
- package/dist/commonjs/client/clientHelpers.js +62 -39
- package/dist/commonjs/client/clientHelpers.js.map +7 -1
- package/dist/commonjs/client/common.js +15 -5
- package/dist/commonjs/client/common.js.map +7 -1
- package/dist/commonjs/client/getClient.js +170 -82
- package/dist/commonjs/client/getClient.js.map +7 -1
- package/dist/commonjs/client/multipart.js +119 -110
- package/dist/commonjs/client/multipart.js.map +7 -1
- package/dist/commonjs/client/operationOptionHelpers.js +36 -21
- package/dist/commonjs/client/operationOptionHelpers.js.map +7 -1
- package/dist/commonjs/client/restError.js +44 -26
- package/dist/commonjs/client/restError.js.map +7 -1
- package/dist/commonjs/client/sendRequest.d.ts +10 -1
- package/dist/commonjs/client/sendRequest.js +150 -164
- package/dist/commonjs/client/sendRequest.js.map +7 -1
- package/dist/commonjs/client/urlHelpers.js +124 -131
- package/dist/commonjs/client/urlHelpers.js.map +7 -1
- package/dist/commonjs/constants.js +30 -8
- package/dist/commonjs/constants.js.map +7 -1
- package/dist/commonjs/createPipelineFromOptions.js +56 -45
- package/dist/commonjs/createPipelineFromOptions.js.map +7 -1
- package/dist/commonjs/defaultHttpClient.js +28 -11
- package/dist/commonjs/defaultHttpClient.js.map +7 -1
- package/dist/commonjs/fetchHttpClient.js +211 -256
- package/dist/commonjs/fetchHttpClient.js.map +7 -1
- package/dist/commonjs/httpHeaders.js +97 -82
- package/dist/commonjs/httpHeaders.js.map +7 -1
- package/dist/commonjs/index.d.ts +2 -2
- package/dist/commonjs/index.js +67 -36
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/interfaces.js +15 -5
- package/dist/commonjs/interfaces.js.map +7 -1
- package/dist/commonjs/log.js +28 -8
- package/dist/commonjs/log.js.map +7 -1
- package/dist/commonjs/logger/debug.js +150 -155
- package/dist/commonjs/logger/debug.js.map +7 -1
- package/dist/commonjs/logger/internal.js +27 -8
- package/dist/commonjs/logger/internal.js.map +7 -1
- package/dist/commonjs/logger/log.common.js +39 -23
- package/dist/commonjs/logger/log.common.js.map +7 -1
- package/dist/commonjs/logger/log.js +40 -11
- package/dist/commonjs/logger/log.js.map +7 -1
- package/dist/commonjs/logger/logger.js +120 -110
- package/dist/commonjs/logger/logger.js.map +7 -1
- package/dist/commonjs/nodeHttpClient.js +313 -321
- package/dist/commonjs/nodeHttpClient.js.map +7 -1
- package/dist/commonjs/pipeline.js +190 -247
- package/dist/commonjs/pipeline.js.map +7 -1
- package/dist/commonjs/pipelineRequest.d.ts +1 -1
- package/dist/commonjs/pipelineRequest.js +69 -54
- package/dist/commonjs/pipelineRequest.js.map +7 -1
- package/dist/commonjs/policies/agentPolicy.js +38 -24
- package/dist/commonjs/policies/agentPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js +45 -32
- package/dist/commonjs/policies/auth/apiKeyAuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js +50 -32
- package/dist/commonjs/policies/auth/basicAuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js +47 -32
- package/dist/commonjs/policies/auth/bearerAuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/auth/checkInsecureConnection.js +47 -44
- package/dist/commonjs/policies/auth/checkInsecureConnection.js.map +7 -1
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js +45 -32
- package/dist/commonjs/policies/auth/oauth2AuthenticationPolicy.js.map +7 -1
- package/dist/commonjs/policies/decompressResponsePolicy.js +38 -25
- package/dist/commonjs/policies/decompressResponsePolicy.js.map +7 -1
- package/dist/commonjs/policies/defaultRetryPolicy.js +39 -27
- package/dist/commonjs/policies/defaultRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/exponentialRetryPolicy.js +43 -26
- package/dist/commonjs/policies/exponentialRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/formDataPolicy.js +101 -90
- package/dist/commonjs/policies/formDataPolicy.js.map +7 -1
- package/dist/commonjs/policies/internal.d.ts +7 -7
- package/dist/commonjs/policies/internal.js +94 -48
- package/dist/commonjs/policies/internal.js.map +7 -1
- package/dist/commonjs/policies/logPolicy.js +49 -35
- package/dist/commonjs/policies/logPolicy.js.map +7 -1
- package/dist/commonjs/policies/multipartPolicy.js +117 -99
- package/dist/commonjs/policies/multipartPolicy.js.map +7 -1
- package/dist/commonjs/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/commonjs/policies/proxyPolicy.common.js +38 -25
- package/dist/commonjs/policies/proxyPolicy.common.js.map +7 -1
- package/dist/commonjs/policies/proxyPolicy.js +160 -171
- package/dist/commonjs/policies/proxyPolicy.js.map +7 -1
- package/dist/commonjs/policies/redirectPolicy.d.ts +7 -0
- package/dist/commonjs/policies/redirectPolicy.js +62 -51
- package/dist/commonjs/policies/redirectPolicy.js.map +7 -1
- package/dist/commonjs/policies/retryPolicy.js +123 -105
- package/dist/commonjs/policies/retryPolicy.js.map +7 -1
- package/dist/commonjs/policies/systemErrorRetryPolicy.js +46 -31
- package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/throttlingRetryPolicy.js +38 -30
- package/dist/commonjs/policies/throttlingRetryPolicy.js.map +7 -1
- package/dist/commonjs/policies/tlsPolicy.js +38 -24
- package/dist/commonjs/policies/tlsPolicy.js.map +7 -1
- package/dist/commonjs/policies/userAgentPolicy.js +41 -28
- package/dist/commonjs/policies/userAgentPolicy.js.map +7 -1
- package/dist/commonjs/restError.js +93 -90
- package/dist/commonjs/restError.js.map +7 -1
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +63 -62
- package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +7 -1
- package/dist/commonjs/retryStrategies/retryStrategy.js +15 -5
- package/dist/commonjs/retryStrategies/retryStrategy.js.map +7 -1
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +58 -69
- package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +7 -1
- package/dist/commonjs/util/arrayBuffer.js +34 -21
- package/dist/commonjs/util/arrayBuffer.js.map +7 -1
- package/dist/commonjs/util/bytesEncoding.common.js +83 -100
- package/dist/commonjs/util/bytesEncoding.common.js.map +7 -1
- package/dist/commonjs/util/bytesEncoding.js +30 -21
- package/dist/commonjs/util/bytesEncoding.js.map +7 -1
- package/dist/commonjs/util/checkEnvironment.js +45 -44
- package/dist/commonjs/util/checkEnvironment.js.map +7 -1
- package/dist/commonjs/util/concat.common.d.ts +1 -2
- package/dist/commonjs/util/concat.common.js +51 -52
- package/dist/commonjs/util/concat.common.js.map +7 -1
- package/dist/commonjs/util/concat.js +70 -61
- package/dist/commonjs/util/concat.js.map +7 -1
- package/dist/commonjs/util/delay.js +31 -21
- package/dist/commonjs/util/delay.js.map +7 -1
- package/dist/commonjs/util/error.js +33 -17
- package/dist/commonjs/util/error.js.map +7 -1
- package/dist/commonjs/util/helpers.js +65 -57
- package/dist/commonjs/util/helpers.js.map +7 -1
- package/dist/commonjs/util/inspect.common.js +27 -7
- package/dist/commonjs/util/inspect.common.js.map +7 -1
- package/dist/commonjs/util/inspect.js +28 -8
- package/dist/commonjs/util/inspect.js.map +7 -1
- package/dist/commonjs/util/internal.js +67 -32
- package/dist/commonjs/util/internal.js.map +7 -1
- package/dist/commonjs/util/object.js +27 -15
- package/dist/commonjs/util/object.js.map +7 -1
- package/dist/commonjs/util/random.js +30 -22
- package/dist/commonjs/util/random.js.map +7 -1
- package/dist/commonjs/util/sanitizer.js +157 -148
- package/dist/commonjs/util/sanitizer.js.map +7 -1
- package/dist/commonjs/util/sha256.common.js +61 -45
- package/dist/commonjs/util/sha256.common.js.map +7 -1
- package/dist/commonjs/util/sha256.js +32 -22
- package/dist/commonjs/util/sha256.js.map +7 -1
- package/dist/commonjs/util/typeGuards.js +41 -21
- package/dist/commonjs/util/typeGuards.js.map +7 -1
- package/dist/commonjs/util/userAgent.js +43 -28
- package/dist/commonjs/util/userAgent.js.map +7 -1
- package/dist/commonjs/util/userAgentPlatform.js +51 -29
- package/dist/commonjs/util/userAgentPlatform.js.map +7 -1
- package/dist/commonjs/util/uuidUtils.common.js +43 -39
- package/dist/commonjs/util/uuidUtils.common.js.map +7 -1
- package/dist/commonjs/util/uuidUtils.js +27 -12
- package/dist/commonjs/util/uuidUtils.js.map +7 -1
- package/dist/commonjs/xhrHttpClient.js +171 -163
- package/dist/commonjs/xhrHttpClient.js.map +7 -1
- package/dist/esm/client/sendRequest.d.ts +10 -1
- package/dist/esm/client/sendRequest.js +8 -2
- package/dist/esm/client/sendRequest.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pipelineRequest.d.ts +1 -1
- package/dist/esm/pipelineRequest.js.map +1 -1
- package/dist/esm/policies/internal.d.ts +7 -7
- package/dist/esm/policies/internal.js +2 -2
- package/dist/esm/policies/internal.js.map +1 -1
- package/dist/esm/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/esm/policies/proxyPolicy.common.js +2 -2
- package/dist/esm/policies/proxyPolicy.common.js.map +1 -1
- package/dist/esm/policies/redirectPolicy.d.ts +7 -0
- package/dist/esm/policies/redirectPolicy.js +13 -4
- package/dist/esm/policies/redirectPolicy.js.map +1 -1
- package/dist/esm/util/concat.common.d.ts +1 -2
- package/dist/esm/util/concat.common.js.map +1 -1
- package/dist/react-native/client/sendRequest.d.ts +10 -1
- package/dist/react-native/client/sendRequest.js +8 -2
- package/dist/react-native/client/sendRequest.js.map +1 -1
- package/dist/react-native/defaultHttpClient.d.ts +1 -1
- package/dist/react-native/defaultHttpClient.js +1 -1
- package/dist/react-native/defaultHttpClient.js.map +1 -0
- package/dist/react-native/index.d.ts +2 -2
- package/dist/react-native/index.js +0 -2
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/logger/log.d.ts +1 -1
- package/dist/react-native/logger/log.js +1 -1
- package/dist/react-native/logger/log.js.map +1 -0
- package/dist/react-native/pipelineRequest.d.ts +1 -1
- package/dist/react-native/pipelineRequest.js.map +1 -1
- package/dist/react-native/policies/internal.d.ts +7 -7
- package/dist/react-native/policies/internal.js +2 -2
- package/dist/react-native/policies/internal.js.map +1 -1
- package/dist/react-native/policies/proxyPolicy.common.d.ts +7 -3
- package/dist/react-native/policies/proxyPolicy.common.js +2 -2
- package/dist/react-native/policies/proxyPolicy.common.js.map +1 -1
- package/dist/react-native/policies/proxyPolicy.d.ts +1 -1
- package/dist/react-native/policies/proxyPolicy.js +1 -1
- package/dist/react-native/policies/proxyPolicy.js.map +1 -0
- package/dist/react-native/policies/redirectPolicy.d.ts +7 -0
- package/dist/react-native/policies/redirectPolicy.js +13 -4
- package/dist/react-native/policies/redirectPolicy.js.map +1 -1
- package/dist/react-native/util/bytesEncoding.d.ts +1 -1
- package/dist/react-native/util/bytesEncoding.js +1 -1
- package/dist/react-native/util/bytesEncoding.js.map +1 -0
- package/dist/react-native/util/concat.common.d.ts +1 -2
- package/dist/react-native/util/concat.common.js.map +1 -1
- package/dist/react-native/util/concat.d.ts +1 -1
- package/dist/react-native/util/concat.js +1 -1
- package/dist/react-native/util/concat.js.map +1 -0
- package/dist/react-native/util/inspect.d.ts +1 -1
- package/dist/react-native/util/inspect.js +1 -1
- package/dist/react-native/util/inspect.js.map +1 -0
- package/dist/react-native/util/sha256.d.ts +1 -1
- package/dist/react-native/util/sha256.js +1 -1
- package/dist/react-native/util/sha256.js.map +1 -0
- package/dist/react-native/util/userAgentPlatform.d.ts +1 -1
- package/dist/react-native/util/userAgentPlatform.js +1 -1
- package/dist/react-native/util/userAgentPlatform.js.map +1 -0
- package/dist/react-native/util/uuidUtils.d.ts +1 -1
- package/dist/react-native/util/uuidUtils.js +1 -1
- package/dist/react-native/util/uuidUtils.js.map +1 -0
- package/package.json +3 -23
- package/dist/browser/defaultHttpClient-browser.mjs.map +0 -1
- package/dist/browser/logger/log-browser.mjs.map +0 -1
- package/dist/browser/policies/decompressResponsePolicy-browser.mjs.map +0 -1
- package/dist/browser/policies/proxyPolicy-browser.mjs.map +0 -1
- package/dist/browser/util/bytesEncoding-browser.mjs.map +0 -1
- package/dist/browser/util/concat-browser.mjs.map +0 -1
- package/dist/browser/util/inspect-browser.mjs.map +0 -1
- package/dist/browser/util/sha256-browser.mjs.map +0 -1
- package/dist/browser/util/userAgentPlatform-browser.mjs.map +0 -1
- package/dist/browser/util/uuidUtils-browser.mjs.map +0 -1
- package/dist/react-native/defaultHttpClient-react-native.mjs.map +0 -1
- package/dist/react-native/logger/log-react-native.mjs.map +0 -1
- package/dist/react-native/policies/proxyPolicy-react-native.mjs.map +0 -1
- package/dist/react-native/util/bytesEncoding-react-native.mjs.map +0 -1
- package/dist/react-native/util/concat-react-native.mjs.map +0 -1
- package/dist/react-native/util/inspect-react-native.mjs.map +0 -1
- package/dist/react-native/util/sha256-react-native.mjs.map +0 -1
- package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +0 -1
- package/dist/react-native/util/uuidUtils-react-native.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HttpClient, HttpMethods } from "../interfaces.js";
|
|
1
|
+
import type { HttpClient, HttpMethods, MultipartRequestBody, RequestBodyType } from "../interfaces.js";
|
|
2
2
|
import type { Pipeline } from "../pipeline.js";
|
|
3
3
|
import type { HttpResponse, RequestParameters } from "./common.js";
|
|
4
4
|
/**
|
|
@@ -14,4 +14,13 @@ export declare function sendRequest(method: HttpMethods, url: string, pipeline:
|
|
|
14
14
|
export interface InternalRequestParameters extends RequestParameters {
|
|
15
15
|
responseAsStream?: boolean;
|
|
16
16
|
}
|
|
17
|
+
interface RequestBody {
|
|
18
|
+
body?: RequestBodyType;
|
|
19
|
+
multipartBody?: MultipartRequestBody;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Prepares the body before sending the request
|
|
23
|
+
*/
|
|
24
|
+
export declare function getRequestBody(body?: unknown, contentType?: string): RequestBody;
|
|
25
|
+
export {};
|
|
17
26
|
//# sourceMappingURL=sendRequest.d.ts.map
|
|
@@ -4,7 +4,7 @@ import { isRestError, RestError } from "../restError.js";
|
|
|
4
4
|
import { createHttpHeaders } from "../httpHeaders.js";
|
|
5
5
|
import { createPipelineRequest } from "../pipelineRequest.js";
|
|
6
6
|
import { getCachedDefaultHttpsClient } from "./clientHelpers.js";
|
|
7
|
-
import { isReadableStream } from "../util/typeGuards.js";
|
|
7
|
+
import { isBlob, isReadableStream } from "../util/typeGuards.js";
|
|
8
8
|
import { buildMultipartBody } from "./multipart.js";
|
|
9
9
|
/**
|
|
10
10
|
* Helper function to send request used by the client
|
|
@@ -67,6 +67,9 @@ function getContentType(body) {
|
|
|
67
67
|
if (ArrayBuffer.isView(body)) {
|
|
68
68
|
return "application/octet-stream";
|
|
69
69
|
}
|
|
70
|
+
if (isBlob(body) && body.type) {
|
|
71
|
+
return body.type;
|
|
72
|
+
}
|
|
70
73
|
if (typeof body === "string") {
|
|
71
74
|
try {
|
|
72
75
|
JSON.parse(body);
|
|
@@ -110,13 +113,16 @@ function buildPipelineRequest(method, url, options = {}) {
|
|
|
110
113
|
/**
|
|
111
114
|
* Prepares the body before sending the request
|
|
112
115
|
*/
|
|
113
|
-
function getRequestBody(body, contentType = "") {
|
|
116
|
+
export function getRequestBody(body, contentType = "") {
|
|
114
117
|
if (body === undefined) {
|
|
115
118
|
return { body: undefined };
|
|
116
119
|
}
|
|
117
120
|
if (typeof FormData !== "undefined" && body instanceof FormData) {
|
|
118
121
|
return { body };
|
|
119
122
|
}
|
|
123
|
+
if (isBlob(body)) {
|
|
124
|
+
return { body };
|
|
125
|
+
}
|
|
120
126
|
if (isReadableStream(body) || typeof body === "function") {
|
|
121
127
|
return { body };
|
|
122
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendRequest.js","sourceRoot":"","sources":["../../../src/client/sendRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAmB,EACnB,GAAW,EACX,QAAkB,EAClB,UAAqC,EAAE,EACvC,gBAA6B;IAE7B,MAAM,UAAU,GAAG,gBAAgB,IAAI,2BAA2B,EAAE,CAAC;IACrE,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AAyD;QACzD,6BAA6B;QAC7B,IAAI,SAAS,KAAK,kBAAkB,EAAE,CAAC;YACrC,MAAM,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1C,CAAC;QAED,gEAAgE;QAChE,cAAc;QACd,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,QAA0B,EAAE,GAAQ;IAC5D,MAAM,GAAG,GAAG,UAAU,GAAG,gDAAgD,QAAQ,CAAC,UAAU,GAAG,CAAC;IAChG,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,SAAS,CAAC,WAAW,CAAC;IAClD,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE;QACxB,IAAI,EAAE,OAAO;QACb,UAAU,EAAE,QAAQ,CAAC,MAAM;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpClient,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n PipelineResponse,\n RequestBodyType,\n} from \"../interfaces.js\";\nimport { isRestError, RestError } from \"../restError.js\";\nimport type { Pipeline } from \"../pipeline.js\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport { createPipelineRequest } from \"../pipelineRequest.js\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers.js\";\nimport { isReadableStream } from \"../util/typeGuards.js\";\nimport type { HttpResponse, RequestParameters } from \"./common.js\";\nimport type { PartDescriptor } from \"./multipart.js\";\nimport { buildMultipartBody } from \"./multipart.js\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @param customHttpClient - a custom HttpClient to use when making the request\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: InternalRequestParameters = {},\n customHttpClient?: HttpClient,\n): Promise<HttpResponse> {\n const httpClient = customHttpClient ?? getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n\n try {\n const response = await pipeline.sendRequest(httpClient, request);\n const headers = response.headers.toJSON();\n const stream = response.readableStreamBody ?? response.browserStreamBody;\n const parsedBody =\n options.responseAsStream || stream !== undefined ? undefined : getResponseBody(response);\n const body = stream ?? parsedBody;\n\n if (options?.onResponse) {\n options.onResponse({ ...response, request, rawHeaders: headers, parsedBody });\n }\n\n return {\n request,\n headers,\n status: `${response.status}`,\n body,\n };\n } catch (e: unknown) {\n if (isRestError(e) && e.response && options.onResponse) {\n const { response } = e;\n const rawHeaders = response.headers.toJSON();\n // UNBRANDED DIFFERENCE: onResponse callback does not have a second __legacyError property\n options?.onResponse({ ...response, request, rawHeaders }, e);\n }\n\n throw e;\n }\n}\n\n/**\n * Function to determine the request content type\n * @param options - request options InternalRequestParameters\n * @returns returns the content-type\n */\nfunction getRequestContentType(options: InternalRequestParameters = {}): string | undefined {\n return (\n options.contentType ??\n (options.headers?.[\"content-type\"] as string) ??\n getContentType(options.body)\n );\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string | undefined {\n if (body === undefined) {\n return undefined;\n }\n\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n if (typeof body === \"string\") {\n try {\n JSON.parse(body);\n return \"application/json\";\n } catch (error: any) {\n // If we fail to parse the body, it is not json\n return undefined;\n }\n }\n // By default return json\n return \"application/json\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {},\n): PipelineRequest {\n const requestContentType = getRequestContentType(options);\n const { body, multipartBody } = getRequestBody(options.body, requestContentType);\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? options.headers?.accept ?? \"application/json\",\n ...(requestContentType && {\n \"content-type\": requestContentType,\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n multipartBody,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n abortSignal: options.abortSignal,\n onUploadProgress: options.onUploadProgress,\n onDownloadProgress: options.onDownloadProgress,\n timeout: options.timeout,\n enableBrowserStreams: true,\n streamResponseStatusCodes: options.responseAsStream\n ? new Set([Number.POSITIVE_INFINITY])\n : undefined,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n multipartBody?: MultipartRequestBody;\n}\n\n/**\n * Prepares the body before sending the request\n */\nfunction getRequestBody(body?: unknown, contentType: string = \"\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n if (typeof FormData !== \"undefined\" && body instanceof FormData) {\n return { body };\n }\n\n if (isReadableStream(body) || typeof body === \"function\") {\n return { body } as RequestBody;\n }\n\n if (ArrayBuffer.isView(body)) {\n return { body: body instanceof Uint8Array ? body : JSON.stringify(body) };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n switch (firstType) {\n case \"application/json\":\n return { body: JSON.stringify(body) };\n case \"multipart/form-data\":\n if (Array.isArray(body)) {\n return { multipartBody: buildMultipartBody(body as PartDescriptor[]) };\n }\n return { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n if (typeof body === \"string\") {\n return { body };\n }\n return { body: JSON.stringify(body) };\n }\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(response: PipelineResponse): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error: any) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sendRequest.js","sourceRoot":"","sources":["../../../src/client/sendRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAmB,EACnB,GAAW,EACX,QAAkB,EAClB,UAAqC,EAAE,EACvC,gBAA6B;IAE7B,MAAM,UAAU,GAAG,gBAAgB,IAAI,2BAA2B,EAAE,CAAC;IACrE,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAE3D,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACjE,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QAC1C,MAA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S,KAAK,kBAAkB,EAAE,CAAC;YACrC,MAAM,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC1C,CAAC;QAED,gEAAgE;QAChE,cAAc;QACd,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,QAA0B,EAAE,GAAQ;IAC5D,MAAM,GAAG,GAAG,UAAU,GAAG,gDAAgD,QAAQ,CAAC,UAAU,GAAG,CAAC;IAChG,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,IAAI,SAAS,CAAC,WAAW,CAAC;IAClD,OAAO,IAAI,SAAS,CAAC,GAAG,EAAE;QACxB,IAAI,EAAE,OAAO;QACb,UAAU,EAAE,QAAQ,CAAC,MAAM;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,QAAQ,EAAE,QAAQ;KACnB,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n HttpClient,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n PipelineResponse,\n RequestBodyType,\n} from \"../interfaces.js\";\nimport { isRestError, RestError } from \"../restError.js\";\nimport type { Pipeline } from \"../pipeline.js\";\nimport { createHttpHeaders } from \"../httpHeaders.js\";\nimport { createPipelineRequest } from \"../pipelineRequest.js\";\nimport { getCachedDefaultHttpsClient } from \"./clientHelpers.js\";\nimport { isBlob, isReadableStream } from \"../util/typeGuards.js\";\nimport type { HttpResponse, RequestParameters } from \"./common.js\";\nimport type { PartDescriptor } from \"./multipart.js\";\nimport { buildMultipartBody } from \"./multipart.js\";\n\n/**\n * Helper function to send request used by the client\n * @param method - method to use to send the request\n * @param url - url to send the request to\n * @param pipeline - pipeline with the policies to run when sending the request\n * @param options - request options\n * @param customHttpClient - a custom HttpClient to use when making the request\n * @returns returns and HttpResponse\n */\nexport async function sendRequest(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: InternalRequestParameters = {},\n customHttpClient?: HttpClient,\n): Promise<HttpResponse> {\n const httpClient = customHttpClient ?? getCachedDefaultHttpsClient();\n const request = buildPipelineRequest(method, url, options);\n\n try {\n const response = await pipeline.sendRequest(httpClient, request);\n const headers = response.headers.toJSON();\n const stream = response.readableStreamBody ?? response.browserStreamBody;\n const parsedBody =\n options.responseAsStream || stream !== undefined ? undefined : getResponseBody(response);\n const body = stream ?? parsedBody;\n\n if (options?.onResponse) {\n options.onResponse({ ...response, request, rawHeaders: headers, parsedBody });\n }\n\n return {\n request,\n headers,\n status: `${response.status}`,\n body,\n };\n } catch (e: unknown) {\n if (isRestError(e) && e.response && options.onResponse) {\n const { response } = e;\n const rawHeaders = response.headers.toJSON();\n // UNBRANDED DIFFERENCE: onResponse callback does not have a second __legacyError property\n options?.onResponse({ ...response, request, rawHeaders }, e);\n }\n\n throw e;\n }\n}\n\n/**\n * Function to determine the request content type\n * @param options - request options InternalRequestParameters\n * @returns returns the content-type\n */\nfunction getRequestContentType(options: InternalRequestParameters = {}): string | undefined {\n return (\n options.contentType ??\n (options.headers?.[\"content-type\"] as string) ??\n getContentType(options.body)\n );\n}\n\n/**\n * Function to determine the content-type of a body\n * this is used if an explicit content-type is not provided\n * @param body - body in the request\n * @returns returns the content-type\n */\nfunction getContentType(body: any): string | undefined {\n if (body === undefined) {\n return undefined;\n }\n\n if (ArrayBuffer.isView(body)) {\n return \"application/octet-stream\";\n }\n\n if (isBlob(body) && body.type) {\n return body.type;\n }\n\n if (typeof body === \"string\") {\n try {\n JSON.parse(body);\n return \"application/json\";\n } catch (error: any) {\n // If we fail to parse the body, it is not json\n return undefined;\n }\n }\n // By default return json\n return \"application/json\";\n}\n\nexport interface InternalRequestParameters extends RequestParameters {\n responseAsStream?: boolean;\n}\n\nfunction buildPipelineRequest(\n method: HttpMethods,\n url: string,\n options: InternalRequestParameters = {},\n): PipelineRequest {\n const requestContentType = getRequestContentType(options);\n const { body, multipartBody } = getRequestBody(options.body, requestContentType);\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? options.headers?.accept ?? \"application/json\",\n ...(requestContentType && {\n \"content-type\": requestContentType,\n }),\n });\n\n return createPipelineRequest({\n url,\n method,\n body,\n multipartBody,\n headers,\n allowInsecureConnection: options.allowInsecureConnection,\n abortSignal: options.abortSignal,\n onUploadProgress: options.onUploadProgress,\n onDownloadProgress: options.onDownloadProgress,\n timeout: options.timeout,\n enableBrowserStreams: true,\n streamResponseStatusCodes: options.responseAsStream\n ? new Set([Number.POSITIVE_INFINITY])\n : undefined,\n });\n}\n\ninterface RequestBody {\n body?: RequestBodyType;\n multipartBody?: MultipartRequestBody;\n}\n\n/**\n * Prepares the body before sending the request\n */\nexport function getRequestBody(body?: unknown, contentType: string = \"\"): RequestBody {\n if (body === undefined) {\n return { body: undefined };\n }\n\n if (typeof FormData !== \"undefined\" && body instanceof FormData) {\n return { body };\n }\n\n if (isBlob(body)) {\n return { body };\n }\n\n if (isReadableStream(body) || typeof body === \"function\") {\n return { body } as RequestBody;\n }\n\n if (ArrayBuffer.isView(body)) {\n return { body: body instanceof Uint8Array ? body : JSON.stringify(body) };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n switch (firstType) {\n case \"application/json\":\n return { body: JSON.stringify(body) };\n case \"multipart/form-data\":\n if (Array.isArray(body)) {\n return { multipartBody: buildMultipartBody(body as PartDescriptor[]) };\n }\n return { body: JSON.stringify(body) };\n case \"text/plain\":\n return { body: String(body) };\n default:\n if (typeof body === \"string\") {\n return { body };\n }\n return { body: JSON.stringify(body) };\n }\n}\n\n/**\n * Prepares the response body\n */\nfunction getResponseBody(response: PipelineResponse): RequestBodyType | undefined {\n // Set the default response type\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n const firstType = contentType.split(\";\")[0];\n const bodyToParse = response.bodyAsText ?? \"\";\n\n if (firstType === \"text/plain\") {\n return String(bodyToParse);\n }\n // Default to \"application/json\" and fallback to string;\n try {\n return bodyToParse ? JSON.parse(bodyToParse) : undefined;\n } catch (error: any) {\n // If we were supposed to get a JSON object and failed to\n // parse, throw a parse error\n if (firstType === \"application/json\") {\n throw createParseError(response, error);\n }\n\n // We are not sure how to handle the response so we return it as\n // plain text.\n return String(bodyToParse);\n }\n}\n\nfunction createParseError(response: PipelineResponse, err: any): RestError {\n const msg = `Error \"${err}\" occurred while parsing the response body - ${response.bodyAsText}.`;\n const errCode = err.code ?? RestError.PARSE_ERROR;\n return new RestError(msg, {\n code: errCode,\n statusCode: response.status,\n request: response.request,\n response: response,\n });\n}\n"]}
|
|
@@ -3,4 +3,4 @@ import type { HttpClient } from "./interfaces.js";
|
|
|
3
3
|
* Create the correct HttpClient for the current environment.
|
|
4
4
|
*/
|
|
5
5
|
export declare function createDefaultHttpClient(): HttpClient;
|
|
6
|
-
//# sourceMappingURL=defaultHttpClient
|
|
6
|
+
//# sourceMappingURL=defaultHttpClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultHttpClient.js","sourceRoot":"","sources":["../../src/defaultHttpClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,qBAAqB,EAAE,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient } from \"./interfaces.js\";\nimport { createFetchHttpClient } from \"./fetchHttpClient.js\";\n\n/**\n * Create the correct HttpClient for the current environment.\n */\nexport function createDefaultHttpClient(): HttpClient {\n return createFetchHttpClient();\n}\n"]}
|
package/dist/browser/index.d.ts
CHANGED
|
@@ -14,8 +14,8 @@ export { AbortError } from "./abort-controller/AbortError.js";
|
|
|
14
14
|
export { createClientLogger, getLogLevel, setLogLevel, TypeSpecRuntimeLogger, type Debugger, type TypeSpecRuntimeClientLogger, type TypeSpecRuntimeLogLevel, } from "./logger/logger.js";
|
|
15
15
|
export type { BodyPart, FormDataValue, RawHttpHeaders, KeyObject, PxfObject, HttpClient, PipelineRequest, PipelineResponse, SendRequest, TlsSettings, Agent, RequestBodyType, FormDataMap, HttpHeaders, HttpMethods, MultipartRequestBody, TransferProgressEvent, ProxySettings, RawHttpHeadersInput, PipelineRetryOptions, } from "./interfaces.js";
|
|
16
16
|
export { createHttpHeaders } from "./httpHeaders.js";
|
|
17
|
-
export * from "./auth/schemes.js";
|
|
18
|
-
export * from "./auth/oauth2Flows.js";
|
|
17
|
+
export type * from "./auth/schemes.js";
|
|
18
|
+
export type * from "./auth/oauth2Flows.js";
|
|
19
19
|
export { type BasicCredential, type BearerTokenCredential, type OAuth2TokenCredential, type GetOAuth2TokenOptions, type GetBearerTokenOptions, type ApiKeyCredential, type ClientCredential, } from "./auth/credentials.js";
|
|
20
20
|
export { createPipelineRequest, type PipelineRequestOptions } from "./pipelineRequest.js";
|
|
21
21
|
export { type Pipeline, type PipelinePolicy, type AddPolicyOptions, type PipelinePhase, createEmptyPipeline, } from "./pipeline.js";
|
package/dist/browser/index.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
export { AbortError } from "./abort-controller/AbortError.js";
|
|
4
4
|
export { createClientLogger, getLogLevel, setLogLevel, TypeSpecRuntimeLogger, } from "./logger/logger.js";
|
|
5
5
|
export { createHttpHeaders } from "./httpHeaders.js";
|
|
6
|
-
export * from "./auth/schemes.js";
|
|
7
|
-
export * from "./auth/oauth2Flows.js";
|
|
8
6
|
export { createPipelineRequest } from "./pipelineRequest.js";
|
|
9
7
|
export { createEmptyPipeline, } from "./pipeline.js";
|
|
10
8
|
export { RestError, isRestError } from "./restError.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,qBAAqB,GAItB,MAAM,oBAAoB,CAAC;AAwB5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,qBAAqB,GAItB,MAAM,oBAAoB,CAAC;AAwB5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAYrD,OAAO,EAAE,qBAAqB,EAA+B,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EAKL,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAyB,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAqB,MAAM,yBAAyB,CAAC;AACpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,mCAAmC,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\ndeclare global {\n interface FormData {}\n interface Blob {}\n interface File {}\n interface ReadableStream<R = any> {}\n interface TransformStream<I = any, O = any> {}\n}\n\nexport { AbortError } from \"./abort-controller/AbortError.js\";\nexport {\n createClientLogger,\n getLogLevel,\n setLogLevel,\n TypeSpecRuntimeLogger,\n type Debugger,\n type TypeSpecRuntimeClientLogger,\n type TypeSpecRuntimeLogLevel,\n} from \"./logger/logger.js\";\n\nexport type {\n BodyPart,\n FormDataValue,\n RawHttpHeaders,\n KeyObject,\n PxfObject,\n HttpClient,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n TlsSettings,\n Agent,\n RequestBodyType,\n FormDataMap,\n HttpHeaders,\n HttpMethods,\n MultipartRequestBody,\n TransferProgressEvent,\n ProxySettings,\n RawHttpHeadersInput,\n PipelineRetryOptions,\n} from \"./interfaces.js\";\nexport { createHttpHeaders } from \"./httpHeaders.js\";\nexport type * from \"./auth/schemes.js\";\nexport type * from \"./auth/oauth2Flows.js\";\nexport {\n type BasicCredential,\n type BearerTokenCredential,\n type OAuth2TokenCredential,\n type GetOAuth2TokenOptions,\n type GetBearerTokenOptions,\n type ApiKeyCredential,\n type ClientCredential,\n} from \"./auth/credentials.js\";\nexport { createPipelineRequest, type PipelineRequestOptions } from \"./pipelineRequest.js\";\nexport {\n type Pipeline,\n type PipelinePolicy,\n type AddPolicyOptions,\n type PipelinePhase,\n createEmptyPipeline,\n} from \"./pipeline.js\";\nexport { RestError, isRestError, type RestErrorOptions } from \"./restError.js\";\nexport { stringToUint8Array, uint8ArrayToString, type EncodingType } from \"./util/bytesEncoding.js\";\nexport { createDefaultHttpClient } from \"./defaultHttpClient.js\";\nexport { getClient } from \"./client/getClient.js\";\nexport { operationOptionsToRequestParameters } from \"./client/operationOptionHelpers.js\";\nexport { createRestError } from \"./client/restError.js\";\nexport type {\n Client,\n ClientOptions,\n OperationOptions,\n AdditionalPolicyConfig,\n PathUnchecked,\n PathUncheckedResponse,\n HttpResponse,\n RawResponseCallback,\n OperationRequestOptions,\n PathParameters,\n ResourceMethods,\n PathParameterWithOptions,\n StreamableMethod,\n RequestParameters,\n HttpNodeStreamResponse,\n HttpBrowserStreamResponse,\n FullOperationResponse,\n} from \"./client/common.js\";\nexport type { PipelineOptions, TelemetryOptions } from \"./createPipelineFromOptions.js\";\nexport type { LogPolicyOptions } from \"./policies/logPolicy.js\";\nexport type { RedirectPolicyOptions } from \"./policies/redirectPolicy.js\";\nexport type { UserAgentPolicyOptions } from \"./policies/userAgentPolicy.js\";\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { log } from "./log.common.js";
|
|
2
|
-
//# sourceMappingURL=log
|
|
2
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/logger/log.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { log } from \"./log.common.js\";\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormDataMap, HttpHeaders, HttpMethods, MultipartRequestBody, PipelineRequest, ProxySettings, RequestBodyType, TransferProgressEvent } from "./interfaces.js";
|
|
2
|
-
import { AuthScheme } from "./auth/schemes.js";
|
|
2
|
+
import type { AuthScheme } from "./auth/schemes.js";
|
|
3
3
|
/**
|
|
4
4
|
* Settings to initialize a request.
|
|
5
5
|
* Almost equivalent to Partial<PipelineRequest>, but url is mandatory.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipelineRequest.js","sourceRoot":"","sources":["../../src/pipelineRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAyHjD,MAAM,mBAAmB;IAChB,GAAG,CAAS;IACZ,MAAM,CAAc;IACpB,OAAO,CAAc;IACrB,OAAO,CAAS;IAChB,eAAe,CAAU;IACzB,IAAI,CAAmB;IACvB,aAAa,CAAwB;IACrC,QAAQ,CAAe;IACvB,yBAAyB,CAAe;IACxC,oBAAoB,CAAU;IAE9B,aAAa,CAAiB;IAC9B,gBAAgB,CAAU;IAC1B,WAAW,C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AC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IACzC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n FormDataMap,\n HttpHeaders,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n ProxySettings,\n RequestBodyType,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { randomUUID } from \"./util/uuidUtils.js\";\nimport { AuthScheme } from \"./auth/schemes.js\";\n\n/**\n * Settings to initialize a request.\n * Almost equivalent to Partial<PipelineRequest>, but url is mandatory.\n */\nexport interface PipelineRequestOptions {\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 * If credentials (cookies) should be sent along during an XHR.\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 */\n streamResponseStatusCodes?: Set<number>;\n\n /**\n * BROWSER ONLY\n *\n * A browser only option to enable use of the Streams API. If this option is set and streaming is used\n * (see `streamResponseStatusCodes`), the response will have a property `browserStream` instead of\n * `blobBody` which will be undefined.\n *\n * Default value is false\n */\n enableBrowserStreams?: boolean;\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?: AbortSignal;\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 * List of authentication schemes used for this specific request.\n * These schemes define how the request will be authenticated.\n *\n * If values are provided, these schemes override the client level authentication schemes.\n * If an empty array is provided, it explicitly specifies no authentication for the request.\n * If not provided at the request level, the client level authentication schemes will be used.\n */\n authSchemes?: AuthScheme[];\n\n /**\n * Additional options to set on the request. This provides a way to override\n * existing ones or provide request properties that are not declared.\n *\n * For possible valid properties, see\n * - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback\n * - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit\n *\n * WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.\n */\n requestOverrides?: Record<string, unknown>;\n}\n\nclass PipelineRequestImpl implements PipelineRequest {\n public url: string;\n public method: HttpMethods;\n public headers: HttpHeaders;\n public timeout: number;\n public withCredentials: boolean;\n public body?: RequestBodyType;\n public multipartBody?: MultipartRequestBody;\n public formData?: FormDataMap;\n public streamResponseStatusCodes?: Set<number>;\n public enableBrowserStreams: boolean;\n\n public proxySettings?: ProxySettings;\n public disableKeepAlive: boolean;\n public abortSignal?: AbortSignal;\n public requestId: string;\n public allowInsecureConnection?: boolean;\n public onUploadProgress?: (progress: TransferProgressEvent) => void;\n public onDownloadProgress?: (progress: TransferProgressEvent) => void;\n public requestOverrides?: Record<string, unknown>;\n public authSchemes?: AuthScheme[];\n\n constructor(options: PipelineRequestOptions) {\n this.url = options.url;\n this.body = options.body;\n this.headers = options.headers ?? createHttpHeaders();\n this.method = options.method ?? \"GET\";\n this.timeout = options.timeout ?? 0;\n this.multipartBody = options.multipartBody;\n this.formData = options.formData;\n this.disableKeepAlive = options.disableKeepAlive ?? false;\n this.proxySettings = options.proxySettings;\n this.streamResponseStatusCodes = options.streamResponseStatusCodes;\n this.withCredentials = options.withCredentials ?? false;\n this.abortSignal = options.abortSignal;\n this.onUploadProgress = options.onUploadProgress;\n this.onDownloadProgress = options.onDownloadProgress;\n this.requestId = options.requestId || randomUUID();\n this.allowInsecureConnection = options.allowInsecureConnection ?? false;\n this.enableBrowserStreams = options.enableBrowserStreams ?? false;\n this.requestOverrides = options.requestOverrides;\n this.authSchemes = options.authSchemes;\n }\n}\n\n/**\n * Creates a new pipeline request with the given options.\n * This method is to allow for the easy setting of default values and not required.\n * @param options - The options to create the request with.\n */\nexport function createPipelineRequest(options: PipelineRequestOptions): PipelineRequest {\n return new PipelineRequestImpl(options);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"pipelineRequest.js","sourceRoot":"","sources":["../../src/pipelineRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAyHjD,MAAM,mBAAmB;IAChB,GAAG,CAAS;IACZ,MAAM,CAAc;IACpB,OAAO,CAAc;IACrB,OAAO,CAAS;IAChB,eAAe,CAAU;IACzB,IAAI,CAAmB;IACvB,aAAa,CAAwB;IACrC,QAAQ,CAAe;IACvB,yBAAyB,CAAe;IACxC,oBAAoB,CAAU;IAE9B,aAAa,CAAiB;IAC9B,gBAAgB,CAAU;IAC1B,WAAW,CAAe;IAC1B,SAAS,CAAS;IAClB,uBAAuB,CAAW;IAClC,gBAAgB,CAA6C;IAC7D,kBAAkB,CAA6C;IAC/D,gBAAgB,CAA2B;IAC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AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,OAAO,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n FormDataMap,\n HttpHeaders,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n ProxySettings,\n RequestBodyType,\n TransferProgressEvent,\n} from \"./interfaces.js\";\nimport { createHttpHeaders } from \"./httpHeaders.js\";\nimport { randomUUID } from \"./util/uuidUtils.js\";\nimport type { AuthScheme } from \"./auth/schemes.js\";\n\n/**\n * Settings to initialize a request.\n * Almost equivalent to Partial<PipelineRequest>, but url is mandatory.\n */\nexport interface PipelineRequestOptions {\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 * If credentials (cookies) should be sent along during an XHR.\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 */\n streamResponseStatusCodes?: Set<number>;\n\n /**\n * BROWSER ONLY\n *\n * A browser only option to enable use of the Streams API. If this option is set and streaming is used\n * (see `streamResponseStatusCodes`), the response will have a property `browserStream` instead of\n * `blobBody` which will be undefined.\n *\n * Default value is false\n */\n enableBrowserStreams?: boolean;\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?: AbortSignal;\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 * List of authentication schemes used for this specific request.\n * These schemes define how the request will be authenticated.\n *\n * If values are provided, these schemes override the client level authentication schemes.\n * If an empty array is provided, it explicitly specifies no authentication for the request.\n * If not provided at the request level, the client level authentication schemes will be used.\n */\n authSchemes?: AuthScheme[];\n\n /**\n * Additional options to set on the request. This provides a way to override\n * existing ones or provide request properties that are not declared.\n *\n * For possible valid properties, see\n * - NodeJS https.request options: https://nodejs.org/api/http.html#httprequestoptions-callback\n * - Browser RequestInit: https://developer.mozilla.org/en-US/docs/Web/API/RequestInit\n *\n * WARNING: Options specified here will override any properties of same names when request is sent by {@link HttpClient}.\n */\n requestOverrides?: Record<string, unknown>;\n}\n\nclass PipelineRequestImpl implements PipelineRequest {\n public url: string;\n public method: HttpMethods;\n public headers: HttpHeaders;\n public timeout: number;\n public withCredentials: boolean;\n public body?: RequestBodyType;\n public multipartBody?: MultipartRequestBody;\n public formData?: FormDataMap;\n public streamResponseStatusCodes?: Set<number>;\n public enableBrowserStreams: boolean;\n\n public proxySettings?: ProxySettings;\n public disableKeepAlive: boolean;\n public abortSignal?: AbortSignal;\n public requestId: string;\n public allowInsecureConnection?: boolean;\n public onUploadProgress?: (progress: TransferProgressEvent) => void;\n public onDownloadProgress?: (progress: TransferProgressEvent) => void;\n public requestOverrides?: Record<string, unknown>;\n public authSchemes?: AuthScheme[];\n\n constructor(options: PipelineRequestOptions) {\n this.url = options.url;\n this.body = options.body;\n this.headers = options.headers ?? createHttpHeaders();\n this.method = options.method ?? \"GET\";\n this.timeout = options.timeout ?? 0;\n this.multipartBody = options.multipartBody;\n this.formData = options.formData;\n this.disableKeepAlive = options.disableKeepAlive ?? false;\n this.proxySettings = options.proxySettings;\n this.streamResponseStatusCodes = options.streamResponseStatusCodes;\n this.withCredentials = options.withCredentials ?? false;\n this.abortSignal = options.abortSignal;\n this.onUploadProgress = options.onUploadProgress;\n this.onDownloadProgress = options.onDownloadProgress;\n this.requestId = options.requestId || randomUUID();\n this.allowInsecureConnection = options.allowInsecureConnection ?? false;\n this.enableBrowserStreams = options.enableBrowserStreams ?? false;\n this.requestOverrides = options.requestOverrides;\n this.authSchemes = options.authSchemes;\n }\n}\n\n/**\n * Creates a new pipeline request with the given options.\n * This method is to allow for the easy setting of default values and not required.\n * @param options - The options to create the request with.\n */\nexport function createPipelineRequest(options: PipelineRequestOptions): PipelineRequest {\n return new PipelineRequestImpl(options);\n}\n"]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { PipelinePolicy } from "../pipeline.js";
|
|
1
2
|
export declare const decompressResponsePolicyName = "decompressResponsePolicy";
|
|
2
3
|
/**
|
|
3
4
|
* decompressResponsePolicy is not supported in the browser and attempting
|
|
4
5
|
* to use it will raise an error.
|
|
5
6
|
*/
|
|
6
|
-
export declare function decompressResponsePolicy():
|
|
7
|
-
//# sourceMappingURL=decompressResponsePolicy
|
|
7
|
+
export declare function decompressResponsePolicy(): PipelinePolicy;
|
|
8
|
+
//# sourceMappingURL=decompressResponsePolicy.d.ts.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
/*
|
|
4
|
-
* NOTE: When moving this file, please update "browser" section in package.json
|
|
5
|
-
*/
|
|
6
3
|
export const decompressResponsePolicyName = "decompressResponsePolicy";
|
|
7
4
|
/**
|
|
8
5
|
* decompressResponsePolicy is not supported in the browser and attempting
|
|
@@ -11,4 +8,4 @@ export const decompressResponsePolicyName = "decompressResponsePolicy";
|
|
|
11
8
|
export function decompressResponsePolicy() {
|
|
12
9
|
throw new Error("decompressResponsePolicy is not supported in browser environment");
|
|
13
10
|
}
|
|
14
|
-
//# sourceMappingURL=decompressResponsePolicy
|
|
11
|
+
//# sourceMappingURL=decompressResponsePolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decompressResponsePolicy.js","sourceRoot":"","sources":["../../../src/policies/decompressResponsePolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,MAAM,CAAC,MAAM,4BAA4B,GAAG,0BAA0B,CAAC;AAEvE;;;GAGG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;AACtF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/*\n * NOTE: When moving this file, please update \"browser\" section in package.json\n */\n\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nexport const decompressResponsePolicyName = \"decompressResponsePolicy\";\n\n/**\n * decompressResponsePolicy is not supported in the browser and attempting\n * to use it will raise an error.\n */\nexport function decompressResponsePolicy(): PipelinePolicy {\n throw new Error(\"decompressResponsePolicy is not supported in browser environment\");\n}\n"]}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export { agentPolicy, agentPolicyName } from "./agentPolicy.js";
|
|
2
2
|
export { decompressResponsePolicy, decompressResponsePolicyName, } from "./decompressResponsePolicy.js";
|
|
3
|
-
export { defaultRetryPolicy, defaultRetryPolicyName, DefaultRetryPolicyOptions, } from "./defaultRetryPolicy.js";
|
|
4
|
-
export { exponentialRetryPolicy, exponentialRetryPolicyName, ExponentialRetryPolicyOptions, } from "./exponentialRetryPolicy.js";
|
|
5
|
-
export { retryPolicy, RetryPolicyOptions } from "./retryPolicy.js";
|
|
6
|
-
export { RetryInformation, RetryModifiers, RetryStrategy, } from "../retryStrategies/retryStrategy.js";
|
|
3
|
+
export { defaultRetryPolicy, defaultRetryPolicyName, type DefaultRetryPolicyOptions, } from "./defaultRetryPolicy.js";
|
|
4
|
+
export { exponentialRetryPolicy, exponentialRetryPolicyName, type ExponentialRetryPolicyOptions, } from "./exponentialRetryPolicy.js";
|
|
5
|
+
export { retryPolicy, type RetryPolicyOptions } from "./retryPolicy.js";
|
|
6
|
+
export type { RetryInformation, RetryModifiers, RetryStrategy, } from "../retryStrategies/retryStrategy.js";
|
|
7
7
|
export { systemErrorRetryPolicy, systemErrorRetryPolicyName } from "./systemErrorRetryPolicy.js";
|
|
8
8
|
export { throttlingRetryPolicy, throttlingRetryPolicyName } from "./throttlingRetryPolicy.js";
|
|
9
9
|
export { formDataPolicy, formDataPolicyName } from "./formDataPolicy.js";
|
|
10
|
-
export { logPolicy, logPolicyName, LogPolicyOptions } from "./logPolicy.js";
|
|
10
|
+
export { logPolicy, logPolicyName, type LogPolicyOptions } from "./logPolicy.js";
|
|
11
11
|
export { multipartPolicy, multipartPolicyName } from "./multipartPolicy.js";
|
|
12
12
|
export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./proxyPolicy.js";
|
|
13
|
-
export { redirectPolicy, redirectPolicyName, RedirectPolicyOptions } from "./redirectPolicy.js";
|
|
13
|
+
export { redirectPolicy, redirectPolicyName, type RedirectPolicyOptions, } from "./redirectPolicy.js";
|
|
14
14
|
export { tlsPolicy, tlsPolicyName } from "./tlsPolicy.js";
|
|
15
|
-
export { userAgentPolicy, userAgentPolicyName, UserAgentPolicyOptions } from "./userAgentPolicy.js";
|
|
15
|
+
export { userAgentPolicy, userAgentPolicyName, type UserAgentPolicyOptions, } from "./userAgentPolicy.js";
|
|
16
16
|
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -11,7 +11,7 @@ export { formDataPolicy, formDataPolicyName } from "./formDataPolicy.js";
|
|
|
11
11
|
export { logPolicy, logPolicyName } from "./logPolicy.js";
|
|
12
12
|
export { multipartPolicy, multipartPolicyName } from "./multipartPolicy.js";
|
|
13
13
|
export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./proxyPolicy.js";
|
|
14
|
-
export { redirectPolicy, redirectPolicyName } from "./redirectPolicy.js";
|
|
14
|
+
export { redirectPolicy, redirectPolicyName, } from "./redirectPolicy.js";
|
|
15
15
|
export { tlsPolicy, tlsPolicyName } from "./tlsPolicy.js";
|
|
16
|
-
export { userAgentPolicy, userAgentPolicyName } from "./userAgentPolicy.js";
|
|
16
|
+
export { userAgentPolicy, userAgentPolicyName, } from "./userAgentPolicy.js";
|
|
17
17
|
//# sourceMappingURL=internal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/policies/internal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/policies/internal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EACL,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,kBAAkB,EAClB,sBAAsB,GAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAE3B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAA2B,MAAM,kBAAkB,CAAC;AAMxE,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACjG,OAAO,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAyB,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AACzF,OAAO,EACL,cAAc,EACd,kBAAkB,GAEnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,eAAe,EACf,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { agentPolicy, agentPolicyName } from \"./agentPolicy.js\";\nexport {\n decompressResponsePolicy,\n decompressResponsePolicyName,\n} from \"./decompressResponsePolicy.js\";\nexport {\n defaultRetryPolicy,\n defaultRetryPolicyName,\n type DefaultRetryPolicyOptions,\n} from \"./defaultRetryPolicy.js\";\nexport {\n exponentialRetryPolicy,\n exponentialRetryPolicyName,\n type ExponentialRetryPolicyOptions,\n} from \"./exponentialRetryPolicy.js\";\nexport { retryPolicy, type RetryPolicyOptions } from \"./retryPolicy.js\";\nexport type {\n RetryInformation,\n RetryModifiers,\n RetryStrategy,\n} from \"../retryStrategies/retryStrategy.js\";\nexport { systemErrorRetryPolicy, systemErrorRetryPolicyName } from \"./systemErrorRetryPolicy.js\";\nexport { throttlingRetryPolicy, throttlingRetryPolicyName } from \"./throttlingRetryPolicy.js\";\nexport { formDataPolicy, formDataPolicyName } from \"./formDataPolicy.js\";\nexport { logPolicy, logPolicyName, type LogPolicyOptions } from \"./logPolicy.js\";\nexport { multipartPolicy, multipartPolicyName } from \"./multipartPolicy.js\";\nexport { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from \"./proxyPolicy.js\";\nexport {\n redirectPolicy,\n redirectPolicyName,\n type RedirectPolicyOptions,\n} from \"./redirectPolicy.js\";\nexport { tlsPolicy, tlsPolicyName } from \"./tlsPolicy.js\";\nexport {\n userAgentPolicy,\n userAgentPolicyName,\n type UserAgentPolicyOptions,\n} from \"./userAgentPolicy.js\";\n"]}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
import type { ProxySettings } from "../interfaces.js";
|
|
2
|
+
import type { PipelinePolicy } from "../pipeline.js";
|
|
1
3
|
export declare const proxyPolicyName = "proxyPolicy";
|
|
2
|
-
export declare function getDefaultProxySettings():
|
|
4
|
+
export declare function getDefaultProxySettings(_proxyUrl?: string): ProxySettings | undefined;
|
|
3
5
|
/**
|
|
4
6
|
* proxyPolicy is not supported in the browser and attempting
|
|
5
7
|
* to use it will raise an error.
|
|
6
8
|
*/
|
|
7
|
-
export declare function proxyPolicy(
|
|
9
|
+
export declare function proxyPolicy(_proxySettings?: ProxySettings, _options?: {
|
|
10
|
+
customNoProxyList?: string[];
|
|
11
|
+
}): PipelinePolicy;
|
|
8
12
|
/**
|
|
9
13
|
* A function to reset the cached agents.
|
|
10
14
|
* proxyPolicy is not supported in the browser and attempting
|
|
11
15
|
* to use it will raise an error.
|
|
12
16
|
* @internal
|
|
13
17
|
*/
|
|
14
|
-
export declare function resetCachedProxyAgents():
|
|
18
|
+
export declare function resetCachedProxyAgents(): void;
|
|
15
19
|
//# sourceMappingURL=proxyPolicy.common.d.ts.map
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
export const proxyPolicyName = "proxyPolicy";
|
|
4
4
|
const errorMessage = "proxyPolicy is not supported in browser environment";
|
|
5
|
-
export function getDefaultProxySettings() {
|
|
5
|
+
export function getDefaultProxySettings(_proxyUrl) {
|
|
6
6
|
throw new Error(errorMessage);
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* proxyPolicy is not supported in the browser and attempting
|
|
10
10
|
* to use it will raise an error.
|
|
11
11
|
*/
|
|
12
|
-
export function proxyPolicy() {
|
|
12
|
+
export function proxyPolicy(_proxySettings, _options) {
|
|
13
13
|
throw new Error(errorMessage);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxyPolicy.common.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"proxyPolicy.common.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAAC;AAC7C,MAAM,YAAY,GAAG,qDAAqD,CAAC;AAE3E,MAAM,UAAU,uBAAuB,CAAC,SAAkB;IACxD,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CACzB,cAA8B,EAC9B,QAEC;IAED,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;AAChC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ProxySettings } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\n\nexport const proxyPolicyName = \"proxyPolicy\";\nconst errorMessage = \"proxyPolicy is not supported in browser environment\";\n\nexport function getDefaultProxySettings(_proxyUrl?: string): ProxySettings | undefined {\n throw new Error(errorMessage);\n}\n\n/**\n * proxyPolicy is not supported in the browser and attempting\n * to use it will raise an error.\n */\nexport function proxyPolicy(\n _proxySettings?: ProxySettings,\n _options?: {\n customNoProxyList?: string[];\n },\n): PipelinePolicy {\n throw new Error(errorMessage);\n}\n\n/**\n * A function to reset the cached agents.\n * proxyPolicy is not supported in the browser and attempting\n * to use it will raise an error.\n * @internal\n */\nexport function resetCachedProxyAgents(): void {\n throw new Error(errorMessage);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./proxyPolicy.common.js";
|
|
2
|
-
//# sourceMappingURL=proxyPolicy
|
|
2
|
+
//# sourceMappingURL=proxyPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxyPolicy.js","sourceRoot":"","sources":["../../../src/policies/proxyPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,yBAAyB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"./proxyPolicy.common.js\";\n"]}
|
|
@@ -12,6 +12,13 @@ export interface RedirectPolicyOptions {
|
|
|
12
12
|
* failing. Defaults to 20.
|
|
13
13
|
*/
|
|
14
14
|
maxRetries?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to follow redirects to a different origin (scheme + host + port).
|
|
17
|
+
* When false (the default), cross-origin redirects are not followed and the
|
|
18
|
+
* redirect response is returned directly to the caller.
|
|
19
|
+
* Defaults to false.
|
|
20
|
+
*/
|
|
21
|
+
allowCrossOriginRedirects?: boolean;
|
|
15
22
|
}
|
|
16
23
|
/**
|
|
17
24
|
* A policy to follow Location headers from the server in order
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
+
import { logger } from "../log.js";
|
|
3
4
|
/**
|
|
4
5
|
* The programmatic identifier of the redirectPolicy.
|
|
5
6
|
*/
|
|
@@ -15,16 +16,16 @@ const allowedRedirect = ["GET", "HEAD"];
|
|
|
15
16
|
* @param options - Options to control policy behavior.
|
|
16
17
|
*/
|
|
17
18
|
export function redirectPolicy(options = {}) {
|
|
18
|
-
const { maxRetries = 20 } = options;
|
|
19
|
+
const { maxRetries = 20, allowCrossOriginRedirects = false } = options;
|
|
19
20
|
return {
|
|
20
21
|
name: redirectPolicyName,
|
|
21
22
|
async sendRequest(request, next) {
|
|
22
23
|
const response = await next(request);
|
|
23
|
-
return handleRedirect(next, response, maxRetries);
|
|
24
|
+
return handleRedirect(next, response, maxRetries, allowCrossOriginRedirects);
|
|
24
25
|
},
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
async function handleRedirect(next, response, maxRetries, currentRetries = 0) {
|
|
28
|
+
async function handleRedirect(next, response, maxRetries, allowCrossOriginRedirects, currentRetries = 0) {
|
|
28
29
|
const { request, status, headers } = response;
|
|
29
30
|
const locationHeader = headers.get("location");
|
|
30
31
|
if (locationHeader &&
|
|
@@ -35,6 +36,14 @@ async function handleRedirect(next, response, maxRetries, currentRetries = 0) {
|
|
|
35
36
|
status === 307) &&
|
|
36
37
|
currentRetries < maxRetries) {
|
|
37
38
|
const url = new URL(locationHeader, request.url);
|
|
39
|
+
// Only follow redirects to the same origin by default.
|
|
40
|
+
if (!allowCrossOriginRedirects) {
|
|
41
|
+
const originalUrl = new URL(request.url);
|
|
42
|
+
if (url.origin !== originalUrl.origin) {
|
|
43
|
+
logger.verbose(`Skipping cross-origin redirect from ${originalUrl.origin} to ${url.origin}.`);
|
|
44
|
+
return response;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
38
47
|
request.url = url.toString();
|
|
39
48
|
// POST request with Status code 303 should be converted into a
|
|
40
49
|
// redirected GET request if the redirect url is present in the location header
|
|
@@ -45,7 +54,7 @@ async function handleRedirect(next, response, maxRetries, currentRetries = 0) {
|
|
|
45
54
|
}
|
|
46
55
|
request.headers.delete("Authorization");
|
|
47
56
|
const res = await next(request);
|
|
48
|
-
return handleRedirect(next, res, maxRetries, currentRetries + 1);
|
|
57
|
+
return handleRedirect(next, res, maxRetries, allowCrossOriginRedirects, currentRetries + 1);
|
|
49
58
|
}
|
|
50
59
|
return response;
|
|
51
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redirectPolicy.js","sourceRoot":"","sources":["../../../src/policies/redirectPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"redirectPolicy.js","sourceRoot":"","sources":["../../../src/policies/redirectPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAEnD;;GAEG;AACH,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAoBxC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,UAAiC,EAAE;IAChE,MAAM,EAAE,UAAU,GAAG,EAAE,EAAE,yBAAyB,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACvE,OAAO;QACL,IAAI,EAAE,kBAAkB;QACxB,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;YACrC,OAAO,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,yBAAyB,CAAC,CAAC;QAC/E,CAAC;KACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,IAAiB,EACjB,QAA0B,EAC1B,UAAkB,EAClB,yBAAkC,EAClC,iBAAyB,CAAC;IAE1B,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC9C,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IACE,cAAc;QACd,CAAC,MAAM,KAAK,GAAG;YACb,CAAC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G,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelineRequest, PipelineResponse, SendRequest } from \"../interfaces.js\";\nimport type { PipelinePolicy } from \"../pipeline.js\";\nimport { logger } from \"../log.js\";\n\n/**\n * The programmatic identifier of the redirectPolicy.\n */\nexport const redirectPolicyName = \"redirectPolicy\";\n\n/**\n * Methods that are allowed to follow redirects 301 and 302\n */\nconst allowedRedirect = [\"GET\", \"HEAD\"];\n\n/**\n * Options for how redirect responses are handled.\n */\nexport interface RedirectPolicyOptions {\n /**\n * The maximum number of times the redirect URL will be tried before\n * failing. Defaults to 20.\n */\n maxRetries?: number;\n /**\n * Whether to follow redirects to a different origin (scheme + host + port).\n * When false (the default), cross-origin redirects are not followed and the\n * redirect response is returned directly to the caller.\n * Defaults to false.\n */\n allowCrossOriginRedirects?: boolean;\n}\n\n/**\n * A policy to follow Location headers from the server in order\n * to support server-side redirection.\n * In the browser, this policy is not used.\n * @param options - Options to control policy behavior.\n */\nexport function redirectPolicy(options: RedirectPolicyOptions = {}): PipelinePolicy {\n const { maxRetries = 20, allowCrossOriginRedirects = false } = options;\n return {\n name: redirectPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const response = await next(request);\n return handleRedirect(next, response, maxRetries, allowCrossOriginRedirects);\n },\n };\n}\n\nasync function handleRedirect(\n next: SendRequest,\n response: PipelineResponse,\n maxRetries: number,\n allowCrossOriginRedirects: boolean,\n currentRetries: number = 0,\n): Promise<PipelineResponse> {\n const { request, status, headers } = response;\n const locationHeader = headers.get(\"location\");\n if (\n locationHeader &&\n (status === 300 ||\n (status === 301 && allowedRedirect.includes(request.method)) ||\n (status === 302 && allowedRedirect.includes(request.method)) ||\n (status === 303 && request.method === \"POST\") ||\n status === 307) &&\n currentRetries < maxRetries\n ) {\n const url = new URL(locationHeader, request.url);\n\n // Only follow redirects to the same origin by default.\n if (!allowCrossOriginRedirects) {\n const originalUrl = new URL(request.url);\n if (url.origin !== originalUrl.origin) {\n logger.verbose(\n `Skipping cross-origin redirect from ${originalUrl.origin} to ${url.origin}.`,\n );\n return response;\n }\n }\n\n request.url = url.toString();\n\n // POST request with Status code 303 should be converted into a\n // redirected GET request if the redirect url is present in the location header\n if (status === 303) {\n request.method = \"GET\";\n request.headers.delete(\"Content-Length\");\n delete request.body;\n }\n\n request.headers.delete(\"Authorization\");\n\n const res = await next(request);\n return handleRedirect(next, res, maxRetries, allowCrossOriginRedirects, currentRetries + 1);\n }\n\n return response;\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./bytesEncoding.common.js";
|
|
2
|
-
//# sourceMappingURL=bytesEncoding
|
|
2
|
+
//# sourceMappingURL=bytesEncoding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytesEncoding.js","sourceRoot":"","sources":["../../../src/util/bytesEncoding.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"./bytesEncoding.common.js\";\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
|
-
type ConcatSource = ReadableStream<Uint8Array> |
|
|
6
|
+
export type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;
|
|
7
7
|
/**
|
|
8
8
|
* Utility function that concatenates a set of binary inputs into one combined output.
|
|
9
9
|
*
|
|
@@ -14,5 +14,4 @@ type ConcatSource = ReadableStream<Uint8Array> | Blob | Uint8Array;
|
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
16
|
export declare function concat(sources: (ConcatSource | (() => ConcatSource))[]): Promise<(() => NodeJS.ReadableStream) | Blob>;
|
|
17
|
-
export {};
|
|
18
17
|
//# sourceMappingURL=concat.common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concat.common.js","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,SAAS,KAAK,CAAC,MAAkC;IAC/C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,UAAU,
|
|
1
|
+
{"version":3,"file":"concat.common.js","sourceRoot":"","sources":["../../../src/util/concat.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;GAGG;AACH,SAAS,KAAK,CAAC,MAAkC;IAC/C,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;AACrC,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAAoB;IAC5C,IAAI,MAAM,YAAY,IAAI,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QAC3D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,8FAA8F,CAC/F,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAS,kBAAkB,CAAC,MAAkB;IAC5C,IAAI,QAAQ,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,cAAc;QACd,OAAO,MAAiC,CAAC;IAC3C,CAAC;IACD,oBAAoB;IACpB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9B,CAAC;AASD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,MAAM,CAC1B,OAAgD;IAEhD,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,QAAQ,YAAY,IAAI,EAAE,CAAC;YAC7B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,aAAa;YACb,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isWebReadableStream } from \"./typeGuards.js\";\n\n/**\n * Drain the content of the given ReadableStream into a Blob.\n * The blob's content may end up in memory or on disk dependent on size.\n */\nfunction drain(stream: ReadableStream<Uint8Array>): Promise<Blob> {\n return new Response(stream).blob();\n}\n\nasync function toBlobPart(source: ConcatSource): Promise<Blob | Uint8Array> {\n if (source instanceof Blob || source instanceof Uint8Array) {\n return source;\n }\n\n if (isWebReadableStream(source)) {\n return drain(source);\n } else {\n throw new Error(\n \"Unsupported source type. Only Blob, Uint8Array, and ReadableStream are supported in browser.\",\n );\n }\n}\n\n/**\n * Converts a Uint8Array to a Uint8Array<ArrayBuffer>.\n * @param source - The source Uint8Array.\n * @returns\n */\nfunction arrayToArrayBuffer(source: Uint8Array): Uint8Array<ArrayBuffer> {\n if (\"resize\" in source.buffer) {\n // ArrayBuffer\n return source as Uint8Array<ArrayBuffer>;\n }\n // SharedArrayBuffer\n return source.map((x) => x);\n}\n\n/**\n * Accepted binary data types for concat\n *\n * @internal\n */\nexport type ConcatSource = ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob;\n\n/**\n * Utility function that concatenates a set of binary inputs into one combined output.\n *\n * @param sources - array of sources for the concatenation\n * @returns - in Node, a (() =\\> NodeJS.ReadableStream) which, when read, produces a concatenation of all the inputs.\n * In browser, returns a `Blob` representing all the concatenated inputs.\n *\n * @internal\n */\nexport async function concat(\n sources: (ConcatSource | (() => ConcatSource))[],\n): Promise<(() => NodeJS.ReadableStream) | Blob> {\n const parts = [];\n for (const source of sources) {\n const blobPart = await toBlobPart(typeof source === \"function\" ? source() : source);\n if (blobPart instanceof Blob) {\n parts.push(blobPart);\n } else {\n // Uint8Array\n parts.push(new Blob([arrayToArrayBuffer(blobPart)]));\n }\n }\n\n return new Blob(parts);\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./concat.common.js";
|
|
2
|
-
//# sourceMappingURL=concat
|
|
2
|
+
//# sourceMappingURL=concat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"concat.js","sourceRoot":"","sources":["../../../src/util/concat.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"./concat.common.js\";\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./inspect.common.js";
|
|
2
|
-
//# sourceMappingURL=inspect
|
|
2
|
+
//# sourceMappingURL=inspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect.js","sourceRoot":"","sources":["../../../src/util/inspect.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"./inspect.common.js\";\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./sha256.common.js";
|
|
2
|
-
//# sourceMappingURL=sha256
|
|
2
|
+
//# sourceMappingURL=sha256.d.ts.map
|