@azure/cosmos 4.5.0 → 4.6.0

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 (1401) hide show
  1. package/README.md +32 -0
  2. package/dist/browser/ChangeFeedIterator.js +17 -11
  3. package/dist/browser/ChangeFeedIterator.js.map +1 -1
  4. package/dist/browser/ChangeFeedResponse.js +8 -0
  5. package/dist/browser/ChangeFeedResponse.js.map +1 -1
  6. package/dist/browser/ClientContext.d.ts.map +1 -1
  7. package/dist/browser/ClientContext.js +232 -48
  8. package/dist/browser/ClientContext.js.map +1 -1
  9. package/dist/browser/CosmosClient.d.ts +13 -0
  10. package/dist/browser/CosmosClient.d.ts.map +1 -1
  11. package/dist/browser/CosmosClient.js +53 -6
  12. package/dist/browser/CosmosClient.js.map +1 -1
  13. package/dist/browser/CosmosClientOptions.d.ts.map +1 -1
  14. package/dist/browser/CosmosClientOptions.js.map +1 -1
  15. package/dist/browser/CosmosDiagnostics.d.ts +4 -0
  16. package/dist/browser/CosmosDiagnostics.d.ts.map +1 -1
  17. package/dist/browser/CosmosDiagnostics.js +3 -0
  18. package/dist/browser/CosmosDiagnostics.js.map +1 -1
  19. package/dist/browser/GlobalEndpointManagerOptions.d.ts +2 -0
  20. package/dist/browser/GlobalEndpointManagerOptions.d.ts.map +1 -0
  21. package/dist/browser/GlobalEndpointManagerOptions.js +2 -0
  22. package/dist/browser/GlobalEndpointManagerOptions.js.map +1 -0
  23. package/dist/browser/PartitionKeyRangeFailoverInfo.js +8 -5
  24. package/dist/browser/PartitionKeyRangeFailoverInfo.js.map +1 -1
  25. package/dist/browser/bulk/Batcher.js +13 -3
  26. package/dist/browser/bulk/Batcher.js.map +1 -1
  27. package/dist/browser/bulk/BulkHelper.js +26 -11
  28. package/dist/browser/bulk/BulkHelper.js.map +1 -1
  29. package/dist/browser/bulk/BulkResponse.js +22 -20
  30. package/dist/browser/bulk/BulkResponse.js.map +1 -1
  31. package/dist/browser/bulk/CongestionAlgorithm.js +11 -4
  32. package/dist/browser/bulk/CongestionAlgorithm.js.map +1 -1
  33. package/dist/browser/bulk/HelperPerPartition.js +14 -1
  34. package/dist/browser/bulk/HelperPerPartition.js.map +1 -1
  35. package/dist/browser/bulk/ItemOperationContext.js +4 -0
  36. package/dist/browser/bulk/ItemOperationContext.js.map +1 -1
  37. package/dist/browser/bulk/Limiter.js +27 -18
  38. package/dist/browser/bulk/Limiter.js.map +1 -1
  39. package/dist/browser/bulk/PartitionMetric.js +4 -0
  40. package/dist/browser/bulk/PartitionMetric.js.map +1 -1
  41. package/dist/browser/client/ChangeFeed/ChangeFeedForEpkRange.d.ts.map +1 -1
  42. package/dist/browser/client/ChangeFeed/ChangeFeedForEpkRange.js +29 -15
  43. package/dist/browser/client/ChangeFeed/ChangeFeedForEpkRange.js.map +1 -1
  44. package/dist/browser/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map +1 -1
  45. package/dist/browser/client/ChangeFeed/ChangeFeedForPartitionKey.js +19 -8
  46. package/dist/browser/client/ChangeFeed/ChangeFeedForPartitionKey.js.map +1 -1
  47. package/dist/browser/client/ChangeFeed/ChangeFeedIteratorBuilder.js +12 -9
  48. package/dist/browser/client/ChangeFeed/ChangeFeedIteratorBuilder.js.map +1 -1
  49. package/dist/browser/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts +5 -0
  50. package/dist/browser/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map +1 -1
  51. package/dist/browser/client/ChangeFeed/ChangeFeedIteratorOptions.js.map +1 -1
  52. package/dist/browser/client/ChangeFeed/ChangeFeedIteratorResponse.js +9 -0
  53. package/dist/browser/client/ChangeFeed/ChangeFeedIteratorResponse.js.map +1 -1
  54. package/dist/browser/client/ChangeFeed/ChangeFeedPolicy.js +1 -0
  55. package/dist/browser/client/ChangeFeed/ChangeFeedPolicy.js.map +1 -1
  56. package/dist/browser/client/ChangeFeed/ChangeFeedRange.js +20 -0
  57. package/dist/browser/client/ChangeFeed/ChangeFeedRange.js.map +1 -1
  58. package/dist/browser/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js +1 -0
  59. package/dist/browser/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js.map +1 -1
  60. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromBeginning.js +1 -0
  61. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map +1 -1
  62. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromContinuation.js +1 -0
  63. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map +1 -1
  64. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromNow.js +1 -0
  65. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromNow.js.map +1 -1
  66. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromTime.js +2 -0
  67. package/dist/browser/client/ChangeFeed/ChangeFeedStartFromTime.js.map +1 -1
  68. package/dist/browser/client/ChangeFeed/CompositeContinuationToken.js +8 -0
  69. package/dist/browser/client/ChangeFeed/CompositeContinuationToken.js.map +1 -1
  70. package/dist/browser/client/ChangeFeed/ContinuationTokenForPartitionKey.js +12 -0
  71. package/dist/browser/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map +1 -1
  72. package/dist/browser/client/ChangeFeed/FeedRange.js +8 -0
  73. package/dist/browser/client/ChangeFeed/FeedRange.js.map +1 -1
  74. package/dist/browser/client/ChangeFeed/FeedRangeQueue.js +1 -0
  75. package/dist/browser/client/ChangeFeed/FeedRangeQueue.js.map +1 -1
  76. package/dist/browser/client/ChangeFeed/InternalChangeFeedOptions.d.ts +1 -0
  77. package/dist/browser/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map +1 -1
  78. package/dist/browser/client/ChangeFeed/InternalChangeFeedOptions.js.map +1 -1
  79. package/dist/browser/client/ChangeFeed/changeFeedUtils.d.ts.map +1 -1
  80. package/dist/browser/client/ChangeFeed/changeFeedUtils.js +6 -5
  81. package/dist/browser/client/ChangeFeed/changeFeedUtils.js.map +1 -1
  82. package/dist/browser/client/ClientUtils.js +1 -1
  83. package/dist/browser/client/ClientUtils.js.map +1 -1
  84. package/dist/browser/client/Conflict/Conflict.js +4 -0
  85. package/dist/browser/client/Conflict/Conflict.js.map +1 -1
  86. package/dist/browser/client/Conflict/ConflictResponse.js +2 -0
  87. package/dist/browser/client/Conflict/ConflictResponse.js.map +1 -1
  88. package/dist/browser/client/Conflict/Conflicts.js +2 -0
  89. package/dist/browser/client/Conflict/Conflicts.js.map +1 -1
  90. package/dist/browser/client/Container/Container.js +18 -3
  91. package/dist/browser/client/Container/Container.js.map +1 -1
  92. package/dist/browser/client/Container/ContainerResponse.js +2 -0
  93. package/dist/browser/client/Container/ContainerResponse.js.map +1 -1
  94. package/dist/browser/client/Container/Containers.js +4 -2
  95. package/dist/browser/client/Container/Containers.js.map +1 -1
  96. package/dist/browser/client/Database/Database.js +33 -0
  97. package/dist/browser/client/Database/Database.js.map +1 -1
  98. package/dist/browser/client/Database/DatabaseResponse.js +2 -0
  99. package/dist/browser/client/Database/DatabaseResponse.js.map +1 -1
  100. package/dist/browser/client/Database/Databases.js +3 -0
  101. package/dist/browser/client/Database/Databases.js.map +1 -1
  102. package/dist/browser/client/Item/Item.js +4 -0
  103. package/dist/browser/client/Item/Item.js.map +1 -1
  104. package/dist/browser/client/Item/ItemResponse.js +2 -0
  105. package/dist/browser/client/Item/ItemResponse.js.map +1 -1
  106. package/dist/browser/client/Item/Items.d.ts.map +1 -1
  107. package/dist/browser/client/Item/Items.js +8 -0
  108. package/dist/browser/client/Item/Items.js.map +1 -1
  109. package/dist/browser/client/Offer/Offer.js +3 -0
  110. package/dist/browser/client/Offer/Offer.js.map +1 -1
  111. package/dist/browser/client/Offer/OfferResponse.js +2 -0
  112. package/dist/browser/client/Offer/OfferResponse.js.map +1 -1
  113. package/dist/browser/client/Offer/Offers.js +2 -0
  114. package/dist/browser/client/Offer/Offers.js.map +1 -1
  115. package/dist/browser/client/Permission/Permission.js +3 -0
  116. package/dist/browser/client/Permission/Permission.js.map +1 -1
  117. package/dist/browser/client/Permission/PermissionResponse.js +2 -0
  118. package/dist/browser/client/Permission/PermissionResponse.js.map +1 -1
  119. package/dist/browser/client/Permission/Permissions.js +2 -0
  120. package/dist/browser/client/Permission/Permissions.js.map +1 -1
  121. package/dist/browser/client/SasToken/SasTokenProperties.js +17 -0
  122. package/dist/browser/client/SasToken/SasTokenProperties.js.map +1 -1
  123. package/dist/browser/client/Script/Scripts.js +5 -0
  124. package/dist/browser/client/Script/Scripts.js.map +1 -1
  125. package/dist/browser/client/StoredProcedure/StoredProcedure.js +3 -0
  126. package/dist/browser/client/StoredProcedure/StoredProcedure.js.map +1 -1
  127. package/dist/browser/client/StoredProcedure/StoredProcedureResponse.js +4 -0
  128. package/dist/browser/client/StoredProcedure/StoredProcedureResponse.js.map +1 -1
  129. package/dist/browser/client/StoredProcedure/StoredProcedures.js +2 -0
  130. package/dist/browser/client/StoredProcedure/StoredProcedures.js.map +1 -1
  131. package/dist/browser/client/Trigger/Trigger.js +3 -0
  132. package/dist/browser/client/Trigger/Trigger.js.map +1 -1
  133. package/dist/browser/client/Trigger/TriggerResponse.js +2 -0
  134. package/dist/browser/client/Trigger/TriggerResponse.js.map +1 -1
  135. package/dist/browser/client/Trigger/Triggers.js +2 -0
  136. package/dist/browser/client/Trigger/Triggers.js.map +1 -1
  137. package/dist/browser/client/User/User.js +9 -0
  138. package/dist/browser/client/User/User.js.map +1 -1
  139. package/dist/browser/client/User/UserResponse.js +2 -0
  140. package/dist/browser/client/User/UserResponse.js.map +1 -1
  141. package/dist/browser/client/User/Users.js +2 -0
  142. package/dist/browser/client/User/Users.js.map +1 -1
  143. package/dist/browser/client/UserDefinedFunction/UserDefinedFunction.js +3 -0
  144. package/dist/browser/client/UserDefinedFunction/UserDefinedFunction.js.map +1 -1
  145. package/dist/browser/client/UserDefinedFunction/UserDefinedFunctionResponse.js +2 -0
  146. package/dist/browser/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map +1 -1
  147. package/dist/browser/client/UserDefinedFunction/UserDefinedFunctions.js +2 -0
  148. package/dist/browser/client/UserDefinedFunction/UserDefinedFunctions.js.map +1 -1
  149. package/dist/browser/common/constants.d.ts +4 -0
  150. package/dist/browser/common/constants.d.ts.map +1 -1
  151. package/dist/browser/common/constants.js +5 -1
  152. package/dist/browser/common/constants.js.map +1 -1
  153. package/dist/browser/common/helper.d.ts +6 -0
  154. package/dist/browser/common/helper.d.ts.map +1 -1
  155. package/dist/browser/common/helper.js +9 -1
  156. package/dist/browser/common/helper.js.map +1 -1
  157. package/dist/browser/common/platform.d.ts +1 -0
  158. package/dist/browser/common/platform.d.ts.map +1 -1
  159. package/dist/browser/common/platform.js +1 -3
  160. package/dist/browser/common/platform.js.map +1 -1
  161. package/dist/browser/diagnostics/CosmosDiagnosticsContext.js +8 -7
  162. package/dist/browser/diagnostics/CosmosDiagnosticsContext.js.map +1 -1
  163. package/dist/browser/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
  164. package/dist/browser/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
  165. package/dist/browser/diagnostics/DiagnosticNodeInternal.js +26 -7
  166. package/dist/browser/diagnostics/DiagnosticNodeInternal.js.map +1 -1
  167. package/dist/browser/diagnostics/DiagnosticWriter.js +1 -3
  168. package/dist/browser/diagnostics/DiagnosticWriter.js.map +1 -1
  169. package/dist/browser/diagnostics/index.js +2 -2
  170. package/dist/browser/diagnostics/index.js.map +1 -1
  171. package/dist/browser/documents/ConnectionPolicy.d.ts +10 -4
  172. package/dist/browser/documents/ConnectionPolicy.d.ts.map +1 -1
  173. package/dist/browser/documents/ConnectionPolicy.js +2 -2
  174. package/dist/browser/documents/ConnectionPolicy.js.map +1 -1
  175. package/dist/browser/documents/DatabaseAccount.d.ts +4 -0
  176. package/dist/browser/documents/DatabaseAccount.d.ts.map +1 -1
  177. package/dist/browser/documents/DatabaseAccount.js +29 -4
  178. package/dist/browser/documents/DatabaseAccount.js.map +1 -1
  179. package/dist/browser/documents/PartitionKey.js +1 -3
  180. package/dist/browser/documents/PartitionKey.js.map +1 -1
  181. package/dist/browser/encryption/Cache/ClientEncryptionKeyPropertiesCache.js +2 -0
  182. package/dist/browser/encryption/Cache/ClientEncryptionKeyPropertiesCache.js.map +1 -1
  183. package/dist/browser/encryption/Cache/EncryptionSettingsCache.js +2 -0
  184. package/dist/browser/encryption/Cache/EncryptionSettingsCache.js.map +1 -1
  185. package/dist/browser/encryption/Cache/KeyEncryptionKeyCache.js +2 -0
  186. package/dist/browser/encryption/Cache/KeyEncryptionKeyCache.js.map +1 -1
  187. package/dist/browser/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js +2 -0
  188. package/dist/browser/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js.map +1 -1
  189. package/dist/browser/encryption/EncryptionItemQueryIterator.js +24 -27
  190. package/dist/browser/encryption/EncryptionItemQueryIterator.js.map +1 -1
  191. package/dist/browser/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts +0 -1
  192. package/dist/browser/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts.map +1 -1
  193. package/dist/browser/encryption/EncryptionKey/ProtectedDataEncryptionKey.js +2 -0
  194. package/dist/browser/encryption/EncryptionKey/ProtectedDataEncryptionKey.js.map +1 -1
  195. package/dist/browser/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js +6 -5
  196. package/dist/browser/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js.map +1 -1
  197. package/dist/browser/encryption/EncryptionKeyStoreProvider.js +8 -1
  198. package/dist/browser/encryption/EncryptionKeyStoreProvider.js.map +1 -1
  199. package/dist/browser/encryption/EncryptionManager.js +6 -0
  200. package/dist/browser/encryption/EncryptionManager.js.map +1 -1
  201. package/dist/browser/encryption/EncryptionProcessor.js +5 -0
  202. package/dist/browser/encryption/EncryptionProcessor.js.map +1 -1
  203. package/dist/browser/encryption/EncryptionQueryBuilder.js +2 -0
  204. package/dist/browser/encryption/EncryptionQueryBuilder.js.map +1 -1
  205. package/dist/browser/encryption/EncryptionSettingForProperty.js +6 -0
  206. package/dist/browser/encryption/EncryptionSettingForProperty.js.map +1 -1
  207. package/dist/browser/encryption/EncryptionSettings.js +6 -3
  208. package/dist/browser/encryption/EncryptionSettings.js.map +1 -1
  209. package/dist/browser/encryption/KeyEncryptionKey.js +4 -0
  210. package/dist/browser/encryption/KeyEncryptionKey.js.map +1 -1
  211. package/dist/browser/encryption/Serializers/StringSerializer.js +1 -1
  212. package/dist/browser/encryption/Serializers/StringSerializer.js.map +1 -1
  213. package/dist/browser/extractPartitionKey.js +2 -2
  214. package/dist/browser/extractPartitionKey.js.map +1 -1
  215. package/dist/browser/globalEndpointManager.d.ts +8 -0
  216. package/dist/browser/globalEndpointManager.d.ts.map +1 -1
  217. package/dist/browser/globalEndpointManager.js +104 -29
  218. package/dist/browser/globalEndpointManager.js.map +1 -1
  219. package/dist/browser/globalPartitionEndpointManager.d.ts +0 -2
  220. package/dist/browser/globalPartitionEndpointManager.d.ts.map +1 -1
  221. package/dist/browser/globalPartitionEndpointManager.js +19 -7
  222. package/dist/browser/globalPartitionEndpointManager.js.map +1 -1
  223. package/dist/browser/queryExecutionContext/Aggregators/AverageAggregator.js +2 -0
  224. package/dist/browser/queryExecutionContext/Aggregators/AverageAggregator.js.map +1 -1
  225. package/dist/browser/queryExecutionContext/Aggregators/CountAggregator.js +1 -0
  226. package/dist/browser/queryExecutionContext/Aggregators/CountAggregator.js.map +1 -1
  227. package/dist/browser/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js +1 -0
  228. package/dist/browser/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js.map +1 -1
  229. package/dist/browser/queryExecutionContext/Aggregators/MakeListAggregator.js +1 -0
  230. package/dist/browser/queryExecutionContext/Aggregators/MakeListAggregator.js.map +1 -1
  231. package/dist/browser/queryExecutionContext/Aggregators/MakeSetAggregator.js +1 -0
  232. package/dist/browser/queryExecutionContext/Aggregators/MakeSetAggregator.js.map +1 -1
  233. package/dist/browser/queryExecutionContext/Aggregators/MaxAggregator.js +2 -0
  234. package/dist/browser/queryExecutionContext/Aggregators/MaxAggregator.js.map +1 -1
  235. package/dist/browser/queryExecutionContext/Aggregators/MinAggregator.js +2 -0
  236. package/dist/browser/queryExecutionContext/Aggregators/MinAggregator.js.map +1 -1
  237. package/dist/browser/queryExecutionContext/Aggregators/StaticValueAggregator.js +1 -0
  238. package/dist/browser/queryExecutionContext/Aggregators/StaticValueAggregator.js.map +1 -1
  239. package/dist/browser/queryExecutionContext/Aggregators/SumAggregator.js +1 -0
  240. package/dist/browser/queryExecutionContext/Aggregators/SumAggregator.js.map +1 -1
  241. package/dist/browser/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js +5 -3
  242. package/dist/browser/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map +1 -1
  243. package/dist/browser/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js +6 -3
  244. package/dist/browser/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map +1 -1
  245. package/dist/browser/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js +23 -7
  246. package/dist/browser/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map +1 -1
  247. package/dist/browser/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js +14 -6
  248. package/dist/browser/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map +1 -1
  249. package/dist/browser/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js +3 -0
  250. package/dist/browser/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map +1 -1
  251. package/dist/browser/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js +2 -0
  252. package/dist/browser/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map +1 -1
  253. package/dist/browser/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js +2 -0
  254. package/dist/browser/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map +1 -1
  255. package/dist/browser/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js +2 -0
  256. package/dist/browser/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map +1 -1
  257. package/dist/browser/queryExecutionContext/FetchResult.js +4 -0
  258. package/dist/browser/queryExecutionContext/FetchResult.js.map +1 -1
  259. package/dist/browser/queryExecutionContext/defaultQueryExecutionContext.js +14 -2
  260. package/dist/browser/queryExecutionContext/defaultQueryExecutionContext.js.map +1 -1
  261. package/dist/browser/queryExecutionContext/documentProducer.js +34 -21
  262. package/dist/browser/queryExecutionContext/documentProducer.js.map +1 -1
  263. package/dist/browser/queryExecutionContext/hybridQueryExecutionContext.js +41 -27
  264. package/dist/browser/queryExecutionContext/hybridQueryExecutionContext.js.map +1 -1
  265. package/dist/browser/queryExecutionContext/orderByComparator.js +1 -0
  266. package/dist/browser/queryExecutionContext/orderByComparator.js.map +1 -1
  267. package/dist/browser/queryExecutionContext/orderByDocumentProducerComparator.js +1 -0
  268. package/dist/browser/queryExecutionContext/orderByDocumentProducerComparator.js.map +1 -1
  269. package/dist/browser/queryExecutionContext/orderByQueryExecutionContext.js +1 -0
  270. package/dist/browser/queryExecutionContext/orderByQueryExecutionContext.js.map +1 -1
  271. package/dist/browser/queryExecutionContext/parallelQueryExecutionContextBase.js +20 -2
  272. package/dist/browser/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
  273. package/dist/browser/queryExecutionContext/pipelinedQueryExecutionContext.js +14 -4
  274. package/dist/browser/queryExecutionContext/pipelinedQueryExecutionContext.js.map +1 -1
  275. package/dist/browser/queryIterator.js +41 -33
  276. package/dist/browser/queryIterator.js.map +1 -1
  277. package/dist/browser/queryMetrics/clientSideMetrics.js +2 -1
  278. package/dist/browser/queryMetrics/clientSideMetrics.js.map +1 -1
  279. package/dist/browser/queryMetrics/queryMetrics.js +14 -1
  280. package/dist/browser/queryMetrics/queryMetrics.js.map +1 -1
  281. package/dist/browser/queryMetrics/queryPreparationTime.js +5 -1
  282. package/dist/browser/queryMetrics/queryPreparationTime.js.map +1 -1
  283. package/dist/browser/queryMetrics/runtimeExecutionTimes.js +4 -1
  284. package/dist/browser/queryMetrics/runtimeExecutionTimes.js.map +1 -1
  285. package/dist/browser/queryMetrics/timeSpan.js +4 -3
  286. package/dist/browser/queryMetrics/timeSpan.js.map +1 -1
  287. package/dist/browser/request/ErrorResponse.js +19 -0
  288. package/dist/browser/request/ErrorResponse.js.map +1 -1
  289. package/dist/browser/request/FeedResponse.js +4 -0
  290. package/dist/browser/request/FeedResponse.js.map +1 -1
  291. package/dist/browser/request/RequestHandler.js +3 -4
  292. package/dist/browser/request/RequestHandler.js.map +1 -1
  293. package/dist/browser/request/ResourceResponse.js +5 -0
  294. package/dist/browser/request/ResourceResponse.js.map +1 -1
  295. package/dist/browser/request/SharedOptions.d.ts +5 -0
  296. package/dist/browser/request/SharedOptions.d.ts.map +1 -1
  297. package/dist/browser/request/SharedOptions.js.map +1 -1
  298. package/dist/browser/request/TimeoutError.js +1 -1
  299. package/dist/browser/request/TimeoutError.js.map +1 -1
  300. package/dist/browser/request/hybridSearchQueryResult.js +5 -0
  301. package/dist/browser/request/hybridSearchQueryResult.js.map +1 -1
  302. package/dist/browser/request/request.js +5 -1
  303. package/dist/browser/request/request.js.map +1 -1
  304. package/dist/browser/retry/bulkExecutionRetryPolicy.js +5 -2
  305. package/dist/browser/retry/bulkExecutionRetryPolicy.js.map +1 -1
  306. package/dist/browser/retry/defaultRetryPolicy.d.ts.map +1 -1
  307. package/dist/browser/retry/defaultRetryPolicy.js +7 -7
  308. package/dist/browser/retry/defaultRetryPolicy.js.map +1 -1
  309. package/dist/browser/retry/endpointDiscoveryRetryPolicy.d.ts +3 -2
  310. package/dist/browser/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
  311. package/dist/browser/retry/endpointDiscoveryRetryPolicy.js +24 -7
  312. package/dist/browser/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
  313. package/dist/browser/retry/resourceThrottleRetryPolicy.js +20 -10
  314. package/dist/browser/retry/resourceThrottleRetryPolicy.js.map +1 -1
  315. package/dist/browser/retry/retryUtility.d.ts.map +1 -1
  316. package/dist/browser/retry/retryUtility.js +22 -8
  317. package/dist/browser/retry/retryUtility.js.map +1 -1
  318. package/dist/browser/retry/sessionRetryPolicy.js +8 -4
  319. package/dist/browser/retry/sessionRetryPolicy.js.map +1 -1
  320. package/dist/browser/retry/timeoutFailoverRetryPolicy.d.ts +1 -2
  321. package/dist/browser/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
  322. package/dist/browser/retry/timeoutFailoverRetryPolicy.js +17 -7
  323. package/dist/browser/retry/timeoutFailoverRetryPolicy.js.map +1 -1
  324. package/dist/browser/routing/QueryRange.js +4 -0
  325. package/dist/browser/routing/QueryRange.js.map +1 -1
  326. package/dist/browser/routing/inMemoryCollectionRoutingMap.js +4 -0
  327. package/dist/browser/routing/inMemoryCollectionRoutingMap.js.map +1 -1
  328. package/dist/browser/routing/partitionKeyRangeCache.js +2 -0
  329. package/dist/browser/routing/partitionKeyRangeCache.js.map +1 -1
  330. package/dist/browser/routing/smartRoutingMapProvider.js +1 -0
  331. package/dist/browser/routing/smartRoutingMapProvider.js.map +1 -1
  332. package/dist/browser/session/VectorSessionToken.js +6 -2
  333. package/dist/browser/session/VectorSessionToken.js.map +1 -1
  334. package/dist/browser/session/sessionContainer.js +5 -3
  335. package/dist/browser/session/sessionContainer.js.map +1 -1
  336. package/dist/browser/utils/batch.js +15 -4
  337. package/dist/browser/utils/batch.js.map +1 -1
  338. package/dist/browser/utils/encode.d.ts +1 -1
  339. package/dist/browser/utils/encode.d.ts.map +1 -1
  340. package/dist/browser/utils/encode.js.map +1 -1
  341. package/dist/browser/utils/fixedSizePriorityQueue.js +4 -0
  342. package/dist/browser/utils/fixedSizePriorityQueue.js.map +1 -1
  343. package/dist/browser/utils/hashing/hash.js +1 -1
  344. package/dist/browser/utils/hashing/hash.js.map +1 -1
  345. package/dist/browser/utils/nonStreamingOrderByMap.js +2 -0
  346. package/dist/browser/utils/nonStreamingOrderByMap.js.map +1 -1
  347. package/dist/commonjs/ChangeFeedIterator.js +17 -11
  348. package/dist/commonjs/ChangeFeedIterator.js.map +1 -1
  349. package/dist/commonjs/ChangeFeedResponse.js +8 -0
  350. package/dist/commonjs/ChangeFeedResponse.js.map +1 -1
  351. package/dist/commonjs/ClientContext.d.ts.map +1 -1
  352. package/dist/commonjs/ClientContext.js +232 -48
  353. package/dist/commonjs/ClientContext.js.map +1 -1
  354. package/dist/commonjs/CosmosClient.d.ts +13 -0
  355. package/dist/commonjs/CosmosClient.d.ts.map +1 -1
  356. package/dist/commonjs/CosmosClient.js +53 -6
  357. package/dist/commonjs/CosmosClient.js.map +1 -1
  358. package/dist/commonjs/CosmosClientOptions.d.ts.map +1 -1
  359. package/dist/commonjs/CosmosClientOptions.js.map +1 -1
  360. package/dist/commonjs/CosmosDiagnostics.d.ts +4 -0
  361. package/dist/commonjs/CosmosDiagnostics.d.ts.map +1 -1
  362. package/dist/commonjs/CosmosDiagnostics.js +3 -0
  363. package/dist/commonjs/CosmosDiagnostics.js.map +1 -1
  364. package/dist/commonjs/GlobalEndpointManagerOptions.d.ts +2 -0
  365. package/dist/commonjs/GlobalEndpointManagerOptions.d.ts.map +1 -0
  366. package/dist/commonjs/GlobalEndpointManagerOptions.js +3 -0
  367. package/dist/commonjs/GlobalEndpointManagerOptions.js.map +1 -0
  368. package/dist/commonjs/PartitionKeyRangeFailoverInfo.js +8 -5
  369. package/dist/commonjs/PartitionKeyRangeFailoverInfo.js.map +1 -1
  370. package/dist/commonjs/bulk/Batcher.js +13 -3
  371. package/dist/commonjs/bulk/Batcher.js.map +1 -1
  372. package/dist/commonjs/bulk/BulkHelper.js +26 -11
  373. package/dist/commonjs/bulk/BulkHelper.js.map +1 -1
  374. package/dist/commonjs/bulk/BulkResponse.js +22 -20
  375. package/dist/commonjs/bulk/BulkResponse.js.map +1 -1
  376. package/dist/commonjs/bulk/CongestionAlgorithm.js +11 -4
  377. package/dist/commonjs/bulk/CongestionAlgorithm.js.map +1 -1
  378. package/dist/commonjs/bulk/HelperPerPartition.js +14 -1
  379. package/dist/commonjs/bulk/HelperPerPartition.js.map +1 -1
  380. package/dist/commonjs/bulk/ItemOperationContext.js +4 -0
  381. package/dist/commonjs/bulk/ItemOperationContext.js.map +1 -1
  382. package/dist/commonjs/bulk/Limiter.js +27 -18
  383. package/dist/commonjs/bulk/Limiter.js.map +1 -1
  384. package/dist/commonjs/bulk/PartitionMetric.js +4 -0
  385. package/dist/commonjs/bulk/PartitionMetric.js.map +1 -1
  386. package/dist/commonjs/client/ChangeFeed/ChangeFeedForEpkRange.d.ts.map +1 -1
  387. package/dist/commonjs/client/ChangeFeed/ChangeFeedForEpkRange.js +29 -15
  388. package/dist/commonjs/client/ChangeFeed/ChangeFeedForEpkRange.js.map +1 -1
  389. package/dist/commonjs/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map +1 -1
  390. package/dist/commonjs/client/ChangeFeed/ChangeFeedForPartitionKey.js +19 -8
  391. package/dist/commonjs/client/ChangeFeed/ChangeFeedForPartitionKey.js.map +1 -1
  392. package/dist/commonjs/client/ChangeFeed/ChangeFeedIteratorBuilder.js +12 -9
  393. package/dist/commonjs/client/ChangeFeed/ChangeFeedIteratorBuilder.js.map +1 -1
  394. package/dist/commonjs/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts +5 -0
  395. package/dist/commonjs/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map +1 -1
  396. package/dist/commonjs/client/ChangeFeed/ChangeFeedIteratorOptions.js.map +1 -1
  397. package/dist/commonjs/client/ChangeFeed/ChangeFeedIteratorResponse.js +9 -0
  398. package/dist/commonjs/client/ChangeFeed/ChangeFeedIteratorResponse.js.map +1 -1
  399. package/dist/commonjs/client/ChangeFeed/ChangeFeedPolicy.js +1 -0
  400. package/dist/commonjs/client/ChangeFeed/ChangeFeedPolicy.js.map +1 -1
  401. package/dist/commonjs/client/ChangeFeed/ChangeFeedRange.js +20 -0
  402. package/dist/commonjs/client/ChangeFeed/ChangeFeedRange.js.map +1 -1
  403. package/dist/commonjs/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js +1 -0
  404. package/dist/commonjs/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js.map +1 -1
  405. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromBeginning.js +1 -0
  406. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map +1 -1
  407. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromContinuation.js +1 -0
  408. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map +1 -1
  409. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromNow.js +1 -0
  410. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromNow.js.map +1 -1
  411. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromTime.js +2 -0
  412. package/dist/commonjs/client/ChangeFeed/ChangeFeedStartFromTime.js.map +1 -1
  413. package/dist/commonjs/client/ChangeFeed/CompositeContinuationToken.js +8 -0
  414. package/dist/commonjs/client/ChangeFeed/CompositeContinuationToken.js.map +1 -1
  415. package/dist/commonjs/client/ChangeFeed/ContinuationTokenForPartitionKey.js +12 -0
  416. package/dist/commonjs/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map +1 -1
  417. package/dist/commonjs/client/ChangeFeed/FeedRange.js +8 -0
  418. package/dist/commonjs/client/ChangeFeed/FeedRange.js.map +1 -1
  419. package/dist/commonjs/client/ChangeFeed/FeedRangeQueue.js +1 -0
  420. package/dist/commonjs/client/ChangeFeed/FeedRangeQueue.js.map +1 -1
  421. package/dist/commonjs/client/ChangeFeed/InternalChangeFeedOptions.d.ts +1 -0
  422. package/dist/commonjs/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map +1 -1
  423. package/dist/commonjs/client/ChangeFeed/InternalChangeFeedOptions.js.map +1 -1
  424. package/dist/commonjs/client/ChangeFeed/changeFeedUtils.d.ts.map +1 -1
  425. package/dist/commonjs/client/ChangeFeed/changeFeedUtils.js +6 -5
  426. package/dist/commonjs/client/ChangeFeed/changeFeedUtils.js.map +1 -1
  427. package/dist/commonjs/client/ClientUtils.js +1 -1
  428. package/dist/commonjs/client/ClientUtils.js.map +1 -1
  429. package/dist/commonjs/client/Conflict/Conflict.js +4 -0
  430. package/dist/commonjs/client/Conflict/Conflict.js.map +1 -1
  431. package/dist/commonjs/client/Conflict/ConflictResponse.js +2 -0
  432. package/dist/commonjs/client/Conflict/ConflictResponse.js.map +1 -1
  433. package/dist/commonjs/client/Conflict/Conflicts.js +2 -0
  434. package/dist/commonjs/client/Conflict/Conflicts.js.map +1 -1
  435. package/dist/commonjs/client/Container/Container.js +18 -3
  436. package/dist/commonjs/client/Container/Container.js.map +1 -1
  437. package/dist/commonjs/client/Container/ContainerResponse.js +2 -0
  438. package/dist/commonjs/client/Container/ContainerResponse.js.map +1 -1
  439. package/dist/commonjs/client/Container/Containers.js +4 -2
  440. package/dist/commonjs/client/Container/Containers.js.map +1 -1
  441. package/dist/commonjs/client/Database/Database.js +33 -0
  442. package/dist/commonjs/client/Database/Database.js.map +1 -1
  443. package/dist/commonjs/client/Database/DatabaseResponse.js +2 -0
  444. package/dist/commonjs/client/Database/DatabaseResponse.js.map +1 -1
  445. package/dist/commonjs/client/Database/Databases.js +3 -0
  446. package/dist/commonjs/client/Database/Databases.js.map +1 -1
  447. package/dist/commonjs/client/Item/Item.js +4 -0
  448. package/dist/commonjs/client/Item/Item.js.map +1 -1
  449. package/dist/commonjs/client/Item/ItemResponse.js +2 -0
  450. package/dist/commonjs/client/Item/ItemResponse.js.map +1 -1
  451. package/dist/commonjs/client/Item/Items.d.ts.map +1 -1
  452. package/dist/commonjs/client/Item/Items.js +8 -0
  453. package/dist/commonjs/client/Item/Items.js.map +1 -1
  454. package/dist/commonjs/client/Offer/Offer.js +3 -0
  455. package/dist/commonjs/client/Offer/Offer.js.map +1 -1
  456. package/dist/commonjs/client/Offer/OfferResponse.js +2 -0
  457. package/dist/commonjs/client/Offer/OfferResponse.js.map +1 -1
  458. package/dist/commonjs/client/Offer/Offers.js +2 -0
  459. package/dist/commonjs/client/Offer/Offers.js.map +1 -1
  460. package/dist/commonjs/client/Permission/Permission.js +3 -0
  461. package/dist/commonjs/client/Permission/Permission.js.map +1 -1
  462. package/dist/commonjs/client/Permission/PermissionResponse.js +2 -0
  463. package/dist/commonjs/client/Permission/PermissionResponse.js.map +1 -1
  464. package/dist/commonjs/client/Permission/Permissions.js +2 -0
  465. package/dist/commonjs/client/Permission/Permissions.js.map +1 -1
  466. package/dist/commonjs/client/SasToken/SasTokenProperties.js +17 -0
  467. package/dist/commonjs/client/SasToken/SasTokenProperties.js.map +1 -1
  468. package/dist/commonjs/client/Script/Scripts.js +5 -0
  469. package/dist/commonjs/client/Script/Scripts.js.map +1 -1
  470. package/dist/commonjs/client/StoredProcedure/StoredProcedure.js +3 -0
  471. package/dist/commonjs/client/StoredProcedure/StoredProcedure.js.map +1 -1
  472. package/dist/commonjs/client/StoredProcedure/StoredProcedureResponse.js +4 -0
  473. package/dist/commonjs/client/StoredProcedure/StoredProcedureResponse.js.map +1 -1
  474. package/dist/commonjs/client/StoredProcedure/StoredProcedures.js +2 -0
  475. package/dist/commonjs/client/StoredProcedure/StoredProcedures.js.map +1 -1
  476. package/dist/commonjs/client/Trigger/Trigger.js +3 -0
  477. package/dist/commonjs/client/Trigger/Trigger.js.map +1 -1
  478. package/dist/commonjs/client/Trigger/TriggerResponse.js +2 -0
  479. package/dist/commonjs/client/Trigger/TriggerResponse.js.map +1 -1
  480. package/dist/commonjs/client/Trigger/Triggers.js +2 -0
  481. package/dist/commonjs/client/Trigger/Triggers.js.map +1 -1
  482. package/dist/commonjs/client/User/User.js +9 -0
  483. package/dist/commonjs/client/User/User.js.map +1 -1
  484. package/dist/commonjs/client/User/UserResponse.js +2 -0
  485. package/dist/commonjs/client/User/UserResponse.js.map +1 -1
  486. package/dist/commonjs/client/User/Users.js +2 -0
  487. package/dist/commonjs/client/User/Users.js.map +1 -1
  488. package/dist/commonjs/client/UserDefinedFunction/UserDefinedFunction.js +3 -0
  489. package/dist/commonjs/client/UserDefinedFunction/UserDefinedFunction.js.map +1 -1
  490. package/dist/commonjs/client/UserDefinedFunction/UserDefinedFunctionResponse.js +2 -0
  491. package/dist/commonjs/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map +1 -1
  492. package/dist/commonjs/client/UserDefinedFunction/UserDefinedFunctions.js +2 -0
  493. package/dist/commonjs/client/UserDefinedFunction/UserDefinedFunctions.js.map +1 -1
  494. package/dist/commonjs/common/constants.d.ts +4 -0
  495. package/dist/commonjs/common/constants.d.ts.map +1 -1
  496. package/dist/commonjs/common/constants.js +6 -2
  497. package/dist/commonjs/common/constants.js.map +1 -1
  498. package/dist/commonjs/common/helper.d.ts +6 -0
  499. package/dist/commonjs/common/helper.d.ts.map +1 -1
  500. package/dist/commonjs/common/helper.js +9 -0
  501. package/dist/commonjs/common/helper.js.map +1 -1
  502. package/dist/commonjs/common/platform.d.ts +1 -0
  503. package/dist/commonjs/common/platform.d.ts.map +1 -1
  504. package/dist/commonjs/common/platform.js +1 -3
  505. package/dist/commonjs/common/platform.js.map +1 -1
  506. package/dist/commonjs/diagnostics/CosmosDiagnosticsContext.js +8 -7
  507. package/dist/commonjs/diagnostics/CosmosDiagnosticsContext.js.map +1 -1
  508. package/dist/commonjs/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
  509. package/dist/commonjs/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
  510. package/dist/commonjs/diagnostics/DiagnosticNodeInternal.js +26 -7
  511. package/dist/commonjs/diagnostics/DiagnosticNodeInternal.js.map +1 -1
  512. package/dist/commonjs/diagnostics/DiagnosticWriter.js +1 -3
  513. package/dist/commonjs/diagnostics/DiagnosticWriter.js.map +1 -1
  514. package/dist/commonjs/diagnostics/index.js +2 -2
  515. package/dist/commonjs/diagnostics/index.js.map +1 -1
  516. package/dist/commonjs/documents/ConnectionPolicy.d.ts +10 -4
  517. package/dist/commonjs/documents/ConnectionPolicy.d.ts.map +1 -1
  518. package/dist/commonjs/documents/ConnectionPolicy.js +2 -2
  519. package/dist/commonjs/documents/ConnectionPolicy.js.map +1 -1
  520. package/dist/commonjs/documents/DatabaseAccount.d.ts +4 -0
  521. package/dist/commonjs/documents/DatabaseAccount.d.ts.map +1 -1
  522. package/dist/commonjs/documents/DatabaseAccount.js +29 -4
  523. package/dist/commonjs/documents/DatabaseAccount.js.map +1 -1
  524. package/dist/commonjs/documents/PartitionKey.js +1 -3
  525. package/dist/commonjs/documents/PartitionKey.js.map +1 -1
  526. package/dist/commonjs/encryption/AeadAes256CbcHmacSha256Algorithm/AeadAes256CbcHmacSha256Algorithm.js +8 -2
  527. package/dist/commonjs/encryption/AeadAes256CbcHmacSha256Algorithm/AeadAes256CbcHmacSha256Algorithm.js.map +1 -1
  528. package/dist/commonjs/encryption/Cache/ClientEncryptionKeyPropertiesCache.js +2 -0
  529. package/dist/commonjs/encryption/Cache/ClientEncryptionKeyPropertiesCache.js.map +1 -1
  530. package/dist/commonjs/encryption/Cache/EncryptionSettingsCache.js +2 -0
  531. package/dist/commonjs/encryption/Cache/EncryptionSettingsCache.js.map +1 -1
  532. package/dist/commonjs/encryption/Cache/KeyEncryptionKeyCache.js +2 -0
  533. package/dist/commonjs/encryption/Cache/KeyEncryptionKeyCache.js.map +1 -1
  534. package/dist/commonjs/encryption/Cache/ProtectedDataEncryptionKeyCache.js +5 -0
  535. package/dist/commonjs/encryption/Cache/ProtectedDataEncryptionKeyCache.js.map +1 -1
  536. package/dist/commonjs/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js +2 -0
  537. package/dist/commonjs/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js.map +1 -1
  538. package/dist/commonjs/encryption/EncryptionItemQueryIterator.js +24 -27
  539. package/dist/commonjs/encryption/EncryptionItemQueryIterator.js.map +1 -1
  540. package/dist/commonjs/encryption/EncryptionKey/DataEncryptionKey.js +7 -2
  541. package/dist/commonjs/encryption/EncryptionKey/DataEncryptionKey.js.map +1 -1
  542. package/dist/commonjs/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts +0 -1
  543. package/dist/commonjs/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts.map +1 -1
  544. package/dist/commonjs/encryption/EncryptionKey/ProtectedDataEncryptionKey.js +2 -0
  545. package/dist/commonjs/encryption/EncryptionKey/ProtectedDataEncryptionKey.js.map +1 -1
  546. package/dist/commonjs/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js +6 -5
  547. package/dist/commonjs/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js.map +1 -1
  548. package/dist/commonjs/encryption/EncryptionKeyStoreProvider.js +8 -1
  549. package/dist/commonjs/encryption/EncryptionKeyStoreProvider.js.map +1 -1
  550. package/dist/commonjs/encryption/EncryptionManager.js +6 -0
  551. package/dist/commonjs/encryption/EncryptionManager.js.map +1 -1
  552. package/dist/commonjs/encryption/EncryptionProcessor.js +5 -0
  553. package/dist/commonjs/encryption/EncryptionProcessor.js.map +1 -1
  554. package/dist/commonjs/encryption/EncryptionQueryBuilder.js +2 -0
  555. package/dist/commonjs/encryption/EncryptionQueryBuilder.js.map +1 -1
  556. package/dist/commonjs/encryption/EncryptionSettingForProperty.js +6 -0
  557. package/dist/commonjs/encryption/EncryptionSettingForProperty.js.map +1 -1
  558. package/dist/commonjs/encryption/EncryptionSettings.js +6 -3
  559. package/dist/commonjs/encryption/EncryptionSettings.js.map +1 -1
  560. package/dist/commonjs/encryption/KeyEncryptionKey.js +4 -0
  561. package/dist/commonjs/encryption/KeyEncryptionKey.js.map +1 -1
  562. package/dist/commonjs/encryption/Serializers/StringSerializer.js +1 -1
  563. package/dist/commonjs/encryption/Serializers/StringSerializer.js.map +1 -1
  564. package/dist/commonjs/extractPartitionKey.js +2 -2
  565. package/dist/commonjs/extractPartitionKey.js.map +1 -1
  566. package/dist/commonjs/globalEndpointManager.d.ts +8 -0
  567. package/dist/commonjs/globalEndpointManager.d.ts.map +1 -1
  568. package/dist/commonjs/globalEndpointManager.js +104 -29
  569. package/dist/commonjs/globalEndpointManager.js.map +1 -1
  570. package/dist/commonjs/globalPartitionEndpointManager.d.ts +0 -2
  571. package/dist/commonjs/globalPartitionEndpointManager.d.ts.map +1 -1
  572. package/dist/commonjs/globalPartitionEndpointManager.js +19 -7
  573. package/dist/commonjs/globalPartitionEndpointManager.js.map +1 -1
  574. package/dist/commonjs/queryExecutionContext/Aggregators/AverageAggregator.js +2 -0
  575. package/dist/commonjs/queryExecutionContext/Aggregators/AverageAggregator.js.map +1 -1
  576. package/dist/commonjs/queryExecutionContext/Aggregators/CountAggregator.js +1 -0
  577. package/dist/commonjs/queryExecutionContext/Aggregators/CountAggregator.js.map +1 -1
  578. package/dist/commonjs/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js +1 -0
  579. package/dist/commonjs/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js.map +1 -1
  580. package/dist/commonjs/queryExecutionContext/Aggregators/MakeListAggregator.js +1 -0
  581. package/dist/commonjs/queryExecutionContext/Aggregators/MakeListAggregator.js.map +1 -1
  582. package/dist/commonjs/queryExecutionContext/Aggregators/MakeSetAggregator.js +1 -0
  583. package/dist/commonjs/queryExecutionContext/Aggregators/MakeSetAggregator.js.map +1 -1
  584. package/dist/commonjs/queryExecutionContext/Aggregators/MaxAggregator.js +2 -0
  585. package/dist/commonjs/queryExecutionContext/Aggregators/MaxAggregator.js.map +1 -1
  586. package/dist/commonjs/queryExecutionContext/Aggregators/MinAggregator.js +2 -0
  587. package/dist/commonjs/queryExecutionContext/Aggregators/MinAggregator.js.map +1 -1
  588. package/dist/commonjs/queryExecutionContext/Aggregators/StaticValueAggregator.js +1 -0
  589. package/dist/commonjs/queryExecutionContext/Aggregators/StaticValueAggregator.js.map +1 -1
  590. package/dist/commonjs/queryExecutionContext/Aggregators/SumAggregator.js +1 -0
  591. package/dist/commonjs/queryExecutionContext/Aggregators/SumAggregator.js.map +1 -1
  592. package/dist/commonjs/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js +5 -3
  593. package/dist/commonjs/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map +1 -1
  594. package/dist/commonjs/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js +6 -3
  595. package/dist/commonjs/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map +1 -1
  596. package/dist/commonjs/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js +23 -7
  597. package/dist/commonjs/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map +1 -1
  598. package/dist/commonjs/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js +14 -6
  599. package/dist/commonjs/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map +1 -1
  600. package/dist/commonjs/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js +3 -0
  601. package/dist/commonjs/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map +1 -1
  602. package/dist/commonjs/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js +2 -0
  603. package/dist/commonjs/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map +1 -1
  604. package/dist/commonjs/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js +2 -0
  605. package/dist/commonjs/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map +1 -1
  606. package/dist/commonjs/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js +2 -0
  607. package/dist/commonjs/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map +1 -1
  608. package/dist/commonjs/queryExecutionContext/FetchResult.js +4 -0
  609. package/dist/commonjs/queryExecutionContext/FetchResult.js.map +1 -1
  610. package/dist/commonjs/queryExecutionContext/defaultQueryExecutionContext.js +14 -2
  611. package/dist/commonjs/queryExecutionContext/defaultQueryExecutionContext.js.map +1 -1
  612. package/dist/commonjs/queryExecutionContext/documentProducer.js +34 -21
  613. package/dist/commonjs/queryExecutionContext/documentProducer.js.map +1 -1
  614. package/dist/commonjs/queryExecutionContext/hybridQueryExecutionContext.js +41 -27
  615. package/dist/commonjs/queryExecutionContext/hybridQueryExecutionContext.js.map +1 -1
  616. package/dist/commonjs/queryExecutionContext/orderByComparator.js +1 -0
  617. package/dist/commonjs/queryExecutionContext/orderByComparator.js.map +1 -1
  618. package/dist/commonjs/queryExecutionContext/orderByDocumentProducerComparator.js +1 -0
  619. package/dist/commonjs/queryExecutionContext/orderByDocumentProducerComparator.js.map +1 -1
  620. package/dist/commonjs/queryExecutionContext/orderByQueryExecutionContext.js +1 -0
  621. package/dist/commonjs/queryExecutionContext/orderByQueryExecutionContext.js.map +1 -1
  622. package/dist/commonjs/queryExecutionContext/parallelQueryExecutionContextBase.js +20 -2
  623. package/dist/commonjs/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
  624. package/dist/commonjs/queryExecutionContext/pipelinedQueryExecutionContext.js +14 -4
  625. package/dist/commonjs/queryExecutionContext/pipelinedQueryExecutionContext.js.map +1 -1
  626. package/dist/commonjs/queryIterator.js +41 -33
  627. package/dist/commonjs/queryIterator.js.map +1 -1
  628. package/dist/commonjs/queryMetrics/clientSideMetrics.js +2 -1
  629. package/dist/commonjs/queryMetrics/clientSideMetrics.js.map +1 -1
  630. package/dist/commonjs/queryMetrics/queryMetrics.js +14 -1
  631. package/dist/commonjs/queryMetrics/queryMetrics.js.map +1 -1
  632. package/dist/commonjs/queryMetrics/queryPreparationTime.js +5 -1
  633. package/dist/commonjs/queryMetrics/queryPreparationTime.js.map +1 -1
  634. package/dist/commonjs/queryMetrics/runtimeExecutionTimes.js +4 -1
  635. package/dist/commonjs/queryMetrics/runtimeExecutionTimes.js.map +1 -1
  636. package/dist/commonjs/queryMetrics/timeSpan.js +4 -3
  637. package/dist/commonjs/queryMetrics/timeSpan.js.map +1 -1
  638. package/dist/commonjs/request/ErrorResponse.js +19 -0
  639. package/dist/commonjs/request/ErrorResponse.js.map +1 -1
  640. package/dist/commonjs/request/FeedResponse.js +4 -0
  641. package/dist/commonjs/request/FeedResponse.js.map +1 -1
  642. package/dist/commonjs/request/RequestHandler.js +3 -4
  643. package/dist/commonjs/request/RequestHandler.js.map +1 -1
  644. package/dist/commonjs/request/ResourceResponse.js +5 -0
  645. package/dist/commonjs/request/ResourceResponse.js.map +1 -1
  646. package/dist/commonjs/request/SharedOptions.d.ts +5 -0
  647. package/dist/commonjs/request/SharedOptions.d.ts.map +1 -1
  648. package/dist/commonjs/request/SharedOptions.js.map +1 -1
  649. package/dist/commonjs/request/TimeoutError.js +1 -1
  650. package/dist/commonjs/request/TimeoutError.js.map +1 -1
  651. package/dist/commonjs/request/hybridSearchQueryResult.js +5 -0
  652. package/dist/commonjs/request/hybridSearchQueryResult.js.map +1 -1
  653. package/dist/commonjs/request/request.js +5 -1
  654. package/dist/commonjs/request/request.js.map +1 -1
  655. package/dist/commonjs/retry/bulkExecutionRetryPolicy.js +5 -2
  656. package/dist/commonjs/retry/bulkExecutionRetryPolicy.js.map +1 -1
  657. package/dist/commonjs/retry/defaultRetryPolicy.d.ts.map +1 -1
  658. package/dist/commonjs/retry/defaultRetryPolicy.js +6 -6
  659. package/dist/commonjs/retry/defaultRetryPolicy.js.map +1 -1
  660. package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.d.ts +3 -2
  661. package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
  662. package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.js +24 -7
  663. package/dist/commonjs/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
  664. package/dist/commonjs/retry/resourceThrottleRetryPolicy.js +20 -10
  665. package/dist/commonjs/retry/resourceThrottleRetryPolicy.js.map +1 -1
  666. package/dist/commonjs/retry/retryUtility.d.ts.map +1 -1
  667. package/dist/commonjs/retry/retryUtility.js +22 -8
  668. package/dist/commonjs/retry/retryUtility.js.map +1 -1
  669. package/dist/commonjs/retry/sessionRetryPolicy.js +8 -4
  670. package/dist/commonjs/retry/sessionRetryPolicy.js.map +1 -1
  671. package/dist/commonjs/retry/timeoutFailoverRetryPolicy.d.ts +1 -2
  672. package/dist/commonjs/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
  673. package/dist/commonjs/retry/timeoutFailoverRetryPolicy.js +17 -7
  674. package/dist/commonjs/retry/timeoutFailoverRetryPolicy.js.map +1 -1
  675. package/dist/commonjs/routing/QueryRange.js +4 -0
  676. package/dist/commonjs/routing/QueryRange.js.map +1 -1
  677. package/dist/commonjs/routing/inMemoryCollectionRoutingMap.js +4 -0
  678. package/dist/commonjs/routing/inMemoryCollectionRoutingMap.js.map +1 -1
  679. package/dist/commonjs/routing/partitionKeyRangeCache.js +2 -0
  680. package/dist/commonjs/routing/partitionKeyRangeCache.js.map +1 -1
  681. package/dist/commonjs/routing/smartRoutingMapProvider.js +1 -0
  682. package/dist/commonjs/routing/smartRoutingMapProvider.js.map +1 -1
  683. package/dist/commonjs/session/VectorSessionToken.js +6 -2
  684. package/dist/commonjs/session/VectorSessionToken.js.map +1 -1
  685. package/dist/commonjs/session/sessionContainer.js +5 -3
  686. package/dist/commonjs/session/sessionContainer.js.map +1 -1
  687. package/dist/commonjs/tsdoc-metadata.json +1 -1
  688. package/dist/commonjs/utils/batch.js +15 -4
  689. package/dist/commonjs/utils/batch.js.map +1 -1
  690. package/dist/commonjs/utils/encode.d.ts +1 -1
  691. package/dist/commonjs/utils/encode.d.ts.map +1 -1
  692. package/dist/commonjs/utils/encode.js.map +1 -1
  693. package/dist/commonjs/utils/fixedSizePriorityQueue.js +4 -0
  694. package/dist/commonjs/utils/fixedSizePriorityQueue.js.map +1 -1
  695. package/dist/commonjs/utils/hashing/hash.js +1 -1
  696. package/dist/commonjs/utils/hashing/hash.js.map +1 -1
  697. package/dist/commonjs/utils/nonStreamingOrderByMap.js +2 -0
  698. package/dist/commonjs/utils/nonStreamingOrderByMap.js.map +1 -1
  699. package/dist/esm/ChangeFeedIterator.js +17 -11
  700. package/dist/esm/ChangeFeedIterator.js.map +1 -1
  701. package/dist/esm/ChangeFeedResponse.js +8 -0
  702. package/dist/esm/ChangeFeedResponse.js.map +1 -1
  703. package/dist/esm/ClientContext.d.ts.map +1 -1
  704. package/dist/esm/ClientContext.js +232 -48
  705. package/dist/esm/ClientContext.js.map +1 -1
  706. package/dist/esm/CosmosClient.d.ts +13 -0
  707. package/dist/esm/CosmosClient.d.ts.map +1 -1
  708. package/dist/esm/CosmosClient.js +53 -6
  709. package/dist/esm/CosmosClient.js.map +1 -1
  710. package/dist/esm/CosmosClientOptions.d.ts.map +1 -1
  711. package/dist/esm/CosmosClientOptions.js.map +1 -1
  712. package/dist/esm/CosmosDiagnostics.d.ts +4 -0
  713. package/dist/esm/CosmosDiagnostics.d.ts.map +1 -1
  714. package/dist/esm/CosmosDiagnostics.js +3 -0
  715. package/dist/esm/CosmosDiagnostics.js.map +1 -1
  716. package/dist/esm/GlobalEndpointManagerOptions.d.ts +2 -0
  717. package/dist/esm/GlobalEndpointManagerOptions.d.ts.map +1 -0
  718. package/dist/esm/GlobalEndpointManagerOptions.js +2 -0
  719. package/dist/esm/GlobalEndpointManagerOptions.js.map +1 -0
  720. package/dist/esm/PartitionKeyRangeFailoverInfo.js +8 -5
  721. package/dist/esm/PartitionKeyRangeFailoverInfo.js.map +1 -1
  722. package/dist/esm/bulk/Batcher.js +13 -3
  723. package/dist/esm/bulk/Batcher.js.map +1 -1
  724. package/dist/esm/bulk/BulkHelper.js +26 -11
  725. package/dist/esm/bulk/BulkHelper.js.map +1 -1
  726. package/dist/esm/bulk/BulkResponse.js +22 -20
  727. package/dist/esm/bulk/BulkResponse.js.map +1 -1
  728. package/dist/esm/bulk/CongestionAlgorithm.js +11 -4
  729. package/dist/esm/bulk/CongestionAlgorithm.js.map +1 -1
  730. package/dist/esm/bulk/HelperPerPartition.js +14 -1
  731. package/dist/esm/bulk/HelperPerPartition.js.map +1 -1
  732. package/dist/esm/bulk/ItemOperationContext.js +4 -0
  733. package/dist/esm/bulk/ItemOperationContext.js.map +1 -1
  734. package/dist/esm/bulk/Limiter.js +27 -18
  735. package/dist/esm/bulk/Limiter.js.map +1 -1
  736. package/dist/esm/bulk/PartitionMetric.js +4 -0
  737. package/dist/esm/bulk/PartitionMetric.js.map +1 -1
  738. package/dist/esm/client/ChangeFeed/ChangeFeedForEpkRange.d.ts.map +1 -1
  739. package/dist/esm/client/ChangeFeed/ChangeFeedForEpkRange.js +29 -15
  740. package/dist/esm/client/ChangeFeed/ChangeFeedForEpkRange.js.map +1 -1
  741. package/dist/esm/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map +1 -1
  742. package/dist/esm/client/ChangeFeed/ChangeFeedForPartitionKey.js +19 -8
  743. package/dist/esm/client/ChangeFeed/ChangeFeedForPartitionKey.js.map +1 -1
  744. package/dist/esm/client/ChangeFeed/ChangeFeedIteratorBuilder.js +12 -9
  745. package/dist/esm/client/ChangeFeed/ChangeFeedIteratorBuilder.js.map +1 -1
  746. package/dist/esm/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts +5 -0
  747. package/dist/esm/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map +1 -1
  748. package/dist/esm/client/ChangeFeed/ChangeFeedIteratorOptions.js.map +1 -1
  749. package/dist/esm/client/ChangeFeed/ChangeFeedIteratorResponse.js +9 -0
  750. package/dist/esm/client/ChangeFeed/ChangeFeedIteratorResponse.js.map +1 -1
  751. package/dist/esm/client/ChangeFeed/ChangeFeedPolicy.js +1 -0
  752. package/dist/esm/client/ChangeFeed/ChangeFeedPolicy.js.map +1 -1
  753. package/dist/esm/client/ChangeFeed/ChangeFeedRange.js +20 -0
  754. package/dist/esm/client/ChangeFeed/ChangeFeedRange.js.map +1 -1
  755. package/dist/esm/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js +1 -0
  756. package/dist/esm/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js.map +1 -1
  757. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromBeginning.js +1 -0
  758. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map +1 -1
  759. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromContinuation.js +1 -0
  760. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map +1 -1
  761. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromNow.js +1 -0
  762. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromNow.js.map +1 -1
  763. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromTime.js +2 -0
  764. package/dist/esm/client/ChangeFeed/ChangeFeedStartFromTime.js.map +1 -1
  765. package/dist/esm/client/ChangeFeed/CompositeContinuationToken.js +8 -0
  766. package/dist/esm/client/ChangeFeed/CompositeContinuationToken.js.map +1 -1
  767. package/dist/esm/client/ChangeFeed/ContinuationTokenForPartitionKey.js +12 -0
  768. package/dist/esm/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map +1 -1
  769. package/dist/esm/client/ChangeFeed/FeedRange.js +8 -0
  770. package/dist/esm/client/ChangeFeed/FeedRange.js.map +1 -1
  771. package/dist/esm/client/ChangeFeed/FeedRangeQueue.js +1 -0
  772. package/dist/esm/client/ChangeFeed/FeedRangeQueue.js.map +1 -1
  773. package/dist/esm/client/ChangeFeed/InternalChangeFeedOptions.d.ts +1 -0
  774. package/dist/esm/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map +1 -1
  775. package/dist/esm/client/ChangeFeed/InternalChangeFeedOptions.js.map +1 -1
  776. package/dist/esm/client/ChangeFeed/changeFeedUtils.d.ts.map +1 -1
  777. package/dist/esm/client/ChangeFeed/changeFeedUtils.js +6 -5
  778. package/dist/esm/client/ChangeFeed/changeFeedUtils.js.map +1 -1
  779. package/dist/esm/client/ClientUtils.js +1 -1
  780. package/dist/esm/client/ClientUtils.js.map +1 -1
  781. package/dist/esm/client/Conflict/Conflict.js +4 -0
  782. package/dist/esm/client/Conflict/Conflict.js.map +1 -1
  783. package/dist/esm/client/Conflict/ConflictResponse.js +2 -0
  784. package/dist/esm/client/Conflict/ConflictResponse.js.map +1 -1
  785. package/dist/esm/client/Conflict/Conflicts.js +2 -0
  786. package/dist/esm/client/Conflict/Conflicts.js.map +1 -1
  787. package/dist/esm/client/Container/Container.js +18 -3
  788. package/dist/esm/client/Container/Container.js.map +1 -1
  789. package/dist/esm/client/Container/ContainerResponse.js +2 -0
  790. package/dist/esm/client/Container/ContainerResponse.js.map +1 -1
  791. package/dist/esm/client/Container/Containers.js +4 -2
  792. package/dist/esm/client/Container/Containers.js.map +1 -1
  793. package/dist/esm/client/Database/Database.js +33 -0
  794. package/dist/esm/client/Database/Database.js.map +1 -1
  795. package/dist/esm/client/Database/DatabaseResponse.js +2 -0
  796. package/dist/esm/client/Database/DatabaseResponse.js.map +1 -1
  797. package/dist/esm/client/Database/Databases.js +3 -0
  798. package/dist/esm/client/Database/Databases.js.map +1 -1
  799. package/dist/esm/client/Item/Item.js +4 -0
  800. package/dist/esm/client/Item/Item.js.map +1 -1
  801. package/dist/esm/client/Item/ItemResponse.js +2 -0
  802. package/dist/esm/client/Item/ItemResponse.js.map +1 -1
  803. package/dist/esm/client/Item/Items.d.ts.map +1 -1
  804. package/dist/esm/client/Item/Items.js +8 -0
  805. package/dist/esm/client/Item/Items.js.map +1 -1
  806. package/dist/esm/client/Offer/Offer.js +3 -0
  807. package/dist/esm/client/Offer/Offer.js.map +1 -1
  808. package/dist/esm/client/Offer/OfferResponse.js +2 -0
  809. package/dist/esm/client/Offer/OfferResponse.js.map +1 -1
  810. package/dist/esm/client/Offer/Offers.js +2 -0
  811. package/dist/esm/client/Offer/Offers.js.map +1 -1
  812. package/dist/esm/client/Permission/Permission.js +3 -0
  813. package/dist/esm/client/Permission/Permission.js.map +1 -1
  814. package/dist/esm/client/Permission/PermissionResponse.js +2 -0
  815. package/dist/esm/client/Permission/PermissionResponse.js.map +1 -1
  816. package/dist/esm/client/Permission/Permissions.js +2 -0
  817. package/dist/esm/client/Permission/Permissions.js.map +1 -1
  818. package/dist/esm/client/SasToken/SasTokenProperties.js +17 -0
  819. package/dist/esm/client/SasToken/SasTokenProperties.js.map +1 -1
  820. package/dist/esm/client/Script/Scripts.js +5 -0
  821. package/dist/esm/client/Script/Scripts.js.map +1 -1
  822. package/dist/esm/client/StoredProcedure/StoredProcedure.js +3 -0
  823. package/dist/esm/client/StoredProcedure/StoredProcedure.js.map +1 -1
  824. package/dist/esm/client/StoredProcedure/StoredProcedureResponse.js +4 -0
  825. package/dist/esm/client/StoredProcedure/StoredProcedureResponse.js.map +1 -1
  826. package/dist/esm/client/StoredProcedure/StoredProcedures.js +2 -0
  827. package/dist/esm/client/StoredProcedure/StoredProcedures.js.map +1 -1
  828. package/dist/esm/client/Trigger/Trigger.js +3 -0
  829. package/dist/esm/client/Trigger/Trigger.js.map +1 -1
  830. package/dist/esm/client/Trigger/TriggerResponse.js +2 -0
  831. package/dist/esm/client/Trigger/TriggerResponse.js.map +1 -1
  832. package/dist/esm/client/Trigger/Triggers.js +2 -0
  833. package/dist/esm/client/Trigger/Triggers.js.map +1 -1
  834. package/dist/esm/client/User/User.js +9 -0
  835. package/dist/esm/client/User/User.js.map +1 -1
  836. package/dist/esm/client/User/UserResponse.js +2 -0
  837. package/dist/esm/client/User/UserResponse.js.map +1 -1
  838. package/dist/esm/client/User/Users.js +2 -0
  839. package/dist/esm/client/User/Users.js.map +1 -1
  840. package/dist/esm/client/UserDefinedFunction/UserDefinedFunction.js +3 -0
  841. package/dist/esm/client/UserDefinedFunction/UserDefinedFunction.js.map +1 -1
  842. package/dist/esm/client/UserDefinedFunction/UserDefinedFunctionResponse.js +2 -0
  843. package/dist/esm/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map +1 -1
  844. package/dist/esm/client/UserDefinedFunction/UserDefinedFunctions.js +2 -0
  845. package/dist/esm/client/UserDefinedFunction/UserDefinedFunctions.js.map +1 -1
  846. package/dist/esm/common/constants.d.ts +4 -0
  847. package/dist/esm/common/constants.d.ts.map +1 -1
  848. package/dist/esm/common/constants.js +5 -1
  849. package/dist/esm/common/constants.js.map +1 -1
  850. package/dist/esm/common/helper.d.ts +6 -0
  851. package/dist/esm/common/helper.d.ts.map +1 -1
  852. package/dist/esm/common/helper.js +9 -1
  853. package/dist/esm/common/helper.js.map +1 -1
  854. package/dist/esm/common/platform.d.ts +1 -0
  855. package/dist/esm/common/platform.d.ts.map +1 -1
  856. package/dist/esm/common/platform.js +1 -3
  857. package/dist/esm/common/platform.js.map +1 -1
  858. package/dist/esm/diagnostics/CosmosDiagnosticsContext.js +8 -7
  859. package/dist/esm/diagnostics/CosmosDiagnosticsContext.js.map +1 -1
  860. package/dist/esm/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
  861. package/dist/esm/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
  862. package/dist/esm/diagnostics/DiagnosticNodeInternal.js +26 -7
  863. package/dist/esm/diagnostics/DiagnosticNodeInternal.js.map +1 -1
  864. package/dist/esm/diagnostics/DiagnosticWriter.js +1 -3
  865. package/dist/esm/diagnostics/DiagnosticWriter.js.map +1 -1
  866. package/dist/esm/diagnostics/index.js +2 -2
  867. package/dist/esm/diagnostics/index.js.map +1 -1
  868. package/dist/esm/documents/ConnectionPolicy.d.ts +10 -4
  869. package/dist/esm/documents/ConnectionPolicy.d.ts.map +1 -1
  870. package/dist/esm/documents/ConnectionPolicy.js +2 -2
  871. package/dist/esm/documents/ConnectionPolicy.js.map +1 -1
  872. package/dist/esm/documents/DatabaseAccount.d.ts +4 -0
  873. package/dist/esm/documents/DatabaseAccount.d.ts.map +1 -1
  874. package/dist/esm/documents/DatabaseAccount.js +29 -4
  875. package/dist/esm/documents/DatabaseAccount.js.map +1 -1
  876. package/dist/esm/documents/PartitionKey.js +1 -3
  877. package/dist/esm/documents/PartitionKey.js.map +1 -1
  878. package/dist/esm/encryption/AeadAes256CbcHmacSha256Algorithm/AeadAes256CbcHmacSha256Algorithm.js +8 -2
  879. package/dist/esm/encryption/AeadAes256CbcHmacSha256Algorithm/AeadAes256CbcHmacSha256Algorithm.js.map +1 -1
  880. package/dist/esm/encryption/Cache/ClientEncryptionKeyPropertiesCache.js +2 -0
  881. package/dist/esm/encryption/Cache/ClientEncryptionKeyPropertiesCache.js.map +1 -1
  882. package/dist/esm/encryption/Cache/EncryptionSettingsCache.js +2 -0
  883. package/dist/esm/encryption/Cache/EncryptionSettingsCache.js.map +1 -1
  884. package/dist/esm/encryption/Cache/KeyEncryptionKeyCache.js +2 -0
  885. package/dist/esm/encryption/Cache/KeyEncryptionKeyCache.js.map +1 -1
  886. package/dist/esm/encryption/Cache/ProtectedDataEncryptionKeyCache.js +5 -0
  887. package/dist/esm/encryption/Cache/ProtectedDataEncryptionKeyCache.js.map +1 -1
  888. package/dist/esm/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js +2 -0
  889. package/dist/esm/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js.map +1 -1
  890. package/dist/esm/encryption/EncryptionItemQueryIterator.js +24 -27
  891. package/dist/esm/encryption/EncryptionItemQueryIterator.js.map +1 -1
  892. package/dist/esm/encryption/EncryptionKey/DataEncryptionKey.js +7 -2
  893. package/dist/esm/encryption/EncryptionKey/DataEncryptionKey.js.map +1 -1
  894. package/dist/esm/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts +0 -1
  895. package/dist/esm/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts.map +1 -1
  896. package/dist/esm/encryption/EncryptionKey/ProtectedDataEncryptionKey.js +2 -0
  897. package/dist/esm/encryption/EncryptionKey/ProtectedDataEncryptionKey.js.map +1 -1
  898. package/dist/esm/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js +6 -5
  899. package/dist/esm/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js.map +1 -1
  900. package/dist/esm/encryption/EncryptionKeyStoreProvider.js +8 -1
  901. package/dist/esm/encryption/EncryptionKeyStoreProvider.js.map +1 -1
  902. package/dist/esm/encryption/EncryptionManager.js +6 -0
  903. package/dist/esm/encryption/EncryptionManager.js.map +1 -1
  904. package/dist/esm/encryption/EncryptionProcessor.js +5 -0
  905. package/dist/esm/encryption/EncryptionProcessor.js.map +1 -1
  906. package/dist/esm/encryption/EncryptionQueryBuilder.js +2 -0
  907. package/dist/esm/encryption/EncryptionQueryBuilder.js.map +1 -1
  908. package/dist/esm/encryption/EncryptionSettingForProperty.js +6 -0
  909. package/dist/esm/encryption/EncryptionSettingForProperty.js.map +1 -1
  910. package/dist/esm/encryption/EncryptionSettings.js +6 -3
  911. package/dist/esm/encryption/EncryptionSettings.js.map +1 -1
  912. package/dist/esm/encryption/KeyEncryptionKey.js +4 -0
  913. package/dist/esm/encryption/KeyEncryptionKey.js.map +1 -1
  914. package/dist/esm/encryption/Serializers/StringSerializer.js +1 -1
  915. package/dist/esm/encryption/Serializers/StringSerializer.js.map +1 -1
  916. package/dist/esm/extractPartitionKey.js +2 -2
  917. package/dist/esm/extractPartitionKey.js.map +1 -1
  918. package/dist/esm/globalEndpointManager.d.ts +8 -0
  919. package/dist/esm/globalEndpointManager.d.ts.map +1 -1
  920. package/dist/esm/globalEndpointManager.js +104 -29
  921. package/dist/esm/globalEndpointManager.js.map +1 -1
  922. package/dist/esm/globalPartitionEndpointManager.d.ts +0 -2
  923. package/dist/esm/globalPartitionEndpointManager.d.ts.map +1 -1
  924. package/dist/esm/globalPartitionEndpointManager.js +19 -7
  925. package/dist/esm/globalPartitionEndpointManager.js.map +1 -1
  926. package/dist/esm/queryExecutionContext/Aggregators/AverageAggregator.js +2 -0
  927. package/dist/esm/queryExecutionContext/Aggregators/AverageAggregator.js.map +1 -1
  928. package/dist/esm/queryExecutionContext/Aggregators/CountAggregator.js +1 -0
  929. package/dist/esm/queryExecutionContext/Aggregators/CountAggregator.js.map +1 -1
  930. package/dist/esm/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js +1 -0
  931. package/dist/esm/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js.map +1 -1
  932. package/dist/esm/queryExecutionContext/Aggregators/MakeListAggregator.js +1 -0
  933. package/dist/esm/queryExecutionContext/Aggregators/MakeListAggregator.js.map +1 -1
  934. package/dist/esm/queryExecutionContext/Aggregators/MakeSetAggregator.js +1 -0
  935. package/dist/esm/queryExecutionContext/Aggregators/MakeSetAggregator.js.map +1 -1
  936. package/dist/esm/queryExecutionContext/Aggregators/MaxAggregator.js +2 -0
  937. package/dist/esm/queryExecutionContext/Aggregators/MaxAggregator.js.map +1 -1
  938. package/dist/esm/queryExecutionContext/Aggregators/MinAggregator.js +2 -0
  939. package/dist/esm/queryExecutionContext/Aggregators/MinAggregator.js.map +1 -1
  940. package/dist/esm/queryExecutionContext/Aggregators/StaticValueAggregator.js +1 -0
  941. package/dist/esm/queryExecutionContext/Aggregators/StaticValueAggregator.js.map +1 -1
  942. package/dist/esm/queryExecutionContext/Aggregators/SumAggregator.js +1 -0
  943. package/dist/esm/queryExecutionContext/Aggregators/SumAggregator.js.map +1 -1
  944. package/dist/esm/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js +5 -3
  945. package/dist/esm/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map +1 -1
  946. package/dist/esm/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js +6 -3
  947. package/dist/esm/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map +1 -1
  948. package/dist/esm/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js +23 -7
  949. package/dist/esm/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map +1 -1
  950. package/dist/esm/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js +14 -6
  951. package/dist/esm/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map +1 -1
  952. package/dist/esm/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js +3 -0
  953. package/dist/esm/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map +1 -1
  954. package/dist/esm/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js +2 -0
  955. package/dist/esm/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map +1 -1
  956. package/dist/esm/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js +2 -0
  957. package/dist/esm/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map +1 -1
  958. package/dist/esm/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js +2 -0
  959. package/dist/esm/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map +1 -1
  960. package/dist/esm/queryExecutionContext/FetchResult.js +4 -0
  961. package/dist/esm/queryExecutionContext/FetchResult.js.map +1 -1
  962. package/dist/esm/queryExecutionContext/defaultQueryExecutionContext.js +14 -2
  963. package/dist/esm/queryExecutionContext/defaultQueryExecutionContext.js.map +1 -1
  964. package/dist/esm/queryExecutionContext/documentProducer.js +34 -21
  965. package/dist/esm/queryExecutionContext/documentProducer.js.map +1 -1
  966. package/dist/esm/queryExecutionContext/hybridQueryExecutionContext.js +41 -27
  967. package/dist/esm/queryExecutionContext/hybridQueryExecutionContext.js.map +1 -1
  968. package/dist/esm/queryExecutionContext/orderByComparator.js +1 -0
  969. package/dist/esm/queryExecutionContext/orderByComparator.js.map +1 -1
  970. package/dist/esm/queryExecutionContext/orderByDocumentProducerComparator.js +1 -0
  971. package/dist/esm/queryExecutionContext/orderByDocumentProducerComparator.js.map +1 -1
  972. package/dist/esm/queryExecutionContext/orderByQueryExecutionContext.js +1 -0
  973. package/dist/esm/queryExecutionContext/orderByQueryExecutionContext.js.map +1 -1
  974. package/dist/esm/queryExecutionContext/parallelQueryExecutionContextBase.js +20 -2
  975. package/dist/esm/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
  976. package/dist/esm/queryExecutionContext/pipelinedQueryExecutionContext.js +14 -4
  977. package/dist/esm/queryExecutionContext/pipelinedQueryExecutionContext.js.map +1 -1
  978. package/dist/esm/queryIterator.js +41 -33
  979. package/dist/esm/queryIterator.js.map +1 -1
  980. package/dist/esm/queryMetrics/clientSideMetrics.js +2 -1
  981. package/dist/esm/queryMetrics/clientSideMetrics.js.map +1 -1
  982. package/dist/esm/queryMetrics/queryMetrics.js +14 -1
  983. package/dist/esm/queryMetrics/queryMetrics.js.map +1 -1
  984. package/dist/esm/queryMetrics/queryPreparationTime.js +5 -1
  985. package/dist/esm/queryMetrics/queryPreparationTime.js.map +1 -1
  986. package/dist/esm/queryMetrics/runtimeExecutionTimes.js +4 -1
  987. package/dist/esm/queryMetrics/runtimeExecutionTimes.js.map +1 -1
  988. package/dist/esm/queryMetrics/timeSpan.js +4 -3
  989. package/dist/esm/queryMetrics/timeSpan.js.map +1 -1
  990. package/dist/esm/request/ErrorResponse.js +19 -0
  991. package/dist/esm/request/ErrorResponse.js.map +1 -1
  992. package/dist/esm/request/FeedResponse.js +4 -0
  993. package/dist/esm/request/FeedResponse.js.map +1 -1
  994. package/dist/esm/request/RequestHandler.js +3 -4
  995. package/dist/esm/request/RequestHandler.js.map +1 -1
  996. package/dist/esm/request/ResourceResponse.js +5 -0
  997. package/dist/esm/request/ResourceResponse.js.map +1 -1
  998. package/dist/esm/request/SharedOptions.d.ts +5 -0
  999. package/dist/esm/request/SharedOptions.d.ts.map +1 -1
  1000. package/dist/esm/request/SharedOptions.js.map +1 -1
  1001. package/dist/esm/request/TimeoutError.js +1 -1
  1002. package/dist/esm/request/TimeoutError.js.map +1 -1
  1003. package/dist/esm/request/hybridSearchQueryResult.js +5 -0
  1004. package/dist/esm/request/hybridSearchQueryResult.js.map +1 -1
  1005. package/dist/esm/request/request.js +5 -1
  1006. package/dist/esm/request/request.js.map +1 -1
  1007. package/dist/esm/retry/bulkExecutionRetryPolicy.js +5 -2
  1008. package/dist/esm/retry/bulkExecutionRetryPolicy.js.map +1 -1
  1009. package/dist/esm/retry/defaultRetryPolicy.d.ts.map +1 -1
  1010. package/dist/esm/retry/defaultRetryPolicy.js +7 -7
  1011. package/dist/esm/retry/defaultRetryPolicy.js.map +1 -1
  1012. package/dist/esm/retry/endpointDiscoveryRetryPolicy.d.ts +3 -2
  1013. package/dist/esm/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
  1014. package/dist/esm/retry/endpointDiscoveryRetryPolicy.js +24 -7
  1015. package/dist/esm/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
  1016. package/dist/esm/retry/resourceThrottleRetryPolicy.js +20 -10
  1017. package/dist/esm/retry/resourceThrottleRetryPolicy.js.map +1 -1
  1018. package/dist/esm/retry/retryUtility.d.ts.map +1 -1
  1019. package/dist/esm/retry/retryUtility.js +22 -8
  1020. package/dist/esm/retry/retryUtility.js.map +1 -1
  1021. package/dist/esm/retry/sessionRetryPolicy.js +8 -4
  1022. package/dist/esm/retry/sessionRetryPolicy.js.map +1 -1
  1023. package/dist/esm/retry/timeoutFailoverRetryPolicy.d.ts +1 -2
  1024. package/dist/esm/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
  1025. package/dist/esm/retry/timeoutFailoverRetryPolicy.js +17 -7
  1026. package/dist/esm/retry/timeoutFailoverRetryPolicy.js.map +1 -1
  1027. package/dist/esm/routing/QueryRange.js +4 -0
  1028. package/dist/esm/routing/QueryRange.js.map +1 -1
  1029. package/dist/esm/routing/inMemoryCollectionRoutingMap.js +4 -0
  1030. package/dist/esm/routing/inMemoryCollectionRoutingMap.js.map +1 -1
  1031. package/dist/esm/routing/partitionKeyRangeCache.js +2 -0
  1032. package/dist/esm/routing/partitionKeyRangeCache.js.map +1 -1
  1033. package/dist/esm/routing/smartRoutingMapProvider.js +1 -0
  1034. package/dist/esm/routing/smartRoutingMapProvider.js.map +1 -1
  1035. package/dist/esm/session/VectorSessionToken.js +6 -2
  1036. package/dist/esm/session/VectorSessionToken.js.map +1 -1
  1037. package/dist/esm/session/sessionContainer.js +5 -3
  1038. package/dist/esm/session/sessionContainer.js.map +1 -1
  1039. package/dist/esm/utils/batch.js +15 -4
  1040. package/dist/esm/utils/batch.js.map +1 -1
  1041. package/dist/esm/utils/encode.d.ts +1 -1
  1042. package/dist/esm/utils/encode.d.ts.map +1 -1
  1043. package/dist/esm/utils/encode.js.map +1 -1
  1044. package/dist/esm/utils/fixedSizePriorityQueue.js +4 -0
  1045. package/dist/esm/utils/fixedSizePriorityQueue.js.map +1 -1
  1046. package/dist/esm/utils/hashing/hash.js +1 -1
  1047. package/dist/esm/utils/hashing/hash.js.map +1 -1
  1048. package/dist/esm/utils/nonStreamingOrderByMap.js +2 -0
  1049. package/dist/esm/utils/nonStreamingOrderByMap.js.map +1 -1
  1050. package/dist/react-native/ChangeFeedIterator.js +17 -11
  1051. package/dist/react-native/ChangeFeedIterator.js.map +1 -1
  1052. package/dist/react-native/ChangeFeedResponse.js +8 -0
  1053. package/dist/react-native/ChangeFeedResponse.js.map +1 -1
  1054. package/dist/react-native/ClientContext.d.ts.map +1 -1
  1055. package/dist/react-native/ClientContext.js +232 -48
  1056. package/dist/react-native/ClientContext.js.map +1 -1
  1057. package/dist/react-native/CosmosClient.d.ts +13 -0
  1058. package/dist/react-native/CosmosClient.d.ts.map +1 -1
  1059. package/dist/react-native/CosmosClient.js +53 -6
  1060. package/dist/react-native/CosmosClient.js.map +1 -1
  1061. package/dist/react-native/CosmosClientOptions.d.ts.map +1 -1
  1062. package/dist/react-native/CosmosClientOptions.js.map +1 -1
  1063. package/dist/react-native/CosmosDiagnostics.d.ts +4 -0
  1064. package/dist/react-native/CosmosDiagnostics.d.ts.map +1 -1
  1065. package/dist/react-native/CosmosDiagnostics.js +3 -0
  1066. package/dist/react-native/CosmosDiagnostics.js.map +1 -1
  1067. package/dist/react-native/GlobalEndpointManagerOptions.d.ts +2 -0
  1068. package/dist/react-native/GlobalEndpointManagerOptions.d.ts.map +1 -0
  1069. package/dist/react-native/GlobalEndpointManagerOptions.js +2 -0
  1070. package/dist/react-native/GlobalEndpointManagerOptions.js.map +1 -0
  1071. package/dist/react-native/PartitionKeyRangeFailoverInfo.js +8 -5
  1072. package/dist/react-native/PartitionKeyRangeFailoverInfo.js.map +1 -1
  1073. package/dist/react-native/bulk/Batcher.js +13 -3
  1074. package/dist/react-native/bulk/Batcher.js.map +1 -1
  1075. package/dist/react-native/bulk/BulkHelper.js +26 -11
  1076. package/dist/react-native/bulk/BulkHelper.js.map +1 -1
  1077. package/dist/react-native/bulk/BulkResponse.js +22 -20
  1078. package/dist/react-native/bulk/BulkResponse.js.map +1 -1
  1079. package/dist/react-native/bulk/CongestionAlgorithm.js +11 -4
  1080. package/dist/react-native/bulk/CongestionAlgorithm.js.map +1 -1
  1081. package/dist/react-native/bulk/HelperPerPartition.js +14 -1
  1082. package/dist/react-native/bulk/HelperPerPartition.js.map +1 -1
  1083. package/dist/react-native/bulk/ItemOperationContext.js +4 -0
  1084. package/dist/react-native/bulk/ItemOperationContext.js.map +1 -1
  1085. package/dist/react-native/bulk/Limiter.js +27 -18
  1086. package/dist/react-native/bulk/Limiter.js.map +1 -1
  1087. package/dist/react-native/bulk/PartitionMetric.js +4 -0
  1088. package/dist/react-native/bulk/PartitionMetric.js.map +1 -1
  1089. package/dist/react-native/client/ChangeFeed/ChangeFeedForEpkRange.d.ts.map +1 -1
  1090. package/dist/react-native/client/ChangeFeed/ChangeFeedForEpkRange.js +29 -15
  1091. package/dist/react-native/client/ChangeFeed/ChangeFeedForEpkRange.js.map +1 -1
  1092. package/dist/react-native/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map +1 -1
  1093. package/dist/react-native/client/ChangeFeed/ChangeFeedForPartitionKey.js +19 -8
  1094. package/dist/react-native/client/ChangeFeed/ChangeFeedForPartitionKey.js.map +1 -1
  1095. package/dist/react-native/client/ChangeFeed/ChangeFeedIteratorBuilder.js +12 -9
  1096. package/dist/react-native/client/ChangeFeed/ChangeFeedIteratorBuilder.js.map +1 -1
  1097. package/dist/react-native/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts +5 -0
  1098. package/dist/react-native/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map +1 -1
  1099. package/dist/react-native/client/ChangeFeed/ChangeFeedIteratorOptions.js.map +1 -1
  1100. package/dist/react-native/client/ChangeFeed/ChangeFeedIteratorResponse.js +9 -0
  1101. package/dist/react-native/client/ChangeFeed/ChangeFeedIteratorResponse.js.map +1 -1
  1102. package/dist/react-native/client/ChangeFeed/ChangeFeedPolicy.js +1 -0
  1103. package/dist/react-native/client/ChangeFeed/ChangeFeedPolicy.js.map +1 -1
  1104. package/dist/react-native/client/ChangeFeed/ChangeFeedRange.js +20 -0
  1105. package/dist/react-native/client/ChangeFeed/ChangeFeedRange.js.map +1 -1
  1106. package/dist/react-native/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js +1 -0
  1107. package/dist/react-native/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js.map +1 -1
  1108. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromBeginning.js +1 -0
  1109. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map +1 -1
  1110. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromContinuation.js +1 -0
  1111. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map +1 -1
  1112. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromNow.js +1 -0
  1113. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromNow.js.map +1 -1
  1114. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromTime.js +2 -0
  1115. package/dist/react-native/client/ChangeFeed/ChangeFeedStartFromTime.js.map +1 -1
  1116. package/dist/react-native/client/ChangeFeed/CompositeContinuationToken.js +8 -0
  1117. package/dist/react-native/client/ChangeFeed/CompositeContinuationToken.js.map +1 -1
  1118. package/dist/react-native/client/ChangeFeed/ContinuationTokenForPartitionKey.js +12 -0
  1119. package/dist/react-native/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map +1 -1
  1120. package/dist/react-native/client/ChangeFeed/FeedRange.js +8 -0
  1121. package/dist/react-native/client/ChangeFeed/FeedRange.js.map +1 -1
  1122. package/dist/react-native/client/ChangeFeed/FeedRangeQueue.js +1 -0
  1123. package/dist/react-native/client/ChangeFeed/FeedRangeQueue.js.map +1 -1
  1124. package/dist/react-native/client/ChangeFeed/InternalChangeFeedOptions.d.ts +1 -0
  1125. package/dist/react-native/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map +1 -1
  1126. package/dist/react-native/client/ChangeFeed/InternalChangeFeedOptions.js.map +1 -1
  1127. package/dist/react-native/client/ChangeFeed/changeFeedUtils.d.ts.map +1 -1
  1128. package/dist/react-native/client/ChangeFeed/changeFeedUtils.js +6 -5
  1129. package/dist/react-native/client/ChangeFeed/changeFeedUtils.js.map +1 -1
  1130. package/dist/react-native/client/ClientUtils.js +1 -1
  1131. package/dist/react-native/client/ClientUtils.js.map +1 -1
  1132. package/dist/react-native/client/Conflict/Conflict.js +4 -0
  1133. package/dist/react-native/client/Conflict/Conflict.js.map +1 -1
  1134. package/dist/react-native/client/Conflict/ConflictResponse.js +2 -0
  1135. package/dist/react-native/client/Conflict/ConflictResponse.js.map +1 -1
  1136. package/dist/react-native/client/Conflict/Conflicts.js +2 -0
  1137. package/dist/react-native/client/Conflict/Conflicts.js.map +1 -1
  1138. package/dist/react-native/client/Container/Container.js +18 -3
  1139. package/dist/react-native/client/Container/Container.js.map +1 -1
  1140. package/dist/react-native/client/Container/ContainerResponse.js +2 -0
  1141. package/dist/react-native/client/Container/ContainerResponse.js.map +1 -1
  1142. package/dist/react-native/client/Container/Containers.js +4 -2
  1143. package/dist/react-native/client/Container/Containers.js.map +1 -1
  1144. package/dist/react-native/client/Database/Database.js +33 -0
  1145. package/dist/react-native/client/Database/Database.js.map +1 -1
  1146. package/dist/react-native/client/Database/DatabaseResponse.js +2 -0
  1147. package/dist/react-native/client/Database/DatabaseResponse.js.map +1 -1
  1148. package/dist/react-native/client/Database/Databases.js +3 -0
  1149. package/dist/react-native/client/Database/Databases.js.map +1 -1
  1150. package/dist/react-native/client/Item/Item.js +4 -0
  1151. package/dist/react-native/client/Item/Item.js.map +1 -1
  1152. package/dist/react-native/client/Item/ItemResponse.js +2 -0
  1153. package/dist/react-native/client/Item/ItemResponse.js.map +1 -1
  1154. package/dist/react-native/client/Item/Items.d.ts.map +1 -1
  1155. package/dist/react-native/client/Item/Items.js +8 -0
  1156. package/dist/react-native/client/Item/Items.js.map +1 -1
  1157. package/dist/react-native/client/Offer/Offer.js +3 -0
  1158. package/dist/react-native/client/Offer/Offer.js.map +1 -1
  1159. package/dist/react-native/client/Offer/OfferResponse.js +2 -0
  1160. package/dist/react-native/client/Offer/OfferResponse.js.map +1 -1
  1161. package/dist/react-native/client/Offer/Offers.js +2 -0
  1162. package/dist/react-native/client/Offer/Offers.js.map +1 -1
  1163. package/dist/react-native/client/Permission/Permission.js +3 -0
  1164. package/dist/react-native/client/Permission/Permission.js.map +1 -1
  1165. package/dist/react-native/client/Permission/PermissionResponse.js +2 -0
  1166. package/dist/react-native/client/Permission/PermissionResponse.js.map +1 -1
  1167. package/dist/react-native/client/Permission/Permissions.js +2 -0
  1168. package/dist/react-native/client/Permission/Permissions.js.map +1 -1
  1169. package/dist/react-native/client/SasToken/SasTokenProperties.js +17 -0
  1170. package/dist/react-native/client/SasToken/SasTokenProperties.js.map +1 -1
  1171. package/dist/react-native/client/Script/Scripts.js +5 -0
  1172. package/dist/react-native/client/Script/Scripts.js.map +1 -1
  1173. package/dist/react-native/client/StoredProcedure/StoredProcedure.js +3 -0
  1174. package/dist/react-native/client/StoredProcedure/StoredProcedure.js.map +1 -1
  1175. package/dist/react-native/client/StoredProcedure/StoredProcedureResponse.js +4 -0
  1176. package/dist/react-native/client/StoredProcedure/StoredProcedureResponse.js.map +1 -1
  1177. package/dist/react-native/client/StoredProcedure/StoredProcedures.js +2 -0
  1178. package/dist/react-native/client/StoredProcedure/StoredProcedures.js.map +1 -1
  1179. package/dist/react-native/client/Trigger/Trigger.js +3 -0
  1180. package/dist/react-native/client/Trigger/Trigger.js.map +1 -1
  1181. package/dist/react-native/client/Trigger/TriggerResponse.js +2 -0
  1182. package/dist/react-native/client/Trigger/TriggerResponse.js.map +1 -1
  1183. package/dist/react-native/client/Trigger/Triggers.js +2 -0
  1184. package/dist/react-native/client/Trigger/Triggers.js.map +1 -1
  1185. package/dist/react-native/client/User/User.js +9 -0
  1186. package/dist/react-native/client/User/User.js.map +1 -1
  1187. package/dist/react-native/client/User/UserResponse.js +2 -0
  1188. package/dist/react-native/client/User/UserResponse.js.map +1 -1
  1189. package/dist/react-native/client/User/Users.js +2 -0
  1190. package/dist/react-native/client/User/Users.js.map +1 -1
  1191. package/dist/react-native/client/UserDefinedFunction/UserDefinedFunction.js +3 -0
  1192. package/dist/react-native/client/UserDefinedFunction/UserDefinedFunction.js.map +1 -1
  1193. package/dist/react-native/client/UserDefinedFunction/UserDefinedFunctionResponse.js +2 -0
  1194. package/dist/react-native/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map +1 -1
  1195. package/dist/react-native/client/UserDefinedFunction/UserDefinedFunctions.js +2 -0
  1196. package/dist/react-native/client/UserDefinedFunction/UserDefinedFunctions.js.map +1 -1
  1197. package/dist/react-native/common/constants.d.ts +4 -0
  1198. package/dist/react-native/common/constants.d.ts.map +1 -1
  1199. package/dist/react-native/common/constants.js +5 -1
  1200. package/dist/react-native/common/constants.js.map +1 -1
  1201. package/dist/react-native/common/helper.d.ts +6 -0
  1202. package/dist/react-native/common/helper.d.ts.map +1 -1
  1203. package/dist/react-native/common/helper.js +9 -1
  1204. package/dist/react-native/common/helper.js.map +1 -1
  1205. package/dist/react-native/common/platform.d.ts +1 -0
  1206. package/dist/react-native/common/platform.d.ts.map +1 -1
  1207. package/dist/react-native/common/platform.js +1 -3
  1208. package/dist/react-native/common/platform.js.map +1 -1
  1209. package/dist/react-native/diagnostics/CosmosDiagnosticsContext.js +8 -7
  1210. package/dist/react-native/diagnostics/CosmosDiagnosticsContext.js.map +1 -1
  1211. package/dist/react-native/diagnostics/DiagnosticNodeInternal.d.ts +1 -0
  1212. package/dist/react-native/diagnostics/DiagnosticNodeInternal.d.ts.map +1 -1
  1213. package/dist/react-native/diagnostics/DiagnosticNodeInternal.js +26 -7
  1214. package/dist/react-native/diagnostics/DiagnosticNodeInternal.js.map +1 -1
  1215. package/dist/react-native/diagnostics/DiagnosticWriter.js +1 -3
  1216. package/dist/react-native/diagnostics/DiagnosticWriter.js.map +1 -1
  1217. package/dist/react-native/diagnostics/index.js +2 -2
  1218. package/dist/react-native/diagnostics/index.js.map +1 -1
  1219. package/dist/react-native/documents/ConnectionPolicy.d.ts +10 -4
  1220. package/dist/react-native/documents/ConnectionPolicy.d.ts.map +1 -1
  1221. package/dist/react-native/documents/ConnectionPolicy.js +2 -2
  1222. package/dist/react-native/documents/ConnectionPolicy.js.map +1 -1
  1223. package/dist/react-native/documents/DatabaseAccount.d.ts +4 -0
  1224. package/dist/react-native/documents/DatabaseAccount.d.ts.map +1 -1
  1225. package/dist/react-native/documents/DatabaseAccount.js +29 -4
  1226. package/dist/react-native/documents/DatabaseAccount.js.map +1 -1
  1227. package/dist/react-native/documents/PartitionKey.js +1 -3
  1228. package/dist/react-native/documents/PartitionKey.js.map +1 -1
  1229. package/dist/react-native/encryption/AeadAes256CbcHmacSha256Algorithm/AeadAes256CbcHmacSha256Algorithm.js +8 -2
  1230. package/dist/react-native/encryption/AeadAes256CbcHmacSha256Algorithm/AeadAes256CbcHmacSha256Algorithm.js.map +1 -1
  1231. package/dist/react-native/encryption/Cache/ClientEncryptionKeyPropertiesCache.js +2 -0
  1232. package/dist/react-native/encryption/Cache/ClientEncryptionKeyPropertiesCache.js.map +1 -1
  1233. package/dist/react-native/encryption/Cache/EncryptionSettingsCache.js +2 -0
  1234. package/dist/react-native/encryption/Cache/EncryptionSettingsCache.js.map +1 -1
  1235. package/dist/react-native/encryption/Cache/KeyEncryptionKeyCache.js +2 -0
  1236. package/dist/react-native/encryption/Cache/KeyEncryptionKeyCache.js.map +1 -1
  1237. package/dist/react-native/encryption/Cache/ProtectedDataEncryptionKeyCache.js +5 -0
  1238. package/dist/react-native/encryption/Cache/ProtectedDataEncryptionKeyCache.js.map +1 -1
  1239. package/dist/react-native/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js +2 -0
  1240. package/dist/react-native/encryption/ClientEncryptionKey/ClientEncryptionKeyResponse.js.map +1 -1
  1241. package/dist/react-native/encryption/EncryptionItemQueryIterator.js +24 -27
  1242. package/dist/react-native/encryption/EncryptionItemQueryIterator.js.map +1 -1
  1243. package/dist/react-native/encryption/EncryptionKey/DataEncryptionKey.js +7 -2
  1244. package/dist/react-native/encryption/EncryptionKey/DataEncryptionKey.js.map +1 -1
  1245. package/dist/react-native/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts +0 -1
  1246. package/dist/react-native/encryption/EncryptionKey/ProtectedDataEncryptionKey.d.ts.map +1 -1
  1247. package/dist/react-native/encryption/EncryptionKey/ProtectedDataEncryptionKey.js +2 -0
  1248. package/dist/react-native/encryption/EncryptionKey/ProtectedDataEncryptionKey.js.map +1 -1
  1249. package/dist/react-native/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js +6 -5
  1250. package/dist/react-native/encryption/EncryptionKeyResolver/AzureKeyVaultEncryptionKeyResolver.js.map +1 -1
  1251. package/dist/react-native/encryption/EncryptionKeyStoreProvider.js +8 -1
  1252. package/dist/react-native/encryption/EncryptionKeyStoreProvider.js.map +1 -1
  1253. package/dist/react-native/encryption/EncryptionManager.js +6 -0
  1254. package/dist/react-native/encryption/EncryptionManager.js.map +1 -1
  1255. package/dist/react-native/encryption/EncryptionProcessor.js +5 -0
  1256. package/dist/react-native/encryption/EncryptionProcessor.js.map +1 -1
  1257. package/dist/react-native/encryption/EncryptionQueryBuilder.js +2 -0
  1258. package/dist/react-native/encryption/EncryptionQueryBuilder.js.map +1 -1
  1259. package/dist/react-native/encryption/EncryptionSettingForProperty.js +6 -0
  1260. package/dist/react-native/encryption/EncryptionSettingForProperty.js.map +1 -1
  1261. package/dist/react-native/encryption/EncryptionSettings.js +6 -3
  1262. package/dist/react-native/encryption/EncryptionSettings.js.map +1 -1
  1263. package/dist/react-native/encryption/KeyEncryptionKey.js +4 -0
  1264. package/dist/react-native/encryption/KeyEncryptionKey.js.map +1 -1
  1265. package/dist/react-native/encryption/Serializers/StringSerializer.js +1 -1
  1266. package/dist/react-native/encryption/Serializers/StringSerializer.js.map +1 -1
  1267. package/dist/react-native/extractPartitionKey.js +2 -2
  1268. package/dist/react-native/extractPartitionKey.js.map +1 -1
  1269. package/dist/react-native/globalEndpointManager.d.ts +8 -0
  1270. package/dist/react-native/globalEndpointManager.d.ts.map +1 -1
  1271. package/dist/react-native/globalEndpointManager.js +104 -29
  1272. package/dist/react-native/globalEndpointManager.js.map +1 -1
  1273. package/dist/react-native/globalPartitionEndpointManager.d.ts +0 -2
  1274. package/dist/react-native/globalPartitionEndpointManager.d.ts.map +1 -1
  1275. package/dist/react-native/globalPartitionEndpointManager.js +19 -7
  1276. package/dist/react-native/globalPartitionEndpointManager.js.map +1 -1
  1277. package/dist/react-native/queryExecutionContext/Aggregators/AverageAggregator.js +2 -0
  1278. package/dist/react-native/queryExecutionContext/Aggregators/AverageAggregator.js.map +1 -1
  1279. package/dist/react-native/queryExecutionContext/Aggregators/CountAggregator.js +1 -0
  1280. package/dist/react-native/queryExecutionContext/Aggregators/CountAggregator.js.map +1 -1
  1281. package/dist/react-native/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js +1 -0
  1282. package/dist/react-native/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js.map +1 -1
  1283. package/dist/react-native/queryExecutionContext/Aggregators/MakeListAggregator.js +1 -0
  1284. package/dist/react-native/queryExecutionContext/Aggregators/MakeListAggregator.js.map +1 -1
  1285. package/dist/react-native/queryExecutionContext/Aggregators/MakeSetAggregator.js +1 -0
  1286. package/dist/react-native/queryExecutionContext/Aggregators/MakeSetAggregator.js.map +1 -1
  1287. package/dist/react-native/queryExecutionContext/Aggregators/MaxAggregator.js +2 -0
  1288. package/dist/react-native/queryExecutionContext/Aggregators/MaxAggregator.js.map +1 -1
  1289. package/dist/react-native/queryExecutionContext/Aggregators/MinAggregator.js +2 -0
  1290. package/dist/react-native/queryExecutionContext/Aggregators/MinAggregator.js.map +1 -1
  1291. package/dist/react-native/queryExecutionContext/Aggregators/StaticValueAggregator.js +1 -0
  1292. package/dist/react-native/queryExecutionContext/Aggregators/StaticValueAggregator.js.map +1 -1
  1293. package/dist/react-native/queryExecutionContext/Aggregators/SumAggregator.js +1 -0
  1294. package/dist/react-native/queryExecutionContext/Aggregators/SumAggregator.js.map +1 -1
  1295. package/dist/react-native/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js +5 -3
  1296. package/dist/react-native/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map +1 -1
  1297. package/dist/react-native/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js +6 -3
  1298. package/dist/react-native/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map +1 -1
  1299. package/dist/react-native/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js +23 -7
  1300. package/dist/react-native/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map +1 -1
  1301. package/dist/react-native/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js +14 -6
  1302. package/dist/react-native/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map +1 -1
  1303. package/dist/react-native/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js +3 -0
  1304. package/dist/react-native/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map +1 -1
  1305. package/dist/react-native/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js +2 -0
  1306. package/dist/react-native/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map +1 -1
  1307. package/dist/react-native/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js +2 -0
  1308. package/dist/react-native/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map +1 -1
  1309. package/dist/react-native/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js +2 -0
  1310. package/dist/react-native/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map +1 -1
  1311. package/dist/react-native/queryExecutionContext/FetchResult.js +4 -0
  1312. package/dist/react-native/queryExecutionContext/FetchResult.js.map +1 -1
  1313. package/dist/react-native/queryExecutionContext/defaultQueryExecutionContext.js +14 -2
  1314. package/dist/react-native/queryExecutionContext/defaultQueryExecutionContext.js.map +1 -1
  1315. package/dist/react-native/queryExecutionContext/documentProducer.js +34 -21
  1316. package/dist/react-native/queryExecutionContext/documentProducer.js.map +1 -1
  1317. package/dist/react-native/queryExecutionContext/hybridQueryExecutionContext.js +41 -27
  1318. package/dist/react-native/queryExecutionContext/hybridQueryExecutionContext.js.map +1 -1
  1319. package/dist/react-native/queryExecutionContext/orderByComparator.js +1 -0
  1320. package/dist/react-native/queryExecutionContext/orderByComparator.js.map +1 -1
  1321. package/dist/react-native/queryExecutionContext/orderByDocumentProducerComparator.js +1 -0
  1322. package/dist/react-native/queryExecutionContext/orderByDocumentProducerComparator.js.map +1 -1
  1323. package/dist/react-native/queryExecutionContext/orderByQueryExecutionContext.js +1 -0
  1324. package/dist/react-native/queryExecutionContext/orderByQueryExecutionContext.js.map +1 -1
  1325. package/dist/react-native/queryExecutionContext/parallelQueryExecutionContextBase.js +20 -2
  1326. package/dist/react-native/queryExecutionContext/parallelQueryExecutionContextBase.js.map +1 -1
  1327. package/dist/react-native/queryExecutionContext/pipelinedQueryExecutionContext.js +14 -4
  1328. package/dist/react-native/queryExecutionContext/pipelinedQueryExecutionContext.js.map +1 -1
  1329. package/dist/react-native/queryIterator.js +41 -33
  1330. package/dist/react-native/queryIterator.js.map +1 -1
  1331. package/dist/react-native/queryMetrics/clientSideMetrics.js +2 -1
  1332. package/dist/react-native/queryMetrics/clientSideMetrics.js.map +1 -1
  1333. package/dist/react-native/queryMetrics/queryMetrics.js +14 -1
  1334. package/dist/react-native/queryMetrics/queryMetrics.js.map +1 -1
  1335. package/dist/react-native/queryMetrics/queryPreparationTime.js +5 -1
  1336. package/dist/react-native/queryMetrics/queryPreparationTime.js.map +1 -1
  1337. package/dist/react-native/queryMetrics/runtimeExecutionTimes.js +4 -1
  1338. package/dist/react-native/queryMetrics/runtimeExecutionTimes.js.map +1 -1
  1339. package/dist/react-native/queryMetrics/timeSpan.js +4 -3
  1340. package/dist/react-native/queryMetrics/timeSpan.js.map +1 -1
  1341. package/dist/react-native/request/ErrorResponse.js +19 -0
  1342. package/dist/react-native/request/ErrorResponse.js.map +1 -1
  1343. package/dist/react-native/request/FeedResponse.js +4 -0
  1344. package/dist/react-native/request/FeedResponse.js.map +1 -1
  1345. package/dist/react-native/request/RequestHandler.js +3 -4
  1346. package/dist/react-native/request/RequestHandler.js.map +1 -1
  1347. package/dist/react-native/request/ResourceResponse.js +5 -0
  1348. package/dist/react-native/request/ResourceResponse.js.map +1 -1
  1349. package/dist/react-native/request/SharedOptions.d.ts +5 -0
  1350. package/dist/react-native/request/SharedOptions.d.ts.map +1 -1
  1351. package/dist/react-native/request/SharedOptions.js.map +1 -1
  1352. package/dist/react-native/request/TimeoutError.js +1 -1
  1353. package/dist/react-native/request/TimeoutError.js.map +1 -1
  1354. package/dist/react-native/request/hybridSearchQueryResult.js +5 -0
  1355. package/dist/react-native/request/hybridSearchQueryResult.js.map +1 -1
  1356. package/dist/react-native/request/request.js +5 -1
  1357. package/dist/react-native/request/request.js.map +1 -1
  1358. package/dist/react-native/retry/bulkExecutionRetryPolicy.js +5 -2
  1359. package/dist/react-native/retry/bulkExecutionRetryPolicy.js.map +1 -1
  1360. package/dist/react-native/retry/defaultRetryPolicy.d.ts.map +1 -1
  1361. package/dist/react-native/retry/defaultRetryPolicy.js +7 -7
  1362. package/dist/react-native/retry/defaultRetryPolicy.js.map +1 -1
  1363. package/dist/react-native/retry/endpointDiscoveryRetryPolicy.d.ts +3 -2
  1364. package/dist/react-native/retry/endpointDiscoveryRetryPolicy.d.ts.map +1 -1
  1365. package/dist/react-native/retry/endpointDiscoveryRetryPolicy.js +24 -7
  1366. package/dist/react-native/retry/endpointDiscoveryRetryPolicy.js.map +1 -1
  1367. package/dist/react-native/retry/resourceThrottleRetryPolicy.js +20 -10
  1368. package/dist/react-native/retry/resourceThrottleRetryPolicy.js.map +1 -1
  1369. package/dist/react-native/retry/retryUtility.d.ts.map +1 -1
  1370. package/dist/react-native/retry/retryUtility.js +22 -8
  1371. package/dist/react-native/retry/retryUtility.js.map +1 -1
  1372. package/dist/react-native/retry/sessionRetryPolicy.js +8 -4
  1373. package/dist/react-native/retry/sessionRetryPolicy.js.map +1 -1
  1374. package/dist/react-native/retry/timeoutFailoverRetryPolicy.d.ts +1 -2
  1375. package/dist/react-native/retry/timeoutFailoverRetryPolicy.d.ts.map +1 -1
  1376. package/dist/react-native/retry/timeoutFailoverRetryPolicy.js +17 -7
  1377. package/dist/react-native/retry/timeoutFailoverRetryPolicy.js.map +1 -1
  1378. package/dist/react-native/routing/QueryRange.js +4 -0
  1379. package/dist/react-native/routing/QueryRange.js.map +1 -1
  1380. package/dist/react-native/routing/inMemoryCollectionRoutingMap.js +4 -0
  1381. package/dist/react-native/routing/inMemoryCollectionRoutingMap.js.map +1 -1
  1382. package/dist/react-native/routing/partitionKeyRangeCache.js +2 -0
  1383. package/dist/react-native/routing/partitionKeyRangeCache.js.map +1 -1
  1384. package/dist/react-native/routing/smartRoutingMapProvider.js +1 -0
  1385. package/dist/react-native/routing/smartRoutingMapProvider.js.map +1 -1
  1386. package/dist/react-native/session/VectorSessionToken.js +6 -2
  1387. package/dist/react-native/session/VectorSessionToken.js.map +1 -1
  1388. package/dist/react-native/session/sessionContainer.js +5 -3
  1389. package/dist/react-native/session/sessionContainer.js.map +1 -1
  1390. package/dist/react-native/utils/batch.js +15 -4
  1391. package/dist/react-native/utils/batch.js.map +1 -1
  1392. package/dist/react-native/utils/encode.d.ts +1 -1
  1393. package/dist/react-native/utils/encode.d.ts.map +1 -1
  1394. package/dist/react-native/utils/encode.js.map +1 -1
  1395. package/dist/react-native/utils/fixedSizePriorityQueue.js +4 -0
  1396. package/dist/react-native/utils/fixedSizePriorityQueue.js.map +1 -1
  1397. package/dist/react-native/utils/hashing/hash.js +1 -1
  1398. package/dist/react-native/utils/hashing/hash.js.map +1 -1
  1399. package/dist/react-native/utils/nonStreamingOrderByMap.js +2 -0
  1400. package/dist/react-native/utils/nonStreamingOrderByMap.js.map +1 -1
  1401. package/package.json +33 -33
