@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.
- package/dist/browser/Pipeline.d.ts +2 -3
- package/dist/browser/Pipeline.d.ts.map +1 -1
- package/dist/browser/Pipeline.js.map +1 -1
- package/dist/browser/QueueClient.d.ts +2 -1
- package/dist/browser/QueueClient.d.ts.map +1 -1
- package/dist/browser/QueueClient.js.map +1 -1
- package/dist/browser/QueueSASSignatureValues.d.ts +2 -1
- package/dist/browser/QueueSASSignatureValues.d.ts.map +1 -1
- package/dist/browser/QueueSASSignatureValues.js +2 -2
- package/dist/browser/QueueSASSignatureValues.js.map +1 -1
- package/dist/browser/QueueServiceClient.d.ts +28 -0
- package/dist/browser/QueueServiceClient.d.ts.map +1 -1
- package/dist/browser/QueueServiceClient.js +21 -13
- package/dist/browser/QueueServiceClient.js.map +1 -1
- package/dist/browser/SASQueryParameters.d.ts +6 -1
- package/dist/browser/SASQueryParameters.d.ts.map +1 -1
- package/dist/browser/SASQueryParameters.js +10 -0
- package/dist/browser/SASQueryParameters.js.map +1 -1
- package/dist/browser/generated/src/models/index.d.ts +4 -0
- package/dist/browser/generated/src/models/index.d.ts.map +1 -1
- package/dist/browser/generated/src/models/index.js.map +1 -1
- package/dist/browser/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/browser/generated/src/models/mappers.js +14 -0
- package/dist/browser/generated/src/models/mappers.js.map +1 -1
- package/dist/browser/generated/src/models/parameters.js +1 -1
- package/dist/browser/generated/src/models/parameters.js.map +1 -1
- package/dist/browser/generated/src/storageClient.js +2 -2
- package/dist/browser/generated/src/storageClient.js.map +1 -1
- package/dist/browser/generatedModels.d.ts +2 -2
- package/dist/browser/generatedModels.d.ts.map +1 -1
- package/dist/browser/generatedModels.js.map +1 -1
- package/dist/browser/index.d.ts +8 -8
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +1 -2
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/utils/constants.d.ts.map +1 -1
- package/dist/browser/utils/constants.js +2 -2
- package/dist/browser/utils/constants.js.map +1 -1
- package/dist/commonjs/AccountSASPermissions.js +133 -126
- package/dist/commonjs/AccountSASPermissions.js.map +7 -1
- package/dist/commonjs/AccountSASResourceTypes.js +80 -70
- package/dist/commonjs/AccountSASResourceTypes.js.map +7 -1
- package/dist/commonjs/AccountSASServices.js +88 -78
- package/dist/commonjs/AccountSASServices.js.map +7 -1
- package/dist/commonjs/AccountSASSignatureValues.js +91 -72
- package/dist/commonjs/AccountSASSignatureValues.js.map +7 -1
- package/dist/commonjs/Pipeline.d.ts +2 -3
- package/dist/commonjs/Pipeline.d.ts.map +1 -1
- package/dist/commonjs/Pipeline.js +244 -244
- package/dist/commonjs/Pipeline.js.map +7 -1
- package/dist/commonjs/QueueClient.d.ts +2 -1
- package/dist/commonjs/QueueClient.d.ts.map +1 -1
- package/dist/commonjs/QueueClient.js +710 -683
- package/dist/commonjs/QueueClient.js.map +7 -1
- package/dist/commonjs/QueueSASPermissions.js +90 -80
- package/dist/commonjs/QueueSASPermissions.js.map +7 -1
- package/dist/commonjs/QueueSASSignatureValues.d.ts +2 -1
- package/dist/commonjs/QueueSASSignatureValues.d.ts.map +1 -1
- package/dist/commonjs/QueueSASSignatureValues.js +151 -111
- package/dist/commonjs/QueueSASSignatureValues.js.map +7 -1
- package/dist/commonjs/QueueServiceClient.d.ts +28 -0
- package/dist/commonjs/QueueServiceClient.d.ts.map +1 -1
- package/dist/commonjs/QueueServiceClient.js +532 -472
- package/dist/commonjs/QueueServiceClient.js.map +7 -1
- package/dist/commonjs/SASQueryParameters.d.ts +6 -1
- package/dist/commonjs/SASQueryParameters.d.ts.map +1 -1
- package/dist/commonjs/SASQueryParameters.js +308 -267
- package/dist/commonjs/SASQueryParameters.js.map +7 -1
- package/dist/commonjs/SasIPRange.js +27 -14
- package/dist/commonjs/SasIPRange.js.map +7 -1
- package/dist/commonjs/StorageClient.js +75 -65
- package/dist/commonjs/StorageClient.js.map +7 -1
- package/dist/commonjs/StorageContextClient.js +34 -20
- package/dist/commonjs/StorageContextClient.js.map +7 -1
- package/dist/commonjs/generated/src/index.js +32 -16
- package/dist/commonjs/generated/src/index.js.map +7 -1
- package/dist/commonjs/generated/src/models/index.d.ts +4 -0
- package/dist/commonjs/generated/src/models/index.d.ts.map +1 -1
- package/dist/commonjs/generated/src/models/index.js +86 -129
- package/dist/commonjs/generated/src/models/index.js.map +7 -1
- package/dist/commonjs/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/commonjs/generated/src/models/mappers.js +1947 -1817
- package/dist/commonjs/generated/src/models/mappers.js.map +7 -1
- package/dist/commonjs/generated/src/models/parameters.js +378 -305
- package/dist/commonjs/generated/src/models/parameters.js.map +7 -1
- package/dist/commonjs/generated/src/operations/index.js +27 -15
- package/dist/commonjs/generated/src/operations/index.js.map +7 -1
- package/dist/commonjs/generated/src/operations/messageId.js +130 -99
- package/dist/commonjs/generated/src/operations/messageId.js.map +7 -1
- package/dist/commonjs/generated/src/operations/messages.js +213 -185
- package/dist/commonjs/generated/src/operations/messages.js.map +7 -1
- package/dist/commonjs/generated/src/operations/queue.js +243 -206
- package/dist/commonjs/generated/src/operations/queue.js.map +7 -1
- package/dist/commonjs/generated/src/operations/service.js +239 -199
- package/dist/commonjs/generated/src/operations/service.js.map +7 -1
- package/dist/commonjs/generated/src/operationsInterfaces/index.js +27 -15
- package/dist/commonjs/generated/src/operationsInterfaces/index.js.map +7 -1
- package/dist/commonjs/generated/src/operationsInterfaces/messageId.js +15 -10
- package/dist/commonjs/generated/src/operationsInterfaces/messageId.js.map +7 -1
- package/dist/commonjs/generated/src/operationsInterfaces/messages.js +15 -10
- package/dist/commonjs/generated/src/operationsInterfaces/messages.js.map +7 -1
- package/dist/commonjs/generated/src/operationsInterfaces/queue.js +15 -10
- package/dist/commonjs/generated/src/operationsInterfaces/queue.js.map +7 -1
- package/dist/commonjs/generated/src/operationsInterfaces/service.js +15 -10
- package/dist/commonjs/generated/src/operationsInterfaces/service.js.map +7 -1
- package/dist/commonjs/generated/src/storageClient.js +77 -59
- package/dist/commonjs/generated/src/storageClient.js.map +7 -1
- package/dist/commonjs/generatedModels.d.ts +2 -2
- package/dist/commonjs/generatedModels.d.ts.map +1 -1
- package/dist/commonjs/generatedModels.js +15 -5
- package/dist/commonjs/generatedModels.js.map +7 -1
- package/dist/commonjs/index.d.ts +9 -9
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +88 -43
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/log.js +28 -11
- package/dist/commonjs/log.js.map +7 -1
- package/dist/commonjs/models.js +33 -21
- package/dist/commonjs/models.js.map +7 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/utils/constants.d.ts.map +1 -1
- package/dist/commonjs/utils/constants.js +151 -114
- package/dist/commonjs/utils/constants.js.map +7 -1
- package/dist/commonjs/utils/tracing.js +32 -16
- package/dist/commonjs/utils/tracing.js.map +7 -1
- package/dist/commonjs/utils/utils.common.js +242 -338
- package/dist/commonjs/utils/utils.common.js.map +7 -1
- package/dist/esm/AccountSASPermissions.js +111 -123
- package/dist/esm/AccountSASPermissions.js.map +7 -1
- package/dist/esm/AccountSASResourceTypes.js +58 -67
- package/dist/esm/AccountSASResourceTypes.js.map +7 -1
- package/dist/esm/AccountSASServices.js +66 -75
- package/dist/esm/AccountSASServices.js.map +7 -1
- package/dist/esm/AccountSASSignatureValues.js +62 -63
- package/dist/esm/AccountSASSignatureValues.js.map +7 -1
- package/dist/esm/Pipeline.d.ts +2 -3
- package/dist/esm/Pipeline.d.ts.map +1 -1
- package/dist/esm/Pipeline.js +239 -239
- package/dist/esm/Pipeline.js.map +7 -1
- package/dist/esm/QueueClient.d.ts +2 -1
- package/dist/esm/QueueClient.d.ts.map +1 -1
- package/dist/esm/QueueClient.js +689 -671
- package/dist/esm/QueueClient.js.map +7 -1
- package/dist/esm/QueueSASPermissions.js +68 -77
- package/dist/esm/QueueSASPermissions.js.map +7 -1
- package/dist/esm/QueueSASSignatureValues.d.ts +2 -1
- package/dist/esm/QueueSASSignatureValues.d.ts.map +1 -1
- package/dist/esm/QueueSASSignatureValues.js +124 -104
- package/dist/esm/QueueSASSignatureValues.js.map +7 -1
- package/dist/esm/QueueServiceClient.d.ts +28 -0
- package/dist/esm/QueueServiceClient.d.ts.map +1 -1
- package/dist/esm/QueueServiceClient.js +507 -457
- package/dist/esm/QueueServiceClient.js.map +7 -1
- package/dist/esm/SASQueryParameters.d.ts +6 -1
- package/dist/esm/SASQueryParameters.d.ts.map +1 -1
- package/dist/esm/SASQueryParameters.js +283 -262
- package/dist/esm/SASQueryParameters.js.map +7 -1
- package/dist/esm/SasIPRange.js +5 -12
- package/dist/esm/SasIPRange.js.map +7 -1
- package/dist/esm/StorageClient.js +50 -59
- package/dist/esm/StorageClient.js.map +7 -1
- package/dist/esm/StorageContextClient.js +10 -15
- package/dist/esm/StorageContextClient.js.map +7 -1
- package/dist/esm/generated/src/index.js +4 -9
- package/dist/esm/generated/src/index.js.map +7 -1
- package/dist/esm/generated/src/models/index.d.ts +4 -0
- package/dist/esm/generated/src/models/index.d.ts.map +1 -1
- package/dist/esm/generated/src/models/index.js +63 -126
- package/dist/esm/generated/src/models/index.js.map +7 -1
- package/dist/esm/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/esm/generated/src/models/mappers.js +1873 -1813
- package/dist/esm/generated/src/models/mappers.js.map +7 -1
- package/dist/esm/generated/src/models/parameters.js +330 -302
- package/dist/esm/generated/src/models/parameters.js.map +7 -1
- package/dist/esm/generated/src/operations/index.js +0 -8
- package/dist/esm/generated/src/operations/index.js.map +7 -1
- package/dist/esm/generated/src/operations/messageId.js +95 -92
- package/dist/esm/generated/src/operations/messageId.js.map +7 -1
- package/dist/esm/generated/src/operations/messages.js +178 -178
- package/dist/esm/generated/src/operations/messages.js.map +7 -1
- package/dist/esm/generated/src/operations/queue.js +208 -199
- package/dist/esm/generated/src/operations/queue.js.map +7 -1
- package/dist/esm/generated/src/operations/service.js +204 -192
- package/dist/esm/generated/src/operations/service.js.map +7 -1
- package/dist/esm/generated/src/operationsInterfaces/index.js +0 -8
- package/dist/esm/generated/src/operationsInterfaces/index.js.map +7 -1
- package/dist/esm/generated/src/operationsInterfaces/messageId.js +0 -9
- package/dist/esm/generated/src/operationsInterfaces/messageId.js.map +7 -1
- package/dist/esm/generated/src/operationsInterfaces/messages.js +0 -9
- package/dist/esm/generated/src/operationsInterfaces/messages.js.map +7 -1
- package/dist/esm/generated/src/operationsInterfaces/queue.js +0 -9
- package/dist/esm/generated/src/operationsInterfaces/queue.js.map +7 -1
- package/dist/esm/generated/src/operationsInterfaces/service.js +0 -9
- package/dist/esm/generated/src/operationsInterfaces/service.js.map +7 -1
- package/dist/esm/generated/src/storageClient.js +49 -54
- package/dist/esm/generated/src/storageClient.js.map +7 -1
- package/dist/esm/generatedModels.d.ts +2 -2
- package/dist/esm/generatedModels.d.ts.map +1 -1
- package/dist/esm/generatedModels.js +0 -4
- package/dist/esm/generatedModels.js.map +7 -1
- package/dist/esm/index.d.ts +9 -9
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +50 -11
- package/dist/esm/index.js.map +7 -1
- package/dist/esm/log.js +4 -7
- package/dist/esm/log.js.map +7 -1
- package/dist/esm/models.js +10 -18
- package/dist/esm/models.js.map +7 -1
- package/dist/esm/utils/constants.d.ts.map +1 -1
- package/dist/esm/utils/constants.js +117 -111
- package/dist/esm/utils/constants.js.map +7 -1
- package/dist/esm/utils/tracing.js +7 -11
- package/dist/esm/utils/tracing.js.map +7 -1
- package/dist/esm/utils/utils.common.js +247 -358
- package/dist/esm/utils/utils.common.js.map +7 -1
- package/dist/react-native/Pipeline.d.ts +2 -3
- package/dist/react-native/Pipeline.d.ts.map +1 -1
- package/dist/react-native/Pipeline.js.map +1 -1
- package/dist/react-native/QueueClient.d.ts +2 -1
- package/dist/react-native/QueueClient.d.ts.map +1 -1
- package/dist/react-native/QueueClient.js.map +1 -1
- package/dist/react-native/QueueSASSignatureValues.d.ts +2 -1
- package/dist/react-native/QueueSASSignatureValues.d.ts.map +1 -1
- package/dist/react-native/QueueSASSignatureValues.js +2 -2
- package/dist/react-native/QueueSASSignatureValues.js.map +1 -1
- package/dist/react-native/QueueServiceClient.d.ts +28 -0
- package/dist/react-native/QueueServiceClient.d.ts.map +1 -1
- package/dist/react-native/QueueServiceClient.js +21 -13
- package/dist/react-native/QueueServiceClient.js.map +1 -1
- package/dist/react-native/SASQueryParameters.d.ts +6 -1
- package/dist/react-native/SASQueryParameters.d.ts.map +1 -1
- package/dist/react-native/SASQueryParameters.js +10 -0
- package/dist/react-native/SASQueryParameters.js.map +1 -1
- package/dist/react-native/generated/src/models/index.d.ts +4 -0
- package/dist/react-native/generated/src/models/index.d.ts.map +1 -1
- package/dist/react-native/generated/src/models/index.js.map +1 -1
- package/dist/react-native/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/react-native/generated/src/models/mappers.js +14 -0
- package/dist/react-native/generated/src/models/mappers.js.map +1 -1
- package/dist/react-native/generated/src/models/parameters.js +1 -1
- package/dist/react-native/generated/src/models/parameters.js.map +1 -1
- package/dist/react-native/generated/src/storageClient.js +2 -2
- package/dist/react-native/generated/src/storageClient.js.map +1 -1
- package/dist/react-native/generatedModels.d.ts +2 -2
- package/dist/react-native/generatedModels.d.ts.map +1 -1
- package/dist/react-native/generatedModels.js.map +1 -1
- package/dist/react-native/index.d.ts +9 -9
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +0 -1
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/utils/constants.d.ts.map +1 -1
- package/dist/react-native/utils/constants.js +2 -2
- package/dist/react-native/utils/constants.js.map +1 -1
- package/package.json +2 -19
- package/dist/browser/index-browser.d.mts.map +0 -1
- package/dist/browser/index-browser.mjs.map +0 -1
|
@@ -1,698 +1,725 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
432
|
-
|
|
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
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
-
|
|
536
|
-
|
|
338
|
+
if (identifier.accessPolicy.expiresOn) {
|
|
339
|
+
accessPolicy.expiresOn = new Date(identifier.accessPolicy.expiresOn);
|
|
537
340
|
}
|
|
538
|
-
|
|
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
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
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
|
-
|
|
616
|
-
|
|
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
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
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
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
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
|
-
|
|
698
|
-
|
|
722
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
723
|
+
0 && (module.exports = {
|
|
724
|
+
QueueClient
|
|
725
|
+
});
|