@azure/storage-queue 12.13.0 → 12.20.0-alpha.20230616.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (291) hide show
  1. package/dist/index.js +1323 -1057
  2. package/dist/index.js.map +1 -1
  3. package/dist-esm/storage-blob/src/BatchResponse.js +4 -0
  4. package/dist-esm/storage-blob/src/BatchResponse.js.map +1 -0
  5. package/dist-esm/storage-blob/src/BatchResponseParser.js +137 -0
  6. package/dist-esm/storage-blob/src/BatchResponseParser.js.map +1 -0
  7. package/dist-esm/storage-blob/src/BatchUtils.browser.js +11 -0
  8. package/dist-esm/storage-blob/src/BatchUtils.browser.js.map +1 -0
  9. package/dist-esm/storage-blob/src/BatchUtils.js +15 -0
  10. package/dist-esm/storage-blob/src/BatchUtils.js.map +1 -0
  11. package/dist-esm/storage-blob/src/BlobBatch.js +267 -0
  12. package/dist-esm/storage-blob/src/BlobBatch.js.map +1 -0
  13. package/dist-esm/storage-blob/src/BlobBatchClient.js +140 -0
  14. package/dist-esm/storage-blob/src/BlobBatchClient.js.map +1 -0
  15. package/dist-esm/storage-blob/src/BlobDownloadResponse.browser.js +7 -0
  16. package/dist-esm/storage-blob/src/BlobDownloadResponse.browser.js.map +1 -0
  17. package/dist-esm/storage-blob/src/BlobDownloadResponse.js +455 -0
  18. package/dist-esm/storage-blob/src/BlobDownloadResponse.js.map +1 -0
  19. package/dist-esm/storage-blob/src/BlobLeaseClient.js +192 -0
  20. package/dist-esm/storage-blob/src/BlobLeaseClient.js.map +1 -0
  21. package/dist-esm/storage-blob/src/BlobQueryResponse.browser.js +362 -0
  22. package/dist-esm/storage-blob/src/BlobQueryResponse.browser.js.map +1 -0
  23. package/dist-esm/storage-blob/src/BlobQueryResponse.js +367 -0
  24. package/dist-esm/storage-blob/src/BlobQueryResponse.js.map +1 -0
  25. package/dist-esm/storage-blob/src/BlobServiceClient.js +702 -0
  26. package/dist-esm/storage-blob/src/BlobServiceClient.js.map +1 -0
  27. package/dist-esm/storage-blob/src/Clients.js +2527 -0
  28. package/dist-esm/storage-blob/src/Clients.js.map +1 -0
  29. package/dist-esm/storage-blob/src/ContainerClient.js +1161 -0
  30. package/dist-esm/storage-blob/src/ContainerClient.js.map +1 -0
  31. package/dist-esm/storage-blob/src/PageBlobRangeResponse.js +24 -0
  32. package/dist-esm/storage-blob/src/PageBlobRangeResponse.js.map +1 -0
  33. package/dist-esm/storage-blob/src/Pipeline.js +259 -0
  34. package/dist-esm/storage-blob/src/Pipeline.js.map +1 -0
  35. package/dist-esm/storage-blob/src/Range.js +21 -0
  36. package/dist-esm/storage-blob/src/Range.js.map +1 -0
  37. package/dist-esm/{src → storage-blob/src}/StorageBrowserPolicyFactory.js +1 -1
  38. package/dist-esm/storage-blob/src/StorageBrowserPolicyFactory.js.map +1 -0
  39. package/dist-esm/storage-blob/src/StorageClient.js +29 -0
  40. package/dist-esm/storage-blob/src/StorageClient.js.map +1 -0
  41. package/dist-esm/storage-blob/src/StorageContextClient.js +17 -0
  42. package/dist-esm/storage-blob/src/StorageContextClient.js.map +1 -0
  43. package/dist-esm/{src → storage-blob/src}/StorageRetryPolicyFactory.js +1 -1
  44. package/dist-esm/storage-blob/src/StorageRetryPolicyFactory.js.map +1 -0
  45. package/dist-esm/{src → storage-blob/src}/credentials/AnonymousCredential.js +2 -2
  46. package/dist-esm/storage-blob/src/credentials/AnonymousCredential.js.map +1 -0
  47. package/dist-esm/storage-blob/src/credentials/Credential.js.map +1 -0
  48. package/dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.browser.js.map +1 -0
  49. package/dist-esm/{src → storage-blob/src}/credentials/StorageSharedKeyCredential.js +1 -1
  50. package/dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.js.map +1 -0
  51. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.browser.js +5 -0
  52. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.browser.js.map +1 -0
  53. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.js +31 -0
  54. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.js.map +1 -0
  55. package/dist-esm/{src → storage-blob/src}/generated/src/index.js +1 -1
  56. package/dist-esm/storage-blob/src/generated/src/index.js.map +1 -0
  57. package/dist-esm/storage-blob/src/generated/src/models/index.js +256 -0
  58. package/dist-esm/storage-blob/src/generated/src/models/index.js.map +1 -0
  59. package/dist-esm/storage-blob/src/generated/src/models/mappers.js +8196 -0
  60. package/dist-esm/storage-blob/src/generated/src/models/mappers.js.map +1 -0
  61. package/dist-esm/storage-blob/src/generated/src/models/parameters.js +1610 -0
  62. package/dist-esm/storage-blob/src/generated/src/models/parameters.js.map +1 -0
  63. package/dist-esm/storage-blob/src/generated/src/operations/appendBlob.js +221 -0
  64. package/dist-esm/storage-blob/src/generated/src/operations/appendBlob.js.map +1 -0
  65. package/dist-esm/storage-blob/src/generated/src/operations/blob.js +997 -0
  66. package/dist-esm/storage-blob/src/generated/src/operations/blob.js.map +1 -0
  67. package/dist-esm/storage-blob/src/generated/src/operations/blockBlob.js +365 -0
  68. package/dist-esm/storage-blob/src/generated/src/operations/blockBlob.js.map +1 -0
  69. package/dist-esm/storage-blob/src/generated/src/operations/container.js +705 -0
  70. package/dist-esm/storage-blob/src/generated/src/operations/container.js.map +1 -0
  71. package/dist-esm/storage-blob/src/generated/src/operations/index.js +14 -0
  72. package/dist-esm/storage-blob/src/generated/src/operations/index.js.map +1 -0
  73. package/dist-esm/storage-blob/src/generated/src/operations/pageBlob.js +456 -0
  74. package/dist-esm/storage-blob/src/generated/src/operations/pageBlob.js.map +1 -0
  75. package/dist-esm/storage-blob/src/generated/src/operations/service.js +315 -0
  76. package/dist-esm/storage-blob/src/generated/src/operations/service.js.map +1 -0
  77. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/appendBlob.js +9 -0
  78. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/appendBlob.js.map +1 -0
  79. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/blob.js +9 -0
  80. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/blob.js.map +1 -0
  81. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/blockBlob.js +9 -0
  82. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/blockBlob.js.map +1 -0
  83. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/container.js +9 -0
  84. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/container.js.map +1 -0
  85. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/index.js +14 -0
  86. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/index.js.map +1 -0
  87. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/pageBlob.js +9 -0
  88. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/pageBlob.js.map +1 -0
  89. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/service.js +9 -0
  90. package/dist-esm/storage-blob/src/generated/src/operationsInterfaces/service.js.map +1 -0
  91. package/dist-esm/storage-blob/src/generated/src/storageClient.js +49 -0
  92. package/dist-esm/storage-blob/src/generated/src/storageClient.js.map +1 -0
  93. package/dist-esm/storage-blob/src/generatedModels.js.map +1 -0
  94. package/dist-esm/storage-blob/src/index.browser.js +23 -0
  95. package/dist-esm/storage-blob/src/index.browser.js.map +1 -0
  96. package/dist-esm/storage-blob/src/index.js +33 -0
  97. package/dist-esm/storage-blob/src/index.js.map +1 -0
  98. package/dist-esm/storage-blob/src/log.js +8 -0
  99. package/dist-esm/storage-blob/src/log.js.map +1 -0
  100. package/dist-esm/storage-blob/src/models.js +108 -0
  101. package/dist-esm/storage-blob/src/models.js.map +1 -0
  102. package/dist-esm/storage-blob/src/policies/AnonymousCredentialPolicy.js.map +1 -0
  103. package/dist-esm/{src → storage-blob/src}/policies/CredentialPolicy.js +1 -1
  104. package/dist-esm/storage-blob/src/policies/CredentialPolicy.js.map +1 -0
  105. package/dist-esm/storage-blob/src/policies/RequestPolicy.js +40 -0
  106. package/dist-esm/storage-blob/src/policies/RequestPolicy.js.map +1 -0
  107. package/dist-esm/{src → storage-blob/src}/policies/StorageBrowserPolicy.js +2 -1
  108. package/dist-esm/{src → storage-blob/src}/policies/StorageBrowserPolicy.js.map +1 -1
  109. package/dist-esm/storage-blob/src/policies/StorageBrowserPolicyV2.js +31 -0
  110. package/dist-esm/storage-blob/src/policies/StorageBrowserPolicyV2.js.map +1 -0
  111. package/dist-esm/{src → storage-blob/src}/policies/StorageRetryPolicy.js +5 -4
  112. package/dist-esm/storage-blob/src/policies/StorageRetryPolicy.js.map +1 -0
  113. package/dist-esm/storage-blob/src/policies/StorageRetryPolicyV2.js +165 -0
  114. package/dist-esm/storage-blob/src/policies/StorageRetryPolicyV2.js.map +1 -0
  115. package/dist-esm/{src → storage-blob/src}/policies/StorageSharedKeyCredentialPolicy.js +4 -2
  116. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicy.js.map +1 -0
  117. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.browser.js +18 -0
  118. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.browser.js.map +1 -0
  119. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.js +131 -0
  120. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -0
  121. package/dist-esm/storage-blob/src/pollers/BlobStartCopyFromUrlPoller.js +130 -0
  122. package/dist-esm/storage-blob/src/pollers/BlobStartCopyFromUrlPoller.js.map +1 -0
  123. package/dist-esm/storage-blob/src/sas/AccountSASPermissions.js +227 -0
  124. package/dist-esm/storage-blob/src/sas/AccountSASPermissions.js.map +1 -0
  125. package/dist-esm/storage-blob/src/sas/AccountSASResourceTypes.js.map +1 -0
  126. package/dist-esm/storage-blob/src/sas/AccountSASServices.js.map +1 -0
  127. package/dist-esm/storage-blob/src/sas/AccountSASSignatureValues.js +93 -0
  128. package/dist-esm/storage-blob/src/sas/AccountSASSignatureValues.js.map +1 -0
  129. package/dist-esm/storage-blob/src/sas/BlobSASPermissions.js +195 -0
  130. package/dist-esm/storage-blob/src/sas/BlobSASPermissions.js.map +1 -0
  131. package/dist-esm/storage-blob/src/sas/BlobSASSignatureValues.js +555 -0
  132. package/dist-esm/storage-blob/src/sas/BlobSASSignatureValues.js.map +1 -0
  133. package/dist-esm/storage-blob/src/sas/ContainerSASPermissions.js +221 -0
  134. package/dist-esm/storage-blob/src/sas/ContainerSASPermissions.js.map +1 -0
  135. package/dist-esm/storage-blob/src/sas/SASQueryParameters.js +234 -0
  136. package/dist-esm/storage-blob/src/sas/SASQueryParameters.js.map +1 -0
  137. package/dist-esm/storage-blob/src/sas/SasIPRange.js.map +1 -0
  138. package/dist-esm/storage-blob/src/utils/Batch.js +122 -0
  139. package/dist-esm/storage-blob/src/utils/Batch.js.map +1 -0
  140. package/dist-esm/storage-blob/src/utils/BlobQuickQueryStream.js +111 -0
  141. package/dist-esm/storage-blob/src/utils/BlobQuickQueryStream.js.map +1 -0
  142. package/dist-esm/storage-blob/src/utils/Mutex.js +66 -0
  143. package/dist-esm/storage-blob/src/utils/Mutex.js.map +1 -0
  144. package/dist-esm/storage-blob/src/utils/RetriableReadableStream.js +119 -0
  145. package/dist-esm/storage-blob/src/utils/RetriableReadableStream.js.map +1 -0
  146. package/dist-esm/storage-blob/src/utils/cache.js +11 -0
  147. package/dist-esm/storage-blob/src/utils/cache.js.map +1 -0
  148. package/dist-esm/storage-blob/src/utils/constants.js +223 -0
  149. package/dist-esm/storage-blob/src/utils/constants.js.map +1 -0
  150. package/dist-esm/storage-blob/src/utils/tracing.js +14 -0
  151. package/dist-esm/storage-blob/src/utils/tracing.js.map +1 -0
  152. package/dist-esm/storage-blob/src/utils/utils.browser.js +48 -0
  153. package/dist-esm/storage-blob/src/utils/utils.browser.js.map +1 -0
  154. package/dist-esm/storage-blob/src/utils/utils.common.js +754 -0
  155. package/dist-esm/storage-blob/src/utils/utils.common.js.map +1 -0
  156. package/dist-esm/storage-blob/src/utils/utils.node.js +132 -0
  157. package/dist-esm/storage-blob/src/utils/utils.node.js.map +1 -0
  158. package/dist-esm/storage-queue/src/AccountSASPermissions.js.map +1 -0
  159. package/dist-esm/storage-queue/src/AccountSASResourceTypes.js +72 -0
  160. package/dist-esm/storage-queue/src/AccountSASResourceTypes.js.map +1 -0
  161. package/dist-esm/storage-queue/src/AccountSASServices.js +80 -0
  162. package/dist-esm/storage-queue/src/AccountSASServices.js.map +1 -0
  163. package/dist-esm/storage-queue/src/AccountSASSignatureValues.js.map +1 -0
  164. package/dist-esm/{src → storage-queue/src}/QueueClient.js +108 -290
  165. package/dist-esm/storage-queue/src/QueueClient.js.map +1 -0
  166. package/dist-esm/storage-queue/src/QueueSASPermissions.js.map +1 -0
  167. package/dist-esm/storage-queue/src/QueueSASSignatureValues.js.map +1 -0
  168. package/dist-esm/{src → storage-queue/src}/QueueServiceClient.js +60 -135
  169. package/dist-esm/storage-queue/src/QueueServiceClient.js.map +1 -0
  170. package/dist-esm/{src → storage-queue/src}/SASQueryParameters.js +14 -14
  171. package/dist-esm/storage-queue/src/SASQueryParameters.js.map +1 -0
  172. package/dist-esm/storage-queue/src/SasIPRange.js +13 -0
  173. package/dist-esm/storage-queue/src/SasIPRange.js.map +1 -0
  174. package/dist-esm/storage-queue/src/StorageClient.js +53 -0
  175. package/dist-esm/storage-queue/src/StorageClient.js.map +1 -0
  176. package/dist-esm/storage-queue/src/StorageContextClient.js +18 -0
  177. package/dist-esm/storage-queue/src/StorageContextClient.js.map +1 -0
  178. package/dist-esm/storage-queue/src/generated/src/index.js +11 -0
  179. package/dist-esm/storage-queue/src/generated/src/index.js.map +1 -0
  180. package/dist-esm/{src → storage-queue/src}/generated/src/models/index.js +57 -0
  181. package/dist-esm/storage-queue/src/generated/src/models/index.js.map +1 -0
  182. package/dist-esm/{src → storage-queue/src}/generated/src/models/mappers.js +2 -2
  183. package/dist-esm/storage-queue/src/generated/src/models/mappers.js.map +1 -0
  184. package/dist-esm/{src → storage-queue/src}/generated/src/models/parameters.js +4 -5
  185. package/dist-esm/storage-queue/src/generated/src/models/parameters.js.map +1 -0
  186. package/dist-esm/storage-queue/src/generated/src/operations/index.js.map +1 -0
  187. package/dist-esm/{src → storage-queue/src}/generated/src/operations/messageId.js +6 -15
  188. package/dist-esm/storage-queue/src/generated/src/operations/messageId.js.map +1 -0
  189. package/dist-esm/{src → storage-queue/src}/generated/src/operations/messages.js +8 -21
  190. package/dist-esm/storage-queue/src/generated/src/operations/messages.js.map +1 -0
  191. package/dist-esm/{src → storage-queue/src}/generated/src/operations/queue.js +10 -28
  192. package/dist-esm/storage-queue/src/generated/src/operations/queue.js.map +1 -0
  193. package/dist-esm/{src → storage-queue/src}/generated/src/operations/service.js +8 -21
  194. package/dist-esm/storage-queue/src/generated/src/operations/service.js.map +1 -0
  195. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/index.js +12 -0
  196. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/index.js.map +1 -0
  197. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/messageId.js +9 -0
  198. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/messageId.js.map +1 -0
  199. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/messages.js +9 -0
  200. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/messages.js.map +1 -0
  201. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/queue.js +9 -0
  202. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/queue.js.map +1 -0
  203. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/service.js +9 -0
  204. package/dist-esm/storage-queue/src/generated/src/operationsInterfaces/service.js.map +1 -0
  205. package/dist-esm/storage-queue/src/generated/src/storageClient.js +47 -0
  206. package/dist-esm/storage-queue/src/generated/src/storageClient.js.map +1 -0
  207. package/dist-esm/storage-queue/src/generatedModels.js +4 -0
  208. package/dist-esm/storage-queue/src/generatedModels.js.map +1 -0
  209. package/dist-esm/storage-queue/src/index.browser.js +18 -0
  210. package/dist-esm/storage-queue/src/index.browser.js.map +1 -0
  211. package/dist-esm/storage-queue/src/index.js +26 -0
  212. package/dist-esm/storage-queue/src/index.js.map +1 -0
  213. package/dist-esm/storage-queue/src/log.js.map +1 -0
  214. package/dist-esm/storage-queue/src/models.js.map +1 -0
  215. package/dist-esm/{src → storage-queue/src}/utils/constants.js +2 -2
  216. package/dist-esm/storage-queue/src/utils/constants.js.map +1 -0
  217. package/dist-esm/storage-queue/src/utils/tracing.js +14 -0
  218. package/dist-esm/storage-queue/src/utils/tracing.js.map +1 -0
  219. package/dist-esm/{src → storage-queue/src}/utils/utils.common.js +69 -47
  220. package/dist-esm/storage-queue/src/utils/utils.common.js.map +1 -0
  221. package/package.json +26 -19
  222. package/types/3.1/storage-queue.d.ts +544 -255
  223. package/types/latest/storage-queue.d.ts +583 -259
  224. package/dist-esm/src/AccountSASPermissions.js.map +0 -1
  225. package/dist-esm/src/AccountSASResourceTypes.js.map +0 -1
  226. package/dist-esm/src/AccountSASServices.js.map +0 -1
  227. package/dist-esm/src/AccountSASSignatureValues.js.map +0 -1
  228. package/dist-esm/src/Pipeline.js +0 -85
  229. package/dist-esm/src/Pipeline.js.map +0 -1
  230. package/dist-esm/src/QueueClient.js.map +0 -1
  231. package/dist-esm/src/QueueSASPermissions.js.map +0 -1
  232. package/dist-esm/src/QueueSASSignatureValues.js.map +0 -1
  233. package/dist-esm/src/QueueServiceClient.js.map +0 -1
  234. package/dist-esm/src/SASQueryParameters.js.map +0 -1
  235. package/dist-esm/src/SasIPRange.js.map +0 -1
  236. package/dist-esm/src/StorageBrowserPolicyFactory.js.map +0 -1
  237. package/dist-esm/src/StorageClient.js +0 -44
  238. package/dist-esm/src/StorageClient.js.map +0 -1
  239. package/dist-esm/src/StorageRetryPolicyFactory.js.map +0 -1
  240. package/dist-esm/src/TelemetryPolicyFactory.js +0 -50
  241. package/dist-esm/src/TelemetryPolicyFactory.js.map +0 -1
  242. package/dist-esm/src/credentials/AnonymousCredential.js.map +0 -1
  243. package/dist-esm/src/credentials/Credential.js.map +0 -1
  244. package/dist-esm/src/credentials/StorageSharedKeyCredential.browser.js.map +0 -1
  245. package/dist-esm/src/credentials/StorageSharedKeyCredential.js.map +0 -1
  246. package/dist-esm/src/generated/src/index.js.map +0 -1
  247. package/dist-esm/src/generated/src/models/index.js.map +0 -1
  248. package/dist-esm/src/generated/src/models/mappers.js.map +0 -1
  249. package/dist-esm/src/generated/src/models/parameters.js.map +0 -1
  250. package/dist-esm/src/generated/src/operations/index.js.map +0 -1
  251. package/dist-esm/src/generated/src/operations/messageId.js.map +0 -1
  252. package/dist-esm/src/generated/src/operations/messages.js.map +0 -1
  253. package/dist-esm/src/generated/src/operations/queue.js.map +0 -1
  254. package/dist-esm/src/generated/src/operations/service.js.map +0 -1
  255. package/dist-esm/src/generated/src/storageClient.js +0 -25
  256. package/dist-esm/src/generated/src/storageClient.js.map +0 -1
  257. package/dist-esm/src/generated/src/storageClientContext.js +0 -39
  258. package/dist-esm/src/generated/src/storageClientContext.js.map +0 -1
  259. package/dist-esm/src/generatedModels.js.map +0 -1
  260. package/dist-esm/src/index.browser.js +0 -17
  261. package/dist-esm/src/index.browser.js.map +0 -1
  262. package/dist-esm/src/index.js +0 -25
  263. package/dist-esm/src/index.js.map +0 -1
  264. package/dist-esm/src/log.js.map +0 -1
  265. package/dist-esm/src/models.js.map +0 -1
  266. package/dist-esm/src/policies/AnonymousCredentialPolicy.js.map +0 -1
  267. package/dist-esm/src/policies/CredentialPolicy.js.map +0 -1
  268. package/dist-esm/src/policies/StorageRetryPolicy.js.map +0 -1
  269. package/dist-esm/src/policies/StorageSharedKeyCredentialPolicy.js.map +0 -1
  270. package/dist-esm/src/policies/TelemetryPolicy.js +0 -36
  271. package/dist-esm/src/policies/TelemetryPolicy.js.map +0 -1
  272. package/dist-esm/src/utils/cache.js +0 -8
  273. package/dist-esm/src/utils/cache.js.map +0 -1
  274. package/dist-esm/src/utils/constants.js.map +0 -1
  275. package/dist-esm/src/utils/tracing.js +0 -27
  276. package/dist-esm/src/utils/tracing.js.map +0 -1
  277. package/dist-esm/src/utils/utils.common.js.map +0 -1
  278. /package/dist-esm/{src → storage-blob/src}/credentials/Credential.js +0 -0
  279. /package/dist-esm/{src → storage-blob/src}/credentials/StorageSharedKeyCredential.browser.js +0 -0
  280. /package/dist-esm/{src → storage-blob/src}/generatedModels.js +0 -0
  281. /package/dist-esm/{src → storage-blob/src}/policies/AnonymousCredentialPolicy.js +0 -0
  282. /package/dist-esm/{src → storage-blob/src/sas}/AccountSASResourceTypes.js +0 -0
  283. /package/dist-esm/{src → storage-blob/src/sas}/AccountSASServices.js +0 -0
  284. /package/dist-esm/{src → storage-blob/src/sas}/SasIPRange.js +0 -0
  285. /package/dist-esm/{src → storage-queue/src}/AccountSASPermissions.js +0 -0
  286. /package/dist-esm/{src → storage-queue/src}/AccountSASSignatureValues.js +0 -0
  287. /package/dist-esm/{src → storage-queue/src}/QueueSASPermissions.js +0 -0
  288. /package/dist-esm/{src → storage-queue/src}/QueueSASSignatureValues.js +0 -0
  289. /package/dist-esm/{src → storage-queue/src}/generated/src/operations/index.js +0 -0
  290. /package/dist-esm/{src → storage-queue/src}/log.js +0 -0
  291. /package/dist-esm/{src → storage-queue/src}/models.js +0 -0
