@typespec/ts-http-runtime 1.0.0-alpha.20241021.2 → 1.0.0-alpha.20241023.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/browser/auth/tokenCredential.d.ts +4 -0
  2. package/dist/browser/auth/tokenCredential.d.ts.map +1 -1
  3. package/dist/browser/auth/tokenCredential.js.map +1 -1
  4. package/dist/browser/client/common.d.ts +4 -9
  5. package/dist/browser/client/common.d.ts.map +1 -1
  6. package/dist/browser/client/common.js.map +1 -1
  7. package/dist/browser/client/getClient.js +3 -2
  8. package/dist/browser/client/getClient.js.map +1 -1
  9. package/dist/browser/client/sendRequest.d.ts.map +1 -1
  10. package/dist/browser/client/sendRequest.js +28 -18
  11. package/dist/browser/client/sendRequest.js.map +1 -1
  12. package/dist/browser/client/urlHelpers.d.ts +1 -1
  13. package/dist/browser/client/urlHelpers.d.ts.map +1 -1
  14. package/dist/browser/client/urlHelpers.js +3 -3
  15. package/dist/browser/client/urlHelpers.js.map +1 -1
  16. package/dist/browser/fetchHttpClient.d.ts.map +1 -1
  17. package/dist/browser/fetchHttpClient.js +3 -3
  18. package/dist/browser/fetchHttpClient.js.map +1 -1
  19. package/dist/browser/interfaces.d.ts.map +1 -1
  20. package/dist/browser/interfaces.js.map +1 -1
  21. package/dist/browser/nodeHttpClient.d.ts.map +1 -1
  22. package/dist/browser/nodeHttpClient.js +9 -3
  23. package/dist/browser/nodeHttpClient.js.map +1 -1
  24. package/dist/browser/policies/formDataPolicy.js.map +1 -1
  25. package/dist/browser/policies/multipartPolicy.js.map +1 -1
  26. package/dist/browser/policies/tracingPolicy.js +2 -2
  27. package/dist/browser/policies/tracingPolicy.js.map +1 -1
  28. package/dist/browser/retryStrategies/throttlingRetryStrategy.js +1 -1
  29. package/dist/browser/retryStrategies/throttlingRetryStrategy.js.map +1 -1
  30. package/dist/browser/util/checkEnvironment.d.ts +4 -16
  31. package/dist/browser/util/checkEnvironment.d.ts.map +1 -1
  32. package/dist/browser/util/checkEnvironment.js +4 -4
  33. package/dist/browser/util/checkEnvironment.js.map +1 -1
  34. package/dist/browser/util/sanitizer.js.map +1 -1
  35. package/dist/browser/util/tokenCycler.d.ts.map +1 -1
  36. package/dist/browser/util/tokenCycler.js +7 -2
  37. package/dist/browser/util/tokenCycler.js.map +1 -1
  38. package/dist/browser/util/uuidUtils.common.d.ts.map +1 -1
  39. package/dist/browser/util/uuidUtils.common.js +0 -3
  40. package/dist/browser/util/uuidUtils.common.js.map +1 -1
  41. package/dist/commonjs/auth/tokenCredential.d.ts +4 -0
  42. package/dist/commonjs/auth/tokenCredential.d.ts.map +1 -1
  43. package/dist/commonjs/auth/tokenCredential.js.map +1 -1
  44. package/dist/commonjs/client/common.d.ts +4 -9
  45. package/dist/commonjs/client/common.d.ts.map +1 -1
  46. package/dist/commonjs/client/common.js.map +1 -1
  47. package/dist/commonjs/client/getClient.js +3 -2
  48. package/dist/commonjs/client/getClient.js.map +1 -1
  49. package/dist/commonjs/client/sendRequest.d.ts.map +1 -1
  50. package/dist/commonjs/client/sendRequest.js +27 -17
  51. package/dist/commonjs/client/sendRequest.js.map +1 -1
  52. package/dist/commonjs/client/urlHelpers.d.ts +1 -1
  53. package/dist/commonjs/client/urlHelpers.d.ts.map +1 -1
  54. package/dist/commonjs/client/urlHelpers.js +3 -3
  55. package/dist/commonjs/client/urlHelpers.js.map +1 -1
  56. package/dist/commonjs/fetchHttpClient.d.ts.map +1 -1
  57. package/dist/commonjs/fetchHttpClient.js +2 -2
  58. package/dist/commonjs/fetchHttpClient.js.map +1 -1
  59. package/dist/commonjs/interfaces.d.ts.map +1 -1
  60. package/dist/commonjs/interfaces.js.map +1 -1
  61. package/dist/commonjs/nodeHttpClient.d.ts.map +1 -1
  62. package/dist/commonjs/nodeHttpClient.js +9 -3
  63. package/dist/commonjs/nodeHttpClient.js.map +1 -1
  64. package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
  65. package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
  66. package/dist/commonjs/policies/proxyPolicy.js +1 -1
  67. package/dist/commonjs/policies/proxyPolicy.js.map +1 -1
  68. package/dist/commonjs/policies/tracingPolicy.js +2 -2
  69. package/dist/commonjs/policies/tracingPolicy.js.map +1 -1
  70. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js +1 -1
  71. package/dist/commonjs/retryStrategies/throttlingRetryStrategy.js.map +1 -1
  72. package/dist/commonjs/util/checkEnvironment.d.ts +4 -16
  73. package/dist/commonjs/util/checkEnvironment.d.ts.map +1 -1
  74. package/dist/commonjs/util/checkEnvironment.js +5 -5
  75. package/dist/commonjs/util/checkEnvironment.js.map +1 -1
  76. package/dist/commonjs/util/sanitizer.js.map +1 -1
  77. package/dist/commonjs/util/tokenCycler.d.ts.map +1 -1
  78. package/dist/commonjs/util/tokenCycler.js +7 -2
  79. package/dist/commonjs/util/tokenCycler.js.map +1 -1
  80. package/dist/commonjs/util/uuidUtils.common.d.ts.map +1 -1
  81. package/dist/commonjs/util/uuidUtils.common.js +0 -3
  82. package/dist/commonjs/util/uuidUtils.common.js.map +1 -1
  83. package/dist/commonjs/util/uuidUtils.d.ts.map +1 -1
  84. package/dist/commonjs/util/uuidUtils.js +1 -6
  85. package/dist/commonjs/util/uuidUtils.js.map +1 -1
  86. package/dist/esm/auth/tokenCredential.d.ts +4 -0
  87. package/dist/esm/auth/tokenCredential.d.ts.map +1 -1
  88. package/dist/esm/auth/tokenCredential.js.map +1 -1
  89. package/dist/esm/client/common.d.ts +4 -9
  90. package/dist/esm/client/common.d.ts.map +1 -1
  91. package/dist/esm/client/common.js.map +1 -1
  92. package/dist/esm/client/getClient.js +3 -2
  93. package/dist/esm/client/getClient.js.map +1 -1
  94. package/dist/esm/client/sendRequest.d.ts.map +1 -1
  95. package/dist/esm/client/sendRequest.js +28 -18
  96. package/dist/esm/client/sendRequest.js.map +1 -1
  97. package/dist/esm/client/urlHelpers.d.ts +1 -1
  98. package/dist/esm/client/urlHelpers.d.ts.map +1 -1
  99. package/dist/esm/client/urlHelpers.js +3 -3
  100. package/dist/esm/client/urlHelpers.js.map +1 -1
  101. package/dist/esm/fetchHttpClient.d.ts.map +1 -1
  102. package/dist/esm/fetchHttpClient.js +3 -3
  103. package/dist/esm/fetchHttpClient.js.map +1 -1
  104. package/dist/esm/interfaces.d.ts.map +1 -1
  105. package/dist/esm/interfaces.js.map +1 -1
  106. package/dist/esm/nodeHttpClient.d.ts.map +1 -1
  107. package/dist/esm/nodeHttpClient.js +9 -3
  108. package/dist/esm/nodeHttpClient.js.map +1 -1
  109. package/dist/esm/policies/formDataPolicy.js.map +1 -1
  110. package/dist/esm/policies/multipartPolicy.js.map +1 -1
  111. package/dist/esm/policies/proxyPolicy.js +1 -1
  112. package/dist/esm/policies/proxyPolicy.js.map +1 -1
  113. package/dist/esm/policies/tracingPolicy.js +2 -2
  114. package/dist/esm/policies/tracingPolicy.js.map +1 -1
  115. package/dist/esm/retryStrategies/throttlingRetryStrategy.js +1 -1
  116. package/dist/esm/retryStrategies/throttlingRetryStrategy.js.map +1 -1
  117. package/dist/esm/util/checkEnvironment.d.ts +4 -16
  118. package/dist/esm/util/checkEnvironment.d.ts.map +1 -1
  119. package/dist/esm/util/checkEnvironment.js +4 -4
  120. package/dist/esm/util/checkEnvironment.js.map +1 -1
  121. package/dist/esm/util/sanitizer.js.map +1 -1
  122. package/dist/esm/util/tokenCycler.d.ts.map +1 -1
  123. package/dist/esm/util/tokenCycler.js +7 -2
  124. package/dist/esm/util/tokenCycler.js.map +1 -1
  125. package/dist/esm/util/uuidUtils.common.d.ts.map +1 -1
  126. package/dist/esm/util/uuidUtils.common.js +0 -3
  127. package/dist/esm/util/uuidUtils.common.js.map +1 -1
  128. package/dist/esm/util/uuidUtils.d.ts.map +1 -1
  129. package/dist/esm/util/uuidUtils.js +1 -6
  130. package/dist/esm/util/uuidUtils.js.map +1 -1
  131. package/dist/react-native/auth/tokenCredential.d.ts +4 -0
  132. package/dist/react-native/auth/tokenCredential.d.ts.map +1 -1
  133. package/dist/react-native/auth/tokenCredential.js.map +1 -1
  134. package/dist/react-native/client/common.d.ts +4 -9
  135. package/dist/react-native/client/common.d.ts.map +1 -1
  136. package/dist/react-native/client/common.js.map +1 -1
  137. package/dist/react-native/client/getClient.js +3 -2
  138. package/dist/react-native/client/getClient.js.map +1 -1
  139. package/dist/react-native/client/sendRequest.d.ts.map +1 -1
  140. package/dist/react-native/client/sendRequest.js +28 -18
  141. package/dist/react-native/client/sendRequest.js.map +1 -1
  142. package/dist/react-native/client/urlHelpers.d.ts +1 -1
  143. package/dist/react-native/client/urlHelpers.d.ts.map +1 -1
  144. package/dist/react-native/client/urlHelpers.js +3 -3
  145. package/dist/react-native/client/urlHelpers.js.map +1 -1
  146. package/dist/react-native/fetchHttpClient.d.ts.map +1 -1
  147. package/dist/react-native/fetchHttpClient.js +3 -3
  148. package/dist/react-native/fetchHttpClient.js.map +1 -1
  149. package/dist/react-native/interfaces.d.ts.map +1 -1
  150. package/dist/react-native/interfaces.js.map +1 -1
  151. package/dist/react-native/nodeHttpClient.d.ts.map +1 -1
  152. package/dist/react-native/nodeHttpClient.js +9 -3
  153. package/dist/react-native/nodeHttpClient.js.map +1 -1
  154. package/dist/react-native/policies/formDataPolicy.js.map +1 -1
  155. package/dist/react-native/policies/multipartPolicy.js.map +1 -1
  156. package/dist/react-native/policies/tracingPolicy.js +2 -2
  157. package/dist/react-native/policies/tracingPolicy.js.map +1 -1
  158. package/dist/react-native/retryStrategies/throttlingRetryStrategy.js +1 -1
  159. package/dist/react-native/retryStrategies/throttlingRetryStrategy.js.map +1 -1
  160. package/dist/react-native/util/checkEnvironment.d.ts +4 -16
  161. package/dist/react-native/util/checkEnvironment.d.ts.map +1 -1
  162. package/dist/react-native/util/checkEnvironment.js +4 -4
  163. package/dist/react-native/util/checkEnvironment.js.map +1 -1
  164. package/dist/react-native/util/sanitizer.js.map +1 -1
  165. package/dist/react-native/util/tokenCycler.d.ts.map +1 -1
  166. package/dist/react-native/util/tokenCycler.js +7 -2
  167. package/dist/react-native/util/tokenCycler.js.map +1 -1
  168. package/dist/react-native/util/uuidUtils.common.d.ts.map +1 -1
  169. package/dist/react-native/util/uuidUtils.common.js +0 -3
  170. package/dist/react-native/util/uuidUtils.common.js.map +1 -1
  171. package/dist/ts-http-runtime.d.ts +8 -9
  172. package/package.json +5 -4
