@typespec/ts-http-runtime 1.0.0-alpha.20240322.2 → 1.0.0-alpha.20240329.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (328) hide show
  1. package/dist/browser/accessTokenCache.js +0 -2
  2. package/dist/browser/accessTokenCache.js.map +1 -1
  3. package/dist/browser/client/clientHelpers.js +4 -3
  4. package/dist/browser/client/clientHelpers.js.map +1 -1
  5. package/dist/browser/client/getClient.js +9 -7
  6. package/dist/browser/client/getClient.js.map +1 -1
  7. package/dist/browser/client/operationOptionHelpers.js +7 -6
  8. package/dist/browser/client/operationOptionHelpers.js.map +1 -1
  9. package/dist/browser/client/restError.js +4 -2
  10. package/dist/browser/client/restError.js.map +1 -1
  11. package/dist/browser/client/sendRequest.js +18 -19
  12. package/dist/browser/client/sendRequest.js.map +1 -1
  13. package/dist/browser/client/urlHelpers.js +2 -1
  14. package/dist/browser/client/urlHelpers.js.map +1 -1
  15. package/dist/browser/fetchHttpClient.js +20 -26
  16. package/dist/browser/fetchHttpClient.js.map +1 -1
  17. package/dist/browser/httpHeaders.js +2 -2
  18. package/dist/browser/httpHeaders.js.map +1 -1
  19. package/dist/browser/index.d.ts +1 -1
  20. package/dist/browser/index.d.ts.map +1 -1
  21. package/dist/browser/index.js +1 -1
  22. package/dist/browser/index.js.map +1 -1
  23. package/dist/browser/nodeHttpClient.js +20 -18
  24. package/dist/browser/nodeHttpClient.js.map +1 -1
  25. package/dist/browser/pipeline.js +3 -3
  26. package/dist/browser/pipeline.js.map +1 -1
  27. package/dist/browser/pipelineRequest.js +8 -25
  28. package/dist/browser/pipelineRequest.js.map +1 -1
  29. package/dist/browser/policies/bearerTokenAuthenticationPolicy.js +3 -7
  30. package/dist/browser/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
  31. package/dist/browser/policies/defaultRetryPolicy.js +2 -1
  32. package/dist/browser/policies/defaultRetryPolicy.js.map +1 -1
  33. package/dist/browser/policies/exponentialRetryPolicy.js +3 -5
  34. package/dist/browser/policies/exponentialRetryPolicy.js.map +1 -1
  35. package/dist/browser/policies/formDataPolicy.js +1 -1
  36. package/dist/browser/policies/formDataPolicy.js.map +1 -1
  37. package/dist/browser/policies/logPolicy.js +2 -1
  38. package/dist/browser/policies/logPolicy.js.map +1 -1
  39. package/dist/browser/policies/multipartPolicy.js +3 -2
  40. package/dist/browser/policies/multipartPolicy.js.map +1 -1
  41. package/dist/browser/policies/retryPolicy.js +3 -2
  42. package/dist/browser/policies/retryPolicy.js.map +1 -1
  43. package/dist/browser/policies/systemErrorRetryPolicy.js +3 -5
  44. package/dist/browser/policies/systemErrorRetryPolicy.js.map +1 -1
  45. package/dist/browser/policies/throttlingRetryPolicy.js +2 -1
  46. package/dist/browser/policies/throttlingRetryPolicy.js.map +1 -1
  47. package/dist/browser/policies/tracingPolicy.js +3 -2
  48. package/dist/browser/policies/tracingPolicy.js.map +1 -1
  49. package/dist/browser/restError.js +11 -31
  50. package/dist/browser/restError.js.map +1 -1
  51. package/dist/browser/retryStrategies/exponentialRetryStrategy.js +3 -2
  52. package/dist/browser/retryStrategies/exponentialRetryStrategy.js.map +1 -1
  53. package/dist/browser/tracing/tracingClient.js +3 -7
  54. package/dist/browser/tracing/tracingClient.js.map +1 -1
  55. package/dist/browser/tracing/tracingContext.js +0 -1
  56. package/dist/browser/tracing/tracingContext.js.map +1 -1
  57. package/dist/browser/util/aborterUtils.js +3 -2
  58. package/dist/browser/util/aborterUtils.js.map +1 -1
  59. package/dist/browser/util/checkEnvironment.d.ts +10 -1
  60. package/dist/browser/util/checkEnvironment.d.ts.map +1 -1
  61. package/dist/browser/util/checkEnvironment.js +18 -11
  62. package/dist/browser/util/checkEnvironment.js.map +1 -1
  63. package/dist/browser/util/createAbortablePromise.js +6 -6
  64. package/dist/browser/util/createAbortablePromise.js.map +1 -1
  65. package/dist/browser/util/delay.js +2 -2
  66. package/dist/browser/util/delay.js.map +1 -1
  67. package/dist/browser/util/file.js +5 -22
  68. package/dist/browser/util/file.js.map +1 -1
  69. package/dist/browser/util/helpers.js +4 -4
  70. package/dist/browser/util/helpers.js.map +1 -1
  71. package/dist/browser/util/sanitizer.js +1 -7
  72. package/dist/browser/util/sanitizer.js.map +1 -1
  73. package/dist/browser/util/tokenCycler.js +6 -7
  74. package/dist/browser/util/tokenCycler.js.map +1 -1
  75. package/dist/browser/util/userAgentPlatform-browser.mjs.map +1 -1
  76. package/dist/browser/util/userAgentPlatform.js +2 -1
  77. package/dist/browser/util/uuidUtils-browser.mjs.map +1 -1
  78. package/dist/browser/util/uuidUtils.js +2 -1
  79. package/dist/browser/xhrHttpClient.js +5 -3
  80. package/dist/browser/xhrHttpClient.js.map +1 -1
  81. package/dist/commonjs/accessTokenCache.js +0 -2
  82. package/dist/commonjs/accessTokenCache.js.map +1 -1
  83. package/dist/commonjs/client/clientHelpers.js +4 -3
  84. package/dist/commonjs/client/clientHelpers.js.map +1 -1
  85. package/dist/commonjs/client/getClient.js +9 -7
  86. package/dist/commonjs/client/getClient.js.map +1 -1
  87. package/dist/commonjs/client/operationOptionHelpers.js +7 -6
  88. package/dist/commonjs/client/operationOptionHelpers.js.map +1 -1
  89. package/dist/commonjs/client/restError.js +4 -2
  90. package/dist/commonjs/client/restError.js.map +1 -1
  91. package/dist/commonjs/client/sendRequest.js +18 -19
  92. package/dist/commonjs/client/sendRequest.js.map +1 -1
  93. package/dist/commonjs/client/urlHelpers.js +2 -1
  94. package/dist/commonjs/client/urlHelpers.js.map +1 -1
  95. package/dist/commonjs/fetchHttpClient.js +20 -26
  96. package/dist/commonjs/fetchHttpClient.js.map +1 -1
  97. package/dist/commonjs/httpHeaders.js +2 -2
  98. package/dist/commonjs/httpHeaders.js.map +1 -1
  99. package/dist/commonjs/index.d.ts +1 -1
  100. package/dist/commonjs/index.d.ts.map +1 -1
  101. package/dist/commonjs/index.js +3 -1
  102. package/dist/commonjs/index.js.map +1 -1
  103. package/dist/commonjs/nodeHttpClient.js +20 -18
  104. package/dist/commonjs/nodeHttpClient.js.map +1 -1
  105. package/dist/commonjs/pipeline.js +3 -3
  106. package/dist/commonjs/pipeline.js.map +1 -1
  107. package/dist/commonjs/pipelineRequest.js +8 -25
  108. package/dist/commonjs/pipelineRequest.js.map +1 -1
  109. package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js +3 -7
  110. package/dist/commonjs/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
  111. package/dist/commonjs/policies/defaultRetryPolicy.js +2 -1
  112. package/dist/commonjs/policies/defaultRetryPolicy.js.map +1 -1
  113. package/dist/commonjs/policies/exponentialRetryPolicy.js +3 -5
  114. package/dist/commonjs/policies/exponentialRetryPolicy.js.map +1 -1
  115. package/dist/commonjs/policies/formDataPolicy.js +1 -1
  116. package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
  117. package/dist/commonjs/policies/logPolicy.js +2 -1
  118. package/dist/commonjs/policies/logPolicy.js.map +1 -1
  119. package/dist/commonjs/policies/multipartPolicy.js +3 -2
  120. package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
  121. package/dist/commonjs/policies/proxyPolicy.js +4 -3
  122. package/dist/commonjs/policies/proxyPolicy.js.map +1 -1
  123. package/dist/commonjs/policies/retryPolicy.js +3 -2
  124. package/dist/commonjs/policies/retryPolicy.js.map +1 -1
  125. package/dist/commonjs/policies/systemErrorRetryPolicy.js +3 -5
  126. package/dist/commonjs/policies/systemErrorRetryPolicy.js.map +1 -1
  127. package/dist/commonjs/policies/throttlingRetryPolicy.js +2 -1
  128. package/dist/commonjs/policies/throttlingRetryPolicy.js.map +1 -1
  129. package/dist/commonjs/policies/tracingPolicy.js +3 -2
  130. package/dist/commonjs/policies/tracingPolicy.js.map +1 -1
  131. package/dist/commonjs/restError.js +11 -31
  132. package/dist/commonjs/restError.js.map +1 -1
  133. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js +3 -2
  134. package/dist/commonjs/retryStrategies/exponentialRetryStrategy.js.map +1 -1
  135. package/dist/commonjs/tracing/tracingClient.js +3 -7
  136. package/dist/commonjs/tracing/tracingClient.js.map +1 -1
  137. package/dist/commonjs/tracing/tracingContext.js +0 -1
  138. package/dist/commonjs/tracing/tracingContext.js.map +1 -1
  139. package/dist/commonjs/util/aborterUtils.js +3 -2
  140. package/dist/commonjs/util/aborterUtils.js.map +1 -1
  141. package/dist/commonjs/util/checkEnvironment.d.ts +10 -1
  142. package/dist/commonjs/util/checkEnvironment.d.ts.map +1 -1
  143. package/dist/commonjs/util/checkEnvironment.js +19 -12
  144. package/dist/commonjs/util/checkEnvironment.js.map +1 -1
  145. package/dist/commonjs/util/concat.js +35 -17
  146. package/dist/commonjs/util/concat.js.map +1 -1
  147. package/dist/commonjs/util/createAbortablePromise.js +6 -6
  148. package/dist/commonjs/util/createAbortablePromise.js.map +1 -1
  149. package/dist/commonjs/util/delay.js +2 -2
  150. package/dist/commonjs/util/delay.js.map +1 -1
  151. package/dist/commonjs/util/file.js +5 -22
  152. package/dist/commonjs/util/file.js.map +1 -1
  153. package/dist/commonjs/util/helpers.js +4 -4
  154. package/dist/commonjs/util/helpers.js.map +1 -1
  155. package/dist/commonjs/util/sanitizer.js +1 -7
  156. package/dist/commonjs/util/sanitizer.js.map +1 -1
  157. package/dist/commonjs/util/tokenCycler.js +6 -7
  158. package/dist/commonjs/util/tokenCycler.js.map +1 -1
  159. package/dist/commonjs/util/uuidUtils.js +2 -1
  160. package/dist/commonjs/util/uuidUtils.js.map +1 -1
  161. package/dist/commonjs/xhrHttpClient.js +5 -3
  162. package/dist/commonjs/xhrHttpClient.js.map +1 -1
  163. package/dist/esm/accessTokenCache.js +0 -2
  164. package/dist/esm/accessTokenCache.js.map +1 -1
  165. package/dist/esm/client/clientHelpers.js +4 -3
  166. package/dist/esm/client/clientHelpers.js.map +1 -1
  167. package/dist/esm/client/getClient.js +9 -7
  168. package/dist/esm/client/getClient.js.map +1 -1
  169. package/dist/esm/client/operationOptionHelpers.js +7 -6
  170. package/dist/esm/client/operationOptionHelpers.js.map +1 -1
  171. package/dist/esm/client/restError.js +4 -2
  172. package/dist/esm/client/restError.js.map +1 -1
  173. package/dist/esm/client/sendRequest.js +18 -19
  174. package/dist/esm/client/sendRequest.js.map +1 -1
  175. package/dist/esm/client/urlHelpers.js +2 -1
  176. package/dist/esm/client/urlHelpers.js.map +1 -1
  177. package/dist/esm/fetchHttpClient.js +20 -26
  178. package/dist/esm/fetchHttpClient.js.map +1 -1
  179. package/dist/esm/httpHeaders.js +2 -2
  180. package/dist/esm/httpHeaders.js.map +1 -1
  181. package/dist/esm/index.d.ts +1 -1
  182. package/dist/esm/index.d.ts.map +1 -1
  183. package/dist/esm/index.js +1 -1
  184. package/dist/esm/index.js.map +1 -1
  185. package/dist/esm/nodeHttpClient.js +20 -18
  186. package/dist/esm/nodeHttpClient.js.map +1 -1
  187. package/dist/esm/pipeline.js +3 -3
  188. package/dist/esm/pipeline.js.map +1 -1
  189. package/dist/esm/pipelineRequest.js +8 -25
  190. package/dist/esm/pipelineRequest.js.map +1 -1
  191. package/dist/esm/policies/bearerTokenAuthenticationPolicy.js +3 -7
  192. package/dist/esm/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
  193. package/dist/esm/policies/defaultRetryPolicy.js +2 -1
  194. package/dist/esm/policies/defaultRetryPolicy.js.map +1 -1
  195. package/dist/esm/policies/exponentialRetryPolicy.js +3 -5
  196. package/dist/esm/policies/exponentialRetryPolicy.js.map +1 -1
  197. package/dist/esm/policies/formDataPolicy.js +1 -1
  198. package/dist/esm/policies/formDataPolicy.js.map +1 -1
  199. package/dist/esm/policies/logPolicy.js +2 -1
  200. package/dist/esm/policies/logPolicy.js.map +1 -1
  201. package/dist/esm/policies/multipartPolicy.js +3 -2
  202. package/dist/esm/policies/multipartPolicy.js.map +1 -1
  203. package/dist/esm/policies/proxyPolicy.js +4 -3
  204. package/dist/esm/policies/proxyPolicy.js.map +1 -1
  205. package/dist/esm/policies/retryPolicy.js +3 -2
  206. package/dist/esm/policies/retryPolicy.js.map +1 -1
  207. package/dist/esm/policies/systemErrorRetryPolicy.js +3 -5
  208. package/dist/esm/policies/systemErrorRetryPolicy.js.map +1 -1
  209. package/dist/esm/policies/throttlingRetryPolicy.js +2 -1
  210. package/dist/esm/policies/throttlingRetryPolicy.js.map +1 -1
  211. package/dist/esm/policies/tracingPolicy.js +3 -2
  212. package/dist/esm/policies/tracingPolicy.js.map +1 -1
  213. package/dist/esm/restError.js +11 -31
  214. package/dist/esm/restError.js.map +1 -1
  215. package/dist/esm/retryStrategies/exponentialRetryStrategy.js +3 -2
  216. package/dist/esm/retryStrategies/exponentialRetryStrategy.js.map +1 -1
  217. package/dist/esm/tracing/tracingClient.js +3 -7
  218. package/dist/esm/tracing/tracingClient.js.map +1 -1
  219. package/dist/esm/tracing/tracingContext.js +0 -1
  220. package/dist/esm/tracing/tracingContext.js.map +1 -1
  221. package/dist/esm/util/aborterUtils.js +3 -2
  222. package/dist/esm/util/aborterUtils.js.map +1 -1
  223. package/dist/esm/util/checkEnvironment.d.ts +10 -1
  224. package/dist/esm/util/checkEnvironment.d.ts.map +1 -1
  225. package/dist/esm/util/checkEnvironment.js +18 -11
  226. package/dist/esm/util/checkEnvironment.js.map +1 -1
  227. package/dist/esm/util/concat.js +35 -17
  228. package/dist/esm/util/concat.js.map +1 -1
  229. package/dist/esm/util/createAbortablePromise.js +6 -6
  230. package/dist/esm/util/createAbortablePromise.js.map +1 -1
  231. package/dist/esm/util/delay.js +2 -2
  232. package/dist/esm/util/delay.js.map +1 -1
  233. package/dist/esm/util/file.js +5 -22
  234. package/dist/esm/util/file.js.map +1 -1
  235. package/dist/esm/util/helpers.js +4 -4
  236. package/dist/esm/util/helpers.js.map +1 -1
  237. package/dist/esm/util/sanitizer.js +1 -7
  238. package/dist/esm/util/sanitizer.js.map +1 -1
  239. package/dist/esm/util/tokenCycler.js +6 -7
  240. package/dist/esm/util/tokenCycler.js.map +1 -1
  241. package/dist/esm/util/uuidUtils.js +2 -1
  242. package/dist/esm/util/uuidUtils.js.map +1 -1
  243. package/dist/esm/xhrHttpClient.js +5 -3
  244. package/dist/esm/xhrHttpClient.js.map +1 -1
  245. package/dist/react-native/accessTokenCache.js +0 -2
  246. package/dist/react-native/accessTokenCache.js.map +1 -1
  247. package/dist/react-native/client/clientHelpers.js +4 -3
  248. package/dist/react-native/client/clientHelpers.js.map +1 -1
  249. package/dist/react-native/client/getClient.js +9 -7
  250. package/dist/react-native/client/getClient.js.map +1 -1
  251. package/dist/react-native/client/operationOptionHelpers.js +7 -6
  252. package/dist/react-native/client/operationOptionHelpers.js.map +1 -1
  253. package/dist/react-native/client/restError.js +4 -2
  254. package/dist/react-native/client/restError.js.map +1 -1
  255. package/dist/react-native/client/sendRequest.js +18 -19
  256. package/dist/react-native/client/sendRequest.js.map +1 -1
  257. package/dist/react-native/client/urlHelpers.js +2 -1
  258. package/dist/react-native/client/urlHelpers.js.map +1 -1
  259. package/dist/react-native/fetchHttpClient.js +20 -26
  260. package/dist/react-native/fetchHttpClient.js.map +1 -1
  261. package/dist/react-native/httpHeaders.js +2 -2
  262. package/dist/react-native/httpHeaders.js.map +1 -1
  263. package/dist/react-native/index.d.ts +1 -1
  264. package/dist/react-native/index.d.ts.map +1 -1
  265. package/dist/react-native/index.js +1 -1
  266. package/dist/react-native/index.js.map +1 -1
  267. package/dist/react-native/nodeHttpClient.js +20 -18
  268. package/dist/react-native/nodeHttpClient.js.map +1 -1
  269. package/dist/react-native/pipeline.js +3 -3
  270. package/dist/react-native/pipeline.js.map +1 -1
  271. package/dist/react-native/pipelineRequest.js +8 -25
  272. package/dist/react-native/pipelineRequest.js.map +1 -1
  273. package/dist/react-native/policies/bearerTokenAuthenticationPolicy.js +3 -7
  274. package/dist/react-native/policies/bearerTokenAuthenticationPolicy.js.map +1 -1
  275. package/dist/react-native/policies/defaultRetryPolicy.js +2 -1
  276. package/dist/react-native/policies/defaultRetryPolicy.js.map +1 -1
  277. package/dist/react-native/policies/exponentialRetryPolicy.js +3 -5
  278. package/dist/react-native/policies/exponentialRetryPolicy.js.map +1 -1
  279. package/dist/react-native/policies/formDataPolicy.js +1 -1
  280. package/dist/react-native/policies/formDataPolicy.js.map +1 -1
  281. package/dist/react-native/policies/logPolicy.js +2 -1
  282. package/dist/react-native/policies/logPolicy.js.map +1 -1
  283. package/dist/react-native/policies/multipartPolicy.js +3 -2
  284. package/dist/react-native/policies/multipartPolicy.js.map +1 -1
  285. package/dist/react-native/policies/proxyPolicy.js +4 -3
  286. package/dist/react-native/policies/proxyPolicy.js.map +1 -1
  287. package/dist/react-native/policies/retryPolicy.js +3 -2
  288. package/dist/react-native/policies/retryPolicy.js.map +1 -1
  289. package/dist/react-native/policies/systemErrorRetryPolicy.js +3 -5
  290. package/dist/react-native/policies/systemErrorRetryPolicy.js.map +1 -1
  291. package/dist/react-native/policies/throttlingRetryPolicy.js +2 -1
  292. package/dist/react-native/policies/throttlingRetryPolicy.js.map +1 -1
  293. package/dist/react-native/policies/tracingPolicy.js +3 -2
  294. package/dist/react-native/policies/tracingPolicy.js.map +1 -1
  295. package/dist/react-native/restError.js +11 -31
  296. package/dist/react-native/restError.js.map +1 -1
  297. package/dist/react-native/retryStrategies/exponentialRetryStrategy.js +3 -2
  298. package/dist/react-native/retryStrategies/exponentialRetryStrategy.js.map +1 -1
  299. package/dist/react-native/tracing/tracingClient.js +3 -7
  300. package/dist/react-native/tracing/tracingClient.js.map +1 -1
  301. package/dist/react-native/tracing/tracingContext.js +0 -1
  302. package/dist/react-native/tracing/tracingContext.js.map +1 -1
  303. package/dist/react-native/util/aborterUtils.js +3 -2
  304. package/dist/react-native/util/aborterUtils.js.map +1 -1
  305. package/dist/react-native/util/checkEnvironment.d.ts +10 -1
  306. package/dist/react-native/util/checkEnvironment.d.ts.map +1 -1
  307. package/dist/react-native/util/checkEnvironment.js +18 -11
  308. package/dist/react-native/util/checkEnvironment.js.map +1 -1
  309. package/dist/react-native/util/concat.js +35 -17
  310. package/dist/react-native/util/concat.js.map +1 -1
  311. package/dist/react-native/util/createAbortablePromise.js +6 -6
  312. package/dist/react-native/util/createAbortablePromise.js.map +1 -1
  313. package/dist/react-native/util/delay.js +2 -2
  314. package/dist/react-native/util/delay.js.map +1 -1
  315. package/dist/react-native/util/file.js +5 -22
  316. package/dist/react-native/util/file.js.map +1 -1
  317. package/dist/react-native/util/helpers.js +4 -4
  318. package/dist/react-native/util/helpers.js.map +1 -1
  319. package/dist/react-native/util/sanitizer.js +1 -7
  320. package/dist/react-native/util/sanitizer.js.map +1 -1
  321. package/dist/react-native/util/tokenCycler.js +6 -7
  322. package/dist/react-native/util/tokenCycler.js.map +1 -1
  323. package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +1 -1
  324. package/dist/react-native/util/userAgentPlatform.js +2 -1
  325. package/dist/react-native/xhrHttpClient.js +5 -3
  326. package/dist/react-native/xhrHttpClient.js.map +1 -1
  327. package/dist/ts-http-runtime.d.ts +12 -1
  328. package/package.json +2 -2
