@azure/service-bus 7.10.0-beta.2 → 7.10.0-beta.3

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 (254) hide show
  1. package/dist/browser/connectionContext.js +1 -2
  2. package/dist/browser/connectionContext.js.map +1 -1
  3. package/dist/browser/constructorHelpers.js +3 -4
  4. package/dist/browser/constructorHelpers.js.map +1 -1
  5. package/dist/browser/core/autoLockRenewer.js +9 -5
  6. package/dist/browser/core/autoLockRenewer.js.map +1 -1
  7. package/dist/browser/core/batchingReceiver.js +26 -18
  8. package/dist/browser/core/batchingReceiver.js.map +1 -1
  9. package/dist/browser/core/linkEntity.js +74 -13
  10. package/dist/browser/core/linkEntity.js.map +1 -1
  11. package/dist/browser/core/managementClient.js +48 -48
  12. package/dist/browser/core/managementClient.js.map +1 -1
  13. package/dist/browser/core/messageReceiver.js +41 -14
  14. package/dist/browser/core/messageReceiver.js.map +1 -1
  15. package/dist/browser/core/messageSender.js +33 -10
  16. package/dist/browser/core/messageSender.js.map +1 -1
  17. package/dist/browser/core/receiverHelper.js +3 -2
  18. package/dist/browser/core/receiverHelper.js.map +1 -1
  19. package/dist/browser/core/shared.js +11 -4
  20. package/dist/browser/core/shared.js.map +1 -1
  21. package/dist/browser/core/streamingReceiver.js +74 -43
  22. package/dist/browser/core/streamingReceiver.js.map +1 -1
  23. package/dist/browser/diagnostics/instrumentServiceBusMessage.js +16 -8
  24. package/dist/browser/diagnostics/instrumentServiceBusMessage.js.map +1 -1
  25. package/dist/browser/receivers/receiver.js +68 -23
  26. package/dist/browser/receivers/receiver.js.map +1 -1
  27. package/dist/browser/receivers/receiverCommon.js +36 -21
  28. package/dist/browser/receivers/receiverCommon.js.map +1 -1
  29. package/dist/browser/receivers/sessionReceiver.js +69 -29
  30. package/dist/browser/receivers/sessionReceiver.js.map +1 -1
  31. package/dist/browser/sender.js +33 -11
  32. package/dist/browser/sender.js.map +1 -1
  33. package/dist/browser/serializers/queueResourceSerializer.js +9 -1
  34. package/dist/browser/serializers/queueResourceSerializer.js.map +1 -1
  35. package/dist/browser/serializers/ruleResourceSerializer.js +1 -2
  36. package/dist/browser/serializers/ruleResourceSerializer.js.map +1 -1
  37. package/dist/browser/serviceBusAtomManagementClient.js +181 -228
  38. package/dist/browser/serviceBusAtomManagementClient.js.map +1 -1
  39. package/dist/browser/serviceBusClient.js +31 -22
  40. package/dist/browser/serviceBusClient.js.map +1 -1
  41. package/dist/browser/serviceBusError.js +21 -1
  42. package/dist/browser/serviceBusError.js.map +1 -1
  43. package/dist/browser/serviceBusMessage.js +208 -13
  44. package/dist/browser/serviceBusMessage.js.map +1 -1
  45. package/dist/browser/serviceBusMessageBatch.js +32 -8
  46. package/dist/browser/serviceBusMessageBatch.js.map +1 -1
  47. package/dist/browser/serviceBusRuleManager.js +39 -15
  48. package/dist/browser/serviceBusRuleManager.js.map +1 -1
  49. package/dist/browser/session/messageSession.js +130 -25
  50. package/dist/browser/session/messageSession.js.map +1 -1
  51. package/dist/browser/util/atomXmlHelper.js +4 -5
  52. package/dist/browser/util/atomXmlHelper.js.map +1 -1
  53. package/dist/browser/util/compat/httpHeaders.js +1 -0
  54. package/dist/browser/util/compat/httpHeaders.js.map +1 -1
  55. package/dist/browser/util/constants.js +1 -1
  56. package/dist/browser/util/constants.js.map +1 -1
  57. package/dist/browser/util/sasServiceClientCredentials.js +8 -0
  58. package/dist/browser/util/sasServiceClientCredentials.js.map +1 -1
  59. package/dist/browser/util/semaphore.js +6 -2
  60. package/dist/browser/util/semaphore.js.map +1 -1
  61. package/dist/browser/util/utils.js +5 -7
  62. package/dist/browser/util/utils.js.map +1 -1
  63. package/dist/commonjs/connectionContext.js +1 -2
  64. package/dist/commonjs/connectionContext.js.map +1 -1
  65. package/dist/commonjs/constructorHelpers.js +3 -4
  66. package/dist/commonjs/constructorHelpers.js.map +1 -1
  67. package/dist/commonjs/core/autoLockRenewer.js +9 -5
  68. package/dist/commonjs/core/autoLockRenewer.js.map +1 -1
  69. package/dist/commonjs/core/batchingReceiver.js +26 -18
  70. package/dist/commonjs/core/batchingReceiver.js.map +1 -1
  71. package/dist/commonjs/core/linkEntity.js +74 -13
  72. package/dist/commonjs/core/linkEntity.js.map +1 -1
  73. package/dist/commonjs/core/managementClient.js +48 -48
  74. package/dist/commonjs/core/managementClient.js.map +1 -1
  75. package/dist/commonjs/core/messageReceiver.js +41 -14
  76. package/dist/commonjs/core/messageReceiver.js.map +1 -1
  77. package/dist/commonjs/core/messageSender.js +33 -10
  78. package/dist/commonjs/core/messageSender.js.map +1 -1
  79. package/dist/commonjs/core/receiverHelper.js +3 -2
  80. package/dist/commonjs/core/receiverHelper.js.map +1 -1
  81. package/dist/commonjs/core/shared.js +11 -4
  82. package/dist/commonjs/core/shared.js.map +1 -1
  83. package/dist/commonjs/core/streamingReceiver.js +74 -43
  84. package/dist/commonjs/core/streamingReceiver.js.map +1 -1
  85. package/dist/commonjs/diagnostics/instrumentServiceBusMessage.js +16 -8
  86. package/dist/commonjs/diagnostics/instrumentServiceBusMessage.js.map +1 -1
  87. package/dist/commonjs/receivers/receiver.js +68 -23
  88. package/dist/commonjs/receivers/receiver.js.map +1 -1
  89. package/dist/commonjs/receivers/receiverCommon.js +36 -21
  90. package/dist/commonjs/receivers/receiverCommon.js.map +1 -1
  91. package/dist/commonjs/receivers/sessionReceiver.js +69 -29
  92. package/dist/commonjs/receivers/sessionReceiver.js.map +1 -1
  93. package/dist/commonjs/sender.js +33 -11
  94. package/dist/commonjs/sender.js.map +1 -1
  95. package/dist/commonjs/serializers/queueResourceSerializer.js +9 -1
  96. package/dist/commonjs/serializers/queueResourceSerializer.js.map +1 -1
  97. package/dist/commonjs/serializers/ruleResourceSerializer.js +1 -2
  98. package/dist/commonjs/serializers/ruleResourceSerializer.js.map +1 -1
  99. package/dist/commonjs/serviceBusAtomManagementClient.js +181 -227
  100. package/dist/commonjs/serviceBusAtomManagementClient.js.map +1 -1
  101. package/dist/commonjs/serviceBusClient.js +31 -22
  102. package/dist/commonjs/serviceBusClient.js.map +1 -1
  103. package/dist/commonjs/serviceBusError.js +21 -1
  104. package/dist/commonjs/serviceBusError.js.map +1 -1
  105. package/dist/commonjs/serviceBusMessage.js +208 -12
  106. package/dist/commonjs/serviceBusMessage.js.map +1 -1
  107. package/dist/commonjs/serviceBusMessageBatch.js +32 -8
  108. package/dist/commonjs/serviceBusMessageBatch.js.map +1 -1
  109. package/dist/commonjs/serviceBusRuleManager.js +39 -15
  110. package/dist/commonjs/serviceBusRuleManager.js.map +1 -1
  111. package/dist/commonjs/session/messageSession.js +130 -25
  112. package/dist/commonjs/session/messageSession.js.map +1 -1
  113. package/dist/commonjs/tsdoc-metadata.json +11 -11
  114. package/dist/commonjs/util/atomXmlHelper.js +4 -5
  115. package/dist/commonjs/util/atomXmlHelper.js.map +1 -1
  116. package/dist/commonjs/util/compat/httpHeaders.js +1 -0
  117. package/dist/commonjs/util/compat/httpHeaders.js.map +1 -1
  118. package/dist/commonjs/util/constants.js +1 -1
  119. package/dist/commonjs/util/constants.js.map +1 -1
  120. package/dist/commonjs/util/runtimeInfo.js +2 -2
  121. package/dist/commonjs/util/runtimeInfo.js.map +1 -1
  122. package/dist/commonjs/util/sasServiceClientCredentials.js +8 -0
  123. package/dist/commonjs/util/sasServiceClientCredentials.js.map +1 -1
  124. package/dist/commonjs/util/semaphore.js +6 -2
  125. package/dist/commonjs/util/semaphore.js.map +1 -1
  126. package/dist/commonjs/util/utils.js +5 -7
  127. package/dist/commonjs/util/utils.js.map +1 -1
  128. package/dist/esm/connectionContext.js +1 -2
  129. package/dist/esm/connectionContext.js.map +1 -1
  130. package/dist/esm/constructorHelpers.js +3 -4
  131. package/dist/esm/constructorHelpers.js.map +1 -1
  132. package/dist/esm/core/autoLockRenewer.js +9 -5
  133. package/dist/esm/core/autoLockRenewer.js.map +1 -1
  134. package/dist/esm/core/batchingReceiver.js +26 -18
  135. package/dist/esm/core/batchingReceiver.js.map +1 -1
  136. package/dist/esm/core/linkEntity.js +74 -13
  137. package/dist/esm/core/linkEntity.js.map +1 -1
  138. package/dist/esm/core/managementClient.js +48 -48
  139. package/dist/esm/core/managementClient.js.map +1 -1
  140. package/dist/esm/core/messageReceiver.js +41 -14
  141. package/dist/esm/core/messageReceiver.js.map +1 -1
  142. package/dist/esm/core/messageSender.js +33 -10
  143. package/dist/esm/core/messageSender.js.map +1 -1
  144. package/dist/esm/core/receiverHelper.js +3 -2
  145. package/dist/esm/core/receiverHelper.js.map +1 -1
  146. package/dist/esm/core/shared.js +11 -4
  147. package/dist/esm/core/shared.js.map +1 -1
  148. package/dist/esm/core/streamingReceiver.js +74 -43
  149. package/dist/esm/core/streamingReceiver.js.map +1 -1
  150. package/dist/esm/diagnostics/instrumentServiceBusMessage.js +16 -8
  151. package/dist/esm/diagnostics/instrumentServiceBusMessage.js.map +1 -1
  152. package/dist/esm/receivers/receiver.js +68 -23
  153. package/dist/esm/receivers/receiver.js.map +1 -1
  154. package/dist/esm/receivers/receiverCommon.js +36 -21
  155. package/dist/esm/receivers/receiverCommon.js.map +1 -1
  156. package/dist/esm/receivers/sessionReceiver.js +69 -29
  157. package/dist/esm/receivers/sessionReceiver.js.map +1 -1
  158. package/dist/esm/sender.js +33 -11
  159. package/dist/esm/sender.js.map +1 -1
  160. package/dist/esm/serializers/queueResourceSerializer.js +9 -1
  161. package/dist/esm/serializers/queueResourceSerializer.js.map +1 -1
  162. package/dist/esm/serializers/ruleResourceSerializer.js +1 -2
  163. package/dist/esm/serializers/ruleResourceSerializer.js.map +1 -1
  164. package/dist/esm/serviceBusAtomManagementClient.js +181 -228
  165. package/dist/esm/serviceBusAtomManagementClient.js.map +1 -1
  166. package/dist/esm/serviceBusClient.js +31 -22
  167. package/dist/esm/serviceBusClient.js.map +1 -1
  168. package/dist/esm/serviceBusError.js +21 -1
  169. package/dist/esm/serviceBusError.js.map +1 -1
  170. package/dist/esm/serviceBusMessage.js +208 -13
  171. package/dist/esm/serviceBusMessage.js.map +1 -1
  172. package/dist/esm/serviceBusMessageBatch.js +32 -8
  173. package/dist/esm/serviceBusMessageBatch.js.map +1 -1
  174. package/dist/esm/serviceBusRuleManager.js +39 -15
  175. package/dist/esm/serviceBusRuleManager.js.map +1 -1
  176. package/dist/esm/session/messageSession.js +130 -25
  177. package/dist/esm/session/messageSession.js.map +1 -1
  178. package/dist/esm/util/atomXmlHelper.js +4 -5
  179. package/dist/esm/util/atomXmlHelper.js.map +1 -1
  180. package/dist/esm/util/compat/httpHeaders.js +1 -0
  181. package/dist/esm/util/compat/httpHeaders.js.map +1 -1
  182. package/dist/esm/util/constants.js +1 -1
  183. package/dist/esm/util/constants.js.map +1 -1
  184. package/dist/esm/util/runtimeInfo.js +1 -1
  185. package/dist/esm/util/runtimeInfo.js.map +1 -1
  186. package/dist/esm/util/sasServiceClientCredentials.js +8 -0
  187. package/dist/esm/util/sasServiceClientCredentials.js.map +1 -1
  188. package/dist/esm/util/semaphore.js +6 -2
  189. package/dist/esm/util/semaphore.js.map +1 -1
  190. package/dist/esm/util/utils.js +5 -7
  191. package/dist/esm/util/utils.js.map +1 -1
  192. package/dist/react-native/connectionContext.js +1 -2
  193. package/dist/react-native/connectionContext.js.map +1 -1
  194. package/dist/react-native/constructorHelpers.js +3 -4
  195. package/dist/react-native/constructorHelpers.js.map +1 -1
  196. package/dist/react-native/core/autoLockRenewer.js +9 -5
  197. package/dist/react-native/core/autoLockRenewer.js.map +1 -1
  198. package/dist/react-native/core/batchingReceiver.js +26 -18
  199. package/dist/react-native/core/batchingReceiver.js.map +1 -1
  200. package/dist/react-native/core/linkEntity.js +74 -13
  201. package/dist/react-native/core/linkEntity.js.map +1 -1
  202. package/dist/react-native/core/managementClient.js +48 -48
  203. package/dist/react-native/core/managementClient.js.map +1 -1
  204. package/dist/react-native/core/messageReceiver.js +41 -14
  205. package/dist/react-native/core/messageReceiver.js.map +1 -1
  206. package/dist/react-native/core/messageSender.js +33 -10
  207. package/dist/react-native/core/messageSender.js.map +1 -1
  208. package/dist/react-native/core/receiverHelper.js +3 -2
  209. package/dist/react-native/core/receiverHelper.js.map +1 -1
  210. package/dist/react-native/core/shared.js +11 -4
  211. package/dist/react-native/core/shared.js.map +1 -1
  212. package/dist/react-native/core/streamingReceiver.js +74 -43
  213. package/dist/react-native/core/streamingReceiver.js.map +1 -1
  214. package/dist/react-native/diagnostics/instrumentServiceBusMessage.js +16 -8
  215. package/dist/react-native/diagnostics/instrumentServiceBusMessage.js.map +1 -1
  216. package/dist/react-native/receivers/receiver.js +68 -23
  217. package/dist/react-native/receivers/receiver.js.map +1 -1
  218. package/dist/react-native/receivers/receiverCommon.js +36 -21
  219. package/dist/react-native/receivers/receiverCommon.js.map +1 -1
  220. package/dist/react-native/receivers/sessionReceiver.js +69 -29
  221. package/dist/react-native/receivers/sessionReceiver.js.map +1 -1
  222. package/dist/react-native/sender.js +33 -11
  223. package/dist/react-native/sender.js.map +1 -1
  224. package/dist/react-native/serializers/queueResourceSerializer.js +9 -1
  225. package/dist/react-native/serializers/queueResourceSerializer.js.map +1 -1
  226. package/dist/react-native/serializers/ruleResourceSerializer.js +1 -2
  227. package/dist/react-native/serializers/ruleResourceSerializer.js.map +1 -1
  228. package/dist/react-native/serviceBusAtomManagementClient.js +181 -228
  229. package/dist/react-native/serviceBusAtomManagementClient.js.map +1 -1
  230. package/dist/react-native/serviceBusClient.js +31 -22
  231. package/dist/react-native/serviceBusClient.js.map +1 -1
  232. package/dist/react-native/serviceBusError.js +21 -1
  233. package/dist/react-native/serviceBusError.js.map +1 -1
  234. package/dist/react-native/serviceBusMessage.js +208 -13
  235. package/dist/react-native/serviceBusMessage.js.map +1 -1
  236. package/dist/react-native/serviceBusMessageBatch.js +32 -8
  237. package/dist/react-native/serviceBusMessageBatch.js.map +1 -1
  238. package/dist/react-native/serviceBusRuleManager.js +39 -15
  239. package/dist/react-native/serviceBusRuleManager.js.map +1 -1
  240. package/dist/react-native/session/messageSession.js +130 -25
  241. package/dist/react-native/session/messageSession.js.map +1 -1
  242. package/dist/react-native/util/atomXmlHelper.js +4 -5
  243. package/dist/react-native/util/atomXmlHelper.js.map +1 -1
  244. package/dist/react-native/util/compat/httpHeaders.js +1 -0
  245. package/dist/react-native/util/compat/httpHeaders.js.map +1 -1
  246. package/dist/react-native/util/constants.js +1 -1
  247. package/dist/react-native/util/constants.js.map +1 -1
  248. package/dist/react-native/util/sasServiceClientCredentials.js +8 -0
  249. package/dist/react-native/util/sasServiceClientCredentials.js.map +1 -1
  250. package/dist/react-native/util/semaphore.js +6 -2
  251. package/dist/react-native/util/semaphore.js.map +1 -1
  252. package/dist/react-native/util/utils.js +5 -7
  253. package/dist/react-native/util/utils.js.map +1 -1
  254. package/package.json +38 -38
