@azure/storage-queue 12.29.0 → 12.30.0-beta.1

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 (256) hide show
  1. package/dist/browser/Pipeline.d.ts +2 -3
  2. package/dist/browser/Pipeline.d.ts.map +1 -1
  3. package/dist/browser/Pipeline.js.map +1 -1
  4. package/dist/browser/QueueClient.d.ts +2 -1
  5. package/dist/browser/QueueClient.d.ts.map +1 -1
  6. package/dist/browser/QueueClient.js.map +1 -1
  7. package/dist/browser/QueueSASSignatureValues.d.ts +2 -1
  8. package/dist/browser/QueueSASSignatureValues.d.ts.map +1 -1
  9. package/dist/browser/QueueSASSignatureValues.js +2 -2
  10. package/dist/browser/QueueSASSignatureValues.js.map +1 -1
  11. package/dist/browser/QueueServiceClient.d.ts +28 -0
  12. package/dist/browser/QueueServiceClient.d.ts.map +1 -1
  13. package/dist/browser/QueueServiceClient.js +21 -13
  14. package/dist/browser/QueueServiceClient.js.map +1 -1
  15. package/dist/browser/SASQueryParameters.d.ts +6 -1
  16. package/dist/browser/SASQueryParameters.d.ts.map +1 -1
  17. package/dist/browser/SASQueryParameters.js +10 -0
  18. package/dist/browser/SASQueryParameters.js.map +1 -1
  19. package/dist/browser/generated/src/models/index.d.ts +4 -0
  20. package/dist/browser/generated/src/models/index.d.ts.map +1 -1
  21. package/dist/browser/generated/src/models/index.js.map +1 -1
  22. package/dist/browser/generated/src/models/mappers.d.ts.map +1 -1
  23. package/dist/browser/generated/src/models/mappers.js +14 -0
  24. package/dist/browser/generated/src/models/mappers.js.map +1 -1
  25. package/dist/browser/generated/src/models/parameters.js +1 -1
  26. package/dist/browser/generated/src/models/parameters.js.map +1 -1
  27. package/dist/browser/generated/src/storageClient.js +2 -2
  28. package/dist/browser/generated/src/storageClient.js.map +1 -1
  29. package/dist/browser/generatedModels.d.ts +2 -2
  30. package/dist/browser/generatedModels.d.ts.map +1 -1
  31. package/dist/browser/generatedModels.js.map +1 -1
  32. package/dist/browser/index.d.ts +8 -8
  33. package/dist/browser/index.d.ts.map +1 -0
  34. package/dist/browser/index.js +1 -2
  35. package/dist/browser/index.js.map +1 -0
  36. package/dist/browser/utils/constants.d.ts.map +1 -1
  37. package/dist/browser/utils/constants.js +2 -2
  38. package/dist/browser/utils/constants.js.map +1 -1
  39. package/dist/commonjs/AccountSASPermissions.js +133 -126
  40. package/dist/commonjs/AccountSASPermissions.js.map +7 -1
  41. package/dist/commonjs/AccountSASResourceTypes.js +80 -70
  42. package/dist/commonjs/AccountSASResourceTypes.js.map +7 -1
  43. package/dist/commonjs/AccountSASServices.js +88 -78
  44. package/dist/commonjs/AccountSASServices.js.map +7 -1
  45. package/dist/commonjs/AccountSASSignatureValues.js +91 -72
  46. package/dist/commonjs/AccountSASSignatureValues.js.map +7 -1
  47. package/dist/commonjs/Pipeline.d.ts +2 -3
  48. package/dist/commonjs/Pipeline.d.ts.map +1 -1
  49. package/dist/commonjs/Pipeline.js +244 -244
  50. package/dist/commonjs/Pipeline.js.map +7 -1
  51. package/dist/commonjs/QueueClient.d.ts +2 -1
  52. package/dist/commonjs/QueueClient.d.ts.map +1 -1
  53. package/dist/commonjs/QueueClient.js +710 -683
  54. package/dist/commonjs/QueueClient.js.map +7 -1
  55. package/dist/commonjs/QueueSASPermissions.js +90 -80
  56. package/dist/commonjs/QueueSASPermissions.js.map +7 -1
  57. package/dist/commonjs/QueueSASSignatureValues.d.ts +2 -1
  58. package/dist/commonjs/QueueSASSignatureValues.d.ts.map +1 -1
  59. package/dist/commonjs/QueueSASSignatureValues.js +151 -111
  60. package/dist/commonjs/QueueSASSignatureValues.js.map +7 -1
  61. package/dist/commonjs/QueueServiceClient.d.ts +28 -0
  62. package/dist/commonjs/QueueServiceClient.d.ts.map +1 -1
  63. package/dist/commonjs/QueueServiceClient.js +532 -472
  64. package/dist/commonjs/QueueServiceClient.js.map +7 -1
  65. package/dist/commonjs/SASQueryParameters.d.ts +6 -1
  66. package/dist/commonjs/SASQueryParameters.d.ts.map +1 -1
  67. package/dist/commonjs/SASQueryParameters.js +308 -267
  68. package/dist/commonjs/SASQueryParameters.js.map +7 -1
  69. package/dist/commonjs/SasIPRange.js +27 -14
  70. package/dist/commonjs/SasIPRange.js.map +7 -1
  71. package/dist/commonjs/StorageClient.js +75 -65
  72. package/dist/commonjs/StorageClient.js.map +7 -1
  73. package/dist/commonjs/StorageContextClient.js +34 -20
  74. package/dist/commonjs/StorageContextClient.js.map +7 -1
  75. package/dist/commonjs/generated/src/index.js +32 -16
  76. package/dist/commonjs/generated/src/index.js.map +7 -1
  77. package/dist/commonjs/generated/src/models/index.d.ts +4 -0
  78. package/dist/commonjs/generated/src/models/index.d.ts.map +1 -1
  79. package/dist/commonjs/generated/src/models/index.js +86 -129
  80. package/dist/commonjs/generated/src/models/index.js.map +7 -1
  81. package/dist/commonjs/generated/src/models/mappers.d.ts.map +1 -1
  82. package/dist/commonjs/generated/src/models/mappers.js +1947 -1817
  83. package/dist/commonjs/generated/src/models/mappers.js.map +7 -1
  84. package/dist/commonjs/generated/src/models/parameters.js +378 -305
  85. package/dist/commonjs/generated/src/models/parameters.js.map +7 -1
  86. package/dist/commonjs/generated/src/operations/index.js +27 -15
  87. package/dist/commonjs/generated/src/operations/index.js.map +7 -1
  88. package/dist/commonjs/generated/src/operations/messageId.js +130 -99
  89. package/dist/commonjs/generated/src/operations/messageId.js.map +7 -1
  90. package/dist/commonjs/generated/src/operations/messages.js +213 -185
  91. package/dist/commonjs/generated/src/operations/messages.js.map +7 -1
  92. package/dist/commonjs/generated/src/operations/queue.js +243 -206
  93. package/dist/commonjs/generated/src/operations/queue.js.map +7 -1
  94. package/dist/commonjs/generated/src/operations/service.js +239 -199
  95. package/dist/commonjs/generated/src/operations/service.js.map +7 -1
  96. package/dist/commonjs/generated/src/operationsInterfaces/index.js +27 -15
  97. package/dist/commonjs/generated/src/operationsInterfaces/index.js.map +7 -1
  98. package/dist/commonjs/generated/src/operationsInterfaces/messageId.js +15 -10
  99. package/dist/commonjs/generated/src/operationsInterfaces/messageId.js.map +7 -1
  100. package/dist/commonjs/generated/src/operationsInterfaces/messages.js +15 -10
  101. package/dist/commonjs/generated/src/operationsInterfaces/messages.js.map +7 -1
  102. package/dist/commonjs/generated/src/operationsInterfaces/queue.js +15 -10
  103. package/dist/commonjs/generated/src/operationsInterfaces/queue.js.map +7 -1
  104. package/dist/commonjs/generated/src/operationsInterfaces/service.js +15 -10
  105. package/dist/commonjs/generated/src/operationsInterfaces/service.js.map +7 -1
  106. package/dist/commonjs/generated/src/storageClient.js +77 -59
  107. package/dist/commonjs/generated/src/storageClient.js.map +7 -1
  108. package/dist/commonjs/generatedModels.d.ts +2 -2
  109. package/dist/commonjs/generatedModels.d.ts.map +1 -1
  110. package/dist/commonjs/generatedModels.js +15 -5
  111. package/dist/commonjs/generatedModels.js.map +7 -1
  112. package/dist/commonjs/index.d.ts +9 -9
  113. package/dist/commonjs/index.d.ts.map +1 -1
  114. package/dist/commonjs/index.js +88 -43
  115. package/dist/commonjs/index.js.map +7 -1
  116. package/dist/commonjs/log.js +28 -11
  117. package/dist/commonjs/log.js.map +7 -1
  118. package/dist/commonjs/models.js +33 -21
  119. package/dist/commonjs/models.js.map +7 -1
  120. package/dist/commonjs/tsdoc-metadata.json +1 -1
  121. package/dist/commonjs/utils/constants.d.ts.map +1 -1
  122. package/dist/commonjs/utils/constants.js +151 -114
  123. package/dist/commonjs/utils/constants.js.map +7 -1
  124. package/dist/commonjs/utils/tracing.js +32 -16
  125. package/dist/commonjs/utils/tracing.js.map +7 -1
  126. package/dist/commonjs/utils/utils.common.js +242 -338
  127. package/dist/commonjs/utils/utils.common.js.map +7 -1
  128. package/dist/esm/AccountSASPermissions.js +111 -123
  129. package/dist/esm/AccountSASPermissions.js.map +7 -1
  130. package/dist/esm/AccountSASResourceTypes.js +58 -67
  131. package/dist/esm/AccountSASResourceTypes.js.map +7 -1
  132. package/dist/esm/AccountSASServices.js +66 -75
  133. package/dist/esm/AccountSASServices.js.map +7 -1
  134. package/dist/esm/AccountSASSignatureValues.js +62 -63
  135. package/dist/esm/AccountSASSignatureValues.js.map +7 -1
  136. package/dist/esm/Pipeline.d.ts +2 -3
  137. package/dist/esm/Pipeline.d.ts.map +1 -1
  138. package/dist/esm/Pipeline.js +239 -239
  139. package/dist/esm/Pipeline.js.map +7 -1
  140. package/dist/esm/QueueClient.d.ts +2 -1
  141. package/dist/esm/QueueClient.d.ts.map +1 -1
  142. package/dist/esm/QueueClient.js +689 -671
  143. package/dist/esm/QueueClient.js.map +7 -1
  144. package/dist/esm/QueueSASPermissions.js +68 -77
  145. package/dist/esm/QueueSASPermissions.js.map +7 -1
  146. package/dist/esm/QueueSASSignatureValues.d.ts +2 -1
  147. package/dist/esm/QueueSASSignatureValues.d.ts.map +1 -1
  148. package/dist/esm/QueueSASSignatureValues.js +124 -104
  149. package/dist/esm/QueueSASSignatureValues.js.map +7 -1
  150. package/dist/esm/QueueServiceClient.d.ts +28 -0
  151. package/dist/esm/QueueServiceClient.d.ts.map +1 -1
  152. package/dist/esm/QueueServiceClient.js +507 -457
  153. package/dist/esm/QueueServiceClient.js.map +7 -1
  154. package/dist/esm/SASQueryParameters.d.ts +6 -1
  155. package/dist/esm/SASQueryParameters.d.ts.map +1 -1
  156. package/dist/esm/SASQueryParameters.js +283 -262
  157. package/dist/esm/SASQueryParameters.js.map +7 -1
  158. package/dist/esm/SasIPRange.js +5 -12
  159. package/dist/esm/SasIPRange.js.map +7 -1
  160. package/dist/esm/StorageClient.js +50 -59
  161. package/dist/esm/StorageClient.js.map +7 -1
  162. package/dist/esm/StorageContextClient.js +10 -15
  163. package/dist/esm/StorageContextClient.js.map +7 -1
  164. package/dist/esm/generated/src/index.js +4 -9
  165. package/dist/esm/generated/src/index.js.map +7 -1
  166. package/dist/esm/generated/src/models/index.d.ts +4 -0
  167. package/dist/esm/generated/src/models/index.d.ts.map +1 -1
  168. package/dist/esm/generated/src/models/index.js +63 -126
  169. package/dist/esm/generated/src/models/index.js.map +7 -1
  170. package/dist/esm/generated/src/models/mappers.d.ts.map +1 -1
  171. package/dist/esm/generated/src/models/mappers.js +1873 -1813
  172. package/dist/esm/generated/src/models/mappers.js.map +7 -1
  173. package/dist/esm/generated/src/models/parameters.js +330 -302
  174. package/dist/esm/generated/src/models/parameters.js.map +7 -1
  175. package/dist/esm/generated/src/operations/index.js +0 -8
  176. package/dist/esm/generated/src/operations/index.js.map +7 -1
  177. package/dist/esm/generated/src/operations/messageId.js +95 -92
  178. package/dist/esm/generated/src/operations/messageId.js.map +7 -1
  179. package/dist/esm/generated/src/operations/messages.js +178 -178
  180. package/dist/esm/generated/src/operations/messages.js.map +7 -1
  181. package/dist/esm/generated/src/operations/queue.js +208 -199
  182. package/dist/esm/generated/src/operations/queue.js.map +7 -1
  183. package/dist/esm/generated/src/operations/service.js +204 -192
  184. package/dist/esm/generated/src/operations/service.js.map +7 -1
  185. package/dist/esm/generated/src/operationsInterfaces/index.js +0 -8
  186. package/dist/esm/generated/src/operationsInterfaces/index.js.map +7 -1
  187. package/dist/esm/generated/src/operationsInterfaces/messageId.js +0 -9
  188. package/dist/esm/generated/src/operationsInterfaces/messageId.js.map +7 -1
  189. package/dist/esm/generated/src/operationsInterfaces/messages.js +0 -9
  190. package/dist/esm/generated/src/operationsInterfaces/messages.js.map +7 -1
  191. package/dist/esm/generated/src/operationsInterfaces/queue.js +0 -9
  192. package/dist/esm/generated/src/operationsInterfaces/queue.js.map +7 -1
  193. package/dist/esm/generated/src/operationsInterfaces/service.js +0 -9
  194. package/dist/esm/generated/src/operationsInterfaces/service.js.map +7 -1
  195. package/dist/esm/generated/src/storageClient.js +49 -54
  196. package/dist/esm/generated/src/storageClient.js.map +7 -1
  197. package/dist/esm/generatedModels.d.ts +2 -2
  198. package/dist/esm/generatedModels.d.ts.map +1 -1
  199. package/dist/esm/generatedModels.js +0 -4
  200. package/dist/esm/generatedModels.js.map +7 -1
  201. package/dist/esm/index.d.ts +9 -9
  202. package/dist/esm/index.d.ts.map +1 -1
  203. package/dist/esm/index.js +50 -11
  204. package/dist/esm/index.js.map +7 -1
  205. package/dist/esm/log.js +4 -7
  206. package/dist/esm/log.js.map +7 -1
  207. package/dist/esm/models.js +10 -18
  208. package/dist/esm/models.js.map +7 -1
  209. package/dist/esm/utils/constants.d.ts.map +1 -1
  210. package/dist/esm/utils/constants.js +117 -111
  211. package/dist/esm/utils/constants.js.map +7 -1
  212. package/dist/esm/utils/tracing.js +7 -11
  213. package/dist/esm/utils/tracing.js.map +7 -1
  214. package/dist/esm/utils/utils.common.js +247 -358
  215. package/dist/esm/utils/utils.common.js.map +7 -1
  216. package/dist/react-native/Pipeline.d.ts +2 -3
  217. package/dist/react-native/Pipeline.d.ts.map +1 -1
  218. package/dist/react-native/Pipeline.js.map +1 -1
  219. package/dist/react-native/QueueClient.d.ts +2 -1
  220. package/dist/react-native/QueueClient.d.ts.map +1 -1
  221. package/dist/react-native/QueueClient.js.map +1 -1
  222. package/dist/react-native/QueueSASSignatureValues.d.ts +2 -1
  223. package/dist/react-native/QueueSASSignatureValues.d.ts.map +1 -1
  224. package/dist/react-native/QueueSASSignatureValues.js +2 -2
  225. package/dist/react-native/QueueSASSignatureValues.js.map +1 -1
  226. package/dist/react-native/QueueServiceClient.d.ts +28 -0
  227. package/dist/react-native/QueueServiceClient.d.ts.map +1 -1
  228. package/dist/react-native/QueueServiceClient.js +21 -13
  229. package/dist/react-native/QueueServiceClient.js.map +1 -1
  230. package/dist/react-native/SASQueryParameters.d.ts +6 -1
  231. package/dist/react-native/SASQueryParameters.d.ts.map +1 -1
  232. package/dist/react-native/SASQueryParameters.js +10 -0
  233. package/dist/react-native/SASQueryParameters.js.map +1 -1
  234. package/dist/react-native/generated/src/models/index.d.ts +4 -0
  235. package/dist/react-native/generated/src/models/index.d.ts.map +1 -1
  236. package/dist/react-native/generated/src/models/index.js.map +1 -1
  237. package/dist/react-native/generated/src/models/mappers.d.ts.map +1 -1
  238. package/dist/react-native/generated/src/models/mappers.js +14 -0
  239. package/dist/react-native/generated/src/models/mappers.js.map +1 -1
  240. package/dist/react-native/generated/src/models/parameters.js +1 -1
  241. package/dist/react-native/generated/src/models/parameters.js.map +1 -1
  242. package/dist/react-native/generated/src/storageClient.js +2 -2
  243. package/dist/react-native/generated/src/storageClient.js.map +1 -1
  244. package/dist/react-native/generatedModels.d.ts +2 -2
  245. package/dist/react-native/generatedModels.d.ts.map +1 -1
  246. package/dist/react-native/generatedModels.js.map +1 -1
  247. package/dist/react-native/index.d.ts +9 -9
  248. package/dist/react-native/index.d.ts.map +1 -1
  249. package/dist/react-native/index.js +0 -1
  250. package/dist/react-native/index.js.map +1 -1
  251. package/dist/react-native/utils/constants.d.ts.map +1 -1
  252. package/dist/react-native/utils/constants.js +2 -2
  253. package/dist/react-native/utils/constants.js.map +1 -1
  254. package/package.json +2 -19
  255. package/dist/browser/index-browser.d.mts.map +0 -1
  256. package/dist/browser/index-browser.mjs.map +0 -1
