@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,362 +1,251 @@
1
1
  import { createHttpHeaders } from "@azure/core-rest-pipeline";
2
- import { HeaderConstants, URLConstants, DevelopmentConnectionString, PathStylePorts, } from "./constants.js";
3
- /**
4
- * Append a string to URL path. Will remove duplicated "/" in front of the string
5
- * when URL path ends with a "/".
6
- *
7
- * @param url - Source URL string
8
- * @param name - String to be appended to URL
9
- * @returns An updated URL string
10
- */
11
- export function appendToURLPath(url, name) {
2
+ import {
3
+ HeaderConstants,
4
+ URLConstants,
5
+ DevelopmentConnectionString,
6
+ PathStylePorts
7
+ } from "./constants.js";
8
+ function appendToURLPath(url, name) {
9
+ const urlParsed = new URL(url);
10
+ let path = urlParsed.pathname;
11
+ path = path ? path.endsWith("/") ? `${path}${name}` : `${path}/${name}` : name;
12
+ urlParsed.pathname = path;
13
+ return urlParsed.toString();
14
+ }
15
+ function setURLParameter(url, name, value) {
16
+ const urlParsed = new URL(url);
17
+ const encodedName = encodeURIComponent(name);
18
+ const encodedValue = value ? encodeURIComponent(value) : void 0;
19
+ const searchString = urlParsed.search === "" ? "?" : urlParsed.search;
20
+ const searchPieces = [];
21
+ for (const pair of searchString.slice(1).split("&")) {
22
+ if (pair) {
23
+ const [key] = pair.split("=", 2);
24
+ if (key !== encodedName) {
25
+ searchPieces.push(pair);
26
+ }
27
+ }
28
+ }
29
+ if (encodedValue) {
30
+ searchPieces.push(`${encodedName}=${encodedValue}`);
31
+ }
32
+ urlParsed.search = searchPieces.length ? `?${searchPieces.join("&")}` : "";
33
+ return urlParsed.toString();
34
+ }
35
+ function getURLParameter(url, name) {
36
+ const urlParsed = new URL(url);
37
+ return urlParsed.searchParams.get(name) ?? void 0;
38
+ }
39
+ function setURLHost(url, host) {
40
+ const urlParsed = new URL(url);
41
+ urlParsed.hostname = host;
42
+ return urlParsed.toString();
43
+ }
44
+ function getURLPath(url) {
45
+ try {
12
46
  const urlParsed = new URL(url);
13
- let path = urlParsed.pathname;
14
- path = path ? (path.endsWith("/") ? `${path}${name}` : `${path}/${name}`) : name;
15
- urlParsed.pathname = path;
16
- return urlParsed.toString();
17
- }
18
- /**
19
- * Set URL parameter name and value. If name exists in URL parameters, old value
20
- * will be replaced by name key. If not provide value, the parameter will be deleted.
21
- *
22
- * @param url - Source URL string
23
- * @param name - Parameter name
24
- * @param value - Parameter value
25
- * @returns An updated URL string
26
- */
27
- export function setURLParameter(url, name, value) {
28
- const urlParsed = new URL(url);
29
- const encodedName = encodeURIComponent(name);
30
- const encodedValue = value ? encodeURIComponent(value) : undefined;
31
- // mutating searchParams will change the encoding, so we have to do this ourselves
32
- const searchString = urlParsed.search === "" ? "?" : urlParsed.search;
33
- const searchPieces = [];
34
- for (const pair of searchString.slice(1).split("&")) {
35
- if (pair) {
36
- const [key] = pair.split("=", 2);
37
- if (key !== encodedName) {
38
- searchPieces.push(pair);
39
- }
40
- }
41
- }
42
- if (encodedValue) {
43
- searchPieces.push(`${encodedName}=${encodedValue}`);
44
- }
45
- urlParsed.search = searchPieces.length ? `?${searchPieces.join("&")}` : "";
46
- return urlParsed.toString();
47
- }
48
- /**
49
- * Get URL parameter by name.
50
- *
51
- * @param url - URL string
52
- * @param name - Parameter name
53
- * @returns Parameter value(s) for the given parameter name.
54
- */
55
- export function getURLParameter(url, name) {
56
- const urlParsed = new URL(url);
57
- return urlParsed.searchParams.get(name) ?? undefined;
58
- }
59
- /**
60
- * Set URL host.
61
- *
62
- * @param url - Source URL string
63
- * @param host - New host string
64
- * @returns An updated URL string
65
- */
66
- export function setURLHost(url, host) {
67
- const urlParsed = new URL(url);
68
- urlParsed.hostname = host;
69
- return urlParsed.toString();
70
- }
71
- /**
72
- * Gets URL path from an URL string.
73
- *
74
- * @param url - Source URL string
75
- * @returns The path part of the given URL string.
76
- */
77
- export function getURLPath(url) {
78
- try {
79
- const urlParsed = new URL(url);
80
- return urlParsed.pathname;
81
- }
82
- catch (e) {
83
- return undefined;
84
- }
85
- }
86
- /**
87
- * Gets URL query key value pairs from an URL string.
88
- *
89
- * @param url -
90
- * @returns query key value string pairs from the given URL string.
91
- */
92
- export function getURLQueries(url) {
93
- let queryString = new URL(url).search;
94
- if (!queryString) {
95
- return {};
96
- }
97
- queryString = queryString.trim();
98
- queryString = queryString.startsWith("?") ? queryString.substring(1) : queryString;
99
- let querySubStrings = queryString.split("&");
100
- querySubStrings = querySubStrings.filter((value) => {
101
- const indexOfEqual = value.indexOf("=");
102
- const lastIndexOfEqual = value.lastIndexOf("=");
103
- return (indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1);
104
- });
105
- const queries = {};
106
- for (const querySubString of querySubStrings) {
107
- const splitResults = querySubString.split("=");
108
- const key = splitResults[0];
109
- const value = splitResults[1];
110
- queries[key] = value;
111
- }
112
- return queries;
47
+ return urlParsed.pathname;
48
+ } catch (e) {
49
+ return void 0;
50
+ }
51
+ }
52
+ function getURLQueries(url) {
53
+ let queryString = new URL(url).search;
54
+ if (!queryString) {
55
+ return {};
56
+ }
57
+ queryString = queryString.trim();
58
+ queryString = queryString.startsWith("?") ? queryString.substring(1) : queryString;
59
+ let querySubStrings = queryString.split("&");
60
+ querySubStrings = querySubStrings.filter((value) => {
61
+ const indexOfEqual = value.indexOf("=");
62
+ const lastIndexOfEqual = value.lastIndexOf("=");
63
+ return indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1;
64
+ });
65
+ const queries = {};
66
+ for (const querySubString of querySubStrings) {
67
+ const splitResults = querySubString.split("=");
68
+ const key = splitResults[0];
69
+ const value = splitResults[1];
70
+ queries[key] = value;
71
+ }
72
+ return queries;
113
73
  }
114
74
  function getProxyUriFromDevConnString(connectionString) {
115
- // Development Connection String
116
- // https://learn.microsoft.com/azure/storage/common/storage-configure-connection-string#connect-to-the-emulator-account-using-the-well-known-account-name-and-key
117
- let proxyUri = "";
118
- if (connectionString.search("DevelopmentStorageProxyUri=") !== -1) {
119
- // CONNECTION_STRING=UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://myProxyUri
120
- const matchCredentials = connectionString.split(";");
121
- for (const element of matchCredentials) {
122
- if (element.trim().startsWith("DevelopmentStorageProxyUri=")) {
123
- proxyUri = element.trim().match("DevelopmentStorageProxyUri=(.*)")[1];
124
- }
125
- }
126
- }
127
- return proxyUri;
128
- }
129
- /**
130
- *
131
- * @param connectionString - Account connection string.
132
- * @param argument - property to get value from the connection string.
133
- * @returns Value of the property specified in argument.
134
- */
135
- export function getValueInConnString(connectionString, argument) {
136
- const elements = connectionString.split(";");
137
- for (const element of elements) {
138
- if (element.trim().startsWith(argument)) {
139
- return element.trim().match(argument + "=(.*)")[1];
140
- }
141
- }
142
- return "";
143
- }
144
- /**
145
- * Extracts the parts of an Azure Storage account connection string.
146
- *
147
- * @param connectionString - Connection string.
148
- * @returns String key value pairs of the storage account's url and credentials.
149
- */
150
- export function extractConnectionStringParts(connectionString) {
151
- let proxyUri = "";
152
- if (connectionString.startsWith("UseDevelopmentStorage=true")) {
153
- // Development connection string
154
- proxyUri = getProxyUriFromDevConnString(connectionString);
155
- connectionString = DevelopmentConnectionString;
156
- }
157
- // Matching QueueEndpoint in the Account connection string
158
- let queueEndpoint = getValueInConnString(connectionString, "QueueEndpoint");
159
- // Slicing off '/' at the end if exists
160
- // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)
161
- queueEndpoint = queueEndpoint.endsWith("/") ? queueEndpoint.slice(0, -1) : queueEndpoint;
162
- if (connectionString.search("DefaultEndpointsProtocol=") !== -1 &&
163
- connectionString.search("AccountKey=") !== -1) {
164
- // Account connection string
165
- let defaultEndpointsProtocol = "";
166
- let accountName = "";
167
- let accountKey = Buffer.from("accountKey", "base64");
168
- let endpointSuffix = "";
169
- // Get account name and key
170
- accountName = getValueInConnString(connectionString, "AccountName");
171
- accountKey = Buffer.from(getValueInConnString(connectionString, "AccountKey"), "base64");
172
- if (!queueEndpoint) {
173
- // QueueEndpoint is not present in the Account connection string
174
- // Can be obtained from `${defaultEndpointsProtocol}://${accountName}.queue.${endpointSuffix}`
175
- defaultEndpointsProtocol = getValueInConnString(connectionString, "DefaultEndpointsProtocol");
176
- const protocol = defaultEndpointsProtocol.toLowerCase();
177
- if (protocol !== "https" && protocol !== "http") {
178
- throw new Error("Invalid DefaultEndpointsProtocol in the provided Connection String. Expecting 'https' or 'http'");
179
- }
180
- endpointSuffix = getValueInConnString(connectionString, "EndpointSuffix");
181
- if (!endpointSuffix) {
182
- throw new Error("Invalid EndpointSuffix in the provided Connection String");
183
- }
184
- queueEndpoint = `${defaultEndpointsProtocol}://${accountName}.queue.${endpointSuffix}`;
185
- }
186
- if (!accountName) {
187
- throw new Error("Invalid AccountName in the provided Connection String");
188
- }
189
- else if (accountKey.length === 0) {
190
- throw new Error("Invalid AccountKey in the provided Connection String");
191
- }
192
- return {
193
- kind: "AccountConnString",
194
- url: queueEndpoint,
195
- accountName,
196
- accountKey,
197
- proxyUri,
198
- };
199
- }
200
- else {
201
- // SAS connection string
202
- const accountSas = getValueInConnString(connectionString, "SharedAccessSignature");
203
- let accountName = getValueInConnString(connectionString, "AccountName");
204
- // if accountName is empty, try to read it from BlobEndpoint
205
- if (!accountName) {
206
- accountName = getAccountNameFromUrl(queueEndpoint);
207
- }
208
- if (!queueEndpoint) {
209
- throw new Error("Invalid QueueEndpoint in the provided SAS Connection String");
210
- }
211
- else if (!accountSas) {
212
- throw new Error("Invalid SharedAccessSignature in the provided SAS Connection String");
213
- }
214
- return { kind: "SASConnString", url: queueEndpoint, accountName, accountSas };
215
- }
216
- }
217
- /**
218
- * Rounds a date off to seconds.
219
- *
220
- * @param date -
221
- * @param withMilliseconds - If true, YYYY-MM-DDThh:mm:ss.fffffffZ will be returned;
222
- * If false, YYYY-MM-DDThh:mm:ssZ will be returned.
223
- * @returns Date string in ISO8061 format, with or without 7 milliseconds component
224
- */
225
- export function truncatedISO8061Date(date, withMilliseconds = true) {
226
- // Date.toISOString() will return like "2018-10-29T06:34:36.139Z"
227
- const dateString = date.toISOString();
228
- return withMilliseconds
229
- ? dateString.substring(0, dateString.length - 1) + "0000" + "Z"
230
- : dateString.substring(0, dateString.length - 5) + "Z";
231
- }
232
- /**
233
- * Delay specified time interval.
234
- *
235
- * @param timeInMs -
236
- * @param aborter -
237
- * @param abortError -
238
- */
239
- export async function delay(timeInMs, aborter, abortError) {
240
- return new Promise((resolve, reject) => {
241
- /* eslint-disable-next-line prefer-const*/
242
- let timeout;
243
- const abortHandler = () => {
244
- if (timeout !== undefined) {
245
- clearTimeout(timeout);
246
- }
247
- reject(abortError);
248
- };
249
- const resolveHandler = () => {
250
- if (aborter !== undefined) {
251
- aborter.removeEventListener("abort", abortHandler);
252
- }
253
- resolve();
254
- };
255
- timeout = setTimeout(resolveHandler, timeInMs);
256
- if (aborter !== undefined) {
257
- aborter.addEventListener("abort", abortHandler);
258
- }
259
- });
260
- }
261
- /**
262
- * Sanitizes a url by removing the Signature parameter
263
- * @param url - to sanitize
264
- * @returns sanitized string
265
- */
266
- export function sanitizeURL(url) {
267
- let safeURL = url;
268
- if (getURLParameter(safeURL, URLConstants.Parameters.SIGNATURE)) {
269
- safeURL = setURLParameter(safeURL, URLConstants.Parameters.SIGNATURE, "*****");
270
- }
271
- return safeURL;
272
- }
273
- /**
274
- * Sanitize headers by removing sensitive values such as AUTHORIZATION and X_MS_COPY_SOURCE
275
- * @param originalHeader - original headers
276
- * @returns sanitized headers
277
- */
278
- export function sanitizeHeaders(originalHeader) {
279
- const headers = createHttpHeaders();
280
- for (const [name, value] of originalHeader) {
281
- if (name.toLowerCase() === HeaderConstants.AUTHORIZATION) {
282
- headers.set(name, "*****");
283
- }
284
- else if (name.toLowerCase() === HeaderConstants.X_MS_COPY_SOURCE) {
285
- headers.set(name, sanitizeURL(value));
286
- }
287
- else {
288
- headers.set(name, value);
289
- }
290
- }
291
- return headers;
292
- }
293
- /**
294
- * Extracts account name from the url
295
- * @param url - url to extract the account name from
296
- * @returns with the account name
297
- */
298
- export function getAccountNameFromUrl(url) {
299
- const parsedUrl = new URL(url);
300
- let accountName;
301
- try {
302
- if (parsedUrl.hostname.split(".")[1] === "queue") {
303
- // `${defaultEndpointsProtocol}://${accountName}.queue.${endpointSuffix}`;
304
- accountName = parsedUrl.hostname.split(".")[0];
305
- }
306
- else if (isIpEndpointStyle(parsedUrl)) {
307
- // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/
308
- // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/
309
- // .getPath() -> /devstoreaccount1/
310
- accountName = parsedUrl.pathname.split("/")[1];
311
- }
312
- else {
313
- // Custom domain case: "https://customdomain.com/containername/blob".
314
- accountName = "";
315
- }
316
- return accountName;
317
- }
318
- catch (error) {
319
- throw new Error("Unable to extract accountName with provided information.");
320
- }
321
- }
322
- export function isIpEndpointStyle(parsedUrl) {
323
- const host = parsedUrl.host;
324
- // Case 1: Ipv6, use a broad regex to find out candidates whose host contains two ':'.
325
- // Case 2: localhost(:port) or host.docker.internal, use broad regex to match port part.
326
- // Case 3: Ipv4, use broad regex which just check if host contains Ipv4.
327
- // For valid host please refer to https://man7.org/linux/man-pages/man7/hostname.7.html.
328
- return (/^.*:.*:.*$|^(localhost|host.docker.internal)(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(host) ||
329
- (Boolean(parsedUrl.port) && PathStylePorts.includes(parsedUrl.port)));
330
- }
331
- /**
332
- * Append a string to URL query.
333
- *
334
- * @param url - Source URL string.
335
- * @param queryParts - String to be appended to the URL query.
336
- * @returns An updated URL string.
337
- */
338
- export function appendToURLQuery(url, queryParts) {
339
- const urlParsed = new URL(url);
340
- let query = urlParsed.search;
341
- if (query) {
342
- query += "&" + queryParts;
343
- }
344
- else {
345
- query = queryParts;
346
- }
347
- urlParsed.search = query;
348
- return urlParsed.toString();
349
- }
350
- /**
351
- * A typesafe helper for ensuring that a given response object has
352
- * the original _response attached.
353
- * @param response - A response object from calling a client operation
354
- * @returns The same object, but with known _response property
355
- */
356
- export function assertResponse(response) {
357
- if (`_response` in response) {
358
- return response;
359
- }
360
- throw new TypeError(`Unexpected response object ${response}`);
361
- }
362
- //# sourceMappingURL=utils.common.js.map
75
+ let proxyUri = "";
76
+ if (connectionString.search("DevelopmentStorageProxyUri=") !== -1) {
77
+ const matchCredentials = connectionString.split(";");
78
+ for (const element of matchCredentials) {
79
+ if (element.trim().startsWith("DevelopmentStorageProxyUri=")) {
80
+ proxyUri = element.trim().match("DevelopmentStorageProxyUri=(.*)")[1];
81
+ }
82
+ }
83
+ }
84
+ return proxyUri;
85
+ }
86
+ function getValueInConnString(connectionString, argument) {
87
+ const elements = connectionString.split(";");
88
+ for (const element of elements) {
89
+ if (element.trim().startsWith(argument)) {
90
+ return element.trim().match(argument + "=(.*)")[1];
91
+ }
92
+ }
93
+ return "";
94
+ }
95
+ function extractConnectionStringParts(connectionString) {
96
+ let proxyUri = "";
97
+ if (connectionString.startsWith("UseDevelopmentStorage=true")) {
98
+ proxyUri = getProxyUriFromDevConnString(connectionString);
99
+ connectionString = DevelopmentConnectionString;
100
+ }
101
+ let queueEndpoint = getValueInConnString(connectionString, "QueueEndpoint");
102
+ queueEndpoint = queueEndpoint.endsWith("/") ? queueEndpoint.slice(0, -1) : queueEndpoint;
103
+ if (connectionString.search("DefaultEndpointsProtocol=") !== -1 && connectionString.search("AccountKey=") !== -1) {
104
+ let defaultEndpointsProtocol = "";
105
+ let accountName = "";
106
+ let accountKey = Buffer.from("accountKey", "base64");
107
+ let endpointSuffix = "";
108
+ accountName = getValueInConnString(connectionString, "AccountName");
109
+ accountKey = Buffer.from(getValueInConnString(connectionString, "AccountKey"), "base64");
110
+ if (!queueEndpoint) {
111
+ defaultEndpointsProtocol = getValueInConnString(connectionString, "DefaultEndpointsProtocol");
112
+ const protocol = defaultEndpointsProtocol.toLowerCase();
113
+ if (protocol !== "https" && protocol !== "http") {
114
+ throw new Error(
115
+ "Invalid DefaultEndpointsProtocol in the provided Connection String. Expecting 'https' or 'http'"
116
+ );
117
+ }
118
+ endpointSuffix = getValueInConnString(connectionString, "EndpointSuffix");
119
+ if (!endpointSuffix) {
120
+ throw new Error("Invalid EndpointSuffix in the provided Connection String");
121
+ }
122
+ queueEndpoint = `${defaultEndpointsProtocol}://${accountName}.queue.${endpointSuffix}`;
123
+ }
124
+ if (!accountName) {
125
+ throw new Error("Invalid AccountName in the provided Connection String");
126
+ } else if (accountKey.length === 0) {
127
+ throw new Error("Invalid AccountKey in the provided Connection String");
128
+ }
129
+ return {
130
+ kind: "AccountConnString",
131
+ url: queueEndpoint,
132
+ accountName,
133
+ accountKey,
134
+ proxyUri
135
+ };
136
+ } else {
137
+ const accountSas = getValueInConnString(connectionString, "SharedAccessSignature");
138
+ let accountName = getValueInConnString(connectionString, "AccountName");
139
+ if (!accountName) {
140
+ accountName = getAccountNameFromUrl(queueEndpoint);
141
+ }
142
+ if (!queueEndpoint) {
143
+ throw new Error("Invalid QueueEndpoint in the provided SAS Connection String");
144
+ } else if (!accountSas) {
145
+ throw new Error("Invalid SharedAccessSignature in the provided SAS Connection String");
146
+ }
147
+ return { kind: "SASConnString", url: queueEndpoint, accountName, accountSas };
148
+ }
149
+ }
150
+ function truncatedISO8061Date(date, withMilliseconds = true) {
151
+ const dateString = date.toISOString();
152
+ return withMilliseconds ? dateString.substring(0, dateString.length - 1) + "0000Z" : dateString.substring(0, dateString.length - 5) + "Z";
153
+ }
154
+ async function delay(timeInMs, aborter, abortError) {
155
+ return new Promise((resolve, reject) => {
156
+ let timeout;
157
+ const abortHandler = () => {
158
+ if (timeout !== void 0) {
159
+ clearTimeout(timeout);
160
+ }
161
+ reject(abortError);
162
+ };
163
+ const resolveHandler = () => {
164
+ if (aborter !== void 0) {
165
+ aborter.removeEventListener("abort", abortHandler);
166
+ }
167
+ resolve();
168
+ };
169
+ timeout = setTimeout(resolveHandler, timeInMs);
170
+ if (aborter !== void 0) {
171
+ aborter.addEventListener("abort", abortHandler);
172
+ }
173
+ });
174
+ }
175
+ function sanitizeURL(url) {
176
+ let safeURL = url;
177
+ if (getURLParameter(safeURL, URLConstants.Parameters.SIGNATURE)) {
178
+ safeURL = setURLParameter(safeURL, URLConstants.Parameters.SIGNATURE, "*****");
179
+ }
180
+ return safeURL;
181
+ }
182
+ function sanitizeHeaders(originalHeader) {
183
+ const headers = createHttpHeaders();
184
+ for (const [name, value] of originalHeader) {
185
+ if (name.toLowerCase() === HeaderConstants.AUTHORIZATION) {
186
+ headers.set(name, "*****");
187
+ } else if (name.toLowerCase() === HeaderConstants.X_MS_COPY_SOURCE) {
188
+ headers.set(name, sanitizeURL(value));
189
+ } else {
190
+ headers.set(name, value);
191
+ }
192
+ }
193
+ return headers;
194
+ }
195
+ function getAccountNameFromUrl(url) {
196
+ const parsedUrl = new URL(url);
197
+ let accountName;
198
+ try {
199
+ if (parsedUrl.hostname.split(".")[1] === "queue") {
200
+ accountName = parsedUrl.hostname.split(".")[0];
201
+ } else if (isIpEndpointStyle(parsedUrl)) {
202
+ accountName = parsedUrl.pathname.split("/")[1];
203
+ } else {
204
+ accountName = "";
205
+ }
206
+ return accountName;
207
+ } catch (error) {
208
+ throw new Error("Unable to extract accountName with provided information.");
209
+ }
210
+ }
211
+ function isIpEndpointStyle(parsedUrl) {
212
+ const host = parsedUrl.host;
213
+ return /^.*:.*:.*$|^(localhost|host.docker.internal)(:[0-9]+)?$|^(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])(\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])){3}(:[0-9]+)?$/.test(
214
+ host
215
+ ) || Boolean(parsedUrl.port) && PathStylePorts.includes(parsedUrl.port);
216
+ }
217
+ function appendToURLQuery(url, queryParts) {
218
+ const urlParsed = new URL(url);
219
+ let query = urlParsed.search;
220
+ if (query) {
221
+ query += "&" + queryParts;
222
+ } else {
223
+ query = queryParts;
224
+ }
225
+ urlParsed.search = query;
226
+ return urlParsed.toString();
227
+ }
228
+ function assertResponse(response) {
229
+ if (`_response` in response) {
230
+ return response;
231
+ }
232
+ throw new TypeError(`Unexpected response object ${response}`);
233
+ }
234
+ export {
235
+ appendToURLPath,
236
+ appendToURLQuery,
237
+ assertResponse,
238
+ delay,
239
+ extractConnectionStringParts,
240
+ getAccountNameFromUrl,
241
+ getURLParameter,
242
+ getURLPath,
243
+ getURLQueries,
244
+ getValueInConnString,
245
+ isIpEndpointStyle,
246
+ sanitizeHeaders,
247
+ sanitizeURL,
248
+ setURLHost,
249
+ setURLParameter,
250
+ truncatedISO8061Date
251
+ };