@@ -1 +1 @@
1
- {"version":3,"file":"sender.js","sourceRoot":"","sources":["../../src/sender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,0CAA0C,EAC1C,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AA2HjF;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAU/B,IAAY,SAAS;QACnB,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,WAAW,IAAI,CAAC,UAAU,GAAG,CAAC;IACrE,C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AAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,sBAA+B;IAE/B,IAAI,sBAAsB,IAAI,IAAI,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,sBAAgD,CAAC;IAEvE,OAAO,CACL,OAAO,aAAa,CAAC,aAAa,KAAK,UAAU;QACjD,OAAO,aAAa,CAAC,cAAc,KAAK,QAAQ;QAChD,OAAO,aAAa,CAAC,WAAW,KAAK,QAAQ,CAC9C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type Long from \"long\";\nimport { MessageSender } from \"./core/messageSender.js\";\nimport type { ServiceBusMessage } from \"./serviceBusMessage.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport {\n errorInvalidMessageTypeSingleOrArray,\n getSenderClosedErrorMsg,\n throwErrorIfConnectionClosed,\n throwIfNotValidServiceBusMessage,\n throwTypeErrorIfNotInstanceOfParameterType,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n} from \"./util/errors.js\";\nimport type { ServiceBusMessageBatch } from \"./serviceBusMessageBatch.js\";\nimport type { CreateMessageBatchOptions } from \"./models.js\";\nimport type { RetryConfig, RetryOptions, AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { RetryOperationType, retry } from \"@azure/core-amqp\";\nimport type { OperationOptionsBase } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\nimport { senderLogger as logger } from \"./log.js\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing.js\";\nimport { ensureValidIdentifier } from \"./util/utils.js\";\nimport { ServiceBusError } from \"./serviceBusError.js\";\nimport { instrumentMessage } from \"./diagnostics/instrumentServiceBusMessage.js\";\n\n/**\n * A Sender can be used to send messages, schedule messages to be sent at a later time\n * and cancel such scheduled messages.\n * Use the `createSender` function on the ServiceBusClient to instantiate a Sender.\n * The Sender class is an abstraction over the underlying AMQP sender link.\n */\nexport interface ServiceBusSender {\n /**\n * A name used to identify the sender. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n /**\n * Sends the given messages after creating an AMQP Sender link if it doesn't already exist.\n *\n * - To send messages to a `session` and/or `partition` enabled Queue/Topic, set the `sessionId`\n * and/or `partitionKey` properties respectively on the messages.\n * - All messages passed to the same sendMessages() call should have the same `sessionId` (if using\n * sessions) and the same `partitionKey` (if using partitions).\n *\n * **Note:**\n *\n * __If you want to send messages of size greater than 1MB, please send individual messages instead of sending a batched message or an array of messages like below.__\n *\n * `await sender.sendMessages(message);`\n *\n * __This is because the batched messages are not capable of sending the larger messages yet. You'll hit the `force detached` error in this case otherwise. Read [service-bus-premium-messaging#large-messages-support](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support). More info at [#23014](https://github.com/Azure/azure-sdk-for-js/pull/23014).__\n *\n * @param messages - A single message or an array of messages or a batch of messages created via the createBatch()\n * method to send.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws `ServiceBusError` with the code `MessageSizeExceeded` if the provided messages do not fit in a single `ServiceBusMessageBatch`.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while sending messages to the service.\n */\n sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n\n /**\n * Creates an instance of `ServiceBusMessageBatch` to which one can add messages until the maximum supported size is reached.\n * The batch can be passed to the {@link send} method to send the messages to Azure Service Bus.\n * @param options - Configures the behavior of the batch.\n * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n *\n * @throws `ServiceBusError` if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch>;\n\n // TODO: Commented out to come up with an alternative name\n // /**\n // * Opens the AMQP link to Azure Service Bus from the sender.\n // *\n // * It is not necessary to call this method in order to use the sender. It is\n // * recommended to call this before your first sendMessages() call if you\n // * want to front load the work of setting up the AMQP link to the service.\n // *\n // * @param options - Options to configure tracing and the abortSignal.\n // */\n // open(options?: OperationOptionsBase): Promise<void>;\n\n /**\n * Returns `true` if either the sender or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n\n /**\n * Schedules given messages to appear on Service Bus Queue/Subscription at a later time.\n *\n * @param messages - Message or an array of messages that need to be scheduled.\n * @param scheduledEnqueueTimeUtc - The UTC time at which the messages should be enqueued.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The sequence numbers of messages that were scheduled.\n * You will need the sequence number if you intend to cancel the scheduling of the messages.\n * Save the `Long` type as-is in your application without converting to number. Since JavaScript\n * only supports 53 bit numbers, converting the `Long` to number will cause loss in precision.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while scheduling messages.\n */\n scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options?: OperationOptionsBase,\n ): Promise<Long[]>;\n\n /**\n * Cancels multiple messages that were scheduled to appear on a ServiceBus Queue/Subscription.\n * @param sequenceNumbers - Sequence number or an array of sequence numbers of the messages to be cancelled.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while canceling scheduled messages.\n */\n cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Path of the entity for which the sender has been created.\n */\n entityPath: string;\n /**\n * Closes the underlying AMQP sender link.\n * Once closed, the sender cannot be used for any further operations.\n * Use the `createSender` function on the QueueClient or TopicClient to instantiate a new Sender\n *\n */\n close(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusSenderImpl implements ServiceBusSender {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this sender\n */\n private _isClosed: boolean = false;\n private _sender: MessageSender;\n public entityPath: string;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|sender:${this.entityPath}]`;\n }\n\n /**\n * @internal\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n private _entityPath: string,\n retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this.entityPath = _entityPath;\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n this._sender = MessageSender.create(this.identifier, this._context, _entityPath, retryOptions);\n this._retryOptions = retryOptions;\n }\n\n private _throwIfSenderOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getSenderClosedErrorMsg(this._entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `[${this._context.connectionId}] is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n\n if (!isServiceBusMessageBatch(messages) && !Array.isArray(messages)) {\n // Case 1: Single message\n throwIfNotValidServiceBusMessage(messages, errorInvalidMessageTypeSingleOrArray);\n const originalMessage = messages as ServiceBusMessage | AmqpAnnotatedMessage;\n const { message, spanContext } = instrumentMessage(\n originalMessage,\n options ?? {},\n this.entityPath,\n this._context.config.host,\n \"publish\",\n );\n const spanLinks: TracingSpanLink[] = spanContext ? [{ tracingContext: spanContext }] : [];\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.send(message, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n let batch: ServiceBusMessageBatch;\n if (isServiceBusMessageBatch(messages)) {\n // Case 2: Batch message\n batch = messages;\n } else {\n // Case 3: Array of messages\n batch = await this.createMessageBatch(options);\n for (const message of messages) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n if (!batch.tryAddMessage(message, options)) {\n // this is too big - throw an error\n throw new ServiceBusError(\n \"Messages were too big to fit in a single batch. Remove some messages and try again or create your own batch using createBatch(), which gives more fine-grained control.\",\n \"MessageSizeExceeded\",\n );\n }\n }\n }\n\n const spanLinks: TracingSpanLink[] = batch._messageSpanContexts.map((tracingContext) => {\n return {\n tracingContext,\n };\n });\n\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.sendBatch(batch, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n async createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch> {\n this._throwIfSenderOrConnectionClosed();\n return this._sender.createBatch(options);\n }\n\n async scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options: OperationOptionsBase = {},\n ): Promise<Long[]> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n );\n throwTypeErrorIfNotInstanceOfParameterType(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n Date,\n );\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n const messagesToSchedule = Array.isArray(messages) ? messages : [messages];\n\n for (const message of messagesToSchedule) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n }\n\n const scheduleMessageOperationPromise = async (): Promise<Long[]> => {\n return this._context\n .getManagementClient(this._entityPath)\n .scheduleMessages(scheduledEnqueueTimeUtc, messagesToSchedule, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"scheduleMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<Long[]> = {\n operation: scheduleMessageOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<Long[]>(config);\n }\n\n async cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const sequenceNumbersToCancel = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const cancelSchedulesMessagesOperationPromise = async (): Promise<void> => {\n return this._context\n .getManagementClient(this._entityPath)\n .cancelScheduledMessages(sequenceNumbersToCancel, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"cancelScheduledMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: cancelSchedulesMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<void>(config);\n }\n\n // async open(options?: OperationOptionsBase): Promise<void> {\n // this._throwIfSenderOrConnectionClosed();\n\n // const config: RetryConfig<void> = {\n // // TODO: Pass tracing options too\n // operation: () => this._sender.open(undefined, options?.abortSignal),\n // connectionId: this._context.connectionId,\n // operationType: RetryOperationType.senderLink,\n // retryOptions: this._retryOptions,\n // abortSignal: options?.abortSignal\n // };\n\n // return retry<void>(config);\n // }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n await this._sender.close();\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Sender`);\n throw err;\n }\n }\n}\n\n/**\n * @internal\n */\nexport function isServiceBusMessageBatch(\n messageBatchOrAnything: unknown,\n): messageBatchOrAnything is ServiceBusMessageBatch {\n if (messageBatchOrAnything == null) {\n return false;\n }\n\n const possibleBatch = messageBatchOrAnything as ServiceBusMessageBatch;\n\n return (\n typeof possibleBatch.tryAddMessage === \"function\" &&\n typeof possibleBatch.maxSizeInBytes === \"number\" &&\n typeof possibleBatch.sizeInBytes === \"number\"\n );\n}\n"]}
1
+ {"version":3,"file":"sender.js","sourceRoot":"","sources":["../../src/sender.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,0CAA0C,EAC1C,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AA2HjF;;GAE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,CAAC;QAC7B,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,6CAA6C,CAAC,CAAC;YACrF,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,sBAA+B;IAE/B,IAAI,sBAAsB,IAAI,IAAI,EAAE,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,aAAa,GAAG,sBAAgD,CAAC;IAEvE,OAAO,CACL,OAAO,aAAa,CAAC,aAAa,KAAK,UAAU;QACjD,OAAO,aAAa,CAAC,cAAc,KAAK,QAAQ;QAChD,OAAO,aAAa,CAAC,WAAW,KAAK,QAAQ,CAC9C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type Long from \"long\";\nimport { MessageSender } from \"./core/messageSender.js\";\nimport type { ServiceBusMessage } from \"./serviceBusMessage.js\";\nimport type { ConnectionContext } from \"./connectionContext.js\";\nimport {\n errorInvalidMessageTypeSingleOrArray,\n getSenderClosedErrorMsg,\n throwErrorIfConnectionClosed,\n throwIfNotValidServiceBusMessage,\n throwTypeErrorIfNotInstanceOfParameterType,\n throwTypeErrorIfParameterMissing,\n throwTypeErrorIfParameterNotLong,\n} from \"./util/errors.js\";\nimport type { ServiceBusMessageBatch } from \"./serviceBusMessageBatch.js\";\nimport type { CreateMessageBatchOptions } from \"./models.js\";\nimport type { RetryConfig, RetryOptions, AmqpAnnotatedMessage } from \"@azure/core-amqp\";\nimport { RetryOperationType, retry } from \"@azure/core-amqp\";\nimport type { OperationOptionsBase } from \"./modelsToBeSharedWithEventHubs.js\";\nimport type { TracingSpanLink } from \"@azure/core-tracing\";\nimport { senderLogger as logger } from \"./log.js\";\nimport { toSpanOptions, tracingClient } from \"./diagnostics/tracing.js\";\nimport { ensureValidIdentifier } from \"./util/utils.js\";\nimport { ServiceBusError } from \"./serviceBusError.js\";\nimport { instrumentMessage } from \"./diagnostics/instrumentServiceBusMessage.js\";\n\n/**\n * A Sender can be used to send messages, schedule messages to be sent at a later time\n * and cancel such scheduled messages.\n * Use the `createSender` function on the ServiceBusClient to instantiate a Sender.\n * The Sender class is an abstraction over the underlying AMQP sender link.\n */\nexport interface ServiceBusSender {\n /**\n * A name used to identify the sender. This can be used to correlate logs and exceptions.\n * If not specified or empty, a random unique one will be generated.\n */\n identifier: string;\n /**\n * Sends the given messages after creating an AMQP Sender link if it doesn't already exist.\n *\n * - To send messages to a `session` and/or `partition` enabled Queue/Topic, set the `sessionId`\n * and/or `partitionKey` properties respectively on the messages.\n * - All messages passed to the same sendMessages() call should have the same `sessionId` (if using\n * sessions) and the same `partitionKey` (if using partitions).\n *\n * **Note:**\n *\n * __If you want to send messages of size greater than 1MB, please send individual messages instead of sending a batched message or an array of messages like below.__\n *\n * `await sender.sendMessages(message);`\n *\n * __This is because the batched messages are not capable of sending the larger messages yet. You'll hit the `force detached` error in this case otherwise. Read [service-bus-premium-messaging#large-messages-support](https://learn.microsoft.com/azure/service-bus-messaging/service-bus-premium-messaging#large-messages-support). More info at [#23014](https://github.com/Azure/azure-sdk-for-js/pull/23014).__\n *\n * @param messages - A single message or an array of messages or a batch of messages created via the createBatch()\n * method to send.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws `ServiceBusError` with the code `MessageSizeExceeded` if the provided messages do not fit in a single `ServiceBusMessageBatch`.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while sending messages to the service.\n */\n sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n\n /**\n * Creates an instance of `ServiceBusMessageBatch` to which one can add messages until the maximum supported size is reached.\n * The batch can be passed to the {@link send} method to send the messages to Azure Service Bus.\n * @param options - Configures the behavior of the batch.\n * - `maxSizeInBytes`: The upper limit for the size of batch. The `tryAdd` function will return `false` after this limit is reached.\n *\n * @throws `ServiceBusError` if an error is encountered while sending a message.\n * @throws Error if the underlying connection or sender has been closed.\n */\n createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch>;\n\n // TODO: Commented out to come up with an alternative name\n // /**\n // * Opens the AMQP link to Azure Service Bus from the sender.\n // *\n // * It is not necessary to call this method in order to use the sender. It is\n // * recommended to call this before your first sendMessages() call if you\n // * want to front load the work of setting up the AMQP link to the service.\n // *\n // * @param options - Options to configure tracing and the abortSignal.\n // */\n // open(options?: OperationOptionsBase): Promise<void>;\n\n /**\n * Returns `true` if either the sender or the client that created it has been closed.\n * @readonly\n */\n isClosed: boolean;\n\n /**\n * Schedules given messages to appear on Service Bus Queue/Subscription at a later time.\n *\n * @param messages - Message or an array of messages that need to be scheduled.\n * @param scheduledEnqueueTimeUtc - The UTC time at which the messages should be enqueued.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @returns The sequence numbers of messages that were scheduled.\n * You will need the sequence number if you intend to cancel the scheduling of the messages.\n * Save the `Long` type as-is in your application without converting to number. Since JavaScript\n * only supports 53 bit numbers, converting the `Long` to number will cause loss in precision.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while scheduling messages.\n */\n scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options?: OperationOptionsBase,\n ): Promise<Long[]>;\n\n /**\n * Cancels multiple messages that were scheduled to appear on a ServiceBus Queue/Subscription.\n * @param sequenceNumbers - Sequence number or an array of sequence numbers of the messages to be cancelled.\n * @param options - Options bag to pass an abort signal or tracing options.\n * @throws Error if the underlying connection, client or sender is closed.\n * @throws `ServiceBusError` if the service returns an error while canceling scheduled messages.\n */\n cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options?: OperationOptionsBase,\n ): Promise<void>;\n /**\n * Path of the entity for which the sender has been created.\n */\n entityPath: string;\n /**\n * Closes the underlying AMQP sender link.\n * Once closed, the sender cannot be used for any further operations.\n * Use the `createSender` function on the QueueClient or TopicClient to instantiate a new Sender\n *\n */\n close(): Promise<void>;\n}\n\n/**\n * @internal\n */\nexport class ServiceBusSenderImpl implements ServiceBusSender {\n public identifier: string;\n private _retryOptions: RetryOptions;\n /**\n * Denotes if close() was called on this sender\n */\n private _isClosed: boolean = false;\n private _sender: MessageSender;\n public entityPath: string;\n\n private get logPrefix(): string {\n return `[${this._context.connectionId}|sender:${this.entityPath}]`;\n }\n\n /**\n * @internal\n * @throws Error if the underlying connection is closed.\n */\n constructor(\n private _context: ConnectionContext,\n private _entityPath: string,\n retryOptions: RetryOptions = {},\n identifier?: string,\n ) {\n throwErrorIfConnectionClosed(_context);\n this.entityPath = _entityPath;\n this.identifier = ensureValidIdentifier(this.entityPath, identifier);\n this._sender = MessageSender.create(this.identifier, this._context, _entityPath, retryOptions);\n this._retryOptions = retryOptions;\n }\n\n private _throwIfSenderOrConnectionClosed(): void {\n throwErrorIfConnectionClosed(this._context);\n if (this.isClosed) {\n const errorMessage = getSenderClosedErrorMsg(this._entityPath);\n const error = new Error(errorMessage);\n logger.logError(error, `[${this._context.connectionId}] is closed`);\n throw error;\n }\n }\n\n public get isClosed(): boolean {\n return this._isClosed || this._context.wasConnectionCloseCalled;\n }\n\n async sendMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | ServiceBusMessageBatch\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n options?: OperationOptionsBase,\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n\n if (!isServiceBusMessageBatch(messages) && !Array.isArray(messages)) {\n // Case 1: Single message\n throwIfNotValidServiceBusMessage(messages, errorInvalidMessageTypeSingleOrArray);\n const originalMessage = messages as ServiceBusMessage | AmqpAnnotatedMessage;\n const { message, spanContext } = instrumentMessage(\n originalMessage,\n options ?? {},\n this.entityPath,\n this._context.config.host,\n \"publish\",\n );\n const spanLinks: TracingSpanLink[] = spanContext ? [{ tracingContext: spanContext }] : [];\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.send(message, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n let batch: ServiceBusMessageBatch;\n if (isServiceBusMessageBatch(messages)) {\n // Case 2: Batch message\n batch = messages;\n } else {\n // Case 3: Array of messages\n batch = await this.createMessageBatch(options);\n for (const message of messages) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n if (!batch.tryAddMessage(message, options)) {\n // this is too big - throw an error\n throw new ServiceBusError(\n \"Messages were too big to fit in a single batch. Remove some messages and try again or create your own batch using createBatch(), which gives more fine-grained control.\",\n \"MessageSizeExceeded\",\n );\n }\n }\n }\n\n const spanLinks: TracingSpanLink[] = batch._messageSpanContexts.map((tracingContext) => {\n return {\n tracingContext,\n };\n });\n\n return tracingClient.withSpan(\n \"ServiceBusSender.send\",\n options ?? {},\n (updatedOptions) => this._sender.sendBatch(batch, updatedOptions),\n {\n spanLinks,\n ...toSpanOptions(\n { entityPath: this.entityPath, host: this._context.config.host },\n \"publish\",\n \"client\",\n ),\n },\n );\n }\n\n async createMessageBatch(options?: CreateMessageBatchOptions): Promise<ServiceBusMessageBatch> {\n this._throwIfSenderOrConnectionClosed();\n return this._sender.createBatch(options);\n }\n\n async scheduleMessages(\n messages:\n | ServiceBusMessage\n | ServiceBusMessage[]\n | AmqpAnnotatedMessage\n | AmqpAnnotatedMessage[],\n scheduledEnqueueTimeUtc: Date,\n options: OperationOptionsBase = {},\n ): Promise<Long[]> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n );\n throwTypeErrorIfNotInstanceOfParameterType(\n this._context.connectionId,\n \"scheduledEnqueueTimeUtc\",\n scheduledEnqueueTimeUtc,\n Date,\n );\n throwTypeErrorIfParameterMissing(this._context.connectionId, \"messages\", messages);\n const messagesToSchedule = Array.isArray(messages) ? messages : [messages];\n\n for (const message of messagesToSchedule) {\n throwIfNotValidServiceBusMessage(message, errorInvalidMessageTypeSingleOrArray);\n }\n\n const scheduleMessageOperationPromise = async (): Promise<Long[]> => {\n return this._context\n .getManagementClient(this._entityPath)\n .scheduleMessages(scheduledEnqueueTimeUtc, messagesToSchedule, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"scheduleMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<Long[]> = {\n operation: scheduleMessageOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<Long[]>(config);\n }\n\n async cancelScheduledMessages(\n sequenceNumbers: Long | Long[],\n options: OperationOptionsBase = {},\n ): Promise<void> {\n this._throwIfSenderOrConnectionClosed();\n throwTypeErrorIfParameterMissing(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n throwTypeErrorIfParameterNotLong(\n this._context.connectionId,\n \"sequenceNumbers\",\n sequenceNumbers,\n );\n\n const sequenceNumbersToCancel = Array.isArray(sequenceNumbers)\n ? sequenceNumbers\n : [sequenceNumbers];\n const cancelSchedulesMessagesOperationPromise = async (): Promise<void> => {\n return this._context\n .getManagementClient(this._entityPath)\n .cancelScheduledMessages(sequenceNumbersToCancel, {\n ...options,\n associatedLinkName: this._sender.name,\n requestName: \"cancelScheduledMessages\",\n timeoutInMs: this._retryOptions.timeoutInMs,\n });\n };\n const config: RetryConfig<void> = {\n operation: cancelSchedulesMessagesOperationPromise,\n connectionId: this._context.connectionId,\n operationType: RetryOperationType.management,\n retryOptions: this._retryOptions,\n abortSignal: options?.abortSignal,\n };\n return retry<void>(config);\n }\n\n // async open(options?: OperationOptionsBase): Promise<void> {\n // this._throwIfSenderOrConnectionClosed();\n\n // const config: RetryConfig<void> = {\n // // TODO: Pass tracing options too\n // operation: () => this._sender.open(undefined, options?.abortSignal),\n // connectionId: this._context.connectionId,\n // operationType: RetryOperationType.senderLink,\n // retryOptions: this._retryOptions,\n // abortSignal: options?.abortSignal\n // };\n\n // return retry<void>(config);\n // }\n\n async close(): Promise<void> {\n try {\n this._isClosed = true;\n await this._sender.close();\n } catch (err: any) {\n logger.logError(err, `${this.logPrefix} An error occurred while closing the Sender`);\n throw err;\n }\n }\n}\n\n/**\n * @internal\n */\nexport function isServiceBusMessageBatch(\n messageBatchOrAnything: unknown,\n): messageBatchOrAnything is ServiceBusMessageBatch {\n if (messageBatchOrAnything == null) {\n return false;\n }\n\n const possibleBatch = messageBatchOrAnything as ServiceBusMessageBatch;\n\n return (\n typeof possibleBatch.tryAddMessage === \"function\" &&\n typeof possibleBatch.maxSizeInBytes === \"number\" &&\n typeof possibleBatch.sizeInBytes === \"number\"\n );\n}\n"]}
@@ -74,7 +74,15 @@ export function buildQueue(rawQueue) {
74
74
  */
75
75
  export function buildQueueRuntimeProperties(rawQueue) {
76
76
  const messageCountDetails = getMessageCountDetails(rawQueue[Constants.COUNT_DETAILS]);
77
- return Object.assign(Object.assign({ name: getString(rawQueue[Constants.QUEUE_NAME], "queueName"), sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]), totalMessageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]) }, messageCountDetails), { createdAt: getDate(rawQueue[Constants.CREATED_AT], "createdAt"), modifiedAt: getDate(rawQueue[Constants.UPDATED_AT], "modifiedAt"), accessedAt: getDate(rawQueue[Constants.ACCESSED_AT], "accessedAt") });
77
+ return {
78
+ name: getString(rawQueue[Constants.QUEUE_NAME], "queueName"),
79
+ sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]),
80
+ totalMessageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]),
81
+ ...messageCountDetails,
82
+ createdAt: getDate(rawQueue[Constants.CREATED_AT], "createdAt"),
83
+ modifiedAt: getDate(rawQueue[Constants.UPDATED_AT], "modifiedAt"),
84
+ accessedAt: getDate(rawQueue[Constants.ACCESSED_AT], "accessedAt"),
85
+ };
78
86
  }