@@ -1,694 +1,712 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT License.
3
1
  import { isTokenCredential } from "@azure/core-auth";
4
2
  import { isNode } from "@azure/core-util";
5
3
  import { newPipeline, isPipelineLike } from "./Pipeline.js";
6
4
  import { StorageClient, getStorageClientContext } from "./StorageClient.js";
7
- import { appendToURLPath, extractConnectionStringParts, isIpEndpointStyle, truncatedISO8061Date, appendToURLQuery, assertResponse, } from "./utils/utils.common.js";
5
+ import {
6
+ appendToURLPath,
7
+ extractConnectionStringParts,
8
+ isIpEndpointStyle,
9
+ truncatedISO8061Date,
10
+ appendToURLQuery,
11
+ assertResponse
12
+ } from "./utils/utils.common.js";
8
13
  import { StorageSharedKeyCredential } from "@azure/storage-common";
9
14
  import { AnonymousCredential } from "@azure/storage-common";
10
15
  import { tracingClient } from "./utils/tracing.js";
11
- import { generateQueueSASQueryParameters, generateQueueSASQueryParametersInternal, } from "./QueueSASSignatureValues.js";
16
+ import {
17
+ generateQueueSASQueryParameters,
18
+ generateQueueSASQueryParametersInternal
19
+ } from "./QueueSASSignatureValues.js";
12
20
  import { getDefaultProxySettings } from "@azure/core-rest-pipeline";
