@typespec/ts-http-runtime 0.3.4-alpha.20260227.2 → 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 +1 -21
- 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 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"sendRequest.js","sourceRoot":"","sources":["../../../src/client/sendRequest.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AA6BlC,kCAsCC;AAzDD,kDAAyD;AAEzD,sDAAsD;AACtD,8DAA8D;AAC9D,yDAAiE;AACjE,yDAAyD;AAGzD,iDAAoD;AAEpD;;;;;;;;GAQG;AACI,KAAK,UAAU,WAAW,CAC/B,MAAmB,EACnB,GAAW,EACX,QAAkB,EAClB,UAAqC,EAAE,EACvC,gBAA6B;IAE7B,MAAM,UAAU,GAAG,gBAAgB,IAAI,IAAA,8CAA2B,GAAE,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,MAAM,MAAM,GAAG,QAAQ,CAAC,kBAAkB,IAAI,QAAQ,CAAC,iBAAiB,CAAC;QACzE,MAAM,UAAU,GACd,OAAO,CAAC,gBAAgB,IAAI,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC3F,MAAM,IAAI,GAAG,MAAM,IAAI,UAAU,CAAC;QAElC,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;YACxB,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAA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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
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/sendRequest.ts"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,uBAAuC;AAEvC,yBAAkC;AAClC,6BAAsC;AACtC,2BAA4C;AAC5C,wBAAyC;AAGzC,uBAAmC;AAWnC,eAAsB,YACpB,QACA,KACA,UACA,UAAqC,CAAC,GACtC,kBACuB;AACvB,QAAM,aAAa,wBAAoB,kDAA4B;AACnE,QAAM,UAAU,qBAAqB,QAAQ,KAAK,OAAO;AAEzD,MAAI;AACF,UAAM,WAAW,MAAM,SAAS,YAAY,YAAY,OAAO;AAC/D,UAAM,UAAU,SAAS,QAAQ,OAAO;AACxC,UAAM,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UAAU,IAAI,EAAE;AAAA,IACtC,KAAK;AACH,aAAO,EAAE,MAAM,OAAO,IAAI,EAAE;AAAA,IAC9B;AACE,UAAI,OAAO,SAAS,UAAU;AAC5B,eAAO,EAAE,KAAK;AAAA,MAChB;AACA,aAAO,EAAE,MAAM,KAAK,UAAU,IAAI,EAAE;AAAA,EACxC;AACF;AAKA,SAAS,gBAAgB,UAAyD;AAEhF,QAAM,cAAc,SAAS,QAAQ,IAAI,cAAc,KAAK;AAC5D,QAAM,YAAY,YAAY,MAAM,GAAG,EAAE,CAAC;AAC1C,QAAM,cAAc,SAAS,cAAc;AAE3C,MAAI,cAAc,cAAc;AAC9B,WAAO,OAAO,WAAW;AAAA,EAC3B;AAEA,MAAI;AACF,WAAO,cAAc,KAAK,MAAM,WAAW,IAAI;AAAA,EACjD,SAAS,OAAY;AAGnB,QAAI,cAAc,oBAAoB;AACpC,YAAM,iBAAiB,UAAU,KAAK;AAAA,IACxC;AAIA,WAAO,OAAO,WAAW;AAAA,EAC3B;AACF;AAEA,SAAS,iBAAiB,UAA4B,KAAqB;AACzE,QAAM,MAAM,UAAU,GAAG,gDAAgD,SAAS,UAAU;AAC5F,QAAM,UAAU,IAAI,QAAQ,2BAAU;AACtC,SAAO,IAAI,2BAAU,KAAK;AAAA,IACxB,MAAM;AAAA,IACN,YAAY,SAAS;AAAA,IACrB,SAAS,SAAS;AAAA,IAClB;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,154 +1,147 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var urlHelpers_exports = {};
|
|
19
|
+
__export(urlHelpers_exports, {
|
|
20
|
+
buildBaseUrl: () => buildBaseUrl,
|
|
21
|
+
buildRequestUrl: () => buildRequestUrl,
|
|
22
|
+
replaceAll: () => replaceAll
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(urlHelpers_exports);
|
|
8
25
|
function isQueryParameterWithOptions(x) {
|
|
9
|
-
|
|
10
|
-
|
|
26
|
+
const value = x.value;
|
|
27
|
+
return value !== void 0 && value.toString !== void 0 && typeof value.toString === "function";
|
|
11
28
|
}
|
|
12
|
-
/**
|
|
13
|
-
* Builds the request url, filling in query and path parameters
|
|
14
|
-
* @param endpoint - base url which can be a template url
|
|
15
|
-
* @param routePath - path to append to the endpoint
|
|
16
|
-
* @param pathParameters - values of the path parameters
|
|
17
|
-
* @param options - request parameters including query parameters
|
|
18
|
-
* @returns a full url with path and query parameters
|
|
19
|
-
*/
|
|
20
29
|
function buildRequestUrl(endpoint, routePath, pathParameters, options = {}) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.toString()
|
|
30
|
-
// Remove double forward slashes
|
|
31
|
-
.replace(/([^:]\/)\/+/g, "$1"));
|
|
30
|
+
if (routePath.startsWith("https://") || routePath.startsWith("http://")) {
|
|
31
|
+
return routePath;
|
|
32
|
+
}
|
|
33
|
+
endpoint = buildBaseUrl(endpoint, options);
|
|
34
|
+
routePath = buildRoutePath(routePath, pathParameters, options);
|
|
35
|
+
const requestUrl = appendQueryParams(`${endpoint}/${routePath}`, options);
|
|
36
|
+
const url = new URL(requestUrl);
|
|
37
|
+
return url.toString().replace(/([^:]\/)\/+/g, "$1");
|
|
32
38
|
}
|
|
33
39
|
function getQueryParamValue(key, allowReserved, style, param) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
let separator;
|
|
41
|
+
if (style === "pipeDelimited") {
|
|
42
|
+
separator = "|";
|
|
43
|
+
} else if (style === "spaceDelimited") {
|
|
44
|
+
separator = "%20";
|
|
45
|
+
} else {
|
|
46
|
+
separator = ",";
|
|
47
|
+
}
|
|
48
|
+
let paramValues;
|
|
49
|
+
if (Array.isArray(param)) {
|
|
50
|
+
paramValues = param;
|
|
51
|
+
} else if (typeof param === "object" && param.toString === Object.prototype.toString) {
|
|
52
|
+
paramValues = Object.entries(param).flat();
|
|
53
|
+
} else {
|
|
54
|
+
paramValues = [param];
|
|
55
|
+
}
|
|
56
|
+
const value = paramValues.map((p) => {
|
|
57
|
+
if (p === null || p === void 0) {
|
|
58
|
+
return "";
|
|
47
59
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// then we should deconstruct the object into an array [key1, value1, key2, value2, ...].
|
|
51
|
-
paramValues = Object.entries(param).flat();
|
|
60
|
+
if (!p.toString || typeof p.toString !== "function") {
|
|
61
|
+
throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);
|
|
52
62
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
.map((p) => {
|
|
58
|
-
if (p === null || p === undefined) {
|
|
59
|
-
return "";
|
|
60
|
-
}
|
|
61
|
-
if (!p.toString || typeof p.toString !== "function") {
|
|
62
|
-
throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);
|
|
63
|
-
}
|
|
64
|
-
const rawValue = p.toISOString !== undefined ? p.toISOString() : p.toString();
|
|
65
|
-
return allowReserved ? rawValue : encodeURIComponent(rawValue);
|
|
66
|
-
})
|
|
67
|
-
.join(separator);
|
|
68
|
-
return `${allowReserved ? key : encodeURIComponent(key)}=${value}`;
|
|
63
|
+
const rawValue = p.toISOString !== void 0 ? p.toISOString() : p.toString();
|
|
64
|
+
return allowReserved ? rawValue : encodeURIComponent(rawValue);
|
|
65
|
+
}).join(separator);
|
|
66
|
+
return `${allowReserved ? key : encodeURIComponent(key)}=${value}`;
|
|
69
67
|
}
|
|
70
68
|
function appendQueryParams(url, options = {}) {
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
if (!options.queryParameters) {
|
|
70
|
+
return url;
|
|
71
|
+
}
|
|
72
|
+
const parsedUrl = new URL(url);
|
|
73
|
+
const queryParams = options.queryParameters;
|
|
74
|
+
const paramStrings = [];
|
|
75
|
+
for (const key of Object.keys(queryParams)) {
|
|
76
|
+
const param = queryParams[key];
|
|
77
|
+
if (param === void 0 || param === null) {
|
|
78
|
+
continue;
|
|
73
79
|
}
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const hasMetadata = isQueryParameterWithOptions(param);
|
|
83
|
-
const rawValue = hasMetadata ? param.value : param;
|
|
84
|
-
const explode = hasMetadata ? (param.explode ?? false) : false;
|
|
85
|
-
const style = hasMetadata && param.style ? param.style : "form";
|
|
86
|
-
if (explode) {
|
|
87
|
-
if (Array.isArray(rawValue)) {
|
|
88
|
-
for (const item of rawValue) {
|
|
89
|
-
paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, item));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
else if (typeof rawValue === "object") {
|
|
93
|
-
// For object explode, the name of the query parameter is ignored and we use the object key instead
|
|
94
|
-
for (const [actualKey, value] of Object.entries(rawValue)) {
|
|
95
|
-
paramStrings.push(getQueryParamValue(actualKey, options.skipUrlEncoding ?? false, style, value));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
// Explode doesn't really make sense for primitives
|
|
100
|
-
throw new Error("explode can only be set to true for objects and arrays");
|
|
101
|
-
}
|
|
80
|
+
const hasMetadata = isQueryParameterWithOptions(param);
|
|
81
|
+
const rawValue = hasMetadata ? param.value : param;
|
|
82
|
+
const explode = hasMetadata ? param.explode ?? false : false;
|
|
83
|
+
const style = hasMetadata && param.style ? param.style : "form";
|
|
84
|
+
if (explode) {
|
|
85
|
+
if (Array.isArray(rawValue)) {
|
|
86
|
+
for (const item of rawValue) {
|
|
87
|
+
paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, item));
|
|
102
88
|
}
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
} else if (typeof rawValue === "object") {
|
|
90
|
+
for (const [actualKey, value] of Object.entries(rawValue)) {
|
|
91
|
+
paramStrings.push(
|
|
92
|
+
getQueryParamValue(actualKey, options.skipUrlEncoding ?? false, style, value)
|
|
93
|
+
);
|
|
105
94
|
}
|
|
95
|
+
} else {
|
|
96
|
+
throw new Error("explode can only be set to true for objects and arrays");
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, rawValue));
|
|
106
100
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
101
|
+
}
|
|
102
|
+
if (parsedUrl.search !== "") {
|
|
103
|
+
parsedUrl.search += "&";
|
|
104
|
+
}
|
|
105
|
+
parsedUrl.search += paramStrings.join("&");
|
|
106
|
+
return parsedUrl.toString();
|
|
112
107
|
}
|
|
113
108
|
function buildBaseUrl(endpoint, options) {
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
if (!options.pathParameters) {
|
|
110
|
+
return endpoint;
|
|
111
|
+
}
|
|
112
|
+
const pathParams = options.pathParameters;
|
|
113
|
+
for (const [key, param] of Object.entries(pathParams)) {
|
|
114
|
+
if (param === void 0 || param === null) {
|
|
115
|
+
throw new Error(`Path parameters ${key} must not be undefined or null`);
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (param === undefined || param === null) {
|
|
120
|
-
throw new Error(`Path parameters ${key} must not be undefined or null`);
|
|
121
|
-
}
|
|
122
|
-
if (!param.toString || typeof param.toString !== "function") {
|
|
123
|
-
throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);
|
|
124
|
-
}
|
|
125
|
-
let value = param.toISOString !== undefined ? param.toISOString() : String(param);
|
|
126
|
-
if (!options.skipUrlEncoding) {
|
|
127
|
-
value = encodeURIComponent(param);
|
|
128
|
-
}
|
|
129
|
-
endpoint = replaceAll(endpoint, `{${key}}`, value) ?? "";
|
|
117
|
+
if (!param.toString || typeof param.toString !== "function") {
|
|
118
|
+
throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);
|
|
130
119
|
}
|
|
131
|
-
|
|
120
|
+
let value = param.toISOString !== void 0 ? param.toISOString() : String(param);
|
|
121
|
+
if (!options.skipUrlEncoding) {
|
|
122
|
+
value = encodeURIComponent(param);
|
|
123
|
+
}
|
|
124
|
+
endpoint = replaceAll(endpoint, `{${key}}`, value) ?? "";
|
|
125
|
+
}
|
|
126
|
+
return endpoint;
|
|
132
127
|
}
|
|
133
128
|
function buildRoutePath(routePath, pathParameters, options = {}) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
routePath = routePath.replace(/\{[\w-]+\}/, String(value));
|
|
129
|
+
for (const pathParam of pathParameters) {
|
|
130
|
+
const allowReserved = typeof pathParam === "object" && (pathParam.allowReserved ?? false);
|
|
131
|
+
let value = typeof pathParam === "object" ? pathParam.value : pathParam;
|
|
132
|
+
if (!options.skipUrlEncoding && !allowReserved) {
|
|
133
|
+
value = encodeURIComponent(value);
|
|
141
134
|
}
|
|
142
|
-
|
|
135
|
+
routePath = routePath.replace(/\{[\w-]+\}/, String(value));
|
|
136
|
+
}
|
|
137
|
+
return routePath;
|
|
143
138
|
}
|
|
144
|
-
/**
|
|
145
|
-
* Replace all of the instances of searchValue in value with the provided replaceValue.
|
|
146
|
-
* @param value - The value to search and replace in.
|
|
147
|
-
* @param searchValue - The value to search for in the value argument.
|
|
148
|
-
* @param replaceValue - The value to replace searchValue with in the value argument.
|
|
149
|
-
* @returns The value where each instance of searchValue was replaced with replacedValue.
|
|
150
|
-
*/
|
|
151
139
|
function replaceAll(value, searchValue, replaceValue) {
|
|
152
|
-
|
|
140
|
+
return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || "");
|
|
153
141
|
}
|
|
154
|
-
|
|
142
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
143
|
+
0 && (module.exports = {
|
|
144
|
+
buildBaseUrl,
|
|
145
|
+
buildRequestUrl,
|
|
146
|
+
replaceAll
|
|
147
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"urlHelpers.js","sourceRoot":"","sources":["../../../src/client/urlHelpers.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAoDlC,0CAoBC;AA6FD,oCAmBC;AA2BD,gCAMC;AApLD,SAAS,2BAA2B,CAAC,CAAU;IAC7C,MAAM,KAAK,GAAI,CAA+B,CAAC,KAAY,CAAC;IAC5D,OAAO,CACL,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,CAC5F,CAAC;AACJ,CAA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,CAAC;QAClF,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;YAC7B,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QACD,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,IAAI,GAAG,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3D,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,cAAc,CACrB,SAAiB,EACjB,cAA8D,EAC9D,UAA6B,EAAE;IAE/B,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;QACvC,MAAM,aAAa,GAAG,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,SAAS,CAAC,aAAa,IAAI,KAAK,CAAC,CAAC;QAC1F,IAAI,KAAK,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QAExE,IAAI,CAAC,OAAO,CAAC,eAAe,IAAI,CAAC,aAAa,EAAE,CAAC;YAC/C,KAAK,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;QAED,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CACxB,KAAyB,EACzB,WAAmB,EACnB,YAAoB;IAEpB,OAAO,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PathParameterWithOptions, RequestParameters } from \"./common.js\";\n\ntype QueryParameterStyle = \"form\" | \"spaceDelimited\" | \"pipeDelimited\";\n\n/**\n * An object that can be passed as a query parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\ninterface QueryParameterWithOptions {\n /**\n * The value of the query parameter.\n */\n value: unknown;\n\n /**\n * If set to true, value must be an array. Setting this option to true will cause the array to be encoded as multiple query parameters.\n * Setting it to false will cause the array values to be encoded as a single query parameter, with each value separated by a comma ','.\n *\n * For example, with `explode` set to true, a query parameter named \"foo\" with value [\"a\", \"b\", \"c\"] will be encoded as foo=a&foo=b&foo=c.\n * If `explode` was set to false, the same example would instead be encouded as foo=a,b,c.\n *\n * Defaults to false.\n */\n explode?: boolean;\n\n /**\n * Style for encoding arrays. Three possible values:\n * - \"form\": array values will be separated by a comma \",\" in the query parameter value.\n * - \"spaceDelimited\": array values will be separated by a space (\" \", url-encoded to \"%20\").\n * - \"pipeDelimited\": array values will be separated by a pipe (\"|\").\n *\n * Defaults to \"form\".\n */\n style?: QueryParameterStyle;\n}\n\nfunction isQueryParameterWithOptions(x: unknown): x is QueryParameterWithOptions {\n const value = (x as QueryParameterWithOptions).value as any;\n return (\n value !== undefined && value.toString !== undefined && typeof value.toString === \"function\"\n );\n}\n\n/**\n * Builds the request url, filling in query and path parameters\n * @param endpoint - base url which can be a template url\n * @param routePath - path to append to the endpoint\n * @param pathParameters - values of the path parameters\n * @param options - request parameters including query parameters\n * @returns a full url with path and query parameters\n */\nexport function buildRequestUrl(\n endpoint: string,\n routePath: string,\n pathParameters: (string | number | PathParameterWithOptions)[],\n options: RequestParameters = {},\n): string {\n if (routePath.startsWith(\"https://\") || routePath.startsWith(\"http://\")) {\n return routePath;\n }\n endpoint = buildBaseUrl(endpoint, options);\n routePath = buildRoutePath(routePath, pathParameters, options);\n const requestUrl = appendQueryParams(`${endpoint}/${routePath}`, options);\n const url = new URL(requestUrl);\n\n return (\n url\n .toString()\n // Remove double forward slashes\n .replace(/([^:]\\/)\\/+/g, \"$1\")\n );\n}\n\nfunction getQueryParamValue(\n key: string,\n allowReserved: boolean,\n style: QueryParameterStyle,\n param: any,\n): string {\n let separator: string;\n if (style === \"pipeDelimited\") {\n separator = \"|\";\n } else if (style === \"spaceDelimited\") {\n separator = \"%20\";\n } else {\n separator = \",\";\n }\n\n let paramValues: any[];\n if (Array.isArray(param)) {\n paramValues = param;\n } else if (typeof param === \"object\" && param.toString === Object.prototype.toString) {\n // If the parameter is an object without a custom toString implementation (e.g. a Date),\n // then we should deconstruct the object into an array [key1, value1, key2, value2, ...].\n paramValues = Object.entries(param).flat();\n } else {\n paramValues = [param];\n }\n\n const value = paramValues\n .map((p) => {\n if (p === null || p === undefined) {\n return \"\";\n }\n\n if (!p.toString || typeof p.toString !== \"function\") {\n throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);\n }\n\n const rawValue = p.toISOString !== undefined ? p.toISOString() : p.toString();\n return allowReserved ? rawValue : encodeURIComponent(rawValue);\n })\n .join(separator);\n\n return `${allowReserved ? key : encodeURIComponent(key)}=${value}`;\n}\n\nfunction appendQueryParams(url: string, options: RequestParameters = {}): string {\n if (!options.queryParameters) {\n return url;\n }\n const parsedUrl = new URL(url);\n const queryParams = options.queryParameters;\n\n const paramStrings: string[] = [];\n for (const key of Object.keys(queryParams)) {\n const param = queryParams[key] as any;\n if (param === undefined || param === null) {\n continue;\n }\n\n const hasMetadata = isQueryParameterWithOptions(param);\n const rawValue = hasMetadata ? param.value : param;\n const explode = hasMetadata ? (param.explode ?? false) : false;\n const style = hasMetadata && param.style ? param.style : \"form\";\n\n if (explode) {\n if (Array.isArray(rawValue)) {\n for (const item of rawValue) {\n paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, item));\n }\n } else if (typeof rawValue === \"object\") {\n // For object explode, the name of the query parameter is ignored and we use the object key instead\n for (const [actualKey, value] of Object.entries(rawValue)) {\n paramStrings.push(\n getQueryParamValue(actualKey, options.skipUrlEncoding ?? false, style, value),\n );\n }\n } else {\n // Explode doesn't really make sense for primitives\n throw new Error(\"explode can only be set to true for objects and arrays\");\n }\n } else {\n paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, rawValue));\n }\n }\n\n if (parsedUrl.search !== \"\") {\n parsedUrl.search += \"&\";\n }\n parsedUrl.search += paramStrings.join(\"&\");\n return parsedUrl.toString();\n}\n\nexport function buildBaseUrl(endpoint: string, options: RequestParameters): string {\n if (!options.pathParameters) {\n return endpoint;\n }\n const pathParams = options.pathParameters;\n for (const [key, param] of Object.entries(pathParams)) {\n if (param === undefined || param === null) {\n throw new Error(`Path parameters ${key} must not be undefined or null`);\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);\n }\n let value = param.toISOString !== undefined ? param.toISOString() : String(param);\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(param);\n }\n endpoint = replaceAll(endpoint, `{${key}}`, value) ?? \"\";\n }\n return endpoint;\n}\n\nfunction buildRoutePath(\n routePath: string,\n pathParameters: (string | number | PathParameterWithOptions)[],\n options: RequestParameters = {},\n): string {\n for (const pathParam of pathParameters) {\n const allowReserved = typeof pathParam === \"object\" && (pathParam.allowReserved ?? false);\n let value = typeof pathParam === \"object\" ? pathParam.value : pathParam;\n\n if (!options.skipUrlEncoding && !allowReserved) {\n value = encodeURIComponent(value);\n }\n\n routePath = routePath.replace(/\\{[\\w-]+\\}/, String(value));\n }\n return routePath;\n}\n\n/**\n * Replace all of the instances of searchValue in value with the provided replaceValue.\n * @param value - The value to search and replace in.\n * @param searchValue - The value to search for in the value argument.\n * @param replaceValue - The value to replace searchValue with in the value argument.\n * @returns The value where each instance of searchValue was replaced with replacedValue.\n */\nexport function replaceAll(\n value: string | undefined,\n searchValue: string,\n replaceValue: string,\n): string | undefined {\n return !value || !searchValue ? value : value.split(searchValue).join(replaceValue || \"\");\n}\n"]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/client/urlHelpers.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PathParameterWithOptions, RequestParameters } from \"./common.js\";\n\ntype QueryParameterStyle = \"form\" | \"spaceDelimited\" | \"pipeDelimited\";\n\n/**\n * An object that can be passed as a query parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\ninterface QueryParameterWithOptions {\n /**\n * The value of the query parameter.\n */\n value: unknown;\n\n /**\n * If set to true, value must be an array. Setting this option to true will cause the array to be encoded as multiple query parameters.\n * Setting it to false will cause the array values to be encoded as a single query parameter, with each value separated by a comma ','.\n *\n * For example, with `explode` set to true, a query parameter named \"foo\" with value [\"a\", \"b\", \"c\"] will be encoded as foo=a&foo=b&foo=c.\n * If `explode` was set to false, the same example would instead be encouded as foo=a,b,c.\n *\n * Defaults to false.\n */\n explode?: boolean;\n\n /**\n * Style for encoding arrays. Three possible values:\n * - \"form\": array values will be separated by a comma \",\" in the query parameter value.\n * - \"spaceDelimited\": array values will be separated by a space (\" \", url-encoded to \"%20\").\n * - \"pipeDelimited\": array values will be separated by a pipe (\"|\").\n *\n * Defaults to \"form\".\n */\n style?: QueryParameterStyle;\n}\n\nfunction isQueryParameterWithOptions(x: unknown): x is QueryParameterWithOptions {\n const value = (x as QueryParameterWithOptions).value as any;\n return (\n value !== undefined && value.toString !== undefined && typeof value.toString === \"function\"\n );\n}\n\n/**\n * Builds the request url, filling in query and path parameters\n * @param endpoint - base url which can be a template url\n * @param routePath - path to append to the endpoint\n * @param pathParameters - values of the path parameters\n * @param options - request parameters including query parameters\n * @returns a full url with path and query parameters\n */\nexport function buildRequestUrl(\n endpoint: string,\n routePath: string,\n pathParameters: (string | number | PathParameterWithOptions)[],\n options: RequestParameters = {},\n): string {\n if (routePath.startsWith(\"https://\") || routePath.startsWith(\"http://\")) {\n return routePath;\n }\n endpoint = buildBaseUrl(endpoint, options);\n routePath = buildRoutePath(routePath, pathParameters, options);\n const requestUrl = appendQueryParams(`${endpoint}/${routePath}`, options);\n const url = new URL(requestUrl);\n\n return (\n url\n .toString()\n // Remove double forward slashes\n .replace(/([^:]\\/)\\/+/g, \"$1\")\n );\n}\n\nfunction getQueryParamValue(\n key: string,\n allowReserved: boolean,\n style: QueryParameterStyle,\n param: any,\n): string {\n let separator: string;\n if (style === \"pipeDelimited\") {\n separator = \"|\";\n } else if (style === \"spaceDelimited\") {\n separator = \"%20\";\n } else {\n separator = \",\";\n }\n\n let paramValues: any[];\n if (Array.isArray(param)) {\n paramValues = param;\n } else if (typeof param === \"object\" && param.toString === Object.prototype.toString) {\n // If the parameter is an object without a custom toString implementation (e.g. a Date),\n // then we should deconstruct the object into an array [key1, value1, key2, value2, ...].\n paramValues = Object.entries(param).flat();\n } else {\n paramValues = [param];\n }\n\n const value = paramValues\n .map((p) => {\n if (p === null || p === undefined) {\n return \"\";\n }\n\n if (!p.toString || typeof p.toString !== \"function\") {\n throw new Error(`Query parameters must be able to be represented as string, ${key} can't`);\n }\n\n const rawValue = p.toISOString !== undefined ? p.toISOString() : p.toString();\n return allowReserved ? rawValue : encodeURIComponent(rawValue);\n })\n .join(separator);\n\n return `${allowReserved ? key : encodeURIComponent(key)}=${value}`;\n}\n\nfunction appendQueryParams(url: string, options: RequestParameters = {}): string {\n if (!options.queryParameters) {\n return url;\n }\n const parsedUrl = new URL(url);\n const queryParams = options.queryParameters;\n\n const paramStrings: string[] = [];\n for (const key of Object.keys(queryParams)) {\n const param = queryParams[key] as any;\n if (param === undefined || param === null) {\n continue;\n }\n\n const hasMetadata = isQueryParameterWithOptions(param);\n const rawValue = hasMetadata ? param.value : param;\n const explode = hasMetadata ? (param.explode ?? false) : false;\n const style = hasMetadata && param.style ? param.style : \"form\";\n\n if (explode) {\n if (Array.isArray(rawValue)) {\n for (const item of rawValue) {\n paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, item));\n }\n } else if (typeof rawValue === \"object\") {\n // For object explode, the name of the query parameter is ignored and we use the object key instead\n for (const [actualKey, value] of Object.entries(rawValue)) {\n paramStrings.push(\n getQueryParamValue(actualKey, options.skipUrlEncoding ?? false, style, value),\n );\n }\n } else {\n // Explode doesn't really make sense for primitives\n throw new Error(\"explode can only be set to true for objects and arrays\");\n }\n } else {\n paramStrings.push(getQueryParamValue(key, options.skipUrlEncoding ?? false, style, rawValue));\n }\n }\n\n if (parsedUrl.search !== \"\") {\n parsedUrl.search += \"&\";\n }\n parsedUrl.search += paramStrings.join(\"&\");\n return parsedUrl.toString();\n}\n\nexport function buildBaseUrl(endpoint: string, options: RequestParameters): string {\n if (!options.pathParameters) {\n return endpoint;\n }\n const pathParams = options.pathParameters;\n for (const [key, param] of Object.entries(pathParams)) {\n if (param === undefined || param === null) {\n throw new Error(`Path parameters ${key} must not be undefined or null`);\n }\n if (!param.toString || typeof param.toString !== \"function\") {\n throw new Error(`Path parameters must be able to be represented as string, ${key} can't`);\n }\n let value = param.toISOString !== undefined ? param.toISOString() : String(param);\n if (!options.skipUrlEncoding) {\n value = encodeURIComponent(param);\n }\n endpoint = replaceAll(endpoint, `{${key}}`, value) ?? \"\";\n }\n return endpoint;\n}\n\nfunction buildRoutePath(\n routePath: string,\n pathParameters: (string | number | PathParameterWithOptions)[],\n options: RequestParameters = {},\n): string {\n for (const pathParam of pathParameters) {\n const allowReserved = typeof pathParam === \"object\" && (pathParam.allowReserved ?? false);\n let value = typeof pathParam === \"object\" ? pathParam.value : pathParam;\n\n if (!options.skipUrlEncoding && !allowReserved) {\n value = encodeURIComponent(value);\n }\n\n routePath = routePath.replace(/\\{[\\w-]+\\}/, String(value));\n }\n return routePath;\n}\n\n/**\n * Replace all of the instances of searchValue in value with the provided replaceValue.\n * @param value - The value to search and replace in.\n * @param searchValue - The value to search for in the value argument.\n * @param replaceValue - The value to replace searchValue with in the value argument.\n * @returns The value where each instance of searchValue was replaced with replacedValue.\n */\nexport function replaceAll(\n value: string | undefined,\n searchValue: string,\n replaceValue: string,\n): string | undefined {\n return !value || !searchValue ? value : value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
7
|
+
}
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var constants_exports = {};
|
|
19
|
+
__export(constants_exports, {
|
|
20
|
+
DEFAULT_RETRY_POLICY_COUNT: () => DEFAULT_RETRY_POLICY_COUNT,
|
|
21
|
+
SDK_VERSION: () => SDK_VERSION
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
|
24
|
+
const SDK_VERSION = "0.3.4";
|
|
25
|
+
const DEFAULT_RETRY_POLICY_COUNT = 3;
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
DEFAULT_RETRY_POLICY_COUNT,
|
|
29
|
+
SDK_VERSION
|
|
30
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/constants.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION: string = \"0.3.4\";\n\nexport const DEFAULT_RETRY_POLICY_COUNT = 3;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,cAAsB;AAE5B,MAAM,6BAA6B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,49 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var createPipelineFromOptions_exports = {};
|
|
19
|
+
__export(createPipelineFromOptions_exports, {
|
|
20
|
+
createPipelineFromOptions: () => createPipelineFromOptions
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(createPipelineFromOptions_exports);
|
|
23
|
+
var import_logPolicy = require("./policies/logPolicy.js");
|
|
24
|
+
var import_pipeline = require("./pipeline.js");
|
|
25
|
+
var import_redirectPolicy = require("./policies/redirectPolicy.js");
|
|
26
|
+
var import_userAgentPolicy = require("./policies/userAgentPolicy.js");
|
|
27
|
+
var import_decompressResponsePolicy = require("./policies/decompressResponsePolicy.js");
|
|
28
|
+
var import_defaultRetryPolicy = require("./policies/defaultRetryPolicy.js");
|
|
29
|
+
var import_formDataPolicy = require("./policies/formDataPolicy.js");
|
|
30
|
+
var import_checkEnvironment = require("./util/checkEnvironment.js");
|
|
31
|
+
var import_proxyPolicy = require("./policies/proxyPolicy.js");
|
|
32
|
+
var import_agentPolicy = require("./policies/agentPolicy.js");
|
|
33
|
+
var import_tlsPolicy = require("./policies/tlsPolicy.js");
|
|
34
|
+
var import_multipartPolicy = require("./policies/multipartPolicy.js");
|
|
22
35
|
function createPipelineFromOptions(options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
if (options.tlsOptions) {
|
|
29
|
-
pipeline.addPolicy((0, tlsPolicy_js_1.tlsPolicy)(options.tlsOptions));
|
|
30
|
-
}
|
|
31
|
-
pipeline.addPolicy((0, proxyPolicy_js_1.proxyPolicy)(options.proxyOptions));
|
|
32
|
-
pipeline.addPolicy((0, decompressResponsePolicy_js_1.decompressResponsePolicy)());
|
|
36
|
+
const pipeline = (0, import_pipeline.createEmptyPipeline)();
|
|
37
|
+
if (import_checkEnvironment.isNodeLike) {
|
|
38
|
+
if (options.agent) {
|
|
39
|
+
pipeline.addPolicy((0, import_agentPolicy.agentPolicy)(options.agent));
|
|
33
40
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// The multipart policy is added after policies with no phase, so that
|
|
37
|
-
// policies can be added between it and formDataPolicy to modify
|
|
38
|
-
// properties (e.g., making the boundary constant in recorded tests).
|
|
39
|
-
pipeline.addPolicy((0, multipartPolicy_js_1.multipartPolicy)(), { afterPhase: "Deserialize" });
|
|
40
|
-
pipeline.addPolicy((0, defaultRetryPolicy_js_1.defaultRetryPolicy)(options.retryOptions), { phase: "Retry" });
|
|
41
|
-
if (checkEnvironment_js_1.isNodeLike) {
|
|
42
|
-
// Both XHR and Fetch expect to handle redirects automatically,
|
|
43
|
-
// so only include this policy when we're in Node.
|
|
44
|
-
pipeline.addPolicy((0, redirectPolicy_js_1.redirectPolicy)(options.redirectOptions), { afterPhase: "Retry" });
|
|
41
|
+
if (options.tlsOptions) {
|
|
42
|
+
pipeline.addPolicy((0, import_tlsPolicy.tlsPolicy)(options.tlsOptions));
|
|
45
43
|
}
|
|
46
|
-
pipeline.addPolicy((0,
|
|
47
|
-
|
|
44
|
+
pipeline.addPolicy((0, import_proxyPolicy.proxyPolicy)(options.proxyOptions));
|
|
45
|
+
pipeline.addPolicy((0, import_decompressResponsePolicy.decompressResponsePolicy)());
|
|
46
|
+
}
|
|
47
|
+
pipeline.addPolicy((0, import_formDataPolicy.formDataPolicy)(), { beforePolicies: [import_multipartPolicy.multipartPolicyName] });
|
|
48
|
+
pipeline.addPolicy((0, import_userAgentPolicy.userAgentPolicy)(options.userAgentOptions));
|
|
49
|
+
pipeline.addPolicy((0, import_multipartPolicy.multipartPolicy)(), { afterPhase: "Deserialize" });
|
|
50
|
+
pipeline.addPolicy((0, import_defaultRetryPolicy.defaultRetryPolicy)(options.retryOptions), { phase: "Retry" });
|
|
51
|
+
if (import_checkEnvironment.isNodeLike) {
|
|
52
|
+
pipeline.addPolicy((0, import_redirectPolicy.redirectPolicy)(options.redirectOptions), { afterPhase: "Retry" });
|
|
53
|
+
}
|
|
54
|
+
pipeline.addPolicy((0, import_logPolicy.logPolicy)(options.loggingOptions), { afterPhase: "Sign" });
|
|
55
|
+
return pipeline;
|
|
48
56
|
}
|
|
49
|
-
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
createPipelineFromOptions
|
|
60
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/core/ts-http-runtime/src/createPipelineFromOptions.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { type LogPolicyOptions, logPolicy } from \"./policies/logPolicy.js\";\nimport { type Pipeline, createEmptyPipeline } from \"./pipeline.js\";\nimport type { Agent, PipelineRetryOptions, ProxySettings, TlsSettings } from \"./interfaces.js\";\nimport { type RedirectPolicyOptions, redirectPolicy } from \"./policies/redirectPolicy.js\";\nimport { type UserAgentPolicyOptions, userAgentPolicy } from \"./policies/userAgentPolicy.js\";\nimport { decompressResponsePolicy } from \"./policies/decompressResponsePolicy.js\";\nimport { defaultRetryPolicy } from \"./policies/defaultRetryPolicy.js\";\nimport { formDataPolicy } from \"./policies/formDataPolicy.js\";\nimport { isNodeLike } from \"./util/checkEnvironment.js\";\nimport { proxyPolicy } from \"./policies/proxyPolicy.js\";\nimport { agentPolicy } from \"./policies/agentPolicy.js\";\nimport { tlsPolicy } from \"./policies/tlsPolicy.js\";\nimport { multipartPolicy, multipartPolicyName } from \"./policies/multipartPolicy.js\";\n\n/**\n * Defines options that are used to configure the HTTP pipeline for\n * an SDK client.\n */\nexport interface PipelineOptions {\n /**\n * Options that control how to retry failed requests.\n */\n retryOptions?: PipelineRetryOptions;\n\n /**\n * Options to configure a proxy for outgoing requests.\n */\n proxyOptions?: ProxySettings;\n\n /** Options for configuring Agent instance for outgoing requests */\n agent?: Agent;\n\n /** Options for configuring TLS authentication */\n tlsOptions?: TlsSettings;\n\n /**\n * Options for how redirect responses are handled.\n */\n redirectOptions?: RedirectPolicyOptions;\n\n /**\n * Options for adding user agent details to outgoing requests.\n */\n userAgentOptions?: UserAgentPolicyOptions;\n\n /**\n * Options for setting common telemetry and tracing info to outgoing requests.\n */\n telemetryOptions?: TelemetryOptions;\n}\n\n/**\n * Defines options that are used to configure common telemetry and tracing info\n */\nexport interface TelemetryOptions {\n /**\n * The name of the header to pass the request ID to.\n */\n clientRequestIdHeaderName?: string;\n}\n\n/**\n * Defines options that are used to configure internal options of\n * the HTTP pipeline for an SDK client.\n */\nexport interface InternalPipelineOptions extends PipelineOptions {\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n}\n\n/**\n * Create a new pipeline with a default set of customizable policies.\n * @param options - Options to configure a custom pipeline.\n */\nexport function createPipelineFromOptions(options: InternalPipelineOptions): Pipeline {\n const pipeline = createEmptyPipeline();\n\n if (isNodeLike) {\n if (options.agent) {\n pipeline.addPolicy(agentPolicy(options.agent));\n }\n if (options.tlsOptions) {\n pipeline.addPolicy(tlsPolicy(options.tlsOptions));\n }\n pipeline.addPolicy(proxyPolicy(options.proxyOptions));\n pipeline.addPolicy(decompressResponsePolicy());\n }\n\n pipeline.addPolicy(formDataPolicy(), { beforePolicies: [multipartPolicyName] });\n pipeline.addPolicy(userAgentPolicy(options.userAgentOptions));\n // The multipart policy is added after policies with no phase, so that\n // policies can be added between it and formDataPolicy to modify\n // properties (e.g., making the boundary constant in recorded tests).\n pipeline.addPolicy(multipartPolicy(), { afterPhase: \"Deserialize\" });\n pipeline.addPolicy(defaultRetryPolicy(options.retryOptions), { phase: \"Retry\" });\n if (isNodeLike) {\n // Both XHR and Fetch expect to handle redirects automatically,\n // so only include this policy when we're in Node.\n pipeline.addPolicy(redirectPolicy(options.redirectOptions), { afterPhase: \"Retry\" });\n }\n pipeline.addPolicy(logPolicy(options.loggingOptions), { afterPhase: \"Sign\" });\n\n return pipeline;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAiD;AACjD,sBAAmD;AAEnD,4BAA2D;AAC3D,6BAA6D;AAC7D,sCAAyC;AACzC,gCAAmC;AACnC,4BAA+B;AAC/B,8BAA2B;AAC3B,yBAA4B;AAC5B,yBAA4B;AAC5B,uBAA0B;AAC1B,6BAAqD;AAgE9C,SAAS,0BAA0B,SAA4C;AACpF,QAAM,eAAW,qCAAoB;AAErC,MAAI,oCAAY;AACd,QAAI,QAAQ,OAAO;AACjB,eAAS,cAAU,gCAAY,QAAQ,KAAK,CAAC;AAAA,IAC/C;AACA,QAAI,QAAQ,YAAY;AACtB,eAAS,cAAU,4BAAU,QAAQ,UAAU,CAAC;AAAA,IAClD;AACA,aAAS,cAAU,gCAAY,QAAQ,YAAY,CAAC;AACpD,aAAS,cAAU,0DAAyB,CAAC;AAAA,EAC/C;AAEA,WAAS,cAAU,sCAAe,GAAG,EAAE,gBAAgB,CAAC,0CAAmB,EAAE,CAAC;AAC9E,WAAS,cAAU,wCAAgB,QAAQ,gBAAgB,CAAC;AAI5D,WAAS,cAAU,wCAAgB,GAAG,EAAE,YAAY,cAAc,CAAC;AACnE,WAAS,cAAU,8CAAmB,QAAQ,YAAY,GAAG,EAAE,OAAO,QAAQ,CAAC;AAC/E,MAAI,oCAAY;AAGd,aAAS,cAAU,sCAAe,QAAQ,eAAe,GAAG,EAAE,YAAY,QAAQ,CAAC;AAAA,EACrF;AACA,WAAS,cAAU,4BAAU,QAAQ,cAAc,GAAG,EAAE,YAAY,OAAO,CAAC;AAE5E,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|