79
87
  /**
80
88
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"queueResourceSerializer.js","sourceRoot":"","sources":["../../../src/serializers/queueResourceSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACjG,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAElD,OAAO,EACL,gCAAgC,EAChC,UAAU,EACV,sBAAsB,EACtB,UAAU,EACV,qBAAqB,EACrB,wBAAwB,EACxB,SAAS,EACT,oBAAoB,EACpB,OAAO,GACR,MAAM,kBAAkB,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IACzD,OAAO;QACL,mGAAmG;QACnG,mGAAmG;QACnG,wBAAwB;QACxB,EAAE;QACF,0CAA0C;QAC1C,yLAAyL;QAEzL,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,kBAAkB,EAAE,oBAAoB,CAAC,KAAK,CAAC,kBAAkB,CAAC;QAClE,0BAA0B,EAAE,oBAAoB,CAAC,KAAK,CAAC,0BAA0B,CAAC;QAClF,eAAe,EAAE,oBAAoB,CAAC,KAAK,CAAC,eAAe,CAAC;QAC5D,wBAAwB,EAAE,KAAK,CAAC,wBAAwB;QACxD,gCAAgC,EAAE,oBAAoB,CAAC,KAAK,CAAC,gCAAgC,CAAC;QAC9F,mCAAmC,E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BAA6B,CAAC,CAClD;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAA6B;IACvE,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC;IACtF,qCACE,IAAI,EAAE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,EAC5D,WAAW,EAAE,qBAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,EACrE,iBAAiB,EAAE,qBAAqB,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,IACxE,mBAAmB,KACtB,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,EAC/D,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC,EACjE,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC,IAClE;AACJ,CAAC;AAofD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAClC,SAAS,CAAC,QAA8B;QACtC,OAAO,yBAAyB,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAA+B;QAC/C,OAAO,0BAA0B,CAAC,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullOperationResponse, OperationOptions } from \"@azure/core-client\";\nimport type { AtomXmlSerializer } from \"../util/atomXmlHelper.js\";\nimport { deserializeAtomXmlResponse, serializeToAtomXmlRequest } from \"../util/atomXmlHelper.js\";\nimport * as Constants from \"../util/constants.js\";\nimport type { AuthorizationRule, EntityStatus, EntityAvailabilityStatus } from \"../util/utils.js\";\nimport {\n getAuthorizationRulesOrUndefined,\n getBoolean,\n getMessageCountDetails,\n getInteger,\n getIntegerOrUndefined,\n getRawAuthorizationRules,\n getString,\n getStringOrUndefined,\n getDate,\n} from \"../util/utils.js\";\n\n/**\n * @internal\n * Builds the queue options object from the user provided options.\n * Handles the differences in casing for the property names,\n * converts values to string and ensures the right order as expected by the service\n */\nexport function buildQueueOptions(queue: CreateQueueOptions): InternalQueueOptions {\n return {\n // NOTE: this ordering is extremely important. As an example, misordering of the ForwardTo property\n // resulted in a customer bug where the Forwarding attributes appeared to be set but the portal was\n // not picking up on it.\n //\n // The authority on this ordering is here:\n // https://github.com/Azure/azure-sdk-for-net/blob/8af2dfc32c96ef3e340f9d20013bf588d97ea756/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueuePropertiesExtensions.cs#L20\n\n LockDuration: queue.lockDuration,\n MaxSizeInMegabytes: getStringOrUndefined(queue.maxSizeInMegabytes),\n RequiresDuplicateDetection: getStringOrUndefined(queue.requiresDuplicateDetection),\n RequiresSession: getStringOrUndefined(queue.requiresSession),\n DefaultMessageTimeToLive: queue.defaultMessageTimeToLive,\n DeadLetteringOnMessageExpiration: getStringOrUndefined(queue.deadLetteringOnMessageExpiration),\n DuplicateDetectionHistoryTimeWindow: queue.duplicateDetectionHistoryTimeWindow,\n MaxDeliveryCount: getStringOrUndefined(queue.maxDeliveryCount),\n EnableBatchedOperations: getStringOrUndefined(queue.enableBatchedOperations),\n AuthorizationRules: getRawAuthorizationRules(queue.authorizationRules),\n Status: getStringOrUndefined(queue.status),\n ForwardTo: getStringOrUndefined(queue.forwardTo),\n UserMetadata: getStringOrUndefined(queue.userMetadata),\n AutoDeleteOnIdle: getStringOrUndefined(queue.autoDeleteOnIdle),\n EnablePartitioning: getStringOrUndefined(queue.enablePartitioning),\n ForwardDeadLetteredMessagesTo: getStringOrUndefined(queue.forwardDeadLetteredMessagesTo),\n EntityAvailabilityStatus: getStringOrUndefined(queue.availabilityStatus),\n EnableExpress: getStringOrUndefined(queue.enableExpress),\n MaxMessageSizeInKilobytes: getStringOrUndefined(queue.maxMessageSizeInKilobytes),\n };\n}\n\n/**\n * @internal\n * Builds the queue object from the raw json object gotten after deserializing the\n * response from the service\n */\nexport function buildQueue(rawQueue: Record<string, any>): QueueProperties {\n return {\n name: getString(rawQueue[Constants.QUEUE_NAME], \"queueName\"),\n\n forwardTo: getStringOrUndefined(rawQueue[Constants.FORWARD_TO]),\n userMetadata: rawQueue[Constants.USER_METADATA],\n\n lockDuration: getString(rawQueue[Constants.LOCK_DURATION], \"lockDuration\"),\n maxSizeInMegabytes: getInteger(rawQueue[Constants.MAX_SIZE_IN_MEGABYTES], \"maxSizeInMegabytes\"),\n\n maxDeliveryCount: getInteger(rawQueue[Constants.MAX_DELIVERY_COUNT], \"maxDeliveryCount\"),\n\n enablePartitioning: getBoolean(rawQueue[Constants.ENABLE_PARTITIONING], \"enablePartitioning\"),\n requiresSession: getBoolean(rawQueue[Constants.REQUIRES_SESSION], \"requiresSession\"),\n enableBatchedOperations: getBoolean(\n rawQueue[Constants.ENABLE_BATCHED_OPERATIONS],\n \"enableBatchedOperations\",\n ),\n\n defaultMessageTimeToLive: getString(\n rawQueue[Constants.DEFAULT_MESSAGE_TIME_TO_LIVE],\n \"defaultMessageTimeToLive\",\n ),\n autoDeleteOnIdle: rawQueue[Constants.AUTO_DELETE_ON_IDLE],\n\n requiresDuplicateDetection: getBoolean(\n rawQueue[Constants.REQUIRES_DUPLICATE_DETECTION],\n \"requiresDuplicateDetection\",\n ),\n duplicateDetectionHistoryTimeWindow: getString(\n rawQueue[Constants.DUPLICATE_DETECTION_HISTORY_TIME_WINDOW],\n \"duplicateDetectionHistoryTimeWindow\",\n ),\n deadLetteringOnMessageExpiration: getBoolean(\n rawQueue[Constants.DEAD_LETTERING_ON_MESSAGE_EXPIRATION],\n \"deadLetteringOnMessageExpiration\",\n ),\n forwardDeadLetteredMessagesTo: getStringOrUndefined(\n rawQueue[Constants.FORWARD_DEADLETTERED_MESSAGES_TO],\n ),\n\n authorizationRules: getAuthorizationRulesOrUndefined(rawQueue[Constants.AUTHORIZATION_RULES]),\n\n status: rawQueue[Constants.STATUS],\n\n enableExpress: getBoolean(rawQueue[Constants.ENABLE_EXPRESS], \"enableExpress\"),\n\n availabilityStatus: rawQueue[Constants.ENTITY_AVAILABILITY_STATUS],\n\n maxMessageSizeInKilobytes: getIntegerOrUndefined(\n rawQueue[Constants.MAX_MESSAGE_SIZE_IN_KILOBYTES],\n ),\n };\n}\n\n/**\n * @internal\n * Builds the queue runtime info object from the raw json object gotten after deserializing the\n * response from the service\n */\nexport function buildQueueRuntimeProperties(rawQueue: Record<string, any>): QueueRuntimeProperties {\n const messageCountDetails = getMessageCountDetails(rawQueue[Constants.COUNT_DETAILS]);\n return {\n name: getString(rawQueue[Constants.QUEUE_NAME], \"queueName\"),\n sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]),\n totalMessageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]),\n ...messageCountDetails,\n createdAt: getDate(rawQueue[Constants.CREATED_AT], \"createdAt\"),\n modifiedAt: getDate(rawQueue[Constants.UPDATED_AT], \"modifiedAt\"),\n accessedAt: getDate(rawQueue[Constants.ACCESSED_AT], \"accessedAt\"),\n };\n}\n\n/**\n * Represents settable options on a queue\n */\nexport interface CreateQueueOptions extends OperationOptions {\n /**\n * Determines the amount of time in seconds in which a message should be locked for\n * processing by a receiver. After this period, the message is unlocked and available\n * for consumption by the next receiver.\n * (If sessions are enabled, this lock duration is applicable for sessions and not for messages.)\n *\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n lockDuration?: string;\n\n /**\n * Specifies the maximum queue size in megabytes. Any attempt to enqueue a message that\n * will cause the queue to exceed this value will fail.\n */\n maxSizeInMegabytes?: number;\n\n /**\n * The maximum message size in kilobytes for messages sent to this queue.\n *\n * (Configurable only for Premium Tier Service Bus namespace.)\n */\n maxMessageSizeInKilobytes?: number;\n\n /**\n * If enabled, the topic will detect duplicate messages within the time\n * span specified by the DuplicateDetectionHistoryTimeWindow property.\n * Settable only at queue creation time.\n */\n requiresDuplicateDetection?: boolean;\n\n /**\n * If set to true, the queue will be session-aware and only SessionReceiver\n * will be supported. Session-aware queues are not supported through REST.\n * Settable only at queue creation time.\n */\n requiresSession?: boolean;\n\n /**\n * Depending on whether DeadLettering is enabled, a message is automatically\n * moved to the dead-letter sub-queue or deleted if it has been stored in the\n * queue for longer than the specified time.\n * This value is overwritten by a TTL specified on the message\n * if and only if the message TTL is smaller than the TTL set on the queue.\n * This value is immutable after the Queue has been created.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n defaultMessageTimeToLive?: string;\n\n /**\n * If it is enabled and a message expires, the Service Bus moves the message\n * from the queue into the queue’s dead-letter sub-queue. If disabled,\n * message will be permanently deleted from the queue.\n * Settable only at queue creation time.\n */\n deadLetteringOnMessageExpiration?: boolean;\n\n /**\n * Specifies the time span during which the Service Bus detects message duplication.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n duplicateDetectionHistoryTimeWindow?: string;\n\n /**\n * The maximum delivery count of messages after which if it is still not settled,\n * gets moved to the dead-letter sub-queue.\n */\n maxDeliveryCount?: number;\n\n /**\n * Specifies if batched operations should be allowed.\n */\n enableBatchedOperations?: boolean;\n\n /**\n * Authorization rules on the queue\n */\n authorizationRules?: AuthorizationRule[];\n\n /**\n * Status of the messaging entity.\n */\n status?: EntityStatus;\n\n /**\n * Absolute URL or the name of the queue or topic the\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardTo?: string;\n\n /**\n * The user provided metadata information associated with the queue.\n * Used to specify textual content such as tags, labels, etc.\n * Value must not exceed 1024 bytes encoded in utf-8.\n */\n userMetadata?: string;\n\n /**\n * Max idle time before entity is deleted.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n autoDeleteOnIdle?: string;\n\n /**\n * Specifies whether the queue should be partitioned.\n */\n enablePartitioning?: boolean;\n\n /**\n * Absolute URL or the name of the queue or topic the dead-lettered\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardDeadLetteredMessagesTo?: string;\n\n /**\n * Specifies whether express entities are enabled on queue.\n */\n enableExpress?: boolean;\n\n /**\n * Availability status of the messaging entity.\n */\n availabilityStatus?: EntityAvailabilityStatus;\n}\n\n/**\n * Represents the input for updateQueue.\n *\n */\nexport interface QueueProperties {\n /**\n * Name of the queue\n */\n readonly name: string;\n\n /**\n * Determines the amount of time in seconds in which a message should be locked for\n * processing by a receiver. After this period, the message is unlocked and available\n * for consumption by the next receiver.\n * (If sessions are enabled, this lock duration is applicable for sessions and not for messages.)\n *\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n lockDuration: string;\n\n /**\n * Specifies the maximum queue size in megabytes. Any attempt to enqueue a message that\n * will cause the queue to exceed this value will fail.\n */\n maxSizeInMegabytes: number;\n\n /**\n * The maximum message size in kilobytes for messages sent to this queue.\n *\n * Not applicable if service version \"2017-04\" is chosen when creating the `ServiceBusAdministrationClient`.\n */\n maxMessageSizeInKilobytes?: number;\n\n /**\n * If enabled, the topic will detect duplicate messages within the time\n * span specified by the DuplicateDetectionHistoryTimeWindow property.\n * Settable only at queue creation time.\n */\n readonly requiresDuplicateDetection: boolean;\n\n /**\n * If set to true, the queue will be session-aware and only SessionReceiver\n * will be supported. Session-aware queues are not supported through REST.\n * Settable only at queue creation time.\n */\n readonly requiresSession: boolean;\n\n /**\n * Depending on whether DeadLettering is enabled, a message is automatically\n * moved to the dead-letter sub-queue or deleted if it has been stored in the\n * queue for longer than the specified time.\n * This value is overwritten by a TTL specified on the message\n * if and only if the message TTL is smaller than the TTL set on the queue.\n * This value is immutable after the Queue has been created.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n defaultMessageTimeToLive: string;\n\n /**\n * If it is enabled and a message expires, the Service Bus moves the message\n * from the queue into the queue’s dead-letter sub-queue. If disabled,\n * message will be permanently deleted from the queue.\n * Settable only at queue creation time.\n */\n deadLetteringOnMessageExpiration: boolean;\n\n /**\n * Specifies the time span during which the Service Bus detects message duplication.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n duplicateDetectionHistoryTimeWindow: string;\n\n /**\n * The maximum delivery count of messages after which if it is still not settled,\n * gets moved to the dead-letter sub-queue.\n */\n maxDeliveryCount: number;\n\n /**\n * Specifies if batched operations should be allowed.\n */\n enableBatchedOperations: boolean;\n\n /**\n * Authorization rules on the queue\n */\n authorizationRules?: AuthorizationRule[];\n\n /**\n * Status of the messaging entity.\n */\n status: EntityStatus;\n\n /**\n * Absolute URL or the name of the queue or topic the\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardTo?: string;\n\n /**\n * The user provided metadata information associated with the queue.\n * Used to specify textual content such as tags, labels, etc.\n * Value must not exceed 1024 bytes encoded in utf-8.\n */\n userMetadata: string;\n\n /**\n * Max idle time before entity is deleted.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n autoDeleteOnIdle: string;\n\n /**\n * Specifies whether the queue should be partitioned.\n */\n readonly enablePartitioning: boolean;\n\n /**\n * Absolute URL or the name of the queue or topic the dead-lettered\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardDeadLetteredMessagesTo?: string;\n\n /**\n * Specifies whether express entities are enabled on queue.\n */\n readonly enableExpress: boolean;\n\n /**\n * Availability status of the messaging entity.\n */\n readonly availabilityStatus: EntityAvailabilityStatus;\n}\n/**\n * @internal\n * Internal representation of settable options on a queue\n */\nexport interface InternalQueueOptions {\n /**\n * Determines the amount of time in seconds in which a message should be locked for\n * processing by a receiver. After this period, the message is unlocked and\n * can be consumed by the next receiver.\n * (If sessions are enabled, this lock duration is applicable for sessions and not for messages.)\n *\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n LockDuration?: string;\n\n /**\n * The max size in MegaBytes\n *\n */\n MaxSizeInMegabytes?: string;\n\n /**\n * The maximum message size in kilobytes for messages sent to this queue/topic.\n */\n MaxMessageSizeInKilobytes?: string;\n\n /**\n * If enabled, the topic will detect duplicate messages within the time\n * span specified by the DuplicateDetectionHistoryTimeWindow property.\n * Settable only at queue creation time.\n */\n RequiresDuplicateDetection?: string;\n\n /**\n * If set to true, the queue will be session-aware and only SessionReceiver\n * will be supported. Session-aware queues are not supported through REST.\n * Settable only at queue creation time.\n */\n RequiresSession?: string;\n\n /**\n * Depending on whether DeadLettering is enabled, a message is automatically moved to\n * the DeadLetterQueue or deleted if it has been stored in the queue for longer than\n * the specified time. This value is overwritten by a TTL specified on the message\n * if and only if the message TTL is smaller than the TTL set on the queue.\n * This value is immutable after the Queue has been created.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n DefaultMessageTimeToLive?: string;\n\n /**\n * If it is enabled and a message expires, the Service Bus moves the message\n * from the queue into the queue’s dead-letter sub-queue. If disabled,\n * message will be permanently deleted from the queue.\n * Settable only at queue creation time.\n */\n DeadLetteringOnMessageExpiration?: string;\n\n /**\n * Specifies the time span during which the Service Bus detects message duplication.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n DuplicateDetectionHistoryTimeWindow?: string;\n\n /**\n * The maximum delivery count of messages after which if it is still not settled,\n * gets moved to the dead-letter sub-queue.\n *\n */\n MaxDeliveryCount?: string;\n\n /**\n * Specifies if batched operations should be allowed.\n */\n EnableBatchedOperations?: string;\n\n /**\n * Authorization rules on the queue\n */\n AuthorizationRules?: any;\n\n /**\n * Status of the messaging entity.\n */\n Status?: string;\n\n /**\n * Absolute URL or the name of the queue or topic the\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n ForwardTo?: string;\n\n /**\n * The user provided metadata information associated with the queue.\n * Used to specify textual content such as tags, labels, etc.\n * Value must not exceed 1024 bytes encoded in utf-8.\n */\n UserMetadata?: string;\n\n /**\n * Max idle time before entity is deleted.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n AutoDeleteOnIdle?: string;\n\n /**\n * Specifies whether the queue should be partitioned.\n */\n EnablePartitioning?: string;\n\n /**\n * Absolute URL or the name of the queue or topic the dead-lettered\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n ForwardDeadLetteredMessagesTo?: string;\n\n /**\n * Specifies whether express entities are enabled on queue.\n */\n EnableExpress?: string;\n\n /**\n * Availability status of the messaging entity.\n */\n EntityAvailabilityStatus?: string;\n}\n\n/**\n * Represents runtime info attributes of a queue entity\n */\nexport interface QueueRuntimeProperties {\n /**\n * Name of the queue\n */\n name: string;\n\n /**\n * Created at timestamp\n */\n createdAt: Date;\n\n /**\n * Updated at timestamp\n */\n modifiedAt: Date;\n\n /**\n * Accessed at timestamp\n */\n accessedAt: Date;\n\n /**\n * The entity's message count.\n *\n */\n totalMessageCount?: number;\n\n /**\n * The number of active messages in the queue.\n */\n activeMessageCount: number;\n\n /**\n * The number of messages that have been dead lettered.\n */\n deadLetterMessageCount: number;\n\n /**\n * The number of scheduled messages.\n */\n scheduledMessageCount: number;\n\n /**\n * The number of messages transferred to another queue, topic, or subscription\n */\n transferMessageCount: number;\n\n /**\n * The number of messages transferred to the dead letter queue.\n */\n transferDeadLetterMessageCount: number;\n\n /**\n * The entity's size in bytes.\n *\n */\n sizeInBytes?: number;\n}\n\n/**\n * @internal\n * Atom XML Serializer for Queues.\n */\nexport class QueueResourceSerializer implements AtomXmlSerializer {\n serialize(resource: InternalQueueOptions): Record<string, unknown> {\n return serializeToAtomXmlRequest(\"QueueDescription\", resource);\n }\n\n async deserialize(response: FullOperationResponse): Promise<FullOperationResponse> {\n return deserializeAtomXmlResponse([\"QueueName\"], response);\n }\n}\n"]}
1
+ {"version":3,"file":"queueResourceSerializer.js","sourceRoot":"","sources":["../../../src/serializers/queueResourceSerializer.ts"],"names":[],"mappings":"AAAA,uCAAu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tB,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC;QAC/D,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,YAAY,CAAC;QACjE,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,YAAY,CAAC;KACnE,CAAC;AACJ,CAAC;AAofD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAClC,SAAS,CAAC,QAA8B;QACtC,OAAO,yBAAyB,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAA+B;QAC/C,OAAO,0BAA0B,CAAC,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC7D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullOperationResponse, OperationOptions } from \"@azure/core-client\";\nimport type { AtomXmlSerializer } from \"../util/atomXmlHelper.js\";\nimport { deserializeAtomXmlResponse, serializeToAtomXmlRequest } from \"../util/atomXmlHelper.js\";\nimport * as Constants from \"../util/constants.js\";\nimport type { AuthorizationRule, EntityStatus, EntityAvailabilityStatus } from \"../util/utils.js\";\nimport {\n getAuthorizationRulesOrUndefined,\n getBoolean,\n getMessageCountDetails,\n getInteger,\n getIntegerOrUndefined,\n getRawAuthorizationRules,\n getString,\n getStringOrUndefined,\n getDate,\n} from \"../util/utils.js\";\n\n/**\n * @internal\n * Builds the queue options object from the user provided options.\n * Handles the differences in casing for the property names,\n * converts values to string and ensures the right order as expected by the service\n */\nexport function buildQueueOptions(queue: CreateQueueOptions): InternalQueueOptions {\n return {\n // NOTE: this ordering is extremely important. As an example, misordering of the ForwardTo property\n // resulted in a customer bug where the Forwarding attributes appeared to be set but the portal was\n // not picking up on it.\n //\n // The authority on this ordering is here:\n // https://github.com/Azure/azure-sdk-for-net/blob/8af2dfc32c96ef3e340f9d20013bf588d97ea756/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/QueuePropertiesExtensions.cs#L20\n\n LockDuration: queue.lockDuration,\n MaxSizeInMegabytes: getStringOrUndefined(queue.maxSizeInMegabytes),\n RequiresDuplicateDetection: getStringOrUndefined(queue.requiresDuplicateDetection),\n RequiresSession: getStringOrUndefined(queue.requiresSession),\n DefaultMessageTimeToLive: queue.defaultMessageTimeToLive,\n DeadLetteringOnMessageExpiration: getStringOrUndefined(queue.deadLetteringOnMessageExpiration),\n DuplicateDetectionHistoryTimeWindow: queue.duplicateDetectionHistoryTimeWindow,\n MaxDeliveryCount: getStringOrUndefined(queue.maxDeliveryCount),\n EnableBatchedOperations: getStringOrUndefined(queue.enableBatchedOperations),\n AuthorizationRules: getRawAuthorizationRules(queue.authorizationRules),\n Status: getStringOrUndefined(queue.status),\n ForwardTo: getStringOrUndefined(queue.forwardTo),\n UserMetadata: getStringOrUndefined(queue.userMetadata),\n AutoDeleteOnIdle: getStringOrUndefined(queue.autoDeleteOnIdle),\n EnablePartitioning: getStringOrUndefined(queue.enablePartitioning),\n ForwardDeadLetteredMessagesTo: getStringOrUndefined(queue.forwardDeadLetteredMessagesTo),\n EntityAvailabilityStatus: getStringOrUndefined(queue.availabilityStatus),\n EnableExpress: getStringOrUndefined(queue.enableExpress),\n MaxMessageSizeInKilobytes: getStringOrUndefined(queue.maxMessageSizeInKilobytes),\n };\n}\n\n/**\n * @internal\n * Builds the queue object from the raw json object gotten after deserializing the\n * response from the service\n */\nexport function buildQueue(rawQueue: Record<string, any>): QueueProperties {\n return {\n name: getString(rawQueue[Constants.QUEUE_NAME], \"queueName\"),\n\n forwardTo: getStringOrUndefined(rawQueue[Constants.FORWARD_TO]),\n userMetadata: rawQueue[Constants.USER_METADATA],\n\n lockDuration: getString(rawQueue[Constants.LOCK_DURATION], \"lockDuration\"),\n maxSizeInMegabytes: getInteger(rawQueue[Constants.MAX_SIZE_IN_MEGABYTES], \"maxSizeInMegabytes\"),\n\n maxDeliveryCount: getInteger(rawQueue[Constants.MAX_DELIVERY_COUNT], \"maxDeliveryCount\"),\n\n enablePartitioning: getBoolean(rawQueue[Constants.ENABLE_PARTITIONING], \"enablePartitioning\"),\n requiresSession: getBoolean(rawQueue[Constants.REQUIRES_SESSION], \"requiresSession\"),\n enableBatchedOperations: getBoolean(\n rawQueue[Constants.ENABLE_BATCHED_OPERATIONS],\n \"enableBatchedOperations\",\n ),\n\n defaultMessageTimeToLive: getString(\n rawQueue[Constants.DEFAULT_MESSAGE_TIME_TO_LIVE],\n \"defaultMessageTimeToLive\",\n ),\n autoDeleteOnIdle: rawQueue[Constants.AUTO_DELETE_ON_IDLE],\n\n requiresDuplicateDetection: getBoolean(\n rawQueue[Constants.REQUIRES_DUPLICATE_DETECTION],\n \"requiresDuplicateDetection\",\n ),\n duplicateDetectionHistoryTimeWindow: getString(\n rawQueue[Constants.DUPLICATE_DETECTION_HISTORY_TIME_WINDOW],\n \"duplicateDetectionHistoryTimeWindow\",\n ),\n deadLetteringOnMessageExpiration: getBoolean(\n rawQueue[Constants.DEAD_LETTERING_ON_MESSAGE_EXPIRATION],\n \"deadLetteringOnMessageExpiration\",\n ),\n forwardDeadLetteredMessagesTo: getStringOrUndefined(\n rawQueue[Constants.FORWARD_DEADLETTERED_MESSAGES_TO],\n ),\n\n authorizationRules: getAuthorizationRulesOrUndefined(rawQueue[Constants.AUTHORIZATION_RULES]),\n\n status: rawQueue[Constants.STATUS],\n\n enableExpress: getBoolean(rawQueue[Constants.ENABLE_EXPRESS], \"enableExpress\"),\n\n availabilityStatus: rawQueue[Constants.ENTITY_AVAILABILITY_STATUS],\n\n maxMessageSizeInKilobytes: getIntegerOrUndefined(\n rawQueue[Constants.MAX_MESSAGE_SIZE_IN_KILOBYTES],\n ),\n };\n}\n\n/**\n * @internal\n * Builds the queue runtime info object from the raw json object gotten after deserializing the\n * response from the service\n */\nexport function buildQueueRuntimeProperties(rawQueue: Record<string, any>): QueueRuntimeProperties {\n const messageCountDetails = getMessageCountDetails(rawQueue[Constants.COUNT_DETAILS]);\n return {\n name: getString(rawQueue[Constants.QUEUE_NAME], \"queueName\"),\n sizeInBytes: getIntegerOrUndefined(rawQueue[Constants.SIZE_IN_BYTES]),\n totalMessageCount: getIntegerOrUndefined(rawQueue[Constants.MESSAGE_COUNT]),\n ...messageCountDetails,\n createdAt: getDate(rawQueue[Constants.CREATED_AT], \"createdAt\"),\n modifiedAt: getDate(rawQueue[Constants.UPDATED_AT], \"modifiedAt\"),\n accessedAt: getDate(rawQueue[Constants.ACCESSED_AT], \"accessedAt\"),\n };\n}\n\n/**\n * Represents settable options on a queue\n */\nexport interface CreateQueueOptions extends OperationOptions {\n /**\n * Determines the amount of time in seconds in which a message should be locked for\n * processing by a receiver. After this period, the message is unlocked and available\n * for consumption by the next receiver.\n * (If sessions are enabled, this lock duration is applicable for sessions and not for messages.)\n *\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n lockDuration?: string;\n\n /**\n * Specifies the maximum queue size in megabytes. Any attempt to enqueue a message that\n * will cause the queue to exceed this value will fail.\n */\n maxSizeInMegabytes?: number;\n\n /**\n * The maximum message size in kilobytes for messages sent to this queue.\n *\n * (Configurable only for Premium Tier Service Bus namespace.)\n */\n maxMessageSizeInKilobytes?: number;\n\n /**\n * If enabled, the topic will detect duplicate messages within the time\n * span specified by the DuplicateDetectionHistoryTimeWindow property.\n * Settable only at queue creation time.\n */\n requiresDuplicateDetection?: boolean;\n\n /**\n * If set to true, the queue will be session-aware and only SessionReceiver\n * will be supported. Session-aware queues are not supported through REST.\n * Settable only at queue creation time.\n */\n requiresSession?: boolean;\n\n /**\n * Depending on whether DeadLettering is enabled, a message is automatically\n * moved to the dead-letter sub-queue or deleted if it has been stored in the\n * queue for longer than the specified time.\n * This value is overwritten by a TTL specified on the message\n * if and only if the message TTL is smaller than the TTL set on the queue.\n * This value is immutable after the Queue has been created.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n defaultMessageTimeToLive?: string;\n\n /**\n * If it is enabled and a message expires, the Service Bus moves the message\n * from the queue into the queue’s dead-letter sub-queue. If disabled,\n * message will be permanently deleted from the queue.\n * Settable only at queue creation time.\n */\n deadLetteringOnMessageExpiration?: boolean;\n\n /**\n * Specifies the time span during which the Service Bus detects message duplication.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n duplicateDetectionHistoryTimeWindow?: string;\n\n /**\n * The maximum delivery count of messages after which if it is still not settled,\n * gets moved to the dead-letter sub-queue.\n */\n maxDeliveryCount?: number;\n\n /**\n * Specifies if batched operations should be allowed.\n */\n enableBatchedOperations?: boolean;\n\n /**\n * Authorization rules on the queue\n */\n authorizationRules?: AuthorizationRule[];\n\n /**\n * Status of the messaging entity.\n */\n status?: EntityStatus;\n\n /**\n * Absolute URL or the name of the queue or topic the\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardTo?: string;\n\n /**\n * The user provided metadata information associated with the queue.\n * Used to specify textual content such as tags, labels, etc.\n * Value must not exceed 1024 bytes encoded in utf-8.\n */\n userMetadata?: string;\n\n /**\n * Max idle time before entity is deleted.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n autoDeleteOnIdle?: string;\n\n /**\n * Specifies whether the queue should be partitioned.\n */\n enablePartitioning?: boolean;\n\n /**\n * Absolute URL or the name of the queue or topic the dead-lettered\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardDeadLetteredMessagesTo?: string;\n\n /**\n * Specifies whether express entities are enabled on queue.\n */\n enableExpress?: boolean;\n\n /**\n * Availability status of the messaging entity.\n */\n availabilityStatus?: EntityAvailabilityStatus;\n}\n\n/**\n * Represents the input for updateQueue.\n *\n */\nexport interface QueueProperties {\n /**\n * Name of the queue\n */\n readonly name: string;\n\n /**\n * Determines the amount of time in seconds in which a message should be locked for\n * processing by a receiver. After this period, the message is unlocked and available\n * for consumption by the next receiver.\n * (If sessions are enabled, this lock duration is applicable for sessions and not for messages.)\n *\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n lockDuration: string;\n\n /**\n * Specifies the maximum queue size in megabytes. Any attempt to enqueue a message that\n * will cause the queue to exceed this value will fail.\n */\n maxSizeInMegabytes: number;\n\n /**\n * The maximum message size in kilobytes for messages sent to this queue.\n *\n * Not applicable if service version \"2017-04\" is chosen when creating the `ServiceBusAdministrationClient`.\n */\n maxMessageSizeInKilobytes?: number;\n\n /**\n * If enabled, the topic will detect duplicate messages within the time\n * span specified by the DuplicateDetectionHistoryTimeWindow property.\n * Settable only at queue creation time.\n */\n readonly requiresDuplicateDetection: boolean;\n\n /**\n * If set to true, the queue will be session-aware and only SessionReceiver\n * will be supported. Session-aware queues are not supported through REST.\n * Settable only at queue creation time.\n */\n readonly requiresSession: boolean;\n\n /**\n * Depending on whether DeadLettering is enabled, a message is automatically\n * moved to the dead-letter sub-queue or deleted if it has been stored in the\n * queue for longer than the specified time.\n * This value is overwritten by a TTL specified on the message\n * if and only if the message TTL is smaller than the TTL set on the queue.\n * This value is immutable after the Queue has been created.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n defaultMessageTimeToLive: string;\n\n /**\n * If it is enabled and a message expires, the Service Bus moves the message\n * from the queue into the queue’s dead-letter sub-queue. If disabled,\n * message will be permanently deleted from the queue.\n * Settable only at queue creation time.\n */\n deadLetteringOnMessageExpiration: boolean;\n\n /**\n * Specifies the time span during which the Service Bus detects message duplication.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n duplicateDetectionHistoryTimeWindow: string;\n\n /**\n * The maximum delivery count of messages after which if it is still not settled,\n * gets moved to the dead-letter sub-queue.\n */\n maxDeliveryCount: number;\n\n /**\n * Specifies if batched operations should be allowed.\n */\n enableBatchedOperations: boolean;\n\n /**\n * Authorization rules on the queue\n */\n authorizationRules?: AuthorizationRule[];\n\n /**\n * Status of the messaging entity.\n */\n status: EntityStatus;\n\n /**\n * Absolute URL or the name of the queue or topic the\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardTo?: string;\n\n /**\n * The user provided metadata information associated with the queue.\n * Used to specify textual content such as tags, labels, etc.\n * Value must not exceed 1024 bytes encoded in utf-8.\n */\n userMetadata: string;\n\n /**\n * Max idle time before entity is deleted.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n autoDeleteOnIdle: string;\n\n /**\n * Specifies whether the queue should be partitioned.\n */\n readonly enablePartitioning: boolean;\n\n /**\n * Absolute URL or the name of the queue or topic the dead-lettered\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n forwardDeadLetteredMessagesTo?: string;\n\n /**\n * Specifies whether express entities are enabled on queue.\n */\n readonly enableExpress: boolean;\n\n /**\n * Availability status of the messaging entity.\n */\n readonly availabilityStatus: EntityAvailabilityStatus;\n}\n/**\n * @internal\n * Internal representation of settable options on a queue\n */\nexport interface InternalQueueOptions {\n /**\n * Determines the amount of time in seconds in which a message should be locked for\n * processing by a receiver. After this period, the message is unlocked and\n * can be consumed by the next receiver.\n * (If sessions are enabled, this lock duration is applicable for sessions and not for messages.)\n *\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n LockDuration?: string;\n\n /**\n * The max size in MegaBytes\n *\n */\n MaxSizeInMegabytes?: string;\n\n /**\n * The maximum message size in kilobytes for messages sent to this queue/topic.\n */\n MaxMessageSizeInKilobytes?: string;\n\n /**\n * If enabled, the topic will detect duplicate messages within the time\n * span specified by the DuplicateDetectionHistoryTimeWindow property.\n * Settable only at queue creation time.\n */\n RequiresDuplicateDetection?: string;\n\n /**\n * If set to true, the queue will be session-aware and only SessionReceiver\n * will be supported. Session-aware queues are not supported through REST.\n * Settable only at queue creation time.\n */\n RequiresSession?: string;\n\n /**\n * Depending on whether DeadLettering is enabled, a message is automatically moved to\n * the DeadLetterQueue or deleted if it has been stored in the queue for longer than\n * the specified time. This value is overwritten by a TTL specified on the message\n * if and only if the message TTL is smaller than the TTL set on the queue.\n * This value is immutable after the Queue has been created.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n DefaultMessageTimeToLive?: string;\n\n /**\n * If it is enabled and a message expires, the Service Bus moves the message\n * from the queue into the queue’s dead-letter sub-queue. If disabled,\n * message will be permanently deleted from the queue.\n * Settable only at queue creation time.\n */\n DeadLetteringOnMessageExpiration?: string;\n\n /**\n * Specifies the time span during which the Service Bus detects message duplication.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n DuplicateDetectionHistoryTimeWindow?: string;\n\n /**\n * The maximum delivery count of messages after which if it is still not settled,\n * gets moved to the dead-letter sub-queue.\n *\n */\n MaxDeliveryCount?: string;\n\n /**\n * Specifies if batched operations should be allowed.\n */\n EnableBatchedOperations?: string;\n\n /**\n * Authorization rules on the queue\n */\n AuthorizationRules?: any;\n\n /**\n * Status of the messaging entity.\n */\n Status?: string;\n\n /**\n * Absolute URL or the name of the queue or topic the\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n ForwardTo?: string;\n\n /**\n * The user provided metadata information associated with the queue.\n * Used to specify textual content such as tags, labels, etc.\n * Value must not exceed 1024 bytes encoded in utf-8.\n */\n UserMetadata?: string;\n\n /**\n * Max idle time before entity is deleted.\n * This is to be specified in ISO-8601 duration format\n * such as \"PT1M\" for 1 minute, \"PT5S\" for 5 seconds.\n *\n * More on ISO-8601 duration format: https://en.wikipedia.org/wiki/ISO_8601#Durations\n */\n AutoDeleteOnIdle?: string;\n\n /**\n * Specifies whether the queue should be partitioned.\n */\n EnablePartitioning?: string;\n\n /**\n * Absolute URL or the name of the queue or topic the dead-lettered\n * messages are to be forwarded to.\n * For example, an absolute URL input would be of the form\n * `sb://<your-service-bus-namespace-endpoint>/<queue-or-topic-name>`\n */\n ForwardDeadLetteredMessagesTo?: string;\n\n /**\n * Specifies whether express entities are enabled on queue.\n */\n EnableExpress?: string;\n\n /**\n * Availability status of the messaging entity.\n */\n EntityAvailabilityStatus?: string;\n}\n\n/**\n * Represents runtime info attributes of a queue entity\n */\nexport interface QueueRuntimeProperties {\n /**\n * Name of the queue\n */\n name: string;\n\n /**\n * Created at timestamp\n */\n createdAt: Date;\n\n /**\n * Updated at timestamp\n */\n modifiedAt: Date;\n\n /**\n * Accessed at timestamp\n */\n accessedAt: Date;\n\n /**\n * The entity's message count.\n *\n */\n totalMessageCount?: number;\n\n /**\n * The number of active messages in the queue.\n */\n activeMessageCount: number;\n\n /**\n * The number of messages that have been dead lettered.\n */\n deadLetterMessageCount: number;\n\n /**\n * The number of scheduled messages.\n */\n scheduledMessageCount: number;\n\n /**\n * The number of messages transferred to another queue, topic, or subscription\n */\n transferMessageCount: number;\n\n /**\n * The number of messages transferred to the dead letter queue.\n */\n transferDeadLetterMessageCount: number;\n\n /**\n * The entity's size in bytes.\n *\n */\n sizeInBytes?: number;\n}\n\n/**\n * @internal\n * Atom XML Serializer for Queues.\n */\nexport class QueueResourceSerializer implements AtomXmlSerializer {\n serialize(resource: InternalQueueOptions): Record<string, unknown> {\n return serializeToAtomXmlRequest(\"QueueDescription\", resource);\n }\n\n async deserialize(response: FullOperationResponse): Promise<FullOperationResponse> {\n return deserializeAtomXmlResponse([\"QueueName\"], response);\n }\n}\n"]}
@@ -180,13 +180,12 @@ const keyValuePairXMLTag = "KeyValueOfstringanyType";
180
180
  * or undefined if not passed in.
181
181
  */
182
182
  function getKeyValuePairsOrUndefined(value, attribute) {
183
- var _a;
184
183
  if (!value) {
185
184
  return undefined;
186
185
  }
187
186
  const properties = {};
188
187
  let rawProperties;
189
- if (!Array.isArray(value[keyValuePairXMLTag]) && ((_a = value[keyValuePairXMLTag]) === null || _a === void 0 ? void 0 : _a.Key)) {
188
+ if (!Array.isArray(value[keyValuePairXMLTag]) && value[keyValuePairXMLTag]?.Key) {
190
189
  // When a single property is present,
191
190
  // value["KeyValueOfstringanyType"] is { Key: <key>, Value: [Object] }
192
191
  // When multiple properties are present,
@@ -1 +1 @@
1
- {"version":3,"file":"ruleResourceSerializer.js","sourceRoot":"","sources":["../../../src/serializers/ruleResourceSerializer.ts"],"names":[],"mappings":"AAAA,uCA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O,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,GAAG,8BAA8B,CAAC,MAAM,CAAC;QAC/C,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,IAAI,GAAG,8BAA8B,CAAC,MAAM,CAAC;QAC/C,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YACtC,IAAI,GAAG,8BAA8B,CAAC,OAAO,CAAC;QAChD,CAAC;aAAM,IAAI,KAAK,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;YAC5D,IAAI,GAAG,8BAA8B,CAAC,IAAI,CAAC;YAC3C,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,SAAS,CACjB,yCAAyC,SAAS,iBAAiB,GAAG,GAAG,CAC1E,CAAC;QACJ,CAAC;QAED,MAAM,YAAY,GAAoB;YACpC,GAAG,EAAE,GAAG;YACR,KAAK,EAAE;gBACL,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE;oBAC/B,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,kCAAkC;iBAChD;gBACD,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,KAAK;aACpC;SACF,CAAC;QACF,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IACD,OAAO;QACL,CAAC,kBAAkB,CAAC,EAAE,aAAa;KACpC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullOperationResponse } from \"@azure/core-client\";\nimport type { CorrelationRuleFilter } from \"../core/managementClient.js\";\nimport type { AtomXmlSerializer } from \"../util/atomXmlHelper.js\";\nimport { deserializeAtomXmlResponse, serializeToAtomXmlRequest } from \"../util/atomXmlHelper.js\";\nimport * as Constants from \"../util/constants.js\";\nimport { isDefined, isObjectWithProperties } from \"@azure/core-util\";\nimport { getString, getStringOrUndefined } from \"../util/utils.js\";\n\n/**\n * @internal\n * Builds the rule object from the raw json object gotten after deserializing the\n * response from the service\n */\nexport function buildRule(rawRule: Record<string, any>): RuleProperties {\n return {\n name: getString(rawRule[\"RuleName\"], \"ruleName\"),\n filter: getTopicFilter(rawRule[\"Filter\"]),\n action: getRuleAction(rawRule[\"Action\"]),\n };\n}\n\n/**\n * @internal\n * Helper utility to retrieve `filter` value from given input,\n * or undefined if not passed in.\n */\nfunction getTopicFilter(value: any): SqlRuleFilter | CorrelationRuleFilter {\n let result: SqlRuleFilter | CorrelationRuleFilter;\n\n if (isDefined(value[\"SqlExpression\"])) {\n result = {\n sqlExpression: value[\"SqlExpression\"],\n sqlParameters: getKeyValuePairsOrUndefined(value[\"Parameters\"], \"SQLParameters\"),\n };\n } else {\n result = {\n correlationId: getStringOrUndefined(value[\"CorrelationId\"]),\n subject: getStringOrUndefined(value[\"Label\"]),\n to: getStringOrUndefined(value[\"To\"]),\n replyTo: getStringOrUndefined(value[\"ReplyTo\"]),\n replyToSessionId: getStringOrUndefined(value[\"ReplyToSessionId\"]),\n sessionId: getStringOrUndefined(value[\"SessionId\"]),\n messageId: getStringOrUndefined(value[\"MessageId\"]),\n contentType: getStringOrUndefined(value[\"ContentType\"]),\n applicationProperties: getKeyValuePairsOrUndefined(\n value[\"Properties\"],\n \"ApplicationProperties\",\n ),\n };\n }\n return result;\n}\n\n/**\n * @internal\n * Helper utility to retrieve rule `action` value from given input.\n */\nfunction getRuleAction(value: any): SqlRuleAction {\n return {\n sqlExpression: value[\"SqlExpression\"],\n sqlParameters: getKeyValuePairsOrUndefined(value[\"Parameters\"], \"SQLParameters\"),\n };\n}\n\n/**\n * Represents the options to create a rule for a subscription.\n * @internal\n */\nexport interface CreateRuleOptions {\n /**\n * Name of the rule\n */\n name: string;\n\n /**\n * Defines the filter expression that the rule evaluates. For `SqlRuleFilter` input,\n * the expression string is interpreted as a SQL92 expression which must\n * evaluate to True or False. Only one between a `CorrelationRuleFilter` or\n * a `SqlRuleFilter` can be defined.\n */\n filter?: SqlRuleFilter | CorrelationRuleFilter;\n\n /**\n * The SQL like expression that can be executed on the message should the\n * associated filter apply.\n */\n action?: SqlRuleAction;\n}\n\n/**\n * Represents all the attributes of a rule.\n */\nexport interface RuleProperties {\n /**\n * Name of the rule\n */\n readonly name: string;\n\n /**\n * Defines the filter expression that the rule evaluates. For `SqlRuleFilter` input,\n * the expression string is interpreted as a SQL92 expression which must\n * evaluate to True or False. Only one between a `CorrelationRuleFilter` or\n * a `SqlRuleFilter` can be defined.\n */\n filter: SqlRuleFilter | CorrelationRuleFilter;\n\n /**\n * The SQL like expression that can be executed on the message should the\n * associated filter apply.\n */\n action: SqlRuleAction;\n}\n\n/**\n * Represents all possible fields on SqlRuleAction\n */\nexport type SqlRuleAction = {\n /**\n * SQL expression to use in the rule action.\n */\n sqlExpression?: string;\n\n /**\n * SQL parameters to the SQL expression in the rule action.\n */\n sqlParameters?: { [key: string]: string | number | boolean };\n};\n\n/**\n * Represents all possible fields on SqlRuleFilter\n */\nexport interface SqlRuleFilter {\n /**\n * SQL expression to use in the rule filter. It is evaluated against the messages'\n * user-defined properties and system properties. All system properties will be prefixed with\n * `sys.` in the condition expression.\n * Defaults to creating a true filter if none specified\n */\n sqlExpression: string;\n\n /**\n * SQL parameters to the SQL expression in the rule filter.\n */\n sqlParameters?: { [key: string]: string | number | boolean };\n}\n\n/**\n * @internal\n *\n */\nexport interface InternalRuleOptions {\n Name: string;\n Filter: any;\n Action: any;\n}\n\n/**\n * @internal\n *\n */\nexport function buildInternalRuleResource(rule: CreateRuleOptions): InternalRuleOptions {\n const resource: InternalRuleOptions = {\n Filter: {},\n Action: {},\n Name: rule.name,\n };\n\n if (!isDefined(rule.filter)) {\n // Defaults to creating a true filter if none specified\n resource.Filter = {\n SqlExpression: \"1=1\",\n };\n resource.Filter[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"SqlFilter\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n } else {\n if (isObjectWithProperties(rule.filter, [\"sqlExpression\"])) {\n const sqlFilter: SqlRuleFilter = rule.filter as SqlRuleFilter;\n resource.Filter = {\n SqlExpression: sqlFilter.sqlExpression,\n Parameters: buildInternalRawKeyValuePairs(sqlFilter.sqlParameters, \"sqlParameters\"),\n };\n resource.Filter[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"SqlFilter\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n } else {\n const correlationFilter: CorrelationRuleFilter = rule.filter as CorrelationRuleFilter;\n\n resource.Filter = {\n CorrelationId: correlationFilter.correlationId,\n Label: correlationFilter.subject,\n To: correlationFilter.to,\n ReplyTo: correlationFilter.replyTo,\n ReplyToSessionId: correlationFilter.replyToSessionId,\n ContentType: correlationFilter.contentType,\n SessionId: correlationFilter.sessionId,\n MessageId: correlationFilter.messageId,\n Properties: buildInternalRawKeyValuePairs(\n correlationFilter.applicationProperties,\n \"applicationProperties\",\n ),\n };\n resource.Filter[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"CorrelationFilter\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n }\n }\n\n if (!isDefined(rule.action) || !isDefined(rule.action.sqlExpression)) {\n // Defaults to creating an empty rule action instance if none specified\n resource.Action = {};\n resource.Action[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"EmptyRuleAction\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n } else {\n resource.Action = {\n SqlExpression: rule.action.sqlExpression,\n Parameters: buildInternalRawKeyValuePairs(rule.action.sqlParameters, \"sqlParameters\"),\n };\n resource.Action[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"SqlRuleAction\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n }\n\n return resource;\n}\n\n/**\n * @internal\n * RuleResourceSerializer for serializing / deserializing Rule entities\n */\nexport class RuleResourceSerializer implements AtomXmlSerializer {\n serialize(rule: RuleProperties): Record<string, unknown> {\n return serializeToAtomXmlRequest(\"RuleDescription\", buildInternalRuleResource(rule));\n }\n\n async deserialize(response: FullOperationResponse): Promise<FullOperationResponse> {\n return deserializeAtomXmlResponse([\"TopicName\", \"SubscriptionName\", \"RuleName\"], response);\n }\n}\n\n/**\n * @internal\n */\nexport function isSqlRuleAction(action: unknown): action is SqlRuleAction {\n return isObjectWithProperties(action, [\"sqlExpression\"]);\n}\n\n/**\n * Service expects the XML request with the special type names serialized in the request,\n * the request would fail otherwise.\n *\n * @internal\n */\nenum TypeMapForRequestSerialization {\n double = \"l28:double\",\n string = \"l28:string\",\n long = \"l28:long\",\n date = \"l28:dateTime\",\n boolean = \"l28:boolean\",\n}\n\n/**\n * @internal\n */\nenum TypeMapForResponseDeserialization {\n int = \"int\",\n double = \"double\",\n string = \"string\",\n boolean = \"boolean\",\n date = \"dateTime\",\n}\n\n/**\n * @internal\n * Internal representation of key-value pair\n */\ntype RawKeyValuePair = {\n Key: string;\n Value: any;\n};\n\n/**\n * @internal\n */\ninterface InternalRawKeyValuePairs {\n KeyValueOfstringanyType: RawKeyValuePair[];\n}\n\n/**\n * Key-value pairs are supposed to be wrapped with this tag in the XML request, they are ignored otherwise.\n *\n * @internal\n */\nconst keyValuePairXMLTag = \"KeyValueOfstringanyType\";\n\n/**\n * @internal\n * Helper utility to retrieve the key-value pairs from the RawKeyValue object from given input,\n * or undefined if not passed in.\n */\nfunction getKeyValuePairsOrUndefined(\n value: any,\n attribute: \"ApplicationProperties\" | \"SQLParameters\",\n): { [key: string]: any } | undefined {\n if (!value) {\n return undefined;\n }\n const properties: any = {};\n let rawProperties;\n if (!Array.isArray(value[keyValuePairXMLTag]) && value[keyValuePairXMLTag]?.Key) {\n // When a single property is present,\n // value[\"KeyValueOfstringanyType\"] is { Key: <key>, Value: [Object] }\n // When multiple properties are present,\n // value[\"KeyValueOfstringanyType\"] is [ { Key: <key-1>, Value: [Object] }, { Key: <key-2>, Value: [Object] } ]\n // For consistency, wrapping `value[\"KeyValueOfstringanyType\"]` as an array for the \"single property\" case.\n rawProperties = [value[keyValuePairXMLTag]];\n } else {\n rawProperties = value[keyValuePairXMLTag];\n }\n if (Array.isArray(rawProperties)) {\n for (const rawProperty of rawProperties) {\n const key = rawProperty.Key;\n const _value = rawProperty.Value[\"_\"];\n const encodedValueType = rawProperty.Value[\"$\"][\"i:type\"].toString().substring(5);\n if (\n encodedValueType === TypeMapForResponseDeserialization.int ||\n encodedValueType === TypeMapForResponseDeserialization.double\n ) {\n properties[key] = Number(_value);\n } else if (encodedValueType === TypeMapForResponseDeserialization.string) {\n properties[key] = _value;\n } else if (encodedValueType === TypeMapForResponseDeserialization.boolean) {\n properties[key] = _value === \"true\" ? true : false;\n } else if (encodedValueType === TypeMapForResponseDeserialization.date) {\n properties[key] = new Date(_value);\n } else {\n throw new TypeError(\n `Unable to parse the key-value pairs in the response - ${JSON.stringify(rawProperty)}`,\n );\n }\n }\n } else {\n throw new TypeError(\n `${attribute} in the response is not an array, unable to parse the response - ${JSON.stringify(\n value,\n )}`,\n );\n }\n return properties;\n}\n\n/**\n * @internal\n * Helper utility to extract array of user properties key-value instances from given input,\n * or undefined if not passed in.\n */\nexport function buildInternalRawKeyValuePairs(\n parameters: { [key: string]: any } | undefined,\n attribute: \"applicationProperties\" | \"sqlParameters\",\n): InternalRawKeyValuePairs | undefined {\n if (!isDefined(parameters)) {\n return undefined;\n }\n if (\n Array.isArray(parameters) ||\n typeof parameters === \"string\" ||\n typeof parameters !== \"object\" ||\n Object.entries(parameters).length < 1\n ) {\n throw new TypeError(\n `Unsupported value for the ${attribute} ${JSON.stringify(\n parameters,\n )}, expected a JSON object with key-value pairs.`,\n );\n }\n const rawParameters: RawKeyValuePair[] = [];\n for (const key of Object.keys(parameters)) {\n let type: string | number | boolean;\n let value = parameters[key];\n if (typeof value === \"number\") {\n type = TypeMapForRequestSerialization.double;\n } else if (typeof value === \"string\") {\n type = TypeMapForRequestSerialization.string;\n } else if (typeof value === \"boolean\") {\n type = TypeMapForRequestSerialization.boolean;\n } else if (value instanceof Date && !isNaN(value.valueOf())) {\n type = TypeMapForRequestSerialization.date;\n value = value.toJSON();\n } else {\n throw new TypeError(\n `Unsupported type for the value in the ${attribute} for the key '${key}'`,\n );\n }\n\n const rawParameter: RawKeyValuePair = {\n Key: key,\n Value: {\n [Constants.XML_METADATA_MARKER]: {\n \"p4:type\": type,\n \"xmlns:l28\": \"http://www.w3.org/2001/XMLSchema\",\n },\n [Constants.XML_VALUE_MARKER]: value,\n },\n };\n rawParameters.push(rawParameter);\n }\n return {\n [keyValuePairXMLTag]: rawParameters,\n };\n}\n"]}
1
+ {"version":3,"file":"ruleResourceSerializer.js","sourceRoot":"","sources":["../../../src/serializers/ruleResourceSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACjG,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,OAA4B;IACpD,OAAO;QACL,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;QAChD,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACzC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;KACzC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAS,cAAc,CAAC,KAAU;IAChC,IAAI,MAA6C,CAAC;IAElD,IAAI,SAAS,CAAC,KAAK,CAAC,eAAe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AAE;gBACL,CAAC,SAAS,CAAC,mBAAmB,CAAC,EAAE;oBAC/B,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,kCAAkC;iBAChD;gBACD,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,KAAK;aACpC;SACF,CAAC;QACF,aAAa,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACnC,CAAC;IACD,OAAO;QACL,CAAC,kBAAkB,CAAC,EAAE,aAAa;KACpC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { FullOperationResponse } from \"@azure/core-client\";\nimport type { CorrelationRuleFilter } from \"../core/managementClient.js\";\nimport type { AtomXmlSerializer } from \"../util/atomXmlHelper.js\";\nimport { deserializeAtomXmlResponse, serializeToAtomXmlRequest } from \"../util/atomXmlHelper.js\";\nimport * as Constants from \"../util/constants.js\";\nimport { isDefined, isObjectWithProperties } from \"@azure/core-util\";\nimport { getString, getStringOrUndefined } from \"../util/utils.js\";\n\n/**\n * @internal\n * Builds the rule object from the raw json object gotten after deserializing the\n * response from the service\n */\nexport function buildRule(rawRule: Record<string, any>): RuleProperties {\n return {\n name: getString(rawRule[\"RuleName\"], \"ruleName\"),\n filter: getTopicFilter(rawRule[\"Filter\"]),\n action: getRuleAction(rawRule[\"Action\"]),\n };\n}\n\n/**\n * @internal\n * Helper utility to retrieve `filter` value from given input,\n * or undefined if not passed in.\n */\nfunction getTopicFilter(value: any): SqlRuleFilter | CorrelationRuleFilter {\n let result: SqlRuleFilter | CorrelationRuleFilter;\n\n if (isDefined(value[\"SqlExpression\"])) {\n result = {\n sqlExpression: value[\"SqlExpression\"],\n sqlParameters: getKeyValuePairsOrUndefined(value[\"Parameters\"], \"SQLParameters\"),\n };\n } else {\n result = {\n correlationId: getStringOrUndefined(value[\"CorrelationId\"]),\n subject: getStringOrUndefined(value[\"Label\"]),\n to: getStringOrUndefined(value[\"To\"]),\n replyTo: getStringOrUndefined(value[\"ReplyTo\"]),\n replyToSessionId: getStringOrUndefined(value[\"ReplyToSessionId\"]),\n sessionId: getStringOrUndefined(value[\"SessionId\"]),\n messageId: getStringOrUndefined(value[\"MessageId\"]),\n contentType: getStringOrUndefined(value[\"ContentType\"]),\n applicationProperties: getKeyValuePairsOrUndefined(\n value[\"Properties\"],\n \"ApplicationProperties\",\n ),\n };\n }\n return result;\n}\n\n/**\n * @internal\n * Helper utility to retrieve rule `action` value from given input.\n */\nfunction getRuleAction(value: any): SqlRuleAction {\n return {\n sqlExpression: value[\"SqlExpression\"],\n sqlParameters: getKeyValuePairsOrUndefined(value[\"Parameters\"], \"SQLParameters\"),\n };\n}\n\n/**\n * Represents the options to create a rule for a subscription.\n * @internal\n */\nexport interface CreateRuleOptions {\n /**\n * Name of the rule\n */\n name: string;\n\n /**\n * Defines the filter expression that the rule evaluates. For `SqlRuleFilter` input,\n * the expression string is interpreted as a SQL92 expression which must\n * evaluate to True or False. Only one between a `CorrelationRuleFilter` or\n * a `SqlRuleFilter` can be defined.\n */\n filter?: SqlRuleFilter | CorrelationRuleFilter;\n\n /**\n * The SQL like expression that can be executed on the message should the\n * associated filter apply.\n */\n action?: SqlRuleAction;\n}\n\n/**\n * Represents all the attributes of a rule.\n */\nexport interface RuleProperties {\n /**\n * Name of the rule\n */\n readonly name: string;\n\n /**\n * Defines the filter expression that the rule evaluates. For `SqlRuleFilter` input,\n * the expression string is interpreted as a SQL92 expression which must\n * evaluate to True or False. Only one between a `CorrelationRuleFilter` or\n * a `SqlRuleFilter` can be defined.\n */\n filter: SqlRuleFilter | CorrelationRuleFilter;\n\n /**\n * The SQL like expression that can be executed on the message should the\n * associated filter apply.\n */\n action: SqlRuleAction;\n}\n\n/**\n * Represents all possible fields on SqlRuleAction\n */\nexport type SqlRuleAction = {\n /**\n * SQL expression to use in the rule action.\n */\n sqlExpression?: string;\n\n /**\n * SQL parameters to the SQL expression in the rule action.\n */\n sqlParameters?: { [key: string]: string | number | boolean };\n};\n\n/**\n * Represents all possible fields on SqlRuleFilter\n */\nexport interface SqlRuleFilter {\n /**\n * SQL expression to use in the rule filter. It is evaluated against the messages'\n * user-defined properties and system properties. All system properties will be prefixed with\n * `sys.` in the condition expression.\n * Defaults to creating a true filter if none specified\n */\n sqlExpression: string;\n\n /**\n * SQL parameters to the SQL expression in the rule filter.\n */\n sqlParameters?: { [key: string]: string | number | boolean };\n}\n\n/**\n * @internal\n *\n */\nexport interface InternalRuleOptions {\n Name: string;\n Filter: any;\n Action: any;\n}\n\n/**\n * @internal\n *\n */\nexport function buildInternalRuleResource(rule: CreateRuleOptions): InternalRuleOptions {\n const resource: InternalRuleOptions = {\n Filter: {},\n Action: {},\n Name: rule.name,\n };\n\n if (!isDefined(rule.filter)) {\n // Defaults to creating a true filter if none specified\n resource.Filter = {\n SqlExpression: \"1=1\",\n };\n resource.Filter[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"SqlFilter\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n } else {\n if (isObjectWithProperties(rule.filter, [\"sqlExpression\"])) {\n const sqlFilter: SqlRuleFilter = rule.filter as SqlRuleFilter;\n resource.Filter = {\n SqlExpression: sqlFilter.sqlExpression,\n Parameters: buildInternalRawKeyValuePairs(sqlFilter.sqlParameters, \"sqlParameters\"),\n };\n resource.Filter[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"SqlFilter\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n } else {\n const correlationFilter: CorrelationRuleFilter = rule.filter as CorrelationRuleFilter;\n\n resource.Filter = {\n CorrelationId: correlationFilter.correlationId,\n Label: correlationFilter.subject,\n To: correlationFilter.to,\n ReplyTo: correlationFilter.replyTo,\n ReplyToSessionId: correlationFilter.replyToSessionId,\n ContentType: correlationFilter.contentType,\n SessionId: correlationFilter.sessionId,\n MessageId: correlationFilter.messageId,\n Properties: buildInternalRawKeyValuePairs(\n correlationFilter.applicationProperties,\n \"applicationProperties\",\n ),\n };\n resource.Filter[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"CorrelationFilter\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n }\n }\n\n if (!isDefined(rule.action) || !isDefined(rule.action.sqlExpression)) {\n // Defaults to creating an empty rule action instance if none specified\n resource.Action = {};\n resource.Action[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"EmptyRuleAction\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n } else {\n resource.Action = {\n SqlExpression: rule.action.sqlExpression,\n Parameters: buildInternalRawKeyValuePairs(rule.action.sqlParameters, \"sqlParameters\"),\n };\n resource.Action[Constants.XML_METADATA_MARKER] = {\n \"p4:type\": \"SqlRuleAction\",\n \"xmlns:p4\": \"http://www.w3.org/2001/XMLSchema-instance\",\n };\n }\n\n return resource;\n}\n\n/**\n * @internal\n * RuleResourceSerializer for serializing / deserializing Rule entities\n */\nexport class RuleResourceSerializer implements AtomXmlSerializer {\n serialize(rule: RuleProperties): Record<string, unknown> {\n return serializeToAtomXmlRequest(\"RuleDescription\", buildInternalRuleResource(rule));\n }\n\n async deserialize(response: FullOperationResponse): Promise<FullOperationResponse> {\n return deserializeAtomXmlResponse([\"TopicName\", \"SubscriptionName\", \"RuleName\"], response);\n }\n}\n\n/**\n * @internal\n */\nexport function isSqlRuleAction(action: unknown): action is SqlRuleAction {\n return isObjectWithProperties(action, [\"sqlExpression\"]);\n}\n\n/**\n * Service expects the XML request with the special type names serialized in the request,\n * the request would fail otherwise.\n *\n * @internal\n */\nenum TypeMapForRequestSerialization {\n double = \"l28:double\",\n string = \"l28:string\",\n long = \"l28:long\",\n date = \"l28:dateTime\",\n boolean = \"l28:boolean\",\n}\n\n/**\n * @internal\n */\nenum TypeMapForResponseDeserialization {\n int = \"int\",\n double = \"double\",\n string = \"string\",\n boolean = \"boolean\",\n date = \"dateTime\",\n}\n\n/**\n * @internal\n * Internal representation of key-value pair\n */\ntype RawKeyValuePair = {\n Key: string;\n Value: any;\n};\n\n/**\n * @internal\n */\ninterface InternalRawKeyValuePairs {\n KeyValueOfstringanyType: RawKeyValuePair[];\n}\n\n/**\n * Key-value pairs are supposed to be wrapped with this tag in the XML request, they are ignored otherwise.\n *\n * @internal\n */\nconst keyValuePairXMLTag = \"KeyValueOfstringanyType\";\n\n/**\n * @internal\n * Helper utility to retrieve the key-value pairs from the RawKeyValue object from given input,\n * or undefined if not passed in.\n */\nfunction getKeyValuePairsOrUndefined(\n value: any,\n attribute: \"ApplicationProperties\" | \"SQLParameters\",\n): { [key: string]: any } | undefined {\n if (!value) {\n return undefined;\n }\n const properties: any = {};\n let rawProperties;\n if (!Array.isArray(value[keyValuePairXMLTag]) && value[keyValuePairXMLTag]?.Key) {\n // When a single property is present,\n // value[\"KeyValueOfstringanyType\"] is { Key: <key>, Value: [Object] }\n // When multiple properties are present,\n // value[\"KeyValueOfstringanyType\"] is [ { Key: <key-1>, Value: [Object] }, { Key: <key-2>, Value: [Object] } ]\n // For consistency, wrapping `value[\"KeyValueOfstringanyType\"]` as an array for the \"single property\" case.\n rawProperties = [value[keyValuePairXMLTag]];\n } else {\n rawProperties = value[keyValuePairXMLTag];\n }\n if (Array.isArray(rawProperties)) {\n for (const rawProperty of rawProperties) {\n const key = rawProperty.Key;\n const _value = rawProperty.Value[\"_\"];\n const encodedValueType = rawProperty.Value[\"$\"][\"i:type\"].toString().substring(5);\n if (\n encodedValueType === TypeMapForResponseDeserialization.int ||\n encodedValueType === TypeMapForResponseDeserialization.double\n ) {\n properties[key] = Number(_value);\n } else if (encodedValueType === TypeMapForResponseDeserialization.string) {\n properties[key] = _value;\n } else if (encodedValueType === TypeMapForResponseDeserialization.boolean) {\n properties[key] = _value === \"true\" ? true : false;\n } else if (encodedValueType === TypeMapForResponseDeserialization.date) {\n properties[key] = new Date(_value);\n } else {\n throw new TypeError(\n `Unable to parse the key-value pairs in the response - ${JSON.stringify(rawProperty)}`,\n );\n }\n }\n } else {\n throw new TypeError(\n `${attribute} in the response is not an array, unable to parse the response - ${JSON.stringify(\n value,\n )}`,\n );\n }\n return properties;\n}\n\n/**\n * @internal\n * Helper utility to extract array of user properties key-value instances from given input,\n * or undefined if not passed in.\n */\nexport function buildInternalRawKeyValuePairs(\n parameters: { [key: string]: any } | undefined,\n attribute: \"applicationProperties\" | \"sqlParameters\",\n): InternalRawKeyValuePairs | undefined {\n if (!isDefined(parameters)) {\n return undefined;\n }\n if (\n Array.isArray(parameters) ||\n typeof parameters === \"string\" ||\n typeof parameters !== \"object\" ||\n Object.entries(parameters).length < 1\n ) {\n throw new TypeError(\n `Unsupported value for the ${attribute} ${JSON.stringify(\n parameters,\n )}, expected a JSON object with key-value pairs.`,\n );\n }\n const rawParameters: RawKeyValuePair[] = [];\n for (const key of Object.keys(parameters)) {\n let type: string | number | boolean;\n let value = parameters[key];\n if (typeof value === \"number\") {\n type = TypeMapForRequestSerialization.double;\n } else if (typeof value === \"string\") {\n type = TypeMapForRequestSerialization.string;\n } else if (typeof value === \"boolean\") {\n type = TypeMapForRequestSerialization.boolean;\n } else if (value instanceof Date && !isNaN(value.valueOf())) {\n type = TypeMapForRequestSerialization.date;\n value = value.toJSON();\n } else {\n throw new TypeError(\n `Unsupported type for the value in the ${attribute} for the key '${key}'`,\n );\n }\n\n const rawParameter: RawKeyValuePair = {\n Key: key,\n Value: {\n [Constants.XML_METADATA_MARKER]: {\n \"p4:type\": type,\n \"xmlns:l28\": \"http://www.w3.org/2001/XMLSchema\",\n },\n [Constants.XML_VALUE_MARKER]: value,\n },\n };\n rawParameters.push(rawParameter);\n }\n return {\n [keyValuePairXMLTag]: rawParameters,\n };\n}\n"]}