package/dist/index.js CHANGED
@@ -2,13 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var coreHttp = require('@azure/core-http');
5
+ var coreRestPipeline = require('@azure/core-rest-pipeline');
6
6
  var crypto = require('crypto');
7
- var logger$1 = require('@azure/logger');
7
+ var coreUtil = require('@azure/core-util');
8
+ var tslib = require('tslib');
9
+ var coreHttpCompat = require('@azure/core-http-compat');
10
+ var coreClient = require('@azure/core-client');
11
+ var coreXml = require('@azure/core-xml');
12
+ var coreAuth = require('@azure/core-auth');
13
+ var logger$2 = require('@azure/logger');
8
14
  var abortController = require('@azure/abort-controller');
9
- var os = require('os');
10
15
  var coreTracing = require('@azure/core-tracing');
11
- var tslib = require('tslib');
12
16
  require('@azure/core-paging');
13
17
 
14
18
  function _interopNamespace(e) {
@@ -29,8 +33,8 @@ function _interopNamespace(e) {
29
33
  return Object.freeze(n);
30
34
  }
31
35
 
32
- var coreHttp__namespace = /*#__PURE__*/_interopNamespace(coreHttp);
33
- var os__namespace = /*#__PURE__*/_interopNamespace(os);
36
+ var coreHttpCompat__namespace = /*#__PURE__*/_interopNamespace(coreHttpCompat);
37
+ var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
34
38
 
35
39
  // Copyright (c) Microsoft Corporation.
36
40
  // Licensed under the MIT license.
@@ -327,90 +331,11 @@ function ipRangeToString(ipRange) {
327
331
 
328
332
  // Copyright (c) Microsoft Corporation.
329
333
  // Licensed under the MIT license.
330
- const SDK_VERSION = "12.13.0";
331
- const SERVICE_VERSION = "2022-11-02";
332
- /**
333
- * The OAuth scope to use with Azure Storage.
334
- */
335
- const StorageOAuthScopes = "https://storage.azure.com/.default";
336
- const URLConstants = {
337
- Parameters: {
338
- FORCE_BROWSER_NO_CACHE: "_",
339
- SIGNATURE: "sig",
340
- TIMEOUT: "timeout",
341
- },
342
- };
343
- const HeaderConstants = {
344
- AUTHORIZATION: "authorization",
345
- AUTHORIZATION_SCHEME: "Bearer",
346
- CONTENT_ENCODING: "content-encoding",
347
- CONTENT_LANGUAGE: "content-language",
348
- CONTENT_LENGTH: "content-length",
349
- CONTENT_MD5: "content-md5",
350
- CONTENT_TYPE: "content-type",
351
- COOKIE: "Cookie",
352
- DATE: "date",
353
- IF_MATCH: "if-match",
354
- IF_MODIFIED_SINCE: "if-modified-since",
355
- IF_NONE_MATCH: "if-none-match",
356
- IF_UNMODIFIED_SINCE: "if-unmodified-since",
357
- PREFIX_FOR_STORAGE: "x-ms-",
358
- RANGE: "Range",
359
- USER_AGENT: "User-Agent",
360
- X_MS_CLIENT_REQUEST_ID: "x-ms-client-request-id",
361
- X_MS_COPY_SOURCE: "x-ms-copy-source",
362
- X_MS_DATE: "x-ms-date",
363
- };
334
+ const SDK_VERSION$1 = "12.20.0";
335
+ const SERVICE_VERSION = "2021-10-04";
364
336
  const DevelopmentConnectionString = `DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
365
337
  AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
366
338
  QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;`;
367
- const StorageQueueLoggingAllowedHeaderNames = [
368
- "Access-Control-Allow-Origin",
369
- "Cache-Control",
370
- "Content-Length",
371
- "Content-Type",
372
- "Date",
373
- "Request-Id",
374
- "traceparent",
375
- "Transfer-Encoding",
376
- "User-Agent",
377
- "x-ms-client-request-id",
378
- "x-ms-date",
379
- "x-ms-error-code",
380
- "x-ms-request-id",
381
- "x-ms-return-client-request-id",
382
- "x-ms-version",
383
- "x-ms-approximate-messages-count",
384
- "x-ms-popreceipt",
385
- "x-ms-time-next-visible",
386
- ];
387
- const StorageQueueLoggingAllowedQueryParameters = [
388
- "comp",
389
- "maxresults",
390
- "rscc",
391
- "rscd",
392
- "rsce",
393
- "rscl",
394
- "rsct",
395
- "se",
396
- "si",
397
- "sip",
398
- "sp",
399
- "spr",
400
- "sr",
401
- "srt",
402
- "ss",
403
- "st",
404
- "sv",
405
- "include",
406
- "marker",
407
- "prefix",
408
- "messagettl",
409
- "numofmessages",
410
- "peekonly",
411
- "popreceipt",
412
- "visibilitytimeout",
413
- ];
414
339
  /// List of ports used for path style addressing.
415
340
  /// Path style addressing means that storage account is put in URI's Path segment in instead of in host.
416
341
  const PathStylePorts = [
@@ -436,44 +361,6 @@ const PathStylePorts = [
436
361
  "11104",
437
362
  ];
438
363
 
439
- /*
440
- * Copyright (c) Microsoft Corporation.
441
- * Licensed under the MIT License.
442
- *
443
- * Code generated by Microsoft (R) AutoRest Code Generator.
444
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
445
- */
446
- const packageName = "azure-storage-queue";
447
- const packageVersion = "12.13.0";
448
- class StorageClientContext extends coreHttp__namespace.ServiceClient {
449
- /**
450
- * Initializes a new instance of the StorageClientContext class.
451
- * @param url The URL of the service account, queue or message that is the target of the desired
452
- * operation.
453
- * @param options The parameter options
454
- */
455
- constructor(url, options) {
456
- if (url === undefined) {
457
- throw new Error("'url' cannot be null");
458
- }
459
- // Initializing default values for options
460
- if (!options) {
461
- options = {};
462
- }
463
- if (!options.userAgent) {
464
- const defaultUserAgent = coreHttp__namespace.getDefaultUserAgentValue();
465
- options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
466
- }
467
- super(undefined, options);
468
- this.requestContentType = "application/json; charset=utf-8";
469
- this.baseUri = options.endpoint || "{url}";
470
- // Parameter assignments
471
- this.url = url;
472
- // Assigning values to Constant parameters
473
- this.version = options.version || "2022-11-02";
474
- }
475
- }
476
-
477
364
  /**
478
365
  * Append a string to URL path. Will remove duplicated "/" in front of the string
479
366
  * when URL path ends with a "/".
@@ -483,76 +370,12 @@ class StorageClientContext extends coreHttp__namespace.ServiceClient {
483
370
  * @returns An updated URL string
484
371
  */
485
372
  function appendToURLPath(url, name) {
486
- const urlParsed = coreHttp.URLBuilder.parse(url);
487
- let path = urlParsed.getPath();
373
+ const urlParsed = new URL(url);
374
+ let path = urlParsed.pathname;
488
375
  path = path ? (path.endsWith("/") ? `${path}${name}` : `${path}/${name}`) : name;
489
- urlParsed.setPath(path);
490
- return urlParsed.toString();
491
- }
492
- /**
493
- * Set URL parameter name and value. If name exists in URL parameters, old value
494
- * will be replaced by name key. If not provide value, the parameter will be deleted.
495
- *
496
- * @param url - Source URL string
497
- * @param name - Parameter name
498
- * @param value - Parameter value
499
- * @returns An updated URL string
500
- */
501
- function setURLParameter(url, name, value) {
502
- const urlParsed = coreHttp.URLBuilder.parse(url);
503
- urlParsed.setQueryParameter(name, value);
504
- return urlParsed.toString();
505
- }
506
- /**
507
- * Set URL host.
508
- *
509
- * @param url - Source URL string
510
- * @param host - New host string
511
- * @returns An updated URL string
512
- */
513
- function setURLHost(url, host) {
514
- const urlParsed = coreHttp.URLBuilder.parse(url);
515
- urlParsed.setHost(host);
376
+ urlParsed.pathname = path;
516
377
  return urlParsed.toString();
517
378
  }
518
- /**
519
- * Gets URL path from an URL string.
520
- *
521
- * @param url - Source URL string
522
- * @returns The path part of the given URL string.
523
- */
524
- function getURLPath(url) {
525
- const urlParsed = coreHttp.URLBuilder.parse(url);
526
- return urlParsed.getPath();
527
- }
528
- /**
529
- * Gets URL query key value pairs from an URL string.
530
- *
531
- * @param url -
532
- * @returns query key value string pairs from the given URL string.
533
- */
534
- function getURLQueries(url) {
535
- let queryString = coreHttp.URLBuilder.parse(url).getQuery();
536
- if (!queryString) {
537
- return {};
538
- }
539
- queryString = queryString.trim();
540
- queryString = queryString.startsWith("?") ? queryString.substr(1) : queryString;
541
- let querySubStrings = queryString.split("&");
542
- querySubStrings = querySubStrings.filter((value) => {
543
- const indexOfEqual = value.indexOf("=");
544
- const lastIndexOfEqual = value.lastIndexOf("=");
545
- return (indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1);
546
- });
547
- const queries = {};
548
- for (const querySubString of querySubStrings) {
549
- const splitResults = querySubString.split("=");
550
- const key = splitResults[0];
551
- const value = splitResults[1];
552
- queries[key] = value;
553
- }
554
- return queries;
555
- }
556
379
  function getProxyUriFromDevConnString(connectionString) {
557
380
  // Development Connection String
558
381
  // https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string#connect-to-the-emulator-account-using-the-well-known-account-name-and-key
@@ -641,7 +464,7 @@ function extractConnectionStringParts(connectionString) {
641
464
  }
642
465
  else {
643
466
  // SAS connection string
644
- const accountSas = getValueInConnString(connectionString, "SharedAccessSignature");
467
+ let accountSas = getValueInConnString(connectionString, "SharedAccessSignature");
645
468
  const accountName = getAccountNameFromUrl(queueEndpoint);
646
469
  if (!queueEndpoint) {
647
470
  throw new Error("Invalid QueueEndpoint in the provided SAS Connection String");
@@ -649,6 +472,10 @@ function extractConnectionStringParts(connectionString) {
649
472
  else if (!accountSas) {
650
473
  throw new Error("Invalid SharedAccessSignature in the provided SAS Connection String");
651
474
  }
475
+ // remove test SAS
476
+ if (accountSas === "fakeSasToken") {
477
+ accountSas = "";
478
+ }
652
479
  return { kind: "SASConnString", url: queueEndpoint, accountName, accountSas };
653
480
  }
654
481
  }
@@ -667,53 +494,24 @@ function truncatedISO8061Date(date, withMilliseconds = true) {
667
494
  ? dateString.substring(0, dateString.length - 1) + "0000" + "Z"
668
495
  : dateString.substring(0, dateString.length - 5) + "Z";
669
496
  }
670
- /**
671
- * Delay specified time interval.
672
- *
673
- * @param timeInMs -
674
- * @param aborter -
675
- * @param abortError -
676
- */
677
- async function delay(timeInMs, aborter, abortError) {
678
- return new Promise((resolve, reject) => {
679
- /* eslint-disable-next-line prefer-const*/
680
- let timeout;
681
- const abortHandler = () => {
682
- if (timeout !== undefined) {
683
- clearTimeout(timeout);
684
- }
685
- reject(abortError);
686
- };
687
- const resolveHandler = () => {
688
- if (aborter !== undefined) {
689
- aborter.removeEventListener("abort", abortHandler);
690
- }
691
- resolve();
692
- };
693
- timeout = setTimeout(resolveHandler, timeInMs);
694
- if (aborter !== undefined) {
695
- aborter.addEventListener("abort", abortHandler);
696
- }
697
- });
698
- }
699
497
  /**
700
498
  * Extracts account name from the url
701
499
  * @param url - url to extract the account name from
702
500
  * @returns with the account name
703
501
  */
704
502
  function getAccountNameFromUrl(url) {
705
- const parsedUrl = coreHttp.URLBuilder.parse(url);
503
+ const parsedUrl = new URL(url);
706
504
  let accountName;
707
505
  try {
708
- if (parsedUrl.getHost().split(".")[1] === "queue") {
506
+ if (parsedUrl.hostname.split(".")[1] === "queue") {
709
507
  // `${defaultEndpointsProtocol}://${accountName}.queue.${endpointSuffix}`;
710
- accountName = parsedUrl.getHost().split(".")[0];
508
+ accountName = parsedUrl.hostname.split(".")[0];
711
509
  }
712
510
  else if (isIpEndpointStyle(parsedUrl)) {
713
511
  // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/
714
512
  // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/
715
513
  // .getPath() -> /devstoreaccount1/
716
- accountName = parsedUrl.getPath().split("/")[1];
514
+ accountName = parsedUrl.pathname.split("/")[1];
717
515
  }
718
516
  else {
719
517
  // Custom domain case: "https://customdomain.com/containername/blob".
@@ -726,28 +524,13 @@ function getAccountNameFromUrl(url) {
726
524
  }
727
525
  }
728
526
  function isIpEndpointStyle(parsedUrl) {
729
- if (parsedUrl.getHost() === undefined) {
730
- return false;
731
- }
732
- const host = parsedUrl.getHost() + (parsedUrl.getPort() === undefined ? "" : ":" + parsedUrl.getPort());
527
+ const host = parsedUrl.host;
733
528
  // Case 1: Ipv6, use a broad regex to find out candidates whose host contains two ':'.
734
529
  // Case 2: localhost(:port), use broad regex to match port part.
735
530
  // Case 3: Ipv4, use broad regex which just check if host contains Ipv4.
736
531
  // For valid host please refer to https://man7.org/linux/man-pages/man7/hostname.7.html.
737
532
  return (/^.*:.*:.*$|^localhost(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host) ||
738
- (parsedUrl.getPort() !== undefined && PathStylePorts.includes(parsedUrl.getPort())));
739
- }
740
- /**
741
- * Gets a new StorageClientContext
742
- * @param url - Url used for the StorageClientContext
743
- * @param pipeline - a pipeline containing HTTP request policies
744
- * @returns new StorageClientContext
745
- */
746
- function getStorageClientContext(url, pipeline) {
747
- const storageClientContext = new StorageClientContext(url, pipeline.toServiceClientOptions());
748
- // Override protocol layer's default content-type
749
- storageClientContext.requestContentType = undefined;
750
- return storageClientContext;
533
+ (Boolean(parsedUrl.port) && PathStylePorts.includes(parsedUrl.port)));
751
534
  }
752
535
  /**
753
536
  * Append a string to URL query.
@@ -757,17 +540,29 @@ function getStorageClientContext(url, pipeline) {
757
540
  * @returns An updated URL string.
758
541
  */
759
542
  function appendToURLQuery(url, queryParts) {
760
- const urlParsed = coreHttp.URLBuilder.parse(url);
761
- let query = urlParsed.getQuery();
543
+ const urlParsed = new URL(url);
544
+ let query = urlParsed.search;
762
545
  if (query) {
763
546
  query += "&" + queryParts;
764
547
  }
765
548
  else {
766
549
  query = queryParts;
767
550
  }
768
- urlParsed.setQuery(query);
551
+ urlParsed.search = query;
769
552
  return urlParsed.toString();
770
553
  }
554
+ /**
555
+ * A typesafe helper for ensuring that a given response object has
556
+ * the original _response attached.
557
+ * @param response - A response object from calling a client operation
558
+ * @returns The same object, but with known _response property
559
+ */
560
+ function assertResponse(response) {
561
+ if (`_response` in response) {
562
+ return response;
563
+ }
564
+ throw new TypeError(`Unexpected response object ${response}`);
565
+ }
771
566
 
772
567
  // Copyright (c) Microsoft Corporation.
773
568
  /**
@@ -794,6 +589,20 @@ exports.SASProtocol = void 0;
794
589
  * NOTE: Instances of this class are immutable.
795
590
  */
796
591
  class SASQueryParameters {
592
+ /**
593
+ * Optional. IP range allowed for this SAS.
594
+ *
595
+ * @readonly
596
+ */
597
+ get ipRange() {
598
+ if (this.ipRangeInner) {
599
+ return {
600
+ end: this.ipRangeInner.end,
601
+ start: this.ipRangeInner.start,
602
+ };
603
+ }
604
+ return undefined;
605
+ }
797
606
  /**
798
607
  * Creates an instance of SASQueryParameters.
799
608
  *
@@ -822,20 +631,6 @@ class SASQueryParameters {
822
631
  this.resource = resource;
823
632
  this.signature = signature;
824
633
  }
825
- /**
826
- * Optional. IP range allowed for this SAS.
827
- *
828
- * @readonly
829
- */
830
- get ipRange() {
831
- if (this.ipRangeInner) {
832
- return {
833
- end: this.ipRangeInner.end,
834
- start: this.ipRangeInner.start,
835
- };
836
- }
837
- return undefined;
838
- }
839
634
  /**
840
635
  * Encodes all SAS query parameters into a string that can be appended to a URL.
841
636
  *
@@ -958,12 +753,52 @@ function generateAccountSASQueryParameters(accountSASSignatureValues, sharedKeyC
958
753
  return new SASQueryParameters(version, signature, parsedPermissions, parsedServices, parsedResourceTypes, accountSASSignatureValues.protocol, accountSASSignatureValues.startsOn, accountSASSignatureValues.expiresOn, accountSASSignatureValues.ipRange);
959
754
  }
960
755
 
756
+ // Copyright (c) Microsoft Corporation.
757
+ // Licensed under the MIT license.
758
+ /**
759
+ * The base class from which all request policies derive.
760
+ */
761
+ class BaseRequestPolicy {
762
+ /**
763
+ * The main method to implement that manipulates a request/response.
764
+ */
765
+ constructor(
766
+ /**
767
+ * The next policy in the pipeline. Each policy is responsible for executing the next one if the request is to continue through the pipeline.
768
+ */
769
+ _nextPolicy,
770
+ /**
771
+ * The options that can be passed to a given request policy.
772
+ */
773
+ _options) {
774
+ this._nextPolicy = _nextPolicy;
775
+ this._options = _options;
776
+ }
777
+ /**
778
+ * Get whether or not a log with the provided log level should be logged.
779
+ * @param logLevel - The log level of the log that will be logged.
780
+ * @returns Whether or not a log with the provided log level should be logged.
781
+ */
782
+ shouldLog(logLevel) {
783
+ return this._options.shouldLog(logLevel);
784
+ }
785
+ /**
786
+ * Attempt to log the provided message to the provided logger. If no logger was provided or if
787
+ * the log level does not meat the logger's threshold, then nothing will be logged.
788
+ * @param logLevel - The log level of this log.
789
+ * @param message - The message of this log.
790
+ */
791
+ log(logLevel, message) {
792
+ this._options.log(logLevel, message);
793
+ }
794
+ }
795
+
961
796
  // Copyright (c) Microsoft Corporation.
962
797
  /**
963
798
  * Credential policy used to sign HTTP(S) requests before sending. This is an
964
799
  * abstract class.
965
800
  */
966
- class CredentialPolicy extends coreHttp.BaseRequestPolicy {
801
+ class CredentialPolicy extends BaseRequestPolicy {
967
802
  /**
968
803
  * Sends out request.
969
804
  *
@@ -1023,8 +858,8 @@ class Credential {
1023
858
 
1024
859
  // Copyright (c) Microsoft Corporation.
1025
860
  /**
1026
- * AnonymousCredential provides a {@link CredentialPolicyCreator} member used to create
1027
- * {@link AnonymousCredentialPolicy} objects. {@link AnonymousCredentialPolicy} is used with
861
+ * AnonymousCredential provides a credentialPolicyCreator member used to create
862
+ * AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with
1028
863
  * HTTP(S) requests that read public resources or for use with Shared Access
1029
864
  * Signatures (SAS).
1030
865
  */
@@ -1041,31 +876,320 @@ class AnonymousCredential extends Credential {
1041
876
  }
1042
877
 
1043
878
  // Copyright (c) Microsoft Corporation.
879
+ // Licensed under the MIT license.
880
+ const SDK_VERSION = "12.13.0";
1044
881
  /**
1045
- * StorageSharedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.
882
+ * The OAuth scope to use with Azure Storage.
1046
883
  */
1047
- class StorageSharedKeyCredentialPolicy extends CredentialPolicy {
1048
- /**
1049
- * Creates an instance of StorageSharedKeyCredentialPolicy.
1050
- * @param nextPolicy -
1051
- * @param options -
1052
- * @param factory -
1053
- */
1054
- constructor(nextPolicy, options, factory) {
1055
- super(nextPolicy, options);
1056
- this.factory = factory;
1057
- }
1058
- /**
1059
- * Signs request.
1060
- *
1061
- * @param request -
1062
- */
1063
- signRequest(request) {
1064
- request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());
1065
- if (request.body && typeof request.body === "string" && request.body.length > 0) {
1066
- request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
1067
- }
1068
- const stringToSign = [
884
+ const StorageOAuthScopes = "https://storage.azure.com/.default";
885
+ const URLConstants = {
886
+ Parameters: {
887
+ FORCE_BROWSER_NO_CACHE: "_",
888
+ SIGNATURE: "sig",
889
+ SNAPSHOT: "snapshot",
890
+ VERSIONID: "versionid",
891
+ TIMEOUT: "timeout",
892
+ },
893
+ };
894
+ const HeaderConstants = {
895
+ AUTHORIZATION: "Authorization",
896
+ AUTHORIZATION_SCHEME: "Bearer",
897
+ CONTENT_ENCODING: "Content-Encoding",
898
+ CONTENT_ID: "Content-ID",
899
+ CONTENT_LANGUAGE: "Content-Language",
900
+ CONTENT_LENGTH: "Content-Length",
901
+ CONTENT_MD5: "Content-Md5",
902
+ CONTENT_TRANSFER_ENCODING: "Content-Transfer-Encoding",
903
+ CONTENT_TYPE: "Content-Type",
904
+ COOKIE: "Cookie",
905
+ DATE: "date",
906
+ IF_MATCH: "if-match",
907
+ IF_MODIFIED_SINCE: "if-modified-since",
908
+ IF_NONE_MATCH: "if-none-match",
909
+ IF_UNMODIFIED_SINCE: "if-unmodified-since",
910
+ PREFIX_FOR_STORAGE: "x-ms-",
911
+ RANGE: "Range",
912
+ USER_AGENT: "User-Agent",
913
+ X_MS_CLIENT_REQUEST_ID: "x-ms-client-request-id",
914
+ X_MS_COPY_SOURCE: "x-ms-copy-source",
915
+ X_MS_DATE: "x-ms-date",
916
+ X_MS_ERROR_CODE: "x-ms-error-code",
917
+ X_MS_VERSION: "x-ms-version",
918
+ };
919
+ const StorageBlobLoggingAllowedHeaderNames = [
920
+ "Access-Control-Allow-Origin",
921
+ "Cache-Control",
922
+ "Content-Length",
923
+ "Content-Type",
924
+ "Date",
925
+ "Request-Id",
926
+ "traceparent",
927
+ "Transfer-Encoding",
928
+ "User-Agent",
929
+ "x-ms-client-request-id",
930
+ "x-ms-date",
931
+ "x-ms-error-code",
932
+ "x-ms-request-id",
933
+ "x-ms-return-client-request-id",
934
+ "x-ms-version",
935
+ "Accept-Ranges",
936
+ "Content-Disposition",
937
+ "Content-Encoding",
938
+ "Content-Language",
939
+ "Content-MD5",
940
+ "Content-Range",
941
+ "ETag",
942
+ "Last-Modified",
943
+ "Server",
944
+ "Vary",
945
+ "x-ms-content-crc64",
946
+ "x-ms-copy-action",
947
+ "x-ms-copy-completion-time",
948
+ "x-ms-copy-id",
949
+ "x-ms-copy-progress",
950
+ "x-ms-copy-status",
951
+ "x-ms-has-immutability-policy",
952
+ "x-ms-has-legal-hold",
953
+ "x-ms-lease-state",
954
+ "x-ms-lease-status",
955
+ "x-ms-range",
956
+ "x-ms-request-server-encrypted",
957
+ "x-ms-server-encrypted",
958
+ "x-ms-snapshot",
959
+ "x-ms-source-range",
960
+ "If-Match",
961
+ "If-Modified-Since",
962
+ "If-None-Match",
963
+ "If-Unmodified-Since",
964
+ "x-ms-access-tier",
965
+ "x-ms-access-tier-change-time",
966
+ "x-ms-access-tier-inferred",
967
+ "x-ms-account-kind",
968
+ "x-ms-archive-status",
969
+ "x-ms-blob-append-offset",
970
+ "x-ms-blob-cache-control",
971
+ "x-ms-blob-committed-block-count",
972
+ "x-ms-blob-condition-appendpos",
973
+ "x-ms-blob-condition-maxsize",
974
+ "x-ms-blob-content-disposition",
975
+ "x-ms-blob-content-encoding",
976
+ "x-ms-blob-content-language",
977
+ "x-ms-blob-content-length",
978
+ "x-ms-blob-content-md5",
979
+ "x-ms-blob-content-type",
980
+ "x-ms-blob-public-access",
981
+ "x-ms-blob-sequence-number",
982
+ "x-ms-blob-type",
983
+ "x-ms-copy-destination-snapshot",
984
+ "x-ms-creation-time",
985
+ "x-ms-default-encryption-scope",
986
+ "x-ms-delete-snapshots",
987
+ "x-ms-delete-type-permanent",
988
+ "x-ms-deny-encryption-scope-override",
989
+ "x-ms-encryption-algorithm",
990
+ "x-ms-if-sequence-number-eq",
991
+ "x-ms-if-sequence-number-le",
992
+ "x-ms-if-sequence-number-lt",
993
+ "x-ms-incremental-copy",
994
+ "x-ms-lease-action",
995
+ "x-ms-lease-break-period",
996
+ "x-ms-lease-duration",
997
+ "x-ms-lease-id",
998
+ "x-ms-lease-time",
999
+ "x-ms-page-write",
1000
+ "x-ms-proposed-lease-id",
1001
+ "x-ms-range-get-content-md5",
1002
+ "x-ms-rehydrate-priority",
1003
+ "x-ms-sequence-number-action",
1004
+ "x-ms-sku-name",
1005
+ "x-ms-source-content-md5",
1006
+ "x-ms-source-if-match",
1007
+ "x-ms-source-if-modified-since",
1008
+ "x-ms-source-if-none-match",
1009
+ "x-ms-source-if-unmodified-since",
1010
+ "x-ms-tag-count",
1011
+ "x-ms-encryption-key-sha256",
1012
+ "x-ms-if-tags",
1013
+ "x-ms-source-if-tags",
1014
+ ];
1015
+ const StorageBlobLoggingAllowedQueryParameters = [
1016
+ "comp",
1017
+ "maxresults",
1018
+ "rscc",
1019
+ "rscd",
1020
+ "rsce",
1021
+ "rscl",
1022
+ "rsct",
1023
+ "se",
1024
+ "si",
1025
+ "sip",
1026
+ "sp",
1027
+ "spr",
1028
+ "sr",
1029
+ "srt",
1030
+ "ss",
1031
+ "st",
1032
+ "sv",
1033
+ "include",
1034
+ "marker",
1035
+ "prefix",
1036
+ "copyid",
1037
+ "restype",
1038
+ "blockid",
1039
+ "blocklisttype",
1040
+ "delimiter",
1041
+ "prevsnapshot",
1042
+ "ske",
1043
+ "skoid",
1044
+ "sks",
1045
+ "skt",
1046
+ "sktid",
1047
+ "skv",
1048
+ "snapshot",
1049
+ ];
1050
+
1051
+ // Copyright (c) Microsoft Corporation.
1052
+ /**
1053
+ * Set URL parameter name and value. If name exists in URL parameters, old value
1054
+ * will be replaced by name key. If not provide value, the parameter will be deleted.
1055
+ *
1056
+ * @param url - Source URL string
1057
+ * @param name - Parameter name
1058
+ * @param value - Parameter value
1059
+ * @returns An updated URL string
1060
+ */
1061
+ function setURLParameter(url, name, value) {
1062
+ const urlParsed = new URL(url);
1063
+ const encodedName = encodeURIComponent(name);
1064
+ const encodedValue = value ? encodeURIComponent(value) : undefined;
1065
+ // mutating searchParams will change the encoding, so we have to do this ourselves
1066
+ const searchString = urlParsed.search === "" ? "?" : urlParsed.search;
1067
+ const searchPieces = [];
1068
+ for (const pair of searchString.slice(1).split("&")) {
1069
+ if (pair) {
1070
+ const [key] = pair.split("=", 2);
1071
+ if (key !== encodedName) {
1072
+ searchPieces.push(pair);
1073
+ }
1074
+ }
1075
+ }
1076
+ if (encodedValue) {
1077
+ searchPieces.push(`${encodedName}=${encodedValue}`);
1078
+ }
1079
+ urlParsed.search = searchPieces.length ? `?${searchPieces.join("&")}` : "";
1080
+ return urlParsed.toString();
1081
+ }
1082
+ /**
1083
+ * Set URL host.
1084
+ *
1085
+ * @param url - Source URL string
1086
+ * @param host - New host string
1087
+ * @returns An updated URL string
1088
+ */
1089
+ function setURLHost(url, host) {
1090
+ const urlParsed = new URL(url);
1091
+ urlParsed.hostname = host;
1092
+ return urlParsed.toString();
1093
+ }
1094
+ /**
1095
+ * Get URL path from an URL string.
1096
+ *
1097
+ * @param url - Source URL string
1098
+ */
1099
+ function getURLPath(url) {
1100
+ try {
1101
+ const urlParsed = new URL(url);
1102
+ return urlParsed.pathname;
1103
+ }
1104
+ catch (e) {
1105
+ return undefined;
1106
+ }
1107
+ }
1108
+ /**
1109
+ * Get URL query key value pairs from an URL string.
1110
+ *
1111
+ * @param url -
1112
+ */
1113
+ function getURLQueries(url) {
1114
+ let queryString = new URL(url).search;
1115
+ if (!queryString) {
1116
+ return {};
1117
+ }
1118
+ queryString = queryString.trim();
1119
+ queryString = queryString.startsWith("?") ? queryString.substring(1) : queryString;
1120
+ let querySubStrings = queryString.split("&");
1121
+ querySubStrings = querySubStrings.filter((value) => {
1122
+ const indexOfEqual = value.indexOf("=");
1123
+ const lastIndexOfEqual = value.lastIndexOf("=");
1124
+ return (indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1);
1125
+ });
1126
+ const queries = {};
1127
+ for (const querySubString of querySubStrings) {
1128
+ const splitResults = querySubString.split("=");
1129
+ const key = splitResults[0];
1130
+ const value = splitResults[1];
1131
+ queries[key] = value;
1132
+ }
1133
+ return queries;
1134
+ }
1135
+ /**
1136
+ * Delay specified time interval.
1137
+ *
1138
+ * @param timeInMs -
1139
+ * @param aborter -
1140
+ * @param abortError -
1141
+ */
1142
+ async function delay(timeInMs, aborter, abortError) {
1143
+ return new Promise((resolve, reject) => {
1144
+ /* eslint-disable-next-line prefer-const */
1145
+ let timeout;
1146
+ const abortHandler = () => {
1147
+ if (timeout !== undefined) {
1148
+ clearTimeout(timeout);
1149
+ }
1150
+ reject(abortError);
1151
+ };
1152
+ const resolveHandler = () => {
1153
+ if (aborter !== undefined) {
1154
+ aborter.removeEventListener("abort", abortHandler);
1155
+ }
1156
+ resolve();
1157
+ };
1158
+ timeout = setTimeout(resolveHandler, timeInMs);
1159
+ if (aborter !== undefined) {
1160
+ aborter.addEventListener("abort", abortHandler);
1161
+ }
1162
+ });
1163
+ }
1164
+
1165
+ // Copyright (c) Microsoft Corporation.
1166
+ /**
1167
+ * StorageSharedKeyCredentialPolicy is a policy used to sign HTTP request with a shared key.
1168
+ */
1169
+ class StorageSharedKeyCredentialPolicy extends CredentialPolicy {
1170
+ /**
1171
+ * Creates an instance of StorageSharedKeyCredentialPolicy.
1172
+ * @param nextPolicy -
1173
+ * @param options -
1174
+ * @param factory -
1175
+ */
1176
+ constructor(nextPolicy, options, factory) {
1177
+ super(nextPolicy, options);
1178
+ this.factory = factory;
1179
+ }
1180
+ /**
1181
+ * Signs request.
1182
+ *
1183
+ * @param request -
1184
+ */
1185
+ signRequest(request) {
1186
+ request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());
1187
+ if (request.body &&
1188
+ (typeof request.body === "string" || request.body !== undefined) &&
1189
+ request.body.length > 0) {
1190
+ request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
1191
+ }
1192
+ const stringToSign = [
1069
1193
  request.method.toUpperCase(),
1070
1194
  this.getHeaderValueToSign(request, HeaderConstants.CONTENT_LANGUAGE),
1071
1195
  this.getHeaderValueToSign(request, HeaderConstants.CONTENT_ENCODING),
@@ -1151,7 +1275,7 @@ class StorageSharedKeyCredentialPolicy extends CredentialPolicy {
1151
1275
  * @param request -
1152
1276
  */
1153
1277
  getCanonicalizedResourceString(request) {
1154
- const path = encodeURI(getURLPath(request.url) || "/");
1278
+ const path = getURLPath(request.url) || "/";
1155
1279
  let canonicalizedResourceString = "";
1156
1280
  canonicalizedResourceString += `/${this.factory.accountName}${path}`;
1157
1281
  const queries = getURLQueries(request.url);
@@ -1192,7 +1316,7 @@ class StorageSharedKeyCredential extends Credential {
1192
1316
  this.accountKey = Buffer.from(accountKey, "base64");
1193
1317
  }
1194
1318
  /**
1195
- * Creates a {@link StorageSharedKeyCredentialPolicy} object.
1319
+ * Creates a StorageSharedKeyCredentialPolicy object.
1196
1320
  *
1197
1321
  * @param nextPolicy -
1198
1322
  * @param options -
@@ -1214,65 +1338,7 @@ class StorageSharedKeyCredential extends Credential {
1214
1338
  /**
1215
1339
  * The `@azure/logger` configuration for this package.
1216
1340
  */
1217
- const logger = logger$1.createClientLogger("storage-queue");
1218
-
1219
- // Copyright (c) Microsoft Corporation.
1220
- /**
1221
- * StorageBrowserPolicy will handle differences between Node.js and browser runtime, including:
1222
- *
1223
- * 1. Browsers cache GET/HEAD requests by adding conditional headers such as 'IF_MODIFIED_SINCE'.
1224
- * StorageBrowserPolicy is a policy used to add a timestamp query to GET/HEAD request URL
1225
- * thus avoid the browser cache.
1226
- *
1227
- * 2. Remove cookie header for security
1228
- *
1229
- * 3. Remove content-length header to avoid browsers warning
1230
- */
1231
- class StorageBrowserPolicy extends coreHttp.BaseRequestPolicy {
1232
- /**
1233
- * Creates an instance of StorageBrowserPolicy.
1234
- * @param nextPolicy -
1235
- * @param options -
1236
- */
1237
- // The base class has a protected constructor. Adding a public one to enable constructing of this class.
1238
- /* eslint-disable-next-line @typescript-eslint/no-useless-constructor*/
1239
- constructor(nextPolicy, options) {
1240
- super(nextPolicy, options);
1241
- }
1242
- /**
1243
- * Sends out request.
1244
- *
1245
- * @param request -
1246
- */
1247
- async sendRequest(request) {
1248
- if (coreHttp.isNode) {
1249
- return this._nextPolicy.sendRequest(request);
1250
- }
1251
- if (request.method.toUpperCase() === "GET" || request.method.toUpperCase() === "HEAD") {
1252
- request.url = setURLParameter(request.url, URLConstants.Parameters.FORCE_BROWSER_NO_CACHE, new Date().getTime().toString());
1253
- }
1254
- request.headers.remove(HeaderConstants.COOKIE);
1255
- // According to XHR standards, content-length should be fully controlled by browsers
1256
- request.headers.remove(HeaderConstants.CONTENT_LENGTH);
1257
- return this._nextPolicy.sendRequest(request);
1258
- }
1259
- }
1260
-
1261
- // Copyright (c) Microsoft Corporation.
1262
- /**
1263
- * StorageBrowserPolicyFactory is a factory class helping generating {@link StorageBrowserPolicy} objects.
1264
- */
1265
- class StorageBrowserPolicyFactory {
1266
- /**
1267
- * Creates a StorageBrowserPolicyFactory object.
1268
- *
1269
- * @param nextPolicy -
1270
- * @param options -
1271
- */
1272
- create(nextPolicy, options) {
1273
- return new StorageBrowserPolicy(nextPolicy, options);
1274
- }
1275
- }
1341
+ const logger$1 = logger$2.createClientLogger("storage-blob");
1276
1342
 
1277
1343
  // Copyright (c) Microsoft Corporation.
1278
1344
  /**
@@ -1290,19 +1356,19 @@ exports.StorageRetryPolicyType = void 0;
1290
1356
  StorageRetryPolicyType[StorageRetryPolicyType["FIXED"] = 1] = "FIXED";
1291
1357
  })(exports.StorageRetryPolicyType || (exports.StorageRetryPolicyType = {}));
1292
1358
  // Default values of StorageRetryOptions
1293
- const DEFAULT_RETRY_OPTIONS = {
1359
+ const DEFAULT_RETRY_OPTIONS$1 = {
1294
1360
  maxRetryDelayInMs: 120 * 1000,
1295
1361
  maxTries: 4,
1296
1362
  retryDelayInMs: 4 * 1000,
1297
1363
  retryPolicyType: exports.StorageRetryPolicyType.EXPONENTIAL,
1298
1364
  secondaryHost: "",
1299
- tryTimeoutInMs: 30 * 1000, // https://docs.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations
1365
+ tryTimeoutInMs: undefined, // Use server side default timeout strategy
1300
1366
  };
1301
- const RETRY_ABORT_ERROR = new abortController.AbortError("The operation was aborted.");
1367
+ const RETRY_ABORT_ERROR$1 = new abortController.AbortError("The operation was aborted.");
1302
1368
  /**
1303
1369
  * Retry policy with exponential retry and linear retry implemented.
1304
1370
  */
1305
- class StorageRetryPolicy extends coreHttp.BaseRequestPolicy {
1371
+ class StorageRetryPolicy extends BaseRequestPolicy {
1306
1372
  /**
1307
1373
  * Creates an instance of RetryPolicy.
1308
1374
  *
@@ -1310,30 +1376,30 @@ class StorageRetryPolicy extends coreHttp.BaseRequestPolicy {
1310
1376
  * @param options -
1311
1377
  * @param retryOptions -
1312
1378
  */
1313
- constructor(nextPolicy, options, retryOptions = DEFAULT_RETRY_OPTIONS) {
1379
+ constructor(nextPolicy, options, retryOptions = DEFAULT_RETRY_OPTIONS$1) {
1314
1380
  super(nextPolicy, options);
1315
1381
  // Initialize retry options
1316
1382
  this.retryOptions = {
1317
1383
  retryPolicyType: retryOptions.retryPolicyType
1318
1384
  ? retryOptions.retryPolicyType
1319
- : DEFAULT_RETRY_OPTIONS.retryPolicyType,
1385
+ : DEFAULT_RETRY_OPTIONS$1.retryPolicyType,
1320
1386
  maxTries: retryOptions.maxTries && retryOptions.maxTries >= 1
1321
1387
  ? Math.floor(retryOptions.maxTries)
1322
- : DEFAULT_RETRY_OPTIONS.maxTries,
1388
+ : DEFAULT_RETRY_OPTIONS$1.maxTries,
1323
1389
  tryTimeoutInMs: retryOptions.tryTimeoutInMs && retryOptions.tryTimeoutInMs >= 0
1324
1390
  ? retryOptions.tryTimeoutInMs
1325
- : DEFAULT_RETRY_OPTIONS.tryTimeoutInMs,
1391
+ : DEFAULT_RETRY_OPTIONS$1.tryTimeoutInMs,
1326
1392
  retryDelayInMs: retryOptions.retryDelayInMs && retryOptions.retryDelayInMs >= 0
1327
1393
  ? Math.min(retryOptions.retryDelayInMs, retryOptions.maxRetryDelayInMs
1328
1394
  ? retryOptions.maxRetryDelayInMs
1329
- : DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs)
1330
- : DEFAULT_RETRY_OPTIONS.retryDelayInMs,
1395
+ : DEFAULT_RETRY_OPTIONS$1.maxRetryDelayInMs)
1396
+ : DEFAULT_RETRY_OPTIONS$1.retryDelayInMs,
1331
1397
  maxRetryDelayInMs: retryOptions.maxRetryDelayInMs && retryOptions.maxRetryDelayInMs >= 0
1332
1398
  ? retryOptions.maxRetryDelayInMs
1333
- : DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs,
1399
+ : DEFAULT_RETRY_OPTIONS$1.maxRetryDelayInMs,
1334
1400
  secondaryHost: retryOptions.secondaryHost
1335
1401
  ? retryOptions.secondaryHost
1336
- : DEFAULT_RETRY_OPTIONS.secondaryHost,
1402
+ : DEFAULT_RETRY_OPTIONS$1.secondaryHost,
1337
1403
  };
1338
1404
  }
1339
1405
  /**
@@ -1348,7 +1414,6 @@ class StorageRetryPolicy extends coreHttp.BaseRequestPolicy {
1348
1414
  * Decide and perform next retry. Won't mutate request parameter.
1349
1415
  *
1350
1416
  * @param request -
1351
- * @param response -
1352
1417
  * @param secondaryHas404 - If attempt was against the secondary & it returned a StatusNotFound (404), then
1353
1418
  * the resource was not found. This may be due to replication delay. So, in this
1354
1419
  * case, we'll never try the secondary again for this operation.
@@ -1365,10 +1430,12 @@ class StorageRetryPolicy extends coreHttp.BaseRequestPolicy {
1365
1430
  newRequest.url = setURLHost(newRequest.url, this.retryOptions.secondaryHost);
1366
1431
  }
1367
1432
  // Set the server-side timeout query parameter "timeout=[seconds]"
1368
- newRequest.url = setURLParameter(newRequest.url, URLConstants.Parameters.TIMEOUT, Math.floor(this.retryOptions.tryTimeoutInMs / 1000).toString());
1433
+ if (this.retryOptions.tryTimeoutInMs) {
1434
+ newRequest.url = setURLParameter(newRequest.url, URLConstants.Parameters.TIMEOUT, Math.floor(this.retryOptions.tryTimeoutInMs / 1000).toString());
1435
+ }
1369
1436
  let response;
1370
1437
  try {
1371
- logger.info(`RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`);
1438
+ logger$1.info(`RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`);
1372
1439
  response = await this._nextPolicy.sendRequest(newRequest);
1373
1440
  if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {
1374
1441
  return response;
@@ -1376,7 +1443,7 @@ class StorageRetryPolicy extends coreHttp.BaseRequestPolicy {
1376
1443
  secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);
1377
1444
  }
1378
1445
  catch (err) {
1379
- logger.error(`RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`);
1446
+ logger$1.error(`RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`);
1380
1447
  if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {
1381
1448
  throw err;
1382
1449
  }
@@ -1385,127 +1452,456 @@ class StorageRetryPolicy extends coreHttp.BaseRequestPolicy {
1385
1452
  return this.attemptSendRequest(request, secondaryHas404, ++attempt);
1386
1453
  }
1387
1454
  /**
1388
- * Decide whether to retry according to last HTTP response and retry counters.
1389
- *
1390
- * @param isPrimaryRetry -
1391
- * @param attempt -
1392
- * @param response -
1393
- * @param err -
1455
+ * Decide whether to retry according to last HTTP response and retry counters.
1456
+ *
1457
+ * @param isPrimaryRetry -
1458
+ * @param attempt -
1459
+ * @param response -
1460
+ * @param err -
1461
+ */
1462
+ shouldRetry(isPrimaryRetry, attempt, response, err) {
1463
+ if (attempt >= this.retryOptions.maxTries) {
1464
+ logger$1.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions
1465
+ .maxTries}, no further try.`);
1466
+ return false;
1467
+ }
1468
+ // Handle network failures, you may need to customize the list when you implement
1469
+ // your own http client
1470
+ const retriableErrors = [
1471
+ "ETIMEDOUT",
1472
+ "ESOCKETTIMEDOUT",
1473
+ "ECONNREFUSED",
1474
+ "ECONNRESET",
1475
+ "ENOENT",
1476
+ "ENOTFOUND",
1477
+ "TIMEOUT",
1478
+ "EPIPE",
1479
+ "REQUEST_SEND_ERROR", // For default xhr based http client provided in ms-rest-js
1480
+ ];
1481
+ if (err) {
1482
+ for (const retriableError of retriableErrors) {
1483
+ if (err.name.toUpperCase().includes(retriableError) ||
1484
+ err.message.toUpperCase().includes(retriableError) ||
1485
+ (err.code && err.code.toString().toUpperCase() === retriableError)) {
1486
+ logger$1.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);
1487
+ return true;
1488
+ }
1489
+ }
1490
+ }
1491
+ // If attempt was against the secondary & it returned a StatusNotFound (404), then
1492
+ // the resource was not found. This may be due to replication delay. So, in this
1493
+ // case, we'll never try the secondary again for this operation.
1494
+ if (response || err) {
1495
+ const statusCode = response ? response.status : err ? err.statusCode : 0;
1496
+ if (!isPrimaryRetry && statusCode === 404) {
1497
+ logger$1.info(`RetryPolicy: Secondary access with 404, will retry.`);
1498
+ return true;
1499
+ }
1500
+ // Server internal error or server timeout
1501
+ if (statusCode === 503 || statusCode === 500) {
1502
+ logger$1.info(`RetryPolicy: Will retry for status code ${statusCode}.`);
1503
+ return true;
1504
+ }
1505
+ }
1506
+ if ((err === null || err === void 0 ? void 0 : err.code) === "PARSE_ERROR" && (err === null || err === void 0 ? void 0 : err.message.startsWith(`Error "Error: Unclosed root tag`))) {
1507
+ logger$1.info("RetryPolicy: Incomplete XML response likely due to service timeout, will retry.");
1508
+ return true;
1509
+ }
1510
+ return false;
1511
+ }
1512
+ /**
1513
+ * Delay a calculated time between retries.
1514
+ *
1515
+ * @param isPrimaryRetry -
1516
+ * @param attempt -
1517
+ * @param abortSignal -
1518
+ */
1519
+ async delay(isPrimaryRetry, attempt, abortSignal) {
1520
+ let delayTimeInMs = 0;
1521
+ if (isPrimaryRetry) {
1522
+ switch (this.retryOptions.retryPolicyType) {
1523
+ case exports.StorageRetryPolicyType.EXPONENTIAL:
1524
+ delayTimeInMs = Math.min((Math.pow(2, attempt - 1) - 1) * this.retryOptions.retryDelayInMs, this.retryOptions.maxRetryDelayInMs);
1525
+ break;
1526
+ case exports.StorageRetryPolicyType.FIXED:
1527
+ delayTimeInMs = this.retryOptions.retryDelayInMs;
1528
+ break;
1529
+ }
1530
+ }
1531
+ else {
1532
+ delayTimeInMs = Math.random() * 1000;
1533
+ }
1534
+ logger$1.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);
1535
+ return delay(delayTimeInMs, abortSignal, RETRY_ABORT_ERROR$1);
1536
+ }
1537
+ }
1538
+
1539
+ // Copyright (c) Microsoft Corporation.
1540
+ /**
1541
+ * StorageRetryPolicyFactory is a factory class helping generating {@link StorageRetryPolicy} objects.
1542
+ */
1543
+ class StorageRetryPolicyFactory {
1544
+ /**
1545
+ * Creates an instance of StorageRetryPolicyFactory.
1546
+ * @param retryOptions -
1547
+ */
1548
+ constructor(retryOptions) {
1549
+ this.retryOptions = retryOptions;
1550
+ }
1551
+ /**
1552
+ * Creates a StorageRetryPolicy object.
1553
+ *
1554
+ * @param nextPolicy -
1555
+ * @param options -
1556
+ */
1557
+ create(nextPolicy, options) {
1558
+ return new StorageRetryPolicy(nextPolicy, options, this.retryOptions);
1559
+ }
1560
+ }
1561
+
1562
+ // Copyright (c) Microsoft Corporation.
1563
+ let _defaultHttpClient;
1564
+ function getCachedDefaultHttpClient() {
1565
+ if (!_defaultHttpClient) {
1566
+ _defaultHttpClient = coreRestPipeline.createDefaultHttpClient();
1567
+ }
1568
+ return _defaultHttpClient;
1569
+ }
1570
+
1571
+ // Copyright (c) Microsoft Corporation.
1572
+ /**
1573
+ * The programmatic identifier of the StorageBrowserPolicy.
1574
+ */
1575
+ const storageBrowserPolicyName = "storageBrowserPolicy";
1576
+ /**
1577
+ * storageBrowserPolicy is a policy used to prevent browsers from caching requests
1578
+ * and to remove cookies and explicit content-length headers.
1579
+ */
1580
+ function storageBrowserPolicy() {
1581
+ return {
1582
+ name: storageBrowserPolicyName,
1583
+ async sendRequest(request, next) {
1584
+ if (coreUtil.isNode) {
1585
+ return next(request);
1586
+ }
1587
+ if (request.method === "GET" || request.method === "HEAD") {
1588
+ request.url = setURLParameter(request.url, URLConstants.Parameters.FORCE_BROWSER_NO_CACHE, new Date().getTime().toString());
1589
+ }
1590
+ request.headers.delete(HeaderConstants.COOKIE);
1591
+ // According to XHR standards, content-length should be fully controlled by browsers
1592
+ request.headers.delete(HeaderConstants.CONTENT_LENGTH);
1593
+ return next(request);
1594
+ },
1595
+ };
1596
+ }
1597
+
1598
+ // Copyright (c) Microsoft Corporation.
1599
+ /**
1600
+ * Name of the {@link storageRetryPolicy}
1601
+ */
1602
+ const storageRetryPolicyName = "storageRetryPolicy";
1603
+ /**
1604
+ * RetryPolicy types.
1605
+ */
1606
+ var StorageRetryPolicyType;
1607
+ (function (StorageRetryPolicyType) {
1608
+ /**
1609
+ * Exponential retry. Retry time delay grows exponentially.
1610
+ */
1611
+ StorageRetryPolicyType[StorageRetryPolicyType["EXPONENTIAL"] = 0] = "EXPONENTIAL";
1612
+ /**
1613
+ * Linear retry. Retry time delay grows linearly.
1394
1614
  */
1395
- shouldRetry(isPrimaryRetry, attempt, response, err) {
1396
- if (attempt >= this.retryOptions.maxTries) {
1397
- logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions
1398
- .maxTries}, no further try.`);
1615
+ StorageRetryPolicyType[StorageRetryPolicyType["FIXED"] = 1] = "FIXED";
1616
+ })(StorageRetryPolicyType || (StorageRetryPolicyType = {}));
1617
+ // Default values of StorageRetryOptions
1618
+ const DEFAULT_RETRY_OPTIONS = {
1619
+ maxRetryDelayInMs: 120 * 1000,
1620
+ maxTries: 4,
1621
+ retryDelayInMs: 4 * 1000,
1622
+ retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,
1623
+ secondaryHost: "",
1624
+ tryTimeoutInMs: undefined, // Use server side default timeout strategy
1625
+ };
1626
+ const retriableErrors = [
1627
+ "ETIMEDOUT",
1628
+ "ESOCKETTIMEDOUT",
1629
+ "ECONNREFUSED",
1630
+ "ECONNRESET",
1631
+ "ENOENT",
1632
+ "ENOTFOUND",
1633
+ "TIMEOUT",
1634
+ "EPIPE",
1635
+ "REQUEST_SEND_ERROR",
1636
+ ];
1637
+ const RETRY_ABORT_ERROR = new abortController.AbortError("The operation was aborted.");
1638
+ /**
1639
+ * Retry policy with exponential retry and linear retry implemented.
1640
+ */
1641
+ function storageRetryPolicy(options = {}) {
1642
+ var _a, _b, _c, _d, _e, _f;
1643
+ const retryPolicyType = (_a = options.retryPolicyType) !== null && _a !== void 0 ? _a : DEFAULT_RETRY_OPTIONS.retryPolicyType;
1644
+ const maxTries = (_b = options.maxTries) !== null && _b !== void 0 ? _b : DEFAULT_RETRY_OPTIONS.maxTries;
1645
+ const retryDelayInMs = (_c = options.retryDelayInMs) !== null && _c !== void 0 ? _c : DEFAULT_RETRY_OPTIONS.retryDelayInMs;
1646
+ const maxRetryDelayInMs = (_d = options.maxRetryDelayInMs) !== null && _d !== void 0 ? _d : DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs;
1647
+ const secondaryHost = (_e = options.secondaryHost) !== null && _e !== void 0 ? _e : DEFAULT_RETRY_OPTIONS.secondaryHost;
1648
+ const tryTimeoutInMs = (_f = options.tryTimeoutInMs) !== null && _f !== void 0 ? _f : DEFAULT_RETRY_OPTIONS.tryTimeoutInMs;
1649
+ function shouldRetry({ isPrimaryRetry, attempt, response, error, }) {
1650
+ var _a, _b;
1651
+ if (attempt >= maxTries) {
1652
+ logger$1.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${maxTries}, no further try.`);
1399
1653
  return false;
1400
1654
  }
1401
- // Handle network failures, you may need to customize the list when you implement
1402
- // your own http client
1403
- const retriableErrors = [
1404
- "ETIMEDOUT",
1405
- "ESOCKETTIMEDOUT",
1406
- "ECONNREFUSED",
1407
- "ECONNRESET",
1408
- "ENOENT",
1409
- "ENOTFOUND",
1410
- "TIMEOUT",
1411
- "EPIPE",
1412
- "REQUEST_SEND_ERROR", // For default xhr based http client provided in ms-rest-js
1413
- ];
1414
- if (err) {
1655
+ if (error) {
1415
1656
  for (const retriableError of retriableErrors) {
1416
- if (err.name.toUpperCase().includes(retriableError) ||
1417
- err.message.toUpperCase().includes(retriableError) ||
1418
- (err.code && err.code.toString().toUpperCase() === retriableError)) {
1419
- logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);
1657
+ if (error.name.toUpperCase().includes(retriableError) ||
1658
+ error.message.toUpperCase().includes(retriableError) ||
1659
+ (error.code && error.code.toString().toUpperCase() === retriableError)) {
1660
+ logger$1.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);
1420
1661
  return true;
1421
1662
  }
1422
1663
  }
1664
+ if ((error === null || error === void 0 ? void 0 : error.code) === "PARSE_ERROR" &&
1665
+ (error === null || error === void 0 ? void 0 : error.message.startsWith(`Error "Error: Unclosed root tag`))) {
1666
+ logger$1.info("RetryPolicy: Incomplete XML response likely due to service timeout, will retry.");
1667
+ return true;
1668
+ }
1423
1669
  }
1424
1670
  // If attempt was against the secondary & it returned a StatusNotFound (404), then
1425
1671
  // the resource was not found. This may be due to replication delay. So, in this
1426
1672
  // case, we'll never try the secondary again for this operation.
1427
- if (response || err) {
1428
- const statusCode = response ? response.status : err ? err.statusCode : 0;
1673
+ if (response || error) {
1674
+ const statusCode = (_b = (_a = response === null || response === void 0 ? void 0 : response.status) !== null && _a !== void 0 ? _a : error === null || error === void 0 ? void 0 : error.statusCode) !== null && _b !== void 0 ? _b : 0;
1429
1675
  if (!isPrimaryRetry && statusCode === 404) {
1430
- logger.info(`RetryPolicy: Secondary access with 404, will retry.`);
1676
+ logger$1.info(`RetryPolicy: Secondary access with 404, will retry.`);
1431
1677
  return true;
1432
1678
  }
1433
1679
  // Server internal error or server timeout
1434
1680
  if (statusCode === 503 || statusCode === 500) {
1435
- logger.info(`RetryPolicy: Will retry for status code ${statusCode}.`);
1681
+ logger$1.info(`RetryPolicy: Will retry for status code ${statusCode}.`);
1436
1682
  return true;
1437
1683
  }
1438
1684
  }
1439
- if ((err === null || err === void 0 ? void 0 : err.code) === "PARSE_ERROR" && (err === null || err === void 0 ? void 0 : err.message.startsWith(`Error "Error: Unclosed root tag`))) {
1440
- logger.info("RetryPolicy: Incomplete XML response likely due to service timeout, will retry.");
1441
- return true;
1442
- }
1443
1685
  return false;
1444
1686
  }
1445
- /**
1446
- * Delay a calculated time between retries.
1447
- *
1448
- * @param isPrimaryRetry -
1449
- * @param attempt -
1450
- * @param abortSignal -
1451
- */
1452
- async delay(isPrimaryRetry, attempt, abortSignal) {
1687
+ function calculateDelay(isPrimaryRetry, attempt) {
1453
1688
  let delayTimeInMs = 0;
1454
1689
  if (isPrimaryRetry) {
1455
- switch (this.retryOptions.retryPolicyType) {
1456
- case exports.StorageRetryPolicyType.EXPONENTIAL:
1457
- delayTimeInMs = Math.min((Math.pow(2, attempt - 1) - 1) * this.retryOptions.retryDelayInMs, this.retryOptions.maxRetryDelayInMs);
1690
+ switch (retryPolicyType) {
1691
+ case StorageRetryPolicyType.EXPONENTIAL:
1692
+ delayTimeInMs = Math.min((Math.pow(2, attempt - 1) - 1) * retryDelayInMs, maxRetryDelayInMs);
1458
1693
  break;
1459
- case exports.StorageRetryPolicyType.FIXED:
1460
- delayTimeInMs = this.retryOptions.retryDelayInMs;
1694
+ case StorageRetryPolicyType.FIXED:
1695
+ delayTimeInMs = retryDelayInMs;
1461
1696
  break;
1462
1697
  }
1463
1698
  }
1464
1699
  else {
1465
1700
  delayTimeInMs = Math.random() * 1000;
1466
1701
  }
1467
- logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);
1468
- return delay(delayTimeInMs, abortSignal, RETRY_ABORT_ERROR);
1702
+ logger$1.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);
1703
+ return delayTimeInMs;
1469
1704
  }
1705
+ return {
1706
+ name: storageRetryPolicyName,
1707
+ async sendRequest(request, next) {
1708
+ // Set the server-side timeout query parameter "timeout=[seconds]"
1709
+ if (tryTimeoutInMs) {
1710
+ request.url = setURLParameter(request.url, URLConstants.Parameters.TIMEOUT, String(Math.floor(tryTimeoutInMs / 1000)));
1711
+ }
1712
+ const primaryUrl = request.url;
1713
+ const secondaryUrl = secondaryHost ? setURLHost(request.url, secondaryHost) : undefined;
1714
+ let secondaryHas404 = false;
1715
+ let attempt = 1;
1716
+ let retryAgain = true;
1717
+ let response;
1718
+ let error;
1719
+ while (retryAgain) {
1720
+ const isPrimaryRetry = secondaryHas404 ||
1721
+ !secondaryUrl ||
1722
+ !["GET", "HEAD", "OPTIONS"].includes(request.method) ||
1723
+ attempt % 2 === 1;
1724
+ request.url = isPrimaryRetry ? primaryUrl : secondaryUrl;
1725
+ response = undefined;
1726
+ error = undefined;
1727
+ try {
1728
+ logger$1.info(`RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? "Primary" : "Secondary"}`);
1729
+ response = await next(request);
1730
+ secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);
1731
+ }
1732
+ catch (e) {
1733
+ if (coreRestPipeline.isRestError(e)) {
1734
+ logger$1.error(`RetryPolicy: Caught error, message: ${e.message}, code: ${e.code}`);
1735
+ error = e;
1736
+ }
1737
+ else {
1738
+ logger$1.error(`RetryPolicy: Caught error, message: ${coreUtil.getErrorMessage(e)}`);
1739
+ throw e;
1740
+ }
1741
+ }
1742
+ retryAgain = shouldRetry({ isPrimaryRetry, attempt, response, error });
1743
+ if (retryAgain) {
1744
+ await delay(calculateDelay(isPrimaryRetry, attempt), request.abortSignal, RETRY_ABORT_ERROR);
1745
+ }
1746
+ attempt++;
1747
+ }
1748
+ if (response) {
1749
+ return response;
1750
+ }
1751
+ throw error !== null && error !== void 0 ? error : new coreRestPipeline.RestError("RetryPolicy failed without known error.");
1752
+ },
1753
+ };
1470
1754
  }
1471
1755
 
1472
1756
  // Copyright (c) Microsoft Corporation.
1473
1757
  /**
1474
- * StorageRetryPolicyFactory is a factory class helping generating {@link StorageRetryPolicy} objects.
1758
+ * The programmatic identifier of the storageSharedKeyCredentialPolicy.
1475
1759
  */
1476
- class StorageRetryPolicyFactory {
1760
+ const storageSharedKeyCredentialPolicyName = "storageSharedKeyCredentialPolicy";
1761
+ /**
1762
+ * storageSharedKeyCredentialPolicy handles signing requests using storage account keys.
1763
+ */
1764
+ function storageSharedKeyCredentialPolicy(options) {
1765
+ function signRequest(request) {
1766
+ request.headers.set(HeaderConstants.X_MS_DATE, new Date().toUTCString());
1767
+ if (request.body &&
1768
+ (typeof request.body === "string" || Buffer.isBuffer(request.body)) &&
1769
+ request.body.length > 0) {
1770
+ request.headers.set(HeaderConstants.CONTENT_LENGTH, Buffer.byteLength(request.body));
1771
+ }
1772
+ const stringToSign = [
1773
+ request.method.toUpperCase(),
1774
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_LANGUAGE),
1775
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_ENCODING),
1776
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_LENGTH),
1777
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_MD5),
1778
+ getHeaderValueToSign(request, HeaderConstants.CONTENT_TYPE),
1779
+ getHeaderValueToSign(request, HeaderConstants.DATE),
1780
+ getHeaderValueToSign(request, HeaderConstants.IF_MODIFIED_SINCE),
1781
+ getHeaderValueToSign(request, HeaderConstants.IF_MATCH),
1782
+ getHeaderValueToSign(request, HeaderConstants.IF_NONE_MATCH),
1783
+ getHeaderValueToSign(request, HeaderConstants.IF_UNMODIFIED_SINCE),
1784
+ getHeaderValueToSign(request, HeaderConstants.RANGE),
1785
+ ].join("\n") +
1786
+ "\n" +
1787
+ getCanonicalizedHeadersString(request) +
1788
+ getCanonicalizedResourceString(request);
1789
+ const signature = crypto.createHmac("sha256", options.accountKey)
1790
+ .update(stringToSign, "utf8")
1791
+ .digest("base64");
1792
+ request.headers.set(HeaderConstants.AUTHORIZATION, `SharedKey ${options.accountName}:${signature}`);
1793
+ // console.log(`[URL]:${request.url}`);
1794
+ // console.log(`[HEADERS]:${request.headers.toString()}`);
1795
+ // console.log(`[STRING TO SIGN]:${JSON.stringify(stringToSign)}`);
1796
+ // console.log(`[KEY]: ${request.headers.get(HeaderConstants.AUTHORIZATION)}`);
1797
+ }
1477
1798
  /**
1478
- * Creates an instance of StorageRetryPolicyFactory.
1479
- * @param retryOptions -
1799
+ * Retrieve header value according to shared key sign rules.
1800
+ * @see https://docs.microsoft.com/en-us/rest/api/storageservices/authenticate-with-shared-key
1480
1801
  */
1481
- constructor(retryOptions) {
1482
- this.retryOptions = retryOptions;
1802
+ function getHeaderValueToSign(request, headerName) {
1803
+ const value = request.headers.get(headerName);
1804
+ if (!value) {
1805
+ return "";
1806
+ }
1807
+ // When using version 2015-02-21 or later, if Content-Length is zero, then
1808
+ // set the Content-Length part of the StringToSign to an empty string.
1809
+ // https://docs.microsoft.com/en-us/rest/api/storageservices/authenticate-with-shared-key
1810
+ if (headerName === HeaderConstants.CONTENT_LENGTH && value === "0") {
1811
+ return "";
1812
+ }
1813
+ return value;
1483
1814
  }
1484
1815
  /**
1485
- * Creates a {@link StorageRetryPolicy} object.
1816
+ * To construct the CanonicalizedHeaders portion of the signature string, follow these steps:
1817
+ * 1. Retrieve all headers for the resource that begin with x-ms-, including the x-ms-date header.
1818
+ * 2. Convert each HTTP header name to lowercase.
1819
+ * 3. Sort the headers lexicographically by header name, in ascending order.
1820
+ * Each header may appear only once in the string.
1821
+ * 4. Replace any linear whitespace in the header value with a single space.
1822
+ * 5. Trim any whitespace around the colon in the header.
1823
+ * 6. Finally, append a new-line character to each canonicalized header in the resulting list.
1824
+ * Construct the CanonicalizedHeaders string by concatenating all headers in this list into a single string.
1486
1825
  *
1487
- * @param nextPolicy -
1488
- * @param options -
1489
1826
  */
1490
- create(nextPolicy, options) {
1491
- return new StorageRetryPolicy(nextPolicy, options, this.retryOptions);
1827
+ function getCanonicalizedHeadersString(request) {
1828
+ let headersArray = [];
1829
+ for (const [name, value] of request.headers) {
1830
+ if (name.toLowerCase().startsWith(HeaderConstants.PREFIX_FOR_STORAGE)) {
1831
+ headersArray.push({ name, value });
1832
+ }
1833
+ }
1834
+ headersArray.sort((a, b) => {
1835
+ return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
1836
+ });
1837
+ // Remove duplicate headers
1838
+ headersArray = headersArray.filter((value, index, array) => {
1839
+ if (index > 0 && value.name.toLowerCase() === array[index - 1].name.toLowerCase()) {
1840
+ return false;
1841
+ }
1842
+ return true;
1843
+ });
1844
+ let canonicalizedHeadersStringToSign = "";
1845
+ headersArray.forEach((header) => {
1846
+ canonicalizedHeadersStringToSign += `${header.name
1847
+ .toLowerCase()
1848
+ .trimRight()}:${header.value.trimLeft()}\n`;
1849
+ });
1850
+ return canonicalizedHeadersStringToSign;
1851
+ }
1852
+ function getCanonicalizedResourceString(request) {
1853
+ const path = getURLPath(request.url) || "/";
1854
+ let canonicalizedResourceString = "";
1855
+ canonicalizedResourceString += `/${options.accountName}${path}`;
1856
+ const queries = getURLQueries(request.url);
1857
+ const lowercaseQueries = {};
1858
+ if (queries) {
1859
+ const queryKeys = [];
1860
+ for (const key in queries) {
1861
+ if (Object.prototype.hasOwnProperty.call(queries, key)) {
1862
+ const lowercaseKey = key.toLowerCase();
1863
+ lowercaseQueries[lowercaseKey] = queries[key];
1864
+ queryKeys.push(lowercaseKey);
1865
+ }
1866
+ }
1867
+ queryKeys.sort();
1868
+ for (const key of queryKeys) {
1869
+ canonicalizedResourceString += `\n${key}:${decodeURIComponent(lowercaseQueries[key])}`;
1870
+ }
1871
+ }
1872
+ return canonicalizedResourceString;
1492
1873
  }
1874
+ return {
1875
+ name: storageSharedKeyCredentialPolicyName,
1876
+ async sendRequest(request, next) {
1877
+ signRequest(request);
1878
+ return next(request);
1879
+ },
1880
+ };
1493
1881
  }
1494
1882
 
1495
1883
  // Copyright (c) Microsoft Corporation.
1496
1884
  /**
1497
- * TelemetryPolicy is a policy used to tag user-agent header for every requests.
1885
+ * StorageBrowserPolicy will handle differences between Node.js and browser runtime, including:
1886
+ *
1887
+ * 1. Browsers cache GET/HEAD requests by adding conditional headers such as 'IF_MODIFIED_SINCE'.
1888
+ * StorageBrowserPolicy is a policy used to add a timestamp query to GET/HEAD request URL
1889
+ * thus avoid the browser cache.
1890
+ *
1891
+ * 2. Remove cookie header for security
1892
+ *
1893
+ * 3. Remove content-length header to avoid browsers warning
1498
1894
  */
1499
- class TelemetryPolicy extends coreHttp.BaseRequestPolicy {
1895
+ class StorageBrowserPolicy extends BaseRequestPolicy {
1500
1896
  /**
1501
- * Creates an instance of TelemetryPolicy.
1897
+ * Creates an instance of StorageBrowserPolicy.
1502
1898
  * @param nextPolicy -
1503
1899
  * @param options -
1504
- * @param telemetry -
1505
1900
  */
1506
- constructor(nextPolicy, options, telemetry) {
1901
+ // The base class has a protected constructor. Adding a public one to enable constructing of this class.
1902
+ /* eslint-disable-next-line @typescript-eslint/no-useless-constructor*/
1903
+ constructor(nextPolicy, options) {
1507
1904
  super(nextPolicy, options);
1508
- this.telemetry = telemetry;
1509
1905
  }
1510
1906
  /**
1511
1907
  * Sends out request.
@@ -1513,76 +1909,57 @@ class TelemetryPolicy extends coreHttp.BaseRequestPolicy {
1513
1909
  * @param request -
1514
1910
  */
1515
1911
  async sendRequest(request) {
1516
- if (coreHttp.isNode) {
1517
- if (!request.headers) {
1518
- request.headers = new coreHttp.HttpHeaders();
1519
- }
1520
- if (!request.headers.get(HeaderConstants.USER_AGENT)) {
1521
- request.headers.set(HeaderConstants.USER_AGENT, this.telemetry);
1522
- }
1912
+ if (coreUtil.isNode) {
1913
+ return this._nextPolicy.sendRequest(request);
1914
+ }
1915
+ if (request.method.toUpperCase() === "GET" || request.method.toUpperCase() === "HEAD") {
1916
+ request.url = setURLParameter(request.url, URLConstants.Parameters.FORCE_BROWSER_NO_CACHE, new Date().getTime().toString());
1523
1917
  }
1918
+ request.headers.remove(HeaderConstants.COOKIE);
1919
+ // According to XHR standards, content-length should be fully controlled by browsers
1920
+ request.headers.remove(HeaderConstants.CONTENT_LENGTH);
1524
1921
  return this._nextPolicy.sendRequest(request);
1525
1922
  }
1526
1923
  }
1527
1924
 
1528
1925
  // Copyright (c) Microsoft Corporation.
1529
1926
  /**
1530
- * TelemetryPolicyFactory is a factory class helping generating {@link TelemetryPolicy} objects.
1927
+ * StorageBrowserPolicyFactory is a factory class helping generating StorageBrowserPolicy objects.
1531
1928
  */
1532
- class TelemetryPolicyFactory {
1533
- /**
1534
- * Creates an instance of TelemetryPolicyFactory.
1535
- * @param telemetry -
1536
- */
1537
- constructor(telemetry) {
1538
- const userAgentInfo = [];
1539
- if (coreHttp.isNode) {
1540
- if (telemetry) {
1541
- const telemetryString = telemetry.userAgentPrefix || "";
1542
- if (telemetryString.length > 0 && userAgentInfo.indexOf(telemetryString) === -1) {
1543
- userAgentInfo.push(telemetryString);
1544
- }
1545
- }
1546
- // e.g. azsdk-js-storagequeue/11.0.0
1547
- const libInfo = `azsdk-js-storagequeue/${SDK_VERSION}`;
1548
- if (userAgentInfo.indexOf(libInfo) === -1) {
1549
- userAgentInfo.push(libInfo);
1550
- }
1551
- // e.g. (NODE-VERSION 4.9.1; Windows_NT 10.0.16299)
1552
- let runtimeInfo = `(NODE-VERSION ${process.version})`;
1553
- if (os__namespace) {
1554
- runtimeInfo = `(NODE-VERSION ${process.version}; ${os__namespace.type()} ${os__namespace.release()})`;
1555
- }
1556
- if (userAgentInfo.indexOf(runtimeInfo) === -1) {
1557
- userAgentInfo.push(runtimeInfo);
1558
- }
1559
- }
1560
- this.telemetryString = userAgentInfo.join(" ");
1561
- }
1929
+ class StorageBrowserPolicyFactory {
1562
1930
  /**
1563
- * Creates a {@link TelemetryPolicy} object.
1931
+ * Creates a StorageBrowserPolicyFactory object.
1564
1932
  *
1565
1933
  * @param nextPolicy -
1566
1934
  * @param options -
1567
1935
  */
1568
1936
  create(nextPolicy, options) {
1569
- return new TelemetryPolicy(nextPolicy, options, this.telemetryString);
1937
+ return new StorageBrowserPolicy(nextPolicy, options);
1570
1938
  }
1571
1939
  }
1572
1940
 
1573
1941
  // Copyright (c) Microsoft Corporation.
1574
- const _defaultHttpClient = new coreHttp.DefaultHttpClient();
1575
- function getCachedDefaultHttpClient() {
1576
- return _defaultHttpClient;
1942
+ /**
1943
+ * A helper to decide if a given argument satisfies the Pipeline contract
1944
+ * @param pipeline - An argument that may be a Pipeline
1945
+ * @returns true when the argument satisfies the Pipeline contract
1946
+ */
1947
+ function isPipelineLike(pipeline) {
1948
+ if (!pipeline || typeof pipeline !== "object") {
1949
+ return false;
1950
+ }
1951
+ const castPipeline = pipeline;
1952
+ return (Array.isArray(castPipeline.factories) &&
1953
+ typeof castPipeline.options === "object" &&
1954
+ typeof castPipeline.toServiceClientOptions === "function");
1577
1955
  }
1578
-
1579
- // Copyright (c) Microsoft Corporation.
1580
1956
  /**
1581
1957
  * A Pipeline class containing HTTP request policies.
1582
- * You can create a default Pipeline by calling newPipeline().
1958
+ * You can create a default Pipeline by calling {@link newPipeline}.
1583
1959
  * Or you can create a Pipeline with your own policies by the constructor of Pipeline.
1584
- * Refer to newPipeline() and provided policies as reference before
1585
- * implementing your customized Pipeline.
1960
+ *
1961
+ * Refer to {@link newPipeline} and provided policies before implementing your
1962
+ * customized Pipeline.
1586
1963
  */
1587
1964
  class Pipeline {
1588
1965
  /**
@@ -1593,12 +1970,10 @@ class Pipeline {
1593
1970
  */
1594
1971
  constructor(factories, options = {}) {
1595
1972
  this.factories = factories;
1596
- // when options.httpClient is not specified, passing in a DefaultHttpClient instance to
1597
- // avoid each client creating its own http client.
1598
- this.options = Object.assign(Object.assign({}, options), { httpClient: options.httpClient || getCachedDefaultHttpClient() });
1973
+ this.options = options;
1599
1974
  }
1600
1975
  /**
1601
- * Transfers Pipeline object to ServiceClientOptions object which required by
1976
+ * Transfer Pipeline object to ServiceClientOptions object which is required by
1602
1977
  * ServiceClient constructor.
1603
1978
  *
1604
1979
  * @returns The ServiceClientOptions object from this Pipeline.
@@ -1614,39 +1989,192 @@ class Pipeline {
1614
1989
  * Creates a new Pipeline object with Credential provided.
1615
1990
  *
1616
1991
  * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
1617
- * @param pipelineOptions - Options.
1992
+ * @param pipelineOptions - Optional. Options.
1618
1993
  * @returns A new Pipeline object.
1619
1994
  */
1620
1995
  function newPipeline(credential, pipelineOptions = {}) {
1621
- if (credential === undefined) {
1996
+ if (!credential) {
1622
1997
  credential = new AnonymousCredential();
1623
1998
  }
1624
- // Order is important. Closer to the API at the top & closer to the network at the bottom.
1625
- // The credential's policy factory must appear close to the wire so it can sign any
1626
- // changes made by other factories (like UniqueRequestIDPolicyFactory)
1627
- const telemetryPolicy = new TelemetryPolicyFactory(pipelineOptions.userAgentOptions);
1628
- const factories = [
1629
- coreHttp.tracingPolicy({ userAgent: telemetryPolicy.telemetryString }),
1630
- coreHttp.keepAlivePolicy(pipelineOptions.keepAliveOptions),
1631
- telemetryPolicy,
1632
- coreHttp.generateClientRequestIdPolicy(),
1633
- new StorageBrowserPolicyFactory(),
1634
- new StorageRetryPolicyFactory(pipelineOptions.retryOptions),
1635
- coreHttp.deserializationPolicy(),
1636
- coreHttp.logPolicy({
1637
- logger: logger.info,
1638
- allowedHeaderNames: StorageQueueLoggingAllowedHeaderNames,
1639
- allowedQueryParameters: StorageQueueLoggingAllowedQueryParameters,
1640
- }),
1999
+ const pipeline = new Pipeline([], pipelineOptions);
2000
+ pipeline._credential = credential;
2001
+ return pipeline;
2002
+ }
2003
+ function processDownlevelPipeline(pipeline) {
2004
+ const knownFactoryFunctions = [
2005
+ isAnonymousCredential,
2006
+ isStorageSharedKeyCredential,
2007
+ isCoreHttpBearerTokenFactory,
2008
+ isStorageBrowserPolicyFactory,
2009
+ isStorageRetryPolicyFactory,
2010
+ isStorageTelemetryPolicyFactory,
2011
+ isCoreHttpPolicyFactory,
2012
+ ];
2013
+ if (pipeline.factories.length) {
2014
+ const novelFactories = pipeline.factories.filter((factory) => {
2015
+ return !knownFactoryFunctions.some((knownFactory) => knownFactory(factory));
2016
+ });
2017
+ if (novelFactories.length) {
2018
+ const hasInjector = novelFactories.some((factory) => isInjectorPolicyFactory(factory));
2019
+ // if there are any left over, wrap in a requestPolicyFactoryPolicy
2020
+ return {
2021
+ wrappedPolicies: coreHttpCompat.createRequestPolicyFactoryPolicy(novelFactories),
2022
+ afterRetry: hasInjector,
2023
+ };
2024
+ }
2025
+ }
2026
+ return undefined;
2027
+ }
2028
+ function getCoreClientOptions(pipeline) {
2029
+ var _a;
2030
+ const _b = pipeline.options, { httpClient: v1Client } = _b, restOptions = tslib.__rest(_b, ["httpClient"]);
2031
+ let httpClient = pipeline._coreHttpClient;
2032
+ if (!httpClient) {
2033
+ httpClient = v1Client ? coreHttpCompat.convertHttpClient(v1Client) : getCachedDefaultHttpClient();
2034
+ pipeline._coreHttpClient = httpClient;
2035
+ }
2036
+ let corePipeline = pipeline._corePipeline;
2037
+ if (!corePipeline) {
2038
+ const packageDetails = `azsdk-js-azure-storage-blob/${SDK_VERSION}`;
2039
+ const userAgentPrefix = restOptions.userAgentOptions && restOptions.userAgentOptions.userAgentPrefix
2040
+ ? `${restOptions.userAgentOptions.userAgentPrefix} ${packageDetails}`
2041
+ : `${packageDetails}`;
2042
+ corePipeline = coreClient.createClientPipeline(Object.assign(Object.assign({}, restOptions), { loggingOptions: {
2043
+ additionalAllowedHeaderNames: StorageBlobLoggingAllowedHeaderNames,
2044
+ additionalAllowedQueryParameters: StorageBlobLoggingAllowedQueryParameters,
2045
+ logger: logger$1.info,
2046
+ }, userAgentOptions: {
2047
+ userAgentPrefix,
2048
+ }, serializationOptions: {
2049
+ stringifyXML: coreXml.stringifyXML,
2050
+ serializerOptions: {
2051
+ xml: {
2052
+ // Use customized XML char key of "#" so we can deserialize metadata
2053
+ // with "_" key
2054
+ xmlCharKey: "#",
2055
+ },
2056
+ },
2057
+ }, deserializationOptions: {
2058
+ parseXML: coreXml.parseXML,
2059
+ serializerOptions: {
2060
+ xml: {
2061
+ // Use customized XML char key of "#" so we can deserialize metadata
2062
+ // with "_" key
2063
+ xmlCharKey: "#",
2064
+ },
2065
+ },
2066
+ } }));
2067
+ corePipeline.removePolicy({ phase: "Retry" });
2068
+ corePipeline.removePolicy({ name: coreRestPipeline.decompressResponsePolicyName });
2069
+ corePipeline.addPolicy(storageRetryPolicy(restOptions.retryOptions), { phase: "Retry" });
2070
+ corePipeline.addPolicy(storageBrowserPolicy());
2071
+ const downlevelResults = processDownlevelPipeline(pipeline);
2072
+ if (downlevelResults) {
2073
+ corePipeline.addPolicy(downlevelResults.wrappedPolicies, downlevelResults.afterRetry ? { afterPhase: "Retry" } : undefined);
2074
+ }
2075
+ const credential = getCredentialFromPipeline(pipeline);
2076
+ if (coreAuth.isTokenCredential(credential)) {
2077
+ corePipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({
2078
+ credential,
2079
+ scopes: (_a = restOptions.audience) !== null && _a !== void 0 ? _a : StorageOAuthScopes,
2080
+ challengeCallbacks: { authorizeRequestOnChallenge: coreClient.authorizeRequestOnTenantChallenge },
2081
+ }), { phase: "Sign" });
2082
+ }
2083
+ else if (credential instanceof StorageSharedKeyCredential) {
2084
+ corePipeline.addPolicy(storageSharedKeyCredentialPolicy({
2085
+ accountName: credential.accountName,
2086
+ accountKey: credential.accountKey,
2087
+ }), { phase: "Sign" });
2088
+ }
2089
+ pipeline._corePipeline = corePipeline;
2090
+ }
2091
+ return Object.assign(Object.assign({}, restOptions), { httpClient, pipeline: corePipeline });
2092
+ }
2093
+ function getCredentialFromPipeline(pipeline) {
2094
+ // see if we squirreled one away on the type itself
2095
+ if (pipeline._credential) {
2096
+ return pipeline._credential;
2097
+ }
2098
+ // if it came from another package, loop over the factories and look for one like before
2099
+ let credential = new AnonymousCredential();
2100
+ for (const factory of pipeline.factories) {
2101
+ if (coreAuth.isTokenCredential(factory.credential)) {
2102
+ // Only works if the factory has been attached a "credential" property.
2103
+ // We do that in newPipeline() when using TokenCredential.
2104
+ credential = factory.credential;
2105
+ }
2106
+ else if (isStorageSharedKeyCredential(factory)) {
2107
+ return factory;
2108
+ }
2109
+ }
2110
+ return credential;
2111
+ }
2112
+ function isStorageSharedKeyCredential(factory) {
2113
+ if (factory instanceof StorageSharedKeyCredential) {
2114
+ return true;
2115
+ }
2116
+ return factory.constructor.name === "StorageSharedKeyCredential";
2117
+ }
2118
+ function isAnonymousCredential(factory) {
2119
+ if (factory instanceof AnonymousCredential) {
2120
+ return true;
2121
+ }
2122
+ return factory.constructor.name === "AnonymousCredential";
2123
+ }
2124
+ function isCoreHttpBearerTokenFactory(factory) {
2125
+ return coreAuth.isTokenCredential(factory.credential);
2126
+ }
2127
+ function isStorageBrowserPolicyFactory(factory) {
2128
+ if (factory instanceof StorageBrowserPolicyFactory) {
2129
+ return true;
2130
+ }
2131
+ return factory.constructor.name === "StorageBrowserPolicyFactory";
2132
+ }
2133
+ function isStorageRetryPolicyFactory(factory) {
2134
+ if (factory instanceof StorageRetryPolicyFactory) {
2135
+ return true;
2136
+ }
2137
+ return factory.constructor.name === "StorageRetryPolicyFactory";
2138
+ }
2139
+ function isStorageTelemetryPolicyFactory(factory) {
2140
+ return factory.constructor.name === "TelemetryPolicyFactory";
2141
+ }
2142
+ function isInjectorPolicyFactory(factory) {
2143
+ return factory.constructor.name === "InjectorPolicyFactory";
2144
+ }
2145
+ function isCoreHttpPolicyFactory(factory) {
2146
+ const knownPolicies = [
2147
+ "GenerateClientRequestIdPolicy",
2148
+ "TracingPolicy",
2149
+ "LogPolicy",
2150
+ "ProxyPolicy",
2151
+ "DisableResponseDecompressionPolicy",
2152
+ "KeepAlivePolicy",
2153
+ "DeserializationPolicy",
1641
2154
  ];
1642
- if (coreHttp.isNode) {
1643
- // ProxyPolicy is only available in Node.js runtime, not in browsers
1644
- factories.push(coreHttp.proxyPolicy(pipelineOptions.proxyOptions));
1645
- }
1646
- factories.push(coreHttp.isTokenCredential(credential)
1647
- ? coreHttp.bearerTokenAuthenticationPolicy(credential, StorageOAuthScopes)
1648
- : credential);
1649
- return new Pipeline(factories, pipelineOptions);
2155
+ const mockHttpClient = {
2156
+ sendRequest: async (request) => {
2157
+ return {
2158
+ request,
2159
+ headers: request.headers.clone(),
2160
+ status: 500,
2161
+ };
2162
+ },
2163
+ };
2164
+ const mockRequestPolicyOptions = {
2165
+ log(_logLevel, _message) {
2166
+ /* do nothing */
2167
+ },
2168
+ shouldLog(_logLevel) {
2169
+ return false;
2170
+ },
2171
+ };
2172
+ const policyInstance = factory.create(mockHttpClient, mockRequestPolicyOptions);
2173
+ const policyName = policyInstance.constructor.name;
2174
+ // bundlers sometimes add a custom suffix to the class name to make it unique
2175
+ return knownPolicies.some((knownPolicyName) => {
2176
+ return policyName.startsWith(knownPolicyName);
2177
+ });
1650
2178
  }
1651
2179
 
1652
2180
  /*
@@ -2667,12 +3195,12 @@ const QueueGetPropertiesHeaders = {
2667
3195
  modelProperties: {
2668
3196
  metadata: {
2669
3197
  serializedName: "x-ms-meta",
3198
+ headerCollectionPrefix: "x-ms-meta-",
2670
3199
  xmlName: "x-ms-meta",
2671
3200
  type: {
2672
3201
  name: "Dictionary",
2673
3202
  value: { type: { name: "String" } }
2674
- },
2675
- headerCollectionPrefix: "x-ms-meta-"
3203
+ }
2676
3204
  },
2677
3205
  approximateMessagesCount: {
2678
3206
  serializedName: "x-ms-approximate-messages-count",
@@ -3495,7 +4023,7 @@ const timeoutInSeconds = {
3495
4023
  const version = {
3496
4024
  parameterPath: "version",
3497
4025
  mapper: {
3498
- defaultValue: "2022-11-02",
4026
+ defaultValue: "2021-10-04",
3499
4027
  isConstant: true,
3500
4028
  serializedName: "x-ms-version",
3501
4029
  type: {
@@ -3596,18 +4124,18 @@ const include = {
3596
4124
  }
3597
4125
  }
3598
4126
  },
3599
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
4127
+ collectionFormat: "CSV"
3600
4128
  };
3601
4129
  const metadata = {
3602
4130
  parameterPath: ["options", "metadata"],
3603
4131
  mapper: {
3604
4132
  serializedName: "x-ms-meta",
3605
4133
  xmlName: "x-ms-meta",
4134
+ headerCollectionPrefix: "x-ms-meta-",
3606
4135
  type: {
3607
4136
  name: "Dictionary",
3608
4137
  value: { type: { name: "String" } }
3609
- },
3610
- headerCollectionPrefix: "x-ms-meta-"
4138
+ }
3611
4139
  }
3612
4140
  };
3613
4141
  const comp3 = {
@@ -3743,8 +4271,8 @@ const visibilityTimeout1 = {
3743
4271
  * Code generated by Microsoft (R) AutoRest Code Generator.
3744
4272
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
3745
4273
  */
3746
- /** Class representing a Service. */
3747
- class Service {
4274
+ /** Class containing Service operations. */
4275
+ class ServiceImpl {
3748
4276
  /**
3749
4277
  * Initialize a new instance of the class Service class.
3750
4278
  * @param client Reference to the service client
@@ -3759,11 +4287,7 @@ class Service {
3759
4287
  * @param options The options parameters.
3760
4288
  */
3761
4289
  setProperties(properties, options) {
3762
- const operationArguments = {
3763
- properties,
3764
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3765
- };
3766
- return this.client.sendOperationRequest(operationArguments, setPropertiesOperationSpec);
4290
+ return this.client.sendOperationRequest({ properties, options }, setPropertiesOperationSpec);
3767
4291
  }
3768
4292
  /**
3769
4293
  * gets the properties of a storage account's Queue service, including properties for Storage Analytics
@@ -3771,10 +4295,7 @@ class Service {
3771
4295
  * @param options The options parameters.
3772
4296
  */
3773
4297
  getProperties(options) {
3774
- const operationArguments = {
3775
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3776
- };
3777
- return this.client.sendOperationRequest(operationArguments, getPropertiesOperationSpec$1);
4298
+ return this.client.sendOperationRequest({ options }, getPropertiesOperationSpec$1);
3778
4299
  }
3779
4300
  /**
3780
4301
  * Retrieves statistics related to replication for the Queue service. It is only available on the
@@ -3783,24 +4304,18 @@ class Service {
3783
4304
  * @param options The options parameters.
3784
4305
  */
3785
4306
  getStatistics(options) {
3786
- const operationArguments = {
3787
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3788
- };
3789
- return this.client.sendOperationRequest(operationArguments, getStatisticsOperationSpec);
4307
+ return this.client.sendOperationRequest({ options }, getStatisticsOperationSpec);
3790
4308
  }
3791
4309
  /**
3792
4310
  * The List Queues Segment operation returns a list of the queues under the specified account
3793
4311
  * @param options The options parameters.
3794
4312
  */
3795
4313
  listQueuesSegment(options) {
3796
- const operationArguments = {
3797
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3798
- };
3799
- return this.client.sendOperationRequest(operationArguments, listQueuesSegmentOperationSpec);
4314
+ return this.client.sendOperationRequest({ options }, listQueuesSegmentOperationSpec);
3800
4315
  }
3801
4316
  }
3802
4317
  // Operation Specifications
3803
- const xmlSerializer$3 = new coreHttp__namespace.Serializer(Mappers, /* isXml */ true);
4318
+ const xmlSerializer$3 = coreClient__namespace.createSerializer(Mappers, /* isXml */ true);
3804
4319
  const setPropertiesOperationSpec = {
3805
4320
  path: "/",
3806
4321
  httpMethod: "PUT",
@@ -3923,8 +4438,8 @@ const listQueuesSegmentOperationSpec = {
3923
4438
  * Code generated by Microsoft (R) AutoRest Code Generator.
3924
4439
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
3925
4440
  */
3926
- /** Class representing a Queue. */
3927
- class Queue {
4441
+ /** Class containing Queue operations. */
4442
+ class QueueImpl {
3928
4443
  /**
3929
4444
  * Initialize a new instance of the class Queue class.
3930
4445
  * @param client Reference to the service client
@@ -3937,20 +4452,14 @@ class Queue {
3937
4452
  * @param options The options parameters.
3938
4453
  */
3939
4454
  create(options) {
3940
- const operationArguments = {
3941
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3942
- };
3943
- return this.client.sendOperationRequest(operationArguments, createOperationSpec);
4455
+ return this.client.sendOperationRequest({ options }, createOperationSpec);
3944
4456
  }
3945
4457
  /**
3946
4458
  * operation permanently deletes the specified queue
3947
4459
  * @param options The options parameters.
3948
4460
  */
3949
4461
  delete(options) {
3950
- const operationArguments = {
3951
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3952
- };
3953
- return this.client.sendOperationRequest(operationArguments, deleteOperationSpec$1);
4462
+ return this.client.sendOperationRequest({ options }, deleteOperationSpec$1);
3954
4463
  }
3955
4464
  /**
3956
4465
  * Retrieves user-defined metadata and queue properties on the specified queue. Metadata is associated
@@ -3958,10 +4467,7 @@ class Queue {
3958
4467
  * @param options The options parameters.
3959
4468
  */
3960
4469
  getProperties(options) {
3961
- const operationArguments = {
3962
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3963
- };
3964
- return this.client.sendOperationRequest(operationArguments, getPropertiesOperationSpec);
4470
+ return this.client.sendOperationRequest({ options }, getPropertiesOperationSpec);
3965
4471
  }
3966
4472
  /**
3967
4473
  * sets user-defined metadata on the specified queue. Metadata is associated with the queue as
@@ -3969,10 +4475,7 @@ class Queue {
3969
4475
  * @param options The options parameters.
3970
4476
  */
3971
4477
  setMetadata(options) {
3972
- const operationArguments = {
3973
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3974
- };
3975
- return this.client.sendOperationRequest(operationArguments, setMetadataOperationSpec);
4478
+ return this.client.sendOperationRequest({ options }, setMetadataOperationSpec);
3976
4479
  }
3977
4480
  /**
3978
4481
  * returns details about any stored access policies specified on the queue that may be used with Shared
@@ -3980,24 +4483,18 @@ class Queue {
3980
4483
  * @param options The options parameters.
3981
4484
  */
3982
4485
  getAccessPolicy(options) {
3983
- const operationArguments = {
3984
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3985
- };
3986
- return this.client.sendOperationRequest(operationArguments, getAccessPolicyOperationSpec);
4486
+ return this.client.sendOperationRequest({ options }, getAccessPolicyOperationSpec);
3987
4487
  }
3988
4488
  /**
3989
4489
  * sets stored access policies for the queue that may be used with Shared Access Signatures
3990
4490
  * @param options The options parameters.
3991
4491
  */
3992
4492
  setAccessPolicy(options) {
3993
- const operationArguments = {
3994
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
3995
- };
3996
- return this.client.sendOperationRequest(operationArguments, setAccessPolicyOperationSpec);
4493
+ return this.client.sendOperationRequest({ options }, setAccessPolicyOperationSpec);
3997
4494
  }
3998
4495
  }
3999
4496
  // Operation Specifications
4000
- const xmlSerializer$2 = new coreHttp__namespace.Serializer(Mappers, /* isXml */ true);
4497
+ const xmlSerializer$2 = coreClient__namespace.createSerializer(Mappers, /* isXml */ true);
4001
4498
  const createOperationSpec = {
4002
4499
  path: "/{queueName}",
4003
4500
  httpMethod: "PUT",
@@ -4159,8 +4656,8 @@ const setAccessPolicyOperationSpec = {
4159
4656
  * Code generated by Microsoft (R) AutoRest Code Generator.
4160
4657
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
4161
4658
  */
4162
- /** Class representing a Messages. */
4163
- class Messages {
4659
+ /** Class containing Messages operations. */
4660
+ class MessagesImpl {
4164
4661
  /**
4165
4662
  * Initialize a new instance of the class Messages class.
4166
4663
  * @param client Reference to the service client
@@ -4173,20 +4670,14 @@ class Messages {
4173
4670
  * @param options The options parameters.
4174
4671
  */
4175
4672
  dequeue(options) {
4176
- const operationArguments = {
4177
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
4178
- };
4179
- return this.client.sendOperationRequest(operationArguments, dequeueOperationSpec);
4673
+ return this.client.sendOperationRequest({ options }, dequeueOperationSpec);
4180
4674
  }
4181
4675
  /**
4182
4676
  * The Clear operation deletes all messages from the specified queue.
4183
4677
  * @param options The options parameters.
4184
4678
  */
4185
4679
  clear(options) {
4186
- const operationArguments = {
4187
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
4188
- };
4189
- return this.client.sendOperationRequest(operationArguments, clearOperationSpec);
4680
+ return this.client.sendOperationRequest({ options }, clearOperationSpec);
4190
4681
  }
4191
4682
  /**
4192
4683
  * The Enqueue operation adds a new message to the back of the message queue. A visibility timeout can
@@ -4197,11 +4688,7 @@ class Messages {
4197
4688
  * @param options The options parameters.
4198
4689
  */
4199
4690
  enqueue(queueMessage, options) {
4200
- const operationArguments = {
4201
- queueMessage,
4202
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
4203
- };
4204
- return this.client.sendOperationRequest(operationArguments, enqueueOperationSpec);
4691
+ return this.client.sendOperationRequest({ queueMessage, options }, enqueueOperationSpec);
4205
4692
  }
4206
4693
  /**
4207
4694
  * The Peek operation retrieves one or more messages from the front of the queue, but does not alter
@@ -4209,14 +4696,11 @@ class Messages {
4209
4696
  * @param options The options parameters.
4210
4697
  */
4211
4698
  peek(options) {
4212
- const operationArguments = {
4213
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
4214
- };
4215
- return this.client.sendOperationRequest(operationArguments, peekOperationSpec);
4699
+ return this.client.sendOperationRequest({ options }, peekOperationSpec);
4216
4700
  }
4217
4701
  }
4218
4702
  // Operation Specifications
4219
- const xmlSerializer$1 = new coreHttp__namespace.Serializer(Mappers, /* isXml */ true);
4703
+ const xmlSerializer$1 = coreClient__namespace.createSerializer(Mappers, /* isXml */ true);
4220
4704
  const dequeueOperationSpec = {
4221
4705
  path: "/{queueName}/messages",
4222
4706
  httpMethod: "GET",
@@ -4363,8 +4847,8 @@ const peekOperationSpec = {
4363
4847
  * Code generated by Microsoft (R) AutoRest Code Generator.
4364
4848
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
4365
4849
  */
4366
- /** Class representing a MessageId. */
4367
- class MessageId {
4850
+ /** Class containing MessageId operations. */
4851
+ class MessageIdImpl {
4368
4852
  /**
4369
4853
  * Initialize a new instance of the class MessageId class.
4370
4854
  * @param client Reference to the service client
@@ -4387,12 +4871,7 @@ class MessageId {
4387
4871
  * @param options The options parameters.
4388
4872
  */
4389
4873
  update(popReceipt, visibilityTimeout, options) {
4390
- const operationArguments = {
4391
- popReceipt,
4392
- visibilityTimeout,
4393
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
4394
- };
4395
- return this.client.sendOperationRequest(operationArguments, updateOperationSpec);
4874
+ return this.client.sendOperationRequest({ popReceipt, visibilityTimeout, options }, updateOperationSpec);
4396
4875
  }
4397
4876
  /**
4398
4877
  * The Delete operation deletes the specified message.
@@ -4401,15 +4880,11 @@ class MessageId {
4401
4880
  * @param options The options parameters.
4402
4881
  */
4403
4882
  delete(popReceipt, options) {
4404
- const operationArguments = {
4405
- popReceipt,
4406
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
4407
- };
4408
- return this.client.sendOperationRequest(operationArguments, deleteOperationSpec);
4883
+ return this.client.sendOperationRequest({ popReceipt, options }, deleteOperationSpec);
4409
4884
  }
4410
4885
  }
4411
4886
  // Operation Specifications
4412
- const xmlSerializer = new coreHttp__namespace.Serializer(Mappers, /* isXml */ true);
4887
+ const xmlSerializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ true);
4413
4888
  const updateOperationSpec = {
4414
4889
  path: "/{queueName}/messages/{messageid}",
4415
4890
  httpMethod: "PUT",
@@ -4463,6 +4938,67 @@ const deleteOperationSpec = {
4463
4938
  serializer: xmlSerializer
4464
4939
  };
4465
4940
 
4941
+ /*
4942
+ * Copyright (c) Microsoft Corporation.
4943
+ * Licensed under the MIT License.
4944
+ *
4945
+ * Code generated by Microsoft (R) AutoRest Code Generator.
4946
+ * Changes may cause incorrect behavior and will be lost if the code is regenerated.
4947
+ */
4948
+ class StorageClient$1 extends coreHttpCompat__namespace.ExtendedServiceClient {
4949
+ /**
4950
+ * Initializes a new instance of the StorageClient class.
4951
+ * @param url The URL of the service account, queue or message that is the target of the desired
4952
+ * operation.
4953
+ * @param options The parameter options
4954
+ */
4955
+ constructor(url, options) {
4956
+ var _a, _b;
4957
+ if (url === undefined) {
4958
+ throw new Error("'url' cannot be null");
4959
+ }
4960
+ // Initializing default values for options
4961
+ if (!options) {
4962
+ options = {};
4963
+ }
4964
+ const defaults = {
4965
+ requestContentType: "application/json; charset=utf-8"
4966
+ };
4967
+ const packageDetails = `azsdk-js-azure-storage-queue/12.20.0`;
4968
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
4969
+ ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
4970
+ : `${packageDetails}`;
4971
+ const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
4972
+ userAgentPrefix
4973
+ }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{url}" });
4974
+ super(optionsWithDefaults);
4975
+ // Parameter assignments
4976
+ this.url = url;
4977
+ // Assigning values to Constant parameters
4978
+ this.version = options.version || "2021-10-04";
4979
+ this.service = new ServiceImpl(this);
4980
+ this.queue = new QueueImpl(this);
4981
+ this.messages = new MessagesImpl(this);
4982
+ this.messageId = new MessageIdImpl(this);
4983
+ }
4984
+ }
4985
+
4986
+ // Copyright (c) Microsoft Corporation.
4987
+ /**
4988
+ * @internal
4989
+ */
4990
+ class StorageContextClient extends StorageClient$1 {
4991
+ async sendOperationRequest(operationArguments, operationSpec) {
4992
+ const operationSpecToSend = Object.assign({}, operationSpec);
4993
+ if (operationSpecToSend.path === "/{queueName}" ||
4994
+ operationSpecToSend.path === "/{queueName}/messages" ||
4995
+ operationSpecToSend.path === "/{queueName}/messages/{messageid}") {
4996
+ operationSpecToSend.path = "";
4997
+ }
4998
+ return super.sendOperationRequest(operationArguments, operationSpecToSend);
4999
+ }
5000
+ }
5001
+
4466
5002
  // Copyright (c) Microsoft Corporation.
4467
5003
  /**
4468
5004
  * A StorageClient represents a based client class for {@link QueueServiceClient}, {@link QueueClient} and etc.
@@ -4477,29 +5013,28 @@ class StorageClient {
4477
5013
  this.url = url;
4478
5014
  this.accountName = getAccountNameFromUrl(url);
4479
5015
  this.pipeline = pipeline;
4480
- this.storageClientContext = getStorageClientContext(url, pipeline);
4481
- // Retrieve credential from the pipeline.
4482
- this.credential = new AnonymousCredential();
4483
- for (const factory of this.pipeline.factories) {
4484
- if ((coreHttp.isNode && factory instanceof StorageSharedKeyCredential) ||
4485
- factory instanceof AnonymousCredential) {
4486
- this.credential = factory;
4487
- break;
4488
- }
4489
- else {
4490
- try {
4491
- const authPolicy = factory.create();
4492
- if (authPolicy.constructor.name === "BearerTokenAuthenticationPolicy") {
4493
- this.credential = factory;
4494
- break;
4495
- }
4496
- }
4497
- catch (err) {
4498
- // ignore errors in creating policy, the client instance may still work without the policy.
4499
- }
4500
- }
4501
- }
5016
+ this.storageClientContext = getStorageClientContext(this.url, this.pipeline);
5017
+ this.credential = getCredentialFromPipeline(pipeline);
5018
+ }
5019
+ }
5020
+ /**
5021
+ * @internal
5022
+ */
5023
+ function getStorageClientContext(url, pipeline) {
5024
+ const pipelineOptions = pipeline.options;
5025
+ // Set maximum timeout for queue operations.
5026
+ // This was previously set manually in the retry policy specific to this package.
5027
+ // https://docs.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations
5028
+ if (pipelineOptions.retryOptions === undefined) {
5029
+ pipelineOptions.retryOptions = {
5030
+ tryTimeoutInMs: 30 * 1000,
5031
+ };
4502
5032
  }
5033
+ else if (pipelineOptions.retryOptions.tryTimeoutInMs === undefined) {
5034
+ pipelineOptions.retryOptions.tryTimeoutInMs = 30 * 1000;
5035
+ }
5036
+ const coreOptions = getCoreClientOptions(pipeline);
5037
+ return new StorageContextClient(url, coreOptions);
4503
5038
  }
4504
5039
 
4505
5040
  // Copyright (c) Microsoft Corporation.
@@ -4507,8 +5042,9 @@ class StorageClient {
4507
5042
  * Creates a span using the global tracer.
4508
5043
  * @internal
4509
5044
  */
4510
- const createSpan = coreTracing.createSpanFunction({
4511
- packagePrefix: "Azure.Storage.Queue",
5045
+ const tracingClient = coreTracing.createTracingClient({
5046
+ packageName: "@azure/storage-queue",
5047
+ packageVersion: SDK_VERSION$1,
4512
5048
  namespace: "Microsoft.Storage",
4513
5049
  });
4514
5050
 
@@ -4651,6 +5187,12 @@ function getCanonicalName(accountName, queueName) {
4651
5187
  * A QueueClient represents a URL to an Azure Storage Queue's messages allowing you to manipulate its messages.
4652
5188
  */
4653
5189
  class QueueClient extends StorageClient {
5190
+ /**
5191
+ * The name of the queue.
5192
+ */
5193
+ get name() {
5194
+ return this._name;
5195
+ }
4654
5196
  constructor(urlOrConnectionString, credentialOrPipelineOrQueueName,
4655
5197
  // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
4656
5198
  /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
@@ -4663,9 +5205,9 @@ class QueueClient extends StorageClient {
4663
5205
  url = urlOrConnectionString;
4664
5206
  pipeline = credentialOrPipelineOrQueueName;
4665
5207
  }
4666
- else if ((coreHttp.isNode && credentialOrPipelineOrQueueName instanceof StorageSharedKeyCredential) ||
5208
+ else if ((coreUtil.isNode && credentialOrPipelineOrQueueName instanceof StorageSharedKeyCredential) ||
4667
5209
  credentialOrPipelineOrQueueName instanceof AnonymousCredential ||
4668
- coreHttp.isTokenCredential(credentialOrPipelineOrQueueName)) {
5210
+ coreAuth.isTokenCredential(credentialOrPipelineOrQueueName)) {
4669
5211
  // (url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)
4670
5212
  url = urlOrConnectionString;
4671
5213
  pipeline = newPipeline(credentialOrPipelineOrQueueName, options);
@@ -4673,7 +5215,7 @@ class QueueClient extends StorageClient {
4673
5215
  else if (!credentialOrPipelineOrQueueName &&
4674
5216
  typeof credentialOrPipelineOrQueueName !== "string") {
4675
5217
  // (url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)
4676
- // The second paramter is undefined. Use anonymous credential.
5218
+ // The second parameter is undefined. Use anonymous credential.
4677
5219
  url = urlOrConnectionString;
4678
5220
  pipeline = newPipeline(new AnonymousCredential(), options);
4679
5221
  }
@@ -4682,12 +5224,12 @@ class QueueClient extends StorageClient {
4682
5224
  // (connectionString: string, containerName: string, queueName: string, options?: StoragePipelineOptions)
4683
5225
  const extractedCreds = extractConnectionStringParts(urlOrConnectionString);
4684
5226
  if (extractedCreds.kind === "AccountConnString") {
4685
- if (coreHttp.isNode) {
5227
+ if (coreUtil.isNode) {
4686
5228
  const queueName = credentialOrPipelineOrQueueName;
4687
5229
  const sharedKeyCredential = new StorageSharedKeyCredential(extractedCreds.accountName, extractedCreds.accountKey);
4688
5230
  url = appendToURLPath(extractedCreds.url, queueName);
4689
5231
  if (!options.proxyOptions) {
4690
- options.proxyOptions = coreHttp.getDefaultProxySettings(extractedCreds.proxyUri);
5232
+ options.proxyOptions = coreRestPipeline.getDefaultProxySettings(extractedCreds.proxyUri);
4691
5233
  }
4692
5234
  pipeline = newPipeline(sharedKeyCredential, options);
4693
5235
  }
@@ -4709,20 +5251,14 @@ class QueueClient extends StorageClient {
4709
5251
  }
4710
5252
  super(url, pipeline);
4711
5253
  this._name = this.getQueueNameFromUrl();
4712
- this.queueContext = new Queue(this.storageClientContext);
5254
+ this.queueContext = this.storageClientContext.queue;
4713
5255
  // MessagesContext
4714
5256
  // Build the url with "messages"
4715
5257
  const partsOfUrl = this.url.split("?");
4716
5258
  this._messagesUrl = partsOfUrl[1]
4717
5259
  ? appendToURLPath(partsOfUrl[0], "messages") + "?" + partsOfUrl[1]
4718
5260
  : appendToURLPath(partsOfUrl[0], "messages");
4719
- this.messagesContext = new Messages(getStorageClientContext(this._messagesUrl, this.pipeline));
4720
- }
4721
- /**
4722
- * The name of the queue.
4723
- */
4724
- get name() {
4725
- return this._name;
5261
+ this.messagesContext = getStorageClientContext(this._messagesUrl, this.pipeline).messages;
4726
5262
  }
4727
5263
  getMessageIdContext(messageId) {
4728
5264
  // Build the url with messageId
@@ -4730,7 +5266,7 @@ class QueueClient extends StorageClient {
4730
5266
  const urlWithMessageId = partsOfUrl[1]
4731
5267
  ? appendToURLPath(partsOfUrl[0], messageId) + "?" + partsOfUrl[1]
4732
5268
  : appendToURLPath(partsOfUrl[0], messageId);
4733
- return new MessageId(getStorageClientContext(urlWithMessageId, this.pipeline));
5269
+ return getStorageClientContext(urlWithMessageId, this.pipeline).messageId;
4734
5270
  }
4735
5271
  /**
4736
5272
  * Creates a new queue under the specified account.
@@ -4747,20 +5283,9 @@ class QueueClient extends StorageClient {
4747
5283
  * ```
4748
5284
  */
4749
5285
  async create(options = {}) {
4750
- const { span, updatedOptions } = createSpan("QueueClient-create", options);
4751
- try {
4752
- return await this.queueContext.create(Object.assign(Object.assign({}, updatedOptions), { abortSignal: options.abortSignal }));
4753
- }
4754
- catch (e) {
4755
- span.setStatus({
4756
- code: coreTracing.SpanStatusCode.ERROR,
4757
- message: e.message,
4758
- });
4759
- throw e;
4760
- }
4761
- finally {
4762
- span.end();
4763
- }
5286
+ return tracingClient.withSpan("QueueClient-create", options, async (updatedOptions) => {
5287
+ return assertResponse(await this.queueContext.create(updatedOptions));
5288
+ });
4764
5289
  }
4765
5290
  /**
4766
5291
  * Creates a new queue under the specified account if it doesn't already exist.
@@ -4770,35 +5295,25 @@ class QueueClient extends StorageClient {
4770
5295
  * @param options -
4771
5296
  */
4772
5297
  async createIfNotExists(options = {}) {
4773
- var _a, _b;
4774
- const { span, updatedOptions } = createSpan("QueueClient-createIfNotExists", options);
4775
- try {
4776
- const response = await this.create(updatedOptions);
4777
- // When a queue with the specified name already exists, the Queue service checks the metadata associated with the existing queue.
4778
- // If the existing metadata is identical to the metadata specified on the Create Queue request, status code 204 (No Content) is returned.
4779
- // If the existing metadata does not match, the operation fails and status code 409 (Conflict) is returned.
4780
- if (response._response.status === 204) {
4781
- return Object.assign({ succeeded: false }, response);
5298
+ return tracingClient.withSpan("QueueClient-createIfNotExists", options, async (updatedOptions) => {
5299
+ var _a, _b;
5300
+ try {
5301
+ const response = await this.create(updatedOptions);
5302
+ // When a queue with the specified name already exists, the Queue service checks the metadata associated with the existing queue.
5303
+ // If the existing metadata is identical to the metadata specified on the Create Queue request, status code 204 (No Content) is returned.
5304
+ // If the existing metadata does not match, the operation fails and status code 409 (Conflict) is returned.
5305
+ if (response._response.status === 204) {
5306
+ return Object.assign({ succeeded: false }, response);
5307
+ }
5308
+ return Object.assign({ succeeded: true }, response);
4782
5309
  }
4783
- return Object.assign({ succeeded: true }, response);
4784
- }
4785
- catch (e) {
4786
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "QueueAlreadyExists") {
4787
- span.setStatus({
4788
- code: coreTracing.SpanStatusCode.ERROR,
4789
- message: "Expected exception when creating a queue only if it does not already exist.",
4790
- });
4791
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
5310
+ catch (e) {
5311
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "QueueAlreadyExists") {
5312
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
5313
+ }
5314
+ throw e;
4792
5315
  }
4793
- span.setStatus({
4794
- code: coreTracing.SpanStatusCode.ERROR,
4795
- message: e.message,
4796
- });
4797
- throw e;
4798
- }
4799
- finally {
4800
- span.end();
4801
- }
5316
+ });
4802
5317
  }
4803
5318
  /**
4804
5319
  * Deletes the specified queue permanently if it exists.
@@ -4807,29 +5322,19 @@ class QueueClient extends StorageClient {
4807
5322
  * @param options -
4808
5323
  */
4809
5324
  async deleteIfExists(options = {}) {
4810
- var _a, _b;
4811
- const { span, updatedOptions } = createSpan("QueueClient-deleteIfExists", options);
4812
- try {
4813
- const res = await this.delete(updatedOptions);
4814
- return Object.assign({ succeeded: true }, res);
4815
- }
4816
- catch (e) {
4817
- if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "QueueNotFound") {
4818
- span.setStatus({
4819
- code: coreTracing.SpanStatusCode.ERROR,
4820
- message: "Expected exception when deleting a queue only if it exists.",
4821
- });
4822
- return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
5325
+ return tracingClient.withSpan("QueueClient-deleteIfExists", options, async (updatedOptions) => {
5326
+ var _a, _b;
5327
+ try {
5328
+ const res = await this.delete(updatedOptions);
5329
+ return Object.assign({ succeeded: true }, res);
4823
5330
  }
4824
- span.setStatus({
4825
- code: coreTracing.SpanStatusCode.ERROR,
4826
- message: e.message,
4827
- });
4828
- throw e;
4829
- }
4830
- finally {
4831
- span.end();
4832
- }
5331
+ catch (e) {
5332
+ if (((_a = e.details) === null || _a === void 0 ? void 0 : _a.errorCode) === "QueueNotFound") {
5333
+ return Object.assign(Object.assign({ succeeded: false }, (_b = e.response) === null || _b === void 0 ? void 0 : _b.parsedHeaders), { _response: e.response });
5334
+ }
5335
+ throw e;
5336
+ }
5337
+ });
4833
5338
  }
4834
5339
  /**
4835
5340
  * Deletes the specified queue permanently.
@@ -4848,23 +5353,12 @@ class QueueClient extends StorageClient {
4848
5353
  * ```
4849
5354
  */
4850
5355
  async delete(options = {}) {
4851
- const { span, updatedOptions } = createSpan("QueueClient-delete", options);
4852
- try {
4853
- return await this.queueContext.delete({
5356
+ return tracingClient.withSpan("QueueClient-delete", options, async (updatedOptions) => {
5357
+ return assertResponse(await this.queueContext.delete({
4854
5358
  abortSignal: options.abortSignal,
4855
5359
  tracingOptions: updatedOptions.tracingOptions,
4856
- });
4857
- }
4858
- catch (e) {
4859
- span.setStatus({
4860
- code: coreTracing.SpanStatusCode.ERROR,
4861
- message: e.message,
4862
- });
4863
- throw e;
4864
- }
4865
- finally {
4866
- span.end();
4867
- }
5360
+ }));
5361
+ });
4868
5362
  }
4869
5363
  /**
4870
5364
  * Returns true if the specified queue exists; false otherwise.
@@ -4876,31 +5370,18 @@ class QueueClient extends StorageClient {
4876
5370
  * @param options - options to Exists operation.
4877
5371
  */
4878
5372
  async exists(options = {}) {
4879
- const { span, updatedOptions } = createSpan("QueueClient-exists", options);
4880
- try {
4881
- await this.getProperties({
4882
- abortSignal: options.abortSignal,
4883
- tracingOptions: updatedOptions.tracingOptions,
4884
- });
4885
- return true;
4886
- }
4887
- catch (e) {
4888
- if (e.statusCode === 404) {
4889
- span.setStatus({
4890
- code: coreTracing.SpanStatusCode.ERROR,
4891
- message: "Expected exception when checking queue existence",
4892
- });
4893
- return false;
5373
+ return tracingClient.withSpan("QueueClient-exists", options, async (updatedOptions) => {
5374
+ try {
5375
+ await this.getProperties(updatedOptions);
5376
+ return true;
4894
5377
  }
4895
- span.setStatus({
4896
- code: coreTracing.SpanStatusCode.ERROR,
4897
- message: e.message,
4898
- });
4899
- throw e;
4900
- }
4901
- finally {
4902
- span.end();
4903
- }
5378
+ catch (e) {
5379
+ if (e.statusCode === 404) {
5380
+ return false;
5381
+ }
5382
+ throw e;
5383
+ }
5384
+ });
4904
5385
  }
4905
5386
  /**
4906
5387
  * Gets all user-defined metadata and system properties for the specified
@@ -4916,23 +5397,9 @@ class QueueClient extends StorageClient {
4916
5397
  * @returns Response data for the Queue get properties operation.
4917
5398
  */
4918
5399
  async getProperties(options = {}) {
4919
- const { span, updatedOptions } = createSpan("QueueClient-getProperties", options);
4920
- try {
4921
- return await this.queueContext.getProperties({
4922
- abortSignal: options.abortSignal,
4923
- tracingOptions: updatedOptions.tracingOptions,
4924
- });
4925
- }
4926
- catch (e) {
4927
- span.setStatus({
4928
- code: coreTracing.SpanStatusCode.ERROR,
4929
- message: e.message,
4930
- });
4931
- throw e;
4932
- }
4933
- finally {
4934
- span.end();
4935
- }
5400
+ return tracingClient.withSpan("QueueClient-getProperties", options, async (updatedOptions) => {
5401
+ return assertResponse(await this.queueContext.getProperties(updatedOptions));
5402
+ });
4936
5403
  }
4937
5404
  /**
4938
5405
  * Sets one or more user-defined name-value pairs for the specified queue.
@@ -4946,24 +5413,9 @@ class QueueClient extends StorageClient {
4946
5413
  * @returns Response data for the Queue set metadata operation.
4947
5414
  */
4948
5415
  async setMetadata(metadata, options = {}) {
4949
- const { span, updatedOptions } = createSpan("QueueClient-setMetadata", options);
4950
- try {
4951
- return await this.queueContext.setMetadata({
4952
- abortSignal: options.abortSignal,
4953
- metadata,
4954
- tracingOptions: updatedOptions.tracingOptions,
4955
- });
4956
- }
4957
- catch (e) {
4958
- span.setStatus({
4959
- code: coreTracing.SpanStatusCode.ERROR,
4960
- message: e.message,
4961
- });
4962
- throw e;
4963
- }
4964
- finally {
4965
- span.end();
4966
- }
5416
+ return tracingClient.withSpan("QueueClient-setMetadata", options, async (updatedOptions) => {
5417
+ return assertResponse(await this.queueContext.setMetadata(Object.assign(Object.assign({}, updatedOptions), { metadata })));
5418
+ });
4967
5419
  }
4968
5420
  /**
4969
5421
  * Gets details about any stored access policies specified on the queue that may be used with Shared Access Signatures.
@@ -4977,12 +5429,11 @@ class QueueClient extends StorageClient {
4977
5429
  * @returns Response data for the Queue get access policy operation.
4978
5430
  */
4979
5431
  async getAccessPolicy(options = {}) {
4980
- const { span, updatedOptions } = createSpan("QueueClient-getAccessPolicy", options);
4981
- try {
4982
- const response = await this.queueContext.getAccessPolicy({
5432
+ return tracingClient.withSpan("QueueClient-getAccessPolicy", options, async (updatedOptions) => {
5433
+ const response = assertResponse(await this.queueContext.getAccessPolicy({
4983
5434
  abortSignal: options.abortSignal,
4984
5435
  tracingOptions: updatedOptions.tracingOptions,
4985
- });
5436
+ }));
4986
5437
  const res = {
4987
5438
  _response: response._response,
4988
5439
  date: response.date,
@@ -5011,17 +5462,7 @@ class QueueClient extends StorageClient {
5011
5462
  });
5012
5463
  }
5013
5464
  return res;
5014
- }
5015
- catch (e) {
5016
- span.setStatus({
5017
- code: coreTracing.SpanStatusCode.ERROR,
5018
- message: e.message,
5019
- });
5020
- throw e;
5021
- }
5022
- finally {
5023
- span.end();
5024
- }
5465
+ });
5025
5466
  }
5026
5467
  /**
5027
5468
  * Sets stored access policies for the queue that may be used with Shared Access Signatures.
@@ -5032,8 +5473,7 @@ class QueueClient extends StorageClient {
5032
5473
  * @returns Response data for the Queue set access policy operation.
5033
5474
  */
5034
5475
  async setAccessPolicy(queueAcl, options = {}) {
5035
- const { span, updatedOptions } = createSpan("QueueClient-setAccessPolicy", options);
5036
- try {
5476
+ return tracingClient.withSpan("QueueClient-setAccessPolicy", options, async (updatedOptions) => {
5037
5477
  const acl = [];
5038
5478
  for (const identifier of queueAcl || []) {
5039
5479
  acl.push({
@@ -5049,22 +5489,8 @@ class QueueClient extends StorageClient {
5049
5489
  id: identifier.id,
5050
5490
  });
5051
5491
  }
5052
- return await this.queueContext.setAccessPolicy({
5053
- abortSignal: options.abortSignal,
5054
- queueAcl: acl,
5055
- tracingOptions: updatedOptions.tracingOptions,
5056
- });
5057
- }
5058
- catch (e) {
5059
- span.setStatus({
5060
- code: coreTracing.SpanStatusCode.ERROR,
5061
- message: e.message,
5062
- });
5063
- throw e;
5064
- }
5065
- finally {
5066
- span.end();
5067
- }
5492
+ return assertResponse(await this.queueContext.setAccessPolicy(Object.assign(Object.assign({}, updatedOptions), { queueAcl: acl })));
5493
+ });
5068
5494
  }
5069
5495
  /**
5070
5496
  * Clear deletes all messages from a queue.
@@ -5074,23 +5500,9 @@ class QueueClient extends StorageClient {
5074
5500
  * @returns Response data for the clear messages operation.
5075
5501
  */
5076
5502
  async clearMessages(options = {}) {
5077
- const { span, updatedOptions } = createSpan("QueueClient-clearMessages", options);
5078
- try {
5079
- return await this.messagesContext.clear({
5080
- abortSignal: options.abortSignal,
5081
- tracingOptions: updatedOptions.tracingOptions,
5082
- });
5083
- }
5084
- catch (e) {
5085
- span.setStatus({
5086
- code: coreTracing.SpanStatusCode.ERROR,
5087
- message: e.message,
5088
- });
5089
- throw e;
5090
- }
5091
- finally {
5092
- span.end();
5093
- }
5503
+ return tracingClient.withSpan("QueueClient-clearMessages", options, async (updatedOptions) => {
5504
+ return assertResponse(await this.messagesContext.clear(updatedOptions));
5505
+ });
5094
5506
  }
5095
5507
  /**
5096
5508
  * sendMessage adds a new message to the back of a queue. The visibility timeout specifies how long
@@ -5114,11 +5526,10 @@ class QueueClient extends StorageClient {
5114
5526
  * ```
5115
5527
  */
5116
5528
  async sendMessage(messageText, options = {}) {
5117
- const { span, updatedOptions } = createSpan("QueueClient-sendMessage", options);
5118
- try {
5119
- const response = await this.messagesContext.enqueue({
5529
+ return tracingClient.withSpan("QueueClient-sendMessage", options, async (updatedOptions) => {
5530
+ const response = assertResponse(await this.messagesContext.enqueue({
5120
5531
  messageText: messageText,
5121
- }, updatedOptions);
5532
+ }, updatedOptions));
5122
5533
  const item = response[0];
5123
5534
  return {
5124
5535
  _response: response._response,
@@ -5133,17 +5544,7 @@ class QueueClient extends StorageClient {
5133
5544
  insertedOn: item.insertedOn,
5134
5545
  expiresOn: item.expiresOn,
5135
5546
  };
5136
- }
5137
- catch (e) {
5138
- span.setStatus({
5139
- code: coreTracing.SpanStatusCode.ERROR,
5140
- message: e.message,
5141
- });
5142
- throw e;
5143
- }
5144
- finally {
5145
- span.end();
5146
- }
5547
+ });
5147
5548
  }
5148
5549
  /**
5149
5550
  * receiveMessages retrieves one or more messages from the front of the queue.
@@ -5171,9 +5572,8 @@ class QueueClient extends StorageClient {
5171
5572
  * ```
5172
5573
  */
5173
5574
  async receiveMessages(options = {}) {
5174
- const { span, updatedOptions } = createSpan("QueueClient-receiveMessages", options);
5175
- try {
5176
- const response = await this.messagesContext.dequeue(updatedOptions);
5575
+ return tracingClient.withSpan("QueueClient-receiveMessages", options, async (updatedOptions) => {
5576
+ const response = assertResponse(await this.messagesContext.dequeue(updatedOptions));
5177
5577
  const res = {
5178
5578
  _response: response._response,
5179
5579
  date: response.date,
@@ -5187,17 +5587,7 @@ class QueueClient extends StorageClient {
5187
5587
  res.receivedMessageItems.push(item);
5188
5588
  }
5189
5589
  return res;
5190
- }
5191
- catch (e) {
5192
- span.setStatus({
5193
- code: coreTracing.SpanStatusCode.ERROR,
5194
- message: e.message,
5195
- });
5196
- throw e;
5197
- }
5198
- finally {
5199
- span.end();
5200
- }
5590
+ });
5201
5591
  }
5202
5592
  /**
5203
5593
  * peekMessages retrieves one or more messages from the front of the queue but does not alter the visibility of the message.
@@ -5214,9 +5604,8 @@ class QueueClient extends StorageClient {
5214
5604
  * ```
5215
5605
  */
5216
5606
  async peekMessages(options = {}) {
5217
- const { span, updatedOptions } = createSpan("QueueClient-peekMessages", options);
5218
- try {
5219
- const response = await this.messagesContext.peek(updatedOptions);
5607
+ return tracingClient.withSpan("QueueClient-peekMessages", options, async (updatedOptions) => {
5608
+ const response = assertResponse(await this.messagesContext.peek(updatedOptions));
5220
5609
  const res = {
5221
5610
  _response: response._response,
5222
5611
  date: response.date,
@@ -5230,17 +5619,7 @@ class QueueClient extends StorageClient {
5230
5619
  res.peekedMessageItems.push(item);
5231
5620
  }
5232
5621
  return res;
5233
- }
5234
- catch (e) {
5235
- span.setStatus({
5236
- code: coreTracing.SpanStatusCode.ERROR,
5237
- message: e.message,
5238
- });
5239
- throw e;
5240
- }
5241
- finally {
5242
- span.end();
5243
- }
5622
+ });
5244
5623
  }
5245
5624
  /**
5246
5625
  * deleteMessage permanently removes the specified message from its queue.
@@ -5252,23 +5631,9 @@ class QueueClient extends StorageClient {
5252
5631
  * @returns Response data for the delete message operation.
5253
5632
  */
5254
5633
  async deleteMessage(messageId, popReceipt, options = {}) {
5255
- const { span, updatedOptions } = createSpan("QueueClient-deleteMessage", options);
5256
- try {
5257
- return await this.getMessageIdContext(messageId).delete(popReceipt, {
5258
- abortSignal: options.abortSignal,
5259
- tracingOptions: updatedOptions.tracingOptions,
5260
- });
5261
- }
5262
- catch (e) {
5263
- span.setStatus({
5264
- code: coreTracing.SpanStatusCode.ERROR,
5265
- message: e.message,
5266
- });
5267
- throw e;
5268
- }
5269
- finally {
5270
- span.end();
5271
- }
5634
+ return tracingClient.withSpan("QueueClient-deleteMessage", options, async (updatedOptions) => {
5635
+ return assertResponse(await this.getMessageIdContext(messageId).delete(popReceipt, updatedOptions));
5636
+ });
5272
5637
  }
5273
5638
  /**
5274
5639
  * Update changes a message's visibility timeout and contents.
@@ -5288,28 +5653,17 @@ class QueueClient extends StorageClient {
5288
5653
  * @returns Response data for the update message operation.
5289
5654
  */
5290
5655
  async updateMessage(messageId, popReceipt, message, visibilityTimeout, options = {}) {
5291
- const { span, updatedOptions } = createSpan("QueueClient-updateMessage", options);
5292
- let queueMessage = undefined;
5293
- if (message !== undefined) {
5294
- queueMessage = { messageText: message };
5295
- }
5296
- try {
5297
- return await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, {
5656
+ return tracingClient.withSpan("QueueClient-updateMessage", options, async (updatedOptions) => {
5657
+ let queueMessage = undefined;
5658
+ if (message !== undefined) {
5659
+ queueMessage = { messageText: message };
5660
+ }
5661
+ return assertResponse(await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, {
5298
5662
  abortSignal: options.abortSignal,
5299
5663
  tracingOptions: updatedOptions.tracingOptions,
5300
5664
  queueMessage,
5301
- });
5302
- }
5303
- catch (e) {
5304
- span.setStatus({
5305
- code: coreTracing.SpanStatusCode.ERROR,
5306
- message: e.message,
5307
- });
5308
- throw e;
5309
- }
5310
- finally {
5311
- span.end();
5312
- }
5665
+ }));
5666
+ });
5313
5667
  }
5314
5668
  getQueueNameFromUrl() {
5315
5669
  let queueName;
@@ -5319,22 +5673,22 @@ class QueueClient extends StorageClient {
5319
5673
  // "https://myaccount.queue.core.windows.net/myqueue".
5320
5674
  // IPv4/IPv6 address hosts, Endpoints - `http://127.0.0.1:10001/devstoreaccount1/myqueue`
5321
5675
  // http://localhost:10001/devstoreaccount1/queuename
5322
- const parsedUrl = coreHttp.URLBuilder.parse(this.url);
5323
- if (parsedUrl.getHost().split(".")[1] === "queue") {
5676
+ const parsedUrl = new URL(this.url);
5677
+ if (parsedUrl.hostname.split(".")[1] === "queue") {
5324
5678
  // "https://myaccount.queue.core.windows.net/queuename".
5325
5679
  // .getPath() -> /queuename
5326
- queueName = parsedUrl.getPath().split("/")[1];
5680
+ queueName = parsedUrl.pathname.split("/")[1];
5327
5681
  }
5328
5682
  else if (isIpEndpointStyle(parsedUrl)) {
5329
5683
  // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/queuename
5330
5684
  // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/queuename
5331
5685
  // .getPath() -> /devstoreaccount1/queuename
5332
- queueName = parsedUrl.getPath().split("/")[2];
5686
+ queueName = parsedUrl.pathname.split("/")[2];
5333
5687
  }
5334
5688
  else {
5335
5689
  // "https://customdomain.com/queuename".
5336
5690
  // .getPath() -> /queuename
5337
- queueName = parsedUrl.getPath().split("/")[1];
5691
+ queueName = parsedUrl.pathname.split("/")[1];
5338
5692
  }
5339
5693
  if (!queueName) {
5340
5694
  throw new Error("Provided queueName is invalid.");
@@ -5371,26 +5725,6 @@ class QueueClient extends StorageClient {
5371
5725
  * to manipulate queues.
5372
5726
  */
5373
5727
  class QueueServiceClient extends StorageClient {
5374
- constructor(url, credentialOrPipeline,
5375
- // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
5376
- /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
5377
- options) {
5378
- let pipeline;
5379
- if (credentialOrPipeline instanceof Pipeline) {
5380
- pipeline = credentialOrPipeline;
5381
- }
5382
- else if ((coreHttp.isNode && credentialOrPipeline instanceof StorageSharedKeyCredential) ||
5383
- credentialOrPipeline instanceof AnonymousCredential ||
5384
- coreHttp.isTokenCredential(credentialOrPipeline)) {
5385
- pipeline = newPipeline(credentialOrPipeline, options);
5386
- }
5387
- else {
5388
- // The second paramter is undefined. Use anonymous credential.
5389
- pipeline = newPipeline(new AnonymousCredential(), options);
5390
- }
5391
- super(url, pipeline);
5392
- this.serviceContext = new Service(this.storageClientContext);
5393
- }
5394
5728
  /**
5395
5729
  * Creates an instance of QueueServiceClient.
5396
5730
  *
@@ -5410,10 +5744,10 @@ class QueueServiceClient extends StorageClient {
5410
5744
  options = options || {};
5411
5745
  const extractedCreds = extractConnectionStringParts(connectionString);
5412
5746
  if (extractedCreds.kind === "AccountConnString") {
5413
- if (coreHttp.isNode) {
5747
+ if (coreUtil.isNode) {
5414
5748
  const sharedKeyCredential = new StorageSharedKeyCredential(extractedCreds.accountName, extractedCreds.accountKey);
5415
5749
  if (!options.proxyOptions) {
5416
- options.proxyOptions = coreHttp.getDefaultProxySettings(extractedCreds.proxyUri);
5750
+ options.proxyOptions = coreRestPipeline.getDefaultProxySettings(extractedCreds.proxyUri);
5417
5751
  }
5418
5752
  const pipeline = newPipeline(sharedKeyCredential, options);
5419
5753
  return new QueueServiceClient(extractedCreds.url, pipeline);
@@ -5430,6 +5764,26 @@ class QueueServiceClient extends StorageClient {
5430
5764
  throw new Error("Connection string must be either an Account connection string or a SAS connection string");
5431
5765
  }
5432
5766
  }
5767
+ constructor(url, credentialOrPipeline,
5768
+ // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
5769
+ /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
5770
+ options) {
5771
+ let pipeline;
5772
+ if (credentialOrPipeline instanceof Pipeline) {
5773
+ pipeline = credentialOrPipeline;
5774
+ }
5775
+ else if ((coreUtil.isNode && credentialOrPipeline instanceof StorageSharedKeyCredential) ||
5776
+ credentialOrPipeline instanceof AnonymousCredential ||
5777
+ coreAuth.isTokenCredential(credentialOrPipeline)) {
5778
+ pipeline = newPipeline(credentialOrPipeline, options);
5779
+ }
5780
+ else {
5781
+ // The second parameter is undefined. Use anonymous credential.
5782
+ pipeline = newPipeline(new AnonymousCredential(), options);
5783
+ }
5784
+ super(url, pipeline);
5785
+ this.serviceContext = this.storageClientContext.service;
5786
+ }
5433
5787
  /**
5434
5788
  * Creates a {@link QueueClient} object.
5435
5789
  *
@@ -5461,30 +5815,12 @@ class QueueServiceClient extends StorageClient {
5461
5815
  * @returns Response data for the list queues segment operation.
5462
5816
  */
5463
5817
  async listQueuesSegment(marker, options = {}) {
5464
- const { span, updatedOptions } = createSpan("QueueServiceClient-listQueuesSegment", options);
5465
5818
  if (options.prefix === "") {
5466
5819
  options.prefix = undefined;
5467
5820
  }
5468
- try {
5469
- return await this.serviceContext.listQueuesSegment({
5470
- abortSignal: options.abortSignal,
5471
- marker: marker,
5472
- maxPageSize: options.maxPageSize,
5473
- prefix: options.prefix,
5474
- include: options.include === undefined ? undefined : [options.include],
5475
- tracingOptions: updatedOptions.tracingOptions,
5476
- });
5477
- }
5478
- catch (e) {
5479
- span.setStatus({
5480
- code: coreTracing.SpanStatusCode.ERROR,
5481
- message: e.message,
5482
- });
5483
- throw e;
5484
- }
5485
- finally {
5486
- span.end();
5487
- }
5821
+ return tracingClient.withSpan("QueueServiceClient-listQueuesSegment", options, async (updatedOptions) => {
5822
+ return assertResponse(await this.serviceContext.listQueuesSegment(Object.assign(Object.assign({}, updatedOptions), { marker, include: options.include === undefined ? undefined : [options.include] })));
5823
+ });
5488
5824
  }
5489
5825
  /**
5490
5826
  * Returns an AsyncIterableIterator for {@link ServiceListQueuesSegmentResponse} objects
@@ -5518,23 +5854,30 @@ class QueueServiceClient extends StorageClient {
5518
5854
  */
5519
5855
  listItems(options = {}) {
5520
5856
  return tslib.__asyncGenerator(this, arguments, function* listItems_1() {
5521
- var e_1, _a;
5857
+ var _a, e_1, _b, _c;
5522
5858
  if (options.prefix === "") {
5523
5859
  options.prefix = undefined;
5524
5860
  }
5525
5861
  let marker;
5526
5862
  try {
5527
- for (var _b = tslib.__asyncValues(this.listSegments(marker, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
5528
- const segment = _c.value;
5529
- if (segment.queueItems) {
5530
- yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(segment.queueItems)));
5863
+ for (var _d = true, _e = tslib.__asyncValues(this.listSegments(marker, options)), _f; _f = yield tslib.__await(_e.next()), _a = _f.done, !_a;) {
5864
+ _c = _f.value;
5865
+ _d = false;
5866
+ try {
5867
+ const segment = _c;
5868
+ if (segment.queueItems) {
5869
+ yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(segment.queueItems)));
5870
+ }
5871
+ }
5872
+ finally {
5873
+ _d = true;
5531
5874
  }
5532
5875
  }
5533
5876
  }
5534
5877
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
5535
5878
  finally {
5536
5879
  try {
5537
- if (_c && !_c.done && (_a = _b.return)) yield tslib.__await(_a.call(_b));
5880
+ if (!_d && !_a && (_b = _e.return)) yield tslib.__await(_b.call(_e));
5538
5881
  }
5539
5882
  finally { if (e_1) throw e_1.error; }
5540
5883
  }
@@ -5563,7 +5906,7 @@ class QueueServiceClient extends StorageClient {
5563
5906
  * let iterator = queueServiceClient.listQueues();
5564
5907
  * let item = await iterator.next();
5565
5908
  * while (!item.done) {
5566
- * console.log(`Queue${i}: ${iterator.value.name}`);
5909
+ * console.log(`Queue${i}: ${item.value.name}`);
5567
5910
  * i++;
5568
5911
  * item = await iterator.next();
5569
5912
  * }
@@ -5654,23 +5997,9 @@ class QueueServiceClient extends StorageClient {
5654
5997
  * @returns Response data including the queue service properties.
5655
5998
  */
5656
5999
  async getProperties(options = {}) {
5657
- const { span, updatedOptions } = createSpan("QueueServiceClient-getProperties", options);
5658
- try {
5659
- return await this.serviceContext.getProperties({
5660
- abortSignal: options.abortSignal,
5661
- tracingOptions: updatedOptions.tracingOptions,
5662
- });
5663
- }
5664
- catch (e) {
5665
- span.setStatus({
5666
- code: coreTracing.SpanStatusCode.ERROR,
5667
- message: e.message,
5668
- });
5669
- throw e;
5670
- }
5671
- finally {
5672
- span.end();
5673
- }
6000
+ return tracingClient.withSpan("QueueServiceClient-getProperties", options, async (updatedOptions) => {
6001
+ return assertResponse(await this.serviceContext.getProperties(updatedOptions));
6002
+ });
5674
6003
  }
5675
6004
  /**
5676
6005
  * Sets properties for a storage account’s Queue service endpoint, including properties
@@ -5682,23 +6011,9 @@ class QueueServiceClient extends StorageClient {
5682
6011
  * @returns Response data for the Set Properties operation.
5683
6012
  */
5684
6013
  async setProperties(properties, options = {}) {
5685
- const { span, updatedOptions } = createSpan("QueueServiceClient-setProperties", options);
5686
- try {
5687
- return await this.serviceContext.setProperties(properties, {
5688
- abortSignal: options.abortSignal,
5689
- tracingOptions: updatedOptions.tracingOptions,
5690
- });
5691
- }
5692
- catch (e) {
5693
- span.setStatus({
5694
- code: coreTracing.SpanStatusCode.ERROR,
5695
- message: e.message,
5696
- });
5697
- throw e;
5698
- }
5699
- finally {
5700
- span.end();
5701
- }
6014
+ return tracingClient.withSpan("QueueServiceClient-setProperties", options, async (updatedOptions) => {
6015
+ return assertResponse(await this.serviceContext.setProperties(properties, updatedOptions));
6016
+ });
5702
6017
  }
5703
6018
  /**
5704
6019
  * Retrieves statistics related to replication for the Queue service. It is only
@@ -5710,23 +6025,9 @@ class QueueServiceClient extends StorageClient {
5710
6025
  * @returns Response data for get statistics the operation.
5711
6026
  */
5712
6027
  async getStatistics(options = {}) {
5713
- const { span, updatedOptions } = createSpan("QueueServiceClient-getStatistics", options);
5714
- try {
5715
- return await this.serviceContext.getStatistics({
5716
- abortSignal: options.abortSignal,
5717
- tracingOptions: updatedOptions.tracingOptions,
5718
- });
5719
- }
5720
- catch (e) {
5721
- span.setStatus({
5722
- code: coreTracing.SpanStatusCode.ERROR,
5723
- message: e.message,
5724
- });
5725
- throw e;
5726
- }
5727
- finally {
5728
- span.end();
5729
- }
6028
+ return tracingClient.withSpan("QueueServiceClient-getStatistics", options, async (updatedOptions) => {
6029
+ return assertResponse(await this.serviceContext.getStatistics(updatedOptions));
6030
+ });
5730
6031
  }
5731
6032
  /**
5732
6033
  * Creates a new queue under the specified account.
@@ -5737,20 +6038,9 @@ class QueueServiceClient extends StorageClient {
5737
6038
  * @returns Response data for the Queue create operation.
5738
6039
  */
5739
6040
  async createQueue(queueName, options = {}) {
5740
- const { span, updatedOptions } = createSpan("QueueServiceClient-createQueue", options);
5741
- try {
5742
- return await this.getQueueClient(queueName).create(updatedOptions);
5743
- }
5744
- catch (e) {
5745
- span.setStatus({
5746
- code: coreTracing.SpanStatusCode.ERROR,
5747
- message: e.message,
5748
- });
5749
- throw e;
5750
- }
5751
- finally {
5752
- span.end();
5753
- }
6041
+ return tracingClient.withSpan("QueueServiceClient-createQueue", options, async (updatedOptions) => {
6042
+ return this.getQueueClient(queueName).create(updatedOptions);
6043
+ });
5754
6044
  }
5755
6045
  /**
5756
6046
  * Deletes the specified queue permanently.
@@ -5761,20 +6051,9 @@ class QueueServiceClient extends StorageClient {
5761
6051
  * @returns Response data for the Queue delete operation.
5762
6052
  */
5763
6053
  async deleteQueue(queueName, options = {}) {
5764
- const { span, updatedOptions } = createSpan("QueueServiceClient-deleteQueue", options);
5765
- try {
5766
- return await this.getQueueClient(queueName).delete(updatedOptions);
5767
- }
5768
- catch (e) {
5769
- span.setStatus({
5770
- code: coreTracing.SpanStatusCode.ERROR,
5771
- message: e.message,
5772
- });
5773
- throw e;
5774
- }
5775
- finally {
5776
- span.end();
5777
- }
6054
+ return tracingClient.withSpan("QueueServiceClient-deleteQueue", options, async (updatedOptions) => {
6055
+ return this.getQueueClient(queueName).delete(updatedOptions);
6056
+ });
5778
6057
  }
5779
6058
  /**
5780
6059
  * Only available for QueueServiceClient constructed with a shared key credential.
@@ -5805,35 +6084,22 @@ class QueueServiceClient extends StorageClient {
5805
6084
  }
5806
6085
  }
5807
6086
 
5808
- Object.defineProperty(exports, 'BaseRequestPolicy', {
5809
- enumerable: true,
5810
- get: function () { return coreHttp.BaseRequestPolicy; }
5811
- });
5812
- Object.defineProperty(exports, 'HttpHeaders', {
5813
- enumerable: true,
5814
- get: function () { return coreHttp.HttpHeaders; }
5815
- });
5816
- Object.defineProperty(exports, 'RequestPolicyOptions', {
5817
- enumerable: true,
5818
- get: function () { return coreHttp.RequestPolicyOptions; }
5819
- });
6087
+ // Copyright (c) Microsoft Corporation.
6088
+ /**
6089
+ * The `@azure/logger` configuration for this package.
6090
+ */
6091
+ const logger = logger$2.createClientLogger("storage-queue");
6092
+
5820
6093
  Object.defineProperty(exports, 'RestError', {
5821
6094
  enumerable: true,
5822
- get: function () { return coreHttp.RestError; }
5823
- });
5824
- Object.defineProperty(exports, 'WebResource', {
5825
- enumerable: true,
5826
- get: function () { return coreHttp.WebResource; }
5827
- });
5828
- Object.defineProperty(exports, 'deserializationPolicy', {
5829
- enumerable: true,
5830
- get: function () { return coreHttp.deserializationPolicy; }
6095
+ get: function () { return coreRestPipeline.RestError; }
5831
6096
  });
5832
6097
  exports.AccountSASPermissions = AccountSASPermissions;
5833
6098
  exports.AccountSASResourceTypes = AccountSASResourceTypes;
5834
6099
  exports.AccountSASServices = AccountSASServices;
5835
6100
  exports.AnonymousCredential = AnonymousCredential;
5836
6101
  exports.AnonymousCredentialPolicy = AnonymousCredentialPolicy;
6102
+ exports.BaseRequestPolicy = BaseRequestPolicy;
5837
6103
  exports.Credential = Credential;
5838
6104
  exports.CredentialPolicy = CredentialPolicy;
5839
6105
  exports.Pipeline = Pipeline;
@@ -5843,13 +6109,13 @@ exports.QueueServiceClient = QueueServiceClient;
5843
6109
  exports.SASQueryParameters = SASQueryParameters;
5844
6110
  exports.StorageBrowserPolicy = StorageBrowserPolicy;
5845
6111
  exports.StorageBrowserPolicyFactory = StorageBrowserPolicyFactory;
5846
- exports.StorageOAuthScopes = StorageOAuthScopes;
5847
6112
  exports.StorageRetryPolicy = StorageRetryPolicy;
5848
6113
  exports.StorageRetryPolicyFactory = StorageRetryPolicyFactory;
5849
6114
  exports.StorageSharedKeyCredential = StorageSharedKeyCredential;
5850
6115
  exports.StorageSharedKeyCredentialPolicy = StorageSharedKeyCredentialPolicy;
5851
6116
  exports.generateAccountSASQueryParameters = generateAccountSASQueryParameters;
5852
6117
  exports.generateQueueSASQueryParameters = generateQueueSASQueryParameters;
6118
+ exports.isPipelineLike = isPipelineLike;
5853
6119
  exports.logger = logger;
5854
6120
  exports.newPipeline = newPipeline;
5855
6121
  //# sourceMappingURL=index.js.map