@@ -67,6 +67,10 @@ export interface AccessToken {
67
67
  * The access token's expiration timestamp in milliseconds, UNIX epoch time.
68
68
  */
69
69
  expiresOnTimestamp: number;
70
+ /**
71
+ * The timestamp when the access token should be refreshed, in milliseconds, UNIX epoch time.
72
+ */
73
+ refreshAfterTimestamp?: number;
70
74
  }
71
75
  /**
72
76
  * Tests an object to determine whether it implements TokenCredential.
@@ -1 +1 @@
1
- {"version":3,"file":"tokenCredential.d.ts","sourceRoot":"","sources":["../../../src/auth/tokenCredential.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;OASG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CAC7F;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;OAEG;IACH,cAAc,CAAC,EAAE;QACf;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF;;OAEG;IACH,cAAc,CAAC,EAAE;QACf;;WAEG;QACH,cAAc,CAAC,EAAE,cAAc,CAAC;KACjC,CAAC;IACF;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,SAAS,CAAC,E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;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAGhC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,IAAI,eAAe,CAepF"}
@@ -1 +1 @@
1
- {"version":3,"file":"tokenCredential.js","sourceRoot":"","sources":["../../../src/auth/tokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA6ElC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAmB;IACnD,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,qEAAqE;IACrE,sDAAsD;IACtD,MAAM,cAAc,GAAG,UAGtB,CAAC;IACF,OAAO,CACL,cAAc;QACd,OAAO,cAAc,CAAC,QAAQ,KAAK,UAAU;QAC7C,CAAC,cAAc,CAAC,WAAW,KAAK,SAAS,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CACjF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { TracingContext } from \"../tracing/interfaces.js\";\n\n/**\n * Represents a credential capable of providing an authentication token.\n */\nexport interface TokenCredential {\n /**\n * Gets the token provided by this credential.\n *\n * This method is called automatically by Azure SDK client libraries. You may call this method\n * directly, but you must also handle token caching and token refreshing.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;\n}\n\n/**\n * Defines options for TokenCredential.getToken.\n */\nexport interface GetTokenOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: {\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n };\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: {\n /**\n * Tracing Context for the current request.\n */\n tracingContext?: TracingContext;\n };\n /**\n * Claim details to perform the Continuous Access Evaluation authentication flow\n */\n claims?: string;\n /**\n * Indicates whether to enable the Continuous Access Evaluation authentication flow\n */\n enableCae?: boolean;\n /**\n * Allows specifying a tenantId. Useful to handle challenges that provide tenant Id hints.\n */\n tenantId?: string;\n}\n\n/**\n * Represents an access token with an expiration time.\n */\nexport interface AccessToken {\n /**\n * The access token returned by the authentication service.\n */\n token: string;\n\n /**\n * The access token's expiration timestamp in milliseconds, UNIX epoch time.\n */\n expiresOnTimestamp: number;\n}\n\n/**\n * Tests an object to determine whether it implements TokenCredential.\n *\n * @param credential - The assumed TokenCredential to be tested.\n */\nexport function isTokenCredential(credential: unknown): credential is TokenCredential {\n // Check for an object with a 'getToken' function and possibly with\n // a 'signRequest' function. We do this check to make sure that\n // a ServiceClientCredentials implementor (like TokenClientCredentials\n // in ms-rest-nodeauth) doesn't get mistaken for a TokenCredential if\n // it doesn't actually implement TokenCredential also.\n const castCredential = credential as {\n getToken: unknown;\n signRequest: unknown;\n };\n return (\n castCredential &&\n typeof castCredential.getToken === \"function\" &&\n (castCredential.signRequest === undefined || castCredential.getToken.length > 0)\n );\n}\n"]}
1
+ {"version":3,"file":"tokenCredential.js","sourceRoot":"","sources":["../../../src/auth/tokenCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAoFlC;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAmB;IACnD,mEAAmE;IACnE,gEAAgE;IAChE,sEAAsE;IACtE,qEAAqE;IACrE,sDAAsD;IACtD,MAAM,cAAc,GAAG,UAGtB,CAAC;IACF,OAAO,CACL,cAAc;QACd,OAAO,cAAc,CAAC,QAAQ,KAAK,UAAU;QAC7C,CAAC,cAAc,CAAC,WAAW,KAAK,SAAS,IAAI,cAAc,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CACjF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { TracingContext } from \"../tracing/interfaces.js\";\n\n/**\n * Represents a credential capable of providing an authentication token.\n */\nexport interface TokenCredential {\n /**\n * Gets the token provided by this credential.\n *\n * This method is called automatically by Azure SDK client libraries. You may call this method\n * directly, but you must also handle token caching and token refreshing.\n *\n * @param scopes - The list of scopes for which the token will have access.\n * @param options - The options used to configure any requests this\n * TokenCredential implementation might make.\n */\n getToken(scopes: string | string[], options?: GetTokenOptions): Promise<AccessToken | null>;\n}\n\n/**\n * Defines options for TokenCredential.getToken.\n */\nexport interface GetTokenOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: {\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n };\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: {\n /**\n * Tracing Context for the current request.\n */\n tracingContext?: TracingContext;\n };\n /**\n * Claim details to perform the Continuous Access Evaluation authentication flow\n */\n claims?: string;\n /**\n * Indicates whether to enable the Continuous Access Evaluation authentication flow\n */\n enableCae?: boolean;\n /**\n * Allows specifying a tenantId. Useful to handle challenges that provide tenant Id hints.\n */\n tenantId?: string;\n}\n\n/**\n * Represents an access token with an expiration time.\n */\nexport interface AccessToken {\n /**\n * The access token returned by the authentication service.\n */\n token: string;\n\n /**\n * The access token's expiration timestamp in milliseconds, UNIX epoch time.\n */\n expiresOnTimestamp: number;\n\n /**\n * The timestamp when the access token should be refreshed, in milliseconds, UNIX epoch time.\n */\n refreshAfterTimestamp?: number;\n\n // UNBRANDED DIFFERENCE: Unbranded Core does not support PoP (\"Proof-of-Presence\") tokens.\n}\n\n/**\n * Tests an object to determine whether it implements TokenCredential.\n *\n * @param credential - The assumed TokenCredential to be tested.\n */\nexport function isTokenCredential(credential: unknown): credential is TokenCredential {\n // Check for an object with a 'getToken' function and possibly with\n // a 'signRequest' function. We do this check to make sure that\n // a ServiceClientCredentials implementor (like TokenClientCredentials\n // in ms-rest-nodeauth) doesn't get mistaken for a TokenCredential if\n // it doesn't actually implement TokenCredential also.\n const castCredential = credential as {\n getToken: unknown;\n signRequest: unknown;\n };\n return (\n castCredential &&\n typeof castCredential.getToken === \"function\" &&\n (castCredential.signRequest === undefined || castCredential.getToken.length > 0)\n );\n}\n"]}
@@ -5,7 +5,7 @@ import { OperationTracingOptions } from "../tracing/interfaces.js";
5
5
  import { PipelineOptions } from "../createPipelineFromOptions.js";
6
6
  import { LogPolicyOptions } from "../policies/logPolicy.js";
7
7
  /**
8
- * Shape of the default request parameters, this may be overriden by the specific
8
+ * Shape of the default request parameters, this may be overridden by the specific
9
9
  * request types to provide strong types
10
10
  */
11
11
  export type RequestParameters = {
@@ -160,7 +160,7 @@ export interface Client {
160
160
  pipeline: Pipeline;
161
161
  /**
162
162
  * This method will be used to send request that would check the path to provide
163
- * strong types. When used by the codegen this type gets overriden wit the generated
163
+ * strong types. When used by the codegen this type gets overridden with the generated
164
164
  * types. For example:
165
165
  * ```typescript snippet:path_example
166
166
  * import { Client, Routes } from "@typespec/ts-http-runtime";
@@ -276,11 +276,6 @@ export type ClientOptions = PipelineOptions & {
276
276
  */
277
277
  apiKeyHeaderName?: string;
278
278
  };
279
- /**
280
- * Base url for the client
281
- * @deprecated This property is deprecated and will be removed soon, please use endpoint instead
282
- */
283
- baseUrl?: string;
284
279
  /**
285
280
  * Endpoint for the client
286
281
  */
@@ -332,7 +327,7 @@ export type HttpResponse = {
332
327
  * text surrounded by \{\} will be considered a path parameter
333
328
  */
334
329
  export type PathParameters<TRoute extends string> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}` ? [
335
- pathParameter: string | PathParameterWithOptions,
330
+ pathParameter: string | number | PathParameterWithOptions,
336
331
  ...pathParameters: PathParameters<Tail>
337
332
  ] : [
338
333
  ];
@@ -368,7 +363,7 @@ export interface PathParameterWithOptions {
368
363
  /**
369
364
  * The value of the parameter.
370
365
  */
371
- value: string;
366
+ value: string | number;
372
367
  /**
373
368
  * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.
374
369
  * Defaults to false.
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mEAAmE;IACnE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAErC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IAC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MAAM,IAOnB,MAAM,SAAS,GAAG,MAAM,KAAK,KAAK,MAAM,MAAM,IAAI,MAAM,IAAI,EAAE,GAO9D;IACE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,wBAAwB;IACzD,GAAG,cAAc,EAAE,cAAc,CAAC,IAAI,CAAC;CACxC,GAGD;CAAE,CAAC;AAEP,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,wBAAwB;IACxB,KAAK,EAAE,UAAU,CAAC;CACnB;AAED,wBAAwB;AACxB,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3B,8FAA8F;IAC9F,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,iNAAiN;AACjN,MAAM,WAAW,UAAU;IACzB,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n HttpClient,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n RawHttpHeadersInput,\n} from \"../interfaces.js\";\nimport { Pipeline, PipelinePolicy } from \"../pipeline.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { OperationTracingOptions } from \"../tracing/interfaces.js\";\nimport { PipelineOptions } from \"../createPipelineFromOptions.js\";\nimport { LogPolicyOptions } from \"../policies/logPolicy.js\";\n\n/**\n * Shape of the default request parameters, this may be overriden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\nexport type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\n}\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overriden wit the generated\n * types. For example:\n * ```typescript snippet:path_example\n * import { Client, Routes } from \"@typespec/ts-http-runtime\";\n *\n * export type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJS.ReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\n};\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\n}\n\n/**\n * Used to configure additional policies added to the pipeline at construction.\n */\nexport interface AdditionalPolicyConfig {\n /**\n * A policy to be added.\n */\n policy: PipelinePolicy;\n /**\n * Determines if this policy be applied before or after retry logic.\n * Only use `perRetry` if you need to modify the request again\n * each time the operation is retried due to retryable service\n * issues.\n */\n position: \"perCall\" | \"perRetry\";\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n /**\n * Base url for the client\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUrl?: string;\n /**\n * Endpoint for the client\n */\n endpoint?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n /**\n * Additional policies to include in the HTTP pipeline.\n */\n additionalPolicies?: AdditionalPolicyConfig[];\n /**\n * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string,\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [pathParameter: string | PathParameterWithOptions, ...pathParameters: PathParameters<Tail>]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n\n/**\n * An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\nexport interface PathParameterWithOptions {\n /**\n * The value of the parameter.\n */\n value: string;\n\n /**\n * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.\n * Defaults to false.\n */\n allowReserved?: boolean;\n}\n"]}
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n HttpClient,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n RawHttpHeadersInput,\n} from \"../interfaces.js\";\nimport { Pipeline, PipelinePolicy } from \"../pipeline.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { OperationTracingOptions } from \"../tracing/interfaces.js\";\nimport { PipelineOptions } from \"../createPipelineFromOptions.js\";\nimport { LogPolicyOptions } from \"../policies/logPolicy.js\";\n\n/**\n * Shape of the default request parameters, this may be overridden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n// UNBRANDED DIFFERENCE: onResponse callback does not have a second __legacyError parameter which was provided for backwards compatibility\nexport type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\n}\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overridden with the generated\n * types. For example:\n * ```typescript snippet:path_example\n * import { Client, Routes } from \"@typespec/ts-http-runtime\";\n *\n * export type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJS.ReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\n};\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\n}\n\n/**\n * Used to configure additional policies added to the pipeline at construction.\n */\nexport interface AdditionalPolicyConfig {\n /**\n * A policy to be added.\n */\n policy: PipelinePolicy;\n /**\n * Determines if this policy be applied before or after retry logic.\n * Only use `perRetry` if you need to modify the request again\n * each time the operation is retried due to retryable service\n * issues.\n */\n position: \"perCall\" | \"perRetry\";\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n\n // UNBRANDED DIFFERENCE: The deprecated baseUrl property is removed in favor of the endpoint property in the unbranded Core package\n\n /**\n * Endpoint for the client\n */\n endpoint?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n /**\n * Additional policies to include in the HTTP pipeline.\n */\n additionalPolicies?: AdditionalPolicyConfig[];\n /**\n * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string,\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [\n pathParameter: string | number | PathParameterWithOptions,\n ...pathParameters: PathParameters<Tail>,\n ]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n\n/**\n * An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.\n */\nexport interface PathParameterWithOptions {\n /**\n * The value of the parameter.\n */\n value: string | number;\n\n /**\n * Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.\n * Defaults to false.\n */\n allowReserved?: boolean;\n}\n"]}
@@ -6,7 +6,7 @@ import { createDefaultPipeline } from "./clientHelpers.js";
6
6
  import { sendRequest } from "./sendRequest.js";