@@ -8,37 +8,6 @@ const errorSanitizer = new Sanitizer();
8
8
  * A custom error type for failed pipeline requests.
9
9
  */
10
10
  export class RestError extends Error {
11
- /**
12
- * Something went wrong when making the request.
13
- * This means the actual request failed for some reason,
14
- * such as a DNS issue or the connection being lost.
15
- */
16
- static REQUEST_SEND_ERROR = "REQUEST_SEND_ERROR";
17
- /**
18
- * This means that parsing the response from the server failed.
19
- * It may have been malformed.
20
- */
21
- static PARSE_ERROR = "PARSE_ERROR";
22
- /**
23
- * The code of the error itself (use statics on RestError if possible.)
24
- */
25
- code;
26
- /**
27
- * The HTTP status code of the request (if applicable.)
28
- */
29
- statusCode;
30
- /**
31
- * The request that was made.
32
- */
33
- request;
34
- /**
35
- * The response received (if any.)
36
- */
37
- response;
38
- /**
39
- * Bonus property set by the throw site.
40
- */
41
- details;
42
11
  constructor(message, options = {}) {
43
12
  super(message);
44
13
  this.name = "RestError";
@@ -55,6 +24,17 @@ export class RestError extends Error {
55
24
  return `RestError: ${this.message} \n ${errorSanitizer.sanitize(this)}`;
56
25
  }
57
26
  }
27
+ /**
28
+ * Something went wrong when making the request.
29
+ * This means the actual request failed for some reason,
30
+ * such as a DNS issue or the connection being lost.
31
+ */
32
+ RestError.REQUEST_SEND_ERROR = "REQUEST_SEND_ERROR";
33
+ /**
34
+ * This means that parsing the response from the server failed.
35
+ * It may have been malformed.
36
+ */
37
+ RestError.PARSE_ERROR = "PARSE_ERROR";
58
38
  /**
59
39
  * Typeguard for RestError
60
40
  * @param e - Something caught by a catch clause.
@@ -1 +1 @@
1
- {"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE,CAAC;AAwBvC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC;;;;OAIG;IACH,MAAM,CAAU,kBAAkB,GAAW,oBAAoB,CAAC;IAClE;;;OAGG;IACH,MAAM,CAAU,WAAW,GAAW,aAAa,CAAC;IAEpD;;OAEG;IACI,IAAI,CAAU;IACrB;;OAEG;IACI,UAAU,CAAU;IAC3B;;OAEG;IACI,OAAO,CAAmB;IACjC;;OAEG;IACI,QAAQ,CAAoB;IACnC;;OAEG;IACI,OAAO,CAAW;IAEzB,YAAY,OAAe,EAAE,UAA4B,EAAE;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAEjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC;QACN,OAAO,cAAc,IAAI,CAAC,OAAO,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1E,CAAC;;AAGH;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;AAC9C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isError } from \"./util/error.js\";\nimport { PipelineRequest, PipelineResponse } from \"./interfaces.js\";\nimport { custom } from \"./util/inspect.js\";\nimport { Sanitizer } from \"./util/sanitizer.js\";\n\nconst errorSanitizer = new Sanitizer();\n\n/**\n * The options supported by RestError.\n */\nexport interface RestErrorOptions {\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n statusCode?: number;\n /**\n * The request that was made.\n */\n request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n response?: PipelineResponse;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\nexport class RestError extends Error {\n /**\n * Something went wrong when making the request.\n * This means the actual request failed for some reason,\n * such as a DNS issue or the connection being lost.\n */\n static readonly REQUEST_SEND_ERROR: string = \"REQUEST_SEND_ERROR\";\n /**\n * This means that parsing the response from the server failed.\n * It may have been malformed.\n */\n static readonly PARSE_ERROR: string = \"PARSE_ERROR\";\n\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n public code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n public statusCode?: number;\n /**\n * The request that was made.\n */\n public request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n public response?: PipelineResponse;\n /**\n * Bonus property set by the throw site.\n */\n public details?: unknown;\n\n constructor(message: string, options: RestErrorOptions = {}) {\n super(message);\n this.name = \"RestError\";\n this.code = options.code;\n this.statusCode = options.statusCode;\n this.request = options.request;\n this.response = options.response;\n\n Object.setPrototypeOf(this, RestError.prototype);\n }\n\n /**\n * Logging method for util.inspect in Node\n */\n [custom](): string {\n return `RestError: ${this.message} \\n ${errorSanitizer.sanitize(this)}`;\n }\n}\n\n/**\n * Typeguard for RestError\n * @param e - Something caught by a catch clause.\n */\nexport function isRestError(e: unknown): e is RestError {\n if (e instanceof RestError) {\n return true;\n }\n return isError(e) && e.name === \"RestError\";\n}\n"]}
1
+ {"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,cAAc,GAAG,IAAI,SAAS,EAAE,CAAC;AAwBvC;;GAEG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IAkClC,YAAY,OAAe,EAAE,UAA4B,EAAE;QACzD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAEjC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC;QACN,OAAO,cAAc,IAAI,CAAC,OAAO,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAC1E,CAAC;;AAjDD;;;;GAIG;AACa,4BAAkB,GAAW,oBAAoB,CAAC;AAClE;;;GAGG;AACa,qBAAW,GAAW,aAAa,CAAC;AA0CtD;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,IAAI,CAAC,YAAY,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;AAC9C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isError } from \"./util/error.js\";\nimport { PipelineRequest, PipelineResponse } from \"./interfaces.js\";\nimport { custom } from \"./util/inspect.js\";\nimport { Sanitizer } from \"./util/sanitizer.js\";\n\nconst errorSanitizer = new Sanitizer();\n\n/**\n * The options supported by RestError.\n */\nexport interface RestErrorOptions {\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n statusCode?: number;\n /**\n * The request that was made.\n */\n request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n response?: PipelineResponse;\n}\n\n/**\n * A custom error type for failed pipeline requests.\n */\nexport class RestError extends Error {\n /**\n * Something went wrong when making the request.\n * This means the actual request failed for some reason,\n * such as a DNS issue or the connection being lost.\n */\n static readonly REQUEST_SEND_ERROR: string = \"REQUEST_SEND_ERROR\";\n /**\n * This means that parsing the response from the server failed.\n * It may have been malformed.\n */\n static readonly PARSE_ERROR: string = \"PARSE_ERROR\";\n\n /**\n * The code of the error itself (use statics on RestError if possible.)\n */\n public code?: string;\n /**\n * The HTTP status code of the request (if applicable.)\n */\n public statusCode?: number;\n /**\n * The request that was made.\n */\n public request?: PipelineRequest;\n /**\n * The response received (if any.)\n */\n public response?: PipelineResponse;\n /**\n * Bonus property set by the throw site.\n */\n public details?: unknown;\n\n constructor(message: string, options: RestErrorOptions = {}) {\n super(message);\n this.name = \"RestError\";\n this.code = options.code;\n this.statusCode = options.statusCode;\n this.request = options.request;\n this.response = options.response;\n\n Object.setPrototypeOf(this, RestError.prototype);\n }\n\n /**\n * Logging method for util.inspect in Node\n */\n [custom](): string {\n return `RestError: ${this.message} \\n ${errorSanitizer.sanitize(this)}`;\n }\n}\n\n/**\n * Typeguard for RestError\n * @param e - Something caught by a catch clause.\n */\nexport function isRestError(e: unknown): e is RestError {\n if (e instanceof RestError) {\n return true;\n }\n return isError(e) && e.name === \"RestError\";\n}\n"]}
@@ -11,8 +11,9 @@ const DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 64;
11
11
  * - Or otherwise if the outgoing request fails (408, greater or equal than 500, except for 501 and 505).