@@ -1 +1 @@
1
- {"version":3,"file":"globalEndpointManager.js","sourceRoot":"","sources":["../../src/globalEndpointManager.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAI/E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAsBhC;;;OAGG;IACH,YACE,OAA4B,EACpB,mBAGuC;QAHvC,wBAAmB,GAAnB,mBAAmB,CAGoB;QAhBzC,uBAAkB,GAAe,EAAE,CAAC;QACpC,sBAAiB,GAAe,EAAE,CAAC;QACnC,iCAA4B,GAAe,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gBAClB,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACK,MAAM,CAAC,qBAAqB,CAAC,eAAuB,EAAE,YAAoB;QAChF,sGAAsG;QACtG,sFAAsF;QACtF,iCAAiC;QACjC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC;QAE7C,8EAA8E;QAC9E,IAAI,WAAW,CAAC,QAAQ,EAAE,CAAC;YACzB,MAAM,aAAa,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC/E,IAAI,aAAa,EAAE,CAAC;gBAClB,kDAAkD;gBAClD,MAAM,yBAAyB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;gBAEnD,0FAA0F;gBAC1F,MAAM,6BAA6B,GACjC,yBAAyB,GAAG,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;gBAElE,8CAA8C;gBAC9C,+EAA+E;gBAC/E,MAAM,kBAAkB,GAAG,eAAe;qBACvC,WAAW,EAAE;qBACb,OAAO,CAAC,yBAAyB,EAAE,6BAA6B,CAAC,CAAC;gBACrE,OAAO,kBAAkB,CAAC;YAC5B,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OperationType, ResourceType, isReadRequest } from \"./common/index.js\";\nimport type { CosmosClientOptions } from \"./CosmosClientOptions.js\";\nimport type { Location, DatabaseAccount } from \"./documents/index.js\";\nimport type { RequestOptions } from \"./index.js\";\nimport { Constants } from \"./common/constants.js\";\nimport type { ResourceResponse } from \"./request/index.js\";\nimport { MetadataLookUpType } from \"./CosmosDiagnostics.js\";\nimport type { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal.js\";\nimport { withMetadataDiagnostics } from \"./utils/diagnostics.js\";\nimport { normalizeEndpoint } from \"./utils/checkURL.js\";\n\n/**\n * @hidden\n * This internal class implements the logic for endpoint management for geo-replicated database accounts.\n */\nexport class GlobalEndpointManager {\n /**\n * The endpoint used to create the client instance.\n */\n private defaultEndpoint: string;\n /**\n * Flag to enable/disable automatic redirecting of requests based on read/write operations.\n */\n public enableEndpointDiscovery: boolean;\n private isRefreshing: boolean;\n private options: CosmosClientOptions;\n /**\n * List of azure regions to be used as preferred locations for read requests.\n */\n private preferredLocations: string[];\n private writeableLocations: Location[] = [];\n private readableLocations: Location[] = [];\n private unavailableReadableLocations: Location[] = [];\n private unavailableWriteableLocations: Location[] = [];\n private enableMultipleWriteLocations: boolean;\n\n public preferredLocationsCount: number;\n /**\n * @param options - The document client instance.\n * @internal\n */\n constructor(\n options: CosmosClientOptions,\n private readDatabaseAccount: (\n diagnosticNode: DiagnosticNodeInternal,\n opts: RequestOptions,\n ) => Promise<ResourceResponse<DatabaseAccount>>,\n ) {\n this.options = options;\n this.defaultEndpoint = options.endpoint;\n this.enableEndpointDiscovery = options.connectionPolicy.enableEndpointDiscovery;\n this.isRefreshing = false;\n this.preferredLocations = this.options.connectionPolicy.preferredLocations;\n this.preferredLocationsCount = this.preferredLocations ? this.preferredLocations.length : 0;\n }\n\n /**\n * Gets the current read endpoint from the endpoint cache.\n */\n public async getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string> {\n return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Read);\n }\n\n /**\n * Gets the current write endpoint from the endpoint cache.\n */\n public async getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string> {\n return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Replace);\n }\n\n public async getReadEndpoints(): Promise<ReadonlyArray<string>> {\n return this.readableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n public async getWriteEndpoints(): Promise<ReadonlyArray<string>> {\n return this.writeableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n /**\n * Gets the read locations from the endpoint cache.\n */\n public async getReadLocations(): Promise<ReadonlyArray<Location>> {\n return this.readableLocations;\n }\n\n public async markCurrentLocationUnavailableForRead(\n diagnosticNode: DiagnosticNodeInternal,\n endpoint: string,\n ): Promise<void> {\n await this.refreshEndpointList(diagnosticNode);\n const location = this.readableLocations.find((loc) => loc.databaseAccountEndpoint === endpoint);\n if (location) {\n location.unavailable = true;\n location.lastUnavailabilityTimestampInMs = Date.now();\n this.unavailableReadableLocations.push(location);\n }\n }\n\n public async markCurrentLocationUnavailableForWrite(\n diagnosticNode: DiagnosticNodeInternal,\n endpoint: string,\n ): Promise<void> {\n await this.refreshEndpointList(diagnosticNode);\n const location = this.writeableLocations.find(\n (loc) => loc.databaseAccountEndpoint === endpoint,\n );\n if (location) {\n location.unavailable = true;\n location.lastUnavailabilityTimestampInMs = Date.now();\n this.unavailableWriteableLocations.push(location);\n }\n }\n\n public canUseMultipleWriteLocations(\n resourceType?: ResourceType,\n operationType?: OperationType,\n ): boolean {\n let canUse =\n this.options.connectionPolicy.useMultipleWriteLocations && this.enableMultipleWriteLocations;\n\n if (resourceType) {\n canUse =\n canUse &&\n (resourceType === ResourceType.item ||\n (resourceType === ResourceType.sproc && operationType === OperationType.Execute));\n }\n\n return canUse;\n }\n\n public async resolveServiceEndpoint(\n diagnosticNode: DiagnosticNodeInternal,\n resourceType: ResourceType,\n operationType: OperationType,\n startServiceEndpointIndex: number = 0, // Represents the starting index for selecting servers.\n ): Promise<string> {\n // If endpoint discovery is disabled, always use the user provided endpoint\n\n if (!this.options.connectionPolicy.enableEndpointDiscovery) {\n diagnosticNode.addData({ readFromCache: true }, \"default_endpoint\");\n diagnosticNode.recordEndpointResolution(this.defaultEndpoint);\n return this.defaultEndpoint;\n }\n\n // If getting the database account, always use the user provided endpoint\n if (resourceType === ResourceType.none) {\n diagnosticNode.addData({ readFromCache: true }, \"none_resource\");\n diagnosticNode.recordEndpointResolution(this.defaultEndpoint);\n return this.defaultEndpoint;\n }\n\n if (this.readableLocations.length === 0 || this.writeableLocations.length === 0) {\n const resourceResponse = await withMetadataDiagnostics(\n async (metadataNode: DiagnosticNodeInternal) => {\n return this.readDatabaseAccount(metadataNode, {\n urlConnection: this.defaultEndpoint,\n });\n },\n diagnosticNode,\n MetadataLookUpType.DatabaseAccountLookUp,\n );\n\n this.writeableLocations = resourceResponse.resource.writableLocations;\n this.readableLocations = resourceResponse.resource.readableLocations;\n this.enableMultipleWriteLocations = resourceResponse.resource.enableMultipleWritableLocations;\n }\n\n const locations = isReadRequest(operationType)\n ? this.readableLocations\n : this.writeableLocations;\n\n let location;\n // If we have preferred locations, try each one in order and use the first available one\n if (\n this.preferredLocations &&\n this.preferredLocations.length > 0 &&\n startServiceEndpointIndex < this.preferredLocations.length\n ) {\n for (let i = startServiceEndpointIndex; i < this.preferredLocations.length; i++) {\n const preferredLocation = this.preferredLocations[i];\n location = locations.find(\n (loc) =>\n loc.unavailable !== true &&\n normalizeEndpoint(loc.name) === normalizeEndpoint(preferredLocation),\n );\n if (location) {\n break;\n }\n }\n }\n\n // If no preferred locations or one did not match, just grab the first one that is available\n if (!location) {\n const startIndexValid =\n startServiceEndpointIndex >= 0 && startServiceEndpointIndex < locations.length;\n const locationsToSearch = startIndexValid\n ? locations.slice(startServiceEndpointIndex)\n : locations;\n location = locationsToSearch.find((loc) => {\n return loc.unavailable !== true;\n });\n }\n\n location = location ? location : { name: \"\", databaseAccountEndpoint: this.defaultEndpoint };\n diagnosticNode.recordEndpointResolution(location.databaseAccountEndpoint);\n return location.databaseAccountEndpoint;\n }\n\n /**\n * Refreshes the endpoint list by clearning stale unavailability and then\n * retrieving the writable and readable locations from the geo-replicated database account\n * and then updating the locations cache.\n * We skip the refreshing if enableEndpointDiscovery is set to False\n */\n public async refreshEndpointList(diagnosticNode: DiagnosticNodeInternal): Promise<void> {\n if (!this.isRefreshing && this.enableEndpointDiscovery) {\n this.isRefreshing = true;\n const databaseAccount = await this.getDatabaseAccountFromAnyEndpoint(diagnosticNode);\n if (databaseAccount) {\n this.refreshStaleUnavailableLocations();\n this.refreshEndpoints(databaseAccount);\n }\n this.isRefreshing = false;\n }\n }\n\n private refreshEndpoints(databaseAccount: DatabaseAccount): void {\n for (const location of databaseAccount.writableLocations) {\n const existingLocation = this.writeableLocations.find((loc) => loc.name === location.name);\n if (!existingLocation) {\n this.writeableLocations.push(location);\n }\n }\n for (const location of databaseAccount.readableLocations) {\n const existingLocation = this.readableLocations.find((loc) => loc.name === location.name);\n if (!existingLocation) {\n this.readableLocations.push(location);\n }\n }\n }\n\n private refreshStaleUnavailableLocations(): void {\n const now = Date.now();\n this.updateLocation(now, this.unavailableReadableLocations, this.readableLocations);\n this.unavailableReadableLocations = this.cleanUnavailableLocationList(\n now,\n this.unavailableReadableLocations,\n );\n\n this.updateLocation(now, this.unavailableWriteableLocations, this.writeableLocations);\n this.unavailableWriteableLocations = this.cleanUnavailableLocationList(\n now,\n this.unavailableWriteableLocations,\n );\n }\n\n /**\n * update the locationUnavailability to undefined if the location is available again\n * @param now - current time\n * @param unavailableLocations - list of unavailable locations\n * @param allLocations - list of all locations\n */\n private updateLocation(\n now: number,\n unavailableLocations: Location[],\n allLocations: Location[],\n ): void {\n for (const location of unavailableLocations) {\n const unavaialableLocation = allLocations.find((loc) => loc.name === location.name);\n if (\n unavaialableLocation &&\n now - unavaialableLocation.lastUnavailabilityTimestampInMs >\n Constants.LocationUnavailableExpirationTimeInMs\n ) {\n unavaialableLocation.unavailable = false;\n }\n }\n }\n\n private cleanUnavailableLocationList(now: number, unavailableLocations: Location[]): Location[] {\n return unavailableLocations.filter((loc) => {\n if (\n loc &&\n now - loc.lastUnavailabilityTimestampInMs >= Constants.LocationUnavailableExpirationTimeInMs\n ) {\n return false;\n }\n return true;\n });\n }\n\n /**\n * Gets the database account first by using the default endpoint, and if that doesn't returns\n * use the endpoints for the preferred locations in the order they are specified to get\n * the database account.\n */\n private async getDatabaseAccountFromAnyEndpoint(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<DatabaseAccount> {\n try {\n const options = { urlConnection: this.defaultEndpoint };\n const { resource: databaseAccount } = await this.readDatabaseAccount(diagnosticNode, options);\n return databaseAccount;\n // If for any reason(non - globaldb related), we are not able to get the database\n // account from the above call to readDatabaseAccount,\n // we would try to get this information from any of the preferred locations that the user\n // might have specified (by creating a locational endpoint)\n // and keeping eating the exception until we get the database account and return None at the end,\n // if we are not able to get that info from any endpoints\n } catch (err: any) {\n // TODO: Tracing\n }\n\n if (this.preferredLocations) {\n for (const location of this.preferredLocations) {\n try {\n const locationalEndpoint = GlobalEndpointManager.getLocationalEndpoint(\n this.defaultEndpoint,\n location,\n );\n const options = { urlConnection: locationalEndpoint };\n const { resource: databaseAccount } = await this.readDatabaseAccount(\n diagnosticNode,\n options,\n );\n if (databaseAccount) {\n return databaseAccount;\n }\n } catch (err: any) {\n // TODO: Tracing\n }\n }\n }\n }\n\n /**\n * Gets the locational endpoint using the location name passed to it using the default endpoint.\n *\n * @param defaultEndpoint - The default endpoint to use for the endpoint.\n * @param locationName - The location name for the azure region like \"East US\".\n */\n private static getLocationalEndpoint(defaultEndpoint: string, locationName: string): string {\n // For defaultEndpoint like 'https://contoso.documents.azure.com:443/' parse it to generate URL format\n // This defaultEndpoint should be global endpoint(and cannot be a locational endpoint)\n // and we agreed to document that\n const endpointUrl = new URL(defaultEndpoint);\n\n // hostname attribute in endpointUrl will return 'contoso.documents.azure.com'\n if (endpointUrl.hostname) {\n const hostnameParts = endpointUrl.hostname.toString().toLowerCase().split(\".\");\n if (hostnameParts) {\n // globalDatabaseAccountName will return 'contoso'\n const globalDatabaseAccountName = hostnameParts[0];\n\n // Prepare the locationalDatabaseAccountName as contoso-EastUS for location_name 'East US'\n const locationalDatabaseAccountName =\n globalDatabaseAccountName + \"-\" + locationName.replace(\" \", \"\");\n\n // Replace 'contoso' with 'contoso-EastUS' and\n // return locationalEndpoint as https://contoso-EastUS.documents.azure.com:443/\n const locationalEndpoint = defaultEndpoint\n .toLowerCase()\n .replace(globalDatabaseAccountName, locationalDatabaseAccountName);\n return locationalEndpoint;\n }\n }\n\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"globalEndpointManager.js","sourceRoot":"","sources":["../../src/globalEndpointManager.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAK/E,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAE/D;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAuCtB;IAtCV;;OAEG;IACK,eAAe,CAAS;IAChC;;OAEG;IACI,uBAAuB,CAAU;IAChC,YAAY,CAAU;IACtB,OAAO,CAAsB;IACrC;;OAEG;IACK,kBAAkB,CAAW;IAC7B,kBAAkB,GAAe,EAAE,CAAC;IACpC,iBAAiB,GAAe,EAAE,CAAC;IACnC,4BAA4B,GAAe,EAAE,CAAC;IAC9C,6BAA6B,GAAe,EAAE,CAAC;IAC/C,4BAA4B,CAAU;IAEvC,uBAAuB,CAAS;IACvC;;;OAGG;IACI,4BAA4B,CAAU;IAC7C;;;OAGG;IACI,kCAAkC,CAAU;IAEnD;;;OAGG;IACH,YACE,OAA4B,EACpB,mBAGuC;QAHvC,wBAAmB,GAAnB,mBAAmB,CAGoB;QAE/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,uBAAuB,CAAC;QAChF,IA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IACK,sBAAsB,CAAC,0BAAmC;QAChE,uFAAuF;QACvF,gCAAgC;QAChC,IAAI,0BAA0B,KAAK,KAAK,EAAE,CAAC;YACzC,IAAI,CAAC,4BAA4B,GAAG,0BAA0B,CAAC;YAC/D,IAAI,CAAC,kCAAkC,GAAG,0BAA0B,CAAC;QACvE,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OperationType, ResourceType, isReadRequest } from \"./common/index.js\";\nimport type { CosmosClientOptions } from \"./CosmosClientOptions.js\";\nimport type { Location, DatabaseAccount } from \"./documents/index.js\";\nimport type { RequestOptions } from \"./index.js\";\nimport type { ResolveServiceEndpointOptions } from \"./GlobalEndpointManagerOptions.js\";\nimport { Constants } from \"./common/constants.js\";\nimport type { ResourceResponse } from \"./request/index.js\";\nimport { MetadataLookUpType } from \"./CosmosDiagnostics.js\";\nimport type { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal.js\";\nimport { withMetadataDiagnostics } from \"./utils/diagnostics.js\";\nimport { normalizeEndpoint } from \"./utils/checkURL.js\";\nimport { canApplyExcludedLocations } from \"./common/helper.js\";\n\n/**\n * @hidden\n * This internal class implements the logic for endpoint management for geo-replicated database accounts.\n */\nexport class GlobalEndpointManager {\n /**\n * The endpoint used to create the client instance.\n */\n private defaultEndpoint: string;\n /**\n * Flag to enable/disable automatic redirecting of requests based on read/write operations.\n */\n public enableEndpointDiscovery: boolean;\n private isRefreshing: boolean;\n private options: CosmosClientOptions;\n /**\n * List of azure regions to be used as preferred locations for read requests.\n */\n private preferredLocations: string[];\n private writeableLocations: Location[] = [];\n private readableLocations: Location[] = [];\n private unavailableReadableLocations: Location[] = [];\n private unavailableWriteableLocations: Location[] = [];\n private enableMultipleWriteLocations: boolean;\n\n public preferredLocationsCount: number;\n /**\n * Flag to enable/disable the Per Partition Level Failover (PPAF)\n * @internal\n */\n public enablePartitionLevelFailover: boolean;\n /**\n * Flag to enable/disable the Per Partition Level Circuit Breaker (PPCB)\n * @internal\n */\n public enablePartitionLevelCircuitBreaker: boolean;\n\n /**\n * @param options - The document client instance.\n * @internal\n */\n constructor(\n options: CosmosClientOptions,\n private readDatabaseAccount: (\n diagnosticNode: DiagnosticNodeInternal,\n opts: RequestOptions,\n ) => Promise<ResourceResponse<DatabaseAccount>>,\n ) {\n this.options = options;\n this.defaultEndpoint = options.endpoint;\n this.enableEndpointDiscovery = options.connectionPolicy.enableEndpointDiscovery;\n this.isRefreshing = false;\n this.preferredLocations = this.options.connectionPolicy.preferredLocations;\n this.preferredLocationsCount = this.preferredLocations ? this.preferredLocations.length : 0;\n this.enablePartitionLevelFailover = options.connectionPolicy.enablePartitionLevelFailover;\n this.enablePartitionLevelCircuitBreaker =\n options.connectionPolicy.enablePartitionLevelCircuitBreaker ||\n options.connectionPolicy.enablePartitionLevelFailover;\n }\n\n /**\n * Gets the current read endpoint from the endpoint cache.\n */\n public async getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string> {\n return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Read);\n }\n\n /**\n * Gets the current write endpoint from the endpoint cache.\n */\n public async getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise<string> {\n return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Replace);\n }\n\n public async getReadEndpoints(): Promise<ReadonlyArray<string>> {\n return this.readableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n public async getWriteEndpoints(): Promise<ReadonlyArray<string>> {\n return this.writeableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n /**\n * Gets the read locations from the endpoint cache.\n */\n public async getReadLocations(): Promise<ReadonlyArray<Location>> {\n return this.readableLocations;\n }\n\n public async markCurrentLocationUnavailableForRead(\n diagnosticNode: DiagnosticNodeInternal,\n endpoint: string,\n ): Promise<void> {\n await this.refreshEndpointList(diagnosticNode);\n const location = this.readableLocations.find((loc) => loc.databaseAccountEndpoint === endpoint);\n if (location) {\n location.unavailable = true;\n location.lastUnavailabilityTimestampInMs = Date.now();\n this.unavailableReadableLocations.push(location);\n }\n }\n\n public async markCurrentLocationUnavailableForWrite(\n diagnosticNode: DiagnosticNodeInternal,\n endpoint: string,\n ): Promise<void> {\n await this.refreshEndpointList(diagnosticNode);\n const location = this.writeableLocations.find(\n (loc) => loc.databaseAccountEndpoint === endpoint,\n );\n if (location) {\n location.unavailable = true;\n location.lastUnavailabilityTimestampInMs = Date.now();\n this.unavailableWriteableLocations.push(location);\n }\n }\n\n public canUseMultipleWriteLocations(\n resourceType?: ResourceType,\n operationType?: OperationType,\n ): boolean {\n let canUse =\n this.options.connectionPolicy.useMultipleWriteLocations && this.enableMultipleWriteLocations;\n\n if (resourceType) {\n canUse =\n canUse &&\n (resourceType === ResourceType.item ||\n (resourceType === ResourceType.sproc && operationType === OperationType.Execute));\n }\n\n return canUse;\n }\n\n private getEffectiveExcludedLocations(\n excludedLocations: string[] = [],\n resourceType: ResourceType,\n ): Set<string> {\n if (!canApplyExcludedLocations(resourceType)) {\n return new Set();\n }\n\n return excludedLocations.length ? new Set(excludedLocations.map(normalizeEndpoint)) : new Set();\n }\n\n private filterExcludedLocations(\n preferredLocations: string[],\n excludedLocations?: Set<string>,\n ): string[] {\n if (!excludedLocations || excludedLocations.size === 0) {\n return preferredLocations;\n }\n const filteredLocations = preferredLocations.filter((location) => {\n return !excludedLocations.has(normalizeEndpoint(location));\n });\n return filteredLocations;\n }\n\n public async resolveServiceEndpoint(\n diagnosticNode: DiagnosticNodeInternal,\n resourceType: ResourceType,\n operationType: OperationType,\n startServiceEndpointIndex: number = 0, // Represents the starting index for selecting servers.\n ): Promise<string> {\n return this.resolveServiceEndpointInternal({\n diagnosticNode: diagnosticNode,\n resourceType: resourceType,\n operationType: operationType,\n startServiceEndpointIndex: startServiceEndpointIndex,\n });\n }\n\n /**\n * @internal\n */\n public async resolveServiceEndpointInternal(\n resolveServiceEndpointOptions: ResolveServiceEndpointOptions,\n ): Promise<string> {\n // Extract all fields from ResolveServiceEndpointOptions\n const {\n diagnosticNode,\n resourceType,\n operationType,\n startServiceEndpointIndex,\n excludedLocations = [],\n } = resolveServiceEndpointOptions;\n\n // If endpoint discovery is disabled, always use the user provided endpoint\n\n if (!this.options.connectionPolicy.enableEndpointDiscovery) {\n diagnosticNode.addData({ readFromCache: true }, \"default_endpoint\");\n diagnosticNode.recordEndpointResolution(this.defaultEndpoint);\n return this.defaultEndpoint;\n }\n\n // If getting the database account, always use the user provided endpoint\n if (resourceType === ResourceType.none) {\n diagnosticNode.addData({ readFromCache: true }, \"none_resource\");\n diagnosticNode.recordEndpointResolution(this.defaultEndpoint);\n return this.defaultEndpoint;\n }\n if (this.readableLocations.length === 0 || this.writeableLocations.length === 0) {\n const resourceResponse = await withMetadataDiagnostics(\n async (metadataNode: DiagnosticNodeInternal) => {\n return this.readDatabaseAccount(metadataNode, {\n urlConnection: this.defaultEndpoint,\n });\n },\n diagnosticNode,\n MetadataLookUpType.DatabaseAccountLookUp,\n );\n\n this.writeableLocations = resourceResponse.resource.writableLocations;\n this.readableLocations = resourceResponse.resource.readableLocations;\n this.enableMultipleWriteLocations = resourceResponse.resource.enableMultipleWritableLocations;\n this.refreshPPAFFeatureFlag(resourceResponse.resource.enablePerPartitionFailover);\n }\n\n const locations = isReadRequest(operationType)\n ? this.readableLocations\n : this.writeableLocations;\n\n const effectiveExcludedLocations = this.getEffectiveExcludedLocations(\n excludedLocations,\n resourceType,\n );\n diagnosticNode.addData(\n { excludedLocations: Array.from(effectiveExcludedLocations) },\n \"excluded_locations\",\n );\n\n // Filter locations based on exclusions\n const availableLocations = this.filterExcludedLocations(\n this.preferredLocations,\n effectiveExcludedLocations,\n );\n\n let location;\n // If we have preferred locations, try each one in order and use the first available one\n if (\n availableLocations &&\n availableLocations.length > 0 &&\n startServiceEndpointIndex < availableLocations.length\n ) {\n this.preferredLocationsCount = availableLocations.length;\n\n for (let i = startServiceEndpointIndex; i < availableLocations.length; i++) {\n const preferredLocation = availableLocations[i];\n location = locations.find(\n (loc) =>\n loc.unavailable !== true &&\n normalizeEndpoint(loc.name) === normalizeEndpoint(preferredLocation),\n );\n if (location) {\n break;\n }\n }\n }\n\n // If no preferred locations or one did not match, just grab the first one that is available\n if (!location) {\n const startIndexValid =\n startServiceEndpointIndex >= 0 && startServiceEndpointIndex < locations.length;\n const locationsToSearch = startIndexValid\n ? locations.slice(startServiceEndpointIndex)\n : locations;\n location = locationsToSearch.find((loc) => {\n return (\n loc.unavailable !== true && !effectiveExcludedLocations.has(normalizeEndpoint(loc.name))\n );\n });\n }\n\n location = location ? location : { name: \"\", databaseAccountEndpoint: this.defaultEndpoint };\n diagnosticNode.recordEndpointResolution(location.databaseAccountEndpoint);\n return location.databaseAccountEndpoint;\n }\n\n /**\n * Refreshes the endpoint list by clearning stale unavailability and then\n * retrieving the writable and readable locations from the geo-replicated database account\n * and then updating the locations cache.\n * We skip the refreshing if enableEndpointDiscovery is set to False\n */\n public async refreshEndpointList(diagnosticNode: DiagnosticNodeInternal): Promise<void> {\n if (!this.isRefreshing && this.enableEndpointDiscovery) {\n this.isRefreshing = true;\n const databaseAccount = await this.getDatabaseAccountFromAnyEndpoint(diagnosticNode);\n if (databaseAccount) {\n this.refreshStaleUnavailableLocations();\n this.refreshEndpoints(databaseAccount);\n }\n this.isRefreshing = false;\n }\n }\n\n private refreshEndpoints(databaseAccount: DatabaseAccount): void {\n const oldWritableLocations = this.writeableLocations;\n const oldReadableLocations = this.readableLocations;\n\n function merge(loc: Location, oldList: Location[]): Location {\n const prev = oldList.find((o) => o.name === loc.name);\n if (prev) {\n loc.unavailable = prev.unavailable;\n loc.lastUnavailabilityTimestampInMs = prev.lastUnavailabilityTimestampInMs;\n }\n return loc;\n }\n\n this.writeableLocations = databaseAccount.writableLocations.map((loc) =>\n merge({ ...loc }, oldWritableLocations),\n );\n this.readableLocations = databaseAccount.readableLocations.map((loc) =>\n merge({ ...loc }, oldReadableLocations),\n );\n }\n\n private refreshStaleUnavailableLocations(): void {\n const now = Date.now();\n this.updateLocation(now, this.unavailableReadableLocations, this.readableLocations);\n this.unavailableReadableLocations = this.cleanUnavailableLocationList(\n now,\n this.unavailableReadableLocations,\n );\n\n this.updateLocation(now, this.unavailableWriteableLocations, this.writeableLocations);\n this.unavailableWriteableLocations = this.cleanUnavailableLocationList(\n now,\n this.unavailableWriteableLocations,\n );\n }\n\n /**\n * update the locationUnavailability to undefined if the location is available again\n * @param now - current time\n * @param unavailableLocations - list of unavailable locations\n * @param allLocations - list of all locations\n */\n private updateLocation(\n now: number,\n unavailableLocations: Location[],\n allLocations: Location[],\n ): void {\n for (const location of unavailableLocations) {\n const unavailableLocation = allLocations.find((loc) => loc.name === location.name);\n if (\n unavailableLocation &&\n now - unavailableLocation.lastUnavailabilityTimestampInMs >\n Constants.LocationUnavailableExpirationTimeInMs\n ) {\n unavailableLocation.unavailable = false;\n }\n }\n }\n\n private cleanUnavailableLocationList(now: number, unavailableLocations: Location[]): Location[] {\n return unavailableLocations.filter((loc) => {\n return (\n now - loc.lastUnavailabilityTimestampInMs < Constants.LocationUnavailableExpirationTimeInMs\n );\n });\n }\n\n /**\n * Gets the database account first by using the default endpoint, and if that doesn't returns\n * use the endpoints for the preferred locations in the order they are specified to get\n * the database account.\n */\n private async getDatabaseAccountFromAnyEndpoint(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<DatabaseAccount> {\n try {\n const options = { urlConnection: this.defaultEndpoint };\n const { resource: databaseAccount } = await this.readDatabaseAccount(diagnosticNode, options);\n return databaseAccount;\n // If for any reason(non - globaldb related), we are not able to get the database\n // account from the above call to readDatabaseAccount,\n // we would try to get this information from any of the preferred locations that the user\n // might have specified (by creating a locational endpoint)\n // and keeping eating the exception until we get the database account and return None at the end,\n // if we are not able to get that info from any endpoints\n } catch (err: any) {\n // TODO: Tracing\n }\n\n if (this.preferredLocations) {\n for (const location of this.preferredLocations) {\n try {\n const locationalEndpoint = GlobalEndpointManager.getLocationalEndpoint(\n this.defaultEndpoint,\n location,\n );\n const options = { urlConnection: locationalEndpoint };\n const { resource: databaseAccount } = await this.readDatabaseAccount(\n diagnosticNode,\n options,\n );\n if (databaseAccount) {\n return databaseAccount;\n }\n } catch (err: any) {\n // TODO: Tracing\n }\n }\n }\n }\n\n /**\n * Gets the locational endpoint using the location name passed to it using the default endpoint.\n *\n * @param defaultEndpoint - The default endpoint to use for the endpoint.\n * @param locationName - The location name for the azure region like \"East US\".\n */\n private static getLocationalEndpoint(defaultEndpoint: string, locationName: string): string {\n // For defaultEndpoint like 'https://contoso.documents.azure.com:443/' parse it to generate URL format\n // This defaultEndpoint should be global endpoint(and cannot be a locational endpoint)\n // and we agreed to document that\n const endpointUrl = new URL(defaultEndpoint);\n\n // hostname attribute in endpointUrl will return 'contoso.documents.azure.com'\n if (endpointUrl.hostname) {\n const hostnameParts = endpointUrl.hostname.toString().toLowerCase().split(\".\");\n if (hostnameParts) {\n // globalDatabaseAccountName will return 'contoso'\n const globalDatabaseAccountName = hostnameParts[0];\n\n // Prepare the locationalDatabaseAccountName as contoso-EastUS for location_name 'East US'\n const locationalDatabaseAccountName =\n globalDatabaseAccountName + \"-\" + locationName.replace(\" \", \"\");\n\n // Replace 'contoso' with 'contoso-EastUS' and\n // return locationalEndpoint as https://contoso-EastUS.documents.azure.com:443/\n const locationalEndpoint = defaultEndpoint\n .toLowerCase()\n .replace(globalDatabaseAccountName, locationalDatabaseAccountName);\n return locationalEndpoint;\n }\n }\n\n return null;\n }\n\n /**\n * Refreshes the enablePartitionLevelFailover and enablePartitionLevelCircuitBreaker flag\n * based on the value from database account.\n * @param enablePerPartitionFailover - value from database account\n */\n private refreshPPAFFeatureFlag(enablePerPartitionFailover: boolean): void {\n // If the enablePartitionLevelFailover is true, but PPAF is not enabled on the account,\n // we will override it to false.\n if (enablePerPartitionFailover === false) {\n this.enablePartitionLevelFailover = enablePerPartitionFailover;\n this.enablePartitionLevelCircuitBreaker = enablePerPartitionFailover;\n }\n }\n}\n"]}
@@ -7,8 +7,6 @@ export declare class GlobalPartitionEndpointManager {
7
7
  private globalEndpointManager;
8
8
  private readonly partitionKeyRangeToLocationForWrite;
9
9
  private readonly partitionKeyRangeToLocationForReadAndWrite;
10
- private enablePartitionLevelFailover;
11
- private enablePartitionLevelCircuitBreaker;
12
10
  private preferredLocations;
13
11
  preferredLocationsCount: number;
14
12
  private circuitBreakerFailbackBackgroundRefresher;
@@ -1 +1 @@
1
- {"version":3,"file":"globalPartitionEndpointManager.d.ts","sourceRoot":"","sources":["../../src/globalPartitionEndpointManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,sBAAsB,EAGtB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAMpB;;;GAGG;AACH,qBAAa,8BAA8B;IAiBvC,OAAO,CAAC,qBAAqB;IAhB/B,OAAO,CAAC,QAAQ,CAAC,mCAAmC,CAA6C;IACjG,OAAO,CAAC,QAAQ,CAAC,0CAA0C,CAGzD;IACF,OAAO,CAAC,4BAA4B,CAAU;IAC9C,OAAO,CAAC,kCAAkC,CAAU;IACpD,OAAO,CAAC,kBAAkB,CAAW;IAC9B,uBAAuB,EAAE,MAAM,CAAC;IACvC,OAAO,CAAC,yCAAyC,CAAiB;IA2BlE;;;;OAIG;IACU,yBAAyB,CACpC,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,OAAO,CAAC;IA6BnB;;;OAGG;IACU,oCAAoC,CAC/C,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,cAAc,CAAC;IAiC1B;;;OAGG;IACI,OAAO,IAAI,IAAI;YAMR,8CAA8C;IA2D5D;;;OAGG;YACW,uCAAuC;IA6CrD,yEAAyE;YAC3D,qCAAqC;IA2BnD,0FAA0F;YAC5E,qCAAqC;IAmBnD;;;;OAIG;IACH,OAAO,CAAC,iDAAiD;IAazD;;;;OAIG;IACH,OAAO,CAAC,gDAAgD;IAexD;;;;;;OAMG;YACW,wDAAwD;IA8BtE;;;;;;;;OAQG;IACH,OAAO,CAAC,kCAAkC;IAU1C;;;;;OAKG;YACW,8CAA8C;CAmB7D"}
1
+ {"version":3,"file":"globalPartitionEndpointManager.d.ts","sourceRoot":"","sources":["../../src/globalPartitionEndpointManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,sBAAsB,EAGtB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAMpB;;;GAGG;AACH,qBAAa,8BAA8B;IAevC,OAAO,CAAC,qBAAqB;IAd/B,OAAO,CAAC,QAAQ,CAAC,mCAAmC,CAA6C;IACjG,OAAO,CAAC,QAAQ,CAAC,0CAA0C,CAGzD;IACF,OAAO,CAAC,kBAAkB,CAAW;IAC9B,uBAAuB,EAAE,MAAM,CAAC;IACvC,OAAO,CAAC,yCAAyC,CAAiB;IAwBlE;;;;OAIG;IACU,yBAAyB,CACpC,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,OAAO,CAAC;IA6BnB;;;OAGG;IACU,oCAAoC,CAC/C,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,cAAc,CAAC;IAiC1B;;;OAGG;IACI,OAAO,IAAI,IAAI;YAMR,8CAA8C;IA2D5D;;;OAGG;YACW,uCAAuC;IA6CrD,yEAAyE;YAC3D,qCAAqC;IA2BnD,0FAA0F;YAC5E,qCAAqC;IAmBnD;;;;OAIG;IACH,OAAO,CAAC,iDAAiD;IAazD;;;;OAIG;IACH,OAAO,CAAC,gDAAgD;IAkBxD;;;;;;OAMG;YACW,wDAAwD;IA8BtE;;;;;;;;OAQG;IACH,OAAO,CAAC,kCAAkC;IAU1C;;;;;OAKG;YACW,8CAA8C;CA4B7D"}
@@ -11,6 +11,12 @@ import { assertNotUndefined } from "./utils/typeChecks.js";
11
11
  * This class is used to failover single partitions to different regions.
12
12
  */
13
13
  export class GlobalPartitionEndpointManager {
14
+ globalEndpointManager;
15
+ partitionKeyRangeToLocationForWrite;
16
+ partitionKeyRangeToLocationForReadAndWrite;
17
+ preferredLocations;
18
+ preferredLocationsCount;
19
+ circuitBreakerFailbackBackgroundRefresher;
14
20
  /**
15
21
  * @internal
16
22
  */
@@ -18,13 +24,10 @@ export class GlobalPartitionEndpointManager {
18
24
  this.globalEndpointManager = globalEndpointManager;
19
25
  this.partitionKeyRangeToLocationForWrite = new Map();
20
26
  this.partitionKeyRangeToLocationForReadAndWrite = new Map();
21
- this.enablePartitionLevelFailover = options.connectionPolicy.enablePartitionLevelFailover;
22
- this.enablePartitionLevelCircuitBreaker =
23
- options.connectionPolicy.enablePartitionLevelCircuitBreaker ||
24
- options.connectionPolicy.enablePartitionLevelFailover;
25
27
  this.preferredLocations = options.connectionPolicy.preferredLocations;
26
28
  this.preferredLocationsCount = this.preferredLocations ? this.preferredLocations.length : 0;
27
- if (this.enablePartitionLevelCircuitBreaker) {
29
+ if (this.globalEndpointManager.enablePartitionLevelCircuitBreaker ||
30
+ this.globalEndpointManager.enablePartitionLevelFailover) {
28
31
  this.initiateCircuitBreakerFailbackLoop();
29
32
  }
30
33
  }
@@ -194,7 +197,7 @@ export class GlobalPartitionEndpointManager {
194
197
  * and the global endpoint manager cannot use multiple write locations for the request.
195
198
  */
196
199
  isRequestEligibleForPerPartitionAutomaticFailover(requestContext) {
197
- return (this.enablePartitionLevelFailover &&
200
+ return (this.globalEndpointManager.enablePartitionLevelFailover &&
198
201
  !isReadRequest(requestContext.operationType) &&
199
202
  !this.globalEndpointManager.canUseMultipleWriteLocations(requestContext.resourceType, requestContext.operationType));
200
203
  }
@@ -204,7 +207,9 @@ export class GlobalPartitionEndpointManager {
204
207
  * the global endpoint manager can use multiple write locations for the request.
205
208
  */
206
209
  isRequestEligibleForPartitionLevelCircuitBreaker(requestContext) {
207
- if (!this.enablePartitionLevelCircuitBreaker) {
210
+ const enablePartitionLevelCircuitBreaker = this.globalEndpointManager.enablePartitionLevelCircuitBreaker ||
211
+ this.globalEndpointManager.enablePartitionLevelFailover;
212
+ if (!enablePartitionLevelCircuitBreaker) {
208
213
  return false;
209
214
  }
210
215
  if (isReadRequest(requestContext.operationType)) {
@@ -260,6 +265,13 @@ export class GlobalPartitionEndpointManager {
260
265
  * location for the partition key range.
261
266
  */
262
267
  async openConnectionToUnhealthyEndpointsWithFailback() {
268
+ // If partition level circuit breaker or failover is not enabled, dispose the timer.
269
+ const enablePartitionLevelCircuitBreaker = this.globalEndpointManager.enablePartitionLevelCircuitBreaker ||
270
+ this.globalEndpointManager.enablePartitionLevelFailover;
271
+ if (!enablePartitionLevelCircuitBreaker) {
272
+ this.dispose();
273
+ return;
274
+ }
263
275
  for (const pkRange of this.partitionKeyRangeToLocationForReadAndWrite.keys()) {
264
276
  const partitionFailover = this.partitionKeyRangeToLocationForReadAndWrite.get(pkRange);
265
277
  if (!partitionFailover)
@@ -1 +1 @@
1
- {"version":3,"file":"globalPartitionEndpointManager.js","sourceRoot":"","sources":["../../src/globalPartitionEndpointManager.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EACL,SAAS,GAKV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;GAGG;AACH,MAAM,OAAO,8BAA8B;IAYzC;;OAEG;IACH,YACE,OAA4B,EACpB,qBAA4C;QAA5C,0BAAqB,GAArB,qBAAqB,CAAuB;QAEpD,IAAI,CAAC,mCAAmC,GAAG,IAAI,GAAG,EAAyC,CAAC;QAC5F,IAAI,CAAC,0CAA0C,GAAG,IA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EvB,IACE,GAAG,CAAC,OAAO,EAAE,GAAG,uBAAuB;gBACvC,SAAS,CAAC,0CAA0C,EACpD,CAAC;gBACD,6FAA6F;gBAC7F,qDAAqD;gBACrD,IAAI,CAAC,0CAA0C,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OperationType, ResourceType, isReadRequest } from \"./common/index.js\";\nimport {\n Constants,\n DiagnosticNodeInternal,\n type CosmosClientOptions,\n type GlobalEndpointManager,\n type RequestContext,\n} from \"./index.js\";\nimport { PartitionKeyRangeFailoverInfo } from \"./PartitionKeyRangeFailoverInfo.js\";\nimport { normalizeEndpoint } from \"./utils/checkURL.js\";\nimport { startBackgroundTask } from \"./utils/time.js\";\nimport { assertNotUndefined } from \"./utils/typeChecks.js\";\n\n/**\n * @hidden\n * This class is used to failover single partitions to different regions.\n */\nexport class GlobalPartitionEndpointManager {\n private readonly partitionKeyRangeToLocationForWrite: Map<string, PartitionKeyRangeFailoverInfo>;\n private readonly partitionKeyRangeToLocationForReadAndWrite: Map<\n string,\n PartitionKeyRangeFailoverInfo\n >;\n private enablePartitionLevelFailover: boolean;\n private enablePartitionLevelCircuitBreaker: boolean;\n private preferredLocations: string[];\n public preferredLocationsCount: number;\n private circuitBreakerFailbackBackgroundRefresher: NodeJS.Timeout;\n\n /**\n * @internal\n */\n constructor(\n options: CosmosClientOptions,\n private globalEndpointManager: GlobalEndpointManager,\n ) {\n this.partitionKeyRangeToLocationForWrite = new Map<string, PartitionKeyRangeFailoverInfo>();\n this.partitionKeyRangeToLocationForReadAndWrite = new Map<\n string,\n PartitionKeyRangeFailoverInfo\n >();\n\n this.enablePartitionLevelFailover = options.connectionPolicy.enablePartitionLevelFailover;\n this.enablePartitionLevelCircuitBreaker =\n options.connectionPolicy.enablePartitionLevelCircuitBreaker ||\n options.connectionPolicy.enablePartitionLevelFailover;\n\n this.preferredLocations = options.connectionPolicy.preferredLocations;\n this.preferredLocationsCount = this.preferredLocations ? this.preferredLocations.length : 0;\n if (this.enablePartitionLevelCircuitBreaker) {\n this.initiateCircuitBreakerFailbackLoop();\n }\n }\n\n /**\n * Checks eligibility of the request for partition failover and\n * tries to mark the endpoint unavailable for the partition key range. Future\n * requests will be routed to the next location if available.\n */\n public async tryPartitionLevelFailover(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<boolean> {\n if (!(await this.isRequestEligibleForPartitionFailover(requestContext, true))) {\n return false;\n }\n\n const isRequestEligibleForPerPartitionAutomaticFailover =\n this.isRequestEligibleForPerPartitionAutomaticFailover(requestContext);\n const isRequestEligibleForPartitionLevelCircuitBreaker =\n this.isRequestEligibleForPartitionLevelCircuitBreaker(requestContext);\n\n if (\n isRequestEligibleForPerPartitionAutomaticFailover ||\n (isRequestEligibleForPartitionLevelCircuitBreaker &&\n (await this.incrementFailureCounterAndCheckFailover(\n requestContext,\n isRequestEligibleForPerPartitionAutomaticFailover,\n isRequestEligibleForPartitionLevelCircuitBreaker,\n )))\n ) {\n return this.tryMarkEndpointUnavailableForPartitionKeyRange(\n requestContext,\n diagnosticNode,\n isRequestEligibleForPerPartitionAutomaticFailover,\n isRequestEligibleForPartitionLevelCircuitBreaker,\n );\n }\n return false;\n }\n\n /**\n * Updates the DocumentServiceRequest routing location to point\n * new a location based if a partition level failover occurred.\n */\n public async tryAddPartitionLevelLocationOverride(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<RequestContext> {\n if (!(await this.isRequestEligibleForPartitionFailover(requestContext, false))) {\n return requestContext;\n }\n\n const partitionKeyRangeId = requestContext.partitionKeyRangeId;\n\n if (this.isRequestEligibleForPerPartitionAutomaticFailover(requestContext)) {\n if (this.partitionKeyRangeToLocationForWrite.has(partitionKeyRangeId)) {\n const partitionFailOver = this.partitionKeyRangeToLocationForWrite.get(partitionKeyRangeId);\n requestContext.endpoint = partitionFailOver.getCurrentEndPoint();\n diagnosticNode.recordEndpointResolution(requestContext.endpoint);\n return requestContext;\n }\n } else if (this.isRequestEligibleForPartitionLevelCircuitBreaker(requestContext)) {\n if (this.partitionKeyRangeToLocationForReadAndWrite.has(partitionKeyRangeId)) {\n const partitionFailOver =\n this.partitionKeyRangeToLocationForReadAndWrite.get(partitionKeyRangeId);\n\n const canCircuitBreakerTriggerPartitionFailOver =\n await partitionFailOver.canCircuitBreakerTriggerPartitionFailOver(\n isReadRequest(requestContext.operationType),\n );\n if (canCircuitBreakerTriggerPartitionFailOver) {\n requestContext.endpoint = partitionFailOver.getCurrentEndPoint();\n diagnosticNode.recordEndpointResolution(requestContext.endpoint);\n return requestContext;\n }\n }\n }\n return requestContext;\n }\n\n /**\n * This method clears the background refresher for circuit breaker failback\n * and stops the periodic checks for unhealthy endpoints.\n */\n public dispose(): void {\n if (this.circuitBreakerFailbackBackgroundRefresher) {\n clearTimeout(this.circuitBreakerFailbackBackgroundRefresher);\n }\n }\n\n private async tryMarkEndpointUnavailableForPartitionKeyRange(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n isRequestEligibleForPerPartitionAutomaticFailover: boolean,\n isRequestEligibleForPartitionLevelCircuitBreaker: boolean,\n ): Promise<boolean> {\n const partitionKeyRangeId = requestContext.partitionKeyRangeId;\n const failedEndPoint = requestContext.endpoint;\n\n const readLocations = await this.globalEndpointManager.getReadLocations();\n const readEndPoints: string[] = [];\n\n if (isRequestEligibleForPerPartitionAutomaticFailover) {\n // For any single master write accounts, the next locations to fail over will be the read regions configured at the account level.\n for (const location of readLocations) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n return this.tryAddOrUpdatePartitionFailoverInfoAndMoveToNextLocation(\n partitionKeyRangeId,\n failedEndPoint,\n readEndPoints,\n this.partitionKeyRangeToLocationForWrite,\n diagnosticNode,\n );\n } else if (isRequestEligibleForPartitionLevelCircuitBreaker) {\n // For the read requests or multi-master write requests, the next locations to fail over will be the preferred locations\n // configured at the account level plus any other read locations that are not already in the preferred locations.\n if (this.preferredLocations && this.preferredLocations.length > 0) {\n for (const preferredLocation of this.preferredLocations) {\n const location = readLocations.find(\n (loc) => normalizeEndpoint(loc.name) === normalizeEndpoint(preferredLocation),\n );\n if (location) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n }\n\n // Add the rest of the locations not already added\n for (const location of readLocations) {\n if (!readEndPoints.includes(location.databaseAccountEndpoint)) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n }\n } else {\n for (const location of readLocations) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n }\n return this.tryAddOrUpdatePartitionFailoverInfoAndMoveToNextLocation(\n partitionKeyRangeId,\n failedEndPoint,\n readEndPoints,\n this.partitionKeyRangeToLocationForReadAndWrite,\n diagnosticNode,\n );\n }\n return false;\n }\n\n /**\n * Increments the failure counter for the specified partition and checks if the partition can fail over.\n * This method is used to determine if a partition should be failed over based on the number of request failures.\n */\n private async incrementFailureCounterAndCheckFailover(\n requestContext: RequestContext,\n isRequestEligibleForPerPartitionAutomaticFailover: boolean,\n isRequestEligibleForPartitionLevelCircuitBreaker: boolean,\n ): Promise<boolean> {\n const partitionKeyRangeId = requestContext.partitionKeyRangeId;\n const failedEndPoint = requestContext.endpoint;\n let partitionKeyRangeFailoverInfo: PartitionKeyRangeFailoverInfo;\n\n if (isRequestEligibleForPerPartitionAutomaticFailover) {\n if (!this.partitionKeyRangeToLocationForWrite.has(partitionKeyRangeId)) {\n // If the partition key range is not already in the map, add it\n const failoverInfo = new PartitionKeyRangeFailoverInfo(failedEndPoint);\n this.partitionKeyRangeToLocationForWrite.set(partitionKeyRangeId, failoverInfo);\n }\n partitionKeyRangeFailoverInfo =\n this.partitionKeyRangeToLocationForWrite.get(partitionKeyRangeId);\n } else if (isRequestEligibleForPartitionLevelCircuitBreaker) {\n if (!this.partitionKeyRangeToLocationForReadAndWrite.has(partitionKeyRangeId)) {\n // If the partition key range is not already in the map, add it\n const failoverInfo = new PartitionKeyRangeFailoverInfo(failedEndPoint);\n this.partitionKeyRangeToLocationForReadAndWrite.set(partitionKeyRangeId, failoverInfo);\n }\n partitionKeyRangeFailoverInfo =\n this.partitionKeyRangeToLocationForReadAndWrite.get(partitionKeyRangeId);\n } else {\n return false;\n }\n\n assertNotUndefined(\n partitionKeyRangeFailoverInfo,\n \"partitionKeyRangeFailoverInfo should be set if failover flags are true.\",\n );\n\n const currentTimeInMilliseconds = Date.now();\n await partitionKeyRangeFailoverInfo.incrementRequestFailureCounts(\n isReadRequest(requestContext.operationType),\n currentTimeInMilliseconds,\n );\n\n return partitionKeyRangeFailoverInfo.canCircuitBreakerTriggerPartitionFailOver(\n isReadRequest(requestContext.operationType),\n );\n }\n\n /** Validates if the given request is eligible for partition failover. */\n private async isRequestEligibleForPartitionFailover(\n requestContext: RequestContext,\n shouldValidateFailedLocation: boolean,\n ): Promise<boolean> {\n if (\n !requestContext ||\n !requestContext.operationType ||\n !requestContext.resourceType ||\n !requestContext.partitionKeyRangeId\n ) {\n return false;\n }\n\n const canUsePartitionLevelFailoverLocations = await this.canUsePartitionLevelFailoverLocations(\n requestContext.operationType,\n requestContext.resourceType,\n );\n if (!canUsePartitionLevelFailoverLocations) {\n return false;\n }\n\n if (shouldValidateFailedLocation && !requestContext.endpoint) {\n return false;\n }\n return true;\n }\n\n /** Determines if partition level failover locations can be used for the given request. */\n private async canUsePartitionLevelFailoverLocations(\n operationType?: OperationType,\n resourceType?: ResourceType,\n ): Promise<boolean> {\n const readEndPoints = await this.globalEndpointManager.getReadEndpoints();\n if (readEndPoints.length <= 1) {\n return false;\n }\n if (\n resourceType === ResourceType.item ||\n (resourceType === ResourceType.sproc && operationType === OperationType.Execute)\n ) {\n // Right now, for single-master only reads are supported for circuit breaker, and writes are supported for automatic.\n // failover. For multi master, both reads and writes are supported. Hence return true for both the cases.\n return true;\n }\n return false;\n }\n\n /**\n * Determines if a request is eligible for per-partition automatic failover.\n * A request is eligible if it is a write request, partition level failover is enabled,\n * and the global endpoint manager cannot use multiple write locations for the request.\n */\n private isRequestEligibleForPerPartitionAutomaticFailover(\n requestContext: RequestContext,\n ): boolean {\n return (\n this.enablePartitionLevelFailover &&\n !isReadRequest(requestContext.operationType) &&\n !this.globalEndpointManager.canUseMultipleWriteLocations(\n requestContext.resourceType,\n requestContext.operationType,\n )\n );\n }\n\n /**\n * Determines if a request is eligible for partition-level circuit breaker.\n * This method checks if partition-level circuit breaker is enabled, and if the request is a read-only request or\n * the global endpoint manager can use multiple write locations for the request.\n */\n private isRequestEligibleForPartitionLevelCircuitBreaker(\n requestContext: RequestContext,\n ): boolean {\n if (!this.enablePartitionLevelCircuitBreaker) {\n return false;\n }\n if (isReadRequest(requestContext.operationType)) {\n return true;\n }\n return this.globalEndpointManager.canUseMultipleWriteLocations(\n requestContext.resourceType,\n requestContext.operationType,\n );\n }\n\n /**\n * Attempts to add or update the partition failover information and move to the next available location.\n * This method checks if the current location for the partition key range has failed and updates the failover\n * information to route the request to the next available location. If all locations have been tried, it removes\n * the failover information for the partition key range. Return True if the failover information was successfully\n * updated and the request was routed to a new location, otherwise false.\n */\n private async tryAddOrUpdatePartitionFailoverInfoAndMoveToNextLocation(\n partitionKeyRangeId: string,\n failedEndPoint: string,\n nextEndPoints: readonly string[],\n partitionKeyRangeToLocation: Map<string, PartitionKeyRangeFailoverInfo>,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<boolean> {\n if (!partitionKeyRangeToLocation.has(partitionKeyRangeId)) {\n // If the partition key range is not already in the map, add it\n const failoverInfo = new PartitionKeyRangeFailoverInfo(failedEndPoint);\n partitionKeyRangeToLocation.set(partitionKeyRangeId, failoverInfo);\n }\n const partitionFailOver = partitionKeyRangeToLocation.get(partitionKeyRangeId);\n\n // Will return true if it was able to update to a new region\n if (\n await partitionFailOver.tryMoveNextLocation(\n nextEndPoints,\n failedEndPoint,\n diagnosticNode,\n partitionKeyRangeId,\n )\n ) {\n return true;\n }\n // All the locations have been tried. Remove the override information\n partitionKeyRangeToLocation.delete(partitionKeyRangeId);\n return false;\n }\n\n /**\n * Initiates a background loop that periodically checks for unhealthy endpoints\n * and attempts to open connections to them. If a connection is successfully\n * established, it initiates a failback to the original location for the partition key range.\n * This is useful for scenarios where a partition key range has been marked as unavailable\n * due to a circuit breaker, and we want to periodically check if the original location\n * has become healthy again.\n * The loop runs at a defined interval specified by Constants.StalePartitionUnavailabilityRefreshIntervalInMs.\n */\n private initiateCircuitBreakerFailbackLoop(): void {\n this.circuitBreakerFailbackBackgroundRefresher = startBackgroundTask(async () => {\n try {\n await this.openConnectionToUnhealthyEndpointsWithFailback();\n } catch (err) {\n console.error(\"Failed to open connection to unhealthy endpoints: \", err);\n }\n }, Constants.StalePartitionUnavailabilityRefreshIntervalInMs);\n }\n\n /**\n * Attempts to open connections to unhealthy endpoints and initiates failback if the connections are successful.\n * This method checks the partition key ranges that have failed locations and tries to re-establish connections\n * to those locations. If a connection is successfully re-established, it initiates a failback to the original\n * location for the partition key range.\n */\n private async openConnectionToUnhealthyEndpointsWithFailback(): Promise<void> {\n for (const pkRange of this.partitionKeyRangeToLocationForReadAndWrite.keys()) {\n const partitionFailover = this.partitionKeyRangeToLocationForReadAndWrite.get(pkRange);\n if (!partitionFailover) continue;\n\n const { firstRequestFailureTime } =\n await partitionFailover.snapshotPartitionFailoverTimestamps();\n const now = new Date();\n\n if (\n now.getTime() - firstRequestFailureTime >\n Constants.AllowedPartitionUnavailabilityDurationInMs\n ) {\n // Un-deterministically marking the original failed endpoint for the PkRange back to healthy.\n // Initiate Failback to the original failed location.\n this.partitionKeyRangeToLocationForReadAndWrite.delete(pkRange);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"globalPartitionEndpointManager.js","sourceRoot":"","sources":["../../src/globalPartitionEndpointManager.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC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CAAC;YAC9D,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,oDAAoD,EAAE,GAAG,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC,EAAE,SAAS,CAAC,+CAA+C,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,8CAA8C;QAC1D,oFAAoF;QACpF,MAAM,kCAAkC,GACtC,IAAI,CAAC,qBAAqB,CAAC,kCAAkC;YAC7D,IAAI,CAAC,qBAAqB,CAAC,4BAA4B,CAAC;QAC1D,IAAI,CAAC,kCAAkC,EAAE,CAAC;YACxC,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,0CAA0C,CAAC,IAAI,EAAE,EAAE,CAAC;YAC7E,MAAM,iBAAiB,GAAG,IAAI,CAAC,0CAA0C,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACvF,IAAI,CAAC,iBAAiB;gBAAE,SAAS;YAEjC,MAAM,EAAE,uBAAuB,EAAE,GAC/B,MAAM,iBAAiB,CAAC,mCAAmC,EAAE,CAAC;YAChE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YAEvB,IACE,GAAG,CAAC,OAAO,EAAE,GAAG,uBAAuB;gBACvC,SAAS,CAAC,0CAA0C,EACpD,CAAC;gBACD,6FAA6F;gBAC7F,qDAAqD;gBACrD,IAAI,CAAC,0CAA0C,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OperationType, ResourceType, isReadRequest } from \"./common/index.js\";\nimport {\n Constants,\n DiagnosticNodeInternal,\n type CosmosClientOptions,\n type GlobalEndpointManager,\n type RequestContext,\n} from \"./index.js\";\nimport { PartitionKeyRangeFailoverInfo } from \"./PartitionKeyRangeFailoverInfo.js\";\nimport { normalizeEndpoint } from \"./utils/checkURL.js\";\nimport { startBackgroundTask } from \"./utils/time.js\";\nimport { assertNotUndefined } from \"./utils/typeChecks.js\";\n\n/**\n * @hidden\n * This class is used to failover single partitions to different regions.\n */\nexport class GlobalPartitionEndpointManager {\n private readonly partitionKeyRangeToLocationForWrite: Map<string, PartitionKeyRangeFailoverInfo>;\n private readonly partitionKeyRangeToLocationForReadAndWrite: Map<\n string,\n PartitionKeyRangeFailoverInfo\n >;\n private preferredLocations: string[];\n public preferredLocationsCount: number;\n private circuitBreakerFailbackBackgroundRefresher: NodeJS.Timeout;\n\n /**\n * @internal\n */\n constructor(\n options: CosmosClientOptions,\n private globalEndpointManager: GlobalEndpointManager,\n ) {\n this.partitionKeyRangeToLocationForWrite = new Map<string, PartitionKeyRangeFailoverInfo>();\n this.partitionKeyRangeToLocationForReadAndWrite = new Map<\n string,\n PartitionKeyRangeFailoverInfo\n >();\n this.preferredLocations = options.connectionPolicy.preferredLocations;\n this.preferredLocationsCount = this.preferredLocations ? this.preferredLocations.length : 0;\n if (\n this.globalEndpointManager.enablePartitionLevelCircuitBreaker ||\n this.globalEndpointManager.enablePartitionLevelFailover\n ) {\n this.initiateCircuitBreakerFailbackLoop();\n }\n }\n\n /**\n * Checks eligibility of the request for partition failover and\n * tries to mark the endpoint unavailable for the partition key range. Future\n * requests will be routed to the next location if available.\n */\n public async tryPartitionLevelFailover(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<boolean> {\n if (!(await this.isRequestEligibleForPartitionFailover(requestContext, true))) {\n return false;\n }\n\n const isRequestEligibleForPerPartitionAutomaticFailover =\n this.isRequestEligibleForPerPartitionAutomaticFailover(requestContext);\n const isRequestEligibleForPartitionLevelCircuitBreaker =\n this.isRequestEligibleForPartitionLevelCircuitBreaker(requestContext);\n\n if (\n isRequestEligibleForPerPartitionAutomaticFailover ||\n (isRequestEligibleForPartitionLevelCircuitBreaker &&\n (await this.incrementFailureCounterAndCheckFailover(\n requestContext,\n isRequestEligibleForPerPartitionAutomaticFailover,\n isRequestEligibleForPartitionLevelCircuitBreaker,\n )))\n ) {\n return this.tryMarkEndpointUnavailableForPartitionKeyRange(\n requestContext,\n diagnosticNode,\n isRequestEligibleForPerPartitionAutomaticFailover,\n isRequestEligibleForPartitionLevelCircuitBreaker,\n );\n }\n return false;\n }\n\n /**\n * Updates the DocumentServiceRequest routing location to point\n * new a location based if a partition level failover occurred.\n */\n public async tryAddPartitionLevelLocationOverride(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<RequestContext> {\n if (!(await this.isRequestEligibleForPartitionFailover(requestContext, false))) {\n return requestContext;\n }\n\n const partitionKeyRangeId = requestContext.partitionKeyRangeId;\n\n if (this.isRequestEligibleForPerPartitionAutomaticFailover(requestContext)) {\n if (this.partitionKeyRangeToLocationForWrite.has(partitionKeyRangeId)) {\n const partitionFailOver = this.partitionKeyRangeToLocationForWrite.get(partitionKeyRangeId);\n requestContext.endpoint = partitionFailOver.getCurrentEndPoint();\n diagnosticNode.recordEndpointResolution(requestContext.endpoint);\n return requestContext;\n }\n } else if (this.isRequestEligibleForPartitionLevelCircuitBreaker(requestContext)) {\n if (this.partitionKeyRangeToLocationForReadAndWrite.has(partitionKeyRangeId)) {\n const partitionFailOver =\n this.partitionKeyRangeToLocationForReadAndWrite.get(partitionKeyRangeId);\n\n const canCircuitBreakerTriggerPartitionFailOver =\n await partitionFailOver.canCircuitBreakerTriggerPartitionFailOver(\n isReadRequest(requestContext.operationType),\n );\n if (canCircuitBreakerTriggerPartitionFailOver) {\n requestContext.endpoint = partitionFailOver.getCurrentEndPoint();\n diagnosticNode.recordEndpointResolution(requestContext.endpoint);\n return requestContext;\n }\n }\n }\n return requestContext;\n }\n\n /**\n * This method clears the background refresher for circuit breaker failback\n * and stops the periodic checks for unhealthy endpoints.\n */\n public dispose(): void {\n if (this.circuitBreakerFailbackBackgroundRefresher) {\n clearTimeout(this.circuitBreakerFailbackBackgroundRefresher);\n }\n }\n\n private async tryMarkEndpointUnavailableForPartitionKeyRange(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n isRequestEligibleForPerPartitionAutomaticFailover: boolean,\n isRequestEligibleForPartitionLevelCircuitBreaker: boolean,\n ): Promise<boolean> {\n const partitionKeyRangeId = requestContext.partitionKeyRangeId;\n const failedEndPoint = requestContext.endpoint;\n\n const readLocations = await this.globalEndpointManager.getReadLocations();\n const readEndPoints: string[] = [];\n\n if (isRequestEligibleForPerPartitionAutomaticFailover) {\n // For any single master write accounts, the next locations to fail over will be the read regions configured at the account level.\n for (const location of readLocations) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n return this.tryAddOrUpdatePartitionFailoverInfoAndMoveToNextLocation(\n partitionKeyRangeId,\n failedEndPoint,\n readEndPoints,\n this.partitionKeyRangeToLocationForWrite,\n diagnosticNode,\n );\n } else if (isRequestEligibleForPartitionLevelCircuitBreaker) {\n // For the read requests or multi-master write requests, the next locations to fail over will be the preferred locations\n // configured at the account level plus any other read locations that are not already in the preferred locations.\n if (this.preferredLocations && this.preferredLocations.length > 0) {\n for (const preferredLocation of this.preferredLocations) {\n const location = readLocations.find(\n (loc) => normalizeEndpoint(loc.name) === normalizeEndpoint(preferredLocation),\n );\n if (location) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n }\n\n // Add the rest of the locations not already added\n for (const location of readLocations) {\n if (!readEndPoints.includes(location.databaseAccountEndpoint)) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n }\n } else {\n for (const location of readLocations) {\n readEndPoints.push(location.databaseAccountEndpoint);\n }\n }\n return this.tryAddOrUpdatePartitionFailoverInfoAndMoveToNextLocation(\n partitionKeyRangeId,\n failedEndPoint,\n readEndPoints,\n this.partitionKeyRangeToLocationForReadAndWrite,\n diagnosticNode,\n );\n }\n return false;\n }\n\n /**\n * Increments the failure counter for the specified partition and checks if the partition can fail over.\n * This method is used to determine if a partition should be failed over based on the number of request failures.\n */\n private async incrementFailureCounterAndCheckFailover(\n requestContext: RequestContext,\n isRequestEligibleForPerPartitionAutomaticFailover: boolean,\n isRequestEligibleForPartitionLevelCircuitBreaker: boolean,\n ): Promise<boolean> {\n const partitionKeyRangeId = requestContext.partitionKeyRangeId;\n const failedEndPoint = requestContext.endpoint;\n let partitionKeyRangeFailoverInfo: PartitionKeyRangeFailoverInfo;\n\n if (isRequestEligibleForPerPartitionAutomaticFailover) {\n if (!this.partitionKeyRangeToLocationForWrite.has(partitionKeyRangeId)) {\n // If the partition key range is not already in the map, add it\n const failoverInfo = new PartitionKeyRangeFailoverInfo(failedEndPoint);\n this.partitionKeyRangeToLocationForWrite.set(partitionKeyRangeId, failoverInfo);\n }\n partitionKeyRangeFailoverInfo =\n this.partitionKeyRangeToLocationForWrite.get(partitionKeyRangeId);\n } else if (isRequestEligibleForPartitionLevelCircuitBreaker) {\n if (!this.partitionKeyRangeToLocationForReadAndWrite.has(partitionKeyRangeId)) {\n // If the partition key range is not already in the map, add it\n const failoverInfo = new PartitionKeyRangeFailoverInfo(failedEndPoint);\n this.partitionKeyRangeToLocationForReadAndWrite.set(partitionKeyRangeId, failoverInfo);\n }\n partitionKeyRangeFailoverInfo =\n this.partitionKeyRangeToLocationForReadAndWrite.get(partitionKeyRangeId);\n } else {\n return false;\n }\n\n assertNotUndefined(\n partitionKeyRangeFailoverInfo,\n \"partitionKeyRangeFailoverInfo should be set if failover flags are true.\",\n );\n\n const currentTimeInMilliseconds = Date.now();\n await partitionKeyRangeFailoverInfo.incrementRequestFailureCounts(\n isReadRequest(requestContext.operationType),\n currentTimeInMilliseconds,\n );\n\n return partitionKeyRangeFailoverInfo.canCircuitBreakerTriggerPartitionFailOver(\n isReadRequest(requestContext.operationType),\n );\n }\n\n /** Validates if the given request is eligible for partition failover. */\n private async isRequestEligibleForPartitionFailover(\n requestContext: RequestContext,\n shouldValidateFailedLocation: boolean,\n ): Promise<boolean> {\n if (\n !requestContext ||\n !requestContext.operationType ||\n !requestContext.resourceType ||\n !requestContext.partitionKeyRangeId\n ) {\n return false;\n }\n\n const canUsePartitionLevelFailoverLocations = await this.canUsePartitionLevelFailoverLocations(\n requestContext.operationType,\n requestContext.resourceType,\n );\n if (!canUsePartitionLevelFailoverLocations) {\n return false;\n }\n\n if (shouldValidateFailedLocation && !requestContext.endpoint) {\n return false;\n }\n return true;\n }\n\n /** Determines if partition level failover locations can be used for the given request. */\n private async canUsePartitionLevelFailoverLocations(\n operationType?: OperationType,\n resourceType?: ResourceType,\n ): Promise<boolean> {\n const readEndPoints = await this.globalEndpointManager.getReadEndpoints();\n if (readEndPoints.length <= 1) {\n return false;\n }\n if (\n resourceType === ResourceType.item ||\n (resourceType === ResourceType.sproc && operationType === OperationType.Execute)\n ) {\n // Right now, for single-master only reads are supported for circuit breaker, and writes are supported for automatic.\n // failover. For multi master, both reads and writes are supported. Hence return true for both the cases.\n return true;\n }\n return false;\n }\n\n /**\n * Determines if a request is eligible for per-partition automatic failover.\n * A request is eligible if it is a write request, partition level failover is enabled,\n * and the global endpoint manager cannot use multiple write locations for the request.\n */\n private isRequestEligibleForPerPartitionAutomaticFailover(\n requestContext: RequestContext,\n ): boolean {\n return (\n this.globalEndpointManager.enablePartitionLevelFailover &&\n !isReadRequest(requestContext.operationType) &&\n !this.globalEndpointManager.canUseMultipleWriteLocations(\n requestContext.resourceType,\n requestContext.operationType,\n )\n );\n }\n\n /**\n * Determines if a request is eligible for partition-level circuit breaker.\n * This method checks if partition-level circuit breaker is enabled, and if the request is a read-only request or\n * the global endpoint manager can use multiple write locations for the request.\n */\n private isRequestEligibleForPartitionLevelCircuitBreaker(\n requestContext: RequestContext,\n ): boolean {\n const enablePartitionLevelCircuitBreaker =\n this.globalEndpointManager.enablePartitionLevelCircuitBreaker ||\n this.globalEndpointManager.enablePartitionLevelFailover;\n if (!enablePartitionLevelCircuitBreaker) {\n return false;\n }\n if (isReadRequest(requestContext.operationType)) {\n return true;\n }\n return this.globalEndpointManager.canUseMultipleWriteLocations(\n requestContext.resourceType,\n requestContext.operationType,\n );\n }\n\n /**\n * Attempts to add or update the partition failover information and move to the next available location.\n * This method checks if the current location for the partition key range has failed and updates the failover\n * information to route the request to the next available location. If all locations have been tried, it removes\n * the failover information for the partition key range. Return True if the failover information was successfully\n * updated and the request was routed to a new location, otherwise false.\n */\n private async tryAddOrUpdatePartitionFailoverInfoAndMoveToNextLocation(\n partitionKeyRangeId: string,\n failedEndPoint: string,\n nextEndPoints: readonly string[],\n partitionKeyRangeToLocation: Map<string, PartitionKeyRangeFailoverInfo>,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<boolean> {\n if (!partitionKeyRangeToLocation.has(partitionKeyRangeId)) {\n // If the partition key range is not already in the map, add it\n const failoverInfo = new PartitionKeyRangeFailoverInfo(failedEndPoint);\n partitionKeyRangeToLocation.set(partitionKeyRangeId, failoverInfo);\n }\n const partitionFailOver = partitionKeyRangeToLocation.get(partitionKeyRangeId);\n\n // Will return true if it was able to update to a new region\n if (\n await partitionFailOver.tryMoveNextLocation(\n nextEndPoints,\n failedEndPoint,\n diagnosticNode,\n partitionKeyRangeId,\n )\n ) {\n return true;\n }\n // All the locations have been tried. Remove the override information\n partitionKeyRangeToLocation.delete(partitionKeyRangeId);\n return false;\n }\n\n /**\n * Initiates a background loop that periodically checks for unhealthy endpoints\n * and attempts to open connections to them. If a connection is successfully\n * established, it initiates a failback to the original location for the partition key range.\n * This is useful for scenarios where a partition key range has been marked as unavailable\n * due to a circuit breaker, and we want to periodically check if the original location\n * has become healthy again.\n * The loop runs at a defined interval specified by Constants.StalePartitionUnavailabilityRefreshIntervalInMs.\n */\n private initiateCircuitBreakerFailbackLoop(): void {\n this.circuitBreakerFailbackBackgroundRefresher = startBackgroundTask(async () => {\n try {\n await this.openConnectionToUnhealthyEndpointsWithFailback();\n } catch (err) {\n console.error(\"Failed to open connection to unhealthy endpoints: \", err);\n }\n }, Constants.StalePartitionUnavailabilityRefreshIntervalInMs);\n }\n\n /**\n * Attempts to open connections to unhealthy endpoints and initiates failback if the connections are successful.\n * This method checks the partition key ranges that have failed locations and tries to re-establish connections\n * to those locations. If a connection is successfully re-established, it initiates a failback to the original\n * location for the partition key range.\n */\n private async openConnectionToUnhealthyEndpointsWithFailback(): Promise<void> {\n // If partition level circuit breaker or failover is not enabled, dispose the timer.\n const enablePartitionLevelCircuitBreaker =\n this.globalEndpointManager.enablePartitionLevelCircuitBreaker ||\n this.globalEndpointManager.enablePartitionLevelFailover;\n if (!enablePartitionLevelCircuitBreaker) {\n this.dispose();\n return;\n }\n\n for (const pkRange of this.partitionKeyRangeToLocationForReadAndWrite.keys()) {\n const partitionFailover = this.partitionKeyRangeToLocationForReadAndWrite.get(pkRange);\n if (!partitionFailover) continue;\n\n const { firstRequestFailureTime } =\n await partitionFailover.snapshotPartitionFailoverTimestamps();\n const now = new Date();\n\n if (\n now.getTime() - firstRequestFailureTime >\n Constants.AllowedPartitionUnavailabilityDurationInMs\n ) {\n // Un-deterministically marking the original failed endpoint for the PkRange back to healthy.\n // Initiate Failback to the original failed location.\n this.partitionKeyRangeToLocationForReadAndWrite.delete(pkRange);\n }\n }\n }\n}\n"]}
@@ -1,5 +1,7 @@
1
1
  /** @hidden */
2
2
  export class AverageAggregator {
3
+ sum;
4
+ count;
3
5
  /**
4
6
  * Add the provided item to aggregation result.
5
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AverageAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/AverageAggregator.ts"],"names":[],"mappings":"AAUA,cAAc;AACd,MAAM,OAAO,iBAAiB;IAG5B;;OAEG;IACI,SAAS,CAAC,KAA6B;QAC5C,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,SAAS;QACd,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport interface AverageAggregateResult {\n sum: number;\n count: number;\n}\n\n/** @hidden */\nexport class AverageAggregator implements Aggregator {\n public sum: number;\n public count: number;\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: AverageAggregateResult): void {\n if (other == null || other.sum == null) {\n return;\n }\n if (this.sum == null) {\n this.sum = 0.0;\n this.count = 0;\n }\n this.sum += other.sum;\n this.count += other.count;\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n if (this.sum == null || this.count <= 0) {\n return undefined;\n }\n return this.sum / this.count;\n }\n}\n"]}
1
+ {"version":3,"file":"AverageAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/AverageAggregator.ts"],"names":[],"mappings":"AAUA,cAAc;AACd,MAAM,OAAO,iBAAiB;IACrB,GAAG,CAAS;IACZ,KAAK,CAAS;IACrB;;OAEG;IACI,SAAS,CAAC,KAA6B;QAC5C,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;YACvC,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC;YACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC;QACtB,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,SAAS;QACd,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC;YACxC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport interface AverageAggregateResult {\n sum: number;\n count: number;\n}\n\n/** @hidden */\nexport class AverageAggregator implements Aggregator {\n public sum: number;\n public count: number;\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: AverageAggregateResult): void {\n if (other == null || other.sum == null) {\n return;\n }\n if (this.sum == null) {\n this.sum = 0.0;\n this.count = 0;\n }\n this.sum += other.sum;\n this.count += other.count;\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n if (this.sum == null || this.count <= 0) {\n return undefined;\n }\n return this.sum / this.count;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  /** @hidden */
2
2
  export class CountAggregator {
3
+ value;
3
4
  /**
4
5
  * Represents an aggregator for COUNT operator.
5
6
  * @hidden
@@ -1 +1 @@
1
- {"version":3,"file":"CountAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/CountAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,eAAe;IAE1B;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAa;QAC5B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class CountAggregator implements Aggregator {\n public value: number;\n /**\n * Represents an aggregator for COUNT operator.\n * @hidden\n */\n constructor() {\n this.value = 0;\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: number): void {\n this.value += other;\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
1
+ {"version":3,"file":"CountAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/CountAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,eAAe;IACnB,KAAK,CAAS;IACrB;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAa;QAC5B,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class CountAggregator implements Aggregator {\n public value: number;\n /**\n * Represents an aggregator for COUNT operator.\n * @hidden\n */\n constructor() {\n this.value = 0;\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: number): void {\n this.value += other;\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  export class GlobalStatisticsAggregator {
4
+ globalStatistics;
4
5
  constructor() {
5
6
  this.globalStatistics = {
6
7
  documentCount: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalStatisticsAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,OAAO,0BAA0B;IAGrC;QACE,IAAI,CAAC,gBAAgB,GAAG;YACtB,aAAa,EAAE,CAAC;YAChB,kBAAkB,EAAE,EAAE;SACvB,CAAC;IACJ,CAAC;IAEM,SAAS,CAAC,KAAuB;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QACD,2BAA2B;QAC3B,IAAI,CAAC,gBAAgB,CAAC,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC;QAC3D,6CAA6C;QAC7C,IAAI,CAAC,KAAK,CAAC,kBAAkB,IAAI,KAAK,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvE,OAAO;QACT,CAAC;QAED,sEAAsE;QACtE,IAAI,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1D,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,GAAG,KAAK,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gBACjF,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,SAAS,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;aAC/B,CAAC,CAAC,CAAC;QACN,CAAC;aAAM,CAAC;YACN,sGAAsG;YACtG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,kBAAkB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACzD,MAAM,SAAS,GAAG,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;gBAE9C,sCAAsC;gBACtC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC;oBACjD,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG;wBAC5C,cAAc,EAAE,CAAC;wBACjB,SAAS,EAAE,EAAE;qBACd,CAAC;gBACJ,CAAC;gBAED,qBAAqB;gBACrB,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,cAAc,IAAI,SAAS,CAAC,cAAc,CAAC;gBAEvF,wBAAwB;gBACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACpD,oCAAoC;oBACpC,IAAI,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;wBACtE,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAChE,CAAC;oBACD,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACrF,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { GlobalStatistics } from \"../../request/globalStatistics.js\";\nimport type { Aggregator } from \"./Aggregator.js\";\n\nexport class GlobalStatisticsAggregator implements Aggregator {\n private globalStatistics: GlobalStatistics;\n\n constructor() {\n this.globalStatistics = {\n documentCount: 0,\n fullTextStatistics: [],\n };\n }\n\n public aggregate(other: GlobalStatistics): void {\n if (!other) {\n return;\n }\n // Aggregate document count\n this.globalStatistics.documentCount += other.documentCount;\n // Ensure `fullTextStatistics` is initialized\n if (!other.fullTextStatistics || other.fullTextStatistics.length === 0) {\n return;\n }\n\n // Initialize `this.globalStatistics.fullTextStatistics` if it's empty\n if (this.globalStatistics.fullTextStatistics.length === 0) {\n this.globalStatistics.fullTextStatistics = other.fullTextStatistics.map((stat) => ({\n totalWordCount: stat.totalWordCount,\n hitCounts: [...stat.hitCounts],\n }));\n } else {\n // Loop through `other.fullTextStatistics` to add values to `this.globalStatistics.fullTextStatistics`\n for (let i = 0; i < other.fullTextStatistics.length; i++) {\n const otherStat = other.fullTextStatistics[i];\n\n // Ensure the index `i` is initialized\n if (!this.globalStatistics.fullTextStatistics[i]) {\n this.globalStatistics.fullTextStatistics[i] = {\n totalWordCount: 0,\n hitCounts: [],\n };\n }\n\n // Add totalWordCount\n this.globalStatistics.fullTextStatistics[i].totalWordCount += otherStat.totalWordCount;\n\n // Aggregate `hitCounts`\n for (let j = 0; j < otherStat.hitCounts.length; j++) {\n // Initialize hit count if necessary\n if (this.globalStatistics.fullTextStatistics[i].hitCounts.length <= j) {\n this.globalStatistics.fullTextStatistics[i].hitCounts.push(0);\n }\n this.globalStatistics.fullTextStatistics[i].hitCounts[j] += otherStat.hitCounts[j];\n }\n }\n }\n }\n\n public getResult(): GlobalStatistics {\n return this.globalStatistics;\n }\n}\n"]}
1
+ {"version":3,"file":"GlobalStatisticsAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,OAAO,0BAA0B;IAC7B,gBAAgB,CAAmB;IAE3C;QACE,IAAI,CAAC,gBAAgB,GAAG;YACtB,aAAa,EAAE,CAAC;YAChB,kBAAkB,EAAE,EAAE;SACvB,CAAC;IACJ,CAAC;IAEM,SAAS,CAAC,KAAuB;QACtC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,O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SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBACpD,oCAAoC;oBACpC,IAAI,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;wBACtE,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAChE,CAAC;oBACD,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACrF,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,gBAAgB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { GlobalStatistics } from \"../../request/globalStatistics.js\";\nimport type { Aggregator } from \"./Aggregator.js\";\n\nexport class GlobalStatisticsAggregator implements Aggregator {\n private globalStatistics: GlobalStatistics;\n\n constructor() {\n this.globalStatistics = {\n documentCount: 0,\n fullTextStatistics: [],\n };\n }\n\n public aggregate(other: GlobalStatistics): void {\n if (!other) {\n return;\n }\n // Aggregate document count\n this.globalStatistics.documentCount += other.documentCount;\n // Ensure `fullTextStatistics` is initialized\n if (!other.fullTextStatistics || other.fullTextStatistics.length === 0) {\n return;\n }\n\n // Initialize `this.globalStatistics.fullTextStatistics` if it's empty\n if (this.globalStatistics.fullTextStatistics.length === 0) {\n this.globalStatistics.fullTextStatistics = other.fullTextStatistics.map((stat) => ({\n totalWordCount: stat.totalWordCount,\n hitCounts: [...stat.hitCounts],\n }));\n } else {\n // Loop through `other.fullTextStatistics` to add values to `this.globalStatistics.fullTextStatistics`\n for (let i = 0; i < other.fullTextStatistics.length; i++) {\n const otherStat = other.fullTextStatistics[i];\n\n // Ensure the index `i` is initialized\n if (!this.globalStatistics.fullTextStatistics[i]) {\n this.globalStatistics.fullTextStatistics[i] = {\n totalWordCount: 0,\n hitCounts: [],\n };\n }\n\n // Add totalWordCount\n this.globalStatistics.fullTextStatistics[i].totalWordCount += otherStat.totalWordCount;\n\n // Aggregate `hitCounts`\n for (let j = 0; j < otherStat.hitCounts.length; j++) {\n // Initialize hit count if necessary\n if (this.globalStatistics.fullTextStatistics[i].hitCounts.length <= j) {\n this.globalStatistics.fullTextStatistics[i].hitCounts.push(0);\n }\n this.globalStatistics.fullTextStatistics[i].hitCounts[j] += otherStat.hitCounts[j];\n }\n }\n }\n }\n\n public getResult(): GlobalStatistics {\n return this.globalStatistics;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  /** @hidden */
2
2
  export class MakeListAggregator {
3
+ value;
3
4
  constructor() {
4
5
  this.value = [];
5
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MakeListAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MakeListAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,kBAAkB;IAG7B;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACM,SAAS,CAAC,KAAY;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACM,SAAS;QACd,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class MakeListAggregator implements Aggregator {\n value: any[];\n\n constructor() {\n this.value = [];\n }\n public aggregate(other: any[]): void {\n if (Array.isArray(other)) {\n this.value.push(...other);\n }\n }\n public getResult(): any[] {\n const result = [...this.value];\n return result;\n }\n}\n"]}
1
+ {"version":3,"file":"MakeListAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MakeListAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,kBAAkB;IAC7B,KAAK,CAAQ;IAEb;QACE,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IAClB,CAAC;IACM,SAAS,CAAC,KAAY;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACM,SAAS;QACd,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class MakeListAggregator implements Aggregator {\n value: any[];\n\n constructor() {\n this.value = [];\n }\n public aggregate(other: any[]): void {\n if (Array.isArray(other)) {\n this.value.push(...other);\n }\n }\n public getResult(): any[] {\n const result = [...this.value];\n return result;\n }\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  * Represents an aggregator that collects unique values into a set.
4
4
  */
5
5
  export class MakeSetAggregator {
6
+ value;
6
7
  constructor() {
7
8
  this.value = new Set();
8
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MakeSetAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MakeSetAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAG5B;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,KAAY;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\n/**\n * Represents an aggregator that collects unique values into a set.\n */\nexport class MakeSetAggregator implements Aggregator {\n value: Set<any>;\n\n constructor() {\n this.value = new Set();\n }\n\n /**\n * Aggregates the values from another set into the current set.\n * @param other - The set to aggregate.\n */\n public aggregate(other: any[]): void {\n other.forEach((item) => {\n this.value.add(item);\n });\n }\n\n /**\n * Gets the result of the MakeSetAggregator.\n * @returns A Set containing the unique values collected by the aggregator.\n */\n public getResult(): any {\n return Array.from(this.value);\n }\n}\n"]}
1
+ {"version":3,"file":"MakeSetAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MakeSetAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAC5B,KAAK,CAAW;IAEhB;QACE,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,SAAS,CAAC,KAAY;QAC3B,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\n/**\n * Represents an aggregator that collects unique values into a set.\n */\nexport class MakeSetAggregator implements Aggregator {\n value: Set<any>;\n\n constructor() {\n this.value = new Set();\n }\n\n /**\n * Aggregates the values from another set into the current set.\n * @param other - The set to aggregate.\n */\n public aggregate(other: any[]): void {\n other.forEach((item) => {\n this.value.add(item);\n });\n }\n\n /**\n * Gets the result of the MakeSetAggregator.\n * @returns A Set containing the unique values collected by the aggregator.\n */\n public getResult(): any {\n return Array.from(this.value);\n }\n}\n"]}
@@ -3,6 +3,8 @@
3
3
  import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator.js";
4
4
  /** @hidden */
5
5
  export class MaxAggregator {
6
+ value;
7
+ comparer;
6
8
  /**
7
9
  * Represents an aggregator for MAX operator.
8
10
  * @hidden
@@ -1 +1 @@
1
- {"version":3,"file":"MaxAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MaxAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAQ5F,cAAc;AACd,MAAM,OAAO,aAAa;IAGxB;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAiC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAyB;QACxC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACzB,CAAC;aAAM,IACL,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAC1F,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator.js\";\nimport type { Aggregator } from \"./Aggregator.js\";\n\ninterface MaxAggregateResult {\n count: number;\n max?: number;\n}\n\n/** @hidden */\nexport class MaxAggregator implements Aggregator {\n private value: number;\n private comparer: OrderByDocumentProducerComparator;\n /**\n * Represents an aggregator for MAX operator.\n * @hidden\n */\n constructor() {\n this.value = undefined;\n this.comparer = new OrderByDocumentProducerComparator([\"Ascending\"]);\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: MaxAggregateResult): void {\n if (this.value === undefined) {\n this.value = other.max;\n } else if (\n this.comparer.compareValue(other.max, typeof other.max, this.value, typeof this.value) > 0\n ) {\n this.value = other.max;\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
1
+ {"version":3,"file":"MaxAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MaxAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAQ5F,cAAc;AACd,MAAM,OAAO,aAAa;IAChB,KAAK,CAAS;IACd,QAAQ,CAAoC;IACpD;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAiC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAyB;QACxC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACzB,CAAC;aAAM,IACL,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAC1F,CAAC;YACD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator.js\";\nimport type { Aggregator } from \"./Aggregator.js\";\n\ninterface MaxAggregateResult {\n count: number;\n max?: number;\n}\n\n/** @hidden */\nexport class MaxAggregator implements Aggregator {\n private value: number;\n private comparer: OrderByDocumentProducerComparator;\n /**\n * Represents an aggregator for MAX operator.\n * @hidden\n */\n constructor() {\n this.value = undefined;\n this.comparer = new OrderByDocumentProducerComparator([\"Ascending\"]);\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: MaxAggregateResult): void {\n if (this.value === undefined) {\n this.value = other.max;\n } else if (\n this.comparer.compareValue(other.max, typeof other.max, this.value, typeof this.value) > 0\n ) {\n this.value = other.max;\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
@@ -3,6 +3,8 @@
3
3
  import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator.js";
4
4
  /** @hidden */
5
5
  export class MinAggregator {
6
+ value;
7
+ comparer;
6
8
  /**
7
9
  * Represents an aggregator for MIN operator.
8
10
  * @hidden
@@ -1 +1 @@
1
- {"version":3,"file":"MinAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MinAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAQ5F,cAAc;AACd,MAAM,OAAO,aAAa;IAGxB;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAiC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAyB;QACxC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,oCAAoC;YACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,+BAA+B;YACpG,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC;YACrE,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator.js\";\nimport type { Aggregator } from \"./Aggregator.js\";\n\nexport interface MinAggregateResult {\n min: number;\n count: number;\n}\n\n/** @hidden */\nexport class MinAggregator implements Aggregator {\n private value: number;\n private comparer: OrderByDocumentProducerComparator;\n /**\n * Represents an aggregator for MIN operator.\n * @hidden\n */\n constructor() {\n this.value = undefined;\n this.comparer = new OrderByDocumentProducerComparator([\"Ascending\"]);\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: MinAggregateResult): void {\n if (this.value === undefined) {\n // || typeof this.value === \"object\"\n this.value = other.min;\n } else {\n const otherType = other.min === null ? \"NoValue\" : typeof other.min; // || typeof other === \"object\"\n const thisType = this.value === null ? \"NoValue\" : typeof this.value;\n if (this.comparer.compareValue(other.min, otherType, this.value, thisType) < 0) {\n this.value = other.min;\n }\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
1
+ {"version":3,"file":"MinAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MinAggregator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAQ5F,cAAc;AACd,MAAM,OAAO,aAAa;IAChB,KAAK,CAAS;IACd,QAAQ,CAAoC;IACpD;;;OAGG;IACH;QACE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAiC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IACD;;OAEG;IACI,SAAS,CAAC,KAAyB;QACxC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,oCAAoC;YACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,+BAA+B;YACpG,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC;YACrE,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC/E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator.js\";\nimport type { Aggregator } from \"./Aggregator.js\";\n\nexport interface MinAggregateResult {\n min: number;\n count: number;\n}\n\n/** @hidden */\nexport class MinAggregator implements Aggregator {\n private value: number;\n private comparer: OrderByDocumentProducerComparator;\n /**\n * Represents an aggregator for MIN operator.\n * @hidden\n */\n constructor() {\n this.value = undefined;\n this.comparer = new OrderByDocumentProducerComparator([\"Ascending\"]);\n }\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: MinAggregateResult): void {\n if (this.value === undefined) {\n // || typeof this.value === \"object\"\n this.value = other.min;\n } else {\n const otherType = other.min === null ? \"NoValue\" : typeof other.min; // || typeof other === \"object\"\n const thisType = this.value === null ? \"NoValue\" : typeof this.value;\n if (this.comparer.compareValue(other.min, otherType, this.value, thisType) < 0) {\n this.value = other.min;\n }\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.value;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  /** @hidden */
2
2
  export class StaticValueAggregator {
3
+ value;
3
4
  aggregate(other) {
4
5
  if (this.value === undefined) {
5
6
  this.value = other;
@@ -1 +1 @@
1
- {"version":3,"file":"StaticValueAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/StaticValueAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,qBAAqB;IAEzB,SAAS,CAAC,KAAc;QAC7B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class StaticValueAggregator implements Aggregator {\n public value: any;\n public aggregate(other: unknown): void {\n if (this.value === undefined) {\n this.value = other;\n }\n }\n\n public getResult(): any {\n return this.value;\n }\n}\n"]}
1
+ {"version":3,"file":"StaticValueAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/StaticValueAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,qBAAqB;IACzB,KAAK,CAAM;IACX,SAAS,CAAC,KAAc;QAC7B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class StaticValueAggregator implements Aggregator {\n public value: any;\n public aggregate(other: unknown): void {\n if (this.value === undefined) {\n this.value = other;\n }\n }\n\n public getResult(): any {\n return this.value;\n }\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  /** @hidden */
2
2
  export class SumAggregator {
3
+ sum;
3
4
  /**
4
5
  * Add the provided item to aggregation result.
5
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"SumAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/SumAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,aAAa;IAExB;;OAEG;IACI,SAAS,CAAC,KAAa;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class SumAggregator implements Aggregator {\n public sum: number;\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: number): void {\n if (other === undefined) {\n return;\n }\n if (this.sum === undefined) {\n this.sum = other;\n } else {\n this.sum += other;\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.sum;\n }\n}\n"]}
1
+ {"version":3,"file":"SumAggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/SumAggregator.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,OAAO,aAAa;IACjB,GAAG,CAAS;IACnB;;OAEG;IACI,SAAS,CAAC,KAAa;QAC5B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAC3B,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;QACnB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IAED;;OAEG;IACI,SAAS;QACd,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Aggregator } from \"./Aggregator.js\";\n\n/** @hidden */\nexport class SumAggregator implements Aggregator {\n public sum: number;\n /**\n * Add the provided item to aggregation result.\n */\n public aggregate(other: number): void {\n if (other === undefined) {\n return;\n }\n if (this.sum === undefined) {\n this.sum = other;\n } else {\n this.sum += other;\n }\n }\n\n /**\n * Get the aggregation result.\n */\n public getResult(): number {\n return this.sum;\n }\n}\n"]}
@@ -4,13 +4,15 @@ import { getInitialHeader, mergeHeaders } from "../headerUtils.js";
4
4
  import { emptyGroup, extractAggregateResult } from "./emptyGroup.js";
5
5
  /** @hidden */
6
6
  export class GroupByEndpointComponent {
7
+ executionContext;
8
+ queryInfo;
7
9
  constructor(executionContext, queryInfo) {
8
10
  this.executionContext = executionContext;
9
11
  this.queryInfo = queryInfo;
10
- this.groupings = new Map();
11
- this.aggregateResultArray = [];
12
- this.completed = false;
13
12
  }
13
+ groupings = new Map();
14
+ aggregateResultArray = [];
15
+ completed = false;
14
16
  hasMoreResults() {
15
17
  return this.executionContext.hasMoreResults();
16
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"GroupByEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAQrE,cAAc;AACd,MAAM,OAAO,wBAAwB;IACnC,YACU,gBAAkC,EAClC,SAAoB;QADp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;6BAAM,CAAC;4BACN,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;wBACrC,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,EAAE,CAAC;YAC3C,OAAO;gBACL,MAAM,EAAE,EAAE;gBACV,OAAO,EAAE,gBAAgB;aAC1B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,IAAI,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAEO,uBAAuB,CAAC,gBAA+B;QAC7D,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/C,MAAM,WAAW,GAAQ,EAAE,CAAC;YAC5B,KAAK,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC5D,WAAW,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;YACrD,CAAC;YACD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC1E,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Response } from \"../../request/index.js\";\nimport type { ExecutionContext } from \"../ExecutionContext.js\";\nimport type { CosmosHeaders } from \"../CosmosHeaders.js\";\nimport type { QueryInfo } from \"../../request/ErrorResponse.js\";\nimport { hashObject } from \"../../utils/hashObject.js\";\nimport type { Aggregator } from \"../Aggregators/index.js\";\nimport { createAggregator } from \"../Aggregators/index.js\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils.js\";\nimport { emptyGroup, extractAggregateResult } from \"./emptyGroup.js\";\nimport type { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal.js\";\n\ninterface GroupByResult {\n groupByItems: any[];\n payload: any;\n}\n\n/** @hidden */\nexport class GroupByEndpointComponent implements ExecutionContext {\n constructor(\n private executionContext: ExecutionContext,\n private queryInfo: QueryInfo,\n ) {}\n\n private readonly groupings: Map<string, Map<string, Aggregator>> = new Map();\n private readonly aggregateResultArray: any[] = [];\n private completed: boolean = false;\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n\n public async fetchMore(diagnosticNode: DiagnosticNodeInternal): Promise<Response<any>> {\n if (this.completed) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n const aggregateHeaders = getInitialHeader();\n const response = await this.executionContext.fetchMore(diagnosticNode);\n mergeHeaders(aggregateHeaders, response.headers);\n\n if (response === undefined || response.result === undefined) {\n // If there are any groupings, consolidate and return them\n if (this.groupings.size > 0) {\n return this.consolidateGroupResults(aggregateHeaders);\n }\n return { result: undefined, headers: aggregateHeaders };\n }\n\n for (const item of response.result as GroupByResult[]) {\n // If it exists, process it via aggregators\n if (item) {\n const group = item.groupByItems ? await hashObject(item.groupByItems) : emptyGroup;\n const aggregators = this.groupings.get(group);\n const payload = item.payload;\n if (aggregators) {\n // Iterator over all results in the payload\n for (const key of Object.keys(payload)) {\n // in case the value of a group is null make sure we create a dummy payload with item2==null\n const effectiveGroupByValue = payload[key]\n ? payload[key]\n : new Map().set(\"item2\", null);\n const aggregateResult = extractAggregateResult(effectiveGroupByValue);\n aggregators.get(key).aggregate(aggregateResult);\n }\n } else {\n // This is the first time we have seen a grouping. Setup the initial result without aggregate values\n const grouping = new Map();\n this.groupings.set(group, grouping);\n // Iterator over all results in the payload\n for (const key of Object.keys(payload)) {\n const aggregateType = this.queryInfo.groupByAliasToAggregateType[key];\n // Create a new aggregator for this specific aggregate field\n const aggregator = createAggregator(aggregateType);\n grouping.set(key, aggregator);\n if (aggregateType) {\n const aggregateResult = extractAggregateResult(payload[key]);\n aggregator.aggregate(aggregateResult);\n } else {\n aggregator.aggregate(payload[key]);\n }\n }\n }\n }\n }\n\n if (this.executionContext.hasMoreResults()) {\n return {\n result: [],\n headers: aggregateHeaders,\n };\n } else {\n return this.consolidateGroupResults(aggregateHeaders);\n }\n }\n\n private consolidateGroupResults(aggregateHeaders: CosmosHeaders): Response<any> {\n for (const grouping of this.groupings.values()) {\n const groupResult: any = {};\n for (const [aggregateKey, aggregator] of grouping.entries()) {\n groupResult[aggregateKey] = aggregator.getResult();\n }\n this.aggregateResultArray.push(groupResult);\n }\n this.completed = true;\n return { result: this.aggregateResultArray, headers: aggregateHeaders };\n }\n}\n"]}
1
+ {"version":3,"file":"GroupByEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAQrE,cAAc;AACd,MAAM,OAAO,wBAAwB;IAEzB;IACA;IAFV,YACU,gBAAkC,EAClC,SAAoB;QADpB,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,cAAS,GAAT,SAAS,CAAW;IAC3B,CAAC;IAEa,SAAS,GAAyC,IAAI,GAAG,EAAE,CAAC;IAC5D,oBAAoB,GAAU,EAAE,CAAC;IAC1C,SAAS,GAAY,KAAK,CAAC;IAE5B,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,cAAsC;QAC3D,IAAI,IAAI,CAAC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AAuB,CAAC,gBAAgB,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAEO,uBAAuB,CAAC,gBAA+B;QAC7D,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/C,MAAM,WAAW,GAAQ,EAAE,CAAC;YAC5B,KAAK,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC5D,WAAW,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;YACrD,CAAC;YACD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9C,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC1E,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport type { Response } from \"../../request/index.js\";\nimport type { ExecutionContext } from \"../ExecutionContext.js\";\nimport type { CosmosHeaders } from \"../CosmosHeaders.js\";\nimport type { QueryInfo } from \"../../request/ErrorResponse.js\";\nimport { hashObject } from \"../../utils/hashObject.js\";\nimport type { Aggregator } from \"../Aggregators/index.js\";\nimport { createAggregator } from \"../Aggregators/index.js\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils.js\";\nimport { emptyGroup, extractAggregateResult } from \"./emptyGroup.js\";\nimport type { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal.js\";\n\ninterface GroupByResult {\n groupByItems: any[];\n payload: any;\n}\n\n/** @hidden */\nexport class GroupByEndpointComponent implements ExecutionContext {\n constructor(\n private executionContext: ExecutionContext,\n private queryInfo: QueryInfo,\n ) {}\n\n private readonly groupings: Map<string, Map<string, Aggregator>> = new Map();\n private readonly aggregateResultArray: any[] = [];\n private completed: boolean = false;\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n\n public async fetchMore(diagnosticNode: DiagnosticNodeInternal): Promise<Response<any>> {\n if (this.completed) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n const aggregateHeaders = getInitialHeader();\n const response = await this.executionContext.fetchMore(diagnosticNode);\n mergeHeaders(aggregateHeaders, response.headers);\n\n if (response === undefined || response.result === undefined) {\n // If there are any groupings, consolidate and return them\n if (this.groupings.size > 0) {\n return this.consolidateGroupResults(aggregateHeaders);\n }\n return { result: undefined, headers: aggregateHeaders };\n }\n\n for (const item of response.result as GroupByResult[]) {\n // If it exists, process it via aggregators\n if (item) {\n const group = item.groupByItems ? await hashObject(item.groupByItems) : emptyGroup;\n const aggregators = this.groupings.get(group);\n const payload = item.payload;\n if (aggregators) {\n // Iterator over all results in the payload\n for (const key of Object.keys(payload)) {\n // in case the value of a group is null make sure we create a dummy payload with item2==null\n const effectiveGroupByValue = payload[key]\n ? payload[key]\n : new Map().set(\"item2\", null);\n const aggregateResult = extractAggregateResult(effectiveGroupByValue);\n aggregators.get(key).aggregate(aggregateResult);\n }\n } else {\n // This is the first time we have seen a grouping. Setup the initial result without aggregate values\n const grouping = new Map();\n this.groupings.set(group, grouping);\n // Iterator over all results in the payload\n for (const key of Object.keys(payload)) {\n const aggregateType = this.queryInfo.groupByAliasToAggregateType[key];\n // Create a new aggregator for this specific aggregate field\n const aggregator = createAggregator(aggregateType);\n grouping.set(key, aggregator);\n if (aggregateType) {\n const aggregateResult = extractAggregateResult(payload[key]);\n aggregator.aggregate(aggregateResult);\n } else {\n aggregator.aggregate(payload[key]);\n }\n }\n }\n }\n }\n\n if (this.executionContext.hasMoreResults()) {\n return {\n result: [],\n headers: aggregateHeaders,\n };\n } else {\n return this.consolidateGroupResults(aggregateHeaders);\n }\n }\n\n private consolidateGroupResults(aggregateHeaders: CosmosHeaders): Response<any> {\n for (const grouping of this.groupings.values()) {\n const groupResult: any = {};\n for (const [aggregateKey, aggregator] of grouping.entries()) {\n groupResult[aggregateKey] = aggregator.getResult();\n }\n this.aggregateResultArray.push(groupResult);\n }\n this.completed = true;\n return { result: this.aggregateResultArray, headers: aggregateHeaders };\n }\n}\n"]}