7
7
  import { buildRequestUrl } from "./urlHelpers.js";
8
8
  export function getClient(endpoint, credentialsOrPipelineOptions, clientOptions = {}) {
9
- var _a;
9
+ var _a, _b;
10
10
  let credentials;
11
11
  if (credentialsOrPipelineOptions) {
12
12
  if (isCredential(credentialsOrPipelineOptions)) {
@@ -28,8 +28,9 @@ export function getClient(endpoint, credentialsOrPipelineOptions, clientOptions
28
28
  }
29
29
  }
30
30
  const { allowInsecureConnection, httpClient } = clientOptions;
31
+ const endpointUrl = (_b = clientOptions.endpoint) !== null && _b !== void 0 ? _b : endpoint;
31
32
  const client = (path, ...args) => {
32
- const getUrl = (requestOptions) => buildRequestUrl(endpoint, path, args, Object.assign({ allowInsecureConnection }, requestOptions));
33
+ const getUrl = (requestOptions) => buildRequestUrl(endpointUrl, path, args, Object.assign({ allowInsecureConnection }, requestOptions));
33
34
  return {
34
35
  get: (requestOptions = {}) => {
35
36
  return buildOperation("GET", getUrl(requestOptions), pipeline, requestOptions, allowInsecureConnection, httpClient);
@@ -1 +1 @@
1
- {"version":3,"file":"getClient.js","sourceRoot":"","sources":["../../../src/client/getClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAmB,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAoBlD,MAAM,UAAU,SAAS,CACvB,QAAgB,EAChB,4BAAgF,EAChF,gBAA+B,EAAE;;IAEjC,IAAI,WAAwD,CAAC;IAC7D,IAAI,4BAA4B,EAAE,CAAC;QACjC,IAAI,YAAY,CAAC,4BAA4B,CAAC,EAAE,CAAC;YAC/C,WAAW,GAAG,4BAA4B,CAAC;QAC7C,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,4BAA4B,aAA5B,4BAA4B,cAA5B,4BAA4B,GAAI,EAAE,CAAC;QACrD,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;IAC7E,IAAI,MAAA,aAAa,CAAC,kBAAkB,0CAAE,MAAM,EAAE,CAAC;QAC7C,KAAK,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,aAAa,CAAC,kBAAkB,EAAE,CAAC;YACpE,2DAA2D;YAC3D,6CAA6C;YAC7C,MAAM,UAAU,GAAG,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC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EAAE,gBAAgB,EAAE,IAAI,KAC7D,UAAU,CAC2B,CAAC;QAC1C,CAAC;QACD,KAAK,CAAC,YAAY;YAChB,OAAO,WAAW,CAChB,MAAM,EACN,GAAG,EACH,QAAQ,kCACH,OAAO,KAAE,uBAAuB,EAAE,gBAAgB,EAAE,IAAI,KAC7D,UAAU,CACwB,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { TokenCredential, isTokenCredential } from \"../auth/tokenCredential.js\";\nimport { KeyCredential, isKeyCredential } from \"../auth/keyCredential.js\";\nimport { HttpClient, HttpMethods } from \"../interfaces.js\";\nimport { Pipeline } from \"../pipeline.js\";\nimport { createDefaultPipeline } from \"./clientHelpers.js\";\nimport {\n Client,\n ClientOptions,\n HttpBrowserStreamResponse,\n HttpNodeStreamResponse,\n RequestParameters,\n ResourceMethods,\n StreamableMethod,\n} from \"./common.js\";\nimport { sendRequest } from \"./sendRequest.js\";\nimport { buildRequestUrl } from \"./urlHelpers.js\";\nimport { PipelineOptions } from \"../createPipelineFromOptions.js\";\n\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(endpoint: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n endpoint: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions,\n): Client;\nexport function getClient(\n endpoint: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {},\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(endpoint, credentials, clientOptions);\n if (clientOptions.additionalPolicies?.length) {\n for (const { policy, position } of clientOptions.additionalPolicies) {\n // Sign happens after Retry and is commonly needed to occur\n // before policies that intercept post-retry.\n const afterPhase = position === \"perRetry\" ? \"Sign\" : undefined;\n pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n\n const { allowInsecureConnection, httpClient } = clientOptions;\n const client = (path: string, ...args: Array<any>): ResourceMethods<StreamableMethod> => {\n const getUrl = (requestOptions: RequestParameters): string =>\n buildRequestUrl(endpoint, path, args, { allowInsecureConnection, ...requestOptions });\n\n return {\n get: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"GET\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n post: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"POST\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n put: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"PUT\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n patch: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"PATCH\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n delete: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"DELETE\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n head: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"HEAD\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n options: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"OPTIONS\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n trace: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"TRACE\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildOperation(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters,\n allowInsecureConnection?: boolean,\n httpClient?: HttpClient,\n): StreamableMethod {\n allowInsecureConnection = options.allowInsecureConnection ?? allowInsecureConnection;\n return {\n then: function (onFulfilled, onrejected) {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection },\n httpClient,\n ).then(onFulfilled, onrejected);\n },\n async asBrowserStream() {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection, responseAsStream: true },\n httpClient,\n ) as Promise<HttpBrowserStreamResponse>;\n },\n async asNodeStream() {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection, responseAsStream: true },\n httpClient,\n ) as Promise<HttpNodeStreamResponse>;\n },\n };\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions,\n): param is TokenCredential | KeyCredential {\n return isKeyCredential(param) || isTokenCredential(param);\n}\n"]}
1
+ {"version":3,"file":"getClient.js","sourceRoot":"","sources":["../../../src/client/getClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAmB,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAiB,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,eA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C;YACD,KAAK,EAAE,CAAC,iBAAoC,EAAE,EAAoB,EAAE;gBAClE,OAAO,cAAc,CACnB,OAAO,EACP,MAAM,CAAC,cAAc,CAAC,EACtB,QAAQ,EACR,cAAc,EACd,uBAAuB,EACvB,UAAU,CACX,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,MAAM;QACrB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CACrB,MAAmB,EACnB,GAAW,EACX,QAAkB,EAClB,OAA0B,EAC1B,uBAAiC,EACjC,UAAuB;;IAEvB,uBAAuB,GAAG,MAAA,OAAO,CAAC,uBAAuB,mCAAI,uBAAuB,CAAC;IACrF,OAAO;QACL,IAAI,EAAE,UAAU,WAAW,EAAE,UAAU;YACrC,OAAO,WAAW,CAChB,MAAM,EACN,GAAG,EACH,QAAQ,kCACH,OAAO,KAAE,uBAAuB,KACrC,UAAU,CACX,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QAClC,CAAC;QACD,KAAK,CAAC,eAAe;YACnB,OAAO,WAAW,CAChB,MAAM,EACN,GAAG,EACH,QAAQ,kCACH,OAAO,KAAE,uBAAuB,EAAE,gBAAgB,EAAE,IAAI,KAC7D,UAAU,CAC2B,CAAC;QAC1C,CAAC;QACD,KAAK,CAAC,YAAY;YAChB,OAAO,WAAW,CAChB,MAAM,EACN,GAAG,EACH,QAAQ,kCACH,OAAO,KAAE,uBAAuB,EAAE,gBAAgB,EAAE,IAAI,KAC7D,UAAU,CACwB,CAAC;QACvC,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CACnB,KAA0D;IAE1D,OAAO,eAAe,CAAC,KAAK,CAAC,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { TokenCredential, isTokenCredential } from \"../auth/tokenCredential.js\";\nimport { KeyCredential, isKeyCredential } from \"../auth/keyCredential.js\";\nimport { HttpClient, HttpMethods } from \"../interfaces.js\";\nimport { Pipeline } from \"../pipeline.js\";\nimport { createDefaultPipeline } from \"./clientHelpers.js\";\nimport {\n Client,\n ClientOptions,\n HttpBrowserStreamResponse,\n HttpNodeStreamResponse,\n RequestParameters,\n ResourceMethods,\n StreamableMethod,\n} from \"./common.js\";\nimport { sendRequest } from \"./sendRequest.js\";\nimport { buildRequestUrl } from \"./urlHelpers.js\";\nimport { PipelineOptions } from \"../createPipelineFromOptions.js\";\n\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param options - Client options\n */\nexport function getClient(endpoint: string, options?: ClientOptions): Client;\n/**\n * Creates a client with a default pipeline\n * @param endpoint - Base endpoint for the client\n * @param credentials - Credentials to authenticate the requests\n * @param options - Client options\n */\nexport function getClient(\n endpoint: string,\n credentials?: TokenCredential | KeyCredential,\n options?: ClientOptions,\n): Client;\nexport function getClient(\n endpoint: string,\n credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | ClientOptions,\n clientOptions: ClientOptions = {},\n): Client {\n let credentials: TokenCredential | KeyCredential | undefined;\n if (credentialsOrPipelineOptions) {\n if (isCredential(credentialsOrPipelineOptions)) {\n credentials = credentialsOrPipelineOptions;\n } else {\n clientOptions = credentialsOrPipelineOptions ?? {};\n }\n }\n\n const pipeline = createDefaultPipeline(endpoint, credentials, clientOptions);\n if (clientOptions.additionalPolicies?.length) {\n for (const { policy, position } of clientOptions.additionalPolicies) {\n // Sign happens after Retry and is commonly needed to occur\n // before policies that intercept post-retry.\n const afterPhase = position === \"perRetry\" ? \"Sign\" : undefined;\n pipeline.addPolicy(policy, {\n afterPhase,\n });\n }\n }\n\n const { allowInsecureConnection, httpClient } = clientOptions;\n const endpointUrl = clientOptions.endpoint ?? endpoint;\n const client = (path: string, ...args: Array<any>): ResourceMethods<StreamableMethod> => {\n const getUrl = (requestOptions: RequestParameters): string =>\n buildRequestUrl(endpointUrl, path, args, { allowInsecureConnection, ...requestOptions });\n\n return {\n get: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"GET\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n post: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"POST\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n put: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"PUT\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n patch: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"PATCH\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n delete: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"DELETE\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n head: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"HEAD\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n options: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"OPTIONS\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n trace: (requestOptions: RequestParameters = {}): StreamableMethod => {\n return buildOperation(\n \"TRACE\",\n getUrl(requestOptions),\n pipeline,\n requestOptions,\n allowInsecureConnection,\n httpClient,\n );\n },\n };\n };\n\n return {\n path: client,\n pathUnchecked: client,\n pipeline,\n };\n}\n\nfunction buildOperation(\n method: HttpMethods,\n url: string,\n pipeline: Pipeline,\n options: RequestParameters,\n allowInsecureConnection?: boolean,\n httpClient?: HttpClient,\n): StreamableMethod {\n allowInsecureConnection = options.allowInsecureConnection ?? allowInsecureConnection;\n return {\n then: function (onFulfilled, onrejected) {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection },\n httpClient,\n ).then(onFulfilled, onrejected);\n },\n async asBrowserStream() {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection, responseAsStream: true },\n httpClient,\n ) as Promise<HttpBrowserStreamResponse>;\n },\n async asNodeStream() {\n return sendRequest(\n method,\n url,\n pipeline,\n { ...options, allowInsecureConnection, responseAsStream: true },\n httpClient,\n ) as Promise<HttpNodeStreamResponse>;\n },\n };\n}\n\nfunction isCredential(\n param: (TokenCredential | KeyCredential) | PipelineOptions,\n): param is TokenCredential | KeyCredential {\n return isKeyCredential(param) || isTokenCredential(param);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sendRequest.d.ts","sourceRoot":"","sources":["../../../src/client/sendRequest.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,WAAW,EAKZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG9D;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,yBAA8B,EACvC,gBAAgB,CAAC,EAAE,UAAU,GAC5B,OAAO,CAAC,YAAY,CAAC,CAoBvB;AAuCD,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
1
+ {"version":3,"file":"sendRequest.d.ts","sourceRoot":"","sources":["../../../src/client/sendRequest.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,WAAW,EAKZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAK1C,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG9D;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,WAAW,EACnB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,yBAA8B,EACvC,gBAAgB,CAAC,EAAE,UAAU,GAC5B,OAAO,CAAC,YAAY,CAAC,CAgCvB;AAuCD,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { RestError } from "../restError.js";
3
+ 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";
@@ -19,20 +19,31 @@ export async function sendRequest(method, url, pipeline, options = {}, customHtt
19
19
  var _a;
20
20
  const httpClient = customHttpClient !== null && customHttpClient !== void 0 ? customHttpClient : getCachedDefaultHttpsClient();
21
21
  const request = buildPipelineRequest(method, url, options);
22
- const response = await pipeline.sendRequest(httpClient, request);
23
- const headers = response.headers.toJSON();
24
- const stream = (_a = response.readableStreamBody) !== null && _a !== void 0 ? _a : response.browserStreamBody;
25
- const parsedBody = options.responseAsStream || stream !== undefined ? undefined : getResponseBody(response);
26
- const body = stream !== null && stream !== void 0 ? stream : parsedBody;
27
- if (options === null || options === void 0 ? void 0 : options.onResponse) {
28
- options.onResponse(Object.assign(Object.assign({}, response), { request, rawHeaders: headers, parsedBody }));
22
+ try {
23
+ const response = await pipeline.sendRequest(httpClient, request);
24
+ const headers = response.headers.toJSON();
25
+ const stream = (_a = response.readableStreamBody) !== null && _a !== void 0 ? _a : response.browserStreamBody;
26
+ const parsedBody = options.responseAsStream || stream !== undefined ? undefined : getResponseBody(response);
27
+ const body = stream !== null && stream !== void 0 ? stream : parsedBody;
28
+ if (options === null || options === void 0 ? void 0 : options.onResponse) {
29
+ options.onResponse(Object.assign(Object.assign({}, response), { request, rawHeaders: headers, parsedBody }));
30
+ }
31
+ return {
32
+ request,
33
+ headers,
34
+ status: `${response.status}`,
35
+ body,
36
+ };
37
+ }
38
+ catch (e) {
39
+ if (isRestError(e) && e.response && options.onResponse) {
40
+ const { response } = e;
41
+ const rawHeaders = response.headers.toJSON();
42
+ // UNBRANDED DIFFERENCE: onResponse callback does not have a second __legacyError property
43
+ options === null || options === void 0 ? void 0 : options.onResponse(Object.assign(Object.assign({}, response), { request, rawHeaders }), e);
44
+ }
45
+ throw e;
29
46
  }
30
- return {
31
- request,
32
- headers,
33
- status: `${response.status}`,
34
- body,
35
- };
36
47
  }
37
48
  /**
38
49
  * Function to determine the request content type
@@ -106,14 +117,13 @@ function getRequestBody(body, contentType = "") {
106
117
  if (isReadableStream(body)) {
107
118
  return { body };
108
119
  }
109
- const firstType = contentType.split(";")[0];
110
- if (firstType === "application/json") {
111
- return { body: JSON.stringify(body) };
112
- }
113
120
  if (ArrayBuffer.isView(body)) {
114
121
  return { body: body instanceof Uint8Array ? body : JSON.stringify(body) };
115
122
  }
123
+ const firstType = contentType.split(";")[0];
116
124
  switch (firstType) {
125
+ case "application/json":
126
+ return { body: JSON.stringify(body) };
117
127
  case "multipart/form-data":
118
128
  if (Array.isArray(body)) {
119
129
  return { multipartBody: buildMultipartBody(body) };
@@ -1 +1 @@
1
- {"version":3,"file":"sendRequest.js","sourceRoot":"","sources":["../../../src/client/sendRequest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC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AC,CAAC,SAAS,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,yDAAyD;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,MAAA,GAAG,CAAC,IAAI,mCAAI,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 {\n HttpClient,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n PipelineResponse,\n RequestBodyType,\n} from \"../interfaces.js\";\nimport { RestError } from \"../restError.js\";\nimport { 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 { HttpResponse, RequestParameters } from \"./common.js\";\nimport { PartDescriptor, 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 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}\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 {\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 (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; charset=UTF-8\";\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; charset=UTF-8\";\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 const hasContent = body !== undefined || multipartBody !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? options.headers?.accept ?? \"application/json\",\n ...(hasContent &&\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 tracingOptions: options.tracingOptions,\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)) {\n return { body };\n }\n\n const firstType = contentType.split(\";\")[0];\n\n if (firstType === \"application/json\") {\n return { body: JSON.stringify(body) };\n }\n\n if (ArrayBuffer.isView(body)) {\n return { body: body instanceof Uint8Array ? body : JSON.stringify(body) };\n }\n\n switch (firstType) {\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: string = 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,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAkB,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAmB,EACnB,GAAW,EACX,QAAkB,EAClB,UAAqC,EAAE,EACvC,gBAA6B;;IAE7B,MAAM,UAAU,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,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,MAAM,MAAM,GAAG,MAAA,QAAQ,CAAC,kBAAkB,mCAAI,QAAQ,CAAC,iBA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AED,SAAS,gBAAgB,CAAC,QAA0B,EAAE,GAAQ;;IAC5D,MAAM,GAAG,GAAG,UAAU,GAAG,gDAAgD,QAAQ,CAAC,UAAU,GAAG,CAAC;IAChG,MAAM,OAAO,GAAG,MAAA,GAAG,CAAC,IAAI,mCAAI,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 {\n HttpClient,\n HttpMethods,\n MultipartRequestBody,\n PipelineRequest,\n PipelineResponse,\n RequestBodyType,\n} from \"../interfaces.js\";\nimport { isRestError, RestError } from \"../restError.js\";\nimport { 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 { HttpResponse, RequestParameters } from \"./common.js\";\nimport { PartDescriptor, 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 {\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 (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; charset=UTF-8\";\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; charset=UTF-8\";\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 const hasContent = body !== undefined || multipartBody !== undefined;\n\n const headers = createHttpHeaders({\n ...(options.headers ? options.headers : {}),\n accept: options.accept ?? options.headers?.accept ?? \"application/json\",\n ...(hasContent &&\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 tracingOptions: options.tracingOptions,\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)) {\n return { body };\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"]}
@@ -7,7 +7,7 @@ import { PathParameterWithOptions, RequestParameters } from "./common.js";
7
7
  * @param options - request parameters including query parameters
8
8
  * @returns a full url with path and query parameters
9
9
  */
10
- export declare function buildRequestUrl(endpoint: string, routePath: string, pathParameters: (string | PathParameterWithOptions)[], options?: RequestParameters): string;
10
+ export declare function buildRequestUrl(endpoint: string, routePath: string, pathParameters: (string | number | PathParameterWithOptions)[], options?: RequestParameters): string;
11
11
  export declare function buildBaseUrl(endpoint: string, options: RequestParameters): string;
12
12
  /**
13
13
  * Replace all of the instances of searchValue in value with the provided replaceValue.
@@ -1 +1 @@
1
- {"version":3,"file":"urlHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/urlHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA0C1E;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,MAAM,GAAG,wBAAwB,CAAC,EAAE,EACrD,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAeR;AA6FD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAmBjF;AAqBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAEpB"}
1
+ {"version":3,"file":"urlHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/urlHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AA0C1E;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,CAAC,MAAM,GAAG,MAAM,GAAG,wBAAwB,CAAC,EAAE,EAC9D,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAeR;AA6FD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAmBjF;AAoBD;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAEpB"}
@@ -130,12 +130,12 @@ export function buildBaseUrl(endpoint, options) {
130
130
  function buildRoutePath(routePath, pathParameters, options = {}) {
131
131
  var _a;
132
132
  for (const pathParam of pathParameters) {
133
- const allowReserved = typeof pathParam === "string" ? false : ((_a = pathParam === null || pathParam === void 0 ? void 0 : pathParam.allowReserved) !== null && _a !== void 0 ? _a : false);
134
- let value = typeof pathParam === "string" ? pathParam : pathParam === null || pathParam === void 0 ? void 0 : pathParam.value;
133
+ const allowReserved = typeof pathParam === "object" && ((_a = pathParam.allowReserved) !== null && _a !== void 0 ? _a : false);
134
+ let value = typeof pathParam === "object" ? pathParam.value : pathParam;
135
135
  if (!options.skipUrlEncoding && !allowReserved) {
136
136
  value = encodeURIComponent(value);
137
137
  }
138
- routePath = routePath.replace(/\{\w+\}/, value);
138
+ routePath = routePath.replace(/\{\w+\}/, String(value));
139
139
  }
140
140
  return routePath;
141
141
  }
@@ -1 +1 @@
1
- {"version":3,"file":"urlHelpers.js","sourceRoot":"","sources":["../../../src/client/urlHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAqClC,SAAS,2BAA2B,CAAC,CAAU;IAC7C,MAAM,KAAK,GAAI,CAA+B,CAAC,KAAY,CAAC;IAC5D,OAAO,CACL,KA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AAC,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 { 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 | 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 | PathParameterWithOptions)[],\n options: RequestParameters = {},\n): string {\n for (const pathParam of pathParameters) {\n const allowReserved =\n typeof pathParam === \"string\" ? false : (pathParam?.allowReserved ?? false);\n let value = typeof pathParam === \"string\" ? pathParam : pathParam?.value;\n\n if (!options.skipUrlEncoding && !allowReserved) {\n value = encodeURIComponent(value);\n }\n\n routePath = routePath.replace(/\\{\\w+\\}/, 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
+ {"version":3,"file":"urlHelpers.js","sourceRoot":"","sources":["../../../src/client/urlHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAqClC,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,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB,EAChB,SAAiB,EACjB,cAA8D,EAC9D,UAA6B,EAAE;IAE/B,IAAI,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,SAAS,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QACxE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,QAAQ,GAAG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3C,SAAS,GAAG,cAAc,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAC/D,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,QAAQ,IAAI,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1E,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAEhC,OAAO,CACL,GAAG;SACA,QAAQ,EAAE;QACX,gCAAgC;SAC/B,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CACjC,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,GAAW,EACX,aAAsB,EACtB,KAA0B,EAC1B,KAAU;IAEV,IAAI,SAAiB,CAAC;IACt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AAK,CAAC,CAAC;QACpC,CAAC;QAED,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,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 { 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 +1 @@
1
- {"version":3,"file":"fetchHttpClient.d.ts","sourceRoot":"","sources":["../../src/fetchHttpClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EAKX,MAAM,iBAAiB,CAAC;AAwSzB;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,CAElD"}
1
+ {"version":3,"file":"fetchHttpClient.d.ts","sourceRoot":"","sources":["../../src/fetchHttpClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EAKX,MAAM,iBAAiB,CAAC;AA6SzB;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,UAAU,CAElD"}
@@ -3,7 +3,7 @@
3
3
  import { AbortError } from "./abort-controller/AbortError.js";
4
4
  import { RestError } from "./restError.js";
5
5
  import { createHttpHeaders } from "./httpHeaders.js";
6
- import { isNodeReadableStream, isReadableStream } from "./util/typeGuards.js";
6
+ import { isNodeReadableStream, isWebReadableStream } from "./util/typeGuards.js";
7
7
  /**
8
8
  * Checks if the body is a Blob or Blob-like
9
9
  */
@@ -83,7 +83,7 @@ async function buildPipelineResponse(httpResponse, request, abortControllerClean
83
83
  headers,
84
84
  status: httpResponse.status,
85
85
  };
86
- const bodyStream = isReadableStream(httpResponse.body)
86
+ const bodyStream = isWebReadableStream(httpResponse.body)
87
87
  ? buildBodyStream(httpResponse.body, {
88
88
  onProgress: request.onDownloadProgress,
89
89
  onEnd: abortControllerCleanup,
@@ -180,7 +180,7 @@ function buildRequestBody(request) {
180
180
  if (isNodeReadableStream(body)) {
181
181
  throw new Error("Node streams are not supported in browser environment.");
182
182
  }
183
- return isReadableStream(body)
183
+ return isWebReadableStream(body)
184
184
  ? { streaming: true, body: buildBodyStream(body, { onProgress: request.onUploadProgress }) }
185
185
  : { streaming: false, body };
186
186
  }