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