12
12
  */
13
13
  export function exponentialRetryStrategy(options = {}) {
14
- const retryInterval = options.retryDelayInMs ?? DEFAULT_CLIENT_RETRY_INTERVAL;
15
- const maxRetryInterval = options.maxRetryDelayInMs ?? DEFAULT_CLIENT_MAX_RETRY_INTERVAL;
14
+ var _a, _b;
15
+ const retryInterval = (_a = options.retryDelayInMs) !== null && _a !== void 0 ? _a : DEFAULT_CLIENT_RETRY_INTERVAL;
16
+ const maxRetryInterval = (_b = options.maxRetryDelayInMs) !== null && _b !== void 0 ? _b : DEFAULT_CLIENT_MAX_RETRY_INTERVAL;
16
17
  let retryAfterInMs = retryInterval;
17
18
  return {
18
19
  name: "exponentialRetryStrategy",
@@ -1 +1 @@
1
- {"version":3,"file":"exponentialRetryStrategy.js","sourceRoot":"","sources":["../../../src/retryStrategies/exponentialRetryStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,M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AgB,EAAE,gBAAgB,CAAC,CAAC;YAC7E,gFAAgF;YAChF,mEAAmE;YACnE,cAAc;gBACZ,uBAAuB,GAAG,CAAC,GAAG,yBAAyB,CAAC,CAAC,EAAE,uBAAuB,GAAG,CAAC,CAAC,CAAC;YAC1F,OAAO,EAAE,cAAc,EAAE,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,QAA2B;IACpE,OAAO,OAAO,CACZ,QAAQ;QACN,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC7B,CAAC,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC;QACnD,QAAQ,CAAC,MAAM,KAAK,GAAG;QACvB,QAAQ,CAAC,MAAM,KAAK,GAAG,CAC1B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAe;IAC3C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,GAAG,CAAC,IAAI,KAAK,WAAW;QACxB,GAAG,CAAC,IAAI,KAAK,iBAAiB;QAC9B,GAAG,CAAC,IAAI,KAAK,cAAc;QAC3B,GAAG,CAAC,IAAI,KAAK,YAAY;QACzB,GAAG,CAAC,IAAI,KAAK,QAAQ;QACrB,GAAG,CAAC,IAAI,KAAK,WAAW,CACzB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PipelineResponse } from \"../interfaces.js\";\nimport { RestError } from \"../restError.js\";\nimport { getRandomIntegerInclusive } from \"../util/random.js\";\nimport { RetryStrategy } from \"./retryStrategy.js\";\nimport { isThrottlingRetryResponse } from \"./throttlingRetryStrategy.js\";\n\n// intervals are in milliseconds\nconst DEFAULT_CLIENT_RETRY_INTERVAL = 1000;\nconst DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 64;\n\n/**\n * A retry strategy that retries with an exponentially increasing delay in these two cases:\n * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).\n * - Or otherwise if the outgoing request fails (408, greater or equal than 500, except for 501 and 505).\n */\nexport function exponentialRetryStrategy(\n options: {\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n\n /**\n * If true it won't retry if it received a system error.\n */\n ignoreSystemErrors?: boolean;\n\n /**\n * If true it won't retry if it received a non-fatal HTTP status code.\n */\n ignoreHttpStatusCodes?: boolean;\n } = {},\n): RetryStrategy {\n const retryInterval = options.retryDelayInMs ?? DEFAULT_CLIENT_RETRY_INTERVAL;\n const maxRetryInterval = options.maxRetryDelayInMs ?? DEFAULT_CLIENT_MAX_RETRY_INTERVAL;\n\n let retryAfterInMs = retryInterval;\n\n return {\n name: \"exponentialRetryStrategy\",\n retry({ retryCount, response, responseError }) {\n const matchedSystemError = isSystemError(responseError);\n const ignoreSystemErrors = matchedSystemError && options.ignoreSystemErrors;\n\n const isExponential = isExponentialRetryResponse(response);\n const ignoreExponentialResponse = isExponential && options.ignoreHttpStatusCodes;\n const unknownResponse = response && (isThrottlingRetryResponse(response) || !isExponential);\n\n if (unknownResponse || ignoreExponentialResponse || ignoreSystemErrors) {\n return { skipStrategy: true };\n }\n\n if (responseError && !matchedSystemError && !isExponential) {\n return { errorToThrow: responseError };\n }\n\n // Exponentially increase the delay each time\n const exponentialDelay = retryAfterInMs * Math.pow(2, retryCount);\n // Don't let the delay exceed the maximum\n const clampedExponentialDelay = Math.min(maxRetryInterval, exponentialDelay);\n // Allow the final value to have some \"jitter\" (within 50% of the delay size) so\n // that retries across multiple clients don't occur simultaneously.\n retryAfterInMs =\n clampedExponentialDelay / 2 + getRandomIntegerInclusive(0, clampedExponentialDelay / 2);\n return { retryAfterInMs };\n },\n };\n}\n\n/**\n * A response is a retry response if it has status codes:\n * - 408, or\n * - Greater or equal than 500, except for 501 and 505.\n */\nexport function isExponentialRetryResponse(response?: PipelineResponse): boolean {\n return Boolean(\n response &&\n response.status !== undefined &&\n (response.status >= 500 || response.status === 408) &&\n response.status !== 501 &&\n response.status !== 505,\n );\n}\n\n/**\n * Determines whether an error from a pipeline response was triggered in the network layer.\n */\nexport function isSystemError(err?: RestError): boolean {\n if (!err) {\n return false;\n }\n return (\n err.code === \"ETIMEDOUT\" ||\n err.code === \"ESOCKETTIMEDOUT\" ||\n err.code === \"ECONNREFUSED\" ||\n err.code === \"ECONNRESET\" ||\n err.code === \"ENOENT\" ||\n err.code === \"ENOTFOUND\"\n );\n}\n"]}
1
+ {"version":3,"file":"exponentialRetryStrategy.js","sourceRoot":"","sources":["../../../src/retryStrategies/exponentialRetryStrategy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAEzE,gCAAgC;AAChC,MAAM,6BAA6B,GAAG,IAAI,CAAC;AAC3C,MAAM,iCAAiC,GAAG,IAAI,GAAG,EAAE,CAAC;AAEpD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,UAuBI,EAAE;;IAEN,MAAM,aAAa,GAAG,MAAA,OAAO,CAAC,cAAc,mCAAI,6BAA6B,CAAC;IAC9E,MAAM,gBAAgB,GAAG,MAAA,OAAO,CAAC,iBAAiB,mCAAI,iCAAiC,CAAC;IAExF,IAAI,cAAc,GAAG,aAAa,CAAC;IAEnC,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,KAAK,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE;YAC3C,MAAM,kBAAkB,GAAG,aAAa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ACvB,QAAQ,CAAC,MAAM,KAAK,GAAG,CAC1B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAe;IAC3C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,CACL,GAAG,CAAC,IAAI,KAAK,WAAW;QACxB,GAAG,CAAC,IAAI,KAAK,iBAAiB;QAC9B,GAAG,CAAC,IAAI,KAAK,cAAc;QAC3B,GAAG,CAAC,IAAI,KAAK,YAAY;QACzB,GAAG,CAAC,IAAI,KAAK,QAAQ;QACrB,GAAG,CAAC,IAAI,KAAK,WAAW,CACzB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PipelineResponse } from \"../interfaces.js\";\nimport { RestError } from \"../restError.js\";\nimport { getRandomIntegerInclusive } from \"../util/random.js\";\nimport { RetryStrategy } from \"./retryStrategy.js\";\nimport { isThrottlingRetryResponse } from \"./throttlingRetryStrategy.js\";\n\n// intervals are in milliseconds\nconst DEFAULT_CLIENT_RETRY_INTERVAL = 1000;\nconst DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 64;\n\n/**\n * A retry strategy that retries with an exponentially increasing delay in these two cases:\n * - When there are errors in the underlying transport layer (e.g. DNS lookup failures).\n * - Or otherwise if the outgoing request fails (408, greater or equal than 500, except for 501 and 505).\n */\nexport function exponentialRetryStrategy(\n options: {\n /**\n * The amount of delay in milliseconds between retry attempts. Defaults to 1000\n * (1 second.) The delay increases exponentially with each retry up to a maximum\n * specified by maxRetryDelayInMs.\n */\n retryDelayInMs?: number;\n\n /**\n * The maximum delay in milliseconds allowed before retrying an operation. Defaults\n * to 64000 (64 seconds).\n */\n maxRetryDelayInMs?: number;\n\n /**\n * If true it won't retry if it received a system error.\n */\n ignoreSystemErrors?: boolean;\n\n /**\n * If true it won't retry if it received a non-fatal HTTP status code.\n */\n ignoreHttpStatusCodes?: boolean;\n } = {},\n): RetryStrategy {\n const retryInterval = options.retryDelayInMs ?? DEFAULT_CLIENT_RETRY_INTERVAL;\n const maxRetryInterval = options.maxRetryDelayInMs ?? DEFAULT_CLIENT_MAX_RETRY_INTERVAL;\n\n let retryAfterInMs = retryInterval;\n\n return {\n name: \"exponentialRetryStrategy\",\n retry({ retryCount, response, responseError }) {\n const matchedSystemError = isSystemError(responseError);\n const ignoreSystemErrors = matchedSystemError && options.ignoreSystemErrors;\n\n const isExponential = isExponentialRetryResponse(response);\n const ignoreExponentialResponse = isExponential && options.ignoreHttpStatusCodes;\n const unknownResponse = response && (isThrottlingRetryResponse(response) || !isExponential);\n\n if (unknownResponse || ignoreExponentialResponse || ignoreSystemErrors) {\n return { skipStrategy: true };\n }\n\n if (responseError && !matchedSystemError && !isExponential) {\n return { errorToThrow: responseError };\n }\n\n // Exponentially increase the delay each time\n const exponentialDelay = retryAfterInMs * Math.pow(2, retryCount);\n // Don't let the delay exceed the maximum\n const clampedExponentialDelay = Math.min(maxRetryInterval, exponentialDelay);\n // Allow the final value to have some \"jitter\" (within 50% of the delay size) so\n // that retries across multiple clients don't occur simultaneously.\n retryAfterInMs =\n clampedExponentialDelay / 2 + getRandomIntegerInclusive(0, clampedExponentialDelay / 2);\n return { retryAfterInMs };\n },\n };\n}\n\n/**\n * A response is a retry response if it has status codes:\n * - 408, or\n * - Greater or equal than 500, except for 501 and 505.\n */\nexport function isExponentialRetryResponse(response?: PipelineResponse): boolean {\n return Boolean(\n response &&\n response.status !== undefined &&\n (response.status >= 500 || response.status === 408) &&\n response.status !== 501 &&\n response.status !== 505,\n );\n}\n\n/**\n * Determines whether an error from a pipeline response was triggered in the network layer.\n */\nexport function isSystemError(err?: RestError): boolean {\n if (!err) {\n return false;\n }\n return (\n err.code === \"ETIMEDOUT\" ||\n err.code === \"ESOCKETTIMEDOUT\" ||\n err.code === \"ECONNREFUSED\" ||\n err.code === \"ECONNRESET\" ||\n err.code === \"ENOENT\" ||\n err.code === \"ENOTFOUND\"\n );\n}\n"]}
@@ -11,12 +11,8 @@ import { knownContextKeys } from "./tracingContext.js";
11
11
  export function createTracingClient(options) {
12
12
  const { namespace, packageName, packageVersion } = options;
13
13
  function startSpan(name, operationOptions, spanOptions) {
14
- const startSpanResult = getInstrumenter().startSpan(name, {
15
- ...spanOptions,
16
- packageName: packageName,
17
- packageVersion: packageVersion,
18
- tracingContext: operationOptions?.tracingOptions?.tracingContext,
19
- });
14
+ var _a;
15
+ const startSpanResult = getInstrumenter().startSpan(name, Object.assign(Object.assign({}, spanOptions), { packageName: packageName, packageVersion: packageVersion, tracingContext: (_a = operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions) === null || _a === void 0 ? void 0 : _a.tracingContext }));
20
16
  let tracingContext = startSpanResult.tracingContext;
21
17
  const span = startSpanResult.span;
22
18
  if (!tracingContext.getValue(knownContextKeys.namespace)) {
@@ -24,7 +20,7 @@ export function createTracingClient(options) {
24
20
  }
25
21
  span.setAttribute("az.namespace", tracingContext.getValue(knownContextKeys.namespace));
26
22
  const updatedOptions = Object.assign({}, operationOptions, {
27
- tracingOptions: { ...operationOptions?.tracingOptions, tracingContext },
23
+ tracingOptions: Object.assign(Object.assign({}, operationOptions === null || operationOptions === void 0 ? void 0 : operationOptions.tracingOptions), { tracingContext }),
28
24
  });
29
25
  return {
30
26
  span,
@@ -1 +1 @@
1
- {"version":3,"file":"tracingClient.js","sourceRoot":"","sources":["../../../src/tracing/tracingClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAE3D,SAAS,SAAS,CAChB,IAAY,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,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;YACtC,OAAO,MAAqC,CAAC;QAC/C,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;YAChD,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,GAAG,EAAE,CAAC;QACb,CAAC;IACH,CAAC;IAED,SAAS,WAAW,CAIlB,OAAuB,EACvB,QAAkB,EAClB,GAAG,YAA0B;QAE7B,OAAO,eAAe,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,YAAY,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;OAKG;IACH,SAAS,sBAAsB,CAAC,iBAAyB;QACvD,OAAO,eAAe,EAAE,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,SAAS,oBAAoB,CAAC,cAA+B;QAC3D,OAAO,eAAe,EAAE,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAChE,CAAC;IAED,OAAO;QACL,SAAS;QACT,QAAQ;QACR,WAAW;QACX,sBAAsB;QACtB,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n OperationTracingOptions,\n OptionsWithTracingContext,\n Resolved,\n TracingClient,\n TracingClientOptions,\n TracingContext,\n TracingSpan,\n TracingSpanOptions,\n} from \"./interfaces.js\";\nimport { getInstrumenter } from \"./instrumenter.js\";\nimport { knownContextKeys } from \"./tracingContext.js\";\n\n/**\n * Creates a new tracing client.\n *\n * @param options - Options used to configure the tracing client.\n * @returns - An instance of {@link TracingClient}.\n */\nexport function createTracingClient(options: TracingClientOptions): TracingClient {\n const { namespace, packageName, packageVersion } = options;\n\n function startSpan<Options extends { tracingOptions?: OperationTracingOptions }>(\n name: string,\n operationOptions?: Options,\n spanOptions?: TracingSpanOptions,\n ): {\n span: TracingSpan;\n updatedOptions: OptionsWithTracingContext<Options>;\n } {\n const startSpanResult = getInstrumenter().startSpan(name, {\n ...spanOptions,\n packageName: packageName,\n packageVersion: packageVersion,\n tracingContext: operationOptions?.tracingOptions?.tracingContext,\n });\n let tracingContext = startSpanResult.tracingContext;\n const span = startSpanResult.span;\n if (!tracingContext.getValue(knownContextKeys.namespace)) {\n tracingContext = tracingContext.setValue(knownContextKeys.namespace, namespace);\n }\n span.setAttribute(\"az.namespace\", tracingContext.getValue(knownContextKeys.namespace));\n const updatedOptions: OptionsWithTracingContext<Options> = Object.assign({}, operationOptions, {\n tracingOptions: { ...operationOptions?.tracingOptions, tracingContext },\n });\n\n return {\n span,\n updatedOptions,\n };\n }\n\n async function withSpan<\n Options extends { tracingOptions?: OperationTracingOptions },\n Callback extends (\n updatedOptions: Options,\n span: Omit<TracingSpan, \"end\">,\n ) => ReturnType<Callback>,\n >(\n name: string,\n operationOptions: Options,\n callback: Callback,\n spanOptions?: TracingSpanOptions,\n ): Promise<Resolved<ReturnType<Callback>>> {\n const { span, updatedOptions } = startSpan(name, operationOptions, spanOptions);\n try {\n const result = await withContext(updatedOptions.tracingOptions.tracingContext, () =>\n Promise.resolve(callback(updatedOptions, span)),\n );\n span.setStatus({ status: \"success\" });\n return result as ReturnType<typeof withSpan>;\n } catch (err: any) {\n span.setStatus({ status: \"error\", error: err });\n throw err;\n } finally {\n span.end();\n }\n }\n\n function withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return getInstrumenter().withContext(context, callback, ...callbackArgs);\n }\n\n /**\n * Parses a traceparent header value into a span identifier.\n *\n * @param traceparentHeader - The traceparent header to parse.\n * @returns An implementation-specific identifier for the span.\n */\n function parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined {\n return getInstrumenter().parseTraceparentHeader(traceparentHeader);\n }\n\n /**\n * Creates a set of request headers to propagate tracing information to a backend.\n *\n * @param tracingContext - The context containing the span to serialize.\n * @returns The set of headers to add to a request.\n */\n function createRequestHeaders(tracingContext?: TracingContext): Record<string, string> {\n return getInstrumenter().createRequestHeaders(tracingContext);\n }\n\n return {\n startSpan,\n withSpan,\n withContext,\n parseTraceparentHeader,\n createRequestHeaders,\n };\n}\n"]}
1
+ {"version":3,"file":"tracingClient.js","sourceRoot":"","sources":["../../../src/tracing/tracingClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC;IAE3D,SAAS,SAAS,CAChB,IAAY,EACZ,gBAA0B,EAC1B,WAAgC;;QAKhC,MAAM,eAAe,GAAG,eAAe,EAAE,CAAC,SAAS,CAAC,IAAI,kCACnD,WAAW,KACd,WAAW,EAAE,WAAW,EACxB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,MAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,cAAc,0CAAE,cAAc,IAChE,CAAC;QACH,IAAI,cAAc,GAAG,eAAe,CAAC,cAAc,CAAC;QACpD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,CAAC,EAAE,CAAC;YACzD,cAAc,GAAG,cAAc,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAClF,CAAC;QACD,IAAI,CAAC,YAA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IACH,SAAS,sBAAsB,CAAC,iBAAyB;QACvD,OAAO,eAAe,EAAE,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,SAAS,oBAAoB,CAAC,cAA+B;QAC3D,OAAO,eAAe,EAAE,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAChE,CAAC;IAED,OAAO;QACL,SAAS;QACT,QAAQ;QACR,WAAW;QACX,sBAAsB;QACtB,oBAAoB;KACrB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n OperationTracingOptions,\n OptionsWithTracingContext,\n Resolved,\n TracingClient,\n TracingClientOptions,\n TracingContext,\n TracingSpan,\n TracingSpanOptions,\n} from \"./interfaces.js\";\nimport { getInstrumenter } from \"./instrumenter.js\";\nimport { knownContextKeys } from \"./tracingContext.js\";\n\n/**\n * Creates a new tracing client.\n *\n * @param options - Options used to configure the tracing client.\n * @returns - An instance of {@link TracingClient}.\n */\nexport function createTracingClient(options: TracingClientOptions): TracingClient {\n const { namespace, packageName, packageVersion } = options;\n\n function startSpan<Options extends { tracingOptions?: OperationTracingOptions }>(\n name: string,\n operationOptions?: Options,\n spanOptions?: TracingSpanOptions,\n ): {\n span: TracingSpan;\n updatedOptions: OptionsWithTracingContext<Options>;\n } {\n const startSpanResult = getInstrumenter().startSpan(name, {\n ...spanOptions,\n packageName: packageName,\n packageVersion: packageVersion,\n tracingContext: operationOptions?.tracingOptions?.tracingContext,\n });\n let tracingContext = startSpanResult.tracingContext;\n const span = startSpanResult.span;\n if (!tracingContext.getValue(knownContextKeys.namespace)) {\n tracingContext = tracingContext.setValue(knownContextKeys.namespace, namespace);\n }\n span.setAttribute(\"az.namespace\", tracingContext.getValue(knownContextKeys.namespace));\n const updatedOptions: OptionsWithTracingContext<Options> = Object.assign({}, operationOptions, {\n tracingOptions: { ...operationOptions?.tracingOptions, tracingContext },\n });\n\n return {\n span,\n updatedOptions,\n };\n }\n\n async function withSpan<\n Options extends { tracingOptions?: OperationTracingOptions },\n Callback extends (\n updatedOptions: Options,\n span: Omit<TracingSpan, \"end\">,\n ) => ReturnType<Callback>,\n >(\n name: string,\n operationOptions: Options,\n callback: Callback,\n spanOptions?: TracingSpanOptions,\n ): Promise<Resolved<ReturnType<Callback>>> {\n const { span, updatedOptions } = startSpan(name, operationOptions, spanOptions);\n try {\n const result = await withContext(updatedOptions.tracingOptions.tracingContext, () =>\n Promise.resolve(callback(updatedOptions, span)),\n );\n span.setStatus({ status: \"success\" });\n return result as ReturnType<typeof withSpan>;\n } catch (err: any) {\n span.setStatus({ status: \"error\", error: err });\n throw err;\n } finally {\n span.end();\n }\n }\n\n function withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return getInstrumenter().withContext(context, callback, ...callbackArgs);\n }\n\n /**\n * Parses a traceparent header value into a span identifier.\n *\n * @param traceparentHeader - The traceparent header to parse.\n * @returns An implementation-specific identifier for the span.\n */\n function parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined {\n return getInstrumenter().parseTraceparentHeader(traceparentHeader);\n }\n\n /**\n * Creates a set of request headers to propagate tracing information to a backend.\n *\n * @param tracingContext - The context containing the span to serialize.\n * @returns The set of headers to add to a request.\n */\n function createRequestHeaders(tracingContext?: TracingContext): Record<string, string> {\n return getInstrumenter().createRequestHeaders(tracingContext);\n }\n\n return {\n startSpan,\n withSpan,\n withContext,\n parseTraceparentHeader,\n createRequestHeaders,\n };\n}\n"]}
@@ -24,7 +24,6 @@ export function createTracingContext(options = {}) {
24
24
  }
25
25
  /** @internal */
26
26
  export class TracingContextImpl {
27
- _contextMap;
28
27
  constructor(initialContext) {
29
28
  this._contextMap =
30
29
  initialContext instanceof TracingContextImpl
@@ -1 +1 @@
1
- {"version":3,"file":"tracingContext.js","sourceR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IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,GAAW;QACrB,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAChD,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TracingContext, TracingSpan } from \"./interfaces.js\";\n\n/** @internal */\nexport const knownContextKeys = {\n span: Symbol.for(\"@typespec/ts-http-runtime span\"),\n namespace: Symbol.for(\"@typespec/ts-http-runtime namespace\"),\n};\n\n/**\n * Creates a new {@link TracingContext} with the given options.\n * @param options - A set of known keys that may be set on the context.\n * @returns A new {@link TracingContext} with the given options.\n *\n * @internal\n */\nexport function createTracingContext(options: CreateTracingContextOptions = {}): TracingContext {\n let context: TracingContext = new TracingContextImpl(options.parentContext);\n if (options.span) {\n context = context.setValue(knownContextKeys.span, options.span);\n }\n if (options.namespace) {\n context = context.setValue(knownContextKeys.namespace, options.namespace);\n }\n return context;\n}\n\n/** @internal */\nexport class TracingContextImpl implements TracingContext {\n private _contextMap: Map<symbol, unknown>;\n constructor(initialContext?: TracingContext) {\n this._contextMap =\n initialContext instanceof TracingContextImpl\n ? new Map<symbol, unknown>(initialContext._contextMap)\n : new Map();\n }\n\n setValue(key: symbol, value: unknown): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.set(key, value);\n return newContext;\n }\n\n getValue(key: symbol): unknown {\n return this._contextMap.get(key);\n }\n\n deleteValue(key: symbol): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.delete(key);\n return newContext;\n }\n}\n\n/**\n * Represents a set of items that can be set when creating a new {@link TracingContext}.\n */\nexport interface CreateTracingContextOptions {\n /** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */\n parentContext?: TracingContext;\n /** An initial span to set on the context. */\n span?: TracingSpan;\n /** The namespace to set on any child spans. */\n namespace?: string;\n}\n"]}
1
+ {"version":3,"file":"tracingContext.js","sourceRoot":"","sources":["../../../src/tracing/tracingContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC;IAClD,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC;CAC7D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,UAAuC,EAAE;IAC5E,IAAI,OAAO,GAAmB,IAAI,kBAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC5E,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,CAAC;IACD,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,gBAAgB;AAChB,MAAM,OAAO,kBAAkB;IAE7B,YAAY,cAA+B;QACzC,IAAI,CAAC,WAAW;YACd,cAAc,YAAY,kBAAkB;gBAC1C,CAAC,CAAC,IAAI,GAAG,CAAkB,cAAc,CAAC,WAAW,CAAC;gBACtD,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;IAClB,CAAC;IAED,QAAQ,CAAC,GAAW,EAAE,KAAc;QAClC,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAChD,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvC,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,QAAQ,CAAC,GAAW;QAClB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,GAAW;QACrB,MAAM,UAAU,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAChD,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TracingContext, TracingSpan } from \"./interfaces.js\";\n\n/** @internal */\nexport const knownContextKeys = {\n span: Symbol.for(\"@typespec/ts-http-runtime span\"),\n namespace: Symbol.for(\"@typespec/ts-http-runtime namespace\"),\n};\n\n/**\n * Creates a new {@link TracingContext} with the given options.\n * @param options - A set of known keys that may be set on the context.\n * @returns A new {@link TracingContext} with the given options.\n *\n * @internal\n */\nexport function createTracingContext(options: CreateTracingContextOptions = {}): TracingContext {\n let context: TracingContext = new TracingContextImpl(options.parentContext);\n if (options.span) {\n context = context.setValue(knownContextKeys.span, options.span);\n }\n if (options.namespace) {\n context = context.setValue(knownContextKeys.namespace, options.namespace);\n }\n return context;\n}\n\n/** @internal */\nexport class TracingContextImpl implements TracingContext {\n private _contextMap: Map<symbol, unknown>;\n constructor(initialContext?: TracingContext) {\n this._contextMap =\n initialContext instanceof TracingContextImpl\n ? new Map<symbol, unknown>(initialContext._contextMap)\n : new Map();\n }\n\n setValue(key: symbol, value: unknown): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.set(key, value);\n return newContext;\n }\n\n getValue(key: symbol): unknown {\n return this._contextMap.get(key);\n }\n\n deleteValue(key: symbol): TracingContext {\n const newContext = new TracingContextImpl(this);\n newContext._contextMap.delete(key);\n return newContext;\n }\n}\n\n/**\n * Represents a set of items that can be set when creating a new {@link TracingContext}.\n */\nexport interface CreateTracingContextOptions {\n /** The {@link parentContext} - the newly created context will contain all the values of the parent context unless overridden. */\n parentContext?: TracingContext;\n /** An initial span to set on the context. */\n span?: TracingSpan;\n /** The namespace to set on any child spans. */\n namespace?: string;\n}\n"]}
@@ -4,17 +4,18 @@
4
4
  * promise.race() wrapper that aborts rest of promises as soon as the first promise settles.
5
5
  */
6
6
  export async function cancelablePromiseRace(abortablePromiseBuilders, options) {
7
+ var _a, _b;
7
8
  const aborter = new AbortController();
8
9
  function abortHandler() {
9
10
  aborter.abort();
10
11
  }
11
- options?.abortSignal?.addEventListener("abort", abortHandler);
12
+ (_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.addEventListener("abort", abortHandler);
12
13
  try {
13
14
  return await Promise.race(abortablePromiseBuilders.map((p) => p({ abortSignal: aborter.signal })));
14
15
  }
15
16
  finally {
16
17
  aborter.abort();
17
- options?.abortSignal?.removeEventListener("abort", abortHandler);
18
+ (_b = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _b === void 0 ? void 0 : _b.removeEventListener("abort", abortHandler);
18
19
  }
19
20
  }
20
21
  //# sourceMappingURL=aborterUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"aborterUtils.js","sourceRoot":"","sources":["../../../src/util/aborterUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAyBlC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,wBAA8D,EAC9D,OAA2C;IAE3C,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,SAAS,YAAY;QACnB,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IACD,OAAO,EAAE,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CACvB,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CACxE,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,EAAE,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnE,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\n\n/**\n * Options related to abort controller.\n */\nexport interface AbortOptions {\n /**\n * The abortSignal associated with containing operation.\n */\n abortSignal?: AbortSignalLike;\n /**\n * The abort error message associated with containing operation.\n */\n abortErrorMsg?: string;\n}\n\n/**\n * Represents a function that returns a promise that can be aborted.\n */\nexport type AbortablePromiseBuilder<T> = (abortOptions: {\n abortSignal?: AbortSignalLike;\n}) => Promise<T>;\n\n/**\n * promise.race() wrapper that aborts rest of promises as soon as the first promise settles.\n */\nexport async function cancelablePromiseRace<T extends unknown[]>(\n abortablePromiseBuilders: AbortablePromiseBuilder<T[number]>[],\n options?: { abortSignal?: AbortSignalLike },\n): Promise<T[number]> {\n const aborter = new AbortController();\n function abortHandler(): void {\n aborter.abort();\n }\n options?.abortSignal?.addEventListener(\"abort\", abortHandler);\n try {\n return await Promise.race(\n abortablePromiseBuilders.map((p) => p({ abortSignal: aborter.signal })),\n );\n } finally {\n aborter.abort();\n options?.abortSignal?.removeEventListener(\"abort\", abortHandler);\n }\n}\n"]}
1
+ {"version":3,"file":"aborterUtils.js","sourceRoot":"","sources":["../../../src/util/aborterUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAyBlC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,wBAA8D,EAC9D,OAA2C;;IAE3C,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,SAAS,YAAY;QACnB,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;IACD,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,gBAAgB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9D,IAAI,CAAC;QACH,OAAO,MAAM,OAAO,CAAC,IAAI,CACvB,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CACxE,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,0CAAE,mBAAmB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnE,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\n\n/**\n * Options related to abort controller.\n */\nexport interface AbortOptions {\n /**\n * The abortSignal associated with containing operation.\n */\n abortSignal?: AbortSignalLike;\n /**\n * The abort error message associated with containing operation.\n */\n abortErrorMsg?: string;\n}\n\n/**\n * Represents a function that returns a promise that can be aborted.\n */\nexport type AbortablePromiseBuilder<T> = (abortOptions: {\n abortSignal?: AbortSignalLike;\n}) => Promise<T>;\n\n/**\n * promise.race() wrapper that aborts rest of promises as soon as the first promise settles.\n */\nexport async function cancelablePromiseRace<T extends unknown[]>(\n abortablePromiseBuilders: AbortablePromiseBuilder<T[number]>[],\n options?: { abortSignal?: AbortSignalLike },\n): Promise<T[number]> {\n const aborter = new AbortController();\n function abortHandler(): void {\n aborter.abort();\n }\n options?.abortSignal?.addEventListener(\"abort\", abortHandler);\n try {\n return await Promise.race(\n abortablePromiseBuilders.map((p) => p({ abortSignal: aborter.signal })),\n );\n } finally {\n aborter.abort();\n options?.abortSignal?.removeEventListener(\"abort\", abortHandler);\n }\n}\n"]}
@@ -27,9 +27,18 @@ export declare const isBun: boolean;
27
27
  */
28
28
  export declare const isDeno: boolean;
29
29
  /**
30
- * A constant that indicates whether the environment the code is running is Node.JS.
30
+ * A constant that indicates whether the environment the code is running is a Node.js compatible environment.
31
+ */
32
+ export declare const isNodeLike: boolean;
33
+ /**
34
+ * A constant that indicates whether the environment the code is running is a Node.js compatible environment.
35
+ * @deprecated Use `isNodeLike` instead.
31
36
  */
32
37
  export declare const isNode: boolean;
38
+ /**
39
+ * A constant that indicates whether the environment the code is running is Node.JS.
40
+ */
41
+ export declare const isNodeRuntime: boolean;
33
42
  /**
34
43
  * A constant that indicates whether the environment the code is running is in React-Native.
35
44
  */
@@ -1 +1 @@
1
- {"version":3,"file":"checkEnvironment.d.ts","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH;IAED,UAAU,SAAS;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB;IAED,MAAM,IAAI,EAAE,UAAU,CAAC;IACvB,MAAM,GAAG,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AAEH,eAAO,MAAM,SAAS,SAA0E,CAAC;AAEjG;;GAEG;AACH,eAAO,MAAM,WAAW,SAKiC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,KAAK,SAAmE,CAAC;AAEtF;;GAEG;AACH,eAAO,MAAM,MAAM,SAGuB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,MAAM,SAMX,CAAC;AAET;;GAEG;AAEH,eAAO,MAAM,aAAa,SACgD,CAAC"}
1
+ {"version":3,"file":"checkEnvironment.d.ts","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;KACH;IAED,UAAU,SAAS;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB;IAED,MAAM,IAAI,EAAE,UAAU,CAAC;IACvB,MAAM,GAAG,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AAEH,eAAO,MAAM,SAAS,SAA0E,CAAC;AAEjG;;GAEG;AACH,eAAO,MAAM,WAAW,SAKiC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,KAAK,SAAmE,CAAC;AAEtF;;GAEG;AACH,eAAO,MAAM,MAAM,SAGuB,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,UAAU,SAGqB,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,MAAM,SAAa,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,aAAa,SAAkC,CAAC;AAE7D;;GAEG;AAEH,eAAO,MAAM,aAAa,SACgD,CAAC"}
@@ -1,5 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
+ var _a, _b, _c, _d;
3
4
  /**
4
5
  * A constant that indicates whether the environment the code is running is a Web Browser.
5
6
  */
@@ -9,10 +10,10 @@ export const isBrowser = typeof window !== "undefined" && typeof window.document
9
10
  * A constant that indicates whether the environment the code is running is a Web Worker.
10
11
  */
11
12
  export const isWebWorker = typeof self === "object" &&
12
- typeof self?.importScripts === "function" &&
13
- (self.constructor?.name === "DedicatedWorkerGlobalScope" ||
14
- self.constructor?.name === "ServiceWorkerGlobalScope" ||
15
- self.constructor?.name === "SharedWorkerGlobalScope");
13
+ typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
14
+ (((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
15
+ ((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
16
+ ((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
16
17
  /**
17
18
  * A constant that indicates whether the environment the code is running is Bun.sh.
18
19
  */
@@ -23,18 +24,24 @@ export const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undef
23
24
  export const isDeno = typeof Deno !== "undefined" &&
24
25
  typeof Deno.version !== "undefined" &&
25
26
  typeof Deno.version.deno !== "undefined";
27
+ /**
28
+ * A constant that indicates whether the environment the code is running is a Node.js compatible environment.
29
+ */
30
+ export const isNodeLike = typeof globalThis.process !== "undefined" &&
31
+ Boolean(globalThis.process.version) &&
32
+ Boolean((_d = globalThis.process.versions) === null || _d === void 0 ? void 0 : _d.node);
33
+ /**
34
+ * A constant that indicates whether the environment the code is running is a Node.js compatible environment.
35
+ * @deprecated Use `isNodeLike` instead.
36
+ */
37
+ export const isNode = isNodeLike;
26
38
  /**
27
39
  * A constant that indicates whether the environment the code is running is Node.JS.
28
40
  */
29
- export const isNode = typeof process !== "undefined" &&
30
- Boolean(process.version) &&
31
- Boolean(process.versions?.node) &&
32
- // Deno thought it was a good idea to spoof process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
33
- !isDeno &&
34
- !isBun;
41
+ export const isNodeRuntime = isNodeLike && !isBun && !isDeno;
35
42
  /**
36
43
  * A constant that indicates whether the environment the code is running is in React-Native.
37
44
  */
38
45
  // https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
39
- export const isReactNative = typeof navigator !== "undefined" && navigator?.product === "ReactNative";
46
+ export const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
40
47
  //# sourceMappingURL=checkEnvironment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"checkEnvironment.js","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAiBlC;;GAEG;AACH,yDAAyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAEjG;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAQ,IAAY,EAAE,aAAa,KAAK,UAAU;IAClD,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,4BAA4B;QACtD,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,0BAA0B;QACrD,IAAI,CAAC,WAAW,EAAE,IAAI,KAAK,yBAAyB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC;AAEtF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,OAAO,IAAI,KAAK,WAAW;IAC3B,OAAO,IAAI,CAAC,OAAO,KAAK,WAAW;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,OAAO,OAAO,KAAK,WAAW;IAC9B,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC;IAC/B,+HAA+H;IAC/H,CAAC,MAAM;IACP,CAAC,KAAK,CAAC;AAET;;GAEG;AACH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,aAAa,GACxB,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,EAAE,OAAO,KAAK,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\ndeclare global {\n interface DenoGlobal {\n version: {\n deno: string;\n };\n }\n\n interface BunGlobal {\n version: string;\n }\n\n const Deno: DenoGlobal;\n const Bun: BunGlobal;\n}\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Browser.\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-no-window\nexport const isBrowser = typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Worker.\n */\nexport const isWebWorker =\n typeof self === \"object\" &&\n typeof (self as any)?.importScripts === \"function\" &&\n (self.constructor?.name === \"DedicatedWorkerGlobalScope\" ||\n self.constructor?.name === \"ServiceWorkerGlobalScope\" ||\n self.constructor?.name === \"SharedWorkerGlobalScope\");\n\n/**\n * A constant that indicates whether the environment the code is running is Bun.sh.\n */\nexport const isBun = typeof Bun !== \"undefined\" && typeof Bun.version !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is Deno.\n */\nexport const isDeno =\n typeof Deno !== \"undefined\" &&\n typeof Deno.version !== \"undefined\" &&\n typeof Deno.version.deno !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is Node.JS.\n */\nexport const isNode =\n typeof process !== \"undefined\" &&\n Boolean(process.version) &&\n Boolean(process.versions?.node) &&\n // Deno thought it was a good idea to spoof process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions\n !isDeno &&\n !isBun;\n\n/**\n * A constant that indicates whether the environment the code is running is in React-Native.\n */\n// https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js\nexport const isReactNative =\n typeof navigator !== \"undefined\" && navigator?.product === \"ReactNative\";\n"]}
1
+ {"version":3,"file":"checkEnvironment.js","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAiBlC;;GAEG;AACH,yDAAyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAEjG;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAO,CAAC,IAAY,aAAZ,IAAI,uBAAJ,IAAI,CAAU,aAAa,CAAA,KAAK,UAAU;IAClD,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,4BAA4B;QACtD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,0BAA0B;QACrD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,yBAAyB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC;AAEtF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,OAAO,IAAI,KAAK,WAAW;IAC3B,OAAO,IAAI,CAAC,OAAO,KAAK,WAAW;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,OAAO,UAAU,CAAC,OAAO,KAAK,WAAW;IACzC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,MAAA,UAAU,CAAC,OAAO,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC;AAEjC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC;AAE7D;;GAEG;AACH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,aAAa,GACxB,OAAO,SAAS,KAAK,WAAW,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,MAAK,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\ndeclare global {\n interface DenoGlobal {\n version: {\n deno: string;\n };\n }\n\n interface BunGlobal {\n version: string;\n }\n\n const Deno: DenoGlobal;\n const Bun: BunGlobal;\n}\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Browser.\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-no-window\nexport const isBrowser = typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Worker.\n */\nexport const isWebWorker =\n typeof self === \"object\" &&\n typeof (self as any)?.importScripts === \"function\" &&\n (self.constructor?.name === \"DedicatedWorkerGlobalScope\" ||\n self.constructor?.name === \"ServiceWorkerGlobalScope\" ||\n self.constructor?.name === \"SharedWorkerGlobalScope\");\n\n/**\n * A constant that indicates whether the environment the code is running is Bun.sh.\n */\nexport const isBun = typeof Bun !== \"undefined\" && typeof Bun.version !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is Deno.\n */\nexport const isDeno =\n typeof Deno !== \"undefined\" &&\n typeof Deno.version !== \"undefined\" &&\n typeof Deno.version.deno !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is a Node.js compatible environment.\n */\nexport const isNodeLike =\n typeof globalThis.process !== \"undefined\" &&\n Boolean(globalThis.process.version) &&\n Boolean(globalThis.process.versions?.node);\n\n/**\n * A constant that indicates whether the environment the code is running is a Node.js compatible environment.\n * @deprecated Use `isNodeLike` instead.\n */\nexport const isNode = isNodeLike;\n\n/**\n * A constant that indicates whether the environment the code is running is Node.JS.\n */\nexport const isNodeRuntime = isNodeLike && !isBun && !isDeno;\n\n/**\n * A constant that indicates whether the environment the code is running is in React-Native.\n */\n// https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js\nexport const isReactNative =\n typeof navigator !== \"undefined\" && navigator?.product === \"ReactNative\";\n"]}
@@ -8,20 +8,20 @@ import { AbortError } from "../abort-controller/AbortError.js";
8
8
  * @returns A promise that can be aborted.
9
9
  */
10
10
  export function createAbortablePromise(buildPromise, options) {
11
- const { cleanupBeforeAbort, abortSignal, abortErrorMsg } = options ?? {};
11
+ const { cleanupBeforeAbort, abortSignal, abortErrorMsg } = options !== null && options !== void 0 ? options : {};
12
12
  return new Promise((resolve, reject) => {
13
13
  function rejectOnAbort() {
14
- reject(new AbortError(abortErrorMsg ?? "The operation was aborted."));
14
+ reject(new AbortError(abortErrorMsg !== null && abortErrorMsg !== void 0 ? abortErrorMsg : "The operation was aborted."));
15
15
  }
16
16
  function removeListeners() {
17
- abortSignal?.removeEventListener("abort", onAbort);
17
+ abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener("abort", onAbort);
18
18
  }
19
19
  function onAbort() {
20
- cleanupBeforeAbort?.();
20
+ cleanupBeforeAbort === null || cleanupBeforeAbort === void 0 ? void 0 : cleanupBeforeAbort();
21
21
  removeListeners();
22
22
  rejectOnAbort();
23
23
  }
24
- if (abortSignal?.aborted) {
24
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
25
25
  return rejectOnAbort();
26
26
  }
27
27
  try {
@@ -36,7 +36,7 @@ export function createAbortablePromise(buildPromise, options) {
36
36
  catch (err) {
37
37
  reject(err);
38
38
  }
39
- abortSignal?.addEventListener("abort", onAbort);
39
+ abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener("abort", onAbort);
40
40
  });
41
41
  }
42
42
  //# sourceMappingURL=createAbortablePromise.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createAbortablePromise.js","sourceRoot":"","sources":["../../../src/util/createAbortablePromise.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAW/D;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAGS,EACT,OAAuC;IAEvC,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACzE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,SAAS,aAAa;YACpB,MAAM,CAAC,IAAI,UAAU,CAAC,aAAa,IAAI,4BAA4B,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,SAAS,eAAe;YACtB,WAAW,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;QACD,SAAS,OAAO;YACd,kBAAkB,EAAE,EAAE,CAAC;YACvB,eAAe,EAAE,CAAC;YAClB,aAAa,EAAE,CAAC;QAClB,CAAC;QACD,IAAI,WAAW,EAAE,OAAO,EAAE,CAAC;YACzB,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QACD,IAAI,CAAC;YACH,YAAY,CACV,CAAC,CAAC,EAAE,EAAE;gBACJ,eAAe,EAAE,CAAC;gBAClB,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,EACD,CAAC,CAAC,EAAE,EAAE;gBACJ,eAAe,EAAE,CAAC;gBAClB,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC;QACD,WAAW,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError } from \"../abort-controller/AbortError.js\";\nimport { AbortOptions } from \"./aborterUtils.js\";\n\n/**\n * Options for the createAbortablePromise function.\n */\nexport interface CreateAbortablePromiseOptions extends AbortOptions {\n /** A function to be called if the promise was aborted */\n cleanupBeforeAbort?: () => void;\n}\n\n/**\n * Creates an abortable promise.\n * @param buildPromise - A function that takes the resolve and reject functions as parameters.\n * @param options - The options for the abortable promise.\n * @returns A promise that can be aborted.\n */\nexport function createAbortablePromise<T>(\n buildPromise: (\n resolve: (value: T | PromiseLike<T>) => void,\n reject: (reason?: any) => void,\n ) => void,\n options?: CreateAbortablePromiseOptions,\n): Promise<T> {\n const { cleanupBeforeAbort, abortSignal, abortErrorMsg } = options ?? {};\n return new Promise((resolve, reject) => {\n function rejectOnAbort(): void {\n reject(new AbortError(abortErrorMsg ?? \"The operation was aborted.\"));\n }\n function removeListeners(): void {\n abortSignal?.removeEventListener(\"abort\", onAbort);\n }\n function onAbort(): void {\n cleanupBeforeAbort?.();\n removeListeners();\n rejectOnAbort();\n }\n if (abortSignal?.aborted) {\n return rejectOnAbort();\n }\n try {\n buildPromise(\n (x) => {\n removeListeners();\n resolve(x);\n },\n (x) => {\n removeListeners();\n reject(x);\n },\n );\n } catch (err) {\n reject(err);\n }\n abortSignal?.addEventListener(\"abort\", onAbort);\n });\n}\n"]}
1
+ {"version":3,"file":"createAbortablePromise.js","sourceRoot":"","sources":["../../../src/util/createAbortablePromise.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAW/D;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,YAGS,EACT,OAAuC;IAEvC,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IACzE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,SAAS,aAAa;YACpB,MAAM,CAAC,IAAI,UAAU,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,4BAA4B,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,SAAS,eAAe;YACtB,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACrD,CAAC;QACD,SAAS,OAAO;YACd,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,EAAI,CAAC;YACvB,eAAe,EAAE,CAAC;YAClB,aAAa,EAAE,CAAC;QAClB,CAAC;QACD,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,EAAE,CAAC;YACzB,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QACD,IAAI,CAAC;YACH,YAAY,CACV,CAAC,CAAC,EAAE,EAAE;gBACJ,eAAe,EAAE,CAAC;gBAClB,OAAO,CAAC,CAAC,CAAC,CAAC;YACb,CAAC,EACD,CAAC,CAAC,EAAE,EAAE;gBACJ,eAAe,EAAE,CAAC;gBAClB,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC;QACD,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError } from \"../abort-controller/AbortError.js\";\nimport { AbortOptions } from \"./aborterUtils.js\";\n\n/**\n * Options for the createAbortablePromise function.\n */\nexport interface CreateAbortablePromiseOptions extends AbortOptions {\n /** A function to be called if the promise was aborted */\n cleanupBeforeAbort?: () => void;\n}\n\n/**\n * Creates an abortable promise.\n * @param buildPromise - A function that takes the resolve and reject functions as parameters.\n * @param options - The options for the abortable promise.\n * @returns A promise that can be aborted.\n */\nexport function createAbortablePromise<T>(\n buildPromise: (\n resolve: (value: T | PromiseLike<T>) => void,\n reject: (reason?: any) => void,\n ) => void,\n options?: CreateAbortablePromiseOptions,\n): Promise<T> {\n const { cleanupBeforeAbort, abortSignal, abortErrorMsg } = options ?? {};\n return new Promise((resolve, reject) => {\n function rejectOnAbort(): void {\n reject(new AbortError(abortErrorMsg ?? \"The operation was aborted.\"));\n }\n function removeListeners(): void {\n abortSignal?.removeEventListener(\"abort\", onAbort);\n }\n function onAbort(): void {\n cleanupBeforeAbort?.();\n removeListeners();\n rejectOnAbort();\n }\n if (abortSignal?.aborted) {\n return rejectOnAbort();\n }\n try {\n buildPromise(\n (x) => {\n removeListeners();\n resolve(x);\n },\n (x) => {\n removeListeners();\n reject(x);\n },\n );\n } catch (err) {\n reject(err);\n }\n abortSignal?.addEventListener(\"abort\", onAbort);\n });\n}\n"]}
@@ -10,13 +10,13 @@ const StandardAbortMessage = "The delay was aborted.";
10
10
  */
11
11
  export function delay(timeInMs, options) {
12
12
  let token;
13
- const { abortSignal, abortErrorMsg } = options ?? {};
13
+ const { abortSignal, abortErrorMsg } = options !== null && options !== void 0 ? options : {};
14
14
  return createAbortablePromise((resolve) => {
15
15
  token = setTimeout(resolve, timeInMs);
16
16
  }, {
17
17
  cleanupBeforeAbort: () => clearTimeout(token),
18
18
  abortSignal,
19
- abortErrorMsg: abortErrorMsg ?? StandardAbortMessage,
19
+ abortErrorMsg: abortErrorMsg !== null && abortErrorMsg !== void 0 ? abortErrorMsg : StandardAbortMessage,
20
20
  });
21
21
  }
22
22
  //# sourceMappingURL=delay.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../src/util/delay.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAOtD;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,OAAsB;IAC5D,IAAI,KAAoC,CAAC;IACzC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IACrD,OAAO,sBAAsB,CAC3B,CAAC,OAAO,EAAE,EAAE;QACV,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,EACD;QACE,kBAAkB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;QAC7C,WAAW;QACX,aAAa,EAAE,aAAa,IAAI,oBAAoB;KACrD,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortOptions } from \"./aborterUtils.js\";\nimport { createAbortablePromise } from \"./createAbortablePromise.js\";\n\nconst StandardAbortMessage = \"The delay was aborted.\";\n\n/**\n * Options for support abort functionality for the delay method\n */\nexport interface DelayOptions extends AbortOptions {}\n\n/**\n * A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.\n * @param timeInMs - The number of milliseconds to be delayed.\n * @param options - The options for delay - currently abort options\n * @returns Promise that is resolved after timeInMs\n */\nexport function delay(timeInMs: number, options?: DelayOptions): Promise<void> {\n let token: ReturnType<typeof setTimeout>;\n const { abortSignal, abortErrorMsg } = options ?? {};\n return createAbortablePromise(\n (resolve) => {\n token = setTimeout(resolve, timeInMs);\n },\n {\n cleanupBeforeAbort: () => clearTimeout(token),\n abortSignal,\n abortErrorMsg: abortErrorMsg ?? StandardAbortMessage,\n },\n );\n}\n"]}
1
+ {"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../src/util/delay.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAOtD;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,QAAgB,EAAE,OAAsB;IAC5D,IAAI,KAAoC,CAAC;IACzC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IACrD,OAAO,sBAAsB,CAC3B,CAAC,OAAO,EAAE,EAAE;QACV,KAAK,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,EACD;QACE,kBAAkB,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC;QAC7C,WAAW;QACX,aAAa,EAAE,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,oBAAoB;KACrD,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortOptions } from \"./aborterUtils.js\";\nimport { createAbortablePromise } from \"./createAbortablePromise.js\";\n\nconst StandardAbortMessage = \"The delay was aborted.\";\n\n/**\n * Options for support abort functionality for the delay method\n */\nexport interface DelayOptions extends AbortOptions {}\n\n/**\n * A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.\n * @param timeInMs - The number of milliseconds to be delayed.\n * @param options - The options for delay - currently abort options\n * @returns Promise that is resolved after timeInMs\n */\nexport function delay(timeInMs: number, options?: DelayOptions): Promise<void> {\n let token: ReturnType<typeof setTimeout>;\n const { abortSignal, abortErrorMsg } = options ?? {};\n return createAbortablePromise(\n (resolve) => {\n token = setTimeout(resolve, timeInMs);\n },\n {\n cleanupBeforeAbort: () => clearTimeout(token),\n abortSignal,\n abortErrorMsg: abortErrorMsg ?? StandardAbortMessage,\n },\n );\n}\n"]}
@@ -64,22 +64,14 @@ export function getRawContent(blob) {
64
64
  * @param options - optional metadata about the file, e.g. file name, file size, MIME type.
65
65
  */
66
66
  export function createFileFromStream(stream, name, options = {}) {
67
- return {
68
- ...unimplementedMethods,
69
- type: options.type ?? "",
70
- lastModified: options.lastModified ?? new Date().getTime(),
71
- webkitRelativePath: options.webkitRelativePath ?? "",
72
- size: options.size ?? -1,
73
- name,
74
- stream: () => {
67
+ var _a, _b, _c, _d;
68
+ return Object.assign(Object.assign({}, unimplementedMethods), { type: (_a = options.type) !== null && _a !== void 0 ? _a : "", lastModified: (_b = options.lastModified) !== null && _b !== void 0 ? _b : new Date().getTime(), webkitRelativePath: (_c = options.webkitRelativePath) !== null && _c !== void 0 ? _c : "", size: (_d = options.size) !== null && _d !== void 0 ? _d : -1, name, stream: () => {
75
69
  const s = stream();
76
70
  if (isNodeReadableStream(s)) {
77
71
  throw new Error("Not supported: a Node stream was provided as input to createFileFromStream.");
78
72
  }
79
73
  return s;
80
- },
81
- [rawContent]: stream,
82
- };
74
+ }, [rawContent]: stream });
83
75
  }
84
76
  /**
85
77
  * Create an object that implements the File interface. This object is intended to be
@@ -93,18 +85,9 @@ export function createFileFromStream(stream, name, options = {}) {
93
85
  * @param options - optional metadata about the file, e.g. file name, file size, MIME type.
94
86
  */
95
87
  export function createFile(content, name, options = {}) {
88
+ var _a, _b, _c;
96
89
  if (isNode) {
97
- return {
98
- ...unimplementedMethods,
99
- type: options.type ?? "",
100
- lastModified: options.lastModified ?? new Date().getTime(),
101
- webkitRelativePath: options.webkitRelativePath ?? "",
102
- size: content.byteLength,
103
- name,
104
- arrayBuffer: async () => content.buffer,
105
- stream: () => new Blob([content]).stream(),
106
- [rawContent]: () => content,
107
- };
90
+ return Object.assign(Object.assign({}, unimplementedMethods), { type: (_a = options.type) !== null && _a !== void 0 ? _a : "", lastModified: (_b = options.lastModified) !== null && _b !== void 0 ? _b : new Date().getTime(), webkitRelativePath: (_c = options.webkitRelativePath) !== null && _c !== void 0 ? _c : "", size: content.byteLength, name, arrayBuffer: async () => content.buffer, stream: () => new Blob([content]).stream(), [rawContent]: () => content });
108
91
  }
109
92
  else {
110
93
  return new File([content], name, options);
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAoCvD,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,KAAK,EAAE,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,EAAE,GAAG,EAAE;QACT,MAAM,IAAI,KAAK,CAAC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AM,EAAE,CAAC;QACX,OAAO;YACL,GAAG,oBAAoB;YACvB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;YACxB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;YAC1D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;YACpD,IAAI,EAAE,OAAO,CAAC,UAAU;YACxB,IAAI;YACJ,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM;YACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE;YAC1C,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO;SACP,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isNode } from \"./checkEnvironment.js\";\nimport { isNodeReadableStream } from \"./typeGuards.js\";\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Private symbol used as key on objects created using createFile containing the\n * original source of the file object.\n *\n * This is used in Node to access the original Node stream without using Blob#stream, which\n * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and\n * Readable#to/fromWeb in Node versions we support:\n * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)\n * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)\n *\n * Once these versions are no longer supported, we may be able to stop doing this.\n *\n * @internal\n */\nconst rawContent: unique symbol = Symbol(\"rawContent\");\n\n/**\n * Type signature of a blob-like object with a raw content property.\n */\ninterface RawContent {\n [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;\n}\n\nfunction hasRawContent(x: unknown): x is RawContent {\n return typeof (x as RawContent)[rawContent] === \"function\";\n}\n\n/**\n * Extract the raw content from a given blob-like object. If the input was created using createFile\n * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.\n * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.\n *\n * @internal\n */\nexport function getRawContent(\n blob: Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array {\n if (hasRawContent(blob)) {\n return blob[rawContent]();\n } else {\n return blob.stream();\n }\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => {\n const s = stream();\n if (isNodeReadableStream(s)) {\n throw new Error(\n \"Not supported: a Node stream was provided as input to createFileFromStream.\",\n );\n }\n\n return s;\n },\n [rawContent]: stream,\n } as File & RawContent;\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n if (isNode) {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n [rawContent]: () => content,\n } as File & RawContent;\n } else {\n return new File([content], name, options);\n }\n}\n"]}
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAoCvD,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,KAAK,EAAE,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,EAAE,GAAG,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,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B,EAAE;;IAE/B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,gCACF,oBAAoB,KACvB,IAAI,EAAE,MAAA,OAAO,CAAC,IAAI,mCAAI,EAAE,EACxB,YAAY,EAAE,MAAA,OAAO,CAAC,YAAY,mCAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,EAC1D,kBAAkB,EAAE,MAAA,OAAO,CAAC,kBAAkB,mCAAI,EAAE,EACpD,IAAI,EAAE,OAAO,CAAC,UAAU,EACxB,IAAI,EACJ,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,EAC1C,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO,GACP,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isNode } from \"./checkEnvironment.js\";\nimport { isNodeReadableStream } from \"./typeGuards.js\";\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Private symbol used as key on objects created using createFile containing the\n * original source of the file object.\n *\n * This is used in Node to access the original Node stream without using Blob#stream, which\n * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and\n * Readable#to/fromWeb in Node versions we support:\n * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)\n * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)\n *\n * Once these versions are no longer supported, we may be able to stop doing this.\n *\n * @internal\n */\nconst rawContent: unique symbol = Symbol(\"rawContent\");\n\n/**\n * Type signature of a blob-like object with a raw content property.\n */\ninterface RawContent {\n [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;\n}\n\nfunction hasRawContent(x: unknown): x is RawContent {\n return typeof (x as RawContent)[rawContent] === \"function\";\n}\n\n/**\n * Extract the raw content from a given blob-like object. If the input was created using createFile\n * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.\n * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.\n *\n * @internal\n */\nexport function getRawContent(\n blob: Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array {\n if (hasRawContent(blob)) {\n return blob[rawContent]();\n } else {\n return blob.stream();\n }\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => {\n const s = stream();\n if (isNodeReadableStream(s)) {\n throw new Error(\n \"Not supported: a Node stream was provided as input to createFileFromStream.\",\n );\n }\n\n return s;\n },\n [rawContent]: stream,\n } as File & RawContent;\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n if (isNode) {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n [rawContent]: () => content,\n } as File & RawContent;\n } else {\n return new File([content], name, options);\n }\n}\n"]}
@@ -16,10 +16,10 @@ export function delay(delayInMs, value, options) {
16
16
  let timer = undefined;
17
17
  let onAborted = undefined;
18
18
  const rejectOnAbort = () => {
19
- return reject(new AbortError(options?.abortErrorMsg ? options?.abortErrorMsg : StandardAbortMessage));
19
+ return reject(new AbortError((options === null || options === void 0 ? void 0 : options.abortErrorMsg) ? options === null || options === void 0 ? void 0 : options.abortErrorMsg : StandardAbortMessage));
20
20
  };
21
21
  const removeListeners = () => {
22
- if (options?.abortSignal && onAborted) {
22
+ if ((options === null || options === void 0 ? void 0 : options.abortSignal) && onAborted) {
23
23
  options.abortSignal.removeEventListener("abort", onAborted);
24
24
  }
25
25
  };
@@ -30,14 +30,14 @@ export function delay(delayInMs, value, options) {
30
30
  removeListeners();
31
31
  return rejectOnAbort();
32
32
  };
33
- if (options?.abortSignal && options.abortSignal.aborted) {
33
+ if ((options === null || options === void 0 ? void 0 : options.abortSignal) && options.abortSignal.aborted) {
34
34
  return rejectOnAbort();
35
35
  }
36
36
  timer = setTimeout(() => {
37
37
  removeListeners();
38
38
  resolve(value);
39
39
  }, delayInMs);
40
- if (options?.abortSignal) {
40
+ if (options === null || options === void 0 ? void 0 : options.abortSignal) {
41
41
  options.abortSignal.addEventListener("abort", onAborted);
42
42
  }
43
43
  });
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/util/helpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAI/D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,UAAU,KAAK,CACnB,SAAiB,EACjB,KAAS,EACT,OAGC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,KAAK,GAA8C,SAAS,CAAC;QACjE,IAAI,SAAS,GAA6B,SAAS,CAAC;QAEpD,MAAM,aAAa,GAAG,GAAS,EAAE;YAC/B,OAAO,MAAM,CACX,IAAI,UAAU,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,oBAAoB,CAAC,CACvF,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,eAAe,GAAG,GAAS,EAAE;YACjC,IAAI,OAAO,EAAE,WAAW,IAAI,SAAS,EAAE,CAAC;gBACtC,OAAO,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAC9D,CAAC;QACH,CAAC,CAAC;QAEF,SAAS,GAAG,GAAS,EAAE;YACrB,IAAI,KAAK,EAAE,CAAC;gBACV,YAAY,CAAC,KAAK,CAAC,CAAC;YACtB,CAAC;YACD,eAAe,EAAE,CAAC;YAClB,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC;QAEF,IAAI,OAAO,EAAE,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACxD,OAAO,aAAa,EAAE,CAAC;QACzB,CAAC;QAED,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,eAAe,EAAE,CAAC;YAClB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,IAAI,OAAO,EAAE,WAAW,EAAE,CAAC;YACzB,OAAO,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAA0B,EAC1B,UAAkB;IAElB,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;QAAE,OAAO;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError } from \"../abort-controller/AbortError.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { PipelineResponse } from \"../interfaces.js\";\n\nconst StandardAbortMessage = \"The operation was aborted.\";\n\n/**\n * A wrapper for setTimeout that resolves a promise after delayInMs milliseconds.\n * @param delayInMs - The number of milliseconds to be delayed.\n * @param value - The value to be resolved with after a timeout of t milliseconds.\n * @param options - The options for delay - currently abort options\n * - abortSignal - The abortSignal associated with containing operation.\n * - abortErrorMsg - The abort error message associated with containing operation.\n * @returns Resolved promise\n */\nexport function delay<T>(\n delayInMs: number,\n value?: T,\n options?: {\n abortSignal?: AbortSignalLike;\n abortErrorMsg?: string;\n },\n): Promise<T | void> {\n return new Promise((resolve, reject) => {\n let timer: ReturnType<typeof setTimeout> | undefined = undefined;\n let onAborted: (() => void) | undefined = undefined;\n\n const rejectOnAbort = (): void => {\n return reject(\n new AbortError(options?.abortErrorMsg ? options?.abortErrorMsg : StandardAbortMessage),\n );\n };\n\n const removeListeners = (): void => {\n if (options?.abortSignal && onAborted) {\n options.abortSignal.removeEventListener(\"abort\", onAborted);\n }\n };\n\n onAborted = (): void => {\n if (timer) {\n clearTimeout(timer);\n }\n removeListeners();\n return rejectOnAbort();\n };\n\n if (options?.abortSignal && options.abortSignal.aborted) {\n return rejectOnAbort();\n }\n\n timer = setTimeout(() => {\n removeListeners();\n resolve(value);\n }, delayInMs);\n\n if (options?.abortSignal) {\n options.abortSignal.addEventListener(\"abort\", onAborted);\n }\n });\n}\n\n/**\n * @internal\n * @returns the parsed value or undefined if the parsed value is invalid.\n */\nexport function parseHeaderValueAsNumber(\n response: PipelineResponse,\n headerName: string,\n): number | undefined {\n const value = response.headers.get(headerName);\n if (!value) return;\n const valueAsNum = Number(value);\n if (Number.isNaN(valueAsNum)) return;\n return valueAsNum;\n}\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/util/helpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAI/D,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAE1D;;;;;;;;GAQG;AACH,MAAM,UAAU,KAAK,CACnB,SAAiB,EACjB,KAAS,EACT,OAGC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,KAAK,GAA8C,SAAS,CAAC;QACjE,IAAI,SA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MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACjC,IAAI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;QAAE,OAAO;IACrC,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError } from \"../abort-controller/AbortError.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { PipelineResponse } from \"../interfaces.js\";\n\nconst StandardAbortMessage = \"The operation was aborted.\";\n\n/**\n * A wrapper for setTimeout that resolves a promise after delayInMs milliseconds.\n * @param delayInMs - The number of milliseconds to be delayed.\n * @param value - The value to be resolved with after a timeout of t milliseconds.\n * @param options - The options for delay - currently abort options\n * - abortSignal - The abortSignal associated with containing operation.\n * - abortErrorMsg - The abort error message associated with containing operation.\n * @returns Resolved promise\n */\nexport function delay<T>(\n delayInMs: number,\n value?: T,\n options?: {\n abortSignal?: AbortSignalLike;\n abortErrorMsg?: string;\n },\n): Promise<T | void> {\n return new Promise((resolve, reject) => {\n let timer: ReturnType<typeof setTimeout> | undefined = undefined;\n let onAborted: (() => void) | undefined = undefined;\n\n const rejectOnAbort = (): void => {\n return reject(\n new AbortError(options?.abortErrorMsg ? options?.abortErrorMsg : StandardAbortMessage),\n );\n };\n\n const removeListeners = (): void => {\n if (options?.abortSignal && onAborted) {\n options.abortSignal.removeEventListener(\"abort\", onAborted);\n }\n };\n\n onAborted = (): void => {\n if (timer) {\n clearTimeout(timer);\n }\n removeListeners();\n return rejectOnAbort();\n };\n\n if (options?.abortSignal && options.abortSignal.aborted) {\n return rejectOnAbort();\n }\n\n timer = setTimeout(() => {\n removeListeners();\n resolve(value);\n }, delayInMs);\n\n if (options?.abortSignal) {\n options.abortSignal.addEventListener(\"abort\", onAborted);\n }\n });\n}\n\n/**\n * @internal\n * @returns the parsed value or undefined if the parsed value is invalid.\n */\nexport function parseHeaderValueAsNumber(\n response: PipelineResponse,\n headerName: string,\n): number | undefined {\n const value = response.headers.get(headerName);\n if (!value) return;\n const valueAsNum = Number(value);\n if (Number.isNaN(valueAsNum)) return;\n return valueAsNum;\n}\n"]}
@@ -49,8 +49,6 @@ const defaultAllowedQueryParameters = ["api-version"];
49
49
  * @internal
50
50
  */
51
51
  export class Sanitizer {
52
- allowedHeaderNames;
53
- allowedQueryParameters;
54
52
  constructor({ additionalAllowedHeaderNames: allowedHeaderNames = [], additionalAllowedQueryParameters: allowedQueryParameters = [], } = {}) {
55
53
  allowedHeaderNames = defaultAllowedHeaderNames.concat(allowedHeaderNames);
56
54
  allowedQueryParameters = defaultAllowedQueryParameters.concat(allowedQueryParameters);
@@ -62,11 +60,7 @@ export class Sanitizer {
62
60
  return JSON.stringify(obj, (key, value) => {
63
61
  // Ensure Errors include their interesting non-enumerable members
64
62
  if (value instanceof Error) {
65
- return {
66
- ...value,
67
- name: value.name,
68
- message: value.message,
69
- };
63
+ return Object.assign(Object.assign({}, value), { name: value.name, message: value.message });
70
64
  }
71
65
  if (key === "headers") {
72
66
  return this.sanitizeHeaders(value);