13
- /**
14
- * A QueueClient represents a URL to an Azure Storage Queue's messages allowing you to manipulate its messages.
15
- */
16
- export class QueueClient extends StorageClient {
17
- /**
18
- * messagesContext provided by protocol layer.
19
- */
20
- messagesContext;
21
- /**
22
- * queueContext provided by protocol layer.
23
- */
24
- queueContext;
25
- _name;
26
- _messagesUrl;
27
- /**
28
- * The name of the queue.
29
- */
30
- get name() {
31
- return this._name;
32
- }
33
- constructor(urlOrConnectionString, credentialOrPipelineOrQueueName,
34
- // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
35
- /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
36
- options) {
37
- options = options || {};
38
- let pipeline;
39
- let url;
40
- if (isPipelineLike(credentialOrPipelineOrQueueName)) {
41
- // (url: string, pipeline: Pipeline)
42
- url = urlOrConnectionString;
43
- pipeline = credentialOrPipelineOrQueueName;
44
- }
45
- else if ((isNode && credentialOrPipelineOrQueueName instanceof StorageSharedKeyCredential) ||
46
- credentialOrPipelineOrQueueName instanceof AnonymousCredential ||
47
- isTokenCredential(credentialOrPipelineOrQueueName)) {
48
- // (url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)
49
- url = urlOrConnectionString;
50
- pipeline = newPipeline(credentialOrPipelineOrQueueName, options);
51
- }
52
- else if (!credentialOrPipelineOrQueueName &&
53
- typeof credentialOrPipelineOrQueueName !== "string") {
54
- // (url: string, credential?: StorageSharedKeyCredential | AnonymousCredential | TokenCredential, options?: StoragePipelineOptions)
55
- // The second parameter is undefined. Use anonymous credential.
56
- url = urlOrConnectionString;
57
- pipeline = newPipeline(new AnonymousCredential(), options);
58
- }
59
- else if (credentialOrPipelineOrQueueName &&
60
- typeof credentialOrPipelineOrQueueName === "string") {
61
- // (connectionString: string, containerName: string, queueName: string, options?: StoragePipelineOptions)
62
- const extractedCreds = extractConnectionStringParts(urlOrConnectionString);
63
- if (extractedCreds.kind === "AccountConnString") {
64
- if (isNode) {
65
- const queueName = credentialOrPipelineOrQueueName;
66
- const sharedKeyCredential = new StorageSharedKeyCredential(extractedCreds.accountName, extractedCreds.accountKey);
67
- url = appendToURLPath(extractedCreds.url, queueName);
68
- if (!options.proxyOptions) {
69
- options.proxyOptions = getDefaultProxySettings(extractedCreds.proxyUri);
70
- }
71
- pipeline = newPipeline(sharedKeyCredential, options);
72
- }
73
- else {
74
- throw new Error("Account connection string is only supported in Node.js environment");
75
- }
76
- }
77
- else if (extractedCreds.kind === "SASConnString") {
78
- const queueName = credentialOrPipelineOrQueueName;
79
- url = appendToURLPath(extractedCreds.url, queueName) + "?" + extractedCreds.accountSas;
80
- pipeline = newPipeline(new AnonymousCredential(), options);
81
- }
82
- else {
83
- throw new Error("Connection string must be either an Account connection string or a SAS connection string");
84
- }
85
- }
86
- else {
87
- throw new Error("Expecting non-empty strings for queueName parameter");
21
+ class QueueClient extends StorageClient {
22
+ /**
23
+ * messagesContext provided by protocol layer.
24
+ */
25
+ messagesContext;
26
+ /**
27
+ * queueContext provided by protocol layer.
28
+ */
29
+ queueContext;
30
+ _name;
31
+ _messagesUrl;
32
+ /**
33
+ * The name of the queue.
34
+ */
35
+ get name() {
36
+ return this._name;
37
+ }
38
+ constructor(urlOrConnectionString, credentialOrPipelineOrQueueName, options) {
39
+ options = options || {};
40
+ let pipeline;
41
+ let url;
42
+ if (isPipelineLike(credentialOrPipelineOrQueueName)) {
43
+ url = urlOrConnectionString;
44
+ pipeline = credentialOrPipelineOrQueueName;
45
+ } else if (isNode && credentialOrPipelineOrQueueName instanceof StorageSharedKeyCredential || credentialOrPipelineOrQueueName instanceof AnonymousCredential || isTokenCredential(credentialOrPipelineOrQueueName)) {
46
+ url = urlOrConnectionString;
47
+ pipeline = newPipeline(credentialOrPipelineOrQueueName, options);
48
+ } else if (!credentialOrPipelineOrQueueName && typeof credentialOrPipelineOrQueueName !== "string") {
49
+ url = urlOrConnectionString;
50
+ pipeline = newPipeline(new AnonymousCredential(), options);
51
+ } else if (credentialOrPipelineOrQueueName && typeof credentialOrPipelineOrQueueName === "string") {
52
+ const extractedCreds = extractConnectionStringParts(urlOrConnectionString);
53
+ if (extractedCreds.kind === "AccountConnString") {
54
+ if (isNode) {
55
+ const queueName = credentialOrPipelineOrQueueName;
56
+ const sharedKeyCredential = new StorageSharedKeyCredential(
57
+ extractedCreds.accountName,
58
+ extractedCreds.accountKey
59
+ );
60
+ url = appendToURLPath(extractedCreds.url, queueName);
61
+ if (!options.proxyOptions) {
62
+ options.proxyOptions = getDefaultProxySettings(extractedCreds.proxyUri);
63
+ }
64
+ pipeline = newPipeline(sharedKeyCredential, options);
65
+ } else {
66
+ throw new Error("Account connection string is only supported in Node.js environment");
88
67
  }
89
- super(url, pipeline);
90
- this._name = this.getQueueNameFromUrl();
91
- this.queueContext = this.storageClientContext.queue;
92
- // MessagesContext
93
- // Build the url with "messages"
94
- const partsOfUrl = this.url.split("?");
95
- this._messagesUrl = partsOfUrl[1]
96
- ? appendToURLPath(partsOfUrl[0], "messages") + "?" + partsOfUrl[1]
97
- : appendToURLPath(partsOfUrl[0], "messages");
98
- this.messagesContext = getStorageClientContext(this._messagesUrl, this.pipeline).messages;
99
- }
100
- getMessageIdContext(messageId) {
101
- // Build the url with messageId
102
- const partsOfUrl = this._messagesUrl.split("?");
103
- const urlWithMessageId = partsOfUrl[1]
104
- ? appendToURLPath(partsOfUrl[0], messageId) + "?" + partsOfUrl[1]
105
- : appendToURLPath(partsOfUrl[0], messageId);
106
- return getStorageClientContext(urlWithMessageId, this.pipeline).messageId;
107
- }
108
- /**
109
- * Creates a new queue under the specified account.
110
- * @see https://learn.microsoft.com/rest/api/storageservices/create-queue4
111
- *
112
- * @param options - Options to Queue create operation.
113
- * @returns Response data for the Queue create operation.
114
- *
115
- * Example usage:
116
- *
117
- * ```ts snippet:ReadmeSampleCreateQueue
118
- * import { QueueServiceClient } from "@azure/storage-queue";
119
- * import { DefaultAzureCredential } from "@azure/identity";
120
- *
121
- * const account = "<account>";
122
- * const queueServiceClient = new QueueServiceClient(
123
- * `https://${account}.queue.core.windows.net`,
124
- * new DefaultAzureCredential(),
125
- * );
126
- *
127
- * const queueName = "<valid queue name>";
128
- * const queueClient = queueServiceClient.getQueueClient(queueName);
129
- * const createQueueResponse = await queueClient.create();
130
- * console.log(
131
- * `Created queue ${queueName} successfully, service assigned request Id: ${createQueueResponse.requestId}`,
132
- * );
133
- * ```
134
- */
135
- async create(options = {}) {
136
- return tracingClient.withSpan("QueueClient-create", options, async (updatedOptions) => {
137
- return assertResponse(await this.queueContext.create(updatedOptions));
138
- });
139
- }
140
- /**
141
- * Creates a new queue under the specified account if it doesn't already exist.
142
- * If the queue already exists, it is not changed.
143
- * @see https://learn.microsoft.com/rest/api/storageservices/create-queue4
144
- *
145
- * @param options -
146
- */
147
- async createIfNotExists(options = {}) {
148
- return tracingClient.withSpan("QueueClient-createIfNotExists", options, async (updatedOptions) => {
149
- try {
150
- const response = await this.create(updatedOptions);
151
- // When a queue with the specified name already exists, the Queue service checks the metadata associated with the existing queue.
152
- // If the existing metadata is identical to the metadata specified on the Create Queue request, status code 204 (No Content) is returned.
153
- // If the existing metadata does not match, the operation fails and status code 409 (Conflict) is returned.
154
- if (response._response.status === 204) {
155
- return {
156
- succeeded: false,
157
- ...response,
158
- };
159
- }
160
- return {
161
- succeeded: true,
162
- ...response,
163
- };
164
- }
165
- catch (e) {
166
- if (e.details?.errorCode === "QueueAlreadyExists") {
167
- return {
168
- succeeded: false,
169
- ...e.response?.parsedHeaders,
170
- _response: e.response,
171
- };
172
- }
173
- throw e;
174
- }
175
- });
176
- }
177
- /**
178
- * Deletes the specified queue permanently if it exists.
179
- * @see https://learn.microsoft.com/rest/api/storageservices/delete-queue3
180
- *
181
- * @param options -
182
- */
183
- async deleteIfExists(options = {}) {
184
- return tracingClient.withSpan("QueueClient-deleteIfExists", options, async (updatedOptions) => {
185
- try {
186
- const res = await this.delete(updatedOptions);
187
- return {
188
- succeeded: true,
189
- ...res,
190
- };
191
- }
192
- catch (e) {
193
- if (e.details?.errorCode === "QueueNotFound") {
194
- return {
195
- succeeded: false,
196
- ...e.response?.parsedHeaders,
197
- _response: e.response,
198
- };
199
- }
200
- throw e;
201
- }
202
- });
203
- }
204
- /**
205
- * Deletes the specified queue permanently.
206
- * @see https://learn.microsoft.com/rest/api/storageservices/delete-queue3
207
- *
208
- * @param options - Options to Queue delete operation.
209
- * @returns Response data for the Queue delete operation.
210
- *
211
- * Example usage:
212
- *
213
- * ```ts snippet:ReadmeSampleDeleteQueue
214
- * import { QueueServiceClient } from "@azure/storage-queue";
215
- * import { DefaultAzureCredential } from "@azure/identity";
216
- *
217
- * const account = "<account>";
218
- * const queueServiceClient = new QueueServiceClient(
219
- * `https://${account}.queue.core.windows.net`,
220
- * new DefaultAzureCredential(),
221
- * );
222
- *
223
- * const queueName = "<valid queue name>";
224
- * const queueClient = queueServiceClient.getQueueClient(queueName);
225
- * const deleteQueueResponse = await queueClient.delete();
226
- * console.log(
227
- * `Deleted queue successfully, service assigned request Id: ${deleteQueueResponse.requestId}`,
228
- * );
229
- * ```
230
- */
231
- async delete(options = {}) {
232
- return tracingClient.withSpan("QueueClient-delete", options, async (updatedOptions) => {
233
- return assertResponse(await this.queueContext.delete({
234
- abortSignal: options.abortSignal,
235
- tracingOptions: updatedOptions.tracingOptions,
236
- }));
237
- });
238
- }
239
- /**
240
- * Returns true if the specified queue exists; false otherwise.
241
- *
242
- * NOTE: use this function with care since an existing queue might be deleted by other clients or
243
- * applications. Vice versa new queues might be added by other clients or applications after this
244
- * function completes.
245
- *
246
- * @param options - options to Exists operation.
247
- */
248
- async exists(options = {}) {
249
- return tracingClient.withSpan("QueueClient-exists", options, async (updatedOptions) => {
250
- try {
251
- await this.getProperties(updatedOptions);
252
- return true;
253
- }
254
- catch (e) {
255
- if (e.statusCode === 404) {
256
- return false;
257
- }
258
- throw e;
259
- }
260
- });
261
- }
262
- /**
263
- * Gets all user-defined metadata and system properties for the specified
264
- * queue. Metadata is associated with the queue as name-values pairs.
265
- * @see https://learn.microsoft.com/rest/api/storageservices/get-queue-metadata
266
- *
267
- * WARNING: The `metadata` object returned in the response will have its keys in lowercase, even if
268
- * they originally contained uppercase characters. This differs from the metadata keys returned by
269
- * the `listQueues` method of {@link QueueServiceClient} using the `includeMetadata` option, which
270
- * will retain their original casing.
271
- *
272
- * @param options - Options to Queue get properties operation.
273
- * @returns Response data for the Queue get properties operation.
274
- */
275
- async getProperties(options = {}) {
276
- return tracingClient.withSpan("QueueClient-getProperties", options, async (updatedOptions) => {
277
- return assertResponse(await this.queueContext.getProperties(updatedOptions));
278
- });
68
+ } else if (extractedCreds.kind === "SASConnString") {
69
+ const queueName = credentialOrPipelineOrQueueName;
70
+ url = appendToURLPath(extractedCreds.url, queueName) + "?" + extractedCreds.accountSas;
71
+ pipeline = newPipeline(new AnonymousCredential(), options);
72
+ } else {
73
+ throw new Error(
74
+ "Connection string must be either an Account connection string or a SAS connection string"
75
+ );
76
+ }
77
+ } else {
78
+ throw new Error("Expecting non-empty strings for queueName parameter");
279
79
  }
280
- /**
281
- * Sets one or more user-defined name-value pairs for the specified queue.
282
- *
283
- * If no option provided, or no metadata defined in the option parameter, the queue
284
- * metadata will be removed.
285
- * @see https://learn.microsoft.com/rest/api/storageservices/set-queue-metadata
286
- *
287
- * @param metadata - If no metadata provided, all existing metadata will be removed.
288
- * @param options - Options to Queue set metadata operation.
289
- * @returns Response data for the Queue set metadata operation.
290
- */
291
- async setMetadata(metadata, options = {}) {
292
- return tracingClient.withSpan("QueueClient-setMetadata", options, async (updatedOptions) => {
293
- return assertResponse(await this.queueContext.setMetadata({
294
- ...updatedOptions,
295
- metadata,
296
- }));
297
- });
298
- }
299
- /**
300
- * Gets details about any stored access policies specified on the queue that may be used with Shared Access Signatures.
301
- *
302
- * WARNING: JavaScript Date will potential lost precision when parsing start and expiry string.
303
- * For example, new Date("2018-12-31T03:44:23.8827891Z").toISOString() will get "2018-12-31T03:44:23.882Z".
304
- *
305
- * @see https://learn.microsoft.com/rest/api/storageservices/get-queue-acl
306
- *
307
- * @param options - Options to Queue get access policy operation.
308
- * @returns Response data for the Queue get access policy operation.
309
- */
310
- async getAccessPolicy(options = {}) {
311
- return tracingClient.withSpan("QueueClient-getAccessPolicy", options, async (updatedOptions) => {
312
- const response = assertResponse(await this.queueContext.getAccessPolicy({
313
- abortSignal: options.abortSignal,
314
- tracingOptions: updatedOptions.tracingOptions,
315
- }));
316
- const res = {
317
- _response: response._response,
318
- date: response.date,
319
- requestId: response.requestId,
320
- clientRequestId: response.clientRequestId,
321
- signedIdentifiers: [],
322
- version: response.version,
323
- errorCode: response.errorCode,
324
- };
325
- for (const identifier of response) {
326
- let accessPolicy = undefined;
327
- if (identifier.accessPolicy) {
328
- accessPolicy = {
329
- permissions: identifier.accessPolicy.permissions,
330
- };
331
- if (identifier.accessPolicy.expiresOn) {
332
- accessPolicy.expiresOn = new Date(identifier.accessPolicy.expiresOn);
333
- }
334
- if (identifier.accessPolicy.startsOn) {
335
- accessPolicy.startsOn = new Date(identifier.accessPolicy.startsOn);
336
- }
337
- }
338
- res.signedIdentifiers.push({
339
- accessPolicy,
340
- id: identifier.id,
341
- });
342
- }
343
- return res;
344
- });
345
- }
346
- /**
347
- * Sets stored access policies for the queue that may be used with Shared Access Signatures.
348
- * @see https://learn.microsoft.com/rest/api/storageservices/set-queue-acl
349
- *
350
- * @param queueAcl -
351
- * @param options - Options to Queue set access policy operation.
352
- * @returns Response data for the Queue set access policy operation.
353
- */
354
- async setAccessPolicy(queueAcl, options = {}) {
355
- return tracingClient.withSpan("QueueClient-setAccessPolicy", options, async (updatedOptions) => {
356
- const acl = [];
357
- for (const identifier of queueAcl || []) {
358
- acl.push({
359
- accessPolicy: {
360
- expiresOn: identifier.accessPolicy.expiresOn
361
- ? truncatedISO8061Date(identifier.accessPolicy.expiresOn)
362
- : undefined,
363
- permissions: identifier.accessPolicy.permissions,
364
- startsOn: identifier.accessPolicy.startsOn
365
- ? truncatedISO8061Date(identifier.accessPolicy.startsOn)
366
- : undefined,
367
- },
368
- id: identifier.id,
369
- });
370
- }
371
- return assertResponse(await this.queueContext.setAccessPolicy({
372
- ...updatedOptions,
373
- queueAcl: acl,
374
- }));
375
- });
376
- }
377
- /**
378
- * Clear deletes all messages from a queue.
379
- * @see https://learn.microsoft.com/rest/api/storageservices/clear-messages
380
- *
381
- * @param options - Options to clear messages operation.
382
- * @returns Response data for the clear messages operation.
383
- */
384
- async clearMessages(options = {}) {
385
- return tracingClient.withSpan("QueueClient-clearMessages", options, async (updatedOptions) => {
386
- return assertResponse(await this.messagesContext.clear(updatedOptions));
387
- });
388
- }
389
- /**
390
- * sendMessage adds a new message to the back of a queue. The visibility timeout specifies how long
391
- * the message should be invisible to Dequeue and Peek operations.
392
- * The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding.
393
- * To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
394
- * @see https://learn.microsoft.com/rest/api/storageservices/put-message
395
- *
396
- * @param messageText - Text of the message to send
397
- * @param options - Options to send messages operation.
398
- * @returns Response data for the send messages operation.
399
- *
400
- * Example usage:
401
- *
402
- * ```ts snippet:ReadmeSampleSendMessage
403
- * import { QueueServiceClient } from "@azure/storage-queue";
404
- * import { DefaultAzureCredential } from "@azure/identity";
405
- *
406
- * const account = "<account>";
407
- * const queueServiceClient = new QueueServiceClient(
408
- * `https://${account}.queue.core.windows.net`,
409
- * new DefaultAzureCredential(),
410
- * );
411
- *
412
- * const queueName = "<valid queue name>";
413
- * const queueClient = queueServiceClient.getQueueClient(queueName);
414
- * // Send a message into the queue using the sendMessage method.
415
- * const sendMessageResponse = await queueClient.sendMessage("Hello World!");
416
- * console.log(
417
- * `Sent message successfully, service assigned message Id: ${sendMessageResponse.messageId}, service assigned request Id: ${sendMessageResponse.requestId}`,
418
- * );
419
- * ```
420
- */
421
- async sendMessage(messageText, options = {}) {
422
- return tracingClient.withSpan("QueueClient-sendMessage", options, async (updatedOptions) => {
423
- const response = assertResponse(await this.messagesContext.enqueue({
424
- messageText: messageText,
425
- }, updatedOptions));
426
- const item = response[0];
80
+ super(url, pipeline);
81
+ this._name = this.getQueueNameFromUrl();
82
+ this.queueContext = this.storageClientContext.queue;
83
+ const partsOfUrl = this.url.split("?");
84
+ this._messagesUrl = partsOfUrl[1] ? appendToURLPath(partsOfUrl[0], "messages") + "?" + partsOfUrl[1] : appendToURLPath(partsOfUrl[0], "messages");
85
+ this.messagesContext = getStorageClientContext(this._messagesUrl, this.pipeline).messages;
86
+ }
87
+ getMessageIdContext(messageId) {
88
+ const partsOfUrl = this._messagesUrl.split("?");
89
+ const urlWithMessageId = partsOfUrl[1] ? appendToURLPath(partsOfUrl[0], messageId) + "?" + partsOfUrl[1] : appendToURLPath(partsOfUrl[0], messageId);
90
+ return getStorageClientContext(urlWithMessageId, this.pipeline).messageId;
91
+ }
92
+ /**
93
+ * Creates a new queue under the specified account.
94
+ * @see https://learn.microsoft.com/rest/api/storageservices/create-queue4
95
+ *
96
+ * @param options - Options to Queue create operation.
97
+ * @returns Response data for the Queue create operation.
98
+ *
99
+ * Example usage:
100
+ *
101
+ * ```ts snippet:ReadmeSampleCreateQueue
102
+ * import { QueueServiceClient } from "@azure/storage-queue";
103
+ * import { DefaultAzureCredential } from "@azure/identity";
104
+ *
105
+ * const account = "<account>";
106
+ * const queueServiceClient = new QueueServiceClient(
107
+ * `https://${account}.queue.core.windows.net`,
108
+ * new DefaultAzureCredential(),
109
+ * );
110
+ *
111
+ * const queueName = "<valid queue name>";
112
+ * const queueClient = queueServiceClient.getQueueClient(queueName);
113
+ * const createQueueResponse = await queueClient.create();
114
+ * console.log(
115
+ * `Created queue ${queueName} successfully, service assigned request Id: ${createQueueResponse.requestId}`,
116
+ * );
117
+ * ```
118
+ */
119
+ async create(options = {}) {
120
+ return tracingClient.withSpan("QueueClient-create", options, async (updatedOptions) => {
121
+ return assertResponse(
122
+ await this.queueContext.create(updatedOptions)
123
+ );
124
+ });
125
+ }
126
+ /**
127
+ * Creates a new queue under the specified account if it doesn't already exist.
128
+ * If the queue already exists, it is not changed.
129
+ * @see https://learn.microsoft.com/rest/api/storageservices/create-queue4
130
+ *
131
+ * @param options -
132
+ */
133
+ async createIfNotExists(options = {}) {
134
+ return tracingClient.withSpan(
135
+ "QueueClient-createIfNotExists",
136
+ options,
137
+ async (updatedOptions) => {
138
+ try {
139
+ const response = await this.create(updatedOptions);
140
+ if (response._response.status === 204) {
427
141
  return {
428
- _response: response._response,
429
- date: response.date,
430
- requestId: response.requestId,
431
- clientRequestId: response.clientRequestId,
432
- version: response.version,
433
- errorCode: response.errorCode,
434
- messageId: item.messageId,
435
- popReceipt: item.popReceipt,
436
- nextVisibleOn: item.nextVisibleOn,
437
- insertedOn: item.insertedOn,
438
- expiresOn: item.expiresOn,
142
+ succeeded: false,
143
+ ...response
439
144
  };
440
- });
441
- }
442
- /**
443
- * receiveMessages retrieves one or more messages from the front of the queue.
444
- * @see https://learn.microsoft.com/rest/api/storageservices/get-messages
445
- *
446
- * @param options - Options to receive messages operation.
447
- * @returns Response data for the receive messages operation.
448
- *
449
- * Example usage:
450
- *
451
- * ```ts snippet:ReadmeSampleReceiveMessage
452
- * import { QueueServiceClient } from "@azure/storage-queue";
453
- * import { DefaultAzureCredential } from "@azure/identity";
454
- *
455
- * const account = "<account>";
456
- * const queueServiceClient = new QueueServiceClient(
457
- * `https://${account}.queue.core.windows.net`,
458
- * new DefaultAzureCredential(),
459
- * );
460
- *
461
- * const queueName = "<valid queue name>";
462
- * const queueClient = queueServiceClient.getQueueClient(queueName);
463
- * const response = await queueClient.receiveMessages();
464
- * if (response.receivedMessageItems.length === 1) {
465
- * const receivedMessageItem = response.receivedMessageItems[0];
466
- * console.log(`Processing & deleting message with content: ${receivedMessageItem.messageText}`);
467
- * const deleteMessageResponse = await queueClient.deleteMessage(
468
- * receivedMessageItem.messageId,
469
- * receivedMessageItem.popReceipt,
470
- * );
471
- * console.log(
472
- * `Delete message successfully, service assigned request Id: ${deleteMessageResponse.requestId}`,
473
- * );
474
- * }
475
- * ```
476
- */
477
- async receiveMessages(options = {}) {
478
- return tracingClient.withSpan("QueueClient-receiveMessages", options, async (updatedOptions) => {
479
- const response = assertResponse(await this.messagesContext.dequeue(updatedOptions));
480
- const res = {
481
- _response: response._response,
482
- date: response.date,
483
- requestId: response.requestId,
484
- clientRequestId: response.clientRequestId,
485
- receivedMessageItems: [],
486
- version: response.version,
487
- errorCode: response.errorCode,
145
+ }
146
+ return {
147
+ succeeded: true,
148
+ ...response
149
+ };
150
+ } catch (e) {
151
+ if (e.details?.errorCode === "QueueAlreadyExists") {
152
+ return {
153
+ succeeded: false,
154
+ ...e.response?.parsedHeaders,
155
+ _response: e.response
488
156
  };
489
- for (const item of response) {
490
- res.receivedMessageItems.push(item);
491
- }
492
- return res;
493
- });
494
- }
495
- /**
496
- * peekMessages retrieves one or more messages from the front of the queue but does not alter the visibility of the message.
497
- * @see https://learn.microsoft.com/rest/api/storageservices/peek-messages
498
- *
499
- * @param options - Options to peek messages operation.
500
- * @returns Response data for the peek messages operation.
501
- *
502
- * Example usage:
503
- *
504
- * ```ts snippet:ReadmeSamplePeekMessage
505
- * import { QueueServiceClient } from "@azure/storage-queue";
506
- * import { DefaultAzureCredential } from "@azure/identity";
507
- *
508
- * const account = "<account>";
509
- * const queueServiceClient = new QueueServiceClient(
510
- * `https://${account}.queue.core.windows.net`,
511
- * new DefaultAzureCredential(),
512
- * );
513
- *
514
- * const queueName = "<valid queue name>";
515
- * const queueClient = queueServiceClient.getQueueClient(queueName);
516
- * const peekMessagesResponse = await queueClient.peekMessages();
517
- * console.log(`The peeked message is: ${peekMessagesResponse.peekedMessageItems[0].messageText}`);
518
- * ```
519
- */
520
- async peekMessages(options = {}) {
521
- return tracingClient.withSpan("QueueClient-peekMessages", options, async (updatedOptions) => {
522
- const response = assertResponse(await this.messagesContext.peek(updatedOptions));
523
- const res = {
524
- _response: response._response,
525
- date: response.date,
526
- requestId: response.requestId,
527
- clientRequestId: response.clientRequestId,
528
- peekedMessageItems: [],
529
- version: response.version,
530
- errorCode: response.errorCode,
157
+ }
158
+ throw e;
159
+ }
160
+ }
161
+ );
162
+ }
163
+ /**
164
+ * Deletes the specified queue permanently if it exists.
165
+ * @see https://learn.microsoft.com/rest/api/storageservices/delete-queue3
166
+ *
167
+ * @param options -
168
+ */
169
+ async deleteIfExists(options = {}) {
170
+ return tracingClient.withSpan("QueueClient-deleteIfExists", options, async (updatedOptions) => {
171
+ try {
172
+ const res = await this.delete(updatedOptions);
173
+ return {
174
+ succeeded: true,
175
+ ...res
176
+ };
177
+ } catch (e) {
178
+ if (e.details?.errorCode === "QueueNotFound") {
179
+ return {
180
+ succeeded: false,
181
+ ...e.response?.parsedHeaders,
182
+ _response: e.response
183
+ };
184
+ }
185
+ throw e;
186
+ }
187
+ });
188
+ }
189
+ /**
190
+ * Deletes the specified queue permanently.
191
+ * @see https://learn.microsoft.com/rest/api/storageservices/delete-queue3
192
+ *
193
+ * @param options - Options to Queue delete operation.
194
+ * @returns Response data for the Queue delete operation.
195
+ *
196
+ * Example usage:
197
+ *
198
+ * ```ts snippet:ReadmeSampleDeleteQueue
199
+ * import { QueueServiceClient } from "@azure/storage-queue";
200
+ * import { DefaultAzureCredential } from "@azure/identity";
201
+ *
202
+ * const account = "<account>";
203
+ * const queueServiceClient = new QueueServiceClient(
204
+ * `https://${account}.queue.core.windows.net`,
205
+ * new DefaultAzureCredential(),
206
+ * );
207
+ *
208
+ * const queueName = "<valid queue name>";
209
+ * const queueClient = queueServiceClient.getQueueClient(queueName);
210
+ * const deleteQueueResponse = await queueClient.delete();
211
+ * console.log(
212
+ * `Deleted queue successfully, service assigned request Id: ${deleteQueueResponse.requestId}`,
213
+ * );
214
+ * ```
215
+ */
216
+ async delete(options = {}) {
217
+ return tracingClient.withSpan("QueueClient-delete", options, async (updatedOptions) => {
218
+ return assertResponse(
219
+ await this.queueContext.delete({
220
+ abortSignal: options.abortSignal,
221
+ tracingOptions: updatedOptions.tracingOptions
222
+ })
223
+ );
224
+ });
225
+ }
226
+ /**
227
+ * Returns true if the specified queue exists; false otherwise.
228
+ *
229
+ * NOTE: use this function with care since an existing queue might be deleted by other clients or
230
+ * applications. Vice versa new queues might be added by other clients or applications after this
231
+ * function completes.
232
+ *
233
+ * @param options - options to Exists operation.
234
+ */
235
+ async exists(options = {}) {
236
+ return tracingClient.withSpan("QueueClient-exists", options, async (updatedOptions) => {
237
+ try {
238
+ await this.getProperties(updatedOptions);
239
+ return true;
240
+ } catch (e) {
241
+ if (e.statusCode === 404) {
242
+ return false;
243
+ }
244
+ throw e;
245
+ }
246
+ });
247
+ }
248
+ /**
249
+ * Gets all user-defined metadata and system properties for the specified
250
+ * queue. Metadata is associated with the queue as name-values pairs.
251
+ * @see https://learn.microsoft.com/rest/api/storageservices/get-queue-metadata
252
+ *
253
+ * WARNING: The `metadata` object returned in the response will have its keys in lowercase, even if
254
+ * they originally contained uppercase characters. This differs from the metadata keys returned by
255
+ * the `listQueues` method of {@link QueueServiceClient} using the `includeMetadata` option, which
256
+ * will retain their original casing.
257
+ *
258
+ * @param options - Options to Queue get properties operation.
259
+ * @returns Response data for the Queue get properties operation.
260
+ */
261
+ async getProperties(options = {}) {
262
+ return tracingClient.withSpan("QueueClient-getProperties", options, async (updatedOptions) => {
263
+ return assertResponse(
264
+ await this.queueContext.getProperties(updatedOptions)
265
+ );
266
+ });
267
+ }
268
+ /**
269
+ * Sets one or more user-defined name-value pairs for the specified queue.
270
+ *
271
+ * If no option provided, or no metadata defined in the option parameter, the queue
272
+ * metadata will be removed.
273
+ * @see https://learn.microsoft.com/rest/api/storageservices/set-queue-metadata
274
+ *
275
+ * @param metadata - If no metadata provided, all existing metadata will be removed.
276
+ * @param options - Options to Queue set metadata operation.
277
+ * @returns Response data for the Queue set metadata operation.
278
+ */
279
+ async setMetadata(metadata, options = {}) {
280
+ return tracingClient.withSpan("QueueClient-setMetadata", options, async (updatedOptions) => {
281
+ return assertResponse(
282
+ await this.queueContext.setMetadata({
283
+ ...updatedOptions,
284
+ metadata
285
+ })
286
+ );
287
+ });
288
+ }
289
+ /**
290
+ * Gets details about any stored access policies specified on the queue that may be used with Shared Access Signatures.
291
+ *
292
+ * WARNING: JavaScript Date will potential lost precision when parsing start and expiry string.
293
+ * For example, new Date("2018-12-31T03:44:23.8827891Z").toISOString() will get "2018-12-31T03:44:23.882Z".
294
+ *
295
+ * @see https://learn.microsoft.com/rest/api/storageservices/get-queue-acl
296
+ *
297
+ * @param options - Options to Queue get access policy operation.
298
+ * @returns Response data for the Queue get access policy operation.
299
+ */
300
+ async getAccessPolicy(options = {}) {
301
+ return tracingClient.withSpan(
302
+ "QueueClient-getAccessPolicy",
303
+ options,
304
+ async (updatedOptions) => {
305
+ const response = assertResponse(
306
+ await this.queueContext.getAccessPolicy({
307
+ abortSignal: options.abortSignal,
308
+ tracingOptions: updatedOptions.tracingOptions
309
+ })
310
+ );
311
+ const res = {
312
+ _response: response._response,
313
+ date: response.date,
314
+ requestId: response.requestId,
315
+ clientRequestId: response.clientRequestId,
316
+ signedIdentifiers: [],
317
+ version: response.version,
318
+ errorCode: response.errorCode
319
+ };
320
+ for (const identifier of response) {
321
+ let accessPolicy = void 0;
322
+ if (identifier.accessPolicy) {
323
+ accessPolicy = {
324
+ permissions: identifier.accessPolicy.permissions
531
325
  };
532
- for (const item of response) {
533
- res.peekedMessageItems.push(item);
326
+ if (identifier.accessPolicy.expiresOn) {
327
+ accessPolicy.expiresOn = new Date(identifier.accessPolicy.expiresOn);
534
328
  }
535
- return res;
536
- });
537
- }
538
- /**
539
- * deleteMessage permanently removes the specified message from its queue.
540
- * @see https://learn.microsoft.com/rest/api/storageservices/delete-message2
541
- *
542
- * @param messageId - Id of the message.
543
- * @param popReceipt - A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
544
- * @param options - Options to delete message operation.
545
- * @returns Response data for the delete message operation.
546
- */
547
- async deleteMessage(messageId, popReceipt, options = {}) {
548
- return tracingClient.withSpan("QueueClient-deleteMessage", options, async (updatedOptions) => {
549
- return assertResponse(await this.getMessageIdContext(messageId).delete(popReceipt, updatedOptions));
550
- });
551
- }
552
- /**
553
- * Update changes a message's visibility timeout and contents.
554
- * The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding.
555
- * To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
556
- * @see https://learn.microsoft.com/rest/api/storageservices/update-message
557
- *
558
- * @param messageId - Id of the message
559
- * @param popReceipt - A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
560
- * @param message - Message to update. If this parameter is undefined, then the content of the message won't be updated.
561
- * @param visibilityTimeout - Specifies the new visibility timeout value, in seconds,
562
- * relative to server time. The new value must be larger than or equal to 0,
563
- * and cannot be larger than 7 days. The visibility timeout of a message cannot
564
- * be set to a value later than the expiry time.
565
- * A message can be updated until it has been deleted or has expired.
566
- * @param options - Options to update message operation.
567
- * @returns Response data for the update message operation.
568
- */
569
- async updateMessage(messageId, popReceipt, message, visibilityTimeout, options = {}) {
570
- return tracingClient.withSpan("QueueClient-updateMessage", options, async (updatedOptions) => {
571
- let queueMessage = undefined;
572
- if (message !== undefined) {
573
- queueMessage = { messageText: message };
574
- }
575
- return assertResponse(await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, {
576
- abortSignal: options.abortSignal,
577
- tracingOptions: updatedOptions.tracingOptions,
578
- queueMessage,
579
- }));
580
- });
581
- }
582
- getQueueNameFromUrl() {
583
- let queueName;
584
- try {
585
- // URL may look like the following
586
- // "https://myaccount.queue.core.windows.net/myqueue?sasString".
587
- // "https://myaccount.queue.core.windows.net/myqueue".
588
- // IPv4/IPv6 address hosts, Endpoints - `http://127.0.0.1:10001/devstoreaccount1/myqueue`
589
- // http://localhost:10001/devstoreaccount1/queuename
590
- const parsedUrl = new URL(this.url);
591
- if (parsedUrl.hostname.split(".")[1] === "queue") {
592
- // "https://myaccount.queue.core.windows.net/queuename".
593
- // .getPath() -> /queuename
594
- queueName = parsedUrl.pathname.split("/")[1];
595
- }
596
- else if (isIpEndpointStyle(parsedUrl)) {
597
- // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/queuename
598
- // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/queuename
599
- // .getPath() -> /devstoreaccount1/queuename
600
- queueName = parsedUrl.pathname.split("/")[2];
329
+ if (identifier.accessPolicy.startsOn) {
330
+ accessPolicy.startsOn = new Date(identifier.accessPolicy.startsOn);
601
331
  }
602
- else {
603
- // "https://customdomain.com/queuename".
604
- // .getPath() -> /queuename
605
- queueName = parsedUrl.pathname.split("/")[1];
606
- }
607
- if (!queueName) {
608
- throw new Error("Provided queueName is invalid.");
609
- }
610
- return queueName;
332
+ }
333
+ res.signedIdentifiers.push({
334
+ accessPolicy,
335
+ id: identifier.id
336
+ });
611
337
  }
612
- catch (error) {
613
- throw new Error("Unable to extract queueName with provided information.");
338
+ return res;
339
+ }
340
+ );
341
+ }
342
+ /**
343
+ * Sets stored access policies for the queue that may be used with Shared Access Signatures.
344
+ * @see https://learn.microsoft.com/rest/api/storageservices/set-queue-acl
345
+ *
346
+ * @param queueAcl -
347
+ * @param options - Options to Queue set access policy operation.
348
+ * @returns Response data for the Queue set access policy operation.
349
+ */
350
+ async setAccessPolicy(queueAcl, options = {}) {
351
+ return tracingClient.withSpan(
352
+ "QueueClient-setAccessPolicy",
353
+ options,
354
+ async (updatedOptions) => {
355
+ const acl = [];
356
+ for (const identifier of queueAcl || []) {
357
+ acl.push({
358
+ accessPolicy: {
359
+ expiresOn: identifier.accessPolicy.expiresOn ? truncatedISO8061Date(identifier.accessPolicy.expiresOn) : void 0,
360
+ permissions: identifier.accessPolicy.permissions,
361
+ startsOn: identifier.accessPolicy.startsOn ? truncatedISO8061Date(identifier.accessPolicy.startsOn) : void 0
362
+ },
363
+ id: identifier.id
364
+ });
614
365
  }
615
- }
616
- /**
617
- * Only available for QueueClient constructed with a shared key credential.
618
- *
619
- * Generates a Service Shared Access Signature (SAS) URI based on the client properties
620
- * and parameters passed in. The SAS is signed by the shared key credential of the client.
621
- *
622
- * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
623
- *
624
- * @param options - Optional parameters.
625
- * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
626
- */
627
- generateSasUrl(options) {
628
- if (!(this.credential instanceof StorageSharedKeyCredential)) {
629
- throw RangeError("Can only generate the SAS when the client is initialized with a shared key credential");
630
- }
631
- const sas = generateQueueSASQueryParameters({
632
- queueName: this.name,
633
- ...options,
634
- }, this.credential).toString();
635
- return appendToURLQuery(this.url, sas);
636
- }
637
- /**
638
- * Only available for QueueClient constructed with a shared key credential.
639
- *
640
- * Generates string to sign for a Service Shared Access Signature (SAS) URI based on the client properties
641
- * and parameters passed in. The SAS is signed by the shared key credential of the client.
642
- *
643
- * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
644
- *
645
- * @param options - Optional parameters.
646
- * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
647
- */
648
- /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/
649
- generateSasStringToSign(options) {
650
- if (!(this.credential instanceof StorageSharedKeyCredential)) {
651
- throw RangeError("Can only generate the SAS when the client is initialized with a shared key credential");
366
+ return assertResponse(
367
+ await this.queueContext.setAccessPolicy({
368
+ ...updatedOptions,
369
+ queueAcl: acl
370
+ })
371
+ );
372
+ }
373
+ );
374
+ }
375
+ /**
376
+ * Clear deletes all messages from a queue.
377
+ * @see https://learn.microsoft.com/rest/api/storageservices/clear-messages
378
+ *
379
+ * @param options - Options to clear messages operation.
380
+ * @returns Response data for the clear messages operation.
381
+ */
382
+ async clearMessages(options = {}) {
383
+ return tracingClient.withSpan("QueueClient-clearMessages", options, async (updatedOptions) => {
384
+ return assertResponse(
385
+ await this.messagesContext.clear(updatedOptions)
386
+ );
387
+ });
388
+ }
389
+ /**
390
+ * sendMessage adds a new message to the back of a queue. The visibility timeout specifies how long
391
+ * the message should be invisible to Dequeue and Peek operations.
392
+ * The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding.
393
+ * To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
394
+ * @see https://learn.microsoft.com/rest/api/storageservices/put-message
395
+ *
396
+ * @param messageText - Text of the message to send
397
+ * @param options - Options to send messages operation.
398
+ * @returns Response data for the send messages operation.
399
+ *
400
+ * Example usage:
401
+ *
402
+ * ```ts snippet:ReadmeSampleSendMessage
403
+ * import { QueueServiceClient } from "@azure/storage-queue";
404
+ * import { DefaultAzureCredential } from "@azure/identity";
405
+ *
406
+ * const account = "<account>";
407
+ * const queueServiceClient = new QueueServiceClient(
408
+ * `https://${account}.queue.core.windows.net`,
409
+ * new DefaultAzureCredential(),
410
+ * );
411
+ *
412
+ * const queueName = "<valid queue name>";
413
+ * const queueClient = queueServiceClient.getQueueClient(queueName);
414
+ * // Send a message into the queue using the sendMessage method.
415
+ * const sendMessageResponse = await queueClient.sendMessage("Hello World!");
416
+ * console.log(
417
+ * `Sent message successfully, service assigned message Id: ${sendMessageResponse.messageId}, service assigned request Id: ${sendMessageResponse.requestId}`,
418
+ * );
419
+ * ```
420
+ */
421
+ async sendMessage(messageText, options = {}) {
422
+ return tracingClient.withSpan("QueueClient-sendMessage", options, async (updatedOptions) => {
423
+ const response = assertResponse(
424
+ await this.messagesContext.enqueue(
425
+ {
426
+ messageText
427
+ },
428
+ updatedOptions
429
+ )
430
+ );
431
+ const item = response[0];
432
+ return {
433
+ _response: response._response,
434
+ date: response.date,
435
+ requestId: response.requestId,
436
+ clientRequestId: response.clientRequestId,
437
+ version: response.version,
438
+ errorCode: response.errorCode,
439
+ messageId: item.messageId,
440
+ popReceipt: item.popReceipt,
441
+ nextVisibleOn: item.nextVisibleOn,
442
+ insertedOn: item.insertedOn,
443
+ expiresOn: item.expiresOn
444
+ };
445
+ });
446
+ }
447
+ /**
448
+ * receiveMessages retrieves one or more messages from the front of the queue.
449
+ * @see https://learn.microsoft.com/rest/api/storageservices/get-messages
450
+ *
451
+ * @param options - Options to receive messages operation.
452
+ * @returns Response data for the receive messages operation.
453
+ *
454
+ * Example usage:
455
+ *
456
+ * ```ts snippet:ReadmeSampleReceiveMessage
457
+ * import { QueueServiceClient } from "@azure/storage-queue";
458
+ * import { DefaultAzureCredential } from "@azure/identity";
459
+ *
460
+ * const account = "<account>";
461
+ * const queueServiceClient = new QueueServiceClient(
462
+ * `https://${account}.queue.core.windows.net`,
463
+ * new DefaultAzureCredential(),
464
+ * );
465
+ *
466
+ * const queueName = "<valid queue name>";
467
+ * const queueClient = queueServiceClient.getQueueClient(queueName);
468
+ * const response = await queueClient.receiveMessages();
469
+ * if (response.receivedMessageItems.length === 1) {
470
+ * const receivedMessageItem = response.receivedMessageItems[0];
471
+ * console.log(`Processing & deleting message with content: ${receivedMessageItem.messageText}`);
472
+ * const deleteMessageResponse = await queueClient.deleteMessage(
473
+ * receivedMessageItem.messageId,
474
+ * receivedMessageItem.popReceipt,
475
+ * );
476
+ * console.log(
477
+ * `Delete message successfully, service assigned request Id: ${deleteMessageResponse.requestId}`,
478
+ * );
479
+ * }
480
+ * ```
481
+ */
482
+ async receiveMessages(options = {}) {
483
+ return tracingClient.withSpan(
484
+ "QueueClient-receiveMessages",
485
+ options,
486
+ async (updatedOptions) => {
487
+ const response = assertResponse(await this.messagesContext.dequeue(updatedOptions));
488
+ const res = {
489
+ _response: response._response,
490
+ date: response.date,
491
+ requestId: response.requestId,
492
+ clientRequestId: response.clientRequestId,
493
+ receivedMessageItems: [],
494
+ version: response.version,
495
+ errorCode: response.errorCode
496
+ };
497
+ for (const item of response) {
498
+ res.receivedMessageItems.push(item);
652
499
  }
653
- return generateQueueSASQueryParametersInternal({
654
- queueName: this.name,
655
- ...options,
656
- }, this.credential).stringToSign;
500
+ return res;
501
+ }
502
+ );
503
+ }
504
+ /**
505
+ * peekMessages retrieves one or more messages from the front of the queue but does not alter the visibility of the message.
506
+ * @see https://learn.microsoft.com/rest/api/storageservices/peek-messages
507
+ *
508
+ * @param options - Options to peek messages operation.
509
+ * @returns Response data for the peek messages operation.
510
+ *
511
+ * Example usage:
512
+ *
513
+ * ```ts snippet:ReadmeSamplePeekMessage
514
+ * import { QueueServiceClient } from "@azure/storage-queue";
515
+ * import { DefaultAzureCredential } from "@azure/identity";
516
+ *
517
+ * const account = "<account>";
518
+ * const queueServiceClient = new QueueServiceClient(
519
+ * `https://${account}.queue.core.windows.net`,
520
+ * new DefaultAzureCredential(),
521
+ * );
522
+ *
523
+ * const queueName = "<valid queue name>";
524
+ * const queueClient = queueServiceClient.getQueueClient(queueName);
525
+ * const peekMessagesResponse = await queueClient.peekMessages();
526
+ * console.log(`The peeked message is: ${peekMessagesResponse.peekedMessageItems[0].messageText}`);
527
+ * ```
528
+ */
529
+ async peekMessages(options = {}) {
530
+ return tracingClient.withSpan("QueueClient-peekMessages", options, async (updatedOptions) => {
531
+ const response = assertResponse(await this.messagesContext.peek(updatedOptions));
532
+ const res = {
533
+ _response: response._response,
534
+ date: response.date,
535
+ requestId: response.requestId,
536
+ clientRequestId: response.clientRequestId,
537
+ peekedMessageItems: [],
538
+ version: response.version,
539
+ errorCode: response.errorCode
540
+ };
541
+ for (const item of response) {
542
+ res.peekedMessageItems.push(item);
543
+ }
544
+ return res;
545
+ });
546
+ }
547
+ /**
548
+ * deleteMessage permanently removes the specified message from its queue.
549
+ * @see https://learn.microsoft.com/rest/api/storageservices/delete-message2
550
+ *
551
+ * @param messageId - Id of the message.
552
+ * @param popReceipt - A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
553
+ * @param options - Options to delete message operation.
554
+ * @returns Response data for the delete message operation.
555
+ */
556
+ async deleteMessage(messageId, popReceipt, options = {}) {
557
+ return tracingClient.withSpan("QueueClient-deleteMessage", options, async (updatedOptions) => {
558
+ return assertResponse(
559
+ await this.getMessageIdContext(messageId).delete(popReceipt, updatedOptions)
560
+ );
561
+ });
562
+ }
563
+ /**
564
+ * Update changes a message's visibility timeout and contents.
565
+ * The message content is up to 64KB in size, and must be in a format that can be included in an XML request with UTF-8 encoding.
566
+ * To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode.
567
+ * @see https://learn.microsoft.com/rest/api/storageservices/update-message
568
+ *
569
+ * @param messageId - Id of the message
570
+ * @param popReceipt - A valid pop receipt value returned from an earlier call to the receive messages or update message operation.
571
+ * @param message - Message to update. If this parameter is undefined, then the content of the message won't be updated.
572
+ * @param visibilityTimeout - Specifies the new visibility timeout value, in seconds,
573
+ * relative to server time. The new value must be larger than or equal to 0,
574
+ * and cannot be larger than 7 days. The visibility timeout of a message cannot
575
+ * be set to a value later than the expiry time.
576
+ * A message can be updated until it has been deleted or has expired.
577
+ * @param options - Options to update message operation.
578
+ * @returns Response data for the update message operation.
579
+ */
580
+ async updateMessage(messageId, popReceipt, message, visibilityTimeout, options = {}) {
581
+ return tracingClient.withSpan("QueueClient-updateMessage", options, async (updatedOptions) => {
582
+ let queueMessage = void 0;
583
+ if (message !== void 0) {
584
+ queueMessage = { messageText: message };
585
+ }
586
+ return assertResponse(
587
+ await this.getMessageIdContext(messageId).update(popReceipt, visibilityTimeout || 0, {
588
+ abortSignal: options.abortSignal,
589
+ tracingOptions: updatedOptions.tracingOptions,
590
+ queueMessage
591
+ })
592
+ );
593
+ });
594
+ }
595
+ getQueueNameFromUrl() {
596
+ let queueName;
597
+ try {
598
+ const parsedUrl = new URL(this.url);
599
+ if (parsedUrl.hostname.split(".")[1] === "queue") {
600
+ queueName = parsedUrl.pathname.split("/")[1];
601
+ } else if (isIpEndpointStyle(parsedUrl)) {
602
+ queueName = parsedUrl.pathname.split("/")[2];
603
+ } else {
604
+ queueName = parsedUrl.pathname.split("/")[1];
605
+ }
606
+ if (!queueName) {
607
+ throw new Error("Provided queueName is invalid.");
608
+ }
609
+ return queueName;
610
+ } catch (error) {
611
+ throw new Error("Unable to extract queueName with provided information.");
657
612
  }
658
- /**
659
- *
660
- * Generates a Service Shared Access Signature (SAS) URI based on the client properties
661
- * and parameters passed in. The SAS is signed by the user delegation key credential input.
662
- *
663
- * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
664
- *
665
- * @param options - Optional parameters.
666
- * @param userDelegationKey - user delegation key used to sign the SAS URI
667
- * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
668
- */
669
- generateUserDelegationSasUrl(options, userDelegationKey) {
670
- const sas = generateQueueSASQueryParameters({
671
- queueName: this.name,
672
- ...options,
673
- }, userDelegationKey, this.accountName).toString();
674
- return appendToURLQuery(this.url, sas);
613
+ }
614
+ /**
615
+ * Only available for QueueClient constructed with a shared key credential.
616
+ *
617
+ * Generates a Service Shared Access Signature (SAS) URI based on the client properties
618
+ * and parameters passed in. The SAS is signed by the shared key credential of the client.
619
+ *
620
+ * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
621
+ *
622
+ * @param options - Optional parameters.
623
+ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
624
+ */
625
+ generateSasUrl(options) {
626
+ if (!(this.credential instanceof StorageSharedKeyCredential)) {
627
+ throw RangeError(
628
+ "Can only generate the SAS when the client is initialized with a shared key credential"
629
+ );
675
630
  }
676
- /**
677
- *
678
- * Generates a Service Shared Access Signature (SAS) URI based on the client properties
679
- * and parameters passed in. The SAS is signed by the user delegation key credential input.
680
- *
681
- * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
682
- *
683
- * @param options - Optional parameters.
684
- * @param userDelegationKey - user delegation key used to sign the SAS URI
685
- * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
686
- */
687
- generateUserDelegationStringToSign(options, userDelegationKey) {
688
- return generateQueueSASQueryParametersInternal({
689
- queueName: this.name,
690
- ...options,
691
- }, userDelegationKey, this.accountName).stringToSign;
631
+ const sas = generateQueueSASQueryParameters(
632
+ {
633
+ queueName: this.name,
634
+ ...options
635
+ },
636
+ this.credential
637
+ ).toString();
638
+ return appendToURLQuery(this.url, sas);
639
+ }
640
+ /**
641
+ * Only available for QueueClient constructed with a shared key credential.
642
+ *
643
+ * Generates string to sign for a Service Shared Access Signature (SAS) URI based on the client properties
644
+ * and parameters passed in. The SAS is signed by the shared key credential of the client.
645
+ *
646
+ * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
647
+ *
648
+ * @param options - Optional parameters.
649
+ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
650
+ */
651
+ /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options*/
652
+ generateSasStringToSign(options) {
653
+ if (!(this.credential instanceof StorageSharedKeyCredential)) {
654
+ throw RangeError(
655
+ "Can only generate the SAS when the client is initialized with a shared key credential"
656
+ );
692
657
  }
658
+ return generateQueueSASQueryParametersInternal(
659
+ {
660
+ queueName: this.name,
661
+ ...options
662
+ },
663
+ this.credential
664
+ ).stringToSign;
665
+ }
666
+ /**
667
+ *
668
+ * Generates a Service Shared Access Signature (SAS) URI based on the client properties
669
+ * and parameters passed in. The SAS is signed by the user delegation key credential input.
670
+ *
671
+ * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
672
+ *
673
+ * @param options - Optional parameters.
674
+ * @param userDelegationKey - user delegation key used to sign the SAS URI
675
+ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
676
+ */
677
+ generateUserDelegationSasUrl(options, userDelegationKey) {
678
+ const sas = generateQueueSASQueryParameters(
679
+ {
680
+ queueName: this.name,
681
+ ...options
682
+ },
683
+ userDelegationKey,
684
+ this.accountName
685
+ ).toString();
686
+ return appendToURLQuery(this.url, sas);
687
+ }
688
+ /**
689
+ *
690
+ * Generates a Service Shared Access Signature (SAS) URI based on the client properties
691
+ * and parameters passed in. The SAS is signed by the user delegation key credential input.
692
+ *
693
+ * @see https://learn.microsoft.com/rest/api/storageservices/constructing-a-service-sas
694
+ *
695
+ * @param options - Optional parameters.
696
+ * @param userDelegationKey - user delegation key used to sign the SAS URI
697
+ * @returns The SAS URI consisting of the URI to the resource represented by this client, followed by the generated SAS token.
698
+ */
699
+ generateUserDelegationStringToSign(options, userDelegationKey) {
700
+ return generateQueueSASQueryParametersInternal(
701
+ {
702
+ queueName: this.name,
703
+ ...options
704
+ },
705
+ userDelegationKey,
706
+ this.accountName
707
+ ).stringToSign;
708
+ }
693
709
  }
694
- //# sourceMappingURL=QueueClient.js.map
710
+ export {
711
+ QueueClient
712
+ };