From ca396cdfbebf4b01e88fe7efb543c2f6956d559b Mon Sep 17 00:00:00 2001 From: Theo van Kraay Date: Sat, 31 Aug 2024 16:44:42 +0100 Subject: [PATCH] add copy of cosmos node.js SDK as local dependency --- local_dependencies/@azure/cosmos/CHANGELOG.md | 1153 ++ local_dependencies/@azure/cosmos/LICENSE | 21 + local_dependencies/@azure/cosmos/README.md | 571 + .../dist-esm/src/ChangeFeedIterator.d.ts | 38 + .../dist-esm/src/ChangeFeedIterator.d.ts.map | 1 + .../cosmos/dist-esm/src/ChangeFeedIterator.js | 107 + .../dist-esm/src/ChangeFeedIterator.js.map | 1 + .../dist-esm/src/ChangeFeedOptions.d.ts | 35 + .../dist-esm/src/ChangeFeedOptions.d.ts.map | 1 + .../cosmos/dist-esm/src/ChangeFeedOptions.js | 2 + .../dist-esm/src/ChangeFeedOptions.js.map | 1 + .../dist-esm/src/ChangeFeedResponse.d.ts | 53 + .../dist-esm/src/ChangeFeedResponse.d.ts.map | 1 + .../cosmos/dist-esm/src/ChangeFeedResponse.js | 68 + .../dist-esm/src/ChangeFeedResponse.js.map | 1 + .../cosmos/dist-esm/src/ClientContext.d.ts | 155 + .../dist-esm/src/ClientContext.d.ts.map | 1 + .../cosmos/dist-esm/src/ClientContext.js | 524 + .../cosmos/dist-esm/src/ClientContext.js.map | 1 + .../cosmos/dist-esm/src/CosmosClient.d.ts | 116 + .../cosmos/dist-esm/src/CosmosClient.d.ts.map | 1 + .../cosmos/dist-esm/src/CosmosClient.js | 181 + .../cosmos/dist-esm/src/CosmosClient.js.map | 1 + .../dist-esm/src/CosmosClientOptions.d.ts | 54 + .../dist-esm/src/CosmosClientOptions.d.ts.map | 1 + .../dist-esm/src/CosmosClientOptions.js | 2 + .../dist-esm/src/CosmosClientOptions.js.map | 1 + .../dist-esm/src/CosmosDiagnostics.d.ts | 202 + .../dist-esm/src/CosmosDiagnostics.d.ts.map | 1 + .../cosmos/dist-esm/src/CosmosDiagnostics.js | 51 + .../dist-esm/src/CosmosDiagnostics.js.map | 1 + .../@azure/cosmos/dist-esm/src/auth.d.ts | 28 + .../@azure/cosmos/dist-esm/src/auth.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/auth.js | 87 + .../@azure/cosmos/dist-esm/src/auth.js.map | 1 + .../client/ChangeFeed/ChangeFeedEnums.d.ts | 8 + .../ChangeFeed/ChangeFeedEnums.d.ts.map | 1 + .../src/client/ChangeFeed/ChangeFeedEnums.js | 11 + .../client/ChangeFeed/ChangeFeedEnums.js.map | 1 + .../ChangeFeed/ChangeFeedForEpkRange.d.ts | 72 + .../ChangeFeed/ChangeFeedForEpkRange.d.ts.map | 1 + .../ChangeFeed/ChangeFeedForEpkRange.js | 313 + .../ChangeFeed/ChangeFeedForEpkRange.js.map | 1 + .../ChangeFeed/ChangeFeedForPartitionKey.d.ts | 42 + .../ChangeFeedForPartitionKey.d.ts.map | 1 + .../ChangeFeed/ChangeFeedForPartitionKey.js | 123 + .../ChangeFeedForPartitionKey.js.map | 1 + .../ChangeFeed/ChangeFeedIteratorOptions.d.ts | 21 + .../ChangeFeedIteratorOptions.d.ts.map | 1 + .../ChangeFeed/ChangeFeedIteratorOptions.js | 4 + .../ChangeFeedIteratorOptions.js.map | 1 + .../ChangeFeedIteratorResponse.d.ts | 48 + .../ChangeFeedIteratorResponse.d.ts.map | 1 + .../ChangeFeed/ChangeFeedIteratorResponse.js | 67 + .../ChangeFeedIteratorResponse.js.map | 1 + .../ChangeFeedPullModelIterator.d.ts | 27 + .../ChangeFeedPullModelIterator.d.ts.map | 1 + .../ChangeFeed/ChangeFeedPullModelIterator.js | 2 + .../ChangeFeedPullModelIterator.js.map | 1 + .../client/ChangeFeed/ChangeFeedRange.d.ts | 2 + .../ChangeFeed/ChangeFeedRange.d.ts.map | 1 + .../src/client/ChangeFeed/ChangeFeedRange.js | 16 + .../client/ChangeFeed/ChangeFeedRange.js.map | 1 + .../ChangeFeed/ChangeFeedStartFrom.d.ts | 33 + .../ChangeFeed/ChangeFeedStartFrom.d.ts.map | 1 + .../client/ChangeFeed/ChangeFeedStartFrom.js | 56 + .../ChangeFeed/ChangeFeedStartFrom.js.map | 1 + .../ChangeFeedStartFromBeginning.d.ts | 12 + .../ChangeFeedStartFromBeginning.d.ts.map | 1 + .../ChangeFeedStartFromBeginning.js | 13 + .../ChangeFeedStartFromBeginning.js.map | 1 + .../ChangeFeedStartFromContinuation.d.ts | 12 + .../ChangeFeedStartFromContinuation.d.ts.map | 1 + .../ChangeFeedStartFromContinuation.js | 36 + .../ChangeFeedStartFromContinuation.js.map | 1 + .../ChangeFeed/ChangeFeedStartFromNow.d.ts | 12 + .../ChangeFeedStartFromNow.d.ts.map | 1 + .../ChangeFeed/ChangeFeedStartFromNow.js | 15 + .../ChangeFeed/ChangeFeedStartFromNow.js.map | 1 + .../ChangeFeed/ChangeFeedStartFromTime.d.ts | 14 + .../ChangeFeedStartFromTime.d.ts.map | 1 + .../ChangeFeed/ChangeFeedStartFromTime.js | 17 + .../ChangeFeed/ChangeFeedStartFromTime.js.map | 1 + .../CompositeContinuationToken.d.ts | 2 + .../CompositeContinuationToken.d.ts.map | 1 + .../ChangeFeed/CompositeContinuationToken.js | 11 + .../CompositeContinuationToken.js.map | 1 + .../ContinuationTokenForPartitionKey.d.ts | 2 + .../ContinuationTokenForPartitionKey.d.ts.map | 1 + .../ContinuationTokenForPartitionKey.js | 12 + .../ContinuationTokenForPartitionKey.js.map | 1 + .../src/client/ChangeFeed/FeedRange.d.ts | 21 + .../src/client/ChangeFeed/FeedRange.d.ts.map | 1 + .../src/client/ChangeFeed/FeedRange.js | 30 + .../src/client/ChangeFeed/FeedRange.js.map | 1 + .../src/client/ChangeFeed/FeedRangeQueue.d.ts | 20 + .../client/ChangeFeed/FeedRangeQueue.d.ts.map | 1 + .../src/client/ChangeFeed/FeedRangeQueue.js | 48 + .../client/ChangeFeed/FeedRangeQueue.js.map | 1 + .../ChangeFeed/InternalChangeFeedOptions.d.ts | 11 + .../InternalChangeFeedOptions.d.ts.map | 1 + .../ChangeFeed/InternalChangeFeedOptions.js | 4 + .../InternalChangeFeedOptions.js.map | 1 + .../ChangeFeed/changeFeedIteratorBuilder.d.ts | 6 + .../changeFeedIteratorBuilder.d.ts.map | 1 + .../ChangeFeed/changeFeedIteratorBuilder.js | 64 + .../changeFeedIteratorBuilder.js.map | 1 + .../client/ChangeFeed/changeFeedUtils.d.ts | 35 + .../ChangeFeed/changeFeedUtils.d.ts.map | 1 + .../src/client/ChangeFeed/changeFeedUtils.js | 104 + .../client/ChangeFeed/changeFeedUtils.js.map | 1 + .../dist-esm/src/client/ChangeFeed/index.d.ts | 10 + .../src/client/ChangeFeed/index.d.ts.map | 1 + .../dist-esm/src/client/ChangeFeed/index.js | 10 + .../src/client/ChangeFeed/index.js.map | 1 + .../dist-esm/src/client/ClientUtils.d.ts | 5 + .../dist-esm/src/client/ClientUtils.d.ts.map | 1 + .../cosmos/dist-esm/src/client/ClientUtils.js | 7 + .../dist-esm/src/client/ClientUtils.js.map | 1 + .../src/client/Conflict/Conflict.d.ts | 35 + .../src/client/Conflict/Conflict.d.ts.map | 1 + .../dist-esm/src/client/Conflict/Conflict.js | 70 + .../src/client/Conflict/Conflict.js.map | 1 + .../client/Conflict/ConflictDefinition.d.ts | 11 + .../Conflict/ConflictDefinition.d.ts.map | 1 + .../src/client/Conflict/ConflictDefinition.js | 2 + .../client/Conflict/ConflictDefinition.js.map | 1 + .../Conflict/ConflictResolutionMode.d.ts | 5 + .../Conflict/ConflictResolutionMode.d.ts.map | 1 + .../client/Conflict/ConflictResolutionMode.js | 8 + .../Conflict/ConflictResolutionMode.js.map | 1 + .../Conflict/ConflictResolutionPolicy.d.ts | 38 + .../ConflictResolutionPolicy.d.ts.map | 1 + .../Conflict/ConflictResolutionPolicy.js | 2 + .../Conflict/ConflictResolutionPolicy.js.map | 1 + .../src/client/Conflict/ConflictResponse.d.ts | 12 + .../client/Conflict/ConflictResponse.d.ts.map | 1 + .../src/client/Conflict/ConflictResponse.js | 8 + .../client/Conflict/ConflictResponse.js.map | 1 + .../src/client/Conflict/Conflicts.d.ts | 37 + .../src/client/Conflict/Conflicts.d.ts.map | 1 + .../dist-esm/src/client/Conflict/Conflicts.js | 36 + .../src/client/Conflict/Conflicts.js.map | 1 + .../dist-esm/src/client/Conflict/index.d.ts | 7 + .../src/client/Conflict/index.d.ts.map | 1 + .../dist-esm/src/client/Conflict/index.js | 7 + .../dist-esm/src/client/Conflict/index.js.map | 1 + .../src/client/Container/Container.d.ts | 121 + .../src/client/Container/Container.d.ts.map | 1 + .../src/client/Container/Container.js | 251 + .../src/client/Container/Container.js.map | 1 + .../client/Container/ContainerDefinition.d.ts | 26 + .../Container/ContainerDefinition.d.ts.map | 1 + .../client/Container/ContainerDefinition.js | 2 + .../Container/ContainerDefinition.js.map | 1 + .../client/Container/ContainerRequest.d.ts | 14 + .../Container/ContainerRequest.d.ts.map | 1 + .../src/client/Container/ContainerRequest.js | 2 + .../client/Container/ContainerRequest.js.map | 1 + .../client/Container/ContainerResponse.d.ts | 13 + .../Container/ContainerResponse.d.ts.map | 1 + .../src/client/Container/ContainerResponse.js | 9 + .../client/Container/ContainerResponse.js.map | 1 + .../src/client/Container/Containers.d.ts | 112 + .../src/client/Container/Containers.d.ts.map | 1 + .../src/client/Container/Containers.js | 177 + .../src/client/Container/Containers.js.map | 1 + .../client/Container/PartitionKeyRange.d.ts | 13 + .../Container/PartitionKeyRange.d.ts.map | 1 + .../src/client/Container/PartitionKeyRange.js | 2 + .../client/Container/PartitionKeyRange.js.map | 1 + .../src/client/Container/UniqueKeyPolicy.d.ts | 9 + .../client/Container/UniqueKeyPolicy.d.ts.map | 1 + .../src/client/Container/UniqueKeyPolicy.js | 2 + .../client/Container/UniqueKeyPolicy.js.map | 1 + .../dist-esm/src/client/Container/index.d.ts | 8 + .../src/client/Container/index.d.ts.map | 1 + .../dist-esm/src/client/Container/index.js | 6 + .../src/client/Container/index.js.map | 1 + .../src/client/Database/Database.d.ts | 79 + .../src/client/Database/Database.d.ts.map | 1 + .../dist-esm/src/client/Database/Database.js | 119 + .../src/client/Database/Database.js.map | 1 + .../client/Database/DatabaseDefinition.d.ts | 5 + .../Database/DatabaseDefinition.d.ts.map | 1 + .../src/client/Database/DatabaseDefinition.js | 2 + .../client/Database/DatabaseDefinition.js.map | 1 + .../src/client/Database/DatabaseRequest.d.ts | 12 + .../client/Database/DatabaseRequest.d.ts.map | 1 + .../src/client/Database/DatabaseRequest.js | 2 + .../client/Database/DatabaseRequest.js.map | 1 + .../src/client/Database/DatabaseResponse.d.ts | 13 + .../client/Database/DatabaseResponse.d.ts.map | 1 + .../src/client/Database/DatabaseResponse.js | 9 + .../client/Database/DatabaseResponse.js.map | 1 + .../src/client/Database/Databases.d.ts | 109 + .../src/client/Database/Databases.d.ts.map | 1 + .../dist-esm/src/client/Database/Databases.js | 158 + .../src/client/Database/Databases.js.map | 1 + .../dist-esm/src/client/Database/index.d.ts | 6 + .../src/client/Database/index.d.ts.map | 1 + .../dist-esm/src/client/Database/index.js | 6 + .../dist-esm/src/client/Database/index.js.map | 1 + .../cosmos/dist-esm/src/client/Item/Item.d.ts | 94 + .../dist-esm/src/client/Item/Item.d.ts.map | 1 + .../cosmos/dist-esm/src/client/Item/Item.js | 164 + .../dist-esm/src/client/Item/Item.js.map | 1 + .../src/client/Item/ItemDefinition.d.ts | 16 + .../src/client/Item/ItemDefinition.d.ts.map | 1 + .../src/client/Item/ItemDefinition.js | 4 + .../src/client/Item/ItemDefinition.js.map | 1 + .../src/client/Item/ItemResponse.d.ts | 12 + .../src/client/Item/ItemResponse.d.ts.map | 1 + .../dist-esm/src/client/Item/ItemResponse.js | 8 + .../src/client/Item/ItemResponse.js.map | 1 + .../dist-esm/src/client/Item/Items.d.ts | 244 + .../dist-esm/src/client/Item/Items.d.ts.map | 1 + .../cosmos/dist-esm/src/client/Item/Items.js | 316 + .../dist-esm/src/client/Item/Items.js.map | 1 + .../dist-esm/src/client/Item/index.d.ts | 5 + .../dist-esm/src/client/Item/index.d.ts.map | 1 + .../cosmos/dist-esm/src/client/Item/index.js | 6 + .../dist-esm/src/client/Item/index.js.map | 1 + .../dist-esm/src/client/Offer/Offer.d.ts | 35 + .../dist-esm/src/client/Offer/Offer.d.ts.map | 1 + .../cosmos/dist-esm/src/client/Offer/Offer.js | 63 + .../dist-esm/src/client/Offer/Offer.js.map | 1 + .../src/client/Offer/OfferDefinition.d.ts | 22 + .../src/client/Offer/OfferDefinition.d.ts.map | 1 + .../src/client/Offer/OfferDefinition.js | 2 + .../src/client/Offer/OfferDefinition.js.map | 1 + .../src/client/Offer/OfferResponse.d.ts | 12 + .../src/client/Offer/OfferResponse.d.ts.map | 1 + .../src/client/Offer/OfferResponse.js | 8 + .../src/client/Offer/OfferResponse.js.map | 1 + .../dist-esm/src/client/Offer/Offers.d.ts | 40 + .../dist-esm/src/client/Offer/Offers.d.ts.map | 1 + .../dist-esm/src/client/Offer/Offers.js | 41 + .../dist-esm/src/client/Offer/Offers.js.map | 1 + .../dist-esm/src/client/Offer/index.d.ts | 5 + .../dist-esm/src/client/Offer/index.d.ts.map | 1 + .../cosmos/dist-esm/src/client/Offer/index.js | 6 + .../dist-esm/src/client/Offer/index.js.map | 1 + .../src/client/Permission/Permission.d.ts | 39 + .../src/client/Permission/Permission.d.ts.map | 1 + .../src/client/Permission/Permission.js | 84 + .../src/client/Permission/Permission.js.map | 1 + .../src/client/Permission/PermissionBody.d.ts | 5 + .../client/Permission/PermissionBody.d.ts.map | 1 + .../src/client/Permission/PermissionBody.js | 2 + .../client/Permission/PermissionBody.js.map | 1 + .../Permission/PermissionDefinition.d.ts | 11 + .../Permission/PermissionDefinition.d.ts.map | 1 + .../client/Permission/PermissionDefinition.js | 2 + .../Permission/PermissionDefinition.js.map | 1 + .../client/Permission/PermissionResponse.d.ts | 13 + .../Permission/PermissionResponse.d.ts.map | 1 + .../client/Permission/PermissionResponse.js | 8 + .../Permission/PermissionResponse.js.map | 1 + .../src/client/Permission/Permissions.d.ts | 56 + .../client/Permission/Permissions.d.ts.map | 1 + .../src/client/Permission/Permissions.js | 99 + .../src/client/Permission/Permissions.js.map | 1 + .../dist-esm/src/client/Permission/index.d.ts | 6 + .../src/client/Permission/index.d.ts.map | 1 + .../dist-esm/src/client/Permission/index.js | 6 + .../src/client/Permission/index.js.map | 1 + .../cosmos/dist-esm/src/client/Resource.d.ts | 13 + .../dist-esm/src/client/Resource.d.ts.map | 1 + .../cosmos/dist-esm/src/client/Resource.js | 2 + .../dist-esm/src/client/Resource.js.map | 1 + .../SasToken/PermissionScopeValues.d.ts | 74 + .../SasToken/PermissionScopeValues.d.ts.map | 1 + .../client/SasToken/PermissionScopeValues.js | 77 + .../SasToken/PermissionScopeValues.js.map | 1 + .../client/SasToken/SasTokenProperties.d.ts | 22 + .../SasToken/SasTokenProperties.d.ts.map | 1 + .../src/client/SasToken/SasTokenProperties.js | 5 + .../client/SasToken/SasTokenProperties.js.map | 1 + .../dist-esm/src/client/Script/Scripts.d.ts | 57 + .../src/client/Script/Scripts.d.ts.map | 1 + .../dist-esm/src/client/Script/Scripts.js | 76 + .../dist-esm/src/client/Script/Scripts.js.map | 1 + .../StoredProcedure/StoredProcedure.d.ts | 52 + .../StoredProcedure/StoredProcedure.d.ts.map | 1 + .../client/StoredProcedure/StoredProcedure.js | 117 + .../StoredProcedure/StoredProcedure.js.map | 1 + .../StoredProcedureDefinition.d.ts | 11 + .../StoredProcedureDefinition.d.ts.map | 1 + .../StoredProcedureDefinition.js | 2 + .../StoredProcedureDefinition.js.map | 1 + .../StoredProcedureResponse.d.ts | 20 + .../StoredProcedureResponse.d.ts.map | 1 + .../StoredProcedureResponse.js | 16 + .../StoredProcedureResponse.js.map | 1 + .../StoredProcedure/StoredProcedures.d.ts | 71 + .../StoredProcedure/StoredProcedures.d.ts.map | 1 + .../StoredProcedure/StoredProcedures.js | 78 + .../StoredProcedure/StoredProcedures.js.map | 1 + .../src/client/StoredProcedure/index.d.ts | 5 + .../src/client/StoredProcedure/index.d.ts.map | 1 + .../src/client/StoredProcedure/index.js | 6 + .../src/client/StoredProcedure/index.js.map | 1 + .../dist-esm/src/client/Trigger/Trigger.d.ts | 39 + .../src/client/Trigger/Trigger.d.ts.map | 1 + .../dist-esm/src/client/Trigger/Trigger.js | 87 + .../src/client/Trigger/Trigger.js.map | 1 + .../src/client/Trigger/TriggerDefinition.d.ts | 12 + .../client/Trigger/TriggerDefinition.d.ts.map | 1 + .../src/client/Trigger/TriggerDefinition.js | 2 + .../client/Trigger/TriggerDefinition.js.map | 1 + .../src/client/Trigger/TriggerResponse.d.ts | 12 + .../client/Trigger/TriggerResponse.d.ts.map | 1 + .../src/client/Trigger/TriggerResponse.js | 8 + .../src/client/Trigger/TriggerResponse.js.map | 1 + .../dist-esm/src/client/Trigger/Triggers.d.ts | 50 + .../src/client/Trigger/Triggers.d.ts.map | 1 + .../dist-esm/src/client/Trigger/Triggers.js | 77 + .../src/client/Trigger/Triggers.js.map | 1 + .../dist-esm/src/client/Trigger/index.d.ts | 5 + .../src/client/Trigger/index.d.ts.map | 1 + .../dist-esm/src/client/Trigger/index.js | 6 + .../dist-esm/src/client/Trigger/index.js.map | 1 + .../cosmos/dist-esm/src/client/User/User.d.ts | 53 + .../dist-esm/src/client/User/User.d.ts.map | 1 + .../cosmos/dist-esm/src/client/User/User.js | 95 + .../dist-esm/src/client/User/User.js.map | 1 + .../src/client/User/UserDefinition.d.ts | 5 + .../src/client/User/UserDefinition.d.ts.map | 1 + .../src/client/User/UserDefinition.js | 2 + .../src/client/User/UserDefinition.js.map | 1 + .../src/client/User/UserResponse.d.ts | 12 + .../src/client/User/UserResponse.d.ts.map | 1 + .../dist-esm/src/client/User/UserResponse.js | 8 + .../src/client/User/UserResponse.js.map | 1 + .../dist-esm/src/client/User/Users.d.ts | 51 + .../dist-esm/src/client/User/Users.d.ts.map | 1 + .../cosmos/dist-esm/src/client/User/Users.js | 94 + .../dist-esm/src/client/User/Users.js.map | 1 + .../dist-esm/src/client/User/index.d.ts | 5 + .../dist-esm/src/client/User/index.d.ts.map | 1 + .../cosmos/dist-esm/src/client/User/index.js | 6 + .../dist-esm/src/client/User/index.js.map | 1 + .../UserDefinedFunction.d.ts | 39 + .../UserDefinedFunction.d.ts.map | 1 + .../UserDefinedFunction.js | 87 + .../UserDefinedFunction.js.map | 1 + .../UserDefinedFunctionDefinition.d.ts | 7 + .../UserDefinedFunctionDefinition.d.ts.map | 1 + .../UserDefinedFunctionDefinition.js | 2 + .../UserDefinedFunctionDefinition.js.map | 1 + .../UserDefinedFunctionResponse.d.ts | 18 + .../UserDefinedFunctionResponse.d.ts.map | 1 + .../UserDefinedFunctionResponse.js | 16 + .../UserDefinedFunctionResponse.js.map | 1 + .../UserDefinedFunctions.d.ts | 50 + .../UserDefinedFunctions.d.ts.map | 1 + .../UserDefinedFunctions.js | 77 + .../UserDefinedFunctions.js.map | 1 + .../src/client/UserDefinedFunction/index.d.ts | 5 + .../client/UserDefinedFunction/index.d.ts.map | 1 + .../src/client/UserDefinedFunction/index.js | 6 + .../client/UserDefinedFunction/index.js.map | 1 + .../cosmos/dist-esm/src/client/index.d.ts | 13 + .../cosmos/dist-esm/src/client/index.d.ts.map | 1 + .../cosmos/dist-esm/src/client/index.js | 15 + .../cosmos/dist-esm/src/client/index.js.map | 1 + .../src/common/RUConsumedManager.d.ts | 13 + .../src/common/RUConsumedManager.d.ts.map | 1 + .../dist-esm/src/common/RUConsumedManager.js | 32 + .../src/common/RUConsumedManager.js.map | 1 + .../cosmos/dist-esm/src/common/constants.d.ts | 372 + .../dist-esm/src/common/constants.d.ts.map | 1 + .../cosmos/dist-esm/src/common/constants.js | 419 + .../dist-esm/src/common/constants.js.map | 1 + .../cosmos/dist-esm/src/common/helper.d.ts | 87 + .../dist-esm/src/common/helper.d.ts.map | 1 + .../cosmos/dist-esm/src/common/helper.js | 295 + .../cosmos/dist-esm/src/common/helper.js.map | 1 + .../cosmos/dist-esm/src/common/index.d.ts | 6 + .../cosmos/dist-esm/src/common/index.d.ts.map | 1 + .../cosmos/dist-esm/src/common/index.js | 8 + .../cosmos/dist-esm/src/common/index.js.map | 1 + .../cosmos/dist-esm/src/common/logger.d.ts | 6 + .../dist-esm/src/common/logger.d.ts.map | 1 + .../cosmos/dist-esm/src/common/logger.js | 8 + .../cosmos/dist-esm/src/common/logger.js.map | 1 + .../dist-esm/src/common/partitionKeys.d.ts | 2 + .../src/common/partitionKeys.d.ts.map | 1 + .../dist-esm/src/common/partitionKeys.js | 4 + .../dist-esm/src/common/partitionKeys.js.map | 1 + .../cosmos/dist-esm/src/common/platform.d.ts | 5 + .../dist-esm/src/common/platform.d.ts.map | 1 + .../cosmos/dist-esm/src/common/platform.js | 15 + .../dist-esm/src/common/platform.js.map | 1 + .../dist-esm/src/common/statusCodes.d.ts | 48 + .../dist-esm/src/common/statusCodes.d.ts.map | 1 + .../cosmos/dist-esm/src/common/statusCodes.js | 51 + .../dist-esm/src/common/statusCodes.js.map | 1 + .../dist-esm/src/common/uriFactory.d.ts | 128 + .../dist-esm/src/common/uriFactory.d.ts.map | 1 + .../cosmos/dist-esm/src/common/uriFactory.js | 204 + .../dist-esm/src/common/uriFactory.js.map | 1 + .../diagnostics/CosmosDbDiagnosticLevel.d.ts | 9 + .../CosmosDbDiagnosticLevel.d.ts.map | 1 + .../diagnostics/CosmosDbDiagnosticLevel.js | 12 + .../CosmosDbDiagnosticLevel.js.map | 1 + .../diagnostics/CosmosDiagnosticsContext.d.ts | 30 + .../CosmosDiagnosticsContext.d.ts.map | 1 + .../diagnostics/CosmosDiagnosticsContext.js | 96 + .../CosmosDiagnosticsContext.js.map | 1 + .../src/diagnostics/DiagnosticFormatter.d.ts | 8 + .../diagnostics/DiagnosticFormatter.d.ts.map | 1 + .../src/diagnostics/DiagnosticFormatter.js | 8 + .../diagnostics/DiagnosticFormatter.js.map | 1 + .../diagnostics/DiagnosticNodeInternal.d.ts | 71 + .../DiagnosticNodeInternal.d.ts.map | 1 + .../src/diagnostics/DiagnosticNodeInternal.js | 225 + .../diagnostics/DiagnosticNodeInternal.js.map | 1 + .../src/diagnostics/DiagnosticWriter.d.ts | 24 + .../src/diagnostics/DiagnosticWriter.d.ts.map | 1 + .../src/diagnostics/DiagnosticWriter.js | 26 + .../src/diagnostics/DiagnosticWriter.js.map | 1 + .../diagnosticLevelComparator.d.ts | 10 + .../diagnosticLevelComparator.d.ts.map | 1 + .../diagnostics/diagnosticLevelComparator.js | 23 + .../diagnosticLevelComparator.js.map | 1 + .../dist-esm/src/diagnostics/index.d.ts | 8 + .../dist-esm/src/diagnostics/index.d.ts.map | 1 + .../cosmos/dist-esm/src/diagnostics/index.js | 40 + .../dist-esm/src/diagnostics/index.js.map | 1 + .../src/documents/ConnectionMode.d.ts | 6 + .../src/documents/ConnectionMode.d.ts.map | 1 + .../dist-esm/src/documents/ConnectionMode.js | 9 + .../src/documents/ConnectionMode.js.map | 1 + .../src/documents/ConnectionPolicy.d.ts | 35 + .../src/documents/ConnectionPolicy.d.ts.map | 1 + .../src/documents/ConnectionPolicy.js | 19 + .../src/documents/ConnectionPolicy.js.map | 1 + .../src/documents/ConsistencyLevel.d.ts | 37 + .../src/documents/ConsistencyLevel.d.ts.map | 1 + .../src/documents/ConsistencyLevel.js | 40 + .../src/documents/ConsistencyLevel.js.map | 1 + .../dist-esm/src/documents/DataType.d.ts | 16 + .../dist-esm/src/documents/DataType.d.ts.map | 1 + .../cosmos/dist-esm/src/documents/DataType.js | 19 + .../dist-esm/src/documents/DataType.js.map | 1 + .../src/documents/DatabaseAccount.d.ts | 69 + .../src/documents/DatabaseAccount.d.ts.map | 1 + .../dist-esm/src/documents/DatabaseAccount.js | 74 + .../src/documents/DatabaseAccount.js.map | 1 + .../dist-esm/src/documents/Document.d.ts | 4 + .../dist-esm/src/documents/Document.d.ts.map | 1 + .../cosmos/dist-esm/src/documents/Document.js | 2 + .../dist-esm/src/documents/Document.js.map | 1 + .../src/documents/GeospatialType.d.ts | 7 + .../src/documents/GeospatialType.d.ts.map | 1 + .../dist-esm/src/documents/GeospatialType.js | 10 + .../src/documents/GeospatialType.js.map | 1 + .../dist-esm/src/documents/IndexKind.d.ts | 14 + .../dist-esm/src/documents/IndexKind.d.ts.map | 1 + .../dist-esm/src/documents/IndexKind.js | 17 + .../dist-esm/src/documents/IndexKind.js.map | 1 + .../dist-esm/src/documents/IndexingMode.d.ts | 21 + .../src/documents/IndexingMode.d.ts.map | 1 + .../dist-esm/src/documents/IndexingMode.js | 24 + .../src/documents/IndexingMode.js.map | 1 + .../src/documents/IndexingPolicy.d.ts | 55 + .../src/documents/IndexingPolicy.d.ts.map | 1 + .../dist-esm/src/documents/IndexingPolicy.js | 9 + .../src/documents/IndexingPolicy.js.map | 1 + .../dist-esm/src/documents/PartitionKey.d.ts | 34 + .../src/documents/PartitionKey.d.ts.map | 1 + .../dist-esm/src/documents/PartitionKey.js | 27 + .../src/documents/PartitionKey.js.map | 1 + .../src/documents/PartitionKeyDefinition.d.ts | 21 + .../documents/PartitionKeyDefinition.d.ts.map | 1 + .../src/documents/PartitionKeyDefinition.js | 2 + .../documents/PartitionKeyDefinition.js.map | 1 + .../PartitionKeyDefinitionVersion.d.ts | 8 + .../PartitionKeyDefinitionVersion.d.ts.map | 1 + .../PartitionKeyDefinitionVersion.js | 11 + .../PartitionKeyDefinitionVersion.js.map | 1 + .../src/documents/PartitionKeyInternal.d.ts | 24 + .../documents/PartitionKeyInternal.d.ts.map | 1 + .../src/documents/PartitionKeyInternal.js | 26 + .../src/documents/PartitionKeyInternal.js.map | 1 + .../src/documents/PartitionKeyKind.d.ts | 8 + .../src/documents/PartitionKeyKind.d.ts.map | 1 + .../src/documents/PartitionKeyKind.js | 11 + .../src/documents/PartitionKeyKind.js.map | 1 + .../src/documents/PermissionMode.d.ts | 12 + .../src/documents/PermissionMode.d.ts.map | 1 + .../dist-esm/src/documents/PermissionMode.js | 15 + .../src/documents/PermissionMode.js.map | 1 + .../dist-esm/src/documents/PriorityLevel.d.ts | 19 + .../src/documents/PriorityLevel.d.ts.map | 1 + .../dist-esm/src/documents/PriorityLevel.js | 22 + .../src/documents/PriorityLevel.js.map | 1 + .../src/documents/TriggerOperation.d.ts | 17 + .../src/documents/TriggerOperation.d.ts.map | 1 + .../src/documents/TriggerOperation.js | 20 + .../src/documents/TriggerOperation.js.map | 1 + .../dist-esm/src/documents/TriggerType.d.ts | 11 + .../src/documents/TriggerType.d.ts.map | 1 + .../dist-esm/src/documents/TriggerType.js | 14 + .../dist-esm/src/documents/TriggerType.js.map | 1 + .../documents/UserDefinedFunctionType.d.ts | 9 + .../UserDefinedFunctionType.d.ts.map | 1 + .../src/documents/UserDefinedFunctionType.js | 12 + .../documents/UserDefinedFunctionType.js.map | 1 + .../src/documents/VectorEmbeddingPolicy.d.ts | 32 + .../documents/VectorEmbeddingPolicy.d.ts.map | 1 + .../src/documents/VectorEmbeddingPolicy.js | 2 + .../documents/VectorEmbeddingPolicy.js.map | 1 + .../cosmos/dist-esm/src/documents/index.d.ts | 22 + .../dist-esm/src/documents/index.d.ts.map | 1 + .../cosmos/dist-esm/src/documents/index.js | 24 + .../dist-esm/src/documents/index.js.map | 1 + .../dist-esm/src/extractPartitionKey.d.ts | 16 + .../dist-esm/src/extractPartitionKey.d.ts.map | 1 + .../dist-esm/src/extractPartitionKey.js | 75 + .../dist-esm/src/extractPartitionKey.js.map | 1 + .../dist-esm/src/globalEndpointManager.d.ts | 73 + .../src/globalEndpointManager.d.ts.map | 1 + .../dist-esm/src/globalEndpointManager.js | 260 + .../dist-esm/src/globalEndpointManager.js.map | 1 + .../@azure/cosmos/dist-esm/src/index.d.ts | 34 + .../@azure/cosmos/dist-esm/src/index.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/index.js | 29 + .../@azure/cosmos/dist-esm/src/index.js.map | 1 + .../CompositeIndexUtilizationEntity.d.ts | 9 + .../CompositeIndexUtilizationEntity.d.ts.map | 1 + .../CompositeIndexUtilizationEntity.js | 4 + .../CompositeIndexUtilizationEntity.js.map | 1 + .../dist-esm/src/indexMetrics/Constants.d.ts | 12 + .../src/indexMetrics/Constants.d.ts.map | 1 + .../dist-esm/src/indexMetrics/Constants.js | 13 + .../src/indexMetrics/Constants.js.map | 1 + .../src/indexMetrics/IndexMetricWriter.d.ts | 12 + .../indexMetrics/IndexMetricWriter.d.ts.map | 1 + .../src/indexMetrics/IndexMetricWriter.js | 61 + .../src/indexMetrics/IndexMetricWriter.js.map | 1 + .../indexMetrics/IndexUtilizationInfo.d.ts | 18 + .../IndexUtilizationInfo.d.ts.map | 1 + .../src/indexMetrics/IndexUtilizationInfo.js | 44 + .../indexMetrics/IndexUtilizationInfo.js.map | 1 + .../SingleIndexUtilizationEntity.d.ts | 11 + .../SingleIndexUtilizationEntity.d.ts.map | 1 + .../SingleIndexUtilizationEntity.js | 4 + .../SingleIndexUtilizationEntity.js.map | 1 + .../dist-esm/src/indexMetrics/index.d.ts | 5 + .../dist-esm/src/indexMetrics/index.d.ts.map | 1 + .../cosmos/dist-esm/src/indexMetrics/index.js | 7 + .../dist-esm/src/indexMetrics/index.js.map | 1 + .../cosmos/dist-esm/src/plugins/Plugin.d.ts | 54 + .../dist-esm/src/plugins/Plugin.d.ts.map | 1 + .../cosmos/dist-esm/src/plugins/Plugin.js | 43 + .../cosmos/dist-esm/src/plugins/Plugin.js.map | 1 + .../Aggregators/Aggregator.d.ts | 6 + .../Aggregators/Aggregator.d.ts.map | 1 + .../Aggregators/Aggregator.js | 2 + .../Aggregators/Aggregator.js.map | 1 + .../Aggregators/AverageAggregator.d.ts | 20 + .../Aggregators/AverageAggregator.d.ts.map | 1 + .../Aggregators/AverageAggregator.js | 27 + .../Aggregators/AverageAggregator.js.map | 1 + .../Aggregators/CountAggregator.d.ts | 19 + .../Aggregators/CountAggregator.d.ts.map | 1 + .../Aggregators/CountAggregator.js | 23 + .../Aggregators/CountAggregator.js.map | 1 + .../Aggregators/MaxAggregator.d.ts | 25 + .../Aggregators/MaxAggregator.d.ts.map | 1 + .../Aggregators/MaxAggregator.js | 32 + .../Aggregators/MaxAggregator.js.map | 1 + .../Aggregators/MinAggregator.d.ts | 24 + .../Aggregators/MinAggregator.d.ts.map | 1 + .../Aggregators/MinAggregator.js | 37 + .../Aggregators/MinAggregator.js.map | 1 + .../Aggregators/StaticValueAggregator.d.ts | 8 + .../StaticValueAggregator.d.ts.map | 1 + .../Aggregators/StaticValueAggregator.js | 12 + .../Aggregators/StaticValueAggregator.js.map | 1 + .../Aggregators/SumAggregator.d.ts | 14 + .../Aggregators/SumAggregator.d.ts.map | 1 + .../Aggregators/SumAggregator.js | 24 + .../Aggregators/SumAggregator.js.map | 1 + .../Aggregators/index.d.ts | 11 + .../Aggregators/index.d.ts.map | 1 + .../Aggregators/index.js | 26 + .../Aggregators/index.js.map | 1 + .../queryExecutionContext/CosmosHeaders.d.ts | 4 + .../CosmosHeaders.d.ts.map | 1 + .../queryExecutionContext/CosmosHeaders.js | 2 + .../CosmosHeaders.js.map | 1 + .../GroupByEndpointComponent.d.ts | 17 + .../GroupByEndpointComponent.d.ts.map | 1 + .../GroupByEndpointComponent.js | 96 + .../GroupByEndpointComponent.js.map | 1 + .../GroupByValueEndpointComponent.d.ts | 18 + .../GroupByValueEndpointComponent.d.ts.map | 1 + .../GroupByValueEndpointComponent.js | 94 + .../GroupByValueEndpointComponent.js.map | 1 + ...amingOrderByDistinctEndpointComponent.d.ts | 23 + ...gOrderByDistinctEndpointComponent.d.ts.map | 1 + ...reamingOrderByDistinctEndpointComponent.js | 96 + ...ingOrderByDistinctEndpointComponent.js.map | 1 + .../NonStreamingOrderByEndpointComponent.d.ts | 27 + ...StreamingOrderByEndpointComponent.d.ts.map | 1 + .../NonStreamingOrderByEndpointComponent.js | 92 + ...onStreamingOrderByEndpointComponent.js.map | 1 + .../OffsetLimitEndpointComponent.d.ts | 14 + .../OffsetLimitEndpointComponent.d.ts.map | 1 + .../OffsetLimitEndpointComponent.js | 42 + .../OffsetLimitEndpointComponent.js.map | 1 + .../OrderByEndpointComponent.d.ts | 26 + .../OrderByEndpointComponent.d.ts.map | 1 + .../OrderByEndpointComponent.js | 40 + .../OrderByEndpointComponent.js.map | 1 + .../OrderedDistinctEndpointComponent.d.ts | 13 + .../OrderedDistinctEndpointComponent.d.ts.map | 1 + .../OrderedDistinctEndpointComponent.js | 31 + .../OrderedDistinctEndpointComponent.js.map | 1 + .../UnorderedDistinctEndpointComponent.d.ts | 13 + ...norderedDistinctEndpointComponent.d.ts.map | 1 + .../UnorderedDistinctEndpointComponent.js | 32 + .../UnorderedDistinctEndpointComponent.js.map | 1 + .../EndpointComponent/emptyGroup.d.ts | 6 + .../EndpointComponent/emptyGroup.d.ts.map | 1 + .../EndpointComponent/emptyGroup.js | 9 + .../EndpointComponent/emptyGroup.js.map | 1 + .../ExecutionContext.d.ts | 10 + .../ExecutionContext.d.ts.map | 1 + .../queryExecutionContext/ExecutionContext.js | 2 + .../ExecutionContext.js.map | 1 + .../queryExecutionContext/FetchResult.d.ts | 22 + .../FetchResult.d.ts.map | 1 + .../src/queryExecutionContext/FetchResult.js | 32 + .../queryExecutionContext/FetchResult.js.map | 1 + .../queryExecutionContext/SqlQuerySpec.d.ts | 37 + .../SqlQuerySpec.d.ts.map | 1 + .../src/queryExecutionContext/SqlQuerySpec.js | 2 + .../queryExecutionContext/SqlQuerySpec.js.map | 1 + .../defaultQueryExecutionContext.d.ts | 52 + .../defaultQueryExecutionContext.d.ts.map | 1 + .../defaultQueryExecutionContext.js | 192 + .../defaultQueryExecutionContext.js.map | 1 + .../documentProducer.d.ts | 63 + .../documentProducer.d.ts.map | 1 + .../queryExecutionContext/documentProducer.js | 233 + .../documentProducer.js.map | 1 + .../queryExecutionContext/headerUtils.d.ts | 14 + .../headerUtils.d.ts.map | 1 + .../src/queryExecutionContext/headerUtils.js | 75 + .../queryExecutionContext/headerUtils.js.map | 1 + .../src/queryExecutionContext/index.d.ts | 14 + .../src/queryExecutionContext/index.d.ts.map | 1 + .../src/queryExecutionContext/index.js | 16 + .../src/queryExecutionContext/index.js.map | 1 + .../nonStreamingOrderByResponse.d.ts | 7 + .../nonStreamingOrderByResponse.d.ts.map | 1 + .../nonStreamingOrderByResponse.js | 4 + .../nonStreamingOrderByResponse.js.map | 1 + .../nonStreamingOrderByResult.d.ts | 5 + .../nonStreamingOrderByResult.d.ts.map | 1 + .../nonStreamingOrderByResult.js | 4 + .../nonStreamingOrderByResult.js.map | 1 + .../orderByComparator.d.ts | 12 + .../orderByComparator.d.ts.map | 1 + .../orderByComparator.js | 95 + .../orderByComparator.js.map | 1 + .../orderByDocumentProducerComparator.d.ts | 14 + ...orderByDocumentProducerComparator.d.ts.map | 1 + .../orderByDocumentProducerComparator.js | 128 + .../orderByDocumentProducerComparator.js.map | 1 + .../orderByQueryExecutionContext.d.ts | 32 + .../orderByQueryExecutionContext.d.ts.map | 1 + .../orderByQueryExecutionContext.js | 34 + .../orderByQueryExecutionContext.js.map | 1 + .../parallelQueryExecutionContext.d.ts | 17 + .../parallelQueryExecutionContext.d.ts.map | 1 + .../parallelQueryExecutionContext.js | 21 + .../parallelQueryExecutionContext.js.map | 1 + .../parallelQueryExecutionContextBase.d.ts | 95 + ...parallelQueryExecutionContextBase.d.ts.map | 1 + .../parallelQueryExecutionContextBase.js | 478 + .../parallelQueryExecutionContextBase.js.map | 1 + .../pipelinedQueryExecutionContext.d.ts | 31 + .../pipelinedQueryExecutionContext.d.ts.map | 1 + .../pipelinedQueryExecutionContext.js | 223 + .../pipelinedQueryExecutionContext.js.map | 1 + .../cosmos/dist-esm/src/queryIterator.d.ts | 89 + .../dist-esm/src/queryIterator.d.ts.map | 1 + .../cosmos/dist-esm/src/queryIterator.js | 278 + .../cosmos/dist-esm/src/queryIterator.js.map | 1 + .../src/queryMetrics/clientSideMetrics.d.ts | 11 + .../queryMetrics/clientSideMetrics.d.ts.map | 1 + .../src/queryMetrics/clientSideMetrics.js | 28 + .../src/queryMetrics/clientSideMetrics.js.map | 1 + .../dist-esm/src/queryMetrics/index.d.ts | 7 + .../dist-esm/src/queryMetrics/index.d.ts.map | 1 + .../cosmos/dist-esm/src/queryMetrics/index.js | 9 + .../dist-esm/src/queryMetrics/index.js.map | 1 + .../src/queryMetrics/queryMetrics.d.ts | 44 + .../src/queryMetrics/queryMetrics.d.ts.map | 1 + .../dist-esm/src/queryMetrics/queryMetrics.js | 145 + .../src/queryMetrics/queryMetrics.js.map | 1 + .../queryMetrics/queryMetricsConstants.d.ts | 46 + .../queryMetricsConstants.d.ts.map | 1 + .../src/queryMetrics/queryMetricsConstants.js | 56 + .../queryMetrics/queryMetricsConstants.js.map | 1 + .../src/queryMetrics/queryMetricsUtils.d.ts | 18 + .../queryMetrics/queryMetricsUtils.d.ts.map | 1 + .../src/queryMetrics/queryMetricsUtils.js | 39 + .../src/queryMetrics/queryMetricsUtils.js.map | 1 + .../queryMetrics/queryPreparationTime.d.ts | 27 + .../queryPreparationTime.d.ts.map | 1 + .../src/queryMetrics/queryPreparationTime.js | 60 + .../queryMetrics/queryPreparationTime.js.map | 1 + .../queryMetrics/runtimeExecutionTimes.d.ts | 26 + .../runtimeExecutionTimes.d.ts.map | 1 + .../src/queryMetrics/runtimeExecutionTimes.js | 64 + .../queryMetrics/runtimeExecutionTimes.js.map | 1 + .../dist-esm/src/queryMetrics/timeSpan.d.ts | 69 + .../src/queryMetrics/timeSpan.d.ts.map | 1 + .../dist-esm/src/queryMetrics/timeSpan.js | 216 + .../dist-esm/src/queryMetrics/timeSpan.js.map | 1 + .../dist-esm/src/request/ErrorResponse.d.ts | 66 + .../src/request/ErrorResponse.d.ts.map | 1 + .../dist-esm/src/request/ErrorResponse.js | 4 + .../dist-esm/src/request/ErrorResponse.js.map | 1 + .../dist-esm/src/request/FeedOptions.d.ts | 112 + .../dist-esm/src/request/FeedOptions.d.ts.map | 1 + .../dist-esm/src/request/FeedOptions.js | 2 + .../dist-esm/src/request/FeedOptions.js.map | 1 + .../dist-esm/src/request/FeedResponse.d.ts | 16 + .../src/request/FeedResponse.d.ts.map | 1 + .../dist-esm/src/request/FeedResponse.js | 34 + .../dist-esm/src/request/FeedResponse.js.map | 1 + .../src/request/OperationOptions.d.ts | 7 + .../src/request/OperationOptions.d.ts.map | 1 + .../dist-esm/src/request/OperationOptions.js | 4 + .../src/request/OperationOptions.js.map | 1 + .../RUCapPerOperationExceededError.d.ts | 11 + .../RUCapPerOperationExceededError.d.ts.map | 1 + .../request/RUCapPerOperationExceededError.js | 20 + .../RUCapPerOperationExceededError.js.map | 1 + .../dist-esm/src/request/RequestContext.d.ts | 34 + .../src/request/RequestContext.d.ts.map | 1 + .../dist-esm/src/request/RequestContext.js | 2 + .../src/request/RequestContext.js.map | 1 + .../dist-esm/src/request/RequestHandler.d.ts | 12 + .../src/request/RequestHandler.d.ts.map | 1 + .../dist-esm/src/request/RequestHandler.js | 150 + .../src/request/RequestHandler.js.map | 1 + .../dist-esm/src/request/RequestOptions.d.ts | 45 + .../src/request/RequestOptions.d.ts.map | 1 + .../dist-esm/src/request/RequestOptions.js | 2 + .../src/request/RequestOptions.js.map | 1 + .../src/request/ResourceResponse.d.ts | 15 + .../src/request/ResourceResponse.d.ts.map | 1 + .../dist-esm/src/request/ResourceResponse.js | 20 + .../src/request/ResourceResponse.js.map | 1 + .../cosmos/dist-esm/src/request/Response.d.ts | 12 + .../dist-esm/src/request/Response.d.ts.map | 1 + .../cosmos/dist-esm/src/request/Response.js | 2 + .../dist-esm/src/request/Response.js.map | 1 + .../dist-esm/src/request/SharedOptions.d.ts | 42 + .../src/request/SharedOptions.d.ts.map | 1 + .../dist-esm/src/request/SharedOptions.js | 2 + .../dist-esm/src/request/SharedOptions.js.map | 1 + .../dist-esm/src/request/StatusCodes.d.ts | 9 + .../dist-esm/src/request/StatusCodes.d.ts.map | 1 + .../dist-esm/src/request/StatusCodes.js | 4 + .../dist-esm/src/request/StatusCodes.js.map | 1 + .../dist-esm/src/request/TimeoutError.d.ts | 9 + .../src/request/TimeoutError.d.ts.map | 1 + .../dist-esm/src/request/TimeoutError.js | 14 + .../dist-esm/src/request/TimeoutError.js.map | 1 + .../src/request/defaultAgent.browser.d.ts | 11 + .../src/request/defaultAgent.browser.d.ts.map | 1 + .../src/request/defaultAgent.browser.js | 9 + .../src/request/defaultAgent.browser.js.map | 1 + .../dist-esm/src/request/defaultAgent.d.ts | 7 + .../src/request/defaultAgent.d.ts.map | 1 + .../dist-esm/src/request/defaultAgent.js | 28 + .../dist-esm/src/request/defaultAgent.js.map | 1 + .../cosmos/dist-esm/src/request/index.d.ts | 13 + .../dist-esm/src/request/index.d.ts.map | 1 + .../cosmos/dist-esm/src/request/index.js | 8 + .../cosmos/dist-esm/src/request/index.js.map | 1 + .../cosmos/dist-esm/src/request/request.d.ts | 29 + .../dist-esm/src/request/request.d.ts.map | 1 + .../cosmos/dist-esm/src/request/request.js | 149 + .../dist-esm/src/request/request.js.map | 1 + .../dist-esm/src/retry/RetryContext.d.ts | 11 + .../dist-esm/src/retry/RetryContext.d.ts.map | 1 + .../cosmos/dist-esm/src/retry/RetryContext.js | 2 + .../dist-esm/src/retry/RetryContext.js.map | 1 + .../dist-esm/src/retry/RetryPolicy.d.ts | 11 + .../dist-esm/src/retry/RetryPolicy.d.ts.map | 1 + .../cosmos/dist-esm/src/retry/RetryPolicy.js | 2 + .../dist-esm/src/retry/RetryPolicy.js.map | 1 + .../src/retry/defaultRetryPolicy.d.ts | 21 + .../src/retry/defaultRetryPolicy.d.ts.map | 1 + .../dist-esm/src/retry/defaultRetryPolicy.js | 139 + .../src/retry/defaultRetryPolicy.js.map | 1 + .../retry/endpointDiscoveryRetryPolicy.d.ts | 32 + .../endpointDiscoveryRetryPolicy.d.ts.map | 1 + .../src/retry/endpointDiscoveryRetryPolicy.js | 50 + .../retry/endpointDiscoveryRetryPolicy.js.map | 1 + .../cosmos/dist-esm/src/retry/index.d.ts | 7 + .../cosmos/dist-esm/src/retry/index.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/retry/index.js | 9 + .../cosmos/dist-esm/src/retry/index.js.map | 1 + .../retry/resourceThrottleRetryPolicy.d.ts | 32 + .../resourceThrottleRetryPolicy.d.ts.map | 1 + .../src/retry/resourceThrottleRetryPolicy.js | 52 + .../retry/resourceThrottleRetryPolicy.js.map | 1 + .../dist-esm/src/retry/retryOptions.d.ts | 12 + .../dist-esm/src/retry/retryOptions.d.ts.map | 1 + .../cosmos/dist-esm/src/retry/retryOptions.js | 2 + .../dist-esm/src/retry/retryOptions.js.map | 1 + .../dist-esm/src/retry/retryUtility.d.ts | 35 + .../dist-esm/src/retry/retryUtility.d.ts.map | 1 + .../cosmos/dist-esm/src/retry/retryUtility.js | 102 + .../dist-esm/src/retry/retryUtility.js.map | 1 + .../src/retry/sessionRetryPolicy.d.ts | 33 + .../src/retry/sessionRetryPolicy.d.ts.map | 1 + .../dist-esm/src/retry/sessionRetryPolicy.js | 69 + .../src/retry/sessionRetryPolicy.js.map | 1 + .../src/retry/timeoutFailoverRetryPolicy.d.ts | 44 + .../retry/timeoutFailoverRetryPolicy.d.ts.map | 1 + .../src/retry/timeoutFailoverRetryPolicy.js | 105 + .../retry/timeoutFailoverRetryPolicy.js.map | 1 + .../routing/CollectionRoutingMapFactory.d.ts | 4 + .../CollectionRoutingMapFactory.d.ts.map | 1 + .../routing/CollectionRoutingMapFactory.js | 72 + .../CollectionRoutingMapFactory.js.map | 1 + .../dist-esm/src/routing/QueryRange.d.ts | 35 + .../dist-esm/src/routing/QueryRange.d.ts.map | 1 + .../cosmos/dist-esm/src/routing/QueryRange.js | 63 + .../dist-esm/src/routing/QueryRange.js.map | 1 + .../routing/inMemoryCollectionRoutingMap.d.ts | 17 + .../inMemoryCollectionRoutingMap.d.ts.map | 1 + .../routing/inMemoryCollectionRoutingMap.js | 81 + .../inMemoryCollectionRoutingMap.js.map | 1 + .../cosmos/dist-esm/src/routing/index.d.ts | 5 + .../dist-esm/src/routing/index.d.ts.map | 1 + .../cosmos/dist-esm/src/routing/index.js | 7 + .../cosmos/dist-esm/src/routing/index.js.map | 1 + .../src/routing/partitionKeyRangeCache.d.ts | 24 + .../routing/partitionKeyRangeCache.d.ts.map | 1 + .../src/routing/partitionKeyRangeCache.js | 42 + .../src/routing/partitionKeyRangeCache.js.map | 1 + .../src/routing/smartRoutingMapProvider.d.ts | 23 + .../routing/smartRoutingMapProvider.d.ts.map | 1 + .../src/routing/smartRoutingMapProvider.js | 116 + .../routing/smartRoutingMapProvider.js.map | 1 + .../dist-esm/src/session/SessionContext.d.ts | 12 + .../src/session/SessionContext.d.ts.map | 1 + .../dist-esm/src/session/SessionContext.js | 2 + .../src/session/SessionContext.js.map | 1 + .../src/session/VectorSessionToken.d.ts | 26 + .../src/session/VectorSessionToken.d.ts.map | 1 + .../src/session/VectorSessionToken.js | 127 + .../src/session/VectorSessionToken.js.map | 1 + .../src/session/sessionContainer.d.ts | 22 + .../src/session/sessionContainer.d.ts.map | 1 + .../dist-esm/src/session/sessionContainer.js | 132 + .../src/session/sessionContainer.js.map | 1 + .../cosmos/dist-esm/src/utils/SasToken.d.ts | 11 + .../dist-esm/src/utils/SasToken.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/SasToken.js | 125 + .../cosmos/dist-esm/src/utils/SasToken.js.map | 1 + .../dist-esm/src/utils/atob.browser.d.ts | 3 + .../dist-esm/src/utils/atob.browser.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/atob.browser.js | 44 + .../dist-esm/src/utils/atob.browser.js.map | 1 + .../cosmos/dist-esm/src/utils/atob.d.ts | 2 + .../cosmos/dist-esm/src/utils/atob.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/utils/atob.js | 6 + .../cosmos/dist-esm/src/utils/atob.js.map | 1 + .../cosmos/dist-esm/src/utils/batch.d.ts | 145 + .../cosmos/dist-esm/src/utils/batch.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/utils/batch.js | 132 + .../cosmos/dist-esm/src/utils/batch.js.map | 1 + .../dist-esm/src/utils/cachedClient.d.ts | 3 + .../dist-esm/src/utils/cachedClient.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/cachedClient.js | 11 + .../dist-esm/src/utils/cachedClient.js.map | 1 + .../cosmos/dist-esm/src/utils/checkURL.d.ts | 3 + .../dist-esm/src/utils/checkURL.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/checkURL.js | 9 + .../cosmos/dist-esm/src/utils/checkURL.js.map | 1 + .../dist-esm/src/utils/diagnostics.d.ts | 51 + .../dist-esm/src/utils/diagnostics.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/diagnostics.js | 120 + .../dist-esm/src/utils/diagnostics.js.map | 1 + .../dist-esm/src/utils/digest.browser.d.ts | 2 + .../src/utils/digest.browser.d.ts.map | 1 + .../dist-esm/src/utils/digest.browser.js | 15 + .../dist-esm/src/utils/digest.browser.js.map | 1 + .../cosmos/dist-esm/src/utils/digest.d.ts | 2 + .../cosmos/dist-esm/src/utils/digest.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/digest.js | 9 + .../cosmos/dist-esm/src/utils/digest.js.map | 1 + .../cosmos/dist-esm/src/utils/encode.d.ts | 4 + .../cosmos/dist-esm/src/utils/encode.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/encode.js | 23 + .../cosmos/dist-esm/src/utils/encode.js.map | 1 + .../dist-esm/src/utils/globalCrypto.d.ts | 3 + .../dist-esm/src/utils/globalCrypto.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/globalCrypto.js | 13 + .../dist-esm/src/utils/globalCrypto.js.map | 1 + .../src/utils/globalCrypto.native.d.ts | 3 + .../src/utils/globalCrypto.native.d.ts.map | 1 + .../dist-esm/src/utils/globalCrypto.native.js | 8 + .../src/utils/globalCrypto.native.js.map | 1 + .../cosmos/dist-esm/src/utils/hashObject.d.ts | 2 + .../dist-esm/src/utils/hashObject.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/hashObject.js | 9 + .../dist-esm/src/utils/hashObject.js.map | 1 + .../src/utils/hashing/encoding/number.d.ts | 4 + .../utils/hashing/encoding/number.d.ts.map | 1 + .../src/utils/hashing/encoding/number.js | 68 + .../src/utils/hashing/encoding/number.js.map | 1 + .../src/utils/hashing/encoding/prefix.d.ts | 25 + .../utils/hashing/encoding/prefix.d.ts.map | 1 + .../src/utils/hashing/encoding/prefix.js | 27 + .../src/utils/hashing/encoding/prefix.js.map | 1 + .../src/utils/hashing/encoding/string.d.ts | 3 + .../utils/hashing/encoding/string.d.ts.map | 1 + .../src/utils/hashing/encoding/string.js | 21 + .../src/utils/hashing/encoding/string.js.map | 1 + .../dist-esm/src/utils/hashing/hash.d.ts | 9 + .../dist-esm/src/utils/hashing/hash.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/hashing/hash.js | 25 + .../dist-esm/src/utils/hashing/hash.js.map | 1 + .../dist-esm/src/utils/hashing/multiHash.d.ts | 8 + .../src/utils/hashing/multiHash.d.ts.map | 1 + .../dist-esm/src/utils/hashing/multiHash.js | 10 + .../src/utils/hashing/multiHash.js.map | 1 + .../src/utils/hashing/murmurHash.d.ts | 18 + .../src/utils/hashing/murmurHash.d.ts.map | 1 + .../dist-esm/src/utils/hashing/murmurHash.js | 436 + .../src/utils/hashing/murmurHash.js.map | 1 + .../cosmos/dist-esm/src/utils/hashing/v1.d.ts | 3 + .../dist-esm/src/utils/hashing/v1.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/hashing/v1.js | 76 + .../dist-esm/src/utils/hashing/v1.js.map | 1 + .../cosmos/dist-esm/src/utils/hashing/v2.d.ts | 5 + .../dist-esm/src/utils/hashing/v2.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/hashing/v2.js | 54 + .../dist-esm/src/utils/hashing/v2.js.map | 1 + .../cosmos/dist-esm/src/utils/headers.d.ts | 5 + .../dist-esm/src/utils/headers.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/headers.js | 34 + .../cosmos/dist-esm/src/utils/headers.js.map | 1 + .../dist-esm/src/utils/hmac.browser.d.ts | 2 + .../dist-esm/src/utils/hmac.browser.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/hmac.browser.js | 16 + .../dist-esm/src/utils/hmac.browser.js.map | 1 + .../cosmos/dist-esm/src/utils/hmac.d.ts | 2 + .../cosmos/dist-esm/src/utils/hmac.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/utils/hmac.js | 7 + .../cosmos/dist-esm/src/utils/hmac.js.map | 1 + .../src/utils/nonStreamingOrderByMap.d.ts | 11 + .../src/utils/nonStreamingOrderByMap.d.ts.map | 1 + .../src/utils/nonStreamingOrderByMap.js | 42 + .../src/utils/nonStreamingOrderByMap.js.map | 1 + .../nonStreamingOrderByPriorityQueue.d.ts | 14 + .../nonStreamingOrderByPriorityQueue.d.ts.map | 1 + .../utils/nonStreamingOrderByPriorityQueue.js | 51 + .../nonStreamingOrderByPriorityQueue.js.map | 1 + .../cosmos/dist-esm/src/utils/offers.d.ts | 3 + .../cosmos/dist-esm/src/utils/offers.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/offers.js | 14 + .../cosmos/dist-esm/src/utils/offers.js.map | 1 + .../cosmos/dist-esm/src/utils/patch.d.ts | 22 + .../cosmos/dist-esm/src/utils/patch.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/utils/patch.js | 10 + .../cosmos/dist-esm/src/utils/patch.js.map | 1 + .../cosmos/dist-esm/src/utils/strings.d.ts | 2 + .../dist-esm/src/utils/strings.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/strings.js | 6 + .../cosmos/dist-esm/src/utils/strings.js.map | 1 + .../utils/supportedQueryFeaturesBuilder.d.ts | 2 + .../supportedQueryFeaturesBuilder.d.ts.map | 1 + .../utils/supportedQueryFeaturesBuilder.js | 14 + .../supportedQueryFeaturesBuilder.js.map | 1 + .../cosmos/dist-esm/src/utils/time.d.ts | 7 + .../cosmos/dist-esm/src/utils/time.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/utils/time.js | 11 + .../cosmos/dist-esm/src/utils/time.js.map | 1 + .../cosmos/dist-esm/src/utils/tracing.d.ts | 2 + .../dist-esm/src/utils/tracing.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/tracing.js | 15 + .../cosmos/dist-esm/src/utils/tracing.js.map | 1 + .../cosmos/dist-esm/src/utils/typeChecks.d.ts | 13 + .../dist-esm/src/utils/typeChecks.d.ts.map | 1 + .../cosmos/dist-esm/src/utils/typeChecks.js | 54 + .../dist-esm/src/utils/typeChecks.js.map | 1 + .../cosmos/dist-esm/src/utils/types.d.ts | 2 + .../cosmos/dist-esm/src/utils/types.d.ts.map | 1 + .../@azure/cosmos/dist-esm/src/utils/types.js | 4 + .../cosmos/dist-esm/src/utils/types.js.map | 1 + .../@azure/cosmos/dist/index.js | 12412 ++++++++++++++++ .../@azure/cosmos/dist/index.js.map | 1 + .../cosmos/dist/types/latest/cosmos.d.ts | 4285 ++++++ .../dist/types/latest/tsdoc-metadata.json | 11 + local_dependencies/@azure/cosmos/package.json | 136 + package-lock.json | 34 +- src/ConfigContext.ts | 2 +- src/Utils/EndpointUtils.ts | 2 +- src/quickstart.html | 4 +- webpack.config.js | 4 +- 1017 files changed, 39434 insertions(+), 19 deletions(-) create mode 100644 local_dependencies/@azure/cosmos/CHANGELOG.md create mode 100644 local_dependencies/@azure/cosmos/LICENSE create mode 100644 local_dependencies/@azure/cosmos/README.md create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/auth.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/auth.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/client/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/request.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/request/request.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts.map create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js create mode 100644 local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js.map create mode 100644 local_dependencies/@azure/cosmos/dist/index.js create mode 100644 local_dependencies/@azure/cosmos/dist/index.js.map create mode 100644 local_dependencies/@azure/cosmos/dist/types/latest/cosmos.d.ts create mode 100644 local_dependencies/@azure/cosmos/dist/types/latest/tsdoc-metadata.json create mode 100644 local_dependencies/@azure/cosmos/package.json diff --git a/local_dependencies/@azure/cosmos/CHANGELOG.md b/local_dependencies/@azure/cosmos/CHANGELOG.md new file mode 100644 index 000000000..3e85c645a --- /dev/null +++ b/local_dependencies/@azure/cosmos/CHANGELOG.md @@ -0,0 +1,1153 @@ +# Release History +## 4.0.1-beta.3 (2024-05-17) + +- Added support for Vector Search. +- Add query feedOption to disable nonStreamingOrderBy query feature + +## 4.0.1-beta.2 (2024-01-22) + +### Bugs Fixed +- The earlier release version 4.0.1-beta.1 encountered compatibility issues with certain browser environments due to the disablement of SharedArrayBuffer. This version resolves that issue. + +## 4.0.1-beta.1 (2024-01-17) + +### Features Added +- We have implemented support for Request Unit (RU) caps in Query operations. Clients can now seamlessly integrate RU caps into their fetch functions by specifying the desired cap within the operation options. If the specified RU cap is surpassed during the operation, clients will promptly receive an error notification, providing enhanced control and transparency over resource consumption. + +### Breaking Changes + +#### Dropped Support for TypeScript 4.1 +- We have opted to discontinue support for TypeScript version 4.1. Consequently, the minimum supported TypeScript version has been elevated to 4.2. Kindly ensure that your environment is promptly updated to align with these changes. + +## 4.0.0 (2023-09-12) +🎉 v4 release! 🎉 Many new features, bug fixes, and a few breaking changes. +- Summary of new added features + - Diagnostics: A diagnostic object has been added to responses of api operations ie. point lookups, bulk & batch operations, query and error responses, which contains information related to metadata lookups, retries, request and reponse latencies and payload siezes. + - Hierarchical Partitioning: Containers with hierarchical partitions are now supported. [docs](https://learn.microsoft.com/azure/cosmos-db/hierarchical-partition-keys) + - Index metrics: can be enabled to show both utilized indexed paths and recommended indexed paths. [docs](https://learn.microsoft.com/azure/cosmos-db/nosql/index-metrics?tabs=javascript) + - New Changefeed iterator: which can consume changes for a specific partition key, a feed range or an entire container. [docs](https://learn.microsoft.com/azure/cosmos-db/nosql/change-feed-pull-model?tabs=JavaScript) + - Priority based throttling is now supported. [docs](https://devblogs.microsoft.com/cosmosdb/introducing-priority-based-execution-in-azure-cosmos-db-preview/) + +### New Features + +#### Diagnostics +- Since `diagnostics` is added to all Response objects. You could programatically access `CosmosDiagnostic` as follows. +```js + // For point look up operations + const { container, diagnostics: containerCreateDiagnostic } = + await database.containers.createIfNotExists({ + id: containerId, + partitionKey: { + paths: ["/key1"], + }, + }); + + // For Batch operations + const operations: OperationInput[] = [ + { + operationType: BulkOperationType.Create, + resourceBody: { id: 'A', key: "A", school: "high" }, + }, + ]; + const response = await container.items.batch(operations, "A"); + const diagnostics = response.diagnostics + + // For Bulk operations + const operations: OperationInput[] = [ + { + operationType: BulkOperationType.Create, + resourceBody: { id: 'A', key: "A", school: "high" }, + }, + ]; + const response = await container.items.bulk(operations);; + const diagnostics = response.diagnostics + + // For query operations + const queryIterator = container.items.query("select * from c"); + const { resources, diagnostics } = await queryIterator.fetchAll(); + + // While error handling + try { + // Some operation that might fail + } catch (err) { + const diagnostics = err.diagnostics + } +``` +#### Hierarchical Partitioning +- Here is a sampele for creating container with Hierarchical Partitions + + ```js + const containerDefinition = { + id: "Test Database", + partitionKey: { + paths: ["/name", "/address/zip"], + version: PartitionKeyDefinitionVersion.V2, + kind: PartitionKeyKind.MultiHash, + }, + } + const { container } = await database.containers.createIfNotExists(containerDefinition); + console.log(container.id); + ``` +- Definition of PartitionKey has been changed to support Hierarchical partitioning. Here is how to use the new definition. + - The operations for which PartitionKey can be derived from Request body, providing PartitionKey is optional as always i.e + ```js + const item = { + id: 1, + name: 'foo', + address: { + zip: 100 + }, + active: true + } + await container.items.create(item); + ``` + - Here is sample for operations which require hierarchical partition to be passed. + + ```js + await container.item("1", ["foo", 100]).read(); + ``` + OR + ```js + const partitionKey: PartitionKey = new PartitionKeyBuilder() + .addValue("foo") + .addValue(100) + .build(); + await container.item("1", partitionKey).read(); + ``` + - If you are not using Hierarchical Partitioning feature, Definition of Partition Key is practically backward compatible. + ```js + await container.item("1", "1").read(); + ``` + +#### New Change feed Iterator + +The v4 SDK now supports [Change feed pull model](https://learn.microsoft.com/azure/cosmos-db/nosql/change-feed-pull-model?tabs=JavaScript). + +***Note: There are no breaking changes, the old change feed iterator is still supported.*** + +Major Differences: +- The new iterator allows fetching change feed for a partition key, a feed range, or an entire container, compared to the older iterator, which was limited to fetching change feed for a partition key only. + +- The new implementation is effectively an infinite list of items that encompasses all future writes and updates. The `hasMoreResults` property now always returns `true`, unlike the older implementation, which returned `false` when a `NotModified` status code was received from the backend. + +Here is an example of creating and using the new change feed iterator: +```js +const changeFeedOptions = { + changeFeedStartFrom : ChangeFeedStartFrom.Beginning("partition key or feed range"), + maxItemCount: 10 +} +const iterator = container.items.getChangeFeedIterator(changeFeedOptions); +while(iterator.hasMoreResults) { + const res = await iterator.readNext(); + // process res +} +``` +#### Index Metrics [#20194](https://github.com/Azure/azure-sdk-for-js/issues/20194) + +Azure Cosmos DB provides indexing metrics for optimizing query performance, especially when you're unsure about adjusting the indexing policy. +You can enable indexing metrics for a query by setting the PopulateIndexMetrics property to true(default=false). + +```js +const { resources: resultsIndexMetrics, indexMetrics } = await container.items + .query(querySpec, { populateIndexMetrics: true }) + .fetchAll(); +``` + +We only recommend enabling the index metrics for troubleshooting query performance. + +#### Enhanced Retry Utility for Improved SDK Reliability [#23475](https://github.com/Azure/azure-sdk-for-js/issues/23475) + +Improved the retry utility to align with other language SDKs. Now, it automatically retries requests on the next available region when encountering HTTP 503 errors (Service Unavailable) +and handles HTTP timeouts more effectively, enhancing the SDK's reliability. + +#### Priority based throttling [docs](https://devblogs.microsoft.com/cosmosdb/introducing-priority-based-execution-in-azure-cosmos-db-preview/) [#26393](https://github.com/Azure/azure-sdk-for-js/pull/26393/files) + +Priority-based execution is a capability which allows users to specify priority for the request sent to Azure Cosmos DB. Based on the priority specified by the user, if there are more requests than the configured RU/s in a second, then Azure Cosmos DB will throttle low priority requests to allow high priority requests to execute. +You can enable priority based throttling by setting priorityLevel property. + +```js +const response = await container.item(document.id).read({ priorityLevel: PriorityLevel.Low }); +``` + +### Bugs Fixed +- Updated response codes for the getDatabase() method. [#25932](https://github.com/Azure/azure-sdk-for-js/issues/25932) +- Fix Upsert operation failing when partition key of container is `/id` and `/id` is missing in the document. [#21383](https://github.com/Azure/azure-sdk-for-js/issues/21383) + +### Breaking Changes +- The definition of PartitionKey is changed, PartitionKeyDefinition is now a independent type. [#23416](https://github.com/Azure/azure-sdk-for-js/issues/23416) + +## 3.17.3 (2023-02-13) + +### Features Added + +- Changes in bulk api to honour size restictions (i.e 2Mb) while creating individual batches.[#23923](https://github.com/Azure/azure-sdk-for-js/issues/23923) +- Enriched Timeout error response. We had defined Timeout error as custom error in our sdk but we were not sending up any message along with it, now we are throwing the specific Error. [#23025](https://github.com/Azure/azure-sdk-for-js/issues/23025) +- Added functionality to delete entire data for a partition id. [#22091](https://github.com/Azure/azure-sdk-for-js/issues/22091) +- SDK now defines all possible error types, namely Export RestError, AbortError, TimeoutError, and ErrorResponse. [22789](https://github.com/Azure/azure-sdk-for-js/issues/22789) +### Bugs Fixed + +- Removed excessive log warnings during bulk operations on a container with no partitionkey set. +- Fix issue with GlobalEndpointManager never making endpoints available after they fall-back [#22726](https://github.com/Azure/azure-sdk-for-js/issues/22726) +- Fix issue that caused parallel queries to break when returning a result of 0 or false. [#24493](https://github.com/Azure/azure-sdk-for-js/issues/24493) + +### Other Changes +- Error handling guidelines are added in README.md +## 3.17.2 (2022-11-15) + +### Bugs Fixed + +- Fix issue with patch api not working with aadCredentials [#20689](https://github.com/Azure/azure-sdk-for-js/issues/20689) +- Improve the contract of Item.batch operation from type any to OperationResponse [#23652](https://github.com/Azure/azure-sdk-for-js/issues/20689) +- Add section for the current limitations with the SDK [#21650](https://github.com/Azure/azure-sdk-for-js/issues/21650) +- Fix issue aad refresh token automatically getting refreshed [#22620](https://github.com/Azure/azure-sdk-for-js/issues/22620) + +## 3.17.1 (2022-09-12) + +### Bugs Fixed + +- Fix issue with unwanted runtime dependency on `@azure/identity` [#22968](https://github.com/Azure/azure-sdk-for-js/issues/22968) + +## 3.17.0 (2022-08-19) + +### Features Added + +#### GA: Azure Cosmos DB Integrated Cache + +- Support DedicatedGatewayRequestOptions and MaxIntegratedCacheStaleness [#21240](https://github.com/Azure/azure-sdk-for-js/pull/21240) +- Upgrade cosmos with azure core tracing [#22284](https://github.com/Azure/azure-sdk-for-js/pull/22284) +- Removed old logging and implement Azure core logging coverage [#18723](https://github.com/Azure/azure-sdk-for-js/pull/18723?) + +### Bugs Fixed + +- ParallelQueryExecutionContextBase breaks use of abortSignal [#18544](https://github.com/Azure/azure-sdk-for-js/pull/18544) +- Fixes id encoding issues when using special characters fo RoutingGateway + +## 3.16.3 (2022-07-13) + +### Bugs Fixed + +- Fixes issues with "id" encoding when using special characters that should be allowed in the "id" property of a document. [#22548](https://github.com/Azure/azure-sdk-for-js/pull/22548) + +## 3.16.2 (2022-06-24) + +### Bugs Fixed + +- Adds support to run queries with group by over a column with null values. [#22345](https://github.com/Azure/azure-sdk-for-js/pull/22345) + +## 3.16.1 (2022-05-31) + +### Bugs Fixed + +- Fix [#22003](https://github.com/Azure/azure-sdk-for-js/issues/22003) missing interface error. [#22015](https://github.com/Azure/azure-sdk-for-js/pull/22015) + +## 3.16.0 (2022-05-23) + +### Features Added + +- Allow users like cosmos-explorer to specify hierarchical partition keys. https://github.com/Azure/azure-sdk-for-js/pull/21934 +- Support Dedicated Gateway RequestOptions and Max Integrated Cache Staleness. https://github.com/Azure/azure-sdk-for-js/pull/21240 + +## 3.15.1 (2022-01-24) + +### Bugs Fixed + +- Fixed the paths mapped by the `browser` entry in `package.json` to be correct for the package's new output structure. This solves errors with bundling the package for browsers. + +## 3.15.0 (2021-11-22) + +### Features Added + +- _GA_ Adds `container.item(itemId).patch()`. `patch()` is an alternative to `replace()` for item updates. https://github.com/Azure/azure-sdk-for-js/pull/16264/files#diff-7caca690c469e2025576523c0377ac71815f001024fde7c48b20cd24adaa6977R561 +- _GA_ support for Bulk operation PATCH. +- _GA_ support for Batch operation PATCH. +- Added the `SasTokenProperties` type and a `createAuthorizationSasToken` function to enable scoped access to Cosmos resources with SAS tokens. For an example that demonstrates creating a SAS token and using it to authenticate a `CosmosClient`, see [the `SasTokenAuth` sample](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/cosmosdb/cosmos/samples/v3/typescript/src/SasTokenAuth.ts). + +### Other Changes + +- Made several changes to the sample programs to improve code quality and compatibility with Node 12, and upgraded the sample programs' dependencies. + +## 3.14.1 (2021-09-02) + +### Bugs Fixed + +- Fix @azure/core-rest-pipeline version for AAD auth. + +## 3.14.0 (2021-09-01) + +### Features Added + +- _PREVIEW_ Adds `container.item(itemId).patch()`. `patch()` is an alternative to `replace()` for item updates. https://github.com/Azure/azure-sdk-for-js/pull/16264/files#diff-7caca690c469e2025576523c0377ac71815f001024fde7c48b20cd24adaa6977R561 +- _PREVIEW_ Adds support for Bulk operation PATCH. +- _PREVIEW_ Adds support for Batch operation PATCH. + +### Bugs Fixed + +- Fixes bug where Batch was passing the wrong header for batch requests with partition keys +- Fixes 401s when using AAD auth. AAD credentials should now work and no longer cause 429s from @azure/identity at high throughput. + +## 3.13.1 (2021-08-23) + +### Bugs Fixed + +- Fixed bugs in session token clearing logic. Session Not found (404, substatus 1002) was not being handled correctly by the session retry policy and would mistakenly retry the request with the same session token. + +## 3.13.0 (2021-08-10) + +### Features Added + +- Adds TransactionalBatch to items `container.items.batch(operations)` + +### Bugs Fixed + +- Fixed bulk requests which had operations without partitionKey specified. + +## 3.12.3 (2021-07-23) + +### Bugs Fixed + +- Fix bulk operations on containers with multiple partitions with nested partition keys + +## 3.12.2 (2021-07-21) + +### Features Added + +- Adopted target ES2017 to reduce bundle size. + +## 3.12.1 (2021-07-16) + +### Bugs Fixed + +- Returned default retryPolicy option `fixedRetryIntervalInMilliseconds` to its original default 0. + +## 3.12.0 (2021-07-06) + +### Features Added + +- With the dropping of support for Node.js versions that are no longer in LTS, the dependency on `@types/node` has been updated to version 12. Read our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. +- Added background refresher for endpoints, and new `ConnectionPolicy` options. Refreshing defaults to true, and the default refresh rate is every 5 minutes. + +```js +const client = new CosmosClient({ + endpoint, + key: masterKey, + connectionPolicy: { + ...defaultConnectionPolicy, + endpointRefreshRateInMs: 700, + enableBackgroundEndpointRefreshing: true, + }, +}); +``` + +- Added `client.dispose()` for closing the endpoint refresher verbosely. Necessary when destroying the CosmosClient inside existing processes like an express web server, or when you want to destroy the client and create a new one in the same process. + +```js +const client = new CosmosClient(); +client.dispose(); // cancels background endpoint refreshing +``` + +## 3.11.5 (2021-06-10) + +### Features Added + +### Breaking Changes + +### Key Bugs Fixed + +### Fixed + +- BUGFIX: Adds another failover condition. + +## 3.11.4 (2021-06-10) + +- BUGFIX: Correctly failover to new regions when regional DNS has gone offline. + +## 3.11.3 (2021-05-21) + +- BUGFIX: Sanitize user endpoint URLs for AAD DataPlane RBAC token generation. + +## 3.11.2 (2021-05-11) + +- BUGFIX: Cache https client between requests. + +## 3.11.1 (2021-05-06) + +- BUGFIX: Import URL from Browser/Node shim rather than built-in module. + +## 3.11.0 (2021-04-21) + +- FEATURE: Internal client update. No user facing changes, but major version bump to be safe. + +## 3.10.6 (2021-04-14) + +- BUGFIX: Adds partitionKey parameter to `container.conflicts.delete` + +## 3.10.5 (2021-03-25) + +- BUGFIX: Pins node-abort-controller version as we depend on a type in v1.2.0. + +## 3.10.4 (2021-03-23) + +- FEATURE: Adds Bulk continueOnError option. + +## 3.10.3 (2021-03-12) + +- BUGFIX: Removes direct dependency on @azure/identity while retaining compatibility. + +## 3.10.2 (2021-03-11) + +- BUGFIX: Fixes @azure/identity dependency in dev deps. + +## 3.10.1 (2021-03-10) + +- BUGFIX: Autogenerates IDs for Upsert operations in bulk. + +## 3.10.0 (2021-01-21) + +- FEATURE: Adds AAD authentication via @azure/identity. + +## 3.9.5 (2021-01-18) + +- BUGFIX: Throws correct Invalid Continuation Token error when making request with malformed token +- BUGFIX: Defaults partitionKeyValue to `'[{}]'` when missing in Read/Delete bulk operations +- BUGFIX: Sums group by operations for cross-partition queries correctly with null values. + +## 3.9.3 (2020-10-19) + +- BUGFIX: Fixes bulk operations with top level partitionKey values that are undefined or null. + +## 3.9.2 (2020-09-16) + +- BUGFIX: Fixes slow `userAgent` lookup on azure functions. + +## 3.9.1 (2020-08-28) + +- BUGFIX: Fixes `OperationInput` type to be more accurate based on `OperationType`. +- FEATURE: Bulk requests with `Create` operations will now autogenerate IDs if they are not present. +- FEATURE: The `BulkOperationType` enum now exists and can be used when making bulk requests. + +## 3.9.0 (2020-08-13) + +- FEATURE: Adds support for autoscale parameters on container and database create methods + +Note that `maxThroughput` cannot be passed with `throughput`. + +```js +// correct +const containerDefinition = { + id: "sample container", + indexingPolicy: { indexingMode: IndexingMode.consistent }, + maxThroughput: 500, + autoUpgradePolicy: { + throughputPolicy: { + incrementPercent: 15 + } + } +}; +database.container.create(containerDefinition) + +// incorrect +const containerDefinition = { + id: "sample container", + indexingPolicy: { indexingMode: IndexingMode.consistent }, + throughput: 500, // do not specify throughput with maxThroughput + maxThroughput: 500 + autoUpgradePolicy: { + throughputPolicy: { + incrementPercent: 15 + } + } +}; +database.container.create(containerDefinition) +``` + +## 3.8.2 (2020-08-12) + +- BUGFIX: Fix checkURL function for Node 8 + +## 3.8.1 (2020-08-12) + +- BUGFIX: Adds separate URL module for browser/node. + +## 3.8.0 (2020-08-10) + +- FEATURE: Throws when initializing ClientContext with an invalid endpoint +- FEATURE: Changes JSONArray type internal from Array to ArrayLike to avoid requiring type coercion for immutable data +- FEATURE: Adds bulk request to container.items. Allows aggregate bulk request for up to 100 operations on items with the types: Create, Upsert, Read, Replace, Delete + +```js +// up to 100 operations +const operations: OperationInput[] = [ + { + operationType: "Create", + resourceBody: { id: "doc1", name: "sample", key: "A" }, + }, + { + operationType: "Upsert", + resourceBody: { id: "doc2", name: "other", key: "A" }, + }, + { + operationType: "Read", + id: "readItemId", + partitionKey: "key", + }, +]; + +await database.container.items.bulk(operations); +``` + +## 3.7.4 (2020-06-30) + +- BUGFIX: Properly escape ASCII "DEL" character in partition key header + +## 3.7.3 (2020-06-29) + +- BUGFIX: Cannot create item with automatic id generation and a container partitioned on ID (#9734) + +## 3.7.2 (2020-06-16) + +- BUGFIX: Internal abort signal incorrectly triggered when user passes a custom abort signal. See #9510 for details. + +## 3.7.1 (2020-06-12) + +- BUGFIX: Typo in globalCrypto.js causing errors in IE browser +- BUGFIX: Resource tokens not matching for item delete operations (#9110) + +## 3.7.0 (2020-06-08) + +- BUGFIX: Support crypto functions in Internet Explorer browser +- BUGFIX: Incorrect key casing in object returned by `setAuthorizationHeader` +- FEATURE: Adds `readOffer` methods to container and database +- FEATURE: Allows string value `partitionKey` parameter when creating containers + +The following result in the same behavior: + +```js +const containerDefinition = { + id: "sample container", + indexingPolicy: { indexingMode: IndexingMode.consistent }, + throughput: 400, + partitionKey: { paths: ["/key"] } +}; +database.container.create(containerDefinition); + +// OR as a string + +const containerDefinition = { + id: "sample container", + indexingPolicy: { indexingMode: IndexingMode.consistent }, + throughput: 400, + partitionKey: "/key" } // must have leading slash "/" +}; +database.container.create(containerDefinition); +``` + +## 3.6.3 (2020-04-08) + +- FEATURE: Add `partitionKey` to `FeedOptions` for scoping a query to a single partition key value + +@azure/cosmos V2 has two different but equivalent ways to specify the partition key for a query: + +```js +// V2 These are effectively the same +container.items.query("SELECT * from c", { partitionKey: "foo" }).toArray(); +container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').toArray(); +``` + +In an effort to simplify, the V3 SDK removed `partitionKey` from `FeedOptions` so there was only one way to specify the partition key: + +```js +// V3 +container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').fetchAll(); +``` + +Based on customer feedback, we identified scenarios where it still makes sense to support passing the partition key via `FeedOptions` and have decided to restore the behavior. + +## 3.6.2 (2020-02-20) + +- BUG FIX: Support signing in web workers where this === self + +## 3.6.1 (2020-02-11) + +- BUG FIX: Normalize location names when selecting endpoint. Allows passing of normalized endpoint names + +## 3.6.0 (2020-02-10) + +- FEATURE: Add support for spatial indexing, bounding boxes, and geospatial configuration +- BUG FIX: Fix bug when passing forceQueryPlan to QueryIterator for non-item resources (#7333) + +## 3.5.4 (2020-01-28) + +- BUG FIX: Return parsed number instead of string for request charge + +## 3.5.3 (2020-01-06) + +- BUG FIX: maxDegreeOfParallelism was defaulting to 1 and should default to the number of partitions of the collection +- BUG FIX: maxItemCount was defaulting to 10 and should default to undefined +- Set default TLS version to 1.2 (#6761) +- Use tslib 1.10.0 (#6710) +- Add partition key to code sample (#6612) + +## 3.5.2 (2019-12-03) + +- Fix handling of special characters in item ids when signing tokens in the browser (#6379) + +## 3.5.1 (2019-11-25) + +- Fix bug when paginating GROUP BY queries or using in conjunction with TOP/OFFSET/LIMIT (#6003) +- Improve error message for mixed type ORDER BY (#6306) + +## 3.5.0 (2019-11-21) + +- FEATURE: Endpoint discovery and multi-region failover improvements. See https://github.com/Azure/azure-sdk-for-js/pull/6283 for more information on this change. (#6283) +- Makes changeFeed and query options optional. Fix #6232 Fix #6277 (#6273) + +## 3.4.2 (2019-11-07) + +- Fixes bug where the query may throw a 410 error during a split operation. Instead, throw 503 (#6074) + +## 3.4.1 (2019-11-05) + +- Fix region drop failover scenario and add test (#5892) + +## 3.4.0 (2019-10-28) + +- FEATURE: GROUP BY query support (#5749) +- Update proxy-agent. Remove types folder (#5854) +- Typo: Fix "an" vs "a" (#5812) +- Update to Mocha 6.2.2 (#5824) +- Remove unused Range type (#5686) +- Remove universal-user-agent (#5869) + +## 3.3.4 (2019-10-14) + +- Query bug fix. Empty result last call not reporting proper RUs (#5517) +- Sign headers using internal package (#5523) +- Use internal digest function instead of crypto-hash package (#5493) +- Remove internal binary-search-bounds package (#5417) +- Fix atob bug impacting browser users (#5375) + +## 3.3.2 (2019-10-03) + +- Export TokenProvider and RequestInfo types (#5262) +- Remove atob package in favor of local version (#5334) +- Fix incorrect lib version in UserAgent (#5295) +- Allow zero for Item TTL (#5257) + +## 3.3.0 (2019-09-24) + +- FEATURE: Add userAgentSuffix to CosmosClient constructor options (#5068) +- Guard process.env to fix webpack issues (#5223) +- Fixes bug where initial QueryIterator promise was not being created (#5215) +- Fix aggregates bug when query was returning no results (#5184) +- sideEffects field set to false (#5022) + +## 3.2.0 (2019-08-26) + +- FEATURE: Endpoint resolution now blocks until initialized (#409) +- FEATURE: Add bufferItems support & other cross-partition perf improvements (#397) +- Fix missing AbortSignal type for users not targeting the DOM (#416) +- Add sample for bulk update with continuation token (#402) +- Export default partition key path (#405) + +## 3.1.1 (2019-08-07) + +- Fix bug where offset limit iterator was being called for each item under the offset count (#398) +- Add retry on EPIPE error (#400) + +## 3.1.0 (2019-07-26) + +- FEATURE: Set default ResponseContinuationTokenLimitInKB to 1kb. Prevents header limit errors (#384) +- Remove unused disableSSLVerification options (#388) + +## 3.0.4 (2019-07-22) + +- Allow initialHeaders to explicitly set partition key header (#383) +- Use package.json#files to prevent extraneous files from being pubished (#382) +- Fix for routing map sort error on older version of node+v8 (#378) +- Fixes bug when user supplies partial retry options. Close #377 (#379) +- README updates (#374) + +## 3.0.3 (2019-07-17) + +- Fix webpack usage. Prevent resolving modules called with `require` (#373) +- Various internal API cleanups and sample fixes + +## 3.0.2 (2019-07-09) + +Fixes a long outstanding bug where RUs were always being reported as 0 for aggregate queries (#366) + +## 3.0.1 (2019-07-02) + +Fixes broken session tokens in the browser. Cosmos uses file system friendly base64 to represent resources internally but does not work with the builtin browser atob function (#363) + +## 3.0.0 (2019-06-28) + +🎉 v3 release! 🎉 Many new features, bug fixes, and a few breaking changes. Primary goals of this release: + +- Implement major new features: + - DISTINCT queries + - LIMIT/OFFSET queries + - User cancelable requests +- Update to the latest Cosmos REST API version where [all containers have unlimited scale](https://docs.microsoft.com/azure/cosmos-db/migrate-containers-partitioned-to-nonpartitioned) +- Make it easier to use Cosmos from the browser +- Better align with the new [Azure JS SDK guidlines](https://azure.github.io/azure-sdk/typescript_introduction.html) + +### Migration Guide for Breaking Changes + +#### Improved Client Constructor Options (#246) + +Constructor options have been simplified: + +- `masterKey` was renamed `key` and moved to the top-level +- Properties previously under `options.auth` have moved to the top-level + +```js +// v2 +const client = new CosmosClient({ + endpoint: "https://your-database.cosmos.azure.com", + auth: { + masterKey: "your-primary-key", + }, +}); + +// v3 +const client = new CosmosClient({ + endpoint: "https://your-database.cosmos.azure.com", + key: "your-primary-key", +}); +``` + +#### Simplified QueryIterator API (#238 #316) + +In v2 there were many different ways to iterate or retrieve results from a query. We have attempted to simplify the v3 API and remove similar or duplciate APIs: + +- Remove iterator.next() and iterator.current(). Use fetchNext() to get pages of results. +- Remove iterator.forEach(). Use async iterators instead. +- iterator.executeNext() renamed to iterator.fetchNext() +- iterator.toArray() renamed to iterator.fetchAll() +- Pages are now proper `Response` objects intead of plain JS objects + +```js +const container = client.database(dbId).container(containerId) + +// v2 +container.items.query('SELECT * from c').toArray() +container.items.query('SELECT * from c').executeNext() +container.items.query('SELECT * from c').forEach(({ body: item }) => { console.log(item.id) }) + +// v3 +container.items.query('SELECT * from c').fetchAll() +container.items.query('SELECT * from c').fetchNext() +for await(const { result: item } in client.databases.readAll().getAsyncIterator()) { + console.log(item.id) +} +``` + +#### Simplified Partition Keys for Queries + +v2 has two different but equivalent ways to specify the partition key for a query: + +```js +// v2. These are effectively the same +container.items.query("SELECT * from c", { partitionKey: "foo" }).toArray(); +container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').toArray(); +``` + +v3 removed `partitionKey` from `FeedOptions` so there is now only one way to specify the partition key: + +```js +// v3 +container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').fetchAll(); +``` + +#### Fixed Containers are now Paritioned (#308) + +[The Cosmos service now supports partition keys on all containers, including those that were previously created as fixed containers](https://docs.microsoft.com/azure/cosmos-db/migrate-containers-partitioned-to-nonpartitioned). The v3 SDK updates to the latest API version that implements this change, but it is not breaking. If you do not supply a partition key for operations, we will default to a system key that works with all your existing containers and documents. + +#### `upsert` removed for Stored Procedures (#356) + +Previously `upsert` was allowed for non-partitioned collections, but with the API version update, all collections are partitioned so we removed it entirely. + +#### Item reads will not throw on 404 (#343, Community Request) + +```js +const container = client.database(dbId).container(containerId); + +// v2 +try { + container.items.read(id, undefined); +} catch (e) { + if (e.code === 404) { + console.log("item not found"); + } +} + +// v3 +const { result: item } = container.items.read(id, undefined); +if (item === undefined) { + console.log("item not found"); +} +``` + +#### Default Multi Region Write (#335) + +The SDK will now write to multiple regions by default if your database configuration supports it. This was previously opt-in behavior. + +#### Proper Error Objects (#334, Community Request) + +Failed requests now throw proper `Error` or subclasses of `Error`. Previously they threw plain JS objects. + +### New Features + +#### User Cancellable Requests (#263, Community Request) + +The move to `fetch` internally allows us to use the browser `AbortController` API to support user cancellable operations. In the case of operations where multiple requests are potentially in progress (like cross partition queries), all requests for the operation will be canceled. Modern browser users will already have `AbortController`. Node.js users will need to use a [polyfill library](https://www.npmjs.com/package/node-abort-controller) + +```js +const controller = new AbortController(); +const { result: item } = await items.query("SELECT * from c", { abortSignal: controller.signal }); +controller.abort(); +``` + +#### Set throughput as part of db/container create operation (#220) + +```js +const { database } = client.databases.create({ id: "my-database", throughput: 10000 }); +database.containers.create({ id: "my-container", throughput: 10000 }); +``` + +#### @azure/cosmos-sign (#213) + +Header token generation was split out into a new library, @azure/cosmos-sign. Anyone calling the Cosmos REST API directly can use this to sign headers using the same code we call inside @azure/cosmos. + +#### UUID for generated IDs (#355) + +v2 had custom code to generate item IDs. We have switched to the well known and maintained community library `uuid`. + +#### Connection Strings (#350, Community Request) + +It is now possible to pass a connection string copied from the Azure portal: + +```js +const client = new CosmosClient( + "AccountEndpoint=https://test-account.documents.azure.com:443/;AccountKey=;" +); +``` + +#### Add DISTINCT and LIMIT/OFFSET queries (#306) + +```js +const { results } = await items.query("SELECT DISTINCT VALUE r.name FROM ROOT").fetchAll(); +const { results } = await items.query("SELECT * FROM root r OFFSET 1 LIMIT 2").fetchAll(); +``` + +### Improved Browser Experience + +While it was possible to use the v2 SDK in the browser it was not an ideal experience. You needed to polyfill several node.js built-in libraries and use a bundler like Webpack or Parcel. The v3 SDK makes the out of the box experience much better for browser users. + +- Replace request internals with `fetch` (#245) +- Remove usage of Buffer (#330) +- Remove node builtin usage in favor of universal packages/APIs (#328) +- Switch to node-abort-controller (#294) + +### Bug Fixes + +- Fix offer read and bring back offer tests (#224) +- Fix EnableEndpointDiscovery (#207) +- Fix missing RUs on paginated results (#360) +- Expand SQL query parameter type (#346) +- Add ttl to ItemDefinition (#341) +- Fix CP query metrics (#311) +- Add activityId to FeedResponse (#293) +- Switch \_ts type from string to number (#252)(#295) +- Fix Request Charge Aggregation (#289) +- Allow blank string partition keys (#277) +- Add string to conflict query type (#237) +- Add uniqueKeyPolicy to container (#234) + +### Engineering Systems + +Not always the most visible changes, but they help our team ship better code, faster. + +- Use rollup for production builds (#104) +- Update to Typescript 3.5 (#327) +- Convert to TS project references. Extract test folder (#270) +- Enable noUnusedLocals and noUnusedParameters (#275) +- Azure Pipelines YAML for CI builds (#298) + +## 2.0.1 (2018-09-25) + +- Fix type issue (See #141) + +## 2.0.0 (2018-09-24) + +- Multi-region Write support +- Shared resource response properties added to responses +- Changed query to allow for customer types for all Resource types +- Modified items.query to allow for cross partition query +- Misc fixes/doc updates + +## 2.0.0-3 (2018-08-02) + +- New object model +- Updated documentation and samples +- Improved types +- Added `createdIfNotExists` for database and container +- Added prettier +- Added public CI (Travis and VSTS) + +## 2.0.0-0 (2018-08-01) + +- Added Promise support +- Added token handler option for auth +- typings now emitted from source (moved source to TypeScript) +- Added CosmosClient (DocumentClient now considered deprecated) + +## 1.14.4 (2018-05-03) + +- npm documentation fixed. + +## 1.14.3 (2018-05-03) + +- Added support for default retries on connection issues. +- Added support to read collection change feed. +- Fixed session consistency bug that intermittently caused "read session not available". +- Added support for query metrics. +- Modified http Agent's maximum number of connections. + +## 1.14.2 (2017-12-21) + +- Updated documentation to use Azure Cosmos DB. +- Added Support for proxyUrl setting in ConnectionPolicy. + +## 1.14.1 (2017-11-10) + +- Minor fix for case sensitive file systems. + +## 1.14.0 (2017-11-09) + +- Adds support for Session Consistency. +- This SDK version requires the latest version of Azure Cosmos DB Emulator available for download from https://aka.ms/cosmosdb-emulator. + +## 1.13.0 (2017-10-11) + +- Splitproofed cross partition queries. +- Adds supports for resource link with leading and trailing slashes (and corresponding tests). + +## 1.12.2 (2017-08-10) + +- npm documentation fixed. + +## 1.12.1 (2017-08-10) + +- Fixed bug in executeStoredProcedure where documents involved had special unicode characters (LS, PS). +- Fixed bug in handling documents with unicode characters in partition key. +- Fixed support for creating collection with name media (github #114). +- Fixed support for permission authorization token (github #178). + +## 1.12.0 (2017-05-10) + +- Added support for Request Unit per Minute (RU/m) feature. +- Added support for a new consistency level called ConsistentPrefix. +- Added support for UriFactory. +- Fixed the unicode support bug (github #171) + +## 1.11.0 (2017-03-16) + +- Added the support for aggregation queries (COUNT, MIN, MAX, SUM, and AVG). +- Added the option for controlling degree of parallelism for cross partition queries. +- Added the option for disabling SSL verification when running against Emulator. +- Lowered minimum throughput on partitioned collections from 10,100 RU/s to 2500 RU/s. +- Fixed the continuation token bug for single partition collection (github #107). +- Fixed the executeStoredProcedure bug in handling 0 as single param (github #155). + +## 1.10.2 (2017-01-27) + +- Fixed user-agent header to include the SDK version. +- Minor code cleanup. + +## 1.10.1 (2016-12-22) + +- Disabling SSL verification when using the SDK to target the emulator(hostname=localhost). +- Added support for enabling script logging during stored procedure execution. + +## 1.10.0 (2016-10-03) + +- Added support for cross partition parallel queries. +- Added support for TOP/ORDER BY queries for partitioned collections. + +## 1.9.0 (2016-07-07) + +- Added retry policy support for throttled requests. (Throttled requests receive a request rate too large exception, error code 429.) + By default, DocumentClient retries nine times for each request when error code 429 is encountered, honoring the retryAfter time in the response header. + A fixed retry interval time can now be set as part of the RetryOptions property on the ConnectionPolicy object if you want to ignore the retryAfter time returned by server between the retries. + DocumentClient now waits for a maximum of 30 seconds for each request that is being throttled (irrespective of retry count) and returns the response with error code 429. + This time can also be overriden in the RetryOptions property on ConnectionPolicy object. + +- DocumentClient now returns x-ms-throttle-retry-count and x-ms-throttle-retry-wait-time-ms as the response headers in every request to denote the throttle retry count and the cummulative time the request waited between the retries. + +- The RetryOptions class was added, exposing the RetryOptions property on the ConnectionPolicy class that can be used to override some of the default retry options. + +## 1.8.0 (2016-06-14) + +- Added the support for geo-replicated database accounts. + +## 1.7.0 (2016-04-26) + +- Added the support for TimeToLive(TTL) feature for documents. + +## 1.6.0 (2016-03-29) + +- Added support for Partitioned Collections. +- Added support for new offer types. + +## 1.5.6 (2016-03-08) + +- Fixed RangePartitionResolver.resolveForRead bug where it was not returning links due to a bad concat of results. +- Move compareFunction from Range class to RangePartitionResolver class. + +## 1.5.5 (2016-02-02) + +- Fixed hashParitionResolver resolveForRead(): When no partition key supplied was throwing exception, instead of returning a list of all registered links. + +## 1.5.4 (2016-02-01) + +- Dedicated HTTPS Agent: Avoid modifying the global. Use a dedicated agent for all of the lib’s requests. + +## 1.5.3 (2016-01-26) + +- Properly handle dashes in the mediaIds. + +## 1.5.2 (2016-01-22) + +- Fix memory leak. + +## 1.5.1 (2016-01-04) + +- Renamed "Hash" directory to "hash". + +## 1.5.0 (2015-12-31) + +- Added client-side sharding support. +- Added hash partition resolver implementation. +- Added range partitoin resolver implementation. + +## 1.4.0 (2015-10-06) + +- Implement Upsert. New upsertXXX methods on documentClient. + +## 1.3.0 (2015-10-06) + +- Skipped to bring version numbers in alignment with other SDKs. + +## 1.2.2 (2015-09-10) + +- Split Q promises wrapper to new repository. +- Update to package file for npm registry. + +## 1.2.1 (2015-08-15) + +- Implements ID Based Routing. +- Fixes Issue [#49](https://github.com/Azure/azure-documentdb-node/issues/49) - current property conflicts with method current(). + +## 1.2.0 (2015-08-05) + +- Added support for GeoSpatial index. +- Validates id property for all resources. Ids for resources cannot contain ?, /, #, \\, characters or end with a space. +- Adds new header "index transformation progress" to ResourceResponse. + +## 1.1.0 (2015-07-09) + +- Implements V2 indexing policy. + +## 1.0.3 (2015-06-04) + +- Issue [#40](https://github.com/Azure/azure-documentdb-node/issues/40) - Implemented eslint and grunt configurations in the core and promise SDK. + +## 1.0.2 (2015-05-23) + +- Issue [#45](https://github.com/Azure/azure-documentdb-node/issues/45) - Promises wrapper does not include header with error. + +## 1.0.1 (2015-05-15) + +- Implemented ability to query for conflicts by adding readConflicts, readConflictAsync, queryConflicts. +- Updated API documentation. +- Issue [#41](https://github.com/Azure/azure-documentdb-node/issues/41) - client.createDocumentAsync error. + +Microsoft will provide notification at least **12 months** in advance of retiring an SDK in order to smooth the transition to a newer/supported version. + +New features, functionality, and optimizations are only added to the current SDK. So it's recommended that you always upgrade to the latest SDK version as early as possible. + +Any request to Cosmos DB using a retired SDK will be rejected by the service. + +> [!WARNING] +> All versions **1.x** of the Cosmos JavaScript SDK for SQL API will be retired on **August 30, 2020**. +> +>
+ +| Version | Release Date | Retirement Date | +| ------------------------ | ------------------ | --------------- | +| [3.4.2](#3.4.2) | November 7, 2019 | --- | +| [3.4.1](#3.4.1) | November 5, 2019 | --- | +| [3.4.0](#3.4.0) | October 28, 2019 | --- | +| [3.3.6](#3.3.6) | October 14, 2019 | --- | +| [3.3.5](#3.3.5) | October 14, 2019 | --- | +| [3.3.4](#3.3.4) | October 14, 2019 | --- | +| [3.3.3](#3.3.3) | October 3, 2019 | --- | +| [3.3.2](#3.3.2) | October 3, 2019 | --- | +| [3.3.1](#3.3.1) | October 1, 2019 | --- | +| [3.3.0](#3.3.0) | September 24, 2019 | --- | +| [3.2.0](#3.2.0) | August 26, 2019 | --- | +| [3.1.1](#3.1.1) | August 7, 2019 | --- | +| [3.1.0](#3.1.0) | July 26, 2019 | --- | +| [3.0.4](#3.0.4) | July 22, 2019 | --- | +| [3.0.3](#3.0.3) | July 17, 2019 | --- | +| [3.0.2](#3.0.2) | July 9, 2019 | --- | +| [3.0.0](#3.0.0) | June 28, 2019 | --- | +| [2.1.5](#2.1.5) | March 20, 2019 | --- | +| [2.1.4](#2.1.4) | March 15, 2019 | --- | +| [2.1.3](#2.1.3) | March 8, 2019 | --- | +| [2.1.2](#2.1.2) | January 28, 2019 | --- | +| [2.1.1](#2.1.1) | December 5, 2018 | --- | +| [2.1.0](#2.1.0) | December 4, 2018 | --- | +| [2.0.5](#2.0.5) | November 7, 2018 | --- | +| [2.0.4](#2.0.4) | October 30, 2018 | --- | +| [2.0.3](#2.0.3) | October 30, 2018 | --- | +| [2.0.2](#2.0.2) | October 10, 2018 | --- | +| [2.0.1](#2.0.1) | September 25, 2018 | --- | +| [2.0.0](#2.0.0) | September 24, 2018 | --- | +| [2.0.0-3 (RC)](#2.0.0-3) | August 2, 2018 | --- | +| [1.14.4](#1.14.4) | May 03, 2018 | August 30, 2020 | +| [1.14.3](#1.14.3) | May 03, 2018 | August 30, 2020 | +| [1.14.2](#1.14.2) | December 21, 2017 | August 30, 2020 | +| [1.14.1](#1.14.1) | November 10, 2017 | August 30, 2020 | +| [1.14.0](#1.14.0) | November 9, 2017 | August 30, 2020 | +| [1.13.0](#1.13.0) | October 11, 2017 | August 30, 2020 | +| [1.12.2](#1.12.2) | August 10, 2017 | August 30, 2020 | +| [1.12.1](#1.12.1) | August 10, 2017 | August 30, 2020 | +| [1.12.0](#1.12.0) | May 10, 2017 | August 30, 2020 | +| [1.11.0](#1.11.0) | March 16, 2017 | August 30, 2020 | +| [1.10.2](#1.10.2) | January 27, 2017 | August 30, 2020 | +| [1.10.1](#1.10.1) | December 22, 2016 | August 30, 2020 | +| [1.10.0](#1.10.0) | October 03, 2016 | August 30, 2020 | +| [1.9.0](#1.9.0) | July 07, 2016 | August 30, 2020 | +| [1.8.0](#1.8.0) | June 14, 2016 | August 30, 2020 | +| [1.7.0](#1.7.0) | April 26, 2016 | August 30, 2020 | +| [1.6.0](#1.6.0) | March 29, 2016 | August 30, 2020 | +| [1.5.6](#1.5.6) | March 08, 2016 | August 30, 2020 | +| [1.5.5](#1.5.5) | February 02, 2016 | August 30, 2020 | +| [1.5.4](#1.5.4) | February 01, 2016 | August 30, 2020 | +| [1.5.3](#1.5.2) | January 26, 2016 | August 30, 2020 | +| [1.5.2](#1.5.2) | January 22, 2016 | August 30, 2020 | +| [1.5.1](#1.5.1) | January 4, 2016 | August 30, 2020 | +| [1.5.0](#1.5.0) | December 31, 2015 | August 30, 2020 | +| [1.4.0](#1.4.0) | October 06, 2015 | August 30, 2020 | +| [1.3.0](#1.3.0) | October 06, 2015 | August 30, 2020 | +| [1.2.2](#1.2.2) | September 10, 2015 | August 30, 2020 | +| [1.2.1](#1.2.1) | August 15, 2015 | August 30, 2020 | +| [1.2.0](#1.2.0) | August 05, 2015 | August 30, 2020 | +| [1.1.0](#1.1.0) | July 09, 2015 | August 30, 2020 | +| [1.0.3](#1.0.3) | June 04, 2015 | August 30, 2020 | +| [1.0.2](#1.0.2) | May 23, 2015 | August 30, 2020 | +| [1.0.1](#1.0.1) | May 15, 2015 | August 30, 2020 | +| [1.0.0](#1.0.0) | April 08, 2015 | August 30, 2020 | diff --git a/local_dependencies/@azure/cosmos/LICENSE b/local_dependencies/@azure/cosmos/LICENSE new file mode 100644 index 000000000..ea8fb1516 --- /dev/null +++ b/local_dependencies/@azure/cosmos/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2020 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/local_dependencies/@azure/cosmos/README.md b/local_dependencies/@azure/cosmos/README.md new file mode 100644 index 000000000..0b83faf67 --- /dev/null +++ b/local_dependencies/@azure/cosmos/README.md @@ -0,0 +1,571 @@ +# Azure Cosmos DB client library for JavaScript/TypeScript + +[![latest npm badge](https://img.shields.io/npm/v/%40azure%2Fcosmos/latest.svg)][npm] +[![Build Status](https://dev.azure.com/azure-sdk/public/_apis/build/status/js/js%20-%20cosmosdb%20-%20ci?branchName=main)](https://dev.azure.com/azure-sdk/public/_build/latest?definitionId=850&branchName=main) + +Azure Cosmos DB is a globally distributed, multi-model database service that supports document, key-value, wide-column, and graph databases. This package is intended for JavaScript/TypeScript applications to interact with **SQL API** databases and the JSON documents they contain: + +- Create Cosmos DB databases and modify their settings +- Create and modify containers to store collections of JSON documents +- Create, read, update, and delete the items (JSON documents) in your containers +- Query the documents in your database using SQL-like syntax + +Key links: + +- [Package (npm)][npm] +- [API reference documentation](https://docs.microsoft.com/javascript/api/@azure/cosmos/?view=azure-node-lates) +- [Product documentation][cosmos_docs] + +## Getting started + +### Prerequisites + +#### Azure Subscription and Cosmos DB SQL API Account + +You must have an [Azure Subscription][azure_sub], and a [Cosmos DB account][cosmos_account] (SQL API) to use this package. + +If you need a Cosmos DB SQL API account, you can use the Azure [Cloud Shell][cloud_shell_bash] to create one with this Azure CLI command: + +```Bash +az cosmosdb create --resource-group --name +``` + +Or you can create an account in the [Azure Portal](https://portal.azure.com/#create/microsoft.documentdb) + +#### NodeJS + +This package is distributed via [npm][npm] which comes preinstalled with [NodeJS](https://nodejs.org/en/). You should be using Node v10 or above. + +#### CORS + +You need to set up [Cross-Origin Resource Sharing (CORS)](https://docs.microsoft.com/azure/cosmos-db/how-to-configure-cross-origin-resource-sharing) rules for your Cosmos DB account if you need to develop for browsers. Follow the instructions in the linked document to create new CORS rules for your Cosmos DB. + +### Install this package + +```Bash +npm install @azure/cosmos +``` + +### Get Account Credentials + +You will need your Cosmos DB **Account Endpoint** and **Key**. You can find these in the [Azure Portal](https://portal.azure.com/#blade/hubsextension/browseresource/resourcetype/microsoft.documentdb%2fdatabaseaccounts) or use the [Azure CLI][azure_cli] snippet below. The snippet is formatted for the Bash shell. + +```Bash +az cosmosdb show --resource-group --name --query documentEndpoint --output tsv +az cosmosdb keys list --resource-group --name --query primaryMasterKey --output tsv +``` + +### Create an instance of `CosmosClient` + +Interaction with Cosmos DB starts with an instance of the [CosmosClient](https://docs.microsoft.com/javascript/api/@azure/cosmos/cosmosclient?view=azure-node-latest) class + +```js +const { CosmosClient } = require("@azure/cosmos"); + +const endpoint = "https://your-account.documents.azure.com"; +const key = ""; +const client = new CosmosClient({ endpoint, key }); + +async function main() { + // The rest of the README samples are designed to be pasted into this function body +} + +main().catch((error) => { + console.error(error); +}); +``` + +For simplicity we have included the `key` and `endpoint` directly in the code but you will likely want to load these from a file not in source control using a project such as [dotenv](https://www.npmjs.com/package/dotenv) or loading from environment variables + +In production environments, secrets like keys should be stored in [Azure Key Vault](https://azure.microsoft.com/services/key-vault/) + +## Key concepts + +Once you've initialized a [CosmosClient](https://docs.microsoft.com/javascript/api/@azure/cosmos/cosmosclient?view=azure-node-lates), you can interact with the primary resource types in Cosmos DB: + +- [Database](https://docs.microsoft.com/javascript/api/@azure/cosmos/database?view=azure-node-latest): A Cosmos DB account can contain multiple databases. When you create a database, you specify the API you'd like to use when interacting with its documents: SQL, MongoDB, Gremlin, Cassandra, or Azure Table. Use the [Database](https://docs.microsoft.com/javascript/api/@azure/cosmos/database?view=azure-node-latest) object to manage its containers. + +- [Container](https://docs.microsoft.com/javascript/api/@azure/cosmos/container?view=azure-node-latest): A container is a collection of JSON documents. You create (insert), read, update, and delete items in a container by using methods on the [Container](https://docs.microsoft.com/javascript/api/@azure/cosmos/container?view=azure-node-latest) object. + +- [Item](https://docs.microsoft.com/javascript/api/@azure/cosmos/item?view=azure-node-latest): An Item is a JSON document stored in a container. Each Item must include an `id` key with a value that uniquely identifies the item within the container. If you do not provide an `id`, the SDK will generate one automatically. + +For more information about these resources, see [Working with Azure Cosmos databases, containers and items][cosmos_resources]. + +## Examples + +The following sections provide several code snippets covering some of the most common Cosmos DB tasks, including: + +- [Create a database](#create-a-database) +- [Create a container](#create-a-container) +- [Using Partition Keys](#using-partition-keys) +- [Insert items](#insert-items) +- [Query documents](#query-the-database) +- [Read an item](#read-an-item) +- [Delete an item](#delete-an-data) +- [CRUD on Container with hierarchical partition key](#container-hierarchical-partition-key) +### Create a database + +After authenticating your [CosmosClient](https://docs.microsoft.com/javascript/api/@azure/cosmos/cosmosclient?view=azure-node-latest), you can work with any resource in the account. The code snippet below creates a NOSQL API database. + +```js +const { database } = await client.databases.createIfNotExists({ id: "Test Database" }); +console.log(database.id); +``` + +### Create a container + +This example creates a container with default settings + +```js +const { container } = await database.containers.createIfNotExists({ id: "Test Database" }); +console.log(container.id); +``` + +### Using Partition Keys +This example shows various types of partition Keys supported. +```js +await container.item("id", "1").read(); // string type +await container.item("id", 2).read(); // number type +await container.item("id", true).read(); // boolean type +await container.item("id", {}).read(); // None type +await container.item("id", undefined).read(); // None type +await container.item("id", null).read(); // null type +``` + +If the Partition Key consists of a single value, it could be supplied either as a literal value, or an array. + +```js +await container.item("id", "1").read(); +await container.item("id", ["1"]).read(); +``` + +If the Partition Key consists of more than one values, it should be supplied as an array. +```js +await container.item("id", ["a", "b"]).read(); +await container.item("id", ["a", 2]).read(); +await container.item("id", [{}, {}]).read(); +await container.item("id", ["a", {}]).read(); +await container.item("id", [2, null]).read(); + +``` + +### Insert items + +To insert items into a container, pass an object containing your data to [Items.upsert](https://docs.microsoft.com/javascript/api/@azure/cosmos/items?view=azure-node-latest#upsert-t--requestoptions-). The Azure Cosmos DB service requires each item has an `id` key. If you do not provide one, the SDK will generate an `id` automatically. + +This example inserts several items into the container + +```js +const cities = [ + { id: "1", name: "Olympia", state: "WA", isCapitol: true }, + { id: "2", name: "Redmond", state: "WA", isCapitol: false }, + { id: "3", name: "Chicago", state: "IL", isCapitol: false } +]; +for (const city of cities) { + await container.items.create(city); +} +``` + +### Read an item + +To read a single item from a container, use [Item.read](https://docs.microsoft.com/javascript/api/@azure/cosmos/item?view=azure-node-latest#read-requestoptions-). This is a less expensive operation than using SQL to query by `id`. + +```js +await container.item("1", "1").read(); +``` +### CRUD on Container with hierarchical partition key + +Create a Container with hierarchical partition key +```js +const containerDefinition = { + id: "Test Database", + partitionKey: { + paths: ["/name", "/address/zip"], + version: PartitionKeyDefinitionVersion.V2, + kind: PartitionKeyKind.MultiHash, + }, +} +const { container } = await database.containers.createIfNotExists(containerDefinition); +console.log(container.id); +``` +Insert an item with hierarchical partition key defined as - `["/name", "/address/zip"]` +```js +const item = { + id: "1", + name: 'foo', + address: { + zip: 100 + }, + active: true +} +await container.items.create(item); +``` + +To read a single item from a container with hierarchical partition key defined as - `["/name", "/address/zip"],` +```js +await container.item("1", ["foo", 100]).read(); +``` +Query an item with hierarchical partition key with hierarchical partition key defined as - `["/name", "/address/zip"],` +```js +const { resources } = await container.items + .query("SELECT * from c WHERE c.active = true", { + partitionKey: ["foo", 100], + }) + .fetchAll(); +for (const item of resources) { + console.log(`${item.name}, ${item.address.zip} `); +} +``` +### Delete an item + +To delete items from a container, use [Item.delete](https://docs.microsoft.com/javascript/api/@azure/cosmos/item?view=azure-node-latest#delete-requestoptions-). + +```js +// Delete the first item returned by the query above +await container.item("1").delete(); +``` + +### Query the database + +A Cosmos DB SQL API database supports querying the items in a container with [Items.query](https://docs.microsoft.com/javascript/api/@azure/cosmos/items?view=azure-node-latest#query-string---sqlqueryspec--feedoptions-) using SQL-like syntax: + +```js +const { resources } = await container.items + .query("SELECT * from c WHERE c.isCapitol = true") + .fetchAll(); +for (const city of resources) { + console.log(`${city.name}, ${city.state} is a capitol `); +} +``` + +Perform parameterized queries by passing an object containing the parameters and their values to [Items.query](https://docs.microsoft.com/javascript/api/@azure/cosmos/items?view=azure-node-latest#query-string---sqlqueryspec--feedoptions-): + +```js +const { resources } = await container.items + .query({ + query: "SELECT * from c WHERE c.isCapitol = @isCapitol", + parameters: [{ name: "@isCapitol", value: true }] + }) + .fetchAll(); +for (const city of resources) { + console.log(`${city.name}, ${city.state} is a capitol `); +} +``` + +For more information on querying Cosmos DB databases using the SQL API, see [Query Azure Cosmos DB data with SQL queries][cosmos_sql_queries]. + +### Change Feed Pull Model + +Change feed can be fetched for a partition key, a feed range or an entire container. + +To process the change feed, create an instance of `ChangeFeedPullModelIterator`. When you initially create `ChangeFeedPullModelIterator`, you must specify a required `changeFeedStartFrom` value inside the `ChangeFeedIteratorOptions` which consists of both the starting position for reading changes and the resource(a partition key or a FeedRange) for which changes are to be fetched. You can optionally use `maxItemCount` in `ChangeFeedIteratorOptions` to set the maximum number of items received per page. + +Note: If no `changeFeedStartFrom` value is specified, then changefeed will be fetched for an entire container from Now(). + +There are four starting positions for change feed: + +- `Beginning` + +```js +// Signals the iterator to read changefeed from the beginning of time. +const options = { + changeFeedStartFrom: ChangeFeedStartFrom.Beginning(), +}; +const iterator = container.getChangeFeedIterator(options); +``` + +- `Time` + +```js +// Signals the iterator to read changefeed from a particular point of time. +const time = new Date("2023/09/11"); // some sample date +const options = { + changeFeedStartFrom: ChangeFeedStartFrom.Time(time), +}; +``` + +- `Now` + +```js +// Signals the iterator to read changefeed from this moment onward. +const options = { + changeFeedStartFrom: ChangeFeedStartFrom.Now(), +}; +``` + +- `Continuation` + +```js +// Signals the iterator to read changefeed from a saved point. +const continuationToken = "some continuation token recieved from previous request"; +const options = { + changeFeedStartFrom: ChangeFeedStartFrom.Continuation(continuationToken), +}; +``` + +Here's an example of fetching change feed for a partition key + +```js +const partitionKey = "some-partition-Key-value"; +const options = { + changeFeedStartFrom: ChangeFeedStartFrom.Beginning(partitionKey), +}; + +const iterator = container.items.getChangeFeedIterator(options); + +while (iterator.hasMoreResults) { + const response = await iterator.readNext(); + // process this response +} +``` + +Because the change feed is effectively an infinite list of items that encompasses all future writes and updates, the value of `hasMoreResults` is always `true`. When you try to read the change feed and there are no new changes available, you receive a response with `NotModified` status. + +More detailed usage guidelines and examples of change feed can be found [here](https://learn.microsoft.com/azure/cosmos-db/nosql/change-feed-pull-model?tabs=javascript). + +## Error Handling + +The SDK generates various types of errors that can occur during an operation. + +1. `ErrorResponse` is thrown if the response of an operation returns an error code of >=400. +2. `TimeoutError` is thrown if Abort is called internally due to timeout. +3. `AbortError` is thrown if any user passed signal caused the abort. +4. `RestError` is thrown in case of failure of underlying system call due to network issues. +5. Errors generated by any devDependencies. For Eg. `@azure/identity` package could throw `CredentialUnavailableError`. + +Following is an example for handling errors of type `ErrorResponse`, `TimeoutError`, `AbortError`, and `RestError`. + +```js +try { + // some code +} catch (err) { + if (err instanceof ErrorResponse) { + // some specific error handling. + } else if (err instanceof RestError) { + // some specific error handling. + } + // handle other type of errors in similar way. + else { + // for any other error. + } +} +``` + +It's important to properly handle these errors to ensure that your application can gracefully recover from any failures and continue functioning as expected. More details about some of these errors and their possible solutions can be found [here](https://learn.microsoft.com/azure/cosmos-db/nosql/conceptual-resilient-sdk-applications#should-my-application-retry-on-errors). + +## Troubleshooting + +### General + +When you interact with Cosmos DB errors returned by the service correspond to the same HTTP status codes returned for REST API requests: + +[HTTP Status Codes for Azure Cosmos DB][cosmos_http_status_codes] + +#### Conflicts + +For example, if you try to create an item using an `id` that's already in use in your Cosmos DB database, a `409` error is returned, indicating the conflict. In the following snippet, the error is handled gracefully by catching the exception and displaying additional information about the error. + +```js +try { + await containers.items.create({ id: "existing-item-id" }); +} catch (error) { + if (error.code === 409) { + console.log("There was a conflict with an existing item"); + } +} +``` + +### Transpiling + +The Azure SDKs are designed to support ES5 JavaScript syntax and [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). If you need support for earlier JavaScript runtimes such as Internet Explorer or Node 6, you will need to transpile the SDK code as part of your build process. + +### Handle transient errors with retries + +While working with Cosmos DB, you might encounter transient failures caused by [rate limits][cosmos_request_units] enforced by the service, or other transient problems like network outages. For information about handling these types of failures, see [Retry pattern][azure_pattern_retry] in the Cloud Design Patterns guide, and the related [Circuit Breaker pattern][azure_pattern_circuit_breaker]. + +### Logging + +Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`. While using `AZURE_LOG_LEVEL` make sure to set it before logging library is initialized. +Ideally pass it through command line, if using libraries like `dotenv` make sure such libraries are initialized before logging library. + +```javascript +const { setLogLevel } = require("@azure/logger"); +setLogLevel("info"); +``` + +For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger). + +### Diagnostics + +Cosmos Diagnostics feature provides enhanced insights into all your client operations. A CosmosDiagnostics object is added to response of all client operations. such as +- Point look up operation reponse - `item.read()`, `container.create()`, `database.delete()` +- Query operation reponse -`queryIterator.fetchAll()`, +- Bulk and Batch operations -`item.batch()`. +- Error/Exception response objects. + +A CosmosDiagnostics object is added to response of all client operations. +There are 3 Cosmos Diagnostic levels, info, debug and debug-unsafe. Where only info is meant for production systems and debug and debug-unsafe are meant to be used during development and debugging, since they consume significantly higher resources. Cosmos Diagnostic level can be set in 2 ways +- Programatically +```js + const client = new CosmosClient({ endpoint, key, diagnosticLevel: CosmosDbDiagnosticLevel.debug }); +``` +- Using environment variables. (Diagnostic level set by Environment variable has higher priority over setting it through client options.) +```bash + export AZURE_COSMOSDB_DIAGNOSTICS_LEVEL="debug" +``` + +Cosmos Diagnostic has three members +- ClientSideRequestStatistics Type: Contains aggregates diagnostic details, including metadata lookups, retries, endpoints contacted, and request and response statistics like payload size and duration. (is always collected, can be used in production systems.) + +- DiagnosticNode: Is a tree-like structure that captures detailed diagnostic information. Similar to `har` recording present in browsers. This feature is disabled by default and is intended for debugging non-production environments only. (collected at diagnostic level debug and debug-unsafe) + +- ClientConfig: Captures essential information related to client's configuration settings during client initialization. (collected at diagnostic level debug and debug-unsafe) + +Please make sure to never set diagnostic level to `debug-unsafe` in production environment, since it this level `CosmosDiagnostics` captures request and response payloads and if you choose to log it (it is by default logged by @azure/logger at `verbose` level). These payloads might get captured in your log sinks. + +#### Consuming Diagnostics + +- Since `diagnostics` is added to all Response objects. You could programatically access `CosmosDiagnostic` as follows. +```js + // For point look up operations + const { container, diagnostics: containerCreateDiagnostic } = + await database.containers.createIfNotExists({ + id: containerId, + partitionKey: { + paths: ["/key1"], + }, + }); + + // For Batch operations + const operations: OperationInput[] = [ + { + operationType: BulkOperationType.Create, + resourceBody: { id: 'A', key: "A", school: "high" }, + }, + ]; + const response = await container.items.batch(operations, "A"); + + // For query operations + const queryIterator = container.items.query("select * from c"); + const { resources, diagnostics } = await queryIterator.fetchAll(); + + // While error handling + try { + // Some operation that might fail + } catch (err) { + const diagnostics = err.diagnostics + } +``` +- You could also log `diagnostics` using `@azure/logger`, diagnostic is always logged using `@azure/logger` at `verbose` level. So if you set Diagnostic level to `debug` or `debug-unsafe` and `@azure/logger` level to `verbose`, `diagnostics` will be logged. +## Next steps + +### More sample code + +[Several samples][cosmos_samples] are available to you in the SDK's GitHub repository. These samples provide example code for additional scenarios commonly encountered while working with Cosmos DB: + +- Database Operations +- Container Operations +- Item Operations +- Configuring Indexing +- Reading a container Change Feed +- Stored Procedures +- Changing Database/Container throughput settings +- Multi Region Write Operations + +### Limitations + +Currently the features below are **not supported**. For alternatives options, check the **Workarounds** section below. + +### Data Plane Limitations: + +* Queries with COUNT from a DISTINCT subquery​ +* Direct TCP Mode access​ +* Aggregate cross-partition queries, like sorting, counting, and distinct, don't support continuation tokens. Streamable queries, like SELECT \* FROM WHERE , support continuation tokens. See the "Workaround" section for executing non-streamable queries without a continuation token. +* Change Feed: Processor +* Change Feed: Read multiple partitions key values +* Change Feed pull model all versions and delete mode [#27058](https://github.com/Azure/azure-sdk-for-js/issues/27058) +* Change Feed pull model support for partial hierarchical partition keys [#27059](https://github.com/Azure/azure-sdk-for-js/issues/27059) +* Cross-partition ORDER BY for mixed types + +### Control Plane Limitations: + +* Get CollectionSizeUsage, DatabaseUsage, and DocumentUsage metrics​ +* Create Geospatial Index +* Update Autoscale throughput + +## Workarounds + +### Continuation token for cross partitions queries +You can achieve cross partition queries with continuation token support by using +[Side car pattern](https://github.com/Azure-Samples/Cosmosdb-query-sidecar). +This pattern can also enable applications to be composed of heterogeneous components and technologies. + +### Executing non-stremable cross-partition query + +To execute non-streamable queries without the use of continuation tokens, you can create a query iterator with the required query specification and options. The following sample code demonstrates how to use a query iterator to fetch all results without the need for a continuation token: + +```javascript +const querySpec = { + query: "SELECT * FROM c WHERE c.status = @status", + parameters: [{ name: "@status", value: "active" }], +}; +const queryOptions = { + maxItemCount: 10, // maximum number of items to return per page + enableCrossPartitionQuery: true, +}; +const querIterator = await container.items.query(querySpec, queryOptions); +while (querIterator.hasMoreResults()) { + const { resources: result } = await querIterator.fetchNext(); + //Do something with result +} +``` + +This approach can also be used for streamable queries. + +### Control Plane operations +Typically, you can use [Azure Portal](https://portal.azure.com/), [Azure Cosmos DB Resource Provider REST API](https://docs.microsoft.com/rest/api/cosmos-db-resource-provider), [Azure CLI](https://docs.microsoft.com/cli/azure/azure-cli-reference-for-cosmos-db) or [PowerShell](https://docs.microsoft.com/azure/cosmos-db/manage-with-powershell) for the control plane unsupported limitations. + + +### Additional documentation + +For more extensive documentation on the Cosmos DB service, see the [Azure Cosmos DB documentation][cosmos_docs] on docs.microsoft.com. + +## Useful links + +- [Welcome to Azure Cosmos DB](https://docs.microsoft.com/azure/cosmos-db/community) +- [Quick start](https://docs.microsoft.com/azure/cosmos-db/sql-api-nodejs-get-started) +- [Tutorial](https://docs.microsoft.com/azure/cosmos-db/sql-api-nodejs-application) +- [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cosmosdb/cosmos/samples) +- [Introduction to Resource Model of Azure Cosmos DB Service](https://docs.microsoft.com/azure/cosmos-db/sql-api-resources) +- [Introduction to SQL API of Azure Cosmos DB Service](https://docs.microsoft.com/azure/cosmos-db/sql-api-sql-query) +- [Partitioning](https://docs.microsoft.com/azure/cosmos-db/sql-api-partition-data) +- [API Documentation](https://docs.microsoft.com/javascript/api/%40azure/cosmos/?view=azure-node-latest) + +## Contributing + +If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code. + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcosmosdb%2Fcosmos%2FREADME.png) + + + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_pattern_circuit_breaker]: https://docs.microsoft.com/azure/architecture/patterns/circuit-breaker +[azure_pattern_retry]: https://docs.microsoft.com/azure/architecture/patterns/retry +[azure_portal]: https://portal.azure.com +[azure_sub]: https://azure.microsoft.com/free/ +[cloud_shell]: https://docs.microsoft.com/azure/cloud-shell/overview +[cloud_shell_bash]: https://shell.azure.com/bash +[cosmos_account_create]: https://docs.microsoft.com/azure/cosmos-db/how-to-manage-database-account +[cosmos_account]: https://docs.microsoft.com/azure/cosmos-db/account-overview +[cosmos_container]: https://docs.microsoft.com/azure/cosmos-db/databases-containers-items#azure-cosmos-containers +[cosmos_database]: https://docs.microsoft.com/azure/cosmos-db/databases-containers-items#azure-cosmos-databases +[cosmos_docs]: https://docs.microsoft.com/azure/cosmos-db/ +[cosmos_http_status_codes]: https://docs.microsoft.com/rest/api/cosmos-db/http-status-codes-for-cosmosdb +[cosmos_item]: https://docs.microsoft.com/azure/cosmos-db/databases-containers-items#azure-cosmos-items +[cosmos_request_units]: https://docs.microsoft.com/azure/cosmos-db/request-units +[cosmos_resources]: https://docs.microsoft.com/azure/cosmos-db/databases-containers-items +[cosmos_samples]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cosmosdb/cosmos/samples +[cosmos_sql_queries]: https://docs.microsoft.com/azure/cosmos-db/how-to-sql-query +[cosmos_ttl]: https://docs.microsoft.com/azure/cosmos-db/time-to-live +[npm]: https://www.npmjs.com/package/@azure/cosmos diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts new file mode 100644 index 000000000..d19f6fddc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts @@ -0,0 +1,38 @@ +/// +import { ChangeFeedResponse } from "./ChangeFeedResponse"; +import { Resource } from "./client"; +/** + * Provides iterator for change feed. + * + * Use `Items.changeFeed()` to get an instance of the iterator. + */ +export declare class ChangeFeedIterator { + private clientContext; + private resourceId; + private resourceLink; + private partitionKey; + private changeFeedOptions; + private static readonly IfNoneMatchAllHeaderValue; + private nextIfNoneMatch; + private ifModifiedSince; + private lastStatusCode; + private isPartitionSpecified; + /** + * Gets a value indicating whether there are potentially additional results that can be retrieved. + * + * Initially returns true. This value is set based on whether the last execution returned a continuation token. + * + * @returns Boolean value representing if whether there are potentially additional results that can be retrieved. + */ + get hasMoreResults(): boolean; + /** + * Gets an async iterator which will yield pages of results from Azure Cosmos DB. + */ + getAsyncIterator(): AsyncIterable>>; + /** + * Read feed and retrieves the next page of results in Azure Cosmos DB. + */ + fetchNext(): Promise>>; + private getFeedResponse; +} +//# sourceMappingURL=ChangeFeedIterator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts.map new file mode 100644 index 000000000..c86960f6d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedIterator.d.ts","sourceRoot":"","sources":["../../src/ChangeFeedIterator.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AASpC;;;;GAIG;AACH,qBAAa,kBAAkB,CAAC,CAAC;IAW7B,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,iBAAiB;IAd3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAO;IACxD,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,oBAAoB,CAAU;IAmCtC;;;;;;OAMG;IACH,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED;;OAEG;IACW,gBAAgB,IAAI,aAAa,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IASxF;;OAEG;IACU,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;YAS5D,eAAe;CAgD9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js new file mode 100644 index 000000000..0309b76d0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js @@ -0,0 +1,107 @@ +import { __asyncGenerator, __await } from "tslib"; +import { ChangeFeedResponse } from "./ChangeFeedResponse"; +import { Constants, ResourceType, StatusCodes } from "./common"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "./utils/diagnostics"; +/** + * Provides iterator for change feed. + * + * Use `Items.changeFeed()` to get an instance of the iterator. + */ +export class ChangeFeedIterator { + /** + * @internal + */ + constructor(clientContext, resourceId, resourceLink, partitionKey, changeFeedOptions) { + this.clientContext = clientContext; + this.resourceId = resourceId; + this.resourceLink = resourceLink; + this.partitionKey = partitionKey; + this.changeFeedOptions = changeFeedOptions; + // partition key XOR partition key range id + const partitionKeyValid = partitionKey !== undefined; + this.isPartitionSpecified = partitionKeyValid; + let canUseStartFromBeginning = true; + if (changeFeedOptions.continuation) { + this.nextIfNoneMatch = changeFeedOptions.continuation; + canUseStartFromBeginning = false; + } + if (changeFeedOptions.startTime) { + // .toUTCString() is platform specific, but most platforms use RFC 1123. + // In ECMAScript 2018, this was standardized to RFC 1123. + // See for more info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString + this.ifModifiedSince = changeFeedOptions.startTime.toUTCString(); + canUseStartFromBeginning = false; + } + if (canUseStartFromBeginning && !changeFeedOptions.startFromBeginning) { + this.nextIfNoneMatch = ChangeFeedIterator.IfNoneMatchAllHeaderValue; + } + } + /** + * Gets a value indicating whether there are potentially additional results that can be retrieved. + * + * Initially returns true. This value is set based on whether the last execution returned a continuation token. + * + * @returns Boolean value representing if whether there are potentially additional results that can be retrieved. + */ + get hasMoreResults() { + return this.lastStatusCode !== StatusCodes.NotModified; + } + /** + * Gets an async iterator which will yield pages of results from Azure Cosmos DB. + */ + getAsyncIterator() { + return __asyncGenerator(this, arguments, function* getAsyncIterator_1() { + do { + const result = yield __await(this.fetchNext()); + if (result.count > 0) { + yield yield __await(result); + } + } while (this.hasMoreResults); + }); + } + /** + * Read feed and retrieves the next page of results in Azure Cosmos DB. + */ + async fetchNext() { + return withDiagnostics(async (diagnosticNode) => { + const response = await this.getFeedResponse(diagnosticNode); + this.lastStatusCode = response.statusCode; + this.nextIfNoneMatch = response.headers[Constants.HttpHeaders.ETag]; + return response; + }, this.clientContext); + } + async getFeedResponse(diagnosticNode) { + if (!this.isPartitionSpecified) { + throw new Error("Container is partitioned, but no partition key or partition key range id was specified."); + } + const feedOptions = { initialHeaders: {}, useIncrementalFeed: true }; + if (typeof this.changeFeedOptions.maxItemCount === "number") { + feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount; + } + if (this.changeFeedOptions.sessionToken) { + feedOptions.sessionToken = this.changeFeedOptions.sessionToken; + } + if (this.nextIfNoneMatch) { + feedOptions.accessCondition = { + type: Constants.HttpHeaders.IfNoneMatch, + condition: this.nextIfNoneMatch, + }; + } + if (this.ifModifiedSince) { + feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.ifModifiedSince; + } + const response = await this.clientContext.queryFeed({ + path: this.resourceLink, + resourceType: ResourceType.item, + resourceId: this.resourceId, + resultFn: (result) => (result ? result.Documents : []), + query: undefined, + options: feedOptions, + partitionKey: this.partitionKey, + diagnosticNode: diagnosticNode, + }); // TODO: some funky issues with query feed. Probably need to change it up. + return new ChangeFeedResponse(response.result, response.result ? response.result.length : 0, response.code, response.headers, getEmptyCosmosDiagnostics()); + } +} +ChangeFeedIterator.IfNoneMatchAllHeaderValue = "*"; +//# sourceMappingURL=ChangeFeedIterator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js.map new file mode 100644 index 000000000..6a786fa95 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedIterator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedIterator.js","sourceRoot":"","sources":["../../src/ChangeFeedIterator.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AA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,CAAC,SAAS,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC;SAC1F;QAED,MAAM,QAAQ,GAAkC,MAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAI;YACrF,IAAI,EAAE,IAAI,CAAC,YAAY;YACvB,YAAY,EAAE,YAAY,CAAC,IAAI;YAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;YACtD,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,WAAW;YACpB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,cAAc,EAAE,cAAc;SAC/B,CAAkB,CAAC,CAAC,0EAA0E;QAE/F,OAAO,IAAI,kBAAkB,CAC3B,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC5C,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,OAAO,EAChB,yBAAyB,EAAE,CAC5B,CAAC;IACJ,CAAC;;AAzHuB,4CAAyB,GAAG,GAAG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/// \nimport { ChangeFeedOptions } from \"./ChangeFeedOptions\";\nimport { ChangeFeedResponse } from \"./ChangeFeedResponse\";\nimport { Resource } from \"./client\";\nimport { ClientContext } from \"./ClientContext\";\nimport { Constants, ResourceType, StatusCodes } from \"./common\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { PartitionKey } from \"./documents\";\nimport { FeedOptions } from \"./request\";\nimport { Response } from \"./request\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"./utils/diagnostics\";\n\n/**\n * Provides iterator for change feed.\n *\n * Use `Items.changeFeed()` to get an instance of the iterator.\n */\nexport class ChangeFeedIterator {\n private static readonly IfNoneMatchAllHeaderValue = \"*\";\n private nextIfNoneMatch: string;\n private ifModifiedSince: string;\n private lastStatusCode: number;\n private isPartitionSpecified: boolean;\n\n /**\n * @internal\n */\n constructor(\n private clientContext: ClientContext,\n private resourceId: string,\n private resourceLink: string,\n private partitionKey: PartitionKey,\n private changeFeedOptions: ChangeFeedOptions,\n ) {\n // partition key XOR partition key range id\n const partitionKeyValid = partitionKey !== undefined;\n this.isPartitionSpecified = partitionKeyValid;\n\n let canUseStartFromBeginning = true;\n if (changeFeedOptions.continuation) {\n this.nextIfNoneMatch = changeFeedOptions.continuation;\n canUseStartFromBeginning = false;\n }\n\n if (changeFeedOptions.startTime) {\n // .toUTCString() is platform specific, but most platforms use RFC 1123.\n // In ECMAScript 2018, this was standardized to RFC 1123.\n // See for more info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString\n this.ifModifiedSince = changeFeedOptions.startTime.toUTCString();\n canUseStartFromBeginning = false;\n }\n\n if (canUseStartFromBeginning && !changeFeedOptions.startFromBeginning) {\n this.nextIfNoneMatch = ChangeFeedIterator.IfNoneMatchAllHeaderValue;\n }\n }\n\n /**\n * Gets a value indicating whether there are potentially additional results that can be retrieved.\n *\n * Initially returns true. This value is set based on whether the last execution returned a continuation token.\n *\n * @returns Boolean value representing if whether there are potentially additional results that can be retrieved.\n */\n get hasMoreResults(): boolean {\n return this.lastStatusCode !== StatusCodes.NotModified;\n }\n\n /**\n * Gets an async iterator which will yield pages of results from Azure Cosmos DB.\n */\n public async *getAsyncIterator(): AsyncIterable>> {\n do {\n const result = await this.fetchNext();\n if (result.count > 0) {\n yield result;\n }\n } while (this.hasMoreResults);\n }\n\n /**\n * Read feed and retrieves the next page of results in Azure Cosmos DB.\n */\n public async fetchNext(): Promise>> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const response = await this.getFeedResponse(diagnosticNode);\n this.lastStatusCode = response.statusCode;\n this.nextIfNoneMatch = response.headers[Constants.HttpHeaders.ETag];\n return response;\n }, this.clientContext);\n }\n\n private async getFeedResponse(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n if (!this.isPartitionSpecified) {\n throw new Error(\n \"Container is partitioned, but no partition key or partition key range id was specified.\",\n );\n }\n const feedOptions: FeedOptions = { initialHeaders: {}, useIncrementalFeed: true };\n\n if (typeof this.changeFeedOptions.maxItemCount === \"number\") {\n feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount;\n }\n\n if (this.changeFeedOptions.sessionToken) {\n feedOptions.sessionToken = this.changeFeedOptions.sessionToken;\n }\n\n if (this.nextIfNoneMatch) {\n feedOptions.accessCondition = {\n type: Constants.HttpHeaders.IfNoneMatch,\n condition: this.nextIfNoneMatch,\n };\n }\n\n if (this.ifModifiedSince) {\n feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.ifModifiedSince;\n }\n\n const response: Response> = await (this.clientContext.queryFeed({\n path: this.resourceLink,\n resourceType: ResourceType.item,\n resourceId: this.resourceId,\n resultFn: (result) => (result ? result.Documents : []),\n query: undefined,\n options: feedOptions,\n partitionKey: this.partitionKey,\n diagnosticNode: diagnosticNode,\n }) as Promise); // TODO: some funky issues with query feed. Probably need to change it up.\n\n return new ChangeFeedResponse(\n response.result,\n response.result ? response.result.length : 0,\n response.code,\n response.headers,\n getEmptyCosmosDiagnostics(),\n );\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts new file mode 100644 index 000000000..c326b284f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts @@ -0,0 +1,35 @@ +/** + * Specifies options for the change feed + * + * Some of these options control where and when to start reading from the change feed. The order of precedence is: + * - continuation + * - startTime + * - startFromBeginning + * + * If none of those options are set, it will start reading changes from the first `ChangeFeedIterator.fetchNext()` call. + */ +export interface ChangeFeedOptions { + /** + * Max amount of items to return per page + */ + maxItemCount?: number; + /** + * The continuation token to start from. + * + * This is equivalent to the etag and continuation value from the `ChangeFeedResponse` + */ + continuation?: string; + /** + * The session token to use. If not specified, will use the most recent captured session token to start with. + */ + sessionToken?: string; + /** + * Signals whether to start from the beginning or not. + */ + startFromBeginning?: boolean; + /** + * Specified the start time to start reading changes from. + */ + startTime?: Date; +} +//# sourceMappingURL=ChangeFeedOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts.map new file mode 100644 index 000000000..9940b8996 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedOptions.d.ts","sourceRoot":"","sources":["../../src/ChangeFeedOptions.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;OAEG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js new file mode 100644 index 000000000..4c929c7dc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ChangeFeedOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js.map new file mode 100644 index 000000000..01b17f7dc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedOptions.js","sourceRoot":"","sources":["../../src/ChangeFeedOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Specifies options for the change feed\n *\n * Some of these options control where and when to start reading from the change feed. The order of precedence is:\n * - continuation\n * - startTime\n * - startFromBeginning\n *\n * If none of those options are set, it will start reading changes from the first `ChangeFeedIterator.fetchNext()` call.\n */\nexport interface ChangeFeedOptions {\n /**\n * Max amount of items to return per page\n */\n maxItemCount?: number;\n /**\n * The continuation token to start from.\n *\n * This is equivalent to the etag and continuation value from the `ChangeFeedResponse`\n */\n continuation?: string;\n /**\n * The session token to use. If not specified, will use the most recent captured session token to start with.\n */\n sessionToken?: string;\n /**\n * Signals whether to start from the beginning or not.\n */\n startFromBeginning?: boolean;\n /**\n * Specified the start time to start reading changes from.\n */\n startTime?: Date;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts new file mode 100644 index 000000000..c280bc03e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts @@ -0,0 +1,53 @@ +import { CosmosDiagnostics } from "./CosmosDiagnostics"; +import { CosmosHeaders } from "./queryExecutionContext"; +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +export declare class ChangeFeedResponse { + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + readonly result: T; + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + readonly count: number; + /** + * Gets the status code of the response from Azure Cosmos DB + */ + readonly statusCode: number; + readonly diagnostics: CosmosDiagnostics; + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge(): number; + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId(): string; + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + * + * This is equivalent to the `etag` property. + */ + get continuation(): string; + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken(): string; + /** + * Gets the entity tag associated with last transaction in the Azure Cosmos DB service, + * which can be used as If-Non-Match Access condition for ReadFeed REST request or + * `continuation` property of `ChangeFeedOptions` parameter for + * `Items.changeFeed()` + * to get feed changes since the transaction specified by this entity tag. + * + * This is equivalent to the `continuation` property. + */ + get etag(): string; + /** + * Response headers of the response from Azure Cosmos DB + */ + headers: CosmosHeaders; +} +//# sourceMappingURL=ChangeFeedResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts.map new file mode 100644 index 000000000..26a0614bc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedResponse.d.ts","sourceRoot":"","sources":["../../src/ChangeFeedResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD;;GAEG;AACH,qBAAa,kBAAkB,CAAC,CAAC;IAK7B;;OAEG;aACa,MAAM,EAAE,CAAC;IACzB;;OAEG;aACa,KAAK,EAAE,MAAM;IAC7B;;OAEG;aACa,UAAU,EAAE,MAAM;aAElB,WAAW,EAAE,iBAAiB;IAKhD;;OAEG;IACH,IAAW,aAAa,IAAI,MAAM,CAGjC;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;;;OAIG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IAED;;;;;;;;OAQG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACI,OAAO,EAAE,aAAa,CAAC;CAC/B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js new file mode 100644 index 000000000..923e2c91e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js @@ -0,0 +1,68 @@ +import { Constants } from "./common"; +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +export class ChangeFeedResponse { + /** + * @internal + */ + constructor( + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + result, + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + count, + /** + * Gets the status code of the response from Azure Cosmos DB + */ + statusCode, headers, diagnostics) { + this.result = result; + this.count = count; + this.statusCode = statusCode; + this.diagnostics = diagnostics; + this.headers = Object.freeze(headers); + } + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge() { + const rus = this.headers[Constants.HttpHeaders.RequestCharge]; + return rus ? parseInt(rus, 10) : null; + } + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId() { + return this.headers[Constants.HttpHeaders.ActivityId]; + } + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + * + * This is equivalent to the `etag` property. + */ + get continuation() { + return this.etag; + } + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken() { + return this.headers[Constants.HttpHeaders.SessionToken]; + } + /** + * Gets the entity tag associated with last transaction in the Azure Cosmos DB service, + * which can be used as If-Non-Match Access condition for ReadFeed REST request or + * `continuation` property of `ChangeFeedOptions` parameter for + * `Items.changeFeed()` + * to get feed changes since the transaction specified by this entity tag. + * + * This is equivalent to the `continuation` property. + */ + get etag() { + return this.headers[Constants.HttpHeaders.ETag]; + } +} +//# sourceMappingURL=ChangeFeedResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js.map new file mode 100644 index 000000000..5b4a7fcb8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ChangeFeedResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedResponse.js","sourceRoot":"","sources":["../../src/ChangeFeedResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC7B;;OAEG;IACH;IACE;;OAEG;IACa,MAAS;IACzB;;OAEG;IACa,KAAa;IAC7B;;OAEG;IACa,UAAkB,EAClC,OAAsB,EACN,WAA8B;QAV9B,WAAM,GAAN,MAAM,CAAG;QAIT,UAAK,GAAL,KAAK,CAAQ;QAIb,eAAU,GAAV,UAAU,CAAQ;QAElB,gBAAW,GAAX,WAAW,CAAmB;QAE9C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAC9D,OAAO,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAED;;;;OAIG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;;OAQG;IACH,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;CAMF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"./CosmosDiagnostics\";\nimport { Constants } from \"./common\";\nimport { CosmosHeaders } from \"./queryExecutionContext\";\n\n/**\n * A single response page from the Azure Cosmos DB Change Feed\n */\nexport class ChangeFeedResponse {\n /**\n * @internal\n */\n constructor(\n /**\n * Gets the items returned in the response from Azure Cosmos DB\n */\n public readonly result: T,\n /**\n * Gets the number of items returned in the response from Azure Cosmos DB\n */\n public readonly count: number,\n /**\n * Gets the status code of the response from Azure Cosmos DB\n */\n public readonly statusCode: number,\n headers: CosmosHeaders,\n public readonly diagnostics: CosmosDiagnostics,\n ) {\n this.headers = Object.freeze(headers);\n }\n\n /**\n * Gets the request charge for this request from the Azure Cosmos DB service.\n */\n public get requestCharge(): number {\n const rus = this.headers[Constants.HttpHeaders.RequestCharge];\n return rus ? parseInt(rus, 10) : null;\n }\n\n /**\n * Gets the activity ID for the request from the Azure Cosmos DB service.\n */\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId];\n }\n\n /**\n * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.\n *\n * This is equivalent to the `etag` property.\n */\n public get continuation(): string {\n return this.etag;\n }\n\n /**\n * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.\n */\n public get sessionToken(): string {\n return this.headers[Constants.HttpHeaders.SessionToken];\n }\n\n /**\n * Gets the entity tag associated with last transaction in the Azure Cosmos DB service,\n * which can be used as If-Non-Match Access condition for ReadFeed REST request or\n * `continuation` property of `ChangeFeedOptions` parameter for\n * `Items.changeFeed()`\n * to get feed changes since the transaction specified by this entity tag.\n *\n * This is equivalent to the `continuation` property.\n */\n public get etag(): string {\n return this.headers[Constants.HttpHeaders.ETag];\n }\n\n /**\n * Response headers of the response from Azure Cosmos DB\n */\n public headers: CosmosHeaders;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.d.ts new file mode 100644 index 000000000..9b4d659d8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.d.ts @@ -0,0 +1,155 @@ +import { PartitionKeyRange } from "./client/Container/PartitionKeyRange"; +import { Resource } from "./client/Resource"; +import { HTTPMethod, ResourceType } from "./common/constants"; +import { CosmosClientOptions } from "./CosmosClientOptions"; +import { DatabaseAccount, PartitionKey } from "./documents"; +import { GlobalEndpointManager } from "./globalEndpointManager"; +import { SqlQuerySpec } from "./queryExecutionContext"; +import { QueryIterator } from "./queryIterator"; +import { FeedOptions, RequestOptions, Response } from "./request"; +import { PartitionedQueryExecutionInfo } from "./request/ErrorResponse"; +import { BulkOptions } from "./utils/batch"; +import { ClientConfigDiagnostic, CosmosDiagnostics } from "./CosmosDiagnostics"; +import { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; +import { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +/** + * @hidden + * @hidden + */ +export declare class ClientContext { + private cosmosClientOptions; + private globalEndpointManager; + private clientConfig; + diagnosticLevel: CosmosDbDiagnosticLevel; + private readonly sessionContainer; + private connectionPolicy; + private pipeline; + private diagnosticWriter; + private diagnosticFormatter; + partitionKeyDefinitionCache: { + [containerUrl: string]: any; + }; + constructor(cosmosClientOptions: CosmosClientOptions, globalEndpointManager: GlobalEndpointManager, clientConfig: ClientConfigDiagnostic, diagnosticLevel: CosmosDbDiagnosticLevel); + /** @hidden */ + read({ path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + queryFeed({ path, resourceType, resourceId, resultFn, query, options, diagnosticNode, partitionKeyRangeId, partitionKey, startEpk, endEpk, }: { + path: string; + resourceType: ResourceType; + resourceId: string; + resultFn: (result: { + [key: string]: any; + }) => any[]; + query: SqlQuerySpec | string; + options: FeedOptions; + diagnosticNode: DiagnosticNodeInternal; + partitionKeyRangeId?: string; + partitionKey?: PartitionKey; + startEpk?: string | undefined; + endEpk?: string | undefined; + }): Promise>; + getQueryPlan(path: string, resourceType: ResourceType, resourceId: string, query: SqlQuerySpec | string, options: FeedOptions, diagnosticNode: DiagnosticNodeInternal): Promise>; + queryPartitionKeyRanges(collectionLink: string, query?: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + delete({ path, resourceType, resourceId, options, partitionKey, method, diagnosticNode, }: { + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + method?: HTTPMethod; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + patch({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + body: any; + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + create({ body, path, resourceType, resourceId, diagnosticNode, options, partitionKey, }: { + body: T; + path: string; + resourceType: ResourceType; + resourceId: string; + diagnosticNode: DiagnosticNodeInternal; + options?: RequestOptions; + partitionKey?: PartitionKey; + }): Promise>; + private processQueryFeedResponse; + private applySessionToken; + replace({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + body: any; + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + upsert({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + body: T; + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + execute({ sprocLink, params, options, partitionKey, diagnosticNode, }: { + sprocLink: string; + params?: any[]; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + /** + * Gets the Database account information. + * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved. + * If not present, current client's url will be used. + */ + getDatabaseAccount(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise>; + getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + getWriteEndpoints(): Promise; + getReadEndpoints(): Promise; + batch({ body, path, partitionKey, resourceId, options, diagnosticNode, }: { + body: T; + path: string; + partitionKey: PartitionKey; + resourceId: string; + options?: RequestOptions; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + bulk({ body, path, partitionKeyRangeId, resourceId, bulkOptions, options, diagnosticNode, }: { + body: T; + path: string; + partitionKeyRangeId: string; + resourceId: string; + bulkOptions?: BulkOptions; + options?: RequestOptions; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + private captureSessionToken; + clearSessionToken(path: string): void; + recordDiagnostics(diagnostic: CosmosDiagnostics): void; + initializeDiagnosticSettings(diagnosticLevel: CosmosDbDiagnosticLevel): void; + private getSessionParams; + private isMasterResource; + private buildHeaders; + /** + * Returns collection of properties which are derived from the context for Request Creation. + * These properties have client wide scope, as opposed to request specific scope. + * @returns + */ + private getContextDerivedPropsForRequestCreation; + getClientConfig(): ClientConfigDiagnostic; +} +//# sourceMappingURL=ClientContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.d.ts.map new file mode 100644 index 000000000..632cd2687 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext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C;KACxC,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IA2Cb,IAAI,CAAC,CAAC,EAAE,EACnB,IAAI,EACJ,IAAI,EACJ,mBAAmB,EACnB,UAAU,EACV,WAAgB,EAChB,OAAY,EACZ,cAAc,GACf,EAAE;QACD,IAAI,EAAE,CAAC,CAAC;QACR,IAAI,EAAE,MAAM,CAAC;QACb,mBAAmB,EAAE,MAAM,CAAC;QAC5B,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,OAAO,CAAC,EAAE,cAAc,CAAC;QACzB,cAAc,EAAE,sBAAsB,CAAC;KACxC,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IA2C1B,OAAO,CAAC,mBAAmB;IAoBpB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKrC,iBAAiB,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI;IAKtD,4BAA4B,CAAC,eAAe,EAAE,uBAAuB,GAAG,IAAI;IAYnF,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,YAAY;IAqBpB;;;;OAIG;IACH,OAAO,CAAC,wCAAwC;IAkBzC,eAAe,IAAI,sBAAsB;CAGjD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js new file mode 100644 index 000000000..09d70cafa --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js @@ -0,0 +1,524 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { v4 } from "uuid"; +const uuid = v4; +import { bearerTokenAuthenticationPolicy, createEmptyPipeline, } from "@azure/core-rest-pipeline"; +import { Constants, HTTPMethod, OperationType, ResourceType } from "./common/constants"; +import { getIdFromLink, getPathFromLink, parseLink } from "./common/helper"; +import { StatusCodes, SubStatusCodes } from "./common/statusCodes"; +import { ConsistencyLevel, DatabaseAccount, convertToInternalPartitionKey, } from "./documents"; +import { PluginOn, executePlugins } from "./plugins/Plugin"; +import { QueryIterator } from "./queryIterator"; +import { getHeaders } from "./request/request"; +import { RequestHandler } from "./request/RequestHandler"; +import { SessionContainer } from "./session/sessionContainer"; +import { sanitizeEndpoint } from "./utils/checkURL"; +import { supportedQueryFeaturesBuilder } from "./utils/supportedQueryFeaturesBuilder"; +import { createClientLogger } from "@azure/logger"; +import { LogDiagnosticWriter, NoOpDiagnosticWriter, } from "./diagnostics/DiagnosticWriter"; +import { DefaultDiagnosticFormatter } from "./diagnostics/DiagnosticFormatter"; +import { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +const logger = createClientLogger("ClientContext"); +const QueryJsonContentType = "application/query+json"; +const HttpHeaders = Constants.HttpHeaders; +/** + * @hidden + * @hidden + */ +export class ClientContext { + constructor(cosmosClientOptions, globalEndpointManager, clientConfig, diagnosticLevel) { + this.cosmosClientOptions = cosmosClientOptions; + this.globalEndpointManager = globalEndpointManager; + this.clientConfig = clientConfig; + this.diagnosticLevel = diagnosticLevel; + this.connectionPolicy = cosmosClientOptions.connectionPolicy; + this.sessionContainer = new SessionContainer(); + this.partitionKeyDefinitionCache = {}; + this.pipeline = null; + if (cosmosClientOptions.aadCredentials) { + this.pipeline = createEmptyPipeline(); + const hrefEndpoint = sanitizeEndpoint(cosmosClientOptions.endpoint); + const scope = `${hrefEndpoint}/.default`; + this.pipeline.addPolicy(bearerTokenAuthenticationPolicy({ + credential: cosmosClientOptions.aadCredentials, + scopes: scope, + challengeCallbacks: { + async authorizeRequest({ request, getAccessToken }) { + const tokenResponse = await getAccessToken([scope], {}); + const AUTH_PREFIX = `type=aad&ver=1.0&sig=`; + const authorizationToken = `${AUTH_PREFIX}${tokenResponse.token}`; + request.headers.set("Authorization", authorizationToken); + }, + }, + })); + } + this.initializeDiagnosticSettings(diagnosticLevel); + } + /** @hidden */ + async read({ path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.get, path, operationType: OperationType.Read, resourceId, + options, + resourceType, + partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Read, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // read will use ReadEndpoint since it uses GET operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + this.captureSessionToken(undefined, path, OperationType.Read, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + async queryFeed({ path, resourceType, resourceId, resultFn, query, options, diagnosticNode, partitionKeyRangeId, partitionKey, startEpk, endEpk, }) { + // Query operations will use ReadEndpoint even though it uses + // GET(for queryFeed) and POST(for regular query operations) + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.get, path, operationType: OperationType.Query, partitionKeyRangeId, + resourceId, + resourceType, + options, body: query, partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Query, + resourceType, + }); + const requestId = uuid(); + if (query !== undefined) { + request.method = HTTPMethod.post; + } + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + request.headers = await this.buildHeaders(request); + if (startEpk !== undefined && endEpk !== undefined) { + request.headers[HttpHeaders.StartEpk] = startEpk; + request.headers[HttpHeaders.EndEpk] = endEpk; + request.headers[HttpHeaders.ReadFeedKeyType] = "EffectivePartitionKeyRange"; + } + if (query !== undefined) { + request.headers[HttpHeaders.IsQuery] = "true"; + request.headers[HttpHeaders.ContentType] = QueryJsonContentType; + if (typeof query === "string") { + request.body = { query }; // Converts query text to query object. + } + } + this.applySessionToken(request); + logger.info("query " + + requestId + + " started" + + (request.partitionKeyRangeId ? " pkrid: " + request.partitionKeyRangeId : "")); + logger.verbose(request); + const start = Date.now(); + const response = await RequestHandler.request(request, diagnosticNode); + logger.info("query " + requestId + " finished - " + (Date.now() - start) + "ms"); + this.captureSessionToken(undefined, path, OperationType.Query, response.headers); + return this.processQueryFeedResponse(response, !!query, resultFn); + } + async getQueryPlan(path, resourceType, resourceId, query, options = {}, diagnosticNode) { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.post, path, operationType: OperationType.Read, resourceId, + resourceType, + options, body: query }); + diagnosticNode.addData({ + operationType: OperationType.Read, + resourceType, + }); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsQueryPlan] = "True"; + request.headers[HttpHeaders.QueryVersion] = "1.4"; + request.headers[HttpHeaders.ContentType] = QueryJsonContentType; + request.headers[HttpHeaders.SupportedQueryFeatures] = supportedQueryFeaturesBuilder(options.disableNonStreamingOrderByQuery); + if (typeof query === "string") { + request.body = { query }; // Converts query text to query object. + } + this.applySessionToken(request); + const response = await RequestHandler.request(request, diagnosticNode); + this.captureSessionToken(undefined, path, OperationType.Query, response.headers); + return response; + } + queryPartitionKeyRanges(collectionLink, query, options) { + const path = getPathFromLink(collectionLink, ResourceType.pkranges); + const id = getIdFromLink(collectionLink); + const cb = async (diagNode, innerOptions) => { + const response = await this.queryFeed({ + path, + resourceType: ResourceType.pkranges, + resourceId: id, + resultFn: (result) => result.PartitionKeyRanges, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + return response; + }; + return new QueryIterator(this, query, options, cb); + } + async delete({ path, resourceType, resourceId, options = {}, partitionKey, method = HTTPMethod.delete, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: method, operationType: OperationType.Delete, path, + resourceType, + options, + resourceId, + partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Delete, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // deleteResource will use WriteEndpoint since it uses DELETE operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + if (parseLink(path).type !== "colls") { + this.captureSessionToken(undefined, path, OperationType.Delete, response.headers); + } + else { + this.clearSessionToken(path); + } + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + async patch({ body, path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.patch, operationType: OperationType.Patch, path, + resourceType, + body, + resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Patch, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // patch will use WriteEndpoint + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + this.captureSessionToken(undefined, path, OperationType.Patch, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + async create({ body, path, resourceType, resourceId, diagnosticNode, options = {}, partitionKey, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.post, operationType: OperationType.Create, path, + resourceType, + resourceId, + body, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Create, + resourceType, + }); + request.headers = await this.buildHeaders(request); + // create will use WriteEndpoint since it uses POST operation + this.applySessionToken(request); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + this.captureSessionToken(undefined, path, OperationType.Create, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + processQueryFeedResponse(res, isQuery, resultFn) { + if (isQuery) { + return { + result: resultFn(res.result), + headers: res.headers, + code: res.code, + }; + } + else { + const newResult = resultFn(res.result).map((body) => body); + return { + result: newResult, + headers: res.headers, + code: res.code, + }; + } + } + applySessionToken(requestContext) { + const request = this.getSessionParams(requestContext.path); + if (requestContext.headers && requestContext.headers[HttpHeaders.SessionToken]) { + return; + } + const sessionConsistency = requestContext.headers[HttpHeaders.ConsistencyLevel]; + if (!sessionConsistency) { + return; + } + if (sessionConsistency !== ConsistencyLevel.Session) { + return; + } + if (request.resourceAddress) { + const sessionToken = this.sessionContainer.get(request); + if (sessionToken) { + requestContext.headers[HttpHeaders.SessionToken] = sessionToken; + } + } + } + async replace({ body, path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.put, operationType: OperationType.Replace, path, + resourceType, + body, + resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Replace, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // replace will use WriteEndpoint since it uses PUT operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + this.captureSessionToken(undefined, path, OperationType.Replace, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + async upsert({ body, path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.post, operationType: OperationType.Upsert, path, + resourceType, + body, + resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Upsert, + resourceType, + }); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsUpsert] = true; + this.applySessionToken(request); + // upsert will use WriteEndpoint since it uses POST operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + this.captureSessionToken(undefined, path, OperationType.Upsert, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + async execute({ sprocLink, params, options = {}, partitionKey, diagnosticNode, }) { + // Accept a single parameter or an array of parameters. + // Didn't add type annotation for this because we should legacy this behavior + if (params !== null && params !== undefined && !Array.isArray(params)) { + params = [params]; + } + const path = getPathFromLink(sprocLink); + const id = getIdFromLink(sprocLink); + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.post, operationType: OperationType.Execute, path, resourceType: ResourceType.sproc, options, resourceId: id, body: params, partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Execute, + resourceType: ResourceType.sproc, + }); + request.headers = await this.buildHeaders(request); + // executeStoredProcedure will use WriteEndpoint since it uses POST operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + return response; + } + /** + * Gets the Database account information. + * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved. + * If not present, current client's url will be used. + */ + async getDatabaseAccount(diagnosticNode, options = {}) { + const endpoint = options.urlConnection || this.cosmosClientOptions.endpoint; + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { endpoint, method: HTTPMethod.get, operationType: OperationType.Read, path: "", resourceType: ResourceType.none, options }); + diagnosticNode.addData({ + operationType: OperationType.Read, + resourceType: ResourceType.none, + }); + request.headers = await this.buildHeaders(request); + // await options.beforeOperation({ endpoint, request, headers: requestHeaders }); + const { result, headers, code, substatus, diagnostics } = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + const databaseAccount = new DatabaseAccount(result, headers); + return { + result: databaseAccount, + headers, + diagnostics, + code: code, + substatus: substatus, + }; + } + getWriteEndpoint(diagnosticNode) { + return this.globalEndpointManager.getWriteEndpoint(diagnosticNode); + } + getReadEndpoint(diagnosticNode) { + return this.globalEndpointManager.getReadEndpoint(diagnosticNode); + } + getWriteEndpoints() { + return this.globalEndpointManager.getWriteEndpoints(); + } + getReadEndpoints() { + return this.globalEndpointManager.getReadEndpoints(); + } + async batch({ body, path, partitionKey, resourceId, options = {}, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.post, operationType: OperationType.Batch, path, + body, resourceType: ResourceType.item, resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: OperationType.Batch, + resourceType: ResourceType.item, + }); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsBatchRequest] = true; + request.headers[HttpHeaders.IsBatchAtomic] = true; + this.applySessionToken(request); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + this.captureSessionToken(undefined, path, OperationType.Batch, response.headers); + response.diagnostics = diagnosticNode.toDiagnostic(this.getClientConfig()); + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + async bulk({ body, path, partitionKeyRangeId, resourceId, bulkOptions = {}, options = {}, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: HTTPMethod.post, operationType: OperationType.Batch, path, + body, resourceType: ResourceType.item, resourceId, + options }); + diagnosticNode.addData({ + operationType: OperationType.Batch, + resourceType: ResourceType.item, + }); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsBatchRequest] = true; + request.headers[HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId; + request.headers[HttpHeaders.IsBatchAtomic] = false; + request.headers[HttpHeaders.BatchContinueOnError] = bulkOptions.continueOnError || false; + this.applySessionToken(request); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, PluginOn.operation); + this.captureSessionToken(undefined, path, OperationType.Batch, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, OperationType.Upsert, err.headers); + throw err; + } + } + captureSessionToken(err, path, operationType, resHeaders) { + const request = this.getSessionParams(path); + request.operationType = operationType; + if (!err || + (!this.isMasterResource(request.resourceType) && + (err.code === StatusCodes.PreconditionFailed || + err.code === StatusCodes.Conflict || + (err.code === StatusCodes.NotFound && + err.substatus !== SubStatusCodes.ReadSessionNotAvailable)))) { + this.sessionContainer.set(request, resHeaders); + } + } + clearSessionToken(path) { + const request = this.getSessionParams(path); + this.sessionContainer.remove(request); + } + recordDiagnostics(diagnostic) { + const formatted = this.diagnosticFormatter.format(diagnostic); + this.diagnosticWriter.write(formatted); + } + initializeDiagnosticSettings(diagnosticLevel) { + this.diagnosticFormatter = new DefaultDiagnosticFormatter(); + switch (diagnosticLevel) { + case CosmosDbDiagnosticLevel.info: + this.diagnosticWriter = new NoOpDiagnosticWriter(); + break; + default: + this.diagnosticWriter = new LogDiagnosticWriter(); + } + } + // TODO: move + getSessionParams(resourceLink) { + const resourceId = null; + let resourceAddress = null; + const parserOutput = parseLink(resourceLink); + resourceAddress = parserOutput.objectBody.self; + const resourceType = parserOutput.type; + return { + resourceId, + resourceAddress, + resourceType, + isNameBased: true, + }; + } + isMasterResource(resourceType) { + if (resourceType === Constants.Path.OffersPathSegment || + resourceType === Constants.Path.DatabasesPathSegment || + resourceType === Constants.Path.UsersPathSegment || + resourceType === Constants.Path.PermissionsPathSegment || + resourceType === Constants.Path.TopologyPathSegment || + resourceType === Constants.Path.DatabaseAccountPathSegment || + resourceType === Constants.Path.PartitionKeyRangesPathSegment || + resourceType === Constants.Path.CollectionsPathSegment) { + return true; + } + return false; + } + buildHeaders(requestContext) { + return getHeaders({ + clientOptions: this.cosmosClientOptions, + defaultHeaders: Object.assign(Object.assign({}, this.cosmosClientOptions.defaultHeaders), requestContext.options.initialHeaders), + verb: requestContext.method, + path: requestContext.path, + resourceId: requestContext.resourceId, + resourceType: requestContext.resourceType, + options: requestContext.options, + partitionKeyRangeId: requestContext.partitionKeyRangeId, + useMultipleWriteLocations: this.connectionPolicy.useMultipleWriteLocations, + partitionKey: requestContext.partitionKey !== undefined + ? convertToInternalPartitionKey(requestContext.partitionKey) + : undefined, // TODO: Move this check from here to PartitionKey + }); + } + /** + * Returns collection of properties which are derived from the context for Request Creation. + * These properties have client wide scope, as opposed to request specific scope. + * @returns + */ + getContextDerivedPropsForRequestCreation() { + return { + globalEndpointManager: this.globalEndpointManager, + requestAgent: this.cosmosClientOptions.agent, + connectionPolicy: this.connectionPolicy, + client: this, + plugins: this.cosmosClientOptions.plugins, + pipeline: this.pipeline, + }; + } + getClientConfig() { + return this.clientConfig; + } +} +//# sourceMappingURL=ClientContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js.map new file mode 100644 index 000000000..71285835e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/ClientContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ClientContext.js","sourceRoot":"","sources":["../../src/ClientContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,OAAO,EAEL,+BAA+B,EAC/B,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,SAAS,EAAE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;IACJ,CAAC;IAEM,eAAe;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { v4 } from \"uuid\";\nconst uuid = v4;\nimport {\n Pipeline,\n bearerTokenAuthenticationPolicy,\n createEmptyPipeline,\n} from \"@azure/core-rest-pipeline\";\nimport { PartitionKeyRange } from \"./client/Container/PartitionKeyRange\";\nimport { Resource } from \"./client/Resource\";\nimport { Constants, HTTPMethod, OperationType, ResourceType } from \"./common/constants\";\nimport { getIdFromLink, getPathFromLink, parseLink } from \"./common/helper\";\nimport { StatusCodes, SubStatusCodes } from \"./common/statusCodes\";\nimport { Agent, CosmosClientOptions } from \"./CosmosClientOptions\";\nimport {\n ConnectionPolicy,\n ConsistencyLevel,\n DatabaseAccount,\n PartitionKey,\n convertToInternalPartitionKey,\n} from \"./documents\";\nimport { GlobalEndpointManager } from \"./globalEndpointManager\";\nimport { PluginConfig, PluginOn, executePlugins } from \"./plugins/Plugin\";\nimport { FetchFunctionCallback, SqlQuerySpec } from \"./queryExecutionContext\";\nimport { CosmosHeaders } from \"./queryExecutionContext/CosmosHeaders\";\nimport { QueryIterator } from \"./queryIterator\";\nimport { ErrorResponse } from \"./request\";\nimport { FeedOptions, RequestOptions, Response } from \"./request\";\nimport { PartitionedQueryExecutionInfo } from \"./request/ErrorResponse\";\nimport { getHeaders } from \"./request/request\";\nimport { RequestContext } from \"./request/RequestContext\";\nimport { RequestHandler } from \"./request/RequestHandler\";\nimport { SessionContainer } from \"./session/sessionContainer\";\nimport { SessionContext } from \"./session/SessionContext\";\nimport { BulkOptions } from \"./utils/batch\";\nimport { sanitizeEndpoint } from \"./utils/checkURL\";\nimport { supportedQueryFeaturesBuilder } from \"./utils/supportedQueryFeaturesBuilder\";\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { ClientConfigDiagnostic, CosmosDiagnostics } from \"./CosmosDiagnostics\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport {\n DiagnosticWriter,\n LogDiagnosticWriter,\n NoOpDiagnosticWriter,\n} from \"./diagnostics/DiagnosticWriter\";\nimport { DefaultDiagnosticFormatter, DiagnosticFormatter } from \"./diagnostics/DiagnosticFormatter\";\nimport { CosmosDbDiagnosticLevel } from \"./diagnostics/CosmosDbDiagnosticLevel\";\n\nconst logger: AzureLogger = createClientLogger(\"ClientContext\");\n\nconst QueryJsonContentType = \"application/query+json\";\nconst HttpHeaders = Constants.HttpHeaders;\n/**\n * @hidden\n * @hidden\n */\nexport class ClientContext {\n private readonly sessionContainer: SessionContainer;\n private connectionPolicy: ConnectionPolicy;\n private pipeline: Pipeline;\n private diagnosticWriter: DiagnosticWriter;\n private diagnosticFormatter: DiagnosticFormatter;\n public partitionKeyDefinitionCache: { [containerUrl: string]: any }; // TODO: PartitionKeyDefinitionCache\n public constructor(\n private cosmosClientOptions: CosmosClientOptions,\n private globalEndpointManager: GlobalEndpointManager,\n private clientConfig: ClientConfigDiagnostic,\n public diagnosticLevel: CosmosDbDiagnosticLevel,\n ) {\n this.connectionPolicy = cosmosClientOptions.connectionPolicy;\n this.sessionContainer = new SessionContainer();\n this.partitionKeyDefinitionCache = {};\n this.pipeline = null;\n if (cosmosClientOptions.aadCredentials) {\n this.pipeline = createEmptyPipeline();\n const hrefEndpoint = sanitizeEndpoint(cosmosClientOptions.endpoint);\n const scope = `${hrefEndpoint}/.default`;\n this.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential: cosmosClientOptions.aadCredentials,\n scopes: scope,\n challengeCallbacks: {\n async authorizeRequest({ request, getAccessToken }) {\n const tokenResponse = await getAccessToken([scope], {});\n const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;\n const authorizationToken = `${AUTH_PREFIX}${tokenResponse.token}`;\n request.headers.set(\"Authorization\", authorizationToken);\n },\n },\n }),\n );\n }\n this.initializeDiagnosticSettings(diagnosticLevel);\n }\n /** @hidden */\n public async read({\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.get,\n path,\n operationType: OperationType.Read,\n resourceId,\n options,\n resourceType,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Read,\n resourceType,\n });\n\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n\n // read will use ReadEndpoint since it uses GET operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Read, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async queryFeed({\n path,\n resourceType,\n resourceId,\n resultFn,\n query,\n options,\n diagnosticNode,\n partitionKeyRangeId,\n partitionKey,\n startEpk,\n endEpk,\n }: {\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n resultFn: (result: { [key: string]: any }) => any[];\n query: SqlQuerySpec | string;\n options: FeedOptions;\n diagnosticNode: DiagnosticNodeInternal;\n partitionKeyRangeId?: string;\n partitionKey?: PartitionKey;\n startEpk?: string | undefined;\n endEpk?: string | undefined;\n }): Promise> {\n // Query operations will use ReadEndpoint even though it uses\n // GET(for queryFeed) and POST(for regular query operations)\n\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.get,\n path,\n operationType: OperationType.Query,\n partitionKeyRangeId,\n resourceId,\n resourceType,\n options,\n body: query,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Query,\n resourceType,\n });\n const requestId = uuid();\n if (query !== undefined) {\n request.method = HTTPMethod.post;\n }\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n request.headers = await this.buildHeaders(request);\n\n if (startEpk !== undefined && endEpk !== undefined) {\n request.headers[HttpHeaders.StartEpk] = startEpk;\n request.headers[HttpHeaders.EndEpk] = endEpk;\n request.headers[HttpHeaders.ReadFeedKeyType] = \"EffectivePartitionKeyRange\";\n }\n\n if (query !== undefined) {\n request.headers[HttpHeaders.IsQuery] = \"true\";\n request.headers[HttpHeaders.ContentType] = QueryJsonContentType;\n if (typeof query === \"string\") {\n request.body = { query }; // Converts query text to query object.\n }\n }\n this.applySessionToken(request);\n logger.info(\n \"query \" +\n requestId +\n \" started\" +\n (request.partitionKeyRangeId ? \" pkrid: \" + request.partitionKeyRangeId : \"\"),\n );\n logger.verbose(request);\n const start = Date.now();\n const response = await RequestHandler.request(request, diagnosticNode);\n logger.info(\"query \" + requestId + \" finished - \" + (Date.now() - start) + \"ms\");\n this.captureSessionToken(undefined, path, OperationType.Query, response.headers);\n return this.processQueryFeedResponse(response, !!query, resultFn);\n }\n\n public async getQueryPlan(\n path: string,\n resourceType: ResourceType,\n resourceId: string,\n query: SqlQuerySpec | string,\n options: FeedOptions = {},\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise> {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n path,\n operationType: OperationType.Read,\n resourceId,\n resourceType,\n options,\n body: query,\n };\n diagnosticNode.addData({\n operationType: OperationType.Read,\n resourceType,\n });\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsQueryPlan] = \"True\";\n request.headers[HttpHeaders.QueryVersion] = \"1.4\";\n request.headers[HttpHeaders.ContentType] = QueryJsonContentType;\n request.headers[HttpHeaders.SupportedQueryFeatures] = supportedQueryFeaturesBuilder(\n options.disableNonStreamingOrderByQuery,\n );\n if (typeof query === \"string\") {\n request.body = { query }; // Converts query text to query object.\n }\n\n this.applySessionToken(request);\n const response = await RequestHandler.request(request, diagnosticNode);\n this.captureSessionToken(undefined, path, OperationType.Query, response.headers);\n return response as any;\n }\n\n public queryPartitionKeyRanges(\n collectionLink: string,\n query?: string | SqlQuerySpec,\n options?: FeedOptions,\n ): QueryIterator {\n const path = getPathFromLink(collectionLink, ResourceType.pkranges);\n const id = getIdFromLink(collectionLink);\n const cb: FetchFunctionCallback = async (diagNode, innerOptions) => {\n const response = await this.queryFeed({\n path,\n resourceType: ResourceType.pkranges,\n resourceId: id,\n resultFn: (result) => result.PartitionKeyRanges,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n return response;\n };\n return new QueryIterator(this, query, options, cb);\n }\n\n public async delete({\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n method = HTTPMethod.delete,\n diagnosticNode,\n }: {\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n method?: HTTPMethod;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: method,\n operationType: OperationType.Delete,\n path,\n resourceType,\n options,\n resourceId,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Delete,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n // deleteResource will use WriteEndpoint since it uses DELETE operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n if (parseLink(path).type !== \"colls\") {\n this.captureSessionToken(undefined, path, OperationType.Delete, response.headers);\n } else {\n this.clearSessionToken(path);\n }\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async patch({\n body,\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n body: any;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.patch,\n operationType: OperationType.Patch,\n path,\n resourceType,\n body,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Patch,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n\n // patch will use WriteEndpoint\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Patch, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async create({\n body,\n path,\n resourceType,\n resourceId,\n diagnosticNode,\n options = {},\n partitionKey,\n }: {\n body: T;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n diagnosticNode: DiagnosticNodeInternal;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Create,\n path,\n resourceType,\n resourceId,\n body,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Create,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n // create will use WriteEndpoint since it uses POST operation\n this.applySessionToken(request);\n\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Create, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n private processQueryFeedResponse(\n res: Response,\n isQuery: boolean,\n resultFn: (result: { [key: string]: any }) => any[],\n ): Response {\n if (isQuery) {\n return {\n result: resultFn(res.result),\n headers: res.headers,\n code: res.code,\n };\n } else {\n const newResult = resultFn(res.result).map((body: any) => body);\n return {\n result: newResult,\n headers: res.headers,\n code: res.code,\n };\n }\n }\n\n private applySessionToken(requestContext: RequestContext): void {\n const request = this.getSessionParams(requestContext.path);\n\n if (requestContext.headers && requestContext.headers[HttpHeaders.SessionToken]) {\n return;\n }\n\n const sessionConsistency: ConsistencyLevel = requestContext.headers[\n HttpHeaders.ConsistencyLevel\n ] as ConsistencyLevel;\n if (!sessionConsistency) {\n return;\n }\n\n if (sessionConsistency !== ConsistencyLevel.Session) {\n return;\n }\n\n if (request.resourceAddress) {\n const sessionToken = this.sessionContainer.get(request);\n if (sessionToken) {\n requestContext.headers[HttpHeaders.SessionToken] = sessionToken;\n }\n }\n }\n\n public async replace({\n body,\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n body: any;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.put,\n operationType: OperationType.Replace,\n path,\n resourceType,\n body,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Replace,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n\n // replace will use WriteEndpoint since it uses PUT operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Replace, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async upsert({\n body,\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n body: T;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Upsert,\n path,\n resourceType,\n body,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Upsert,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsUpsert] = true;\n this.applySessionToken(request);\n\n // upsert will use WriteEndpoint since it uses POST operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Upsert, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async execute({\n sprocLink,\n params,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n sprocLink: string;\n params?: any[];\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n // Accept a single parameter or an array of parameters.\n // Didn't add type annotation for this because we should legacy this behavior\n if (params !== null && params !== undefined && !Array.isArray(params)) {\n params = [params];\n }\n const path = getPathFromLink(sprocLink);\n const id = getIdFromLink(sprocLink);\n\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Execute,\n path,\n resourceType: ResourceType.sproc,\n options,\n resourceId: id,\n body: params,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Execute,\n resourceType: ResourceType.sproc,\n });\n request.headers = await this.buildHeaders(request);\n // executeStoredProcedure will use WriteEndpoint since it uses POST operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n return response;\n }\n\n /**\n * Gets the Database account information.\n * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved.\n * If not present, current client's url will be used.\n */\n public async getDatabaseAccount(\n diagnosticNode: DiagnosticNodeInternal,\n options: RequestOptions = {},\n ): Promise> {\n const endpoint = options.urlConnection || this.cosmosClientOptions.endpoint;\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n endpoint,\n method: HTTPMethod.get,\n operationType: OperationType.Read,\n path: \"\",\n resourceType: ResourceType.none,\n options,\n };\n diagnosticNode.addData({\n operationType: OperationType.Read,\n resourceType: ResourceType.none,\n });\n request.headers = await this.buildHeaders(request);\n // await options.beforeOperation({ endpoint, request, headers: requestHeaders });\n const { result, headers, code, substatus, diagnostics } = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n\n const databaseAccount = new DatabaseAccount(result, headers);\n return {\n result: databaseAccount,\n headers,\n diagnostics,\n code: code,\n substatus: substatus,\n };\n }\n\n public getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise {\n return this.globalEndpointManager.getWriteEndpoint(diagnosticNode);\n }\n\n public getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise {\n return this.globalEndpointManager.getReadEndpoint(diagnosticNode);\n }\n\n public getWriteEndpoints(): Promise {\n return this.globalEndpointManager.getWriteEndpoints();\n }\n\n public getReadEndpoints(): Promise {\n return this.globalEndpointManager.getReadEndpoints();\n }\n\n public async batch({\n body,\n path,\n partitionKey,\n resourceId,\n options = {},\n diagnosticNode,\n }: {\n body: T;\n path: string;\n partitionKey: PartitionKey;\n resourceId: string;\n options?: RequestOptions;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Batch,\n path,\n body,\n resourceType: ResourceType.item,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Batch,\n resourceType: ResourceType.item,\n });\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsBatchRequest] = true;\n request.headers[HttpHeaders.IsBatchAtomic] = true;\n\n this.applySessionToken(request);\n\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Batch, response.headers);\n response.diagnostics = diagnosticNode.toDiagnostic(this.getClientConfig());\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async bulk({\n body,\n path,\n partitionKeyRangeId,\n resourceId,\n bulkOptions = {},\n options = {},\n diagnosticNode,\n }: {\n body: T;\n path: string;\n partitionKeyRangeId: string;\n resourceId: string;\n bulkOptions?: BulkOptions;\n options?: RequestOptions;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Batch,\n path,\n body,\n resourceType: ResourceType.item,\n resourceId,\n options,\n };\n diagnosticNode.addData({\n operationType: OperationType.Batch,\n resourceType: ResourceType.item,\n });\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsBatchRequest] = true;\n request.headers[HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId;\n request.headers[HttpHeaders.IsBatchAtomic] = false;\n request.headers[HttpHeaders.BatchContinueOnError] = bulkOptions.continueOnError || false;\n\n this.applySessionToken(request);\n\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Batch, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n private captureSessionToken(\n err: ErrorResponse,\n path: string,\n operationType: OperationType,\n resHeaders: CosmosHeaders,\n ): void {\n const request = this.getSessionParams(path);\n request.operationType = operationType;\n if (\n !err ||\n (!this.isMasterResource(request.resourceType) &&\n (err.code === StatusCodes.PreconditionFailed ||\n err.code === StatusCodes.Conflict ||\n (err.code === StatusCodes.NotFound &&\n err.substatus !== SubStatusCodes.ReadSessionNotAvailable)))\n ) {\n this.sessionContainer.set(request, resHeaders);\n }\n }\n\n public clearSessionToken(path: string): void {\n const request = this.getSessionParams(path);\n this.sessionContainer.remove(request);\n }\n\n public recordDiagnostics(diagnostic: CosmosDiagnostics): void {\n const formatted = this.diagnosticFormatter.format(diagnostic);\n this.diagnosticWriter.write(formatted);\n }\n\n public initializeDiagnosticSettings(diagnosticLevel: CosmosDbDiagnosticLevel): void {\n this.diagnosticFormatter = new DefaultDiagnosticFormatter();\n switch (diagnosticLevel) {\n case CosmosDbDiagnosticLevel.info:\n this.diagnosticWriter = new NoOpDiagnosticWriter();\n break;\n default:\n this.diagnosticWriter = new LogDiagnosticWriter();\n }\n }\n\n // TODO: move\n private getSessionParams(resourceLink: string): SessionContext {\n const resourceId: string = null;\n let resourceAddress: string = null;\n const parserOutput = parseLink(resourceLink);\n\n resourceAddress = parserOutput.objectBody.self;\n\n const resourceType = parserOutput.type;\n return {\n resourceId,\n resourceAddress,\n resourceType,\n isNameBased: true,\n };\n }\n\n private isMasterResource(resourceType: string): boolean {\n if (\n resourceType === Constants.Path.OffersPathSegment ||\n resourceType === Constants.Path.DatabasesPathSegment ||\n resourceType === Constants.Path.UsersPathSegment ||\n resourceType === Constants.Path.PermissionsPathSegment ||\n resourceType === Constants.Path.TopologyPathSegment ||\n resourceType === Constants.Path.DatabaseAccountPathSegment ||\n resourceType === Constants.Path.PartitionKeyRangesPathSegment ||\n resourceType === Constants.Path.CollectionsPathSegment\n ) {\n return true;\n }\n\n return false;\n }\n\n private buildHeaders(requestContext: RequestContext): Promise {\n return getHeaders({\n clientOptions: this.cosmosClientOptions,\n defaultHeaders: {\n ...this.cosmosClientOptions.defaultHeaders,\n ...requestContext.options.initialHeaders,\n },\n verb: requestContext.method,\n path: requestContext.path,\n resourceId: requestContext.resourceId,\n resourceType: requestContext.resourceType,\n options: requestContext.options,\n partitionKeyRangeId: requestContext.partitionKeyRangeId,\n useMultipleWriteLocations: this.connectionPolicy.useMultipleWriteLocations,\n partitionKey:\n requestContext.partitionKey !== undefined\n ? convertToInternalPartitionKey(requestContext.partitionKey)\n : undefined, // TODO: Move this check from here to PartitionKey\n });\n }\n\n /**\n * Returns collection of properties which are derived from the context for Request Creation.\n * These properties have client wide scope, as opposed to request specific scope.\n * @returns\n */\n private getContextDerivedPropsForRequestCreation(): {\n globalEndpointManager: GlobalEndpointManager;\n connectionPolicy: ConnectionPolicy;\n requestAgent: Agent;\n client?: ClientContext;\n pipeline?: Pipeline;\n plugins: PluginConfig[];\n } {\n return {\n globalEndpointManager: this.globalEndpointManager,\n requestAgent: this.cosmosClientOptions.agent,\n connectionPolicy: this.connectionPolicy,\n client: this,\n plugins: this.cosmosClientOptions.plugins,\n pipeline: this.pipeline,\n };\n }\n\n public getClientConfig(): ClientConfigDiagnostic {\n return this.clientConfig;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts new file mode 100644 index 000000000..39af12596 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts @@ -0,0 +1,116 @@ +import { Database, Databases } from "./client/Database"; +import { Offer, Offers } from "./client/Offer"; +import { CosmosClientOptions } from "./CosmosClientOptions"; +import { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; +import { DatabaseAccount } from "./documents"; +import { RequestOptions, ResourceResponse } from "./request"; +/** + * Provides a client-side logical representation of the Azure Cosmos DB database account. + * This client is used to configure and execute requests in the Azure Cosmos DB database service. + * @example Instantiate a client and create a new database + * ```typescript + * const client = new CosmosClient({endpoint: "", auth: {masterKey: ""}}); + * await client.databases.create({id: ""}); + * ``` + * @example Instantiate a client with custom Connection Policy + * ```typescript + * const connectionPolicy = new ConnectionPolicy(); + * connectionPolicy.RequestTimeout = 10000; + * const client = new CosmosClient({ + * endpoint: "", + * auth: {masterKey: ""}, + * connectionPolicy + * }); + * ``` + */ +export declare class CosmosClient { + /** + * Used for creating new databases, or querying/reading all databases. + * + * Use `.database(id)` to read, replace, or delete a specific, existing database by id. + * + * @example Create a new database + * ```typescript + * const {resource: databaseDefinition, database} = await client.databases.create({id: ""}); + * ``` + */ + readonly databases: Databases; + /** + * Used for querying & reading all offers. + * + * Use `.offer(id)` to read, or replace existing offers. + */ + readonly offers: Offers; + private clientContext; + private endpointRefresher; + /** + * Creates a new {@link CosmosClient} object from a connection string. Your database connection string can be found in the Azure Portal + */ + constructor(connectionString: string); + /** + * Creates a new {@link CosmosClient} object. See {@link CosmosClientOptions} for more details on what options you can use. + * @param options - bag of options; require at least endpoint and auth to be configured + */ + constructor(options: CosmosClientOptions); + private initializeClientConfigDiagnostic; + /** + * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.) + */ + getDatabaseAccount(options?: RequestOptions): Promise>; + /** + * @hidden + */ + getDatabaseAccountInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise>; + /** + * Gets the currently used write endpoint url. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getWriteEndpoint(): Promise; + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getReadEndpoint(): Promise; + /** + * Gets the known write endpoints. Useful for troubleshooting purposes. + * + * The urls may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getWriteEndpoints(): Promise; + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getReadEndpoints(): Promise; + /** + * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database. + * + * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object. + * + * @param id - The id of the database. + * @example Create a new container off of an existing database + * ```typescript + * const container = client.database("").containers.create(""); + * ``` + * + * @example Delete an existing database + * ```typescript + * await client.database("").delete(); + * ``` + */ + database(id: string): Database; + /** + * Used for reading, or updating a existing offer by id. + * @param id - The id of the offer. + */ + offer(id: string): Offer; + /** + * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process. + */ + dispose(): void; + private backgroundRefreshEndpointList; +} +//# sourceMappingURL=CosmosClient.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts.map new file mode 100644 index 000000000..3225bfd3e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosClient.d.ts","sourceRoot":"","sources":["../../src/CosmosClient.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAA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;;;OAGG;IACI,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK;IAI/B;;OAEG;IACI,OAAO,IAAI,IAAI;YAIR,6BAA6B;CAqB5C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js new file mode 100644 index 000000000..b91a840aa --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Database, Databases } from "./client/Database"; +import { Offer, Offers } from "./client/Offer"; +import { ClientContext } from "./ClientContext"; +import { parseConnectionString } from "./common"; +import { Constants } from "./common/constants"; +import { getUserAgent } from "./common/platform"; +import { determineDiagnosticLevel, getDiagnosticLevelFromEnvironment } from "./diagnostics"; +import { DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal"; +import { defaultConnectionPolicy } from "./documents"; +import { GlobalEndpointManager } from "./globalEndpointManager"; +import { ResourceResponse } from "./request"; +import { checkURL } from "./utils/checkURL"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "./utils/diagnostics"; +/** + * Provides a client-side logical representation of the Azure Cosmos DB database account. + * This client is used to configure and execute requests in the Azure Cosmos DB database service. + * @example Instantiate a client and create a new database + * ```typescript + * const client = new CosmosClient({endpoint: "", auth: {masterKey: ""}}); + * await client.databases.create({id: ""}); + * ``` + * @example Instantiate a client with custom Connection Policy + * ```typescript + * const connectionPolicy = new ConnectionPolicy(); + * connectionPolicy.RequestTimeout = 10000; + * const client = new CosmosClient({ + * endpoint: "", + * auth: {masterKey: ""}, + * connectionPolicy + * }); + * ``` + */ +export class CosmosClient { + constructor(optionsOrConnectionString) { + var _a, _b; + if (typeof optionsOrConnectionString === "string") { + optionsOrConnectionString = parseConnectionString(optionsOrConnectionString); + } + const endpoint = checkURL(optionsOrConnectionString.endpoint); + if (!endpoint) { + throw new Error("Invalid endpoint specified"); + } + const clientConfig = this.initializeClientConfigDiagnostic(optionsOrConnectionString); + optionsOrConnectionString.connectionPolicy = Object.assign({}, defaultConnectionPolicy, optionsOrConnectionString.connectionPolicy); + optionsOrConnectionString.defaultHeaders = optionsOrConnectionString.defaultHeaders || {}; + optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.CacheControl] = "no-cache"; + optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.Version] = + Constants.CurrentVersion; + if (optionsOrConnectionString.consistencyLevel !== undefined) { + optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.ConsistencyLevel] = + optionsOrConnectionString.consistencyLevel; + } + optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.UserAgent] = getUserAgent(optionsOrConnectionString.userAgentSuffix); + const globalEndpointManager = new GlobalEndpointManager(optionsOrConnectionString, async (diagnosticNode, opts) => this.getDatabaseAccountInternal(diagnosticNode, opts)); + this.clientContext = new ClientContext(optionsOrConnectionString, globalEndpointManager, clientConfig, determineDiagnosticLevel(optionsOrConnectionString.diagnosticLevel, getDiagnosticLevelFromEnvironment())); + if (((_a = optionsOrConnectionString.connectionPolicy) === null || _a === void 0 ? void 0 : _a.enableEndpointDiscovery) && + ((_b = optionsOrConnectionString.connectionPolicy) === null || _b === void 0 ? void 0 : _b.enableBackgroundEndpointRefreshing)) { + this.backgroundRefreshEndpointList(globalEndpointManager, optionsOrConnectionString.connectionPolicy.endpointRefreshRateInMs || + defaultConnectionPolicy.endpointRefreshRateInMs); + } + this.databases = new Databases(this, this.clientContext); + this.offers = new Offers(this, this.clientContext); + } + initializeClientConfigDiagnostic(optionsOrConnectionString) { + return { + endpoint: optionsOrConnectionString.endpoint, + resourceTokensConfigured: optionsOrConnectionString.resourceTokens !== undefined, + tokenProviderConfigured: optionsOrConnectionString.tokenProvider !== undefined, + aadCredentialsConfigured: optionsOrConnectionString.aadCredentials !== undefined, + connectionPolicyConfigured: optionsOrConnectionString.connectionPolicy !== undefined, + consistencyLevel: optionsOrConnectionString.consistencyLevel, + defaultHeaders: optionsOrConnectionString.defaultHeaders, + agentConfigured: optionsOrConnectionString.agent !== undefined, + userAgentSuffix: optionsOrConnectionString.userAgentSuffix, + diagnosticLevel: optionsOrConnectionString.diagnosticLevel, + pluginsConfigured: optionsOrConnectionString.plugins !== undefined, + sDKVersion: Constants.SDKVersion, + }; + } + /** + * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.) + */ + async getDatabaseAccount(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.getDatabaseAccountInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async getDatabaseAccountInternal(diagnosticNode, options) { + const response = await this.clientContext.getDatabaseAccount(diagnosticNode, options); + return new ResourceResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics(), response.substatus); + } + /** + * Gets the currently used write endpoint url. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + async getWriteEndpoint() { + return withDiagnostics(async (diagnosticNode) => { + return this.clientContext.getWriteEndpoint(diagnosticNode); + }, this.clientContext); + } + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + async getReadEndpoint() { + return withDiagnostics(async (diagnosticNode) => { + return this.clientContext.getReadEndpoint(diagnosticNode); + }, this.clientContext); + } + /** + * Gets the known write endpoints. Useful for troubleshooting purposes. + * + * The urls may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getWriteEndpoints() { + return this.clientContext.getWriteEndpoints(); + } + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getReadEndpoints() { + return this.clientContext.getReadEndpoints(); + } + /** + * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database. + * + * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object. + * + * @param id - The id of the database. + * @example Create a new container off of an existing database + * ```typescript + * const container = client.database("").containers.create(""); + * ``` + * + * @example Delete an existing database + * ```typescript + * await client.database("").delete(); + * ``` + */ + database(id) { + return new Database(this, id, this.clientContext); + } + /** + * Used for reading, or updating a existing offer by id. + * @param id - The id of the offer. + */ + offer(id) { + return new Offer(this, id, this.clientContext); + } + /** + * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process. + */ + dispose() { + clearTimeout(this.endpointRefresher); + } + async backgroundRefreshEndpointList(globalEndpointManager, refreshRate) { + this.endpointRefresher = setInterval(() => { + try { + return withDiagnostics(async (diagnosticNode) => { + return globalEndpointManager.refreshEndpointList(diagnosticNode); + }, this.clientContext, DiagnosticNodeType.BACKGROUND_REFRESH_THREAD); + } + catch (e) { + console.warn("Failed to refresh endpoints", e); + } + }, refreshRate); + if (this.endpointRefresher.unref && typeof this.endpointRefresher.unref === "function") { + this.endpointRefresher.unref(); + } + } +} +//# sourceMappingURL=CosmosClient.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js.map new file mode 100644 index 000000000..bd324c041 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosClient.js","sourceRoot":"","sources":["../../src/CosmosClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,OAAO,EAAE,wBA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AAiB,CAAC,KAAK,IAAI,OAAO,IAAI,CAAC,iBAAiB,CAAC,KAAK,KAAK,UAAU,EAAE;YACtF,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;SAChC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Database, Databases } from \"./client/Database\";\nimport { Offer, Offers } from \"./client/Offer\";\nimport { ClientContext } from \"./ClientContext\";\nimport { parseConnectionString } from \"./common\";\nimport { Constants } from \"./common/constants\";\nimport { getUserAgent } from \"./common/platform\";\nimport { CosmosClientOptions } from \"./CosmosClientOptions\";\nimport { ClientConfigDiagnostic } from \"./CosmosDiagnostics\";\nimport { determineDiagnosticLevel, getDiagnosticLevelFromEnvironment } from \"./diagnostics\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { DatabaseAccount, defaultConnectionPolicy } from \"./documents\";\nimport { GlobalEndpointManager } from \"./globalEndpointManager\";\nimport { RequestOptions, ResourceResponse } from \"./request\";\nimport { checkURL } from \"./utils/checkURL\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"./utils/diagnostics\";\n\n/**\n * Provides a client-side logical representation of the Azure Cosmos DB database account.\n * This client is used to configure and execute requests in the Azure Cosmos DB database service.\n * @example Instantiate a client and create a new database\n * ```typescript\n * const client = new CosmosClient({endpoint: \"\", auth: {masterKey: \"\"}});\n * await client.databases.create({id: \"\"});\n * ```\n * @example Instantiate a client with custom Connection Policy\n * ```typescript\n * const connectionPolicy = new ConnectionPolicy();\n * connectionPolicy.RequestTimeout = 10000;\n * const client = new CosmosClient({\n * endpoint: \"\",\n * auth: {masterKey: \"\"},\n * connectionPolicy\n * });\n * ```\n */\nexport class CosmosClient {\n /**\n * Used for creating new databases, or querying/reading all databases.\n *\n * Use `.database(id)` to read, replace, or delete a specific, existing database by id.\n *\n * @example Create a new database\n * ```typescript\n * const {resource: databaseDefinition, database} = await client.databases.create({id: \"\"});\n * ```\n */\n public readonly databases: Databases;\n /**\n * Used for querying & reading all offers.\n *\n * Use `.offer(id)` to read, or replace existing offers.\n */\n public readonly offers: Offers;\n private clientContext: ClientContext;\n private endpointRefresher: NodeJS.Timeout;\n /**\n * Creates a new {@link CosmosClient} object from a connection string. Your database connection string can be found in the Azure Portal\n */\n constructor(connectionString: string);\n /**\n * Creates a new {@link CosmosClient} object. See {@link CosmosClientOptions} for more details on what options you can use.\n * @param options - bag of options; require at least endpoint and auth to be configured\n */\n constructor(options: CosmosClientOptions);\n constructor(optionsOrConnectionString: string | CosmosClientOptions) {\n if (typeof optionsOrConnectionString === \"string\") {\n optionsOrConnectionString = parseConnectionString(optionsOrConnectionString);\n }\n\n const endpoint = checkURL(optionsOrConnectionString.endpoint);\n if (!endpoint) {\n throw new Error(\"Invalid endpoint specified\");\n }\n\n const clientConfig: ClientConfigDiagnostic =\n this.initializeClientConfigDiagnostic(optionsOrConnectionString);\n\n optionsOrConnectionString.connectionPolicy = Object.assign(\n {},\n defaultConnectionPolicy,\n optionsOrConnectionString.connectionPolicy,\n );\n\n optionsOrConnectionString.defaultHeaders = optionsOrConnectionString.defaultHeaders || {};\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.CacheControl] = \"no-cache\";\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.Version] =\n Constants.CurrentVersion;\n if (optionsOrConnectionString.consistencyLevel !== undefined) {\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.ConsistencyLevel] =\n optionsOrConnectionString.consistencyLevel;\n }\n\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.UserAgent] = getUserAgent(\n optionsOrConnectionString.userAgentSuffix,\n );\n\n const globalEndpointManager = new GlobalEndpointManager(\n optionsOrConnectionString,\n async (diagnosticNode: DiagnosticNodeInternal, opts: RequestOptions) =>\n this.getDatabaseAccountInternal(diagnosticNode, opts),\n );\n\n this.clientContext = new ClientContext(\n optionsOrConnectionString,\n globalEndpointManager,\n clientConfig,\n determineDiagnosticLevel(\n optionsOrConnectionString.diagnosticLevel,\n getDiagnosticLevelFromEnvironment(),\n ),\n );\n if (\n optionsOrConnectionString.connectionPolicy?.enableEndpointDiscovery &&\n optionsOrConnectionString.connectionPolicy?.enableBackgroundEndpointRefreshing\n ) {\n this.backgroundRefreshEndpointList(\n globalEndpointManager,\n optionsOrConnectionString.connectionPolicy.endpointRefreshRateInMs ||\n defaultConnectionPolicy.endpointRefreshRateInMs,\n );\n }\n\n this.databases = new Databases(this, this.clientContext);\n this.offers = new Offers(this, this.clientContext);\n }\n\n private initializeClientConfigDiagnostic(\n optionsOrConnectionString: CosmosClientOptions,\n ): ClientConfigDiagnostic {\n return {\n endpoint: optionsOrConnectionString.endpoint,\n resourceTokensConfigured: optionsOrConnectionString.resourceTokens !== undefined,\n tokenProviderConfigured: optionsOrConnectionString.tokenProvider !== undefined,\n aadCredentialsConfigured: optionsOrConnectionString.aadCredentials !== undefined,\n connectionPolicyConfigured: optionsOrConnectionString.connectionPolicy !== undefined,\n consistencyLevel: optionsOrConnectionString.consistencyLevel,\n defaultHeaders: optionsOrConnectionString.defaultHeaders,\n agentConfigured: optionsOrConnectionString.agent !== undefined,\n userAgentSuffix: optionsOrConnectionString.userAgentSuffix,\n diagnosticLevel: optionsOrConnectionString.diagnosticLevel,\n pluginsConfigured: optionsOrConnectionString.plugins !== undefined,\n sDKVersion: Constants.SDKVersion,\n };\n }\n\n /**\n * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.)\n */\n public async getDatabaseAccount(\n options?: RequestOptions,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.getDatabaseAccountInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async getDatabaseAccountInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: RequestOptions,\n ): Promise> {\n const response = await this.clientContext.getDatabaseAccount(diagnosticNode, options);\n return new ResourceResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n response.substatus,\n );\n }\n\n /**\n * Gets the currently used write endpoint url. Useful for troubleshooting purposes.\n *\n * The url may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public async getWriteEndpoint(): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.clientContext.getWriteEndpoint(diagnosticNode);\n }, this.clientContext);\n }\n\n /**\n * Gets the currently used read endpoint. Useful for troubleshooting purposes.\n *\n * The url may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public async getReadEndpoint(): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.clientContext.getReadEndpoint(diagnosticNode);\n }, this.clientContext);\n }\n\n /**\n * Gets the known write endpoints. Useful for troubleshooting purposes.\n *\n * The urls may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public getWriteEndpoints(): Promise {\n return this.clientContext.getWriteEndpoints();\n }\n\n /**\n * Gets the currently used read endpoint. Useful for troubleshooting purposes.\n *\n * The url may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public getReadEndpoints(): Promise {\n return this.clientContext.getReadEndpoints();\n }\n\n /**\n * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database.\n *\n * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object.\n *\n * @param id - The id of the database.\n * @example Create a new container off of an existing database\n * ```typescript\n * const container = client.database(\"\").containers.create(\"\");\n * ```\n *\n * @example Delete an existing database\n * ```typescript\n * await client.database(\"\").delete();\n * ```\n */\n public database(id: string): Database {\n return new Database(this, id, this.clientContext);\n }\n\n /**\n * Used for reading, or updating a existing offer by id.\n * @param id - The id of the offer.\n */\n public offer(id: string): Offer {\n return new Offer(this, id, this.clientContext);\n }\n\n /**\n * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process.\n */\n public dispose(): void {\n clearTimeout(this.endpointRefresher);\n }\n\n private async backgroundRefreshEndpointList(\n globalEndpointManager: GlobalEndpointManager,\n refreshRate: number,\n ) {\n this.endpointRefresher = setInterval(() => {\n try {\n return withDiagnostics(\n async (diagnosticNode: DiagnosticNodeInternal) => {\n return globalEndpointManager.refreshEndpointList(diagnosticNode);\n },\n this.clientContext,\n DiagnosticNodeType.BACKGROUND_REFRESH_THREAD,\n );\n } catch (e: any) {\n console.warn(\"Failed to refresh endpoints\", e);\n }\n }, refreshRate);\n if (this.endpointRefresher.unref && typeof this.endpointRefresher.unref === \"function\") {\n this.endpointRefresher.unref();\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts new file mode 100644 index 000000000..d81f46d8b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts @@ -0,0 +1,54 @@ +import { TokenCredential } from "@azure/core-auth"; +import { TokenProvider } from "./auth"; +import { PermissionDefinition } from "./client"; +import { ConnectionPolicy, ConsistencyLevel } from "./documents"; +import { CosmosHeaders } from "./queryExecutionContext/CosmosHeaders"; +import { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +export interface Agent { + maxFreeSockets: number; + maxSockets: number; + sockets: any; + requests: any; + destroy(): void; +} +export interface CosmosClientOptions { + /** The service endpoint to use to create the client. */ + endpoint: string; + /** The account master or readonly key */ + key?: string; + /** An object that contains resources tokens. + * Keys for the object are resource Ids and values are the resource tokens. + */ + resourceTokens?: { + [resourcePath: string]: string; + }; + /** A user supplied function for resolving header authorization tokens. + * Allows users to generating their own auth tokens, potentially using a separate service + */ + tokenProvider?: TokenProvider; + /** AAD token from `@azure/identity` + * Obtain a credential object by creating an `@azure/identity` credential object + * We will then use your credential object and a scope URL (your cosmos db endpoint) + * to authenticate requests to Cosmos + */ + aadCredentials?: TokenCredential; + /** An array of {@link Permission} objects. */ + permissionFeed?: PermissionDefinition[]; + /** An instance of {@link ConnectionPolicy} class. + * This parameter is optional and the default connectionPolicy will be used if omitted. + */ + connectionPolicy?: ConnectionPolicy; + /** An optional parameter that represents the consistency level. + * It can take any value from {@link ConsistencyLevel}. + */ + consistencyLevel?: keyof typeof ConsistencyLevel; + defaultHeaders?: CosmosHeaders; + /** An optional custom http(s) Agent to be used in NodeJS enironments + * Use an agent such as https://github.com/TooTallNate/node-proxy-agent if you need to connect to Cosmos via a proxy + */ + agent?: Agent; + /** A custom string to append to the default SDK user agent. */ + userAgentSuffix?: string; + diagnosticLevel?: CosmosDbDiagnosticLevel; +} +//# sourceMappingURL=CosmosClientOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts.map new file mode 100644 index 000000000..7b91460f1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosClientOptions.d.ts","sourceRoot":"","sources":["../../src/CosmosClientOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAGhF,MAAM,WAAW,KAAK;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,GAAG,CAAC;IACd,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,mBAAmB;IAClC,wDAAwD;IACxD,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,cAAc,CAAC,EAAE;QAAE,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpD;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,8CAA8C;IAC9C,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACxC;;OAEG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,OAAO,gBAAgB,CAAC;IACjD,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,uBAAuB,CAAC;CAG3C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js new file mode 100644 index 000000000..91be93315 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=CosmosClientOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js.map new file mode 100644 index 000000000..62b085527 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosClientOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosClientOptions.js","sourceRoot":"","sources":["../../src/CosmosClientOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { TokenProvider } from \"./auth\";\nimport { PermissionDefinition } from \"./client\";\nimport { ConnectionPolicy, ConsistencyLevel } from \"./documents\";\nimport { PluginConfig } from \"./plugins/Plugin\";\nimport { CosmosHeaders } from \"./queryExecutionContext/CosmosHeaders\";\nimport { CosmosDbDiagnosticLevel } from \"./diagnostics/CosmosDbDiagnosticLevel\";\n\n// We expose our own Agent interface to avoid taking a dependency on and leaking node types. This interface should mirror the node Agent interface\nexport interface Agent {\n maxFreeSockets: number;\n maxSockets: number;\n sockets: any;\n requests: any;\n destroy(): void;\n}\n\nexport interface CosmosClientOptions {\n /** The service endpoint to use to create the client. */\n endpoint: string;\n /** The account master or readonly key */\n key?: string;\n /** An object that contains resources tokens.\n * Keys for the object are resource Ids and values are the resource tokens.\n */\n resourceTokens?: { [resourcePath: string]: string };\n /** A user supplied function for resolving header authorization tokens.\n * Allows users to generating their own auth tokens, potentially using a separate service\n */\n tokenProvider?: TokenProvider;\n /** AAD token from `@azure/identity`\n * Obtain a credential object by creating an `@azure/identity` credential object\n * We will then use your credential object and a scope URL (your cosmos db endpoint)\n * to authenticate requests to Cosmos\n */\n aadCredentials?: TokenCredential;\n /** An array of {@link Permission} objects. */\n permissionFeed?: PermissionDefinition[];\n /** An instance of {@link ConnectionPolicy} class.\n * This parameter is optional and the default connectionPolicy will be used if omitted.\n */\n connectionPolicy?: ConnectionPolicy;\n /** An optional parameter that represents the consistency level.\n * It can take any value from {@link ConsistencyLevel}.\n */\n consistencyLevel?: keyof typeof ConsistencyLevel;\n defaultHeaders?: CosmosHeaders;\n /** An optional custom http(s) Agent to be used in NodeJS enironments\n * Use an agent such as https://github.com/TooTallNate/node-proxy-agent if you need to connect to Cosmos via a proxy\n */\n agent?: Agent;\n /** A custom string to append to the default SDK user agent. */\n userAgentSuffix?: string;\n diagnosticLevel?: CosmosDbDiagnosticLevel;\n /** @internal */\n plugins?: PluginConfig[];\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts new file mode 100644 index 000000000..735897b77 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts @@ -0,0 +1,202 @@ +import { OperationType, ResourceType } from "./common"; +import { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +import { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; +import { ConsistencyLevel } from "./documents"; +/** + * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create(). + * It has three members - + * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including - + * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls. + * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call. + * - retries + * - endpoints contacted. + * - request, response payload stats. + * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations + * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation. + * + * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be + * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`. + * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments. + * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used + * in production environment. + * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads. + * Is not meant to be used in production environment. + * 3. clientConfig - Captures information related to how client was configured during initialization. + */ +export declare class CosmosDiagnostics { + readonly clientSideRequestStatistics: ClientSideRequestStatistics; + readonly diagnosticNode: DiagnosticNode; + readonly clientConfig?: ClientConfigDiagnostic; +} +/** + * This type holds information related to initialization of `CosmosClient` + */ +export type ClientConfigDiagnostic = { + /** + * End point configured during client initialization. + */ + endpoint: string; + /** + * True if `resourceTokens` was supplied during client initialization. + */ + resourceTokensConfigured: boolean; + /** + * True if `tokenProvider` was supplied during client initialization. + */ + tokenProviderConfigured: boolean; + /** + * True if `aadCredentials` was supplied during client initialization. + */ + aadCredentialsConfigured: boolean; + /** + * True if `connectionPolicy` was supplied during client initialization. + */ + connectionPolicyConfigured: boolean; + /** + * `consistencyLevel` supplied during client initialization. + */ + consistencyLevel?: keyof typeof ConsistencyLevel; + /** + * `defaultHeaders` supplied during client initialization. + */ + defaultHeaders?: { + [key: string]: any; + }; + /** + * True if `connectionPolicy` were supplied during client initialization. + */ + agentConfigured: boolean; + /** + * `userAgentSuffix` supplied during client initialization. + */ + userAgentSuffix: string; + /** + * `diagnosticLevel` supplied during client initialization. + */ + diagnosticLevel?: CosmosDbDiagnosticLevel; + /** + * True if `plugins` were supplied during client initialization. + */ + pluginsConfigured: boolean; + /** + * SDK version + */ + sDKVersion: string; +}; +/** + * This type contains diagnostic information regarding all metadata request to server during an CosmosDB client operation. + */ +export type MetadataLookUpDiagnostics = { + metadataLookups: MetadataLookUpDiagnostic[]; +}; +/** + * This type captures diagnostic information regarding retries attempt during an CosmosDB client operation. + */ +export type RetryDiagnostics = { + failedAttempts: FailedRequestAttemptDiagnostic[]; +}; +export type GatewayStatistics = { + /** + * This is the activityId for request, made to server for fetching the requested resource. (As opposed to other potential meta data requests) + */ + activityId?: string; + startTimeUTCInMs: number; + durationInMs: number; + operationType?: OperationType; + resourceType?: ResourceType; + statusCode?: number; + subStatusCode?: number; + requestCharge?: number; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; +}; +/** + * This type contains diagnostic information regarding a single metadata request to server. + */ +export interface MetadataLookUpDiagnostic { + activityId: string; + startTimeUTCInMs: number; + durationInMs: number; + operationType?: OperationType; + resourceType?: ResourceType; + metaDataType: MetadataLookUpType; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; +} +/** + * This type captures diagnostic information regarding a failed request to server api. + */ +export interface FailedRequestAttemptDiagnostic { + attemptNumber: number; + activityId: string; + startTimeUTCInMs: number; + durationInMs: number; + operationType?: OperationType; + resourceType?: ResourceType; + statusCode: number; + substatusCode?: number; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; +} +/** + * This is enum for Type of Metadata lookups possible. + */ +export declare enum MetadataLookUpType { + PartitionKeyRangeLookUp = "PARTITION_KEY_RANGE_LOOK_UP", + DatabaseAccountLookUp = "DATABASE_ACCOUNT_LOOK_UP", + QueryPlanLookUp = "QUERY_PLAN_LOOK_UP", + DatabaseLookUp = "DATABASE_LOOK_UP", + ContainerLookUp = "CONTAINER_LOOK_UP" +} +/** + * This is a collection type for all client side diagnostic information. + */ +export type ClientSideRequestStatistics = { + /** + * This is the UTC timestamp for start of client operation. + */ + requestStartTimeUTCInMs: number; + /** + * This is the duration in milli seconds taken by client operation. + */ + requestDurationInMs: number; + /** + * This is the list of Location Endpoints contacted during the client operation. + */ + locationEndpointsContacted: string[]; + /** + * This field captures diagnostic information for retries happened during client operation. + */ + retryDiagnostics: RetryDiagnostics; + /** + * This field captures diagnostic information for meta data lookups happened during client operation. + */ + metadataDiagnostics: MetadataLookUpDiagnostics; + /** + * These are the statistics for main point look operation. + */ + gatewayStatistics: GatewayStatistics[]; + /** + * This is the cumulated Request Payload Length n bytes, this includes metadata calls along with the main operation. + */ + totalRequestPayloadLengthInBytes: number; + /** + * This is the cumulated Response Payload Length n bytes, this includes metadata calls along with the main operation. + */ + totalResponsePayloadLengthInBytes: number; +}; +export declare function getRootNode(node: DiagnosticNodeInternal): DiagnosticNodeInternal; +/** + * Represents a tree like structure, for capturing diagnostic information. + */ +export interface DiagnosticNode { + id: string; + nodeType: string; + children: DiagnosticNode[]; + data: { + [key: string]: any; + }; + startTimeUTCInMs: number; + durationInMs: number; +} +//# sourceMappingURL=CosmosDiagnostics.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts.map new file mode 100644 index 000000000..7f8136175 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosDiagnostics.d.ts","sourceRoot":"","sources":["../../src/CosmosDiagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,iBAAiB;IAC5B,SAAgB,2BAA2B,EAAE,2BAA2B,CAAC;IACzE,SAAgB,cAAc,EAAE,cAAc,CAAC;IAC/C,SAAgB,YAAY,CAAC,EAAE,sBAAsB,CAAC;CAavD;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,uBAAuB,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,wBAAwB,EAAE,OAAO,CAAC;IAClC;;OAEG;IACH,0BAA0B,EAAE,OAAO,CAAC;IACpC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,OAAO,gBAAgB,CAAC;IACjD;;OAEG;IACH,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACxC;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,eAAe,CAA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B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2BAA2B,EAAE,MAAM,CAAC;IACpC,4BAA4B,EAAE,MAAM,CAAC;CACtC;AAED;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,uBAAuB,gCAAgC;IACvD,qBAAqB,6BAA6B;IAClD,eAAe,uBAAuB;IACtC,cAAc,qBAAqB;IACnC,eAAe,sBAAsB;CACtC;AAED;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC;;OAEG;IACH,uBAAuB,EAAE,MAAM,CAAC;IAChC;;OAEG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,0BAA0B,EAAE,MAAM,EAAE,CAAC;IACrC;;OAEG;IACH,gBAAgB,EAAE,gBAAgB,CAAC;IACnC;;OAEG;IACH,mBAAmB,EAAE,yBAAyB,CAAC;IAC/C;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;IACvC;;OAEG;IACH,gCAAgC,EAAE,MAAM,CAAC;IACzC;;OAEG;IACH,iCAAiC,EAAE,MAAM,CAAC;CAC3C,CAAC;AAEF,wBAAgB,WAAW,CAAC,IAAI,EAAE,sBAAsB,GAAG,sBAAsB,CAGhF;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js new file mode 100644 index 000000000..3f564a197 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create(). + * It has three members - + * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including - + * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls. + * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call. + * - retries + * - endpoints contacted. + * - request, response payload stats. + * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations + * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation. + * + * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be + * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`. + * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments. + * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used + * in production environment. + * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads. + * Is not meant to be used in production environment. + * 3. clientConfig - Captures information related to how client was configured during initialization. + */ +export class CosmosDiagnostics { + /** + * @internal + */ + constructor(clientSideRequestStatistics, diagnosticNode, clientConfig) { + this.clientSideRequestStatistics = clientSideRequestStatistics; + this.diagnosticNode = diagnosticNode; + this.clientConfig = clientConfig; + } +} +/** + * This is enum for Type of Metadata lookups possible. + */ +export var MetadataLookUpType; +(function (MetadataLookUpType) { + MetadataLookUpType["PartitionKeyRangeLookUp"] = "PARTITION_KEY_RANGE_LOOK_UP"; + MetadataLookUpType["DatabaseAccountLookUp"] = "DATABASE_ACCOUNT_LOOK_UP"; + MetadataLookUpType["QueryPlanLookUp"] = "QUERY_PLAN_LOOK_UP"; + MetadataLookUpType["DatabaseLookUp"] = "DATABASE_LOOK_UP"; + MetadataLookUpType["ContainerLookUp"] = "CONTAINER_LOOK_UP"; +})(MetadataLookUpType || (MetadataLookUpType = {})); +export function getRootNode(node) { + if (node.parent) + return getRootNode(node.parent); + else + return node; +} +//# sourceMappingURL=CosmosDiagnostics.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js.map new file mode 100644 index 000000000..a1f548a86 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/CosmosDiagnostics.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosDiagnostics.js","sourceRoot":"","sources":["../../src/CosmosDiagnostics.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,iBAAiB;IAI5B;;OAEG;IACH,YACE,2BAAwD,EACxD,cAA+B,EAC/B,YAAqC;QAErC,IAAI,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAoHD;;GAEG;AACH,MAAM,CAAN,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,6EAAuD,CAAA;IACvD,wEAAkD,CAAA;IAClD,4DAAsC,CAAA;IACtC,yDAAmC,CAAA;IACnC,2DAAqC,CAAA;AACvC,CAAC,EANW,kBAAkB,KAAlB,kBAAkB,QAM7B;AAwCD,MAAM,UAAU,WAAW,CAAC,IAA4B;IACtD,IAAI,IAAI,CAAC,MAAM;QAAE,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;;QAC5C,OAAO,IAAI,CAAC;AACnB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationType, ResourceType } from \"./common\";\nimport { CosmosDbDiagnosticLevel } from \"./diagnostics/CosmosDbDiagnosticLevel\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { ConsistencyLevel } from \"./documents\";\n\n/**\n * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create().\n * It has three members -\n * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including -\n * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls.\n * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call.\n * - retries\n * - endpoints contacted.\n * - request, response payload stats.\n * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations\n * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation.\n *\n * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be\n * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`.\n * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments.\n * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used\n * in production environment.\n * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads.\n * Is not meant to be used in production environment.\n * 3. clientConfig - Captures information related to how client was configured during initialization.\n */\nexport class CosmosDiagnostics {\n public readonly clientSideRequestStatistics: ClientSideRequestStatistics;\n public readonly diagnosticNode: DiagnosticNode;\n public readonly clientConfig?: ClientConfigDiagnostic;\n /**\n * @internal\n */\n constructor(\n clientSideRequestStatistics: ClientSideRequestStatistics,\n diagnosticNode?: DiagnosticNode,\n clientConfig?: ClientConfigDiagnostic,\n ) {\n this.clientSideRequestStatistics = clientSideRequestStatistics;\n this.diagnosticNode = diagnosticNode;\n this.clientConfig = clientConfig;\n }\n}\n\n/**\n * This type holds information related to initialization of `CosmosClient`\n */\nexport type ClientConfigDiagnostic = {\n /**\n * End point configured during client initialization.\n */\n endpoint: string;\n /**\n * True if `resourceTokens` was supplied during client initialization.\n */\n resourceTokensConfigured: boolean;\n /**\n * True if `tokenProvider` was supplied during client initialization.\n */\n tokenProviderConfigured: boolean;\n /**\n * True if `aadCredentials` was supplied during client initialization.\n */\n aadCredentialsConfigured: boolean;\n /**\n * True if `connectionPolicy` was supplied during client initialization.\n */\n connectionPolicyConfigured: boolean;\n /**\n * `consistencyLevel` supplied during client initialization.\n */\n consistencyLevel?: keyof typeof ConsistencyLevel;\n /**\n * `defaultHeaders` supplied during client initialization.\n */\n defaultHeaders?: { [key: string]: any };\n /**\n * True if `connectionPolicy` were supplied during client initialization.\n */\n agentConfigured: boolean;\n /**\n * `userAgentSuffix` supplied during client initialization.\n */\n userAgentSuffix: string;\n /**\n * `diagnosticLevel` supplied during client initialization.\n */\n diagnosticLevel?: CosmosDbDiagnosticLevel;\n /**\n * True if `plugins` were supplied during client initialization.\n */\n pluginsConfigured: boolean;\n /**\n * SDK version\n */\n sDKVersion: string;\n};\n\n/**\n * This type contains diagnostic information regarding all metadata request to server during an CosmosDB client operation.\n */\nexport type MetadataLookUpDiagnostics = {\n metadataLookups: MetadataLookUpDiagnostic[];\n};\n\n/**\n * This type captures diagnostic information regarding retries attempt during an CosmosDB client operation.\n */\nexport type RetryDiagnostics = {\n failedAttempts: FailedRequestAttemptDiagnostic[];\n};\n\nexport type GatewayStatistics = {\n /**\n * This is the activityId for request, made to server for fetching the requested resource. (As opposed to other potential meta data requests)\n */\n activityId?: string;\n startTimeUTCInMs: number;\n durationInMs: number;\n operationType?: OperationType;\n resourceType?: ResourceType;\n statusCode?: number;\n subStatusCode?: number;\n requestCharge?: number;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n};\n\n/**\n * This type contains diagnostic information regarding a single metadata request to server.\n */\nexport interface MetadataLookUpDiagnostic {\n activityId: string;\n startTimeUTCInMs: number;\n durationInMs: number;\n operationType?: OperationType;\n resourceType?: ResourceType;\n metaDataType: MetadataLookUpType;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n}\n\n/**\n * This type captures diagnostic information regarding a failed request to server api.\n */\nexport interface FailedRequestAttemptDiagnostic {\n attemptNumber: number;\n activityId: string;\n startTimeUTCInMs: number;\n durationInMs: number;\n operationType?: OperationType;\n resourceType?: ResourceType;\n statusCode: number;\n substatusCode?: number;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n}\n\n/**\n * This is enum for Type of Metadata lookups possible.\n */\nexport enum MetadataLookUpType {\n PartitionKeyRangeLookUp = \"PARTITION_KEY_RANGE_LOOK_UP\",\n DatabaseAccountLookUp = \"DATABASE_ACCOUNT_LOOK_UP\",\n QueryPlanLookUp = \"QUERY_PLAN_LOOK_UP\",\n DatabaseLookUp = \"DATABASE_LOOK_UP\",\n ContainerLookUp = \"CONTAINER_LOOK_UP\",\n}\n\n/**\n * This is a collection type for all client side diagnostic information.\n */\nexport type ClientSideRequestStatistics = {\n /**\n * This is the UTC timestamp for start of client operation.\n */\n requestStartTimeUTCInMs: number;\n /**\n * This is the duration in milli seconds taken by client operation.\n */\n requestDurationInMs: number;\n /**\n * This is the list of Location Endpoints contacted during the client operation.\n */\n locationEndpointsContacted: string[];\n /**\n * This field captures diagnostic information for retries happened during client operation.\n */\n retryDiagnostics: RetryDiagnostics;\n /**\n * This field captures diagnostic information for meta data lookups happened during client operation.\n */\n metadataDiagnostics: MetadataLookUpDiagnostics;\n /**\n * These are the statistics for main point look operation.\n */\n gatewayStatistics: GatewayStatistics[];\n /**\n * This is the cumulated Request Payload Length n bytes, this includes metadata calls along with the main operation.\n */\n totalRequestPayloadLengthInBytes: number;\n /**\n * This is the cumulated Response Payload Length n bytes, this includes metadata calls along with the main operation.\n */\n totalResponsePayloadLengthInBytes: number;\n};\n\nexport function getRootNode(node: DiagnosticNodeInternal): DiagnosticNodeInternal {\n if (node.parent) return getRootNode(node.parent);\n else return node;\n}\n\n/**\n * Represents a tree like structure, for capturing diagnostic information.\n */\nexport interface DiagnosticNode {\n id: string;\n nodeType: string;\n children: DiagnosticNode[];\n data: { [key: string]: any };\n startTimeUTCInMs: number;\n durationInMs: number;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts new file mode 100644 index 000000000..478c9036a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts @@ -0,0 +1,28 @@ +import { HTTPMethod, ResourceType } from "./common"; +import { CosmosClientOptions } from "./CosmosClientOptions"; +import { CosmosHeaders } from "./queryExecutionContext"; +/** @hidden */ +export interface RequestInfo { + verb: HTTPMethod; + path: string; + resourceId: string; + resourceType: ResourceType; + headers: CosmosHeaders; +} +export type TokenProvider = (requestInfo: RequestInfo) => Promise; +/** + * @hidden + */ +export declare function setAuthorizationHeader(clientOptions: CosmosClientOptions, verb: HTTPMethod, path: string, resourceId: string, resourceType: ResourceType, headers: CosmosHeaders): Promise; +/** + * The default function for setting header token using the masterKey + * @hidden + */ +export declare function setAuthorizationTokenHeaderUsingMasterKey(verb: HTTPMethod, resourceId: string, resourceType: ResourceType, headers: CosmosHeaders, masterKey: string): Promise; +/** + * @hidden + */ +export declare function getAuthorizationTokenUsingResourceTokens(resourceTokens: { + [resourceId: string]: string; +}, path: string, resourceId: string): string; +//# sourceMappingURL=auth.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts.map new file mode 100644 index 000000000..de840fb7c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/auth.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,UAAU,EACV,YAAY,EAEb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GAAG,CAAC,WAAW,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AAE1E;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,aAAa,EAAE,mBAAmB,EAClC,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;GAGG;AACH,wBAAsB,yCAAyC,CAC7D,IAAI,EAAE,UAAU,EAChB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CASf;AAED;;GAEG;AAEH,wBAAgB,wCAAwC,CACtD,cAAc,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAChD,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GACjB,MAAM,CA+CR"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/auth.js b/local_dependencies/@azure/cosmos/dist-esm/src/auth.js new file mode 100644 index 000000000..d0bf4ccf5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/auth.js @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { generateHeaders } from "./utils/headers"; +import { Constants, getResourceIdFromPath, ResourceType, trimSlashFromLeftAndRight, } from "./common"; +/** + * @hidden + */ +export async function setAuthorizationHeader(clientOptions, verb, path, resourceId, resourceType, headers) { + if (clientOptions.permissionFeed) { + clientOptions.resourceTokens = {}; + for (const permission of clientOptions.permissionFeed) { + const id = getResourceIdFromPath(permission.resource); + if (!id) { + throw new Error(`authorization error: ${id} \ + is an invalid resourceId in permissionFeed`); + } + clientOptions.resourceTokens[id] = permission._token; // TODO: any + } + } + if (clientOptions.key) { + await setAuthorizationTokenHeaderUsingMasterKey(verb, resourceId, resourceType, headers, clientOptions.key); + } + else if (clientOptions.resourceTokens) { + headers[Constants.HttpHeaders.Authorization] = encodeURIComponent(getAuthorizationTokenUsingResourceTokens(clientOptions.resourceTokens, path, resourceId)); + } + else if (clientOptions.tokenProvider) { + headers[Constants.HttpHeaders.Authorization] = encodeURIComponent(await clientOptions.tokenProvider({ verb, path, resourceId, resourceType, headers })); + } +} +/** + * The default function for setting header token using the masterKey + * @hidden + */ +export async function setAuthorizationTokenHeaderUsingMasterKey(verb, resourceId, resourceType, headers, masterKey) { + // TODO This should live in cosmos-sign + if (resourceType === ResourceType.offer) { + resourceId = resourceId && resourceId.toLowerCase(); + } + headers = Object.assign(headers, await generateHeaders(masterKey, verb, resourceType, resourceId)); +} +/** + * @hidden + */ +// TODO: Resource tokens +export function getAuthorizationTokenUsingResourceTokens(resourceTokens, path, resourceId) { + if (resourceTokens && Object.keys(resourceTokens).length > 0) { + // For database account access(through getDatabaseAccount API), path and resourceId are "", + // so in this case we return the first token to be used for creating the auth header as the + // service will accept any token in this case + if (!path && !resourceId) { + return resourceTokens[Object.keys(resourceTokens)[0]]; + } + // If we have exact resource token for the path use it + if (resourceId && resourceTokens[resourceId]) { + return resourceTokens[resourceId]; + } + // minimum valid path /dbs + if (!path || path.length < 4) { + // TODO: This should throw an error + return null; + } + path = trimSlashFromLeftAndRight(path); + const pathSegments = (path && path.split("/")) || []; + // Item path + if (pathSegments.length === 6) { + // Look for a container token matching the item path + const containerPath = pathSegments.slice(0, 4).map(decodeURIComponent).join("/"); + if (resourceTokens[containerPath]) { + return resourceTokens[containerPath]; + } + } + // TODO remove in v4: This is legacy behavior that lets someone use a resource token pointing ONLY at an ID + // It was used when _rid was exposed by the SDK, but now that we are using user provided ids it is not needed + // However removing it now would be a breaking change + // if it's an incomplete path like /dbs/db1/colls/, start from the parent resource + let index = pathSegments.length % 2 === 0 ? pathSegments.length - 1 : pathSegments.length - 2; + for (; index > 0; index -= 2) { + const id = decodeURI(pathSegments[index]); + if (resourceTokens[id]) { + return resourceTokens[id]; + } + } + } + // TODO: This should throw an error + return null; +} +//# sourceMappingURL=auth.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/auth.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/auth.js.map new file mode 100644 index 000000000..cfaf8d1a9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/auth.js.map @@ -0,0 +1 @@ +{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/auth.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,SAAS,EACT,qBAAqB,EAErB,YAAY,EACZ,yBAAyB,GAC1B,MAAM,UAAU,CAAC;AAelB;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,aAAkC,EAClC,IAAgB,EAChB,IAAY,EACZ,UAAkB,EAClB,YAA0B,EAC1B,OAAsB;IAEtB,IAAI,aAAa,CAAC,cAAc,EAAE;QAChC,aAAa,CAAC,cAAc,GAAG,EAAE,CAAC;QAClC,KAAK,MAAM,UAAU,IAAI,aAAa,CAAC,cAAc,EAAE;YACrD,MAAM,EAAE,GAAG,qBAAqB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACtD,IAAI,CAAC,EAA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AK,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE;YAC5B,MAAM,EAAE,GAAG,SAAS,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;YAC1C,IAAI,cAAc,CAAC,EAAE,CAAC,EAAE;gBACtB,OAAO,cAAc,CAAC,EAAE,CAAC,CAAC;aAC3B;SACF;KACF;IAED,mCAAmC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { generateHeaders } from \"./utils/headers\";\nimport {\n Constants,\n getResourceIdFromPath,\n HTTPMethod,\n ResourceType,\n trimSlashFromLeftAndRight,\n} from \"./common\";\nimport { CosmosClientOptions } from \"./CosmosClientOptions\";\nimport { CosmosHeaders } from \"./queryExecutionContext\";\n\n/** @hidden */\nexport interface RequestInfo {\n verb: HTTPMethod;\n path: string;\n resourceId: string;\n resourceType: ResourceType;\n headers: CosmosHeaders;\n}\n\nexport type TokenProvider = (requestInfo: RequestInfo) => Promise;\n\n/**\n * @hidden\n */\nexport async function setAuthorizationHeader(\n clientOptions: CosmosClientOptions,\n verb: HTTPMethod,\n path: string,\n resourceId: string,\n resourceType: ResourceType,\n headers: CosmosHeaders,\n): Promise {\n if (clientOptions.permissionFeed) {\n clientOptions.resourceTokens = {};\n for (const permission of clientOptions.permissionFeed) {\n const id = getResourceIdFromPath(permission.resource);\n if (!id) {\n throw new Error(`authorization error: ${id} \\\n is an invalid resourceId in permissionFeed`);\n }\n\n clientOptions.resourceTokens[id] = (permission as any)._token; // TODO: any\n }\n }\n\n if (clientOptions.key) {\n await setAuthorizationTokenHeaderUsingMasterKey(\n verb,\n resourceId,\n resourceType,\n headers,\n clientOptions.key,\n );\n } else if (clientOptions.resourceTokens) {\n headers[Constants.HttpHeaders.Authorization] = encodeURIComponent(\n getAuthorizationTokenUsingResourceTokens(clientOptions.resourceTokens, path, resourceId),\n );\n } else if (clientOptions.tokenProvider) {\n headers[Constants.HttpHeaders.Authorization] = encodeURIComponent(\n await clientOptions.tokenProvider({ verb, path, resourceId, resourceType, headers }),\n );\n }\n}\n\n/**\n * The default function for setting header token using the masterKey\n * @hidden\n */\nexport async function setAuthorizationTokenHeaderUsingMasterKey(\n verb: HTTPMethod,\n resourceId: string,\n resourceType: ResourceType,\n headers: CosmosHeaders,\n masterKey: string,\n): Promise {\n // TODO This should live in cosmos-sign\n if (resourceType === ResourceType.offer) {\n resourceId = resourceId && resourceId.toLowerCase();\n }\n headers = Object.assign(\n headers,\n await generateHeaders(masterKey, verb, resourceType, resourceId),\n );\n}\n\n/**\n * @hidden\n */\n// TODO: Resource tokens\nexport function getAuthorizationTokenUsingResourceTokens(\n resourceTokens: { [resourceId: string]: string },\n path: string,\n resourceId: string,\n): string {\n if (resourceTokens && Object.keys(resourceTokens).length > 0) {\n // For database account access(through getDatabaseAccount API), path and resourceId are \"\",\n // so in this case we return the first token to be used for creating the auth header as the\n // service will accept any token in this case\n if (!path && !resourceId) {\n return resourceTokens[Object.keys(resourceTokens)[0]];\n }\n\n // If we have exact resource token for the path use it\n if (resourceId && resourceTokens[resourceId]) {\n return resourceTokens[resourceId];\n }\n\n // minimum valid path /dbs\n if (!path || path.length < 4) {\n // TODO: This should throw an error\n return null;\n }\n\n path = trimSlashFromLeftAndRight(path);\n const pathSegments = (path && path.split(\"/\")) || [];\n\n // Item path\n if (pathSegments.length === 6) {\n // Look for a container token matching the item path\n const containerPath = pathSegments.slice(0, 4).map(decodeURIComponent).join(\"/\");\n if (resourceTokens[containerPath]) {\n return resourceTokens[containerPath];\n }\n }\n\n // TODO remove in v4: This is legacy behavior that lets someone use a resource token pointing ONLY at an ID\n // It was used when _rid was exposed by the SDK, but now that we are using user provided ids it is not needed\n // However removing it now would be a breaking change\n // if it's an incomplete path like /dbs/db1/colls/, start from the parent resource\n let index = pathSegments.length % 2 === 0 ? pathSegments.length - 1 : pathSegments.length - 2;\n for (; index > 0; index -= 2) {\n const id = decodeURI(pathSegments[index]);\n if (resourceTokens[id]) {\n return resourceTokens[id];\n }\n }\n }\n\n // TODO: This should throw an error\n return null;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts new file mode 100644 index 000000000..c30f51233 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts @@ -0,0 +1,8 @@ +/** + * Enum to specify the resource for which change feed is being fetched. + */ +export declare enum ChangeFeedResourceType { + FeedRange = 0, + PartitionKey = 1 +} +//# sourceMappingURL=ChangeFeedEnums.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts.map new file mode 100644 index 000000000..7925f286f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedEnums.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedEnums.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,sBAAsB;IAChC,SAAS,IAAA;IACT,YAAY,IAAA;CACb"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js new file mode 100644 index 000000000..81b91ebdc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum to specify the resource for which change feed is being fetched. + */ +export var ChangeFeedResourceType; +(function (ChangeFeedResourceType) { + ChangeFeedResourceType[ChangeFeedResourceType["FeedRange"] = 0] = "FeedRange"; + ChangeFeedResourceType[ChangeFeedResourceType["PartitionKey"] = 1] = "PartitionKey"; +})(ChangeFeedResourceType || (ChangeFeedResourceType = {})); +//# sourceMappingURL=ChangeFeedEnums.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js.map new file mode 100644 index 000000000..06b6bab51 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedEnums.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedEnums.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedEnums.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,6EAAS,CAAA;IACT,mFAAY,CAAA;AACd,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Enum to specify the resource for which change feed is being fetched.\n */\nexport enum ChangeFeedResourceType {\n FeedRange,\n PartitionKey,\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.d.ts new file mode 100644 index 000000000..0be037eee --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.d.ts @@ -0,0 +1,72 @@ +import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +import { Resource } from "../../client"; +import { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator"; +/** + * @hidden + * Provides iterator for change feed for entire container or an epk range. + * + * Use `Items.getChangeFeedIterator()` to get an instance of the iterator. + */ +export declare class ChangeFeedForEpkRange implements ChangeFeedPullModelIterator { + private clientContext; + private container; + private partitionKeyRangeCache; + private resourceId; + private resourceLink; + private url; + private changeFeedOptions; + private epkRange; + private continuationToken?; + private queue; + private startTime; + private isInstantiated; + private rId; + private setIteratorRid; + private continuationTokenRidMatchContainerRid; + private fillChangeFeedQueue; + /** + * Fill the queue with the feed ranges overlapping with the given epk range. + */ + private fetchOverLappingFeedRanges; + /** + * Fill the queue with feed ranges from continuation token + */ + private fetchContinuationTokenFeedRanges; + /** + * Change feed is an infinite feed. hasMoreResults is always true. + */ + get hasMoreResults(): boolean; + /** + * Gets an async iterator which will yield change feed results. + */ + getAsyncIterator(): AsyncIterable>>; + /** + * Gets an async iterator which will yield pages of results from Azure Cosmos DB. + * + * Keeps iterating over the feedranges and checks if any feed range has new result. Keeps note of the last feed range which returned non 304 result. + * + * When same feed range is reached and no new changes are found, a 304 (not Modified) is returned to the end user. Then starts process all over again. + */ + readNext(): Promise>>; + private generateContinuationToken; + /** + * Read feed and retrieves the next page of results in Azure Cosmos DB. + */ + private fetchNext; + private checkedAllFeedRanges; + /** + * Checks whether the current EpkRange is split into multiple ranges or not. + * + * If yes, it force refreshes the partitionKeyRange cache and enqueue children epk ranges. + */ + private shouldRetryOnFailure; + private handleSplit; + /** + * Fetch the partitionKeyRangeId for the given feed range. + * + * This partitionKeyRangeId is passed to queryFeed to fetch the results. + */ + private getPartitionRangeId; + private getFeedResponse; +} +//# sourceMappingURL=ChangeFeedForEpkRange.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.d.ts.map new file mode 100644 index 000000000..e16d80e9f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/Ch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W5B;;;;OAIG;YACW,oBAAoB;YA2CpB,WAAW;IA4CzB;;;;OAIG;YACW,mBAAmB;YAuBnB,eAAe;CA4D9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js new file mode 100644 index 000000000..770f4f6d4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js @@ -0,0 +1,313 @@ +import { __asyncGenerator, __await } from "tslib"; +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { ChangeFeedRange } from "./ChangeFeedRange"; +import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +import { QueryRange } from "../../routing"; +import { FeedRangeQueue } from "./FeedRangeQueue"; +import { Constants, SubStatusCodes, StatusCodes, ResourceType } from "../../common"; +import { ErrorResponse } from "../../request"; +import { CompositeContinuationToken } from "./CompositeContinuationToken"; +import { extractOverlappingRanges } from "./changeFeedUtils"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * @hidden + * Provides iterator for change feed for entire container or an epk range. + * + * Use `Items.getChangeFeedIterator()` to get an instance of the iterator. + */ +export class ChangeFeedForEpkRange { + /** + * @internal + */ + constructor(clientContext, container, partitionKeyRangeCache, resourceId, resourceLink, url, changeFeedOptions, epkRange) { + this.clientContext = clientContext; + this.container = container; + this.partitionKeyRangeCache = partitionKeyRangeCache; + this.resourceId = resourceId; + this.resourceLink = resourceLink; + this.url = url; + this.changeFeedOptions = changeFeedOptions; + this.epkRange = epkRange; + this.generateContinuationToken = () => { + return JSON.stringify(new CompositeContinuationToken(this.rId, this.queue.returnSnapshot())); + }; + this.queue = new FeedRangeQueue(); + this.continuationToken = changeFeedOptions.continuationToken + ? JSON.parse(changeFeedOptions.continuationToken) + : undefined; + this.startTime = changeFeedOptions.startTime + ? changeFeedOptions.startTime.toUTCString() + : undefined; + this.isInstantiated = false; + } + async setIteratorRid(diagnosticNode) { + const { resource } = await this.container.readInternal(diagnosticNode); + this.rId = resource._rid; + } + continuationTokenRidMatchContainerRid() { + if (this.continuationToken.rid !== this.rId) { + return false; + } + return true; + } + async fillChangeFeedQueue(diagnosticNode) { + if (this.continuationToken) { + // fill the queue with feed ranges in continuation token. + await this.fetchContinuationTokenFeedRanges(diagnosticNode); + } + else { + // fill the queue with feed ranges overlapping the given epk range. + await this.fetchOverLappingFeedRanges(diagnosticNode); + } + this.isInstantiated = true; + } + /** + * Fill the queue with the feed ranges overlapping with the given epk range. + */ + async fetchOverLappingFeedRanges(diagnosticNode) { + try { + const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, this.epkRange, diagnosticNode); + for (const overLappingRange of overLappingRanges) { + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(this.epkRange, overLappingRange); + const feedRange = new ChangeFeedRange(overLappingRange.minInclusive, overLappingRange.maxExclusive, "", epkMinHeader, epkMaxHeader); + this.queue.enqueue(feedRange); + } + } + catch (err) { + throw new ErrorResponse(err.message); + } + } + /** + * Fill the queue with feed ranges from continuation token + */ + async fetchContinuationTokenFeedRanges(diagnosticNode) { + const contToken = this.continuationToken; + if (!this.continuationTokenRidMatchContainerRid()) { + throw new ErrorResponse("The continuation token is not for the current container definition"); + } + else { + for (const cToken of contToken.Continuation) { + const queryRange = new QueryRange(cToken.minInclusive, cToken.maxExclusive, true, false); + try { + const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, queryRange, diagnosticNode); + for (const overLappingRange of overLappingRanges) { + // check if the epk range present in continuation token entirely covers the overlapping range. + // If yes, minInclusive and maxExclusive of the overlapping range will be set. + // If no, i.e. there is only partial overlap, epkMinHeader and epkMaxHeader are set as min and max of overlap. + // This will be used when we make a call to fetch change feed. + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(queryRange, overLappingRange); + const feedRange = new ChangeFeedRange(overLappingRange.minInclusive, overLappingRange.maxExclusive, cToken.continuationToken, epkMinHeader, epkMaxHeader); + this.queue.enqueue(feedRange); + } + } + catch (err) { + throw new ErrorResponse(err.message); + } + } + } + } + /** + * Change feed is an infinite feed. hasMoreResults is always true. + */ + get hasMoreResults() { + return true; + } + /** + * Gets an async iterator which will yield change feed results. + */ + getAsyncIterator() { + return __asyncGenerator(this, arguments, function* getAsyncIterator_1() { + do { + const result = yield __await(this.readNext()); + yield yield __await(result); + } while (this.hasMoreResults); + }); + } + /** + * Gets an async iterator which will yield pages of results from Azure Cosmos DB. + * + * Keeps iterating over the feedranges and checks if any feed range has new result. Keeps note of the last feed range which returned non 304 result. + * + * When same feed range is reached and no new changes are found, a 304 (not Modified) is returned to the end user. Then starts process all over again. + */ + async readNext() { + return withDiagnostics(async (diagnosticNode) => { + // validate if the internal queue is filled up with feed ranges. + if (!this.isInstantiated) { + await this.setIteratorRid(diagnosticNode); + await this.fillChangeFeedQueue(diagnosticNode); + } + // stores the last feedRange for which statusCode is not 304 i.e. there were new changes in that feed range. + let firstNotModifiedFeedRange = undefined; + let result; + do { + const [processedFeedRange, response] = await this.fetchNext(diagnosticNode); + result = response; + if (result !== undefined) { + { + if (firstNotModifiedFeedRange === undefined) { + firstNotModifiedFeedRange = processedFeedRange; + } + // move current feed range to end of queue to fetch result of next feed range. + // This is done to fetch changes in breadth first manner and avoid starvation. + this.queue.moveFirstElementToTheEnd(); + // check if there are new results for the given feed range. + if (result.statusCode === StatusCodes.Ok) { + result.headers[Constants.HttpHeaders.ContinuationToken] = + this.generateContinuationToken(); + return result; + } + } + } + } while (!this.checkedAllFeedRanges(firstNotModifiedFeedRange)); + // set the continuation token after processing. + result.headers[Constants.HttpHeaders.ContinuationToken] = this.generateContinuationToken(); + return result; + }, this.clientContext); + } + /** + * Read feed and retrieves the next page of results in Azure Cosmos DB. + */ + async fetchNext(diagnosticNode) { + const feedRange = this.queue.peek(); + if (feedRange) { + // fetch results for feed range at the beginning of the queue. + const result = await this.getFeedResponse(feedRange, diagnosticNode); + // check if results need to be fetched again depending on status code returned. + // Eg. in case of paritionSplit, results need to be fetched for the child partitions. + const shouldRetry = await this.shouldRetryOnFailure(feedRange, result, diagnosticNode); + if (shouldRetry) { + this.queue.dequeue(); + return this.fetchNext(diagnosticNode); + } + else { + // update the continuation value for the current feed range. + const continuationValueForFeedRange = result.headers[Constants.HttpHeaders.ETag]; + const newFeedRange = this.queue.peek(); + newFeedRange.continuationToken = continuationValueForFeedRange; + return [[newFeedRange.minInclusive, newFeedRange.maxExclusive], result]; + } + } + else { + return [[undefined, undefined], undefined]; + } + } + checkedAllFeedRanges(firstNotModifiedFeedRange) { + if (firstNotModifiedFeedRange === undefined) { + return false; + } + const feedRangeQueueFirstElement = this.queue.peek(); + return (firstNotModifiedFeedRange[0] === (feedRangeQueueFirstElement === null || feedRangeQueueFirstElement === void 0 ? void 0 : feedRangeQueueFirstElement.minInclusive) && + firstNotModifiedFeedRange[1] === (feedRangeQueueFirstElement === null || feedRangeQueueFirstElement === void 0 ? void 0 : feedRangeQueueFirstElement.maxExclusive)); + } + /** + * Checks whether the current EpkRange is split into multiple ranges or not. + * + * If yes, it force refreshes the partitionKeyRange cache and enqueue children epk ranges. + */ + async shouldRetryOnFailure(feedRange, response, diagnosticNode) { + if (response.statusCode === StatusCodes.Ok || response.statusCode === StatusCodes.NotModified) { + return false; + } + const partitionSplit = response.statusCode === StatusCodes.Gone && + (response.subStatusCode === SubStatusCodes.PartitionKeyRangeGone || + response.subStatusCode === SubStatusCodes.CompletingSplit); + if (partitionSplit) { + const queryRange = new QueryRange(feedRange.minInclusive, feedRange.maxExclusive, true, false); + const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, queryRange, diagnosticNode, true); + if (resolvedRanges.length < 1) { + throw new ErrorResponse("Partition split/merge detected but no overlapping ranges found."); + } + // This covers both cases of merge and split. + // resolvedRanges.length > 1 in case of split. + // resolvedRanges.length === 1 in case of merge. EpkRange headers will be added in this case. + if (resolvedRanges.length >= 1) { + await this.handleSplit(false, resolvedRanges, queryRange, feedRange.continuationToken); + } + return true; + } + return false; + } + /* + * Enqueues all the children feed ranges for the given feed range. + */ + async handleSplit(shiftLeft, resolvedRanges, oldFeedRange, continuationToken) { + let flag = 0; + if (shiftLeft) { + // This section is only applicable when handleSplit is called by getPartitionRangeId(). + // used only when existing partition key range cache is used to check for any overlapping ranges. + // Modifies the first element with the first overlapping range. + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(oldFeedRange, resolvedRanges[0]); + const newFeedRange = new ChangeFeedRange(resolvedRanges[0].minInclusive, resolvedRanges[0].maxExclusive, continuationToken, epkMinHeader, epkMaxHeader); + this.queue.modifyFirstElement(newFeedRange); + flag = 1; + } + // Enqueue the overlapping ranges. + for (let i = flag; i < resolvedRanges.length; i++) { + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(oldFeedRange, resolvedRanges[i]); + const newFeedRange = new ChangeFeedRange(resolvedRanges[i].minInclusive, resolvedRanges[i].maxExclusive, continuationToken, epkMinHeader, epkMaxHeader); + this.queue.enqueue(newFeedRange); + } + } + /** + * Fetch the partitionKeyRangeId for the given feed range. + * + * This partitionKeyRangeId is passed to queryFeed to fetch the results. + */ + async getPartitionRangeId(feedRange, diagnosticNode) { + const min = feedRange.epkMinHeader ? feedRange.epkMinHeader : feedRange.minInclusive; + const max = feedRange.epkMaxHeader ? feedRange.epkMaxHeader : feedRange.maxExclusive; + const queryRange = new QueryRange(min, max, true, false); + const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, queryRange, diagnosticNode, false); + if (resolvedRanges.length < 1) { + throw new ErrorResponse("No overlapping ranges found."); + } + const firstResolvedRange = resolvedRanges[0]; + if (resolvedRanges.length > 1) { + await this.handleSplit(true, resolvedRanges, queryRange, feedRange.continuationToken); + } + return firstResolvedRange.id; + } + async getFeedResponse(feedRange, diagnosticNode) { + const feedOptions = { initialHeaders: {}, useIncrementalFeed: true }; + if (typeof this.changeFeedOptions.maxItemCount === "number") { + feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount; + } + if (this.changeFeedOptions.sessionToken) { + feedOptions.sessionToken = this.changeFeedOptions.sessionToken; + } + if (feedRange.continuationToken) { + feedOptions.accessCondition = { + type: Constants.HttpHeaders.IfNoneMatch, + condition: feedRange.continuationToken, + }; + } + if (this.startTime) { + feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.startTime; + } + const rangeId = await this.getPartitionRangeId(feedRange, diagnosticNode); + try { + // startEpk and endEpk are only valid in case we want to fetch result for a part of partition and not the entire partition. + const response = await this.clientContext.queryFeed({ + path: this.resourceLink, + resourceType: ResourceType.item, + resourceId: this.resourceId, + resultFn: (result) => (result ? result.Documents : []), + query: undefined, + options: feedOptions, + diagnosticNode, + partitionKey: undefined, + partitionKeyRangeId: rangeId, + startEpk: feedRange.epkMinHeader, + endEpk: feedRange.epkMaxHeader, + }); + return new ChangeFeedIteratorResponse(response.result, response.result ? response.result.length : 0, response.code, response.headers, getEmptyCosmosDiagnostics()); + } + catch (err) { + // If any errors are encountered, eg. partition split or gone, handle it based on error code and not break the flow. + return new ChangeFeedIteratorResponse([], 0, err.code, err.headers, getEmptyCosmosDiagnostics(), err.substatus); + } + } +} +//# sourceMappingURL=ChangeFeedForEpkRange.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js.map new file mode 100644 index 000000000..cc1a03938 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForEpkRange.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedForEpkRange.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedForEpkRange.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OA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gBAChC,MAAM,EAAE,SAAS,CAAC,YAAY;aAC/B,CAAkB,CAAC;YAEpB,OAAO,IAAI,0BAA0B,CACnC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC5C,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,OAAO,EAChB,yBAAyB,EAAE,CAC5B,CAAC;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,oHAAoH;YACpH,OAAO,IAAI,0BAA0B,CACnC,EAAE,EACF,CAAC,EACD,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,OAAO,EACX,yBAAyB,EAAE,EAC3B,GAAG,CAAC,SAAS,CACd,CAAC;SACH;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedRange } from \"./ChangeFeedRange\";\nimport { ChangeFeedIteratorResponse } from \"./ChangeFeedIteratorResponse\";\nimport { PartitionKeyRangeCache, QueryRange } from \"../../routing\";\nimport { FeedRangeQueue } from \"./FeedRangeQueue\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { Container, Resource } from \"../../client\";\nimport { Constants, SubStatusCodes, StatusCodes, ResourceType } from \"../../common\";\nimport { Response, FeedOptions, ErrorResponse } from \"../../request\";\nimport { CompositeContinuationToken } from \"./CompositeContinuationToken\";\nimport { ChangeFeedPullModelIterator } from \"./ChangeFeedPullModelIterator\";\nimport { extractOverlappingRanges } from \"./changeFeedUtils\";\nimport { InternalChangeFeedIteratorOptions } from \"./InternalChangeFeedOptions\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n/**\n * @hidden\n * Provides iterator for change feed for entire container or an epk range.\n *\n * Use `Items.getChangeFeedIterator()` to get an instance of the iterator.\n */\nexport class ChangeFeedForEpkRange implements ChangeFeedPullModelIterator {\n private continuationToken?: CompositeContinuationToken;\n private queue: FeedRangeQueue;\n private startTime: string;\n private isInstantiated: boolean;\n private rId: string;\n /**\n * @internal\n */\n constructor(\n private clientContext: ClientContext,\n private container: Container,\n private partitionKeyRangeCache: PartitionKeyRangeCache,\n private resourceId: string,\n private resourceLink: string,\n private url: string,\n private changeFeedOptions: InternalChangeFeedIteratorOptions,\n private epkRange: QueryRange,\n ) {\n this.queue = new FeedRangeQueue();\n this.continuationToken = changeFeedOptions.continuationToken\n ? JSON.parse(changeFeedOptions.continuationToken)\n : undefined;\n this.startTime = changeFeedOptions.startTime\n ? changeFeedOptions.startTime.toUTCString()\n : undefined;\n this.isInstantiated = false;\n }\n\n private async setIteratorRid(diagnosticNode: DiagnosticNodeInternal): Promise {\n const { resource } = await this.container.readInternal(diagnosticNode);\n this.rId = resource._rid;\n }\n\n private continuationTokenRidMatchContainerRid(): boolean {\n if (this.continuationToken.rid !== this.rId) {\n return false;\n }\n return true;\n }\n\n private async fillChangeFeedQueue(diagnosticNode: DiagnosticNodeInternal): Promise {\n if (this.continuationToken) {\n // fill the queue with feed ranges in continuation token.\n await this.fetchContinuationTokenFeedRanges(diagnosticNode);\n } else {\n // fill the queue with feed ranges overlapping the given epk range.\n await this.fetchOverLappingFeedRanges(diagnosticNode);\n }\n this.isInstantiated = true;\n }\n\n /**\n * Fill the queue with the feed ranges overlapping with the given epk range.\n */\n private async fetchOverLappingFeedRanges(diagnosticNode: DiagnosticNodeInternal): Promise {\n try {\n const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n this.epkRange,\n diagnosticNode,\n );\n for (const overLappingRange of overLappingRanges) {\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n this.epkRange,\n overLappingRange,\n );\n const feedRange: ChangeFeedRange = new ChangeFeedRange(\n overLappingRange.minInclusive,\n overLappingRange.maxExclusive,\n \"\",\n epkMinHeader,\n epkMaxHeader,\n );\n this.queue.enqueue(feedRange);\n }\n } catch (err) {\n throw new ErrorResponse(err.message);\n }\n }\n /**\n * Fill the queue with feed ranges from continuation token\n */\n private async fetchContinuationTokenFeedRanges(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n const contToken = this.continuationToken;\n if (!this.continuationTokenRidMatchContainerRid()) {\n throw new ErrorResponse(\"The continuation token is not for the current container definition\");\n } else {\n for (const cToken of contToken.Continuation) {\n const queryRange = new QueryRange(cToken.minInclusive, cToken.maxExclusive, true, false);\n try {\n const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n queryRange,\n diagnosticNode,\n );\n for (const overLappingRange of overLappingRanges) {\n // check if the epk range present in continuation token entirely covers the overlapping range.\n // If yes, minInclusive and maxExclusive of the overlapping range will be set.\n // If no, i.e. there is only partial overlap, epkMinHeader and epkMaxHeader are set as min and max of overlap.\n // This will be used when we make a call to fetch change feed.\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n queryRange,\n overLappingRange,\n );\n const feedRange: ChangeFeedRange = new ChangeFeedRange(\n overLappingRange.minInclusive,\n overLappingRange.maxExclusive,\n cToken.continuationToken,\n epkMinHeader,\n epkMaxHeader,\n );\n this.queue.enqueue(feedRange);\n }\n } catch (err) {\n throw new ErrorResponse(err.message);\n }\n }\n }\n }\n\n /**\n * Change feed is an infinite feed. hasMoreResults is always true.\n */\n get hasMoreResults(): boolean {\n return true;\n }\n\n /**\n * Gets an async iterator which will yield change feed results.\n */\n public async *getAsyncIterator(): AsyncIterable>> {\n do {\n const result = await this.readNext();\n yield result;\n } while (this.hasMoreResults);\n }\n\n /**\n * Gets an async iterator which will yield pages of results from Azure Cosmos DB.\n *\n * Keeps iterating over the feedranges and checks if any feed range has new result. Keeps note of the last feed range which returned non 304 result.\n *\n * When same feed range is reached and no new changes are found, a 304 (not Modified) is returned to the end user. Then starts process all over again.\n */\n public async readNext(): Promise>> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n // validate if the internal queue is filled up with feed ranges.\n if (!this.isInstantiated) {\n await this.setIteratorRid(diagnosticNode);\n await this.fillChangeFeedQueue(diagnosticNode);\n }\n\n // stores the last feedRange for which statusCode is not 304 i.e. there were new changes in that feed range.\n let firstNotModifiedFeedRange: [string, string] = undefined;\n let result: ChangeFeedIteratorResponse>;\n do {\n const [processedFeedRange, response] = await this.fetchNext(diagnosticNode);\n result = response;\n if (result !== undefined) {\n {\n if (firstNotModifiedFeedRange === undefined) {\n firstNotModifiedFeedRange = processedFeedRange;\n }\n // move current feed range to end of queue to fetch result of next feed range.\n // This is done to fetch changes in breadth first manner and avoid starvation.\n this.queue.moveFirstElementToTheEnd();\n // check if there are new results for the given feed range.\n if (result.statusCode === StatusCodes.Ok) {\n result.headers[Constants.HttpHeaders.ContinuationToken] =\n this.generateContinuationToken();\n return result;\n }\n }\n }\n } while (!this.checkedAllFeedRanges(firstNotModifiedFeedRange));\n // set the continuation token after processing.\n result.headers[Constants.HttpHeaders.ContinuationToken] = this.generateContinuationToken();\n return result;\n }, this.clientContext);\n }\n\n private generateContinuationToken = (): string => {\n return JSON.stringify(new CompositeContinuationToken(this.rId, this.queue.returnSnapshot()));\n };\n\n /**\n * Read feed and retrieves the next page of results in Azure Cosmos DB.\n */\n private async fetchNext(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<[[string, string], ChangeFeedIteratorResponse>]> {\n const feedRange = this.queue.peek();\n if (feedRange) {\n // fetch results for feed range at the beginning of the queue.\n const result = await this.getFeedResponse(feedRange, diagnosticNode);\n\n // check if results need to be fetched again depending on status code returned.\n // Eg. in case of paritionSplit, results need to be fetched for the child partitions.\n const shouldRetry: boolean = await this.shouldRetryOnFailure(\n feedRange,\n result,\n diagnosticNode,\n );\n\n if (shouldRetry) {\n this.queue.dequeue();\n return this.fetchNext(diagnosticNode);\n } else {\n // update the continuation value for the current feed range.\n const continuationValueForFeedRange = result.headers[Constants.HttpHeaders.ETag];\n const newFeedRange = this.queue.peek();\n newFeedRange.continuationToken = continuationValueForFeedRange;\n\n return [[newFeedRange.minInclusive, newFeedRange.maxExclusive], result];\n }\n } else {\n return [[undefined, undefined], undefined];\n }\n }\n\n private checkedAllFeedRanges(firstNotModifiedFeedRange: [string, string]): boolean {\n if (firstNotModifiedFeedRange === undefined) {\n return false;\n }\n const feedRangeQueueFirstElement = this.queue.peek();\n return (\n firstNotModifiedFeedRange[0] === feedRangeQueueFirstElement?.minInclusive &&\n firstNotModifiedFeedRange[1] === feedRangeQueueFirstElement?.maxExclusive\n );\n }\n\n /**\n * Checks whether the current EpkRange is split into multiple ranges or not.\n *\n * If yes, it force refreshes the partitionKeyRange cache and enqueue children epk ranges.\n */\n private async shouldRetryOnFailure(\n feedRange: ChangeFeedRange,\n response: ChangeFeedIteratorResponse>,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n if (response.statusCode === StatusCodes.Ok || response.statusCode === StatusCodes.NotModified) {\n return false;\n }\n\n const partitionSplit =\n response.statusCode === StatusCodes.Gone &&\n (response.subStatusCode === SubStatusCodes.PartitionKeyRangeGone ||\n response.subStatusCode === SubStatusCodes.CompletingSplit);\n\n if (partitionSplit) {\n const queryRange = new QueryRange(\n feedRange.minInclusive,\n feedRange.maxExclusive,\n true,\n false,\n );\n const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n queryRange,\n diagnosticNode,\n true,\n );\n if (resolvedRanges.length < 1) {\n throw new ErrorResponse(\"Partition split/merge detected but no overlapping ranges found.\");\n }\n // This covers both cases of merge and split.\n // resolvedRanges.length > 1 in case of split.\n // resolvedRanges.length === 1 in case of merge. EpkRange headers will be added in this case.\n if (resolvedRanges.length >= 1) {\n await this.handleSplit(false, resolvedRanges, queryRange, feedRange.continuationToken);\n }\n return true;\n }\n return false;\n }\n /*\n * Enqueues all the children feed ranges for the given feed range.\n */\n private async handleSplit(\n shiftLeft: boolean,\n resolvedRanges: any,\n oldFeedRange: QueryRange,\n continuationToken: string,\n ): Promise {\n let flag = 0;\n if (shiftLeft) {\n // This section is only applicable when handleSplit is called by getPartitionRangeId().\n // used only when existing partition key range cache is used to check for any overlapping ranges.\n // Modifies the first element with the first overlapping range.\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n oldFeedRange,\n resolvedRanges[0],\n );\n const newFeedRange = new ChangeFeedRange(\n resolvedRanges[0].minInclusive,\n resolvedRanges[0].maxExclusive,\n continuationToken,\n epkMinHeader,\n epkMaxHeader,\n );\n\n this.queue.modifyFirstElement(newFeedRange);\n flag = 1;\n }\n // Enqueue the overlapping ranges.\n for (let i = flag; i < resolvedRanges.length; i++) {\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n oldFeedRange,\n resolvedRanges[i],\n );\n\n const newFeedRange = new ChangeFeedRange(\n resolvedRanges[i].minInclusive,\n resolvedRanges[i].maxExclusive,\n continuationToken,\n epkMinHeader,\n epkMaxHeader,\n );\n this.queue.enqueue(newFeedRange);\n }\n }\n\n /**\n * Fetch the partitionKeyRangeId for the given feed range.\n *\n * This partitionKeyRangeId is passed to queryFeed to fetch the results.\n */\n private async getPartitionRangeId(\n feedRange: ChangeFeedRange,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n const min = feedRange.epkMinHeader ? feedRange.epkMinHeader : feedRange.minInclusive;\n const max = feedRange.epkMaxHeader ? feedRange.epkMaxHeader : feedRange.maxExclusive;\n const queryRange = new QueryRange(min, max, true, false);\n const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n queryRange,\n diagnosticNode,\n false,\n );\n if (resolvedRanges.length < 1) {\n throw new ErrorResponse(\"No overlapping ranges found.\");\n }\n const firstResolvedRange = resolvedRanges[0];\n if (resolvedRanges.length > 1) {\n await this.handleSplit(true, resolvedRanges, queryRange, feedRange.continuationToken);\n }\n return firstResolvedRange.id;\n }\n\n private async getFeedResponse(\n feedRange: ChangeFeedRange,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n const feedOptions: FeedOptions = { initialHeaders: {}, useIncrementalFeed: true };\n\n if (typeof this.changeFeedOptions.maxItemCount === \"number\") {\n feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount;\n }\n\n if (this.changeFeedOptions.sessionToken) {\n feedOptions.sessionToken = this.changeFeedOptions.sessionToken;\n }\n\n if (feedRange.continuationToken) {\n feedOptions.accessCondition = {\n type: Constants.HttpHeaders.IfNoneMatch,\n condition: feedRange.continuationToken,\n };\n }\n\n if (this.startTime) {\n feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.startTime;\n }\n const rangeId = await this.getPartitionRangeId(feedRange, diagnosticNode);\n try {\n // startEpk and endEpk are only valid in case we want to fetch result for a part of partition and not the entire partition.\n const response: Response> = await (this.clientContext.queryFeed({\n path: this.resourceLink,\n resourceType: ResourceType.item,\n resourceId: this.resourceId,\n resultFn: (result) => (result ? result.Documents : []),\n query: undefined,\n options: feedOptions,\n diagnosticNode,\n partitionKey: undefined,\n partitionKeyRangeId: rangeId,\n startEpk: feedRange.epkMinHeader,\n endEpk: feedRange.epkMaxHeader,\n }) as Promise);\n\n return new ChangeFeedIteratorResponse(\n response.result,\n response.result ? response.result.length : 0,\n response.code,\n response.headers,\n getEmptyCosmosDiagnostics(),\n );\n } catch (err) {\n // If any errors are encountered, eg. partition split or gone, handle it based on error code and not break the flow.\n return new ChangeFeedIteratorResponse(\n [],\n 0,\n err.code,\n err.headers,\n getEmptyCosmosDiagnostics(),\n err.substatus,\n );\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts new file mode 100644 index 000000000..b8150a69f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts @@ -0,0 +1,42 @@ +import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +import { Resource } from "../../client"; +import { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator"; +/** + * @hidden + * Provides iterator for change feed for one partition key. + * + * Use `Items.getChangeFeedIterator()` to get an instance of the iterator. + */ +export declare class ChangeFeedForPartitionKey implements ChangeFeedPullModelIterator { + private clientContext; + private container; + private resourceId; + private resourceLink; + private partitionKey; + private changeFeedOptions; + private continuationToken; + private startTime; + private rId; + private isInstantiated; + private instantiateIterator; + private continuationTokenRidMatchContainerRid; + private setIteratorRid; + /** + * Change feed is an infinite feed. hasMoreResults is always true. + */ + get hasMoreResults(): boolean; + /** + * Gets an async iterator which will yield change feed results. + */ + getAsyncIterator(): AsyncIterable>>; + /** + * Returns the result of change feed from Azure Cosmos DB. + */ + readNext(): Promise>>; + /** + * Read feed and retrieves the next set of results in Azure Cosmos DB. + */ + private fetchNext; + private getFeedResponse; +} +//# sourceMappingURL=ChangeFeedForPartitionKey.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map new file mode 100644 index 000000000..0554045cf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedForPartitionKey.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedForPartitionKey.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAa,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAI5E;;;;;GAKG;AACH,qBAAa,yBAAyB,CAAC,CAAC,CAAE,YAAW,2BAA2B,CAAC,CAAC,CAAC;IAS/E,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,iBAAiB;IAb3B,OAAO,CAAC,iBAAiB,CAAmC;IAC5D,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,cAAc,CAAU;YAsBlB,mBAAmB;IAiBjC,OAAO,CAAC,qCAAqC;YAO/B,cAAc;IAK5B;;OAEG;IACH,IAAI,cAAc,IAAI,OAAO,CAE5B;IAED;;OAEG;IACW,gBAAgB,IAAI,aAAa,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAOhG;;OAEG;IACU,QAAQ,IAAI,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC;IAUjF;;OAEG;YACW,SAAS;YAWT,eAAe;CA4C9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js new file mode 100644 index 000000000..03c21c6b9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js @@ -0,0 +1,123 @@ +import { __asyncGenerator, __await } from "tslib"; +import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +import { Constants, ResourceType } from "../../common"; +import { ErrorResponse } from "../../request"; +import { ContinuationTokenForPartitionKey } from "./ContinuationTokenForPartitionKey"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * @hidden + * Provides iterator for change feed for one partition key. + * + * Use `Items.getChangeFeedIterator()` to get an instance of the iterator. + */ +export class ChangeFeedForPartitionKey { + /** + * @internal + */ + constructor(clientContext, container, resourceId, resourceLink, partitionKey, changeFeedOptions) { + this.clientContext = clientContext; + this.container = container; + this.resourceId = resourceId; + this.resourceLink = resourceLink; + this.partitionKey = partitionKey; + this.changeFeedOptions = changeFeedOptions; + this.continuationToken = changeFeedOptions.continuationToken + ? JSON.parse(changeFeedOptions.continuationToken) + : undefined; + this.isInstantiated = false; + if (changeFeedOptions.startTime) { + this.startTime = changeFeedOptions.startTime.toUTCString(); + } + } + async instantiateIterator(diagnosticNode) { + await this.setIteratorRid(diagnosticNode); + if (this.continuationToken) { + if (!this.continuationTokenRidMatchContainerRid()) { + throw new ErrorResponse("The continuation is not for the current container definition."); + } + } + else { + this.continuationToken = new ContinuationTokenForPartitionKey(this.rId, this.partitionKey, ""); + } + this.isInstantiated = true; + } + continuationTokenRidMatchContainerRid() { + if (this.continuationToken.rid !== this.rId) { + return false; + } + return true; + } + async setIteratorRid(diagnosticNode) { + const { resource } = await this.container.readInternal(diagnosticNode); + this.rId = resource._rid; + } + /** + * Change feed is an infinite feed. hasMoreResults is always true. + */ + get hasMoreResults() { + return true; + } + /** + * Gets an async iterator which will yield change feed results. + */ + getAsyncIterator() { + return __asyncGenerator(this, arguments, function* getAsyncIterator_1() { + do { + const result = yield __await(this.readNext()); + yield yield __await(result); + } while (this.hasMoreResults); + }); + } + /** + * Returns the result of change feed from Azure Cosmos DB. + */ + async readNext() { + return withDiagnostics(async (diagnosticNode) => { + if (!this.isInstantiated) { + await this.instantiateIterator(diagnosticNode); + } + const result = await this.fetchNext(diagnosticNode); + return result; + }, this.clientContext); + } + /** + * Read feed and retrieves the next set of results in Azure Cosmos DB. + */ + async fetchNext(diagnosticNode) { + const response = await this.getFeedResponse(diagnosticNode); + this.continuationToken.Continuation = response.headers[Constants.HttpHeaders.ETag]; + response.headers[Constants.HttpHeaders.ContinuationToken] = JSON.stringify(this.continuationToken); + return response; + } + async getFeedResponse(diagnosticNode) { + const feedOptions = { initialHeaders: {}, useIncrementalFeed: true }; + if (typeof this.changeFeedOptions.maxItemCount === "number") { + feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount; + } + if (this.changeFeedOptions.sessionToken) { + feedOptions.sessionToken = this.changeFeedOptions.sessionToken; + } + const continuation = this.continuationToken.Continuation; + if (continuation) { + feedOptions.accessCondition = { + type: Constants.HttpHeaders.IfNoneMatch, + condition: continuation, + }; + } + if (this.startTime) { + feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.startTime; + } + const response = await this.clientContext.queryFeed({ + path: this.resourceLink, + resourceType: ResourceType.item, + resourceId: this.resourceId, + resultFn: (result) => (result ? result.Documents : []), + diagnosticNode, + query: undefined, + options: feedOptions, + partitionKey: this.partitionKey, + }); + return new ChangeFeedIteratorResponse(response.result, response.result ? response.result.length : 0, response.code, response.headers, getEmptyCosmosDiagnostics()); + } +} +//# sourceMappingURL=ChangeFeedForPartitionKey.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js.map new file mode 100644 index 000000000..3c3bdec9b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedForPartitionKey.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedForPartitionKey.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedForPartitionKey.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAG1E,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAyB,aAAa,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAItF,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACrF;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;I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,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAC5C,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,OAAO,EAChB,yBAAyB,EAAE,CAC5B,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { InternalChangeFeedIteratorOptions } from \"./InternalChangeFeedOptions\";\nimport { ChangeFeedIteratorResponse } from \"./ChangeFeedIteratorResponse\";\nimport { Container, Resource } from \"../../client\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, ResourceType } from \"../../common\";\nimport { FeedOptions, Response, ErrorResponse } from \"../../request\";\nimport { ContinuationTokenForPartitionKey } from \"./ContinuationTokenForPartitionKey\";\nimport { ChangeFeedPullModelIterator } from \"./ChangeFeedPullModelIterator\";\nimport { PartitionKey } from \"../../documents\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n/**\n * @hidden\n * Provides iterator for change feed for one partition key.\n *\n * Use `Items.getChangeFeedIterator()` to get an instance of the iterator.\n */\nexport class ChangeFeedForPartitionKey implements ChangeFeedPullModelIterator {\n private continuationToken: ContinuationTokenForPartitionKey;\n private startTime: string;\n private rId: string;\n private isInstantiated: boolean;\n /**\n * @internal\n */\n constructor(\n private clientContext: ClientContext,\n private container: Container,\n private resourceId: string,\n private resourceLink: string,\n private partitionKey: PartitionKey,\n private changeFeedOptions: InternalChangeFeedIteratorOptions,\n ) {\n this.continuationToken = changeFeedOptions.continuationToken\n ? JSON.parse(changeFeedOptions.continuationToken)\n : undefined;\n this.isInstantiated = false;\n\n if (changeFeedOptions.startTime) {\n this.startTime = changeFeedOptions.startTime.toUTCString();\n }\n }\n\n private async instantiateIterator(diagnosticNode: DiagnosticNodeInternal): Promise {\n await this.setIteratorRid(diagnosticNode);\n if (this.continuationToken) {\n if (!this.continuationTokenRidMatchContainerRid()) {\n throw new ErrorResponse(\"The continuation is not for the current container definition.\");\n }\n } else {\n this.continuationToken = new ContinuationTokenForPartitionKey(\n this.rId,\n this.partitionKey,\n \"\",\n );\n }\n\n this.isInstantiated = true;\n }\n\n private continuationTokenRidMatchContainerRid(): boolean {\n if (this.continuationToken.rid !== this.rId) {\n return false;\n }\n return true;\n }\n\n private async setIteratorRid(diagnosticNode: DiagnosticNodeInternal): Promise {\n const { resource } = await this.container.readInternal(diagnosticNode);\n this.rId = resource._rid;\n }\n\n /**\n * Change feed is an infinite feed. hasMoreResults is always true.\n */\n get hasMoreResults(): boolean {\n return true;\n }\n\n /**\n * Gets an async iterator which will yield change feed results.\n */\n public async *getAsyncIterator(): AsyncIterable>> {\n do {\n const result = await this.readNext();\n yield result;\n } while (this.hasMoreResults);\n }\n\n /**\n * Returns the result of change feed from Azure Cosmos DB.\n */\n public async readNext(): Promise>> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (!this.isInstantiated) {\n await this.instantiateIterator(diagnosticNode);\n }\n const result = await this.fetchNext(diagnosticNode);\n return result;\n }, this.clientContext);\n }\n\n /**\n * Read feed and retrieves the next set of results in Azure Cosmos DB.\n */\n private async fetchNext(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n const response = await this.getFeedResponse(diagnosticNode);\n this.continuationToken.Continuation = response.headers[Constants.HttpHeaders.ETag];\n response.headers[Constants.HttpHeaders.ContinuationToken] = JSON.stringify(\n this.continuationToken,\n );\n return response;\n }\n\n private async getFeedResponse(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n const feedOptions: FeedOptions = { initialHeaders: {}, useIncrementalFeed: true };\n\n if (typeof this.changeFeedOptions.maxItemCount === \"number\") {\n feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount;\n }\n\n if (this.changeFeedOptions.sessionToken) {\n feedOptions.sessionToken = this.changeFeedOptions.sessionToken;\n }\n\n const continuation = this.continuationToken.Continuation;\n if (continuation) {\n feedOptions.accessCondition = {\n type: Constants.HttpHeaders.IfNoneMatch,\n condition: continuation,\n };\n }\n\n if (this.startTime) {\n feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.startTime;\n }\n\n const response: Response> = await (this.clientContext.queryFeed({\n path: this.resourceLink,\n resourceType: ResourceType.item,\n resourceId: this.resourceId,\n resultFn: (result) => (result ? result.Documents : []),\n diagnosticNode,\n query: undefined,\n options: feedOptions,\n partitionKey: this.partitionKey,\n }) as Promise);\n\n return new ChangeFeedIteratorResponse(\n response.result,\n response.result ? response.result.length : 0,\n response.code,\n response.headers,\n getEmptyCosmosDiagnostics(),\n );\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts new file mode 100644 index 000000000..fe4cb5d83 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts @@ -0,0 +1,21 @@ +import { ChangeFeedStartFrom } from "./ChangeFeedStartFrom"; +/** + * Specifies options for the change feed + * + * If none of those options are set, it will start reading changes from now for the entire container. + */ +export interface ChangeFeedIteratorOptions { + /** + * Max amount of items to return per page + */ + maxItemCount?: number; + /** + * The session token to use. If not specified, will use the most recent captured session token to start with. + */ + sessionToken?: string; + /** + * Signals where to start from in the change feed. + */ + changeFeedStartFrom?: ChangeFeedStartFrom; +} +//# sourceMappingURL=ChangeFeedIteratorOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map new file mode 100644 index 000000000..768e6166f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedIteratorOptions.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedIteratorOptions.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;GAIG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js new file mode 100644 index 000000000..0a78e0b68 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=ChangeFeedIteratorOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js.map new file mode 100644 index 000000000..e56ea2cc7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedIteratorOptions.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedIteratorOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ChangeFeedStartFrom } from \"./ChangeFeedStartFrom\";\n\n/**\n * Specifies options for the change feed\n *\n * If none of those options are set, it will start reading changes from now for the entire container.\n */\nexport interface ChangeFeedIteratorOptions {\n /**\n * Max amount of items to return per page\n */\n maxItemCount?: number;\n /**\n * The session token to use. If not specified, will use the most recent captured session token to start with.\n */\n sessionToken?: string;\n /**\n * Signals where to start from in the change feed.\n */\n changeFeedStartFrom?: ChangeFeedStartFrom;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts new file mode 100644 index 000000000..a7a35aa44 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts @@ -0,0 +1,48 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +export declare class ChangeFeedIteratorResponse { + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + readonly result: T; + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + readonly count: number; + /** + * Gets the status code of the response from Azure Cosmos DB + */ + readonly statusCode: number; + /** + * Cosmos Diagnostic Object. + */ + readonly diagnostics: CosmosDiagnostics; + /** + * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone. + */ + readonly subStatusCode?: number; + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge(): number; + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId(): string; + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + */ + get continuationToken(): string; + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken(): string; + /** + * Response headers of the response from Azure Cosmos DB + */ + headers: CosmosHeaders; +} +//# sourceMappingURL=ChangeFeedIteratorResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts.map new file mode 100644 index 000000000..e1f67ee4b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedIteratorResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedIteratorResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;GAEG;AACH,qBAAa,0BAA0B,CAAC,CAAC;IAKrC;;OAEG;aACa,MAAM,EAAE,CAAC;IACzB;;OAEG;aACa,KAAK,EAAE,MAAM;IAC7B;;OAEG;aACa,UAAU,EAAE,MAAM;IAKlC;;OAEG;aACa,WAAW,EAAE,iBAAiB;IAC9C;;OAEG;aACa,aAAa,CAAC,EAAE,MAAM;IAKxC;;OAEG;IACH,IAAW,aAAa,IAAI,MAAM,CAGjC;IAED;;OAEG;IACH,IAAW,UAAU,IAAI,MAAM,CAE9B;IAED;;OAEG;IACH,IAAW,iBAAiB,IAAI,MAAM,CAErC;IACD;;OAEG;IACH,IAAW,YAAY,IAAI,MAAM,CAEhC;IACD;;OAEG;IACI,OAAO,EAAE,aAAa,CAAC;CAC/B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js new file mode 100644 index 000000000..2204e8d55 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js @@ -0,0 +1,67 @@ +import { Constants } from "../../common"; +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +export class ChangeFeedIteratorResponse { + /** + * @internal + */ + constructor( + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + result, + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + count, + /** + * Gets the status code of the response from Azure Cosmos DB + */ + statusCode, + /** + * Headers related to cosmos DB and change feed. + */ + headers, + /** + * Cosmos Diagnostic Object. + */ + diagnostics, + /** + * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone. + */ + subStatusCode) { + this.result = result; + this.count = count; + this.statusCode = statusCode; + this.diagnostics = diagnostics; + this.subStatusCode = subStatusCode; + this.headers = headers; + } + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge() { + const rus = this.headers[Constants.HttpHeaders.RequestCharge]; + return rus ? parseInt(rus, 10) : null; + } + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId() { + return this.headers[Constants.HttpHeaders.ActivityId]; + } + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + */ + get continuationToken() { + return this.headers[Constants.HttpHeaders.ContinuationToken]; + } + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken() { + return this.headers[Constants.HttpHeaders.SessionToken]; + } +} +//# sourceMappingURL=ChangeFeedIteratorResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js.map new file mode 100644 index 000000000..5150316ed --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedIteratorResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedIteratorResponse.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedIteratorResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC;;GAEG;AACH,MAAM,OAAO,0BAA0B;IACrC;;OAEG;IACH;IACE;;OAEG;IACa,MAAS;IACzB;;OAEG;IACa,KAAa;IAC7B;;OAEG;IACa,UAAkB;IAClC;;OAEG;IACH,OAAsB;IACtB;;OAEG;IACa,WAA8B;IAC9C;;OAEG;IACa,aAAsB;QApBtB,WAAM,GAAN,MAAM,CAAG;QAIT,UAAK,GAAL,KAAK,CAAQ;QAIb,eAAU,GAAV,UAAU,CAAQ;QAQlB,gBAAW,GAAX,WAAW,CAAmB;QAI9B,kBAAa,GAAb,aAAa,CAAS;QAEtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACtB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QAC9D,OAAO,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,IAAW,iBAAiB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;IAC/D,CAAC;IACD;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAC1D,CAAC;CAKF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { Constants } from \"../../common\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\n\n/**\n * A single response page from the Azure Cosmos DB Change Feed\n */\nexport class ChangeFeedIteratorResponse {\n /**\n * @internal\n */\n constructor(\n /**\n * Gets the items returned in the response from Azure Cosmos DB\n */\n public readonly result: T,\n /**\n * Gets the number of items returned in the response from Azure Cosmos DB\n */\n public readonly count: number,\n /**\n * Gets the status code of the response from Azure Cosmos DB\n */\n public readonly statusCode: number,\n /**\n * Headers related to cosmos DB and change feed.\n */\n headers: CosmosHeaders,\n /**\n * Cosmos Diagnostic Object.\n */\n public readonly diagnostics: CosmosDiagnostics,\n /**\n * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone.\n */\n public readonly subStatusCode?: number,\n ) {\n this.headers = headers;\n }\n\n /**\n * Gets the request charge for this request from the Azure Cosmos DB service.\n */\n public get requestCharge(): number {\n const rus = this.headers[Constants.HttpHeaders.RequestCharge];\n return rus ? parseInt(rus, 10) : null;\n }\n\n /**\n * Gets the activity ID for the request from the Azure Cosmos DB service.\n */\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId];\n }\n\n /**\n * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.\n */\n public get continuationToken(): string {\n return this.headers[Constants.HttpHeaders.ContinuationToken];\n }\n /**\n * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.\n */\n public get sessionToken(): string {\n return this.headers[Constants.HttpHeaders.SessionToken];\n }\n /**\n * Response headers of the response from Azure Cosmos DB\n */\n public headers: CosmosHeaders;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts new file mode 100644 index 000000000..3673c414b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts @@ -0,0 +1,27 @@ +import { Resource } from "../Resource"; +import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +/** + * Use `Items.getChangeFeedIterator()` to return an iterator that can iterate over all the changes for a partition key, feed range or an entire container. + */ +export interface ChangeFeedPullModelIterator { + /** + * Always returns true, changefeed is an infinite stream. + */ + readonly hasMoreResults: boolean; + /** + * Returns next set of results for the change feed. + */ + readNext(): Promise>>; + /** + * Gets an async iterator which will yield change feed results. + * @example Get changefeed for an entire container from now + * ```typescript + * const options = { changeFeedStartFrom: ChangeFeedStartFrom.Now() }; + * for await(const res of container.items.getChangeFeedIterator(options).getAsyncIterator()) { + * //process res + * } + * ``` + */ + getAsyncIterator(): AsyncIterable>>; +} +//# sourceMappingURL=ChangeFeedPullModelIterator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts.map new file mode 100644 index 000000000..388d98a70 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedPullModelIterator.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedPullModelIterator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E;;GAEG;AACH,MAAM,WAAW,2BAA2B,CAAC,CAAC;IAC5C;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,QAAQ,IAAI,OAAO,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACrE;;;;;;;;;OASG;IACH,gBAAgB,IAAI,aAAa,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;CACpF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js new file mode 100644 index 000000000..db69a87ee --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ChangeFeedPullModelIterator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js.map new file mode 100644 index 000000000..85dd3f27f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedPullModelIterator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedPullModelIterator.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedPullModelIterator.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Resource } from \"../Resource\";\nimport { ChangeFeedIteratorResponse } from \"./ChangeFeedIteratorResponse\";\n/**\n * Use `Items.getChangeFeedIterator()` to return an iterator that can iterate over all the changes for a partition key, feed range or an entire container.\n */\nexport interface ChangeFeedPullModelIterator {\n /**\n * Always returns true, changefeed is an infinite stream.\n */\n readonly hasMoreResults: boolean;\n /**\n * Returns next set of results for the change feed.\n */\n readNext(): Promise>>;\n /**\n * Gets an async iterator which will yield change feed results.\n * @example Get changefeed for an entire container from now\n * ```typescript\n * const options = { changeFeedStartFrom: ChangeFeedStartFrom.Now() };\n * for await(const res of container.items.getChangeFeedIterator(options).getAsyncIterator()) {\n * //process res\n * }\n * ```\n */\n getAsyncIterator(): AsyncIterable>>;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts new file mode 100644 index 000000000..ad6d6f3da --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ChangeFeedRange.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts.map new file mode 100644 index 000000000..6e5956aef --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedRange.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedRange.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js new file mode 100644 index 000000000..475b4c559 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @internal + * FeedRange for which change feed is being requested. + */ +export class ChangeFeedRange { + constructor(minInclusive, maxExclusive, continuationToken, epkMinHeader, epkMaxHeader) { + this.minInclusive = minInclusive; + this.maxExclusive = maxExclusive; + this.continuationToken = continuationToken; + this.epkMinHeader = epkMinHeader; + this.epkMaxHeader = epkMaxHeader; + } +} +//# sourceMappingURL=ChangeFeedRange.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js.map new file mode 100644 index 000000000..c10d8c508 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedRange.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedRange.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedRange.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AACH,MAAM,OAAO,eAAe;IAsB1B,YACE,YAAoB,EACpB,YAAoB,EACpB,iBAA0B,EAC1B,YAAqB,EACrB,YAAqB;QAErB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * @internal\n * FeedRange for which change feed is being requested.\n */\nexport class ChangeFeedRange {\n /**\n * Min value for the range.\n */\n public minInclusive: string;\n /**\n * Max value for the range.\n */\n public maxExclusive: string;\n /**\n * Continuation token from where to start reading changes.\n */\n public continuationToken?: string;\n /**\n * Min epk value to begin reading changes from in case changefeed of entire partition is not requested.\n */\n public epkMinHeader?: string;\n /**\n * Max epk value to begin reading changes from in case changefeed of entire partition is not requested.\n */\n public epkMaxHeader?: string;\n\n constructor(\n minInclusive: string,\n maxExclusive: string,\n continuationToken?: string,\n epkMinHeader?: string,\n epkMaxHeader?: string,\n ) {\n this.minInclusive = minInclusive;\n this.maxExclusive = maxExclusive;\n this.continuationToken = continuationToken;\n this.epkMinHeader = epkMinHeader;\n this.epkMaxHeader = epkMaxHeader;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts new file mode 100644 index 000000000..215f13d65 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts @@ -0,0 +1,33 @@ +import { PartitionKey } from "../../documents"; +import { FeedRange } from "./FeedRange"; +import { ChangeFeedStartFromNow } from "./ChangeFeedStartFromNow"; +import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning"; +import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime"; +import { ChangeFeedStartFromContinuation } from "./ChangeFeedStartFromContinuation"; +/** + * Base class for where to start a ChangeFeedIterator. + */ +export declare abstract class ChangeFeedStartFrom { + /** + * Returns an object that tells the ChangeFeedIterator to start from the beginning of time. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Beginning(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromBeginning; + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + **/ + static Now(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromNow; + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward. + * @param startTime - Date object specfiying the time to start reading changes from. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Time(startTime: Date, cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromTime; + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point. + * @param continuation - The continuation to resume from. + */ + static Continuation(continuationToken: string): ChangeFeedStartFromContinuation; +} +//# sourceMappingURL=ChangeFeedStartFrom.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts.map new file mode 100644 index 000000000..7344736bd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFrom.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFrom.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAIpF;;GAEG;AAEH,8BAAsB,mBAAmB;IACvC;;;OAGG;WACW,SAAS,CAAC,UAAU,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,4BAA4B;IAG5F;;;QAGI;WACU,GAAG,CAAC,UAAU,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,sBAAsB;IAGhF;;;;OAIG;WACW,IAAI,CAChB,SAAS,EAAE,IAAI,EACf,UAAU,CAAC,EAAE,YAAY,GAAG,SAAS,GACpC,uBAAuB;IAU1B;;;OAGG;WACW,YAAY,CAAC,iBAAiB,EAAE,MAAM,GAAG,+BAA+B;CASvF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js new file mode 100644 index 000000000..3d471ca1e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js @@ -0,0 +1,56 @@ +import { ChangeFeedStartFromNow } from "./ChangeFeedStartFromNow"; +import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning"; +import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime"; +import { ChangeFeedStartFromContinuation } from "./ChangeFeedStartFromContinuation"; +import { ErrorResponse } from "../../request/ErrorResponse"; +import { isNullOrEmpty } from "./changeFeedUtils"; +/** + * Base class for where to start a ChangeFeedIterator. + */ +/* eslint-disable @typescript-eslint/no-extraneous-class */ +export class ChangeFeedStartFrom { + /** + * Returns an object that tells the ChangeFeedIterator to start from the beginning of time. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Beginning(cfResource) { + return new ChangeFeedStartFromBeginning(cfResource); + } + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + **/ + static Now(cfResource) { + return new ChangeFeedStartFromNow(cfResource); + } + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward. + * @param startTime - Date object specfiying the time to start reading changes from. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Time(startTime, cfResource) { + if (!startTime) { + throw new ErrorResponse("startTime must be present"); + } + if (startTime instanceof Date === true) { + return new ChangeFeedStartFromTime(startTime, cfResource); + } + else { + throw new ErrorResponse("startTime must be a Date object."); + } + } + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point. + * @param continuation - The continuation to resume from. + */ + static Continuation(continuationToken) { + if (!continuationToken) { + throw new ErrorResponse("Argument continuation must be passed."); + } + if (isNullOrEmpty(continuationToken)) { + throw new ErrorResponse("Argument continuationToken must be a non-empty string."); + } + return new ChangeFeedStartFromContinuation(continuationToken); + } +} +//# sourceMappingURL=ChangeFeedStartFrom.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js.map new file mode 100644 index 000000000..c1bfff94d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFrom.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFrom.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFrom.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;GAEG;AACH,2DAA2D;AAC3D,MAAM,OAAgB,mBAAmB;IACvC;;;OAGG;IACI,MAAM,CAAC,SAAS,CAAC,UAAqC;QAC3D,OAAO,IAAI,4BAA4B,CAAC,UAAU,CAAC,CAAC;IACtD,CAAC;IACD;;;QAGI;IACG,MAAM,CAAC,GAAG,CAAC,UAAqC;QACrD,OAAO,IAAI,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,IAAI,CAChB,SAAe,EACf,UAAqC;QAErC,IAAI,CAAC,SAAS,EAAE;YACd,MAAM,IAAI,aAAa,CAAC,2BAA2B,CAAC,CAAC;SACtD;QACD,IAAI,SAAS,YAAY,IAAI,KAAK,IAAI,EAAE;YACtC,OAAO,IAAI,uBAAuB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;SAC3D;aAAM;YACL,MAAM,IAAI,aAAa,CAAC,kCAAkC,CAAC,CAAC;SAC7D;IACH,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,YAAY,CAAC,iBAAyB;QAClD,IAAI,CAAC,iBAAiB,EAAE;YACtB,MAAM,IAAI,aAAa,CAAC,uCAAuC,CAAC,CAAC;SAClE;QACD,IAAI,aAAa,CAAC,iBAAiB,CAAC,EAAE;YACpC,MAAM,IAAI,aAAa,CAAC,wDAAwD,CAAC,CAAC;SACnF;QACD,OAAO,IAAI,+BAA+B,CAAC,iBAAiB,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\nimport { ChangeFeedStartFromNow } from \"./ChangeFeedStartFromNow\";\nimport { ChangeFeedStartFromBeginning } from \"./ChangeFeedStartFromBeginning\";\nimport { ChangeFeedStartFromTime } from \"./ChangeFeedStartFromTime\";\nimport { ChangeFeedStartFromContinuation } from \"./ChangeFeedStartFromContinuation\";\nimport { ErrorResponse } from \"../../request/ErrorResponse\";\nimport { isNullOrEmpty } from \"./changeFeedUtils\";\n\n/**\n * Base class for where to start a ChangeFeedIterator.\n */\n/* eslint-disable @typescript-eslint/no-extraneous-class */\nexport abstract class ChangeFeedStartFrom {\n /**\n * Returns an object that tells the ChangeFeedIterator to start from the beginning of time.\n * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.\n */\n public static Beginning(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromBeginning {\n return new ChangeFeedStartFromBeginning(cfResource);\n }\n /**\n * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward.\n * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.\n **/\n public static Now(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromNow {\n return new ChangeFeedStartFromNow(cfResource);\n }\n /**\n * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward.\n * @param startTime - Date object specfiying the time to start reading changes from.\n * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.\n */\n public static Time(\n startTime: Date,\n cfResource?: PartitionKey | FeedRange,\n ): ChangeFeedStartFromTime {\n if (!startTime) {\n throw new ErrorResponse(\"startTime must be present\");\n }\n if (startTime instanceof Date === true) {\n return new ChangeFeedStartFromTime(startTime, cfResource);\n } else {\n throw new ErrorResponse(\"startTime must be a Date object.\");\n }\n }\n /**\n * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point.\n * @param continuation - The continuation to resume from.\n */\n public static Continuation(continuationToken: string): ChangeFeedStartFromContinuation {\n if (!continuationToken) {\n throw new ErrorResponse(\"Argument continuation must be passed.\");\n }\n if (isNullOrEmpty(continuationToken)) {\n throw new ErrorResponse(\"Argument continuationToken must be a non-empty string.\");\n }\n return new ChangeFeedStartFromContinuation(continuationToken);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts new file mode 100644 index 000000000..ea2c2d0c6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts @@ -0,0 +1,12 @@ +import { PartitionKey } from "../../documents"; +import { FeedRange } from "./FeedRange"; +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time. + */ +export declare class ChangeFeedStartFromBeginning { + private cfResource?; + constructor(cfResource?: PartitionKey | FeedRange); + getCfResource(): PartitionKey | FeedRange | undefined; +} +//# sourceMappingURL=ChangeFeedStartFromBeginning.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts.map new file mode 100644 index 000000000..57ebe6909 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromBeginning.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromBeginning.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;GAGG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,UAAU,CAAC,CAA2B;gBAElC,UAAU,CAAC,EAAE,YAAY,GAAG,SAAS;IAI1C,aAAa,IAAI,YAAY,GAAG,SAAS,GAAG,SAAS;CAG7D"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js new file mode 100644 index 000000000..06324aba7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js @@ -0,0 +1,13 @@ +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time. + */ +export class ChangeFeedStartFromBeginning { + constructor(cfResource) { + this.cfResource = cfResource; + } + getCfResource() { + return this.cfResource; + } +} +//# sourceMappingURL=ChangeFeedStartFromBeginning.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map new file mode 100644 index 000000000..eb2291318 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromBeginning.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromBeginning.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromBeginning.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAGvC,YAAY,UAAqC;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\n\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time.\n */\nexport class ChangeFeedStartFromBeginning {\n private cfResource?: PartitionKey | FeedRange;\n\n constructor(cfResource?: PartitionKey | FeedRange) {\n this.cfResource = cfResource;\n }\n\n public getCfResource(): PartitionKey | FeedRange | undefined {\n return this.cfResource;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts new file mode 100644 index 000000000..b98003fb0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts @@ -0,0 +1,12 @@ +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a saved point. + */ +export declare class ChangeFeedStartFromContinuation { + private continuationToken; + constructor(continuation: string); + getCfResource(): string; + getCfResourceJson(): any; + getResourceType(): any; +} +//# sourceMappingURL=ChangeFeedStartFromContinuation.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts.map new file mode 100644 index 000000000..8b0d68b8d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromContinuation.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromContinuation.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,qBAAa,+BAA+B;IAC1C,OAAO,CAAC,iBAAiB,CAAS;gBAEtB,YAAY,EAAE,MAAM;IAIzB,aAAa,IAAI,MAAM;IAGvB,iBAAiB,IAAI,GAAG;IAIxB,eAAe,IAAI,GAAG;CAkB9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js new file mode 100644 index 000000000..edaf1367d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { ErrorResponse } from "../../request"; +import { ChangeFeedResourceType } from "./ChangeFeedEnums"; +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a saved point. + */ +export class ChangeFeedStartFromContinuation { + constructor(continuation) { + this.continuationToken = continuation; + } + getCfResource() { + return this.continuationToken; + } + getCfResourceJson() { + return JSON.parse(this.continuationToken); + } + getResourceType() { + const cToken = this.getCfResourceJson(); + if (Object.prototype.hasOwnProperty.call(cToken, "partitionKey") && + Object.prototype.hasOwnProperty.call(cToken, "Continuation") && + typeof cToken.Continuation === "string") { + return ChangeFeedResourceType.PartitionKey; + } + else if (Object.prototype.hasOwnProperty.call(cToken, "Continuation") && + Array.isArray(cToken.Continuation) && + cToken.Continuation.length > 0) { + return ChangeFeedResourceType.FeedRange; + } + else { + throw new ErrorResponse("Invalid continuation token."); + } + } +} +//# sourceMappingURL=ChangeFeedStartFromContinuation.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map new file mode 100644 index 000000000..50591c992 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromContinuation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromContinuation.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromContinuation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D;;;GAGG;AACH,MAAM,OAAO,+BAA+B;IAG1C,YAAY,YAAoB;QAC9B,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC;IACxC,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IACM,iBAAiB;QACtB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAC5C,CAAC;IAEM,eAAe;QACpB,MAAM,MAAM,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACxC,IACE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC;YAC5D,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC;YAC5D,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,EACvC;YACA,OAAO,sBAAsB,CAAC,YAAY,CAAC;SAC5C;aAAM,IACL,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC;YAC5D,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC;YAClC,MAAM,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAC9B;YACA,OAAO,sBAAsB,CAAC,SAAS,CAAC;SACzC;aAAM;YACL,MAAM,IAAI,aAAa,CAAC,6BAA6B,CAAC,CAAC;SACxD;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ErrorResponse } from \"../../request\";\nimport { ChangeFeedResourceType } from \"./ChangeFeedEnums\";\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from a saved point.\n */\nexport class ChangeFeedStartFromContinuation {\n private continuationToken: string;\n\n constructor(continuation: string) {\n this.continuationToken = continuation;\n }\n\n public getCfResource(): string {\n return this.continuationToken;\n }\n public getCfResourceJson(): any {\n return JSON.parse(this.continuationToken);\n }\n\n public getResourceType(): any {\n const cToken = this.getCfResourceJson();\n if (\n Object.prototype.hasOwnProperty.call(cToken, \"partitionKey\") &&\n Object.prototype.hasOwnProperty.call(cToken, \"Continuation\") &&\n typeof cToken.Continuation === \"string\"\n ) {\n return ChangeFeedResourceType.PartitionKey;\n } else if (\n Object.prototype.hasOwnProperty.call(cToken, \"Continuation\") &&\n Array.isArray(cToken.Continuation) &&\n cToken.Continuation.length > 0\n ) {\n return ChangeFeedResourceType.FeedRange;\n } else {\n throw new ErrorResponse(\"Invalid continuation token.\");\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts new file mode 100644 index 000000000..3abce18f0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts @@ -0,0 +1,12 @@ +import { PartitionKey } from "../../documents"; +import { FeedRange } from "./FeedRange"; +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time. + */ +export declare class ChangeFeedStartFromNow { + cfResource?: PartitionKey | FeedRange; + constructor(cfResource?: PartitionKey | FeedRange); + getCfResource(): PartitionKey | FeedRange | undefined; +} +//# sourceMappingURL=ChangeFeedStartFromNow.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts.map new file mode 100644 index 000000000..1fcd84823 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromNow.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromNow.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC;;;GAGG;AACH,qBAAa,sBAAsB;IAC1B,UAAU,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;gBAEjC,UAAU,CAAC,EAAE,YAAY,GAAG,SAAS;IAI1C,aAAa,IAAI,YAAY,GAAG,SAAS,GAAG,SAAS;CAG7D"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js new file mode 100644 index 000000000..46f5ec18b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time. + */ +export class ChangeFeedStartFromNow { + constructor(cfResource) { + this.cfResource = cfResource; + } + getCfResource() { + return this.cfResource; + } +} +//# sourceMappingURL=ChangeFeedStartFromNow.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js.map new file mode 100644 index 000000000..5dd634970 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromNow.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromNow.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromNow.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAGjC,YAAY,UAAqC;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time.\n */\nexport class ChangeFeedStartFromNow {\n public cfResource?: PartitionKey | FeedRange;\n\n constructor(cfResource?: PartitionKey | FeedRange) {\n this.cfResource = cfResource;\n }\n\n public getCfResource(): PartitionKey | FeedRange | undefined {\n return this.cfResource;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts new file mode 100644 index 000000000..795ff732f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts @@ -0,0 +1,14 @@ +import { PartitionKey } from "../../documents"; +import { FeedRange } from "./FeedRange"; +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time. + */ +export declare class ChangeFeedStartFromTime { + private cfResource?; + private startTime; + constructor(startTime: Date, cfResource?: PartitionKey | FeedRange); + getCfResource(): PartitionKey | FeedRange | undefined; + getStartTime(): Date; +} +//# sourceMappingURL=ChangeFeedStartFromTime.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts.map new file mode 100644 index 000000000..a604d8c5e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromTime.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromTime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC;;;GAGG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,UAAU,CAAC,CAA2B;IAE9C,OAAO,CAAC,SAAS,CAAO;gBAEZ,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,EAAE,YAAY,GAAG,SAAS;IAK3D,aAAa,IAAI,YAAY,GAAG,SAAS,GAAG,SAAS;IAIrD,YAAY,IAAI,IAAI;CAG5B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js new file mode 100644 index 000000000..5b2823307 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js @@ -0,0 +1,17 @@ +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time. + */ +export class ChangeFeedStartFromTime { + constructor(startTime, cfResource) { + this.startTime = startTime; + this.cfResource = cfResource; + } + getCfResource() { + return this.cfResource; + } + getStartTime() { + return this.startTime; + } +} +//# sourceMappingURL=ChangeFeedStartFromTime.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js.map new file mode 100644 index 000000000..19f89d0de --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ChangeFeedStartFromTime.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ChangeFeedStartFromTime.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ChangeFeedStartFromTime.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAKlC,YAAY,SAAe,EAAE,UAAqC;QAChE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEM,YAAY;QACjB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time.\n */\nexport class ChangeFeedStartFromTime {\n private cfResource?: PartitionKey | FeedRange;\n\n private startTime: Date;\n\n constructor(startTime: Date, cfResource?: PartitionKey | FeedRange) {\n this.startTime = startTime;\n this.cfResource = cfResource;\n }\n\n public getCfResource(): PartitionKey | FeedRange | undefined {\n return this.cfResource;\n }\n\n public getStartTime(): Date {\n return this.startTime;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts new file mode 100644 index 000000000..a7d05d2b2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=CompositeContinuationToken.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts.map new file mode 100644 index 000000000..b67f8e7f8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CompositeContinuationToken.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/CompositeContinuationToken.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js new file mode 100644 index 000000000..fe75a8928 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js @@ -0,0 +1,11 @@ +/** + * Continuation token for change feed of entire container, or a specific Epk Range. + * @internal + */ +export class CompositeContinuationToken { + constructor(rid, Continuation) { + this.rid = rid; + this.Continuation = Continuation; + } +} +//# sourceMappingURL=CompositeContinuationToken.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js.map new file mode 100644 index 000000000..96f57353c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/CompositeContinuationToken.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CompositeContinuationToken.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/CompositeContinuationToken.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAO,0BAA0B;IAUrC,YAAY,GAAW,EAAE,YAA+B;QACtD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedRange } from \"./ChangeFeedRange\";\n/**\n * Continuation token for change feed of entire container, or a specific Epk Range.\n * @internal\n */\nexport class CompositeContinuationToken {\n /**\n * rid of the container for which the continuation token is issued.\n */\n public readonly rid: string;\n /**\n * List of Epk Ranges part of the continuation token\n */\n public readonly Continuation: ChangeFeedRange[];\n\n constructor(rid: string, Continuation: ChangeFeedRange[]) {\n this.rid = rid;\n this.Continuation = Continuation;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts new file mode 100644 index 000000000..f46516e59 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ContinuationTokenForPartitionKey.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts.map new file mode 100644 index 000000000..c3d082437 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ContinuationTokenForPartitionKey.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ContinuationTokenForPartitionKey.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js new file mode 100644 index 000000000..66815e82d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js @@ -0,0 +1,12 @@ +/** + * Continuation token for change feed of entire container, or a specific Epk Range. + * @internal + */ +export class ContinuationTokenForPartitionKey { + constructor(rid, partitionKey, continuation) { + this.rid = rid; + this.partitionKey = partitionKey; + this.Continuation = continuation; + } +} +//# sourceMappingURL=ContinuationTokenForPartitionKey.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map new file mode 100644 index 000000000..136ecc270 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/ContinuationTokenForPartitionKey.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ContinuationTokenForPartitionKey.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/ContinuationTokenForPartitionKey.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,OAAO,gCAAgC;IAc3C,YAAY,GAAW,EAAE,YAA0B,EAAE,YAAoB;QACvE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\n/**\n * Continuation token for change feed of entire container, or a specific Epk Range.\n * @internal\n */\nexport class ContinuationTokenForPartitionKey {\n /**\n * rid of the container for which the continuation token is issued.\n */\n public readonly rid: string;\n /**\n * A specific Partition key in the container for which the continuation token is issued.\n */\n public readonly partitionKey: PartitionKey;\n /**\n * Continuation value for the specific Partition key in the container.\n */\n public Continuation: string;\n\n constructor(rid: string, partitionKey: PartitionKey, continuation: string) {\n this.rid = rid;\n this.partitionKey = partitionKey;\n this.Continuation = continuation;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts new file mode 100644 index 000000000..3cb75292e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts @@ -0,0 +1,21 @@ +/** + * Specifies a feed range for the changefeed. + */ +export declare abstract class FeedRange { + /** + * Min value for the feed range. + */ + readonly minInclusive: string; + /** + * Max value for the feed range. + */ + readonly maxExclusive: string; +} +/** + * @hidden + * Specifies a feed range for the changefeed. + */ +export declare class FeedRangeInternal extends FeedRange { + constructor(minInclusive: string, maxExclusive: string); +} +//# sourceMappingURL=FeedRange.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts.map new file mode 100644 index 000000000..dcec002ee --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedRange.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/FeedRange.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,8BAAsB,SAAS;IAC7B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAa/B;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;gBAElC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAGvD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js new file mode 100644 index 000000000..ecfcdf3c6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { ErrorResponse } from "../../request"; +/** + * Specifies a feed range for the changefeed. + */ +export class FeedRange { + /** + * @internal + */ + constructor(minInclusive, maxExclusive) { + // only way to explictly block users from creating FeedRange directly in JS + if (new.target === FeedRange) { + throw new ErrorResponse("Cannot instantiate abstract class FeedRange"); + } + this.minInclusive = minInclusive; + this.maxExclusive = maxExclusive; + } +} +/** + * @hidden + * Specifies a feed range for the changefeed. + */ +export class FeedRangeInternal extends FeedRange { + /* eslint-disable @typescript-eslint/no-useless-constructor */ + constructor(minInclusive, maxExclusive) { + super(minInclusive, maxExclusive); + } +} +//# sourceMappingURL=FeedRange.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js.map new file mode 100644 index 000000000..0864ad774 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRange.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedRange.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/FeedRange.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAgB,SAAS;IAS7B;;OAEG;IACH,YAAsB,YAAoB,EAAE,YAAoB;QAC9D,2EAA2E;QAC3E,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,EAAE;YAC5B,MAAM,IAAI,aAAa,CAAC,6CAA6C,CAAC,CAAC;SACxE;QAED,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,8DAA8D;IAC9D,YAAY,YAAoB,EAAE,YAAoB;QACpD,KAAK,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IACpC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ErrorResponse } from \"../../request\";\n\n/**\n * Specifies a feed range for the changefeed.\n */\nexport abstract class FeedRange {\n /**\n * Min value for the feed range.\n */\n readonly minInclusive: string;\n /**\n * Max value for the feed range.\n */\n readonly maxExclusive: string;\n /**\n * @internal\n */\n protected constructor(minInclusive: string, maxExclusive: string) {\n // only way to explictly block users from creating FeedRange directly in JS\n if (new.target === FeedRange) {\n throw new ErrorResponse(\"Cannot instantiate abstract class FeedRange\");\n }\n\n this.minInclusive = minInclusive;\n this.maxExclusive = maxExclusive;\n }\n}\n\n/**\n * @hidden\n * Specifies a feed range for the changefeed.\n */\nexport class FeedRangeInternal extends FeedRange {\n /* eslint-disable @typescript-eslint/no-useless-constructor */\n constructor(minInclusive: string, maxExclusive: string) {\n super(minInclusive, maxExclusive);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts new file mode 100644 index 000000000..7db5a50ae --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts @@ -0,0 +1,20 @@ +import { ChangeFeedRange } from "./ChangeFeedRange"; +/** + * @hidden + * A queue for iterating over specified Epk ranges and fetch change feed for the given epk ranges. + */ +export declare class FeedRangeQueue { + private elements; + constructor(); + modifyFirstElement(newItem: ChangeFeedRange): void; + enqueue(item: ChangeFeedRange): void; + dequeue(): ChangeFeedRange; + peek(): T | ChangeFeedRange; + isEmpty(): boolean; + moveFirstElementToTheEnd(): void; + /** + * Returns a snapshot of the queue as an array to be used as Continuation token. + */ + returnSnapshot(): ChangeFeedRange[]; +} +//# sourceMappingURL=FeedRangeQueue.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts.map new file mode 100644 index 000000000..42651a1e1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedRangeQueue.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/FeedRangeQueue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD;;;GAGG;AACH,qBAAa,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,QAAQ,CAAoB;;IAM7B,kBAAkB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAMlD,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,IAAI;IAIpC,OAAO,IAAI,eAAe;IAI1B,IAAI,IAAI,CAAC,GAAG,eAAe;IAI3B,OAAO,IAAI,OAAO;IAIlB,wBAAwB,IAAI,IAAI;IAKvC;;OAEG;IACI,cAAc,IAAI,eAAe,EAAE;CAc3C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js new file mode 100644 index 000000000..736e4bb81 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { ChangeFeedRange } from "./ChangeFeedRange"; +/** + * @hidden + * A queue for iterating over specified Epk ranges and fetch change feed for the given epk ranges. + */ +export class FeedRangeQueue { + constructor() { + this.elements = []; + } + modifyFirstElement(newItem) { + if (!this.isEmpty()) { + this.elements[0] = newItem; + } + } + enqueue(item) { + this.elements.push(item); + } + dequeue() { + return this.elements.shift(); + } + peek() { + return !this.isEmpty() ? this.elements[0] : undefined; + } + isEmpty() { + return this.elements.length === 0; + } + moveFirstElementToTheEnd() { + if (!this.isEmpty()) { + this.elements.push(this.dequeue()); + } + } + /** + * Returns a snapshot of the queue as an array to be used as Continuation token. + */ + returnSnapshot() { + const allFeedRanges = []; + this.elements.map((element) => { + const minInclusive = element.epkMinHeader ? element.epkMinHeader : element.minInclusive; + const maxExclusive = element.epkMaxHeader ? element.epkMaxHeader : element.maxExclusive; + const feedRangeElement = new ChangeFeedRange(minInclusive, maxExclusive, element.continuationToken); + allFeedRanges.push(feedRangeElement); + }); + return allFeedRanges; + } +} +//# sourceMappingURL=FeedRangeQueue.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js.map new file mode 100644 index 000000000..eda492f8e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/FeedRangeQueue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedRangeQueue.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/FeedRangeQueue.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD;;;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AC1C,YAAY,EACZ,YAAY,EACZ,OAAO,CAAC,iBAAiB,CAC1B,CAAC;YACF,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;QACH,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedRange } from \"./ChangeFeedRange\";\n/**\n * @hidden\n * A queue for iterating over specified Epk ranges and fetch change feed for the given epk ranges.\n */\nexport class FeedRangeQueue {\n private elements: ChangeFeedRange[];\n\n constructor() {\n this.elements = [];\n }\n\n public modifyFirstElement(newItem: ChangeFeedRange): void {\n if (!this.isEmpty()) {\n this.elements[0] = newItem;\n }\n }\n\n public enqueue(item: ChangeFeedRange): void {\n this.elements.push(item);\n }\n\n public dequeue(): ChangeFeedRange {\n return this.elements.shift();\n }\n\n public peek(): T | ChangeFeedRange {\n return !this.isEmpty() ? this.elements[0] : undefined;\n }\n\n public isEmpty(): boolean {\n return this.elements.length === 0;\n }\n\n public moveFirstElementToTheEnd(): void {\n if (!this.isEmpty()) {\n this.elements.push(this.dequeue());\n }\n }\n /**\n * Returns a snapshot of the queue as an array to be used as Continuation token.\n */\n public returnSnapshot(): ChangeFeedRange[] {\n const allFeedRanges: ChangeFeedRange[] = [];\n this.elements.map((element) => {\n const minInclusive = element.epkMinHeader ? element.epkMinHeader : element.minInclusive;\n const maxExclusive = element.epkMaxHeader ? element.epkMaxHeader : element.maxExclusive;\n const feedRangeElement = new ChangeFeedRange(\n minInclusive,\n maxExclusive,\n element.continuationToken,\n );\n allFeedRanges.push(feedRangeElement);\n });\n return allFeedRanges;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts new file mode 100644 index 000000000..b918c7b0f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts @@ -0,0 +1,11 @@ +/** + * @hidden + * Internal Change Feed Iterator Options used only by ChangeFeedForEpkRange and ChangeFeedForPartitionKey. + */ +export interface InternalChangeFeedIteratorOptions { + maxItemCount?: number; + sessionToken?: string; + continuationToken?: string; + startTime?: Date; +} +//# sourceMappingURL=InternalChangeFeedOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map new file mode 100644 index 000000000..7e2ed4651 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"InternalChangeFeedOptions.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/InternalChangeFeedOptions.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,iCAAiC;IAChD,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js new file mode 100644 index 000000000..98ac059dc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=InternalChangeFeedOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js.map new file mode 100644 index 000000000..000dead34 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/InternalChangeFeedOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"InternalChangeFeedOptions.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/InternalChangeFeedOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @hidden\n * Internal Change Feed Iterator Options used only by ChangeFeedForEpkRange and ChangeFeedForPartitionKey.\n */\nexport interface InternalChangeFeedIteratorOptions {\n maxItemCount?: number;\n\n sessionToken?: string;\n\n continuationToken?: string;\n\n startTime?: Date;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts new file mode 100644 index 000000000..e1c6230e8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts @@ -0,0 +1,6 @@ +import { ClientContext } from "../../ClientContext"; +import { PartitionKeyRangeCache } from "../../routing"; +import { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions"; +import { Container } from "../Container"; +export declare function changeFeedIteratorBuilder(cfOptions: ChangeFeedIteratorOptions, clientContext: ClientContext, container: Container, partitionKeyRangeCache: PartitionKeyRangeCache): any; +//# sourceMappingURL=changeFeedIteratorBuilder.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts.map new file mode 100644 index 000000000..eadb8c513 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"changeFeedIteratorBuilder.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/changeFeedIteratorBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAc,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAaxE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,yBAAyB,EACpC,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,sBAAsB,EAAE,sBAAsB,GAC7C,GAAG,CA+FL"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js new file mode 100644 index 000000000..dec57d9c4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js @@ -0,0 +1,64 @@ +import { QueryRange } from "../../routing"; +import { ChangeFeedStartFrom } from "./ChangeFeedStartFrom"; +import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning"; +import { ChangeFeedStartFromContinuation } from "./ChangeFeedStartFromContinuation"; +import { ChangeFeedStartFromNow } from "./ChangeFeedStartFromNow"; +import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime"; +import { ChangeFeedResourceType } from "./ChangeFeedEnums"; +import { ChangeFeedForPartitionKey } from "./ChangeFeedForPartitionKey"; +import { ErrorResponse } from "../../request"; +import { ChangeFeedForEpkRange } from "./ChangeFeedForEpkRange"; +import { getIdFromLink, getPathFromLink, ResourceType, Constants } from "../../common"; +import { buildInternalChangeFeedOptions, fetchStartTime, isEpkRange } from "./changeFeedUtils"; +import { isPartitionKey } from "../../utils/typeChecks"; +export function changeFeedIteratorBuilder(cfOptions, clientContext, container, partitionKeyRangeCache) { + const url = container.url; + const path = getPathFromLink(url, ResourceType.item); + const id = getIdFromLink(url); + let changeFeedStartFrom = cfOptions.changeFeedStartFrom; + if (changeFeedStartFrom === undefined) { + changeFeedStartFrom = ChangeFeedStartFrom.Now(); + } + if (changeFeedStartFrom instanceof ChangeFeedStartFromContinuation) { + const continuationToken = changeFeedStartFrom.getCfResourceJson(); + const resourceType = changeFeedStartFrom.getResourceType(); + const internalCfOptions = buildInternalChangeFeedOptions(cfOptions, changeFeedStartFrom.getCfResource()); + if (resourceType === ChangeFeedResourceType.PartitionKey && + isPartitionKey(continuationToken.partitionKey)) { + return new ChangeFeedForPartitionKey(clientContext, container, id, path, continuationToken.partitionKey, internalCfOptions); + } + else if (resourceType === ChangeFeedResourceType.FeedRange) { + return new ChangeFeedForEpkRange(clientContext, container, partitionKeyRangeCache, id, path, url, internalCfOptions, undefined); + } + else { + throw new ErrorResponse("Invalid continuation token."); + } + } + else if (changeFeedStartFrom instanceof ChangeFeedStartFromNow || + changeFeedStartFrom instanceof ChangeFeedStartFromTime || + changeFeedStartFrom instanceof ChangeFeedStartFromBeginning) { + const startTime = fetchStartTime(changeFeedStartFrom); + const internalCfOptions = buildInternalChangeFeedOptions(cfOptions, undefined, startTime); + const cfResource = changeFeedStartFrom.getCfResource(); + if (isPartitionKey(cfResource)) { + return new ChangeFeedForPartitionKey(clientContext, container, id, path, cfResource, internalCfOptions); + } + else { + let internalCfResource; + if (cfResource === undefined) { + internalCfResource = new QueryRange(Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey, Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey, true, false); + } + else if (isEpkRange(cfResource)) { + internalCfResource = new QueryRange(cfResource.minInclusive, cfResource.maxExclusive, true, false); + } + else { + throw new ErrorResponse("Invalid feed range."); + } + return new ChangeFeedForEpkRange(clientContext, container, partitionKeyRangeCache, id, path, url, internalCfOptions, internalCfResource); + } + } + else { + throw new ErrorResponse("Invalid change feed start location."); + } +} +//# sourceMappingURL=changeFeedIteratorBuilder.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js.map new file mode 100644 index 000000000..ce448049a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedIteratorBuilder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"changeFeedIteratorBuilder.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/changeFeedIteratorBuilder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAA0B,MAAM,eAAe,CAAC;AAEnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EAAE,8BAA8B,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;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;QACrD,mBAAmB,YAAY,uBAAuB;QACtD,mBAAmB,YAAY,4BAA4B,EAC3D;QACA,MAAM,SAAS,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAAC;QACtD,MAAM,iBAAiB,GAAG,8BAA8B,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAC1F,MAAM,UAAU,GAAG,mBAAmB,CAAC,aAAa,EAAE,CAAC;QACvD,IAAI,cAAc,CAAC,UAAU,CAAC,EAAE;YAC9B,OAAO,IAAI,yBAAyB,CAClC,aAAa,EACb,SAAS,EACT,EAAE,EACF,IAAI,EACJ,UAA0B,EAC1B,iBAAiB,CAClB,CAAC;SACH;aAAM;YACL,IAAI,kBAA8B,CAAC;YACnC,IAAI,UAAU,KAAK,SAAS,EAAE;gBAC5B,kBAAkB,GAAG,IAAI,UAAU,CACjC,SAAS,CAAC,8BAA8B,CAAC,qCAAqC,EAC9E,SAAS,CAAC,8BAA8B,CAAC,qCAAqC,EAC9E,IAAI,EACJ,KAAK,CACN,CAAC;aACH;iBAAM,IAAI,UAAU,CAAC,UAAU,CAAC,EAAE;gBACjC,kBAAkB,GAAG,IAAI,UAAU,CAChC,UAAgC,CAAC,YAAY,EAC7C,UAAgC,CAAC,YAAY,EAC9C,IAAI,EACJ,KAAK,CACN,CAAC;aACH;iBAAM;gBACL,MAAM,IAAI,aAAa,CAAC,qBAAqB,CAAC,CAAC;aAChD;YACD,OAAO,IAAI,qBAAqB,CAC9B,aAAa,EACb,SAAS,EACT,sBAAsB,EACtB,EAAE,EACF,IAAI,EACJ,GAAG,EACH,iBAAiB,EACjB,kBAAkB,CACnB,CAAC;SACH;KACF;SAAM;QACL,MAAM,IAAI,aAAa,CAAC,qCAAqC,CAAC,CAAC;KAChE;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { PartitionKey } from \"../../documents\";\nimport { QueryRange, PartitionKeyRangeCache } from \"../../routing\";\nimport { ChangeFeedIteratorOptions } from \"./ChangeFeedIteratorOptions\";\nimport { ChangeFeedStartFrom } from \"./ChangeFeedStartFrom\";\nimport { ChangeFeedStartFromBeginning } from \"./ChangeFeedStartFromBeginning\";\nimport { ChangeFeedStartFromContinuation } from \"./ChangeFeedStartFromContinuation\";\nimport { ChangeFeedStartFromNow } from \"./ChangeFeedStartFromNow\";\nimport { ChangeFeedStartFromTime } from \"./ChangeFeedStartFromTime\";\nimport { ChangeFeedResourceType } from \"./ChangeFeedEnums\";\nimport { ChangeFeedForPartitionKey } from \"./ChangeFeedForPartitionKey\";\nimport { ErrorResponse } from \"../../request\";\nimport { ChangeFeedForEpkRange } from \"./ChangeFeedForEpkRange\";\nimport { getIdFromLink, getPathFromLink, ResourceType, Constants } from \"../../common\";\nimport { buildInternalChangeFeedOptions, fetchStartTime, isEpkRange } from \"./changeFeedUtils\";\nimport { isPartitionKey } from \"../../utils/typeChecks\";\nimport { Container } from \"../Container\";\nimport { FeedRangeInternal } from \"./FeedRange\";\n\nexport function changeFeedIteratorBuilder(\n cfOptions: ChangeFeedIteratorOptions,\n clientContext: ClientContext,\n container: Container,\n partitionKeyRangeCache: PartitionKeyRangeCache,\n): any {\n const url = container.url;\n const path = getPathFromLink(url, ResourceType.item);\n const id = getIdFromLink(url);\n\n let changeFeedStartFrom = cfOptions.changeFeedStartFrom;\n\n if (changeFeedStartFrom === undefined) {\n changeFeedStartFrom = ChangeFeedStartFrom.Now();\n }\n\n if (changeFeedStartFrom instanceof ChangeFeedStartFromContinuation) {\n const continuationToken = changeFeedStartFrom.getCfResourceJson();\n const resourceType = changeFeedStartFrom.getResourceType();\n const internalCfOptions = buildInternalChangeFeedOptions(\n cfOptions,\n changeFeedStartFrom.getCfResource(),\n );\n\n if (\n resourceType === ChangeFeedResourceType.PartitionKey &&\n isPartitionKey(continuationToken.partitionKey)\n ) {\n return new ChangeFeedForPartitionKey(\n clientContext,\n container,\n id,\n path,\n continuationToken.partitionKey,\n internalCfOptions,\n );\n } else if (resourceType === ChangeFeedResourceType.FeedRange) {\n return new ChangeFeedForEpkRange(\n clientContext,\n container,\n partitionKeyRangeCache,\n id,\n path,\n url,\n internalCfOptions,\n undefined,\n );\n } else {\n throw new ErrorResponse(\"Invalid continuation token.\");\n }\n } else if (\n changeFeedStartFrom instanceof ChangeFeedStartFromNow ||\n changeFeedStartFrom instanceof ChangeFeedStartFromTime ||\n changeFeedStartFrom instanceof ChangeFeedStartFromBeginning\n ) {\n const startTime = fetchStartTime(changeFeedStartFrom);\n const internalCfOptions = buildInternalChangeFeedOptions(cfOptions, undefined, startTime);\n const cfResource = changeFeedStartFrom.getCfResource();\n if (isPartitionKey(cfResource)) {\n return new ChangeFeedForPartitionKey(\n clientContext,\n container,\n id,\n path,\n cfResource as PartitionKey,\n internalCfOptions,\n );\n } else {\n let internalCfResource: QueryRange;\n if (cfResource === undefined) {\n internalCfResource = new QueryRange(\n Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey,\n Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey,\n true,\n false,\n );\n } else if (isEpkRange(cfResource)) {\n internalCfResource = new QueryRange(\n (cfResource as FeedRangeInternal).minInclusive,\n (cfResource as FeedRangeInternal).maxExclusive,\n true,\n false,\n );\n } else {\n throw new ErrorResponse(\"Invalid feed range.\");\n }\n return new ChangeFeedForEpkRange(\n clientContext,\n container,\n partitionKeyRangeCache,\n id,\n path,\n url,\n internalCfOptions,\n internalCfResource,\n );\n }\n } else {\n throw new ErrorResponse(\"Invalid change feed start location.\");\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts new file mode 100644 index 000000000..cb252f6e0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts @@ -0,0 +1,35 @@ +import { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions"; +import { PartitionKeyRange } from "../Container"; +import { InternalChangeFeedIteratorOptions } from "./InternalChangeFeedOptions"; +import { ChangeFeedStartFrom } from "./ChangeFeedStartFrom"; +import { QueryRange } from "../../routing"; +/** + * @hidden + * Validates the change feed options passed by the user + */ +export declare function validateChangeFeedIteratorOptions(options: ChangeFeedIteratorOptions): void; +/** + * @hidden + * Checks if pkRange entirely covers the given overLapping range or there is only partial overlap. + * + * If no complete overlap, exact range which overlaps is retured which is used to set minEpk and maxEpk headers while quering change feed. + */ +export declare function extractOverlappingRanges(epkRange: QueryRange, overLappingRange: PartitionKeyRange): Promise<[string, string]>; +/** + * @hidden + * Checks if the object is a valid EpkRange + */ +export declare function isEpkRange(obj: unknown): boolean; +/** + * @hidden + */ +export declare function buildInternalChangeFeedOptions(options: ChangeFeedIteratorOptions, continuationToken?: string, startTime?: Date): InternalChangeFeedIteratorOptions; +/** + * @hidden + */ +export declare function fetchStartTime(changeFeedStartFrom: ChangeFeedStartFrom): Date | undefined; +/** + * @hidden + */ +export declare function isNullOrEmpty(text: string | null | undefined): boolean; +//# sourceMappingURL=changeFeedUtils.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts.map new file mode 100644 index 000000000..1df6d39b5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"changeFeedUtils.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/changeFeedUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,iCAAiC,EAAE,MAAM,6BAA6B,CAAC;AAEhF,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAK5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,OAAO,EAAE,yBAAyB,GAAG,IAAI,CAU1F;AAYD;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,UAAU,EACpB,gBAAgB,EAAE,iBAAiB,GAClC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAwB3B;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAWhD;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,yBAAyB,EAClC,iBAAiB,CAAC,EAAE,MAAM,EAC1B,SAAS,CAAC,EAAE,IAAI,GACf,iCAAiC,CASnC;AACD;;GAEG;AACH,wBAAgB,cAAc,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,IAAI,GAAG,SAAS,CAQzF;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAEtE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js new file mode 100644 index 000000000..5b6bfd1d8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js @@ -0,0 +1,104 @@ +import { ErrorResponse } from "../../request"; +import { isPrimitivePartitionKeyValue } from "../../utils/typeChecks"; +import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning"; +import { ChangeFeedStartFromNow } from "./ChangeFeedStartFromNow"; +import { Constants } from "../../common"; +import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime"; +import { FeedRangeInternal } from "./FeedRange"; +/** + * @hidden + * Validates the change feed options passed by the user + */ +export function validateChangeFeedIteratorOptions(options) { + if (!isChangeFeedIteratorOptions(options)) { + throw new ErrorResponse("Invalid Changefeed Iterator Options."); + } + if ((options === null || options === void 0 ? void 0 : options.maxItemCount) && typeof (options === null || options === void 0 ? void 0 : options.maxItemCount) !== "number") { + throw new ErrorResponse("maxItemCount must be number"); + } + if ((options === null || options === void 0 ? void 0 : options.maxItemCount) !== undefined && (options === null || options === void 0 ? void 0 : options.maxItemCount) < 1) { + throw new ErrorResponse("maxItemCount must be a positive number"); + } +} +function isChangeFeedIteratorOptions(options) { + if (typeof options !== "object") { + return false; + } + if (Object.keys(options).length === 0 && JSON.stringify(options) === "{}") { + return true; + } + return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options)); +} +/** + * @hidden + * Checks if pkRange entirely covers the given overLapping range or there is only partial overlap. + * + * If no complete overlap, exact range which overlaps is retured which is used to set minEpk and maxEpk headers while quering change feed. + */ +export async function extractOverlappingRanges(epkRange, overLappingRange) { + if (overLappingRange.minInclusive >= epkRange.min && + overLappingRange.maxExclusive <= epkRange.max) { + return [undefined, undefined]; + } + else if (overLappingRange.minInclusive <= epkRange.min && + overLappingRange.maxExclusive >= epkRange.max) { + return [epkRange.min, epkRange.max]; + } + // Right Side of overlapping range is covered + else if (overLappingRange.minInclusive <= epkRange.min && + overLappingRange.maxExclusive <= epkRange.max && + overLappingRange.maxExclusive >= epkRange.min) { + return [epkRange.min, overLappingRange.maxExclusive]; + } + // Left Side of overlapping range is covered + else { + return [overLappingRange.minInclusive, epkRange.max]; + } +} +/** + * @hidden + * Checks if the object is a valid EpkRange + */ +export function isEpkRange(obj) { + return (obj instanceof FeedRangeInternal && + typeof obj.minInclusive === "string" && + typeof obj.maxExclusive === "string" && + obj.minInclusive >= + Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey && + obj.maxExclusive <= + Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey && + obj.maxExclusive > obj.minInclusive); +} +/** + * @hidden + */ +export function buildInternalChangeFeedOptions(options, continuationToken, startTime) { + const internalCfOptions = {}; + internalCfOptions.maxItemCount = options === null || options === void 0 ? void 0 : options.maxItemCount; + internalCfOptions.sessionToken = options === null || options === void 0 ? void 0 : options.sessionToken; + internalCfOptions.continuationToken = continuationToken; + // Default option of changefeed is to start from now. + internalCfOptions.startTime = startTime; + return internalCfOptions; +} +/** + * @hidden + */ +export function fetchStartTime(changeFeedStartFrom) { + if (changeFeedStartFrom instanceof ChangeFeedStartFromBeginning) { + return undefined; + } + else if (changeFeedStartFrom instanceof ChangeFeedStartFromNow) { + return new Date(); + } + else if (changeFeedStartFrom instanceof ChangeFeedStartFromTime) { + return changeFeedStartFrom.getStartTime(); + } +} +/** + * @hidden + */ +export function isNullOrEmpty(text) { + return text === null || text === undefined || text.trim() === ""; +} +//# sourceMappingURL=changeFeedUtils.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js.map new file mode 100644 index 000000000..05b65c2a5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/changeFeedUtils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"changeFeedUtils.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/changeFeedUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2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AAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC;IACvD,iBAAiB,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAExD,qDAAqD;IACrD,iBAAiB,CAAC,SAAS,GAAG,SAAS,CAAC;IACxC,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AACD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,mBAAwC;IACrE,IAAI,mBAAmB,YAAY,4BAA4B,EAAE;QAC/D,OAAO,SAAS,CAAC;KAClB;SAAM,IAAI,mBAAmB,YAAY,sBAAsB,EAAE;QAChE,OAAO,IAAI,IAAI,EAAE,CAAC;KACnB;SAAM,IAAI,mBAAmB,YAAY,uBAAuB,EAAE;QACjE,OAAO,mBAAmB,CAAC,YAAY,EAAE,CAAC;KAC3C;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAA+B;IAC3D,OAAO,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AACnE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedIteratorOptions } from \"./ChangeFeedIteratorOptions\";\nimport { ErrorResponse } from \"../../request\";\nimport { PartitionKeyRange } from \"../Container\";\nimport { InternalChangeFeedIteratorOptions } from \"./InternalChangeFeedOptions\";\nimport { isPrimitivePartitionKeyValue } from \"../../utils/typeChecks\";\nimport { ChangeFeedStartFrom } from \"./ChangeFeedStartFrom\";\nimport { ChangeFeedStartFromBeginning } from \"./ChangeFeedStartFromBeginning\";\nimport { ChangeFeedStartFromNow } from \"./ChangeFeedStartFromNow\";\nimport { Constants } from \"../../common\";\nimport { ChangeFeedStartFromTime } from \"./ChangeFeedStartFromTime\";\nimport { QueryRange } from \"../../routing\";\nimport { FeedRangeInternal } from \"./FeedRange\";\n\n/**\n * @hidden\n * Validates the change feed options passed by the user\n */\nexport function validateChangeFeedIteratorOptions(options: ChangeFeedIteratorOptions): void {\n if (!isChangeFeedIteratorOptions(options)) {\n throw new ErrorResponse(\"Invalid Changefeed Iterator Options.\");\n }\n if (options?.maxItemCount && typeof options?.maxItemCount !== \"number\") {\n throw new ErrorResponse(\"maxItemCount must be number\");\n }\n if (options?.maxItemCount !== undefined && options?.maxItemCount < 1) {\n throw new ErrorResponse(\"maxItemCount must be a positive number\");\n }\n}\n\nfunction isChangeFeedIteratorOptions(options: unknown): options is ChangeFeedIteratorOptions {\n if (typeof options !== \"object\") {\n return false;\n }\n if (Object.keys(options).length === 0 && JSON.stringify(options) === \"{}\") {\n return true;\n }\n return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options));\n}\n\n/**\n * @hidden\n * Checks if pkRange entirely covers the given overLapping range or there is only partial overlap.\n *\n * If no complete overlap, exact range which overlaps is retured which is used to set minEpk and maxEpk headers while quering change feed.\n */\nexport async function extractOverlappingRanges(\n epkRange: QueryRange,\n overLappingRange: PartitionKeyRange,\n): Promise<[string, string]> {\n if (\n overLappingRange.minInclusive >= epkRange.min &&\n overLappingRange.maxExclusive <= epkRange.max\n ) {\n return [undefined, undefined];\n } else if (\n overLappingRange.minInclusive <= epkRange.min &&\n overLappingRange.maxExclusive >= epkRange.max\n ) {\n return [epkRange.min, epkRange.max];\n }\n // Right Side of overlapping range is covered\n else if (\n overLappingRange.minInclusive <= epkRange.min &&\n overLappingRange.maxExclusive <= epkRange.max &&\n overLappingRange.maxExclusive >= epkRange.min\n ) {\n return [epkRange.min, overLappingRange.maxExclusive];\n }\n // Left Side of overlapping range is covered\n else {\n return [overLappingRange.minInclusive, epkRange.max];\n }\n}\n\n/**\n * @hidden\n * Checks if the object is a valid EpkRange\n */\nexport function isEpkRange(obj: unknown): boolean {\n return (\n obj instanceof FeedRangeInternal &&\n typeof obj.minInclusive === \"string\" &&\n typeof obj.maxExclusive === \"string\" &&\n obj.minInclusive >=\n Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey &&\n obj.maxExclusive <=\n Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey &&\n obj.maxExclusive > obj.minInclusive\n );\n}\n\n/**\n * @hidden\n */\nexport function buildInternalChangeFeedOptions(\n options: ChangeFeedIteratorOptions,\n continuationToken?: string,\n startTime?: Date,\n): InternalChangeFeedIteratorOptions {\n const internalCfOptions = {} as InternalChangeFeedIteratorOptions;\n internalCfOptions.maxItemCount = options?.maxItemCount;\n internalCfOptions.sessionToken = options?.sessionToken;\n internalCfOptions.continuationToken = continuationToken;\n\n // Default option of changefeed is to start from now.\n internalCfOptions.startTime = startTime;\n return internalCfOptions;\n}\n/**\n * @hidden\n */\nexport function fetchStartTime(changeFeedStartFrom: ChangeFeedStartFrom): Date | undefined {\n if (changeFeedStartFrom instanceof ChangeFeedStartFromBeginning) {\n return undefined;\n } else if (changeFeedStartFrom instanceof ChangeFeedStartFromNow) {\n return new Date();\n } else if (changeFeedStartFrom instanceof ChangeFeedStartFromTime) {\n return changeFeedStartFrom.getStartTime();\n }\n}\n\n/**\n * @hidden\n */\nexport function isNullOrEmpty(text: string | null | undefined): boolean {\n return text === null || text === undefined || text.trim() === \"\";\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts new file mode 100644 index 000000000..30f0bdd50 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts @@ -0,0 +1,10 @@ +export { ChangeFeedForEpkRange } from "./ChangeFeedForEpkRange"; +export { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions"; +export { ChangeFeedForPartitionKey } from "./ChangeFeedForPartitionKey"; +export { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +export { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator"; +export { FeedRangeInternal, FeedRange } from "./FeedRange"; +export { ChangeFeedStartFrom } from "./ChangeFeedStartFrom"; +export { buildInternalChangeFeedOptions } from "./changeFeedUtils"; +export { changeFeedIteratorBuilder } from "./changeFeedIteratorBuilder"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts.map new file mode 100644 index 000000000..1fd166329 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js new file mode 100644 index 000000000..6b033ec2e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { ChangeFeedForEpkRange } from "./ChangeFeedForEpkRange"; +export { ChangeFeedForPartitionKey } from "./ChangeFeedForPartitionKey"; +export { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +export { FeedRangeInternal, FeedRange } from "./FeedRange"; +export { ChangeFeedStartFrom } from "./ChangeFeedStartFrom"; +export { buildInternalChangeFeedOptions } from "./changeFeedUtils"; +export { changeFeedIteratorBuilder } from "./changeFeedIteratorBuilder"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js.map new file mode 100644 index 000000000..5cf14e4c0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ChangeFeed/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/ChangeFeed/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,8BAA8B,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { ChangeFeedForEpkRange } from \"./ChangeFeedForEpkRange\";\nexport { ChangeFeedIteratorOptions } from \"./ChangeFeedIteratorOptions\";\nexport { ChangeFeedForPartitionKey } from \"./ChangeFeedForPartitionKey\";\nexport { ChangeFeedIteratorResponse } from \"./ChangeFeedIteratorResponse\";\nexport { ChangeFeedPullModelIterator } from \"./ChangeFeedPullModelIterator\";\nexport { FeedRangeInternal, FeedRange } from \"./FeedRange\";\nexport { ChangeFeedStartFrom } from \"./ChangeFeedStartFrom\";\nexport { buildInternalChangeFeedOptions } from \"./changeFeedUtils\";\nexport { changeFeedIteratorBuilder } from \"./changeFeedIteratorBuilder\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts new file mode 100644 index 000000000..f41dd648d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts @@ -0,0 +1,5 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { PartitionKeyDefinition } from "../documents"; +import { Container } from "./Container"; +export declare function readPartitionKeyDefinition(diagnosticNode: DiagnosticNodeInternal, container: Container): Promise; +//# sourceMappingURL=ClientUtils.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts.map new file mode 100644 index 000000000..c2b257b6d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ClientUtils.d.ts","sourceRoot":"","sources":["../../../src/client/ClientUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,wBAAsB,0BAA0B,CAC9C,cAAc,EAAE,sBAAsB,EACtC,SAAS,EAAE,SAAS,GACnB,OAAO,CAAC,sBAAsB,CAAC,CAGjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js new file mode 100644 index 000000000..768cff533 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export async function readPartitionKeyDefinition(diagnosticNode, container) { + const partitionKeyDefinition = await container.readPartitionKeyDefinition(diagnosticNode); + return partitionKeyDefinition.resource; +} +//# sourceMappingURL=ClientUtils.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js.map new file mode 100644 index 000000000..1fe70e159 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/ClientUtils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ClientUtils.js","sourceRoot":"","sources":["../../../src/client/ClientUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,cAAsC,EACtC,SAAoB;IAEpB,MAAM,sBAAsB,GAAG,MAAM,SAAS,CAAC,0BAA0B,CAAC,cAAc,CAAC,CAAC;IAC1F,OAAO,sBAAsB,CAAC,QAAQ,CAAC;AACzC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { PartitionKeyDefinition } from \"../documents\";\nimport { Container } from \"./Container\";\n\nexport async function readPartitionKeyDefinition(\n diagnosticNode: DiagnosticNodeInternal,\n container: Container,\n): Promise {\n const partitionKeyDefinition = await container.readPartitionKeyDefinition(diagnosticNode);\n return partitionKeyDefinition.resource;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts new file mode 100644 index 000000000..3c586c779 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts @@ -0,0 +1,35 @@ +import { ClientContext } from "../../ClientContext"; +import { RequestOptions } from "../../request"; +import { Container } from "../Container"; +import { ConflictResponse } from "./ConflictResponse"; +import { PartitionKey } from "../../documents"; +/** + * Use to read or delete a given {@link Conflict} by id. + * + * @see {@link Conflicts} to query or read all conflicts. + */ +export declare class Conflict { + readonly container: Container; + readonly id: string; + private readonly clientContext; + private partitionKey?; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Conflict}. + */ + constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey); + /** + * Read the {@link ConflictDefinition} for the given {@link Conflict}. + */ + read(options?: RequestOptions): Promise; + /** + * Delete the given {@link ConflictDefinition}. + */ + delete(options?: RequestOptions): Promise; +} +//# sourceMappingURL=Conflict.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts.map new file mode 100644 index 000000000..65be9e006 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Conflict.d.ts","sourceRoot":"","sources":["../../../../src/client/Conflict/Conflict.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAK/C;;;;GAIG;AACH,qBAAa,QAAQ;aAaD,SAAS,EAAE,SAAS;aACpB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,YAAY,CAAC;IAfvB;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD;;;;OAIG;gBAEe,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa,EACrC,YAAY,CAAC,EAAE,YAAY;IAKrC;;OAEG;IACU,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAuBtE;;OAEG;IACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;CA6BzE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js new file mode 100644 index 000000000..4e060783f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js @@ -0,0 +1,70 @@ +import { Constants, getIdFromLink, getPathFromLink, ResourceType } from "../../common"; +import { ConflictResponse } from "./ConflictResponse"; +import { undefinedPartitionKey } from "../../extractPartitionKey"; +import { readPartitionKeyDefinition } from "../ClientUtils"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Use to read or delete a given {@link Conflict} by id. + * + * @see {@link Conflicts} to query or read all conflicts. + */ +export class Conflict { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return `/${this.container.url}/${Constants.Path.ConflictsPathSegment}/${this.id}`; + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Conflict}. + */ + constructor(container, id, clientContext, partitionKey) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + this.partitionKey = partitionKey; + this.partitionKey = partitionKey; + } + /** + * Read the {@link ConflictDefinition} for the given {@link Conflict}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url, ResourceType.conflicts); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new ConflictResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link ConflictDefinition}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = undefinedPartitionKey(partitionKeyDefinition); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.conflicts, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ConflictResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Conflict.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js.map new file mode 100644 index 000000000..8d6519a9a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflict.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Conflict.js","sourceRoot":"","sources":["../../../../src/client/Conflict/Conflict.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACnB;;OAEG;IAC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G,MAAM,0BAA0B,CAC7D,cAAc,EACd,IAAI,CAAC,SAAS,CACf,CAAC;gBACF,IAAI,CAAC,YAAY,GAAG,qBAAqB,CAAC,sBAAsB,CAAC,CAAC;aACnE;YACD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAqB;gBACnE,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,SAAS;gBACpC,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,gBAAgB,CACzB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, getIdFromLink, getPathFromLink, ResourceType } from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { ConflictDefinition } from \"./ConflictDefinition\";\nimport { ConflictResponse } from \"./ConflictResponse\";\nimport { undefinedPartitionKey } from \"../../extractPartitionKey\";\nimport { PartitionKey } from \"../../documents\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Use to read or delete a given {@link Conflict} by id.\n *\n * @see {@link Conflicts} to query or read all conflicts.\n */\nexport class Conflict {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return `/${this.container.url}/${Constants.Path.ConflictsPathSegment}/${this.id}`;\n }\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link Conflict}.\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n private partitionKey?: PartitionKey,\n ) {\n this.partitionKey = partitionKey;\n }\n\n /**\n * Read the {@link ConflictDefinition} for the given {@link Conflict}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url, ResourceType.conflicts);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n\n return new ConflictResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link ConflictDefinition}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = undefinedPartitionKey(partitionKeyDefinition);\n }\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.conflicts,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n return new ConflictResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts new file mode 100644 index 000000000..315c7dc7e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts @@ -0,0 +1,11 @@ +import { OperationType, ResourceType } from "../../common"; +export interface ConflictDefinition { + /** The id of the conflict */ + id?: string; + /** Source resource id */ + resourceId?: string; + resourceType?: ResourceType; + operationType?: OperationType; + content?: string; +} +//# sourceMappingURL=ConflictDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts.map new file mode 100644 index 000000000..2684fc893 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,yBAAyB;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js new file mode 100644 index 000000000..f5bd30887 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ConflictDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js.map new file mode 100644 index 000000000..5fac1271a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictDefinition.js","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OperationType, ResourceType } from \"../../common\";\n\nexport interface ConflictDefinition {\n /** The id of the conflict */\n id?: string;\n /** Source resource id */\n resourceId?: string;\n resourceType?: ResourceType;\n operationType?: OperationType;\n content?: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts new file mode 100644 index 000000000..e82d6f916 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts @@ -0,0 +1,5 @@ +export declare enum ConflictResolutionMode { + Custom = "Custom", + LastWriterWins = "LastWriterWins" +} +//# sourceMappingURL=ConflictResolutionMode.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts.map new file mode 100644 index 000000000..5264b9a53 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictResolutionMode.d.ts","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictResolutionMode.ts"],"names":[],"mappings":"AAEA,oBAAY,sBAAsB;IAChC,MAAM,WAAW;IACjB,cAAc,mBAAmB;CAClC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js new file mode 100644 index 000000000..7030031ad --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export var ConflictResolutionMode; +(function (ConflictResolutionMode) { + ConflictResolutionMode["Custom"] = "Custom"; + ConflictResolutionMode["LastWriterWins"] = "LastWriterWins"; +})(ConflictResolutionMode || (ConflictResolutionMode = {})); +//# sourceMappingURL=ConflictResolutionMode.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js.map new file mode 100644 index 000000000..75fdcbe6d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionMode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictResolutionMode.js","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictResolutionMode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,MAAM,CAAN,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,2CAAiB,CAAA;IACjB,2DAAiC,CAAA;AACnC,CAAC,EAHW,sBAAsB,KAAtB,sBAAsB,QAGjC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport enum ConflictResolutionMode {\n Custom = \"Custom\",\n LastWriterWins = \"LastWriterWins\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts new file mode 100644 index 000000000..424de83d9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts @@ -0,0 +1,38 @@ +import { ConflictResolutionMode } from "./ConflictResolutionMode"; +/** + * Represents the conflict resolution policy configuration for specifying how to resolve conflicts + * in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service. + */ +export interface ConflictResolutionPolicy { + /** + * Gets or sets the in the Azure Cosmos DB service. By default it is {@link ConflictResolutionMode.LastWriterWins}. + */ + mode?: keyof typeof ConflictResolutionMode; + /** + * Gets or sets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution. + * This path must be present in each document and must be an integer value. + * In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked. + * If the path is unspecified, by default the timestamp path will be used. + * + * This value should only be set when using {@link ConflictResolutionMode.LastWriterWins}. + * + * ```typescript + * conflictResolutionPolicy.ConflictResolutionPath = "/name/first"; + * ``` + * + */ + conflictResolutionPath?: string; + /** + * Gets or sets the {@link StoredProcedure} which is used for conflict resolution in the Azure Cosmos DB service. + * This stored procedure may be created after the {@link Container} is created and can be changed as required. + * + * 1. This value should only be set when using {@link ConflictResolutionMode.Custom}. + * 2. In case the stored procedure fails or throws an exception, the conflict resolution will default to registering conflicts in the conflicts feed. + * + * ```typescript + * conflictResolutionPolicy.ConflictResolutionProcedure = "resolveConflict" + * ``` + */ + conflictResolutionProcedure?: string; +} +//# sourceMappingURL=ConflictResolutionPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts.map new file mode 100644 index 000000000..681b5986f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictResolutionPolicy.d.ts","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictResolutionPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,OAAO,sBAAsB,CAAC;IAC3C;;;;;;;;;;;;OAYG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;;;;;;OAUG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACtC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js new file mode 100644 index 000000000..33c09c80b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ConflictResolutionPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js.map new file mode 100644 index 000000000..117ea2f76 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResolutionPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictResolutionPolicy.js","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictResolutionPolicy.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ConflictResolutionMode } from \"./ConflictResolutionMode\";\n\n/**\n * Represents the conflict resolution policy configuration for specifying how to resolve conflicts\n * in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service.\n */\nexport interface ConflictResolutionPolicy {\n /**\n * Gets or sets the in the Azure Cosmos DB service. By default it is {@link ConflictResolutionMode.LastWriterWins}.\n */\n mode?: keyof typeof ConflictResolutionMode;\n /**\n * Gets or sets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution.\n * This path must be present in each document and must be an integer value.\n * In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked.\n * If the path is unspecified, by default the timestamp path will be used.\n *\n * This value should only be set when using {@link ConflictResolutionMode.LastWriterWins}.\n *\n * ```typescript\n * conflictResolutionPolicy.ConflictResolutionPath = \"/name/first\";\n * ```\n *\n */\n conflictResolutionPath?: string;\n /**\n * Gets or sets the {@link StoredProcedure} which is used for conflict resolution in the Azure Cosmos DB service.\n * This stored procedure may be created after the {@link Container} is created and can be changed as required.\n *\n * 1. This value should only be set when using {@link ConflictResolutionMode.Custom}.\n * 2. In case the stored procedure fails or throws an exception, the conflict resolution will default to registering conflicts in the conflicts feed.\n *\n * ```typescript\n * conflictResolutionPolicy.ConflictResolutionProcedure = \"resolveConflict\"\n * ```\n */\n conflictResolutionProcedure?: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts new file mode 100644 index 000000000..ada6079c9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts @@ -0,0 +1,12 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request"; +import { Resource } from "../Resource"; +import { Conflict } from "./Conflict"; +import { ConflictDefinition } from "./ConflictDefinition"; +export declare class ConflictResponse extends ResourceResponse { + constructor(resource: ConflictDefinition & Resource, headers: CosmosHeaders, statusCode: number, conflict: Conflict, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Conflict} corresponding to the returned {@link ConflictDefinition}. */ + readonly conflict: Conflict; +} +//# sourceMappingURL=ConflictResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts.map new file mode 100644 index 000000000..07899f1e3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,kBAAkB,GAAG,QAAQ,CAAC;gBAEjF,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,EACvC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,iBAAiB;IAKhC,oGAAoG;IACpG,SAAgB,QAAQ,EAAE,QAAQ,CAAC;CACpC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js new file mode 100644 index 000000000..c4b4de284 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js @@ -0,0 +1,8 @@ +import { ResourceResponse } from "../../request"; +export class ConflictResponse extends ResourceResponse { + constructor(resource, headers, statusCode, conflict, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.conflict = conflict; + } +} +//# sourceMappingURL=ConflictResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js.map new file mode 100644 index 000000000..513943327 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/ConflictResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ConflictResponse.js","sourceRoot":"","sources":["../../../../src/client/Conflict/ConflictResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,OAAO,gBAAiB,SAAQ,gBAA+C;IACnF,YACE,QAAuC,EACvC,OAAsB,EACtB,UAAkB,EAClB,QAAkB,EAClB,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Conflict } from \"./Conflict\";\nimport { ConflictDefinition } from \"./ConflictDefinition\";\n\nexport class ConflictResponse extends ResourceResponse {\n constructor(\n resource: ConflictDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n conflict: Conflict,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.conflict = conflict;\n }\n /** A reference to the {@link Conflict} corresponding to the returned {@link ConflictDefinition}. */\n public readonly conflict: Conflict;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts new file mode 100644 index 000000000..82060988f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts @@ -0,0 +1,37 @@ +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions } from "../../request"; +import { Container } from "../Container"; +import { Resource } from "../Resource"; +import { ConflictDefinition } from "./ConflictDefinition"; +/** + * Use to query or read all conflicts. + * + * @see {@link Conflict} to read or delete a given {@link Conflict} by id. + */ +export declare class Conflicts { + readonly container: Container; + private readonly clientContext; + constructor(container: Container, clientContext: ClientContext); + /** + * Queries all conflicts. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time. + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all conflicts. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time. + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Reads all conflicts + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + readAll(options?: FeedOptions): QueryIterator; +} +//# sourceMappingURL=Conflicts.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts.map new file mode 100644 index 000000000..5a3699cce --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Conflicts.d.ts","sourceRoot":"","sources":["../../../../src/client/Conflict/Conflicts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;GAIG;AACH,qBAAa,SAAS;aAEF,SAAS,EAAE,SAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADd,SAAS,EAAE,SAAS,EACnB,aAAa,EAAE,aAAa;IAG/C;;;;;OAKG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IACrF;;;;;OAKG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAuBtF;;;OAGG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,kBAAkB,GAAG,QAAQ,CAAC;CAGpF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js new file mode 100644 index 000000000..7f967f218 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js @@ -0,0 +1,36 @@ +import { getIdFromLink, getPathFromLink, ResourceType } from "../../common"; +import { QueryIterator } from "../../queryIterator"; +/** + * Use to query or read all conflicts. + * + * @see {@link Conflict} to read or delete a given {@link Conflict} by id. + */ +export class Conflicts { + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, ResourceType.conflicts); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.conflicts, + resourceId: id, + resultFn: (result) => result.Conflicts, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }); + } + /** + * Reads all conflicts + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + readAll(options) { + return this.query(undefined, options); + } +} +//# sourceMappingURL=Conflicts.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js.map new file mode 100644 index 000000000..2037ac618 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/Conflicts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Conflicts.js","sourceRoot":"","sources":["../../../../src/client/Conflict/Conflicts.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMpD;;;;GAIG;AACH,MAAM,OAAO,SAAS;IACpB,YACkB,SAAoB,EACnB,aAA4B;QAD7B,cAAS,GAAT,SAAS,CAAW;QACnB,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAgBG,KAAK,CAAI,KAA4B,EAAE,OAAqB;QACjE,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;QACzE,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAE7C,OAAO,IAAI,aAAa,CACtB,IAAI,CAAC,aAAa,EAClB,KAAK,EACL,OAAO,EACP,CAAC,QAAgC,EAAE,YAAY,EAAE,EAAE;YACjD,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;gBAClC,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,SAAS;gBACpC,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS;gBACtC,KAAK;gBACL,OAAO,EAAE,YAAY;gBACrB,cAAc,EAAE,QAAQ;aACzB,CAAC,CAAC;QACL,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,OAAqB;QAClC,OAAO,IAAI,CAAC,KAAK,CAAgC,SAAS,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { ConflictDefinition } from \"./ConflictDefinition\";\n\n/**\n * Use to query or read all conflicts.\n *\n * @see {@link Conflict} to read or delete a given {@link Conflict} by id.\n */\nexport class Conflicts {\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Queries all conflicts.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all conflicts.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.conflicts);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(\n this.clientContext,\n query,\n options,\n (diagNode: DiagnosticNodeInternal, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.conflicts,\n resourceId: id,\n resultFn: (result) => result.Conflicts,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n },\n );\n }\n\n /**\n * Reads all conflicts\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts new file mode 100644 index 000000000..803d79015 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts @@ -0,0 +1,7 @@ +export { Conflict } from "./Conflict"; +export { Conflicts } from "./Conflicts"; +export { ConflictDefinition } from "./ConflictDefinition"; +export { ConflictResponse } from "./ConflictResponse"; +export { ConflictResolutionPolicy } from "./ConflictResolutionPolicy"; +export { ConflictResolutionMode } from "./ConflictResolutionMode"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts.map new file mode 100644 index 000000000..8a6fe3b50 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/Conflict/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js new file mode 100644 index 000000000..ae59ea107 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { Conflict } from "./Conflict"; +export { Conflicts } from "./Conflicts"; +export { ConflictResponse } from "./ConflictResponse"; +export { ConflictResolutionMode } from "./ConflictResolutionMode"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js.map new file mode 100644 index 000000000..a225fdef2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Conflict/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/Conflict/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { Conflict } from \"./Conflict\";\nexport { Conflicts } from \"./Conflicts\";\nexport { ConflictDefinition } from \"./ConflictDefinition\";\nexport { ConflictResponse } from \"./ConflictResponse\";\nexport { ConflictResolutionPolicy } from \"./ConflictResolutionPolicy\";\nexport { ConflictResolutionMode } from \"./ConflictResolutionMode\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts new file mode 100644 index 000000000..0bbc3090c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts @@ -0,0 +1,121 @@ +import { ClientContext } from "../../ClientContext"; +import { PartitionKey, PartitionKeyDefinition } from "../../documents"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions, ResourceResponse, Response } from "../../request"; +import { PartitionedQueryExecutionInfo } from "../../request/ErrorResponse"; +import { Conflict, Conflicts } from "../Conflict"; +import { Database } from "../Database"; +import { Item, Items } from "../Item"; +import { Scripts } from "../Script/Scripts"; +import { ContainerDefinition } from "./ContainerDefinition"; +import { ContainerResponse } from "./ContainerResponse"; +import { PartitionKeyRange } from "./PartitionKeyRange"; +import { OfferResponse } from "../Offer/OfferResponse"; +import { FeedRange } from "../ChangeFeed"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +/** + * Operations for reading, replacing, or deleting a specific, existing container by id. + * + * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ +export declare class Container { + readonly database: Database; + readonly id: string; + private readonly clientContext; + private $items; + /** + * Operations for creating new items, and reading/querying all items + * + * For reading, replacing, or deleting an existing item, use `.item(id)`. + * + * @example Create a new item + * ```typescript + * const {body: createdItem} = await container.items.create({id: "", properties: {}}); + * ``` + */ + get items(): Items; + private $scripts; + /** + * All operations for Stored Procedures, Triggers, and User Defined Functions + */ + get scripts(): Scripts; + private $conflicts; + /** + * Operations for reading and querying conflicts for the given container. + * + * For reading or deleting a specific conflict, use `.conflict(id)`. + */ + get conflicts(): Conflicts; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object. + * @param database - The parent {@link Database}. + * @param id - The id of the given container. + * @hidden + */ + constructor(database: Database, id: string, clientContext: ClientContext); + /** + * Used to read, replace, or delete a specific, existing {@link Item} by id. + * + * Use `.items` for creating new items, or querying/reading all items. + * + * @param id - The id of the {@link Item}. + * @param partitionKeyValue - The value of the {@link Item} partition key + * @example Replace an item + * `const {body: replacedItem} = await container.item("", "").replace({id: "", title: "Updated post", authorID: 5});` + */ + item(id: string, partitionKeyValue?: PartitionKey): Item; + /** + * Used to read, replace, or delete a specific, existing {@link Conflict} by id. + * + * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts. + * @param id - The id of the {@link Conflict}. + */ + conflict(id: string, partitionKey?: PartitionKey): Conflict; + /** Read the container's definition */ + read(options?: RequestOptions): Promise; + /** + * @hidden + */ + readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise; + /** Replace the container's definition */ + replace(body: ContainerDefinition, options?: RequestOptions): Promise; + /** Delete the container */ + delete(options?: RequestOptions): Promise; + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @deprecated This method has been renamed to readPartitionKeyDefinition. + */ + getPartitionKeyDefinition(): Promise>; + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @hidden + */ + readPartitionKeyDefinition(diagnosticNode: DiagnosticNodeInternal): Promise>; + /** + * Gets offer on container. If none exists, returns an OfferResponse with undefined. + */ + readOffer(options?: RequestOptions): Promise; + getQueryPlan(query: string | SqlQuerySpec): Promise>; + readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator; + /** + * + * @returns all the feed ranges for which changefeed could be fetched. + */ + getFeedRanges(): Promise>; + /** + * Delete all documents belong to the container for the provided partition key value + * @param partitionKey - The partition key value of the items to be deleted + */ + deleteAllItemsForPartitionKey(partitionKey: PartitionKey, options?: RequestOptions): Promise; +} +//# sourceMappingURL=Container.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts.map new file mode 100644 index 000000000..58ea98e2f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Container.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/Container.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAqB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAQlF;;;;;;;;;GAS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cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IA6BpD;;OAEG;IACU,SAAS,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IA4B/D,YAAY,CACvB,KAAK,EAAE,MAAM,GAAG,YAAY,GAC3B,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;IAe5C,sBAAsB,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,iBAAiB,CAAC;IAI1F;;;OAGG;IACU,aAAa,IAAI,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAc/D;;;OAGG;IACU,6BAA6B,CACxC,YAAY,EAAE,YAAY,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,iBAAiB,CAAC;CAuB9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js new file mode 100644 index 000000000..f0651ade3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js @@ -0,0 +1,251 @@ +import { createDocumentCollectionUri, getIdFromLink, getPathFromLink, HTTPMethod, isResourceValid, ResourceType, } from "../../common"; +import { ResourceResponse } from "../../request"; +import { Conflict, Conflicts } from "../Conflict"; +import { Item, Items } from "../Item"; +import { Scripts } from "../Script/Scripts"; +import { ContainerResponse } from "./ContainerResponse"; +import { Offer } from "../Offer"; +import { OfferResponse } from "../Offer/OfferResponse"; +import { FeedRangeInternal } from "../ChangeFeed"; +import { getEmptyCosmosDiagnostics, withDiagnostics, withMetadataDiagnostics, } from "../../utils/diagnostics"; +import { MetadataLookUpType } from "../../CosmosDiagnostics"; +/** + * Operations for reading, replacing, or deleting a specific, existing container by id. + * + * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ +export class Container { + /** + * Operations for creating new items, and reading/querying all items + * + * For reading, replacing, or deleting an existing item, use `.item(id)`. + * + * @example Create a new item + * ```typescript + * const {body: createdItem} = await container.items.create({id: "", properties: {}}); + * ``` + */ + get items() { + if (!this.$items) { + this.$items = new Items(this, this.clientContext); + } + return this.$items; + } + /** + * All operations for Stored Procedures, Triggers, and User Defined Functions + */ + get scripts() { + if (!this.$scripts) { + this.$scripts = new Scripts(this, this.clientContext); + } + return this.$scripts; + } + /** + * Operations for reading and querying conflicts for the given container. + * + * For reading or deleting a specific conflict, use `.conflict(id)`. + */ + get conflicts() { + if (!this.$conflicts) { + this.$conflicts = new Conflicts(this, this.clientContext); + } + return this.$conflicts; + } + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createDocumentCollectionUri(this.database.id, this.id); + } + /** + * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object. + * @param database - The parent {@link Database}. + * @param id - The id of the given container. + * @hidden + */ + constructor(database, id, clientContext) { + this.database = database; + this.id = id; + this.clientContext = clientContext; + } + /** + * Used to read, replace, or delete a specific, existing {@link Item} by id. + * + * Use `.items` for creating new items, or querying/reading all items. + * + * @param id - The id of the {@link Item}. + * @param partitionKeyValue - The value of the {@link Item} partition key + * @example Replace an item + * `const {body: replacedItem} = await container.item("", "").replace({id: "", title: "Updated post", authorID: 5});` + */ + item(id, partitionKeyValue) { + return new Item(this, id, this.clientContext, partitionKeyValue); + } + /** + * Used to read, replace, or delete a specific, existing {@link Conflict} by id. + * + * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts. + * @param id - The id of the {@link Conflict}. + */ + conflict(id, partitionKey) { + return new Conflict(this, id, this.clientContext, partitionKey); + } + /** Read the container's definition */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.readInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async readInternal(diagnosticNode, options) { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.container, + resourceId: id, + options, + diagnosticNode, + }); + this.clientContext.partitionKeyDefinitionCache[this.url] = response.result.partitionKey; + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + } + /** Replace the container's definition */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: ResourceType.container, + resourceId: id, + options, + diagnosticNode, + }); + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** Delete the container */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.container, + resourceId: id, + options, + diagnosticNode, + }); + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @deprecated This method has been renamed to readPartitionKeyDefinition. + */ + async getPartitionKeyDefinition() { + return withDiagnostics(async (diagnosticNode) => { + return this.readPartitionKeyDefinition(diagnosticNode); + }, this.clientContext); + } + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @hidden + */ + async readPartitionKeyDefinition(diagnosticNode) { + // $ISSUE-felixfan-2016-03-17: Make name based path and link based path use the same key + // $ISSUE-felixfan-2016-03-17: Refresh partitionKeyDefinitionCache when necessary + if (this.url in this.clientContext.partitionKeyDefinitionCache) { + diagnosticNode.addData({ readFromCache: true }); + return new ResourceResponse(this.clientContext.partitionKeyDefinitionCache[this.url], {}, 0, getEmptyCosmosDiagnostics()); + } + const { headers, statusCode, diagnostics } = await withMetadataDiagnostics(async (node) => { + return this.readInternal(node); + }, diagnosticNode, MetadataLookUpType.ContainerLookUp); + return new ResourceResponse(this.clientContext.partitionKeyDefinitionCache[this.url], headers, statusCode, diagnostics); + } + /** + * Gets offer on container. If none exists, returns an OfferResponse with undefined. + */ + async readOffer(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + const { resource: container } = await this.read(); + const path = "/offers"; + const url = container._self; + const response = await this.clientContext.queryFeed({ + path, + resourceId: "", + resourceType: ResourceType.offer, + query: `SELECT * from root where root.resource = "${url}"`, + resultFn: (result) => result.Offers, + options, + diagnosticNode, + }); + const offer = response.result[0] + ? new Offer(this.database.client, response.result[0].id, this.clientContext) + : undefined; + return new OfferResponse(response.result[0], response.headers, response.code, getEmptyCosmosDiagnostics(), offer); + }, this.clientContext); + } + async getQueryPlan(query) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + return this.clientContext.getQueryPlan(path + "/docs", ResourceType.item, getIdFromLink(this.url), query, {}, diagnosticNode); + }, this.clientContext); + } + readPartitionKeyRanges(feedOptions) { + feedOptions = feedOptions || {}; + return this.clientContext.queryPartitionKeyRanges(this.url, undefined, feedOptions); + } + /** + * + * @returns all the feed ranges for which changefeed could be fetched. + */ + async getFeedRanges() { + return withDiagnostics(async (diagnosticNode) => { + const { resources } = await this.readPartitionKeyRanges().fetchAllInternal(diagnosticNode); + const feedRanges = []; + for (const resource of resources) { + const feedRange = new FeedRangeInternal(resource.minInclusive, resource.maxExclusive); + Object.freeze(feedRange); + feedRanges.push(feedRange); + } + return feedRanges; + }, this.clientContext); + } + /** + * Delete all documents belong to the container for the provided partition key value + * @param partitionKey - The partition key value of the items to be deleted + */ + async deleteAllItemsForPartitionKey(partitionKey, options) { + return withDiagnostics(async (diagnosticNode) => { + let path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + path = path + "/operations/partitionkeydelete"; + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.container, + resourceId: id, + options, + partitionKey: partitionKey, + method: HTTPMethod.post, + diagnosticNode, + }); + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Container.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js.map new file mode 100644 index 000000000..92554878e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Container.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../../src/client/Container/Container.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,2BAA2B,EAC3B,aAAa,EACb,eAAe,EACf,UAAU,EACV,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC;AAItB,OAAO,EAA+B,gBAAgB,EAAY,MAAM,eAAe,CAAC;AAExF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,KAAK,EAAmB,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAa,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,EACL,yBAAyB,EACzB,eAAe,EACf,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,OAAO,SAAS;IAEpB;;;;;;;;;OASG;IACH,IAAW,KAAK;QACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,aAA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// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport {\n createDocumentCollectionUri,\n getIdFromLink,\n getPathFromLink,\n HTTPMethod,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { PartitionKey, PartitionKeyDefinition } from \"../../documents\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions, ResourceResponse, Response } from \"../../request\";\nimport { PartitionedQueryExecutionInfo } from \"../../request/ErrorResponse\";\nimport { Conflict, Conflicts } from \"../Conflict\";\nimport { Database } from \"../Database\";\nimport { Item, Items } from \"../Item\";\nimport { Scripts } from \"../Script/Scripts\";\nimport { ContainerDefinition } from \"./ContainerDefinition\";\nimport { ContainerResponse } from \"./ContainerResponse\";\nimport { PartitionKeyRange } from \"./PartitionKeyRange\";\nimport { Offer, OfferDefinition } from \"../Offer\";\nimport { OfferResponse } from \"../Offer/OfferResponse\";\nimport { Resource } from \"../Resource\";\nimport { FeedRange, FeedRangeInternal } from \"../ChangeFeed\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n withMetadataDiagnostics,\n} from \"../../utils/diagnostics\";\nimport { MetadataLookUpType } from \"../../CosmosDiagnostics\";\n\n/**\n * Operations for reading, replacing, or deleting a specific, existing container by id.\n *\n * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists;\n * do this once on application start up.\n */\nexport class Container {\n private $items: Items;\n /**\n * Operations for creating new items, and reading/querying all items\n *\n * For reading, replacing, or deleting an existing item, use `.item(id)`.\n *\n * @example Create a new item\n * ```typescript\n * const {body: createdItem} = await container.items.create({id: \"\", properties: {}});\n * ```\n */\n public get items(): Items {\n if (!this.$items) {\n this.$items = new Items(this, this.clientContext);\n }\n return this.$items;\n }\n\n private $scripts: Scripts;\n /**\n * All operations for Stored Procedures, Triggers, and User Defined Functions\n */\n public get scripts(): Scripts {\n if (!this.$scripts) {\n this.$scripts = new Scripts(this, this.clientContext);\n }\n return this.$scripts;\n }\n\n private $conflicts: Conflicts;\n /**\n * Operations for reading and querying conflicts for the given container.\n *\n * For reading or deleting a specific conflict, use `.conflict(id)`.\n */\n public get conflicts(): Conflicts {\n if (!this.$conflicts) {\n this.$conflicts = new Conflicts(this, this.clientContext);\n }\n return this.$conflicts;\n }\n\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createDocumentCollectionUri(this.database.id, this.id);\n }\n\n /**\n * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object.\n * @param database - The parent {@link Database}.\n * @param id - The id of the given container.\n * @hidden\n */\n constructor(\n public readonly database: Database,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Item} by id.\n *\n * Use `.items` for creating new items, or querying/reading all items.\n *\n * @param id - The id of the {@link Item}.\n * @param partitionKeyValue - The value of the {@link Item} partition key\n * @example Replace an item\n * `const {body: replacedItem} = await container.item(\"\", \"\").replace({id: \"\", title: \"Updated post\", authorID: 5});`\n */\n public item(id: string, partitionKeyValue?: PartitionKey): Item {\n return new Item(this, id, this.clientContext, partitionKeyValue);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Conflict} by id.\n *\n * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts.\n * @param id - The id of the {@link Conflict}.\n */\n public conflict(id: string, partitionKey?: PartitionKey): Conflict {\n return new Conflict(this, id, this.clientContext, partitionKey);\n }\n\n /** Read the container's definition */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.readInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async readInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: RequestOptions,\n ): Promise {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n diagnosticNode,\n });\n this.clientContext.partitionKeyDefinitionCache[this.url] = response.result.partitionKey;\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /** Replace the container's definition */\n public async replace(\n body: ContainerDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /** Delete the container */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Gets the partition key definition first by looking into the cache otherwise by reading the collection.\n * @deprecated This method has been renamed to readPartitionKeyDefinition.\n */\n public async getPartitionKeyDefinition(): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.readPartitionKeyDefinition(diagnosticNode);\n }, this.clientContext);\n }\n\n /**\n * Gets the partition key definition first by looking into the cache otherwise by reading the collection.\n * @hidden\n */\n public async readPartitionKeyDefinition(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise> {\n // $ISSUE-felixfan-2016-03-17: Make name based path and link based path use the same key\n // $ISSUE-felixfan-2016-03-17: Refresh partitionKeyDefinitionCache when necessary\n if (this.url in this.clientContext.partitionKeyDefinitionCache) {\n diagnosticNode.addData({ readFromCache: true });\n return new ResourceResponse(\n this.clientContext.partitionKeyDefinitionCache[this.url],\n {},\n 0,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n const { headers, statusCode, diagnostics } = await withMetadataDiagnostics(\n async (node: DiagnosticNodeInternal) => {\n return this.readInternal(node);\n },\n diagnosticNode,\n MetadataLookUpType.ContainerLookUp,\n );\n\n return new ResourceResponse(\n this.clientContext.partitionKeyDefinitionCache[this.url],\n headers,\n statusCode,\n diagnostics,\n );\n }\n\n /**\n * Gets offer on container. If none exists, returns an OfferResponse with undefined.\n */\n public async readOffer(options: RequestOptions = {}): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resource: container } = await this.read();\n const path = \"/offers\";\n const url = container._self;\n\n const response = await this.clientContext.queryFeed({\n path,\n resourceId: \"\",\n resourceType: ResourceType.offer,\n query: `SELECT * from root where root.resource = \"${url}\"`,\n resultFn: (result) => result.Offers,\n options,\n diagnosticNode,\n });\n const offer = response.result[0]\n ? new Offer(this.database.client, response.result[0].id, this.clientContext)\n : undefined;\n return new OfferResponse(\n response.result[0],\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n offer,\n );\n }, this.clientContext);\n }\n\n public async getQueryPlan(\n query: string | SqlQuerySpec,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n\n return this.clientContext.getQueryPlan(\n path + \"/docs\",\n ResourceType.item,\n getIdFromLink(this.url),\n query,\n {},\n diagnosticNode,\n );\n }, this.clientContext);\n }\n\n public readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator {\n feedOptions = feedOptions || {};\n return this.clientContext.queryPartitionKeyRanges(this.url, undefined, feedOptions);\n }\n /**\n *\n * @returns all the feed ranges for which changefeed could be fetched.\n */\n public async getFeedRanges(): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resources } = await this.readPartitionKeyRanges().fetchAllInternal(diagnosticNode);\n\n const feedRanges: FeedRange[] = [];\n for (const resource of resources) {\n const feedRange = new FeedRangeInternal(resource.minInclusive, resource.maxExclusive);\n Object.freeze(feedRange);\n feedRanges.push(feedRange);\n }\n return feedRanges;\n }, this.clientContext);\n }\n\n /**\n * Delete all documents belong to the container for the provided partition key value\n * @param partitionKey - The partition key value of the items to be deleted\n */\n public async deleteAllItemsForPartitionKey(\n partitionKey: PartitionKey,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n let path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n path = path + \"/operations/partitionkeydelete\";\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n partitionKey: partitionKey,\n method: HTTPMethod.post,\n diagnosticNode,\n });\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts new file mode 100644 index 000000000..b8e117be8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts @@ -0,0 +1,26 @@ +import { IndexingPolicy, PartitionKeyDefinition } from "../../documents"; +import { ConflictResolutionPolicy } from "../Conflict/ConflictResolutionPolicy"; +import { UniqueKeyPolicy } from "./UniqueKeyPolicy"; +import { GeospatialType } from "../../documents/GeospatialType"; +import { VectorEmbeddingPolicy } from "../../documents/VectorEmbeddingPolicy"; +export interface ContainerDefinition { + /** The id of the container. */ + id?: string; + /** The partition key for the container. */ + partitionKey?: PartitionKeyDefinition; + /** The indexing policy associated with the container. */ + indexingPolicy?: IndexingPolicy; + /** The default time to live in seconds for items in a container. */ + defaultTtl?: number; + /** The conflict resolution policy used to resolve conflicts in a container. */ + conflictResolutionPolicy?: ConflictResolutionPolicy; + /** Policy for additional keys that must be unique per partition key */ + uniqueKeyPolicy?: UniqueKeyPolicy; + /** Geospatial configuration for a collection. Type is set to Geography by default */ + geospatialConfig?: { + type: GeospatialType; + }; + /** The vector embedding policy information for storing items in a container. */ + vectorEmbeddingPolicy?: VectorEmbeddingPolicy; +} +//# sourceMappingURL=ContainerDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts.map new file mode 100644 index 000000000..70fc300b1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ContainerDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/ContainerDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAE9E,MAAM,WAAW,mBAAmB;IAClC,+BAA+B;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2CAA2C;IAC3C,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,yDAAyD;IACzD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+EAA+E;IAC/E,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,uEAAuE;IACvE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,qFAAqF;IACrF,gBAAgB,CAAC,EAAE;QACjB,IAAI,EAAE,cAAc,CAAC;KACtB,CAAC;IACF,gFAAgF;IAChF,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js new file mode 100644 index 000000000..678a5ccb7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ContainerDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js.map new file mode 100644 index 000000000..3065a670d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ContainerDefinition.js","sourceRoot":"","sources":["../../../../src/client/Container/ContainerDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { IndexingPolicy, PartitionKeyDefinition } from \"../../documents\";\nimport { ConflictResolutionPolicy } from \"../Conflict/ConflictResolutionPolicy\";\nimport { UniqueKeyPolicy } from \"./UniqueKeyPolicy\";\nimport { GeospatialType } from \"../../documents/GeospatialType\";\nimport { VectorEmbeddingPolicy } from \"../../documents/VectorEmbeddingPolicy\";\n\nexport interface ContainerDefinition {\n /** The id of the container. */\n id?: string;\n /** The partition key for the container. */\n partitionKey?: PartitionKeyDefinition;\n /** The indexing policy associated with the container. */\n indexingPolicy?: IndexingPolicy;\n /** The default time to live in seconds for items in a container. */\n defaultTtl?: number;\n /** The conflict resolution policy used to resolve conflicts in a container. */\n conflictResolutionPolicy?: ConflictResolutionPolicy;\n /** Policy for additional keys that must be unique per partition key */\n uniqueKeyPolicy?: UniqueKeyPolicy;\n /** Geospatial configuration for a collection. Type is set to Geography by default */\n geospatialConfig?: {\n type: GeospatialType;\n };\n /** The vector embedding policy information for storing items in a container. */\n vectorEmbeddingPolicy?: VectorEmbeddingPolicy;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts new file mode 100644 index 000000000..02738af7b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts @@ -0,0 +1,14 @@ +import { ContainerDefinition } from "./ContainerDefinition"; +import { PartitionKeyDefinition } from "../../documents"; +import { VerboseOmit } from "../../utils/types"; +export interface ContainerRequest extends VerboseOmit { + throughput?: number; + maxThroughput?: number; + autoUpgradePolicy?: { + throughputPolicy: { + incrementPercent: number; + }; + }; + partitionKey?: string | PartitionKeyDefinition; +} +//# sourceMappingURL=ContainerRequest.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts.map new file mode 100644 index 000000000..dd26a84c2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ContainerRequest.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/ContainerRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,WAAW,gBAAiB,SAAQ,WAAW,CAAC,mBAAmB,EAAE,cAAc,CAAC;IAExF,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,iBAAiB,CAAC,EAAE;QAClB,gBAAgB,EAAE;YAChB,gBAAgB,EAAE,MAAM,CAAC;SAC1B,CAAC;KACH,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,GAAG,sBAAsB,CAAC;CAChD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js new file mode 100644 index 000000000..1a7d3dc4e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ContainerRequest.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js.map new file mode 100644 index 000000000..8ca1de81c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ContainerRequest.js","sourceRoot":"","sources":["../../../../src/client/Container/ContainerRequest.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ContainerDefinition } from \"./ContainerDefinition\";\nimport { PartitionKeyDefinition } from \"../../documents\";\nimport { VerboseOmit } from \"../../utils/types\";\n\nexport interface ContainerRequest extends VerboseOmit {\n /* Throughput for this container. Cannot use with maxThroughput */\n throughput?: number;\n /* Max throughput for this container. Specify to use Autoscale*/\n maxThroughput?: number;\n /* Autoscale scaling defined by throughput increment percent */\n autoUpgradePolicy?: {\n throughputPolicy: {\n incrementPercent: number;\n };\n };\n partitionKey?: string | PartitionKeyDefinition;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts new file mode 100644 index 000000000..584931d9d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts @@ -0,0 +1,13 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request/ResourceResponse"; +import { Resource } from "../Resource"; +import { ContainerDefinition } from "./ContainerDefinition"; +import { Container } from "./index"; +/** Response object for Container operations */ +export declare class ContainerResponse extends ResourceResponse { + constructor(resource: ContainerDefinition & Resource, headers: CosmosHeaders, statusCode: number, container: Container, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Container} that the returned {@link ContainerDefinition} corresponds to. */ + readonly container: Container; +} +//# sourceMappingURL=ContainerResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts.map new file mode 100644 index 000000000..70f1c3bc1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ContainerResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/ContainerResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC,+CAA+C;AAC/C,qBAAa,iBAAkB,SAAQ,gBAAgB,CAAC,mBAAmB,GAAG,QAAQ,CAAC;gBAEnF,QAAQ,EAAE,mBAAmB,GAAG,QAAQ,EACxC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,iBAAiB;IAKhC,yGAAyG;IACzG,SAAgB,SAAS,EAAE,SAAS,CAAC;CACtC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js new file mode 100644 index 000000000..8dd024857 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js @@ -0,0 +1,9 @@ +import { ResourceResponse } from "../../request/ResourceResponse"; +/** Response object for Container operations */ +export class ContainerResponse extends ResourceResponse { + constructor(resource, headers, statusCode, container, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.container = container; + } +} +//# sourceMappingURL=ContainerResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js.map new file mode 100644 index 000000000..33d42da3f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/ContainerResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ContainerResponse.js","sourceRoot":"","sources":["../../../../src/client/Container/ContainerResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,+CAA+C;AAC/C,MAAM,OAAO,iBAAkB,SAAQ,gBAAgD;IACrF,YACE,QAAwC,EACxC,OAAsB,EACtB,UAAkB,EAClB,SAAoB,EACpB,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request/ResourceResponse\";\nimport { Resource } from \"../Resource\";\nimport { ContainerDefinition } from \"./ContainerDefinition\";\nimport { Container } from \"./index\";\n\n/** Response object for Container operations */\nexport class ContainerResponse extends ResourceResponse {\n constructor(\n resource: ContainerDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n container: Container,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.container = container;\n }\n /** A reference to the {@link Container} that the returned {@link ContainerDefinition} corresponds to. */\n public readonly container: Container;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts new file mode 100644 index 000000000..296cfc548 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts @@ -0,0 +1,112 @@ +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions } from "../../request"; +import { Database } from "../Database"; +import { Resource } from "../Resource"; +import { ContainerDefinition } from "./ContainerDefinition"; +import { ContainerRequest } from "./ContainerRequest"; +import { ContainerResponse } from "./ContainerResponse"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +/** + * Operations for creating new containers, and reading/querying all containers + * + * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ +export declare class Containers { + readonly database: Database; + private readonly clientContext; + constructor(database: Database, clientContext: ClientContext); + /** + * Queries all containers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @container", + * parameters: [ + * {name: "@container", value: "Todo"} + * ] + * }; + * const {body: containerList} = await client.database("").containers.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all containers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @container", + * parameters: [ + * {name: "@container", value: "Todo"} + * ] + * }; + * const {body: containerList} = await client.database("").containers.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Creates a container. + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + create(body: ContainerRequest, options?: RequestOptions): Promise; + /** + * @hidden + */ + createInternal(diagnosticNode: DiagnosticNodeInternal, body: ContainerRequest, options?: RequestOptions): Promise; + /** + * Checks if a Container exists, and, if it doesn't, creates it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.) + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + createIfNotExists(body: ContainerRequest, options?: RequestOptions): Promise; + /** + * Read all containers. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const {body: containerList} = await client.database("").containers.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; +} +//# sourceMappingURL=Containers.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts.map new file mode 100644 index 000000000..b93483fe7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Containers.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/Containers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAUpD,OAAO,EAAgB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAGlF;;;;;;;;;GASG;AACH,qBAAa,UAAU;aAEH,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADd,QAAQ,EAAE,QAAQ,EACjB,aAAa,EAAE,aAAa;IAG/C;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IAC5E;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAuB7E;;;;;;;;;;;;;;;;OAgBG;IACU,MAAM,CACjB,IAAI,EAAE,gBAAgB,EACtB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,iBAAiB,CAAC;IAM7B;;OAEG;IACU,cAAc,CACzB,cAAc,EAAE,sBAAsB,EACtC,IAAI,EAAE,gBAAgB,EACtB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,iBAAiB,CAAC;IAyE7B;;;;;;;;;;;;;;;;;;OAkBG;IACU,iBAAiB,CAC5B,IAAI,EAAE,gBAAgB,EACtB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,iBAAiB,CAAC;IA2B7B;;;;;;;;OAQG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,mBAAmB,GAAG,QAAQ,CAAC;CAGrF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js new file mode 100644 index 000000000..842707d14 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js @@ -0,0 +1,177 @@ +import { Constants, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, StatusCodes, } from "../../common"; +import { DEFAULT_PARTITION_KEY_PATH } from "../../common/partitionKeys"; +import { mergeHeaders } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { Container } from "./Container"; +import { ContainerResponse } from "./ContainerResponse"; +import { validateOffer } from "../../utils/offers"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Operations for creating new containers, and reading/querying all containers + * + * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ +export class Containers { + constructor(database, clientContext) { + this.database = database; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.database.url, ResourceType.container); + const id = getIdFromLink(this.database.url); + return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.container, + resourceId: id, + resultFn: (result) => result.DocumentCollections, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }); + } + /** + * Creates a container. + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + async create(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + return this.createInternal(diagnosticNode, body, options); + }, this.clientContext); + } + /** + * @hidden + */ + async createInternal(diagnosticNode, body, options = {}) { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.database.url, ResourceType.container); + const id = getIdFromLink(this.database.url); + validateOffer(body); + if (body.maxThroughput) { + const autoscaleParams = { + maxThroughput: body.maxThroughput, + }; + if (body.autoUpgradePolicy) { + autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy; + } + const autoscaleHeader = JSON.stringify(autoscaleParams); + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants.HttpHeaders.AutoscaleSettings]: autoscaleHeader, + }); + delete body.maxThroughput; + delete body.autoUpgradePolicy; + } + if (body.throughput) { + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants.HttpHeaders.OfferThroughput]: body.throughput, + }); + delete body.throughput; + } + if (typeof body.partitionKey === "string") { + if (!body.partitionKey.startsWith("/")) { + throw new Error("Partition key must start with '/'"); + } + body.partitionKey = { + paths: [body.partitionKey], + }; + } + // If they don't specify a partition key, use the default path + if (!body.partitionKey || !body.partitionKey.paths) { + body.partitionKey = { + paths: [DEFAULT_PARTITION_KEY_PATH], + }; + } + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.container, + resourceId: id, + diagnosticNode, + options, + }); + const ref = new Container(this.database, response.result.id, this.clientContext); + return new ContainerResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + } + /** + * Checks if a Container exists, and, if it doesn't, creates it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.) + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + async createIfNotExists(body, options) { + if (!body || body.id === null || body.id === undefined) { + throw new Error("body parameter must be an object with an id property"); + } + /* + 1. Attempt to read the Container (based on an assumption that most containers will already exist, so its faster) + 2. If it fails with NotFound error, attempt to create the container. Else, return the read results. + */ + return withDiagnostics(async (diagnosticNode) => { + try { + const readResponse = await this.database + .container(body.id) + .readInternal(diagnosticNode, options); + return readResponse; + } + catch (err) { + if (err.code === StatusCodes.NotFound) { + const createResponse = await this.createInternal(diagnosticNode, body, options); + // Must merge the headers to capture RU costskaty + mergeHeaders(createResponse.headers, err.headers); + return createResponse; + } + else { + throw err; + } + } + }, this.clientContext); + } + /** + * Read all containers. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const {body: containerList} = await client.database("").containers.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } +} +//# sourceMappingURL=Containers.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js.map new file mode 100644 index 000000000..c4398f24f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/Containers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Containers.js","sourceRoot":"","sources":["../../../../src/client/Container/Containers.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAgB,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;;;;;;GASG;AACH,MAAM,OAAO,UAAU;IACrB,YACkB,QAAkB,EACjB,aAA4B;QAD7B,aAAQ,GAAR,QAAQ,CAAU;QACjB,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAoCG,KAAK,CAAI,KAAmB,EAAE,OAAqB;QACxD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,SAAS,CAA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EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;oBAClD,OAAO,cAAc,CAAC;iBACvB;qBAAM;oBACL,MAAM,GAAG,CAAC;iBACX;aACF;QACH,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;;;OAQG;IACI,OAAO,CAAC,OAAqB;QAClC,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport {\n Constants,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n StatusCodes,\n} from \"../../common\";\nimport { DEFAULT_PARTITION_KEY_PATH } from \"../../common/partitionKeys\";\nimport { mergeHeaders, SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Database } from \"../Database\";\nimport { Resource } from \"../Resource\";\nimport { Container } from \"./Container\";\nimport { ContainerDefinition } from \"./ContainerDefinition\";\nimport { ContainerRequest } from \"./ContainerRequest\";\nimport { ContainerResponse } from \"./ContainerResponse\";\nimport { validateOffer } from \"../../utils/offers\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for creating new containers, and reading/querying all containers\n *\n * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists;\n * do this once on application start up.\n */\nexport class Containers {\n constructor(\n public readonly database: Database,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Queries all containers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.\n * @example Read all containers to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @container\",\n * parameters: [\n * {name: \"@container\", value: \"Todo\"}\n * ]\n * };\n * const {body: containerList} = await client.database(\"\").containers.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all containers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.\n * @example Read all containers to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @container\",\n * parameters: [\n * {name: \"@container\", value: \"Todo\"}\n * ]\n * };\n * const {body: containerList} = await client.database(\"\").containers.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.database.url, ResourceType.container);\n const id = getIdFromLink(this.database.url);\n\n return new QueryIterator(\n this.clientContext,\n query,\n options,\n (diagNode: DiagnosticNodeInternal, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n resultFn: (result) => result.DocumentCollections,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n },\n );\n }\n\n /**\n * Creates a container.\n *\n * A container is a named logical container for items.\n *\n * A database may contain zero or more named containers and each container consists of\n * zero or more JSON items.\n *\n * Being schema-free, the items in a container do not need to share the same structure or fields.\n *\n *\n * Since containers are application resources, they can be authorized using either the\n * master key or resource keys.\n *\n * @param body - Represents the body of the container.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public async create(\n body: ContainerRequest,\n options: RequestOptions = {},\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.createInternal(diagnosticNode, body, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async createInternal(\n diagnosticNode: DiagnosticNodeInternal,\n body: ContainerRequest,\n options: RequestOptions = {},\n ): Promise {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n const path = getPathFromLink(this.database.url, ResourceType.container);\n const id = getIdFromLink(this.database.url);\n\n validateOffer(body);\n\n if (body.maxThroughput) {\n const autoscaleParams: {\n maxThroughput: number;\n autoUpgradePolicy?: {\n throughputPolicy: {\n incrementPercent: number;\n };\n };\n } = {\n maxThroughput: body.maxThroughput,\n };\n if (body.autoUpgradePolicy) {\n autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy;\n }\n const autoscaleHeader = JSON.stringify(autoscaleParams);\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.AutoscaleSettings]: autoscaleHeader,\n });\n delete body.maxThroughput;\n delete body.autoUpgradePolicy;\n }\n\n if (body.throughput) {\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.OfferThroughput]: body.throughput,\n });\n delete body.throughput;\n }\n\n if (typeof body.partitionKey === \"string\") {\n if (!body.partitionKey.startsWith(\"/\")) {\n throw new Error(\"Partition key must start with '/'\");\n }\n body.partitionKey = {\n paths: [body.partitionKey],\n };\n }\n\n // If they don't specify a partition key, use the default path\n if (!body.partitionKey || !body.partitionKey.paths) {\n body.partitionKey = {\n paths: [DEFAULT_PARTITION_KEY_PATH],\n };\n }\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n diagnosticNode,\n options,\n });\n const ref = new Container(this.database, response.result.id, this.clientContext);\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /**\n * Checks if a Container exists, and, if it doesn't, creates it.\n * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.\n * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.)\n *\n * A container is a named logical container for items.\n *\n * A database may contain zero or more named containers and each container consists of\n * zero or more JSON items.\n *\n * Being schema-free, the items in a container do not need to share the same structure or fields.\n *\n *\n * Since containers are application resources, they can be authorized using either the\n * master key or resource keys.\n *\n * @param body - Represents the body of the container.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public async createIfNotExists(\n body: ContainerRequest,\n options?: RequestOptions,\n ): Promise {\n if (!body || body.id === null || body.id === undefined) {\n throw new Error(\"body parameter must be an object with an id property\");\n }\n /*\n 1. Attempt to read the Container (based on an assumption that most containers will already exist, so its faster)\n 2. If it fails with NotFound error, attempt to create the container. Else, return the read results.\n */\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n try {\n const readResponse = await this.database\n .container(body.id)\n .readInternal(diagnosticNode, options);\n return readResponse;\n } catch (err: any) {\n if (err.code === StatusCodes.NotFound) {\n const createResponse = await this.createInternal(diagnosticNode, body, options);\n // Must merge the headers to capture RU costskaty\n mergeHeaders(createResponse.headers, err.headers);\n return createResponse;\n } else {\n throw err;\n }\n }\n }, this.clientContext);\n }\n\n /**\n * Read all containers.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time.\n * @example Read all containers to array.\n * ```typescript\n * const {body: containerList} = await client.database(\"\").containers.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts new file mode 100644 index 000000000..3fe8fc426 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts @@ -0,0 +1,13 @@ +/** + * @hidden + */ +export interface PartitionKeyRange { + id: string; + minInclusive: string; + maxExclusive: string; + ridPrefix: number; + throughputFraction: number; + status: string; + parents: string[]; +} +//# sourceMappingURL=PartitionKeyRange.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts.map new file mode 100644 index 000000000..f43b50727 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyRange.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/PartitionKeyRange.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js new file mode 100644 index 000000000..a70003be8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=PartitionKeyRange.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js.map new file mode 100644 index 000000000..d5acf2381 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/PartitionKeyRange.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyRange.js","sourceRoot":"","sources":["../../../../src/client/Container/PartitionKeyRange.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * @hidden\n */\nexport interface PartitionKeyRange {\n id: string;\n minInclusive: string;\n maxExclusive: string;\n ridPrefix: number;\n throughputFraction: number;\n status: string;\n parents: string[];\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts new file mode 100644 index 000000000..397690fe9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts @@ -0,0 +1,9 @@ +/** Interface for setting unique keys on container creation */ +export interface UniqueKeyPolicy { + uniqueKeys: UniqueKey[]; +} +/** Interface for a single unique key passed as part of UniqueKeyPolicy */ +export interface UniqueKey { + paths: string[]; +} +//# sourceMappingURL=UniqueKeyPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts.map new file mode 100644 index 000000000..1f9268a2d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueKeyPolicy.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/UniqueKeyPolicy.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,0EAA0E;AAC1E,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js new file mode 100644 index 000000000..7f2935d1a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=UniqueKeyPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js.map new file mode 100644 index 000000000..19ceea382 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/UniqueKeyPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UniqueKeyPolicy.js","sourceRoot":"","sources":["../../../../src/client/Container/UniqueKeyPolicy.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** Interface for setting unique keys on container creation */\nexport interface UniqueKeyPolicy {\n uniqueKeys: UniqueKey[];\n}\n\n/** Interface for a single unique key passed as part of UniqueKeyPolicy */\nexport interface UniqueKey {\n paths: string[];\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts new file mode 100644 index 000000000..3787c1882 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts @@ -0,0 +1,8 @@ +export { Container } from "./Container"; +export { Containers } from "./Containers"; +export { ContainerDefinition } from "./ContainerDefinition"; +export { ContainerResponse } from "./ContainerResponse"; +export { PartitionKeyRange } from "./PartitionKeyRange"; +export { UniqueKeyPolicy, UniqueKey } from "./UniqueKeyPolicy"; +export { ContainerRequest } from "./ContainerRequest"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts.map new file mode 100644 index 000000000..d2c017e57 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/Container/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js new file mode 100644 index 000000000..7165c7f18 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { Container } from "./Container"; +export { Containers } from "./Containers"; +export { ContainerResponse } from "./ContainerResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js.map new file mode 100644 index 000000000..83d740c1b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Container/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/Container/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { Container } from \"./Container\";\nexport { Containers } from \"./Containers\";\nexport { ContainerDefinition } from \"./ContainerDefinition\";\nexport { ContainerResponse } from \"./ContainerResponse\";\nexport { PartitionKeyRange } from \"./PartitionKeyRange\";\nexport { UniqueKeyPolicy, UniqueKey } from \"./UniqueKeyPolicy\";\nexport { ContainerRequest } from \"./ContainerRequest\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts new file mode 100644 index 000000000..46673f38a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts @@ -0,0 +1,79 @@ +import { ClientContext } from "../../ClientContext"; +import { CosmosClient } from "../../CosmosClient"; +import { RequestOptions } from "../../request"; +import { Container, Containers } from "../Container"; +import { User, Users } from "../User"; +import { DatabaseResponse } from "./DatabaseResponse"; +import { OfferResponse } from "../Offer"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +/** + * Operations for reading or deleting an existing database. + * + * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ +export declare class Database { + readonly client: CosmosClient; + readonly id: string; + private clientContext; + /** + * Used for creating new containers, or querying/reading all containers. + * + * Use `.database(id)` to read, replace, or delete a specific, existing {@link Database} by id. + * + * @example Create a new container + * ```typescript + * const {body: containerDefinition, container} = await client.database("").containers.create({id: ""}); + * ``` + */ + readonly containers: Containers; + /** + * Used for creating new users, or querying/reading all users. + * + * Use `.user(id)` to read, replace, or delete a specific, existing {@link User} by id. + */ + readonly users: Users; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** Returns a new {@link Database} instance. + * + * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself. + */ + constructor(client: CosmosClient, id: string, clientContext: ClientContext); + /** + * Used to read, replace, or delete a specific, existing {@link Database} by id. + * + * Use `.containers` creating new containers, or querying/reading all containers. + * + * @example Delete a container + * ```typescript + * await client.database("").container("").delete(); + * ``` + */ + container(id: string): Container; + /** + * Used to read, replace, or delete a specific, existing {@link User} by id. + * + * Use `.users` for creating new users, or querying/reading all users. + */ + user(id: string): User; + /** Read the definition of the given Database. */ + read(options?: RequestOptions): Promise; + /** + * @hidden + */ + readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise; + /** Delete the given Database. */ + delete(options?: RequestOptions): Promise; + /** + * Gets offer on database. If none exists, returns an OfferResponse with undefined. + */ + readOffer(options?: RequestOptions): Promise; +} +//# sourceMappingURL=Database.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts.map new file mode 100644 index 000000000..044e568a3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../../src/client/Database/Database.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAA0B,MAAM,UAAU,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAQlF;;;;;;;;;GASG;AACH,qBAAa,QAAQ;aA+BD,MAAM,EAAE,YAAY;aACpB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,aAAa;IAhCvB;;;;;;;;;OASG;IACH,SAAgB,UAAU,EAAE,UAAU,CAAC;IACvC;;;;OAIG;IACH,SAAgB,KAAK,EAAE,KAAK,CAAC;IAE7B;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED;;;OAGG;gBAEe,MAAM,EAAE,YAAY,EACpB,EAAE,EAAE,MAAM,EAClB,aAAa,EAAE,aAAa;IAMtC;;;;;;;;;OASG;IACI,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAIvC;;;;OAIG;IACI,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI7B,iDAAiD;IACpC,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAMtE;;OAEG;IACU,YAAY,CACvB,cAAc,EAAE,sBAAsB,EACtC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,gBAAgB,CAAC;IAmB5B,iCAAiC;IACpB,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsBxE;;OAEG;IACU,SAAS,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;CAkC7E"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js new file mode 100644 index 000000000..b5aad3f55 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js @@ -0,0 +1,119 @@ +import { createDatabaseUri, getIdFromLink, getPathFromLink, ResourceType } from "../../common"; +import { Container, Containers } from "../Container"; +import { User, Users } from "../User"; +import { DatabaseResponse } from "./DatabaseResponse"; +import { OfferResponse, Offer } from "../Offer"; +import { getEmptyCosmosDiagnostics, withDiagnostics, withMetadataDiagnostics, } from "../../utils/diagnostics"; +import { MetadataLookUpType } from "../../CosmosDiagnostics"; +/** + * Operations for reading or deleting an existing database. + * + * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ +export class Database { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createDatabaseUri(this.id); + } + /** Returns a new {@link Database} instance. + * + * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself. + */ + constructor(client, id, clientContext) { + this.client = client; + this.id = id; + this.clientContext = clientContext; + this.containers = new Containers(this, this.clientContext); + this.users = new Users(this, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link Database} by id. + * + * Use `.containers` creating new containers, or querying/reading all containers. + * + * @example Delete a container + * ```typescript + * await client.database("").container("").delete(); + * ``` + */ + container(id) { + return new Container(this, id, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link User} by id. + * + * Use `.users` for creating new users, or querying/reading all users. + */ + user(id) { + return new User(this, id, this.clientContext); + } + /** Read the definition of the given Database. */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.readInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async readInternal(diagnosticNode, options) { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.database, + resourceId: id, + options, + diagnosticNode, + }); + return new DatabaseResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + } + /** Delete the given Database. */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.database, + resourceId: id, + options, + diagnosticNode, + }); + return new DatabaseResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Gets offer on database. If none exists, returns an OfferResponse with undefined. + */ + async readOffer(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + const { resource: record } = await withMetadataDiagnostics(async (node) => { + return this.readInternal(node); + }, diagnosticNode, MetadataLookUpType.DatabaseLookUp); + const path = "/offers"; + const url = record._self; + const response = await this.clientContext.queryFeed({ + path, + resourceId: "", + resourceType: ResourceType.offer, + query: `SELECT * from root where root.resource = "${url}"`, + resultFn: (result) => result.Offers, + options, + diagnosticNode, + }); + const offer = response.result[0] + ? new Offer(this.client, response.result[0].id, this.clientContext) + : undefined; + return new OfferResponse(response.result[0], response.headers, response.code, getEmptyCosmosDiagnostics(), offer); + }, this.clientContext); + } +} +//# sourceMappingURL=Database.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js.map new file mode 100644 index 000000000..89a97e34f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Database.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Database.js","sourceRoot":"","sources":["../../../../src/client/Database/Database.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG/F,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAmB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjE,OAAO,EACL,yBAAyB,E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AAE,EAAE;gBACrC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC,EACD,cAAc,EACd,kBAAkB,CAAC,cAAc,CAClC,CAAC;YAEF,MAAM,IAAI,GAAG,SAAS,CAAC;YACvB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC;YAEzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,SAAS,CAA+B;gBAChF,IAAI;gBACJ,UAAU,EAAE,EAAE;gBACd,YAAY,EAAE,YAAY,CAAC,KAAK;gBAChC,KAAK,EAAE,6CAA6C,GAAG,GAAG;gBAC1D,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM;gBACnC,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC9B,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC;gBACnE,CAAC,CAAC,SAAS,CAAC;YACd,OAAO,IAAI,aAAa,CACtB,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAClB,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,yBAAyB,EAAE,EAC3B,KAAK,CACN,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { createDatabaseUri, getIdFromLink, getPathFromLink, ResourceType } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { RequestOptions } from \"../../request\";\nimport { Container, Containers } from \"../Container\";\nimport { User, Users } from \"../User\";\nimport { DatabaseDefinition } from \"./DatabaseDefinition\";\nimport { DatabaseResponse } from \"./DatabaseResponse\";\nimport { OfferResponse, OfferDefinition, Offer } from \"../Offer\";\nimport { Resource } from \"../Resource\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n withMetadataDiagnostics,\n} from \"../../utils/diagnostics\";\nimport { MetadataLookUpType } from \"../../CosmosDiagnostics\";\n\n/**\n * Operations for reading or deleting an existing database.\n *\n * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists;\n * do this once on application start up.\n */\nexport class Database {\n /**\n * Used for creating new containers, or querying/reading all containers.\n *\n * Use `.database(id)` to read, replace, or delete a specific, existing {@link Database} by id.\n *\n * @example Create a new container\n * ```typescript\n * const {body: containerDefinition, container} = await client.database(\"\").containers.create({id: \"\"});\n * ```\n */\n public readonly containers: Containers;\n /**\n * Used for creating new users, or querying/reading all users.\n *\n * Use `.user(id)` to read, replace, or delete a specific, existing {@link User} by id.\n */\n public readonly users: Users;\n\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createDatabaseUri(this.id);\n }\n\n /** Returns a new {@link Database} instance.\n *\n * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself.\n */\n constructor(\n public readonly client: CosmosClient,\n public readonly id: string,\n private clientContext: ClientContext,\n ) {\n this.containers = new Containers(this, this.clientContext);\n this.users = new Users(this, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Database} by id.\n *\n * Use `.containers` creating new containers, or querying/reading all containers.\n *\n * @example Delete a container\n * ```typescript\n * await client.database(\"\").container(\"\").delete();\n * ```\n */\n public container(id: string): Container {\n return new Container(this, id, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link User} by id.\n *\n * Use `.users` for creating new users, or querying/reading all users.\n */\n public user(id: string): User {\n return new User(this, id, this.clientContext);\n }\n\n /** Read the definition of the given Database. */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.readInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async readInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: RequestOptions,\n ): Promise {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.database,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new DatabaseResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /** Delete the given Database. */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.database,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new DatabaseResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Gets offer on database. If none exists, returns an OfferResponse with undefined.\n */\n public async readOffer(options: RequestOptions = {}): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resource: record } = await withMetadataDiagnostics(\n async (node: DiagnosticNodeInternal) => {\n return this.readInternal(node);\n },\n diagnosticNode,\n MetadataLookUpType.DatabaseLookUp,\n );\n\n const path = \"/offers\";\n const url = record._self;\n\n const response = await this.clientContext.queryFeed({\n path,\n resourceId: \"\",\n resourceType: ResourceType.offer,\n query: `SELECT * from root where root.resource = \"${url}\"`,\n resultFn: (result) => result.Offers,\n options,\n diagnosticNode,\n });\n const offer = response.result[0]\n ? new Offer(this.client, response.result[0].id, this.clientContext)\n : undefined;\n return new OfferResponse(\n response.result[0],\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n offer,\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts new file mode 100644 index 000000000..426d19aa9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts @@ -0,0 +1,5 @@ +export interface DatabaseDefinition { + /** The id of the database. */ + id?: string; +} +//# sourceMappingURL=DatabaseDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts.map new file mode 100644 index 000000000..3c6d82533 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/Database/DatabaseDefinition.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,8BAA8B;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js new file mode 100644 index 000000000..16bf22f13 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=DatabaseDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js.map new file mode 100644 index 000000000..9a3e9dcd6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseDefinition.js","sourceRoot":"","sources":["../../../../src/client/Database/DatabaseDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface DatabaseDefinition {\n /** The id of the database. */\n id?: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts new file mode 100644 index 000000000..f2589bdeb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts @@ -0,0 +1,12 @@ +import { DatabaseDefinition } from "./DatabaseDefinition"; +export interface DatabaseRequest extends DatabaseDefinition { + /** Throughput for this database. */ + throughput?: number; + maxThroughput?: number; + autoUpgradePolicy?: { + throughputPolicy: { + incrementPercent: number; + }; + }; +} +//# sourceMappingURL=DatabaseRequest.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts.map new file mode 100644 index 000000000..ccf75b0a3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseRequest.d.ts","sourceRoot":"","sources":["../../../../src/client/Database/DatabaseRequest.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE;QAClB,gBAAgB,EAAE;YAChB,gBAAgB,EAAE,MAAM,CAAC;SAC1B,CAAC;KACH,CAAC;CACH"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js new file mode 100644 index 000000000..c69f19c7e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=DatabaseRequest.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js.map new file mode 100644 index 000000000..3be591736 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseRequest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseRequest.js","sourceRoot":"","sources":["../../../../src/client/Database/DatabaseRequest.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DatabaseDefinition } from \"./DatabaseDefinition\";\n\nexport interface DatabaseRequest extends DatabaseDefinition {\n /** Throughput for this database. */\n throughput?: number;\n maxThroughput?: number;\n autoUpgradePolicy?: {\n throughputPolicy: {\n incrementPercent: number;\n };\n };\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts new file mode 100644 index 000000000..a853b2660 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts @@ -0,0 +1,13 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request/ResourceResponse"; +import { Resource } from "../Resource"; +import { Database } from "./Database"; +import { DatabaseDefinition } from "./DatabaseDefinition"; +/** Response object for Database operations */ +export declare class DatabaseResponse extends ResourceResponse { + constructor(resource: DatabaseDefinition & Resource, headers: CosmosHeaders, statusCode: number, database: Database, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Database} that the returned {@link DatabaseDefinition} corresponds to. */ + readonly database: Database; +} +//# sourceMappingURL=DatabaseResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts.map new file mode 100644 index 000000000..a2ba9ee4c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/Database/DatabaseResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,8CAA8C;AAC9C,qBAAa,gBAAiB,SAAQ,gBAAgB,CAAC,kBAAkB,GAAG,QAAQ,CAAC;gBAEjF,QAAQ,EAAE,kBAAkB,GAAG,QAAQ,EACvC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,iBAAiB;IAKhC,uGAAuG;IACvG,SAAgB,QAAQ,EAAE,QAAQ,CAAC;CACpC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js new file mode 100644 index 000000000..5a069f43b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js @@ -0,0 +1,9 @@ +import { ResourceResponse } from "../../request/ResourceResponse"; +/** Response object for Database operations */ +export class DatabaseResponse extends ResourceResponse { + constructor(resource, headers, statusCode, database, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.database = database; + } +} +//# sourceMappingURL=DatabaseResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js.map new file mode 100644 index 000000000..0337f8392 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/DatabaseResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseResponse.js","sourceRoot":"","sources":["../../../../src/client/Database/DatabaseResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,8CAA8C;AAC9C,MAAM,OAAO,gBAAiB,SAAQ,gBAA+C;IACnF,YACE,QAAuC,EACvC,OAAsB,EACtB,UAAkB,EAClB,QAAkB,EAClB,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request/ResourceResponse\";\nimport { Resource } from \"../Resource\";\nimport { Database } from \"./Database\";\nimport { DatabaseDefinition } from \"./DatabaseDefinition\";\n\n/** Response object for Database operations */\nexport class DatabaseResponse extends ResourceResponse {\n constructor(\n resource: DatabaseDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n database: Database,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.database = database;\n }\n /** A reference to the {@link Database} that the returned {@link DatabaseDefinition} corresponds to. */\n public readonly database: Database;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts new file mode 100644 index 000000000..1a0e1029b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts @@ -0,0 +1,109 @@ +import { ClientContext } from "../../ClientContext"; +import { CosmosClient } from "../../CosmosClient"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions } from "../../request"; +import { Resource } from "../Resource"; +import { DatabaseDefinition } from "./DatabaseDefinition"; +import { DatabaseRequest } from "./DatabaseRequest"; +import { DatabaseResponse } from "./DatabaseResponse"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +/** + * Operations for creating new databases, and reading/querying all databases + * + * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ +export declare class Databases { + readonly client: CosmosClient; + private readonly clientContext; + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database. + */ + constructor(client: CosmosClient, clientContext: ClientContext); + /** + * Queries all databases. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @db", + * parameters: [ + * {name: "@db", value: "Todo"} + * ] + * }; + * const {body: databaseList} = await client.databases.query(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all databases. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @db", + * parameters: [ + * {name: "@db", value: "Todo"} + * ] + * }; + * const {body: databaseList} = await client.databases.query(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Send a request for creating a database. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + create(body: DatabaseRequest, options?: RequestOptions): Promise; + /** + * @hidden + */ + createInternal(diagnosticNode: DiagnosticNodeInternal, body: DatabaseRequest, options?: RequestOptions): Promise; + /** + * Check if a database exists, and if it doesn't, create it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Additional options for the request + */ + createIfNotExists(body: DatabaseRequest, options?: RequestOptions): Promise; + /** + * Reads all databases. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const {body: databaseList} = await client.databases.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; +} +//# sourceMappingURL=Databases.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts.map new file mode 100644 index 000000000..6a4f89947 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Databases.d.ts","sourceRoot":"","sources":["../../../../src/client/Database/Databases.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAuC,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAGlF;;;;;;;;;GASG;AACH,qBAAa,SAAS;aAMF,MAAM,EAAE,YAAY;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,MAAM,EAAE,YAAY,EACnB,aAAa,EAAE,aAAa;IAG/C;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IACrF;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAgBtF;;;;;;;;;;;;;OAaG;IACU,MAAM,CACjB,IAAI,EAAE,eAAe,EACrB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC;IAM5B;;OAEG;IACU,cAAc,CACzB,cAAc,EAAE,sBAAsB,EACtC,IAAI,EAAE,eAAe,EACrB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,gBAAgB,CAAC;IAwD5B;;;;;;;;;;;;;;OAcG;IACU,iBAAiB,CAC5B,IAAI,EAAE,eAAe,EACrB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,gBAAgB,CAAC;IA4B5B;;;;;;;;OAQG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,kBAAkB,GAAG,QAAQ,CAAC;CAGpF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js new file mode 100644 index 000000000..467f7bd96 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js @@ -0,0 +1,158 @@ +import { Constants, isResourceValid, ResourceType, StatusCodes } from "../../common"; +import { mergeHeaders } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { Database } from "./Database"; +import { DatabaseResponse } from "./DatabaseResponse"; +import { validateOffer } from "../../utils/offers"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Operations for creating new databases, and reading/querying all databases + * + * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ +export class Databases { + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database. + */ + constructor(client, clientContext) { + this.client = client; + this.clientContext = clientContext; + } + query(query, options) { + const cb = (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path: "/dbs", + resourceType: ResourceType.database, + resourceId: "", + resultFn: (result) => result.Databases, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }; + return new QueryIterator(this.clientContext, query, options, cb); + } + /** + * Send a request for creating a database. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + async create(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + return this.createInternal(diagnosticNode, body, options); + }, this.clientContext); + } + /** + * @hidden + */ + async createInternal(diagnosticNode, body, options = {}) { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + validateOffer(body); + if (body.maxThroughput) { + const autoscaleParams = { + maxThroughput: body.maxThroughput, + }; + if (body.autoUpgradePolicy) { + autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy; + } + const autoscaleHeaders = JSON.stringify(autoscaleParams); + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants.HttpHeaders.AutoscaleSettings]: autoscaleHeaders, + }); + delete body.maxThroughput; + delete body.autoUpgradePolicy; + } + if (body.throughput) { + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants.HttpHeaders.OfferThroughput]: body.throughput, + }); + delete body.throughput; + } + const path = "/dbs"; // TODO: constant + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.database, + resourceId: undefined, + diagnosticNode, + options, + }); + const ref = new Database(this.client, body.id, this.clientContext); + return new DatabaseResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + } + /** + * Check if a database exists, and if it doesn't, create it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Additional options for the request + */ + async createIfNotExists(body, options) { + if (!body || body.id === null || body.id === undefined) { + throw new Error("body parameter must be an object with an id property"); + } + /* + 1. Attempt to read the Database (based on an assumption that most databases will already exist, so its faster) + 2. If it fails with NotFound error, attempt to create the db. Else, return the read results. + */ + return withDiagnostics(async (diagnosticNode) => { + try { + const readResponse = await this.client + .database(body.id) + .readInternal(diagnosticNode, options); + return readResponse; + } + catch (err) { + if (err.code === StatusCodes.NotFound) { + const createResponse = await this.createInternal(diagnosticNode, body, options); + // Must merge the headers to capture RU costskaty + mergeHeaders(createResponse.headers, err.headers); + return createResponse; + } + else { + throw err; + } + } + }, this.clientContext); + } + // TODO: DatabaseResponse for QueryIterator? + /** + * Reads all databases. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const {body: databaseList} = await client.databases.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } +} +//# sourceMappingURL=Databases.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js.map new file mode 100644 index 000000000..c1d8f5be7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/Databases.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Databases.js","sourceRoot":"","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AE,GAAG,CAAC,OAAO,CAAC,CAAC;oBAClD,OAAO,cAAc,CAAC;iBACvB;qBAAM;oBACL,MAAM,GAAG,CAAC;iBACX;aACF;QACH,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IAED,4CAA4C;IAC5C;;;;;;;;OAQG;IACI,OAAO,CAAC,OAAqB;QAClC,OAAO,IAAI,CAAC,KAAK,CAAgC,SAAS,EAAE,OAAO,CAAC,CAAC;IACvE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, isResourceValid, ResourceType, StatusCodes } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { FetchFunctionCallback, mergeHeaders, SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Database } from \"./Database\";\nimport { DatabaseDefinition } from \"./DatabaseDefinition\";\nimport { DatabaseRequest } from \"./DatabaseRequest\";\nimport { DatabaseResponse } from \"./DatabaseResponse\";\nimport { validateOffer } from \"../../utils/offers\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for creating new databases, and reading/querying all databases\n *\n * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists;\n * do this once on application start up.\n */\nexport class Databases {\n /**\n * @hidden\n * @param client - The parent {@link CosmosClient} for the Database.\n */\n constructor(\n public readonly client: CosmosClient,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Queries all databases.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.\n * @example Read all databases to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @db\",\n * parameters: [\n * {name: \"@db\", value: \"Todo\"}\n * ]\n * };\n * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all databases.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.\n * @example Read all databases to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @db\",\n * parameters: [\n * {name: \"@db\", value: \"Todo\"}\n * ]\n * };\n * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const cb: FetchFunctionCallback = (diagNode: DiagnosticNodeInternal, innerOptions) => {\n return this.clientContext.queryFeed({\n path: \"/dbs\",\n resourceType: ResourceType.database,\n resourceId: \"\",\n resultFn: (result) => result.Databases,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n };\n return new QueryIterator(this.clientContext, query, options, cb);\n }\n\n /**\n * Send a request for creating a database.\n *\n * A database manages users, permissions and a set of containers.\n * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,\n * with the database being the logical container for data.\n *\n * Each Database consists of one or more containers, each of which in turn contain one or more\n * documents. Since databases are an administrative resource, the Service Master Key will be\n * required in order to access and successfully complete any action using the User APIs.\n *\n * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public async create(\n body: DatabaseRequest,\n options: RequestOptions = {},\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.createInternal(diagnosticNode, body, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async createInternal(\n diagnosticNode: DiagnosticNodeInternal,\n body: DatabaseRequest,\n options: RequestOptions = {},\n ): Promise {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n validateOffer(body);\n\n if (body.maxThroughput) {\n const autoscaleParams: {\n maxThroughput: number;\n autoUpgradePolicy?: {\n throughputPolicy: {\n incrementPercent: number;\n };\n };\n } = {\n maxThroughput: body.maxThroughput,\n };\n if (body.autoUpgradePolicy) {\n autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy;\n }\n const autoscaleHeaders = JSON.stringify(autoscaleParams);\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.AutoscaleSettings]: autoscaleHeaders,\n });\n delete body.maxThroughput;\n delete body.autoUpgradePolicy;\n }\n\n if (body.throughput) {\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.OfferThroughput]: body.throughput,\n });\n delete body.throughput;\n }\n\n const path = \"/dbs\"; // TODO: constant\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.database,\n resourceId: undefined,\n diagnosticNode,\n options,\n });\n const ref = new Database(this.client, body.id, this.clientContext);\n return new DatabaseResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /**\n * Check if a database exists, and if it doesn't, create it.\n * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.\n *\n * A database manages users, permissions and a set of containers.\n * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,\n * with the database being the logical container for data.\n *\n * Each Database consists of one or more containers, each of which in turn contain one or more\n * documents. Since databases are an an administrative resource, the Service Master Key will be\n * required in order to access and successfully complete any action using the User APIs.\n *\n * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.\n * @param options - Additional options for the request\n */\n public async createIfNotExists(\n body: DatabaseRequest,\n options?: RequestOptions,\n ): Promise {\n if (!body || body.id === null || body.id === undefined) {\n throw new Error(\"body parameter must be an object with an id property\");\n }\n /*\n 1. Attempt to read the Database (based on an assumption that most databases will already exist, so its faster)\n 2. If it fails with NotFound error, attempt to create the db. Else, return the read results.\n */\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n try {\n const readResponse = await this.client\n .database(body.id)\n .readInternal(diagnosticNode, options);\n return readResponse;\n } catch (err: any) {\n if (err.code === StatusCodes.NotFound) {\n const createResponse = await this.createInternal(diagnosticNode, body, options);\n // Must merge the headers to capture RU costskaty\n mergeHeaders(createResponse.headers, err.headers);\n return createResponse;\n } else {\n throw err;\n }\n }\n }, this.clientContext);\n }\n\n // TODO: DatabaseResponse for QueryIterator?\n /**\n * Reads all databases.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.\n * @example Read all databases to array.\n * ```typescript\n * const {body: databaseList} = await client.databases.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts new file mode 100644 index 000000000..7ea6bf4d1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts @@ -0,0 +1,6 @@ +export { Database } from "./Database"; +export { Databases } from "./Databases"; +export { DatabaseDefinition } from "./DatabaseDefinition"; +export { DatabaseResponse } from "./DatabaseResponse"; +export { DatabaseRequest } from "./DatabaseRequest"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts.map new file mode 100644 index 000000000..ded9cc290 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/Database/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js new file mode 100644 index 000000000..ceb8c7d20 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { Database } from "./Database"; +export { Databases } from "./Databases"; +export { DatabaseResponse } from "./DatabaseResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js.map new file mode 100644 index 000000000..5a8db6461 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Database/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/Database/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { Database } from \"./Database\";\nexport { Databases } from \"./Databases\";\nexport { DatabaseDefinition } from \"./DatabaseDefinition\";\nexport { DatabaseResponse } from \"./DatabaseResponse\";\nexport { DatabaseRequest } from \"./DatabaseRequest\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts new file mode 100644 index 000000000..2ec1a0232 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts @@ -0,0 +1,94 @@ +import { ClientContext } from "../../ClientContext"; +import { PartitionKey } from "../../documents"; +import { RequestOptions } from "../../request"; +import { PatchRequestBody } from "../../utils/patch"; +import { Container } from "../Container"; +import { ItemDefinition } from "./ItemDefinition"; +import { ItemResponse } from "./ItemResponse"; +/** + * Used to perform operations on a specific item. + * + * @see {@link Items} for operations on all items; see `container.items`. + */ +export declare class Item { + readonly container: Container; + readonly id: string; + private readonly clientContext; + private partitionKey; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Item}. + * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers). + */ + constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey); + /** + * Read the item's definition. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype. + * It's recommended to only use interfaces. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Additional options for the request + * + * @example Using custom type for response + * ```typescript + * interface TodoItem { + * title: string; + * done: bool; + * id: string; + * } + * + * let item: TodoItem; + * ({body: item} = await item.read()); + * ``` + */ + read(options?: RequestOptions): Promise>; + /** + * Replace the item's definition. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - The definition to replace the existing {@link Item}'s definition with. + * @param options - Additional options for the request + */ + replace(body: ItemDefinition, options?: RequestOptions): Promise>; + /** + * Replace the item's definition. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - The definition to replace the existing {@link Item}'s definition with. + * @param options - Additional options for the request + */ + replace(body: T, options?: RequestOptions): Promise>; + /** + * Delete the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + delete(options?: RequestOptions): Promise>; + /** + * Perform a JSONPatch on the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + patch(body: PatchRequestBody, options?: RequestOptions): Promise>; +} +//# sourceMappingURL=Item.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts.map new file mode 100644 index 000000000..53eaeadbe --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../../../src/client/Item/Item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAUpD,OAAO,EAAE,YAAY,EAAuD,MAAM,iBAAiB,CAAC;AAEpG,OAAO,EAAE,cAAc,EAAY,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;GAIG;AACH,qBAAa,IAAI;aAgBG,SAAS,EAAE,SAAS;aACpB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAjBhC,OAAO,CAAC,YAAY,CAAuB;IAC3C;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED;;;;;OAKG;gBAEe,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa,EAC7C,YAAY,CAAC,EAAE,YAAY;IAM7B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACU,IAAI,CAAC,CAAC,SAAS,cAAc,GAAG,GAAG,EAC9C,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAwC3B;;;;;;;OAOG;IACI,OAAO,CACZ,IAAI,EAAE,cAAc,EACpB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;IACxC;;;;;;;;;;OAUG;IACI,OAAO,CAAC,CAAC,SAAS,cAAc,EACrC,IAAI,EAAE,CAAC,EACP,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IA0C3B;;;;;;;OAOG;IACU,MAAM,CAAC,CAAC,SAAS,cAAc,GAAG,GAAG,EAChD,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAiC3B;;;;;;;OAOG;IACU,KAAK,CAAC,CAAC,SAAS,cAAc,GAAG,GAAG,EAC/C,IAAI,EAAE,gBAAgB,EACtB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;CAiC5B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js new file mode 100644 index 000000000..7c84f85ad --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js @@ -0,0 +1,164 @@ +import { createDocumentUri, getIdFromLink, getPathFromLink, isItemResourceValid, ResourceType, StatusCodes, } from "../../common"; +import { convertToInternalPartitionKey } from "../../documents"; +import { extractPartitionKeys, undefinedPartitionKey } from "../../extractPartitionKey"; +import { readPartitionKeyDefinition } from "../ClientUtils"; +import { ItemResponse } from "./ItemResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Used to perform operations on a specific item. + * + * @see {@link Items} for operations on all items; see `container.items`. + */ +export class Item { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createDocumentUri(this.container.database.id, this.container.id, this.id); + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Item}. + * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers). + */ + constructor(container, id, clientContext, partitionKey) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + this.partitionKey = + partitionKey === undefined ? undefined : convertToInternalPartitionKey(partitionKey); + } + /** + * Read the item's definition. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype. + * It's recommended to only use interfaces. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Additional options for the request + * + * @example Using custom type for response + * ```typescript + * interface TodoItem { + * title: string; + * done: bool; + * id: string; + * } + * + * let item: TodoItem; + * ({body: item} = await item.read()); + * ``` + */ + async read(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = undefinedPartitionKey(partitionKeyDefinition); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + let response; + try { + response = await this.clientContext.read({ + path, + resourceType: ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + } + catch (error) { + if (error.code !== StatusCodes.NotFound) { + throw error; + } + response = error; + } + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + async replace(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = extractPartitionKeys(body, partitionKeyResponse); + } + const err = {}; + if (!isItemResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + async delete(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = undefinedPartitionKey(partitionKeyResponse); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Perform a JSONPatch on the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + async patch(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = extractPartitionKeys(body, partitionKeyResponse); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.patch({ + body, + path, + resourceType: ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Item.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js.map new file mode 100644 index 000000000..27ce7b15e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Item.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Item.js","sourceRoot":"","sources":["../../../../src/client/Item/Item.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAsC,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AACpG,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAI5D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,IAAI;IAEf;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnF,CAAC;IAED;;;;;OAKG;IACH,YACkB,SAAoB,EACpB,EAAU,EACT,aAA4B,EAC7C,YAA2B;QAHX,cAAS,GAAT,SAAS,CAAW;QACpB,OAAE,GAAF,EAAE,CAAQ;QACT,kBAAa,GAAb,aAAa,CAAe;QAG7C,IAAI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,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAI;gBACjD,IAAI;gBACJ,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,IAAI;gBAC/B,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,cAAc;aACf,CAAC,CAAC;YAEH,OAAO,IAAI,YAAY,CACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,SAAS,EAClB,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createDocumentUri,\n getIdFromLink,\n getPathFromLink,\n isItemResourceValid,\n ResourceType,\n StatusCodes,\n} from \"../../common\";\nimport { PartitionKey, PartitionKeyInternal, convertToInternalPartitionKey } from \"../../documents\";\nimport { extractPartitionKeys, undefinedPartitionKey } from \"../../extractPartitionKey\";\nimport { RequestOptions, Response } from \"../../request\";\nimport { PatchRequestBody } from \"../../utils/patch\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { ItemDefinition } from \"./ItemDefinition\";\nimport { ItemResponse } from \"./ItemResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to perform operations on a specific item.\n *\n * @see {@link Items} for operations on all items; see `container.items`.\n */\nexport class Item {\n private partitionKey: PartitionKeyInternal;\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createDocumentUri(this.container.database.id, this.container.id, this.id);\n }\n\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link Item}.\n * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers).\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n partitionKey?: PartitionKey,\n ) {\n this.partitionKey =\n partitionKey === undefined ? undefined : convertToInternalPartitionKey(partitionKey);\n }\n\n /**\n * Read the item's definition.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype.\n * It's recommended to only use interfaces.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param options - Additional options for the request\n *\n * @example Using custom type for response\n * ```typescript\n * interface TodoItem {\n * title: string;\n * done: bool;\n * id: string;\n * }\n *\n * let item: TodoItem;\n * ({body: item} = await item.read());\n * ```\n */\n public async read(\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = undefinedPartitionKey(partitionKeyDefinition);\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n let response: Response;\n try {\n response = await this.clientContext.read({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n } catch (error: any) {\n if (error.code !== StatusCodes.NotFound) {\n throw error;\n }\n response = error;\n }\n\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the item's definition.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - The definition to replace the existing {@link Item}'s definition with.\n * @param options - Additional options for the request\n */\n public replace(\n body: ItemDefinition,\n options?: RequestOptions,\n ): Promise>;\n /**\n * Replace the item's definition.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - The definition to replace the existing {@link Item}'s definition with.\n * @param options - Additional options for the request\n */\n public replace(\n body: T,\n options?: RequestOptions,\n ): Promise>;\n public async replace(\n body: T,\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = extractPartitionKeys(body, partitionKeyResponse);\n }\n\n const err = {};\n if (!isItemResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * @param options - Additional options for the request\n */\n public async delete(\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = undefinedPartitionKey(partitionKeyResponse);\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Perform a JSONPatch on the item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * @param options - Additional options for the request\n */\n public async patch(\n body: PatchRequestBody,\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = extractPartitionKeys(body, partitionKeyResponse);\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.patch({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts new file mode 100644 index 000000000..4517c24b3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts @@ -0,0 +1,16 @@ +/** + * Items in Cosmos DB are simply JSON objects. + * Most of the Item operations allow for your to provide your own type + * that extends the very simple ItemDefinition. + * + * You cannot use any reserved keys. You can see the reserved key list + * in {@link ItemBody} + */ +export interface ItemDefinition { + /** The id of the item. User settable property. Uniquely identifies the item along with the partition key */ + id?: string; + /** Time to live in seconds for collections with TTL enabled */ + ttl?: number; + [key: string]: any; +} +//# sourceMappingURL=ItemDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts.map new file mode 100644 index 000000000..376e4560b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ItemDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/Item/ItemDefinition.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAGH,MAAM,WAAW,cAAc;IAC7B,4GAA4G;IAC5G,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js new file mode 100644 index 000000000..8231dd2f0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=ItemDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js.map new file mode 100644 index 000000000..88dd20fda --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ItemDefinition.js","sourceRoot":"","sources":["../../../../src/client/Item/ItemDefinition.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Items in Cosmos DB are simply JSON objects.\n * Most of the Item operations allow for your to provide your own type\n * that extends the very simple ItemDefinition.\n *\n * You cannot use any reserved keys. You can see the reserved key list\n * in {@link ItemBody}\n */\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface ItemDefinition {\n /** The id of the item. User settable property. Uniquely identifies the item along with the partition key */\n id?: string;\n /** Time to live in seconds for collections with TTL enabled */\n ttl?: number;\n [key: string]: any;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts new file mode 100644 index 000000000..09e9cf847 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts @@ -0,0 +1,12 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request/ResourceResponse"; +import { Resource } from "../Resource"; +import { Item } from "./Item"; +import { ItemDefinition } from "./ItemDefinition"; +export declare class ItemResponse extends ResourceResponse { + constructor(resource: T & Resource, headers: CosmosHeaders, statusCode: number, subsstatusCode: number, item: Item, diagnostics: CosmosDiagnostics); + /** Reference to the {@link Item} the response corresponds to. */ + readonly item: Item; +} +//# sourceMappingURL=ItemResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts.map new file mode 100644 index 000000000..77dd39273 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ItemResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/Item/ItemResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,qBAAa,YAAY,CAAC,CAAC,SAAS,cAAc,CAAE,SAAQ,gBAAgB,CAAC,CAAC,GAAG,QAAQ,CAAC;gBAEtF,QAAQ,EAAE,CAAC,GAAG,QAAQ,EACtB,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,iBAAiB;IAKhC,iEAAiE;IACjE,SAAgB,IAAI,EAAE,IAAI,CAAC;CAC5B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js new file mode 100644 index 000000000..dc549fed7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js @@ -0,0 +1,8 @@ +import { ResourceResponse } from "../../request/ResourceResponse"; +export class ItemResponse extends ResourceResponse { + constructor(resource, headers, statusCode, subsstatusCode, item, diagnostics) { + super(resource, headers, statusCode, diagnostics, subsstatusCode); + this.item = item; + } +} +//# sourceMappingURL=ItemResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js.map new file mode 100644 index 000000000..a53b0bcf7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/ItemResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ItemResponse.js","sourceRoot":"","sources":["../../../../src/client/Item/ItemResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAKlE,MAAM,OAAO,YAAuC,SAAQ,gBAA8B;IACxF,YACE,QAAsB,EACtB,OAAsB,EACtB,UAAkB,EAClB,cAAsB,EACtB,IAAU,EACV,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request/ResourceResponse\";\nimport { Resource } from \"../Resource\";\nimport { Item } from \"./Item\";\nimport { ItemDefinition } from \"./ItemDefinition\";\n\nexport class ItemResponse extends ResourceResponse {\n constructor(\n resource: T & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n subsstatusCode: number,\n item: Item,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics, subsstatusCode);\n this.item = item;\n }\n /** Reference to the {@link Item} the response corresponds to. */\n public readonly item: Item;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts new file mode 100644 index 000000000..69964ed8a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts @@ -0,0 +1,244 @@ +import { ChangeFeedIterator } from "../../ChangeFeedIterator"; +import { ChangeFeedOptions } from "../../ChangeFeedOptions"; +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions, Response } from "../../request"; +import { Container } from "../Container"; +import { ItemDefinition } from "./ItemDefinition"; +import { ItemResponse } from "./ItemResponse"; +import { OperationResponse, OperationInput, BulkOptions, BulkOperationResponse } from "../../utils/batch"; +import { PartitionKey } from "../../documents"; +import { ChangeFeedPullModelIterator, ChangeFeedIteratorOptions } from "../../client/ChangeFeed"; +/** + * Operations for creating new items, and reading/querying all items + * + * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`. + */ +export declare class Items { + readonly container: Container; + private readonly clientContext; + private partitionKeyRangeCache; + /** + * Create an instance of {@link Items} linked to the parent {@link Container}. + * @param container - The parent container. + * @hidden + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Queries all items. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM Families f WHERE f.lastName = @lastName", + * parameters: [ + * {name: "@lastName", value: "Hendricks"} + * ] + * }; + * const {result: items} = await items.query(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all items. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT firstname FROM Families f WHERE f.lastName = @lastName", + * parameters: [ + * {name: "@lastName", value: "Hendricks"} + * ] + * }; + * const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * + * @deprecated Use `changeFeed` instead. + * + * @example Read from the beginning of the change feed. + * ```javascript + * const iterator = items.readChangeFeed({ startFromBeginning: true }); + * const firstPage = await iterator.fetchNext(); + * const firstPageResults = firstPage.result + * const secondPage = await iterator.fetchNext(); + * ``` + */ + readChangeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * @deprecated Use `changeFeed` instead. + * + */ + readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * @deprecated Use `changeFeed` instead. + */ + readChangeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * @deprecated Use `changeFeed` instead. + */ + readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * + * @example Read from the beginning of the change feed. + * ```javascript + * const iterator = items.readChangeFeed({ startFromBeginning: true }); + * const firstPage = await iterator.fetchNext(); + * const firstPageResults = firstPage.result + * const secondPage = await iterator.fetchNext(); + * ``` + */ + changeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + */ + changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + */ + changeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + */ + changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container. + */ + getChangeFeedIterator(changeFeedIteratorOptions?: ChangeFeedIteratorOptions): ChangeFeedPullModelIterator; + /** + * Read all items. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const {body: containerList} = await items.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Read all items. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const {body: containerList} = await items.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create an item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + create(body: T, options?: RequestOptions): Promise>; + /** + * Upsert an item. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + upsert(body: unknown, options?: RequestOptions): Promise>; + /** + * Upsert an item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + upsert(body: T, options?: RequestOptions): Promise>; + /** + * Execute bulk operations on items. + * + * Bulk takes an array of Operations which are typed based on what the operation does. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is optional at the top level if present in the resourceBody + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.bulk(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param bulkOptions - Optional options object to modify bulk behavior. Pass \{ continueOnError: true \} to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE + * @param options - Used for modifying the request. + */ + bulk(operations: OperationInput[], bulkOptions?: BulkOptions, options?: RequestOptions): Promise; + /** + * Function to create batches based of partition key Ranges. + * @param operations - operations to group + * @param partitionDefinition - PartitionKey definition of container. + * @param options - Request options for bulk request. + * @param batches - Groups to be filled with operations. + */ + private groupOperationsBasedOnPartitionKey; + /** + * Execute transactional batch operations on items. + * + * Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is required as a second argument to batch, but defaults to the default partition key + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.batch(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param options - Used for modifying the request + */ + batch(operations: OperationInput[], partitionKey?: PartitionKey, options?: RequestOptions): Promise>; +} +//# sourceMappingURL=Items.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts.map new file mode 100644 index 000000000..b5bf4f1f2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Items.d.ts","sourceRoot":"","sources":["../../../../src/client/Item/Items.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAyB,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,SAAS,EAAqB,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO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AE,EAC5B,WAAW,CAAC,EAAE,WAAW,EACzB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,qBAAqB,CAAC;IAwEjC;;;;;;OAMG;IACH,OAAO,CAAC,kCAAkC;IA8B1C;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACU,KAAK,CAChB,UAAU,EAAE,cAAc,EAAE,EAC5B,YAAY,CAAC,EAAE,YAAY,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC;CAwB1C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js new file mode 100644 index 000000000..66bd68546 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js @@ -0,0 +1,316 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { v4 } from "uuid"; +const uuid = v4; +import { ChangeFeedIterator } from "../../ChangeFeedIterator"; +import { getIdFromLink, getPathFromLink, isItemResourceValid, ResourceType } from "../../common"; +import { extractPartitionKeys } from "../../extractPartitionKey"; +import { QueryIterator } from "../../queryIterator"; +import { Item } from "./Item"; +import { ItemResponse } from "./ItemResponse"; +import { isKeyInRange, prepareOperations, decorateBatchOperation, splitBatchBasedOnBodySize, } from "../../utils/batch"; +import { readPartitionKeyDefinition } from "../ClientUtils"; +import { assertNotUndefined, isPrimitivePartitionKeyValue } from "../../utils/typeChecks"; +import { hashPartitionKey } from "../../utils/hashing/hash"; +import { PartitionKeyRangeCache } from "../../routing"; +import { changeFeedIteratorBuilder, } from "../../client/ChangeFeed"; +import { validateChangeFeedIteratorOptions } from "../../client/ChangeFeed/changeFeedUtils"; +import { DiagnosticNodeType, } from "../../diagnostics/DiagnosticNodeInternal"; +import { getEmptyCosmosDiagnostics, withDiagnostics, addDignosticChild, } from "../../utils/diagnostics"; +/** + * @hidden + */ +function isChangeFeedOptions(options) { + return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options)); +} +/** + * Operations for creating new items, and reading/querying all items + * + * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`. + */ +export class Items { + /** + * Create an instance of {@link Items} linked to the parent {@link Container}. + * @param container - The parent container. + * @hidden + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + this.partitionKeyRangeCache = new PartitionKeyRangeCache(this.clientContext); + } + query(query, options = {}) { + const path = getPathFromLink(this.container.url, ResourceType.item); + const id = getIdFromLink(this.container.url); + const fetchFunction = async (diagnosticNode, innerOptions) => { + const response = await this.clientContext.queryFeed({ + path, + resourceType: ResourceType.item, + resourceId: id, + resultFn: (result) => (result ? result.Documents : []), + query, + options: innerOptions, + partitionKey: options.partitionKey, + diagnosticNode, + }); + return response; + }; + return new QueryIterator(this.clientContext, query, options, fetchFunction, this.container.url, ResourceType.item); + } + readChangeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions) { + if (isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) { + return this.changeFeed(partitionKeyOrChangeFeedOptions); + } + else { + return this.changeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions); + } + } + changeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions) { + let partitionKey; + if (!changeFeedOptions && isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) { + partitionKey = undefined; + changeFeedOptions = partitionKeyOrChangeFeedOptions; + } + else if (partitionKeyOrChangeFeedOptions !== undefined && + !isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) { + partitionKey = partitionKeyOrChangeFeedOptions; + } + if (!changeFeedOptions) { + changeFeedOptions = {}; + } + const path = getPathFromLink(this.container.url, ResourceType.item); + const id = getIdFromLink(this.container.url); + return new ChangeFeedIterator(this.clientContext, id, path, partitionKey, changeFeedOptions); + } + /** + * Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container. + */ + getChangeFeedIterator(changeFeedIteratorOptions) { + const cfOptions = changeFeedIteratorOptions !== undefined ? changeFeedIteratorOptions : {}; + validateChangeFeedIteratorOptions(cfOptions); + const iterator = changeFeedIteratorBuilder(cfOptions, this.clientContext, this.container, this.partitionKeyRangeCache); + return iterator; + } + readAll(options) { + return this.query("SELECT * from c", options); + } + /** + * Create an item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + async create(body, options = {}) { + // Generate random document id if the id is missing in the payload and + // options.disableAutomaticIdGeneration != true + return withDiagnostics(async (diagnosticNode) => { + if ((body.id === undefined || body.id === "") && !options.disableAutomaticIdGeneration) { + body.id = uuid(); + } + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + const partitionKey = extractPartitionKeys(body, partitionKeyDefinition); + const err = {}; + if (!isItemResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, ResourceType.item); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.item, + resourceId: id, + diagnosticNode, + options, + partitionKey, + }); + const ref = new Item(this.container, response.result.id, this.clientContext, partitionKey); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + async upsert(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + // Generate random document id if the id is missing in the payload and + // options.disableAutomaticIdGeneration != true + if ((body.id === undefined || body.id === "") && !options.disableAutomaticIdGeneration) { + body.id = uuid(); + } + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + const partitionKey = extractPartitionKeys(body, partitionKeyDefinition); + const err = {}; + if (!isItemResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, ResourceType.item); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.upsert({ + body, + path, + resourceType: ResourceType.item, + resourceId: id, + options, + partitionKey, + diagnosticNode, + }); + const ref = new Item(this.container, response.result.id, this.clientContext, partitionKey); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Execute bulk operations on items. + * + * Bulk takes an array of Operations which are typed based on what the operation does. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is optional at the top level if present in the resourceBody + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.bulk(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param bulkOptions - Optional options object to modify bulk behavior. Pass \{ continueOnError: true \} to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE + * @param options - Used for modifying the request. + */ + async bulk(operations, bulkOptions, options) { + return withDiagnostics(async (diagnosticNode) => { + const { resources: partitionKeyRanges } = await this.container + .readPartitionKeyRanges() + .fetchAll(); + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + const batches = partitionKeyRanges.map((keyRange) => { + return { + min: keyRange.minInclusive, + max: keyRange.maxExclusive, + rangeId: keyRange.id, + indexes: [], + operations: [], + }; + }); + this.groupOperationsBasedOnPartitionKey(operations, partitionKeyDefinition, options, batches); + const path = getPathFromLink(this.container.url, ResourceType.item); + const orderedResponses = []; + await Promise.all(batches + .filter((batch) => batch.operations.length) + .flatMap((batch) => splitBatchBasedOnBodySize(batch)) + .map(async (batch) => { + if (batch.operations.length > 100) { + throw new Error("Cannot run bulk request with more than 100 operations per partition"); + } + try { + const response = await addDignosticChild(async (childNode) => this.clientContext.bulk({ + body: batch.operations, + partitionKeyRangeId: batch.rangeId, + path, + resourceId: this.container.url, + bulkOptions, + options, + diagnosticNode: childNode, + }), diagnosticNode, DiagnosticNodeType.BATCH_REQUEST); + response.result.forEach((operationResponse, index) => { + orderedResponses[batch.indexes[index]] = operationResponse; + }); + } + catch (err) { + // In the case of 410 errors, we need to recompute the partition key ranges + // and redo the batch request, however, 410 errors occur for unsupported + // partition key types as well since we don't support them, so for now we throw + if (err.code === 410) { + throw new Error("Partition key error. Either the partitions have split or an operation has an unsupported partitionKey type" + + err.message); + } + throw new Error(`Bulk request errored with: ${err.message}`); + } + })); + const response = orderedResponses; + response.diagnostics = diagnosticNode.toDiagnostic(this.clientContext.getClientConfig()); + return response; + }, this.clientContext); + } + /** + * Function to create batches based of partition key Ranges. + * @param operations - operations to group + * @param partitionDefinition - PartitionKey definition of container. + * @param options - Request options for bulk request. + * @param batches - Groups to be filled with operations. + */ + groupOperationsBasedOnPartitionKey(operations, partitionDefinition, options, batches) { + operations.forEach((operationInput, index) => { + const { operation, partitionKey } = prepareOperations(operationInput, partitionDefinition, options); + const hashed = hashPartitionKey(assertNotUndefined(partitionKey, "undefined value for PartitionKey is not expected during grouping of bulk operations."), partitionDefinition); + const batchForKey = assertNotUndefined(batches.find((batch) => { + return isKeyInRange(batch.min, batch.max, hashed); + }), "No suitable Batch found."); + batchForKey.operations.push(operation); + batchForKey.indexes.push(index); + }); + } + /** + * Execute transactional batch operations on items. + * + * Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is required as a second argument to batch, but defaults to the default partition key + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.batch(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param options - Used for modifying the request + */ + async batch(operations, partitionKey, options) { + return withDiagnostics(async (diagnosticNode) => { + operations.map((operation) => decorateBatchOperation(operation, options)); + const path = getPathFromLink(this.container.url, ResourceType.item); + if (operations.length > 100) { + throw new Error("Cannot run batch request with more than 100 operations per partition"); + } + try { + const response = await this.clientContext.batch({ + body: operations, + partitionKey, + path, + resourceId: this.container.url, + options, + diagnosticNode, + }); + return response; + } + catch (err) { + throw new Error(`Batch request error: ${err.message}`); + } + }, this.clientContext); + } +} +//# sourceMappingURL=Items.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js.map new file mode 100644 index 000000000..e75b4e7e0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/Items.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Items.js","sourceRoot":"","sources":["../../../../src/client/Item/Items.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAEL,YAAY,EACZ,iBAAiB,EAIjB,sBAAsB,EACtB,yBAAyB,GAE1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,4BAA4B,EAAE,MAAM,wBAA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AAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { v4 } from \"uuid\";\nconst uuid = v4;\nimport { ChangeFeedIterator } from \"../../ChangeFeedIterator\";\nimport { ChangeFeedOptions } from \"../../ChangeFeedOptions\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { getIdFromLink, getPathFromLink, isItemResourceValid, ResourceType } from \"../../common\";\nimport { extractPartitionKeys } from \"../../extractPartitionKey\";\nimport { FetchFunctionCallback, SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions, Response } from \"../../request\";\nimport { Container, PartitionKeyRange } from \"../Container\";\nimport { Item } from \"./Item\";\nimport { ItemDefinition } from \"./ItemDefinition\";\nimport { ItemResponse } from \"./ItemResponse\";\nimport {\n Batch,\n isKeyInRange,\n prepareOperations,\n OperationResponse,\n OperationInput,\n BulkOptions,\n decorateBatchOperation,\n splitBatchBasedOnBodySize,\n BulkOperationResponse,\n} from \"../../utils/batch\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { assertNotUndefined, isPrimitivePartitionKeyValue } from \"../../utils/typeChecks\";\nimport { hashPartitionKey } from \"../../utils/hashing/hash\";\nimport { PartitionKey, PartitionKeyDefinition } from \"../../documents\";\nimport { PartitionKeyRangeCache } from \"../../routing\";\nimport {\n ChangeFeedPullModelIterator,\n ChangeFeedIteratorOptions,\n changeFeedIteratorBuilder,\n} from \"../../client/ChangeFeed\";\nimport { validateChangeFeedIteratorOptions } from \"../../client/ChangeFeed/changeFeedUtils\";\nimport {\n DiagnosticNodeInternal,\n DiagnosticNodeType,\n} from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n addDignosticChild,\n} from \"../../utils/diagnostics\";\n\n/**\n * @hidden\n */\nfunction isChangeFeedOptions(options: unknown): options is ChangeFeedOptions {\n return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options));\n}\n\n/**\n * Operations for creating new items, and reading/querying all items\n *\n * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`.\n */\nexport class Items {\n private partitionKeyRangeCache: PartitionKeyRangeCache;\n /**\n * Create an instance of {@link Items} linked to the parent {@link Container}.\n * @param container - The parent container.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {\n this.partitionKeyRangeCache = new PartitionKeyRangeCache(this.clientContext);\n }\n\n /**\n * Queries all items.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM Families f WHERE f.lastName = @lastName\",\n * parameters: [\n * {name: \"@lastName\", value: \"Hendricks\"}\n * ]\n * };\n * const {result: items} = await items.query(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all items.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT firstname FROM Families f WHERE f.lastName = @lastName\",\n * parameters: [\n * {name: \"@lastName\", value: \"Hendricks\"}\n * ]\n * };\n * const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: string | SqlQuerySpec, options: FeedOptions = {}): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n\n const fetchFunction: FetchFunctionCallback = async (\n diagnosticNode: DiagnosticNodeInternal,\n innerOptions: FeedOptions,\n ) => {\n const response = await this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n resultFn: (result) => (result ? result.Documents : []),\n query,\n options: innerOptions,\n partitionKey: options.partitionKey,\n diagnosticNode,\n });\n return response;\n };\n\n return new QueryIterator(\n this.clientContext,\n query,\n options,\n fetchFunction,\n this.container.url,\n ResourceType.item,\n );\n }\n\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n *\n * @deprecated Use `changeFeed` instead.\n *\n * @example Read from the beginning of the change feed.\n * ```javascript\n * const iterator = items.readChangeFeed({ startFromBeginning: true });\n * const firstPage = await iterator.fetchNext();\n * const firstPageResults = firstPage.result\n * const secondPage = await iterator.fetchNext();\n * ```\n */\n public readChangeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n * @deprecated Use `changeFeed` instead.\n *\n */\n public readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n * @deprecated Use `changeFeed` instead.\n */\n public readChangeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n * @deprecated Use `changeFeed` instead.\n */\n public readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n public readChangeFeed(\n partitionKeyOrChangeFeedOptions?: PartitionKey | ChangeFeedOptions,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator {\n if (isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) {\n return this.changeFeed(partitionKeyOrChangeFeedOptions);\n } else {\n return this.changeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions);\n }\n }\n\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n *\n * @example Read from the beginning of the change feed.\n * ```javascript\n * const iterator = items.readChangeFeed({ startFromBeginning: true });\n * const firstPage = await iterator.fetchNext();\n * const firstPageResults = firstPage.result\n * const secondPage = await iterator.fetchNext();\n * ```\n */\n public changeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n */\n public changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n */\n public changeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n */\n public changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n public changeFeed(\n partitionKeyOrChangeFeedOptions?: PartitionKey | ChangeFeedOptions,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator {\n let partitionKey: PartitionKey;\n if (!changeFeedOptions && isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) {\n partitionKey = undefined;\n changeFeedOptions = partitionKeyOrChangeFeedOptions;\n } else if (\n partitionKeyOrChangeFeedOptions !== undefined &&\n !isChangeFeedOptions(partitionKeyOrChangeFeedOptions)\n ) {\n partitionKey = partitionKeyOrChangeFeedOptions;\n }\n\n if (!changeFeedOptions) {\n changeFeedOptions = {};\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n return new ChangeFeedIterator(this.clientContext, id, path, partitionKey, changeFeedOptions);\n }\n\n /**\n * Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container.\n */\n public getChangeFeedIterator(\n changeFeedIteratorOptions?: ChangeFeedIteratorOptions,\n ): ChangeFeedPullModelIterator {\n const cfOptions = changeFeedIteratorOptions !== undefined ? changeFeedIteratorOptions : {};\n validateChangeFeedIteratorOptions(cfOptions);\n const iterator = changeFeedIteratorBuilder(\n cfOptions,\n this.clientContext,\n this.container,\n this.partitionKeyRangeCache,\n );\n return iterator;\n }\n\n /**\n * Read all items.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const {body: containerList} = await items.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator;\n /**\n * Read all items.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const {body: containerList} = await items.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator;\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(\"SELECT * from c\", options);\n }\n\n /**\n * Create an item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - Represents the body of the item. Can contain any number of user defined properties.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n */\n public async create(\n body: T,\n options: RequestOptions = {},\n ): Promise> {\n // Generate random document id if the id is missing in the payload and\n // options.disableAutomaticIdGeneration != true\n\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if ((body.id === undefined || body.id === \"\") && !options.disableAutomaticIdGeneration) {\n body.id = uuid();\n }\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n const partitionKey = extractPartitionKeys(body, partitionKeyDefinition);\n\n const err = {};\n if (!isItemResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n diagnosticNode,\n options,\n partitionKey,\n });\n\n const ref = new Item(\n this.container,\n (response.result as any).id,\n this.clientContext,\n partitionKey,\n );\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Upsert an item.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - Represents the body of the item. Can contain any number of user defined properties.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n */\n public async upsert(\n body: unknown,\n options?: RequestOptions,\n ): Promise>;\n /**\n * Upsert an item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - Represents the body of the item. Can contain any number of user defined properties.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n */\n public async upsert(\n body: T,\n options?: RequestOptions,\n ): Promise>;\n public async upsert(\n body: T,\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n // Generate random document id if the id is missing in the payload and\n // options.disableAutomaticIdGeneration != true\n if ((body.id === undefined || body.id === \"\") && !options.disableAutomaticIdGeneration) {\n body.id = uuid();\n }\n\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n const partitionKey = extractPartitionKeys(body, partitionKeyDefinition);\n\n const err = {};\n if (!isItemResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.upsert({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey,\n diagnosticNode,\n });\n\n const ref = new Item(\n this.container,\n (response.result as any).id,\n this.clientContext,\n partitionKey,\n );\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Execute bulk operations on items.\n *\n * Bulk takes an array of Operations which are typed based on what the operation does.\n * The choices are: Create, Upsert, Read, Replace, and Delete\n *\n * Usage example:\n * ```typescript\n * // partitionKey is optional at the top level if present in the resourceBody\n * const operations: OperationInput[] = [\n * {\n * operationType: \"Create\",\n * resourceBody: { id: \"doc1\", name: \"sample\", key: \"A\" }\n * },\n * {\n * operationType: \"Upsert\",\n * partitionKey: 'A',\n * resourceBody: { id: \"doc2\", name: \"other\", key: \"A\" }\n * }\n * ]\n *\n * await database.container.items.bulk(operations)\n * ```\n *\n * @param operations - List of operations. Limit 100\n * @param bulkOptions - Optional options object to modify bulk behavior. Pass \\{ continueOnError: true \\} to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE\n * @param options - Used for modifying the request.\n */\n public async bulk(\n operations: OperationInput[],\n bulkOptions?: BulkOptions,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resources: partitionKeyRanges } = await this.container\n .readPartitionKeyRanges()\n .fetchAll();\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n const batches: Batch[] = partitionKeyRanges.map((keyRange: PartitionKeyRange) => {\n return {\n min: keyRange.minInclusive,\n max: keyRange.maxExclusive,\n rangeId: keyRange.id,\n indexes: [],\n operations: [],\n };\n });\n\n this.groupOperationsBasedOnPartitionKey(operations, partitionKeyDefinition, options, batches);\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n\n const orderedResponses: OperationResponse[] = [];\n await Promise.all(\n batches\n .filter((batch: Batch) => batch.operations.length)\n .flatMap((batch: Batch) => splitBatchBasedOnBodySize(batch))\n .map(async (batch: Batch) => {\n if (batch.operations.length > 100) {\n throw new Error(\n \"Cannot run bulk request with more than 100 operations per partition\",\n );\n }\n try {\n const response = await addDignosticChild(\n async (childNode: DiagnosticNodeInternal) =>\n this.clientContext.bulk({\n body: batch.operations,\n partitionKeyRangeId: batch.rangeId,\n path,\n resourceId: this.container.url,\n bulkOptions,\n options,\n diagnosticNode: childNode,\n }),\n diagnosticNode,\n DiagnosticNodeType.BATCH_REQUEST,\n );\n response.result.forEach((operationResponse: OperationResponse, index: number) => {\n orderedResponses[batch.indexes[index]] = operationResponse;\n });\n } catch (err: any) {\n // In the case of 410 errors, we need to recompute the partition key ranges\n // and redo the batch request, however, 410 errors occur for unsupported\n // partition key types as well since we don't support them, so for now we throw\n if (err.code === 410) {\n throw new Error(\n \"Partition key error. Either the partitions have split or an operation has an unsupported partitionKey type\" +\n err.message,\n );\n }\n throw new Error(`Bulk request errored with: ${err.message}`);\n }\n }),\n );\n const response: any = orderedResponses;\n response.diagnostics = diagnosticNode.toDiagnostic(this.clientContext.getClientConfig());\n return response;\n }, this.clientContext);\n }\n\n /**\n * Function to create batches based of partition key Ranges.\n * @param operations - operations to group\n * @param partitionDefinition - PartitionKey definition of container.\n * @param options - Request options for bulk request.\n * @param batches - Groups to be filled with operations.\n */\n private groupOperationsBasedOnPartitionKey(\n operations: OperationInput[],\n partitionDefinition: PartitionKeyDefinition,\n options: RequestOptions | undefined,\n batches: Batch[],\n ) {\n operations.forEach((operationInput, index: number) => {\n const { operation, partitionKey } = prepareOperations(\n operationInput,\n partitionDefinition,\n options,\n );\n const hashed = hashPartitionKey(\n assertNotUndefined(\n partitionKey,\n \"undefined value for PartitionKey is not expected during grouping of bulk operations.\",\n ),\n partitionDefinition,\n );\n const batchForKey = assertNotUndefined(\n batches.find((batch: Batch) => {\n return isKeyInRange(batch.min, batch.max, hashed);\n }),\n \"No suitable Batch found.\",\n );\n batchForKey.operations.push(operation);\n batchForKey.indexes.push(index);\n });\n }\n\n /**\n * Execute transactional batch operations on items.\n *\n * Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails.\n * The choices are: Create, Upsert, Read, Replace, and Delete\n *\n * Usage example:\n * ```typescript\n * // partitionKey is required as a second argument to batch, but defaults to the default partition key\n * const operations: OperationInput[] = [\n * {\n * operationType: \"Create\",\n * resourceBody: { id: \"doc1\", name: \"sample\", key: \"A\" }\n * },\n * {\n * operationType: \"Upsert\",\n * partitionKey: 'A',\n * resourceBody: { id: \"doc2\", name: \"other\", key: \"A\" }\n * }\n * ]\n *\n * await database.container.items.batch(operations)\n * ```\n *\n * @param operations - List of operations. Limit 100\n * @param options - Used for modifying the request\n */\n public async batch(\n operations: OperationInput[],\n partitionKey?: PartitionKey,\n options?: RequestOptions,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n operations.map((operation) => decorateBatchOperation(operation, options));\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n\n if (operations.length > 100) {\n throw new Error(\"Cannot run batch request with more than 100 operations per partition\");\n }\n try {\n const response: Response = await this.clientContext.batch({\n body: operations,\n partitionKey,\n path,\n resourceId: this.container.url,\n options,\n diagnosticNode,\n });\n return response;\n } catch (err: any) {\n throw new Error(`Batch request error: ${err.message}`);\n }\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts new file mode 100644 index 000000000..e077d76de --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts @@ -0,0 +1,5 @@ +export { Item } from "./Item"; +export { Items } from "./Items"; +export { ItemResponse } from "./ItemResponse"; +export { ItemDefinition } from "./ItemDefinition"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts.map new file mode 100644 index 000000000..bac4ca002 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/Item/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js new file mode 100644 index 000000000..4c05a207e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { Item } from "./Item"; +export { Items } from "./Items"; +export { ItemResponse } from "./ItemResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js.map new file mode 100644 index 000000000..037472d44 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Item/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/Item/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { Item } from \"./Item\";\nexport { Items } from \"./Items\";\nexport { ItemResponse } from \"./ItemResponse\";\nexport { ItemDefinition } from \"./ItemDefinition\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts new file mode 100644 index 000000000..390d93b94 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts @@ -0,0 +1,35 @@ +import { ClientContext } from "../../ClientContext"; +import { CosmosClient } from "../../CosmosClient"; +import { RequestOptions } from "../../request"; +import { OfferDefinition } from "./OfferDefinition"; +import { OfferResponse } from "./OfferResponse"; +/** + * Use to read or replace an existing {@link Offer} by id. + * + * @see {@link Offers} to query or read all offers. + */ +export declare class Offer { + readonly client: CosmosClient; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database Account. + * @param id - The id of the given {@link Offer}. + */ + constructor(client: CosmosClient, id: string, clientContext: ClientContext); + /** + * Read the {@link OfferDefinition} for the given {@link Offer}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link Offer} with the specified {@link OfferDefinition}. + * @param body - The specified {@link OfferDefinition} + */ + replace(body: OfferDefinition, options?: RequestOptions): Promise; +} +//# sourceMappingURL=Offer.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts.map new file mode 100644 index 000000000..ab4215917 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Offer.d.ts","sourceRoot":"","sources":["../../../../src/client/Offer/Offer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,qBAAa,KAAK;aAaE,MAAM,EAAE,YAAY;aACpB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAdhC;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD;;;;OAIG;gBAEe,MAAM,EAAE,YAAY,EACpB,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa;IAG/C;;OAEG;IACU,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBnE;;;OAGG;IACU,OAAO,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAuB9F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js new file mode 100644 index 000000000..7f52ff598 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js @@ -0,0 +1,63 @@ +import { Constants, isResourceValid, ResourceType } from "../../common"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import { OfferResponse } from "./OfferResponse"; +/** + * Use to read or replace an existing {@link Offer} by id. + * + * @see {@link Offers} to query or read all offers. + */ +export class Offer { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return `/${Constants.Path.OffersPathSegment}/${this.id}`; + } + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database Account. + * @param id - The id of the given {@link Offer}. + */ + constructor(client, id, clientContext) { + this.client = client; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link OfferDefinition} for the given {@link Offer}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const response = await this.clientContext.read({ + path: this.url, + resourceType: ResourceType.offer, + resourceId: this.id, + options, + diagnosticNode, + }); + return new OfferResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics(), this); + }, this.clientContext); + } + /** + * Replace the given {@link Offer} with the specified {@link OfferDefinition}. + * @param body - The specified {@link OfferDefinition} + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const response = await this.clientContext.replace({ + body, + path: this.url, + resourceType: ResourceType.offer, + resourceId: this.id, + options, + diagnosticNode, + }); + return new OfferResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics(), this); + }, this.clientContext); + } +} +//# sourceMappingURL=Offer.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js.map new file mode 100644 index 000000000..00cd46325 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Offer.js","sourceRoot":"","sources":["../../../../src/client/Offer/Offer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAIrF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAChB;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;IAC3D,CAAC;IACD;;;;OAIG;IACH,YACkB,MAAoB,EACpB,EAAU,EACT,aAA4B;QAF7B,WAAM,GAAN,MAAM,CAAc;QACpB,OAAE,GAAF,EAAE,CAAQ;QACT,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,OAAwB;QACxC,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAkB;gBAC9D,IAAI,EAAE,IAAI,CAAC,GAAG;gBACd,YAAY,EAAE,YAAY,CAAC,KAAK;gBAChC,UAAU,EAAE,IAAI,CAAC,EAAE;gBACnB,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,aAAa,CACtB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,yBAAyB,EAAE,EAC3B,IAAI,CACL,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,OAAwB;QAClE,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,GAAG,GAAG,EAAE,CAAC;YACf,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;gBAC/B,MAAM,GAAG,CAAC;aACX;YACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAkB;gBACjE,IAAI;gBACJ,IAAI,EAAE,IAAI,CAAC,GAAG;gBACd,YAAY,EAAE,YAAY,CAAC,KAAK;gBAChC,UAAU,EAAE,IAAI,CAAC,EAAE;gBACnB,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,aAAa,CACtB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,yBAAyB,EAAE,EAC3B,IAAI,CACL,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, isResourceValid, ResourceType } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RequestOptions } from \"../../request\";\nimport { OfferDefinition } from \"./OfferDefinition\";\nimport { OfferResponse } from \"./OfferResponse\";\n\n/**\n * Use to read or replace an existing {@link Offer} by id.\n *\n * @see {@link Offers} to query or read all offers.\n */\nexport class Offer {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return `/${Constants.Path.OffersPathSegment}/${this.id}`;\n }\n /**\n * @hidden\n * @param client - The parent {@link CosmosClient} for the Database Account.\n * @param id - The id of the given {@link Offer}.\n */\n constructor(\n public readonly client: CosmosClient,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link OfferDefinition} for the given {@link Offer}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const response = await this.clientContext.read({\n path: this.url,\n resourceType: ResourceType.offer,\n resourceId: this.id,\n options,\n diagnosticNode,\n });\n return new OfferResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n this,\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link Offer} with the specified {@link OfferDefinition}.\n * @param body - The specified {@link OfferDefinition}\n */\n public async replace(body: OfferDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n const response = await this.clientContext.replace({\n body,\n path: this.url,\n resourceType: ResourceType.offer,\n resourceId: this.id,\n options,\n diagnosticNode,\n });\n return new OfferResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n this,\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts new file mode 100644 index 000000000..09ff1145c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts @@ -0,0 +1,22 @@ +export interface OfferDefinition { + id?: string; + offerType?: string; + offerVersion?: string; + resource?: string; + offerResourceId?: string; + content?: { + offerThroughput: number; + offerIsRUPerMinuteThroughputEnabled: boolean; + offerMinimumThroughputParameters?: { + maxThroughputEverProvisioned: number; + maxConsumedStorageEverInKB: number; + }; + offerAutopilotSettings?: { + tier: number; + maximumTierThroughput: number; + autoUpgrade: boolean; + maxThroughput: number; + }; + }; +} +//# sourceMappingURL=OfferDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts.map new file mode 100644 index 000000000..70b15bfd2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"OfferDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/Offer/OfferDefinition.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE;QACR,eAAe,EAAE,MAAM,CAAC;QACxB,mCAAmC,EAAE,OAAO,CAAC;QAC7C,gCAAgC,CAAC,EAAE;YACjC,4BAA4B,EAAE,MAAM,CAAC;YACrC,0BAA0B,EAAE,MAAM,CAAC;SACpC,CAAC;QACF,sBAAsB,CAAC,EAAE;YACvB,IAAI,EAAE,MAAM,CAAC;YACb,qBAAqB,EAAE,MAAM,CAAC;YAC9B,WAAW,EAAE,OAAO,CAAC;YACrB,aAAa,EAAE,MAAM,CAAC;SACvB,CAAC;KACH,CAAC;CACH"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js new file mode 100644 index 000000000..f71ebb9dc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=OfferDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js.map new file mode 100644 index 000000000..bdbf53349 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OfferDefinition.js","sourceRoot":"","sources":["../../../../src/client/Offer/OfferDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface OfferDefinition {\n id?: string;\n offerType?: string; // TODO: enum?\n offerVersion?: string; // TODO: enum?\n resource?: string;\n offerResourceId?: string;\n content?: {\n offerThroughput: number;\n offerIsRUPerMinuteThroughputEnabled: boolean;\n offerMinimumThroughputParameters?: {\n maxThroughputEverProvisioned: number;\n maxConsumedStorageEverInKB: number;\n };\n offerAutopilotSettings?: {\n tier: number;\n maximumTierThroughput: number;\n autoUpgrade: boolean;\n maxThroughput: number;\n };\n };\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts new file mode 100644 index 000000000..e3eca48ad --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts @@ -0,0 +1,12 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request"; +import { Resource } from "../Resource"; +import { Offer } from "./Offer"; +import { OfferDefinition } from "./OfferDefinition"; +export declare class OfferResponse extends ResourceResponse { + constructor(resource: OfferDefinition & Resource, headers: CosmosHeaders, statusCode: number, diagnostics: CosmosDiagnostics, offer?: Offer); + /** A reference to the {@link Offer} corresponding to the returned {@link OfferDefinition}. */ + readonly offer: Offer; +} +//# sourceMappingURL=OfferResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts.map new file mode 100644 index 000000000..b8920f0b0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"OfferResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/Offer/OfferResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,aAAc,SAAQ,gBAAgB,CAAC,eAAe,GAAG,QAAQ,CAAC;gBAE3E,QAAQ,EAAE,eAAe,GAAG,QAAQ,EACpC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,iBAAiB,EAC9B,KAAK,CAAC,EAAE,KAAK;IAKf,8FAA8F;IAC9F,SAAgB,KAAK,EAAE,KAAK,CAAC;CAC9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js new file mode 100644 index 000000000..f9cda4bea --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js @@ -0,0 +1,8 @@ +import { ResourceResponse } from "../../request"; +export class OfferResponse extends ResourceResponse { + constructor(resource, headers, statusCode, diagnostics, offer) { + super(resource, headers, statusCode, diagnostics); + this.offer = offer; + } +} +//# sourceMappingURL=OfferResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js.map new file mode 100644 index 000000000..550508dbd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/OfferResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OfferResponse.js","sourceRoot":"","sources":["../../../../src/client/Offer/OfferResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,OAAO,aAAc,SAAQ,gBAA4C;IAC7E,YACE,QAAoC,EACpC,OAAsB,EACtB,UAAkB,EAClB,WAA8B,EAC9B,KAAa;QAEb,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Offer } from \"./Offer\";\nimport { OfferDefinition } from \"./OfferDefinition\";\n\nexport class OfferResponse extends ResourceResponse {\n constructor(\n resource: OfferDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n diagnostics: CosmosDiagnostics,\n offer?: Offer,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.offer = offer;\n }\n /** A reference to the {@link Offer} corresponding to the returned {@link OfferDefinition}. */\n public readonly offer: Offer;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts new file mode 100644 index 000000000..3c3a7ead8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts @@ -0,0 +1,40 @@ +import { ClientContext } from "../../ClientContext"; +import { CosmosClient } from "../../CosmosClient"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions } from "../../request"; +import { Resource } from "../Resource"; +import { OfferDefinition } from "./OfferDefinition"; +/** + * Use to query or read all Offers. + * + * @see {@link Offer} to read or replace an existing {@link Offer} by id. + */ +export declare class Offers { + readonly client: CosmosClient; + private readonly clientContext; + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the offers. + */ + constructor(client: CosmosClient, clientContext: ClientContext); + /** + * Query all offers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all offers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all offers. + * @example Read all offers to array. + * ```typescript + * const {body: offerList} = await client.offers.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; +} +//# sourceMappingURL=Offers.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts.map new file mode 100644 index 000000000..571ab27bc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Offers.d.ts","sourceRoot":"","sources":["../../../../src/client/Offer/Offers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;;GAIG;AACH,qBAAa,MAAM;aAMC,MAAM,EAAE,YAAY;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,MAAM,EAAE,YAAY,EACnB,aAAa,EAAE,aAAa;IAG/C;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IAC5E;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAe7E;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,eAAe,GAAG,QAAQ,CAAC;CAGjF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js new file mode 100644 index 000000000..71ae886a9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js @@ -0,0 +1,41 @@ +import { ResourceType } from "../../common"; +import { QueryIterator } from "../../queryIterator"; +/** + * Use to query or read all Offers. + * + * @see {@link Offer} to read or replace an existing {@link Offer} by id. + */ +export class Offers { + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the offers. + */ + constructor(client, clientContext) { + this.client = client; + this.clientContext = clientContext; + } + query(query, options) { + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path: "/offers", + resourceType: ResourceType.offer, + resourceId: "", + resultFn: (result) => result.Offers, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all offers. + * @example Read all offers to array. + * ```typescript + * const {body: offerList} = await client.offers.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } +} +//# sourceMappingURL=Offers.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js.map new file mode 100644 index 000000000..240c866b0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/Offers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Offers.js","sourceRoot":"","sources":["../../../../src/client/Offer/Offers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKpD;;;;GAIG;AACH,MAAM,OAAO,MAAM;IACjB;;;OAGG;IACH,YACkB,MAAoB,EACnB,aAA4B;QAD7B,WAAM,GAAN,MAAM,CAAc;QACnB,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAYG,KAAK,CAAI,KAAmB,EAAE,OAAqB;QACxD,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE;YAC5F,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAI;gBACrC,IAAI,EAAE,SAAS;gBACf,YAAY,EAAE,YAAY,CAAC,KAAK;gBAChC,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM;gBACnC,KAAK;gBACL,OAAO,EAAE,YAAY;gBACrB,cAAc;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACI,OAAO,CAAC,OAAqB;QAClC,OAAO,IAAI,CAAC,KAAK,CAA6B,SAAS,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { ResourceType } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { OfferDefinition } from \"./OfferDefinition\";\n\n/**\n * Use to query or read all Offers.\n *\n * @see {@link Offer} to read or replace an existing {@link Offer} by id.\n */\nexport class Offers {\n /**\n * @hidden\n * @param client - The parent {@link CosmosClient} for the offers.\n */\n constructor(\n public readonly client: CosmosClient,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all offers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all offers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path: \"/offers\",\n resourceType: ResourceType.offer,\n resourceId: \"\",\n resultFn: (result) => result.Offers,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all offers.\n * @example Read all offers to array.\n * ```typescript\n * const {body: offerList} = await client.offers.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts new file mode 100644 index 000000000..803aff976 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts @@ -0,0 +1,5 @@ +export { Offer } from "./Offer"; +export { Offers } from "./Offers"; +export { OfferDefinition } from "./OfferDefinition"; +export { OfferResponse } from "./OfferResponse"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts.map new file mode 100644 index 000000000..f09ec66c1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/Offer/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js new file mode 100644 index 000000000..7264ea29e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { Offer } from "./Offer"; +export { Offers } from "./Offers"; +export { OfferResponse } from "./OfferResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js.map new file mode 100644 index 000000000..4a9335880 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Offer/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/Offer/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { Offer } from \"./Offer\";\nexport { Offers } from \"./Offers\";\nexport { OfferDefinition } from \"./OfferDefinition\";\nexport { OfferResponse } from \"./OfferResponse\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts new file mode 100644 index 000000000..223a58dff --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts @@ -0,0 +1,39 @@ +import { ClientContext } from "../../ClientContext"; +import { RequestOptions } from "../../request/RequestOptions"; +import { User } from "../User"; +import { PermissionDefinition } from "./PermissionDefinition"; +import { PermissionResponse } from "./PermissionResponse"; +/** + * Use to read, replace, or delete a given {@link Permission} by id. + * + * @see {@link Permissions} to create, upsert, query, or read all Permissions. + */ +export declare class Permission { + readonly user: User; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param user - The parent {@link User}. + * @param id - The id of the given {@link Permission}. + */ + constructor(user: User, id: string, clientContext: ClientContext); + /** + * Read the {@link PermissionDefinition} of the given {@link Permission}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link Permission} with the specified {@link PermissionDefinition}. + * @param body - The specified {@link PermissionDefinition}. + */ + replace(body: PermissionDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link Permission}. + */ + delete(options?: RequestOptions): Promise; +} +//# sourceMappingURL=Permission.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts.map new file mode 100644 index 000000000..580253690 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Permission.d.ts","sourceRoot":"","sources":["../../../../src/client/Permission/Permission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;;GAIG;AACH,qBAAa,UAAU;aAaH,IAAI,EAAE,IAAI;aACV,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAdhC;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD;;;;OAIG;gBAEe,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa;IAG/C;;OAEG;IACU,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsBxE;;;OAGG;IACU,OAAO,CAClB,IAAI,EAAE,oBAAoB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,kBAAkB,CAAC;IA2B9B;;OAEG;IACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js new file mode 100644 index 000000000..16978da3a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js @@ -0,0 +1,84 @@ +import { createPermissionUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, } from "../../common"; +import { PermissionResponse } from "./PermissionResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Use to read, replace, or delete a given {@link Permission} by id. + * + * @see {@link Permissions} to create, upsert, query, or read all Permissions. + */ +export class Permission { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createPermissionUri(this.user.database.id, this.user.id, this.id); + } + /** + * @hidden + * @param user - The parent {@link User}. + * @param id - The id of the given {@link Permission}. + */ + constructor(user, id, clientContext) { + this.user = user; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link PermissionDefinition} of the given {@link Permission}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + return new PermissionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link Permission} with the specified {@link PermissionDefinition}. + * @param body - The specified {@link PermissionDefinition}. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + return new PermissionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link Permission}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + return new PermissionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Permission.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js.map new file mode 100644 index 000000000..bc69f9526 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permission.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Permission.js","sourceRoot":"","sources":["../../../../src/client/Permission/Permission.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC;AAKtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,UAAU;IACrB;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD;;;;OAIG;IACH,YACkB,IAAU,EACV,EAAU,EACT,aAA4B;QAF7B,SAAI,GAAJ,IAAI,CAAM;QACV,OAAE,GAAF,EAAE,CAAQ;QACT,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAEJ;;OAEG;IACI,KAAK,C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ACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,OAAwB;QAC1C,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAwC;gBACtF,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,UAAU;gBACrC,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,kBAAkB,CAC3B,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createPermissionUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request/RequestOptions\";\nimport { User } from \"../User\";\nimport { PermissionBody } from \"./PermissionBody\";\nimport { PermissionDefinition } from \"./PermissionDefinition\";\nimport { PermissionResponse } from \"./PermissionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Use to read, replace, or delete a given {@link Permission} by id.\n *\n * @see {@link Permissions} to create, upsert, query, or read all Permissions.\n */\nexport class Permission {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createPermissionUri(this.user.database.id, this.user.id, this.id);\n }\n /**\n * @hidden\n * @param user - The parent {@link User}.\n * @param id - The id of the given {@link Permission}.\n */\n constructor(\n public readonly user: User,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link PermissionDefinition} of the given {@link Permission}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link Permission} with the specified {@link PermissionDefinition}.\n * @param body - The specified {@link PermissionDefinition}.\n */\n public async replace(\n body: PermissionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link Permission}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts new file mode 100644 index 000000000..4c25f5057 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts @@ -0,0 +1,5 @@ +export interface PermissionBody { + /** System generated resource token for the particular resource and user */ + _token: string; +} +//# sourceMappingURL=PermissionBody.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts.map new file mode 100644 index 000000000..8bc2e9584 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionBody.d.ts","sourceRoot":"","sources":["../../../../src/client/Permission/PermissionBody.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,2EAA2E;IAC3E,MAAM,EAAE,MAAM,CAAC;CAChB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js new file mode 100644 index 000000000..909656cac --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=PermissionBody.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js.map new file mode 100644 index 000000000..1666a52e8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionBody.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionBody.js","sourceRoot":"","sources":["../../../../src/client/Permission/PermissionBody.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface PermissionBody {\n /** System generated resource token for the particular resource and user */\n _token: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts new file mode 100644 index 000000000..8390e6cbf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts @@ -0,0 +1,11 @@ +import { PermissionMode } from "../../documents"; +export interface PermissionDefinition { + /** The id of the permission */ + id: string; + /** The mode of the permission, must be a value of {@link PermissionMode} */ + permissionMode: PermissionMode; + /** The link of the resource that the permission will be applied to. */ + resource: string; + resourcePartitionKey?: string | any[]; +} +//# sourceMappingURL=PermissionDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts.map new file mode 100644 index 000000000..41427a39b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/Permission/PermissionDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,WAAW,oBAAoB;IACnC,+BAA+B;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,4EAA4E;IAC5E,cAAc,EAAE,cAAc,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;CACvC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js new file mode 100644 index 000000000..f218b81af --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=PermissionDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js.map new file mode 100644 index 000000000..45d6252b8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionDefinition.js","sourceRoot":"","sources":["../../../../src/client/Permission/PermissionDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PermissionMode } from \"../../documents\";\n\nexport interface PermissionDefinition {\n /** The id of the permission */\n id: string;\n /** The mode of the permission, must be a value of {@link PermissionMode} */\n permissionMode: PermissionMode;\n /** The link of the resource that the permission will be applied to. */\n resource: string;\n resourcePartitionKey?: string | any[]; // TODO: what's allowed here?\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts new file mode 100644 index 000000000..283ffd7ee --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts @@ -0,0 +1,13 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request"; +import { Resource } from "../Resource"; +import { Permission } from "./Permission"; +import { PermissionBody } from "./PermissionBody"; +import { PermissionDefinition } from "./PermissionDefinition"; +export declare class PermissionResponse extends ResourceResponse { + constructor(resource: PermissionDefinition & PermissionBody & Resource, headers: CosmosHeaders, statusCode: number, permission: Permission, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Permission} corresponding to the returned {@link PermissionDefinition}. */ + readonly permission: Permission; +} +//# sourceMappingURL=PermissionResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts.map new file mode 100644 index 000000000..580e6b6e4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/Permission/PermissionResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,qBAAa,kBAAmB,SAAQ,gBAAgB,CACtD,oBAAoB,GAAG,cAAc,GAAG,QAAQ,CACjD;gBAEG,QAAQ,EAAE,oBAAoB,GAAG,cAAc,GAAG,QAAQ,EAC1D,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,iBAAiB;IAKhC,wGAAwG;IACxG,SAAgB,UAAU,EAAE,UAAU,CAAC;CACxC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js new file mode 100644 index 000000000..254620266 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js @@ -0,0 +1,8 @@ +import { ResourceResponse } from "../../request"; +export class PermissionResponse extends ResourceResponse { + constructor(resource, headers, statusCode, permission, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.permission = permission; + } +} +//# sourceMappingURL=PermissionResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js.map new file mode 100644 index 000000000..09e686491 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/PermissionResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionResponse.js","sourceRoot":"","sources":["../../../../src/client/Permission/PermissionResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMjD,MAAM,OAAO,kBAAmB,SAAQ,gBAEvC;IACC,YACE,QAA0D,EAC1D,OAAsB,EACtB,UAAkB,EAClB,UAAsB,EACtB,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Permission } from \"./Permission\";\nimport { PermissionBody } from \"./PermissionBody\";\nimport { PermissionDefinition } from \"./PermissionDefinition\";\n\nexport class PermissionResponse extends ResourceResponse<\n PermissionDefinition & PermissionBody & Resource\n> {\n constructor(\n resource: PermissionDefinition & PermissionBody & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n permission: Permission,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.permission = permission;\n }\n /** A reference to the {@link Permission} corresponding to the returned {@link PermissionDefinition}. */\n public readonly permission: Permission;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts new file mode 100644 index 000000000..1e6b9f226 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts @@ -0,0 +1,56 @@ +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions } from "../../request"; +import { Resource } from "../Resource"; +import { User } from "../User"; +import { PermissionDefinition } from "./PermissionDefinition"; +import { PermissionResponse } from "./PermissionResponse"; +/** + * Use to create, replace, query, and read all Permissions. + * + * @see {@link Permission} to read, replace, or delete a specific permission by id. + */ +export declare class Permissions { + readonly user: User; + private readonly clientContext; + /** + * @hidden + * @param user - The parent {@link User}. + */ + constructor(user: User, clientContext: ClientContext); + /** + * Query all permissions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all permissions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all permissions. + * @example Read all permissions to array. + * ```typescript + * const {body: permissionList} = await user.permissions.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a permission. + * + * A permission represents a per-User Permission to access a specific resource + * e.g. Item or Container. + * @param body - Represents the body of the permission. + */ + create(body: PermissionDefinition, options?: RequestOptions): Promise; + /** + * Upsert a permission. + * + * A permission represents a per-User Permission to access a + * specific resource e.g. Item or Container. + */ + upsert(body: PermissionDefinition, options?: RequestOptions): Promise; +} +//# sourceMappingURL=Permissions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts.map new file mode 100644 index 000000000..374192598 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Permissions.d.ts","sourceRoot":"","sources":["../../../../src/client/Permission/Permissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;;GAIG;AACH,qBAAa,WAAW;aAMJ,IAAI,EAAE,IAAI;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,IAAI,EAAE,IAAI,EACT,aAAa,EAAE,aAAa;IAG/C;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IAC5E;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAkB7E;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,oBAAoB,GAAG,QAAQ,CAAC;IAIrF;;;;;;OAMG;IACU,MAAM,CACjB,IAAI,EAAE,oBAAoB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,kBAAkB,CAAC;IA6B9B;;;;;OAKG;IACU,MAAM,CACjB,IAAI,EAAE,oBAAoB,EAC1B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,kBAAkB,CAAC;CA4B/B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js new file mode 100644 index 000000000..ea9f5cc29 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js @@ -0,0 +1,99 @@ +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; +import { QueryIterator } from "../../queryIterator"; +import { Permission } from "./Permission"; +import { PermissionResponse } from "./PermissionResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Use to create, replace, query, and read all Permissions. + * + * @see {@link Permission} to read, replace, or delete a specific permission by id. + */ +export class Permissions { + /** + * @hidden + * @param user - The parent {@link User}. + */ + constructor(user, clientContext) { + this.user = user; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.user.url, ResourceType.permission); + const id = getIdFromLink(this.user.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.permission, + resourceId: id, + resultFn: (result) => result.Permissions, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all permissions. + * @example Read all permissions to array. + * ```typescript + * const {body: permissionList} = await user.permissions.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a permission. + * + * A permission represents a per-User Permission to access a specific resource + * e.g. Item or Container. + * @param body - Represents the body of the permission. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.user.url, ResourceType.permission); + const id = getIdFromLink(this.user.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.permission, + resourceId: id, + diagnosticNode, + options, + }); + const ref = new Permission(this.user, response.result.id, this.clientContext); + return new PermissionResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Upsert a permission. + * + * A permission represents a per-User Permission to access a + * specific resource e.g. Item or Container. + */ + async upsert(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.user.url, ResourceType.permission); + const id = getIdFromLink(this.user.url); + const response = await this.clientContext.upsert({ + body, + path, + resourceType: ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new Permission(this.user, response.result.id, this.clientContext); + return new PermissionResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Permissions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js.map new file mode 100644 index 000000000..d42ca5955 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/Permissions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Permissions.js","sourceRoot":"","sources":["../../../../src/client/Permission/Permissions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,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,MAAM,CAAuC;gBACrF,IAAI;gBACJ,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,UAAU;gBACrC,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAC9E,OAAO,IAAI,kBAAkB,CAC3B,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,GAAG,EACH,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { User } from \"../User\";\nimport { Permission } from \"./Permission\";\nimport { PermissionBody } from \"./PermissionBody\";\nimport { PermissionDefinition } from \"./PermissionDefinition\";\nimport { PermissionResponse } from \"./PermissionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Use to create, replace, query, and read all Permissions.\n *\n * @see {@link Permission} to read, replace, or delete a specific permission by id.\n */\nexport class Permissions {\n /**\n * @hidden\n * @param user - The parent {@link User}.\n */\n constructor(\n public readonly user: User,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all permissions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all permissions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.user.url, ResourceType.permission);\n const id = getIdFromLink(this.user.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n resultFn: (result) => result.Permissions,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all permissions.\n * @example Read all permissions to array.\n * ```typescript\n * const {body: permissionList} = await user.permissions.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a permission.\n *\n * A permission represents a per-User Permission to access a specific resource\n * e.g. Item or Container.\n * @param body - Represents the body of the permission.\n */\n public async create(\n body: PermissionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.user.url, ResourceType.permission);\n const id = getIdFromLink(this.user.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n diagnosticNode,\n options,\n });\n const ref = new Permission(this.user, response.result.id, this.clientContext);\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Upsert a permission.\n *\n * A permission represents a per-User Permission to access a\n * specific resource e.g. Item or Container.\n */\n public async upsert(\n body: PermissionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.user.url, ResourceType.permission);\n const id = getIdFromLink(this.user.url);\n\n const response = await this.clientContext.upsert({\n body,\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new Permission(this.user, response.result.id, this.clientContext);\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts new file mode 100644 index 000000000..fd181eee9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts @@ -0,0 +1,6 @@ +export { Permission } from "./Permission"; +export { Permissions } from "./Permissions"; +export { PermissionDefinition } from "./PermissionDefinition"; +export { PermissionResponse } from "./PermissionResponse"; +export { PermissionBody } from "./PermissionBody"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts.map new file mode 100644 index 000000000..4b6450440 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/Permission/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js new file mode 100644 index 000000000..f98f29d66 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { Permission } from "./Permission"; +export { Permissions } from "./Permissions"; +export { PermissionResponse } from "./PermissionResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js.map new file mode 100644 index 000000000..9cb225bf3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Permission/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/Permission/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { Permission } from \"./Permission\";\nexport { Permissions } from \"./Permissions\";\nexport { PermissionDefinition } from \"./PermissionDefinition\";\nexport { PermissionResponse } from \"./PermissionResponse\";\nexport { PermissionBody } from \"./PermissionBody\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts new file mode 100644 index 000000000..d3552409f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts @@ -0,0 +1,13 @@ +export interface Resource { + /** Required. User settable property. Unique name that identifies the item, that is, no two items share the same ID within a database. The id must not exceed 255 characters. */ + id: string; + /** System generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the item resource. */ + _rid: string; + /** System generated property. Specifies the last updated timestamp of the resource. The value is a timestamp. */ + _ts: number; + /** System generated property. The unique addressable URI for the resource. */ + _self: string; + /** System generated property. Represents the resource etag required for optimistic concurrency control. */ + _etag: string; +} +//# sourceMappingURL=Resource.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts.map new file mode 100644 index 000000000..1f099a731 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Resource.d.ts","sourceRoot":"","sources":["../../../src/client/Resource.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,gLAAgL;IAChL,EAAE,EAAE,MAAM,CAAC;IACX,gOAAgO;IAChO,IAAI,EAAE,MAAM,CAAC;IACb,iHAAiH;IACjH,GAAG,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC;IACd,2GAA2G;IAC3G,KAAK,EAAE,MAAM,CAAC;CACf"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js new file mode 100644 index 000000000..3dcffe999 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=Resource.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js.map new file mode 100644 index 000000000..0e545a587 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Resource.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Resource.js","sourceRoot":"","sources":["../../../src/client/Resource.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface Resource {\n /** Required. User settable property. Unique name that identifies the item, that is, no two items share the same ID within a database. The id must not exceed 255 characters. */\n id: string;\n /** System generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the item resource. */\n _rid: string;\n /** System generated property. Specifies the last updated timestamp of the resource. The value is a timestamp. */\n _ts: number;\n /** System generated property. The unique addressable URI for the resource. */\n _self: string;\n /** System generated property. Represents the resource etag required for optimistic concurrency control. */\n _etag: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts new file mode 100644 index 000000000..cd3fc756f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts @@ -0,0 +1,74 @@ +/** + * Represents permission Scope Values. + */ +export declare enum PermissionScopeValues { + /** + * Values which set permission Scope applicable to control plane related operations. + */ + ScopeAccountReadValue = 1, + ScopeAccountListDatabasesValue = 2, + ScopeDatabaseReadValue = 4, + ScopeDatabaseReadOfferValue = 8, + ScopeDatabaseListContainerValue = 16, + ScopeContainerReadValue = 32, + ScopeContainerReadOfferValue = 64, + ScopeAccountCreateDatabasesValue = 1, + ScopeAccountDeleteDatabasesValue = 2, + ScopeDatabaseDeleteValue = 4, + ScopeDatabaseReplaceOfferValue = 8, + ScopeDatabaseCreateContainerValue = 16, + ScopeDatabaseDeleteContainerValue = 32, + ScopeContainerReplaceValue = 64, + ScopeContainerDeleteValue = 128, + ScopeContainerReplaceOfferValue = 256, + ScopeAccountReadAllAccessValue = 65535, + ScopeDatabaseReadAllAccessValue = 124, + ScopeContainersReadAllAccessValue = 96, + ScopeAccountWriteAllAccessValue = 65535, + ScopeDatabaseWriteAllAccessValue = 508, + ScopeContainersWriteAllAccessValue = 448, + /** + * Values which set permission Scope applicable to data plane related operations. + */ + ScopeContainerExecuteQueriesValue = 1, + ScopeContainerReadFeedsValue = 2, + ScopeContainerReadStoredProceduresValue = 4, + ScopeContainerReadUserDefinedFunctionsValue = 8, + ScopeContainerReadTriggersValue = 16, + ScopeContainerReadConflictsValue = 32, + ScopeItemReadValue = 64, + ScopeStoredProcedureReadValue = 128, + ScopeUserDefinedFunctionReadValue = 256, + ScopeTriggerReadValue = 512, + ScopeContainerCreateItemsValue = 1, + ScopeContainerReplaceItemsValue = 2, + ScopeContainerUpsertItemsValue = 4, + ScopeContainerDeleteItemsValue = 8, + ScopeContainerCreateStoredProceduresValue = 16, + ScopeContainerReplaceStoredProceduresValue = 32, + ScopeContainerDeleteStoredProceduresValue = 64, + ScopeContainerExecuteStoredProceduresValue = 128, + ScopeContainerCreateTriggersValue = 256, + ScopeContainerReplaceTriggersValue = 512, + ScopeContainerDeleteTriggersValue = 1024, + ScopeContainerCreateUserDefinedFunctionsValue = 2048, + ScopeContainerReplaceUserDefinedFunctionsValue = 4096, + ScopeContainerDeleteUserDefinedFunctionSValue = 8192, + ScopeContainerDeleteCONFLICTSValue = 16384, + ScopeItemReplaceValue = 65536, + ScopeItemUpsertValue = 131072, + ScopeItemDeleteValue = 262144, + ScopeStoredProcedureReplaceValue = 1048576, + ScopeStoredProcedureDeleteValue = 2097152, + ScopeStoredProcedureExecuteValue = 4194304, + ScopeUserDefinedFunctionReplaceValue = 8388608, + ScopeUserDefinedFunctionDeleteValue = 16777216, + ScopeTriggerReplaceValue = 33554432, + ScopeTriggerDeleteValue = 67108864, + ScopeContainerReadAllAccessValue = 4294967295, + ScopeItemReadAllAccessValue = 65, + ScopeContainerWriteAllAccessValue = 4294967295, + ScopeItemWriteAllAccessValue = 458767, + NoneValue = 0 +} +//# sourceMappingURL=PermissionScopeValues.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts.map new file mode 100644 index 000000000..ae03e493b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionScopeValues.d.ts","sourceRoot":"","sources":["../../../../src/client/SasToken/PermissionScopeValues.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,qBAAqB;IAC/B;;OAEG;IACH,qBAAqB,IAAS;IAC9B,8BAA8B,IAAS;IACvC,sBAAsB,IAAS;IAC/B,2BAA2B,IAAS;IACpC,+BAA+B,KAAS;IACxC,uBAAuB,KAAS;IAChC,4BAA4B,KAAS;IAErC,gCAAgC,IAAS;IACzC,gCAAgC,IAAS;IACzC,wBAAwB,IAAS;IACjC,8BAA8B,IAAS;IACvC,iCAAiC,KAAS;IAC1C,iCAAiC,KAAS;IAC1C,0BAA0B,KAAS;IACnC,yBAAyB,MAAS;IAClC,+BAA+B,MAAS;IAExC,8BAA8B,QAAS;IACvC,+BAA+B,MAIqB;IAEpD,iCAAiC,KACmB;IAEpD,+BAA+B,QAAS;IACxC,gCAAgC,MAMuB;IAEvD,kCAAkC,MAEqB;IAEvD;;OAEG;IACH,iCAAiC,IAAa;IAC9C,4BAA4B,IAAa;IACzC,uCAAuC,IAAa;IACpD,2CAA2C,IAAa;IACxD,+BAA+B,KAAa;IAC5C,gCAAgC,KAAa;IAC7C,kBAAkB,KAAa;IAC/B,6BAA6B,MAAa;IAC1C,iCAAiC,MAAa;IAC9C,qBAAqB,MAAa;IAElC,8BAA8B,IAAa;IAC3C,+BAA+B,IAAa;IAC5C,8BAA8B,IAAa;IAC3C,8BAA8B,IAAa;IAC3C,yCAAyC,KAAa;IACtD,0CAA0C,KAAa;IACvD,yCAAyC,KAAa;IACtD,0CAA0C,MAAa;IACvD,iCAAiC,MAAa;IAC9C,kCAAkC,MAAa;IAC/C,iCAAiC,OAAa;IAC9C,6CAA6C,OAAa;IAC1D,8CAA8C,OAAa;IAC3D,6CAA6C,OAAa;IAC1D,kCAAkC,QAAa;IAC/C,qBAAqB,QAAa;IAClC,oBAAoB,SAAa;IACjC,oBAAoB,SAAa;IACjC,gCAAgC,UAAa;IAC7C,+BAA+B,UAAa;IAC5C,gCAAgC,UAAa;IAC7C,oCAAoC,UAAa;IACjD,mCAAmC,WAAa;IAChD,wBAAwB,WAAa;IACrC,uBAAuB,WAAa;IAEpC,gCAAgC,aAAa;IAC7C,2BAA2B,KACe;IAC1C,iCAAiC,aAAa;IAC9C,4BAA4B,SAMgB;IAE5C,SAAS,IAAI;CACd"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js new file mode 100644 index 000000000..e291730b5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Represents permission Scope Values. + */ +export var PermissionScopeValues; +(function (PermissionScopeValues) { + /** + * Values which set permission Scope applicable to control plane related operations. + */ + PermissionScopeValues[PermissionScopeValues["ScopeAccountReadValue"] = 1] = "ScopeAccountReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountListDatabasesValue"] = 2] = "ScopeAccountListDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadValue"] = 4] = "ScopeDatabaseReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadOfferValue"] = 8] = "ScopeDatabaseReadOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseListContainerValue"] = 16] = "ScopeDatabaseListContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadValue"] = 32] = "ScopeContainerReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadOfferValue"] = 64] = "ScopeContainerReadOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountCreateDatabasesValue"] = 1] = "ScopeAccountCreateDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountDeleteDatabasesValue"] = 2] = "ScopeAccountDeleteDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseDeleteValue"] = 4] = "ScopeDatabaseDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReplaceOfferValue"] = 8] = "ScopeDatabaseReplaceOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseCreateContainerValue"] = 16] = "ScopeDatabaseCreateContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseDeleteContainerValue"] = 32] = "ScopeDatabaseDeleteContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceValue"] = 64] = "ScopeContainerReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteValue"] = 128] = "ScopeContainerDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceOfferValue"] = 256] = "ScopeContainerReplaceOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountReadAllAccessValue"] = 65535] = "ScopeAccountReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadAllAccessValue"] = 124] = "ScopeDatabaseReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainersReadAllAccessValue"] = 96] = "ScopeContainersReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountWriteAllAccessValue"] = 65535] = "ScopeAccountWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseWriteAllAccessValue"] = 508] = "ScopeDatabaseWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainersWriteAllAccessValue"] = 448] = "ScopeContainersWriteAllAccessValue"; + /** + * Values which set permission Scope applicable to data plane related operations. + */ + PermissionScopeValues[PermissionScopeValues["ScopeContainerExecuteQueriesValue"] = 1] = "ScopeContainerExecuteQueriesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadFeedsValue"] = 2] = "ScopeContainerReadFeedsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadStoredProceduresValue"] = 4] = "ScopeContainerReadStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadUserDefinedFunctionsValue"] = 8] = "ScopeContainerReadUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadTriggersValue"] = 16] = "ScopeContainerReadTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadConflictsValue"] = 32] = "ScopeContainerReadConflictsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReadValue"] = 64] = "ScopeItemReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureReadValue"] = 128] = "ScopeStoredProcedureReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionReadValue"] = 256] = "ScopeUserDefinedFunctionReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerReadValue"] = 512] = "ScopeTriggerReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateItemsValue"] = 1] = "ScopeContainerCreateItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceItemsValue"] = 2] = "ScopeContainerReplaceItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerUpsertItemsValue"] = 4] = "ScopeContainerUpsertItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteItemsValue"] = 8] = "ScopeContainerDeleteItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateStoredProceduresValue"] = 16] = "ScopeContainerCreateStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceStoredProceduresValue"] = 32] = "ScopeContainerReplaceStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteStoredProceduresValue"] = 64] = "ScopeContainerDeleteStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerExecuteStoredProceduresValue"] = 128] = "ScopeContainerExecuteStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateTriggersValue"] = 256] = "ScopeContainerCreateTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceTriggersValue"] = 512] = "ScopeContainerReplaceTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteTriggersValue"] = 1024] = "ScopeContainerDeleteTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateUserDefinedFunctionsValue"] = 2048] = "ScopeContainerCreateUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceUserDefinedFunctionsValue"] = 4096] = "ScopeContainerReplaceUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteUserDefinedFunctionSValue"] = 8192] = "ScopeContainerDeleteUserDefinedFunctionSValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteCONFLICTSValue"] = 16384] = "ScopeContainerDeleteCONFLICTSValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReplaceValue"] = 65536] = "ScopeItemReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemUpsertValue"] = 131072] = "ScopeItemUpsertValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemDeleteValue"] = 262144] = "ScopeItemDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureReplaceValue"] = 1048576] = "ScopeStoredProcedureReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureDeleteValue"] = 2097152] = "ScopeStoredProcedureDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureExecuteValue"] = 4194304] = "ScopeStoredProcedureExecuteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionReplaceValue"] = 8388608] = "ScopeUserDefinedFunctionReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionDeleteValue"] = 16777216] = "ScopeUserDefinedFunctionDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerReplaceValue"] = 33554432] = "ScopeTriggerReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerDeleteValue"] = 67108864] = "ScopeTriggerDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadAllAccessValue"] = 4294967295] = "ScopeContainerReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReadAllAccessValue"] = 65] = "ScopeItemReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerWriteAllAccessValue"] = 4294967295] = "ScopeContainerWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemWriteAllAccessValue"] = 458767] = "ScopeItemWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["NoneValue"] = 0] = "NoneValue"; +})(PermissionScopeValues || (PermissionScopeValues = {})); +//# sourceMappingURL=PermissionScopeValues.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js.map new file mode 100644 index 000000000..0bb9281f9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/PermissionScopeValues.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionScopeValues.js","sourceRoot":"","sources":["../../../../src/client/SasToken/PermissionScopeValues.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,qBAkGX;AAlGD,WAAY,qBAAqB;IAC/B;;OAEG;IACH,mGAA8B,CAAA;IAC9B,qHAAuC,CAAA;IACvC,qGAA+B,CAAA;IAC/B,+GAAoC,CAAA;IACpC,wHAAwC,CAAA;IACxC,wGAAgC,CAAA;IAChC,kHAAqC,C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ent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Represents permission Scope Values.\n */\nexport enum PermissionScopeValues {\n /**\n * Values which set permission Scope applicable to control plane related operations.\n */\n ScopeAccountReadValue = 0x0001,\n ScopeAccountListDatabasesValue = 0x0002,\n ScopeDatabaseReadValue = 0x0004,\n ScopeDatabaseReadOfferValue = 0x0008,\n ScopeDatabaseListContainerValue = 0x0010,\n ScopeContainerReadValue = 0x0020,\n ScopeContainerReadOfferValue = 0x0040,\n\n ScopeAccountCreateDatabasesValue = 0x0001,\n ScopeAccountDeleteDatabasesValue = 0x0002,\n ScopeDatabaseDeleteValue = 0x0004,\n ScopeDatabaseReplaceOfferValue = 0x0008,\n ScopeDatabaseCreateContainerValue = 0x0010,\n ScopeDatabaseDeleteContainerValue = 0x0020,\n ScopeContainerReplaceValue = 0x0040,\n ScopeContainerDeleteValue = 0x0080,\n ScopeContainerReplaceOfferValue = 0x0100,\n\n ScopeAccountReadAllAccessValue = 0xffff,\n ScopeDatabaseReadAllAccessValue = PermissionScopeValues.ScopeDatabaseReadValue |\n PermissionScopeValues.ScopeDatabaseReadOfferValue |\n PermissionScopeValues.ScopeDatabaseListContainerValue |\n PermissionScopeValues.ScopeContainerReadValue |\n PermissionScopeValues.ScopeContainerReadOfferValue,\n\n ScopeContainersReadAllAccessValue = PermissionScopeValues.ScopeContainerReadValue |\n PermissionScopeValues.ScopeContainerReadOfferValue,\n\n ScopeAccountWriteAllAccessValue = 0xffff,\n ScopeDatabaseWriteAllAccessValue = PermissionScopeValues.ScopeDatabaseDeleteValue |\n PermissionScopeValues.ScopeDatabaseReplaceOfferValue |\n PermissionScopeValues.ScopeDatabaseCreateContainerValue |\n PermissionScopeValues.ScopeDatabaseDeleteContainerValue |\n PermissionScopeValues.ScopeContainerReplaceValue |\n PermissionScopeValues.ScopeContainerDeleteValue |\n PermissionScopeValues.ScopeContainerReplaceOfferValue,\n\n ScopeContainersWriteAllAccessValue = PermissionScopeValues.ScopeContainerReplaceValue |\n PermissionScopeValues.ScopeContainerDeleteValue |\n PermissionScopeValues.ScopeContainerReplaceOfferValue,\n\n /**\n * Values which set permission Scope applicable to data plane related operations.\n */\n ScopeContainerExecuteQueriesValue = 0x00000001,\n ScopeContainerReadFeedsValue = 0x00000002,\n ScopeContainerReadStoredProceduresValue = 0x00000004,\n ScopeContainerReadUserDefinedFunctionsValue = 0x00000008,\n ScopeContainerReadTriggersValue = 0x00000010,\n ScopeContainerReadConflictsValue = 0x00000020,\n ScopeItemReadValue = 0x00000040,\n ScopeStoredProcedureReadValue = 0x00000080,\n ScopeUserDefinedFunctionReadValue = 0x00000100,\n ScopeTriggerReadValue = 0x00000200,\n\n ScopeContainerCreateItemsValue = 0x00000001,\n ScopeContainerReplaceItemsValue = 0x00000002,\n ScopeContainerUpsertItemsValue = 0x00000004,\n ScopeContainerDeleteItemsValue = 0x00000008,\n ScopeContainerCreateStoredProceduresValue = 0x00000010,\n ScopeContainerReplaceStoredProceduresValue = 0x00000020,\n ScopeContainerDeleteStoredProceduresValue = 0x00000040,\n ScopeContainerExecuteStoredProceduresValue = 0x00000080,\n ScopeContainerCreateTriggersValue = 0x00000100,\n ScopeContainerReplaceTriggersValue = 0x00000200,\n ScopeContainerDeleteTriggersValue = 0x00000400,\n ScopeContainerCreateUserDefinedFunctionsValue = 0x00000800,\n ScopeContainerReplaceUserDefinedFunctionsValue = 0x00001000,\n ScopeContainerDeleteUserDefinedFunctionSValue = 0x00002000,\n ScopeContainerDeleteCONFLICTSValue = 0x00004000,\n ScopeItemReplaceValue = 0x00010000,\n ScopeItemUpsertValue = 0x00020000,\n ScopeItemDeleteValue = 0x00040000,\n ScopeStoredProcedureReplaceValue = 0x00100000,\n ScopeStoredProcedureDeleteValue = 0x00200000,\n ScopeStoredProcedureExecuteValue = 0x00400000,\n ScopeUserDefinedFunctionReplaceValue = 0x00800000,\n ScopeUserDefinedFunctionDeleteValue = 0x01000000,\n ScopeTriggerReplaceValue = 0x02000000,\n ScopeTriggerDeleteValue = 0x04000000,\n\n ScopeContainerReadAllAccessValue = 0xffffffff,\n ScopeItemReadAllAccessValue = PermissionScopeValues.ScopeContainerExecuteQueriesValue |\n PermissionScopeValues.ScopeItemReadValue,\n ScopeContainerWriteAllAccessValue = 0xffffffff,\n ScopeItemWriteAllAccessValue = PermissionScopeValues.ScopeContainerCreateItemsValue |\n PermissionScopeValues.ScopeContainerReplaceItemsValue |\n PermissionScopeValues.ScopeContainerUpsertItemsValue |\n PermissionScopeValues.ScopeContainerDeleteItemsValue |\n PermissionScopeValues.ScopeItemReplaceValue |\n PermissionScopeValues.ScopeItemUpsertValue |\n PermissionScopeValues.ScopeItemDeleteValue,\n\n NoneValue = 0,\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts new file mode 100644 index 000000000..1bd0b5678 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts @@ -0,0 +1,22 @@ +import { CosmosContainerChildResourceKind } from "../../common/constants"; +import { CosmosKeyType } from "../../common/constants"; +export declare class SasTokenProperties { + user: string; + userTag: string; + databaseName: string; + containerName: string; + resourceName: string; + resourcePath: string; + resourceKind: CosmosContainerChildResourceKind; + partitionKeyValueRanges: string[]; + startTime: Date; + expiryTime: Date; + keyType: CosmosKeyType | number; + controlPlaneReaderScope: number; + controlPlaneWriterScope: number; + dataPlaneReaderScope: number; + dataPlaneWriterScope: number; + cosmosContainerChildResourceKind: CosmosContainerChildResourceKind; + cosmosKeyType: CosmosKeyType; +} +//# sourceMappingURL=SasTokenProperties.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts.map new file mode 100644 index 000000000..29cc99541 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"SasTokenProperties.d.ts","sourceRoot":"","sources":["../../../../src/client/SasToken/SasTokenProperties.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,qBAAa,kBAAkB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,gCAAgC,CAAC;IAC/C,uBAAuB,EAAE,MAAM,EAAE,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gCAAgC,EAAE,gCAAgC,CAAC;IACnE,aAAa,EAAE,aAAa,CAAC;CAC9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js new file mode 100644 index 000000000..de9fe202a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export class SasTokenProperties { +} +//# sourceMappingURL=SasTokenProperties.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js.map new file mode 100644 index 000000000..ed92f609d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/SasToken/SasTokenProperties.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SasTokenProperties.js","sourceRoot":"","sources":["../../../../src/client/SasToken/SasTokenProperties.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,OAAO,kBAAkB;CAkB9B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosContainerChildResourceKind } from \"../../common/constants\";\nimport { CosmosKeyType } from \"../../common/constants\";\n\nexport class SasTokenProperties {\n user: string;\n userTag: string;\n databaseName: string;\n containerName: string;\n resourceName: string;\n resourcePath: string;\n resourceKind: CosmosContainerChildResourceKind;\n partitionKeyValueRanges: string[];\n startTime: Date;\n expiryTime: Date;\n keyType: CosmosKeyType | number;\n controlPlaneReaderScope: number;\n controlPlaneWriterScope: number;\n dataPlaneReaderScope: number;\n dataPlaneWriterScope: number;\n cosmosContainerChildResourceKind: CosmosContainerChildResourceKind;\n cosmosKeyType: CosmosKeyType;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts new file mode 100644 index 000000000..4a93489cd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts @@ -0,0 +1,57 @@ +import { StoredProcedures, StoredProcedure } from "../StoredProcedure"; +import { Trigger, Triggers } from "../Trigger"; +import { UserDefinedFunction, UserDefinedFunctions } from "../UserDefinedFunction"; +import { ClientContext } from "../../ClientContext"; +import { Container } from "../Container/Container"; +export declare class Scripts { + readonly container: Container; + private readonly clientContext; + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Used to read, replace, or delete a specific, existing {@link StoredProcedure} by id. + * + * Use `.storedProcedures` for creating new stored procedures, or querying/reading all stored procedures. + * @param id - The id of the {@link StoredProcedure}. + */ + storedProcedure(id: string): StoredProcedure; + /** + * Used to read, replace, or delete a specific, existing {@link Trigger} by id. + * + * Use `.triggers` for creating new triggers, or querying/reading all triggers. + * @param id - The id of the {@link Trigger}. + */ + trigger(id: string): Trigger; + /** + * Used to read, replace, or delete a specific, existing {@link UserDefinedFunction} by id. + * + * Use `.userDefinedFunctions` for creating new user defined functions, or querying/reading all user defined functions. + * @param id - The id of the {@link UserDefinedFunction}. + */ + userDefinedFunction(id: string): UserDefinedFunction; + private $sprocs; + /** + * Operations for creating new stored procedures, and reading/querying all stored procedures. + * + * For reading, replacing, or deleting an existing stored procedure, use `.storedProcedure(id)`. + */ + get storedProcedures(): StoredProcedures; + private $triggers; + /** + * Operations for creating new triggers, and reading/querying all triggers. + * + * For reading, replacing, or deleting an existing trigger, use `.trigger(id)`. + */ + get triggers(): Triggers; + private $udfs; + /** + * Operations for creating new user defined functions, and reading/querying all user defined functions. + * + * For reading, replacing, or deleting an existing user defined function, use `.userDefinedFunction(id)`. + */ + get userDefinedFunctions(): UserDefinedFunctions; +} +//# sourceMappingURL=Scripts.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts.map new file mode 100644 index 000000000..758e21a25 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Scripts.d.ts","sourceRoot":"","sources":["../../../../src/client/Script/Scripts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,qBAAa,OAAO;aAMA,SAAS,EAAE,SAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,SAAS,EAAE,SAAS,EACnB,aAAa,EAAE,aAAa;IAG/C;;;;;OAKG;IACI,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe;IAInD;;;;;OAKG;IACI,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAInC;;;;;OAKG;IACI,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,mBAAmB;IAI3D,OAAO,CAAC,OAAO,CAAmB;IAClC;;;;OAIG;IACH,IAAW,gBAAgB,IAAI,gBAAgB,CAK9C;IAED,OAAO,CAAC,SAAS,CAAW;IAC5B;;;;OAIG;IACH,IAAW,QAAQ,IAAI,QAAQ,CAK9B;IAED,OAAO,CAAC,KAAK,CAAuB;IACpC;;;;OAIG;IACH,IAAW,oBAAoB,IAAI,oBAAoB,CAKtD;CACF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js new file mode 100644 index 000000000..463e61a9a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { StoredProcedures, StoredProcedure } from "../StoredProcedure"; +import { Trigger, Triggers } from "../Trigger"; +import { UserDefinedFunction, UserDefinedFunctions } from "../UserDefinedFunction"; +export class Scripts { + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + /** + * Used to read, replace, or delete a specific, existing {@link StoredProcedure} by id. + * + * Use `.storedProcedures` for creating new stored procedures, or querying/reading all stored procedures. + * @param id - The id of the {@link StoredProcedure}. + */ + storedProcedure(id) { + return new StoredProcedure(this.container, id, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link Trigger} by id. + * + * Use `.triggers` for creating new triggers, or querying/reading all triggers. + * @param id - The id of the {@link Trigger}. + */ + trigger(id) { + return new Trigger(this.container, id, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link UserDefinedFunction} by id. + * + * Use `.userDefinedFunctions` for creating new user defined functions, or querying/reading all user defined functions. + * @param id - The id of the {@link UserDefinedFunction}. + */ + userDefinedFunction(id) { + return new UserDefinedFunction(this.container, id, this.clientContext); + } + /** + * Operations for creating new stored procedures, and reading/querying all stored procedures. + * + * For reading, replacing, or deleting an existing stored procedure, use `.storedProcedure(id)`. + */ + get storedProcedures() { + if (!this.$sprocs) { + this.$sprocs = new StoredProcedures(this.container, this.clientContext); + } + return this.$sprocs; + } + /** + * Operations for creating new triggers, and reading/querying all triggers. + * + * For reading, replacing, or deleting an existing trigger, use `.trigger(id)`. + */ + get triggers() { + if (!this.$triggers) { + this.$triggers = new Triggers(this.container, this.clientContext); + } + return this.$triggers; + } + /** + * Operations for creating new user defined functions, and reading/querying all user defined functions. + * + * For reading, replacing, or deleting an existing user defined function, use `.userDefinedFunction(id)`. + */ + get userDefinedFunctions() { + if (!this.$udfs) { + this.$udfs = new UserDefinedFunctions(this.container, this.clientContext); + } + return this.$udfs; + } +} +//# sourceMappingURL=Scripts.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js.map new file mode 100644 index 000000000..2f04ff4a2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Script/Scripts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Scripts.js","sourceRoot":"","sources":["../../../../src/client/Script/Scripts.ts"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Aa,CAAC,CAAC;SACnE;QACD,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAGD;;;;OAIG;IACH,IAAW,oBAAoB;QAC7B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;SAC3E;QACD,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { StoredProcedures, StoredProcedure } from \"../StoredProcedure\";\nimport { Trigger, Triggers } from \"../Trigger\";\nimport { UserDefinedFunction, UserDefinedFunctions } from \"../UserDefinedFunction\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { Container } from \"../Container/Container\";\n\nexport class Scripts {\n /**\n * @param container - The parent {@link Container}.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Used to read, replace, or delete a specific, existing {@link StoredProcedure} by id.\n *\n * Use `.storedProcedures` for creating new stored procedures, or querying/reading all stored procedures.\n * @param id - The id of the {@link StoredProcedure}.\n */\n public storedProcedure(id: string): StoredProcedure {\n return new StoredProcedure(this.container, id, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Trigger} by id.\n *\n * Use `.triggers` for creating new triggers, or querying/reading all triggers.\n * @param id - The id of the {@link Trigger}.\n */\n public trigger(id: string): Trigger {\n return new Trigger(this.container, id, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link UserDefinedFunction} by id.\n *\n * Use `.userDefinedFunctions` for creating new user defined functions, or querying/reading all user defined functions.\n * @param id - The id of the {@link UserDefinedFunction}.\n */\n public userDefinedFunction(id: string): UserDefinedFunction {\n return new UserDefinedFunction(this.container, id, this.clientContext);\n }\n\n private $sprocs: StoredProcedures;\n /**\n * Operations for creating new stored procedures, and reading/querying all stored procedures.\n *\n * For reading, replacing, or deleting an existing stored procedure, use `.storedProcedure(id)`.\n */\n public get storedProcedures(): StoredProcedures {\n if (!this.$sprocs) {\n this.$sprocs = new StoredProcedures(this.container, this.clientContext);\n }\n return this.$sprocs;\n }\n\n private $triggers: Triggers;\n /**\n * Operations for creating new triggers, and reading/querying all triggers.\n *\n * For reading, replacing, or deleting an existing trigger, use `.trigger(id)`.\n */\n public get triggers(): Triggers {\n if (!this.$triggers) {\n this.$triggers = new Triggers(this.container, this.clientContext);\n }\n return this.$triggers;\n }\n\n private $udfs: UserDefinedFunctions;\n /**\n * Operations for creating new user defined functions, and reading/querying all user defined functions.\n *\n * For reading, replacing, or deleting an existing user defined function, use `.userDefinedFunction(id)`.\n */\n public get userDefinedFunctions(): UserDefinedFunctions {\n if (!this.$udfs) {\n this.$udfs = new UserDefinedFunctions(this.container, this.clientContext);\n }\n return this.$udfs;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts new file mode 100644 index 000000000..c198a5d34 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts @@ -0,0 +1,52 @@ +import { ClientContext } from "../../ClientContext"; +import { PartitionKey } from "../../documents/PartitionKey"; +import { RequestOptions, ResourceResponse } from "../../request"; +import { Container } from "../Container"; +import { StoredProcedureDefinition } from "./StoredProcedureDefinition"; +import { StoredProcedureResponse } from "./StoredProcedureResponse"; +/** + * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id. + * + * For operations to create, read all, or query Stored Procedures, + */ +export declare class StoredProcedure { + readonly container: Container; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}. + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link StoredProcedure}. + * @hidden + */ + constructor(container: Container, id: string, clientContext: ClientContext); + /** + * Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}. + * @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition. + */ + replace(body: StoredProcedureDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link StoredProcedure}. + */ + delete(options?: RequestOptions): Promise; + /** + * Execute the given {@link StoredProcedure}. + * + * The specified type, T, is not enforced by the client. + * Be sure to validate the response from the stored procedure matches the type, T, you provide. + * + * @param partitionKey - The partition key to use when executing the stored procedure + * @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}. + * @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on. + */ + execute(partitionKey: PartitionKey, params?: any[], options?: RequestOptions): Promise>; +} +//# sourceMappingURL=StoredProcedure.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts.map new file mode 100644 index 000000000..309a32e6e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedure.d.ts","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;;GAIG;AACH,qBAAa,eAAe;aAcR,SAAS,EAAE,SAAS;aACpB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAfhC;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD;;;;;OAKG;gBAEe,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa;IAG/C;;OAEG;IACU,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAsB7E;;;OAGG;IACU,OAAO,CAClB,IAAI,EAAE,yBAAyB,EAC/B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,uBAAuB,CAAC;IAgCnC;;OAEG;IACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAsB/E;;;;;;;;;OASG;IACU,OAAO,CAAC,CAAC,GAAG,GAAG,EAC1B,YAAY,EAAE,YAAY,EAC1B,MAAM,CAAC,EAAE,GAAG,EAAE,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAwBhC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js new file mode 100644 index 000000000..0798ffdae --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js @@ -0,0 +1,117 @@ +import { createStoredProcedureUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, } from "../../common"; +import { undefinedPartitionKey } from "../../extractPartitionKey"; +import { ResourceResponse } from "../../request"; +import { readPartitionKeyDefinition } from "../ClientUtils"; +import { StoredProcedureResponse } from "./StoredProcedureResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id. + * + * For operations to create, read all, or query Stored Procedures, + */ +export class StoredProcedure { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createStoredProcedureUri(this.container.database.id, this.container.id, this.id); + } + /** + * Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}. + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link StoredProcedure}. + * @hidden + */ + constructor(container, id, clientContext) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + return new StoredProcedureResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}. + * @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + return new StoredProcedureResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link StoredProcedure}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + return new StoredProcedureResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Execute the given {@link StoredProcedure}. + * + * The specified type, T, is not enforced by the client. + * Be sure to validate the response from the stored procedure matches the type, T, you provide. + * + * @param partitionKey - The partition key to use when executing the stored procedure + * @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}. + * @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on. + */ + async execute(partitionKey, params, options) { + return withDiagnostics(async (diagnosticNode) => { + if (partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + partitionKey = undefinedPartitionKey(partitionKeyResponse); + } + const response = await this.clientContext.execute({ + sprocLink: this.url, + params, + options, + partitionKey, + diagnosticNode, + }); + return new ResourceResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=StoredProcedure.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js.map new file mode 100644 index 000000000..626bc4adc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedure.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedure.js","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedure.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,wBAAwB,EACxB,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAkB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,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ACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,OAAO,CAClB,YAA0B,EAC1B,MAAc,EACd,OAAwB;QAExB,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,IAAI,YAAY,KAAK,SAAS,EAAE;gBAC9B,MAAM,oBAAoB,GAAG,MAAM,0BAA0B,CAC3D,cAAc,EACd,IAAI,CAAC,SAAS,CACf,CAAC;gBACF,YAAY,GAAG,qBAAqB,CAAC,oBAAoB,CAAC,CAAC;aAC5D;YACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAI;gBACnD,SAAS,EAAE,IAAI,CAAC,GAAG;gBACnB,MAAM;gBACN,OAAO;gBACP,YAAY;gBACZ,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,gBAAgB,CACzB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createStoredProcedureUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { PartitionKey } from \"../../documents/PartitionKey\";\nimport { undefinedPartitionKey } from \"../../extractPartitionKey\";\nimport { RequestOptions, ResourceResponse } from \"../../request\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { Container } from \"../Container\";\nimport { StoredProcedureDefinition } from \"./StoredProcedureDefinition\";\nimport { StoredProcedureResponse } from \"./StoredProcedureResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id.\n *\n * For operations to create, read all, or query Stored Procedures,\n */\nexport class StoredProcedure {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createStoredProcedureUri(this.container.database.id, this.container.id, this.id);\n }\n /**\n * Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}.\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link StoredProcedure}.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}.\n * @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition.\n */\n public async replace(\n body: StoredProcedureDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link StoredProcedure}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Execute the given {@link StoredProcedure}.\n *\n * The specified type, T, is not enforced by the client.\n * Be sure to validate the response from the stored procedure matches the type, T, you provide.\n *\n * @param partitionKey - The partition key to use when executing the stored procedure\n * @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}.\n * @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on.\n */\n public async execute(\n partitionKey: PartitionKey,\n params?: any[],\n options?: RequestOptions,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n partitionKey = undefinedPartitionKey(partitionKeyResponse);\n }\n const response = await this.clientContext.execute({\n sprocLink: this.url,\n params,\n options,\n partitionKey,\n diagnosticNode,\n });\n return new ResourceResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts new file mode 100644 index 000000000..f62f4c515 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts @@ -0,0 +1,11 @@ +export interface StoredProcedureDefinition { + /** + * The id of the {@link StoredProcedure}. + */ + id?: string; + /** + * The body of the {@link StoredProcedure}. This is a JavaScript function. + */ + body?: string | ((...inputs: any[]) => void); +} +//# sourceMappingURL=StoredProcedureDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts.map new file mode 100644 index 000000000..3dc9b8d12 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedureDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedureDefinition.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC,CAAC;CAC9C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js new file mode 100644 index 000000000..95ef6748b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=StoredProcedureDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js.map new file mode 100644 index 000000000..5316b1d57 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedureDefinition.js","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedureDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface StoredProcedureDefinition {\n /**\n * The id of the {@link StoredProcedure}.\n */\n id?: string;\n /**\n * The body of the {@link StoredProcedure}. This is a JavaScript function.\n */\n body?: string | ((...inputs: any[]) => void);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts new file mode 100644 index 000000000..e997c0a0c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts @@ -0,0 +1,20 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request"; +import { Resource } from "../Resource"; +import { StoredProcedure } from "./StoredProcedure"; +import { StoredProcedureDefinition } from "./StoredProcedureDefinition"; +export declare class StoredProcedureResponse extends ResourceResponse { + constructor(resource: StoredProcedureDefinition & Resource, headers: CosmosHeaders, statusCode: number, storedProcedure: StoredProcedure, diagnostics: CosmosDiagnostics); + /** + * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to. + */ + readonly storedProcedure: StoredProcedure; + /** + * Alias for storedProcedure. + * + * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to. + */ + get sproc(): StoredProcedure; +} +//# sourceMappingURL=StoredProcedureResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts.map new file mode 100644 index 000000000..cd85b50e9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedureResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedureResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,qBAAa,uBAAwB,SAAQ,gBAAgB,CAC3D,yBAAyB,GAAG,QAAQ,CACrC;gBAEG,QAAQ,EAAE,yBAAyB,GAAG,QAAQ,EAC9C,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,eAAe,EAChC,WAAW,EAAE,iBAAiB;IAKhC;;OAEG;IACH,SAAgB,eAAe,EAAE,eAAe,CAAC;IAEjD;;;;OAIG;IACH,IAAW,KAAK,IAAI,eAAe,CAElC;CACF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js new file mode 100644 index 000000000..a27008555 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js @@ -0,0 +1,16 @@ +import { ResourceResponse } from "../../request"; +export class StoredProcedureResponse extends ResourceResponse { + constructor(resource, headers, statusCode, storedProcedure, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.storedProcedure = storedProcedure; + } + /** + * Alias for storedProcedure. + * + * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to. + */ + get sproc() { + return this.storedProcedure; + } +} +//# sourceMappingURL=StoredProcedureResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js.map new file mode 100644 index 000000000..d432921e1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedureResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedureResponse.js","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedureResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,OAAO,uBAAwB,SAAQ,gBAE5C;IACC,YACE,QAA8C,EAC9C,OAAsB,EACtB,UAAkB,EAClB,eAAgC,EAChC,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAMD;;;;OAIG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { StoredProcedure } from \"./StoredProcedure\";\nimport { StoredProcedureDefinition } from \"./StoredProcedureDefinition\";\n\nexport class StoredProcedureResponse extends ResourceResponse<\n StoredProcedureDefinition & Resource\n> {\n constructor(\n resource: StoredProcedureDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n storedProcedure: StoredProcedure,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.storedProcedure = storedProcedure;\n }\n /**\n * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.\n */\n public readonly storedProcedure: StoredProcedure;\n\n /**\n * Alias for storedProcedure.\n *\n * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.\n */\n public get sproc(): StoredProcedure {\n return this.storedProcedure;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts new file mode 100644 index 000000000..55fb6b8c1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts @@ -0,0 +1,71 @@ +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions } from "../../request"; +import { Container } from "../Container"; +import { Resource } from "../Resource"; +import { StoredProcedureDefinition } from "./StoredProcedureDefinition"; +import { StoredProcedureResponse } from "./StoredProcedureResponse"; +/** + * Operations for creating, upserting, or reading/querying all Stored Procedures. + * + * For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`. + */ +export declare class StoredProcedures { + readonly container: Container; + private readonly clientContext; + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Query all Stored Procedures. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @example Read all stored procedures to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @sproc", + * parameters: [ + * {name: "@sproc", value: "Todo"} + * ] + * }; + * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all Stored Procedures. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @example Read all stored procedures to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @sproc", + * parameters: [ + * {name: "@sproc", value: "Todo"} + * ] + * }; + * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all stored procedures. + * @example Read all stored procedures to array. + * ```typescript + * const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a StoredProcedure. + * + * Azure Cosmos DB allows stored procedures to be executed in the storage tier, + * directly against an item container. The script + * gets executed under ACID transactions on the primary storage partition of the + * specified container. For additional details, + * refer to the server-side JavaScript API documentation. + */ + create(body: StoredProcedureDefinition, options?: RequestOptions): Promise; +} +//# sourceMappingURL=StoredProcedures.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts.map new file mode 100644 index 000000000..eaf0b81af --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedures.d.ts","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedures.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;;GAIG;AACH,qBAAa,gBAAgB;aAMT,SAAS,EAAE,SAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,SAAS,EAAE,SAAS,EACnB,aAAa,EAAE,aAAa;IAG/C;;;;;;;;;;;;;OAaG;IACI,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IAC5E;;;;;;;;;;;;;OAaG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAkB7E;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,yBAAyB,GAAG,QAAQ,CAAC;IAI1F;;;;;;;;OAQG;IACU,MAAM,CACjB,IAAI,EAAE,yBAAyB,EAC/B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,uBAAuB,CAAC;CAgCpC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js new file mode 100644 index 000000000..684861ed3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js @@ -0,0 +1,78 @@ +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; +import { QueryIterator } from "../../queryIterator"; +import { StoredProcedure } from "./StoredProcedure"; +import { StoredProcedureResponse } from "./StoredProcedureResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Operations for creating, upserting, or reading/querying all Stored Procedures. + * + * For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`. + */ +export class StoredProcedures { + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, ResourceType.sproc); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.sproc, + resourceId: id, + resultFn: (result) => result.StoredProcedures, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }); + } + /** + * Read all stored procedures. + * @example Read all stored procedures to array. + * ```typescript + * const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a StoredProcedure. + * + * Azure Cosmos DB allows stored procedures to be executed in the storage tier, + * directly against an item container. The script + * gets executed under ACID transactions on the primary storage partition of the + * specified container. For additional details, + * refer to the server-side JavaScript API documentation. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, ResourceType.sproc); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new StoredProcedure(this.container, response.result.id, this.clientContext); + return new StoredProcedureResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=StoredProcedures.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js.map new file mode 100644 index 000000000..6b201f4bb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/StoredProcedures.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StoredProcedures.js","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/StoredProcedures.ts"],"names":[],"mappings":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E,CAAC;IAED;;;;;;;;OAQG;IACI,KAAK,CAAC,MAAM,CACjB,IAA+B,EAC/B,OAAwB;QAExB,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,IAAI,IAAI,CAAC,IAAI,EAAE;gBACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;aAClC;YAED,MAAM,GAAG,GAAG,EAAE,CAAC;YACf,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;gBAC/B,MAAM,GAAG,CAAC;aACX;YAED,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YACrE,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAE7C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAA4B;gBAC1E,IAAI;gBACJ,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,KAAK;gBAChC,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YACxF,OAAO,IAAI,uBAAuB,CAChC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,GAAG,EACH,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { StoredProcedure } from \"./StoredProcedure\";\nimport { StoredProcedureDefinition } from \"./StoredProcedureDefinition\";\nimport { StoredProcedureResponse } from \"./StoredProcedureResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for creating, upserting, or reading/querying all Stored Procedures.\n *\n * For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`.\n */\nexport class StoredProcedures {\n /**\n * @param container - The parent {@link Container}.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all Stored Procedures.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @example Read all stored procedures to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @sproc\",\n * parameters: [\n * {name: \"@sproc\", value: \"Todo\"}\n * ]\n * };\n * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all Stored Procedures.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @example Read all stored procedures to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @sproc\",\n * parameters: [\n * {name: \"@sproc\", value: \"Todo\"}\n * ]\n * };\n * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.sproc);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n resultFn: (result) => result.StoredProcedures,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n });\n }\n\n /**\n * Read all stored procedures.\n * @example Read all stored procedures to array.\n * ```typescript\n * const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a StoredProcedure.\n *\n * Azure Cosmos DB allows stored procedures to be executed in the storage tier,\n * directly against an item container. The script\n * gets executed under ACID transactions on the primary storage partition of the\n * specified container. For additional details,\n * refer to the server-side JavaScript API documentation.\n */\n public async create(\n body: StoredProcedureDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.sproc);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new StoredProcedure(this.container, response.result.id, this.clientContext);\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts new file mode 100644 index 000000000..34d6d0612 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts @@ -0,0 +1,5 @@ +export { StoredProcedure } from "./StoredProcedure"; +export { StoredProcedures } from "./StoredProcedures"; +export { StoredProcedureDefinition } from "./StoredProcedureDefinition"; +export { StoredProcedureResponse } from "./StoredProcedureResponse"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts.map new file mode 100644 index 000000000..ab38c1c6c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js new file mode 100644 index 000000000..588bda933 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { StoredProcedure } from "./StoredProcedure"; +export { StoredProcedures } from "./StoredProcedures"; +export { StoredProcedureResponse } from "./StoredProcedureResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js.map new file mode 100644 index 000000000..a167ec338 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/StoredProcedure/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/StoredProcedure/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { StoredProcedure } from \"./StoredProcedure\";\nexport { StoredProcedures } from \"./StoredProcedures\";\nexport { StoredProcedureDefinition } from \"./StoredProcedureDefinition\";\nexport { StoredProcedureResponse } from \"./StoredProcedureResponse\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts new file mode 100644 index 000000000..d58234333 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts @@ -0,0 +1,39 @@ +import { ClientContext } from "../../ClientContext"; +import { RequestOptions } from "../../request"; +import { Container } from "../Container"; +import { TriggerDefinition } from "./TriggerDefinition"; +import { TriggerResponse } from "./TriggerResponse"; +/** + * Operations to read, replace, or delete a {@link Trigger}. + * + * Use `container.triggers` to create, upsert, query, or read all. + */ +export declare class Trigger { + readonly container: Container; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Trigger}. + */ + constructor(container: Container, id: string, clientContext: ClientContext); + /** + * Read the {@link TriggerDefinition} for the given {@link Trigger}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link Trigger} with the specified {@link TriggerDefinition}. + * @param body - The specified {@link TriggerDefinition} to replace the existing definition with. + */ + replace(body: TriggerDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link Trigger}. + */ + delete(options?: RequestOptions): Promise; +} +//# sourceMappingURL=Trigger.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts.map new file mode 100644 index 000000000..a05383a63 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Trigger.d.ts","sourceRoot":"","sources":["../../../../src/client/Trigger/Trigger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;;GAIG;AACH,qBAAa,OAAO;aAcA,SAAS,EAAE,SAAS;aACpB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAfhC;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IAED;;;;OAIG;gBAEe,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa;IAG/C;;OAEG;IACU,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAsBrE;;;OAGG;IACU,OAAO,CAClB,IAAI,EAAE,iBAAiB,EACvB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,eAAe,CAAC;IAgC3B;;OAEG;IACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAqBxE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js new file mode 100644 index 000000000..ee990e0cf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js @@ -0,0 +1,87 @@ +import { createTriggerUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, } from "../../common"; +import { TriggerResponse } from "./TriggerResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Operations to read, replace, or delete a {@link Trigger}. + * + * Use `container.triggers` to create, upsert, query, or read all. + */ +export class Trigger { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createTriggerUri(this.container.database.id, this.container.id, this.id); + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Trigger}. + */ + constructor(container, id, clientContext) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link TriggerDefinition} for the given {@link Trigger}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + return new TriggerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link Trigger} with the specified {@link TriggerDefinition}. + * @param body - The specified {@link TriggerDefinition} to replace the existing definition with. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + return new TriggerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link Trigger}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + return new TriggerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Trigger.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js.map new file mode 100644 index 000000000..38a2903ce --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Trigger.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Trigger.js","sourceRoot":"","sources":["../../../../src/client/Trigger/Trigger.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,OAAO;IAClB;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;;;;OAIG;IACH,YACkB,SAAoB,EACpB,EAAU,EACT,aAA4B;QAF7B,cAAS,GAAT,SAAS,CAAW;QACpB,OAAE,GAAF,EAAE,CAAQ;QACT,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,OAAwB;QACxC,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC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AAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,OAAwB;QAC1C,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAoB;gBAClE,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,OAAO;gBAClC,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,eAAe,CACxB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createTriggerUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { TriggerDefinition } from \"./TriggerDefinition\";\nimport { TriggerResponse } from \"./TriggerResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations to read, replace, or delete a {@link Trigger}.\n *\n * Use `container.triggers` to create, upsert, query, or read all.\n */\nexport class Trigger {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createTriggerUri(this.container.database.id, this.container.id, this.id);\n }\n\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link Trigger}.\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link TriggerDefinition} for the given {@link Trigger}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link Trigger} with the specified {@link TriggerDefinition}.\n * @param body - The specified {@link TriggerDefinition} to replace the existing definition with.\n */\n public async replace(\n body: TriggerDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link Trigger}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts new file mode 100644 index 000000000..01a07b39e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts @@ -0,0 +1,12 @@ +import { TriggerOperation, TriggerType } from "../../documents"; +export interface TriggerDefinition { + /** The id of the trigger. */ + id?: string; + /** The body of the trigger, it can also be passed as a stringifed function */ + body: (() => void) | string; + /** The type of the trigger, should be one of the values of {@link TriggerType}. */ + triggerType: TriggerType; + /** The trigger operation, should be one of the values of {@link TriggerOperation}. */ + triggerOperation: TriggerOperation; +} +//# sourceMappingURL=TriggerDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts.map new file mode 100644 index 000000000..1121e537b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/Trigger/TriggerDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,WAAW,iBAAiB;IAChC,6BAA6B;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,8EAA8E;IAC9E,IAAI,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC;IAC5B,mFAAmF;IACnF,WAAW,EAAE,WAAW,CAAC;IACzB,sFAAsF;IACtF,gBAAgB,EAAE,gBAAgB,CAAC;CACpC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js new file mode 100644 index 000000000..c1255621b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=TriggerDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js.map new file mode 100644 index 000000000..874446f22 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerDefinition.js","sourceRoot":"","sources":["../../../../src/client/Trigger/TriggerDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { TriggerOperation, TriggerType } from \"../../documents\";\n\nexport interface TriggerDefinition {\n /** The id of the trigger. */\n id?: string;\n /** The body of the trigger, it can also be passed as a stringifed function */\n body: (() => void) | string;\n /** The type of the trigger, should be one of the values of {@link TriggerType}. */\n triggerType: TriggerType;\n /** The trigger operation, should be one of the values of {@link TriggerOperation}. */\n triggerOperation: TriggerOperation;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts new file mode 100644 index 000000000..aa97b66e0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts @@ -0,0 +1,12 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request"; +import { Resource } from "../Resource"; +import { Trigger } from "./index"; +import { TriggerDefinition } from "./TriggerDefinition"; +export declare class TriggerResponse extends ResourceResponse { + constructor(resource: TriggerDefinition & Resource, headers: CosmosHeaders, statusCode: number, trigger: Trigger, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Trigger} corresponding to the returned {@link TriggerDefinition}. */ + readonly trigger: Trigger; +} +//# sourceMappingURL=TriggerResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts.map new file mode 100644 index 000000000..b10b50a89 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/Trigger/TriggerResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,eAAgB,SAAQ,gBAAgB,CAAC,iBAAiB,GAAG,QAAQ,CAAC;gBAE/E,QAAQ,EAAE,iBAAiB,GAAG,QAAQ,EACtC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,iBAAiB;IAKhC,kGAAkG;IAClG,SAAgB,OAAO,EAAE,OAAO,CAAC;CAClC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js new file mode 100644 index 000000000..c7b2330d6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js @@ -0,0 +1,8 @@ +import { ResourceResponse } from "../../request"; +export class TriggerResponse extends ResourceResponse { + constructor(resource, headers, statusCode, trigger, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.trigger = trigger; + } +} +//# sourceMappingURL=TriggerResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js.map new file mode 100644 index 000000000..74f35c7e8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/TriggerResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerResponse.js","sourceRoot":"","sources":["../../../../src/client/Trigger/TriggerResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,OAAO,eAAgB,SAAQ,gBAA8C;IACjF,YACE,QAAsC,EACtC,OAAsB,EACtB,UAAkB,EAClB,OAAgB,EAChB,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Trigger } from \"./index\";\nimport { TriggerDefinition } from \"./TriggerDefinition\";\n\nexport class TriggerResponse extends ResourceResponse {\n constructor(\n resource: TriggerDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n trigger: Trigger,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.trigger = trigger;\n }\n /** A reference to the {@link Trigger} corresponding to the returned {@link TriggerDefinition}. */\n public readonly trigger: Trigger;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts new file mode 100644 index 000000000..e320eb927 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts @@ -0,0 +1,50 @@ +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions } from "../../request"; +import { Container } from "../Container"; +import { Resource } from "../Resource"; +import { TriggerDefinition } from "./TriggerDefinition"; +import { TriggerResponse } from "./TriggerResponse"; +/** + * Operations to create, upsert, query, and read all triggers. + * + * Use `container.triggers` to read, replace, or delete a {@link Trigger}. + */ +export declare class Triggers { + readonly container: Container; + private readonly clientContext; + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Query all Triggers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all Triggers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all Triggers. + * @example Read all trigger to array. + * ```typescript + * const {body: triggerList} = await container.triggers.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a trigger. + * + * Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed + * on creates, updates and deletes. + * + * For additional details, refer to the server-side JavaScript API documentation. + */ + create(body: TriggerDefinition, options?: RequestOptions): Promise; +} +//# sourceMappingURL=Triggers.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts.map new file mode 100644 index 000000000..fb29ff5be --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Triggers.d.ts","sourceRoot":"","sources":["../../../../src/client/Trigger/Triggers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD;;;;GAIG;AACH,qBAAa,QAAQ;aAMD,SAAS,EAAE,SAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,SAAS,EAAE,SAAS,EACnB,aAAa,EAAE,aAAa;IAG/C;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IAC5E;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAkB7E;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,iBAAiB,GAAG,QAAQ,CAAC;IAGlF;;;;;;;OAOG;IACU,MAAM,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;CAgCjG"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js new file mode 100644 index 000000000..60f108d9d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js @@ -0,0 +1,77 @@ +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; +import { QueryIterator } from "../../queryIterator"; +import { Trigger } from "./Trigger"; +import { TriggerResponse } from "./TriggerResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Operations to create, upsert, query, and read all triggers. + * + * Use `container.triggers` to read, replace, or delete a {@link Trigger}. + */ +export class Triggers { + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, ResourceType.trigger); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.trigger, + resourceId: id, + resultFn: (result) => result.Triggers, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all Triggers. + * @example Read all trigger to array. + * ```typescript + * const {body: triggerList} = await container.triggers.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a trigger. + * + * Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed + * on creates, updates and deletes. + * + * For additional details, refer to the server-side JavaScript API documentation. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, ResourceType.trigger); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new Trigger(this.container, response.result.id, this.clientContext); + return new TriggerResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Triggers.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js.map new file mode 100644 index 000000000..868f3349a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/Triggers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Triggers.js","sourceRoot":"","sources":["../../../../src/client/Trigger/Triggers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,QAAQ;IACnB;;;OAGG;IACH,YACkB,SAAoB,EACnB,aAA4B;QAD7B,cAAS,GAAT,SAAS,CAAW;QACnB,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAYG,KAAK,CAAI,KAAmB,EAAE,OAAqB;QACxD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;QACvE,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAE7C,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,YAA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AAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAChF,OAAO,IAAI,eAAe,CACxB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,GAAG,EACH,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { Trigger } from \"./Trigger\";\nimport { TriggerDefinition } from \"./TriggerDefinition\";\nimport { TriggerResponse } from \"./TriggerResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations to create, upsert, query, and read all triggers.\n *\n * Use `container.triggers` to read, replace, or delete a {@link Trigger}.\n */\nexport class Triggers {\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all Triggers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all Triggers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.trigger);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n resultFn: (result) => result.Triggers,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all Triggers.\n * @example Read all trigger to array.\n * ```typescript\n * const {body: triggerList} = await container.triggers.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n /**\n * Create a trigger.\n *\n * Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed\n * on creates, updates and deletes.\n *\n * For additional details, refer to the server-side JavaScript API documentation.\n */\n public async create(body: TriggerDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.trigger);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new Trigger(this.container, response.result.id, this.clientContext);\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts new file mode 100644 index 000000000..64fc451fa --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts @@ -0,0 +1,5 @@ +export { Trigger } from "./Trigger"; +export { Triggers } from "./Triggers"; +export { TriggerDefinition } from "./TriggerDefinition"; +export { TriggerResponse } from "./TriggerResponse"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts.map new file mode 100644 index 000000000..afdbe4d81 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/Trigger/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js new file mode 100644 index 000000000..d49685600 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { Trigger } from "./Trigger"; +export { Triggers } from "./Triggers"; +export { TriggerResponse } from "./TriggerResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js.map new file mode 100644 index 000000000..1e2f9f527 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/Trigger/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/Trigger/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { Trigger } from \"./Trigger\";\nexport { Triggers } from \"./Triggers\";\nexport { TriggerDefinition } from \"./TriggerDefinition\";\nexport { TriggerResponse } from \"./TriggerResponse\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts new file mode 100644 index 000000000..f449a800d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts @@ -0,0 +1,53 @@ +import { ClientContext } from "../../ClientContext"; +import { RequestOptions } from "../../request"; +import { Database } from "../Database"; +import { Permission, Permissions } from "../Permission"; +import { UserDefinition } from "./UserDefinition"; +import { UserResponse } from "./UserResponse"; +/** + * Used to read, replace, and delete Users. + * + * Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`. + * + * @see {@link Users} to create, upsert, query, or read all. + */ +export declare class User { + readonly database: Database; + readonly id: string; + private readonly clientContext; + /** + * Operations for creating, upserting, querying, or reading all operations. + * + * See `client.permission(id)` to read, replace, or delete a specific Permission by id. + */ + readonly permissions: Permissions; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database: Database, id: string, clientContext: ClientContext); + /** + * Operations to read, replace, or delete a specific Permission by id. + * + * See `client.permissions` for creating, upserting, querying, or reading all operations. + */ + permission(id: string): Permission; + /** + * Read the {@link UserDefinition} for the given {@link User}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link User}'s definition with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition} to replace the definition. + */ + replace(body: UserDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link User}. + */ + delete(options?: RequestOptions): Promise; +} +//# sourceMappingURL=User.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts.map new file mode 100644 index 000000000..0db2c8c8f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"User.d.ts","sourceRoot":"","sources":["../../../../src/client/User/User.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;;;GAMG;AACH,qBAAa,IAAI;aAkBG,QAAQ,EAAE,QAAQ;aAClB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAnBhC;;;;OAIG;IACH,SAAgB,WAAW,EAAE,WAAW,CAAC;IACzC;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD;;;OAGG;gBAEe,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa;IAK/C;;;;OAIG;IACI,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAIzC;;OAEG;IACU,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAqBlE;;;OAGG;IACU,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IA4B3F;;OAEG;IACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAqBrE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js new file mode 100644 index 000000000..1f3ecedc8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js @@ -0,0 +1,95 @@ +import { createUserUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, } from "../../common"; +import { Permission, Permissions } from "../Permission"; +import { UserResponse } from "./UserResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Used to read, replace, and delete Users. + * + * Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`. + * + * @see {@link Users} to create, upsert, query, or read all. + */ +export class User { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createUserUri(this.database.id, this.id); + } + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database, id, clientContext) { + this.database = database; + this.id = id; + this.clientContext = clientContext; + this.permissions = new Permissions(this, this.clientContext); + } + /** + * Operations to read, replace, or delete a specific Permission by id. + * + * See `client.permissions` for creating, upserting, querying, or reading all operations. + */ + permission(id) { + return new Permission(this, id, this.clientContext); + } + /** + * Read the {@link UserDefinition} for the given {@link User}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new UserResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link User}'s definition with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition} to replace the definition. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new UserResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link User}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new UserResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=User.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js.map new file mode 100644 index 000000000..5d441cf23 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/User.js.map @@ -0,0 +1 @@ +{"version":3,"file":"User.js","sourceRoot":"","sources":["../../../../src/client/User/User.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,OAAO,IAAI;IAOf;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC;IACD;;;OAGG;IACH,YACkB,QAAkB,EAClB,EAAU,EACT,aAA4B;QAF7B,aAAQ,GAAR,QAAQ,CAAU;QAClB,OAAE,GAAF,EAAE,CAAQ;QACT,kBAAa,GAAb,aAAa,CAAe;QAE7C,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC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;gBACJ,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,IAAI;gBAC/B,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,YAAY,CACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,MAAM,CAAC,OAAwB;QAC1C,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAiB;gBAC/D,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,IAAI;gBAC/B,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,YAAY,CACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createUserUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Database } from \"../Database\";\nimport { Permission, Permissions } from \"../Permission\";\nimport { UserDefinition } from \"./UserDefinition\";\nimport { UserResponse } from \"./UserResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to read, replace, and delete Users.\n *\n * Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`.\n *\n * @see {@link Users} to create, upsert, query, or read all.\n */\nexport class User {\n /**\n * Operations for creating, upserting, querying, or reading all operations.\n *\n * See `client.permission(id)` to read, replace, or delete a specific Permission by id.\n */\n public readonly permissions: Permissions;\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createUserUri(this.database.id, this.id);\n }\n /**\n * @hidden\n * @param database - The parent {@link Database}.\n */\n constructor(\n public readonly database: Database,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {\n this.permissions = new Permissions(this, this.clientContext);\n }\n\n /**\n * Operations to read, replace, or delete a specific Permission by id.\n *\n * See `client.permissions` for creating, upserting, querying, or reading all operations.\n */\n public permission(id: string): Permission {\n return new Permission(this, id, this.clientContext);\n }\n\n /**\n * Read the {@link UserDefinition} for the given {@link User}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link User}'s definition with the specified {@link UserDefinition}.\n * @param body - The specified {@link UserDefinition} to replace the definition.\n */\n public async replace(body: UserDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link User}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts new file mode 100644 index 000000000..2323cb54a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts @@ -0,0 +1,5 @@ +export interface UserDefinition { + /** The id of the user. */ + id?: string; +} +//# sourceMappingURL=UserDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts.map new file mode 100644 index 000000000..67450731d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/User/UserDefinition.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js new file mode 100644 index 000000000..4897195ab --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=UserDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js.map new file mode 100644 index 000000000..bc88984c9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinition.js","sourceRoot":"","sources":["../../../../src/client/User/UserDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface UserDefinition {\n /** The id of the user. */\n id?: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts new file mode 100644 index 000000000..c6c400b5a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts @@ -0,0 +1,12 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request"; +import { Resource } from "../Resource"; +import { User } from "./User"; +import { UserDefinition } from "./UserDefinition"; +export declare class UserResponse extends ResourceResponse { + constructor(resource: UserDefinition & Resource, headers: CosmosHeaders, statusCode: number, user: User, diagnostics: CosmosDiagnostics); + /** A reference to the {@link User} corresponding to the returned {@link UserDefinition}. */ + readonly user: User; +} +//# sourceMappingURL=UserResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts.map new file mode 100644 index 000000000..838d56fdf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UserResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/User/UserResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,qBAAa,YAAa,SAAQ,gBAAgB,CAAC,cAAc,GAAG,QAAQ,CAAC;gBAEzE,QAAQ,EAAE,cAAc,GAAG,QAAQ,EACnC,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,iBAAiB;IAKhC,4FAA4F;IAC5F,SAAgB,IAAI,EAAE,IAAI,CAAC;CAC5B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js new file mode 100644 index 000000000..0b25cc27b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js @@ -0,0 +1,8 @@ +import { ResourceResponse } from "../../request"; +export class UserResponse extends ResourceResponse { + constructor(resource, headers, statusCode, user, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.user = user; + } +} +//# sourceMappingURL=UserResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js.map new file mode 100644 index 000000000..b25f1ff7a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/UserResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserResponse.js","sourceRoot":"","sources":["../../../../src/client/User/UserResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,OAAO,YAAa,SAAQ,gBAA2C;IAC3E,YACE,QAAmC,EACnC,OAAsB,EACtB,UAAkB,EAClB,IAAU,EACV,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CAGF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { User } from \"./User\";\nimport { UserDefinition } from \"./UserDefinition\";\n\nexport class UserResponse extends ResourceResponse {\n constructor(\n resource: UserDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n user: User,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.user = user;\n }\n /** A reference to the {@link User} corresponding to the returned {@link UserDefinition}. */\n public readonly user: User;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts new file mode 100644 index 000000000..97b6a2e7b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts @@ -0,0 +1,51 @@ +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions } from "../../request"; +import { Database } from "../Database"; +import { Resource } from "../Resource"; +import { UserDefinition } from "./UserDefinition"; +import { UserResponse } from "./UserResponse"; +/** + * Used to create, upsert, query, and read all users. + * + * @see {@link User} to read, replace, or delete a specific User by id. + */ +export declare class Users { + readonly database: Database; + private readonly clientContext; + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database: Database, clientContext: ClientContext); + /** + * Query all users. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all users. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all users.- + * @example Read all users to array. + * ```typescript + * const {body: usersList} = await database.users.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a database user with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + create(body: UserDefinition, options?: RequestOptions): Promise; + /** + * Upsert a database user with a specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + upsert(body: UserDefinition, options?: RequestOptions): Promise; +} +//# sourceMappingURL=Users.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts.map new file mode 100644 index 000000000..35a570169 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Users.d.ts","sourceRoot":"","sources":["../../../../src/client/User/Users.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C;;;;GAIG;AACH,qBAAa,KAAK;aAME,QAAQ,EAAE,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,QAAQ,EAAE,QAAQ,EACjB,aAAa,EAAE,aAAa;IAG/C;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IAC5E;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAiB7E;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,cAAc,GAAG,QAAQ,CAAC;IAI/E;;;OAGG;IACU,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IA4B1F;;;OAGG;IACU,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CA4B3F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js new file mode 100644 index 000000000..c52fd083f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js @@ -0,0 +1,94 @@ +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; +import { QueryIterator } from "../../queryIterator"; +import { User } from "./User"; +import { UserResponse } from "./UserResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Used to create, upsert, query, and read all users. + * + * @see {@link User} to read, replace, or delete a specific User by id. + */ +export class Users { + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database, clientContext) { + this.database = database; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.database.url, ResourceType.user); + const id = getIdFromLink(this.database.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.user, + resourceId: id, + resultFn: (result) => result.Users, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all users.- + * @example Read all users to array. + * ```typescript + * const {body: usersList} = await database.users.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a database user with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.database.url, ResourceType.user); + const id = getIdFromLink(this.database.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new User(this.database, response.result.id, this.clientContext); + return new UserResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Upsert a database user with a specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + async upsert(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.database.url, ResourceType.user); + const id = getIdFromLink(this.database.url); + const response = await this.clientContext.upsert({ + body, + path, + resourceType: ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new User(this.database, response.result.id, this.clientContext); + return new UserResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=Users.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js.map new file mode 100644 index 000000000..bd859b4f7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/Users.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Users.js","sourceRoot":"","sources":["../../../../src/client/User/Users.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAChB;;;OAGG;IACH,YACkB,QAAkB,EACjB,aAA4B;QAD7B,aAAQ,GAAR,QAAQ,CAAU;QACjB,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAYG,KAAK,CAAI,KAAmB,EAAE,OAAqB;QACxD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;QACnE,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE;YAC5F,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;gBAClC,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,IAAI;gBAC/B,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK;gBAClC,KAAK;gBACL,OAAO,EAAE,YAAY;gBACrB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AK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,GAAG,GAAG,EAAE,CAAC;YACf,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE;gBAC/B,MAAM,GAAG,CAAC;aACX;YAED,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;YACnE,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YAE5C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAiB;gBAC/D,IAAI;gBACJ,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,IAAI;gBAC/B,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;YAC5E,OAAO,IAAI,YAAY,CACrB,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,GAAG,EACH,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Database } from \"../Database\";\nimport { Resource } from \"../Resource\";\nimport { User } from \"./User\";\nimport { UserDefinition } from \"./UserDefinition\";\nimport { UserResponse } from \"./UserResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to create, upsert, query, and read all users.\n *\n * @see {@link User} to read, replace, or delete a specific User by id.\n */\nexport class Users {\n /**\n * @hidden\n * @param database - The parent {@link Database}.\n */\n constructor(\n public readonly database: Database,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all users.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all users.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.database.url, ResourceType.user);\n const id = getIdFromLink(this.database.url);\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n resultFn: (result) => result.Users,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all users.-\n * @example Read all users to array.\n * ```typescript\n * const {body: usersList} = await database.users.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a database user with the specified {@link UserDefinition}.\n * @param body - The specified {@link UserDefinition}.\n */\n public async create(body: UserDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.database.url, ResourceType.user);\n const id = getIdFromLink(this.database.url);\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new User(this.database, response.result.id, this.clientContext);\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Upsert a database user with a specified {@link UserDefinition}.\n * @param body - The specified {@link UserDefinition}.\n */\n public async upsert(body: UserDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.database.url, ResourceType.user);\n const id = getIdFromLink(this.database.url);\n\n const response = await this.clientContext.upsert({\n body,\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new User(this.database, response.result.id, this.clientContext);\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts new file mode 100644 index 000000000..f7dcce37d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts @@ -0,0 +1,5 @@ +export { User } from "./User"; +export { Users } from "./Users"; +export { UserDefinition } from "./UserDefinition"; +export { UserResponse } from "./UserResponse"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts.map new file mode 100644 index 000000000..4a7623dc7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/User/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js new file mode 100644 index 000000000..4d2e6a641 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { User } from "./User"; +export { Users } from "./Users"; +export { UserResponse } from "./UserResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js.map new file mode 100644 index 000000000..eb84e3bb4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/User/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/User/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { User } from \"./User\";\nexport { Users } from \"./Users\";\nexport { UserDefinition } from \"./UserDefinition\";\nexport { UserResponse } from \"./UserResponse\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts new file mode 100644 index 000000000..6e21011fc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts @@ -0,0 +1,39 @@ +import { ClientContext } from "../../ClientContext"; +import { RequestOptions } from "../../request"; +import { Container } from "../Container"; +import { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; +import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; +/** + * Used to read, replace, or delete a specified User Definied Function by id. + * + * @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions. + */ +export declare class UserDefinedFunction { + readonly container: Container; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link UserDefinedFunction}. + */ + constructor(container: Container, id: string, clientContext: ClientContext); + /** + * Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}. + * @param options - + */ + replace(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link UserDefined}. + */ + delete(options?: RequestOptions): Promise; +} +//# sourceMappingURL=UserDefinedFunction.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts.map new file mode 100644 index 000000000..79403396e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunction.d.ts","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E;;;;GAIG;AACH,qBAAa,mBAAmB;aAaZ,SAAS,EAAE,SAAS;aACpB,EAAE,EAAE,MAAM;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAdhC;;OAEG;IACH,IAAW,GAAG,IAAI,MAAM,CAEvB;IACD;;;;OAIG;gBAEe,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,MAAM,EACT,aAAa,EAAE,aAAa;IAG/C;;OAEG;IACU,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAsBjF;;;OAGG;IACU,OAAO,CAClB,IAAI,EAAE,6BAA6B,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,2BAA2B,CAAC;IAgCvC;;OAEG;IACU,MAAM,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAqBpF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js new file mode 100644 index 000000000..c2e0b284e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js @@ -0,0 +1,87 @@ +import { createUserDefinedFunctionUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, } from "../../common"; +import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Used to read, replace, or delete a specified User Definied Function by id. + * + * @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions. + */ +export class UserDefinedFunction { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createUserDefinedFunctionUri(this.container.database.id, this.container.id, this.id); + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link UserDefinedFunction}. + */ + constructor(container, id, clientContext) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}. + * @param options - + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link UserDefined}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=UserDefinedFunction.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js.map new file mode 100644 index 000000000..2353cd0f7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunction.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunction.js","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunction.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,4BAA4B,EAC5B,aAAa,EACb,eAAe,EACf,eAAe,EACf,YAAY,GACb,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAC9B;;OAEG;IACH,IAAW,GAAG;QACZ,OAAO,4BAA4B,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9F,CAAC;IACD;;;;OAIG;IACH,YACkB,SAAoB,EACpB,EAAU,EACT,aAA4B;QAF7B,cAAS,GAAT,SAAS,CAAW;QACpB,OAAE,GAAF,EAAE,CAAQ;QACT,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAEJ;;OAEG;IACI,KAAK,CAAC,IAAI,CAAC,OAAwB;QACxC,OAAO,eAAe,CAAC,KAAK,EAAE,cAAsC,EAAE,EAAE;YACtE,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAAgC;gBAC5E,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,GAAG;gBAC9B,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,2BAA2B,CACpC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAA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AC,GAAG,CAAC,CAAC;YAEnC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;gBAC/C,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,GAAG;gBAC9B,UAAU,EAAE,EAAE;gBACd,OAAO;gBACP,cAAc;aACf,CAAC,CAAC;YACH,OAAO,IAAI,2BAA2B,CACpC,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,OAAO,EAChB,QAAQ,CAAC,IAAI,EACb,IAAI,EACJ,yBAAyB,EAAE,CAC5B,CAAC;QACJ,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createUserDefinedFunctionUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { UserDefinedFunctionDefinition } from \"./UserDefinedFunctionDefinition\";\nimport { UserDefinedFunctionResponse } from \"./UserDefinedFunctionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to read, replace, or delete a specified User Definied Function by id.\n *\n * @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions.\n */\nexport class UserDefinedFunction {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createUserDefinedFunctionUri(this.container.database.id, this.container.id, this.id);\n }\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link UserDefinedFunction}.\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}.\n * @param options -\n */\n public async replace(\n body: UserDefinedFunctionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link UserDefined}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts new file mode 100644 index 000000000..64a5cbcd8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts @@ -0,0 +1,7 @@ +export interface UserDefinedFunctionDefinition { + /** The id of the {@link UserDefinedFunction} */ + id?: string; + /** The body of the user defined function, it can also be passed as a stringifed function */ + body?: string | (() => void); +} +//# sourceMappingURL=UserDefinedFunctionDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts.map new file mode 100644 index 000000000..b5ef6b699 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctionDefinition.d.ts","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunctionDefinition.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,6BAA6B;IAC5C,gDAAgD;IAChD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,4FAA4F;IAC5F,IAAI,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CAC9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js new file mode 100644 index 000000000..ef2fed969 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=UserDefinedFunctionDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js.map new file mode 100644 index 000000000..2b649c7a7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctionDefinition.js","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunctionDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface UserDefinedFunctionDefinition {\n /** The id of the {@link UserDefinedFunction} */\n id?: string;\n /** The body of the user defined function, it can also be passed as a stringifed function */\n body?: string | (() => void);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts new file mode 100644 index 000000000..ea5226cb4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts @@ -0,0 +1,18 @@ +import { CosmosDiagnostics } from "../../CosmosDiagnostics"; +import { CosmosHeaders } from "../../queryExecutionContext"; +import { ResourceResponse } from "../../request"; +import { Resource } from "../Resource"; +import { UserDefinedFunction } from "./UserDefinedFunction"; +import { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; +export declare class UserDefinedFunctionResponse extends ResourceResponse { + constructor(resource: UserDefinedFunctionDefinition & Resource, headers: CosmosHeaders, statusCode: number, udf: UserDefinedFunction, diagnostics: CosmosDiagnostics); + /** A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. */ + readonly userDefinedFunction: UserDefinedFunction; + /** + * Alias for `userDefinedFunction(id)`. + * + * A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. + */ + get udf(): UserDefinedFunction; +} +//# sourceMappingURL=UserDefinedFunctionResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts.map new file mode 100644 index 000000000..70434ee77 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctionResponse.d.ts","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAEhF,qBAAa,2BAA4B,SAAQ,gBAAgB,CAC/D,6BAA6B,GAAG,QAAQ,CACzC;gBAEG,QAAQ,EAAE,6BAA6B,GAAG,QAAQ,EAClD,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,mBAAmB,EACxB,WAAW,EAAE,iBAAiB;IAKhC,0HAA0H;IAC1H,SAAgB,mBAAmB,EAAE,mBAAmB,CAAC;IACzD;;;;OAIG;IACH,IAAW,GAAG,IAAI,mBAAmB,CAEpC;CACF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js new file mode 100644 index 000000000..de1af015d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js @@ -0,0 +1,16 @@ +import { ResourceResponse } from "../../request"; +export class UserDefinedFunctionResponse extends ResourceResponse { + constructor(resource, headers, statusCode, udf, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.userDefinedFunction = udf; + } + /** + * Alias for `userDefinedFunction(id)`. + * + * A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. + */ + get udf() { + return this.userDefinedFunction; + } +} +//# sourceMappingURL=UserDefinedFunctionResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map new file mode 100644 index 000000000..76d3f2fc3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctionResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctionResponse.js","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKjD,MAAM,OAAO,2BAA4B,SAAQ,gBAEhD;IACC,YACE,QAAkD,EAClD,OAAsB,EACtB,UAAkB,EAClB,GAAwB,EACxB,WAA8B;QAE9B,KAAK,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;QAClD,IAAI,CAAC,mBAAmB,GAAG,GAAG,CAAC;IACjC,CAAC;IAGD;;;;OAIG;IACH,IAAW,GAAG;QACZ,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { UserDefinedFunction } from \"./UserDefinedFunction\";\nimport { UserDefinedFunctionDefinition } from \"./UserDefinedFunctionDefinition\";\n\nexport class UserDefinedFunctionResponse extends ResourceResponse<\n UserDefinedFunctionDefinition & Resource\n> {\n constructor(\n resource: UserDefinedFunctionDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n udf: UserDefinedFunction,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.userDefinedFunction = udf;\n }\n /** A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. */\n public readonly userDefinedFunction: UserDefinedFunction;\n /**\n * Alias for `userDefinedFunction(id)`.\n *\n * A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}.\n */\n public get udf(): UserDefinedFunction {\n return this.userDefinedFunction;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts new file mode 100644 index 000000000..597c09eec --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts @@ -0,0 +1,50 @@ +import { ClientContext } from "../../ClientContext"; +import { SqlQuerySpec } from "../../queryExecutionContext"; +import { QueryIterator } from "../../queryIterator"; +import { FeedOptions, RequestOptions } from "../../request"; +import { Container } from "../Container"; +import { Resource } from "../Resource"; +import { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; +import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; +/** + * Used to create, upsert, query, or read all User Defined Functions. + * + * @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id. + */ +export declare class UserDefinedFunctions { + readonly container: Container; + private readonly clientContext; + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Query all User Defined Functions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all User Defined Functions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all User Defined Functions. + * @example Read all User Defined Functions to array. + * ```typescript + * const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a UserDefinedFunction. + * + * Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers. + * + * For additional details, refer to the server-side JavaScript API documentation. + * + */ + create(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise; +} +//# sourceMappingURL=UserDefinedFunctions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts.map new file mode 100644 index 000000000..b85181217 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctions.d.ts","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunctions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E;;;;GAIG;AACH,qBAAa,oBAAoB;aAMb,SAAS,EAAE,SAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,aAAa;IANhC;;;OAGG;gBAEe,SAAS,EAAE,SAAS,EACnB,aAAa,EAAE,aAAa;IAG/C;;;OAGG;IACI,KAAK,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC;IAC5E;;;OAGG;IACI,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,CAAC,CAAC;IAkB7E;;;;;;OAMG;IACI,OAAO,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,aAAa,CAAC,6BAA6B,GAAG,QAAQ,CAAC;IAI9F;;;;;;;OAOG;IACU,MAAM,CACjB,IAAI,EAAE,6BAA6B,EACnC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,2BAA2B,CAAC;CAgCxC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js new file mode 100644 index 000000000..96add0b11 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js @@ -0,0 +1,77 @@ +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; +import { QueryIterator } from "../../queryIterator"; +import { UserDefinedFunction } from "./UserDefinedFunction"; +import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +/** + * Used to create, upsert, query, or read all User Defined Functions. + * + * @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id. + */ +export class UserDefinedFunctions { + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, ResourceType.udf); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.udf, + resourceId: id, + resultFn: (result) => result.UserDefinedFunctions, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all User Defined Functions. + * @example Read all User Defined Functions to array. + * ```typescript + * const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a UserDefinedFunction. + * + * Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers. + * + * For additional details, refer to the server-side JavaScript API documentation. + * + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, ResourceType.udf); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new UserDefinedFunction(this.container, response.result.id, this.clientContext); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} +//# sourceMappingURL=UserDefinedFunctions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js.map new file mode 100644 index 000000000..a78bbf5e7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/UserDefinedFunctions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctions.js","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/UserDefinedFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAC/B;;;OAGG;IACH,YACkB,SAAoB,EACnB,aAA4B;QAD7B,cAAS,GAAT,SAAS,CAAW;QACnB,kBAAa,GAAb,aAAa,CAAe;IAC5C,CAAC;IAYG,KAAK,CAAI,KAAmB,EAAE,OAAqB;QACxD,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;QACnE,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAE7C,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE;YAC5F,OAAO,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC;gBAClC,IAAI;gBACJ,YAAY,EAAE,YAAY,CAAC,GAAG;gBAC9B,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAoB;gBACjD,KAAK;gBACL,OAAO,EAAE,YAAY;gBACrB,cAAc;aACf,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;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poration.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { UserDefinedFunction } from \"./UserDefinedFunction\";\nimport { UserDefinedFunctionDefinition } from \"./UserDefinedFunctionDefinition\";\nimport { UserDefinedFunctionResponse } from \"./UserDefinedFunctionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to create, upsert, query, or read all User Defined Functions.\n *\n * @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id.\n */\nexport class UserDefinedFunctions {\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all User Defined Functions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all User Defined Functions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.udf);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n resultFn: (result) => result.UserDefinedFunctions,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all User Defined Functions.\n * @example Read all User Defined Functions to array.\n * ```typescript\n * const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a UserDefinedFunction.\n *\n * Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers.\n *\n * For additional details, refer to the server-side JavaScript API documentation.\n *\n */\n public async create(\n body: UserDefinedFunctionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.udf);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new UserDefinedFunction(this.container, response.result.id, this.clientContext);\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts new file mode 100644 index 000000000..b7af3ebe6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts @@ -0,0 +1,5 @@ +export { UserDefinedFunction } from "./UserDefinedFunction"; +export { UserDefinedFunctions } from "./UserDefinedFunctions"; +export { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; +export { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts.map new file mode 100644 index 000000000..5b4911407 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js new file mode 100644 index 000000000..dc9b79024 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { UserDefinedFunction } from "./UserDefinedFunction"; +export { UserDefinedFunctions } from "./UserDefinedFunctions"; +export { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js.map new file mode 100644 index 000000000..ff5a6aff9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/UserDefinedFunction/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/client/UserDefinedFunction/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { UserDefinedFunction } from \"./UserDefinedFunction\";\nexport { UserDefinedFunctions } from \"./UserDefinedFunctions\";\nexport { UserDefinedFunctionDefinition } from \"./UserDefinedFunctionDefinition\";\nexport { UserDefinedFunctionResponse } from \"./UserDefinedFunctionResponse\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts new file mode 100644 index 000000000..5200cf68b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts @@ -0,0 +1,13 @@ +export * from "./Conflict"; +export * from "./Container"; +export * from "./Database"; +export * from "./Item"; +export * from "./Offer"; +export * from "./Permission"; +export * from "./StoredProcedure"; +export * from "./Trigger"; +export * from "./User"; +export * from "./UserDefinedFunction"; +export * from "./Resource"; +export * from "./SasToken/SasTokenProperties"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts.map new file mode 100644 index 000000000..4ed20c725 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.js new file mode 100644 index 000000000..8f30d9a24 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.js @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export * from "./Conflict"; +export * from "./Container"; +export * from "./Database"; +export * from "./Item"; +export * from "./Offer"; +export * from "./Permission"; +export * from "./StoredProcedure"; +export * from "./Trigger"; +export * from "./User"; +export * from "./UserDefinedFunction"; +export * from "./Resource"; +export * from "./SasToken/SasTokenProperties"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/client/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.js.map new file mode 100644 index 000000000..47153cf54 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/client/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./Conflict\";\nexport * from \"./Container\";\nexport * from \"./Database\";\nexport * from \"./Item\";\nexport * from \"./Offer\";\nexport * from \"./Permission\";\nexport * from \"./StoredProcedure\";\nexport * from \"./Trigger\";\nexport * from \"./User\";\nexport * from \"./UserDefinedFunction\";\nexport * from \"./Resource\";\nexport * from \"./SasToken/SasTokenProperties\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts new file mode 100644 index 000000000..d23e29f4b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts @@ -0,0 +1,13 @@ +/** + * @hidden + * @hidden + * Specifies Net RUConsumed + */ +export declare class RUConsumedManager { + private ruConsumed; + private semaphore; + constructor(); + getRUConsumed(): Promise; + addToRUConsumed(value: number): Promise; +} +//# sourceMappingURL=RUConsumedManager.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts.map new file mode 100644 index 000000000..e8fb59f11 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"RUConsumedManager.d.ts","sourceRoot":"","sources":["../../../src/common/RUConsumedManager.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,SAAS,CAAM;;IAMvB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IAShC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAS9C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js new file mode 100644 index 000000000..8711ee2b0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import semaphore from "semaphore"; +/** + * @hidden + * @hidden + * Specifies Net RUConsumed + */ +export class RUConsumedManager { + constructor() { + this.ruConsumed = 0; + this.semaphore = semaphore(1); + } + getRUConsumed() { + return new Promise((resolve) => { + this.semaphore.take(() => { + this.semaphore.leave(); + resolve(this.ruConsumed); + }); + }); + } + addToRUConsumed(value) { + return new Promise((resolve) => { + this.semaphore.take(() => { + this.ruConsumed += value; + this.semaphore.leave(); + resolve(); + }); + }); + } +} +//# sourceMappingURL=RUConsumedManager.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js.map new file mode 100644 index 000000000..c961ed7a6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/RUConsumedManager.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RUConsumedManager.js","sourceRoot":"","sources":["../../../src/common/RUConsumedManager.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAI5B;QAHQ,eAAU,GAAW,CAAC,CAAC;QAI7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,aAAa;QACX,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;gBACvB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,KAAa;QAC3B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE;gBACvB,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC;gBACzB,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;gBACvB,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport semaphore from \"semaphore\";\n\n/**\n * @hidden\n * @hidden\n * Specifies Net RUConsumed\n */\nexport class RUConsumedManager {\n private ruConsumed: number = 0;\n private semaphore: any;\n\n constructor() {\n this.semaphore = semaphore(1);\n }\n\n getRUConsumed(): Promise {\n return new Promise((resolve) => {\n this.semaphore.take(() => {\n this.semaphore.leave();\n resolve(this.ruConsumed);\n });\n });\n }\n\n addToRUConsumed(value: number): Promise {\n return new Promise((resolve) => {\n this.semaphore.take(() => {\n this.ruConsumed += value;\n this.semaphore.leave();\n resolve();\n });\n });\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts new file mode 100644 index 000000000..37e2a354e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts @@ -0,0 +1,372 @@ +export interface PartitionKeyRangePropertiesNames { + MinInclusive: "minInclusive"; + MaxExclusive: "maxExclusive"; + Id: "id"; +} +/** + * @hidden + */ +export declare const Constants: { + HttpHeaders: { + Authorization: string; + ETag: string; + MethodOverride: string; + Slug: string; + ContentType: string; + LastModified: string; + ContentEncoding: string; + CharacterSet: string; + UserAgent: string; + IfModifiedSince: string; + IfMatch: string; + IfNoneMatch: string; + ContentLength: string; + AcceptEncoding: string; + KeepAlive: string; + CacheControl: string; + TransferEncoding: string; + ContentLanguage: string; + ContentLocation: string; + ContentMd5: string; + ContentRange: string; + Accept: string; + AcceptCharset: string; + AcceptLanguage: string; + IfRange: string; + IfUnmodifiedSince: string; + MaxForwards: string; + ProxyAuthorization: string; + AcceptRanges: string; + ProxyAuthenticate: string; + RetryAfter: string; + SetCookie: string; + WwwAuthenticate: string; + Origin: string; + Host: string; + AccessControlAllowOrigin: string; + AccessControlAllowHeaders: string; + KeyValueEncodingFormat: string; + WrapAssertionFormat: string; + WrapAssertion: string; + WrapScope: string; + SimpleToken: string; + HttpDate: string; + Prefer: string; + Location: string; + Referer: string; + A_IM: string; + Query: string; + IsQuery: string; + IsQueryPlan: string; + SupportedQueryFeatures: string; + QueryVersion: string; + Continuation: string; + ContinuationToken: string; + PageSize: string; + ItemCount: string; + ActivityId: string; + PreTriggerInclude: string; + PreTriggerExclude: string; + PostTriggerInclude: string; + PostTriggerExclude: string; + IndexingDirective: string; + SessionToken: string; + ConsistencyLevel: string; + XDate: string; + CollectionPartitionInfo: string; + CollectionServiceInfo: string; + RetryAfterInMilliseconds: string; + RetryAfterInMs: string; + IsFeedUnfiltered: string; + ResourceTokenExpiry: string; + EnableScanInQuery: string; + EmitVerboseTracesInQuery: string; + EnableCrossPartitionQuery: string; + ParallelizeCrossPartitionQuery: string; + ResponseContinuationTokenLimitInKB: string; + PopulateQueryMetrics: string; + QueryMetrics: string; + PopulateIndexMetrics: string; + IndexUtilization: string; + Version: string; + OwnerFullName: string; + OwnerId: string; + PartitionKey: string; + PartitionKeyRangeID: string; + StartEpk: string; + EndEpk: string; + ReadFeedKeyType: string; + MaxEntityCount: string; + CurrentEntityCount: string; + CollectionQuotaInMb: string; + CollectionCurrentUsageInMb: string; + MaxMediaStorageUsageInMB: string; + CurrentMediaStorageUsageInMB: string; + RequestCharge: string; + PopulateQuotaInfo: string; + MaxResourceQuota: string; + OfferType: string; + OfferThroughput: string; + AutoscaleSettings: string; + DisableRUPerMinuteUsage: string; + IsRUPerMinuteUsed: string; + OfferIsRUPerMinuteThroughputEnabled: string; + IndexTransformationProgress: string; + LazyIndexingProgress: string; + IsUpsert: string; + SubStatus: string; + EnableScriptLogging: string; + ScriptLogResults: string; + ALLOW_MULTIPLE_WRITES: string; + IsBatchRequest: string; + IsBatchAtomic: string; + BatchContinueOnError: string; + DedicatedGatewayPerRequestCacheStaleness: string; + ForceRefresh: string; + PriorityLevel: string; + }; + WritableLocations: string; + ReadableLocations: string; + LocationUnavailableExpirationTimeInMs: number; + ENABLE_MULTIPLE_WRITABLE_LOCATIONS: string; + DefaultUnavailableLocationExpirationTimeMS: number; + ThrottleRetryCount: string; + ThrottleRetryWaitTimeInMs: string; + CurrentVersion: string; + AzureNamespace: string; + AzurePackageName: string; + SDKName: string; + SDKVersion: string; + CosmosDbDiagnosticLevelEnvVarName: string; + DefaultMaxBulkRequestBodySizeInBytes: number; + Quota: { + CollectionSize: string; + }; + Path: { + Root: string; + DatabasesPathSegment: string; + CollectionsPathSegment: string; + UsersPathSegment: string; + DocumentsPathSegment: string; + PermissionsPathSegment: string; + StoredProceduresPathSegment: string; + TriggersPathSegment: string; + UserDefinedFunctionsPathSegment: string; + ConflictsPathSegment: string; + AttachmentsPathSegment: string; + PartitionKeyRangesPathSegment: string; + SchemasPathSegment: string; + OffersPathSegment: string; + TopologyPathSegment: string; + DatabaseAccountPathSegment: string; + }; + PartitionKeyRange: PartitionKeyRangePropertiesNames; + QueryRangeConstants: { + MinInclusive: string; + MaxExclusive: string; + min: string; + }; + /** + * @deprecated Use EffectivePartitionKeyConstants instead + */ + EffectiveParitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: string; + MaximumExclusiveEffectivePartitionKey: string; + }; + EffectivePartitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: string; + MaximumExclusiveEffectivePartitionKey: string; + }; + NonStreamingQueryDefaultRUThreshold: number; +}; +/** + * @hidden + */ +export declare enum ResourceType { + none = "", + database = "dbs", + offer = "offers", + user = "users", + permission = "permissions", + container = "colls", + conflicts = "conflicts", + sproc = "sprocs", + udf = "udfs", + trigger = "triggers", + item = "docs", + pkranges = "pkranges", + partitionkey = "partitionKey" +} +/** + * @hidden + */ +export declare enum HTTPMethod { + get = "GET", + patch = "PATCH", + post = "POST", + put = "PUT", + delete = "DELETE" +} +/** + * @hidden + */ +export declare enum OperationType { + Create = "create", + Replace = "replace", + Upsert = "upsert", + Delete = "delete", + Read = "read", + Query = "query", + Execute = "execute", + Batch = "batch", + Patch = "patch" +} +/** + * @hidden + */ +export declare enum CosmosKeyType { + PrimaryMaster = "PRIMARY_MASTER", + SecondaryMaster = "SECONDARY_MASTER", + PrimaryReadOnly = "PRIMARY_READONLY", + SecondaryReadOnly = "SECONDARY_READONLY" +} +/** + * @hidden + */ +export declare enum CosmosContainerChildResourceKind { + Item = "ITEM", + StoredProcedure = "STORED_PROCEDURE", + UserDefinedFunction = "USER_DEFINED_FUNCTION", + Trigger = "TRIGGER" +} +/** + * @hidden + */ +export declare enum PermissionScopeValues { + /** + * Values which set permission Scope applicable to control plane related operations. + */ + ScopeAccountReadValue = 1, + ScopeAccountListDatabasesValue = 2, + ScopeDatabaseReadValue = 4, + ScopeDatabaseReadOfferValue = 8, + ScopeDatabaseListContainerValue = 16, + ScopeContainerReadValue = 32, + ScopeContainerReadOfferValue = 64, + ScopeAccountCreateDatabasesValue = 1, + ScopeAccountDeleteDatabasesValue = 2, + ScopeDatabaseDeleteValue = 4, + ScopeDatabaseReplaceOfferValue = 8, + ScopeDatabaseCreateContainerValue = 16, + ScopeDatabaseDeleteContainerValue = 32, + ScopeContainerReplaceValue = 64, + ScopeContainerDeleteValue = 128, + ScopeContainerReplaceOfferValue = 256, + ScopeAccountReadAllAccessValue = 65535, + ScopeDatabaseReadAllAccessValue = 124, + ScopeContainersReadAllAccessValue = 96, + ScopeAccountWriteAllAccessValue = 65535, + ScopeDatabaseWriteAllAccessValue = 508, + ScopeContainersWriteAllAccessValue = 448, + /** + * Values which set permission Scope applicable to data plane related operations. + */ + ScopeContainerExecuteQueriesValue = 1, + ScopeContainerReadFeedsValue = 2, + ScopeContainerReadStoredProceduresValue = 4, + ScopeContainerReadUserDefinedFunctionsValue = 8, + ScopeContainerReadTriggersValue = 16, + ScopeContainerReadConflictsValue = 32, + ScopeItemReadValue = 64, + ScopeStoredProcedureReadValue = 128, + ScopeUserDefinedFunctionReadValue = 256, + ScopeTriggerReadValue = 512, + ScopeContainerCreateItemsValue = 1, + ScopeContainerReplaceItemsValue = 2, + ScopeContainerUpsertItemsValue = 4, + ScopeContainerDeleteItemsValue = 8, + ScopeContainerCreateStoredProceduresValue = 16, + ScopeContainerReplaceStoredProceduresValue = 32, + ScopeContainerDeleteStoredProceduresValue = 64, + ScopeContainerExecuteStoredProceduresValue = 128, + ScopeContainerCreateTriggersValue = 256, + ScopeContainerReplaceTriggersValue = 512, + ScopeContainerDeleteTriggersValue = 1024, + ScopeContainerCreateUserDefinedFunctionsValue = 2048, + ScopeContainerReplaceUserDefinedFunctionsValue = 4096, + ScopeContainerDeleteUserDefinedFunctionSValue = 8192, + ScopeContainerDeleteCONFLICTSValue = 16384, + ScopeItemReplaceValue = 65536, + ScopeItemUpsertValue = 131072, + ScopeItemDeleteValue = 262144, + ScopeStoredProcedureReplaceValue = 1048576, + ScopeStoredProcedureDeleteValue = 2097152, + ScopeStoredProcedureExecuteValue = 4194304, + ScopeUserDefinedFunctionReplaceValue = 8388608, + ScopeUserDefinedFunctionDeleteValue = 16777216, + ScopeTriggerReplaceValue = 33554432, + ScopeTriggerDeleteValue = 67108864, + ScopeContainerReadAllAccessValue = 4294967295, + ScopeItemReadAllAccessValue = 65, + ScopeContainerWriteAllAccessValue = 4294967295, + ScopeItemWriteAllAccessValue = 458767, + NoneValue = 0 +} +/** + * @hidden + */ +export declare enum SasTokenPermissionKind { + ContainerCreateItems = 1, + ContainerReplaceItems = 2, + ContainerUpsertItems = 4, + ContainerDeleteItems = 128, + ContainerExecuteQueries = 1, + ContainerReadFeeds = 2, + ContainerCreateStoreProcedure = 16, + ContainerReadStoreProcedure = 4, + ContainerReplaceStoreProcedure = 32, + ContainerDeleteStoreProcedure = 64, + ContainerCreateTriggers = 256, + ContainerReadTriggers = 16, + ContainerReplaceTriggers = 512, + ContainerDeleteTriggers = 1024, + ContainerCreateUserDefinedFunctions = 2048, + ContainerReadUserDefinedFunctions = 8, + ContainerReplaceUserDefinedFunctions = 4096, + ContainerDeleteUserDefinedFunctions = 8192, + ContainerExecuteStoredProcedure = 128, + ContainerReadConflicts = 32, + ContainerDeleteConflicts = 16384, + ContainerReadAny = 64, + ContainerFullAccess = 4294967295, + ItemReadAny = 65536, + ItemFullAccess = 65, + ItemRead = 64, + ItemReplace = 65536, + ItemUpsert = 131072, + ItemDelete = 262144, + StoreProcedureRead = 128, + StoreProcedureReplace = 1048576, + StoreProcedureDelete = 2097152, + StoreProcedureExecute = 4194304, + UserDefinedFuntionRead = 256, + UserDefinedFuntionReplace = 8388608, + UserDefinedFuntionDelete = 16777216, + TriggerRead = 512, + TriggerReplace = 33554432, + TriggerDelete = 67108864 +} +export declare enum QueryFeature { + NonValueAggregate = "NonValueAggregate", + Aggregate = "Aggregate", + Distinct = "Distinct", + MultipleOrderBy = "MultipleOrderBy", + OffsetAndLimit = "OffsetAndLimit", + OrderBy = "OrderBy", + Top = "Top", + CompositeAggregate = "CompositeAggregate", + GroupBy = "GroupBy", + MultipleAggregates = "MultipleAggregates", + NonStreamingOrderBy = "NonStreamingOrderBy" +} +//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts.map new file mode 100644 index 000000000..ba317e14f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/common/constants.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,gCAAgC;IAE/C,YAAY,EAAE,cAAc,CAAC;IAC7B,YAAY,EAAE,cAAc,CAAC;IAC7B,EAAE,EAAE,IAAI,CAAC;CACV;AAED;;GAEG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,qBAAqB,IAAwD;IAC7E,oBAAoB,IAAuD;IAC3E,oBAAoB,MAAkD;IACtE,uBAAuB,IAA0D;IACjF,kBAAkB,IAAqD;IACvE,6BAA6B,KAAkE;IAC/F,2BAA2B,IAAgE;IAC3F,8BAA8B,KAAmE;IACjG,6BAA6B,KAAkE;IAC/F,uBAAuB,MAA0D;IACjF,qBAAqB,KAAwD;IAC7E,wBAAwB,MAA2D;IACnF,uBAAuB,OAA0D;IACjF,mCAAmC,OAAsE;IACzG,iCAAiC,IAAoE;IACrG,oCAAoC,OAAuE;IAC3G,mCAAmC,OAAsE;IACzG,+BAA+B,MAAmE;IAClG,sBAAsB,KAAyD;IAC/E,wBAAwB,QAA2D;IACnF,gBAAgB,KAAqD;IACrE,mBAAmB,aAAyD;IAC5E,WAAW,QAA8C;IACzD,cAAc,KAAoD;IAClE,QAAQ,KAA2C;IACnD,WAAW,QAA8C;IACzD,UAAU,SAA6C;IACvD,UAAU,SAA6C;IACvD,kBAAkB,MAAsD;IACxE,qBAAqB,UAAyD;IAC9E,oBAAoB,UAAwD;IAC5E,qBAAqB,UAAyD;IAC9E,sBAAsB,MAA0D;IAChF,yBAAyB,UAA6D;IACtF,wBAAwB,WAA4D;IACpF,WAAW,MAA8C;IACzD,cAAc,WAAiD;IAC/D,aAAa,WAAgD;CAC9D;AAED,oBAAY,YAAY;IACtB,iBAAiB,sBAAsB;IACvC,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,eAAe,oBAAoB;IACnC,cAAc,mBAAmB;IACjC,OAAO,YAAY;IACnB,GAAG,QAAQ;IACX,kBAAkB,uBAAuB;IACzC,OAAO,YAAY;IACnB,kBAAkB,uBAAuB;IACzC,mBAAmB,wBAAwB;CAC5C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js new file mode 100644 index 000000000..f7c2d310e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js @@ -0,0 +1,419 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +export const Constants = { + HttpHeaders: { + Authorization: "authorization", + ETag: "etag", + MethodOverride: "X-HTTP-Method", + Slug: "Slug", + ContentType: "Content-Type", + LastModified: "Last-Modified", + ContentEncoding: "Content-Encoding", + CharacterSet: "CharacterSet", + UserAgent: "User-Agent", + IfModifiedSince: "If-Modified-Since", + IfMatch: "If-Match", + IfNoneMatch: "If-None-Match", + ContentLength: "Content-Length", + AcceptEncoding: "Accept-Encoding", + KeepAlive: "Keep-Alive", + CacheControl: "Cache-Control", + TransferEncoding: "Transfer-Encoding", + ContentLanguage: "Content-Language", + ContentLocation: "Content-Location", + ContentMd5: "Content-Md5", + ContentRange: "Content-Range", + Accept: "Accept", + AcceptCharset: "Accept-Charset", + AcceptLanguage: "Accept-Language", + IfRange: "If-Range", + IfUnmodifiedSince: "If-Unmodified-Since", + MaxForwards: "Max-Forwards", + ProxyAuthorization: "Proxy-Authorization", + AcceptRanges: "Accept-Ranges", + ProxyAuthenticate: "Proxy-Authenticate", + RetryAfter: "Retry-After", + SetCookie: "Set-Cookie", + WwwAuthenticate: "Www-Authenticate", + Origin: "Origin", + Host: "Host", + AccessControlAllowOrigin: "Access-Control-Allow-Origin", + AccessControlAllowHeaders: "Access-Control-Allow-Headers", + KeyValueEncodingFormat: "application/x-www-form-urlencoded", + WrapAssertionFormat: "wrap_assertion_format", + WrapAssertion: "wrap_assertion", + WrapScope: "wrap_scope", + SimpleToken: "SWT", + HttpDate: "date", + Prefer: "Prefer", + Location: "Location", + Referer: "referer", + A_IM: "A-IM", + // Query + Query: "x-ms-documentdb-query", + IsQuery: "x-ms-documentdb-isquery", + IsQueryPlan: "x-ms-cosmos-is-query-plan-request", + SupportedQueryFeatures: "x-ms-cosmos-supported-query-features", + QueryVersion: "x-ms-cosmos-query-version", + // Our custom Azure Cosmos DB headers + Continuation: "x-ms-continuation", + ContinuationToken: "x-ms-continuation-token", + PageSize: "x-ms-max-item-count", + ItemCount: "x-ms-item-count", + // Request sender generated. Simply echoed by backend. + ActivityId: "x-ms-activity-id", + PreTriggerInclude: "x-ms-documentdb-pre-trigger-include", + PreTriggerExclude: "x-ms-documentdb-pre-trigger-exclude", + PostTriggerInclude: "x-ms-documentdb-post-trigger-include", + PostTriggerExclude: "x-ms-documentdb-post-trigger-exclude", + IndexingDirective: "x-ms-indexing-directive", + SessionToken: "x-ms-session-token", + ConsistencyLevel: "x-ms-consistency-level", + XDate: "x-ms-date", + CollectionPartitionInfo: "x-ms-collection-partition-info", + CollectionServiceInfo: "x-ms-collection-service-info", + // Deprecated, use RetryAfterInMs instead. + RetryAfterInMilliseconds: "x-ms-retry-after-ms", + RetryAfterInMs: "x-ms-retry-after-ms", + IsFeedUnfiltered: "x-ms-is-feed-unfiltered", + ResourceTokenExpiry: "x-ms-documentdb-expiry-seconds", + EnableScanInQuery: "x-ms-documentdb-query-enable-scan", + EmitVerboseTracesInQuery: "x-ms-documentdb-query-emit-traces", + EnableCrossPartitionQuery: "x-ms-documentdb-query-enablecrosspartition", + ParallelizeCrossPartitionQuery: "x-ms-documentdb-query-parallelizecrosspartitionquery", + ResponseContinuationTokenLimitInKB: "x-ms-documentdb-responsecontinuationtokenlimitinkb", + // QueryMetrics + // Request header to tell backend to give you query metrics. + PopulateQueryMetrics: "x-ms-documentdb-populatequerymetrics", + // Response header that holds the serialized version of query metrics. + QueryMetrics: "x-ms-documentdb-query-metrics", + // IndexMetrics + // Request header to tell backend to give you index metrics. + PopulateIndexMetrics: "x-ms-cosmos-populateindexmetrics", + // Response header that holds the serialized version of index metrics. + IndexUtilization: "x-ms-cosmos-index-utilization", + // Version headers and values + Version: "x-ms-version", + // Owner name + OwnerFullName: "x-ms-alt-content-path", + // Owner ID used for name based request in session token. + OwnerId: "x-ms-content-path", + // Partition Key + PartitionKey: "x-ms-documentdb-partitionkey", + PartitionKeyRangeID: "x-ms-documentdb-partitionkeyrangeid", + // Epk Range headers + StartEpk: "x-ms-start-epk", + EndEpk: "x-ms-end-epk", + // Read Feed Type + ReadFeedKeyType: "x-ms-read-key-type", + // Quota Info + MaxEntityCount: "x-ms-root-entity-max-count", + CurrentEntityCount: "x-ms-root-entity-current-count", + CollectionQuotaInMb: "x-ms-collection-quota-mb", + CollectionCurrentUsageInMb: "x-ms-collection-usage-mb", + MaxMediaStorageUsageInMB: "x-ms-max-media-storage-usage-mb", + CurrentMediaStorageUsageInMB: "x-ms-media-storage-usage-mb", + RequestCharge: "x-ms-request-charge", + PopulateQuotaInfo: "x-ms-documentdb-populatequotainfo", + MaxResourceQuota: "x-ms-resource-quota", + // Offer header + OfferType: "x-ms-offer-type", + OfferThroughput: "x-ms-offer-throughput", + AutoscaleSettings: "x-ms-cosmos-offer-autopilot-settings", + // Custom RUs/minute headers + DisableRUPerMinuteUsage: "x-ms-documentdb-disable-ru-per-minute-usage", + IsRUPerMinuteUsed: "x-ms-documentdb-is-ru-per-minute-used", + OfferIsRUPerMinuteThroughputEnabled: "x-ms-offer-is-ru-per-minute-throughput-enabled", + // Index progress headers + IndexTransformationProgress: "x-ms-documentdb-collection-index-transformation-progress", + LazyIndexingProgress: "x-ms-documentdb-collection-lazy-indexing-progress", + // Upsert header + IsUpsert: "x-ms-documentdb-is-upsert", + // Sub status of the error + SubStatus: "x-ms-substatus", + // StoredProcedure related headers + EnableScriptLogging: "x-ms-documentdb-script-enable-logging", + ScriptLogResults: "x-ms-documentdb-script-log-results", + // Multi-Region Write + ALLOW_MULTIPLE_WRITES: "x-ms-cosmos-allow-tentative-writes", + // Bulk/Batch header + IsBatchRequest: "x-ms-cosmos-is-batch-request", + IsBatchAtomic: "x-ms-cosmos-batch-atomic", + BatchContinueOnError: "x-ms-cosmos-batch-continue-on-error", + // Dedicated Gateway Headers + DedicatedGatewayPerRequestCacheStaleness: "x-ms-dedicatedgateway-max-age", + // Cache Refresh header + ForceRefresh: "x-ms-force-refresh", + // Priority Based throttling header + PriorityLevel: "x-ms-cosmos-priority-level", + }, + // GlobalDB related constants + WritableLocations: "writableLocations", + ReadableLocations: "readableLocations", + LocationUnavailableExpirationTimeInMs: 5 * 60 * 1000, + // ServiceDocument Resource + ENABLE_MULTIPLE_WRITABLE_LOCATIONS: "enableMultipleWriteLocations", + // Background refresh time + DefaultUnavailableLocationExpirationTimeMS: 5 * 60 * 1000, + // Client generated retry count response header + ThrottleRetryCount: "x-ms-throttle-retry-count", + ThrottleRetryWaitTimeInMs: "x-ms-throttle-retry-wait-time-ms", + // Platform + CurrentVersion: "2020-07-15", + AzureNamespace: "Azure.Cosmos", + AzurePackageName: "@azure/cosmos", + SDKName: "azure-cosmos-js", + SDKVersion: "4.0.1-beta.3", + // Diagnostics + CosmosDbDiagnosticLevelEnvVarName: "AZURE_COSMOSDB_DIAGNOSTICS_LEVEL", + // Bulk Operations + DefaultMaxBulkRequestBodySizeInBytes: 220201, + Quota: { + CollectionSize: "collectionSize", + }, + Path: { + Root: "/", + DatabasesPathSegment: "dbs", + CollectionsPathSegment: "colls", + UsersPathSegment: "users", + DocumentsPathSegment: "docs", + PermissionsPathSegment: "permissions", + StoredProceduresPathSegment: "sprocs", + TriggersPathSegment: "triggers", + UserDefinedFunctionsPathSegment: "udfs", + ConflictsPathSegment: "conflicts", + AttachmentsPathSegment: "attachments", + PartitionKeyRangesPathSegment: "pkranges", + SchemasPathSegment: "schemas", + OffersPathSegment: "offers", + TopologyPathSegment: "topology", + DatabaseAccountPathSegment: "databaseaccount", + }, + PartitionKeyRange: { + // Partition Key Range Constants + MinInclusive: "minInclusive", + MaxExclusive: "maxExclusive", + Id: "id", + }, + QueryRangeConstants: { + // Partition Key Range Constants + MinInclusive: "minInclusive", + MaxExclusive: "maxExclusive", + min: "min", + }, + /** + * @deprecated Use EffectivePartitionKeyConstants instead + */ + EffectiveParitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: "", + MaximumExclusiveEffectivePartitionKey: "FF", + }, + EffectivePartitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: "", + MaximumExclusiveEffectivePartitionKey: "FF", + }, + // NonStreaming queries + NonStreamingQueryDefaultRUThreshold: 5000, +}; +/** + * @hidden + */ +export var ResourceType; +(function (ResourceType) { + ResourceType["none"] = ""; + ResourceType["database"] = "dbs"; + ResourceType["offer"] = "offers"; + ResourceType["user"] = "users"; + ResourceType["permission"] = "permissions"; + ResourceType["container"] = "colls"; + ResourceType["conflicts"] = "conflicts"; + ResourceType["sproc"] = "sprocs"; + ResourceType["udf"] = "udfs"; + ResourceType["trigger"] = "triggers"; + ResourceType["item"] = "docs"; + ResourceType["pkranges"] = "pkranges"; + ResourceType["partitionkey"] = "partitionKey"; +})(ResourceType || (ResourceType = {})); +/** + * @hidden + */ +export var HTTPMethod; +(function (HTTPMethod) { + HTTPMethod["get"] = "GET"; + HTTPMethod["patch"] = "PATCH"; + HTTPMethod["post"] = "POST"; + HTTPMethod["put"] = "PUT"; + HTTPMethod["delete"] = "DELETE"; +})(HTTPMethod || (HTTPMethod = {})); +/** + * @hidden + */ +export var OperationType; +(function (OperationType) { + OperationType["Create"] = "create"; + OperationType["Replace"] = "replace"; + OperationType["Upsert"] = "upsert"; + OperationType["Delete"] = "delete"; + OperationType["Read"] = "read"; + OperationType["Query"] = "query"; + OperationType["Execute"] = "execute"; + OperationType["Batch"] = "batch"; + OperationType["Patch"] = "patch"; +})(OperationType || (OperationType = {})); +/** + * @hidden + */ +export var CosmosKeyType; +(function (CosmosKeyType) { + CosmosKeyType["PrimaryMaster"] = "PRIMARY_MASTER"; + CosmosKeyType["SecondaryMaster"] = "SECONDARY_MASTER"; + CosmosKeyType["PrimaryReadOnly"] = "PRIMARY_READONLY"; + CosmosKeyType["SecondaryReadOnly"] = "SECONDARY_READONLY"; +})(CosmosKeyType || (CosmosKeyType = {})); +/** + * @hidden + */ +export var CosmosContainerChildResourceKind; +(function (CosmosContainerChildResourceKind) { + CosmosContainerChildResourceKind["Item"] = "ITEM"; + CosmosContainerChildResourceKind["StoredProcedure"] = "STORED_PROCEDURE"; + CosmosContainerChildResourceKind["UserDefinedFunction"] = "USER_DEFINED_FUNCTION"; + CosmosContainerChildResourceKind["Trigger"] = "TRIGGER"; +})(CosmosContainerChildResourceKind || (CosmosContainerChildResourceKind = {})); +/** + * @hidden + */ +export var PermissionScopeValues; +(function (PermissionScopeValues) { + /** + * Values which set permission Scope applicable to control plane related operations. + */ + PermissionScopeValues[PermissionScopeValues["ScopeAccountReadValue"] = 1] = "ScopeAccountReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountListDatabasesValue"] = 2] = "ScopeAccountListDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadValue"] = 4] = "ScopeDatabaseReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadOfferValue"] = 8] = "ScopeDatabaseReadOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseListContainerValue"] = 16] = "ScopeDatabaseListContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadValue"] = 32] = "ScopeContainerReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadOfferValue"] = 64] = "ScopeContainerReadOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountCreateDatabasesValue"] = 1] = "ScopeAccountCreateDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountDeleteDatabasesValue"] = 2] = "ScopeAccountDeleteDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseDeleteValue"] = 4] = "ScopeDatabaseDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReplaceOfferValue"] = 8] = "ScopeDatabaseReplaceOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseCreateContainerValue"] = 16] = "ScopeDatabaseCreateContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseDeleteContainerValue"] = 32] = "ScopeDatabaseDeleteContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceValue"] = 64] = "ScopeContainerReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteValue"] = 128] = "ScopeContainerDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceOfferValue"] = 256] = "ScopeContainerReplaceOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountReadAllAccessValue"] = 65535] = "ScopeAccountReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadAllAccessValue"] = 124] = "ScopeDatabaseReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainersReadAllAccessValue"] = 96] = "ScopeContainersReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountWriteAllAccessValue"] = 65535] = "ScopeAccountWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseWriteAllAccessValue"] = 508] = "ScopeDatabaseWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainersWriteAllAccessValue"] = 448] = "ScopeContainersWriteAllAccessValue"; + /** + * Values which set permission Scope applicable to data plane related operations. + */ + PermissionScopeValues[PermissionScopeValues["ScopeContainerExecuteQueriesValue"] = 1] = "ScopeContainerExecuteQueriesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadFeedsValue"] = 2] = "ScopeContainerReadFeedsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadStoredProceduresValue"] = 4] = "ScopeContainerReadStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadUserDefinedFunctionsValue"] = 8] = "ScopeContainerReadUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadTriggersValue"] = 16] = "ScopeContainerReadTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadConflictsValue"] = 32] = "ScopeContainerReadConflictsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReadValue"] = 64] = "ScopeItemReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureReadValue"] = 128] = "ScopeStoredProcedureReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionReadValue"] = 256] = "ScopeUserDefinedFunctionReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerReadValue"] = 512] = "ScopeTriggerReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateItemsValue"] = 1] = "ScopeContainerCreateItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceItemsValue"] = 2] = "ScopeContainerReplaceItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerUpsertItemsValue"] = 4] = "ScopeContainerUpsertItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteItemsValue"] = 8] = "ScopeContainerDeleteItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateStoredProceduresValue"] = 16] = "ScopeContainerCreateStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceStoredProceduresValue"] = 32] = "ScopeContainerReplaceStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteStoredProceduresValue"] = 64] = "ScopeContainerDeleteStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerExecuteStoredProceduresValue"] = 128] = "ScopeContainerExecuteStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateTriggersValue"] = 256] = "ScopeContainerCreateTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceTriggersValue"] = 512] = "ScopeContainerReplaceTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteTriggersValue"] = 1024] = "ScopeContainerDeleteTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateUserDefinedFunctionsValue"] = 2048] = "ScopeContainerCreateUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceUserDefinedFunctionsValue"] = 4096] = "ScopeContainerReplaceUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteUserDefinedFunctionSValue"] = 8192] = "ScopeContainerDeleteUserDefinedFunctionSValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteCONFLICTSValue"] = 16384] = "ScopeContainerDeleteCONFLICTSValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReplaceValue"] = 65536] = "ScopeItemReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemUpsertValue"] = 131072] = "ScopeItemUpsertValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemDeleteValue"] = 262144] = "ScopeItemDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureReplaceValue"] = 1048576] = "ScopeStoredProcedureReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureDeleteValue"] = 2097152] = "ScopeStoredProcedureDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureExecuteValue"] = 4194304] = "ScopeStoredProcedureExecuteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionReplaceValue"] = 8388608] = "ScopeUserDefinedFunctionReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionDeleteValue"] = 16777216] = "ScopeUserDefinedFunctionDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerReplaceValue"] = 33554432] = "ScopeTriggerReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerDeleteValue"] = 67108864] = "ScopeTriggerDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadAllAccessValue"] = 4294967295] = "ScopeContainerReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReadAllAccessValue"] = 65] = "ScopeItemReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerWriteAllAccessValue"] = 4294967295] = "ScopeContainerWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemWriteAllAccessValue"] = 458767] = "ScopeItemWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["NoneValue"] = 0] = "NoneValue"; +})(PermissionScopeValues || (PermissionScopeValues = {})); +/** + * @hidden + */ +export var SasTokenPermissionKind; +(function (SasTokenPermissionKind) { + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateItems"] = 1] = "ContainerCreateItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceItems"] = 2] = "ContainerReplaceItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerUpsertItems"] = 4] = "ContainerUpsertItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteItems"] = 128] = "ContainerDeleteItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerExecuteQueries"] = 1] = "ContainerExecuteQueries"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadFeeds"] = 2] = "ContainerReadFeeds"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateStoreProcedure"] = 16] = "ContainerCreateStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadStoreProcedure"] = 4] = "ContainerReadStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceStoreProcedure"] = 32] = "ContainerReplaceStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteStoreProcedure"] = 64] = "ContainerDeleteStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateTriggers"] = 256] = "ContainerCreateTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadTriggers"] = 16] = "ContainerReadTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceTriggers"] = 512] = "ContainerReplaceTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteTriggers"] = 1024] = "ContainerDeleteTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateUserDefinedFunctions"] = 2048] = "ContainerCreateUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadUserDefinedFunctions"] = 8] = "ContainerReadUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceUserDefinedFunctions"] = 4096] = "ContainerReplaceUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteUserDefinedFunctions"] = 8192] = "ContainerDeleteUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerExecuteStoredProcedure"] = 128] = "ContainerExecuteStoredProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadConflicts"] = 32] = "ContainerReadConflicts"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteConflicts"] = 16384] = "ContainerDeleteConflicts"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadAny"] = 64] = "ContainerReadAny"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerFullAccess"] = 4294967295] = "ContainerFullAccess"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemReadAny"] = 65536] = "ItemReadAny"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemFullAccess"] = 65] = "ItemFullAccess"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemRead"] = 64] = "ItemRead"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemReplace"] = 65536] = "ItemReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemUpsert"] = 131072] = "ItemUpsert"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemDelete"] = 262144] = "ItemDelete"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureRead"] = 128] = "StoreProcedureRead"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureReplace"] = 1048576] = "StoreProcedureReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureDelete"] = 2097152] = "StoreProcedureDelete"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureExecute"] = 4194304] = "StoreProcedureExecute"; + SasTokenPermissionKind[SasTokenPermissionKind["UserDefinedFuntionRead"] = 256] = "UserDefinedFuntionRead"; + SasTokenPermissionKind[SasTokenPermissionKind["UserDefinedFuntionReplace"] = 8388608] = "UserDefinedFuntionReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["UserDefinedFuntionDelete"] = 16777216] = "UserDefinedFuntionDelete"; + SasTokenPermissionKind[SasTokenPermissionKind["TriggerRead"] = 512] = "TriggerRead"; + SasTokenPermissionKind[SasTokenPermissionKind["TriggerReplace"] = 33554432] = "TriggerReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["TriggerDelete"] = 67108864] = "TriggerDelete"; +})(SasTokenPermissionKind || (SasTokenPermissionKind = {})); +export var QueryFeature; +(function (QueryFeature) { + QueryFeature["NonValueAggregate"] = "NonValueAggregate"; + QueryFeature["Aggregate"] = "Aggregate"; + QueryFeature["Distinct"] = "Distinct"; + QueryFeature["MultipleOrderBy"] = "MultipleOrderBy"; + QueryFeature["OffsetAndLimit"] = "OffsetAndLimit"; + QueryFeature["OrderBy"] = "OrderBy"; + QueryFeature["Top"] = "Top"; + QueryFeature["CompositeAggregate"] = "CompositeAggregate"; + QueryFeature["GroupBy"] = "GroupBy"; + QueryFeature["MultipleAggregates"] = "MultipleAggregates"; + QueryFeature["NonStreamingOrderBy"] = "NonStreamingOrderBy"; +})(QueryFeature || (QueryFeature = {})); +//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js.map new file mode 100644 index 000000000..0facfe9e9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/common/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS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4FAA6D,CAAA;AAC/D,CAAC,EAxCW,sBAAsB,KAAtB,sBAAsB,QAwCjC;AAED,MAAM,CAAN,IAAY,YAYX;AAZD,WAAY,YAAY;IACtB,uDAAuC,CAAA;IACvC,uCAAuB,CAAA;IACvB,qCAAqB,CAAA;IACrB,mDAAmC,CAAA;IACnC,iDAAiC,CAAA;IACjC,mCAAmB,CAAA;IACnB,2BAAW,CAAA;IACX,yDAAyC,CAAA;IACzC,mCAAmB,CAAA;IACnB,yDAAyC,CAAA;IACzC,2DAA2C,CAAA;AAC7C,CAAC,EAZW,YAAY,KAAZ,YAAY,QAYvB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface PartitionKeyRangePropertiesNames {\n // Partition Key Range Constants\n MinInclusive: \"minInclusive\";\n MaxExclusive: \"maxExclusive\";\n Id: \"id\";\n}\n\n/**\n * @hidden\n */\nexport const Constants = {\n HttpHeaders: {\n Authorization: \"authorization\",\n ETag: \"etag\",\n MethodOverride: \"X-HTTP-Method\",\n Slug: \"Slug\",\n ContentType: \"Content-Type\",\n LastModified: \"Last-Modified\",\n ContentEncoding: \"Content-Encoding\",\n CharacterSet: \"CharacterSet\",\n UserAgent: \"User-Agent\",\n IfModifiedSince: \"If-Modified-Since\",\n IfMatch: \"If-Match\",\n IfNoneMatch: \"If-None-Match\",\n ContentLength: \"Content-Length\",\n AcceptEncoding: \"Accept-Encoding\",\n KeepAlive: \"Keep-Alive\",\n CacheControl: \"Cache-Control\",\n TransferEncoding: \"Transfer-Encoding\",\n ContentLanguage: \"Content-Language\",\n ContentLocation: \"Content-Location\",\n ContentMd5: \"Content-Md5\",\n ContentRange: \"Content-Range\",\n Accept: \"Accept\",\n AcceptCharset: \"Accept-Charset\",\n AcceptLanguage: \"Accept-Language\",\n IfRange: \"If-Range\",\n IfUnmodifiedSince: \"If-Unmodified-Since\",\n MaxForwards: \"Max-Forwards\",\n ProxyAuthorization: \"Proxy-Authorization\",\n AcceptRanges: \"Accept-Ranges\",\n ProxyAuthenticate: \"Proxy-Authenticate\",\n RetryAfter: \"Retry-After\",\n SetCookie: \"Set-Cookie\",\n WwwAuthenticate: \"Www-Authenticate\",\n Origin: \"Origin\",\n Host: \"Host\",\n AccessControlAllowOrigin: \"Access-Control-Allow-Origin\",\n AccessControlAllowHeaders: \"Access-Control-Allow-Headers\",\n KeyValueEncodingFormat: \"application/x-www-form-urlencoded\",\n WrapAssertionFormat: \"wrap_assertion_format\",\n WrapAssertion: \"wrap_assertion\",\n WrapScope: \"wrap_scope\",\n SimpleToken: \"SWT\",\n HttpDate: \"date\",\n Prefer: \"Prefer\",\n Location: \"Location\",\n Referer: \"referer\",\n A_IM: \"A-IM\",\n\n // Query\n Query: \"x-ms-documentdb-query\",\n IsQuery: \"x-ms-documentdb-isquery\",\n IsQueryPlan: \"x-ms-cosmos-is-query-plan-request\",\n SupportedQueryFeatures: \"x-ms-cosmos-supported-query-features\",\n QueryVersion: \"x-ms-cosmos-query-version\",\n\n // Our custom Azure Cosmos DB headers\n Continuation: \"x-ms-continuation\",\n ContinuationToken: \"x-ms-continuation-token\",\n PageSize: \"x-ms-max-item-count\",\n ItemCount: \"x-ms-item-count\",\n\n // Request sender generated. Simply echoed by backend.\n ActivityId: \"x-ms-activity-id\",\n PreTriggerInclude: \"x-ms-documentdb-pre-trigger-include\",\n PreTriggerExclude: \"x-ms-documentdb-pre-trigger-exclude\",\n PostTriggerInclude: \"x-ms-documentdb-post-trigger-include\",\n PostTriggerExclude: \"x-ms-documentdb-post-trigger-exclude\",\n IndexingDirective: \"x-ms-indexing-directive\",\n SessionToken: \"x-ms-session-token\",\n ConsistencyLevel: \"x-ms-consistency-level\",\n XDate: \"x-ms-date\",\n CollectionPartitionInfo: \"x-ms-collection-partition-info\",\n CollectionServiceInfo: \"x-ms-collection-service-info\",\n // Deprecated, use RetryAfterInMs instead.\n RetryAfterInMilliseconds: \"x-ms-retry-after-ms\",\n RetryAfterInMs: \"x-ms-retry-after-ms\",\n IsFeedUnfiltered: \"x-ms-is-feed-unfiltered\",\n ResourceTokenExpiry: \"x-ms-documentdb-expiry-seconds\",\n EnableScanInQuery: \"x-ms-documentdb-query-enable-scan\",\n EmitVerboseTracesInQuery: \"x-ms-documentdb-query-emit-traces\",\n EnableCrossPartitionQuery: \"x-ms-documentdb-query-enablecrosspartition\",\n ParallelizeCrossPartitionQuery: \"x-ms-documentdb-query-parallelizecrosspartitionquery\",\n ResponseContinuationTokenLimitInKB: \"x-ms-documentdb-responsecontinuationtokenlimitinkb\",\n\n // QueryMetrics\n // Request header to tell backend to give you query metrics.\n PopulateQueryMetrics: \"x-ms-documentdb-populatequerymetrics\",\n // Response header that holds the serialized version of query metrics.\n QueryMetrics: \"x-ms-documentdb-query-metrics\",\n\n // IndexMetrics\n // Request header to tell backend to give you index metrics.\n PopulateIndexMetrics: \"x-ms-cosmos-populateindexmetrics\",\n // Response header that holds the serialized version of index metrics.\n IndexUtilization: \"x-ms-cosmos-index-utilization\",\n // Version headers and values\n Version: \"x-ms-version\",\n\n // Owner name\n OwnerFullName: \"x-ms-alt-content-path\",\n\n // Owner ID used for name based request in session token.\n OwnerId: \"x-ms-content-path\",\n\n // Partition Key\n PartitionKey: \"x-ms-documentdb-partitionkey\",\n PartitionKeyRangeID: \"x-ms-documentdb-partitionkeyrangeid\",\n\n // Epk Range headers\n StartEpk: \"x-ms-start-epk\",\n EndEpk: \"x-ms-end-epk\",\n\n // Read Feed Type\n ReadFeedKeyType: \"x-ms-read-key-type\",\n\n // Quota Info\n MaxEntityCount: \"x-ms-root-entity-max-count\",\n CurrentEntityCount: \"x-ms-root-entity-current-count\",\n CollectionQuotaInMb: \"x-ms-collection-quota-mb\",\n CollectionCurrentUsageInMb: \"x-ms-collection-usage-mb\",\n MaxMediaStorageUsageInMB: \"x-ms-max-media-storage-usage-mb\",\n CurrentMediaStorageUsageInMB: \"x-ms-media-storage-usage-mb\",\n RequestCharge: \"x-ms-request-charge\",\n PopulateQuotaInfo: \"x-ms-documentdb-populatequotainfo\",\n MaxResourceQuota: \"x-ms-resource-quota\",\n\n // Offer header\n OfferType: \"x-ms-offer-type\",\n OfferThroughput: \"x-ms-offer-throughput\",\n AutoscaleSettings: \"x-ms-cosmos-offer-autopilot-settings\",\n\n // Custom RUs/minute headers\n DisableRUPerMinuteUsage: \"x-ms-documentdb-disable-ru-per-minute-usage\",\n IsRUPerMinuteUsed: \"x-ms-documentdb-is-ru-per-minute-used\",\n OfferIsRUPerMinuteThroughputEnabled: \"x-ms-offer-is-ru-per-minute-throughput-enabled\",\n\n // Index progress headers\n IndexTransformationProgress: \"x-ms-documentdb-collection-index-transformation-progress\",\n LazyIndexingProgress: \"x-ms-documentdb-collection-lazy-indexing-progress\",\n\n // Upsert header\n IsUpsert: \"x-ms-documentdb-is-upsert\",\n\n // Sub status of the error\n SubStatus: \"x-ms-substatus\",\n\n // StoredProcedure related headers\n EnableScriptLogging: \"x-ms-documentdb-script-enable-logging\",\n ScriptLogResults: \"x-ms-documentdb-script-log-results\",\n\n // Multi-Region Write\n ALLOW_MULTIPLE_WRITES: \"x-ms-cosmos-allow-tentative-writes\",\n\n // Bulk/Batch header\n IsBatchRequest: \"x-ms-cosmos-is-batch-request\",\n IsBatchAtomic: \"x-ms-cosmos-batch-atomic\",\n BatchContinueOnError: \"x-ms-cosmos-batch-continue-on-error\",\n\n // Dedicated Gateway Headers\n DedicatedGatewayPerRequestCacheStaleness: \"x-ms-dedicatedgateway-max-age\",\n\n // Cache Refresh header\n ForceRefresh: \"x-ms-force-refresh\",\n\n // Priority Based throttling header\n PriorityLevel: \"x-ms-cosmos-priority-level\",\n },\n\n // GlobalDB related constants\n WritableLocations: \"writableLocations\",\n ReadableLocations: \"readableLocations\",\n LocationUnavailableExpirationTimeInMs: 5 * 60 * 1000, // 5 minutes\n\n // ServiceDocument Resource\n ENABLE_MULTIPLE_WRITABLE_LOCATIONS: \"enableMultipleWriteLocations\",\n\n // Background refresh time\n DefaultUnavailableLocationExpirationTimeMS: 5 * 60 * 1000,\n\n // Client generated retry count response header\n ThrottleRetryCount: \"x-ms-throttle-retry-count\",\n ThrottleRetryWaitTimeInMs: \"x-ms-throttle-retry-wait-time-ms\",\n\n // Platform\n CurrentVersion: \"2020-07-15\",\n AzureNamespace: \"Azure.Cosmos\",\n AzurePackageName: \"@azure/cosmos\",\n SDKName: \"azure-cosmos-js\",\n SDKVersion: \"4.0.1-beta.3\",\n\n // Diagnostics\n CosmosDbDiagnosticLevelEnvVarName: \"AZURE_COSMOSDB_DIAGNOSTICS_LEVEL\",\n\n // Bulk Operations\n DefaultMaxBulkRequestBodySizeInBytes: 220201,\n\n Quota: {\n CollectionSize: \"collectionSize\",\n },\n\n Path: {\n Root: \"/\",\n DatabasesPathSegment: \"dbs\",\n CollectionsPathSegment: \"colls\",\n UsersPathSegment: \"users\",\n DocumentsPathSegment: \"docs\",\n PermissionsPathSegment: \"permissions\",\n StoredProceduresPathSegment: \"sprocs\",\n TriggersPathSegment: \"triggers\",\n UserDefinedFunctionsPathSegment: \"udfs\",\n ConflictsPathSegment: \"conflicts\",\n AttachmentsPathSegment: \"attachments\",\n PartitionKeyRangesPathSegment: \"pkranges\",\n SchemasPathSegment: \"schemas\",\n OffersPathSegment: \"offers\",\n TopologyPathSegment: \"topology\",\n DatabaseAccountPathSegment: \"databaseaccount\",\n },\n\n PartitionKeyRange: {\n // Partition Key Range Constants\n MinInclusive: \"minInclusive\",\n MaxExclusive: \"maxExclusive\",\n Id: \"id\",\n } as PartitionKeyRangePropertiesNames,\n\n QueryRangeConstants: {\n // Partition Key Range Constants\n MinInclusive: \"minInclusive\",\n MaxExclusive: \"maxExclusive\",\n min: \"min\",\n },\n\n /**\n * @deprecated Use EffectivePartitionKeyConstants instead\n */\n EffectiveParitionKeyConstants: {\n MinimumInclusiveEffectivePartitionKey: \"\",\n MaximumExclusiveEffectivePartitionKey: \"FF\",\n },\n\n EffectivePartitionKeyConstants: {\n MinimumInclusiveEffectivePartitionKey: \"\",\n MaximumExclusiveEffectivePartitionKey: \"FF\",\n },\n\n // NonStreaming queries\n NonStreamingQueryDefaultRUThreshold: 5000,\n};\n\n/**\n * @hidden\n */\nexport enum ResourceType {\n none = \"\",\n database = \"dbs\",\n offer = \"offers\",\n user = \"users\",\n permission = \"permissions\",\n container = \"colls\",\n conflicts = \"conflicts\",\n sproc = \"sprocs\",\n udf = \"udfs\",\n trigger = \"triggers\",\n item = \"docs\",\n pkranges = \"pkranges\",\n partitionkey = \"partitionKey\",\n}\n\n/**\n * @hidden\n */\nexport enum HTTPMethod {\n get = \"GET\",\n patch = \"PATCH\",\n post = \"POST\",\n put = \"PUT\",\n delete = \"DELETE\",\n}\n\n/**\n * @hidden\n */\nexport enum OperationType {\n Create = \"create\",\n Replace = \"replace\",\n Upsert = \"upsert\",\n Delete = \"delete\",\n Read = \"read\",\n Query = \"query\",\n Execute = \"execute\",\n Batch = \"batch\",\n Patch = \"patch\",\n}\n\n/**\n * @hidden\n */\nexport enum CosmosKeyType {\n PrimaryMaster = \"PRIMARY_MASTER\",\n SecondaryMaster = \"SECONDARY_MASTER\",\n PrimaryReadOnly = \"PRIMARY_READONLY\",\n SecondaryReadOnly = \"SECONDARY_READONLY\",\n}\n\n/**\n * @hidden\n */\nexport enum CosmosContainerChildResourceKind {\n Item = \"ITEM\",\n StoredProcedure = \"STORED_PROCEDURE\",\n UserDefinedFunction = \"USER_DEFINED_FUNCTION\",\n Trigger = \"TRIGGER\",\n}\n/**\n * @hidden\n */\nexport enum PermissionScopeValues {\n /**\n * Values which set permission Scope applicable to control plane related operations.\n */\n ScopeAccountReadValue = 0x0001,\n ScopeAccountListDatabasesValue = 0x0002,\n ScopeDatabaseReadValue = 0x0004,\n ScopeDatabaseReadOfferValue = 0x0008,\n ScopeDatabaseListContainerValue = 0x0010,\n ScopeContainerReadValue = 0x0020,\n ScopeContainerReadOfferValue = 0x0040,\n\n ScopeAccountCreateDatabasesValue = 0x0001,\n ScopeAccountDeleteDatabasesValue = 0x0002,\n ScopeDatabaseDeleteValue = 0x0004,\n ScopeDatabaseReplaceOfferValue = 0x0008,\n ScopeDatabaseCreateContainerValue = 0x0010,\n ScopeDatabaseDeleteContainerValue = 0x0020,\n ScopeContainerReplaceValue = 0x0040,\n ScopeContainerDeleteValue = 0x0080,\n ScopeContainerReplaceOfferValue = 0x0100,\n\n ScopeAccountReadAllAccessValue = 0xffff,\n ScopeDatabaseReadAllAccessValue = PermissionScopeValues.ScopeDatabaseReadValue |\n PermissionScopeValues.ScopeDatabaseReadOfferValue |\n PermissionScopeValues.ScopeDatabaseListContainerValue |\n PermissionScopeValues.ScopeContainerReadValue |\n PermissionScopeValues.ScopeContainerReadOfferValue,\n\n ScopeContainersReadAllAccessValue = PermissionScopeValues.ScopeContainerReadValue |\n PermissionScopeValues.ScopeContainerReadOfferValue,\n\n ScopeAccountWriteAllAccessValue = 0xffff,\n ScopeDatabaseWriteAllAccessValue = PermissionScopeValues.ScopeDatabaseDeleteValue |\n PermissionScopeValues.ScopeDatabaseReplaceOfferValue |\n PermissionScopeValues.ScopeDatabaseCreateContainerValue |\n PermissionScopeValues.ScopeDatabaseDeleteContainerValue |\n PermissionScopeValues.ScopeContainerReplaceValue |\n PermissionScopeValues.ScopeContainerDeleteValue |\n PermissionScopeValues.ScopeContainerReplaceOfferValue,\n\n ScopeContainersWriteAllAccessValue = PermissionScopeValues.ScopeContainerReplaceValue |\n PermissionScopeValues.ScopeContainerDeleteValue |\n PermissionScopeValues.ScopeContainerReplaceOfferValue,\n\n /**\n * Values which set permission Scope applicable to data plane related operations.\n */\n ScopeContainerExecuteQueriesValue = 0x00000001,\n ScopeContainerReadFeedsValue = 0x00000002,\n ScopeContainerReadStoredProceduresValue = 0x00000004,\n ScopeContainerReadUserDefinedFunctionsValue = 0x00000008,\n ScopeContainerReadTriggersValue = 0x00000010,\n ScopeContainerReadConflictsValue = 0x00000020,\n ScopeItemReadValue = 0x00000040,\n ScopeStoredProcedureReadValue = 0x00000080,\n ScopeUserDefinedFunctionReadValue = 0x00000100,\n ScopeTriggerReadValue = 0x00000200,\n\n ScopeContainerCreateItemsValue = 0x00000001,\n ScopeContainerReplaceItemsValue = 0x00000002,\n ScopeContainerUpsertItemsValue = 0x00000004,\n ScopeContainerDeleteItemsValue = 0x00000008,\n ScopeContainerCreateStoredProceduresValue = 0x00000010,\n ScopeContainerReplaceStoredProceduresValue = 0x00000020,\n ScopeContainerDeleteStoredProceduresValue = 0x00000040,\n ScopeContainerExecuteStoredProceduresValue = 0x00000080,\n ScopeContainerCreateTriggersValue = 0x00000100,\n ScopeContainerReplaceTriggersValue = 0x00000200,\n ScopeContainerDeleteTriggersValue = 0x00000400,\n ScopeContainerCreateUserDefinedFunctionsValue = 0x00000800,\n ScopeContainerReplaceUserDefinedFunctionsValue = 0x00001000,\n ScopeContainerDeleteUserDefinedFunctionSValue = 0x00002000,\n ScopeContainerDeleteCONFLICTSValue = 0x00004000,\n ScopeItemReplaceValue = 0x00010000,\n ScopeItemUpsertValue = 0x00020000,\n ScopeItemDeleteValue = 0x00040000,\n ScopeStoredProcedureReplaceValue = 0x00100000,\n ScopeStoredProcedureDeleteValue = 0x00200000,\n ScopeStoredProcedureExecuteValue = 0x00400000,\n ScopeUserDefinedFunctionReplaceValue = 0x00800000,\n ScopeUserDefinedFunctionDeleteValue = 0x01000000,\n ScopeTriggerReplaceValue = 0x02000000,\n ScopeTriggerDeleteValue = 0x04000000,\n\n ScopeContainerReadAllAccessValue = 0xffffffff,\n ScopeItemReadAllAccessValue = PermissionScopeValues.ScopeContainerExecuteQueriesValue |\n PermissionScopeValues.ScopeItemReadValue,\n ScopeContainerWriteAllAccessValue = 0xffffffff,\n ScopeItemWriteAllAccessValue = PermissionScopeValues.ScopeContainerCreateItemsValue |\n PermissionScopeValues.ScopeContainerReplaceItemsValue |\n PermissionScopeValues.ScopeContainerUpsertItemsValue |\n PermissionScopeValues.ScopeContainerDeleteItemsValue |\n PermissionScopeValues.ScopeItemReplaceValue |\n PermissionScopeValues.ScopeItemUpsertValue |\n PermissionScopeValues.ScopeItemDeleteValue,\n\n NoneValue = 0,\n}\n/**\n * @hidden\n */\nexport enum SasTokenPermissionKind {\n ContainerCreateItems = PermissionScopeValues.ScopeContainerCreateItemsValue,\n ContainerReplaceItems = PermissionScopeValues.ScopeContainerReplaceItemsValue,\n ContainerUpsertItems = PermissionScopeValues.ScopeContainerUpsertItemsValue,\n ContainerDeleteItems = PermissionScopeValues.ScopeContainerDeleteValue,\n ContainerExecuteQueries = PermissionScopeValues.ScopeContainerExecuteQueriesValue,\n ContainerReadFeeds = PermissionScopeValues.ScopeContainerReadFeedsValue,\n ContainerCreateStoreProcedure = PermissionScopeValues.ScopeContainerCreateStoredProceduresValue,\n ContainerReadStoreProcedure = PermissionScopeValues.ScopeContainerReadStoredProceduresValue,\n ContainerReplaceStoreProcedure = PermissionScopeValues.ScopeContainerReplaceStoredProceduresValue,\n ContainerDeleteStoreProcedure = PermissionScopeValues.ScopeContainerDeleteStoredProceduresValue,\n ContainerCreateTriggers = PermissionScopeValues.ScopeContainerCreateTriggersValue,\n ContainerReadTriggers = PermissionScopeValues.ScopeContainerReadTriggersValue,\n ContainerReplaceTriggers = PermissionScopeValues.ScopeContainerReplaceTriggersValue,\n ContainerDeleteTriggers = PermissionScopeValues.ScopeContainerDeleteTriggersValue,\n ContainerCreateUserDefinedFunctions = PermissionScopeValues.ScopeContainerCreateUserDefinedFunctionsValue,\n ContainerReadUserDefinedFunctions = PermissionScopeValues.ScopeContainerReadUserDefinedFunctionsValue,\n ContainerReplaceUserDefinedFunctions = PermissionScopeValues.ScopeContainerReplaceUserDefinedFunctionsValue,\n ContainerDeleteUserDefinedFunctions = PermissionScopeValues.ScopeContainerDeleteUserDefinedFunctionSValue,\n ContainerExecuteStoredProcedure = PermissionScopeValues.ScopeContainerExecuteStoredProceduresValue,\n ContainerReadConflicts = PermissionScopeValues.ScopeContainerReadConflictsValue,\n ContainerDeleteConflicts = PermissionScopeValues.ScopeContainerDeleteCONFLICTSValue,\n ContainerReadAny = PermissionScopeValues.ScopeContainerReadOfferValue,\n ContainerFullAccess = PermissionScopeValues.ScopeContainerReadAllAccessValue,\n ItemReadAny = PermissionScopeValues.ScopeItemReplaceValue,\n ItemFullAccess = PermissionScopeValues.ScopeItemReadAllAccessValue,\n ItemRead = PermissionScopeValues.ScopeItemReadValue,\n ItemReplace = PermissionScopeValues.ScopeItemReplaceValue,\n ItemUpsert = PermissionScopeValues.ScopeItemUpsertValue,\n ItemDelete = PermissionScopeValues.ScopeItemDeleteValue,\n StoreProcedureRead = PermissionScopeValues.ScopeStoredProcedureReadValue,\n StoreProcedureReplace = PermissionScopeValues.ScopeStoredProcedureReplaceValue,\n StoreProcedureDelete = PermissionScopeValues.ScopeStoredProcedureDeleteValue,\n StoreProcedureExecute = PermissionScopeValues.ScopeStoredProcedureExecuteValue,\n UserDefinedFuntionRead = PermissionScopeValues.ScopeUserDefinedFunctionReadValue,\n UserDefinedFuntionReplace = PermissionScopeValues.ScopeUserDefinedFunctionReplaceValue,\n UserDefinedFuntionDelete = PermissionScopeValues.ScopeUserDefinedFunctionDeleteValue,\n TriggerRead = PermissionScopeValues.ScopeTriggerReadValue,\n TriggerReplace = PermissionScopeValues.ScopeTriggerReplaceValue,\n TriggerDelete = PermissionScopeValues.ScopeTriggerDeleteValue,\n}\n\nexport enum QueryFeature {\n NonValueAggregate = \"NonValueAggregate\",\n Aggregate = \"Aggregate\",\n Distinct = \"Distinct\",\n MultipleOrderBy = \"MultipleOrderBy\",\n OffsetAndLimit = \"OffsetAndLimit\",\n OrderBy = \"OrderBy\",\n Top = \"Top\",\n CompositeAggregate = \"CompositeAggregate\",\n GroupBy = \"GroupBy\",\n MultipleAggregates = \"MultipleAggregates\",\n NonStreamingOrderBy = \"NonStreamingOrderBy\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts new file mode 100644 index 000000000..c93e2206c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts @@ -0,0 +1,87 @@ +import { CosmosClientOptions } from "../CosmosClientOptions"; +import { OperationType, ResourceType } from "./constants"; +/** @hidden */ +export declare function jsonStringifyAndEscapeNonASCII(arg: unknown): string; +/** + * @hidden + */ +export declare function parseLink(resourcePath: string): { + type: ResourceType; + objectBody: { + id: string; + self: string; + }; +}; +/** + * @hidden + */ +export declare function isReadRequest(operationType: OperationType): boolean; +/** + * @hidden + */ +export declare function sleep(time: number): Promise; +/** + * @hidden + */ +export declare function getContainerLink(link: string): string; +/** + * @hidden + */ +export declare function prepareURL(endpoint: string, path: string): string; +/** + * @hidden + */ +export declare function trimSlashes(source: string): string; +/** + * @hidden + */ +export declare function getHexaDigit(): string; +/** + * @hidden + */ +export declare function parsePath(path: string): string[]; +/** + * @hidden + */ +export declare function isResourceValid(resource: { + id?: string; +}, err: { + message?: string; +}): boolean; +/** + * @hidden + */ +export declare function isItemResourceValid(resource: { + id?: string; +}, err: { + message?: string; +}): boolean; +/** @hidden */ +export declare function getIdFromLink(resourceLink: string): string; +/** @hidden */ +export declare function getPathFromLink(resourceLink: string, resourceType?: string): string; +/** + * @hidden + */ +export declare function isStringNullOrEmpty(inputString: string): boolean; +/** + * @hidden + */ +export declare function trimSlashFromLeftAndRight(inputString: string): string; +/** + * @hidden + */ +export declare function validateResourceId(resourceId: string): boolean; +/** + * @hidden + */ +export declare function validateItemResourceId(resourceId: string): boolean; +/** + * @hidden + */ +export declare function getResourceIdFromPath(resourcePath: string): string; +/** + * @hidden + */ +export declare function parseConnectionString(connectionString: string): CosmosClientOptions; +//# sourceMappingURL=helper.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts.map new file mode 100644 index 000000000..31a3a01db --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.d.ts.map @@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,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAkBjG;AAED,cAAc;AACd,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,cAAc;AACd,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAOnF;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAGhE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAMrE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAY9D;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAYlE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAclE;AAUD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,GAAG,mBAAmB,CAiBnF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js new file mode 100644 index 000000000..5561c4e19 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js @@ -0,0 +1,295 @@ +import { OperationType } from "./constants"; +const trimLeftSlashes = new RegExp("^[/]+"); +const trimRightSlashes = new RegExp("[/]+$"); +const illegalResourceIdCharacters = new RegExp("[/\\\\?#]"); +const illegalItemResourceIdCharacters = new RegExp("[/\\\\#]"); +/** @hidden */ +export function jsonStringifyAndEscapeNonASCII(arg) { + // TODO: better way for this? Not sure. + // escapes non-ASCII characters as \uXXXX + return JSON.stringify(arg).replace(/[\u007F-\uFFFF]/g, (m) => { + return "\\u" + ("0000" + m.charCodeAt(0).toString(16)).slice(-4); + }); +} +/** + * @hidden + */ +export function parseLink(resourcePath) { + if (resourcePath.length === 0) { + /* for DatabaseAccount case, both type and objectBody will be undefined. */ + return { + type: undefined, + objectBody: undefined, + }; + } + if (resourcePath[resourcePath.length - 1] !== "/") { + resourcePath = resourcePath + "/"; + } + if (resourcePath[0] !== "/") { + resourcePath = "/" + resourcePath; + } + /* + The path will be in the form of /[resourceType]/[resourceId]/ .... + /[resourceType]//[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/ + or /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/[resourceType]/[resourceId]/ .... + /[resourceType]/[resourceId]/ + The result of split will be in the form of + [[[resourceType], [resourceId] ... ,[resourceType], [resourceId], ""] + In the first case, to extract the resourceId it will the element before last ( at length -2 ) + and the type will be before it ( at length -3 ) + In the second case, to extract the resource type it will the element before last ( at length -2 ) + */ + const pathParts = resourcePath.split("/"); + let id; + let type; + if (pathParts.length % 2 === 0) { + // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]. + id = pathParts[pathParts.length - 2]; + type = pathParts[pathParts.length - 3]; + } + else { + // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/. + id = pathParts[pathParts.length - 3]; + type = pathParts[pathParts.length - 2]; + } + const result = { + type, + objectBody: { + id, + self: resourcePath, + }, + }; + return result; +} +/** + * @hidden + */ +export function isReadRequest(operationType) { + return operationType === OperationType.Read || operationType === OperationType.Query; +} +/** + * @hidden + */ +export function sleep(time) { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, time); + }); +} +/** + * @hidden + */ +export function getContainerLink(link) { + return link.split("/").slice(0, 4).join("/"); +} +/** + * @hidden + */ +export function prepareURL(endpoint, path) { + return trimSlashes(endpoint) + path; +} +/** + * @hidden + */ +export function trimSlashes(source) { + return source.replace(trimLeftSlashes, "").replace(trimRightSlashes, ""); +} +/** + * @hidden + */ +export function getHexaDigit() { + return Math.floor(Math.random() * 16).toString(16); +} +/** + * @hidden + */ +export function parsePath(path) { + const pathParts = []; + let currentIndex = 0; + const throwError = () => { + throw new Error("Path " + path + " is invalid at index " + currentIndex); + }; + const getEscapedToken = () => { + const quote = path[currentIndex]; + let newIndex = ++currentIndex; + for (;;) { + newIndex = path.indexOf(quote, newIndex); + if (newIndex === -1) { + throwError(); + } + if (path[newIndex - 1] !== "\\") { + break; + } + ++newIndex; + } + const token = path.substr(currentIndex, newIndex - currentIndex); + currentIndex = newIndex + 1; + return token; + }; + const getToken = () => { + const newIndex = path.indexOf("/", currentIndex); + let token = null; + if (newIndex === -1) { + token = path.substr(currentIndex); + currentIndex = path.length; + } + else { + token = path.substr(currentIndex, newIndex - currentIndex); + currentIndex = newIndex; + } + token = token.trim(); + return token; + }; + while (currentIndex < path.length) { + if (path[currentIndex] !== "/") { + throwError(); + } + if (++currentIndex === path.length) { + break; + } + if (path[currentIndex] === '"' || path[currentIndex] === "'") { + pathParts.push(getEscapedToken()); + } + else { + pathParts.push(getToken()); + } + } + return pathParts; +} +/** + * @hidden + */ +export function isResourceValid(resource, err) { + // TODO: fix strictness issues so that caller contexts respects the types of the functions + if (resource.id) { + if (typeof resource.id !== "string") { + err.message = "Id must be a string."; + return false; + } + if (resource.id.indexOf("/") !== -1 || + resource.id.indexOf("\\") !== -1 || + resource.id.indexOf("?") !== -1 || + resource.id.indexOf("#") !== -1) { + err.message = "Id contains illegal chars."; + return false; + } + if (resource.id[resource.id.length - 1] === " ") { + err.message = "Id ends with a space."; + return false; + } + } + return true; +} +/** + * @hidden + */ +export function isItemResourceValid(resource, err) { + // TODO: fix strictness issues so that caller contexts respects the types of the functions + if (resource.id) { + if (typeof resource.id !== "string") { + err.message = "Id must be a string."; + return false; + } + if (resource.id.indexOf("/") !== -1 || + resource.id.indexOf("\\") !== -1 || + resource.id.indexOf("#") !== -1) { + err.message = "Id contains illegal chars."; + return false; + } + } + return true; +} +/** @hidden */ +export function getIdFromLink(resourceLink) { + resourceLink = trimSlashes(resourceLink); + return resourceLink; +} +/** @hidden */ +export function getPathFromLink(resourceLink, resourceType) { + resourceLink = trimSlashes(resourceLink); + if (resourceType) { + return "/" + encodeURI(resourceLink) + "/" + resourceType; + } + else { + return "/" + encodeURI(resourceLink); + } +} +/** + * @hidden + */ +export function isStringNullOrEmpty(inputString) { + // checks whether string is null, undefined, empty or only contains space + return !inputString || /^\s*$/.test(inputString); +} +/** + * @hidden + */ +export function trimSlashFromLeftAndRight(inputString) { + if (typeof inputString !== "string") { + throw new Error("invalid input: input is not string"); + } + return inputString.replace(trimLeftSlashes, "").replace(trimRightSlashes, ""); +} +/** + * @hidden + */ +export function validateResourceId(resourceId) { + // if resourceId is not a string or is empty throw an error + if (typeof resourceId !== "string" || isStringNullOrEmpty(resourceId)) { + throw new Error("Resource ID must be a string and cannot be undefined, null or empty"); + } + // if resource id contains illegal characters throw an error + if (illegalResourceIdCharacters.test(resourceId)) { + throw new Error("Illegal characters ['/', '\\', '#', '?'] cannot be used in Resource ID"); + } + return true; +} +/** + * @hidden + */ +export function validateItemResourceId(resourceId) { + // if resourceId is not a string or is empty throw an error + if (typeof resourceId !== "string" || isStringNullOrEmpty(resourceId)) { + throw new Error("Resource ID must be a string and cannot be undefined, null or empty"); + } + // if resource id contains illegal characters throw an error + if (illegalItemResourceIdCharacters.test(resourceId)) { + throw new Error("Illegal characters ['/', '\\', '#'] cannot be used in Resource ID"); + } + return true; +} +/** + * @hidden + */ +export function getResourceIdFromPath(resourcePath) { + if (!resourcePath || typeof resourcePath !== "string") { + return null; + } + const trimmedPath = trimSlashFromLeftAndRight(resourcePath); + const pathSegments = trimmedPath.split("/"); + // number of segments of a path must always be even + if (pathSegments.length % 2 !== 0) { + return null; + } + return pathSegments[pathSegments.length - 1]; +} +/** + * @hidden + */ +export function parseConnectionString(connectionString) { + const keyValueStrings = connectionString.split(";"); + const { AccountEndpoint, AccountKey } = keyValueStrings.reduce((connectionObject, keyValueString) => { + const [key, ...value] = keyValueString.split("="); + connectionObject[key] = value.join("="); + return connectionObject; + }, {}); + if (!AccountEndpoint || !AccountKey) { + throw new Error("Could not parse the provided connection string"); + } + return { + endpoint: AccountEndpoint, + key: AccountKey, + }; +} +//# sourceMappingURL=helper.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js.map new file mode 100644 index 000000000..4e6377697 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/helper.js.map @@ -0,0 +1 @@ +{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../src/common/helper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAC;AAE1D,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAC5C,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;AAC7C,MAAM,2BAA2B,GAAG,IAAI,MAAM,CAAC,WAAW,CAAC,CAAC;AAC5D,MAAM,+BAA+B,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC;AAE/D,cAAc;AACd,MAAM,UAAU,8BAA8B,CAAC,GAAY;IACzD,uCAAuC;IACvC,yCAAyC;IACzC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,EAAE;QAC3D,OAAO,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,YAAoB;IAO5C,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE;QAC7B,2EAA2E;QAC3E,OAAO;YACL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AM,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC,MAAM,CAC5D,CAAC,gBAAgB,EAAE,cAAsB,EAAE,EAAE;QAC3C,MAAM,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjD,gBAAwB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjD,OAAO,gBAAgB,CAAC;IAC1B,CAAC,EACD,EAAsB,CACvB,CAAC;IACF,IAAI,CAAC,eAAe,IAAI,CAAC,UAAU,EAAE;QACnC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;KACnE;IACD,OAAO;QACL,QAAQ,EAAE,eAAe;QACzB,GAAG,EAAE,UAAU;KAChB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosClientOptions } from \"../CosmosClientOptions\";\nimport { OperationType, ResourceType } from \"./constants\";\n\nconst trimLeftSlashes = new RegExp(\"^[/]+\");\nconst trimRightSlashes = new RegExp(\"[/]+$\");\nconst illegalResourceIdCharacters = new RegExp(\"[/\\\\\\\\?#]\");\nconst illegalItemResourceIdCharacters = new RegExp(\"[/\\\\\\\\#]\");\n\n/** @hidden */\nexport function jsonStringifyAndEscapeNonASCII(arg: unknown): string {\n // TODO: better way for this? Not sure.\n // escapes non-ASCII characters as \\uXXXX\n return JSON.stringify(arg).replace(/[\\u007F-\\uFFFF]/g, (m) => {\n return \"\\\\u\" + (\"0000\" + m.charCodeAt(0).toString(16)).slice(-4);\n });\n}\n\n/**\n * @hidden\n */\nexport function parseLink(resourcePath: string): {\n type: ResourceType;\n objectBody: {\n id: string;\n self: string;\n };\n} {\n if (resourcePath.length === 0) {\n /* for DatabaseAccount case, both type and objectBody will be undefined. */\n return {\n type: undefined,\n objectBody: undefined,\n };\n }\n\n if (resourcePath[resourcePath.length - 1] !== \"/\") {\n resourcePath = resourcePath + \"/\";\n }\n\n if (resourcePath[0] !== \"/\") {\n resourcePath = \"/\" + resourcePath;\n }\n\n /*\n The path will be in the form of /[resourceType]/[resourceId]/ ....\n /[resourceType]//[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/\n or /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/[resourceType]/[resourceId]/ ....\n /[resourceType]/[resourceId]/\n The result of split will be in the form of\n [[[resourceType], [resourceId] ... ,[resourceType], [resourceId], \"\"]\n In the first case, to extract the resourceId it will the element before last ( at length -2 )\n and the type will be before it ( at length -3 )\n In the second case, to extract the resource type it will the element before last ( at length -2 )\n */\n const pathParts = resourcePath.split(\"/\");\n let id;\n let type: ResourceType;\n if (pathParts.length % 2 === 0) {\n // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId].\n id = pathParts[pathParts.length - 2];\n type = pathParts[pathParts.length - 3] as ResourceType;\n } else {\n // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/.\n id = pathParts[pathParts.length - 3];\n type = pathParts[pathParts.length - 2] as ResourceType;\n }\n\n const result = {\n type,\n objectBody: {\n id,\n self: resourcePath,\n },\n };\n\n return result;\n}\n\n/**\n * @hidden\n */\nexport function isReadRequest(operationType: OperationType): boolean {\n return operationType === OperationType.Read || operationType === OperationType.Query;\n}\n\n/**\n * @hidden\n */\nexport function sleep(time: number): Promise {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve();\n }, time);\n });\n}\n\n/**\n * @hidden\n */\nexport function getContainerLink(link: string): string {\n return link.split(\"/\").slice(0, 4).join(\"/\");\n}\n\n/**\n * @hidden\n */\nexport function prepareURL(endpoint: string, path: string): string {\n return trimSlashes(endpoint) + path;\n}\n\n/**\n * @hidden\n */\nexport function trimSlashes(source: string): string {\n return source.replace(trimLeftSlashes, \"\").replace(trimRightSlashes, \"\");\n}\n\n/**\n * @hidden\n */\nexport function getHexaDigit(): string {\n return Math.floor(Math.random() * 16).toString(16);\n}\n\n/**\n * @hidden\n */\nexport function parsePath(path: string): string[] {\n const pathParts = [];\n let currentIndex = 0;\n\n const throwError = (): never => {\n throw new Error(\"Path \" + path + \" is invalid at index \" + currentIndex);\n };\n\n const getEscapedToken = (): string => {\n const quote = path[currentIndex];\n let newIndex = ++currentIndex;\n\n for (;;) {\n newIndex = path.indexOf(quote, newIndex);\n if (newIndex === -1) {\n throwError();\n }\n\n if (path[newIndex - 1] !== \"\\\\\") {\n break;\n }\n\n ++newIndex;\n }\n\n const token = path.substr(currentIndex, newIndex - currentIndex);\n currentIndex = newIndex + 1;\n return token;\n };\n\n const getToken = (): string => {\n const newIndex = path.indexOf(\"/\", currentIndex);\n let token = null;\n if (newIndex === -1) {\n token = path.substr(currentIndex);\n currentIndex = path.length;\n } else {\n token = path.substr(currentIndex, newIndex - currentIndex);\n currentIndex = newIndex;\n }\n\n token = token.trim();\n return token;\n };\n\n while (currentIndex < path.length) {\n if (path[currentIndex] !== \"/\") {\n throwError();\n }\n\n if (++currentIndex === path.length) {\n break;\n }\n\n if (path[currentIndex] === '\"' || path[currentIndex] === \"'\") {\n pathParts.push(getEscapedToken());\n } else {\n pathParts.push(getToken());\n }\n }\n\n return pathParts;\n}\n\n/**\n * @hidden\n */\nexport function isResourceValid(resource: { id?: string }, err: { message?: string }): boolean {\n // TODO: fix strictness issues so that caller contexts respects the types of the functions\n if (resource.id) {\n if (typeof resource.id !== \"string\") {\n err.message = \"Id must be a string.\";\n return false;\n }\n\n if (\n resource.id.indexOf(\"/\") !== -1 ||\n resource.id.indexOf(\"\\\\\") !== -1 ||\n resource.id.indexOf(\"?\") !== -1 ||\n resource.id.indexOf(\"#\") !== -1\n ) {\n err.message = \"Id contains illegal chars.\";\n return false;\n }\n\n if (resource.id[resource.id.length - 1] === \" \") {\n err.message = \"Id ends with a space.\";\n return false;\n }\n }\n return true;\n}\n\n/**\n * @hidden\n */\nexport function isItemResourceValid(resource: { id?: string }, err: { message?: string }): boolean {\n // TODO: fix strictness issues so that caller contexts respects the types of the functions\n if (resource.id) {\n if (typeof resource.id !== \"string\") {\n err.message = \"Id must be a string.\";\n return false;\n }\n\n if (\n resource.id.indexOf(\"/\") !== -1 ||\n resource.id.indexOf(\"\\\\\") !== -1 ||\n resource.id.indexOf(\"#\") !== -1\n ) {\n err.message = \"Id contains illegal chars.\";\n return false;\n }\n }\n return true;\n}\n\n/** @hidden */\nexport function getIdFromLink(resourceLink: string): string {\n resourceLink = trimSlashes(resourceLink);\n return resourceLink;\n}\n\n/** @hidden */\nexport function getPathFromLink(resourceLink: string, resourceType?: string): string {\n resourceLink = trimSlashes(resourceLink);\n if (resourceType) {\n return \"/\" + encodeURI(resourceLink) + \"/\" + resourceType;\n } else {\n return \"/\" + encodeURI(resourceLink);\n }\n}\n\n/**\n * @hidden\n */\nexport function isStringNullOrEmpty(inputString: string): boolean {\n // checks whether string is null, undefined, empty or only contains space\n return !inputString || /^\\s*$/.test(inputString);\n}\n\n/**\n * @hidden\n */\nexport function trimSlashFromLeftAndRight(inputString: string): string {\n if (typeof inputString !== \"string\") {\n throw new Error(\"invalid input: input is not string\");\n }\n\n return inputString.replace(trimLeftSlashes, \"\").replace(trimRightSlashes, \"\");\n}\n\n/**\n * @hidden\n */\nexport function validateResourceId(resourceId: string): boolean {\n // if resourceId is not a string or is empty throw an error\n if (typeof resourceId !== \"string\" || isStringNullOrEmpty(resourceId)) {\n throw new Error(\"Resource ID must be a string and cannot be undefined, null or empty\");\n }\n\n // if resource id contains illegal characters throw an error\n if (illegalResourceIdCharacters.test(resourceId)) {\n throw new Error(\"Illegal characters ['/', '\\\\', '#', '?'] cannot be used in Resource ID\");\n }\n\n return true;\n}\n\n/**\n * @hidden\n */\nexport function validateItemResourceId(resourceId: string): boolean {\n // if resourceId is not a string or is empty throw an error\n if (typeof resourceId !== \"string\" || isStringNullOrEmpty(resourceId)) {\n throw new Error(\"Resource ID must be a string and cannot be undefined, null or empty\");\n }\n\n // if resource id contains illegal characters throw an error\n if (illegalItemResourceIdCharacters.test(resourceId)) {\n throw new Error(\"Illegal characters ['/', '\\\\', '#'] cannot be used in Resource ID\");\n }\n\n return true;\n}\n\n/**\n * @hidden\n */\nexport function getResourceIdFromPath(resourcePath: string): string {\n if (!resourcePath || typeof resourcePath !== \"string\") {\n return null;\n }\n\n const trimmedPath = trimSlashFromLeftAndRight(resourcePath);\n const pathSegments = trimmedPath.split(\"/\");\n\n // number of segments of a path must always be even\n if (pathSegments.length % 2 !== 0) {\n return null;\n }\n\n return pathSegments[pathSegments.length - 1];\n}\n\n/**\n * @hidden\n */\ninterface ConnectionObject {\n AccountEndpoint: string;\n AccountKey: string;\n}\n\n/**\n * @hidden\n */\nexport function parseConnectionString(connectionString: string): CosmosClientOptions {\n const keyValueStrings = connectionString.split(\";\");\n const { AccountEndpoint, AccountKey } = keyValueStrings.reduce(\n (connectionObject, keyValueString: string) => {\n const [key, ...value] = keyValueString.split(\"=\");\n (connectionObject as any)[key] = value.join(\"=\");\n return connectionObject;\n },\n {} as ConnectionObject,\n );\n if (!AccountEndpoint || !AccountKey) {\n throw new Error(\"Could not parse the provided connection string\");\n }\n return {\n endpoint: AccountEndpoint,\n key: AccountKey,\n };\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts new file mode 100644 index 000000000..ba69f1e41 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts @@ -0,0 +1,6 @@ +export * from "./constants"; +export * from "./helper"; +export * from "./statusCodes"; +export * from "./uriFactory"; +export { RUConsumedManager } from "./RUConsumedManager"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts.map new file mode 100644 index 000000000..ab74fac33 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.js new file mode 100644 index 000000000..614a92fb6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export * from "./constants"; +export * from "./helper"; +export * from "./statusCodes"; +export * from "./uriFactory"; +export { RUConsumedManager } from "./RUConsumedManager"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.js.map new file mode 100644 index 000000000..beebaa264 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./constants\";\nexport * from \"./helper\";\nexport * from \"./statusCodes\";\nexport * from \"./uriFactory\";\nexport { RUConsumedManager } from \"./RUConsumedManager\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts new file mode 100644 index 000000000..54135cd0b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts @@ -0,0 +1,6 @@ +import { AzureLogger } from "@azure/logger"; +/** + * The \@azure/logger configuration for this package. + */ +export declare const defaultLogger: AzureLogger; +//# sourceMappingURL=logger.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts.map new file mode 100644 index 000000000..0c28f711d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/common/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,WAA4C,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js new file mode 100644 index 000000000..c4f120553 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createClientLogger } from "@azure/logger"; +/** + * The \@azure/logger configuration for this package. + */ +export const defaultLogger = createClientLogger("cosmosdb"); +//# sourceMappingURL=logger.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js.map new file mode 100644 index 000000000..718ba0693 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/logger.js.map @@ -0,0 +1 @@ +{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/common/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,kBAAkB,EAAe,MAAM,eAAe,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAgB,kBAAkB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { createClientLogger, AzureLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure/logger configuration for this package.\n */\nexport const defaultLogger: AzureLogger = createClientLogger(\"cosmosdb\");\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts new file mode 100644 index 000000000..5d199b744 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts @@ -0,0 +1,2 @@ +export declare const DEFAULT_PARTITION_KEY_PATH: "/_partitionKey"; +//# sourceMappingURL=partitionKeys.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts.map new file mode 100644 index 000000000..367dd658f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"partitionKeys.d.ts","sourceRoot":"","sources":["../../../src/common/partitionKeys.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,0BAA0B,kBAAuC,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js new file mode 100644 index 000000000..fb3a638e6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export const DEFAULT_PARTITION_KEY_PATH = "/_partitionKey"; // eslint-disable-line @typescript-eslint/prefer-as-const +//# sourceMappingURL=partitionKeys.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js.map new file mode 100644 index 000000000..56d22b66c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/partitionKeys.js.map @@ -0,0 +1 @@ +{"version":3,"file":"partitionKeys.js","sourceRoot":"","sources":["../../../src/common/partitionKeys.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,MAAM,CAAC,MAAM,0BAA0B,GAAG,gBAAoC,CAAC,CAAC,yDAAyD","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport const DEFAULT_PARTITION_KEY_PATH = \"/_partitionKey\" as \"/_partitionKey\"; // eslint-disable-line @typescript-eslint/prefer-as-const\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts new file mode 100644 index 000000000..6b5886952 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts @@ -0,0 +1,5 @@ +/** + * @hidden + */ +export declare function getUserAgent(suffix?: string): string; +//# sourceMappingURL=platform.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts.map new file mode 100644 index 000000000..eff2ff33a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../src/common/platform.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAMpD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js new file mode 100644 index 000000000..56efc6b8f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { getUserAgent as userAgent } from "universal-user-agent"; +import { Constants } from "./constants"; +/** + * @hidden + */ +export function getUserAgent(suffix) { + const ua = `${userAgent()} ${Constants.SDKName}/${Constants.SDKVersion}`; + if (suffix) { + return ua + " " + suffix; + } + return ua; +} +//# sourceMappingURL=platform.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js.map new file mode 100644 index 000000000..0c8a6a58e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/platform.js.map @@ -0,0 +1 @@ +{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../../src/common/platform.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,YAAY,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,IAAI,SAAS,CAAC,OAAO,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;IACzE,IAAI,MAAM,EAAE;QACV,OAAO,EAAE,GAAG,GAAG,GAAG,MAAM,CAAC;KAC1B;IACD,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { getUserAgent as userAgent } from \"universal-user-agent\";\nimport { Constants } from \"./constants\";\n\n/**\n * @hidden\n */\nexport function getUserAgent(suffix?: string): string {\n const ua = `${userAgent()} ${Constants.SDKName}/${Constants.SDKVersion}`;\n if (suffix) {\n return ua + \" \" + suffix;\n }\n return ua;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts new file mode 100644 index 000000000..00eed4a87 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts @@ -0,0 +1,48 @@ +/** + * @hidden + */ +export interface StatusCodesType { + Ok: 200; + Created: 201; + Accepted: 202; + NoContent: 204; + NotModified: 304; + BadRequest: 400; + Unauthorized: 401; + Forbidden: 403; + NotFound: 404; + MethodNotAllowed: 405; + RequestTimeout: 408; + Conflict: 409; + Gone: 410; + PreconditionFailed: 412; + RequestEntityTooLarge: 413; + TooManyRequests: 429; + RetryWith: 449; + InternalServerError: 500; + ServiceUnavailable: 503; + ENOTFOUND: "ENOTFOUND"; + OperationPaused: 1200; + OperationCancelled: 1201; +} +/** + * @hidden + */ +export declare const StatusCodes: StatusCodesType; +/** + * @hidden + */ +export interface SubStatusCodesType { + Unknown: 0; + CrossPartitionQueryNotServable: 1004; + PartitionKeyRangeGone: 1002; + CompletingSplit: 1007; + ReadSessionNotAvailable: 1002; + WriteForbidden: 3; + DatabaseAccountNotFound: 1008; +} +/** + * @hidden + */ +export declare const SubStatusCodes: SubStatusCodesType; +//# sourceMappingURL=statusCodes.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts.map new file mode 100644 index 000000000..82a58be3e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"statusCodes.d.ts","sourceRoot":"","sources":["../../../src/common/statusCodes.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,eAAe;IAE9B,EAAE,EAAE,GAAG,CAAC;IACR,OAAO,EAAE,GAAG,CAAC;IACb,QAAQ,EAAE,GAAG,CAAC;IACd,SAAS,EAAE,GAAG,CAAC;IACf,WAAW,EAAE,GAAG,CAAC;IAGjB,UAAU,EAAE,GAAG,CAAC;IAChB,YAAY,EAAE,GAAG,CAAC;IAClB,SAAS,EAAE,GAAG,CAAC;IACf,QAAQ,EAAE,GAAG,CAAC;IACd,gBAAgB,EAAE,GAAG,CAAC;IACtB,cAAc,EAAE,GAAG,CAAC;IACpB,QAAQ,EAAE,GAAG,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,kBAAkB,EAAE,GAAG,CAAC;IACxB,qBAAqB,EAAE,GAAG,CAAC;IAC3B,eAAe,EAAE,GAAG,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC;IAGf,mBAAmB,EAAE,GAAG,CAAC;IACzB,kBAAkB,EAAE,GAAG,CAAC;IAGxB,SAAS,EAAE,WAAW,CAAC;IAGvB,eAAe,EAAE,IAAI,CAAC;IACtB,kBAAkB,EAAE,IAAI,CAAC;CAC1B;AAED;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,eAgCzB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,CAAC,CAAC;IAGX,8BAA8B,EAAE,IAAI,CAAC;IAGrC,qBAAqB,EAAE,IAAI,CAAC;IAC5B,eAAe,EAAE,IAAI,CAAC;IAGtB,uBAAuB,EAAE,IAAI,CAAC;IAG9B,cAAc,EAAE,CAAC,CAAC;IAClB,uBAAuB,EAAE,IAAI,CAAC;CAC/B;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,kBAe5B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js new file mode 100644 index 000000000..740e08b05 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +export const StatusCodes = { + // Success + Ok: 200, + Created: 201, + Accepted: 202, + NoContent: 204, + NotModified: 304, + // Client error + BadRequest: 400, + Unauthorized: 401, + Forbidden: 403, + NotFound: 404, + MethodNotAllowed: 405, + RequestTimeout: 408, + Conflict: 409, + Gone: 410, + PreconditionFailed: 412, + RequestEntityTooLarge: 413, + TooManyRequests: 429, + RetryWith: 449, + // Server Error + InternalServerError: 500, + ServiceUnavailable: 503, + // System codes + ENOTFOUND: "ENOTFOUND", + // Operation pause and cancel. These are FAKE status codes for QOS logging purpose only. + OperationPaused: 1200, + OperationCancelled: 1201, +}; +/** + * @hidden + */ +export const SubStatusCodes = { + Unknown: 0, + // 400: Bad Request Substatus + CrossPartitionQueryNotServable: 1004, + // 410: StatusCodeType_Gone: substatus + PartitionKeyRangeGone: 1002, + CompletingSplit: 1007, + // 404: NotFound Substatus + ReadSessionNotAvailable: 1002, + // 403: Forbidden Substatus + WriteForbidden: 3, + DatabaseAccountNotFound: 1008, +}; +//# sourceMappingURL=statusCodes.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js.map new file mode 100644 index 000000000..f47e48983 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/statusCodes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"statusCodes.js","sourceRoot":"","sources":["../../../src/common/statusCodes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAuClC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAoB;IAC1C,UAAU;IACV,EAAE,EAAE,GAAG;IACP,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,SAAS,EAAE,GAAG;IACd,WAAW,EAAE,GAAG;IAEhB,eAAe;IACf,UAAU,EAAE,GAAG;IACf,YAAY,EAAE,GAAG;IACjB,SAAS,EAAE,GAAG;IACd,QAAQ,EAAE,GAAG;IACb,gBAAgB,EAAE,GAAG;IACrB,cAAc,EAAE,GAAG;IACnB,QAAQ,EAAE,GAAG;IACb,IAAI,EAAE,GAAG;IACT,kBAAkB,EAAE,GAAG;IACvB,qBAAqB,EAAE,GAAG;IAC1B,eAAe,EAAE,GAAG;IACpB,SAAS,EAAE,GAAG;IAEd,eAAe;IACf,mBAAmB,EAAE,GAAG;IACxB,kBAAkB,EAAE,GAAG;IAEvB,eAAe;IACf,SAAS,EAAE,WAAW;IAEtB,wFAAwF;IACxF,eAAe,EAAE,IAAI;IACrB,kBAAkB,EAAE,IAAI;CACzB,CAAC;AAuBF;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAuB;IAChD,OAAO,EAAE,CAAC;IAEV,6BAA6B;IAC7B,8BAA8B,EAAE,IAAI;IAEpC,sCAAsC;IACtC,qBAAqB,EAAE,IAAI;IAC3B,eAAe,EAAE,IAAI;IACrB,0BAA0B;IAC1B,uBAAuB,EAAE,IAAI;IAE7B,2BAA2B;IAC3B,cAAc,EAAE,CAAC;IACjB,uBAAuB,EAAE,IAAI;CAC9B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @hidden\n */\nexport interface StatusCodesType {\n // Success\n Ok: 200;\n Created: 201;\n Accepted: 202;\n NoContent: 204;\n NotModified: 304;\n\n // Client error\n BadRequest: 400;\n Unauthorized: 401;\n Forbidden: 403;\n NotFound: 404;\n MethodNotAllowed: 405;\n RequestTimeout: 408;\n Conflict: 409;\n Gone: 410;\n PreconditionFailed: 412;\n RequestEntityTooLarge: 413;\n TooManyRequests: 429;\n RetryWith: 449;\n\n // Server Error\n InternalServerError: 500;\n ServiceUnavailable: 503;\n\n // System codes\n ENOTFOUND: \"ENOTFOUND\";\n\n // Operation pause and cancel. These are FAKE status codes for QOS logging purpose only.\n OperationPaused: 1200;\n OperationCancelled: 1201;\n}\n\n/**\n * @hidden\n */\nexport const StatusCodes: StatusCodesType = {\n // Success\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NoContent: 204,\n NotModified: 304,\n\n // Client error\n BadRequest: 400,\n Unauthorized: 401,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n PreconditionFailed: 412,\n RequestEntityTooLarge: 413,\n TooManyRequests: 429,\n RetryWith: 449,\n\n // Server Error\n InternalServerError: 500,\n ServiceUnavailable: 503,\n\n // System codes\n ENOTFOUND: \"ENOTFOUND\",\n\n // Operation pause and cancel. These are FAKE status codes for QOS logging purpose only.\n OperationPaused: 1200,\n OperationCancelled: 1201,\n};\n\n/**\n * @hidden\n */\nexport interface SubStatusCodesType {\n Unknown: 0;\n\n // 400: Bad Request Substatus\n CrossPartitionQueryNotServable: 1004;\n\n // 410: StatusCodeType_Gone: substatus\n PartitionKeyRangeGone: 1002;\n CompletingSplit: 1007;\n\n // 404: NotFound Substatus\n ReadSessionNotAvailable: 1002;\n\n // 403: Forbidden Substatus\n WriteForbidden: 3;\n DatabaseAccountNotFound: 1008;\n}\n\n/**\n * @hidden\n */\nexport const SubStatusCodes: SubStatusCodesType = {\n Unknown: 0,\n\n // 400: Bad Request Substatus\n CrossPartitionQueryNotServable: 1004,\n\n // 410: StatusCodeType_Gone: substatus\n PartitionKeyRangeGone: 1002,\n CompletingSplit: 1007,\n // 404: NotFound Substatus\n ReadSessionNotAvailable: 1002,\n\n // 403: Forbidden Substatus\n WriteForbidden: 3,\n DatabaseAccountNotFound: 1008,\n};\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts new file mode 100644 index 000000000..6276d033b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts @@ -0,0 +1,128 @@ +/** + * Would be used when creating or deleting a DocumentCollection + * or a User in Azure Cosmos DB database service + * @hidden + * Given a database id, this creates a database link. + * @param databaseId - The database id + * @returns A database link in the format of `dbs/{0}` + * with `{0}` being a Uri escaped version of the databaseId + */ +export declare function createDatabaseUri(databaseId: string): string; +/** + * Given a database and collection id, this creates a collection link. + * Would be used when updating or deleting a DocumentCollection, creating a + * Document, a StoredProcedure, a Trigger, a UserDefinedFunction, or when executing a query + * with CreateDocumentQuery in Azure Cosmos DB database service. + * @param databaseId - The database id + * @param collectionId - The collection id + * @returns A collection link in the format of `dbs/{0}/colls/{1}` + * with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId + * @hidden + */ +export declare function createDocumentCollectionUri(databaseId: string, collectionId: string): string; +/** + * Given a database and user id, this creates a user link. + * Would be used when creating a Permission, or when replacing or deleting + * a User in Azure Cosmos DB database service + * @param databaseId - The database id + * @param userId - The user id + * @returns A user link in the format of `dbs/{0}/users/{1}` + * with `{0}` being a Uri escaped version of the databaseId and `{1}` being userId + * @hidden + */ +export declare function createUserUri(databaseId: string, userId: string): string; +/** + * Given a database and collection id, this creates a collection link. + * Would be used when creating an Attachment, or when replacing + * or deleting a Document in Azure Cosmos DB database service + * @param databaseId - The database id + * @param collectionId - The collection id + * @param documentId - The document id + * @returns A document link in the format of + * `dbs/{0}/colls/{1}/docs/{2}` with `{0}` being a Uri escaped version of + * the databaseId, `{1}` being collectionId and `{2}` being the documentId + * @hidden + */ +export declare function createDocumentUri(databaseId: string, collectionId: string, documentId: string): string; +/** + * Given a database, collection and document id, this creates a document link. + * Would be used when replacing or deleting a Permission in Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param userId -The user Id + * @param permissionId - The permissionId + * @returns A permission link in the format of `dbs/{0}/users/{1}/permissions/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being userId and `{2}` being permissionId + * @hidden + */ +export declare function createPermissionUri(databaseId: string, userId: string, permissionId: string): string; +/** + * Given a database, collection and stored proc id, this creates a stored proc link. + * Would be used when replacing, executing, or deleting a StoredProcedure in + * Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param storedProcedureId -The stored procedure Id + * @returns A stored procedure link in the format of + * `dbs/{0}/colls/{1}/sprocs/{2}` with `{0}` being a Uri escaped version of the databaseId, + * `{1}` being collectionId and `{2}` being the storedProcedureId + * @hidden + */ +export declare function createStoredProcedureUri(databaseId: string, collectionId: string, storedProcedureId: string): string; +/** + * Given a database, collection and trigger id, this creates a trigger link. + * Would be used when replacing, executing, or deleting a Trigger in Azure Cosmos DB database service + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param triggerId -The trigger Id + * @returns A trigger link in the format of + * `dbs/{0}/colls/{1}/triggers/{2}` with `{0}` being a Uri escaped version of the databaseId, + * `{1}` being collectionId and `{2}` being the triggerId + * @hidden + */ +export declare function createTriggerUri(databaseId: string, collectionId: string, triggerId: string): string; +/** + * Given a database, collection and udf id, this creates a udf link. + * Would be used when replacing, executing, or deleting a UserDefinedFunction in + * Azure Cosmos DB database service + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param udfId -The User Defined Function Id + * @returns A udf link in the format of `dbs/{0}/colls/{1}/udfs/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the udfId + * @hidden + */ +export declare function createUserDefinedFunctionUri(databaseId: string, collectionId: string, udfId: string): string; +/** + * Given a database, collection and conflict id, this creates a conflict link. + * Would be used when creating a Conflict in Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param conflictId -The conflict Id + * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId + * @hidden + */ +export declare function createConflictUri(databaseId: string, collectionId: string, conflictId: string): string; +/** + * Given a database, collection and conflict id, this creates a conflict link. + * Would be used when creating a Conflict in Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param documentId -The document Id + * @param attachmentId -The attachment Id + * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId + * @hidden + */ +export declare function createAttachmentUri(databaseId: string, collectionId: string, documentId: string, attachmentId: string): string; +/** + * Given a database and collection, this creates a partition key ranges link in + * the Azure Cosmos DB database service. + * @param databaseId - The database Id + * @param collectionId - The collection Id + * @returns A partition key ranges link in the format of + * `dbs/{0}/colls/{1}/pkranges` with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId + * @hidden + */ +export declare function createPartitionKeyRangesUri(databaseId: string, collectionId: string): string; +//# sourceMappingURL=uriFactory.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts.map new file mode 100644 index 000000000..4993056d8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"uriFactory.d.ts","sourceRoot":"","sources":["../../../src/common/uriFactory.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAK5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAO5F;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAWR;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GACnB,MAAM,CAWR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,iBAAiB,EAAE,MAAM,GACxB,MAAM,CAWR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,MAAM,CAWR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACZ,MAAM,CAWR;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,MAAM,CAWR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,GACnB,MAAM,CAWR;AAED;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAM5F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js new file mode 100644 index 000000000..34d61ae74 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants } from "./constants"; +import { trimSlashFromLeftAndRight, validateResourceId, validateItemResourceId } from "./helper"; +/** + * Would be used when creating or deleting a DocumentCollection + * or a User in Azure Cosmos DB database service + * @hidden + * Given a database id, this creates a database link. + * @param databaseId - The database id + * @returns A database link in the format of `dbs/{0}` + * with `{0}` being a Uri escaped version of the databaseId + */ +export function createDatabaseUri(databaseId) { + databaseId = trimSlashFromLeftAndRight(databaseId); + validateResourceId(databaseId); + return Constants.Path.DatabasesPathSegment + "/" + databaseId; +} +/** + * Given a database and collection id, this creates a collection link. + * Would be used when updating or deleting a DocumentCollection, creating a + * Document, a StoredProcedure, a Trigger, a UserDefinedFunction, or when executing a query + * with CreateDocumentQuery in Azure Cosmos DB database service. + * @param databaseId - The database id + * @param collectionId - The collection id + * @returns A collection link in the format of `dbs/{0}/colls/{1}` + * with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId + * @hidden + */ +export function createDocumentCollectionUri(databaseId, collectionId) { + collectionId = trimSlashFromLeftAndRight(collectionId); + validateResourceId(collectionId); + return (createDatabaseUri(databaseId) + "/" + Constants.Path.CollectionsPathSegment + "/" + collectionId); +} +/** + * Given a database and user id, this creates a user link. + * Would be used when creating a Permission, or when replacing or deleting + * a User in Azure Cosmos DB database service + * @param databaseId - The database id + * @param userId - The user id + * @returns A user link in the format of `dbs/{0}/users/{1}` + * with `{0}` being a Uri escaped version of the databaseId and `{1}` being userId + * @hidden + */ +export function createUserUri(databaseId, userId) { + userId = trimSlashFromLeftAndRight(userId); + validateResourceId(userId); + return createDatabaseUri(databaseId) + "/" + Constants.Path.UsersPathSegment + "/" + userId; +} +/** + * Given a database and collection id, this creates a collection link. + * Would be used when creating an Attachment, or when replacing + * or deleting a Document in Azure Cosmos DB database service + * @param databaseId - The database id + * @param collectionId - The collection id + * @param documentId - The document id + * @returns A document link in the format of + * `dbs/{0}/colls/{1}/docs/{2}` with `{0}` being a Uri escaped version of + * the databaseId, `{1}` being collectionId and `{2}` being the documentId + * @hidden + */ +export function createDocumentUri(databaseId, collectionId, documentId) { + documentId = trimSlashFromLeftAndRight(documentId); + validateItemResourceId(documentId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants.Path.DocumentsPathSegment + + "/" + + documentId); +} +/** + * Given a database, collection and document id, this creates a document link. + * Would be used when replacing or deleting a Permission in Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param userId -The user Id + * @param permissionId - The permissionId + * @returns A permission link in the format of `dbs/{0}/users/{1}/permissions/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being userId and `{2}` being permissionId + * @hidden + */ +export function createPermissionUri(databaseId, userId, permissionId) { + permissionId = trimSlashFromLeftAndRight(permissionId); + validateResourceId(permissionId); + return (createUserUri(databaseId, userId) + + "/" + + Constants.Path.PermissionsPathSegment + + "/" + + permissionId); +} +/** + * Given a database, collection and stored proc id, this creates a stored proc link. + * Would be used when replacing, executing, or deleting a StoredProcedure in + * Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param storedProcedureId -The stored procedure Id + * @returns A stored procedure link in the format of + * `dbs/{0}/colls/{1}/sprocs/{2}` with `{0}` being a Uri escaped version of the databaseId, + * `{1}` being collectionId and `{2}` being the storedProcedureId + * @hidden + */ +export function createStoredProcedureUri(databaseId, collectionId, storedProcedureId) { + storedProcedureId = trimSlashFromLeftAndRight(storedProcedureId); + validateResourceId(storedProcedureId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants.Path.StoredProceduresPathSegment + + "/" + + storedProcedureId); +} +/** + * Given a database, collection and trigger id, this creates a trigger link. + * Would be used when replacing, executing, or deleting a Trigger in Azure Cosmos DB database service + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param triggerId -The trigger Id + * @returns A trigger link in the format of + * `dbs/{0}/colls/{1}/triggers/{2}` with `{0}` being a Uri escaped version of the databaseId, + * `{1}` being collectionId and `{2}` being the triggerId + * @hidden + */ +export function createTriggerUri(databaseId, collectionId, triggerId) { + triggerId = trimSlashFromLeftAndRight(triggerId); + validateResourceId(triggerId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants.Path.TriggersPathSegment + + "/" + + triggerId); +} +/** + * Given a database, collection and udf id, this creates a udf link. + * Would be used when replacing, executing, or deleting a UserDefinedFunction in + * Azure Cosmos DB database service + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param udfId -The User Defined Function Id + * @returns A udf link in the format of `dbs/{0}/colls/{1}/udfs/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the udfId + * @hidden + */ +export function createUserDefinedFunctionUri(databaseId, collectionId, udfId) { + udfId = trimSlashFromLeftAndRight(udfId); + validateResourceId(udfId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants.Path.UserDefinedFunctionsPathSegment + + "/" + + udfId); +} +/** + * Given a database, collection and conflict id, this creates a conflict link. + * Would be used when creating a Conflict in Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param conflictId -The conflict Id + * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId + * @hidden + */ +export function createConflictUri(databaseId, collectionId, conflictId) { + conflictId = trimSlashFromLeftAndRight(conflictId); + validateResourceId(conflictId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants.Path.ConflictsPathSegment + + "/" + + conflictId); +} +/** + * Given a database, collection and conflict id, this creates a conflict link. + * Would be used when creating a Conflict in Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param documentId -The document Id + * @param attachmentId -The attachment Id + * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId + * @hidden + */ +export function createAttachmentUri(databaseId, collectionId, documentId, attachmentId) { + attachmentId = trimSlashFromLeftAndRight(attachmentId); + validateResourceId(attachmentId); + return (createDocumentUri(databaseId, collectionId, documentId) + + "/" + + Constants.Path.AttachmentsPathSegment + + "/" + + attachmentId); +} +/** + * Given a database and collection, this creates a partition key ranges link in + * the Azure Cosmos DB database service. + * @param databaseId - The database Id + * @param collectionId - The collection Id + * @returns A partition key ranges link in the format of + * `dbs/{0}/colls/{1}/pkranges` with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId + * @hidden + */ +export function createPartitionKeyRangesUri(databaseId, collectionId) { + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants.Path.PartitionKeyRangesPathSegment); +} +//# sourceMappingURL=uriFactory.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js.map new file mode 100644 index 000000000..a5aa3d353 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/common/uriFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"uriFactory.js","sourceRoot":"","sources":["../../../src/common/uriFactory.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAEjG;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,UAAkB;IAClD,UAAU,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACnD,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAE/B,OAAO,SAAS,CAAC,IAAI,CAAC,oBAAoB,GAAG,GAAG,GAAG,UAAU,CAAC;AAChE,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CAAC,UAAkB,EAAE,YAAoB;IAClF,YAAY,GAAG,yBAAyB,CAAC,YAAY,CAAC,CAAC;IACvD,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAEjC,OAAO,CACL,iBAAiB,CAAC,UAAU,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,sBAAsB,GAAG,GAAG,GAAG,YAAY,CACjG,CAAC;AACJ,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,UAAkB,EAAE,MAA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QACvD,GAAG;QACH,SAAS,CAAC,IAAI,CAAC,sBAAsB;QACrC,GAAG;QACH,YAAY,CACb,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,2BAA2B,CAAC,UAAkB,EAAE,YAAoB;IAClF,OAAO,CACL,2BAA2B,CAAC,UAAU,EAAE,YAAY,CAAC;QACrD,GAAG;QACH,SAAS,CAAC,IAAI,CAAC,6BAA6B,CAC7C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"./constants\";\nimport { trimSlashFromLeftAndRight, validateResourceId, validateItemResourceId } from \"./helper\";\n\n/**\n * Would be used when creating or deleting a DocumentCollection\n * or a User in Azure Cosmos DB database service\n * @hidden\n * Given a database id, this creates a database link.\n * @param databaseId - The database id\n * @returns A database link in the format of `dbs/{0}`\n * with `{0}` being a Uri escaped version of the databaseId\n */\nexport function createDatabaseUri(databaseId: string): string {\n databaseId = trimSlashFromLeftAndRight(databaseId);\n validateResourceId(databaseId);\n\n return Constants.Path.DatabasesPathSegment + \"/\" + databaseId;\n}\n\n/**\n * Given a database and collection id, this creates a collection link.\n * Would be used when updating or deleting a DocumentCollection, creating a\n * Document, a StoredProcedure, a Trigger, a UserDefinedFunction, or when executing a query\n * with CreateDocumentQuery in Azure Cosmos DB database service.\n * @param databaseId - The database id\n * @param collectionId - The collection id\n * @returns A collection link in the format of `dbs/{0}/colls/{1}`\n * with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId\n * @hidden\n */\nexport function createDocumentCollectionUri(databaseId: string, collectionId: string): string {\n collectionId = trimSlashFromLeftAndRight(collectionId);\n validateResourceId(collectionId);\n\n return (\n createDatabaseUri(databaseId) + \"/\" + Constants.Path.CollectionsPathSegment + \"/\" + collectionId\n );\n}\n\n/**\n * Given a database and user id, this creates a user link.\n * Would be used when creating a Permission, or when replacing or deleting\n * a User in Azure Cosmos DB database service\n * @param databaseId - The database id\n * @param userId - The user id\n * @returns A user link in the format of `dbs/{0}/users/{1}`\n * with `{0}` being a Uri escaped version of the databaseId and `{1}` being userId\n * @hidden\n */\nexport function createUserUri(databaseId: string, userId: string): string {\n userId = trimSlashFromLeftAndRight(userId);\n validateResourceId(userId);\n\n return createDatabaseUri(databaseId) + \"/\" + Constants.Path.UsersPathSegment + \"/\" + userId;\n}\n\n/**\n * Given a database and collection id, this creates a collection link.\n * Would be used when creating an Attachment, or when replacing\n * or deleting a Document in Azure Cosmos DB database service\n * @param databaseId - The database id\n * @param collectionId - The collection id\n * @param documentId - The document id\n * @returns A document link in the format of\n * `dbs/{0}/colls/{1}/docs/{2}` with `{0}` being a Uri escaped version of\n * the databaseId, `{1}` being collectionId and `{2}` being the documentId\n * @hidden\n */\nexport function createDocumentUri(\n databaseId: string,\n collectionId: string,\n documentId: string,\n): string {\n documentId = trimSlashFromLeftAndRight(documentId);\n validateItemResourceId(documentId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.DocumentsPathSegment +\n \"/\" +\n documentId\n );\n}\n\n/**\n * Given a database, collection and document id, this creates a document link.\n * Would be used when replacing or deleting a Permission in Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param userId -The user Id\n * @param permissionId - The permissionId\n * @returns A permission link in the format of `dbs/{0}/users/{1}/permissions/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being userId and `{2}` being permissionId\n * @hidden\n */\nexport function createPermissionUri(\n databaseId: string,\n userId: string,\n permissionId: string,\n): string {\n permissionId = trimSlashFromLeftAndRight(permissionId);\n validateResourceId(permissionId);\n\n return (\n createUserUri(databaseId, userId) +\n \"/\" +\n Constants.Path.PermissionsPathSegment +\n \"/\" +\n permissionId\n );\n}\n\n/**\n * Given a database, collection and stored proc id, this creates a stored proc link.\n * Would be used when replacing, executing, or deleting a StoredProcedure in\n * Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param storedProcedureId -The stored procedure Id\n * @returns A stored procedure link in the format of\n * `dbs/{0}/colls/{1}/sprocs/{2}` with `{0}` being a Uri escaped version of the databaseId,\n * `{1}` being collectionId and `{2}` being the storedProcedureId\n * @hidden\n */\nexport function createStoredProcedureUri(\n databaseId: string,\n collectionId: string,\n storedProcedureId: string,\n): string {\n storedProcedureId = trimSlashFromLeftAndRight(storedProcedureId);\n validateResourceId(storedProcedureId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.StoredProceduresPathSegment +\n \"/\" +\n storedProcedureId\n );\n}\n\n/**\n * Given a database, collection and trigger id, this creates a trigger link.\n * Would be used when replacing, executing, or deleting a Trigger in Azure Cosmos DB database service\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param triggerId -The trigger Id\n * @returns A trigger link in the format of\n * `dbs/{0}/colls/{1}/triggers/{2}` with `{0}` being a Uri escaped version of the databaseId,\n * `{1}` being collectionId and `{2}` being the triggerId\n * @hidden\n */\nexport function createTriggerUri(\n databaseId: string,\n collectionId: string,\n triggerId: string,\n): string {\n triggerId = trimSlashFromLeftAndRight(triggerId);\n validateResourceId(triggerId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.TriggersPathSegment +\n \"/\" +\n triggerId\n );\n}\n\n/**\n * Given a database, collection and udf id, this creates a udf link.\n * Would be used when replacing, executing, or deleting a UserDefinedFunction in\n * Azure Cosmos DB database service\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param udfId -The User Defined Function Id\n * @returns A udf link in the format of `dbs/{0}/colls/{1}/udfs/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the udfId\n * @hidden\n */\nexport function createUserDefinedFunctionUri(\n databaseId: string,\n collectionId: string,\n udfId: string,\n): string {\n udfId = trimSlashFromLeftAndRight(udfId);\n validateResourceId(udfId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.UserDefinedFunctionsPathSegment +\n \"/\" +\n udfId\n );\n}\n\n/**\n * Given a database, collection and conflict id, this creates a conflict link.\n * Would be used when creating a Conflict in Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param conflictId -The conflict Id\n * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId\n * @hidden\n */\nexport function createConflictUri(\n databaseId: string,\n collectionId: string,\n conflictId: string,\n): string {\n conflictId = trimSlashFromLeftAndRight(conflictId);\n validateResourceId(conflictId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.ConflictsPathSegment +\n \"/\" +\n conflictId\n );\n}\n\n/**\n * Given a database, collection and conflict id, this creates a conflict link.\n * Would be used when creating a Conflict in Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param documentId -The document Id\n * @param attachmentId -The attachment Id\n * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId\n * @hidden\n */\nexport function createAttachmentUri(\n databaseId: string,\n collectionId: string,\n documentId: string,\n attachmentId: string,\n): string {\n attachmentId = trimSlashFromLeftAndRight(attachmentId);\n validateResourceId(attachmentId);\n\n return (\n createDocumentUri(databaseId, collectionId, documentId) +\n \"/\" +\n Constants.Path.AttachmentsPathSegment +\n \"/\" +\n attachmentId\n );\n}\n\n/**\n * Given a database and collection, this creates a partition key ranges link in\n * the Azure Cosmos DB database service.\n * @param databaseId - The database Id\n * @param collectionId - The collection Id\n * @returns A partition key ranges link in the format of\n * `dbs/{0}/colls/{1}/pkranges` with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId\n * @hidden\n */\nexport function createPartitionKeyRangesUri(databaseId: string, collectionId: string): string {\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.PartitionKeyRangesPathSegment\n );\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts new file mode 100644 index 000000000..50d49e5ca --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts @@ -0,0 +1,9 @@ +/** + * Cosmos DB Diagnostic Level + */ +export declare enum CosmosDbDiagnosticLevel { + info = "info", + debug = "debug", + debugUnsafe = "debug-unsafe" +} +//# sourceMappingURL=CosmosDbDiagnosticLevel.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts.map new file mode 100644 index 000000000..1bed5d491 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosDbDiagnosticLevel.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/CosmosDbDiagnosticLevel.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,uBAAuB;IACjC,IAAI,SAAS;IACb,KAAK,UAAU;IACf,WAAW,iBAAiB;CAC7B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js new file mode 100644 index 000000000..3be838368 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Cosmos DB Diagnostic Level + */ +export var CosmosDbDiagnosticLevel; +(function (CosmosDbDiagnosticLevel) { + CosmosDbDiagnosticLevel["info"] = "info"; + CosmosDbDiagnosticLevel["debug"] = "debug"; + CosmosDbDiagnosticLevel["debugUnsafe"] = "debug-unsafe"; +})(CosmosDbDiagnosticLevel || (CosmosDbDiagnosticLevel = {})); +//# sourceMappingURL=CosmosDbDiagnosticLevel.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js.map new file mode 100644 index 000000000..ff3397c9d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDbDiagnosticLevel.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosDbDiagnosticLevel.js","sourceRoot":"","sources":["../../../src/diagnostics/CosmosDbDiagnosticLevel.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAN,IAAY,uBAIX;AAJD,WAAY,uBAAuB;IACjC,wCAAa,CAAA;IACb,0CAAe,CAAA;IACf,uDAA4B,CAAA;AAC9B,CAAC,EAJW,uBAAuB,KAAvB,uBAAuB,QAIlC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Cosmos DB Diagnostic Level\n */\nexport enum CosmosDbDiagnosticLevel {\n info = \"info\",\n debug = \"debug\",\n debugUnsafe = \"debug-unsafe\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts new file mode 100644 index 000000000..327804e7b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts @@ -0,0 +1,30 @@ +import { ClientSideRequestStatistics, GatewayStatistics, MetadataLookUpType } from "../CosmosDiagnostics"; +/** + * @hidden + * Internal class to hold CosmosDiagnostic aggregate information all through the lifecycle of a request. + * This object gathers diagnostic information throughout Client operation which may span across multiple + * Server call, retries etc. + * Functions - recordFailedAttempt, recordMetaDataQuery, recordEndpointContactEvent are used to ingest + * data into the context. At the end of operation, getDiagnostics() is used to + * get final CosmosDiagnostic object. + */ +export declare class CosmosDiagnosticContext { + private requestStartTimeUTCinMs; + private failedAttempts; + private metadataLookups; + private gaterwayStatistics; + locationEndpointsContacted: Set; + constructor(); + recordFailedAttempt(gaterwayStatistics: GatewayStatistics, retryAttemptNumber: number): void; + recordNetworkCall(gaterwayStatistics: GatewayStatistics): void; + /** + * Merge given DiagnosticContext to current node's DiagnosticContext, Treating GatewayRequests of + * given DiagnosticContext, as metadata requests. + */ + mergeDiagnostics(childDiagnostics: CosmosDiagnosticContext, metadataType: MetadataLookUpType): void; + getClientSideStats(endTimeUTCInMs?: number): ClientSideRequestStatistics; + getTotalRequestPayloadLength(): number; + getTotalResponsePayloadLength(): number; + recordEndpointResolution(location: string): void; +} +//# sourceMappingURL=CosmosDiagnosticsContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts.map new file mode 100644 index 000000000..8c4a00791 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosDiagnosticsContext.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/CosmosDiagnosticsContext.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,2BAA2B,EAE3B,iBAAiB,EAEjB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAG9B;;;;;;;;GAQG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,uBAAuB,CAAS;IACxC,OAAO,CAAC,cAAc,CAAwC;IAC9D,OAAO,CAAC,eAAe,CAAkC;IACzD,OAAO,CAAC,kBAAkB,CAA2B;IAC9C,0BAA0B,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;;IAMpD,mBAAmB,CACxB,kBAAkB,EAAE,iBAAiB,EACrC,kBAAkB,EAAE,MAAM,GACzB,IAAI;IAgBA,iBAAiB,CAAC,kBAAkB,EAAE,iBAAiB,GAAG,IAAI;IAIrE;;;OAGG;IACI,gBAAgB,CACrB,gBAAgB,EAAE,uBAAuB,EACzC,YAAY,EAAE,kBAAkB,GAC/B,IAAI;IA2BA,kBAAkB,CACvB,cAAc,GAAE,MAAkC,GACjD,2BAA2B;IAiBvB,4BAA4B,IAAI,MAAM;IActC,6BAA6B,IAAI,MAAM;IAcvC,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAGxD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js new file mode 100644 index 000000000..63cad6353 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js @@ -0,0 +1,96 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { getCurrentTimestampInMs } from "../utils/time"; +/** + * @hidden + * Internal class to hold CosmosDiagnostic aggregate information all through the lifecycle of a request. + * This object gathers diagnostic information throughout Client operation which may span across multiple + * Server call, retries etc. + * Functions - recordFailedAttempt, recordMetaDataQuery, recordEndpointContactEvent are used to ingest + * data into the context. At the end of operation, getDiagnostics() is used to + * get final CosmosDiagnostic object. + */ +export class CosmosDiagnosticContext { + constructor() { + this.failedAttempts = []; + this.metadataLookups = []; + this.gaterwayStatistics = []; + this.locationEndpointsContacted = new Set(); + this.requestStartTimeUTCinMs = getCurrentTimestampInMs(); + } + recordFailedAttempt(gaterwayStatistics, retryAttemptNumber) { + const attempt = { + attemptNumber: retryAttemptNumber, + startTimeUTCInMs: gaterwayStatistics.startTimeUTCInMs, + durationInMs: gaterwayStatistics.durationInMs, + statusCode: gaterwayStatistics.statusCode, + substatusCode: gaterwayStatistics.subStatusCode, + requestPayloadLengthInBytes: gaterwayStatistics.requestPayloadLengthInBytes, + responsePayloadLengthInBytes: gaterwayStatistics.responsePayloadLengthInBytes, + activityId: gaterwayStatistics.activityId, + operationType: gaterwayStatistics.operationType, + resourceType: gaterwayStatistics.resourceType, + }; + this.failedAttempts.push(attempt); + } + recordNetworkCall(gaterwayStatistics) { + this.gaterwayStatistics.push(gaterwayStatistics); + } + /** + * Merge given DiagnosticContext to current node's DiagnosticContext, Treating GatewayRequests of + * given DiagnosticContext, as metadata requests. + */ + mergeDiagnostics(childDiagnostics, metadataType) { + // Copy Location endpoints contacted. + childDiagnostics.locationEndpointsContacted.forEach((endpoint) => this.locationEndpointsContacted.add(endpoint)); + // Copy child nodes's GatewayStatistics to parent's metadata lookups. + childDiagnostics.gaterwayStatistics.forEach((gateway) => this.metadataLookups.push({ + activityId: gateway.activityId, + requestPayloadLengthInBytes: gateway.requestPayloadLengthInBytes, + responsePayloadLengthInBytes: gateway.responsePayloadLengthInBytes, + startTimeUTCInMs: gateway.startTimeUTCInMs, + operationType: gateway.operationType, + resourceType: gateway.resourceType, + durationInMs: gateway.durationInMs, + metaDataType: metadataType, + })); + // Copy child nodes's metadata lookups to parent's metadata lookups. + childDiagnostics.metadataLookups.forEach((lookup) => this.metadataLookups.push(lookup)); + // Copy child nodes's failed attempts to parent's failed attempts. + childDiagnostics.failedAttempts.forEach((lookup) => this.failedAttempts.push(lookup)); + } + getClientSideStats(endTimeUTCInMs = getCurrentTimestampInMs()) { + return { + requestStartTimeUTCInMs: this.requestStartTimeUTCinMs, + requestDurationInMs: endTimeUTCInMs - this.requestStartTimeUTCinMs, + totalRequestPayloadLengthInBytes: this.getTotalRequestPayloadLength(), + totalResponsePayloadLengthInBytes: this.getTotalResponsePayloadLength(), + locationEndpointsContacted: [...this.locationEndpointsContacted.values()], + metadataDiagnostics: { + metadataLookups: [...this.metadataLookups], + }, + retryDiagnostics: { + failedAttempts: [...this.failedAttempts], + }, + gatewayStatistics: this.gaterwayStatistics, + }; + } + getTotalRequestPayloadLength() { + let totalRequestPayloadLength = 0; + this.gaterwayStatistics.forEach((req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes)); + this.metadataLookups.forEach((req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes)); + this.failedAttempts.forEach((req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes)); + return totalRequestPayloadLength; + } + getTotalResponsePayloadLength() { + let totalResponsePayloadLength = 0; + this.gaterwayStatistics.forEach((req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes)); + this.metadataLookups.forEach((req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes)); + this.failedAttempts.forEach((req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes)); + return totalResponsePayloadLength; + } + recordEndpointResolution(location) { + this.locationEndpointsContacted.add(location); + } +} +//# sourceMappingURL=CosmosDiagnosticsContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js.map new file mode 100644 index 000000000..0ee3bc597 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/CosmosDiagnosticsContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosDiagnosticsContext.js","sourceRoot":"","sources":["../../../src/diagnostics/CosmosDiagnosticsContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,OAAO,uBAAuB;IAOlC;QALQ,mBAAc,GAAqC,EAAE,CAAC;QACtD,oBAAe,GA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C,CAAC,yBAAyB,IAAI,GAAG,CAAC,2BAA2B,CAAC,CACxE,CAAC;QACF,IAAI,CAAC,eAAe,CAAC,OAAO,CAC1B,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,yBAAyB,IAAI,GAAG,CAAC,2BAA2B,CAAC,CACxE,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,OAAO,CACzB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,yBAAyB,IAAI,GAAG,CAAC,2BAA2B,CAAC,CACxE,CAAC;QACF,OAAO,yBAAyB,CAAC;IACnC,CAAC;IAEM,6BAA6B;QAClC,IAAI,0BAA0B,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAC7B,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,0BAA0B,IAAI,GAAG,CAAC,4BAA4B,CAAC,CAC1E,CAAC;QACF,IAAI,CAAC,eAAe,CAAC,OAAO,CAC1B,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,0BAA0B,IAAI,GAAG,CAAC,4BAA4B,CAAC,CAC1E,CAAC;QACF,IAAI,CAAC,cAAc,CAAC,OAAO,CACzB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,0BAA0B,IAAI,GAAG,CAAC,4BAA4B,CAAC,CAC1E,CAAC;QACF,OAAO,0BAA0B,CAAC;IACpC,CAAC;IAEM,wBAAwB,CAAC,QAAgB;QAC9C,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ClientSideRequestStatistics,\n FailedRequestAttemptDiagnostic,\n GatewayStatistics,\n MetadataLookUpDiagnostic,\n MetadataLookUpType,\n} from \"../CosmosDiagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\n\n/**\n * @hidden\n * Internal class to hold CosmosDiagnostic aggregate information all through the lifecycle of a request.\n * This object gathers diagnostic information throughout Client operation which may span across multiple\n * Server call, retries etc.\n * Functions - recordFailedAttempt, recordMetaDataQuery, recordEndpointContactEvent are used to ingest\n * data into the context. At the end of operation, getDiagnostics() is used to\n * get final CosmosDiagnostic object.\n */\nexport class CosmosDiagnosticContext {\n private requestStartTimeUTCinMs: number;\n private failedAttempts: FailedRequestAttemptDiagnostic[] = [];\n private metadataLookups: MetadataLookUpDiagnostic[] = [];\n private gaterwayStatistics: GatewayStatistics[] = [];\n public locationEndpointsContacted: Set = new Set();\n\n public constructor() {\n this.requestStartTimeUTCinMs = getCurrentTimestampInMs();\n }\n\n public recordFailedAttempt(\n gaterwayStatistics: GatewayStatistics,\n retryAttemptNumber: number,\n ): void {\n const attempt: FailedRequestAttemptDiagnostic = {\n attemptNumber: retryAttemptNumber,\n startTimeUTCInMs: gaterwayStatistics.startTimeUTCInMs,\n durationInMs: gaterwayStatistics.durationInMs,\n statusCode: gaterwayStatistics.statusCode,\n substatusCode: gaterwayStatistics.subStatusCode,\n requestPayloadLengthInBytes: gaterwayStatistics.requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: gaterwayStatistics.responsePayloadLengthInBytes,\n activityId: gaterwayStatistics.activityId,\n operationType: gaterwayStatistics.operationType,\n resourceType: gaterwayStatistics.resourceType,\n };\n this.failedAttempts.push(attempt);\n }\n\n public recordNetworkCall(gaterwayStatistics: GatewayStatistics): void {\n this.gaterwayStatistics.push(gaterwayStatistics);\n }\n\n /**\n * Merge given DiagnosticContext to current node's DiagnosticContext, Treating GatewayRequests of\n * given DiagnosticContext, as metadata requests.\n */\n public mergeDiagnostics(\n childDiagnostics: CosmosDiagnosticContext,\n metadataType: MetadataLookUpType,\n ): void {\n // Copy Location endpoints contacted.\n childDiagnostics.locationEndpointsContacted.forEach((endpoint) =>\n this.locationEndpointsContacted.add(endpoint),\n );\n\n // Copy child nodes's GatewayStatistics to parent's metadata lookups.\n childDiagnostics.gaterwayStatistics.forEach((gateway) =>\n this.metadataLookups.push({\n activityId: gateway.activityId,\n requestPayloadLengthInBytes: gateway.requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: gateway.responsePayloadLengthInBytes,\n startTimeUTCInMs: gateway.startTimeUTCInMs,\n operationType: gateway.operationType,\n resourceType: gateway.resourceType,\n durationInMs: gateway.durationInMs,\n metaDataType: metadataType,\n }),\n );\n\n // Copy child nodes's metadata lookups to parent's metadata lookups.\n childDiagnostics.metadataLookups.forEach((lookup) => this.metadataLookups.push(lookup));\n\n // Copy child nodes's failed attempts to parent's failed attempts.\n childDiagnostics.failedAttempts.forEach((lookup) => this.failedAttempts.push(lookup));\n }\n\n public getClientSideStats(\n endTimeUTCInMs: number = getCurrentTimestampInMs(),\n ): ClientSideRequestStatistics {\n return {\n requestStartTimeUTCInMs: this.requestStartTimeUTCinMs,\n requestDurationInMs: endTimeUTCInMs - this.requestStartTimeUTCinMs,\n totalRequestPayloadLengthInBytes: this.getTotalRequestPayloadLength(),\n totalResponsePayloadLengthInBytes: this.getTotalResponsePayloadLength(),\n locationEndpointsContacted: [...this.locationEndpointsContacted.values()],\n metadataDiagnostics: {\n metadataLookups: [...this.metadataLookups],\n },\n retryDiagnostics: {\n failedAttempts: [...this.failedAttempts],\n },\n gatewayStatistics: this.gaterwayStatistics,\n };\n }\n\n public getTotalRequestPayloadLength(): number {\n let totalRequestPayloadLength = 0;\n this.gaterwayStatistics.forEach(\n (req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes),\n );\n this.metadataLookups.forEach(\n (req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes),\n );\n this.failedAttempts.forEach(\n (req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes),\n );\n return totalRequestPayloadLength;\n }\n\n public getTotalResponsePayloadLength(): number {\n let totalResponsePayloadLength = 0;\n this.gaterwayStatistics.forEach(\n (req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes),\n );\n this.metadataLookups.forEach(\n (req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes),\n );\n this.failedAttempts.forEach(\n (req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes),\n );\n return totalResponsePayloadLength;\n }\n\n public recordEndpointResolution(location: string): void {\n this.locationEndpointsContacted.add(location);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts new file mode 100644 index 000000000..4d38579ff --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts @@ -0,0 +1,8 @@ +import { CosmosDiagnostics } from "../CosmosDiagnostics"; +export interface DiagnosticFormatter { + format(cosmosDiagnostic: CosmosDiagnostics): string; +} +export declare class DefaultDiagnosticFormatter implements DiagnosticFormatter { + format(cosmosDiagnostic: CosmosDiagnostics): string; +} +//# sourceMappingURL=DiagnosticFormatter.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts.map new file mode 100644 index 000000000..2f8c000e7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DiagnosticFormatter.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/DiagnosticFormatter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,MAAM,CAAC;CACrD;AAED,qBAAa,0BAA2B,YAAW,mBAAmB;IACpE,MAAM,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,MAAM;CAGpD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js new file mode 100644 index 000000000..9a6722a88 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export class DefaultDiagnosticFormatter { + format(cosmosDiagnostic) { + return JSON.stringify(cosmosDiagnostic); + } +} +//# sourceMappingURL=DiagnosticFormatter.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js.map new file mode 100644 index 000000000..c6124f732 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticFormatter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DiagnosticFormatter.js","sourceRoot":"","sources":["../../../src/diagnostics/DiagnosticFormatter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,MAAM,OAAO,0BAA0B;IACrC,MAAM,CAAC,gBAAmC;QACxC,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\n\nexport interface DiagnosticFormatter {\n format(cosmosDiagnostic: CosmosDiagnostics): string;\n}\n\nexport class DefaultDiagnosticFormatter implements DiagnosticFormatter {\n format(cosmosDiagnostic: CosmosDiagnostics): string {\n return JSON.stringify(cosmosDiagnostic);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts new file mode 100644 index 000000000..1c6e4f62e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts @@ -0,0 +1,71 @@ +import { DiagnosticNode, MetadataLookUpType } from "../CosmosDiagnostics"; +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; +import { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; +import { OperationType, ResourceType } from "../common"; +/** + * @hidden + * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect + * diagnostic information throughout the lifetime of Diagnostic session. + * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart. + */ +export declare class DiagnosticNodeInternal implements DiagnosticNode { + id: string; + nodeType: DiagnosticNodeType; + parent: DiagnosticNodeInternal; + children: DiagnosticNodeInternal[]; + data: Partial; + startTimeUTCInMs: number; + durationInMs: number; + diagnosticLevel: CosmosDbDiagnosticLevel; + private diagnosticCtx; +} +/** + * @hidden + */ +export type DiagnosticDataValue = { + selectedLocation: string; + activityId: string; + requestAttempNumber: number; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; + responseStatus: number; + readFromCache: boolean; + operationType: OperationType; + metadatOperationType: MetadataLookUpType; + resourceType: ResourceType; + failedAttempty: boolean; + successfulRetryPolicy: string; + partitionKeyRangeId: string; + stateful: boolean; + queryRecordsRead: number; + queryMethodIdentifier: string; + log: string[]; + failure: boolean; + startTimeUTCInMs: number; + durationInMs: number; + requestData: Partial<{ + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; + operationType: OperationType; + resourceType: ResourceType; + headers: CosmosHeaders; + requestBody: any; + responseBody: any; + url: string; + }>; +}; +/** + * @hidden + */ +export declare enum DiagnosticNodeType { + CLIENT_REQUEST_NODE = "CLIENT_REQUEST_NODE", + METADATA_REQUEST_NODE = "METADATA_REQUEST_NODE", + HTTP_REQUEST = "HTTP_REQUEST", + BATCH_REQUEST = "BATCH_REQUEST", + PARALLEL_QUERY_NODE = "PARALLEL_QUERY_NODE", + DEFAULT_QUERY_NODE = "DEFAULT_QUERY_NODE", + QUERY_REPAIR_NODE = "QUERY_REPAIR_NODE", + BACKGROUND_REFRESH_THREAD = "BACKGROUND_REFRESH_THREAD", + REQUEST_ATTEMPTS = "REQUEST_ATTEMPTS" +} +//# sourceMappingURL=DiagnosticNodeInternal.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts.map new file mode 100644 index 000000000..306c6670d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DiagnosticNodeInternal.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/DiagnosticNodeInternal.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,cAAc,EACd,kBAAkB,EAInB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EAAa,aAAa,EAAE,YAAY,EAAc,MAAM,WAAW,CAAC;AAG/E;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,cAAc;IACpD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,MAAM,EAAE,sBAAsB,CAAC;IAC/B,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACnC,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,uBAAuB,CAAC;IAChD,OAAO,CAAC,aAAa,CAA0B;CA+PhD;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,2BAA2B,EAAE,MAAM,CAAC;IACpC,4BAA4B,EAAE,MAAM,CAAC;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,oBAAoB,EAAE,kBAAkB,CAAC;IACzC,YAAY,EAAE,YAAY,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;QACnB,2BAA2B,EAAE,MAAM,CAAC;QACpC,4BAA4B,EAAE,MAAM,CAAC;QACrC,aAAa,EAAE,aAAa,CAAC;QAC7B,YAAY,EAAE,YAAY,CAAC;QAC3B,OAAO,EAAE,aAAa,CAAC;QACvB,WAAW,EAAE,GAAG,CAAC;QACjB,YAAY,EAAE,GAAG,CAAC;QAClB,GAAG,EAAE,MAAM,CAAC;KACb,CAAC,CAAC;CACJ,CAAC;AAEF;;GAEG;AACH,oBAAY,kBAAkB;IAC5B,mBAAmB,wBAAwB;IAC3C,qBAAqB,0BAA0B;IAC/C,YAAY,iBAAiB;IAC7B,aAAa,kBAAkB;IAC/B,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;IACzC,iBAAiB,sBAAsB;IACvC,yBAAyB,8BAA8B;IACvD,gBAAgB,qBAAqB;CACtC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js new file mode 100644 index 000000000..9c8e45d05 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js @@ -0,0 +1,225 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { CosmosDiagnosticContext } from "./CosmosDiagnosticsContext"; +import { v4 } from "uuid"; +import { CosmosDiagnostics, getRootNode, } from "../CosmosDiagnostics"; +import { getCurrentTimestampInMs } from "../utils/time"; +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; +import { Constants, prepareURL } from "../common"; +import { allowTracing } from "./diagnosticLevelComparator"; +/** + * @hidden + * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect + * diagnostic information throughout the lifetime of Diagnostic session. + * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart. + */ +export class DiagnosticNodeInternal { + /** + * @internal + */ + constructor(diagnosticLevel, type, parent, data = {}, startTimeUTCInMs = getCurrentTimestampInMs(), ctx = new CosmosDiagnosticContext()) { + this.id = v4(); + this.nodeType = type; + this.startTimeUTCInMs = startTimeUTCInMs; + this.data = data; + this.children = []; + this.durationInMs = 0; + this.parent = parent; + this.diagnosticCtx = ctx; + this.diagnosticLevel = diagnosticLevel; + } + /** + * @internal + */ + addLog(msg) { + if (!this.data.log) { + this.data.log = []; + } + this.data.log.push(msg); + } + /** + * @internal + */ + sanitizeHeaders(headers) { + return headers; + } + /** + * Updated durationInMs for node, based on endTimeUTCInMs provided. + * @internal + */ + updateTimestamp(endTimeUTCInMs = getCurrentTimestampInMs()) { + this.durationInMs = endTimeUTCInMs - this.startTimeUTCInMs; + } + /** + * @internal + */ + recordSuccessfulNetworkCall(startTimeUTCInMs, requestContext, pipelineResponse, substatus, url) { + const responseHeaders = pipelineResponse.headers.toJSON(); + const gatewayRequest = { + activityId: responseHeaders[Constants.HttpHeaders.ActivityId], + startTimeUTCInMs, + durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs, + statusCode: pipelineResponse.status, + subStatusCode: substatus, + requestPayloadLengthInBytes: calculateRequestPayloadLength(requestContext), + responsePayloadLengthInBytes: calculateResponsePayloadLength(pipelineResponse), + operationType: requestContext.operationType, + resourceType: requestContext.resourceType, + partitionKeyRangeId: requestContext.partitionKeyRangeId, + }; + let requestData = { + OperationType: gatewayRequest.operationType, + resourceType: gatewayRequest.resourceType, + requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes, + }; + if (allowTracing(CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) { + requestData = Object.assign(Object.assign({}, requestData), { headers: this.sanitizeHeaders(requestContext.headers), requestBody: requestContext.body, responseBody: pipelineResponse.bodyAsText, url: url }); + } + this.addData({ + requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes, + responsePayloadLengthInBytes: gatewayRequest.responsePayloadLengthInBytes, + startTimeUTCInMs: gatewayRequest.startTimeUTCInMs, + durationInMs: gatewayRequest.durationInMs, + requestData, + }); + this.diagnosticCtx.recordNetworkCall(gatewayRequest); + } + /** + * @internal + */ + recordFailedNetworkCall(startTimeUTCInMs, requestContext, retryAttemptNumber, statusCode, substatusCode, responseHeaders) { + this.addData({ failedAttempty: true }); + const requestPayloadLengthInBytes = calculateRequestPayloadLength(requestContext); + this.diagnosticCtx.recordFailedAttempt({ + activityId: responseHeaders[Constants.HttpHeaders.ActivityId], + startTimeUTCInMs, + durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs, + statusCode, + subStatusCode: substatusCode, + requestPayloadLengthInBytes, + responsePayloadLengthInBytes: 0, + operationType: requestContext.operationType, + resourceType: requestContext.resourceType, + }, retryAttemptNumber); + let requestData = { + OperationType: requestContext.operationType, + resourceType: requestContext.resourceType, + requestPayloadLengthInBytes, + }; + if (allowTracing(CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) { + requestData = Object.assign(Object.assign({}, requestData), { headers: this.sanitizeHeaders(requestContext.headers), requestBody: requestContext.body, url: prepareURL(requestContext.endpoint, requestContext.path) }); + } + this.addData({ + failedAttempty: true, + requestData, + }); + } + /** + * @internal + */ + recordEndpointResolution(location) { + this.addData({ selectedLocation: location }); + this.diagnosticCtx.recordEndpointResolution(location); + } + /** + * @internal + */ + addData(data, msg, level = this.diagnosticLevel) { + if (level !== CosmosDbDiagnosticLevel.info) { + this.data = Object.assign(Object.assign({}, this.data), data); + if (msg) { + this.addLog(msg); + } + } + } + /** + * Merge given DiagnosticNodeInternal's context to current node's DiagnosticContext, Treating GatewayRequests of + * given DiagnosticContext, as metadata requests. Given DiagnosticNodeInternal becomes a child of this node. + * @internal + */ + addChildNode(child, level, metadataType) { + this.diagnosticCtx.mergeDiagnostics(child.diagnosticCtx, metadataType); + if (allowTracing(level, this.diagnosticLevel)) { + child.parent = this; + this.children.push(child); + } + return child; + } + /** + * @internal + */ + initializeChildNode(type, level, data = {}) { + if (allowTracing(level, this.diagnosticLevel)) { + const child = new DiagnosticNodeInternal(this.diagnosticLevel, type, this, data, getCurrentTimestampInMs(), this.diagnosticCtx); + this.children.push(child); + return child; + } + else { + return this; + } + } + /** + * @internal + */ + recordQueryResult(resources, level) { + var _a; + if (allowTracing(level, this.diagnosticLevel)) { + const previousCount = (_a = this.data.queryRecordsRead) !== null && _a !== void 0 ? _a : 0; + if (Array.isArray(resources)) { + this.data.queryRecordsRead = previousCount + resources.length; + } + } + } + /** + * Convert DiagnosticNodeInternal (internal representation) to DiagnosticNode (public, sanitized representation) + * @internal + */ + toDiagnosticNode() { + return { + id: this.id, + nodeType: this.nodeType, + children: this.children.map((child) => child.toDiagnosticNode()), + data: this.data, + startTimeUTCInMs: this.startTimeUTCInMs, + durationInMs: this.durationInMs, + }; + } + /** + * Convert to CosmosDiagnostics + * @internal + */ + toDiagnostic(clientConfigDiagnostic) { + const rootNode = getRootNode(this); + const diagnostiNode = allowTracing(CosmosDbDiagnosticLevel.debug, this.diagnosticLevel) + ? rootNode.toDiagnosticNode() + : undefined; + const clientConfig = allowTracing(CosmosDbDiagnosticLevel.debug, this.diagnosticLevel) + ? clientConfigDiagnostic + : undefined; + const cosmosDiagnostic = new CosmosDiagnostics(this.diagnosticCtx.getClientSideStats(), diagnostiNode, clientConfig); + return cosmosDiagnostic; + } +} +/** + * @hidden + */ +export var DiagnosticNodeType; +(function (DiagnosticNodeType) { + DiagnosticNodeType["CLIENT_REQUEST_NODE"] = "CLIENT_REQUEST_NODE"; + DiagnosticNodeType["METADATA_REQUEST_NODE"] = "METADATA_REQUEST_NODE"; + DiagnosticNodeType["HTTP_REQUEST"] = "HTTP_REQUEST"; + DiagnosticNodeType["BATCH_REQUEST"] = "BATCH_REQUEST"; + DiagnosticNodeType["PARALLEL_QUERY_NODE"] = "PARALLEL_QUERY_NODE"; + DiagnosticNodeType["DEFAULT_QUERY_NODE"] = "DEFAULT_QUERY_NODE"; + DiagnosticNodeType["QUERY_REPAIR_NODE"] = "QUERY_REPAIR_NODE"; + DiagnosticNodeType["BACKGROUND_REFRESH_THREAD"] = "BACKGROUND_REFRESH_THREAD"; + DiagnosticNodeType["REQUEST_ATTEMPTS"] = "REQUEST_ATTEMPTS"; +})(DiagnosticNodeType || (DiagnosticNodeType = {})); +function calculateResponsePayloadLength(response) { + var _a; + return ((_a = response === null || response === void 0 ? void 0 : response.bodyAsText) === null || _a === void 0 ? void 0 : _a.length) || 0; +} +function calculateRequestPayloadLength(requestContext) { + return requestContext.body ? requestContext.body.length : 0; +} +//# sourceMappingURL=DiagnosticNodeInternal.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js.map new file mode 100644 index 000000000..87aa53ce3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticNodeInternal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DiagnosticNodeInternal.js","sourceRoot":"","sources":["../../../src/diagnostics/Di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BAAgB,EAAE;YAC7B,CAAC,CAAC,SAAS,CAAC;QACd,MAAM,YAAY,GAAG,YAAY,CAAC,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC;YACpF,CAAC,CAAC,sBAAsB;YACxB,CAAC,CAAC,SAAS,CAAC;QACd,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,CAC5C,IAAI,CAAC,aAAa,CAAC,kBAAkB,EAAE,EACvC,aAAa,EACb,YAAY,CACb,CAAC;QACF,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAsCD;;GAEG;AACH,MAAM,CAAN,IAAY,kBAUX;AAVD,WAAY,kBAAkB;IAC5B,iEAA2C,CAAA;IAC3C,qEAA+C,CAAA;IAC/C,mDAA6B,CAAA;IAC7B,qDAA+B,CAAA;IAC/B,iEAA2C,CAAA;IAC3C,+DAAyC,CAAA;IACzC,6DAAuC,CAAA;IACvC,6EAAuD,CAAA;IACvD,2DAAqC,CAAA;AACvC,CAAC,EAVW,kBAAkB,KAAlB,kBAAkB,QAU7B;AAED,SAAS,8BAA8B,CAAC,QAA0B;;IAChE,OAAO,CAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,UAAU,0CAAE,MAAM,KAAI,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,6BAA6B,CAAC,cAA8B;IACnE,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDiagnosticContext } from \"./CosmosDiagnosticsContext\";\nimport { RequestContext } from \"../request\";\nimport { v4 } from \"uuid\";\nimport {\n DiagnosticNode,\n MetadataLookUpType,\n CosmosDiagnostics,\n getRootNode,\n ClientConfigDiagnostic,\n} from \"../CosmosDiagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\nimport { CosmosDbDiagnosticLevel } from \"./CosmosDbDiagnosticLevel\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { HttpHeaders, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { Constants, OperationType, ResourceType, prepareURL } from \"../common\";\nimport { allowTracing } from \"./diagnosticLevelComparator\";\n\n/**\n * @hidden\n * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect\n * diagnostic information throughout the lifetime of Diagnostic session.\n * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart.\n */\nexport class DiagnosticNodeInternal implements DiagnosticNode {\n public id: string;\n public nodeType: DiagnosticNodeType;\n public parent: DiagnosticNodeInternal;\n public children: DiagnosticNodeInternal[];\n public data: Partial;\n public startTimeUTCInMs: number;\n public durationInMs: number;\n public diagnosticLevel: CosmosDbDiagnosticLevel;\n private diagnosticCtx: CosmosDiagnosticContext;\n\n /**\n * @internal\n */\n constructor(\n diagnosticLevel: CosmosDbDiagnosticLevel,\n type: DiagnosticNodeType,\n parent: DiagnosticNodeInternal,\n data: Partial = {},\n startTimeUTCInMs: number = getCurrentTimestampInMs(),\n ctx: CosmosDiagnosticContext = new CosmosDiagnosticContext(),\n ) {\n this.id = v4();\n this.nodeType = type;\n this.startTimeUTCInMs = startTimeUTCInMs;\n this.data = data;\n this.children = [];\n this.durationInMs = 0;\n this.parent = parent;\n this.diagnosticCtx = ctx;\n this.diagnosticLevel = diagnosticLevel;\n }\n\n /**\n * @internal\n */\n private addLog(msg: string): void {\n if (!this.data.log) {\n this.data.log = [];\n }\n this.data.log.push(msg);\n }\n\n /**\n * @internal\n */\n private sanitizeHeaders(headers?: CosmosHeaders | HttpHeaders): CosmosHeaders | HttpHeaders {\n return headers;\n }\n\n /**\n * Updated durationInMs for node, based on endTimeUTCInMs provided.\n * @internal\n */\n public updateTimestamp(endTimeUTCInMs: number = getCurrentTimestampInMs()): void {\n this.durationInMs = endTimeUTCInMs - this.startTimeUTCInMs;\n }\n\n /**\n * @internal\n */\n public recordSuccessfulNetworkCall(\n startTimeUTCInMs: number,\n requestContext: RequestContext,\n pipelineResponse: PipelineResponse,\n substatus: number,\n url: string,\n ): void {\n const responseHeaders = pipelineResponse.headers.toJSON();\n const gatewayRequest = {\n activityId: responseHeaders[Constants.HttpHeaders.ActivityId],\n startTimeUTCInMs,\n durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs,\n statusCode: pipelineResponse.status,\n subStatusCode: substatus,\n requestPayloadLengthInBytes: calculateRequestPayloadLength(requestContext),\n responsePayloadLengthInBytes: calculateResponsePayloadLength(pipelineResponse),\n operationType: requestContext.operationType,\n resourceType: requestContext.resourceType,\n partitionKeyRangeId: requestContext.partitionKeyRangeId,\n };\n let requestData: any = {\n OperationType: gatewayRequest.operationType,\n resourceType: gatewayRequest.resourceType,\n requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes,\n };\n\n if (allowTracing(CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) {\n requestData = {\n ...requestData,\n headers: this.sanitizeHeaders(requestContext.headers),\n requestBody: requestContext.body,\n responseBody: pipelineResponse.bodyAsText,\n url: url,\n };\n }\n this.addData({\n requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: gatewayRequest.responsePayloadLengthInBytes,\n startTimeUTCInMs: gatewayRequest.startTimeUTCInMs,\n durationInMs: gatewayRequest.durationInMs,\n requestData,\n });\n this.diagnosticCtx.recordNetworkCall(gatewayRequest);\n }\n\n /**\n * @internal\n */\n public recordFailedNetworkCall(\n startTimeUTCInMs: number,\n requestContext: RequestContext,\n retryAttemptNumber: number,\n statusCode: number,\n substatusCode: number,\n responseHeaders: CosmosHeaders,\n ): void {\n this.addData({ failedAttempty: true });\n const requestPayloadLengthInBytes = calculateRequestPayloadLength(requestContext);\n this.diagnosticCtx.recordFailedAttempt(\n {\n activityId: responseHeaders[Constants.HttpHeaders.ActivityId] as string,\n startTimeUTCInMs,\n durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs,\n statusCode,\n subStatusCode: substatusCode,\n requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: 0,\n operationType: requestContext.operationType,\n resourceType: requestContext.resourceType,\n },\n retryAttemptNumber,\n );\n let requestData: any = {\n OperationType: requestContext.operationType,\n resourceType: requestContext.resourceType,\n requestPayloadLengthInBytes,\n };\n if (allowTracing(CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) {\n requestData = {\n ...requestData,\n headers: this.sanitizeHeaders(requestContext.headers),\n requestBody: requestContext.body,\n url: prepareURL(requestContext.endpoint, requestContext.path),\n };\n }\n this.addData({\n failedAttempty: true,\n requestData,\n });\n }\n\n /**\n * @internal\n */\n public recordEndpointResolution(location: string): void {\n this.addData({ selectedLocation: location });\n this.diagnosticCtx.recordEndpointResolution(location);\n }\n\n /**\n * @internal\n */\n public addData(\n data: Partial,\n msg?: string,\n level: CosmosDbDiagnosticLevel = this.diagnosticLevel,\n ): void {\n if (level !== CosmosDbDiagnosticLevel.info) {\n this.data = { ...this.data, ...data };\n if (msg) {\n this.addLog(msg);\n }\n }\n }\n\n /**\n * Merge given DiagnosticNodeInternal's context to current node's DiagnosticContext, Treating GatewayRequests of\n * given DiagnosticContext, as metadata requests. Given DiagnosticNodeInternal becomes a child of this node.\n * @internal\n */\n public addChildNode(\n child: DiagnosticNodeInternal,\n level: CosmosDbDiagnosticLevel,\n metadataType?: MetadataLookUpType,\n ): DiagnosticNodeInternal {\n this.diagnosticCtx.mergeDiagnostics(child.diagnosticCtx, metadataType);\n if (allowTracing(level, this.diagnosticLevel)) {\n child.parent = this;\n this.children.push(child);\n }\n return child;\n }\n\n /**\n * @internal\n */\n public initializeChildNode(\n type: DiagnosticNodeType,\n level: CosmosDbDiagnosticLevel,\n data: Partial = {},\n ): DiagnosticNodeInternal {\n if (allowTracing(level, this.diagnosticLevel)) {\n const child = new DiagnosticNodeInternal(\n this.diagnosticLevel,\n type,\n this,\n data,\n getCurrentTimestampInMs(),\n this.diagnosticCtx,\n );\n this.children.push(child);\n return child;\n } else {\n return this;\n }\n }\n\n /**\n * @internal\n */\n public recordQueryResult(resources: unknown, level: CosmosDbDiagnosticLevel): void {\n if (allowTracing(level, this.diagnosticLevel)) {\n const previousCount = this.data.queryRecordsRead ?? 0;\n if (Array.isArray(resources)) {\n this.data.queryRecordsRead = previousCount + resources.length;\n }\n }\n }\n\n /**\n * Convert DiagnosticNodeInternal (internal representation) to DiagnosticNode (public, sanitized representation)\n * @internal\n */\n public toDiagnosticNode(): DiagnosticNode {\n return {\n id: this.id,\n nodeType: this.nodeType,\n children: this.children.map((child) => child.toDiagnosticNode()),\n data: this.data,\n startTimeUTCInMs: this.startTimeUTCInMs,\n durationInMs: this.durationInMs,\n };\n }\n\n /**\n * Convert to CosmosDiagnostics\n * @internal\n */\n public toDiagnostic(clientConfigDiagnostic: ClientConfigDiagnostic): CosmosDiagnostics {\n const rootNode = getRootNode(this);\n const diagnostiNode = allowTracing(CosmosDbDiagnosticLevel.debug, this.diagnosticLevel)\n ? rootNode.toDiagnosticNode()\n : undefined;\n const clientConfig = allowTracing(CosmosDbDiagnosticLevel.debug, this.diagnosticLevel)\n ? clientConfigDiagnostic\n : undefined;\n const cosmosDiagnostic = new CosmosDiagnostics(\n this.diagnosticCtx.getClientSideStats(),\n diagnostiNode,\n clientConfig,\n );\n return cosmosDiagnostic;\n }\n}\n\n/**\n * @hidden\n */\nexport type DiagnosticDataValue = {\n selectedLocation: string;\n activityId: string;\n requestAttempNumber: number;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n responseStatus: number;\n readFromCache: boolean;\n operationType: OperationType;\n metadatOperationType: MetadataLookUpType;\n resourceType: ResourceType;\n failedAttempty: boolean;\n successfulRetryPolicy: string;\n partitionKeyRangeId: string;\n stateful: boolean;\n queryRecordsRead: number;\n queryMethodIdentifier: string;\n log: string[];\n failure: boolean;\n startTimeUTCInMs: number;\n durationInMs: number;\n requestData: Partial<{\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n operationType: OperationType;\n resourceType: ResourceType;\n headers: CosmosHeaders;\n requestBody: any;\n responseBody: any;\n url: string;\n }>;\n};\n\n/**\n * @hidden\n */\nexport enum DiagnosticNodeType {\n CLIENT_REQUEST_NODE = \"CLIENT_REQUEST_NODE\", // Top most node representing client operations.\n METADATA_REQUEST_NODE = \"METADATA_REQUEST_NODE\", // Node representing a metadata request.\n HTTP_REQUEST = \"HTTP_REQUEST\", // Node representing REST call to backend services.\n BATCH_REQUEST = \"BATCH_REQUEST\", // Node representing batch request.\n PARALLEL_QUERY_NODE = \"PARALLEL_QUERY_NODE\", // Node representing parallel query execution.\n DEFAULT_QUERY_NODE = \"DEFAULT_QUERY_NODE\", // Node representing default query execution.\n QUERY_REPAIR_NODE = \"QUERY_REPAIR_NODE\", // Node representing query repair.\n BACKGROUND_REFRESH_THREAD = \"BACKGROUND_REFRESH_THREAD\", // Node representing background refresh.\n REQUEST_ATTEMPTS = \"REQUEST_ATTEMPTS\", // Node representing request attempts.\n}\n\nfunction calculateResponsePayloadLength(response: PipelineResponse) {\n return response?.bodyAsText?.length || 0;\n}\n\nfunction calculateRequestPayloadLength(requestContext: RequestContext) {\n return requestContext.body ? requestContext.body.length : 0;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts new file mode 100644 index 000000000..608a868ef --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts @@ -0,0 +1,24 @@ +/** + * Interface for a Diagnostic Writer. + * @hidden + */ +export interface DiagnosticWriter { + write(message: string): Promise; +} +/** + * Implementation of DiagnosticWriter, which uses \@azure/logger to write + * diagnostics. + * @hidden + */ +export declare class LogDiagnosticWriter implements DiagnosticWriter { + private logger; + write(diagnosticsData: string): Promise; +} +/** + * Implementation of a no-op DiagnosticWriter. + * @hidden + */ +export declare class NoOpDiagnosticWriter implements DiagnosticWriter { + write(_diagnosticsData: string): Promise; +} +//# sourceMappingURL=DiagnosticWriter.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts.map new file mode 100644 index 000000000..c33e7087d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DiagnosticWriter.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/DiagnosticWriter.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;IAC1D,OAAO,CAAC,MAAM,CAA0D;IAC3D,KAAK,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D;AAED;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAC9C,KAAK,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG5D"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js new file mode 100644 index 000000000..e3cb598ed --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createClientLogger } from "@azure/logger"; +/** + * Implementation of DiagnosticWriter, which uses \@azure/logger to write + * diagnostics. + * @hidden + */ +export class LogDiagnosticWriter { + constructor() { + this.logger = createClientLogger("CosmosDBDiagnostics"); + } + async write(diagnosticsData) { + this.logger.verbose(diagnosticsData); + } +} +/** + * Implementation of a no-op DiagnosticWriter. + * @hidden + */ +export class NoOpDiagnosticWriter { + async write(_diagnosticsData) { + // No op + } +} +//# sourceMappingURL=DiagnosticWriter.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js.map new file mode 100644 index 000000000..ca0ef601a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/DiagnosticWriter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DiagnosticWriter.js","sourceRoot":"","sources":["../../../src/diagnostics/DiagnosticWriter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAe,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAUhE;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACU,WAAM,GAAgB,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;IAI1E,CAAC;IAHQ,KAAK,CAAC,KAAK,CAAC,eAAuB;QACxC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACvC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IACxB,KAAK,CAAC,KAAK,CAAC,gBAAwB;QACzC,QAAQ;IACV,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\n\n/**\n * Interface for a Diagnostic Writer.\n * @hidden\n */\nexport interface DiagnosticWriter {\n write(message: string): Promise;\n}\n\n/**\n * Implementation of DiagnosticWriter, which uses \\@azure/logger to write\n * diagnostics.\n * @hidden\n */\nexport class LogDiagnosticWriter implements DiagnosticWriter {\n private logger: AzureLogger = createClientLogger(\"CosmosDBDiagnostics\");\n public async write(diagnosticsData: string): Promise {\n this.logger.verbose(diagnosticsData);\n }\n}\n\n/**\n * Implementation of a no-op DiagnosticWriter.\n * @hidden\n */\nexport class NoOpDiagnosticWriter implements DiagnosticWriter {\n public async write(_diagnosticsData: string): Promise {\n // No op\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts new file mode 100644 index 000000000..375b666a7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts @@ -0,0 +1,10 @@ +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; +/** + * @hidden + */ +export declare const CosmosDbDiagnosticLevelOrder: CosmosDbDiagnosticLevel[]; +/** + * @hidden + */ +export declare function allowTracing(levelToCheck: CosmosDbDiagnosticLevel, clientDiagnosticLevel: CosmosDbDiagnosticLevel): boolean; +//# sourceMappingURL=diagnosticLevelComparator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts.map new file mode 100644 index 000000000..d31436a25 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"diagnosticLevelComparator.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/diagnosticLevelComparator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,4BAA4B,2BAIxC,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,uBAAuB,EACrC,qBAAqB,EAAE,uBAAuB,GAC7C,OAAO,CAOT"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js new file mode 100644 index 000000000..79a3f6602 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; +/** + * @hidden + */ +export const CosmosDbDiagnosticLevelOrder = [ + CosmosDbDiagnosticLevel.info, + CosmosDbDiagnosticLevel.debug, + CosmosDbDiagnosticLevel.debugUnsafe, +]; +/** + * @hidden + */ +export function allowTracing(levelToCheck, clientDiagnosticLevel) { + const indexOfDiagnosticLevelToCheck = CosmosDbDiagnosticLevelOrder.indexOf(levelToCheck); + const indexOfClientDiagnosticLevel = CosmosDbDiagnosticLevelOrder.indexOf(clientDiagnosticLevel); + if (indexOfDiagnosticLevelToCheck === -1 || indexOfClientDiagnosticLevel === -1) { + return false; + } + return indexOfDiagnosticLevelToCheck <= indexOfClientDiagnosticLevel; +} +//# sourceMappingURL=diagnosticLevelComparator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js.map new file mode 100644 index 000000000..5092df587 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/diagnosticLevelComparator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"diagnosticLevelComparator.js","sourceRoot":"","sources":["../../../src/diagnostics/diagnosticLevelComparator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,uBAAuB,CAAC,IAAI;IAC5B,uBAAuB,CAAC,KAAK;IAC7B,uBAAuB,CAAC,WAAW;CACpC,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,YAAqC,EACrC,qBAA8C;IAE9C,MAAM,6BAA6B,GAAG,4BAA4B,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACzF,MAAM,4BAA4B,GAAG,4BAA4B,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACjG,IAAI,6BAA6B,KAAK,CAAC,CAAC,IAAI,4BAA4B,KAAK,CAAC,CAAC,EAAE;QAC/E,OAAO,KAAK,CAAC;KACd;IACD,OAAO,6BAA6B,IAAI,4BAA4B,CAAC;AACvE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDbDiagnosticLevel } from \"./CosmosDbDiagnosticLevel\";\n\n/**\n * @hidden\n */\nexport const CosmosDbDiagnosticLevelOrder = [\n CosmosDbDiagnosticLevel.info,\n CosmosDbDiagnosticLevel.debug,\n CosmosDbDiagnosticLevel.debugUnsafe,\n];\n\n/**\n * @hidden\n */\nexport function allowTracing(\n levelToCheck: CosmosDbDiagnosticLevel,\n clientDiagnosticLevel: CosmosDbDiagnosticLevel,\n): boolean {\n const indexOfDiagnosticLevelToCheck = CosmosDbDiagnosticLevelOrder.indexOf(levelToCheck);\n const indexOfClientDiagnosticLevel = CosmosDbDiagnosticLevelOrder.indexOf(clientDiagnosticLevel);\n if (indexOfDiagnosticLevelToCheck === -1 || indexOfClientDiagnosticLevel === -1) {\n return false;\n }\n return indexOfDiagnosticLevelToCheck <= indexOfClientDiagnosticLevel;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts new file mode 100644 index 000000000..fda486c77 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts @@ -0,0 +1,8 @@ +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; +export * from "./DiagnosticWriter"; +export * from "./DiagnosticFormatter"; +export declare const DefaultDiagnosticLevelValue = CosmosDbDiagnosticLevel.info; +export declare function setDiagnosticLevel(level?: CosmosDbDiagnosticLevel): void; +export declare function getDiagnosticLevelFromEnvironment(): CosmosDbDiagnosticLevel | undefined; +export declare function determineDiagnosticLevel(diagnosticLevelFromClientConfig: CosmosDbDiagnosticLevel, diagnosticLevelFromEnvironment: CosmosDbDiagnosticLevel): CosmosDbDiagnosticLevel; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts.map new file mode 100644 index 000000000..905f171c3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/diagnostics/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AAEtC,eAAO,MAAM,2BAA2B,+BAA+B,CAAC;AA6BxE,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,uBAAuB,GAAG,IAAI,CASxE;AAED,wBAAgB,iCAAiC,IAAI,uBAAuB,GAAG,SAAS,CAEvF;AAQD,wBAAgB,wBAAwB,CACtC,+BAA+B,EAAE,uBAAuB,EACxD,8BAA8B,EAAE,uBAAuB,GACtD,uBAAuB,CAIzB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js new file mode 100644 index 000000000..02a0f1f11 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants } from "../common"; +import { isNonEmptyString } from "../utils/strings"; +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; +export * from "./DiagnosticWriter"; +export * from "./DiagnosticFormatter"; +export const DefaultDiagnosticLevelValue = CosmosDbDiagnosticLevel.info; +const diagnosticLevelFromEnv = (typeof process !== "undefined" && + process.env && + process.env[Constants.CosmosDbDiagnosticLevelEnvVarName]) || + undefined; +const acceptableDiagnosticLevelValues = Object.values(CosmosDbDiagnosticLevel).map((x) => x.toString()); +let cosmosDiagnosticLevel; +if (isNonEmptyString(diagnosticLevelFromEnv)) { + // avoid calling setDiagnosticLevel because we don't want a mis-set environment variable to crash + if (isCosmosDiagnosticLevel(diagnosticLevelFromEnv)) { + setDiagnosticLevel(diagnosticLevelFromEnv); + } + else { + console.error(`${Constants.CosmosDbDiagnosticLevelEnvVarName} set to unknown diagnostic level '${diagnosticLevelFromEnv}'; Setting Cosmos Db diagnostic level to info. Acceptable values: ${acceptableDiagnosticLevelValues.join(", ")}.`); + } +} +export function setDiagnosticLevel(level) { + if (level && !isCosmosDiagnosticLevel(level)) { + throw new Error(`Unknown diagnostic level '${level}'. Acceptable values: ${acceptableDiagnosticLevelValues.join(",")}`); + } + cosmosDiagnosticLevel = level; +} +export function getDiagnosticLevelFromEnvironment() { + return cosmosDiagnosticLevel; +} +function isCosmosDiagnosticLevel(diagnosticLevel) { + return acceptableDiagnosticLevelValues.includes(diagnosticLevel); +} +export function determineDiagnosticLevel(diagnosticLevelFromClientConfig, diagnosticLevelFromEnvironment) { + const diagnosticLevelFromEnvOrClient = diagnosticLevelFromEnvironment !== null && diagnosticLevelFromEnvironment !== void 0 ? diagnosticLevelFromEnvironment : diagnosticLevelFromClientConfig; // Diagnostic Setting from environment gets first priority. + return diagnosticLevelFromEnvOrClient !== null && diagnosticLevelFromEnvOrClient !== void 0 ? diagnosticLevelFromEnvOrClient : DefaultDiagnosticLevelValue; // Diagnostic Setting supplied in Client config gets second priority. +} +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js.map new file mode 100644 index 000000000..d811f5f87 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/diagnostics/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AAEtC,MAAM,CAAC,MAAM,2BAA2B,GAAG,uBAAuB,CAAC,IAAI,CAAC;AAExE,MAAM,sBAAsB,GAC1B,CAAC,OAAO,OAAO,KAAK,WAAW;IAC7B,OAAO,CAAC,GAAG;IACX,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC;IAC3D,SAAS,CAAC;AAEZ,MAAM,+BAA+B,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACvF,CAAC,CAAC,QAAQ,EAAE,CACb,CAAC;AAEF,IAAI,qBAA0D,CAAC;AAE/D,IAAI,gBAAgB,CAAC,sBAAsB,CAAC,EAAE;IAC5C,iGAAiG;IACjG,IAAI,uBAAuB,CAAC,sBAAsB,CAAC,EAAE;QACnD,kBAAkB,CAAC,sBAAiD,CAAC,CAAC;KACvE;SAAM;QACL,OAAO,CAAC,KAAK,CACX,GACE,SAAS,CAAC,iCACZ,qCAAqC,sBAAsB,qEAAqE,+BAA+B,CAAC,IAAI,CAClK,IAAI,CACL,GAAG,CACL,CAAC;KACH;CACF;AAED,MAAM,UAAU,kBAAkB,CAAC,KAA+B;IAChE,IAAI,KAAK,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAC5C,MAAM,IAAI,KAAK,CACb,6BAA6B,KAAK,yBAAyB,+BAA+B,CAAC,IAAI,CAC7F,GAAG,CACJ,EAAE,CACJ,CAAC;KACH;IACD,qBAAqB,GAAG,KAAK,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,iCAAiC;IAC/C,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,SAAS,uBAAuB,CAC9B,eAAuB;IAEvB,OAAO,+BAA+B,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,+BAAwD,EACxD,8BAAuD;IAEvD,MAAM,8BAA8B,GAClC,8BAA8B,aAA9B,8BAA8B,cAA9B,8BAA8B,GAAI,+BAA+B,CAAC,CAAC,2DAA2D;IAChI,OAAO,8BAA8B,aAA9B,8BAA8B,cAA9B,8BAA8B,GAAI,2BAA2B,CAAC,CAAC,qEAAqE;AAC7I,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Constants } from \"../common\";\nimport { isNonEmptyString } from \"../utils/strings\";\nimport { CosmosDbDiagnosticLevel } from \"./CosmosDbDiagnosticLevel\";\n\nexport * from \"./DiagnosticWriter\";\nexport * from \"./DiagnosticFormatter\";\n\nexport const DefaultDiagnosticLevelValue = CosmosDbDiagnosticLevel.info;\n\nconst diagnosticLevelFromEnv =\n (typeof process !== \"undefined\" &&\n process.env &&\n process.env[Constants.CosmosDbDiagnosticLevelEnvVarName]) ||\n undefined;\n\nconst acceptableDiagnosticLevelValues = Object.values(CosmosDbDiagnosticLevel).map((x) =>\n x.toString(),\n);\n\nlet cosmosDiagnosticLevel: CosmosDbDiagnosticLevel | undefined;\n\nif (isNonEmptyString(diagnosticLevelFromEnv)) {\n // avoid calling setDiagnosticLevel because we don't want a mis-set environment variable to crash\n if (isCosmosDiagnosticLevel(diagnosticLevelFromEnv)) {\n setDiagnosticLevel(diagnosticLevelFromEnv as CosmosDbDiagnosticLevel);\n } else {\n console.error(\n `${\n Constants.CosmosDbDiagnosticLevelEnvVarName\n } set to unknown diagnostic level '${diagnosticLevelFromEnv}'; Setting Cosmos Db diagnostic level to info. Acceptable values: ${acceptableDiagnosticLevelValues.join(\n \", \",\n )}.`,\n );\n }\n}\n\nexport function setDiagnosticLevel(level?: CosmosDbDiagnosticLevel): void {\n if (level && !isCosmosDiagnosticLevel(level)) {\n throw new Error(\n `Unknown diagnostic level '${level}'. Acceptable values: ${acceptableDiagnosticLevelValues.join(\n \",\",\n )}`,\n );\n }\n cosmosDiagnosticLevel = level;\n}\n\nexport function getDiagnosticLevelFromEnvironment(): CosmosDbDiagnosticLevel | undefined {\n return cosmosDiagnosticLevel;\n}\n\nfunction isCosmosDiagnosticLevel(\n diagnosticLevel: string,\n): diagnosticLevel is CosmosDbDiagnosticLevel {\n return acceptableDiagnosticLevelValues.includes(diagnosticLevel);\n}\n\nexport function determineDiagnosticLevel(\n diagnosticLevelFromClientConfig: CosmosDbDiagnosticLevel,\n diagnosticLevelFromEnvironment: CosmosDbDiagnosticLevel,\n): CosmosDbDiagnosticLevel {\n const diagnosticLevelFromEnvOrClient =\n diagnosticLevelFromEnvironment ?? diagnosticLevelFromClientConfig; // Diagnostic Setting from environment gets first priority.\n return diagnosticLevelFromEnvOrClient ?? DefaultDiagnosticLevelValue; // Diagnostic Setting supplied in Client config gets second priority.\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts new file mode 100644 index 000000000..22c40e406 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts @@ -0,0 +1,6 @@ +/** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */ +export declare enum ConnectionMode { + /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */ + Gateway = 0 +} +//# sourceMappingURL=ConnectionMode.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts.map new file mode 100644 index 000000000..959e991c6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ConnectionMode.d.ts","sourceRoot":"","sources":["../../../src/documents/ConnectionMode.ts"],"names":[],"mappings":"AAEA,4GAA4G;AAC5G,oBAAY,cAAc;IACxB,4HAA4H;IAC5H,OAAO,IAAI;CACZ"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js new file mode 100644 index 000000000..1f7bc37cc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */ +export var ConnectionMode; +(function (ConnectionMode) { + /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */ + ConnectionMode[ConnectionMode["Gateway"] = 0] = "Gateway"; +})(ConnectionMode || (ConnectionMode = {})); +//# sourceMappingURL=ConnectionMode.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js.map new file mode 100644 index 000000000..2205aa0a2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionMode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ConnectionMode.js","sourceRoot":"","sources":["../../../src/documents/ConnectionMode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,4GAA4G;AAC5G,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,4HAA4H;IAC5H,yDAAW,CAAA;AACb,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */\nexport enum ConnectionMode {\n /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */\n Gateway = 0,\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts new file mode 100644 index 000000000..696b31774 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts @@ -0,0 +1,35 @@ +import { RetryOptions } from "../retry/retryOptions"; +import { ConnectionMode } from "./ConnectionMode"; +/** + * Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service. + */ +export interface ConnectionPolicy { + /** Determines which mode to connect to Cosmos with. (Currently only supports Gateway option) */ + connectionMode?: ConnectionMode; + /** Request timeout (time to wait for response from network peer). Represented in milliseconds. */ + requestTimeout?: number; + /** + * Flag to enable/disable automatic redirecting of requests based on read/write operations. Default true. + * Required to call client.dispose() when this is set to true after destroying the CosmosClient inside another process or in the browser. + */ + enableEndpointDiscovery?: boolean; + /** List of azure regions to be used as preferred locations for read requests. */ + preferredLocations?: string[]; + /** RetryOptions object which defines several configurable properties used during retry. */ + retryOptions?: RetryOptions; + /** + * The flag that enables writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. + * Default is `false`. + */ + useMultipleWriteLocations?: boolean; + /** Rate in milliseconds at which the client will refresh the endpoints list in the background */ + endpointRefreshRateInMs?: number; + /** Flag to enable/disable background refreshing of endpoints. Defaults to false. + * Endpoint discovery using `enableEndpointsDiscovery` will still work for failed requests. */ + enableBackgroundEndpointRefreshing?: boolean; +} +/** + * @hidden + */ +export declare const defaultConnectionPolicy: ConnectionPolicy; +//# sourceMappingURL=ConnectionPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts.map new file mode 100644 index 000000000..2f08b29dc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ConnectionPolicy.d.ts","sourceRoot":"","sources":["../../../src/documents/ConnectionPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gGAAgG;IAChG,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,kGAAkG;IAClG,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iFAAiF;IACjF,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,2FAA2F;IAC3F,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,iGAAiG;IACjG,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC;kGAC8F;IAC9F,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAapC,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js new file mode 100644 index 000000000..17707a043 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js @@ -0,0 +1,19 @@ +import { ConnectionMode } from "./ConnectionMode"; +/** + * @hidden + */ +export const defaultConnectionPolicy = Object.freeze({ + connectionMode: ConnectionMode.Gateway, + requestTimeout: 60000, + enableEndpointDiscovery: true, + preferredLocations: [], + retryOptions: { + maxRetryAttemptCount: 9, + fixedRetryIntervalInMilliseconds: 0, + maxWaitTimeInSeconds: 30, + }, + useMultipleWriteLocations: true, + endpointRefreshRateInMs: 300000, + enableBackgroundEndpointRefreshing: true, +}); +//# sourceMappingURL=ConnectionPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js.map new file mode 100644 index 000000000..e770a140d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConnectionPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ConnectionPolicy.js","sourceRoot":"","sources":["../../../src/documents/ConnectionPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA8BlD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqB,MAAM,CAAC,MAAM,CAAC;IACrE,cAAc,EAAE,cAAc,CAAC,OAAO;IACtC,cAAc,EAAE,KAAK;IACrB,uBAAuB,EAAE,IAAI;IAC7B,kBAAkB,EAAE,EAAE;IACtB,YAAY,EAAE;QACZ,oBAAoB,EAAE,CAAC;QACvB,gCAAgC,EAAE,CAAC;QACnC,oBAAoB,EAAE,EAAE;KACzB;IACD,yBAAyB,EAAE,IAAI;IAC/B,uBAAuB,EAAE,MAAM;IAC/B,kCAAkC,EAAE,IAAI;CACzC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { RetryOptions } from \"../retry/retryOptions\";\nimport { ConnectionMode } from \"./ConnectionMode\";\n/**\n * Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service.\n */\nexport interface ConnectionPolicy {\n /** Determines which mode to connect to Cosmos with. (Currently only supports Gateway option) */\n connectionMode?: ConnectionMode;\n /** Request timeout (time to wait for response from network peer). Represented in milliseconds. */\n requestTimeout?: number;\n /**\n * Flag to enable/disable automatic redirecting of requests based on read/write operations. Default true.\n * Required to call client.dispose() when this is set to true after destroying the CosmosClient inside another process or in the browser.\n */\n enableEndpointDiscovery?: boolean;\n /** List of azure regions to be used as preferred locations for read requests. */\n preferredLocations?: string[];\n /** RetryOptions object which defines several configurable properties used during retry. */\n retryOptions?: RetryOptions;\n /**\n * The flag that enables writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.\n * Default is `false`.\n */\n useMultipleWriteLocations?: boolean;\n /** Rate in milliseconds at which the client will refresh the endpoints list in the background */\n endpointRefreshRateInMs?: number;\n /** Flag to enable/disable background refreshing of endpoints. Defaults to false.\n * Endpoint discovery using `enableEndpointsDiscovery` will still work for failed requests. */\n enableBackgroundEndpointRefreshing?: boolean;\n}\n\n/**\n * @hidden\n */\nexport const defaultConnectionPolicy: ConnectionPolicy = Object.freeze({\n connectionMode: ConnectionMode.Gateway,\n requestTimeout: 60000,\n enableEndpointDiscovery: true,\n preferredLocations: [],\n retryOptions: {\n maxRetryAttemptCount: 9,\n fixedRetryIntervalInMilliseconds: 0,\n maxWaitTimeInSeconds: 30,\n },\n useMultipleWriteLocations: true,\n endpointRefreshRateInMs: 300000,\n enableBackgroundEndpointRefreshing: true,\n});\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts new file mode 100644 index 000000000..6ae59ae77 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts @@ -0,0 +1,37 @@ +/** + * Represents the consistency levels supported for Azure Cosmos DB client operations.
+ * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. + * Consistency levels. + * + * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual. + * + * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels. + */ +export declare enum ConsistencyLevel { + /** + * Strong Consistency guarantees that read operations always return the value that was last written. + */ + Strong = "Strong", + /** + * Bounded Staleness guarantees that reads are not too out-of-date. + * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds). + */ + BoundedStaleness = "BoundedStaleness", + /** + * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), + * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads) + * within any single session. + */ + Session = "Session", + /** + * Eventual Consistency guarantees that reads will return a subset of writes. + * All writes will be eventually be available for reads. + */ + Eventual = "Eventual", + /** + * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. + * All writes will be eventually be available for reads. + */ + ConsistentPrefix = "ConsistentPrefix" +} +//# sourceMappingURL=ConsistencyLevel.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts.map new file mode 100644 index 000000000..c123c257f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ConsistencyLevel.d.ts","sourceRoot":"","sources":["../../../src/documents/ConsistencyLevel.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,oBAAY,gBAAgB;IAC1B;;OAEG;IACH,MAAM,WAAW;IACjB;;;OAGG;IACH,gBAAgB,qBAAqB;IACrC;;;;OAIG;IACH,OAAO,YAAY;IACnB;;;OAGG;IACH,QAAQ,aAAa;IACrB;;;OAGG;IACH,gBAAgB,qBAAqB;CACtC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js new file mode 100644 index 000000000..99701fe56 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Represents the consistency levels supported for Azure Cosmos DB client operations.
+ * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. + * Consistency levels. + * + * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual. + * + * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels. + */ +export var ConsistencyLevel; +(function (ConsistencyLevel) { + /** + * Strong Consistency guarantees that read operations always return the value that was last written. + */ + ConsistencyLevel["Strong"] = "Strong"; + /** + * Bounded Staleness guarantees that reads are not too out-of-date. + * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds). + */ + ConsistencyLevel["BoundedStaleness"] = "BoundedStaleness"; + /** + * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), + * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads) + * within any single session. + */ + ConsistencyLevel["Session"] = "Session"; + /** + * Eventual Consistency guarantees that reads will return a subset of writes. + * All writes will be eventually be available for reads. + */ + ConsistencyLevel["Eventual"] = "Eventual"; + /** + * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. + * All writes will be eventually be available for reads. + */ + ConsistencyLevel["ConsistentPrefix"] = "ConsistentPrefix"; +})(ConsistencyLevel || (ConsistencyLevel = {})); +//# sourceMappingURL=ConsistencyLevel.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js.map new file mode 100644 index 000000000..0d9817329 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/ConsistencyLevel.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ConsistencyLevel.js","sourceRoot":"","sources":["../../../src/documents/ConsistencyLevel.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;;;;;;GAQG;AACH,MAAM,CAAN,IAAY,gBA0BX;AA1BD,WAAY,gBAAgB;IAC1B;;OAEG;IACH,qCAAiB,CAAA;IACjB;;;OAGG;IACH,yDAAqC,CAAA;IACrC;;;;OAIG;IACH,uCAAmB,CAAA;IACnB;;;OAGG;IACH,yCAAqB,CAAA;IACrB;;;OAGG;IACH,yDAAqC,CAAA;AACvC,CAAC,EA1BW,gBAAgB,KAAhB,gBAAgB,QA0B3B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents the consistency levels supported for Azure Cosmos DB client operations.
\n * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account.\n * Consistency levels.\n *\n * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual.\n *\n * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels.\n */\nexport enum ConsistencyLevel {\n /**\n * Strong Consistency guarantees that read operations always return the value that was last written.\n */\n Strong = \"Strong\",\n /**\n * Bounded Staleness guarantees that reads are not too out-of-date.\n * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds).\n */\n BoundedStaleness = \"BoundedStaleness\",\n /**\n * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again),\n * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads)\n * within any single session.\n */\n Session = \"Session\",\n /**\n * Eventual Consistency guarantees that reads will return a subset of writes.\n * All writes will be eventually be available for reads.\n */\n Eventual = \"Eventual\",\n /**\n * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps.\n * All writes will be eventually be available for reads.\n */\n ConsistentPrefix = \"ConsistentPrefix\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts new file mode 100644 index 000000000..6090711ff --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts @@ -0,0 +1,16 @@ +/** Defines a target data type of an index path specification in the Azure Cosmos DB service. */ +export declare enum DataType { + /** Represents a numeric data type. */ + Number = "Number", + /** Represents a string data type. */ + String = "String", + /** Represents a point data type. */ + Point = "Point", + /** Represents a line string data type. */ + LineString = "LineString", + /** Represents a polygon data type. */ + Polygon = "Polygon", + /** Represents a multi-polygon data type. */ + MultiPolygon = "MultiPolygon" +} +//# sourceMappingURL=DataType.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts.map new file mode 100644 index 000000000..5f5f4cfcb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DataType.d.ts","sourceRoot":"","sources":["../../../src/documents/DataType.ts"],"names":[],"mappings":"AAEA,gGAAgG;AAChG,oBAAY,QAAQ;IAClB,sCAAsC;IACtC,MAAM,WAAW;IACjB,qCAAqC;IACrC,MAAM,WAAW;IACjB,oCAAoC;IACpC,KAAK,UAAU;IACf,0CAA0C;IAC1C,UAAU,eAAe;IACzB,sCAAsC;IACtC,OAAO,YAAY;IACnB,4CAA4C;IAC5C,YAAY,iBAAiB;CAC9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js new file mode 100644 index 000000000..516361437 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** Defines a target data type of an index path specification in the Azure Cosmos DB service. */ +export var DataType; +(function (DataType) { + /** Represents a numeric data type. */ + DataType["Number"] = "Number"; + /** Represents a string data type. */ + DataType["String"] = "String"; + /** Represents a point data type. */ + DataType["Point"] = "Point"; + /** Represents a line string data type. */ + DataType["LineString"] = "LineString"; + /** Represents a polygon data type. */ + DataType["Polygon"] = "Polygon"; + /** Represents a multi-polygon data type. */ + DataType["MultiPolygon"] = "MultiPolygon"; +})(DataType || (DataType = {})); +//# sourceMappingURL=DataType.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js.map new file mode 100644 index 000000000..8682dbddc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DataType.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DataType.js","sourceRoot":"","sources":["../../../src/documents/DataType.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,gGAAgG;AAChG,MAAM,CAAN,IAAY,QAaX;AAbD,WAAY,QAAQ;IAClB,sCAAsC;IACtC,6BAAiB,CAAA;IACjB,qCAAqC;IACrC,6BAAiB,CAAA;IACjB,oCAAoC;IACpC,2BAAe,CAAA;IACf,0CAA0C;IAC1C,qCAAyB,CAAA;IACzB,sCAAsC;IACtC,+BAAmB,CAAA;IACnB,4CAA4C;IAC5C,yCAA6B,CAAA;AAC/B,CAAC,EAbW,QAAQ,KAAR,QAAQ,QAanB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** Defines a target data type of an index path specification in the Azure Cosmos DB service. */\nexport enum DataType {\n /** Represents a numeric data type. */\n Number = \"Number\",\n /** Represents a string data type. */\n String = \"String\",\n /** Represents a point data type. */\n Point = \"Point\",\n /** Represents a line string data type. */\n LineString = \"LineString\",\n /** Represents a polygon data type. */\n Polygon = \"Polygon\",\n /** Represents a multi-polygon data type. */\n MultiPolygon = \"MultiPolygon\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts new file mode 100644 index 000000000..a354a8074 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts @@ -0,0 +1,69 @@ +import { CosmosHeaders } from "../queryExecutionContext"; +import { ConsistencyLevel } from "./ConsistencyLevel"; +/** + * Represents a DatabaseAccount in the Azure Cosmos DB database service. + */ +export declare class DatabaseAccount { + /** The list of writable locations for a geo-replicated database account. */ + readonly writableLocations: Location[]; + /** The list of readable locations for a geo-replicated database account. */ + readonly readableLocations: Location[]; + /** + * The self-link for Databases in the databaseAccount. + * @deprecated Use `databasesLink` + */ + get DatabasesLink(): string; + /** The self-link for Databases in the databaseAccount. */ + readonly databasesLink: string; + /** + * The self-link for Media in the databaseAccount. + * @deprecated Use `mediaLink` + */ + get MediaLink(): string; + /** The self-link for Media in the databaseAccount. */ + readonly mediaLink: string; + /** + * Attachment content (media) storage quota in MBs ( Retrieved from gateway ). + * @deprecated use `maxMediaStorageUsageInMB` + */ + get MaxMediaStorageUsageInMB(): number; + /** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */ + readonly maxMediaStorageUsageInMB: number; + /** + * Current attachment content (media) usage in MBs (Retrieved from gateway ) + * + * Value is returned from cached information updated periodically and is not guaranteed + * to be real time. + * + * @deprecated use `currentMediaStorageUsageInMB` + */ + get CurrentMediaStorageUsageInMB(): number; + /** + * Current attachment content (media) usage in MBs (Retrieved from gateway ) + * + * Value is returned from cached information updated periodically and is not guaranteed + * to be real time. + */ + readonly currentMediaStorageUsageInMB: number; + /** + * Gets the UserConsistencyPolicy settings. + * @deprecated use `consistencyPolicy` + */ + get ConsistencyPolicy(): ConsistencyLevel; + /** Gets the UserConsistencyPolicy settings. */ + readonly consistencyPolicy: ConsistencyLevel; + readonly enableMultipleWritableLocations: boolean; + constructor(body: { + [key: string]: any; + }, headers: CosmosHeaders); +} +/** + * Used to specify the locations that are available, read is index 1 and write is index 0. + */ +export interface Location { + name: string; + databaseAccountEndpoint: string; + unavailable?: boolean; + lastUnavailabilityTimestampInMs?: number; +} +//# sourceMappingURL=DatabaseAccount.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts.map new file mode 100644 index 000000000..fc379cab9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseAccount.d.ts","sourceRoot":"","sources":["../../../src/documents/DatabaseAccount.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,qBAAa,eAAe;IAC1B,4EAA4E;IAC5E,SAAgB,iBAAiB,EAAE,QAAQ,EAAE,CAAM;IACnD,4EAA4E;IAC5E,SAAgB,iBAAiB,EAAE,QAAQ,EAAE,CAAM;IACnD;;;OAGG;IACH,IAAW,aAAa,IAAI,MAAM,CAEjC;IACD,0DAA0D;IAC1D,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC;;;OAGG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IACD,sDAAsD;IACtD,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,IAAW,wBAAwB,IAAI,MAAM,CAE5C;IACD,kFAAkF;IAClF,SAAgB,wBAAwB,EAAE,MAAM,CAAC;IACjD;;;;;;;OAOG;IACH,IAAW,4BAA4B,IAAI,MAAM,CAEhD;IACD;;;;;OAKG;IACH,SAAgB,4BAA4B,EAAE,MAAM,CAAC;IACrD;;;OAGG;IACH,IAAW,iBAAiB,IAAI,gBAAgB,CAE/C;IACD,+CAA+C;IAC/C,SAAgB,iBAAiB,EAAE,gBAAgB,CAAC;IACpD,SAAgB,+BAA+B,EAAE,OAAO,CAAC;gBAGtC,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,OAAO,EAAE,aAAa;CAoBxE;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB,EAAE,MAAM,CAAC;IAChC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+BAA+B,CAAC,EAAE,MAAM,CAAC;CAC1C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js new file mode 100644 index 000000000..301ac1084 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js @@ -0,0 +1,74 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants } from "../common"; +import { ConsistencyLevel } from "./ConsistencyLevel"; +/** + * Represents a DatabaseAccount in the Azure Cosmos DB database service. + */ +export class DatabaseAccount { + /** + * The self-link for Databases in the databaseAccount. + * @deprecated Use `databasesLink` + */ + get DatabasesLink() { + return this.databasesLink; + } + /** + * The self-link for Media in the databaseAccount. + * @deprecated Use `mediaLink` + */ + get MediaLink() { + return this.mediaLink; + } + /** + * Attachment content (media) storage quota in MBs ( Retrieved from gateway ). + * @deprecated use `maxMediaStorageUsageInMB` + */ + get MaxMediaStorageUsageInMB() { + return this.maxMediaStorageUsageInMB; + } + /** + * Current attachment content (media) usage in MBs (Retrieved from gateway ) + * + * Value is returned from cached information updated periodically and is not guaranteed + * to be real time. + * + * @deprecated use `currentMediaStorageUsageInMB` + */ + get CurrentMediaStorageUsageInMB() { + return this.currentMediaStorageUsageInMB; + } + /** + * Gets the UserConsistencyPolicy settings. + * @deprecated use `consistencyPolicy` + */ + get ConsistencyPolicy() { + return this.consistencyPolicy; + } + // TODO: body - any + constructor(body, headers) { + /** The list of writable locations for a geo-replicated database account. */ + this.writableLocations = []; + /** The list of readable locations for a geo-replicated database account. */ + this.readableLocations = []; + this.databasesLink = "/dbs/"; + this.mediaLink = "/media/"; + this.maxMediaStorageUsageInMB = headers[Constants.HttpHeaders.MaxMediaStorageUsageInMB]; + this.currentMediaStorageUsageInMB = headers[Constants.HttpHeaders.CurrentMediaStorageUsageInMB]; + this.consistencyPolicy = body.userConsistencyPolicy + ? body.userConsistencyPolicy.defaultConsistencyLevel + : ConsistencyLevel.Session; + if (body[Constants.WritableLocations] && body.id !== "localhost") { + this.writableLocations = body[Constants.WritableLocations]; + } + if (body[Constants.ReadableLocations] && body.id !== "localhost") { + this.readableLocations = body[Constants.ReadableLocations]; + } + if (body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS]) { + this.enableMultipleWritableLocations = + body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === true || + body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === "true"; + } + } +} +//# sourceMappingURL=DatabaseAccount.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js.map new file mode 100644 index 000000000..63e4f78c0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/DatabaseAccount.js.map @@ -0,0 +1 @@ +{"version":3,"file":"DatabaseAccount.js","sourceRoot":"","sources":["../../../src/documents/DatabaseAccount.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,eAAe;IA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AE,KAAK,WAAW,EAAE;YAChE,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAe,CAAC;SAC1E;QACD,IAAI,IAAI,CAAC,SAAS,CAAC,kCAAkC,CAAC,EAAE;YACtD,IAAI,CAAC,+BAA+B;gBAClC,IAAI,CAAC,SAAS,CAAC,kCAAkC,CAAC,KAAK,IAAI;oBAC3D,IAAI,CAAC,SAAS,CAAC,kCAAkC,CAAC,KAAK,MAAM,CAAC;SACjE;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common\";\nimport { CosmosHeaders } from \"../queryExecutionContext\";\nimport { ConsistencyLevel } from \"./ConsistencyLevel\";\n\n/**\n * Represents a DatabaseAccount in the Azure Cosmos DB database service.\n */\nexport class DatabaseAccount {\n /** The list of writable locations for a geo-replicated database account. */\n public readonly writableLocations: Location[] = [];\n /** The list of readable locations for a geo-replicated database account. */\n public readonly readableLocations: Location[] = [];\n /**\n * The self-link for Databases in the databaseAccount.\n * @deprecated Use `databasesLink`\n */\n public get DatabasesLink(): string {\n return this.databasesLink;\n }\n /** The self-link for Databases in the databaseAccount. */\n public readonly databasesLink: string;\n /**\n * The self-link for Media in the databaseAccount.\n * @deprecated Use `mediaLink`\n */\n public get MediaLink(): string {\n return this.mediaLink;\n }\n /** The self-link for Media in the databaseAccount. */\n public readonly mediaLink: string;\n /**\n * Attachment content (media) storage quota in MBs ( Retrieved from gateway ).\n * @deprecated use `maxMediaStorageUsageInMB`\n */\n public get MaxMediaStorageUsageInMB(): number {\n return this.maxMediaStorageUsageInMB;\n }\n /** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */\n public readonly maxMediaStorageUsageInMB: number;\n /**\n * Current attachment content (media) usage in MBs (Retrieved from gateway )\n *\n * Value is returned from cached information updated periodically and is not guaranteed\n * to be real time.\n *\n * @deprecated use `currentMediaStorageUsageInMB`\n */\n public get CurrentMediaStorageUsageInMB(): number {\n return this.currentMediaStorageUsageInMB;\n }\n /**\n * Current attachment content (media) usage in MBs (Retrieved from gateway )\n *\n * Value is returned from cached information updated periodically and is not guaranteed\n * to be real time.\n */\n public readonly currentMediaStorageUsageInMB: number;\n /**\n * Gets the UserConsistencyPolicy settings.\n * @deprecated use `consistencyPolicy`\n */\n public get ConsistencyPolicy(): ConsistencyLevel {\n return this.consistencyPolicy;\n }\n /** Gets the UserConsistencyPolicy settings. */\n public readonly consistencyPolicy: ConsistencyLevel;\n public readonly enableMultipleWritableLocations: boolean;\n\n // TODO: body - any\n public constructor(body: { [key: string]: any }, headers: CosmosHeaders) {\n this.databasesLink = \"/dbs/\";\n this.mediaLink = \"/media/\";\n this.maxMediaStorageUsageInMB = headers[Constants.HttpHeaders.MaxMediaStorageUsageInMB];\n this.currentMediaStorageUsageInMB = headers[Constants.HttpHeaders.CurrentMediaStorageUsageInMB];\n this.consistencyPolicy = body.userConsistencyPolicy\n ? (body.userConsistencyPolicy.defaultConsistencyLevel as ConsistencyLevel)\n : ConsistencyLevel.Session;\n if (body[Constants.WritableLocations] && body.id !== \"localhost\") {\n this.writableLocations = body[Constants.WritableLocations] as Location[];\n }\n if (body[Constants.ReadableLocations] && body.id !== \"localhost\") {\n this.readableLocations = body[Constants.ReadableLocations] as Location[];\n }\n if (body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS]) {\n this.enableMultipleWritableLocations =\n body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === true ||\n body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === \"true\";\n }\n }\n}\n\n/**\n * Used to specify the locations that are available, read is index 1 and write is index 0.\n */\nexport interface Location {\n name: string;\n databaseAccountEndpoint: string;\n unavailable?: boolean;\n lastUnavailabilityTimestampInMs?: number;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts new file mode 100644 index 000000000..870e3f31f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts @@ -0,0 +1,4 @@ +export interface Document { + [key: string]: any; +} +//# sourceMappingURL=Document.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts.map new file mode 100644 index 000000000..e16e796ca --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../../src/documents/Document.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js new file mode 100644 index 000000000..5ec9a6392 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=Document.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js.map new file mode 100644 index 000000000..e9692e49c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/Document.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Document.js","sourceRoot":"","sources":["../../../src/documents/Document.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface Document {\n [key: string]: any;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts new file mode 100644 index 000000000..bd961cfc3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts @@ -0,0 +1,7 @@ +export declare enum GeospatialType { + /** Represents data in round-earth coordinate system. */ + Geography = "Geography", + /** Represents data in Eucledian(flat) coordinate system. */ + Geometry = "Geometry" +} +//# sourceMappingURL=GeospatialType.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts.map new file mode 100644 index 000000000..e7b17ccff --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"GeospatialType.d.ts","sourceRoot":"","sources":["../../../src/documents/GeospatialType.ts"],"names":[],"mappings":"AAGA,oBAAY,cAAc;IACxB,wDAAwD;IACxD,SAAS,cAAc;IACvB,4DAA4D;IAC5D,QAAQ,aAAa;CACtB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js new file mode 100644 index 000000000..53fdbd932 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export var GeospatialType; +(function (GeospatialType) { + /** Represents data in round-earth coordinate system. */ + GeospatialType["Geography"] = "Geography"; + /** Represents data in Eucledian(flat) coordinate system. */ + GeospatialType["Geometry"] = "Geometry"; +})(GeospatialType || (GeospatialType = {})); +//# sourceMappingURL=GeospatialType.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js.map new file mode 100644 index 000000000..f4ec1b4a4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/GeospatialType.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GeospatialType.js","sourceRoot":"","sources":["../../../src/documents/GeospatialType.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,wDAAwD;IACxD,yCAAuB,CAAA;IACvB,4DAA4D;IAC5D,uCAAqB,CAAA;AACvB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport enum GeospatialType {\n /** Represents data in round-earth coordinate system. */\n Geography = \"Geography\",\n /** Represents data in Eucledian(flat) coordinate system. */\n Geometry = \"Geometry\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts new file mode 100644 index 000000000..96a3c469f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts @@ -0,0 +1,14 @@ +/** + * Specifies the supported Index types. + */ +export declare enum IndexKind { + /** + * This is supplied for a path which requires sorting. + */ + Range = "Range", + /** + * This is supplied for a path which requires geospatial indexing. + */ + Spatial = "Spatial" +} +//# sourceMappingURL=IndexKind.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts.map new file mode 100644 index 000000000..3baa4787d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexKind.d.ts","sourceRoot":"","sources":["../../../src/documents/IndexKind.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,SAAS;IACnB;;OAEG;IACH,KAAK,UAAU;IACf;;OAEG;IACH,OAAO,YAAY;CACpB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js new file mode 100644 index 000000000..a23dc4889 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Specifies the supported Index types. + */ +export var IndexKind; +(function (IndexKind) { + /** + * This is supplied for a path which requires sorting. + */ + IndexKind["Range"] = "Range"; + /** + * This is supplied for a path which requires geospatial indexing. + */ + IndexKind["Spatial"] = "Spatial"; +})(IndexKind || (IndexKind = {})); +//# sourceMappingURL=IndexKind.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js.map new file mode 100644 index 000000000..33936e405 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexKind.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexKind.js","sourceRoot":"","sources":["../../../src/documents/IndexKind.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;GAEG;AACH,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB;;OAEG;IACH,4BAAe,CAAA;IACf;;OAEG;IACH,gCAAmB,CAAA;AACrB,CAAC,EATW,SAAS,KAAT,SAAS,QASpB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Specifies the supported Index types.\n */\nexport enum IndexKind {\n /**\n * This is supplied for a path which requires sorting.\n */\n Range = \"Range\",\n /**\n * This is supplied for a path which requires geospatial indexing.\n */\n Spatial = \"Spatial\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts new file mode 100644 index 000000000..080eb8085 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts @@ -0,0 +1,21 @@ +/** + * Specifies the supported indexing modes. + */ +export declare enum IndexingMode { + /** + * Index is updated synchronously with a create or update operation. + * + * With consistent indexing, query behavior is the same as the default consistency level for the container. + * The index is always kept up to date with the data. + */ + consistent = "consistent", + /** + * Index is updated asynchronously with respect to a create or update operation. + * + * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle. + */ + lazy = "lazy", + /** No Index is provided. */ + none = "none" +} +//# sourceMappingURL=IndexingMode.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts.map new file mode 100644 index 000000000..1ed4154fa --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexingMode.d.ts","sourceRoot":"","sources":["../../../src/documents/IndexingMode.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,YAAY;IACtB;;;;;OAKG;IACH,UAAU,eAAe;IACzB;;;;OAIG;IACH,IAAI,SAAS;IACb,4BAA4B;IAC5B,IAAI,SAAS;CACd"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js new file mode 100644 index 000000000..74c3a39ef --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Specifies the supported indexing modes. + */ +export var IndexingMode; +(function (IndexingMode) { + /** + * Index is updated synchronously with a create or update operation. + * + * With consistent indexing, query behavior is the same as the default consistency level for the container. + * The index is always kept up to date with the data. + */ + IndexingMode["consistent"] = "consistent"; + /** + * Index is updated asynchronously with respect to a create or update operation. + * + * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle. + */ + IndexingMode["lazy"] = "lazy"; + /** No Index is provided. */ + IndexingMode["none"] = "none"; +})(IndexingMode || (IndexingMode = {})); +//# sourceMappingURL=IndexingMode.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js.map new file mode 100644 index 000000000..c2c18ad5f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingMode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexingMode.js","sourceRoot":"","sources":["../../../src/documents/IndexingMode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;GAEG;AACH,MAAM,CAAN,IAAY,YAgBX;AAhBD,WAAY,YAAY;IACtB;;;;;OAKG;IACH,yCAAyB,CAAA;IACzB;;;;OAIG;IACH,6BAAa,CAAA;IACb,4BAA4B;IAC5B,6BAAa,CAAA;AACf,CAAC,EAhBW,YAAY,KAAZ,YAAY,QAgBvB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Specifies the supported indexing modes.\n */\nexport enum IndexingMode {\n /**\n * Index is updated synchronously with a create or update operation.\n *\n * With consistent indexing, query behavior is the same as the default consistency level for the container.\n * The index is always kept up to date with the data.\n */\n consistent = \"consistent\",\n /**\n * Index is updated asynchronously with respect to a create or update operation.\n *\n * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle.\n */\n lazy = \"lazy\",\n /** No Index is provided. */\n none = \"none\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts new file mode 100644 index 000000000..291b65573 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts @@ -0,0 +1,55 @@ +import { DataType, IndexingMode, IndexKind } from "./index"; +export interface IndexingPolicy { + /** The indexing mode (consistent or lazy) {@link IndexingMode}. */ + indexingMode?: keyof typeof IndexingMode; + automatic?: boolean; + /** An array of {@link IncludedPath} represents the paths to be included for indexing. */ + includedPaths?: IndexedPath[]; + /** An array of {@link IncludedPath} represents the paths to be excluded for indexing. */ + excludedPaths?: IndexedPath[]; + spatialIndexes?: SpatialIndex[]; + /** An array of {@link VectorIndex} represents the vector index paths to be included for indexing. */ + vectorIndexes?: VectorIndex[]; +} +export declare enum SpatialType { + LineString = "LineString", + MultiPolygon = "MultiPolygon", + Point = "Point", + Polygon = "Polygon" +} +export interface SpatialIndex { + path: string; + types: SpatialType[]; + boundingBox: { + xmin: number; + ymin: number; + xmax: number; + ymax: number; + }; +} +export interface IndexedPath { + path: string; + indexes?: Index[]; +} +export interface Index { + kind: keyof typeof IndexKind; + dataType: keyof typeof DataType; + precision?: number; +} +/** + * Represents a vector index in the Azure Cosmos DB service. + * A vector index is used to index vector fields in the documents. + */ +export interface VectorIndex { + /** + * The path to the vector field in the document. + * for example, path: "/path/to/vector". + */ + path: string; + /** + * The index type of the vector. + * Currently, flat, diskANN, and quantizedFlat are supported. + */ + type: "flat" | "diskANN" | "quantizedFlat"; +} +//# sourceMappingURL=IndexingPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts.map new file mode 100644 index 000000000..125e92ff2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexingPolicy.d.ts","sourceRoot":"","sources":["../../../src/documents/IndexingPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,OAAO,YAAY,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yFAAyF;IACzF,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,yFAAyF;IACzF,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,YAAY,EAAE,CAAC;IAChC,qGAAqG;IACrG,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;CAC/B;AAGD,oBAAY,WAAW;IACrB,UAAU,eAAe;IACzB,YAAY,iBAAiB;IAC7B,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,YAAY;IAE3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,WAAW,EAAE,CAAC;IAErB,WAAW,EAAE;QAEX,IAAI,EAAE,MAAM,CAAC;QAEb,IAAI,EAAE,MAAM,CAAC;QAEb,IAAI,EAAE,MAAM,CAAC;QAEb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,OAAO,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,OAAO,QAAQ,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,eAAe,CAAC;CAC5C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js new file mode 100644 index 000000000..06feeb20b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js @@ -0,0 +1,9 @@ +/* The target data type of a spatial path */ +export var SpatialType; +(function (SpatialType) { + SpatialType["LineString"] = "LineString"; + SpatialType["MultiPolygon"] = "MultiPolygon"; + SpatialType["Point"] = "Point"; + SpatialType["Polygon"] = "Polygon"; +})(SpatialType || (SpatialType = {})); +//# sourceMappingURL=IndexingPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js.map new file mode 100644 index 000000000..f9172cea1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/IndexingPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexingPolicy.js","sourceRoot":"","sources":["../../../src/documents/IndexingPolicy.ts"],"names":[],"mappings":"AAiBA,4CAA4C;AAC5C,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,wCAAyB,CAAA;IACzB,4CAA6B,CAAA;IAC7B,8BAAe,CAAA;IACf,kCAAmB,CAAA;AACrB,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DataType, IndexingMode, IndexKind } from \"./index\";\n\nexport interface IndexingPolicy {\n /** The indexing mode (consistent or lazy) {@link IndexingMode}. */\n indexingMode?: keyof typeof IndexingMode;\n automatic?: boolean;\n /** An array of {@link IncludedPath} represents the paths to be included for indexing. */\n includedPaths?: IndexedPath[];\n /** An array of {@link IncludedPath} represents the paths to be excluded for indexing. */\n excludedPaths?: IndexedPath[];\n spatialIndexes?: SpatialIndex[];\n /** An array of {@link VectorIndex} represents the vector index paths to be included for indexing. */\n vectorIndexes?: VectorIndex[];\n}\n\n/* The target data type of a spatial path */\nexport enum SpatialType {\n LineString = \"LineString\",\n MultiPolygon = \"MultiPolygon\",\n Point = \"Point\",\n Polygon = \"Polygon\",\n}\n\nexport interface SpatialIndex {\n /* Path in JSON document to index */\n path: string;\n types: SpatialType[];\n /* Bounding box for geometry spatial path */\n boundingBox: {\n /* X-coordinate of the lower-left corner of the bounding box. */\n xmin: number;\n /* Y-coordinate of the lower-left corner of the bounding box. */\n ymin: number;\n /* X-coordinate of the upper-right corner of the bounding box. */\n xmax: number;\n /* Y-coordinate of the upper-right corner of the bounding box. */\n ymax: number;\n };\n}\n\nexport interface IndexedPath {\n path: string;\n indexes?: Index[];\n}\n\nexport interface Index {\n kind: keyof typeof IndexKind;\n dataType: keyof typeof DataType;\n precision?: number;\n}\n/**\n * Represents a vector index in the Azure Cosmos DB service.\n * A vector index is used to index vector fields in the documents.\n */\nexport interface VectorIndex {\n /**\n * The path to the vector field in the document.\n * for example, path: \"/path/to/vector\".\n */\n path: string;\n /**\n * The index type of the vector.\n * Currently, flat, diskANN, and quantizedFlat are supported.\n */\n type: \"flat\" | \"diskANN\" | \"quantizedFlat\";\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts new file mode 100644 index 000000000..019312f81 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts @@ -0,0 +1,34 @@ +/** + * PartitionKey of a container. + * @remarks + * - PartitionKeyDefinition is no longer part of PartitionKey. So please use PartitionKeyDefinition + * type directly where appropriate. + */ +export type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[]; +/** + * A primitive Partition Key value. + */ +export type PrimitivePartitionKeyValue = string | number | boolean | NullPartitionKeyType | NonePartitionKeyType; +/** + * The returned object represents a partition key value that allows creating and accessing items + * with a null value for the partition key. + */ +export type NullPartitionKeyType = null; +/** + * The returned object represents a partition key value that allows creating and accessing items + * without a value for partition key + */ +export type NonePartitionKeyType = { + [K in any]: never; +}; +/** + * Builder class for building PartitionKey. + */ +export declare class PartitionKeyBuilder { + readonly values: PrimitivePartitionKeyValue[]; + addValue(value: string | boolean | number): PartitionKeyBuilder; + addNullValue(): PartitionKeyBuilder; + addNoneValue(): PartitionKeyBuilder; + build(): PartitionKey; +} +//# sourceMappingURL=PartitionKey.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts.map new file mode 100644 index 000000000..2c2ac4c05 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKey.d.ts","sourceRoot":"","sources":["../../../src/documents/PartitionKey.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,0BAA0B,GAAG,0BAA0B,EAAE,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,MAAM,GACN,MAAM,GACN,OAAO,GACP,oBAAoB,GACpB,oBAAoB,CAAC;AAEzB;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG;KAChC,CAAC,IAAI,GAAG,GAAG,KAAK;CAClB,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,QAAQ,CAAC,MAAM,EAAE,0BAA0B,EAAE,CAAM;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,mBAAmB;IAI/D,YAAY,IAAI,mBAAmB;IAInC,YAAY,IAAI,mBAAmB;IAInC,KAAK,IAAI,YAAY;CAG7B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js new file mode 100644 index 000000000..95c78980d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from "./PartitionKeyInternal"; +/** + * Builder class for building PartitionKey. + */ +export class PartitionKeyBuilder { + constructor() { + this.values = []; + } + addValue(value) { + this.values.push(value); + return this; + } + addNullValue() { + this.values.push(NullPartitionKeyLiteral); + return this; + } + addNoneValue() { + this.values.push(NonePartitionKeyLiteral); + return this; + } + build() { + return [...this.values]; + } +} +//# sourceMappingURL=PartitionKey.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js.map new file mode 100644 index 000000000..2b90b1bd4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKey.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKey.js","sourceRoot":"","sources":["../../../src/documents/PartitionKey.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,uBAAuB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAkC1F;;GAEG;AACH,MAAM,OAAO,mBAAmB;IAAhC;QACW,WAAM,GAAiC,EAAE,CAAC;IAgBrD,CAAC;IAfQ,QAAQ,CAAC,KAAgC;QAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACM,YAAY;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IACM,YAAY;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IACM,KAAK;QACV,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from \"./PartitionKeyInternal\";\n\n/**\n * PartitionKey of a container.\n * @remarks\n * - PartitionKeyDefinition is no longer part of PartitionKey. So please use PartitionKeyDefinition\n * type directly where appropriate.\n */\nexport type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[];\n\n/**\n * A primitive Partition Key value.\n */\nexport type PrimitivePartitionKeyValue =\n | string\n | number\n | boolean\n | NullPartitionKeyType\n | NonePartitionKeyType;\n\n/**\n * The returned object represents a partition key value that allows creating and accessing items\n * with a null value for the partition key.\n */\nexport type NullPartitionKeyType = null;\n\n/**\n * The returned object represents a partition key value that allows creating and accessing items\n * without a value for partition key\n */\nexport type NonePartitionKeyType = {\n [K in any]: never;\n};\n\n/**\n * Builder class for building PartitionKey.\n */\nexport class PartitionKeyBuilder {\n readonly values: PrimitivePartitionKeyValue[] = [];\n public addValue(value: string | boolean | number): PartitionKeyBuilder {\n this.values.push(value);\n return this;\n }\n public addNullValue(): PartitionKeyBuilder {\n this.values.push(NullPartitionKeyLiteral);\n return this;\n }\n public addNoneValue(): PartitionKeyBuilder {\n this.values.push(NonePartitionKeyLiteral);\n return this;\n }\n public build(): PartitionKey {\n return [...this.values];\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts new file mode 100644 index 000000000..86bff6f8d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts @@ -0,0 +1,21 @@ +import { PartitionKeyDefinitionVersion } from "./PartitionKeyDefinitionVersion"; +import { PartitionKeyKind } from "./PartitionKeyKind"; +export interface PartitionKeyDefinition { + /** + * An array of paths for which data within the collection can be partitioned. Paths must not contain a wildcard or + * a trailing slash. For example, the JSON property “AccountNumber” is specified as “/AccountNumber”. The array must + * contain only a single value. + */ + paths: string[]; + /** + * An optional field, if not specified the default value is 1. To use the large partition key set the version to 2. + * To learn about large partition keys, see [how to create containers with large partition key](https://docs.microsoft.com/en-us/azure/cosmos-db/large-partition-keys) article. + */ + version?: PartitionKeyDefinitionVersion; + systemKey?: boolean; + /** + * What kind of partition key is being defined (default: "Hash") + */ + kind?: PartitionKeyKind; +} +//# sourceMappingURL=PartitionKeyDefinition.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts.map new file mode 100644 index 000000000..9f39ff7f5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyDefinition.d.ts","sourceRoot":"","sources":["../../../src/documents/PartitionKeyDefinition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,6BAA6B,CAAC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,IAAI,CAAC,EAAE,gBAAgB,CAAC;CACzB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js new file mode 100644 index 000000000..95dbe1830 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=PartitionKeyDefinition.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js.map new file mode 100644 index 000000000..e4261ee3e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinition.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyDefinition.js","sourceRoot":"","sources":["../../../src/documents/PartitionKeyDefinition.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKeyDefinitionVersion } from \"./PartitionKeyDefinitionVersion\";\nimport { PartitionKeyKind } from \"./PartitionKeyKind\";\n\nexport interface PartitionKeyDefinition {\n /**\n * An array of paths for which data within the collection can be partitioned. Paths must not contain a wildcard or\n * a trailing slash. For example, the JSON property “AccountNumber” is specified as “/AccountNumber”. The array must\n * contain only a single value.\n */\n paths: string[];\n /**\n * An optional field, if not specified the default value is 1. To use the large partition key set the version to 2.\n * To learn about large partition keys, see [how to create containers with large partition key](https://docs.microsoft.com/en-us/azure/cosmos-db/large-partition-keys) article.\n */\n version?: PartitionKeyDefinitionVersion;\n systemKey?: boolean;\n /**\n * What kind of partition key is being defined (default: \"Hash\")\n */\n kind?: PartitionKeyKind;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts new file mode 100644 index 000000000..4fa8a0fed --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts @@ -0,0 +1,8 @@ +/** + * PartitionKey Definition Version + */ +export declare enum PartitionKeyDefinitionVersion { + V1 = 1, + V2 = 2 +} +//# sourceMappingURL=PartitionKeyDefinitionVersion.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts.map new file mode 100644 index 000000000..dbf2cfc34 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyDefinitionVersion.d.ts","sourceRoot":"","sources":["../../../src/documents/PartitionKeyDefinitionVersion.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,6BAA6B;IACvC,EAAE,IAAI;IACN,EAAE,IAAI;CACP"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js new file mode 100644 index 000000000..ae44ae51e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * PartitionKey Definition Version + */ +export var PartitionKeyDefinitionVersion; +(function (PartitionKeyDefinitionVersion) { + PartitionKeyDefinitionVersion[PartitionKeyDefinitionVersion["V1"] = 1] = "V1"; + PartitionKeyDefinitionVersion[PartitionKeyDefinitionVersion["V2"] = 2] = "V2"; +})(PartitionKeyDefinitionVersion || (PartitionKeyDefinitionVersion = {})); +//# sourceMappingURL=PartitionKeyDefinitionVersion.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js.map new file mode 100644 index 000000000..82b181d69 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyDefinitionVersion.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyDefinitionVersion.js","sourceRoot":"","sources":["../../../src/documents/PartitionKeyDefinitionVersion.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;GAEG;AACH,MAAM,CAAN,IAAY,6BAGX;AAHD,WAAY,6BAA6B;IACvC,6EAAM,CAAA;IACN,6EAAM,CAAA;AACR,CAAC,EAHW,6BAA6B,KAA7B,6BAA6B,QAGxC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * PartitionKey Definition Version\n */\nexport enum PartitionKeyDefinitionVersion {\n V1 = 1,\n V2 = 2,\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts new file mode 100644 index 000000000..544887d1e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts @@ -0,0 +1,24 @@ +import { NonePartitionKeyType, NullPartitionKeyType, PartitionKey, PrimitivePartitionKeyValue } from "./PartitionKey"; +/** + * @hidden + * Internal Representation Of Partition Key. TODO: Make sure {@link ClientContext} working with only {@link PartitionKeyInternal} + */ +export type PartitionKeyInternal = PrimitivePartitionKeyValue[]; +/** + * @hidden + * None PartitionKey Literal + */ +export declare const NonePartitionKeyLiteral: NonePartitionKeyType; +/** + * @hidden + * Null PartitionKey Literal + */ +export declare const NullPartitionKeyLiteral: NullPartitionKeyType; +/** + * @hidden + * Maps PartitionKey to InternalPartitionKey. + * @param partitionKey - PartitonKey to be converted. + * @returns PartitionKeyInternal + */ +export declare function convertToInternalPartitionKey(partitionKey: PartitionKey): PartitionKeyInternal; +//# sourceMappingURL=PartitionKeyInternal.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts.map new file mode 100644 index 000000000..63d93a6c4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyInternal.d.ts","sourceRoot":"","sources":["../../../src/documents/PartitionKeyInternal.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,EAAE,CAAC;AAChE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,oBAAyB,CAAC;AAChE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,oBAA2B,CAAC;AAClE;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,YAAY,GAAG,oBAAoB,CAI9F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js new file mode 100644 index 000000000..1afe1f392 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * None PartitionKey Literal + */ +export const NonePartitionKeyLiteral = {}; +/** + * @hidden + * Null PartitionKey Literal + */ +export const NullPartitionKeyLiteral = null; +/** + * @hidden + * Maps PartitionKey to InternalPartitionKey. + * @param partitionKey - PartitonKey to be converted. + * @returns PartitionKeyInternal + */ +export function convertToInternalPartitionKey(partitionKey) { + if (Array.isArray(partitionKey)) { + return partitionKey.map((key) => (key === undefined ? NonePartitionKeyLiteral : key)); + } + else + return [partitionKey]; +} +//# sourceMappingURL=PartitionKeyInternal.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js.map new file mode 100644 index 000000000..b9b7dd42b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyInternal.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyInternal.js","sourceRoot":"","sources":["../../../src/documents/PartitionKeyInternal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAclC;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAyB,EAAE,CAAC;AAChE;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAyB,IAAI,CAAC;AAClE;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,YAA0B;IACtE,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;QAC/B,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KACvF;;QAAM,OAAO,CAAC,YAAY,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NonePartitionKeyType,\n NullPartitionKeyType,\n PartitionKey,\n PrimitivePartitionKeyValue,\n} from \"./PartitionKey\";\n\n/**\n * @hidden\n * Internal Representation Of Partition Key. TODO: Make sure {@link ClientContext} working with only {@link PartitionKeyInternal}\n */\nexport type PartitionKeyInternal = PrimitivePartitionKeyValue[];\n/**\n * @hidden\n * None PartitionKey Literal\n */\nexport const NonePartitionKeyLiteral: NonePartitionKeyType = {};\n/**\n * @hidden\n * Null PartitionKey Literal\n */\nexport const NullPartitionKeyLiteral: NullPartitionKeyType = null;\n/**\n * @hidden\n * Maps PartitionKey to InternalPartitionKey.\n * @param partitionKey - PartitonKey to be converted.\n * @returns PartitionKeyInternal\n */\nexport function convertToInternalPartitionKey(partitionKey: PartitionKey): PartitionKeyInternal {\n if (Array.isArray(partitionKey)) {\n return partitionKey.map((key) => (key === undefined ? NonePartitionKeyLiteral : key));\n } else return [partitionKey];\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts new file mode 100644 index 000000000..25e2cc4ef --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts @@ -0,0 +1,8 @@ +/** + * Type of PartitionKey i.e. Hash, MultiHash + */ +export declare enum PartitionKeyKind { + Hash = "Hash", + MultiHash = "MultiHash" +} +//# sourceMappingURL=PartitionKeyKind.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts.map new file mode 100644 index 000000000..393e5916c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyKind.d.ts","sourceRoot":"","sources":["../../../src/documents/PartitionKeyKind.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,gBAAgB;IAC1B,IAAI,SAAS;IACb,SAAS,cAAc;CACxB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js new file mode 100644 index 000000000..29f3433e1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Type of PartitionKey i.e. Hash, MultiHash + */ +export var PartitionKeyKind; +(function (PartitionKeyKind) { + PartitionKeyKind["Hash"] = "Hash"; + PartitionKeyKind["MultiHash"] = "MultiHash"; +})(PartitionKeyKind || (PartitionKeyKind = {})); +//# sourceMappingURL=PartitionKeyKind.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js.map new file mode 100644 index 000000000..71a23c0e4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PartitionKeyKind.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PartitionKeyKind.js","sourceRoot":"","sources":["../../../src/documents/PartitionKeyKind.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;GAEG;AACH,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,iCAAa,CAAA;IACb,2CAAuB,CAAA;AACzB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Type of PartitionKey i.e. Hash, MultiHash\n */\nexport enum PartitionKeyKind {\n Hash = \"Hash\",\n MultiHash = \"MultiHash\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts new file mode 100644 index 000000000..bc1724aab --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts @@ -0,0 +1,12 @@ +/** + * Enum for permission mode values. + */ +export declare enum PermissionMode { + /** Permission not valid. */ + None = "none", + /** Permission applicable for read operations only. */ + Read = "read", + /** Permission applicable for all operations. */ + All = "all" +} +//# sourceMappingURL=PermissionMode.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts.map new file mode 100644 index 000000000..6d01d4a39 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionMode.d.ts","sourceRoot":"","sources":["../../../src/documents/PermissionMode.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,cAAc;IACxB,4BAA4B;IAC5B,IAAI,SAAS;IACb,sDAAsD;IACtD,IAAI,SAAS;IACb,gDAAgD;IAChD,GAAG,QAAQ;CACZ"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js new file mode 100644 index 000000000..0a5ab9ce6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for permission mode values. + */ +export var PermissionMode; +(function (PermissionMode) { + /** Permission not valid. */ + PermissionMode["None"] = "none"; + /** Permission applicable for read operations only. */ + PermissionMode["Read"] = "read"; + /** Permission applicable for all operations. */ + PermissionMode["All"] = "all"; +})(PermissionMode || (PermissionMode = {})); +//# sourceMappingURL=PermissionMode.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js.map new file mode 100644 index 000000000..5834cd413 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PermissionMode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PermissionMode.js","sourceRoot":"","sources":["../../../src/documents/PermissionMode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;GAEG;AACH,MAAM,CAAN,IAAY,cAOX;AAPD,WAAY,cAAc;IACxB,4BAA4B;IAC5B,+BAAa,CAAA;IACb,sDAAsD;IACtD,+BAAa,CAAA;IACb,gDAAgD;IAChD,6BAAW,CAAA;AACb,CAAC,EAPW,cAAc,KAAd,cAAc,QAOzB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for permission mode values.\n */\nexport enum PermissionMode {\n /** Permission not valid. */\n None = \"none\",\n /** Permission applicable for read operations only. */\n Read = \"read\",\n /** Permission applicable for all operations. */\n All = \"all\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts new file mode 100644 index 000000000..e840cd232 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts @@ -0,0 +1,19 @@ +/** + * Represents Priority Level associated with each Azure Cosmos DB client requests.
+ * The Low priority requests are always throttled before any High priority requests. + * + * By default all requests are considered as High priority requests. + * + * See https://aka.ms/CosmosDB/PriorityBasedExecution for more detailed documentation on Priority based throttling. + */ +export declare enum PriorityLevel { + /** + * High Priority requests are throttled after Low priority requests. + */ + High = "High", + /** + * Low Priority requests are throttled before High priority requests. + */ + Low = "Low" +} +//# sourceMappingURL=PriorityLevel.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts.map new file mode 100644 index 000000000..af6840602 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"PriorityLevel.d.ts","sourceRoot":"","sources":["../../../src/documents/PriorityLevel.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,oBAAY,aAAa;IACvB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,GAAG,QAAQ;CACZ"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js new file mode 100644 index 000000000..3699c879b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Represents Priority Level associated with each Azure Cosmos DB client requests.
+ * The Low priority requests are always throttled before any High priority requests. + * + * By default all requests are considered as High priority requests. + * + * See https://aka.ms/CosmosDB/PriorityBasedExecution for more detailed documentation on Priority based throttling. + */ +export var PriorityLevel; +(function (PriorityLevel) { + /** + * High Priority requests are throttled after Low priority requests. + */ + PriorityLevel["High"] = "High"; + /** + * Low Priority requests are throttled before High priority requests. + */ + PriorityLevel["Low"] = "Low"; +})(PriorityLevel || (PriorityLevel = {})); +//# sourceMappingURL=PriorityLevel.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js.map new file mode 100644 index 000000000..0101e1c6f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/PriorityLevel.js.map @@ -0,0 +1 @@ +{"version":3,"file":"PriorityLevel.js","sourceRoot":"","sources":["../../../src/documents/PriorityLevel.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,aASX;AATD,WAAY,aAAa;IACvB;;OAEG;IACH,8BAAa,CAAA;IACb;;OAEG;IACH,4BAAW,CAAA;AACb,CAAC,EATW,aAAa,KAAb,aAAa,QASxB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents Priority Level associated with each Azure Cosmos DB client requests.
\n * The Low priority requests are always throttled before any High priority requests.\n *\n * By default all requests are considered as High priority requests.\n *\n * See https://aka.ms/CosmosDB/PriorityBasedExecution for more detailed documentation on Priority based throttling.\n */\nexport enum PriorityLevel {\n /**\n * High Priority requests are throttled after Low priority requests.\n */\n High = \"High\",\n /**\n * Low Priority requests are throttled before High priority requests.\n */\n Low = \"Low\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts new file mode 100644 index 000000000..576a119d7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts @@ -0,0 +1,17 @@ +/** + * Enum for trigger operation values. + * specifies the operations on which a trigger should be executed. + */ +export declare enum TriggerOperation { + /** All operations. */ + All = "all", + /** Create operations only. */ + Create = "create", + /** Update operations only. */ + Update = "update", + /** Delete operations only. */ + Delete = "delete", + /** Replace operations only. */ + Replace = "replace" +} +//# sourceMappingURL=TriggerOperation.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts.map new file mode 100644 index 000000000..347386307 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerOperation.d.ts","sourceRoot":"","sources":["../../../src/documents/TriggerOperation.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,sBAAsB;IACtB,GAAG,QAAQ;IACX,8BAA8B;IAC9B,MAAM,WAAW;IACjB,8BAA8B;IAC9B,MAAM,WAAW;IACjB,8BAA8B;IAC9B,MAAM,WAAW;IACjB,+BAA+B;IAC/B,OAAO,YAAY;CACpB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js new file mode 100644 index 000000000..aa3078c21 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for trigger operation values. + * specifies the operations on which a trigger should be executed. + */ +export var TriggerOperation; +(function (TriggerOperation) { + /** All operations. */ + TriggerOperation["All"] = "all"; + /** Create operations only. */ + TriggerOperation["Create"] = "create"; + /** Update operations only. */ + TriggerOperation["Update"] = "update"; + /** Delete operations only. */ + TriggerOperation["Delete"] = "delete"; + /** Replace operations only. */ + TriggerOperation["Replace"] = "replace"; +})(TriggerOperation || (TriggerOperation = {})); +//# sourceMappingURL=TriggerOperation.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js.map new file mode 100644 index 000000000..cd7f375bd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerOperation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerOperation.js","sourceRoot":"","sources":["../../../src/documents/TriggerOperation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAWX;AAXD,WAAY,gBAAgB;IAC1B,sBAAsB;IACtB,+BAAW,CAAA;IACX,8BAA8B;IAC9B,qCAAiB,CAAA;IACjB,8BAA8B;IAC9B,qCAAiB,CAAA;IACjB,8BAA8B;IAC9B,qCAAiB,CAAA;IACjB,+BAA+B;IAC/B,uCAAmB,CAAA;AACrB,CAAC,EAXW,gBAAgB,KAAhB,gBAAgB,QAW3B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for trigger operation values.\n * specifies the operations on which a trigger should be executed.\n */\nexport enum TriggerOperation {\n /** All operations. */\n All = \"all\",\n /** Create operations only. */\n Create = \"create\",\n /** Update operations only. */\n Update = \"update\",\n /** Delete operations only. */\n Delete = \"delete\",\n /** Replace operations only. */\n Replace = \"replace\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts new file mode 100644 index 000000000..076495060 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts @@ -0,0 +1,11 @@ +/** + * Enum for trigger type values. + * Specifies the type of the trigger. + */ +export declare enum TriggerType { + /** Trigger should be executed before the associated operation(s). */ + Pre = "pre", + /** Trigger should be executed after the associated operation(s). */ + Post = "post" +} +//# sourceMappingURL=TriggerType.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts.map new file mode 100644 index 000000000..00e78ae97 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerType.d.ts","sourceRoot":"","sources":["../../../src/documents/TriggerType.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,oBAAY,WAAW;IACrB,qEAAqE;IACrE,GAAG,QAAQ;IACX,oEAAoE;IACpE,IAAI,SAAS;CACd"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js new file mode 100644 index 000000000..e336f5c42 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for trigger type values. + * Specifies the type of the trigger. + */ +export var TriggerType; +(function (TriggerType) { + /** Trigger should be executed before the associated operation(s). */ + TriggerType["Pre"] = "pre"; + /** Trigger should be executed after the associated operation(s). */ + TriggerType["Post"] = "post"; +})(TriggerType || (TriggerType = {})); +//# sourceMappingURL=TriggerType.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js.map new file mode 100644 index 000000000..f8084bcc9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/TriggerType.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TriggerType.js","sourceRoot":"","sources":["../../../src/documents/TriggerType.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AACH,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,qEAAqE;IACrE,0BAAW,CAAA;IACX,oEAAoE;IACpE,4BAAa,CAAA;AACf,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for trigger type values.\n * Specifies the type of the trigger.\n */\nexport enum TriggerType {\n /** Trigger should be executed before the associated operation(s). */\n Pre = \"pre\",\n /** Trigger should be executed after the associated operation(s). */\n Post = \"post\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts new file mode 100644 index 000000000..9c5aa274b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts @@ -0,0 +1,9 @@ +/** + * Enum for udf type values. + * Specifies the types of user defined functions. + */ +export declare enum UserDefinedFunctionType { + /** The User Defined Function is written in JavaScript. This is currently the only option. */ + Javascript = "Javascript" +} +//# sourceMappingURL=UserDefinedFunctionType.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts.map new file mode 100644 index 000000000..6e18d4588 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctionType.d.ts","sourceRoot":"","sources":["../../../src/documents/UserDefinedFunctionType.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,oBAAY,uBAAuB;IACjC,6FAA6F;IAC7F,UAAU,eAAe;CAC1B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js new file mode 100644 index 000000000..a16d5e48d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for udf type values. + * Specifies the types of user defined functions. + */ +export var UserDefinedFunctionType; +(function (UserDefinedFunctionType) { + /** The User Defined Function is written in JavaScript. This is currently the only option. */ + UserDefinedFunctionType["Javascript"] = "Javascript"; +})(UserDefinedFunctionType || (UserDefinedFunctionType = {})); +//# sourceMappingURL=UserDefinedFunctionType.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js.map new file mode 100644 index 000000000..849ba2954 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/UserDefinedFunctionType.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UserDefinedFunctionType.js","sourceRoot":"","sources":["../../../src/documents/UserDefinedFunctionType.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;GAGG;AACH,MAAM,CAAN,IAAY,uBAGX;AAHD,WAAY,uBAAuB;IACjC,6FAA6F;IAC7F,oDAAyB,CAAA;AAC3B,CAAC,EAHW,uBAAuB,KAAvB,uBAAuB,QAGlC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for udf type values.\n * Specifies the types of user defined functions.\n */\nexport enum UserDefinedFunctionType {\n /** The User Defined Function is written in JavaScript. This is currently the only option. */\n Javascript = \"Javascript\",\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts new file mode 100644 index 000000000..961346457 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts @@ -0,0 +1,32 @@ +/** + * Represents the policy configuration for vector embeddings in the Azure Cosmos DB service. + */ +export interface VectorEmbeddingPolicy { + /** + * The vector embeddings to be configured. + */ + vectorEmbeddings: VectorEmbedding[]; +} +/** + * Represents a vector embedding. + * A vector embedding is used to define a vector field in the documents. + */ +export interface VectorEmbedding { + /** + * The path to the vector field in the document. + */ + path: string; + /** + * The number of dimensions in the vector. + */ + dimensions: number; + /** + * The data type of the vector. + */ + dataType: "float16" | "float32" | "uint8" | "int8"; + /** + * The distance function to use for distance calculation in between vectors. + */ + distanceFunction: "euclidean" | "cosine" | "dotproduct"; +} +//# sourceMappingURL=VectorEmbeddingPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts.map new file mode 100644 index 000000000..84e886c0d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"VectorEmbeddingPolicy.d.ts","sourceRoot":"","sources":["../../../src/documents/VectorEmbeddingPolicy.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,gBAAgB,EAAE,eAAe,EAAE,CAAC;CACrC;AACD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACnD;;OAEG;IACH,gBAAgB,EAAE,WAAW,GAAG,QAAQ,GAAG,YAAY,CAAC;CACzD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js new file mode 100644 index 000000000..fcc44e5e0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=VectorEmbeddingPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js.map new file mode 100644 index 000000000..d0f4d47a9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/VectorEmbeddingPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"VectorEmbeddingPolicy.js","sourceRoot":"","sources":["../../../src/documents/VectorEmbeddingPolicy.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents the policy configuration for vector embeddings in the Azure Cosmos DB service.\n */\nexport interface VectorEmbeddingPolicy {\n /**\n * The vector embeddings to be configured.\n */\n vectorEmbeddings: VectorEmbedding[];\n}\n/**\n * Represents a vector embedding.\n * A vector embedding is used to define a vector field in the documents.\n */\nexport interface VectorEmbedding {\n /**\n * The path to the vector field in the document.\n */\n path: string;\n /**\n * The number of dimensions in the vector.\n */\n dimensions: number;\n /**\n * The data type of the vector.\n */\n dataType: \"float16\" | \"float32\" | \"uint8\" | \"int8\";\n /**\n * The distance function to use for distance calculation in between vectors.\n */\n distanceFunction: \"euclidean\" | \"cosine\" | \"dotproduct\";\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts new file mode 100644 index 000000000..943b1f09d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts @@ -0,0 +1,22 @@ +export * from "./ConnectionMode"; +export * from "./ConnectionPolicy"; +export * from "./ConsistencyLevel"; +export * from "./DatabaseAccount"; +export * from "./DataType"; +export * from "./Document"; +export * from "./IndexingMode"; +export * from "./IndexingPolicy"; +export * from "./IndexKind"; +export * from "./PartitionKey"; +export * from "./PartitionKeyInternal"; +export * from "./PartitionKeyDefinitionVersion"; +export * from "./PartitionKeyKind"; +export * from "./PartitionKeyDefinition"; +export * from "./PermissionMode"; +export * from "./PriorityLevel"; +export * from "./TriggerOperation"; +export * from "./TriggerType"; +export * from "./UserDefinedFunctionType"; +export * from "./GeospatialType"; +export * from "./VectorEmbeddingPolicy"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts.map new file mode 100644 index 000000000..d4efcf1d8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/documents/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js new file mode 100644 index 000000000..d88af02a6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export * from "./ConnectionMode"; +export * from "./ConnectionPolicy"; +export * from "./ConsistencyLevel"; +export * from "./DatabaseAccount"; +export * from "./DataType"; +export * from "./Document"; +export * from "./IndexingMode"; +export * from "./IndexingPolicy"; +export * from "./IndexKind"; +export * from "./PartitionKey"; +export * from "./PartitionKeyInternal"; +export * from "./PartitionKeyDefinitionVersion"; +export * from "./PartitionKeyKind"; +export * from "./PartitionKeyDefinition"; +export * from "./PermissionMode"; +export * from "./PriorityLevel"; +export * from "./TriggerOperation"; +export * from "./TriggerType"; +export * from "./UserDefinedFunctionType"; +export * from "./GeospatialType"; +export * from "./VectorEmbeddingPolicy"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js.map new file mode 100644 index 000000000..a4dd9585b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/documents/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/documents/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./ConnectionMode\";\nexport * from \"./ConnectionPolicy\";\nexport * from \"./ConsistencyLevel\";\nexport * from \"./DatabaseAccount\";\nexport * from \"./DataType\";\nexport * from \"./Document\";\nexport * from \"./IndexingMode\";\nexport * from \"./IndexingPolicy\";\nexport * from \"./IndexKind\";\nexport * from \"./PartitionKey\";\nexport * from \"./PartitionKeyInternal\";\nexport * from \"./PartitionKeyDefinitionVersion\";\nexport * from \"./PartitionKeyKind\";\nexport * from \"./PartitionKeyDefinition\";\nexport * from \"./PermissionMode\";\nexport * from \"./PriorityLevel\";\nexport * from \"./TriggerOperation\";\nexport * from \"./TriggerType\";\nexport * from \"./UserDefinedFunctionType\";\nexport * from \"./GeospatialType\";\nexport * from \"./VectorEmbeddingPolicy\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts new file mode 100644 index 000000000..67596c231 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts @@ -0,0 +1,16 @@ +import { PartitionKeyDefinition, PartitionKeyInternal } from "./documents"; +/** + * Function to extract PartitionKey based on {@link PartitionKeyDefinition} + * from an object. + * Retuns + * 1. PartitionKeyInternal[] if extraction is successful. + * 2. undefined if either {@link partitionKeyDefinition} is not well formed + * or an unsupported partitionkey type is encountered. + * @hidden + */ +export declare function extractPartitionKeys(document: unknown, partitionKeyDefinition?: PartitionKeyDefinition): PartitionKeyInternal | undefined; +/** + * @hidden + */ +export declare function undefinedPartitionKey(partitionKeyDefinition: PartitionKeyDefinition): PartitionKeyInternal; +//# sourceMappingURL=extractPartitionKey.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts.map new file mode 100644 index 000000000..0295fe3f1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"extractPartitionKey.d.ts","sourceRoot":"","sources":["../../src/extractPartitionKey.ts"],"names":[],"mappings":"AAIA,OAAO,EAGL,sBAAsB,EACtB,oBAAoB,EAErB,MAAM,aAAa,CAAC;AAKrB;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,OAAO,EACjB,sBAAsB,CAAC,EAAE,sBAAsB,GAC9C,oBAAoB,GAAG,SAAS,CA8BlC;AAsBD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,sBAAsB,EAAE,sBAAsB,GAC7C,oBAAoB,CAMtB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js new file mode 100644 index 000000000..1765d40dc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createClientLogger } from "@azure/logger"; +import { parsePath } from "./common"; +import { NonePartitionKeyLiteral, NullPartitionKeyLiteral, } from "./documents"; +import { DEFAULT_PARTITION_KEY_PATH } from "./common/partitionKeys"; +const logger = createClientLogger("extractPartitionKey"); +/** + * Function to extract PartitionKey based on {@link PartitionKeyDefinition} + * from an object. + * Retuns + * 1. PartitionKeyInternal[] if extraction is successful. + * 2. undefined if either {@link partitionKeyDefinition} is not well formed + * or an unsupported partitionkey type is encountered. + * @hidden + */ +export function extractPartitionKeys(document, partitionKeyDefinition) { + if (partitionKeyDefinition && + partitionKeyDefinition.paths && + partitionKeyDefinition.paths.length > 0) { + if (partitionKeyDefinition.systemKey === true) { + return []; + } + if (partitionKeyDefinition.paths.length === 1 && + partitionKeyDefinition.paths[0] === DEFAULT_PARTITION_KEY_PATH) { + return [extractPartitionKey(DEFAULT_PARTITION_KEY_PATH, document)]; + } + const partitionKeys = []; + partitionKeyDefinition.paths.forEach((path) => { + const obj = extractPartitionKey(path, document); + if (obj === undefined) { + logger.warning("Unsupported PartitionKey found."); + return undefined; + } + partitionKeys.push(obj); + }); + return partitionKeys; + } + logger.error("Unexpected Partition Key Definition Found."); + return undefined; +} +function extractPartitionKey(path, obj) { + const pathParts = parsePath(path); + for (const part of pathParts) { + if (typeof obj === "object" && obj !== null && part in obj) { + obj = obj[part]; + } + else { + obj = undefined; + break; + } + } + if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean") { + return obj; + } + else if (obj === NullPartitionKeyLiteral) { + return NullPartitionKeyLiteral; + } + else if (obj === undefined || JSON.stringify(obj) === JSON.stringify(NonePartitionKeyLiteral)) { + return NonePartitionKeyLiteral; + } + return undefined; +} +/** + * @hidden + */ +export function undefinedPartitionKey(partitionKeyDefinition) { + if (partitionKeyDefinition.systemKey === true) { + return []; + } + else { + return partitionKeyDefinition.paths.map(() => NonePartitionKeyLiteral); + } +} +//# sourceMappingURL=extractPartitionKey.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js.map new file mode 100644 index 000000000..a637bff11 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/extractPartitionKey.js.map @@ -0,0 +1 @@ +{"version":3,"file":"extractPartitionKey.js","sourceRoot":"","sources":["../../src/extractPartitionKey.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAe,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,uBAAuB,EACvB,uBAAuB,GAIxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEpE,MAAM,MAAM,GAAgB,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;AAEtE;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAiB,EACjB,sBAA+C;IAE/C,IACE,sBAAsB;QACtB,sBAAsB,CAAC,KAAK;QAC5B,sBAAsB,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EACvC;QACA,IAAI,sBAAsB,CAAC,SAAS,KAAK,IAAI,EAAE;YAC7C,OAAO,EAAE,CAAC;SACX;QAED,IACE,sBAAsB,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;YACzC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,0BAA0B,EAC9D;YACA,OAAO,CAAC,mBAAmB,CAAC,0BAA0B,EAAE,QAAQ,CAAC,CAAC,CAAC;SACpE;QAED,MAAM,aAAa,GAAiC,EAAE,CAAC;QACvD,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;YACpD,MAAM,GAAG,GAAG,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAChD,IAAI,GAAG,KAAK,SAAS,EAAE;gBACrB,MAAM,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAC;gBAClD,OAAO,SAAS,CAAC;aAClB;YACD,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;QACH,OAAO,aAAa,CAAC;KACtB;IACD,MAAM,CAAC,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAC3D,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY,EAAE,GAAY;IACrD,MAAM,SAAS,GAAa,SAAS,CAAC,IAAI,CAAC,CAAC;IAC5C,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC5B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,EAAE;YAC1D,GAAG,GAAI,GAA+B,CAAC,IAAI,CAAC,CAAC;SAC9C;aAAM;YACL,GAAG,GAAG,SAAS,CAAC;YAChB,MAAM;SACP;KACF;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,SAAS,EAAE;QAClF,OAAO,GAAG,CAAC;KACZ;SAAM,IAAI,GAAG,KAAK,uBAAuB,EAAE;QAC1C,OAAO,uBAAuB,CAAC;KAChC;SAAM,IAAI,GAAG,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,EAAE;QAC/F,OAAO,uBAAuB,CAAC;KAChC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,sBAA8C;IAE9C,IAAI,sBAAsB,CAAC,SAAS,KAAK,IAAI,EAAE;QAC7C,OAAO,EAAE,CAAC;KACX;SAAM;QACL,OAAO,sBAAsB,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,CAAC;KACxE;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { parsePath } from \"./common\";\nimport {\n NonePartitionKeyLiteral,\n NullPartitionKeyLiteral,\n PartitionKeyDefinition,\n PartitionKeyInternal,\n PrimitivePartitionKeyValue,\n} from \"./documents\";\nimport { DEFAULT_PARTITION_KEY_PATH } from \"./common/partitionKeys\";\n\nconst logger: AzureLogger = createClientLogger(\"extractPartitionKey\");\n\n/**\n * Function to extract PartitionKey based on {@link PartitionKeyDefinition}\n * from an object.\n * Retuns\n * 1. PartitionKeyInternal[] if extraction is successful.\n * 2. undefined if either {@link partitionKeyDefinition} is not well formed\n * or an unsupported partitionkey type is encountered.\n * @hidden\n */\nexport function extractPartitionKeys(\n document: unknown,\n partitionKeyDefinition?: PartitionKeyDefinition,\n): PartitionKeyInternal | undefined {\n if (\n partitionKeyDefinition &&\n partitionKeyDefinition.paths &&\n partitionKeyDefinition.paths.length > 0\n ) {\n if (partitionKeyDefinition.systemKey === true) {\n return [];\n }\n\n if (\n partitionKeyDefinition.paths.length === 1 &&\n partitionKeyDefinition.paths[0] === DEFAULT_PARTITION_KEY_PATH\n ) {\n return [extractPartitionKey(DEFAULT_PARTITION_KEY_PATH, document)];\n }\n\n const partitionKeys: PrimitivePartitionKeyValue[] = [];\n partitionKeyDefinition.paths.forEach((path: string) => {\n const obj = extractPartitionKey(path, document);\n if (obj === undefined) {\n logger.warning(\"Unsupported PartitionKey found.\");\n return undefined;\n }\n partitionKeys.push(obj);\n });\n return partitionKeys;\n }\n logger.error(\"Unexpected Partition Key Definition Found.\");\n return undefined;\n}\n\nfunction extractPartitionKey(path: string, obj: unknown): any {\n const pathParts: string[] = parsePath(path);\n for (const part of pathParts) {\n if (typeof obj === \"object\" && obj !== null && part in obj) {\n obj = (obj as Record)[part];\n } else {\n obj = undefined;\n break;\n }\n }\n if (typeof obj === \"string\" || typeof obj === \"number\" || typeof obj === \"boolean\") {\n return obj;\n } else if (obj === NullPartitionKeyLiteral) {\n return NullPartitionKeyLiteral;\n } else if (obj === undefined || JSON.stringify(obj) === JSON.stringify(NonePartitionKeyLiteral)) {\n return NonePartitionKeyLiteral;\n }\n return undefined;\n}\n\n/**\n * @hidden\n */\nexport function undefinedPartitionKey(\n partitionKeyDefinition: PartitionKeyDefinition,\n): PartitionKeyInternal {\n if (partitionKeyDefinition.systemKey === true) {\n return [];\n } else {\n return partitionKeyDefinition.paths.map(() => NonePartitionKeyLiteral);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts new file mode 100644 index 000000000..43309d118 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts @@ -0,0 +1,73 @@ +import { OperationType, ResourceType } from "./common"; +import { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; +/** + * @hidden + * This internal class implements the logic for endpoint management for geo-replicated database accounts. + */ +export declare class GlobalEndpointManager { + private readDatabaseAccount; + /** + * The endpoint used to create the client instance. + */ + private defaultEndpoint; + /** + * Flag to enable/disable automatic redirecting of requests based on read/write operations. + */ + enableEndpointDiscovery: boolean; + private isRefreshing; + private options; + /** + * List of azure regions to be used as preferred locations for read requests. + */ + private preferredLocations; + private writeableLocations; + private readableLocations; + private unavailableReadableLocations; + private unavailableWriteableLocations; + preferredLocationsCount: number; + /** + * Gets the current read endpoint from the endpoint cache. + */ + getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + /** + * Gets the current write endpoint from the endpoint cache. + */ + getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + getReadEndpoints(): Promise>; + getWriteEndpoints(): Promise>; + markCurrentLocationUnavailableForRead(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise; + markCurrentLocationUnavailableForWrite(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise; + canUseMultipleWriteLocations(resourceType?: ResourceType, operationType?: OperationType): boolean; + resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number): Promise; + /** + * Refreshes the endpoint list by clearning stale unavailability and then + * retrieving the writable and readable locations from the geo-replicated database account + * and then updating the locations cache. + * We skip the refreshing if enableEndpointDiscovery is set to False + */ + refreshEndpointList(diagnosticNode: DiagnosticNodeInternal): Promise; + private refreshEndpoints; + private refreshStaleUnavailableLocations; + /** + * update the locationUnavailability to undefined if the location is available again + * @param now - current time + * @param unavailableLocations - list of unavailable locations + * @param allLocations - list of all locations + */ + private updateLocation; + private cleanUnavailableLocationList; + /** + * Gets the database account first by using the default endpoint, and if that doesn't returns + * use the endpoints for the preferred locations in the order they are specified to get + * the database account. + */ + private getDatabaseAccountFromAnyEndpoint; + /** + * Gets the locational endpoint using the location name passed to it using the default endpoint. + * + * @param defaultEndpoint - The default endpoint to use for the endpoint. + * @param locationName - The location name for the azure region like "East US". + */ + private static getLocationalEndpoint; +} +//# sourceMappingURL=globalEndpointManager.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts.map new file mode 100644 index 000000000..64a529873 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"globalEndpointManager.d.ts","sourceRoot":"","sources":["../../src/globalEndpointManager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,UAAU,CAAC;AAOtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAG9E;;;GAGG;AACH,qBAAa,qBAAqB;IA2B9B,OAAO,CAAC,mBAAmB;IA1B7B;;OAEG;IACH,OAAO,CAAC,eAAe,CAAS;IAChC;;OAEG;IACI,uBAAuB,EAAE,OAAO,CAAC;IACxC,OAAO,CAAC,YAAY,CAAU;IAC9B,OAAO,CAAC,OAAO,CAAsB;IACrC;;OAEG;I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No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js new file mode 100644 index 000000000..590b90784 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js @@ -0,0 +1,260 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { OperationType, ResourceType, isReadRequest } from "./common"; +import { Constants } from "./common/constants"; +import { MetadataLookUpType } from "./CosmosDiagnostics"; +import { withMetadataDiagnostics } from "./utils/diagnostics"; +/** + * @hidden + * This internal class implements the logic for endpoint management for geo-replicated database accounts. + */ +export class GlobalEndpointManager { + /** + * @param options - The document client instance. + * @internal + */ + constructor(options, readDatabaseAccount) { + this.readDatabaseAccount = readDatabaseAccount; + this.writeableLocations = []; + this.readableLocations = []; + this.unavailableReadableLocations = []; + this.unavailableWriteableLocations = []; + this.options = options; + this.defaultEndpoint = options.endpoint; + this.enableEndpointDiscovery = options.connectionPolicy.enableEndpointDiscovery; + this.isRefreshing = false; + this.preferredLocations = this.options.connectionPolicy.preferredLocations; + this.preferredLocationsCount = this.preferredLocations ? this.preferredLocations.length : 0; + } + /** + * Gets the current read endpoint from the endpoint cache. + */ + async getReadEndpoint(diagnosticNode) { + return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Read); + } + /** + * Gets the current write endpoint from the endpoint cache. + */ + async getWriteEndpoint(diagnosticNode) { + return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Replace); + } + async getReadEndpoints() { + return this.readableLocations.map((loc) => loc.databaseAccountEndpoint); + } + async getWriteEndpoints() { + return this.writeableLocations.map((loc) => loc.databaseAccountEndpoint); + } + async markCurrentLocationUnavailableForRead(diagnosticNode, endpoint) { + await this.refreshEndpointList(diagnosticNode); + const location = this.readableLocations.find((loc) => loc.databaseAccountEndpoint === endpoint); + if (location) { + location.unavailable = true; + location.lastUnavailabilityTimestampInMs = Date.now(); + this.unavailableReadableLocations.push(location); + } + } + async markCurrentLocationUnavailableForWrite(diagnosticNode, endpoint) { + await this.refreshEndpointList(diagnosticNode); + const location = this.writeableLocations.find((loc) => loc.databaseAccountEndpoint === endpoint); + if (location) { + location.unavailable = true; + location.lastUnavailabilityTimestampInMs = Date.now(); + this.unavailableWriteableLocations.push(location); + } + } + canUseMultipleWriteLocations(resourceType, operationType) { + let canUse = this.options.connectionPolicy.useMultipleWriteLocations; + if (resourceType) { + canUse = + canUse && + (resourceType === ResourceType.item || + (resourceType === ResourceType.sproc && operationType === OperationType.Execute)); + } + return canUse; + } + async resolveServiceEndpoint(diagnosticNode, resourceType, operationType, startServiceEndpointIndex = 0) { + // If endpoint discovery is disabled, always use the user provided endpoint + if (!this.options.connectionPolicy.enableEndpointDiscovery) { + diagnosticNode.addData({ readFromCache: true }, "default_endpoint"); + diagnosticNode.recordEndpointResolution(this.defaultEndpoint); + return this.defaultEndpoint; + } + // If getting the database account, always use the user provided endpoint + if (resourceType === ResourceType.none) { + diagnosticNode.addData({ readFromCache: true }, "none_resource"); + diagnosticNode.recordEndpointResolution(this.defaultEndpoint); + return this.defaultEndpoint; + } + if (this.readableLocations.length === 0 || this.writeableLocations.length === 0) { + const resourceResponse = await withMetadataDiagnostics(async (metadataNode) => { + return this.readDatabaseAccount(metadataNode, { + urlConnection: this.defaultEndpoint, + }); + }, diagnosticNode, MetadataLookUpType.DatabaseAccountLookUp); + this.writeableLocations = resourceResponse.resource.writableLocations; + this.readableLocations = resourceResponse.resource.readableLocations; + } + const locations = isReadRequest(operationType) + ? this.readableLocations + : this.writeableLocations; + let location; + // If we have preferred locations, try each one in order and use the first available one + if (this.preferredLocations && + this.preferredLocations.length > 0 && + startServiceEndpointIndex < this.preferredLocations.length) { + for (let i = startServiceEndpointIndex; i < this.preferredLocations.length; i++) { + const preferredLocation = this.preferredLocations[i]; + location = locations.find((loc) => loc.unavailable !== true && + normalizeEndpoint(loc.name) === normalizeEndpoint(preferredLocation)); + if (location) { + break; + } + } + } + // If no preferred locations or one did not match, just grab the first one that is available + if (!location) { + const startIndexValid = startServiceEndpointIndex >= 0 && startServiceEndpointIndex < locations.length; + const locationsToSearch = startIndexValid + ? locations.slice(startServiceEndpointIndex) + : locations; + location = locationsToSearch.find((loc) => { + return loc.unavailable !== true; + }); + } + location = location ? location : { name: "", databaseAccountEndpoint: this.defaultEndpoint }; + diagnosticNode.recordEndpointResolution(location.databaseAccountEndpoint); + return location.databaseAccountEndpoint; + } + /** + * Refreshes the endpoint list by clearning stale unavailability and then + * retrieving the writable and readable locations from the geo-replicated database account + * and then updating the locations cache. + * We skip the refreshing if enableEndpointDiscovery is set to False + */ + async refreshEndpointList(diagnosticNode) { + if (!this.isRefreshing && this.enableEndpointDiscovery) { + this.isRefreshing = true; + const databaseAccount = await this.getDatabaseAccountFromAnyEndpoint(diagnosticNode); + if (databaseAccount) { + this.refreshStaleUnavailableLocations(); + this.refreshEndpoints(databaseAccount); + } + this.isRefreshing = false; + } + } + refreshEndpoints(databaseAccount) { + for (const location of databaseAccount.writableLocations) { + const existingLocation = this.writeableLocations.find((loc) => loc.name === location.name); + if (!existingLocation) { + this.writeableLocations.push(location); + } + } + for (const location of databaseAccount.readableLocations) { + const existingLocation = this.readableLocations.find((loc) => loc.name === location.name); + if (!existingLocation) { + this.readableLocations.push(location); + } + } + } + refreshStaleUnavailableLocations() { + const now = Date.now(); + this.updateLocation(now, this.unavailableReadableLocations, this.readableLocations); + this.unavailableReadableLocations = this.cleanUnavailableLocationList(now, this.unavailableReadableLocations); + this.updateLocation(now, this.unavailableWriteableLocations, this.writeableLocations); + this.unavailableWriteableLocations = this.cleanUnavailableLocationList(now, this.unavailableWriteableLocations); + } + /** + * update the locationUnavailability to undefined if the location is available again + * @param now - current time + * @param unavailableLocations - list of unavailable locations + * @param allLocations - list of all locations + */ + updateLocation(now, unavailableLocations, allLocations) { + for (const location of unavailableLocations) { + const unavaialableLocation = allLocations.find((loc) => loc.name === location.name); + if (unavaialableLocation && + now - unavaialableLocation.lastUnavailabilityTimestampInMs > + Constants.LocationUnavailableExpirationTimeInMs) { + unavaialableLocation.unavailable = false; + } + } + } + cleanUnavailableLocationList(now, unavailableLocations) { + return unavailableLocations.filter((loc) => { + if (loc && + now - loc.lastUnavailabilityTimestampInMs >= Constants.LocationUnavailableExpirationTimeInMs) { + return false; + } + return true; + }); + } + /** + * Gets the database account first by using the default endpoint, and if that doesn't returns + * use the endpoints for the preferred locations in the order they are specified to get + * the database account. + */ + async getDatabaseAccountFromAnyEndpoint(diagnosticNode) { + try { + const options = { urlConnection: this.defaultEndpoint }; + const { resource: databaseAccount } = await this.readDatabaseAccount(diagnosticNode, options); + return databaseAccount; + // If for any reason(non - globaldb related), we are not able to get the database + // account from the above call to readDatabaseAccount, + // we would try to get this information from any of the preferred locations that the user + // might have specified (by creating a locational endpoint) + // and keeping eating the exception until we get the database account and return None at the end, + // if we are not able to get that info from any endpoints + } + catch (err) { + // TODO: Tracing + } + if (this.preferredLocations) { + for (const location of this.preferredLocations) { + try { + const locationalEndpoint = GlobalEndpointManager.getLocationalEndpoint(this.defaultEndpoint, location); + const options = { urlConnection: locationalEndpoint }; + const { resource: databaseAccount } = await this.readDatabaseAccount(diagnosticNode, options); + if (databaseAccount) { + return databaseAccount; + } + } + catch (err) { + // TODO: Tracing + } + } + } + } + /** + * Gets the locational endpoint using the location name passed to it using the default endpoint. + * + * @param defaultEndpoint - The default endpoint to use for the endpoint. + * @param locationName - The location name for the azure region like "East US". + */ + static getLocationalEndpoint(defaultEndpoint, locationName) { + // For defaultEndpoint like 'https://contoso.documents.azure.com:443/' parse it to generate URL format + // This defaultEndpoint should be global endpoint(and cannot be a locational endpoint) + // and we agreed to document that + const endpointUrl = new URL(defaultEndpoint); + // hostname attribute in endpointUrl will return 'contoso.documents.azure.com' + if (endpointUrl.hostname) { + const hostnameParts = endpointUrl.hostname.toString().toLowerCase().split("."); + if (hostnameParts) { + // globalDatabaseAccountName will return 'contoso' + const globalDatabaseAccountName = hostnameParts[0]; + // Prepare the locationalDatabaseAccountName as contoso-EastUS for location_name 'East US' + const locationalDatabaseAccountName = globalDatabaseAccountName + "-" + locationName.replace(" ", ""); + // Replace 'contoso' with 'contoso-EastUS' and + // return locationalEndpoint as https://contoso-EastUS.documents.azure.com:443/ + const locationalEndpoint = defaultEndpoint + .toLowerCase() + .replace(globalDatabaseAccountName, locationalDatabaseAccountName); + return locationalEndpoint; + } + } + return null; + } +} +function normalizeEndpoint(endpoint) { + return endpoint.split(" ").join("").toLowerCase(); +} +//# sourceMappingURL=globalEndpointManager.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js.map new file mode 100644 index 000000000..291adc8f4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/globalEndpointManager.js.map @@ -0,0 +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,UAAU,CAAC;AAItE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAE9D;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAqBhC;;;OAGG;IACH,YACE,OAA4B,EACpB,mBAGuC;QAHvC,wBAAmB,GAAnB,mBAAmB,CAGoB;QAfzC,uBAAkB,GAAe,EAAE,CAAC;QACpC,sBAAiB,GAAe,EAAE,CAAC;QACnC,iCAA4B,GAAe,EAAE,CAAC;QAC9C,kCAA6B,GAAe,EAAE,CAAC;QAcrD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,eAAe,GAAG,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BAElE,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;aAC3B;SACF;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAED,SAAS,iBAAiB,CAAC,QAAgB;IACzC,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACpD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OperationType, ResourceType, isReadRequest } from \"./common\";\nimport { CosmosClientOptions } from \"./CosmosClientOptions\";\nimport { Location, DatabaseAccount } from \"./documents\";\nimport { RequestOptions } from \"./index\";\nimport { Constants } from \"./common/constants\";\nimport { ResourceResponse } from \"./request\";\nimport { MetadataLookUpType } from \"./CosmosDiagnostics\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { withMetadataDiagnostics } from \"./utils/diagnostics\";\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\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>,\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 {\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 {\n return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Replace);\n }\n\n public async getReadEndpoints(): Promise> {\n return this.readableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n public async getWriteEndpoints(): Promise> {\n return this.writeableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n public async markCurrentLocationUnavailableForRead(\n diagnosticNode: DiagnosticNodeInternal,\n endpoint: string,\n ): Promise {\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 {\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 = this.options.connectionPolicy.useMultipleWriteLocations;\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 {\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 }\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 {\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 {\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\nfunction normalizeEndpoint(endpoint: string): string {\n return endpoint.split(\" \").join(\"\").toLowerCase();\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts new file mode 100644 index 000000000..f9364ffd7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts @@ -0,0 +1,34 @@ +export { DEFAULT_PARTITION_KEY_PATH } from "./common/partitionKeys"; +export { StatusCodes, StatusCodesType, PartitionKeyRangePropertiesNames } from "./common"; +export { setAuthorizationTokenHeaderUsingMasterKey } from "./auth"; +export { Operation, OperationResponse, BulkOptions, CreateOperation, UpsertOperation, ReplaceOperation, DeleteOperation, ReadOperation, OperationBase, OperationWithItem, OperationInput, BulkOperationType, BulkOperationResponse, CreateOperationInput, UpsertOperationInput, ReplaceOperationInput, ReadOperationInput, DeleteOperationInput, PatchOperationInput, BulkPatchOperation, } from "./utils/batch"; +export { PatchOperation, PatchOperationType, ExistingKeyOperation, RemoveOperation, PatchRequestBody, } from "./utils/patch"; +export { ConnectionMode, ConsistencyLevel, ConnectionPolicy, DatabaseAccount, DataType, Index, IndexedPath, IndexingMode, IndexingPolicy, SpatialIndex, SpatialType, GeospatialType, IndexKind, Location, PartitionKey, PrimitivePartitionKeyValue, NullPartitionKeyType, NonePartitionKeyType, PartitionKeyKind, PartitionKeyDefinition, PartitionKeyDefinitionVersion, PartitionKeyBuilder, PermissionMode, PriorityLevel, TriggerOperation, TriggerType, UserDefinedFunctionType, VectorEmbeddingPolicy, VectorIndex, VectorEmbedding, } from "./documents"; +export { UniqueKeyPolicy, UniqueKey } from "./client/Container/UniqueKeyPolicy"; +export { ContainerRequest } from "./client/Container/ContainerRequest"; +export { Constants, OperationType, ResourceType, HTTPMethod } from "./common"; +export { RetryOptions } from "./retry"; +export * from "./request"; +export { DiagnosticNodeInternal, DiagnosticDataValue, DiagnosticNodeType, } from "./diagnostics/DiagnosticNodeInternal"; +export { CosmosHeaders, SqlParameter, SqlQuerySpec, JSONValue, JSONArray, JSONObject, } from "./queryExecutionContext"; +export { QueryIterator } from "./queryIterator"; +export * from "./queryMetrics"; +export { CosmosClient } from "./CosmosClient"; +export { CosmosClientOptions, Agent } from "./CosmosClientOptions"; +export * from "./client"; +export { Scripts } from "./client/Script/Scripts"; +export { Next, Plugin, PluginConfig, PluginOn } from "./plugins/Plugin"; +export { TokenProvider, RequestInfo } from "./auth"; +export { ChangeFeedIterator } from "./ChangeFeedIterator"; +export { ChangeFeedOptions } from "./ChangeFeedOptions"; +export { ChangeFeedResponse } from "./ChangeFeedResponse"; +export { ClientContext } from "./ClientContext"; +export { CosmosDiagnostics, MetadataLookUpDiagnostic, MetadataLookUpDiagnostics, MetadataLookUpType, RetryDiagnostics, FailedRequestAttemptDiagnostic, GatewayStatistics, ClientSideRequestStatistics, ClientConfigDiagnostic, DiagnosticNode, } from "./CosmosDiagnostics"; +export { ChangeFeedPullModelIterator, ChangeFeedIteratorOptions, ChangeFeedIteratorResponse, ChangeFeedStartFrom, FeedRange, } from "./client/ChangeFeed"; +export { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +export { GlobalEndpointManager } from "./globalEndpointManager"; +export { SasTokenPermissionKind } from "./common/constants"; +export { createAuthorizationSasToken } from "./utils/SasToken"; +export { RestError } from "@azure/core-rest-pipeline"; +export { AbortError } from "@azure/abort-controller"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts.map new file mode 100644 index 000000000..023e26c8e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gCAAgC,EAAE,MAAM,UAAU,CAAC;AAC1F,OAAO,EAAE,yCAAyC,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,KAAK,EACL,WAAW,EACX,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,cAAc,EACd,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,0BAA0B,EAC1B,oBAAoB,EACpB,oBAAoB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AAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EAChB,8BAA8B,EAC9B,iBAAiB,EACjB,2BAA2B,EAC3B,sBAAsB,EACtB,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/index.js new file mode 100644 index 000000000..778c589ab --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/index.js @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { DEFAULT_PARTITION_KEY_PATH } from "./common/partitionKeys"; +export { StatusCodes } from "./common"; +export { setAuthorizationTokenHeaderUsingMasterKey } from "./auth"; +export { BulkOperationType, } from "./utils/batch"; +export { PatchOperationType, } from "./utils/patch"; +export { ConnectionMode, ConsistencyLevel, DatabaseAccount, DataType, IndexingMode, SpatialType, GeospatialType, IndexKind, PartitionKeyKind, PartitionKeyDefinitionVersion, PartitionKeyBuilder, PermissionMode, PriorityLevel, TriggerOperation, TriggerType, UserDefinedFunctionType, } from "./documents"; +export { Constants, OperationType, ResourceType, HTTPMethod } from "./common"; +export * from "./request"; +export { DiagnosticNodeInternal, DiagnosticNodeType, } from "./diagnostics/DiagnosticNodeInternal"; +export { QueryIterator } from "./queryIterator"; +export * from "./queryMetrics"; +export { CosmosClient } from "./CosmosClient"; +export * from "./client"; +export { Scripts } from "./client/Script/Scripts"; +export { PluginOn } from "./plugins/Plugin"; +export { ChangeFeedIterator } from "./ChangeFeedIterator"; +export { ChangeFeedResponse } from "./ChangeFeedResponse"; +export { ClientContext } from "./ClientContext"; +export { CosmosDiagnostics, MetadataLookUpType, } from "./CosmosDiagnostics"; +export { ChangeFeedIteratorResponse, ChangeFeedStartFrom, FeedRange, } from "./client/ChangeFeed"; +export { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +export { GlobalEndpointManager } from "./globalEndpointManager"; +export { SasTokenPermissionKind } from "./common/constants"; +export { createAuthorizationSasToken } from "./utils/SasToken"; +export { RestError } from "@azure/core-rest-pipeline"; +export { AbortError } from "@azure/abort-controller"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/index.js.map new file mode 100644 index 000000000..af54f8d65 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAqD,MAAM,UAAU,CAAC;AAC1F,OAAO,EAAE,yCAAyC,EAAE,MAAM,QAAQ,CAAC;AACnE,OAAO,EAYL,iBAAiB,GASlB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,kBAAkB,GAInB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,cAAc,EACd,gBAAgB,EAEhB,eAAe,EACf,QAAQ,EAGR,YAAY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C","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { DEFAULT_PARTITION_KEY_PATH } from \"./common/partitionKeys\";\nexport { StatusCodes, StatusCodesType, PartitionKeyRangePropertiesNames } from \"./common\";\nexport { setAuthorizationTokenHeaderUsingMasterKey } from \"./auth\";\nexport {\n Operation,\n OperationResponse,\n BulkOptions,\n CreateOperation,\n UpsertOperation,\n ReplaceOperation,\n DeleteOperation,\n ReadOperation,\n OperationBase,\n OperationWithItem,\n OperationInput,\n BulkOperationType,\n BulkOperationResponse,\n CreateOperationInput,\n UpsertOperationInput,\n ReplaceOperationInput,\n ReadOperationInput,\n DeleteOperationInput,\n PatchOperationInput,\n BulkPatchOperation,\n} from \"./utils/batch\";\nexport {\n PatchOperation,\n PatchOperationType,\n ExistingKeyOperation,\n RemoveOperation,\n PatchRequestBody,\n} from \"./utils/patch\";\nexport {\n ConnectionMode,\n ConsistencyLevel,\n ConnectionPolicy,\n DatabaseAccount,\n DataType,\n Index,\n IndexedPath,\n IndexingMode,\n IndexingPolicy,\n SpatialIndex,\n SpatialType,\n GeospatialType,\n IndexKind,\n Location,\n PartitionKey,\n PrimitivePartitionKeyValue,\n NullPartitionKeyType,\n NonePartitionKeyType,\n PartitionKeyKind,\n PartitionKeyDefinition,\n PartitionKeyDefinitionVersion,\n PartitionKeyBuilder,\n PermissionMode,\n PriorityLevel,\n TriggerOperation,\n TriggerType,\n UserDefinedFunctionType,\n VectorEmbeddingPolicy,\n VectorIndex,\n VectorEmbedding,\n} from \"./documents\";\n\nexport { UniqueKeyPolicy, UniqueKey } from \"./client/Container/UniqueKeyPolicy\";\nexport { ContainerRequest } from \"./client/Container/ContainerRequest\";\nexport { Constants, OperationType, ResourceType, HTTPMethod } from \"./common\";\nexport { RetryOptions } from \"./retry\";\nexport * from \"./request\";\n\nexport {\n DiagnosticNodeInternal,\n DiagnosticDataValue,\n DiagnosticNodeType,\n} from \"./diagnostics/DiagnosticNodeInternal\";\n\nexport {\n CosmosHeaders,\n SqlParameter,\n SqlQuerySpec,\n JSONValue,\n JSONArray,\n JSONObject,\n} from \"./queryExecutionContext\";\nexport { QueryIterator } from \"./queryIterator\";\nexport * from \"./queryMetrics\";\nexport { CosmosClient } from \"./CosmosClient\";\nexport { CosmosClientOptions, Agent } from \"./CosmosClientOptions\";\nexport * from \"./client\";\nexport { Scripts } from \"./client/Script/Scripts\";\nexport { Next, Plugin, PluginConfig, PluginOn } from \"./plugins/Plugin\";\nexport { TokenProvider, RequestInfo } from \"./auth\";\n\nexport { ChangeFeedIterator } from \"./ChangeFeedIterator\";\nexport { ChangeFeedOptions } from \"./ChangeFeedOptions\";\nexport { ChangeFeedResponse } from \"./ChangeFeedResponse\";\nexport { ClientContext } from \"./ClientContext\";\n\nexport {\n CosmosDiagnostics,\n MetadataLookUpDiagnostic,\n MetadataLookUpDiagnostics,\n MetadataLookUpType,\n RetryDiagnostics,\n FailedRequestAttemptDiagnostic,\n GatewayStatistics,\n ClientSideRequestStatistics,\n ClientConfigDiagnostic,\n DiagnosticNode,\n} from \"./CosmosDiagnostics\";\n\nexport {\n ChangeFeedPullModelIterator,\n ChangeFeedIteratorOptions,\n ChangeFeedIteratorResponse,\n ChangeFeedStartFrom,\n FeedRange,\n} from \"./client/ChangeFeed\";\nexport { CosmosDbDiagnosticLevel } from \"./diagnostics/CosmosDbDiagnosticLevel\";\n\nexport { GlobalEndpointManager } from \"./globalEndpointManager\";\nexport { SasTokenPermissionKind } from \"./common/constants\";\nexport { createAuthorizationSasToken } from \"./utils/SasToken\";\nexport { RestError } from \"@azure/core-rest-pipeline\";\nexport { AbortError } from \"@azure/abort-controller\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts new file mode 100644 index 000000000..9765aa7a4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts @@ -0,0 +1,9 @@ +/** + * Represents a composite index in the Azure Cosmos DB database service. + */ +export interface CompositeIndexUtilizationEntity { + IndexSpecs: string[]; + IndexPreciseSet: boolean; + IndexImpactScore: string; +} +//# sourceMappingURL=CompositeIndexUtilizationEntity.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts.map new file mode 100644 index 000000000..b1f31e009 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CompositeIndexUtilizationEntity.d.ts","sourceRoot":"","sources":["../../../src/indexMetrics/CompositeIndexUtilizationEntity.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js new file mode 100644 index 000000000..c403af208 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=CompositeIndexUtilizationEntity.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js.map new file mode 100644 index 000000000..412e3a9da --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/CompositeIndexUtilizationEntity.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CompositeIndexUtilizationEntity.js","sourceRoot":"","sources":["../../../src/indexMetrics/CompositeIndexUtilizationEntity.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Represents a composite index in the Azure Cosmos DB database service.\n */\nexport interface CompositeIndexUtilizationEntity {\n IndexSpecs: string[]; // IndexDocumentExpressions\n IndexPreciseSet: boolean; // IndexPlanFullFidelity\n IndexImpactScore: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts new file mode 100644 index 000000000..55192217b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts @@ -0,0 +1,12 @@ +declare const _default: { + IndexUtilizationInfo: string; + UtilizedSingleIndexes: string; + PotentialSingleIndexes: string; + UtilizedCompositeIndexes: string; + PotentialCompositeIndexes: string; + IndexExpression: string; + IndexImpactScore: string; + IndexUtilizationSeparator: string; +}; +export default _default; +//# sourceMappingURL=Constants.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts.map new file mode 100644 index 000000000..811388e95 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../../../src/indexMetrics/Constants.ts"],"names":[],"mappings":";;;;;;;;;;AAGA,wBASE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js new file mode 100644 index 000000000..ee7c97973 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export default { + IndexUtilizationInfo: "Index Utilization Information", + UtilizedSingleIndexes: "Utilized Single Indexes", + PotentialSingleIndexes: "Potential Single Indexes", + UtilizedCompositeIndexes: "Utilized Composite Indexes", + PotentialCompositeIndexes: "Potential Composite Indexes", + IndexExpression: "Index Spec", + IndexImpactScore: "Index Impact Score", + IndexUtilizationSeparator: "---", +}; +//# sourceMappingURL=Constants.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js.map new file mode 100644 index 000000000..961a5ef94 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/Constants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../../src/indexMetrics/Constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,eAAe;IACb,oBAAoB,EAAE,+BAA+B;IACrD,qBAAqB,EAAE,yBAAyB;IAChD,sBAAsB,EAAE,0BAA0B;IAClD,wBAAwB,EAAE,4BAA4B;IACtD,yBAAyB,EAAE,6BAA6B;IACxD,eAAe,EAAE,YAAY;IAC7B,gBAAgB,EAAE,oBAAoB;IACtC,yBAAyB,EAAE,KAAK;CACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport default {\n IndexUtilizationInfo: \"Index Utilization Information\",\n UtilizedSingleIndexes: \"Utilized Single Indexes\",\n PotentialSingleIndexes: \"Potential Single Indexes\",\n UtilizedCompositeIndexes: \"Utilized Composite Indexes\",\n PotentialCompositeIndexes: \"Potential Composite Indexes\",\n IndexExpression: \"Index Spec\",\n IndexImpactScore: \"Index Impact Score\",\n IndexUtilizationSeparator: \"---\",\n};\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts new file mode 100644 index 000000000..9e3b706de --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts @@ -0,0 +1,12 @@ +import { IndexUtilizationInfo } from "./IndexUtilizationInfo"; +export declare class IndexMetricWriter { + writeIndexMetrics(indexUtilizationInfo: IndexUtilizationInfo): string; + protected writeBeforeIndexUtilizationInfo(result: string): string; + protected writeIndexUtilizationInfo(result: string, indexUtilizationInfo: IndexUtilizationInfo): string; + protected writeAfterIndexUtilizationInfo(result: string): string; + private writeSingleIndexUtilizationEntity; + private writeCompositeIndexUtilizationEntity; + private appendNewlineToResult; + private appendHeaderToResult; +} +//# sourceMappingURL=IndexMetricWriter.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts.map new file mode 100644 index 000000000..89014f397 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexMetricWriter.d.ts","sourceRoot":"","sources":["../../../src/indexMetrics/IndexMetricWriter.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,qBAAa,iBAAiB;IACrB,iBAAiB,CAAC,oBAAoB,EAAE,oBAAoB,GAAG,MAAM;IAQ5E,SAAS,CAAC,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAMjE,SAAS,CAAC,yBAAyB,CACjC,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,oBAAoB,GACzC,MAAM;IA0BT,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIhE,OAAO,CAAC,iCAAiC;IAkBzC,OAAO,CAAC,oCAAoC;IAkB5C,OAAO,CAAC,qBAAqB;IAI7B,OAAO,CAAC,oBAAoB;CAM7B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js new file mode 100644 index 000000000..deab9f1da --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import Constants from "./Constants"; +export class IndexMetricWriter { + writeIndexMetrics(indexUtilizationInfo) { + let result = ""; + result = this.writeBeforeIndexUtilizationInfo(result); + result = this.writeIndexUtilizationInfo(result, indexUtilizationInfo); + result = this.writeAfterIndexUtilizationInfo(result); + return result; + } + writeBeforeIndexUtilizationInfo(result) { + result = this.appendNewlineToResult(result); + result = this.appendHeaderToResult(result, Constants.IndexUtilizationInfo, 0); + return result; + } + writeIndexUtilizationInfo(result, indexUtilizationInfo) { + result = this.appendHeaderToResult(result, Constants.UtilizedSingleIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedSingleIndexes) { + result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity); + } + result = this.appendHeaderToResult(result, Constants.PotentialSingleIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.PotentialSingleIndexes) { + result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity); + } + result = this.appendHeaderToResult(result, Constants.UtilizedCompositeIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedCompositeIndexes) { + result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity); + } + result = this.appendHeaderToResult(result, Constants.PotentialCompositeIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.PotentialCompositeIndexes) { + result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity); + } + return result; + } + writeAfterIndexUtilizationInfo(result) { + return result; + } + writeSingleIndexUtilizationEntity(result, indexUtilizationEntity) { + result = this.appendHeaderToResult(result, `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpec}`, 2); + result = this.appendHeaderToResult(result, `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`, 2); + result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2); + return result; + } + writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity) { + result = this.appendHeaderToResult(result, `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpecs.join(", ")}`, 2); + result = this.appendHeaderToResult(result, `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`, 2); + result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2); + return result; + } + appendNewlineToResult(result) { + return this.appendHeaderToResult(result, "", 0); + } + appendHeaderToResult(result, headerTitle, indentLevel) { + const Indent = " "; + const header = `${Indent.repeat(indentLevel)}${headerTitle}\n`; + result += header; + return result; + } +} +//# sourceMappingURL=IndexMetricWriter.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js.map new file mode 100644 index 000000000..3ecf4cb37 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexMetricWriter.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexMetricWriter.js","sourceRoot":"","sources":["../../../src/indexMetrics/IndexMetricWriter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,SAAS,MAAM,aAAa,CAAC;AAKpC,MAAM,OAAO,iBAAiB;IACrB,iBAAiB,CAAC,oBAA0C;QACjE,IA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E,SAAS,CAAC,yBAAyB,EAAE,CAAC,CAAC,CAAC;QACnF,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,qBAAqB,CAAC,MAAc;QAC1C,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IAEO,oBAAoB,CAAC,MAAc,EAAE,WAAmB,EAAE,WAAmB;QACnF,MAAM,MAAM,GAAG,IAAI,CAAC;QACpB,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,WAAW,IAAI,CAAC;QAC/D,MAAM,IAAI,MAAM,CAAC;QACjB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport Constants from \"./Constants\";\nimport { CompositeIndexUtilizationEntity } from \"./CompositeIndexUtilizationEntity\";\nimport { IndexUtilizationInfo } from \"./IndexUtilizationInfo\";\nimport { SingleIndexUtilizationEntity } from \"./SingleIndexUtilizationEntity\";\n\nexport class IndexMetricWriter {\n public writeIndexMetrics(indexUtilizationInfo: IndexUtilizationInfo): string {\n let result = \"\";\n result = this.writeBeforeIndexUtilizationInfo(result);\n result = this.writeIndexUtilizationInfo(result, indexUtilizationInfo);\n result = this.writeAfterIndexUtilizationInfo(result);\n return result;\n }\n\n protected writeBeforeIndexUtilizationInfo(result: string): string {\n result = this.appendNewlineToResult(result);\n result = this.appendHeaderToResult(result, Constants.IndexUtilizationInfo, 0);\n return result;\n }\n\n protected writeIndexUtilizationInfo(\n result: string,\n indexUtilizationInfo: IndexUtilizationInfo,\n ): string {\n result = this.appendHeaderToResult(result, Constants.UtilizedSingleIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedSingleIndexes) {\n result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n result = this.appendHeaderToResult(result, Constants.PotentialSingleIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.PotentialSingleIndexes) {\n result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n\n result = this.appendHeaderToResult(result, Constants.UtilizedCompositeIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedCompositeIndexes) {\n result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n\n result = this.appendHeaderToResult(result, Constants.PotentialCompositeIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.PotentialCompositeIndexes) {\n result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n return result;\n }\n\n protected writeAfterIndexUtilizationInfo(result: string): string {\n return result;\n }\n\n private writeSingleIndexUtilizationEntity(\n result: string,\n indexUtilizationEntity: SingleIndexUtilizationEntity,\n ): string {\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpec}`,\n 2,\n );\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`,\n 2,\n );\n result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2);\n return result;\n }\n\n private writeCompositeIndexUtilizationEntity(\n result: string,\n indexUtilizationEntity: CompositeIndexUtilizationEntity,\n ): string {\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpecs.join(\", \")}`,\n 2,\n );\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`,\n 2,\n );\n result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2);\n return result;\n }\n\n private appendNewlineToResult(result: string): string {\n return this.appendHeaderToResult(result, \"\", 0);\n }\n\n private appendHeaderToResult(result: string, headerTitle: string, indentLevel: number): string {\n const Indent = \" \";\n const header = `${Indent.repeat(indentLevel)}${headerTitle}\\n`;\n result += header;\n return result;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts new file mode 100644 index 000000000..75a2a7eec --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts @@ -0,0 +1,18 @@ +import { SingleIndexUtilizationEntity } from "./SingleIndexUtilizationEntity"; +import { CompositeIndexUtilizationEntity } from "./CompositeIndexUtilizationEntity"; +export declare class IndexUtilizationInfo { + readonly UtilizedSingleIndexes: SingleIndexUtilizationEntity[]; + readonly PotentialSingleIndexes: SingleIndexUtilizationEntity[]; + readonly UtilizedCompositeIndexes: CompositeIndexUtilizationEntity[]; + readonly PotentialCompositeIndexes: CompositeIndexUtilizationEntity[]; + static readonly Empty: IndexUtilizationInfo; + constructor(UtilizedSingleIndexes: SingleIndexUtilizationEntity[], PotentialSingleIndexes: SingleIndexUtilizationEntity[], UtilizedCompositeIndexes: CompositeIndexUtilizationEntity[], PotentialCompositeIndexes: CompositeIndexUtilizationEntity[]); + static tryCreateFromDelimitedBase64String(delimitedString: string, out: { + result?: IndexUtilizationInfo; + }): boolean; + static tryCreateFromDelimitedString(delimitedString: string, out: { + result?: IndexUtilizationInfo; + }): boolean; + static createFromString(delimitedString: string, isBase64Encoded: boolean): IndexUtilizationInfo; +} +//# sourceMappingURL=IndexUtilizationInfo.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts.map new file mode 100644 index 000000000..fd22823a6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexUtilizationInfo.d.ts","sourceRoot":"","sources":["../../../src/indexMetrics/IndexUtilizationInfo.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,qBAAa,oBAAoB;aAIb,qBAAqB,EAAE,4BAA4B,EAAE;aACrD,sBAAsB,EAAE,4BAA4B,EAAE;aACtD,wBAAwB,EAAE,+BAA+B,EAAE;aAC3D,yBAAyB,EAAE,+BAA+B,EAAE;IAN9E,gBAAuB,KAAK,uBAA4C;gBAGtD,qBAAqB,EAAE,4BAA4B,EAAE,EACrD,sBAAsB,EAAE,4BAA4B,EAAE,EACtD,wBAAwB,EAAE,+BAA+B,EAAE,EAC3D,yBAAyB,EAAE,+BAA+B,EAAE;WAGhE,kCAAkC,CAC9C,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE;QAAE,MAAM,CAAC,EAAE,oBAAoB,CAAA;KAAE,GACrC,OAAO;WAYI,4BAA4B,CACxC,eAAe,EAAE,MAAM,EACvB,GAAG,EAAE;QAAE,MAAM,CAAC,EAAE,oBAAoB,CAAA;KAAE,GACrC,OAAO;WAeI,gBAAgB,CAC5B,eAAe,EAAE,MAAM,EACvB,eAAe,EAAE,OAAO,GACvB,oBAAoB;CAWxB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js new file mode 100644 index 000000000..683c74e44 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export class IndexUtilizationInfo { + constructor(UtilizedSingleIndexes, PotentialSingleIndexes, UtilizedCompositeIndexes, PotentialCompositeIndexes) { + this.UtilizedSingleIndexes = UtilizedSingleIndexes; + this.PotentialSingleIndexes = PotentialSingleIndexes; + this.UtilizedCompositeIndexes = UtilizedCompositeIndexes; + this.PotentialCompositeIndexes = PotentialCompositeIndexes; + } + static tryCreateFromDelimitedBase64String(delimitedString, out) { + if (delimitedString == null) { + out.result = IndexUtilizationInfo.Empty; + return false; + } + return IndexUtilizationInfo.tryCreateFromDelimitedString(Buffer.from(delimitedString, "base64").toString(), out); + } + static tryCreateFromDelimitedString(delimitedString, out) { + if (delimitedString == null) { + out.result = IndexUtilizationInfo.Empty; + return false; + } + try { + out.result = JSON.parse(delimitedString) || IndexUtilizationInfo.Empty; + return true; + } + catch (error) { + out.result = IndexUtilizationInfo.Empty; + return false; + } + } + static createFromString(delimitedString, isBase64Encoded) { + var _a; + const result = { result: undefined }; + if (isBase64Encoded) { + IndexUtilizationInfo.tryCreateFromDelimitedBase64String(delimitedString, result); + } + else { + IndexUtilizationInfo.tryCreateFromDelimitedString(delimitedString, result); + } + return (_a = result.result) !== null && _a !== void 0 ? _a : IndexUtilizationInfo.Empty; + } +} +IndexUtilizationInfo.Empty = new IndexUtilizationInfo([], [], [], []); +//# sourceMappingURL=IndexUtilizationInfo.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js.map new file mode 100644 index 000000000..e05ee7441 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/IndexUtilizationInfo.js.map @@ -0,0 +1 @@ +{"version":3,"file":"IndexUtilizationInfo.js","sourceRoot":"","sources":["../../../src/indexMetrics/IndexUtilizationInfo.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,OAAO,oBAAoB;IAG/B,YACkB,qBAAqD,EACrD,sBAAsD,EACtD,wBAA2D,EAC3D,yBAA4D;QAH5D,0BAAqB,GAArB,qBAAqB,CAAgC;QACrD,2BAAsB,GAAtB,sBAAsB,CAAgC;QACtD,6BAAwB,GAAxB,wBAAwB,CAAmC;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EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SingleIndexUtilizationEntity } from \"./SingleIndexUtilizationEntity\";\nimport { CompositeIndexUtilizationEntity } from \"./CompositeIndexUtilizationEntity\";\nexport class IndexUtilizationInfo {\n public static readonly Empty = new IndexUtilizationInfo([], [], [], []);\n\n constructor(\n public readonly UtilizedSingleIndexes: SingleIndexUtilizationEntity[],\n public readonly PotentialSingleIndexes: SingleIndexUtilizationEntity[],\n public readonly UtilizedCompositeIndexes: CompositeIndexUtilizationEntity[],\n public readonly PotentialCompositeIndexes: CompositeIndexUtilizationEntity[],\n ) {}\n\n public static tryCreateFromDelimitedBase64String(\n delimitedString: string,\n out: { result?: IndexUtilizationInfo },\n ): boolean {\n if (delimitedString == null) {\n out.result = IndexUtilizationInfo.Empty;\n return false;\n }\n\n return IndexUtilizationInfo.tryCreateFromDelimitedString(\n Buffer.from(delimitedString, \"base64\").toString(),\n out,\n );\n }\n\n public static tryCreateFromDelimitedString(\n delimitedString: string,\n out: { result?: IndexUtilizationInfo },\n ): boolean {\n if (delimitedString == null) {\n out.result = IndexUtilizationInfo.Empty;\n return false;\n }\n\n try {\n out.result = JSON.parse(delimitedString) || IndexUtilizationInfo.Empty;\n return true;\n } catch (error) {\n out.result = IndexUtilizationInfo.Empty;\n return false;\n }\n }\n\n public static createFromString(\n delimitedString: string,\n isBase64Encoded: boolean,\n ): IndexUtilizationInfo {\n const result: { result?: IndexUtilizationInfo } = { result: undefined };\n\n if (isBase64Encoded) {\n IndexUtilizationInfo.tryCreateFromDelimitedBase64String(delimitedString, result);\n } else {\n IndexUtilizationInfo.tryCreateFromDelimitedString(delimitedString, result);\n }\n\n return result.result ?? IndexUtilizationInfo.Empty;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts new file mode 100644 index 000000000..7bf58bb20 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts @@ -0,0 +1,11 @@ +/** + * Query index utilization data for single index (sub-structure of the Index Utilization metrics) in the Azure Cosmos database service. + */ +export interface SingleIndexUtilizationEntity { + FilterExpression?: string; + IndexSpec?: string; + FilterPreciseSet?: boolean; + IndexPreciseSet?: boolean; + IndexImpactScore?: string; +} +//# sourceMappingURL=SingleIndexUtilizationEntity.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts.map new file mode 100644 index 000000000..757bd75d2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"SingleIndexUtilizationEntity.d.ts","sourceRoot":"","sources":["../../../src/indexMetrics/SingleIndexUtilizationEntity.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js new file mode 100644 index 000000000..477dfe48d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=SingleIndexUtilizationEntity.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js.map new file mode 100644 index 000000000..5de67196a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/SingleIndexUtilizationEntity.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SingleIndexUtilizationEntity.js","sourceRoot":"","sources":["../../../src/indexMetrics/SingleIndexUtilizationEntity.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Query index utilization data for single index (sub-structure of the Index Utilization metrics) in the Azure Cosmos database service.\n */\nexport interface SingleIndexUtilizationEntity {\n FilterExpression?: string;\n IndexSpec?: string; // IndexDocumentExpression\n FilterPreciseSet?: boolean; // FilterExpressionPrecision\n IndexPreciseSet?: boolean; // IndexPlanFullFidelity\n IndexImpactScore?: string;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts new file mode 100644 index 000000000..0e8c2c831 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts @@ -0,0 +1,5 @@ +export * from "./IndexUtilizationInfo"; +export * from "./CompositeIndexUtilizationEntity"; +export * from "./SingleIndexUtilizationEntity"; +export * from "./IndexMetricWriter"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts.map new file mode 100644 index 000000000..a88d3805a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/indexMetrics/index.ts"],"names":[],"mappings":"AAEA,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js new file mode 100644 index 000000000..755db27b3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export * from "./IndexUtilizationInfo"; +export * from "./CompositeIndexUtilizationEntity"; +export * from "./SingleIndexUtilizationEntity"; +export * from "./IndexMetricWriter"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js.map new file mode 100644 index 000000000..ef4b52db1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/indexMetrics/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/indexMetrics/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./IndexUtilizationInfo\";\nexport * from \"./CompositeIndexUtilizationEntity\";\nexport * from \"./SingleIndexUtilizationEntity\";\nexport * from \"./IndexMetricWriter\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts new file mode 100644 index 000000000..4f1417c65 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts @@ -0,0 +1,54 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { RequestContext } from "../request/RequestContext"; +import { Response } from "../request/Response"; +/** + * Used to specify which type of events to execute this plug in on. + * + * @hidden + */ +export declare enum PluginOn { + /** + * Will be executed per network request + */ + request = "request", + /** + * Will be executed per API operation + */ + operation = "operation" +} +/** + * Specifies which event to run for the specified plugin + * + * @hidden + */ +export interface PluginConfig { + /** + * The event to run the plugin on + */ + on: keyof typeof PluginOn; + /** + * The plugin to run + */ + plugin: Plugin; +} +/** + * Plugins allow you to customize the behavior of the SDk with additional logging, retry, or additional functionality. + * + * A plugin is a function which returns a `Promise>`, and is passed a RequestContext and Next object. + * + * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins, + * allowing you to log those results or handle errors. + * + * RequestContext is an object which controls what operation is happening, against which endpoint, and more. Modifying this and passing it along via next is how + * you modify future SDK behavior. + * + * @hidden + */ +export type Plugin = (context: RequestContext, diagnosticNode: DiagnosticNodeInternal, next: Next) => Promise>; +/** + * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins, + * allowing you to log those results or handle errors. + * @hidden + */ +export type Next = (context: RequestContext) => Promise>; +//# sourceMappingURL=Plugin.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts.map new file mode 100644 index 000000000..f5f3af811 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/Plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;;GAIG;AACH,oBAAY,QAAQ;IAClB;;OAEG;IACH,OAAO,YAAY;IACnB;;OAEG;IACH,SAAS,cAAc;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,EAAE,EAAE,MAAM,OAAO,QAAQ,CAAC;IAC1B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CACtB,OAAO,EAAE,cAAc,EACvB,cAAc,EAAE,sBAAsB,EACtC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,KACV,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1B;;;;GAIG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js new file mode 100644 index 000000000..c6e56dd79 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js @@ -0,0 +1,43 @@ +/** + * Used to specify which type of events to execute this plug in on. + * + * @hidden + */ +export var PluginOn; +(function (PluginOn) { + /** + * Will be executed per network request + */ + PluginOn["request"] = "request"; + /** + * Will be executed per API operation + */ + PluginOn["operation"] = "operation"; +})(PluginOn || (PluginOn = {})); +/** + * @internal + */ +export async function executePlugins(diagnosticNode, requestContext, next, on) { + if (!requestContext.plugins) { + return next(requestContext, diagnosticNode, undefined); + } + let level = 0; + const _ = (inner) => { + if (++level >= inner.plugins.length) { + return next(requestContext, diagnosticNode, undefined); + } + else if (inner.plugins[level].on !== on) { + return _(requestContext); + } + else { + return inner.plugins[level].plugin(inner, diagnosticNode, _); + } + }; + if (requestContext.plugins[level].on !== on) { + return _(requestContext); + } + else { + return requestContext.plugins[level].plugin(requestContext, diagnosticNode, _); + } +} +//# sourceMappingURL=Plugin.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js.map new file mode 100644 index 000000000..547148de1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/plugins/Plugin.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../../src/plugins/Plugin.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,MAAM,CAAN,IAAY,QASX;AATD,WAAY,QAAQ;IAClB;;OAEG;IACH,+BAAmB,CAAA;IACnB;;OAEG;IACH,mCAAuB,CAAA;AACzB,CAAC,EATW,QAAQ,KAAR,QAAQ,QASnB;AA4CD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,cAAsC,EACtC,cAA8B,EAC9B,IAAiB,EACjB,EAAY;IAEZ,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;QAC3B,OAAO,IAAI,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;KACxD;IACD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,MAAM,CAAC,GAAc,CAAC,KAAqB,EAA0B,EAAE;QACrE,IAAI,EAAE,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;YACnC,OAAO,IAAI,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC;SACxD;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;YACzC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC;SAC1B;aAAM;YACL,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;SAC9D;IACH,CAAC,CAAC;IACF,IAAI,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QAC3C,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC;KAC1B;SAAM;QACL,OAAO,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;KAChF;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { RequestContext } from \"../request/RequestContext\";\nimport { Response } from \"../request/Response\";\n\n/**\n * Used to specify which type of events to execute this plug in on.\n *\n * @hidden\n */\nexport enum PluginOn {\n /**\n * Will be executed per network request\n */\n request = \"request\",\n /**\n * Will be executed per API operation\n */\n operation = \"operation\",\n}\n\n/**\n * Specifies which event to run for the specified plugin\n *\n * @hidden\n */\nexport interface PluginConfig {\n /**\n * The event to run the plugin on\n */\n on: keyof typeof PluginOn;\n /**\n * The plugin to run\n */\n plugin: Plugin;\n}\n\n/**\n * Plugins allow you to customize the behavior of the SDk with additional logging, retry, or additional functionality.\n *\n * A plugin is a function which returns a `Promise>`, and is passed a RequestContext and Next object.\n *\n * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins,\n * allowing you to log those results or handle errors.\n *\n * RequestContext is an object which controls what operation is happening, against which endpoint, and more. Modifying this and passing it along via next is how\n * you modify future SDK behavior.\n *\n * @hidden\n */\nexport type Plugin = (\n context: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n next: Next,\n) => Promise>;\n\n/**\n * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins,\n * allowing you to log those results or handle errors.\n * @hidden\n */\nexport type Next = (context: RequestContext) => Promise>;\n\n/**\n * @internal\n */\nexport async function executePlugins(\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n next: Plugin,\n on: PluginOn,\n): Promise> {\n if (!requestContext.plugins) {\n return next(requestContext, diagnosticNode, undefined);\n }\n let level = 0;\n const _: Next = (inner: RequestContext): Promise> => {\n if (++level >= inner.plugins.length) {\n return next(requestContext, diagnosticNode, undefined);\n } else if (inner.plugins[level].on !== on) {\n return _(requestContext);\n } else {\n return inner.plugins[level].plugin(inner, diagnosticNode, _);\n }\n };\n if (requestContext.plugins[level].on !== on) {\n return _(requestContext);\n } else {\n return requestContext.plugins[level].plugin(requestContext, diagnosticNode, _);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts new file mode 100644 index 000000000..b837ce6fe --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts @@ -0,0 +1,6 @@ +/** @hidden */ +export interface Aggregator { + aggregate: (other: any) => void; + getResult: () => number; +} +//# sourceMappingURL=Aggregator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts.map new file mode 100644 index 000000000..d44c6d937 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Aggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/Aggregator.ts"],"names":[],"mappings":"AAEA,cAAc;AACd,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,SAAS,EAAE,MAAM,MAAM,CAAC;CACzB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js new file mode 100644 index 000000000..12114e45e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=Aggregator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js.map new file mode 100644 index 000000000..5b3136b60 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/Aggregator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Aggregator.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/Aggregator.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** @hidden */\nexport interface Aggregator {\n aggregate: (other: any) => void;\n getResult: () => number;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts new file mode 100644 index 000000000..379dddae5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts @@ -0,0 +1,20 @@ +import { Aggregator } from "./Aggregator"; +/** @hidden */ +export interface AverageAggregateResult { + sum: number; + count: number; +} +/** @hidden */ +export declare class AverageAggregator implements Aggregator { + sum: number; + count: number; + /** + * Add the provided item to aggregation result. + */ + aggregate(other: AverageAggregateResult): void; + /** + * Get the aggregation result. + */ + getResult(): number; +} +//# sourceMappingURL=AverageAggregator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts.map new file mode 100644 index 000000000..a0f1abd0a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"AverageAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/AverageAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,MAAM,WAAW,sBAAsB;IACrC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,qBAAa,iBAAkB,YAAW,UAAU;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACrB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI;IAYrD;;OAEG;IACI,SAAS,IAAI,MAAM;CAM3B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js new file mode 100644 index 000000000..e7d3d251d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js @@ -0,0 +1,27 @@ +/** @hidden */ +export class AverageAggregator { + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (other == null || other.sum == null) { + return; + } + if (this.sum == null) { + this.sum = 0.0; + this.count = 0; + } + this.sum += other.sum; + this.count += other.count; + } + /** + * Get the aggregation result. + */ + getResult() { + if (this.sum == null || this.count <= 0) { + return undefined; + } + return this.sum / this.count; + } +} +//# sourceMappingURL=AverageAggregator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js.map new file mode 100644 index 000000000..4515436b0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/AverageAggregator.js.map @@ -0,0 +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;YACtC,OAAO;SACR;QACD,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,EAAE;YACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;YACf,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;SAChB;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;YACvC,OAAO,SAAS,CAAC;SAClB;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 { Aggregator } from \"./Aggregator\";\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"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts new file mode 100644 index 000000000..b12b5a7b6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts @@ -0,0 +1,19 @@ +import { Aggregator } from "./Aggregator"; +/** @hidden */ +export declare class CountAggregator implements Aggregator { + value: number; + /** + * Represents an aggregator for COUNT operator. + * @hidden + */ + constructor(); + /** + * Add the provided item to aggregation result. + */ + aggregate(other: number): void; + /** + * Get the aggregation result. + */ + getResult(): number; +} +//# sourceMappingURL=CountAggregator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts.map new file mode 100644 index 000000000..bb5618bca --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CountAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/CountAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,eAAgB,YAAW,UAAU;IACzC,KAAK,EAAE,MAAM,CAAC;IACrB;;;OAGG;;IAIH;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js new file mode 100644 index 000000000..a2e0b949f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js @@ -0,0 +1,23 @@ +/** @hidden */ +export class CountAggregator { + /** + * Represents an aggregator for COUNT operator. + * @hidden + */ + constructor() { + this.value = 0; + } + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + this.value += other; + } + /** + * Get the aggregation result. + */ + getResult() { + return this.value; + } +} +//# sourceMappingURL=CountAggregator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js.map new file mode 100644 index 000000000..f2f95f47f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/CountAggregator.js.map @@ -0,0 +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 { Aggregator } from \"./Aggregator\";\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"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts new file mode 100644 index 000000000..109e5e74a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts @@ -0,0 +1,25 @@ +import { Aggregator } from "./Aggregator"; +interface MaxAggregateResult { + count: number; + max?: number; +} +/** @hidden */ +export declare class MaxAggregator implements Aggregator { + private value; + private comparer; + /** + * Represents an aggregator for MAX operator. + * @hidden + */ + constructor(); + /** + * Add the provided item to aggregation result. + */ + aggregate(other: MaxAggregateResult): void; + /** + * Get the aggregation result. + */ + getResult(): number; +} +export {}; +//# sourceMappingURL=MaxAggregator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts.map new file mode 100644 index 000000000..14b6809d5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"MaxAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MaxAggregator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,UAAU,kBAAkB;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,cAAc;AACd,qBAAa,aAAc,YAAW,UAAU;IAC9C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAoC;IACpD;;;OAGG;;IAKH;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAUjD;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js new file mode 100644 index 000000000..6d782796a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator"; +/** @hidden */ +export class MaxAggregator { + /** + * Represents an aggregator for MAX operator. + * @hidden + */ + constructor() { + this.value = undefined; + this.comparer = new OrderByDocumentProducerComparator(["Ascending"]); + } + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (this.value === undefined) { + this.value = other.max; + } + else if (this.comparer.compareValue(other.max, typeof other.max, this.value, typeof this.value) > 0) { + this.value = other.max; + } + } + /** + * Get the aggregation result. + */ + getResult() { + return this.value; + } +} +//# sourceMappingURL=MaxAggregator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js.map new file mode 100644 index 000000000..53021e0f4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MaxAggregator.js.map @@ -0,0 +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,sCAAsC,CAAC;AAQzF,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;YAC5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;SACxB;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;YACA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;SACxB;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\";\nimport { Aggregator } from \"./Aggregator\";\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"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts new file mode 100644 index 000000000..a4a910cf4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts @@ -0,0 +1,24 @@ +import { Aggregator } from "./Aggregator"; +export interface MinAggregateResult { + min: number; + count: number; +} +/** @hidden */ +export declare class MinAggregator implements Aggregator { + private value; + private comparer; + /** + * Represents an aggregator for MIN operator. + * @hidden + */ + constructor(); + /** + * Add the provided item to aggregation result. + */ + aggregate(other: MinAggregateResult): void; + /** + * Get the aggregation result. + */ + getResult(): number; +} +//# sourceMappingURL=MinAggregator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts.map new file mode 100644 index 000000000..8e9f0d0fe --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"MinAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/MinAggregator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,cAAc;AACd,qBAAa,aAAc,YAAW,UAAU;IAC9C,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,QAAQ,CAAoC;IACpD;;;OAGG;;IAKH;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,kBAAkB,GAAG,IAAI;IAajD;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js new file mode 100644 index 000000000..28c5a5001 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator"; +/** @hidden */ +export class MinAggregator { + /** + * Represents an aggregator for MIN operator. + * @hidden + */ + constructor() { + this.value = undefined; + this.comparer = new OrderByDocumentProducerComparator(["Ascending"]); + } + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (this.value === undefined) { + // || typeof this.value === "object" + this.value = other.min; + } + else { + const otherType = other.min === null ? "NoValue" : typeof other.min; // || typeof other === "object" + const thisType = this.value === null ? "NoValue" : typeof this.value; + if (this.comparer.compareValue(other.min, otherType, this.value, thisType) < 0) { + this.value = other.min; + } + } + } + /** + * Get the aggregation result. + */ + getResult() { + return this.value; + } +} +//# sourceMappingURL=MinAggregator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js.map new file mode 100644 index 000000000..b9d0be2ec --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/MinAggregator.js.map @@ -0,0 +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,sCAAsC,CAAC;AAQzF,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;YAC5B,oCAAoC;YACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;SACxB;aAAM;YACL,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;gBAC9E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;aACxB;SACF;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\";\nimport { Aggregator } from \"./Aggregator\";\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"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts new file mode 100644 index 000000000..faf52d618 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts @@ -0,0 +1,8 @@ +import { Aggregator } from "./Aggregator"; +/** @hidden */ +export declare class StaticValueAggregator implements Aggregator { + value: any; + aggregate(other: unknown): void; + getResult(): any; +} +//# sourceMappingURL=StaticValueAggregator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts.map new file mode 100644 index 000000000..d271fcd2f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"StaticValueAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/StaticValueAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,qBAAsB,YAAW,UAAU;IAC/C,KAAK,EAAE,GAAG,CAAC;IACX,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAM/B,SAAS,IAAI,GAAG;CAGxB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js new file mode 100644 index 000000000..4d5ea1876 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js @@ -0,0 +1,12 @@ +/** @hidden */ +export class StaticValueAggregator { + aggregate(other) { + if (this.value === undefined) { + this.value = other; + } + } + getResult() { + return this.value; + } +} +//# sourceMappingURL=StaticValueAggregator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js.map new file mode 100644 index 000000000..18a9d4fbe --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/StaticValueAggregator.js.map @@ -0,0 +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;YAC5B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;SACpB;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 { Aggregator } from \"./Aggregator\";\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"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts new file mode 100644 index 000000000..ad9c44541 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts @@ -0,0 +1,14 @@ +import { Aggregator } from "./Aggregator"; +/** @hidden */ +export declare class SumAggregator implements Aggregator { + sum: number; + /** + * Add the provided item to aggregation result. + */ + aggregate(other: number): void; + /** + * Get the aggregation result. + */ + getResult(): number; +} +//# sourceMappingURL=SumAggregator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts.map new file mode 100644 index 000000000..428eb188e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"SumAggregator.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/SumAggregator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,aAAc,YAAW,UAAU;IACvC,GAAG,EAAE,MAAM,CAAC;IACnB;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAWrC;;OAEG;IACI,SAAS,IAAI,MAAM;CAG3B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js new file mode 100644 index 000000000..a85cf16f5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js @@ -0,0 +1,24 @@ +/** @hidden */ +export class SumAggregator { + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (other === undefined) { + return; + } + if (this.sum === undefined) { + this.sum = other; + } + else { + this.sum += other; + } + } + /** + * Get the aggregation result. + */ + getResult() { + return this.sum; + } +} +//# sourceMappingURL=SumAggregator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js.map new file mode 100644 index 000000000..1ca37180e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/SumAggregator.js.map @@ -0,0 +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;YACvB,OAAO;SACR;QACD,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS,EAAE;YAC1B,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;SAClB;aAAM;YACL,IAAI,CAAC,GAAG,IAAI,KAAK,CAAC;SACnB;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 { Aggregator } from \"./Aggregator\";\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"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts new file mode 100644 index 000000000..ea717a214 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts @@ -0,0 +1,11 @@ +import { AverageAggregator } from "./AverageAggregator"; +import { CountAggregator } from "./CountAggregator"; +import { MaxAggregator } from "./MaxAggregator"; +import { MinAggregator } from "./MinAggregator"; +import { SumAggregator } from "./SumAggregator"; +import { StaticValueAggregator } from "./StaticValueAggregator"; +import { AggregateType } from "../../request/ErrorResponse"; +export declare function createAggregator(aggregateType: AggregateType): AverageAggregator | CountAggregator | MaxAggregator | MinAggregator | SumAggregator | StaticValueAggregator; +export { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator }; +export { Aggregator } from "./Aggregator"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts.map new file mode 100644 index 000000000..51e5f8c2d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,aAAa,GAE1B,iBAAiB,GACjB,eAAe,GACf,aAAa,GACb,aAAa,GACb,aAAa,GACb,qBAAqB,CAexB;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js new file mode 100644 index 000000000..a3401a1b9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { AverageAggregator } from "./AverageAggregator"; +import { CountAggregator } from "./CountAggregator"; +import { MaxAggregator } from "./MaxAggregator"; +import { MinAggregator } from "./MinAggregator"; +import { SumAggregator } from "./SumAggregator"; +import { StaticValueAggregator } from "./StaticValueAggregator"; +export function createAggregator(aggregateType) { + switch (aggregateType) { + case "Average": + return new AverageAggregator(); + case "Count": + return new CountAggregator(); + case "Max": + return new MaxAggregator(); + case "Min": + return new MinAggregator(); + case "Sum": + return new SumAggregator(); + default: + return new StaticValueAggregator(); + } +} +export { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js.map new file mode 100644 index 000000000..fd981bc45 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/Aggregators/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/Aggregators/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,MAAM,UAAU,gBAAgB,CAC9B,aAA4B;IAQ5B,QAAQ,aAAa,EAAE;QACrB,KAAK,SAAS;YACZ,OAAO,IAAI,iBAAiB,EAAE,CAAC;QACjC,KAAK,OAAO;YACV,OAAO,IAAI,eAAe,EAAE,CAAC;QAC/B,KAAK,KAAK;YACR,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B,KAAK,KAAK;YACR,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B,KAAK,KAAK;YACR,OAAO,IAAI,aAAa,EAAE,CAAC;QAC7B;YACE,OAAO,IAAI,qBAAqB,EAAE,CAAC;KACtC;AACH,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AverageAggregator } from \"./AverageAggregator\";\nimport { CountAggregator } from \"./CountAggregator\";\nimport { MaxAggregator } from \"./MaxAggregator\";\nimport { MinAggregator } from \"./MinAggregator\";\nimport { SumAggregator } from \"./SumAggregator\";\nimport { StaticValueAggregator } from \"./StaticValueAggregator\";\nimport { AggregateType } from \"../../request/ErrorResponse\";\n\nexport function createAggregator(\n aggregateType: AggregateType,\n):\n | AverageAggregator\n | CountAggregator\n | MaxAggregator\n | MinAggregator\n | SumAggregator\n | StaticValueAggregator {\n switch (aggregateType) {\n case \"Average\":\n return new AverageAggregator();\n case \"Count\":\n return new CountAggregator();\n case \"Max\":\n return new MaxAggregator();\n case \"Min\":\n return new MinAggregator();\n case \"Sum\":\n return new SumAggregator();\n default:\n return new StaticValueAggregator();\n }\n}\n\nexport { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator };\nexport { Aggregator } from \"./Aggregator\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts new file mode 100644 index 000000000..253000650 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts @@ -0,0 +1,4 @@ +export interface CosmosHeaders { + [key: string]: string | boolean | number; +} +//# sourceMappingURL=CosmosHeaders.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts.map new file mode 100644 index 000000000..bc40af3b9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosHeaders.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/CosmosHeaders.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;CAC1C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js new file mode 100644 index 000000000..040170ea8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=CosmosHeaders.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js.map new file mode 100644 index 000000000..8e2679d88 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/CosmosHeaders.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CosmosHeaders.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/CosmosHeaders.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface CosmosHeaders {\n [key: string]: string | boolean | number;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts new file mode 100644 index 000000000..8b23c2e75 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts @@ -0,0 +1,17 @@ +import { QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +import { QueryInfo } from "../../request/ErrorResponse"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { RUConsumedManager } from "../../common"; +/** @hidden */ +export declare class GroupByEndpointComponent implements ExecutionContext { + private executionContext; + private queryInfo; + constructor(executionContext: ExecutionContext, queryInfo: QueryInfo); + private readonly groupings; + private readonly aggregateResultArray; + private completed; + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + hasMoreResults(): boolean; +} +//# sourceMappingURL=GroupByEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts.map new file mode 100644 index 000000000..5e8c723f1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupByEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAKxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAYjD,cAAc;AACd,qBAAa,wBAAyB,YAAW,gBAAgB;IAE7D,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;gBADT,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS;IAG9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmD;IAC7E,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAa;IAClD,OAAO,CAAC,SAAS,CAAkB;IAEtB,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAmFlB,cAAc,IAAI,OAAO;CAGjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js new file mode 100644 index 000000000..2bc733df4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js @@ -0,0 +1,96 @@ +import { hashObject } from "../../utils/hashObject"; +import { createAggregator } from "../Aggregators"; +import { getInitialHeader, mergeHeaders } from "../headerUtils"; +import { emptyGroup, extractAggregateResult } from "./emptyGroup"; +import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError"; +/** @hidden */ +export class GroupByEndpointComponent { + constructor(executionContext, queryInfo) { + this.executionContext = executionContext; + this.queryInfo = queryInfo; + this.groupings = new Map(); + this.aggregateResultArray = []; + this.completed = false; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + // If we have a full result set, begin returning results + if (this.aggregateResultArray.length > 0) { + return { + result: this.aggregateResultArray.pop(), + headers: getInitialHeader(), + }; + } + if (this.completed) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + const aggregateHeaders = getInitialHeader(); + try { + while (this.executionContext.hasMoreResults()) { + // Grab the next result + const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + mergeHeaders(aggregateHeaders, headers); + // If it exists, process it via aggregators + if (result) { + const group = result.groupByItems ? await hashObject(result.groupByItems) : emptyGroup; + const aggregators = this.groupings.get(group); + const payload = result.payload; + if (aggregators) { + // Iterator over all results in the payload + Object.keys(payload).map((key) => { + // in case the value of a group is null make sure we create a dummy payload with item2==null + const effectiveGroupByValue = payload[key] + ? payload[key] + : new Map().set("item2", null); + const aggregateResult = extractAggregateResult(effectiveGroupByValue); + aggregators.get(key).aggregate(aggregateResult); + }); + } + else { + // This is the first time we have seen a grouping. Setup the initial result without aggregate values + const grouping = new Map(); + this.groupings.set(group, grouping); + // Iterator over all results in the payload + Object.keys(payload).map((key) => { + const aggregateType = this.queryInfo.groupByAliasToAggregateType[key]; + // Create a new aggregator for this specific aggregate field + const aggregator = createAggregator(aggregateType); + grouping.set(key, aggregator); + if (aggregateType) { + const aggregateResult = extractAggregateResult(payload[key]); + aggregator.aggregate(aggregateResult); + } + else { + aggregator.aggregate(payload[key]); + } + }); + } + } + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + for (const grouping of this.groupings.values()) { + const groupResult = {}; + for (const [aggregateKey, aggregator] of grouping.entries()) { + groupResult[aggregateKey] = aggregator.getResult(); + } + this.aggregateResultArray.push(groupResult); + } + this.completed = true; + return { + result: this.aggregateResultArray.pop(), + headers: aggregateHeaders, + }; + } + hasMoreResults() { + return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0; + } +} +//# sourceMappingURL=GroupByEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map new file mode 100644 index 000000000..2a0fa4fc7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupByEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAc,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,C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CAAC,GAAG,CAAC,CAAC,CAAC;6BACpC;wBACH,CAAC,CAAC,CAAC;qBACJ;iBACF;aACF;SACF;QAAC,OAAO,GAAQ,EAAE;YACjB,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;QAED,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE;YAC9C,MAAM,WAAW,GAAQ,EAAE,CAAC;YAC5B,KAAK,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE;gBAC3D,WAAW,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;aACpD;YACD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;SAC7C;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE;YACvC,OAAO,EAAE,gBAAgB;SAC1B,CAAC;IACJ,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACxF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { CosmosHeaders } from \"../CosmosHeaders\";\nimport { QueryInfo } from \"../../request/ErrorResponse\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { Aggregator, createAggregator } from \"../Aggregators\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils\";\nimport { emptyGroup, extractAggregateResult } from \"./emptyGroup\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\ninterface GroupByResponse {\n result: GroupByResult;\n headers: CosmosHeaders;\n}\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> = new Map();\n private readonly aggregateResultArray: any[] = [];\n private completed: boolean = false;\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // If we have a full result set, begin returning results\n if (this.aggregateResultArray.length > 0) {\n return {\n result: this.aggregateResultArray.pop(),\n headers: getInitialHeader(),\n };\n }\n\n if (this.completed) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n const aggregateHeaders = getInitialHeader();\n try {\n while (this.executionContext.hasMoreResults()) {\n // Grab the next result\n const { result, headers } = (await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )) as GroupByResponse;\n mergeHeaders(aggregateHeaders, headers);\n\n // If it exists, process it via aggregators\n if (result) {\n const group = result.groupByItems ? await hashObject(result.groupByItems) : emptyGroup;\n const aggregators = this.groupings.get(group);\n const payload = result.payload;\n if (aggregators) {\n // Iterator over all results in the payload\n Object.keys(payload).map((key) => {\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 Object.keys(payload).map((key) => {\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 } catch (err: any) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n\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 {\n result: this.aggregateResultArray.pop(),\n headers: aggregateHeaders,\n };\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts new file mode 100644 index 000000000..16533dc93 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts @@ -0,0 +1,18 @@ +import { QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +import { QueryInfo } from "../../request/ErrorResponse"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { RUConsumedManager } from "../../common"; +/** @hidden */ +export declare class GroupByValueEndpointComponent implements ExecutionContext { + private executionContext; + private queryInfo; + private readonly aggregators; + private readonly aggregateResultArray; + private aggregateType; + private completed; + constructor(executionContext: ExecutionContext, queryInfo: QueryInfo); + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + hasMoreResults(): boolean; +} +//# sourceMappingURL=GroupByValueEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts.map new file mode 100644 index 000000000..8e700eaae --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupByValueEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAiB,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAKvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAYjD,cAAc;AACd,qBAAa,6BAA8B,YAAW,gBAAgB;IAOlE,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;IAPnB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsC;IAClE,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAa;IAClD,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,SAAS,CAAkB;gBAGzB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS;IAMjB,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAkFlB,cAAc,IAAI,OAAO;CAGjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js new file mode 100644 index 000000000..c73b3e6ba --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js @@ -0,0 +1,94 @@ +import { hashObject } from "../../utils/hashObject"; +import { createAggregator } from "../Aggregators"; +import { getInitialHeader, mergeHeaders } from "../headerUtils"; +import { emptyGroup, extractAggregateResult } from "./emptyGroup"; +import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError"; +/** @hidden */ +export class GroupByValueEndpointComponent { + constructor(executionContext, queryInfo) { + this.executionContext = executionContext; + this.queryInfo = queryInfo; + this.aggregators = new Map(); + this.aggregateResultArray = []; + this.completed = false; + // VALUE queries will only every have a single grouping + this.aggregateType = this.queryInfo.aggregates[0]; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + // Start returning results if we have processed a full results set + if (this.aggregateResultArray.length > 0) { + return { + result: this.aggregateResultArray.pop(), + headers: getInitialHeader(), + }; + } + if (this.completed) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + const aggregateHeaders = getInitialHeader(); + try { + while (this.executionContext.hasMoreResults()) { + // Grab the next result + const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + mergeHeaders(aggregateHeaders, headers); + // If it exists, process it via aggregators + if (result) { + let grouping = emptyGroup; + let payload = result; + if (result.groupByItems) { + // If the query contains a GROUP BY clause, it will have a payload property and groupByItems + payload = result.payload; + grouping = await hashObject(result.groupByItems); + } + const aggregator = this.aggregators.get(grouping); + if (!aggregator) { + // This is the first time we have seen a grouping so create a new aggregator + this.aggregators.set(grouping, createAggregator(this.aggregateType)); + } + if (this.aggregateType) { + const aggregateResult = extractAggregateResult(payload[0]); + // if aggregate result is null, we need to short circuit aggregation and return undefined + if (aggregateResult === null) { + this.completed = true; + } + this.aggregators.get(grouping).aggregate(aggregateResult); + } + else { + // Queries with no aggregates pass the payload directly to the aggregator + // Example: SELECT VALUE c.team FROM c GROUP BY c.team + this.aggregators.get(grouping).aggregate(payload); + } + } + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + // We bail early since we got an undefined result back `[{}]` + if (this.completed) { + return { + result: undefined, + headers: aggregateHeaders, + }; + } + // If no results are left in the underlying execution context, convert our aggregate results to an array + for (const aggregator of this.aggregators.values()) { + this.aggregateResultArray.push(aggregator.getResult()); + } + this.completed = true; + return { + result: this.aggregateResultArray.pop(), + headers: aggregateHeaders, + }; + } + hasMoreResults() { + return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0; + } +} +//# sourceMappingURL=GroupByValueEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map new file mode 100644 index 000000000..cfc600b24 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"GroupByValueEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAc,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAA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D,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;SACxD;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE;YACvC,OAAO,EAAE,gBAAgB;SAC1B,CAAC;IACJ,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACxF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { CosmosHeaders } from \"../CosmosHeaders\";\nimport { AggregateType, QueryInfo } from \"../../request/ErrorResponse\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { Aggregator, createAggregator } from \"../Aggregators\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils\";\nimport { emptyGroup, extractAggregateResult } from \"./emptyGroup\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\ninterface GroupByResponse {\n result: GroupByResult;\n headers: CosmosHeaders;\n}\n\ninterface GroupByResult {\n groupByItems: any[];\n payload: any;\n}\n\n/** @hidden */\nexport class GroupByValueEndpointComponent implements ExecutionContext {\n private readonly aggregators: Map = new Map();\n private readonly aggregateResultArray: any[] = [];\n private aggregateType: AggregateType;\n private completed: boolean = false;\n\n constructor(\n private executionContext: ExecutionContext,\n private queryInfo: QueryInfo,\n ) {\n // VALUE queries will only every have a single grouping\n this.aggregateType = this.queryInfo.aggregates[0];\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // Start returning results if we have processed a full results set\n if (this.aggregateResultArray.length > 0) {\n return {\n result: this.aggregateResultArray.pop(),\n headers: getInitialHeader(),\n };\n }\n\n if (this.completed) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n const aggregateHeaders = getInitialHeader();\n try {\n while (this.executionContext.hasMoreResults()) {\n // Grab the next result\n const { result, headers } = (await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )) as GroupByResponse;\n mergeHeaders(aggregateHeaders, headers);\n\n // If it exists, process it via aggregators\n if (result) {\n let grouping: string = emptyGroup;\n let payload: any = result;\n if (result.groupByItems) {\n // If the query contains a GROUP BY clause, it will have a payload property and groupByItems\n payload = result.payload;\n grouping = await hashObject(result.groupByItems);\n }\n\n const aggregator = this.aggregators.get(grouping);\n if (!aggregator) {\n // This is the first time we have seen a grouping so create a new aggregator\n this.aggregators.set(grouping, createAggregator(this.aggregateType));\n }\n\n if (this.aggregateType) {\n const aggregateResult = extractAggregateResult(payload[0]);\n // if aggregate result is null, we need to short circuit aggregation and return undefined\n if (aggregateResult === null) {\n this.completed = true;\n }\n this.aggregators.get(grouping).aggregate(aggregateResult);\n } else {\n // Queries with no aggregates pass the payload directly to the aggregator\n // Example: SELECT VALUE c.team FROM c GROUP BY c.team\n this.aggregators.get(grouping).aggregate(payload);\n }\n }\n }\n } catch (err: any) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n\n // We bail early since we got an undefined result back `[{}]`\n if (this.completed) {\n return {\n result: undefined,\n headers: aggregateHeaders,\n };\n }\n // If no results are left in the underlying execution context, convert our aggregate results to an array\n for (const aggregator of this.aggregators.values()) {\n this.aggregateResultArray.push(aggregator.getResult());\n }\n this.completed = true;\n return {\n result: this.aggregateResultArray.pop(),\n headers: aggregateHeaders,\n };\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts new file mode 100644 index 000000000..c9e6e2f93 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts @@ -0,0 +1,23 @@ +import { QueryInfo, QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { RUConsumedManager } from "../../common"; +/** @hidden */ +export declare class NonStreamingOrderByDistinctEndpointComponent implements ExecutionContext { + private executionContext; + private queryInfo; + private priorityQueueBufferSize; + private aggregateMap; + private nonStreamingOrderByPQ; + private finalResultArray; + private sortOrders; + private isCompleted; + constructor(executionContext: ExecutionContext, queryInfo: QueryInfo, priorityQueueBufferSize: number); + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + /** + * Build final sorted result array from which responses will be served. + */ + private buildFinalResultArray; + hasMoreResults(): boolean; +} +//# sourceMappingURL=NonStreamingOrderByDistinctEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts.map new file mode 100644 index 000000000..31eeaa1de --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"NonStreamingOrderByDistinctEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAOjD,cAAc;AACd,qBAAa,4CAA6C,YAAW,gBAAgB;IAQjF,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,uBAAuB;IATjC,OAAO,CAAC,YAAY,CAAoD;IACxE,OAAO,CAAC,qBAAqB,CAA8D;IAC3F,OAAO,CAAC,gBAAgB,CAA8B;IACtD,OAAO,CAAC,UAAU,CAAW;IAC7B,OAAO,CAAC,WAAW,CAAkB;gBAG3B,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,uBAAuB,EAAE,MAAM;IAiB5B,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAkDzB;;OAEG;YACW,qBAAqB;IAoB5B,cAAc,IAAI,OAAO;CAIjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js new file mode 100644 index 000000000..b22693ee3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js @@ -0,0 +1,96 @@ +import { getInitialHeader } from "../headerUtils"; +import { hashObject } from "../../utils/hashObject"; +import { NonStreamingOrderByPriorityQueue } from "../../utils/nonStreamingOrderByPriorityQueue"; +import { NonStreamingOrderByMap } from "../../utils/nonStreamingOrderByMap"; +import { OrderByComparator } from "../orderByComparator"; +/** @hidden */ +export class NonStreamingOrderByDistinctEndpointComponent { + constructor(executionContext, queryInfo, priorityQueueBufferSize) { + this.executionContext = executionContext; + this.queryInfo = queryInfo; + this.priorityQueueBufferSize = priorityQueueBufferSize; + this.isCompleted = false; + this.sortOrders = this.queryInfo.orderBy; + const comparator = new OrderByComparator(this.sortOrders); + this.aggregateMap = new NonStreamingOrderByMap((a, b) => { + return comparator.compareItems(a, b); + }); + this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue((a, b) => { + return comparator.compareItems(b, a); + }, this.priorityQueueBufferSize); + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + // if size is 0, just return undefined. Valid if query is TOP 0 or LIMIT 0 + if (this.priorityQueueBufferSize === 0) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + let resHeaders = getInitialHeader(); + if (!this.isCompleted && this.executionContext.hasMoreResults()) { + // Grab the next result + const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + resHeaders = headers; + if (result) { + // make hash of result object and update the map if required. + const key = await hashObject(result === null || result === void 0 ? void 0 : result.payload); + this.aggregateMap.set(key, result); + } + if (!this.executionContext.hasMoreResults()) { + this.isCompleted = true; + await this.buildFinalResultArray(); + } + } + if (this.isCompleted) { + // start returning the results if final result is computed. + if (this.finalResultArray.length > 0) { + return { + result: this.finalResultArray.shift(), + headers: resHeaders, + }; + } + else { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + } + else { + // keep returning empty till final results are getting computed. + return { + result: {}, + headers: resHeaders, + }; + } + } + /** + * Build final sorted result array from which responses will be served. + */ + async buildFinalResultArray() { + var _a; + const allValues = this.aggregateMap.getAllValues(); + for (const value of allValues) { + this.nonStreamingOrderByPQ.enqueue(value); + } + const offSet = this.queryInfo.offset ? this.queryInfo.offset : 0; + const queueSize = this.nonStreamingOrderByPQ.size(); + const finalArraySize = queueSize - offSet; + if (finalArraySize <= 0) { + this.finalResultArray = []; + } + else { + this.finalResultArray = new Array(finalArraySize); + for (let count = finalArraySize - 1; count >= 0; count--) { + this.finalResultArray[count] = (_a = this.nonStreamingOrderByPQ.dequeue()) === null || _a === void 0 ? void 0 : _a.payload; + } + } + } + hasMoreResults() { + if (this.priorityQueueBufferSize === 0) + return false; + return this.executionContext.hasMoreResults() || this.finalResultArray.length > 0; + } +} +//# sourceMappingURL=NonStreamingOrderByDistinctEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map new file mode 100644 index 000000000..6556fae32 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NonStreamingOrderByDistinctEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,cAAc;AACd,MAAM,OAAO,4CAA4C;IAOvD,YACU,gBAAkC,EAClC,SAAo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,IAAI,EAAE,CAAC;QACpD,MAAM,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC;QAE1C,IAAI,cAAc,IAAI,CAAC,EAAE;YACvB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;SAC5B;aAAM;YACL,IAAI,CAAC,gBAAgB,GAAG,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC;YAElD,KAAK,IAAI,KAAK,GAAG,cAAc,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE;gBACxD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAA,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,0CAAE,OAAO,CAAC;aAC9E;SACF;IACH,CAAC;IAEM,cAAc;QACnB,IAAI,IAAI,CAAC,uBAAuB,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QACrD,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;IACpF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryInfo, QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { getInitialHeader } from \"../headerUtils\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { RUConsumedManager } from \"../../common\";\nimport { NonStreamingOrderByResult } from \"../nonStreamingOrderByResult\";\nimport { NonStreamingOrderByResponse } from \"../nonStreamingOrderByResponse\";\nimport { NonStreamingOrderByPriorityQueue } from \"../../utils/nonStreamingOrderByPriorityQueue\";\nimport { NonStreamingOrderByMap } from \"../../utils/nonStreamingOrderByMap\";\nimport { OrderByComparator } from \"../orderByComparator\";\n\n/** @hidden */\nexport class NonStreamingOrderByDistinctEndpointComponent implements ExecutionContext {\n private aggregateMap: NonStreamingOrderByMap; // map to store distinct values before storing in pq.\n private nonStreamingOrderByPQ: NonStreamingOrderByPriorityQueue; // pq to compute final orderBy results\n private finalResultArray: NonStreamingOrderByResult[]; // result array to store final sorted and orderBy results.\n private sortOrders: string[];\n private isCompleted: boolean = false;\n\n constructor(\n private executionContext: ExecutionContext,\n private queryInfo: QueryInfo,\n private priorityQueueBufferSize: number,\n ) {\n this.sortOrders = this.queryInfo.orderBy;\n const comparator = new OrderByComparator(this.sortOrders);\n this.aggregateMap = new NonStreamingOrderByMap(\n (a: NonStreamingOrderByResult, b: NonStreamingOrderByResult) => {\n return comparator.compareItems(a, b);\n },\n );\n this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue(\n (a: NonStreamingOrderByResult, b: NonStreamingOrderByResult) => {\n return comparator.compareItems(b, a);\n },\n this.priorityQueueBufferSize,\n );\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // if size is 0, just return undefined. Valid if query is TOP 0 or LIMIT 0\n if (this.priorityQueueBufferSize === 0) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n let resHeaders = getInitialHeader();\n if (!this.isCompleted && this.executionContext.hasMoreResults()) {\n // Grab the next result\n const { result, headers } = (await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )) as NonStreamingOrderByResponse;\n resHeaders = headers;\n if (result) {\n // make hash of result object and update the map if required.\n const key = await hashObject(result?.payload);\n this.aggregateMap.set(key, result);\n }\n\n if (!this.executionContext.hasMoreResults()) {\n this.isCompleted = true;\n await this.buildFinalResultArray();\n }\n }\n if (this.isCompleted) {\n // start returning the results if final result is computed.\n if (this.finalResultArray.length > 0) {\n return {\n result: this.finalResultArray.shift(),\n headers: resHeaders,\n };\n } else {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n } else {\n // keep returning empty till final results are getting computed.\n return {\n result: {},\n headers: resHeaders,\n };\n }\n }\n /**\n * Build final sorted result array from which responses will be served.\n */\n private async buildFinalResultArray(): Promise {\n const allValues = this.aggregateMap.getAllValues();\n for (const value of allValues) {\n this.nonStreamingOrderByPQ.enqueue(value);\n }\n const offSet = this.queryInfo.offset ? this.queryInfo.offset : 0;\n const queueSize = this.nonStreamingOrderByPQ.size();\n const finalArraySize = queueSize - offSet;\n\n if (finalArraySize <= 0) {\n this.finalResultArray = [];\n } else {\n this.finalResultArray = new Array(finalArraySize);\n\n for (let count = finalArraySize - 1; count >= 0; count--) {\n this.finalResultArray[count] = this.nonStreamingOrderByPQ.dequeue()?.payload;\n }\n }\n }\n\n public hasMoreResults(): boolean {\n if (this.priorityQueueBufferSize === 0) return false;\n return this.executionContext.hasMoreResults() || this.finalResultArray.length > 0;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts new file mode 100644 index 000000000..77eb0844c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts @@ -0,0 +1,27 @@ +import { RUConsumedManager } from "../../common/RUConsumedManager"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +export declare class NonStreamingOrderByEndpointComponent implements ExecutionContext { + private executionContext; + private sortOrders; + private priorityQueueBufferSize; + private offset; + private nonStreamingOrderByPQ; + private isCompleted; + /** + * Represents an endpoint in handling an non-streaming order by query. For each processed orderby + * result it returns 'payload' item of the result + * + * @param executionContext - Underlying Execution Context + * @hidden + */ + constructor(executionContext: ExecutionContext, sortOrders: any[], priorityQueueBufferSize?: number, offset?: number); + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + /** + * Determine if there are still remaining resources to processs. + * @returns true if there is other elements to process in the NonStreamingOrderByEndpointComponent. + */ + hasMoreResults(): boolean; +} +//# sourceMappingURL=NonStreamingOrderByEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts.map new file mode 100644 index 000000000..67068f01a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"NonStreamingOrderByEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAMvD,qBAAa,oCAAqC,YAAW,gBAAgB;IAWzE,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,uBAAuB;IAC/B,OAAO,CAAC,MAAM;IAbhB,OAAO,CAAC,qBAAqB,CAA8D;IAC3F,OAAO,CAAC,WAAW,CAAkB;IACrC;;;;;;OAMG;gBAEO,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,GAAG,EAAE,EACjB,uBAAuB,GAAE,MAAa,EACtC,MAAM,GAAE,MAAU;IAWf,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAgEzB;;;OAGG;IACI,cAAc,IAAI,OAAO;CAMjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js new file mode 100644 index 000000000..50a8a1133 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js @@ -0,0 +1,92 @@ +import { OrderByComparator } from "../orderByComparator"; +import { NonStreamingOrderByPriorityQueue } from "../../utils/nonStreamingOrderByPriorityQueue"; +import { getInitialHeader } from "../headerUtils"; +import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError"; +export class NonStreamingOrderByEndpointComponent { + /** + * Represents an endpoint in handling an non-streaming order by query. For each processed orderby + * result it returns 'payload' item of the result + * + * @param executionContext - Underlying Execution Context + * @hidden + */ + constructor(executionContext, sortOrders, priorityQueueBufferSize = 2000, offset = 0) { + this.executionContext = executionContext; + this.sortOrders = sortOrders; + this.priorityQueueBufferSize = priorityQueueBufferSize; + this.offset = offset; + this.isCompleted = false; + const comparator = new OrderByComparator(this.sortOrders); + this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue((a, b) => { + return comparator.compareItems(b, a); + }, this.priorityQueueBufferSize); + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + var _a, _b; + if (this.priorityQueueBufferSize <= 0 || + (this.isCompleted && this.nonStreamingOrderByPQ.isEmpty())) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + if (this.isCompleted && !this.nonStreamingOrderByPQ.isEmpty()) { + const item = (_a = this.nonStreamingOrderByPQ.dequeue()) === null || _a === void 0 ? void 0 : _a.payload; + return { + result: item, + headers: getInitialHeader(), + }; + } + try { + if (this.executionContext.hasMoreResults()) { + const { result: item, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + if (item !== undefined) { + this.nonStreamingOrderByPQ.enqueue(item); + } + return { + result: {}, + headers, + }; + } + else { + this.isCompleted = true; + // Reverse the priority queue to get the results in the correct order + this.nonStreamingOrderByPQ = this.nonStreamingOrderByPQ.reverse(); + // For offset limit case we set the size of priority queue to offset + limit + // and we drain offset number of items from the priority queue + while (this.offset < this.priorityQueueBufferSize && this.offset > 0) { + this.nonStreamingOrderByPQ.dequeue(); + this.offset--; + } + if (this.nonStreamingOrderByPQ.size() !== 0) { + const item = (_b = this.nonStreamingOrderByPQ.dequeue()) === null || _b === void 0 ? void 0 : _b.payload; + return { + result: item, + headers: getInitialHeader(), + }; + } + else { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + /** + * Determine if there are still remaining resources to processs. + * @returns true if there is other elements to process in the NonStreamingOrderByEndpointComponent. + */ + hasMoreResults() { + return (this.priorityQueueBufferSize > 0 && + (this.executionContext.hasMoreResults() || this.nonStreamingOrderByPQ.size() !== 0)); + } +} +//# sourceMappingURL=NonStreamingOrderByEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map new file mode 100644 index 000000000..256a8586c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"NonStreamingOrderByEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/NonStreamingO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,EAAE;qBAC5B,CAAC;iBACH;aACF;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAED;;;OAGG;IACI,cAAc;QACnB,OAAO,CACL,IAAI,CAAC,uBAAuB,GAAG,CAAC;YAChC,CAAC,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,IAAI,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CACpF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { RUConsumedManager } from \"../../common/RUConsumedManager\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { OrderByComparator } from \"../orderByComparator\";\nimport { NonStreamingOrderByResult } from \"../nonStreamingOrderByResult\";\nimport { NonStreamingOrderByPriorityQueue } from \"../../utils/nonStreamingOrderByPriorityQueue\";\nimport { getInitialHeader } from \"../headerUtils\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nexport class NonStreamingOrderByEndpointComponent implements ExecutionContext {\n private nonStreamingOrderByPQ: NonStreamingOrderByPriorityQueue;\n private isCompleted: boolean = false;\n /**\n * Represents an endpoint in handling an non-streaming order by query. For each processed orderby\n * result it returns 'payload' item of the result\n *\n * @param executionContext - Underlying Execution Context\n * @hidden\n */\n constructor(\n private executionContext: ExecutionContext,\n private sortOrders: any[],\n private priorityQueueBufferSize: number = 2000,\n private offset: number = 0,\n ) {\n const comparator = new OrderByComparator(this.sortOrders);\n this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue(\n (a: NonStreamingOrderByResult, b: NonStreamingOrderByResult) => {\n return comparator.compareItems(b, a);\n },\n this.priorityQueueBufferSize,\n );\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (\n this.priorityQueueBufferSize <= 0 ||\n (this.isCompleted && this.nonStreamingOrderByPQ.isEmpty())\n ) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n if (this.isCompleted && !this.nonStreamingOrderByPQ.isEmpty()) {\n const item = this.nonStreamingOrderByPQ.dequeue()?.payload;\n return {\n result: item,\n headers: getInitialHeader(),\n };\n }\n try {\n if (this.executionContext.hasMoreResults()) {\n const { result: item, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (item !== undefined) {\n this.nonStreamingOrderByPQ.enqueue(item);\n }\n return {\n result: {},\n headers,\n };\n } else {\n this.isCompleted = true;\n // Reverse the priority queue to get the results in the correct order\n this.nonStreamingOrderByPQ = this.nonStreamingOrderByPQ.reverse();\n // For offset limit case we set the size of priority queue to offset + limit\n // and we drain offset number of items from the priority queue\n while (this.offset < this.priorityQueueBufferSize && this.offset > 0) {\n this.nonStreamingOrderByPQ.dequeue();\n this.offset--;\n }\n\n if (this.nonStreamingOrderByPQ.size() !== 0) {\n const item = this.nonStreamingOrderByPQ.dequeue()?.payload;\n return {\n result: item,\n headers: getInitialHeader(),\n };\n } else {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n }\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n /**\n * Determine if there are still remaining resources to processs.\n * @returns true if there is other elements to process in the NonStreamingOrderByEndpointComponent.\n */\n public hasMoreResults(): boolean {\n return (\n this.priorityQueueBufferSize > 0 &&\n (this.executionContext.hasMoreResults() || this.nonStreamingOrderByPQ.size() !== 0)\n );\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts new file mode 100644 index 000000000..194e4504d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts @@ -0,0 +1,14 @@ +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +import { RUConsumedManager } from "../../common"; +/** @hidden */ +export declare class OffsetLimitEndpointComponent implements ExecutionContext { + private executionContext; + private offset; + private limit; + constructor(executionContext: ExecutionContext, offset: number, limit: number); + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + hasMoreResults(): boolean; +} +//# sourceMappingURL=OffsetLimitEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts.map new file mode 100644 index 000000000..26ca8b845 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"OffsetLimitEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,4BAA6B,YAAW,gBAAgB;IAEjE,OAAO,CAAC,gBAAgB;IACxB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,KAAK;gBAFL,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM;IAGV,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAoClB,cAAc,IAAI,OAAO;CAGjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js new file mode 100644 index 000000000..cec733fe2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js @@ -0,0 +1,42 @@ +import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError"; +import { getInitialHeader, mergeHeaders } from "../headerUtils"; +/** @hidden */ +export class OffsetLimitEndpointComponent { + constructor(executionContext, offset, limit) { + this.executionContext = executionContext; + this.offset = offset; + this.limit = limit; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + const aggregateHeaders = getInitialHeader(); + try { + while (this.offset > 0) { + // Grab next item but ignore the result. We only need the headers + const { headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + this.offset--; + mergeHeaders(aggregateHeaders, headers); + } + if (this.limit > 0) { + const { result, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + this.limit--; + mergeHeaders(aggregateHeaders, headers); + return { result, headers: aggregateHeaders }; + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + // If both limit and offset are 0, return nothing + return { + result: undefined, + headers: getInitialHeader(), + }; + } + hasMoreResults() { + return (this.offset > 0 || this.limit > 0) && this.executionContext.hasMoreResults(); + } +} +//# sourceMappingURL=OffsetLimitEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map new file mode 100644 index 000000000..ffcbeb7ed --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OffsetLimitEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAElG,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGhE,cAAc;AACd,MAAM,OAAO,4BAA4B;IACvC,YACU,gBAAkC,EAClC,MAAc,EACd,KAAa;QAFb,qBAAgB,GAAhB,gBAAgB,CAAkB;QAClC,WAAM,GAAN,MAAM,CAAQ;QACd,UAAK,GAAL,KAAK,CAAQ;IACpB,CAAC;IAEG,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,MAAM,gBAAgB,GAAG,gBAAgB,EAAE,CAAC;QAC5C,IAAI;YACF,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;gBACtB,iEAAiE;gBACjE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CACtD,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;gBACF,IAAI,CAAC,MAAM,EAAE,CAAC;gBACd,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;aACzC;YACD,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE;gBAClB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC9D,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;gBACF,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,YAAY,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;gBACxC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;aAC9C;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;QACD,iDAAiD;QACjD,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,gBAAgB,EAAE;SAC5B,CAAC;IACJ,CAAC;IAEM,cAAc;QACnB,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IACvF,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OffsetLimitEndpointComponent implements ExecutionContext {\n constructor(\n private executionContext: ExecutionContext,\n private offset: number,\n private limit: number,\n ) {}\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n const aggregateHeaders = getInitialHeader();\n try {\n while (this.offset > 0) {\n // Grab next item but ignore the result. We only need the headers\n const { headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.offset--;\n mergeHeaders(aggregateHeaders, headers);\n }\n if (this.limit > 0) {\n const { result, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.limit--;\n mergeHeaders(aggregateHeaders, headers);\n return { result, headers: aggregateHeaders };\n }\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n // If both limit and offset are 0, return nothing\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n public hasMoreResults(): boolean {\n return (this.offset > 0 || this.limit > 0) && this.executionContext.hasMoreResults();\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts new file mode 100644 index 000000000..9b8400a13 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts @@ -0,0 +1,26 @@ +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +import { RUConsumedManager } from "../../common"; +/** @hidden */ +export declare class OrderByEndpointComponent implements ExecutionContext { + private executionContext; + /** + * Represents an endpoint in handling an order by query. For each processed orderby + * result it returns 'payload' item of the result + * + * @param executionContext - Underlying Execution Context + * @hidden + */ + constructor(executionContext: ExecutionContext); + /** + * Execute a provided function on the next element in the OrderByEndpointComponent. + */ + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + /** + * Determine if there are still remaining resources to processs. + * @returns true if there is other elements to process in the OrderByEndpointComponent. + */ + hasMoreResults(): boolean; +} +//# sourceMappingURL=OrderByEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts.map new file mode 100644 index 000000000..81b7692cd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"OrderByEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,wBAAyB,YAAW,gBAAgB;IAQnD,OAAO,CAAC,gBAAgB;IAPpC;;;;;;OAMG;gBACiB,gBAAgB,EAAE,gBAAgB;IACtD;;OAEG;IACU,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAmBzB;;;OAGG;IACI,cAAc,IAAI,OAAO;CAGjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js new file mode 100644 index 000000000..37b87bbf1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js @@ -0,0 +1,40 @@ +import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError"; +/** @hidden */ +export class OrderByEndpointComponent { + /** + * Represents an endpoint in handling an order by query. For each processed orderby + * result it returns 'payload' item of the result + * + * @param executionContext - Underlying Execution Context + * @hidden + */ + constructor(executionContext) { + this.executionContext = executionContext; + } + /** + * Execute a provided function on the next element in the OrderByEndpointComponent. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { result: item, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + return { + result: item !== undefined ? item.payload : undefined, + headers, + }; + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + /** + * Determine if there are still remaining resources to processs. + * @returns true if there is other elements to process in the OrderByEndpointComponent. + */ + hasMoreResults() { + return this.executionContext.hasMoreResults(); + } +} +//# sourceMappingURL=OrderByEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map new file mode 100644 index 000000000..05094a10c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OrderByEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAIlG,cAAc;AACd,MAAM,OAAO,wBAAwB;IACnC;;;;;;OAMG;IACH,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAC1D;;OAEG;IACI,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,IAAI;YACF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CACpE,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;YACF,OAAO;gBACL,MAAM,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;gBACrD,OAAO;aACR,CAAC;SACH;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAED;;;OAGG;IACI,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OrderByEndpointComponent implements ExecutionContext {\n /**\n * Represents an endpoint in handling an order by query. For each processed orderby\n * result it returns 'payload' item of the result\n *\n * @param executionContext - Underlying Execution Context\n * @hidden\n */\n constructor(private executionContext: ExecutionContext) {}\n /**\n * Execute a provided function on the next element in the OrderByEndpointComponent.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { result: item, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n return {\n result: item !== undefined ? item.payload : undefined,\n headers,\n };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n /**\n * Determine if there are still remaining resources to processs.\n * @returns true if there is other elements to process in the OrderByEndpointComponent.\n */\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts new file mode 100644 index 000000000..1d4fcecc5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts @@ -0,0 +1,13 @@ +import { QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { RUConsumedManager } from "../../common"; +/** @hidden */ +export declare class OrderedDistinctEndpointComponent implements ExecutionContext { + private executionContext; + private hashedLastResult; + constructor(executionContext: ExecutionContext); + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + hasMoreResults(): boolean; +} +//# sourceMappingURL=OrderedDistinctEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts.map new file mode 100644 index 000000000..12882a32f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"OrderedDistinctEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,gCAAiC,YAAW,gBAAgB;IAE3D,OAAO,CAAC,gBAAgB;IADpC,OAAO,CAAC,gBAAgB,CAAS;gBACb,gBAAgB,EAAE,gBAAgB;IAEzC,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAuBlB,cAAc,IAAI,OAAO;CAGjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js new file mode 100644 index 000000000..e2e5c2114 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js @@ -0,0 +1,31 @@ +import { hashObject } from "../../utils/hashObject"; +import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError"; +/** @hidden */ +export class OrderedDistinctEndpointComponent { + constructor(executionContext) { + this.executionContext = executionContext; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { headers, result } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + if (result) { + const hashedResult = await hashObject(result); + if (hashedResult === this.hashedLastResult) { + return { result: undefined, headers }; + } + this.hashedLastResult = hashedResult; + } + return { result, headers }; + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + hasMoreResults() { + return this.executionContext.hasMoreResults(); + } +} +//# sourceMappingURL=OrderedDistinctEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map new file mode 100644 index 000000000..068199933 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OrderedDistinctEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAGlG,cAAc;AACd,MAAM,OAAO,gCAAgC;IAE3C,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAEnD,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,IAAI;YACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC9D,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;YACF,IAAI,MAAM,EAAE;gBACV,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC9C,IAAI,YAAY,KAAK,IAAI,CAAC,gBAAgB,EAAE;oBAC1C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;iBACvC;gBACD,IAAI,CAAC,gBAAgB,GAAG,YAAY,CAAC;aACtC;YACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SAC5B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OrderedDistinctEndpointComponent implements ExecutionContext {\n private hashedLastResult: string;\n constructor(private executionContext: ExecutionContext) {}\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { headers, result } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (result) {\n const hashedResult = await hashObject(result);\n if (hashedResult === this.hashedLastResult) {\n return { result: undefined, headers };\n }\n this.hashedLastResult = hashedResult;\n }\n return { result, headers };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts new file mode 100644 index 000000000..cc6bbabaa --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts @@ -0,0 +1,13 @@ +import { QueryOperationOptions, Response } from "../../request"; +import { ExecutionContext } from "../ExecutionContext"; +import { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import { RUConsumedManager } from "../../common"; +/** @hidden */ +export declare class UnorderedDistinctEndpointComponent implements ExecutionContext { + private executionContext; + private hashedResults; + constructor(executionContext: ExecutionContext); + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + hasMoreResults(): boolean; +} +//# sourceMappingURL=UnorderedDistinctEndpointComponent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts.map new file mode 100644 index 000000000..4afabaf4f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"UnorderedDistinctEndpointComponent.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAElF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,cAAc;AACd,qBAAa,kCAAmC,YAAW,gBAAgB;IAE7D,OAAO,CAAC,gBAAgB;IADpC,OAAO,CAAC,aAAa,CAAc;gBACf,gBAAgB,EAAE,gBAAgB;IAIzC,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAuBlB,cAAc,IAAI,OAAO;CAGjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js new file mode 100644 index 000000000..52fd1cc9c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js @@ -0,0 +1,32 @@ +import { hashObject } from "../../utils/hashObject"; +import { RUCapPerOperationExceededErrorCode } from "../../request/RUCapPerOperationExceededError"; +/** @hidden */ +export class UnorderedDistinctEndpointComponent { + constructor(executionContext) { + this.executionContext = executionContext; + this.hashedResults = new Set(); + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { headers, result } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + if (result) { + const hashedResult = await hashObject(result); + if (this.hashedResults.has(hashedResult)) { + return { result: undefined, headers }; + } + this.hashedResults.add(hashedResult); + } + return { result, headers }; + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + hasMoreResults() { + return this.executionContext.hasMoreResults(); + } +} +//# sourceMappingURL=UnorderedDistinctEndpointComponent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map new file mode 100644 index 000000000..9e26f4e8f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"UnorderedDistinctEndpointComponent.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,kCAAkC,EAAE,MAAM,8CAA8C,CAAC;AAGlG,cAAc;AACd,MAAM,OAAO,kCAAkC;IAE7C,YAAoB,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;QACpD,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,EAAE,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,QAAQ,CACnB,cAAsC,EACtC,gBAAwC,EACxC,iBAAqC;QAErC,IAAI;YACF,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAC9D,cAAc,EACd,gBAAgB,EAChB,iBAAiB,CAClB,CAAC;YACF,IAAI,MAAM,EAAE;gBACV,MAAM,YAAY,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC9C,IAAI,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;oBACxC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;iBACvC;gBACD,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;aACtC;YACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SAC5B;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAkC,EAAE;gBACnD,GAAG,CAAC,cAAc,GAAG,SAAS,CAAC;aAChC;YACD,MAAM,GAAG,CAAC;SACX;IACH,CAAC;IAEM,cAAc;QACnB,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class UnorderedDistinctEndpointComponent implements ExecutionContext {\n private hashedResults: Set;\n constructor(private executionContext: ExecutionContext) {\n this.hashedResults = new Set();\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { headers, result } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (result) {\n const hashedResult = await hashObject(result);\n if (this.hashedResults.has(hashedResult)) {\n return { result: undefined, headers };\n }\n this.hashedResults.add(hashedResult);\n }\n return { result, headers };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts new file mode 100644 index 000000000..e5a3ddfc3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts @@ -0,0 +1,6 @@ +export declare const emptyGroup = "__empty__"; +export declare const extractAggregateResult: (payload: { + item2?: unknown; + item: unknown; +}) => any; +//# sourceMappingURL=emptyGroup.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts.map new file mode 100644 index 000000000..bc354ad90 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"emptyGroup.d.ts","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/emptyGroup.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,UAAU,cAAc,CAAC;AAItC,eAAO,MAAM,sBAAsB,YAAa;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,KAAG,GACI,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js new file mode 100644 index 000000000..6e5f51add --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// All aggregates are effectively a group by operation +// The empty group is used for aggregates without a GROUP BY clause +export const emptyGroup = "__empty__"; +// Newer API versions rewrite the query to return `item2`. It fixes some legacy issues with the original `item` result +// Aggregator code should use item2 when available +export const extractAggregateResult = (payload) => Object.keys(payload).length > 0 ? (payload.item2 ? payload.item2 : payload.item) : null; +//# sourceMappingURL=emptyGroup.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js.map new file mode 100644 index 000000000..a0a93c833 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/EndpointComponent/emptyGroup.js.map @@ -0,0 +1 @@ +{"version":3,"file":"emptyGroup.js","sourceRoot":"","sources":["../../../../src/queryExecutionContext/EndpointComponent/emptyGroup.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,sDAAsD;AACtD,mEAAmE;AACnE,MAAM,CAAC,MAAM,UAAU,GAAG,WAAW,CAAC;AAEtC,sHAAsH;AACtH,kDAAkD;AAClD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAA2C,EAAO,EAAE,CACzF,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// All aggregates are effectively a group by operation\n// The empty group is used for aggregates without a GROUP BY clause\nexport const emptyGroup = \"__empty__\";\n\n// Newer API versions rewrite the query to return `item2`. It fixes some legacy issues with the original `item` result\n// Aggregator code should use item2 when available\nexport const extractAggregateResult = (payload: { item2?: unknown; item: unknown }): any =>\n Object.keys(payload).length > 0 ? (payload.item2 ? payload.item2 : payload.item) : null;\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts new file mode 100644 index 000000000..d91811178 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts @@ -0,0 +1,10 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { QueryOperationOptions, Response } from "../request"; +import { RUConsumedManager } from "../common"; +/** @hidden */ +export interface ExecutionContext { + nextItem: (diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumed?: RUConsumedManager) => Promise>; + hasMoreResults: () => boolean; + fetchMore?: (diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumed?: RUConsumedManager) => Promise>; +} +//# sourceMappingURL=ExecutionContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts.map new file mode 100644 index 000000000..0ed509eb4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/ExecutionContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,cAAc;AACd,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,CACR,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,UAAU,CAAC,EAAE,iBAAiB,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,cAAc,EAAE,MAAM,OAAO,CAAC;IAC9B,SAAS,CAAC,EAAE,CACV,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,UAAU,CAAC,EAAE,iBAAiB,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js new file mode 100644 index 000000000..45811ce31 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=ExecutionContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js.map new file mode 100644 index 000000000..368d8e448 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/ExecutionContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ExecutionContext.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/ExecutionContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../request\";\nimport { RUConsumedManager } from \"../common\";\n\n/** @hidden */\nexport interface ExecutionContext {\n nextItem: (\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumed?: RUConsumedManager,\n ) => Promise>;\n hasMoreResults: () => boolean;\n fetchMore?: (\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumed?: RUConsumedManager,\n ) => Promise>; // TODO: code smell\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts new file mode 100644 index 000000000..fb97cefea --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts @@ -0,0 +1,22 @@ +/** @hidden */ +export declare enum FetchResultType { + "Done" = 0, + "Exception" = 1, + "Result" = 2 +} +/** @hidden */ +export declare class FetchResult { + feedResponse: any; + fetchResultType: FetchResultType; + error: any; + /** + * Wraps fetch results for the document producer. + * This allows the document producer to buffer exceptions so that actual results don't get flushed during splits. + * + * @param feedReponse - The response the document producer got back on a successful fetch + * @param error - The exception meant to be buffered on an unsuccessful fetch + * @hidden + */ + constructor(feedResponse: unknown, error: unknown); +} +//# sourceMappingURL=FetchResult.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts.map new file mode 100644 index 000000000..ba90b6b06 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"FetchResult.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/FetchResult.ts"],"names":[],"mappings":"AAEA,cAAc;AACd,oBAAY,eAAe;IACzB,MAAM,IAAI;IACV,WAAW,IAAI;IACf,QAAQ,IAAI;CACb;AAED,cAAc;AACd,qBAAa,WAAW;IACf,YAAY,EAAE,GAAG,CAAC;IAClB,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,EAAE,GAAG,CAAC;IAClB;;;;;;;OAOG;gBACS,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO;CAUlD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js new file mode 100644 index 000000000..8f040afe9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +export var FetchResultType; +(function (FetchResultType) { + FetchResultType[FetchResultType["Done"] = 0] = "Done"; + FetchResultType[FetchResultType["Exception"] = 1] = "Exception"; + FetchResultType[FetchResultType["Result"] = 2] = "Result"; +})(FetchResultType || (FetchResultType = {})); +/** @hidden */ +export class FetchResult { + /** + * Wraps fetch results for the document producer. + * This allows the document producer to buffer exceptions so that actual results don't get flushed during splits. + * + * @param feedReponse - The response the document producer got back on a successful fetch + * @param error - The exception meant to be buffered on an unsuccessful fetch + * @hidden + */ + constructor(feedResponse, error) { + // TODO: feedResponse/error + if (feedResponse !== undefined) { + this.feedResponse = feedResponse; + this.fetchResultType = FetchResultType.Result; + } + else { + this.error = error; + this.fetchResultType = FetchResultType.Exception; + } + } +} +//# sourceMappingURL=FetchResult.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js.map new file mode 100644 index 000000000..2145beade --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/FetchResult.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FetchResult.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/FetchResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc;AACd,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,qDAAU,CAAA;IACV,+DAAe,CAAA;IACf,yDAAY,CAAA;AACd,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED,cAAc;AACd,MAAM,OAAO,WAAW;IAItB;;;;;;;OAOG;IACH,YAAY,YAAqB,EAAE,KAAc;QAC/C,2BAA2B;QAC3B,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;YACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC;SAC/C;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;YACnB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC,SAAS,CAAC;SAClD;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** @hidden */\nexport enum FetchResultType {\n \"Done\" = 0,\n \"Exception\" = 1,\n \"Result\" = 2,\n}\n\n/** @hidden */\nexport class FetchResult {\n public feedResponse: any;\n public fetchResultType: FetchResultType;\n public error: any;\n /**\n * Wraps fetch results for the document producer.\n * This allows the document producer to buffer exceptions so that actual results don't get flushed during splits.\n *\n * @param feedReponse - The response the document producer got back on a successful fetch\n * @param error - The exception meant to be buffered on an unsuccessful fetch\n * @hidden\n */\n constructor(feedResponse: unknown, error: unknown) {\n // TODO: feedResponse/error\n if (feedResponse !== undefined) {\n this.feedResponse = feedResponse;\n this.fetchResultType = FetchResultType.Result;\n } else {\n this.error = error;\n this.fetchResultType = FetchResultType.Exception;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts new file mode 100644 index 000000000..e76e62371 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts @@ -0,0 +1,37 @@ +/** + * Represents a SQL query in the Azure Cosmos DB service. + * + * Queries with inputs should be parameterized to protect against SQL injection. + * + * @example Parameterized SQL Query + * ```typescript + * const query: SqlQuerySpec = { + * query: "SELECT * FROM Families f where f.lastName = @lastName", + * parameters: [ + * {name: "@lastName", value: "Wakefield"} + * ] + * }; + * ``` + */ +export interface SqlQuerySpec { + /** The text of the SQL query */ + query: string; + /** The parameters you provide in the query */ + parameters?: SqlParameter[]; +} +/** + * Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec} + */ +export interface SqlParameter { + /** Name of the parameter. (i.e. `@lastName`) */ + name: string; + /** Value of the parameter (this is safe to come from users, assuming they are authorized) */ + value: JSONValue; +} +export type JSONValue = boolean | number | string | null | JSONArray | JSONObject; +export interface JSONObject { + [key: string]: JSONValue; +} +export interface JSONArray extends ArrayLike { +} +//# sourceMappingURL=SqlQuerySpec.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts.map new file mode 100644 index 000000000..580027952 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"SqlQuerySpec.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/SqlQuerySpec.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,8CAA8C;IAC9C,UAAU,CAAC,EAAE,YAAY,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,6FAA6F;IAC7F,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,CAAC;AAClF,MAAM,WAAW,UAAU;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1B;AACD,MAAM,WAAW,SAAU,SAAQ,SAAS,CAAC,SAAS,CAAC;CAAG"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js new file mode 100644 index 000000000..6ba9f7d25 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=SqlQuerySpec.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js.map new file mode 100644 index 000000000..3960534f5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/SqlQuerySpec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SqlQuerySpec.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/SqlQuerySpec.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents a SQL query in the Azure Cosmos DB service.\n *\n * Queries with inputs should be parameterized to protect against SQL injection.\n *\n * @example Parameterized SQL Query\n * ```typescript\n * const query: SqlQuerySpec = {\n * query: \"SELECT * FROM Families f where f.lastName = @lastName\",\n * parameters: [\n * {name: \"@lastName\", value: \"Wakefield\"}\n * ]\n * };\n * ```\n */\nexport interface SqlQuerySpec {\n /** The text of the SQL query */\n query: string;\n /** The parameters you provide in the query */\n parameters?: SqlParameter[];\n}\n\n/**\n * Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec}\n */\nexport interface SqlParameter {\n /** Name of the parameter. (i.e. `@lastName`) */\n name: string;\n /** Value of the parameter (this is safe to come from users, assuming they are authorized) */\n value: JSONValue;\n}\n\nexport type JSONValue = boolean | number | string | null | JSONArray | JSONObject;\nexport interface JSONObject {\n [key: string]: JSONValue;\n}\nexport interface JSONArray extends ArrayLike {}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts new file mode 100644 index 000000000..25f57c50d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts @@ -0,0 +1,52 @@ +import { RUConsumedManager } from "../common"; +import { FeedOptions, QueryOperationOptions, Response } from "../request"; +import { ExecutionContext } from "./index"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +/** @hidden */ +export type FetchFunctionCallback = (diagnosticNode: DiagnosticNodeInternal, options: FeedOptions) => Promise>; +/** @hidden */ +export declare class DefaultQueryExecutionContext implements ExecutionContext { + private static readonly STATES; + private resources; + private currentIndex; + private currentPartitionIndex; + private fetchFunctions; + private options; + continuationToken: string; + get continuation(): string; + private state; + private nextFetchFunction; + /** + * Provides the basic Query Execution Context. + * This wraps the internal logic query execution using provided fetch functions + * + * @param clientContext - Is used to read the partitionKeyRanges for split proofing + * @param query - A SQL query. + * @param options - Represents the feed options. + * @param fetchFunctions - A function to retrieve each page of data. + * An array of functions may be used to query more than one partition. + * @hidden + */ + constructor(options: FeedOptions, fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[]); + /** + * Execute a provided callback on the next element in the execution context. + */ + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + /** + * Retrieve the current element on the execution context. + */ + current(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + /** + * Determine if there are still remaining resources to processs based on + * the value of the continuation token or the elements remaining on the current batch in the execution context. + * + * @returns true if there is other elements to process in the DefaultQueryExecutionContext. + */ + hasMoreResults(): boolean; + /** + * Fetches the next batch of the feed and pass them as an array to a callback + */ + fetchMore(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + private _canFetchMore; +} +//# sourceMappingURL=defaultQueryExecutionContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts.map new file mode 100644 index 000000000..54f126f8f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultQueryExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/defaultQueryExecutionContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAa,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAsB,MAAM,uCAAuC,CAAC;AAMnG,cAAc;AACd,MAAM,MAAM,qBAAqB,GAAG,CAClC,cAAc,EAAE,sBAAsB,EACtC,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAS5B,cAAc;AACd,qBAAa,4BAA6B,YAAW,gBAAgB;IACnE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAU;IACxC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,OAAO,CAAc;IACtB,iBAAiB,EAAE,MAAM,CAAC;IACjC,IAAW,YAAY,IAAI,MAAM,CAEhC;IACD,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,iBAAiB,CAAyB;IAClD;;;;;;;;;;OAUG;gBAED,OAAO,EAAE,WAAW,EACpB,cAAc,EAAE,qBAAqB,GAAG,qBAAqB,EAAE;IAWjE;;OAEG;IACU,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAMzB;;OAEG;IACU,OAAO,CAClB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAgCzB;;;;;OAKG;IACI,cAAc,IAAI,OAAO;IAShC;;OAEG;IACU,SAAS,CACpB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAqHzB,OAAO,CAAC,aAAa;CAQtB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js new file mode 100644 index 000000000..914c3c3b7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js @@ -0,0 +1,192 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createClientLogger } from "@azure/logger"; +import { Constants } from "../common"; +import { ClientSideMetrics, QueryMetrics } from "../queryMetrics"; +import { getInitialHeader, getRequestChargeIfAny } from "./headerUtils"; +import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; +import { addDignosticChild } from "../utils/diagnostics"; +import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel"; +import { RUCapPerOperationExceededError } from "../request/RUCapPerOperationExceededError"; +const logger = createClientLogger("ClientContext"); +/** @hidden */ +var STATES; +(function (STATES) { + STATES["start"] = "start"; + STATES["inProgress"] = "inProgress"; + STATES["ended"] = "ended"; +})(STATES || (STATES = {})); +/** @hidden */ +export class DefaultQueryExecutionContext { + get continuation() { + return this.continuationToken; + } + /** + * Provides the basic Query Execution Context. + * This wraps the internal logic query execution using provided fetch functions + * + * @param clientContext - Is used to read the partitionKeyRanges for split proofing + * @param query - A SQL query. + * @param options - Represents the feed options. + * @param fetchFunctions - A function to retrieve each page of data. + * An array of functions may be used to query more than one partition. + * @hidden + */ + constructor(options, fetchFunctions) { + this.resources = []; + this.currentIndex = 0; + this.currentPartitionIndex = 0; + this.fetchFunctions = Array.isArray(fetchFunctions) ? fetchFunctions : [fetchFunctions]; + this.options = options || {}; + this.continuationToken = this.options.continuationToken || this.options.continuation || null; + this.state = DefaultQueryExecutionContext.STATES.start; + } + /** + * Execute a provided callback on the next element in the execution context. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + ++this.currentIndex; + const response = await this.current(diagnosticNode, operationOptions, ruConsumedManager); + return response; + } + /** + * Retrieve the current element on the execution context. + */ + async current(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.currentIndex < this.resources.length) { + return { + result: this.resources[this.currentIndex], + headers: getInitialHeader(), + }; + } + if (this._canFetchMore()) { + const { result: resources, headers } = await this.fetchMore(diagnosticNode, operationOptions, ruConsumedManager); + this.resources = resources; + if (this.resources.length === 0) { + if (!this.continuationToken && this.currentPartitionIndex >= this.fetchFunctions.length) { + this.state = DefaultQueryExecutionContext.STATES.ended; + return { result: undefined, headers }; + } + else { + return this.current(diagnosticNode, operationOptions, ruConsumedManager); + } + } + return { result: this.resources[this.currentIndex], headers }; + } + else { + this.state = DefaultQueryExecutionContext.STATES.ended; + return { + result: undefined, + headers: getInitialHeader(), + }; + } + } + /** + * Determine if there are still remaining resources to processs based on + * the value of the continuation token or the elements remaining on the current batch in the execution context. + * + * @returns true if there is other elements to process in the DefaultQueryExecutionContext. + */ + hasMoreResults() { + return (this.state === DefaultQueryExecutionContext.STATES.start || + this.continuationToken !== undefined || + this.currentIndex < this.resources.length - 1 || + this.currentPartitionIndex < this.fetchFunctions.length); + } + /** + * Fetches the next batch of the feed and pass them as an array to a callback + */ + async fetchMore(diagnosticNode, operationOptions, ruConsumedManager) { + return addDignosticChild(async (childDiagnosticNode) => { + if (this.currentPartitionIndex >= this.fetchFunctions.length) { + return { + headers: getInitialHeader(), + result: undefined, + }; + } + // Keep to the original continuation and to restore the value after fetchFunction call + const originalContinuation = this.options.continuationToken || this.options.continuation; + this.options.continuationToken = this.continuationToken; + // Return undefined if there is no more results + if (this.currentPartitionIndex >= this.fetchFunctions.length) { + return { + headers: getInitialHeader(), + result: undefined, + }; + } + let resources; + let responseHeaders; + try { + let p; + if (this.nextFetchFunction !== undefined) { + logger.verbose("using prefetch"); + p = this.nextFetchFunction; + this.nextFetchFunction = undefined; + } + else { + logger.verbose("using fresh fetch"); + p = this.fetchFunctions[this.currentPartitionIndex](childDiagnosticNode, this.options); + } + const response = await p; + resources = response.result; + childDiagnosticNode.recordQueryResult(resources, CosmosDbDiagnosticLevel.debugUnsafe); + responseHeaders = response.headers; + this.continuationToken = responseHeaders[Constants.HttpHeaders.Continuation]; + if (!this.continuationToken) { + ++this.currentPartitionIndex; + } + if (this.options && this.options.bufferItems === true) { + const fetchFunction = this.fetchFunctions[this.currentPartitionIndex]; + this.nextFetchFunction = fetchFunction + ? fetchFunction(childDiagnosticNode, Object.assign(Object.assign({}, this.options), { continuationToken: this.continuationToken })) + : undefined; + } + } + catch (err) { + this.state = DefaultQueryExecutionContext.STATES.ended; + // return callback(err, undefined, responseHeaders); + // TODO: Error and data being returned is an antipattern, this might broken + throw err; + } + this.state = DefaultQueryExecutionContext.STATES.inProgress; + this.currentIndex = 0; + this.options.continuationToken = originalContinuation; + this.options.continuation = originalContinuation; + // deserializing query metrics so that we aren't working with delimited strings in the rest of the code base + if (Constants.HttpHeaders.QueryMetrics in responseHeaders) { + const delimitedString = responseHeaders[Constants.HttpHeaders.QueryMetrics]; + let queryMetrics = QueryMetrics.createFromDelimitedString(delimitedString); + // Add the request charge to the query metrics so that we can have per partition request charge. + if (Constants.HttpHeaders.RequestCharge in responseHeaders) { + const requestCharge = Number(responseHeaders[Constants.HttpHeaders.RequestCharge]) || 0; + queryMetrics = new QueryMetrics(queryMetrics.retrievedDocumentCount, queryMetrics.retrievedDocumentSize, queryMetrics.outputDocumentCount, queryMetrics.outputDocumentSize, queryMetrics.indexHitDocumentCount, queryMetrics.totalQueryExecutionTime, queryMetrics.queryPreparationTimes, queryMetrics.indexLookupTime, queryMetrics.documentLoadTime, queryMetrics.vmExecutionTime, queryMetrics.runtimeExecutionTimes, queryMetrics.documentWriteTime, new ClientSideMetrics(requestCharge)); + } + // Wraping query metrics in a object where the key is '0' just so single partition + // and partition queries have the same response schema + responseHeaders[Constants.HttpHeaders.QueryMetrics] = {}; + responseHeaders[Constants.HttpHeaders.QueryMetrics]["0"] = queryMetrics; + } + if (operationOptions && operationOptions.ruCapPerOperation && ruConsumedManager) { + await ruConsumedManager.addToRUConsumed(getRequestChargeIfAny(responseHeaders)); + const ruConsumedValue = await ruConsumedManager.getRUConsumed(); + if (ruConsumedValue > operationOptions.ruCapPerOperation) { + // For RUCapPerOperationExceededError error, we won't be updating the state from + // inProgress as we want to support continue + throw new RUCapPerOperationExceededError("Request Unit limit per Operation call exceeded", resources); + } + } + return { result: resources, headers: responseHeaders }; + }, diagnosticNode, DiagnosticNodeType.DEFAULT_QUERY_NODE, { + queryMethodIdentifier: "fetchMore", + }); + } + _canFetchMore() { + const res = this.state === DefaultQueryExecutionContext.STATES.start || + (this.continuationToken && this.state === DefaultQueryExecutionContext.STATES.inProgress) || + (this.currentPartitionIndex < this.fetchFunctions.length && + this.state === DefaultQueryExecutionContext.STATES.inProgress); + return res; + } +} +DefaultQueryExecutionContext.STATES = STATES; +//# sourceMappingURL=defaultQueryExecutionContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js.map new file mode 100644 index 000000000..912ee717e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/defaultQueryExecutionContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultQueryExecutionContext.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/defaultQueryExecutionContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAe,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,SAAS,EAAqB,MAAM,WAAW,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAA0B,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,MAAM,MAAM,GAAgB,kBAAkB,CAAC,eAAe,CAAC,CAAC;AAOhE,cAAc;AACd,IAAK,MAIJ;AAJD,WAAK,MAAM;IACT,yBAAe,CAAA;IACf,mCAAyB,CAAA;IACzB,yBAAe,CAAA;AACjB,CAAC,EAJI,MAAM,KAAN,MAAM,QAIV;AAED,cAAc;AACd,MAAM,OAAO,4BAA4B;IAQvC,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAChC,CAAC;IAGD;;;;;;;;;;OAUG;IACH,YACE,OAAoB,EACpB,cAA+D;QAE/D,IAAI,CAAC,SAAS,GAA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AA4B,CAAC,MAAM,CAAC,KAAK;YACxD,CAAC,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,KAAK,KAAK,4BAA4B,CAAC,MAAM,CAAC,UAAU,CAAC;YACzF,CAAC,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM;gBACtD,IAAI,CAAC,KAAK,KAAK,4BAA4B,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACnE,OAAO,GAAG,CAAC;IACb,CAAC;;AA1OuB,mCAAM,GAAG,MAAM,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { Constants, RUConsumedManager } from \"../common\";\nimport { ClientSideMetrics, QueryMetrics } from \"../queryMetrics\";\nimport { FeedOptions, QueryOperationOptions, Response } from \"../request\";\nimport { getInitialHeader, getRequestChargeIfAny } from \"./headerUtils\";\nimport { ExecutionContext } from \"./index\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { CosmosDbDiagnosticLevel } from \"../diagnostics/CosmosDbDiagnosticLevel\";\nimport { RUCapPerOperationExceededError } from \"../request/RUCapPerOperationExceededError\";\n\nconst logger: AzureLogger = createClientLogger(\"ClientContext\");\n/** @hidden */\nexport type FetchFunctionCallback = (\n diagnosticNode: DiagnosticNodeInternal,\n options: FeedOptions,\n) => Promise>;\n\n/** @hidden */\nenum STATES {\n start = \"start\",\n inProgress = \"inProgress\",\n ended = \"ended\",\n}\n\n/** @hidden */\nexport class DefaultQueryExecutionContext implements ExecutionContext {\n private static readonly STATES = STATES;\n private resources: any[]; // TODO: any resources\n private currentIndex: number;\n private currentPartitionIndex: number;\n private fetchFunctions: FetchFunctionCallback[];\n private options: FeedOptions; // TODO: any options\n public continuationToken: string; // TODO: any continuation\n public get continuation(): string {\n return this.continuationToken;\n }\n private state: STATES;\n private nextFetchFunction: Promise>;\n /**\n * Provides the basic Query Execution Context.\n * This wraps the internal logic query execution using provided fetch functions\n *\n * @param clientContext - Is used to read the partitionKeyRanges for split proofing\n * @param query - A SQL query.\n * @param options - Represents the feed options.\n * @param fetchFunctions - A function to retrieve each page of data.\n * An array of functions may be used to query more than one partition.\n * @hidden\n */\n constructor(\n options: FeedOptions,\n fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[],\n ) {\n this.resources = [];\n this.currentIndex = 0;\n this.currentPartitionIndex = 0;\n this.fetchFunctions = Array.isArray(fetchFunctions) ? fetchFunctions : [fetchFunctions];\n this.options = options || {};\n this.continuationToken = this.options.continuationToken || this.options.continuation || null;\n this.state = DefaultQueryExecutionContext.STATES.start;\n }\n\n /**\n * Execute a provided callback on the next element in the execution context.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n ++this.currentIndex;\n const response = await this.current(diagnosticNode, operationOptions, ruConsumedManager);\n return response;\n }\n\n /**\n * Retrieve the current element on the execution context.\n */\n public async current(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.currentIndex < this.resources.length) {\n return {\n result: this.resources[this.currentIndex],\n headers: getInitialHeader(),\n };\n }\n if (this._canFetchMore()) {\n const { result: resources, headers } = await this.fetchMore(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.resources = resources;\n if (this.resources.length === 0) {\n if (!this.continuationToken && this.currentPartitionIndex >= this.fetchFunctions.length) {\n this.state = DefaultQueryExecutionContext.STATES.ended;\n return { result: undefined, headers };\n } else {\n return this.current(diagnosticNode, operationOptions, ruConsumedManager);\n }\n }\n return { result: this.resources[this.currentIndex], headers };\n } else {\n this.state = DefaultQueryExecutionContext.STATES.ended;\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n }\n\n /**\n * Determine if there are still remaining resources to processs based on\n * the value of the continuation token or the elements remaining on the current batch in the execution context.\n *\n * @returns true if there is other elements to process in the DefaultQueryExecutionContext.\n */\n public hasMoreResults(): boolean {\n return (\n this.state === DefaultQueryExecutionContext.STATES.start ||\n this.continuationToken !== undefined ||\n this.currentIndex < this.resources.length - 1 ||\n this.currentPartitionIndex < this.fetchFunctions.length\n );\n }\n\n /**\n * Fetches the next batch of the feed and pass them as an array to a callback\n */\n public async fetchMore(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n return addDignosticChild(\n async (childDiagnosticNode: DiagnosticNodeInternal) => {\n if (this.currentPartitionIndex >= this.fetchFunctions.length) {\n return {\n headers: getInitialHeader(),\n result: undefined,\n };\n }\n\n // Keep to the original continuation and to restore the value after fetchFunction call\n const originalContinuation = this.options.continuationToken || this.options.continuation;\n this.options.continuationToken = this.continuationToken;\n\n // Return undefined if there is no more results\n if (this.currentPartitionIndex >= this.fetchFunctions.length) {\n return {\n headers: getInitialHeader(),\n result: undefined,\n };\n }\n\n let resources;\n let responseHeaders;\n try {\n let p: Promise>;\n if (this.nextFetchFunction !== undefined) {\n logger.verbose(\"using prefetch\");\n p = this.nextFetchFunction;\n this.nextFetchFunction = undefined;\n } else {\n logger.verbose(\"using fresh fetch\");\n p = this.fetchFunctions[this.currentPartitionIndex](childDiagnosticNode, this.options);\n }\n const response = await p;\n resources = response.result;\n childDiagnosticNode.recordQueryResult(resources, CosmosDbDiagnosticLevel.debugUnsafe);\n responseHeaders = response.headers;\n this.continuationToken = responseHeaders[Constants.HttpHeaders.Continuation];\n if (!this.continuationToken) {\n ++this.currentPartitionIndex;\n }\n\n if (this.options && this.options.bufferItems === true) {\n const fetchFunction = this.fetchFunctions[this.currentPartitionIndex];\n this.nextFetchFunction = fetchFunction\n ? fetchFunction(childDiagnosticNode, {\n ...this.options,\n continuationToken: this.continuationToken,\n })\n : undefined;\n }\n } catch (err: any) {\n this.state = DefaultQueryExecutionContext.STATES.ended;\n // return callback(err, undefined, responseHeaders);\n // TODO: Error and data being returned is an antipattern, this might broken\n throw err;\n }\n\n this.state = DefaultQueryExecutionContext.STATES.inProgress;\n this.currentIndex = 0;\n this.options.continuationToken = originalContinuation;\n this.options.continuation = originalContinuation;\n\n // deserializing query metrics so that we aren't working with delimited strings in the rest of the code base\n if (Constants.HttpHeaders.QueryMetrics in responseHeaders) {\n const delimitedString = responseHeaders[Constants.HttpHeaders.QueryMetrics];\n let queryMetrics = QueryMetrics.createFromDelimitedString(delimitedString);\n\n // Add the request charge to the query metrics so that we can have per partition request charge.\n if (Constants.HttpHeaders.RequestCharge in responseHeaders) {\n const requestCharge = Number(responseHeaders[Constants.HttpHeaders.RequestCharge]) || 0;\n queryMetrics = new QueryMetrics(\n queryMetrics.retrievedDocumentCount,\n queryMetrics.retrievedDocumentSize,\n queryMetrics.outputDocumentCount,\n queryMetrics.outputDocumentSize,\n queryMetrics.indexHitDocumentCount,\n queryMetrics.totalQueryExecutionTime,\n queryMetrics.queryPreparationTimes,\n queryMetrics.indexLookupTime,\n queryMetrics.documentLoadTime,\n queryMetrics.vmExecutionTime,\n queryMetrics.runtimeExecutionTimes,\n queryMetrics.documentWriteTime,\n new ClientSideMetrics(requestCharge),\n );\n }\n\n // Wraping query metrics in a object where the key is '0' just so single partition\n // and partition queries have the same response schema\n responseHeaders[Constants.HttpHeaders.QueryMetrics] = {};\n responseHeaders[Constants.HttpHeaders.QueryMetrics][\"0\"] = queryMetrics;\n }\n\n if (operationOptions && operationOptions.ruCapPerOperation && ruConsumedManager) {\n await ruConsumedManager.addToRUConsumed(getRequestChargeIfAny(responseHeaders));\n const ruConsumedValue = await ruConsumedManager.getRUConsumed();\n if (ruConsumedValue > operationOptions.ruCapPerOperation) {\n // For RUCapPerOperationExceededError error, we won't be updating the state from\n // inProgress as we want to support continue\n throw new RUCapPerOperationExceededError(\n \"Request Unit limit per Operation call exceeded\",\n resources,\n );\n }\n }\n return { result: resources, headers: responseHeaders };\n },\n diagnosticNode,\n DiagnosticNodeType.DEFAULT_QUERY_NODE,\n {\n queryMethodIdentifier: \"fetchMore\",\n },\n );\n }\n\n private _canFetchMore(): boolean {\n const res =\n this.state === DefaultQueryExecutionContext.STATES.start ||\n (this.continuationToken && this.state === DefaultQueryExecutionContext.STATES.inProgress) ||\n (this.currentPartitionIndex < this.fetchFunctions.length &&\n this.state === DefaultQueryExecutionContext.STATES.inProgress);\n return res;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts new file mode 100644 index 000000000..6798e6a79 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts @@ -0,0 +1,63 @@ +import { PartitionKeyRange, Resource } from "../client"; +import { ClientContext } from "../ClientContext"; +import { RUConsumedManager } from "../common"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { FeedOptions, QueryOperationOptions } from "../request"; +import { Response } from "../request"; +import { FetchResult } from "./FetchResult"; +import { SqlQuerySpec } from "./index"; +/** @hidden */ +export declare class DocumentProducer { + private clientContext; + private collectionLink; + private query; + targetPartitionKeyRange: PartitionKeyRange; + fetchResults: FetchResult[]; + allFetched: boolean; + private err; + previousContinuationToken: string; + continuationToken: string; + generation: number; + private respHeaders; + private internalExecutionContext; + /** + * Provides the Target Partition Range Query Execution Context. + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - Represents collection link + * @param query - A SQL query. + * @param targetPartitionKeyRange - Query Target Partition key Range + * @hidden + */ + constructor(clientContext: ClientContext, collectionLink: string, query: SqlQuerySpec, targetPartitionKeyRange: PartitionKeyRange, options: FeedOptions); + /** + * Synchronously gives the contiguous buffered results (stops at the first non result) if any + * @returns buffered current items if any + * @hidden + */ + peekBufferedItems(): any[]; + fetchFunction: (diagnosticNode: DiagnosticNodeInternal, options: FeedOptions) => Promise>; + hasMoreResults(): boolean; + gotSplit(): boolean; + private _getAndResetActiveResponseHeaders; + private _updateStates; + private static _needPartitionKeyRangeCacheRefresh; + /** + * Fetches and bufferes the next page of results and executes the given callback + */ + bufferMore(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + /** + * Synchronously gives the bufferend current item if any + * @returns buffered current item if any + * @hidden + */ + getTargetParitionKeyRange(): PartitionKeyRange; + /** + * Fetches the next element in the DocumentProducer. + */ + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + /** + * Retrieve the current element on the DocumentProducer. + */ + current(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; +} +//# sourceMappingURL=documentProducer.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts.map new file mode 100644 index 000000000..81319d7f8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"documentProducer.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/documentProducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAOL,iBAAiB,EAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,M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AAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAiCzB;;OAEG;IACU,OAAO,CAClB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;CA0C1B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js new file mode 100644 index 000000000..1c421db1a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js @@ -0,0 +1,233 @@ +import { Constants, getIdFromLink, getPathFromLink, ResourceType, StatusCodes, SubStatusCodes, } from "../common"; +import { DefaultQueryExecutionContext } from "./defaultQueryExecutionContext"; +import { FetchResult, FetchResultType } from "./FetchResult"; +import { getInitialHeader, mergeHeaders } from "./headerUtils"; +/** @hidden */ +export class DocumentProducer { + /** + * Provides the Target Partition Range Query Execution Context. + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - Represents collection link + * @param query - A SQL query. + * @param targetPartitionKeyRange - Query Target Partition key Range + * @hidden + */ + constructor(clientContext, collectionLink, query, targetPartitionKeyRange, options) { + this.clientContext = clientContext; + this.generation = 0; + this.fetchFunction = async (diagnosticNode, options) => { + const path = getPathFromLink(this.collectionLink, ResourceType.item); + diagnosticNode.addData({ partitionKeyRangeId: this.targetPartitionKeyRange.id }); + const id = getIdFromLink(this.collectionLink); + return this.clientContext.queryFeed({ + path, + resourceType: ResourceType.item, + resourceId: id, + resultFn: (result) => result.Documents, + query: this.query, + options, + diagnosticNode, + partitionKeyRangeId: this.targetPartitionKeyRange["id"], + }); + }; + // TODO: any options + this.collectionLink = collectionLink; + this.query = query; + this.targetPartitionKeyRange = targetPartitionKeyRange; + this.fetchResults = []; + this.allFetched = false; + this.err = undefined; + this.previousContinuationToken = undefined; + this.continuationToken = undefined; + this.respHeaders = getInitialHeader(); + this.internalExecutionContext = new DefaultQueryExecutionContext(options, this.fetchFunction); + } + /** + * Synchronously gives the contiguous buffered results (stops at the first non result) if any + * @returns buffered current items if any + * @hidden + */ + peekBufferedItems() { + const bufferedResults = []; + for (let i = 0, done = false; i < this.fetchResults.length && !done; i++) { + const fetchResult = this.fetchResults[i]; + switch (fetchResult.fetchResultType) { + case FetchResultType.Done: + done = true; + break; + case FetchResultType.Exception: + done = true; + break; + case FetchResultType.Result: + bufferedResults.push(fetchResult.feedResponse); + break; + } + } + return bufferedResults; + } + hasMoreResults() { + return this.internalExecutionContext.hasMoreResults() || this.fetchResults.length !== 0; + } + gotSplit() { + const fetchResult = this.fetchResults[0]; + if (fetchResult.fetchResultType === FetchResultType.Exception) { + if (DocumentProducer._needPartitionKeyRangeCacheRefresh(fetchResult.error)) { + return true; + } + } + return false; + } + _getAndResetActiveResponseHeaders() { + const ret = this.respHeaders; + this.respHeaders = getInitialHeader(); + return ret; + } + _updateStates(err, allFetched) { + // TODO: any Error + if (err) { + this.err = err; + return; + } + if (allFetched) { + this.allFetched = true; + } + if (this.internalExecutionContext.continuationToken === this.continuationToken) { + // nothing changed + return; + } + this.previousContinuationToken = this.continuationToken; + this.continuationToken = this.internalExecutionContext.continuationToken; + } + static _needPartitionKeyRangeCacheRefresh(error) { + // TODO: error + return (error.code === StatusCodes.Gone && + "substatus" in error && + error["substatus"] === SubStatusCodes.PartitionKeyRangeGone); + } + /** + * Fetches and bufferes the next page of results and executes the given callback + */ + async bufferMore(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.err) { + throw this.err; + } + try { + const { result: resources, headers: headerResponse } = await this.internalExecutionContext.fetchMore(diagnosticNode, operationOptions, ruConsumedManager); + ++this.generation; + this._updateStates(undefined, resources === undefined); + if (resources !== undefined) { + // some more results + resources.forEach((element) => { + // TODO: resources any + this.fetchResults.push(new FetchResult(element, undefined)); + }); + } + // need to modify the header response so that the query metrics are per partition + if (headerResponse != null && Constants.HttpHeaders.QueryMetrics in headerResponse) { + // "0" is the default partition before one is actually assigned. + const queryMetrics = headerResponse[Constants.HttpHeaders.QueryMetrics]["0"]; + // Wraping query metrics in a object where the keys are the partition key range. + headerResponse[Constants.HttpHeaders.QueryMetrics] = {}; + headerResponse[Constants.HttpHeaders.QueryMetrics][this.targetPartitionKeyRange.id] = + queryMetrics; + } + return { result: resources, headers: headerResponse }; + } + catch (err) { + // TODO: any error + if (DocumentProducer._needPartitionKeyRangeCacheRefresh(err)) { + // Split just happend + // Buffer the error so the execution context can still get the feedResponses in the itemBuffer + const bufferedError = new FetchResult(undefined, err); + this.fetchResults.push(bufferedError); + // Putting a dummy result so that the rest of code flows + return { + result: [bufferedError], + headers: err.headers, + }; + } + else { + this._updateStates(err, err.resources === undefined); + throw err; + } + } + } + /** + * Synchronously gives the bufferend current item if any + * @returns buffered current item if any + * @hidden + */ + getTargetParitionKeyRange() { + return this.targetPartitionKeyRange; + } + /** + * Fetches the next element in the DocumentProducer. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.err) { + this._updateStates(this.err, undefined); + throw this.err; + } + try { + const { result, headers } = await this.current(diagnosticNode, operationOptions, ruConsumedManager); + const fetchResult = this.fetchResults.shift(); + this._updateStates(undefined, result === undefined); + if (fetchResult.feedResponse !== result) { + throw new Error(`Expected ${fetchResult.feedResponse} to equal ${result}`); + } + switch (fetchResult.fetchResultType) { + case FetchResultType.Done: + return { result: undefined, headers }; + case FetchResultType.Exception: + fetchResult.error.headers = headers; + throw fetchResult.error; + case FetchResultType.Result: + return { result: fetchResult.feedResponse, headers }; + } + } + catch (err) { + this._updateStates(err, err.item === undefined); + throw err; + } + } + /** + * Retrieve the current element on the DocumentProducer. + */ + async current(diagnosticNode, operationOptions, ruConsumedManager) { + // If something is buffered just give that + if (this.fetchResults.length > 0) { + const fetchResult = this.fetchResults[0]; + // Need to unwrap fetch results + switch (fetchResult.fetchResultType) { + case FetchResultType.Done: + return { + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }; + case FetchResultType.Exception: + fetchResult.error.headers = this._getAndResetActiveResponseHeaders(); + throw fetchResult.error; + case FetchResultType.Result: + return { + result: fetchResult.feedResponse, + headers: this._getAndResetActiveResponseHeaders(), + }; + } + } + // If there isn't anymore items left to fetch then let the user know. + if (this.allFetched) { + return { + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }; + } + // If there are no more bufferd items and there are still items to be fetched then buffer more + const { result, headers } = await this.bufferMore(diagnosticNode, operationOptions, ruConsumedManager); + mergeHeaders(this.respHeaders, headers); + if (result === undefined) { + return { result: undefined, headers: this.respHeaders }; + } + return this.current(diagnosticNode, operationOptions, ruConsumedManager); + } +} +//# sourceMappingURL=documentProducer.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js.map new file mode 100644 index 000000000..213744ce2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/documentProducer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"documentProducer.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/documentProducer.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,EACX,cAAc,GAEf,MAAM,WAAW,CAAC;AAInB,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAiB,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG9E,cAAc;AACd,MAAM,OAAO,gBAAgB;IAa3B;;;;;;;OAOG;IACH,YACU,aAA4B,EACpC,cAAsB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sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKeyRange, Resource } from \"../client\";\nimport { ClientContext } from \"../ClientContext\";\nimport {\n Constants,\n getIdFromLink,\n getPathFromLink,\n ResourceType,\n StatusCodes,\n SubStatusCodes,\n RUConsumedManager,\n} from \"../common\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { FeedOptions, QueryOperationOptions } from \"../request\";\nimport { Response } from \"../request\";\nimport { DefaultQueryExecutionContext } from \"./defaultQueryExecutionContext\";\nimport { FetchResult, FetchResultType } from \"./FetchResult\";\nimport { CosmosHeaders, getInitialHeader, mergeHeaders } from \"./headerUtils\";\nimport { SqlQuerySpec } from \"./index\";\n\n/** @hidden */\nexport class DocumentProducer {\n private collectionLink: string;\n private query: string | SqlQuerySpec;\n public targetPartitionKeyRange: PartitionKeyRange;\n public fetchResults: FetchResult[];\n public allFetched: boolean;\n private err: Error;\n public previousContinuationToken: string;\n public continuationToken: string;\n public generation: number = 0;\n private respHeaders: CosmosHeaders;\n private internalExecutionContext: DefaultQueryExecutionContext;\n\n /**\n * Provides the Target Partition Range Query Execution Context.\n * @param clientContext - The service endpoint to use to create the client.\n * @param collectionLink - Represents collection link\n * @param query - A SQL query.\n * @param targetPartitionKeyRange - Query Target Partition key Range\n * @hidden\n */\n constructor(\n private clientContext: ClientContext,\n collectionLink: string,\n query: SqlQuerySpec,\n targetPartitionKeyRange: PartitionKeyRange,\n options: FeedOptions,\n ) {\n // TODO: any options\n this.collectionLink = collectionLink;\n this.query = query;\n this.targetPartitionKeyRange = targetPartitionKeyRange;\n this.fetchResults = [];\n\n this.allFetched = false;\n this.err = undefined;\n\n this.previousContinuationToken = undefined;\n this.continuationToken = undefined;\n this.respHeaders = getInitialHeader();\n\n this.internalExecutionContext = new DefaultQueryExecutionContext(options, this.fetchFunction);\n }\n /**\n * Synchronously gives the contiguous buffered results (stops at the first non result) if any\n * @returns buffered current items if any\n * @hidden\n */\n public peekBufferedItems(): any[] {\n const bufferedResults = [];\n for (let i = 0, done = false; i < this.fetchResults.length && !done; i++) {\n const fetchResult = this.fetchResults[i];\n switch (fetchResult.fetchResultType) {\n case FetchResultType.Done:\n done = true;\n break;\n case FetchResultType.Exception:\n done = true;\n break;\n case FetchResultType.Result:\n bufferedResults.push(fetchResult.feedResponse);\n break;\n }\n }\n return bufferedResults;\n }\n\n public fetchFunction = async (\n diagnosticNode: DiagnosticNodeInternal,\n options: FeedOptions,\n ): Promise> => {\n const path = getPathFromLink(this.collectionLink, ResourceType.item);\n diagnosticNode.addData({ partitionKeyRangeId: this.targetPartitionKeyRange.id });\n const id = getIdFromLink(this.collectionLink);\n\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n resultFn: (result: any) => result.Documents,\n query: this.query,\n options,\n diagnosticNode,\n partitionKeyRangeId: this.targetPartitionKeyRange[\"id\"],\n });\n };\n\n public hasMoreResults(): boolean {\n return this.internalExecutionContext.hasMoreResults() || this.fetchResults.length !== 0;\n }\n\n public gotSplit(): boolean {\n const fetchResult = this.fetchResults[0];\n if (fetchResult.fetchResultType === FetchResultType.Exception) {\n if (DocumentProducer._needPartitionKeyRangeCacheRefresh(fetchResult.error)) {\n return true;\n }\n }\n\n return false;\n }\n\n private _getAndResetActiveResponseHeaders(): CosmosHeaders {\n const ret = this.respHeaders;\n this.respHeaders = getInitialHeader();\n return ret;\n }\n\n private _updateStates(err: any, allFetched: boolean): void {\n // TODO: any Error\n if (err) {\n this.err = err;\n return;\n }\n if (allFetched) {\n this.allFetched = true;\n }\n if (this.internalExecutionContext.continuationToken === this.continuationToken) {\n // nothing changed\n return;\n }\n this.previousContinuationToken = this.continuationToken;\n this.continuationToken = this.internalExecutionContext.continuationToken;\n }\n\n private static _needPartitionKeyRangeCacheRefresh(error: any): boolean {\n // TODO: error\n return (\n error.code === StatusCodes.Gone &&\n \"substatus\" in error &&\n error[\"substatus\"] === SubStatusCodes.PartitionKeyRangeGone\n );\n }\n\n /**\n * Fetches and bufferes the next page of results and executes the given callback\n */\n public async bufferMore(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.err) {\n throw this.err;\n }\n\n try {\n const { result: resources, headers: headerResponse } =\n await this.internalExecutionContext.fetchMore(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n ++this.generation;\n this._updateStates(undefined, resources === undefined);\n if (resources !== undefined) {\n // some more results\n resources.forEach((element: any) => {\n // TODO: resources any\n this.fetchResults.push(new FetchResult(element, undefined));\n });\n }\n\n // need to modify the header response so that the query metrics are per partition\n if (headerResponse != null && Constants.HttpHeaders.QueryMetrics in headerResponse) {\n // \"0\" is the default partition before one is actually assigned.\n const queryMetrics = headerResponse[Constants.HttpHeaders.QueryMetrics][\"0\"];\n\n // Wraping query metrics in a object where the keys are the partition key range.\n headerResponse[Constants.HttpHeaders.QueryMetrics] = {};\n headerResponse[Constants.HttpHeaders.QueryMetrics][this.targetPartitionKeyRange.id] =\n queryMetrics;\n }\n\n return { result: resources, headers: headerResponse };\n } catch (err: any) {\n // TODO: any error\n if (DocumentProducer._needPartitionKeyRangeCacheRefresh(err)) {\n // Split just happend\n // Buffer the error so the execution context can still get the feedResponses in the itemBuffer\n const bufferedError = new FetchResult(undefined, err);\n this.fetchResults.push(bufferedError);\n // Putting a dummy result so that the rest of code flows\n return {\n result: [bufferedError],\n headers: err.headers,\n };\n } else {\n this._updateStates(err, err.resources === undefined);\n throw err;\n }\n }\n }\n\n /**\n * Synchronously gives the bufferend current item if any\n * @returns buffered current item if any\n * @hidden\n */\n public getTargetParitionKeyRange(): PartitionKeyRange {\n return this.targetPartitionKeyRange;\n }\n\n /**\n * Fetches the next element in the DocumentProducer.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.err) {\n this._updateStates(this.err, undefined);\n throw this.err;\n }\n\n try {\n const { result, headers } = await this.current(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n\n const fetchResult = this.fetchResults.shift();\n this._updateStates(undefined, result === undefined);\n if (fetchResult.feedResponse !== result) {\n throw new Error(`Expected ${fetchResult.feedResponse} to equal ${result}`);\n }\n switch (fetchResult.fetchResultType) {\n case FetchResultType.Done:\n return { result: undefined, headers };\n case FetchResultType.Exception:\n fetchResult.error.headers = headers;\n throw fetchResult.error;\n case FetchResultType.Result:\n return { result: fetchResult.feedResponse, headers };\n }\n } catch (err: any) {\n this._updateStates(err, err.item === undefined);\n throw err;\n }\n }\n\n /**\n * Retrieve the current element on the DocumentProducer.\n */\n public async current(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // If something is buffered just give that\n if (this.fetchResults.length > 0) {\n const fetchResult = this.fetchResults[0];\n // Need to unwrap fetch results\n switch (fetchResult.fetchResultType) {\n case FetchResultType.Done:\n return {\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n };\n case FetchResultType.Exception:\n fetchResult.error.headers = this._getAndResetActiveResponseHeaders();\n throw fetchResult.error;\n case FetchResultType.Result:\n return {\n result: fetchResult.feedResponse,\n headers: this._getAndResetActiveResponseHeaders(),\n };\n }\n }\n\n // If there isn't anymore items left to fetch then let the user know.\n if (this.allFetched) {\n return {\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n };\n }\n\n // If there are no more bufferd items and there are still items to be fetched then buffer more\n const { result, headers } = await this.bufferMore(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n mergeHeaders(this.respHeaders, headers);\n if (result === undefined) {\n return { result: undefined, headers: this.respHeaders };\n }\n return this.current(diagnosticNode, operationOptions, ruConsumedManager);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts new file mode 100644 index 000000000..e242cd5eb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts @@ -0,0 +1,14 @@ +export interface CosmosHeaders { + [key: string]: any; +} +/** @hidden */ +export declare function getRequestChargeIfAny(headers: CosmosHeaders | number): number; +/** + * @hidden + */ +export declare function getInitialHeader(): CosmosHeaders; +/** + * @hidden + */ +export declare function mergeHeaders(headers: CosmosHeaders, toBeMergedHeaders: CosmosHeaders): void; +//# sourceMappingURL=headerUtils.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts.map new file mode 100644 index 000000000..9a7ea6a2a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"headerUtils.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/headerUtils.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,cAAc;AAEd,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,CAiB7E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED;;GAEG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,aAAa,GAAG,IAAI,CAuC3F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js new file mode 100644 index 000000000..dada745f5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants } from "../common"; +import { QueryMetrics } from "../queryMetrics/queryMetrics"; +/** @hidden */ +// TODO: docs +export function getRequestChargeIfAny(headers) { + if (typeof headers === "number") { + return headers; + } + else if (typeof headers === "string") { + return parseFloat(headers); + } + if (headers) { + const rc = headers[Constants.HttpHeaders.RequestCharge]; + if (rc) { + return parseFloat(rc); + } + else { + return 0; + } + } + else { + return 0; + } +} +/** + * @hidden + */ +export function getInitialHeader() { + const headers = {}; + headers[Constants.HttpHeaders.RequestCharge] = 0; + headers[Constants.HttpHeaders.QueryMetrics] = {}; + return headers; +} +/** + * @hidden + */ +// TODO: The name of this method isn't very accurate to what it does +export function mergeHeaders(headers, toBeMergedHeaders) { + if (headers[Constants.HttpHeaders.RequestCharge] === undefined) { + headers[Constants.HttpHeaders.RequestCharge] = 0; + } + if (headers[Constants.HttpHeaders.QueryMetrics] === undefined) { + headers[Constants.HttpHeaders.QueryMetrics] = QueryMetrics.zero; + } + if (!toBeMergedHeaders) { + return; + } + headers[Constants.HttpHeaders.RequestCharge] += getRequestChargeIfAny(toBeMergedHeaders); + if (toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed]) { + headers[Constants.HttpHeaders.IsRUPerMinuteUsed] = + toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed]; + } + if (Constants.HttpHeaders.QueryMetrics in toBeMergedHeaders) { + const headerQueryMetrics = headers[Constants.HttpHeaders.QueryMetrics]; + const toBeMergedHeaderQueryMetrics = toBeMergedHeaders[Constants.HttpHeaders.QueryMetrics]; + for (const partitionId in toBeMergedHeaderQueryMetrics) { + if (headerQueryMetrics[partitionId]) { + const combinedQueryMetrics = headerQueryMetrics[partitionId].add([ + toBeMergedHeaderQueryMetrics[partitionId], + ]); + headerQueryMetrics[partitionId] = combinedQueryMetrics; + } + else { + headerQueryMetrics[partitionId] = toBeMergedHeaderQueryMetrics[partitionId]; + } + } + } + if (Constants.HttpHeaders.IndexUtilization in toBeMergedHeaders) { + headers[Constants.HttpHeaders.IndexUtilization] = + toBeMergedHeaders[Constants.HttpHeaders.IndexUtilization]; + } +} +//# sourceMappingURL=headerUtils.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js.map new file mode 100644 index 000000000..e52dbbf00 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/headerUtils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"headerUtils.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/headerUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAM5D,cAAc;AACd,aAAa;AACb,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,OAAO,OAAO,CAAC;KAChB;SAAM,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QACtC,OAAO,UAAU,CAAC,OAAO,CAAC,CAAC;KAC5B;IAED,IAAI,OAAO,EAAE;QACX,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QACxD,IAAI,EAAE,EAAE;YACN,OAAO,UAAU,CAAC,EAAY,CAAC,CAAC;SACjC;aAAM;YACL,OAAO,CAAC,CAAC;SACV;KACF;SAAM;QACL,OAAO,CAAC,CAAC;KACV;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC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AG,CAAC;oBAC/D,4BAA4B,CAAC,WAAW,CAAC;iBAC1C,CAAC,CAAC;gBACH,kBAAkB,CAAC,WAAW,CAAC,GAAG,oBAAoB,CAAC;aACxD;iBAAM;gBACL,kBAAkB,CAAC,WAAW,CAAC,GAAG,4BAA4B,CAAC,WAAW,CAAC,CAAC;aAC7E;SACF;KACF;IAED,IAAI,SAAS,CAAC,WAAW,CAAC,gBAAgB,IAAI,iBAAiB,EAAE;QAC/D,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC;YAC7C,iBAAiB,CAAC,SAAS,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;KAC7D;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common\";\nimport { QueryMetrics } from \"../queryMetrics/queryMetrics\";\n\nexport interface CosmosHeaders {\n [key: string]: any;\n}\n\n/** @hidden */\n// TODO: docs\nexport function getRequestChargeIfAny(headers: CosmosHeaders | number): number {\n if (typeof headers === \"number\") {\n return headers;\n } else if (typeof headers === \"string\") {\n return parseFloat(headers);\n }\n\n if (headers) {\n const rc = headers[Constants.HttpHeaders.RequestCharge];\n if (rc) {\n return parseFloat(rc as string);\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n}\n\n/**\n * @hidden\n */\nexport function getInitialHeader(): CosmosHeaders {\n const headers: CosmosHeaders = {};\n headers[Constants.HttpHeaders.RequestCharge] = 0;\n headers[Constants.HttpHeaders.QueryMetrics] = {};\n return headers;\n}\n\n/**\n * @hidden\n */\n// TODO: The name of this method isn't very accurate to what it does\nexport function mergeHeaders(headers: CosmosHeaders, toBeMergedHeaders: CosmosHeaders): void {\n if (headers[Constants.HttpHeaders.RequestCharge] === undefined) {\n headers[Constants.HttpHeaders.RequestCharge] = 0;\n }\n\n if (headers[Constants.HttpHeaders.QueryMetrics] === undefined) {\n headers[Constants.HttpHeaders.QueryMetrics] = QueryMetrics.zero;\n }\n\n if (!toBeMergedHeaders) {\n return;\n }\n\n headers[Constants.HttpHeaders.RequestCharge] += getRequestChargeIfAny(toBeMergedHeaders);\n if (toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed]) {\n headers[Constants.HttpHeaders.IsRUPerMinuteUsed] =\n toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed];\n }\n\n if (Constants.HttpHeaders.QueryMetrics in toBeMergedHeaders) {\n const headerQueryMetrics = headers[Constants.HttpHeaders.QueryMetrics];\n const toBeMergedHeaderQueryMetrics = toBeMergedHeaders[Constants.HttpHeaders.QueryMetrics];\n\n for (const partitionId in toBeMergedHeaderQueryMetrics) {\n if (headerQueryMetrics[partitionId]) {\n const combinedQueryMetrics = headerQueryMetrics[partitionId].add([\n toBeMergedHeaderQueryMetrics[partitionId],\n ]);\n headerQueryMetrics[partitionId] = combinedQueryMetrics;\n } else {\n headerQueryMetrics[partitionId] = toBeMergedHeaderQueryMetrics[partitionId];\n }\n }\n }\n\n if (Constants.HttpHeaders.IndexUtilization in toBeMergedHeaders) {\n headers[Constants.HttpHeaders.IndexUtilization] =\n toBeMergedHeaders[Constants.HttpHeaders.IndexUtilization];\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts new file mode 100644 index 000000000..3d10fbcf6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts @@ -0,0 +1,14 @@ +export * from "./headerUtils"; +export * from "./SqlQuerySpec"; +export * from "./defaultQueryExecutionContext"; +export * from "./Aggregators"; +export * from "./documentProducer"; +export * from "./FetchResult"; +export * from "./orderByDocumentProducerComparator"; +export * from "./ExecutionContext"; +export * from "./parallelQueryExecutionContextBase"; +export * from "./parallelQueryExecutionContext"; +export * from "./orderByQueryExecutionContext"; +export * from "./pipelinedQueryExecutionContext"; +export * from "./orderByComparator"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts.map new file mode 100644 index 000000000..1c32c1d06 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/index.ts"],"names":[],"mappings":"AAEA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qCAAqC,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js new file mode 100644 index 000000000..636052f3b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export * from "./headerUtils"; +export * from "./SqlQuerySpec"; +export * from "./defaultQueryExecutionContext"; +export * from "./Aggregators"; +export * from "./documentProducer"; +export * from "./FetchResult"; +export * from "./orderByDocumentProducerComparator"; +export * from "./ExecutionContext"; +export * from "./parallelQueryExecutionContextBase"; +export * from "./parallelQueryExecutionContext"; +export * from "./orderByQueryExecutionContext"; +export * from "./pipelinedQueryExecutionContext"; +export * from "./orderByComparator"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js.map new file mode 100644 index 000000000..cbd19783d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,qCAAqC,CAAC;AACpD,cAAc,oBAAoB,CAAC;AACnC,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./headerUtils\";\nexport * from \"./SqlQuerySpec\";\nexport * from \"./defaultQueryExecutionContext\";\nexport * from \"./Aggregators\";\nexport * from \"./documentProducer\";\nexport * from \"./FetchResult\";\nexport * from \"./orderByDocumentProducerComparator\";\nexport * from \"./ExecutionContext\";\nexport * from \"./parallelQueryExecutionContextBase\";\nexport * from \"./parallelQueryExecutionContext\";\nexport * from \"./orderByQueryExecutionContext\";\nexport * from \"./pipelinedQueryExecutionContext\";\nexport * from \"./orderByComparator\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts new file mode 100644 index 000000000..d7eeafc8d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts @@ -0,0 +1,7 @@ +import { CosmosHeaders } from "./CosmosHeaders"; +import { NonStreamingOrderByResult } from "./nonStreamingOrderByResult"; +export interface NonStreamingOrderByResponse { + result: NonStreamingOrderByResult; + headers: CosmosHeaders; +} +//# sourceMappingURL=nonStreamingOrderByResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts.map new file mode 100644 index 000000000..53da0ec8a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByResponse.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/nonStreamingOrderByResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,yBAAyB,CAAC;IAClC,OAAO,EAAE,aAAa,CAAC;CACxB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js new file mode 100644 index 000000000..2fa2c879b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=nonStreamingOrderByResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js.map new file mode 100644 index 000000000..d58759aba --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByResponse.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/nonStreamingOrderByResponse.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosHeaders } from \"./CosmosHeaders\";\nimport { NonStreamingOrderByResult } from \"./nonStreamingOrderByResult\";\n\nexport interface NonStreamingOrderByResponse {\n result: NonStreamingOrderByResult;\n headers: CosmosHeaders;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts new file mode 100644 index 000000000..9105d8a75 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts @@ -0,0 +1,5 @@ +export interface NonStreamingOrderByResult { + orderByItems: []; + payload: any; +} +//# sourceMappingURL=nonStreamingOrderByResult.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts.map new file mode 100644 index 000000000..ad2a682de --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByResult.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/nonStreamingOrderByResult.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,yBAAyB;IACxC,YAAY,EAAE,EAAE,CAAC;IACjB,OAAO,EAAE,GAAG,CAAC;CACd"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js new file mode 100644 index 000000000..54f171e5e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=nonStreamingOrderByResult.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js.map new file mode 100644 index 000000000..4ebe3fc14 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/nonStreamingOrderByResult.js.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByResult.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/nonStreamingOrderByResult.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface NonStreamingOrderByResult {\n orderByItems: [];\n payload: any;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts new file mode 100644 index 000000000..bf6b85db0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts @@ -0,0 +1,12 @@ +import { NonStreamingOrderByResult } from "./nonStreamingOrderByResult"; +/** @hidden */ +export declare class OrderByComparator { + sortOrder: string[]; + constructor(sortOrder: string[]); + compareItems(item1: NonStreamingOrderByResult, item2: NonStreamingOrderByResult): number; + private getOrderByItems; + private compareOrderByItem; + private getType; + private compareValue; +} +//# sourceMappingURL=orderByComparator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts.map new file mode 100644 index 000000000..edf3626a0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"orderByComparator.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/orderByComparator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAgCxE,cAAc;AACd,qBAAa,iBAAiB;IACT,SAAS,EAAE,MAAM,EAAE;gBAAnB,SAAS,EAAE,MAAM,EAAE;IAE/B,YAAY,CAAC,KAAK,EAAE,yBAAyB,EAAE,KAAK,EAAE,yBAAyB,GAAG,MAAM;IAiB/F,OAAO,CAAC,eAAe;IAIvB,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,OAAO;IAuBf,OAAO,CAAC,YAAY;CA6BrB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js new file mode 100644 index 000000000..823e5afd1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +const TYPEORDCOMPARATOR = Object.freeze({ + NoValue: { + ord: 0, + }, + undefined: { + ord: 1, + }, + boolean: { + ord: 2, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + number: { + ord: 4, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + string: { + ord: 5, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, +}); +/** @hidden */ +export class OrderByComparator { + constructor(sortOrder) { + this.sortOrder = sortOrder; + } + compareItems(item1, item2) { + const orderByItemsRes1 = this.getOrderByItems(item1); + const orderByItemsRes2 = this.getOrderByItems(item2); + for (let i = 0; i < orderByItemsRes1.length; i++) { + // compares the orderby items one by one + const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]); + if (compRes !== 0) { + if (this.sortOrder[i] === "Descending") { + return compRes; + } + else if (this.sortOrder[i] === "Ascending") { + return -compRes; + } + } + } + } + getOrderByItems(res) { + return res["orderByItems"]; + } + compareOrderByItem(orderByItem1, orderByItem2) { + const type1 = this.getType(orderByItem1); + const type2 = this.getType(orderByItem2); + return this.compareValue(orderByItem1["item"], type1, orderByItem2["item"], type2); + } + getType(orderByItem) { + // TODO: any item? + if (orderByItem === undefined || orderByItem.item === undefined) { + return "NoValue"; + } + const type = typeof orderByItem.item; + if (TYPEORDCOMPARATOR[type] === undefined) { + throw new Error(`unrecognizable type ${type}`); + } + return type; + } + compareValue(item1, type1, item2, type2) { + if (type1 === "object" || type2 === "object") { + throw new Error("Tried to compare an object type"); + } + const type1Ord = TYPEORDCOMPARATOR[type1].ord; + const type2Ord = TYPEORDCOMPARATOR[type2].ord; + const typeCmp = type1Ord - type2Ord; + if (typeCmp !== 0) { + // if the types are different, use type ordinal + return typeCmp; + } + // both are of the same type + if (type1Ord === TYPEORDCOMPARATOR["undefined"].ord || + type1Ord === TYPEORDCOMPARATOR["NoValue"].ord) { + // if both types are undefined or Null they are equal + return 0; + } + const compFunc = TYPEORDCOMPARATOR[type1].compFunc; + if (typeof compFunc === "undefined") { + throw new Error("Cannot find the comparison function"); + } + // same type and type is defined compare the items + return compFunc(item1, item2); + } +} +//# sourceMappingURL=orderByComparator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js.map new file mode 100644 index 000000000..8afc622d1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByComparator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"orderByComparator.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/orderByComparator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,cAAc;AACd,MAAM,iBAAiB,GAEnB,MAAM,CAAC,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,GAAG,EAAE,CAAC;KACP;IACD,SAAS,EAAE;QACT,GAAG,EAAE,CAAC;KACP;IACD,OAAO,EAAE;QACP,GAAG,EAAE,CAAC;QACN,QAAQ,EAAE,CAAC,CAAU,EAAE,CAAU,EAAE,EAAE;YACnC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;KACF;IACD,MAAM,EAAE;QACN,GAAG,EAAE,CAAC;QACN,QAAQ,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;KACF;IACD,MAAM,EAAE;QACN,GAAG,EAAE,CAAC;QACN,QAAQ,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE;YACjC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;KACF;CACF,CAAC,CAAC;AAEH,cAAc;AACd,MAAM,OAAO,i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} from \"./nonStreamingOrderByResult\";\n\n/** @hidden */\nconst TYPEORDCOMPARATOR: {\n [type: string]: { ord: number; compFunc?: (a: any, b: any) => number };\n} = Object.freeze({\n NoValue: {\n ord: 0,\n },\n undefined: {\n ord: 1,\n },\n boolean: {\n ord: 2,\n compFunc: (a: boolean, b: boolean) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n number: {\n ord: 4,\n compFunc: (a: number, b: number) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n string: {\n ord: 5,\n compFunc: (a: string, b: string) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n});\n\n/** @hidden */\nexport class OrderByComparator {\n constructor(public sortOrder: string[]) {}\n\n public compareItems(item1: NonStreamingOrderByResult, item2: NonStreamingOrderByResult): number {\n const orderByItemsRes1 = this.getOrderByItems(item1);\n const orderByItemsRes2 = this.getOrderByItems(item2);\n\n for (let i = 0; i < orderByItemsRes1.length; i++) {\n // compares the orderby items one by one\n const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]);\n if (compRes !== 0) {\n if (this.sortOrder[i] === \"Descending\") {\n return compRes;\n } else if (this.sortOrder[i] === \"Ascending\") {\n return -compRes;\n }\n }\n }\n }\n\n private getOrderByItems(res: any): any {\n return res[\"orderByItems\"];\n }\n\n private compareOrderByItem(orderByItem1: any, orderByItem2: any): number {\n const type1 = this.getType(orderByItem1);\n const type2 = this.getType(orderByItem2);\n return this.compareValue(orderByItem1[\"item\"], type1, orderByItem2[\"item\"], type2);\n }\n\n private getType(\n orderByItem: any,\n ):\n | \"string\"\n | \"number\"\n | \"bigint\"\n | \"boolean\"\n | \"symbol\"\n | \"undefined\"\n | \"object\"\n | \"function\"\n | \"NoValue\" {\n // TODO: any item?\n if (orderByItem === undefined || orderByItem.item === undefined) {\n return \"NoValue\";\n }\n const type = typeof orderByItem.item;\n if (TYPEORDCOMPARATOR[type] === undefined) {\n throw new Error(`unrecognizable type ${type}`);\n }\n return type;\n }\n\n private compareValue(item1: unknown, type1: string, item2: unknown, type2: string): number {\n if (type1 === \"object\" || type2 === \"object\") {\n throw new Error(\"Tried to compare an object type\");\n }\n const type1Ord = TYPEORDCOMPARATOR[type1].ord;\n const type2Ord = TYPEORDCOMPARATOR[type2].ord;\n const typeCmp = type1Ord - type2Ord;\n\n if (typeCmp !== 0) {\n // if the types are different, use type ordinal\n return typeCmp;\n }\n\n // both are of the same type\n if (\n type1Ord === TYPEORDCOMPARATOR[\"undefined\"].ord ||\n type1Ord === TYPEORDCOMPARATOR[\"NoValue\"].ord\n ) {\n // if both types are undefined or Null they are equal\n return 0;\n }\n\n const compFunc = TYPEORDCOMPARATOR[type1].compFunc;\n if (typeof compFunc === \"undefined\") {\n throw new Error(\"Cannot find the comparison function\");\n }\n // same type and type is defined compare the items\n return compFunc(item1, item2);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts new file mode 100644 index 000000000..8aa23f062 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts @@ -0,0 +1,14 @@ +import { DocumentProducer } from "./documentProducer"; +/** @hidden */ +export declare class OrderByDocumentProducerComparator { + sortOrder: string[]; + constructor(sortOrder: string[]); + private targetPartitionKeyRangeDocProdComparator; + compare(docProd1: DocumentProducer, docProd2: DocumentProducer): number; + compareValue(item1: unknown, type1: string, item2: unknown, type2: string): number; + private compareOrderByItem; + private validateOrderByItems; + private getType; + private getOrderByItems; +} +//# sourceMappingURL=orderByDocumentProducerComparator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts.map new file mode 100644 index 000000000..c0495f9c1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"orderByDocumentProducerComparator.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/orderByDocumentProducerComparator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAiCtD,cAAc;AACd,qBAAa,iCAAiC;IACzB,SAAS,EAAE,MAAM,EAAE;gBAAnB,SAAS,EAAE,MAAM,EAAE;IAEtC,OAAO,CAAC,wCAAwC;IASzC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,MAAM;IAiCvE,YAAY,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IA8BzF,OAAO,CAAC,kBAAkB;IAM1B,OAAO,CAAC,oBAAoB;IAmB5B,OAAO,CAAC,OAAO;IAuBf,OAAO,CAAC,eAAe;CAIxB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js new file mode 100644 index 000000000..72f35cfa9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js @@ -0,0 +1,128 @@ +// TODO: this smells funny +/** @hidden */ +const TYPEORDCOMPARATOR = Object.freeze({ + NoValue: { + ord: 0, + }, + undefined: { + ord: 1, + }, + boolean: { + ord: 2, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + number: { + ord: 4, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + string: { + ord: 5, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, +}); +/** @hidden */ +export class OrderByDocumentProducerComparator { + constructor(sortOrder) { + this.sortOrder = sortOrder; + } // TODO: This should be an enum + targetPartitionKeyRangeDocProdComparator(docProd1, docProd2) { + const a = docProd1.getTargetParitionKeyRange()["minInclusive"]; + const b = docProd2.getTargetParitionKeyRange()["minInclusive"]; + return a === b ? 0 : a > b ? 1 : -1; + } + compare(docProd1, docProd2) { + // Need to check for split, since we don't want to dereference "item" of undefined / exception + if (docProd1.gotSplit()) { + return -1; + } + if (docProd2.gotSplit()) { + return 1; + } + const orderByItemsRes1 = this.getOrderByItems(docProd1.peekBufferedItems()[0]); + const orderByItemsRes2 = this.getOrderByItems(docProd2.peekBufferedItems()[0]); + // validate order by items and types + // TODO: once V1 order by on different types is fixed this need to change + this.validateOrderByItems(orderByItemsRes1, orderByItemsRes2); + // no async call in the for loop + for (let i = 0; i < orderByItemsRes1.length; i++) { + // compares the orderby items one by one + const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]); + if (compRes !== 0) { + if (this.sortOrder[i] === "Ascending") { + return compRes; + } + else if (this.sortOrder[i] === "Descending") { + return -compRes; + } + } + } + return this.targetPartitionKeyRangeDocProdComparator(docProd1, docProd2); + } + // TODO: This smells funny + compareValue(item1, type1, item2, type2) { + if (type1 === "object" || type2 === "object") { + throw new Error("Tried to compare an object type"); + } + const type1Ord = TYPEORDCOMPARATOR[type1].ord; + const type2Ord = TYPEORDCOMPARATOR[type2].ord; + const typeCmp = type1Ord - type2Ord; + if (typeCmp !== 0) { + // if the types are different, use type ordinal + return typeCmp; + } + // both are of the same type + if (type1Ord === TYPEORDCOMPARATOR["undefined"].ord || + type1Ord === TYPEORDCOMPARATOR["NoValue"].ord) { + // if both types are undefined or Null they are equal + return 0; + } + const compFunc = TYPEORDCOMPARATOR[type1].compFunc; + if (typeof compFunc === "undefined") { + throw new Error("Cannot find the comparison function"); + } + // same type and type is defined compare the items + return compFunc(item1, item2); + } + compareOrderByItem(orderByItem1, orderByItem2) { + const type1 = this.getType(orderByItem1); + const type2 = this.getType(orderByItem2); + return this.compareValue(orderByItem1["item"], type1, orderByItem2["item"], type2); + } + validateOrderByItems(res1, res2) { + if (res1.length !== res2.length) { + throw new Error(`Expected ${res1.length}, but got ${res2.length}.`); + } + if (res1.length !== this.sortOrder.length) { + throw new Error("orderByItems cannot have a different size than sort orders."); + } + for (let i = 0; i < this.sortOrder.length; i++) { + const type1 = this.getType(res1[i]); + const type2 = this.getType(res2[i]); + if (type1 !== type2) { + throw new Error(`Expected ${type1}, but got ${type2}. Cannot execute cross partition order-by queries on mixed types. Consider filtering your query using IS_STRING or IS_NUMBER to get around this exception.`); + } + } + } + getType(orderByItem) { + // TODO: any item? + if (orderByItem === undefined || orderByItem.item === undefined) { + return "NoValue"; + } + const type = typeof orderByItem.item; + if (TYPEORDCOMPARATOR[type] === undefined) { + throw new Error(`unrecognizable type ${type}`); + } + return type; + } + getOrderByItems(res) { + // TODO: any res? + return res["orderByItems"]; + } +} +//# sourceMappingURL=orderByDocumentProducerComparator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js.map new file mode 100644 index 000000000..a1d3ff9ce --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByDocumentProducerComparator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"orderByDocumentProducerComparator.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/orderByDocumentProducerComparator.ts"],"names":[],"mappings":"AAIA,0BAA0B;AAC1B,cAAc;AACd,MAAM,iBAAiB,GAEnB,MAAM,CAAC,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,GAAG,EAAE,CAAC;KACP;IACD,SAAS,EAAE;QACT,GAAG,EAAE,CAAC;KACP;IACD,OAAO,EAAE;QACP,GAAG,EAAE,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,YAAY,IAAI,CAAC,MAAM,aAAa,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACrE;QACD,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;SAChF;QAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,IAAI,KAAK,KAAK,KAAK,EAAE;gBACnB,MAAM,IAAI,KAAK,CACb,YAAY,KAAK,aAAa,KAAK,4JAA4J,CAChM,CAAC;aACH;SACF;IACH,CAAC;IAEO,OAAO,CACb,WAAgB;QAWhB,kBAAkB;QAClB,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;YAC/D,OAAO,SAAS,CAAC;SAClB;QACD,MAAM,IAAI,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;QACrC,IAAI,iBAAiB,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE;YACzC,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;SAChD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,eAAe,CAAC,GAAQ;QAC9B,iBAAiB;QACjB,OAAO,GAAG,CAAC,cAAc,CAAC,CAAC;IAC7B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DocumentProducer } from \"./documentProducer\";\n\n// TODO: this smells funny\n/** @hidden */\nconst TYPEORDCOMPARATOR: {\n [type: string]: { ord: number; compFunc?: (a: any, b: any) => number };\n} = Object.freeze({\n NoValue: {\n ord: 0,\n },\n undefined: {\n ord: 1,\n },\n boolean: {\n ord: 2,\n compFunc: (a: boolean, b: boolean) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n number: {\n ord: 4,\n compFunc: (a: number, b: number) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n string: {\n ord: 5,\n compFunc: (a: string, b: string) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n});\n\n/** @hidden */\nexport class OrderByDocumentProducerComparator {\n constructor(public sortOrder: string[]) {} // TODO: This should be an enum\n\n private targetPartitionKeyRangeDocProdComparator(\n docProd1: DocumentProducer,\n docProd2: DocumentProducer,\n ): 0 | 1 | -1 {\n const a = docProd1.getTargetParitionKeyRange()[\"minInclusive\"];\n const b = docProd2.getTargetParitionKeyRange()[\"minInclusive\"];\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n public compare(docProd1: DocumentProducer, docProd2: DocumentProducer): number {\n // Need to check for split, since we don't want to dereference \"item\" of undefined / exception\n if (docProd1.gotSplit()) {\n return -1;\n }\n if (docProd2.gotSplit()) {\n return 1;\n }\n\n const orderByItemsRes1 = this.getOrderByItems(docProd1.peekBufferedItems()[0]);\n const orderByItemsRes2 = this.getOrderByItems(docProd2.peekBufferedItems()[0]);\n\n // validate order by items and types\n // TODO: once V1 order by on different types is fixed this need to change\n this.validateOrderByItems(orderByItemsRes1, orderByItemsRes2);\n\n // no async call in the for loop\n for (let i = 0; i < orderByItemsRes1.length; i++) {\n // compares the orderby items one by one\n const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]);\n if (compRes !== 0) {\n if (this.sortOrder[i] === \"Ascending\") {\n return compRes;\n } else if (this.sortOrder[i] === \"Descending\") {\n return -compRes;\n }\n }\n }\n\n return this.targetPartitionKeyRangeDocProdComparator(docProd1, docProd2);\n }\n\n // TODO: This smells funny\n public compareValue(item1: unknown, type1: string, item2: unknown, type2: string): number {\n if (type1 === \"object\" || type2 === \"object\") {\n throw new Error(\"Tried to compare an object type\");\n }\n const type1Ord = TYPEORDCOMPARATOR[type1].ord;\n const type2Ord = TYPEORDCOMPARATOR[type2].ord;\n const typeCmp = type1Ord - type2Ord;\n\n if (typeCmp !== 0) {\n // if the types are different, use type ordinal\n return typeCmp;\n }\n\n // both are of the same type\n if (\n type1Ord === TYPEORDCOMPARATOR[\"undefined\"].ord ||\n type1Ord === TYPEORDCOMPARATOR[\"NoValue\"].ord\n ) {\n // if both types are undefined or Null they are equal\n return 0;\n }\n\n const compFunc = TYPEORDCOMPARATOR[type1].compFunc;\n if (typeof compFunc === \"undefined\") {\n throw new Error(\"Cannot find the comparison function\");\n }\n // same type and type is defined compare the items\n return compFunc(item1, item2);\n }\n\n private compareOrderByItem(orderByItem1: any, orderByItem2: any): number {\n const type1 = this.getType(orderByItem1);\n const type2 = this.getType(orderByItem2);\n return this.compareValue(orderByItem1[\"item\"], type1, orderByItem2[\"item\"], type2);\n }\n\n private validateOrderByItems(res1: string[], res2: string[]): void {\n if (res1.length !== res2.length) {\n throw new Error(`Expected ${res1.length}, but got ${res2.length}.`);\n }\n if (res1.length !== this.sortOrder.length) {\n throw new Error(\"orderByItems cannot have a different size than sort orders.\");\n }\n\n for (let i = 0; i < this.sortOrder.length; i++) {\n const type1 = this.getType(res1[i]);\n const type2 = this.getType(res2[i]);\n if (type1 !== type2) {\n throw new Error(\n `Expected ${type1}, but got ${type2}. Cannot execute cross partition order-by queries on mixed types. Consider filtering your query using IS_STRING or IS_NUMBER to get around this exception.`,\n );\n }\n }\n }\n\n private getType(\n orderByItem: any,\n ):\n | \"string\"\n | \"number\"\n | \"bigint\"\n | \"boolean\"\n | \"symbol\"\n | \"undefined\"\n | \"object\"\n | \"function\"\n | \"NoValue\" {\n // TODO: any item?\n if (orderByItem === undefined || orderByItem.item === undefined) {\n return \"NoValue\";\n }\n const type = typeof orderByItem.item;\n if (TYPEORDCOMPARATOR[type] === undefined) {\n throw new Error(`unrecognizable type ${type}`);\n }\n return type;\n }\n\n private getOrderByItems(res: any): any {\n // TODO: any res?\n return res[\"orderByItems\"];\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts new file mode 100644 index 000000000..fc83c7485 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts @@ -0,0 +1,32 @@ +import { ClientContext } from "../ClientContext"; +import { PartitionedQueryExecutionInfo } from "../request/ErrorResponse"; +import { FeedOptions } from "../request/FeedOptions"; +import { DocumentProducer } from "./documentProducer"; +import { ExecutionContext } from "./ExecutionContext"; +import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase"; +import { SqlQuerySpec } from "./SqlQuerySpec"; +/** @hidden */ +export declare class OrderByQueryExecutionContext extends ParallelQueryExecutionContextBase implements ExecutionContext { + private orderByComparator; + /** + * Provides the OrderByQueryExecutionContext. + * This class is capable of handling orderby queries and dervives from ParallelQueryExecutionContextBase. + * + * When handling a parallelized query, it instantiates one instance of + * DocumentProcuder per target partition key range and aggregates the result of each. + * + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - The Collection Link + * @param options - Represents the feed options. + * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo + * @hidden + */ + constructor(clientContext: ClientContext, collectionLink: string, query: string | SqlQuerySpec, options: FeedOptions, partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo); + /** + * Provides a Comparator for document producers which respects orderby sort order. + * @returns Comparator Function + * @hidden + */ + documentProducerComparator(docProd1: DocumentProducer, docProd2: DocumentProducer): any; +} +//# sourceMappingURL=orderByQueryExecutionContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts.map new file mode 100644 index 000000000..00183b703 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"orderByQueryExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/orderByQueryExecutionContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,cAAc;AACd,qBAAa,4BACX,SAAQ,iCACR,YAAW,gBAAgB;IAE3B,OAAO,CAAC,iBAAiB,CAAM;IAC/B;;;;;;;;;;;;OAYG;gBAED,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,GAAG,YAAY,EAC5B,OAAO,EAAE,WAAW,EACpB,6BAA6B,EAAE,6BAA6B;IAS9D;;;;OAIG;IACI,0BAA0B,CAAC,QAAQ,EAAE,gBAAgB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,GAAG;CAG/F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js new file mode 100644 index 000000000..67e961616 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js @@ -0,0 +1,34 @@ +import { OrderByDocumentProducerComparator } from "./orderByDocumentProducerComparator"; +import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase"; +/** @hidden */ +export class OrderByQueryExecutionContext extends ParallelQueryExecutionContextBase { + /** + * Provides the OrderByQueryExecutionContext. + * This class is capable of handling orderby queries and dervives from ParallelQueryExecutionContextBase. + * + * When handling a parallelized query, it instantiates one instance of + * DocumentProcuder per target partition key range and aggregates the result of each. + * + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - The Collection Link + * @param options - Represents the feed options. + * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo + * @hidden + */ + constructor(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo) { + // Calling on base class constructor + super(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo); + this.orderByComparator = new OrderByDocumentProducerComparator(this.sortOrders); + } + // Instance members are inherited + // Overriding documentProducerComparator for OrderByQueryExecutionContexts + /** + * Provides a Comparator for document producers which respects orderby sort order. + * @returns Comparator Function + * @hidden + */ + documentProducerComparator(docProd1, docProd2) { + return this.orderByComparator.compare(docProd1, docProd2); + } +} +//# sourceMappingURL=orderByQueryExecutionContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js.map new file mode 100644 index 000000000..40e379163 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/orderByQueryExecutionContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"orderByQueryExecutionContext.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/orderByQueryExecutionContext.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAGxF,cAAc;AACd,MAAM,OAAO,4BACX,SAAQ,iCAAiC;IAIzC;;;;;;;;;;;;OAYG;IACH,YACE,aAA4B,EAC5B,cAAsB,EACtB,KAA4B,EAC5B,OAAoB,EACpB,6BAA4D;QAE5D,oCAAoC;QACpC,KAAK,CAAC,aAAa,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE,6BAA6B,CAAC,CAAC;QACpF,IAAI,CAAC,iBAAiB,GAAG,IAAI,iCAAiC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAClF,CAAC;IACD,iCAAiC;IAEjC,0EAA0E;IAC1E;;;;OAIG;IACI,0BAA0B,CAAC,QAA0B,EAAE,QAA0B;QACtF,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC5D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { PartitionedQueryExecutionInfo } from \"../request/ErrorResponse\";\nimport { FeedOptions } from \"../request/FeedOptions\";\nimport { DocumentProducer } from \"./documentProducer\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { OrderByDocumentProducerComparator } from \"./orderByDocumentProducerComparator\";\nimport { ParallelQueryExecutionContextBase } from \"./parallelQueryExecutionContextBase\";\nimport { SqlQuerySpec } from \"./SqlQuerySpec\";\n\n/** @hidden */\nexport class OrderByQueryExecutionContext\n extends ParallelQueryExecutionContextBase\n implements ExecutionContext\n{\n private orderByComparator: any;\n /**\n * Provides the OrderByQueryExecutionContext.\n * This class is capable of handling orderby queries and dervives from ParallelQueryExecutionContextBase.\n *\n * When handling a parallelized query, it instantiates one instance of\n * DocumentProcuder per target partition key range and aggregates the result of each.\n *\n * @param clientContext - The service endpoint to use to create the client.\n * @param collectionLink - The Collection Link\n * @param options - Represents the feed options.\n * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo\n * @hidden\n */\n constructor(\n clientContext: ClientContext,\n collectionLink: string,\n query: string | SqlQuerySpec,\n options: FeedOptions,\n partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo,\n ) {\n // Calling on base class constructor\n super(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo);\n this.orderByComparator = new OrderByDocumentProducerComparator(this.sortOrders);\n }\n // Instance members are inherited\n\n // Overriding documentProducerComparator for OrderByQueryExecutionContexts\n /**\n * Provides a Comparator for document producers which respects orderby sort order.\n * @returns Comparator Function\n * @hidden\n */\n public documentProducerComparator(docProd1: DocumentProducer, docProd2: DocumentProducer): any {\n return this.orderByComparator.compare(docProd1, docProd2);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts new file mode 100644 index 000000000..80840db0f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts @@ -0,0 +1,17 @@ +import { DocumentProducer } from "./documentProducer"; +import { ExecutionContext } from "./ExecutionContext"; +import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase"; +/** + * Provides the ParallelQueryExecutionContext. + * This class is capable of handling parallelized queries and derives from ParallelQueryExecutionContextBase. + * @hidden + */ +export declare class ParallelQueryExecutionContext extends ParallelQueryExecutionContextBase implements ExecutionContext { + /** + * Provides a Comparator for document producers using the min value of the corresponding target partition. + * @returns Comparator Function + * @hidden + */ + documentProducerComparator(docProd1: DocumentProducer, docProd2: DocumentProducer): number; +} +//# sourceMappingURL=parallelQueryExecutionContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts.map new file mode 100644 index 000000000..e7745d332 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parallelQueryExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/parallelQueryExecutionContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF;;;;GAIG;AACH,qBAAa,6BACX,SAAQ,iCACR,YAAW,gBAAgB;IAK3B;;;;OAIG;IACI,0BAA0B,CAC/B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,gBAAgB,GACzB,MAAM;CAGV"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js new file mode 100644 index 000000000..ea191c461 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase"; +/** + * Provides the ParallelQueryExecutionContext. + * This class is capable of handling parallelized queries and derives from ParallelQueryExecutionContextBase. + * @hidden + */ +export class ParallelQueryExecutionContext extends ParallelQueryExecutionContextBase { + // Instance members are inherited + // Overriding documentProducerComparator for ParallelQueryExecutionContexts + /** + * Provides a Comparator for document producers using the min value of the corresponding target partition. + * @returns Comparator Function + * @hidden + */ + documentProducerComparator(docProd1, docProd2) { + return docProd1.generation - docProd2.generation; + } +} +//# sourceMappingURL=parallelQueryExecutionContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js.map new file mode 100644 index 000000000..4ef4bc799 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"parallelQueryExecutionContext.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/parallelQueryExecutionContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AAExF;;;;GAIG;AACH,MAAM,OAAO,6BACX,SAAQ,iCAAiC;IAGzC,iCAAiC;IAEjC,2EAA2E;IAC3E;;;;OAIG;IACI,0BAA0B,CAC/B,QAA0B,EAC1B,QAA0B;QAE1B,OAAO,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACnD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { DocumentProducer } from \"./documentProducer\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { ParallelQueryExecutionContextBase } from \"./parallelQueryExecutionContextBase\";\n\n/**\n * Provides the ParallelQueryExecutionContext.\n * This class is capable of handling parallelized queries and derives from ParallelQueryExecutionContextBase.\n * @hidden\n */\nexport class ParallelQueryExecutionContext\n extends ParallelQueryExecutionContextBase\n implements ExecutionContext\n{\n // Instance members are inherited\n\n // Overriding documentProducerComparator for ParallelQueryExecutionContexts\n /**\n * Provides a Comparator for document producers using the min value of the corresponding target partition.\n * @returns Comparator Function\n * @hidden\n */\n public documentProducerComparator(\n docProd1: DocumentProducer,\n docProd2: DocumentProducer,\n ): number {\n return docProd1.generation - docProd2.generation;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts new file mode 100644 index 000000000..8348d7fbd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts @@ -0,0 +1,95 @@ +import { ClientContext } from "../ClientContext"; +import { RUConsumedManager } from "../common"; +import { FeedOptions, QueryOperationOptions, Response } from "../request"; +import { PartitionedQueryExecutionInfo } from "../request/ErrorResponse"; +import { DocumentProducer } from "./documentProducer"; +import { ExecutionContext } from "./ExecutionContext"; +import { SqlQuerySpec } from "./SqlQuerySpec"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +/** @hidden */ +export declare enum ParallelQueryExecutionContextBaseStates { + started = "started", + inProgress = "inProgress", + ended = "ended" +} +/** @hidden */ +export declare abstract class ParallelQueryExecutionContextBase implements ExecutionContext { + private clientContext; + private collectionLink; + private query; + private options; + private partitionedQueryExecutionInfo; + private err; + private state; + private static STATES; + private routingProvider; + protected sortOrders: any; + private requestContinuation; + private respHeaders; + private orderByPQ; + private diagnosticNodeWrapper; + private initializedPriorityQueue; + private ruCapExceededError; + /** + * Semaphore for Controlling Concurrent Access to the `nextItem` Method + * + * serializes access to the `nextItem` method, + * preventing concurrent issues during initialization, document producer + * handling, diagnostic node updates, and error propagation. + */ + private nextItemfetchSemaphore; + /** + * Provides the ParallelQueryExecutionContextBase. + * This is the base class that ParallelQueryExecutionContext and OrderByQueryExecutionContext will derive from. + * + * When handling a parallelized query, it instantiates one instance of + * DocumentProcuder per target partition key range and aggregates the result of each. + * + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - The Collection Link + * @param options - Represents the feed options. + * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo + * @hidden + */ + constructor(clientContext: ClientContext, collectionLink: string, query: string | SqlQuerySpec, options: FeedOptions, partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo); + protected abstract documentProducerComparator(dp1: DocumentProducer, dp2: DocumentProducer): number; + private _mergeWithActiveResponseHeaders; + private _getAndResetActiveResponseHeaders; + private getDiagnosticNode; + private _onTargetPartitionRanges; + /** + * Gets the replacement ranges for a partitionkeyrange that has been split + */ + private _getReplacementPartitionKeyRanges; + /** + * Removes the current document producer from the priqueue, + * replaces that document producer with child document producers, + * then reexecutes the originFunction with the corrrected executionContext + */ + private _repairExecutionContext; + private static _needPartitionKeyRangeCacheRefresh; + /** + * Checks to see if the executionContext needs to be repaired. + * if so it repairs the execution context and executes the ifCallback, + * else it continues with the current execution context and executes the elseCallback + */ + private _repairExecutionContextIfNeeded; + /** + * Fetches the next element in the ParallelQueryExecutionContextBase. + */ + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + private _updateErrorObjectWithBufferedData; + /** + * Determine if there are still remaining resources to processs based on the value of the continuation + * token or the elements remaining on the current batch in the QueryIterator. + * @returns true if there is other elements to process in the ParallelQueryExecutionContextBase. + */ + hasMoreResults(): boolean; + /** + * Creates document producers + */ + private _createTargetPartitionQueryExecutionContext; + private _createDocumentProducersAndFillUpPriorityQueue; + private _processAndEnqueueDocumentProducer; +} +//# sourceMappingURL=parallelQueryExecutionContextBase.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map new file mode 100644 index 000000000..c1d03088b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parallelQueryExecutionContextBase.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/parallelQueryExecutionContextBase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAA+B,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,QAAQ,EAA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BAAgB,GACpB,MAAM;IAET,OAAO,CAAC,+BAA+B;IAIvC,OAAO,CAAC,iCAAiC;IAMzC,OAAO,CAAC,iBAAiB;YAIX,wBAAwB;IAWtC;;OAEG;YACW,iCAAiC;IAgB/C;;;;OAIG;YACW,uBAAuB;IA6DrC,OAAO,CAAC,MAAM,CAAC,kCAAkC;IASjD;;;;OAIG;YACW,+BAA+B;IA4B7C;;OAEG;IACU,QAAQ,CACnB,cAAc,EAAE,sBAAsB,EACtC,gBAAgB,CAAC,EAAE,qBAAqB,EACxC,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAgLzB,OAAO,CAAC,kCAAkC;IAO1C;;;;OAIG;IACI,cAAc,IAAI,OAAO;IAMhC;;OAEG;IACH,OAAO,CAAC,2CAA2C;YAmCrC,8CAA8C;YA4E9C,kCAAkC;CAmCjD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js new file mode 100644 index 000000000..e04a01229 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js @@ -0,0 +1,478 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import PriorityQueue from "priorityqueuejs"; +import { createClientLogger } from "@azure/logger"; +import { StatusCodes, SubStatusCodes } from "../common"; +import { QueryRange } from "../routing/QueryRange"; +import { SmartRoutingMapProvider } from "../routing/smartRoutingMapProvider"; +import { DocumentProducer } from "./documentProducer"; +import { getInitialHeader, mergeHeaders } from "./headerUtils"; +import { DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; +import { addDignosticChild } from "../utils/diagnostics"; +import { MetadataLookUpType } from "../CosmosDiagnostics"; +import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel"; +import { RUCapPerOperationExceededErrorCode, } from "../request/RUCapPerOperationExceededError"; +import semaphore from "semaphore"; +/** @hidden */ +const logger = createClientLogger("parallelQueryExecutionContextBase"); +/** @hidden */ +export var ParallelQueryExecutionContextBaseStates; +(function (ParallelQueryExecutionContextBaseStates) { + ParallelQueryExecutionContextBaseStates["started"] = "started"; + ParallelQueryExecutionContextBaseStates["inProgress"] = "inProgress"; + ParallelQueryExecutionContextBaseStates["ended"] = "ended"; +})(ParallelQueryExecutionContextBaseStates || (ParallelQueryExecutionContextBaseStates = {})); +/** @hidden */ +export class ParallelQueryExecutionContextBase { + /** + * Provides the ParallelQueryExecutionContextBase. + * This is the base class that ParallelQueryExecutionContext and OrderByQueryExecutionContext will derive from. + * + * When handling a parallelized query, it instantiates one instance of + * DocumentProcuder per target partition key range and aggregates the result of each. + * + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - The Collection Link + * @param options - Represents the feed options. + * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo + * @hidden + */ + constructor(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo) { + this.clientContext = clientContext; + this.collectionLink = collectionLink; + this.query = query; + this.options = options; + this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo; + this.initializedPriorityQueue = false; + this.ruCapExceededError = undefined; + this.clientContext = clientContext; + this.collectionLink = collectionLink; + this.query = query; + this.options = options; + this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo; + this.diagnosticNodeWrapper = { + consumed: false, + diagnosticNode: new DiagnosticNodeInternal(clientContext.diagnosticLevel, DiagnosticNodeType.PARALLEL_QUERY_NODE, null), + }; + this.diagnosticNodeWrapper.diagnosticNode.addData({ stateful: true }); + this.err = undefined; + this.state = ParallelQueryExecutionContextBase.STATES.started; + this.routingProvider = new SmartRoutingMapProvider(this.clientContext); + this.sortOrders = this.partitionedQueryExecutionInfo.queryInfo.orderBy; + this.requestContinuation = options ? options.continuationToken || options.continuation : null; + // response headers of undergoing operation + this.respHeaders = getInitialHeader(); + // Make priority queue for documentProducers + // The comparator is supplied by the derived class + this.orderByPQ = new PriorityQueue((a, b) => this.documentProducerComparator(b, a)); + this.nextItemfetchSemaphore = semaphore(1); + } + _mergeWithActiveResponseHeaders(headers) { + mergeHeaders(this.respHeaders, headers); + } + _getAndResetActiveResponseHeaders() { + const ret = this.respHeaders; + this.respHeaders = getInitialHeader(); + return ret; + } + getDiagnosticNode() { + return this.diagnosticNodeWrapper.diagnosticNode; + } + async _onTargetPartitionRanges() { + // invokes the callback when the target partition ranges are ready + const parsedRanges = this.partitionedQueryExecutionInfo.queryRanges; + const queryRanges = parsedRanges.map((item) => QueryRange.parseFromDict(item)); + return this.routingProvider.getOverlappingRanges(this.collectionLink, queryRanges, this.getDiagnosticNode()); + } + /** + * Gets the replacement ranges for a partitionkeyrange that has been split + */ + async _getReplacementPartitionKeyRanges(documentProducer) { + const partitionKeyRange = documentProducer.targetPartitionKeyRange; + // Download the new routing map + this.routingProvider = new SmartRoutingMapProvider(this.clientContext); + // Get the queryRange that relates to this partitionKeyRange + const queryRange = QueryRange.parsePartitionKeyRange(partitionKeyRange); + return this.routingProvider.getOverlappingRanges(this.collectionLink, [queryRange], this.getDiagnosticNode()); + } + // TODO: P0 Code smell - can barely tell what this is doing + /** + * Removes the current document producer from the priqueue, + * replaces that document producer with child document producers, + * then reexecutes the originFunction with the corrrected executionContext + */ + async _repairExecutionContext(diagnosticNode, originFunction) { + // TODO: any + // Get the replacement ranges + // Removing the invalid documentProducer from the orderByPQ + const parentDocumentProducer = this.orderByPQ.deq(); + try { + const replacementPartitionKeyRanges = await this._getReplacementPartitionKeyRanges(parentDocumentProducer); + const replacementDocumentProducers = []; + // Create the replacement documentProducers + replacementPartitionKeyRanges.forEach((partitionKeyRange) => { + // Create replacment document producers with the parent's continuationToken + const replacementDocumentProducer = this._createTargetPartitionQueryExecutionContext(partitionKeyRange, parentDocumentProducer.continuationToken); + replacementDocumentProducers.push(replacementDocumentProducer); + }); + // We need to check if the documentProducers even has anything left to fetch from before enqueing them + const checkAndEnqueueDocumentProducer = async (documentProducerToCheck, checkNextDocumentProducerCallback) => { + try { + const { result: afterItem } = await documentProducerToCheck.current(diagnosticNode); + if (afterItem === undefined) { + // no more results left in this document producer, so we don't enqueue it + } + else { + // Safe to put document producer back in the queue + this.orderByPQ.enq(documentProducerToCheck); + } + await checkNextDocumentProducerCallback(); + } + catch (err) { + this.err = err; + return; + } + }; + const checkAndEnqueueDocumentProducers = async (rdp) => { + if (rdp.length > 0) { + // We still have a replacementDocumentProducer to check + const replacementDocumentProducer = rdp.shift(); + await checkAndEnqueueDocumentProducer(replacementDocumentProducer, async () => { + await checkAndEnqueueDocumentProducers(rdp); + }); + } + else { + // reexecutes the originFunction with the corrrected executionContext + return originFunction(); + } + }; + // Invoke the recursive function to get the ball rolling + await checkAndEnqueueDocumentProducers(replacementDocumentProducers); + } + catch (err) { + this.err = err; + throw err; + } + } + static _needPartitionKeyRangeCacheRefresh(error) { + // TODO: any error + return (error.code === StatusCodes.Gone && + "substatus" in error && + error["substatus"] === SubStatusCodes.PartitionKeyRangeGone); + } + /** + * Checks to see if the executionContext needs to be repaired. + * if so it repairs the execution context and executes the ifCallback, + * else it continues with the current execution context and executes the elseCallback + */ + async _repairExecutionContextIfNeeded(diagnosticNode, ifCallback, elseCallback, operationOptions, ruConsumedManager) { + const documentProducer = this.orderByPQ.peek(); + // Check if split happened + try { + await documentProducer.current(diagnosticNode, operationOptions, ruConsumedManager); + elseCallback(); + } + catch (err) { + if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) { + // Split has happened so we need to repair execution context before continueing + return addDignosticChild((childNode) => this._repairExecutionContext(childNode, ifCallback), diagnosticNode, DiagnosticNodeType.QUERY_REPAIR_NODE); + } + else { + // Something actually bad happened ... + this.err = err; + throw err; + } + } + } + /** + * Fetches the next element in the ParallelQueryExecutionContextBase. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.err) { + // if there is a prior error return error + throw this.err; + } + return new Promise((resolve, reject) => { + this.nextItemfetchSemaphore.take(async () => { + // document producer queue initilization + if (!this.initializedPriorityQueue) { + try { + await this._createDocumentProducersAndFillUpPriorityQueue(operationOptions, ruConsumedManager); + this.initializedPriorityQueue = true; + } + catch (err) { + this.err = err; + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + reject(this.err); + return; + } + } + if (!this.diagnosticNodeWrapper.consumed) { + diagnosticNode.addChildNode(this.diagnosticNodeWrapper.diagnosticNode, CosmosDbDiagnosticLevel.debug, MetadataLookUpType.QueryPlanLookUp); + this.diagnosticNodeWrapper.diagnosticNode = undefined; + this.diagnosticNodeWrapper.consumed = true; + } + else { + this.diagnosticNodeWrapper.diagnosticNode = diagnosticNode; + } + // NOTE: lock must be released before invoking quitting + if (this.err) { + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + this.err.headers = this._getAndResetActiveResponseHeaders(); + reject(this.err); + return; + } + if (this.orderByPQ.size() === 0) { + // there is no more results + this.state = ParallelQueryExecutionContextBase.STATES.ended; + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + return resolve({ + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }); + } + const ifCallback = () => { + // Release the semaphore to avoid deadlock + this.nextItemfetchSemaphore.leave(); + // Reexcute the function + return resolve(this.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + }; + const elseCallback = async () => { + let documentProducer; + try { + documentProducer = this.orderByPQ.deq(); + } + catch (e) { + // if comparing elements of the priority queue throws exception + // set that error and return error + this.err = e; + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + this.err.headers = this._getAndResetActiveResponseHeaders(); + reject(this.err); + return; + } + let item; + let headers; + try { + const response = await documentProducer.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + item = response.result; + headers = response.headers; + this._mergeWithActiveResponseHeaders(headers); + if (item === undefined) { + // this should never happen + // because the documentProducer already has buffered an item + // assert item !== undefined + this.err = new Error(`Extracted DocumentProducer from the priority queue \ + doesn't have any buffered item!`); + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + return resolve({ + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }); + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + this._updateErrorObjectWithBufferedData(err); + this.err = err; + } + else { + this.err = new Error(`Extracted DocumentProducer from the priority queue fails to get the \ + buffered item. Due to ${JSON.stringify(err)}`); + this.err.headers = this._getAndResetActiveResponseHeaders(); + } + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + reject(this.err); + return; + } + // we need to put back the document producer to the queue if it has more elements. + // the lock will be released after we know document producer must be put back in the queue or not + try { + const { result: afterItem, headers: otherHeaders } = await documentProducer.current(diagnosticNode, operationOptions, ruConsumedManager); + this._mergeWithActiveResponseHeaders(otherHeaders); + if (afterItem === undefined) { + // no more results is left in this document producer + } + else { + try { + const headItem = documentProducer.fetchResults[0]; + if (typeof headItem === "undefined") { + throw new Error("Extracted DocumentProducer from PQ is invalid state with no result!"); + } + this.orderByPQ.enq(documentProducer); + } + catch (e) { + // if comparing elements in priority queue throws exception + // set error + this.err = e; + } + } + } + catch (err) { + if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) { + // We want the document producer enqueued + // So that later parts of the code can repair the execution context + this.orderByPQ.enq(documentProducer); + } + else if (err.code === RUCapPerOperationExceededErrorCode) { + this._updateErrorObjectWithBufferedData(err); + this.err = err; + reject(this.err); + } + else { + // Something actually bad happened + this.err = err; + reject(this.err); + } + } + finally { + // release the lock before returning + this.nextItemfetchSemaphore.leave(); + } + // invoke the callback on the item + return resolve({ + result: item, + headers: this._getAndResetActiveResponseHeaders(), + }); + }; + this._repairExecutionContextIfNeeded(diagnosticNode, ifCallback, elseCallback).catch(reject); + }); + }); + } + _updateErrorObjectWithBufferedData(err) { + this.orderByPQ.forEach((dp) => { + const bufferedItems = dp.peekBufferedItems(); + err.fetchedResults.push(...bufferedItems); + }); + } + /** + * Determine if there are still remaining resources to processs based on the value of the continuation + * token or the elements remaining on the current batch in the QueryIterator. + * @returns true if there is other elements to process in the ParallelQueryExecutionContextBase. + */ + hasMoreResults() { + return !(this.state === ParallelQueryExecutionContextBase.STATES.ended || this.err !== undefined); + } + /** + * Creates document producers + */ + _createTargetPartitionQueryExecutionContext(partitionKeyTargetRange, continuationToken) { + // TODO: any + // creates target partition range Query Execution Context + let rewrittenQuery = this.partitionedQueryExecutionInfo.queryInfo.rewrittenQuery; + let sqlQuerySpec; + const query = this.query; + if (typeof query === "string") { + sqlQuerySpec = { query }; + } + else { + sqlQuerySpec = query; + } + const formatPlaceHolder = "{documentdb-formattableorderbyquery-filter}"; + if (rewrittenQuery) { + sqlQuerySpec = JSON.parse(JSON.stringify(sqlQuerySpec)); + // We hardcode the formattable filter to true for now + rewrittenQuery = rewrittenQuery.replace(formatPlaceHolder, "true"); + sqlQuerySpec["query"] = rewrittenQuery; + } + const options = Object.assign({}, this.options); + options.continuationToken = continuationToken; + return new DocumentProducer(this.clientContext, this.collectionLink, sqlQuerySpec, partitionKeyTargetRange, options); + } + async _createDocumentProducersAndFillUpPriorityQueue(operationOptions, ruConsumedManager) { + try { + const targetPartitionRanges = await this._onTargetPartitionRanges(); + const maxDegreeOfParallelism = this.options.maxDegreeOfParallelism === undefined || this.options.maxDegreeOfParallelism < 1 + ? targetPartitionRanges.length + : Math.min(this.options.maxDegreeOfParallelism, targetPartitionRanges.length); + logger.info("Query starting against " + + targetPartitionRanges.length + + " ranges with parallelism of " + + maxDegreeOfParallelism); + let filteredPartitionKeyRanges = []; + // The document producers generated from filteredPartitionKeyRanges + const targetPartitionQueryExecutionContextList = []; + if (this.requestContinuation) { + throw new Error("Continuation tokens are not yet supported for cross partition queries"); + } + else { + filteredPartitionKeyRanges = targetPartitionRanges; + } + // Create one documentProducer for each partitionTargetRange + filteredPartitionKeyRanges.forEach((partitionTargetRange) => { + // TODO: any partitionTargetRange + // no async callback + targetPartitionQueryExecutionContextList.push(this._createTargetPartitionQueryExecutionContext(partitionTargetRange)); + }); + // Fill up our priority queue with documentProducers + let inProgressPromises = []; + for (const documentProducer of targetPartitionQueryExecutionContextList) { + // Don't enqueue any new promise if RU cap exceeded + if (this.ruCapExceededError) { + break; + } + const promise = this._processAndEnqueueDocumentProducer(documentProducer, operationOptions, ruConsumedManager); + inProgressPromises.push(promise); + // Limit concurrent executions + if (inProgressPromises.length === maxDegreeOfParallelism) { + await Promise.all(inProgressPromises); + inProgressPromises = []; + } + } + // Wait for all promises to complete + await Promise.all(inProgressPromises); + if (this.err) { + if (this.ruCapExceededError) { + // merge the buffered items + this.orderByPQ.forEach((dp) => { + const bufferedItems = dp.peekBufferedItems(); + this.ruCapExceededError.fetchedResults.push(...bufferedItems); + }); + throw this.ruCapExceededError; + } + throw this.err; + } + } + catch (err) { + this.err = err; + throw err; + } + } + async _processAndEnqueueDocumentProducer(documentProducer, operationOptions, ruConsumedManager) { + try { + const { result: document, headers } = await documentProducer.current(this.getDiagnosticNode(), operationOptions, ruConsumedManager); + this._mergeWithActiveResponseHeaders(headers); + if (document !== undefined) { + this.orderByPQ.enq(documentProducer); + } + } + catch (err) { + this._mergeWithActiveResponseHeaders(err.headers); + this.err = err; + if (err.code === RUCapPerOperationExceededErrorCode) { + // would be halting further execution of other promises + if (!this.ruCapExceededError) { + this.ruCapExceededError = err; + } + else { + // merge the buffered items + if (err.fetchedResults) { + this.ruCapExceededError.fetchedResults.push(...err.fetchedResults); + } + } + } + else { + throw err; + } + } + return; + } +} +ParallelQueryExecutionContextBase.STATES = ParallelQueryExecutionContextBaseStates; +//# sourceMappingURL=parallelQueryExecutionContextBase.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js.map new file mode 100644 index 000000000..58832b3fb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/parallelQueryExecutionContextBase.js.map @@ -0,0 +1 @@ +{"version":3,"file":"parallelQueryExecutionContextBase.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/parallelQueryExecutionContextBase.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAe,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAqB,MAAM,WAAW,CAAC;AAG3E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAEL,kCAAkC,GACnC,MAAM,2CAA2C,CAAC;AACnD,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,cAAc;AACd,MAAM,MAAM,GAAgB,kBAAkB,CAAC,mCAAmC,CAAC,CAAC;AAEpF,cAAc;AACd,MAAM,CAAN,IAAY,uCAIX;AAJD,WAAY,uCAAuC;IACjD,8DAAmB,CAAA;IACnB,oEAAyB,CAAA;IACzB,0DAAe,CAAA;AACjB,CAAC,EAJW,uCAAuC,KAAvC,uCAAuC,QAIlD;AAED,cAAc;AACd,MAAM,OAAgB,iCAAiC;IAuBrD;;;;;;;;;;;;OAYG;IACH,YACU,aAA4B,EAC5B,cAAsB,EACtB,KAA4B,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1C,CAA2C","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport PriorityQueue from \"priorityqueuejs\";\nimport { ClientContext } from \"../ClientContext\";\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { StatusCodes, SubStatusCodes, RUConsumedManager } from \"../common\";\nimport { FeedOptions, QueryOperationOptions, Response } from \"../request\";\nimport { PartitionedQueryExecutionInfo } from \"../request/ErrorResponse\";\nimport { QueryRange } from \"../routing/QueryRange\";\nimport { SmartRoutingMapProvider } from \"../routing/smartRoutingMapProvider\";\nimport { CosmosHeaders } from \"./CosmosHeaders\";\nimport { DocumentProducer } from \"./documentProducer\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { getInitialHeader, mergeHeaders } from \"./headerUtils\";\nimport { SqlQuerySpec } from \"./SqlQuerySpec\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { MetadataLookUpType } from \"../CosmosDiagnostics\";\nimport { CosmosDbDiagnosticLevel } from \"../diagnostics/CosmosDbDiagnosticLevel\";\nimport {\n RUCapPerOperationExceededError,\n RUCapPerOperationExceededErrorCode,\n} from \"../request/RUCapPerOperationExceededError\";\nimport semaphore from \"semaphore\";\n\n/** @hidden */\nconst logger: AzureLogger = createClientLogger(\"parallelQueryExecutionContextBase\");\n\n/** @hidden */\nexport enum ParallelQueryExecutionContextBaseStates {\n started = \"started\",\n inProgress = \"inProgress\",\n ended = \"ended\",\n}\n\n/** @hidden */\nexport abstract class ParallelQueryExecutionContextBase implements ExecutionContext {\n private err: any;\n private state: any;\n private static STATES = ParallelQueryExecutionContextBaseStates;\n private routingProvider: SmartRoutingMapProvider;\n protected sortOrders: any;\n private requestContinuation: any;\n private respHeaders: CosmosHeaders;\n private orderByPQ: PriorityQueue;\n private diagnosticNodeWrapper: {\n consumed: boolean;\n diagnosticNode: DiagnosticNodeInternal;\n };\n private initializedPriorityQueue: boolean = false;\n private ruCapExceededError: RUCapPerOperationExceededError = undefined;\n /**\n * Semaphore for Controlling Concurrent Access to the `nextItem` Method\n *\n * serializes access to the `nextItem` method,\n * preventing concurrent issues during initialization, document producer\n * handling, diagnostic node updates, and error propagation.\n */\n private nextItemfetchSemaphore;\n /**\n * Provides the ParallelQueryExecutionContextBase.\n * This is the base class that ParallelQueryExecutionContext and OrderByQueryExecutionContext will derive from.\n *\n * When handling a parallelized query, it instantiates one instance of\n * DocumentProcuder per target partition key range and aggregates the result of each.\n *\n * @param clientContext - The service endpoint to use to create the client.\n * @param collectionLink - The Collection Link\n * @param options - Represents the feed options.\n * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo\n * @hidden\n */\n constructor(\n private clientContext: ClientContext,\n private collectionLink: string,\n private query: string | SqlQuerySpec,\n private options: FeedOptions,\n private partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo,\n ) {\n this.clientContext = clientContext;\n this.collectionLink = collectionLink;\n this.query = query;\n this.options = options;\n this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo;\n this.diagnosticNodeWrapper = {\n consumed: false,\n diagnosticNode: new DiagnosticNodeInternal(\n clientContext.diagnosticLevel,\n DiagnosticNodeType.PARALLEL_QUERY_NODE,\n null,\n ),\n };\n this.diagnosticNodeWrapper.diagnosticNode.addData({ stateful: true });\n this.err = undefined;\n this.state = ParallelQueryExecutionContextBase.STATES.started;\n this.routingProvider = new SmartRoutingMapProvider(this.clientContext);\n this.sortOrders = this.partitionedQueryExecutionInfo.queryInfo.orderBy;\n\n this.requestContinuation = options ? options.continuationToken || options.continuation : null;\n // response headers of undergoing operation\n this.respHeaders = getInitialHeader();\n\n // Make priority queue for documentProducers\n // The comparator is supplied by the derived class\n this.orderByPQ = new PriorityQueue(\n (a: DocumentProducer, b: DocumentProducer) => this.documentProducerComparator(b, a),\n );\n this.nextItemfetchSemaphore = semaphore(1);\n }\n\n protected abstract documentProducerComparator(\n dp1: DocumentProducer,\n dp2: DocumentProducer,\n ): number;\n\n private _mergeWithActiveResponseHeaders(headers: CosmosHeaders): void {\n mergeHeaders(this.respHeaders, headers);\n }\n\n private _getAndResetActiveResponseHeaders(): CosmosHeaders {\n const ret = this.respHeaders;\n this.respHeaders = getInitialHeader();\n return ret;\n }\n\n private getDiagnosticNode(): DiagnosticNodeInternal {\n return this.diagnosticNodeWrapper.diagnosticNode;\n }\n\n private async _onTargetPartitionRanges(): Promise {\n // invokes the callback when the target partition ranges are ready\n const parsedRanges = this.partitionedQueryExecutionInfo.queryRanges;\n const queryRanges = parsedRanges.map((item) => QueryRange.parseFromDict(item));\n return this.routingProvider.getOverlappingRanges(\n this.collectionLink,\n queryRanges,\n this.getDiagnosticNode(),\n );\n }\n\n /**\n * Gets the replacement ranges for a partitionkeyrange that has been split\n */\n private async _getReplacementPartitionKeyRanges(\n documentProducer: DocumentProducer,\n ): Promise {\n const partitionKeyRange = documentProducer.targetPartitionKeyRange;\n // Download the new routing map\n this.routingProvider = new SmartRoutingMapProvider(this.clientContext);\n // Get the queryRange that relates to this partitionKeyRange\n const queryRange = QueryRange.parsePartitionKeyRange(partitionKeyRange);\n return this.routingProvider.getOverlappingRanges(\n this.collectionLink,\n [queryRange],\n this.getDiagnosticNode(),\n );\n }\n\n // TODO: P0 Code smell - can barely tell what this is doing\n /**\n * Removes the current document producer from the priqueue,\n * replaces that document producer with child document producers,\n * then reexecutes the originFunction with the corrrected executionContext\n */\n private async _repairExecutionContext(\n diagnosticNode: DiagnosticNodeInternal,\n originFunction: any,\n ): Promise {\n // TODO: any\n // Get the replacement ranges\n // Removing the invalid documentProducer from the orderByPQ\n const parentDocumentProducer = this.orderByPQ.deq();\n try {\n const replacementPartitionKeyRanges: any[] =\n await this._getReplacementPartitionKeyRanges(parentDocumentProducer);\n const replacementDocumentProducers: DocumentProducer[] = [];\n // Create the replacement documentProducers\n replacementPartitionKeyRanges.forEach((partitionKeyRange) => {\n // Create replacment document producers with the parent's continuationToken\n const replacementDocumentProducer = this._createTargetPartitionQueryExecutionContext(\n partitionKeyRange,\n parentDocumentProducer.continuationToken,\n );\n replacementDocumentProducers.push(replacementDocumentProducer);\n });\n // We need to check if the documentProducers even has anything left to fetch from before enqueing them\n const checkAndEnqueueDocumentProducer = async (\n documentProducerToCheck: DocumentProducer,\n checkNextDocumentProducerCallback: any,\n ): Promise => {\n try {\n const { result: afterItem } = await documentProducerToCheck.current(diagnosticNode);\n if (afterItem === undefined) {\n // no more results left in this document producer, so we don't enqueue it\n } else {\n // Safe to put document producer back in the queue\n this.orderByPQ.enq(documentProducerToCheck);\n }\n\n await checkNextDocumentProducerCallback();\n } catch (err: any) {\n this.err = err;\n return;\n }\n };\n const checkAndEnqueueDocumentProducers = async (rdp: DocumentProducer[]): Promise => {\n if (rdp.length > 0) {\n // We still have a replacementDocumentProducer to check\n const replacementDocumentProducer = rdp.shift();\n await checkAndEnqueueDocumentProducer(replacementDocumentProducer, async () => {\n await checkAndEnqueueDocumentProducers(rdp);\n });\n } else {\n // reexecutes the originFunction with the corrrected executionContext\n return originFunction();\n }\n };\n // Invoke the recursive function to get the ball rolling\n await checkAndEnqueueDocumentProducers(replacementDocumentProducers);\n } catch (err: any) {\n this.err = err;\n throw err;\n }\n }\n\n private static _needPartitionKeyRangeCacheRefresh(error: any): boolean {\n // TODO: any error\n return (\n error.code === StatusCodes.Gone &&\n \"substatus\" in error &&\n error[\"substatus\"] === SubStatusCodes.PartitionKeyRangeGone\n );\n }\n\n /**\n * Checks to see if the executionContext needs to be repaired.\n * if so it repairs the execution context and executes the ifCallback,\n * else it continues with the current execution context and executes the elseCallback\n */\n private async _repairExecutionContextIfNeeded(\n diagnosticNode: DiagnosticNodeInternal,\n ifCallback: any,\n elseCallback: any,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise {\n const documentProducer = this.orderByPQ.peek();\n // Check if split happened\n try {\n await documentProducer.current(diagnosticNode, operationOptions, ruConsumedManager);\n elseCallback();\n } catch (err: any) {\n if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) {\n // Split has happened so we need to repair execution context before continueing\n return addDignosticChild(\n (childNode) => this._repairExecutionContext(childNode, ifCallback),\n diagnosticNode,\n DiagnosticNodeType.QUERY_REPAIR_NODE,\n );\n } else {\n // Something actually bad happened ...\n this.err = err;\n throw err;\n }\n }\n }\n\n /**\n * Fetches the next element in the ParallelQueryExecutionContextBase.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.err) {\n // if there is a prior error return error\n throw this.err;\n }\n return new Promise>((resolve, reject) => {\n this.nextItemfetchSemaphore.take(async () => {\n // document producer queue initilization\n if (!this.initializedPriorityQueue) {\n try {\n await this._createDocumentProducersAndFillUpPriorityQueue(\n operationOptions,\n ruConsumedManager,\n );\n this.initializedPriorityQueue = true;\n } catch (err: any) {\n this.err = err;\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n reject(this.err);\n return;\n }\n }\n\n if (!this.diagnosticNodeWrapper.consumed) {\n diagnosticNode.addChildNode(\n this.diagnosticNodeWrapper.diagnosticNode,\n CosmosDbDiagnosticLevel.debug,\n MetadataLookUpType.QueryPlanLookUp,\n );\n this.diagnosticNodeWrapper.diagnosticNode = undefined;\n this.diagnosticNodeWrapper.consumed = true;\n } else {\n this.diagnosticNodeWrapper.diagnosticNode = diagnosticNode;\n }\n // NOTE: lock must be released before invoking quitting\n if (this.err) {\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n this.err.headers = this._getAndResetActiveResponseHeaders();\n reject(this.err);\n return;\n }\n\n if (this.orderByPQ.size() === 0) {\n // there is no more results\n this.state = ParallelQueryExecutionContextBase.STATES.ended;\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n return resolve({\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n });\n }\n\n const ifCallback = (): void => {\n // Release the semaphore to avoid deadlock\n this.nextItemfetchSemaphore.leave();\n // Reexcute the function\n return resolve(this.nextItem(diagnosticNode, operationOptions, ruConsumedManager));\n };\n const elseCallback = async (): Promise => {\n let documentProducer: DocumentProducer;\n try {\n documentProducer = this.orderByPQ.deq();\n } catch (e: any) {\n // if comparing elements of the priority queue throws exception\n // set that error and return error\n this.err = e;\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n this.err.headers = this._getAndResetActiveResponseHeaders();\n reject(this.err);\n return;\n }\n\n let item: any;\n let headers: CosmosHeaders;\n try {\n const response = await documentProducer.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n item = response.result;\n headers = response.headers;\n this._mergeWithActiveResponseHeaders(headers);\n if (item === undefined) {\n // this should never happen\n // because the documentProducer already has buffered an item\n // assert item !== undefined\n this.err = new Error(\n `Extracted DocumentProducer from the priority queue \\\n doesn't have any buffered item!`,\n );\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n return resolve({\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n });\n }\n } catch (err: any) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n this._updateErrorObjectWithBufferedData(err);\n this.err = err;\n } else {\n this.err = new Error(\n `Extracted DocumentProducer from the priority queue fails to get the \\\n buffered item. Due to ${JSON.stringify(err)}`,\n );\n this.err.headers = this._getAndResetActiveResponseHeaders();\n }\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n reject(this.err);\n return;\n }\n\n // we need to put back the document producer to the queue if it has more elements.\n // the lock will be released after we know document producer must be put back in the queue or not\n try {\n const { result: afterItem, headers: otherHeaders } = await documentProducer.current(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this._mergeWithActiveResponseHeaders(otherHeaders);\n if (afterItem === undefined) {\n // no more results is left in this document producer\n } else {\n try {\n const headItem = documentProducer.fetchResults[0];\n if (typeof headItem === \"undefined\") {\n throw new Error(\n \"Extracted DocumentProducer from PQ is invalid state with no result!\",\n );\n }\n this.orderByPQ.enq(documentProducer);\n } catch (e: any) {\n // if comparing elements in priority queue throws exception\n // set error\n this.err = e;\n }\n }\n } catch (err: any) {\n if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) {\n // We want the document producer enqueued\n // So that later parts of the code can repair the execution context\n this.orderByPQ.enq(documentProducer);\n } else if (err.code === RUCapPerOperationExceededErrorCode) {\n this._updateErrorObjectWithBufferedData(err);\n this.err = err;\n reject(this.err);\n } else {\n // Something actually bad happened\n this.err = err;\n reject(this.err);\n }\n } finally {\n // release the lock before returning\n this.nextItemfetchSemaphore.leave();\n }\n // invoke the callback on the item\n return resolve({\n result: item,\n headers: this._getAndResetActiveResponseHeaders(),\n });\n };\n this._repairExecutionContextIfNeeded(diagnosticNode, ifCallback, elseCallback).catch(\n reject,\n );\n });\n });\n }\n\n private _updateErrorObjectWithBufferedData(err: any) {\n this.orderByPQ.forEach((dp) => {\n const bufferedItems = dp.peekBufferedItems();\n err.fetchedResults.push(...bufferedItems);\n });\n }\n\n /**\n * Determine if there are still remaining resources to processs based on the value of the continuation\n * token or the elements remaining on the current batch in the QueryIterator.\n * @returns true if there is other elements to process in the ParallelQueryExecutionContextBase.\n */\n public hasMoreResults(): boolean {\n return !(\n this.state === ParallelQueryExecutionContextBase.STATES.ended || this.err !== undefined\n );\n }\n\n /**\n * Creates document producers\n */\n private _createTargetPartitionQueryExecutionContext(\n partitionKeyTargetRange: any,\n continuationToken?: any,\n ): DocumentProducer {\n // TODO: any\n // creates target partition range Query Execution Context\n let rewrittenQuery = this.partitionedQueryExecutionInfo.queryInfo.rewrittenQuery;\n let sqlQuerySpec: SqlQuerySpec;\n const query = this.query;\n if (typeof query === \"string\") {\n sqlQuerySpec = { query };\n } else {\n sqlQuerySpec = query;\n }\n\n const formatPlaceHolder = \"{documentdb-formattableorderbyquery-filter}\";\n if (rewrittenQuery) {\n sqlQuerySpec = JSON.parse(JSON.stringify(sqlQuerySpec));\n // We hardcode the formattable filter to true for now\n rewrittenQuery = rewrittenQuery.replace(formatPlaceHolder, \"true\");\n sqlQuerySpec[\"query\"] = rewrittenQuery;\n }\n\n const options = { ...this.options };\n options.continuationToken = continuationToken;\n\n return new DocumentProducer(\n this.clientContext,\n this.collectionLink,\n sqlQuerySpec,\n partitionKeyTargetRange,\n options,\n );\n }\n\n private async _createDocumentProducersAndFillUpPriorityQueue(\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise {\n try {\n const targetPartitionRanges = await this._onTargetPartitionRanges();\n const maxDegreeOfParallelism =\n this.options.maxDegreeOfParallelism === undefined || this.options.maxDegreeOfParallelism < 1\n ? targetPartitionRanges.length\n : Math.min(this.options.maxDegreeOfParallelism, targetPartitionRanges.length);\n\n logger.info(\n \"Query starting against \" +\n targetPartitionRanges.length +\n \" ranges with parallelism of \" +\n maxDegreeOfParallelism,\n );\n\n let filteredPartitionKeyRanges = [];\n // The document producers generated from filteredPartitionKeyRanges\n const targetPartitionQueryExecutionContextList: DocumentProducer[] = [];\n\n if (this.requestContinuation) {\n throw new Error(\"Continuation tokens are not yet supported for cross partition queries\");\n } else {\n filteredPartitionKeyRanges = targetPartitionRanges;\n }\n\n // Create one documentProducer for each partitionTargetRange\n filteredPartitionKeyRanges.forEach((partitionTargetRange: any) => {\n // TODO: any partitionTargetRange\n // no async callback\n targetPartitionQueryExecutionContextList.push(\n this._createTargetPartitionQueryExecutionContext(partitionTargetRange),\n );\n });\n\n // Fill up our priority queue with documentProducers\n let inProgressPromises: Promise[] = [];\n for (const documentProducer of targetPartitionQueryExecutionContextList) {\n // Don't enqueue any new promise if RU cap exceeded\n if (this.ruCapExceededError) {\n break;\n }\n const promise: Promise = this._processAndEnqueueDocumentProducer(\n documentProducer,\n operationOptions,\n ruConsumedManager,\n );\n inProgressPromises.push(promise);\n\n // Limit concurrent executions\n if (inProgressPromises.length === maxDegreeOfParallelism) {\n await Promise.all(inProgressPromises);\n inProgressPromises = [];\n }\n }\n // Wait for all promises to complete\n await Promise.all(inProgressPromises);\n if (this.err) {\n if (this.ruCapExceededError) {\n // merge the buffered items\n this.orderByPQ.forEach((dp) => {\n const bufferedItems = dp.peekBufferedItems();\n this.ruCapExceededError.fetchedResults.push(...bufferedItems);\n });\n throw this.ruCapExceededError;\n }\n throw this.err;\n }\n } catch (err: any) {\n this.err = err;\n throw err;\n }\n }\n\n private async _processAndEnqueueDocumentProducer(\n documentProducer: DocumentProducer,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise {\n try {\n const { result: document, headers } = await documentProducer.current(\n this.getDiagnosticNode(),\n operationOptions,\n ruConsumedManager,\n );\n this._mergeWithActiveResponseHeaders(headers);\n\n if (document !== undefined) {\n this.orderByPQ.enq(documentProducer);\n }\n } catch (err) {\n this._mergeWithActiveResponseHeaders(err.headers);\n this.err = err;\n if (err.code === RUCapPerOperationExceededErrorCode) {\n // would be halting further execution of other promises\n if (!this.ruCapExceededError) {\n this.ruCapExceededError = err;\n } else {\n // merge the buffered items\n if (err.fetchedResults) {\n this.ruCapExceededError.fetchedResults.push(...err.fetchedResults);\n }\n }\n } else {\n throw err;\n }\n }\n return;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts new file mode 100644 index 000000000..bfc9f2ba5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts @@ -0,0 +1,31 @@ +import { ClientContext } from "../ClientContext"; +import { Response, FeedOptions, QueryOperationOptions } from "../request"; +import { PartitionedQueryExecutionInfo } from "../request/ErrorResponse"; +import { ExecutionContext } from "./ExecutionContext"; +import { SqlQuerySpec } from "./SqlQuerySpec"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { RUConsumedManager } from "../common"; +/** @hidden */ +export declare class PipelinedQueryExecutionContext implements ExecutionContext { + private clientContext; + private collectionLink; + private query; + private options; + private partitionedQueryExecutionInfo; + private fetchBuffer; + private fetchMoreRespHeaders; + private endpoint; + private pageSize; + private vectorSearchBufferSize; + private static DEFAULT_PAGE_SIZE; + private static DEFAULT_VECTOR_SEARCH_BUFFER_SIZE; + private nonStreamingOrderBy; + constructor(clientContext: ClientContext, collectionLink: string, query: string | SqlQuerySpec, options: FeedOptions, partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo); + nextItem(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + hasMoreResults(): boolean; + fetchMore(diagnosticNode: DiagnosticNodeInternal, operationOptions?: QueryOperationOptions, ruConsumedManager?: RUConsumedManager): Promise>; + private _fetchMoreImplementation; + private _nonStreamingFetchMoreImplementation; + private calculateVectorSearchBufferSize; +} +//# sourceMappingURL=pipelinedQueryExecutionContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts.map new file mode 100644 index 000000000..185f54409 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"pipelinedQueryExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/queryExecutionContext/pipelinedQueryExecutionContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,6BAA6B,EAAa,MAAM,0BAA0B,CAAC;AAOpF,OAAO,EAAE,gBAAgB,EAAE,MAAM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/queryExecutionContext/pipelinedQueryExecutionContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js new file mode 100644 index 000000000..fd0bcf7c4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js @@ -0,0 +1,223 @@ +import { Constants } from "../common"; +import { RUCapPerOperationExceededErrorCode } from "../request/RUCapPerOperationExceededError"; +import { GroupByEndpointComponent } from "./EndpointComponent/GroupByEndpointComponent"; +import { GroupByValueEndpointComponent } from "./EndpointComponent/GroupByValueEndpointComponent"; +import { NonStreamingOrderByDistinctEndpointComponent } from "./EndpointComponent/NonStreamingOrderByDistinctEndpointComponent"; +import { NonStreamingOrderByEndpointComponent } from "./EndpointComponent/NonStreamingOrderByEndpointComponent"; +import { OffsetLimitEndpointComponent } from "./EndpointComponent/OffsetLimitEndpointComponent"; +import { OrderByEndpointComponent } from "./EndpointComponent/OrderByEndpointComponent"; +import { OrderedDistinctEndpointComponent } from "./EndpointComponent/OrderedDistinctEndpointComponent"; +import { UnorderedDistinctEndpointComponent } from "./EndpointComponent/UnorderedDistinctEndpointComponent"; +import { getInitialHeader, mergeHeaders } from "./headerUtils"; +import { OrderByQueryExecutionContext } from "./orderByQueryExecutionContext"; +import { ParallelQueryExecutionContext } from "./parallelQueryExecutionContext"; +/** @hidden */ +export class PipelinedQueryExecutionContext { + constructor(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo) { + this.clientContext = clientContext; + this.collectionLink = collectionLink; + this.query = query; + this.options = options; + this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo; + this.vectorSearchBufferSize = 0; + this.nonStreamingOrderBy = false; + this.endpoint = null; + this.pageSize = options["maxItemCount"]; + if (this.pageSize === undefined) { + this.pageSize = PipelinedQueryExecutionContext.DEFAULT_PAGE_SIZE; + } + // Pick between Nonstreaming and streaming endpoints + this.nonStreamingOrderBy = partitionedQueryExecutionInfo.queryInfo.hasNonStreamingOrderBy; + // Pick between parallel vs order by execution context + const sortOrders = partitionedQueryExecutionInfo.queryInfo.orderBy; + // TODO: Currently we don't get any field from backend to determine streaming queries + if (this.nonStreamingOrderBy) { + this.vectorSearchBufferSize = this.calculateVectorSearchBufferSize(partitionedQueryExecutionInfo.queryInfo, options); + const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; + const context = new ParallelQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo); + if (distinctType === "None") { + this.endpoint = new NonStreamingOrderByEndpointComponent(context, sortOrders, this.vectorSearchBufferSize, partitionedQueryExecutionInfo.queryInfo.offset); + } + else { + this.endpoint = new NonStreamingOrderByDistinctEndpointComponent(context, partitionedQueryExecutionInfo.queryInfo, this.vectorSearchBufferSize); + } + } + else { + if (Array.isArray(sortOrders) && sortOrders.length > 0) { + // Need to wrap orderby execution context in endpoint component, since the data is nested as a \ + // "payload" property. + this.endpoint = new OrderByEndpointComponent(new OrderByQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo)); + } + else { + this.endpoint = new ParallelQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo); + } + if (Object.keys(partitionedQueryExecutionInfo.queryInfo.groupByAliasToAggregateType).length > + 0 || + partitionedQueryExecutionInfo.queryInfo.aggregates.length > 0 || + partitionedQueryExecutionInfo.queryInfo.groupByExpressions.length > 0) { + if (partitionedQueryExecutionInfo.queryInfo.hasSelectValue) { + this.endpoint = new GroupByValueEndpointComponent(this.endpoint, partitionedQueryExecutionInfo.queryInfo); + } + else { + this.endpoint = new GroupByEndpointComponent(this.endpoint, partitionedQueryExecutionInfo.queryInfo); + } + } + // If top then add that to the pipeline. TOP N is effectively OFFSET 0 LIMIT N + const top = partitionedQueryExecutionInfo.queryInfo.top; + if (typeof top === "number") { + this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, 0, top); + } + // If offset+limit then add that to the pipeline + const limit = partitionedQueryExecutionInfo.queryInfo.limit; + const offset = partitionedQueryExecutionInfo.queryInfo.offset; + if (typeof limit === "number" && typeof offset === "number") { + this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, offset, limit); + } + // If distinct then add that to the pipeline + const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; + if (distinctType === "Ordered") { + this.endpoint = new OrderedDistinctEndpointComponent(this.endpoint); + } + if (distinctType === "Unordered") { + this.endpoint = new UnorderedDistinctEndpointComponent(this.endpoint); + } + } + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + return this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + } + // Removed callback here beacuse it wouldn't have ever worked... + hasMoreResults() { + return this.endpoint.hasMoreResults(); + } + async fetchMore(diagnosticNode, operationOptions, ruConsumedManager) { + // if the wrapped endpoint has different implementation for fetchMore use that + // otherwise use the default implementation + if (typeof this.endpoint.fetchMore === "function") { + return this.endpoint.fetchMore(diagnosticNode, operationOptions, ruConsumedManager); + } + else { + this.fetchBuffer = []; + this.fetchMoreRespHeaders = getInitialHeader(); + return this.nonStreamingOrderBy + ? this._nonStreamingFetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager) + : this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager); + } + } + async _fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { result: item, headers } = await this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + mergeHeaders(this.fetchMoreRespHeaders, headers); + if (item === undefined) { + // no more results + if (this.fetchBuffer.length === 0) { + return { + result: undefined, + headers: this.fetchMoreRespHeaders, + }; + } + else { + // Just give what we have + const temp = this.fetchBuffer; + this.fetchBuffer = []; + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + } + else { + this.fetchBuffer.push(item); + if (this.fetchBuffer.length >= this.pageSize) { + // fetched enough results + const temp = this.fetchBuffer.slice(0, this.pageSize); + this.fetchBuffer = this.fetchBuffer.splice(this.pageSize); + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + else { + // recursively fetch more + // TODO: is recursion a good idea? + return this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager); + } + } + } + catch (err) { + mergeHeaders(this.fetchMoreRespHeaders, err.headers); + err.headers = this.fetchMoreRespHeaders; + if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) { + err.fetchedResults.push(...this.fetchBuffer); + } + if (err) { + throw err; + } + } + } + async _nonStreamingFetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { result: item, headers } = await this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + mergeHeaders(this.fetchMoreRespHeaders, headers); + if (item === undefined) { + // no more results + if (this.fetchBuffer.length === 0) { + return { + result: undefined, + headers: this.fetchMoreRespHeaders, + }; + } + else { + // Just give what we have + const temp = this.fetchBuffer; + this.fetchBuffer = []; + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + } + else { + const ruConsumed = await ruConsumedManager.getRUConsumed(); + const maxRUAllowed = operationOptions && operationOptions.ruCapPerOperation + ? operationOptions.ruCapPerOperation + : Constants.NonStreamingQueryDefaultRUThreshold; + // append the result + if (typeof item !== "object") { + this.fetchBuffer.push(item); + } + else if (Object.keys(item).length !== 0) { + this.fetchBuffer.push(item); + } + if (this.fetchBuffer.length >= this.pageSize) { + // fetched enough results + const temp = this.fetchBuffer.slice(0, this.pageSize); + this.fetchBuffer = this.fetchBuffer.splice(this.pageSize); + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + else if (ruConsumed * 2 < maxRUAllowed) { + // recursively fetch more only if we have more than 50% RUs left. + return this._nonStreamingFetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager); + } + else { + return { result: [], headers: this.fetchMoreRespHeaders }; + } + } + } + catch (err) { + mergeHeaders(this.fetchMoreRespHeaders, err.headers); + err.headers = this.fetchMoreRespHeaders; + if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) { + err.fetchedResults.push(...this.fetchBuffer); + } + if (err) { + throw err; + } + } + } + calculateVectorSearchBufferSize(queryInfo, options) { + if (queryInfo.top === 0 || queryInfo.limit === 0) + return 0; + return queryInfo.top + ? queryInfo.top + : queryInfo.limit + ? queryInfo.offset + queryInfo.limit + : options["vectorSearchBufferSize"] && options["vectorSearchBufferSize"] > 0 + ? options["vectorSearchBufferSize"] + : PipelinedQueryExecutionContext.DEFAULT_VECTOR_SEARCH_BUFFER_SIZE; + } +} +PipelinedQueryExecutionContext.DEFAULT_PAGE_SIZE = 10; +PipelinedQueryExecutionContext.DEFAULT_VECTOR_SEARCH_BUFFER_SIZE = 2000; +//# sourceMappingURL=pipelinedQueryExecutionContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js.map new file mode 100644 index 000000000..791474dbd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryExecutionContext/pipelinedQueryExecutionContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pipelinedQueryExecutionContext.js","sourceRoot":"","sources":["../../../src/queryExecutionContext/pipelinedQueryExecutionContext.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,4BAA4B,EAAE,MAAM,kDAAkD,CAAC;AAChG,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,gCAAgC,EAAE,MAAM,sDAAsD,CAAC;AACxG,OAAO,EAAE,kCAAkC,EAAE,MAAM,wDAAwD,CAAC;AAC5G,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AAExF,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AA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SAAS,CAAC,KAAK,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QAC3D,OAAO,SAAS,CAAC,GAAG;YAClB,CAAC,CAAC,SAAS,CAAC,GAAG;YACf,CAAC,CAAC,SAAS,CAAC,KAAK;gBACf,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,KAAK;gBACpC,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC,IAAI,OAAO,CAAC,wBAAwB,CAAC,GAAG,CAAC;oBAC1E,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAAC;oBACnC,CAAC,CAAC,8BAA8B,CAAC,iCAAiC,CAAC;IAC3E,CAAC;;AAlRc,gDAAiB,GAAG,EAAE,AAAL,CAAM;AACvB,gEAAiC,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { Response, FeedOptions, QueryOperationOptions } from \"../request\";\nimport { PartitionedQueryExecutionInfo, QueryInfo } from \"../request/ErrorResponse\";\nimport { CosmosHeaders } from \"./CosmosHeaders\";\nimport { OffsetLimitEndpointComponent } from \"./EndpointComponent/OffsetLimitEndpointComponent\";\nimport { OrderByEndpointComponent } from \"./EndpointComponent/OrderByEndpointComponent\";\nimport { OrderedDistinctEndpointComponent } from \"./EndpointComponent/OrderedDistinctEndpointComponent\";\nimport { UnorderedDistinctEndpointComponent } from \"./EndpointComponent/UnorderedDistinctEndpointComponent\";\nimport { GroupByEndpointComponent } from \"./EndpointComponent/GroupByEndpointComponent\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { getInitialHeader, mergeHeaders } from \"./headerUtils\";\nimport { OrderByQueryExecutionContext } from \"./orderByQueryExecutionContext\";\nimport { ParallelQueryExecutionContext } from \"./parallelQueryExecutionContext\";\nimport { GroupByValueEndpointComponent } from \"./EndpointComponent/GroupByValueEndpointComponent\";\nimport { SqlQuerySpec } from \"./SqlQuerySpec\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../request/RUCapPerOperationExceededError\";\nimport { Constants, RUConsumedManager } from \"../common\";\nimport { NonStreamingOrderByDistinctEndpointComponent } from \"./EndpointComponent/NonStreamingOrderByDistinctEndpointComponent\";\nimport { NonStreamingOrderByEndpointComponent } from \"./EndpointComponent/NonStreamingOrderByEndpointComponent\";\n\n/** @hidden */\nexport class PipelinedQueryExecutionContext implements ExecutionContext {\n private fetchBuffer: any[];\n private fetchMoreRespHeaders: CosmosHeaders;\n private endpoint: ExecutionContext;\n private pageSize: number;\n private vectorSearchBufferSize: number = 0;\n private static DEFAULT_PAGE_SIZE = 10;\n private static DEFAULT_VECTOR_SEARCH_BUFFER_SIZE = 2000;\n private nonStreamingOrderBy = false;\n\n constructor(\n private clientContext: ClientContext,\n private collectionLink: string,\n private query: string | SqlQuerySpec,\n private options: FeedOptions,\n private partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo,\n ) {\n this.endpoint = null;\n this.pageSize = options[\"maxItemCount\"];\n if (this.pageSize === undefined) {\n this.pageSize = PipelinedQueryExecutionContext.DEFAULT_PAGE_SIZE;\n }\n // Pick between Nonstreaming and streaming endpoints\n this.nonStreamingOrderBy = partitionedQueryExecutionInfo.queryInfo.hasNonStreamingOrderBy;\n\n // Pick between parallel vs order by execution context\n const sortOrders = partitionedQueryExecutionInfo.queryInfo.orderBy;\n // TODO: Currently we don't get any field from backend to determine streaming queries\n if (this.nonStreamingOrderBy) {\n this.vectorSearchBufferSize = this.calculateVectorSearchBufferSize(\n partitionedQueryExecutionInfo.queryInfo,\n options,\n );\n\n const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType;\n const context: ExecutionContext = new ParallelQueryExecutionContext(\n this.clientContext,\n this.collectionLink,\n this.query,\n this.options,\n this.partitionedQueryExecutionInfo,\n );\n\n if (distinctType === \"None\") {\n this.endpoint = new NonStreamingOrderByEndpointComponent(\n context,\n sortOrders,\n this.vectorSearchBufferSize,\n partitionedQueryExecutionInfo.queryInfo.offset,\n );\n } else {\n this.endpoint = new NonStreamingOrderByDistinctEndpointComponent(\n context,\n partitionedQueryExecutionInfo.queryInfo,\n this.vectorSearchBufferSize,\n );\n }\n } else {\n if (Array.isArray(sortOrders) && sortOrders.length > 0) {\n // Need to wrap orderby execution context in endpoint component, since the data is nested as a \\\n // \"payload\" property.\n this.endpoint = new OrderByEndpointComponent(\n new OrderByQueryExecutionContext(\n this.clientContext,\n this.collectionLink,\n this.query,\n this.options,\n this.partitionedQueryExecutionInfo,\n ),\n );\n } else {\n this.endpoint = new ParallelQueryExecutionContext(\n this.clientContext,\n this.collectionLink,\n this.query,\n this.options,\n this.partitionedQueryExecutionInfo,\n );\n }\n if (\n Object.keys(partitionedQueryExecutionInfo.queryInfo.groupByAliasToAggregateType).length >\n 0 ||\n partitionedQueryExecutionInfo.queryInfo.aggregates.length > 0 ||\n partitionedQueryExecutionInfo.queryInfo.groupByExpressions.length > 0\n ) {\n if (partitionedQueryExecutionInfo.queryInfo.hasSelectValue) {\n this.endpoint = new GroupByValueEndpointComponent(\n this.endpoint,\n partitionedQueryExecutionInfo.queryInfo,\n );\n } else {\n this.endpoint = new GroupByEndpointComponent(\n this.endpoint,\n partitionedQueryExecutionInfo.queryInfo,\n );\n }\n }\n // If top then add that to the pipeline. TOP N is effectively OFFSET 0 LIMIT N\n const top = partitionedQueryExecutionInfo.queryInfo.top;\n if (typeof top === \"number\") {\n this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, 0, top);\n }\n\n // If offset+limit then add that to the pipeline\n const limit = partitionedQueryExecutionInfo.queryInfo.limit;\n const offset = partitionedQueryExecutionInfo.queryInfo.offset;\n if (typeof limit === \"number\" && typeof offset === \"number\") {\n this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, offset, limit);\n }\n\n // If distinct then add that to the pipeline\n const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType;\n if (distinctType === \"Ordered\") {\n this.endpoint = new OrderedDistinctEndpointComponent(this.endpoint);\n }\n if (distinctType === \"Unordered\") {\n this.endpoint = new UnorderedDistinctEndpointComponent(this.endpoint);\n }\n }\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n return this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager);\n }\n\n // Removed callback here beacuse it wouldn't have ever worked...\n public hasMoreResults(): boolean {\n return this.endpoint.hasMoreResults();\n }\n\n public async fetchMore(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // if the wrapped endpoint has different implementation for fetchMore use that\n // otherwise use the default implementation\n if (typeof this.endpoint.fetchMore === \"function\") {\n return this.endpoint.fetchMore(diagnosticNode, operationOptions, ruConsumedManager);\n } else {\n this.fetchBuffer = [];\n this.fetchMoreRespHeaders = getInitialHeader();\n return this.nonStreamingOrderBy\n ? this._nonStreamingFetchMoreImplementation(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )\n : this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager);\n }\n }\n\n private async _fetchMoreImplementation(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { result: item, headers } = await this.endpoint.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n mergeHeaders(this.fetchMoreRespHeaders, headers);\n if (item === undefined) {\n // no more results\n if (this.fetchBuffer.length === 0) {\n return {\n result: undefined,\n headers: this.fetchMoreRespHeaders,\n };\n } else {\n // Just give what we have\n const temp = this.fetchBuffer;\n this.fetchBuffer = [];\n return { result: temp, headers: this.fetchMoreRespHeaders };\n }\n } else {\n this.fetchBuffer.push(item);\n if (this.fetchBuffer.length >= this.pageSize) {\n // fetched enough results\n const temp = this.fetchBuffer.slice(0, this.pageSize);\n this.fetchBuffer = this.fetchBuffer.splice(this.pageSize);\n return { result: temp, headers: this.fetchMoreRespHeaders };\n } else {\n // recursively fetch more\n // TODO: is recursion a good idea?\n return this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager);\n }\n }\n } catch (err: any) {\n mergeHeaders(this.fetchMoreRespHeaders, err.headers);\n err.headers = this.fetchMoreRespHeaders;\n if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) {\n err.fetchedResults.push(...this.fetchBuffer);\n }\n if (err) {\n throw err;\n }\n }\n }\n\n private async _nonStreamingFetchMoreImplementation(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { result: item, headers } = await this.endpoint.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n mergeHeaders(this.fetchMoreRespHeaders, headers);\n if (item === undefined) {\n // no more results\n if (this.fetchBuffer.length === 0) {\n return {\n result: undefined,\n headers: this.fetchMoreRespHeaders,\n };\n } else {\n // Just give what we have\n const temp = this.fetchBuffer;\n this.fetchBuffer = [];\n return { result: temp, headers: this.fetchMoreRespHeaders };\n }\n } else {\n const ruConsumed = await ruConsumedManager.getRUConsumed();\n const maxRUAllowed =\n operationOptions && operationOptions.ruCapPerOperation\n ? operationOptions.ruCapPerOperation\n : Constants.NonStreamingQueryDefaultRUThreshold;\n // append the result\n if (typeof item !== \"object\") {\n this.fetchBuffer.push(item);\n } else if (Object.keys(item).length !== 0) {\n this.fetchBuffer.push(item);\n }\n if (this.fetchBuffer.length >= this.pageSize) {\n // fetched enough results\n const temp = this.fetchBuffer.slice(0, this.pageSize);\n this.fetchBuffer = this.fetchBuffer.splice(this.pageSize);\n return { result: temp, headers: this.fetchMoreRespHeaders };\n } else if (ruConsumed * 2 < maxRUAllowed) {\n // recursively fetch more only if we have more than 50% RUs left.\n return this._nonStreamingFetchMoreImplementation(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n } else {\n return { result: [], headers: this.fetchMoreRespHeaders };\n }\n }\n } catch (err: any) {\n mergeHeaders(this.fetchMoreRespHeaders, err.headers);\n err.headers = this.fetchMoreRespHeaders;\n if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) {\n err.fetchedResults.push(...this.fetchBuffer);\n }\n if (err) {\n throw err;\n }\n }\n }\n\n private calculateVectorSearchBufferSize(queryInfo: QueryInfo, options: FeedOptions): number {\n if (queryInfo.top === 0 || queryInfo.limit === 0) return 0;\n return queryInfo.top\n ? queryInfo.top\n : queryInfo.limit\n ? queryInfo.offset + queryInfo.limit\n : options[\"vectorSearchBufferSize\"] && options[\"vectorSearchBufferSize\"] > 0\n ? options[\"vectorSearchBufferSize\"]\n : PipelinedQueryExecutionContext.DEFAULT_VECTOR_SEARCH_BUFFER_SIZE;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts new file mode 100644 index 000000000..82aa81fd6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts @@ -0,0 +1,89 @@ +/// +import { ClientContext } from "./ClientContext"; +import { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; +import { ResourceType } from "./common"; +import { FetchFunctionCallback, SqlQuerySpec } from "./queryExecutionContext"; +import { FeedOptions } from "./request/FeedOptions"; +import { FeedResponse } from "./request/FeedResponse"; +import { QueryOperationOptions } from "./request/OperationOptions"; +/** + * Represents a QueryIterator Object, an implementation of feed or query response that enables + * traversal and iterating over the response + * in the Azure Cosmos DB database service. + */ +export declare class QueryIterator { + private clientContext; + private query; + private options; + private fetchFunctions; + private resourceLink?; + private resourceType?; + private fetchAllTempResources; + private fetchAllLastResHeaders; + private queryExecutionContext; + private queryPlanPromise; + private isInitialized; + private nonStreamingOrderBy; + /** + * @hidden + */ + constructor(clientContext: ClientContext, query: SqlQuerySpec | string, options: FeedOptions, fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[], resourceLink?: string, resourceType?: ResourceType); + /** + * Gets an async iterator that will yield results until completion. + * + * NOTE: AsyncIterators are a very new feature and you might need to + * use polyfils/etc. in order to use them in your code. + * + * If you're using TypeScript, you can use the following polyfill as long + * as you target ES6 or higher and are running on Node 6 or higher. + * + * ```typescript + * if (!Symbol || !Symbol.asyncIterator) { + * (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator"); + * } + * ``` + * + * @example Iterate over all databases + * ```typescript + * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) { + * console.log(`Got ${db} from AsyncIterator`); + * } + * ``` + */ + getAsyncIterator(options?: QueryOperationOptions): AsyncIterable>; + /** + * Determine if there are still remaining resources to process based on the value of the continuation token or the + * elements remaining on the current batch in the QueryIterator. + * @returns true if there is other elements to process in the QueryIterator. + */ + hasMoreResults(): boolean; + /** + * Fetch all pages for the query and return a single FeedResponse. + */ + fetchAll(options?: QueryOperationOptions): Promise>; + /** + * @hidden + */ + fetchAllInternal(diagnosticNode: DiagnosticNodeInternal, options?: QueryOperationOptions): Promise>; + /** + * Retrieve the next batch from the feed. + * + * This may or may not fetch more pages from the backend depending on your settings + * and the type of query. Aggregate queries will generally fetch all backend pages + * before returning the first batch of responses. + */ + fetchNext(options?: QueryOperationOptions): Promise>; + /** + * Reset the QueryIterator to the beginning and clear all the resources inside it + */ + reset(): void; + private toArrayImplementation; + private createPipelinedExecutionContext; + private fetchQueryPlan; + private needsQueryPlan; + private initPromise; + private init; + private _init; + private handleSplitError; +} +//# sourceMappingURL=queryIterator.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts.map new file mode 100644 index 000000000..4b0ef0653 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.d.ts.map @@ -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AAc,IAAI,OAAO;IAIhC;;OAEG;IAEU,QAAQ,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAMhF;;OAEG;IACU,gBAAgB,CAC3B,cAAc,EAAE,sBAAsB,EACtC,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAW3B;;;;;;OAMG;IACU,SAAS,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IA+CjF;;OAEG;IACI,KAAK,IAAI,IAAI;YAUN,qBAAqB;YAmErB,+BAA+B;YAuB/B,cAAc;IAgB5B,OAAO,CAAC,cAAc;IAYtB,OAAO,CAAC,WAAW,CAAgB;YACrB,IAAI;YASJ,KAAK;IAOnB,OAAO,CAAC,gBAAgB;CAYzB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js new file mode 100644 index 000000000..313d14c46 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js @@ -0,0 +1,278 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { __asyncGenerator, __await } from "tslib"; +import { getPathFromLink, ResourceType, RUConsumedManager, StatusCodes } from "./common"; +import { MetadataLookUpType } from "./CosmosDiagnostics"; +import { DiagnosticNodeInternal, DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal"; +import { DefaultQueryExecutionContext, getInitialHeader, mergeHeaders, PipelinedQueryExecutionContext, } from "./queryExecutionContext"; +import { FeedResponse } from "./request/FeedResponse"; +import { RUCapPerOperationExceededErrorCode } from "./request/RUCapPerOperationExceededError"; +import { getEmptyCosmosDiagnostics, withDiagnostics, withMetadataDiagnostics, } from "./utils/diagnostics"; +/** + * Represents a QueryIterator Object, an implementation of feed or query response that enables + * traversal and iterating over the response + * in the Azure Cosmos DB database service. + */ +export class QueryIterator { + /** + * @hidden + */ + constructor(clientContext, query, options, fetchFunctions, resourceLink, resourceType) { + this.clientContext = clientContext; + this.query = query; + this.options = options; + this.fetchFunctions = fetchFunctions; + this.resourceLink = resourceLink; + this.resourceType = resourceType; + this.nonStreamingOrderBy = false; + this.query = query; + this.fetchFunctions = fetchFunctions; + this.options = options || {}; + this.resourceLink = resourceLink; + this.fetchAllLastResHeaders = getInitialHeader(); + this.reset(); + this.isInitialized = false; + } + /** + * Gets an async iterator that will yield results until completion. + * + * NOTE: AsyncIterators are a very new feature and you might need to + * use polyfils/etc. in order to use them in your code. + * + * If you're using TypeScript, you can use the following polyfill as long + * as you target ES6 or higher and are running on Node 6 or higher. + * + * ```typescript + * if (!Symbol || !Symbol.asyncIterator) { + * (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator"); + * } + * ``` + * + * @example Iterate over all databases + * ```typescript + * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) { + * console.log(`Got ${db} from AsyncIterator`); + * } + * ``` + */ + getAsyncIterator(options) { + return __asyncGenerator(this, arguments, function* getAsyncIterator_1() { + this.reset(); + let diagnosticNode = new DiagnosticNodeInternal(this.clientContext.diagnosticLevel, DiagnosticNodeType.CLIENT_REQUEST_NODE, null); + this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode); + let ruConsumedManager; + if (options && options.ruCapPerOperation) { + ruConsumedManager = new RUConsumedManager(); + } + while (this.queryExecutionContext.hasMoreResults()) { + let response; + try { + response = yield __await(this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager)); + } + catch (error) { + if (this.needsQueryPlan(error)) { + yield __await(this.createPipelinedExecutionContext()); + try { + response = yield __await(this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager)); + } + catch (queryError) { + this.handleSplitError(queryError); + } + } + else { + throw error; + } + } + const feedResponse = new FeedResponse(response.result, response.headers, this.queryExecutionContext.hasMoreResults(), diagnosticNode.toDiagnostic(this.clientContext.getClientConfig())); + diagnosticNode = new DiagnosticNodeInternal(this.clientContext.diagnosticLevel, DiagnosticNodeType.CLIENT_REQUEST_NODE, null); + if (response.result !== undefined) { + yield yield __await(feedResponse); + } + } + }); + } + /** + * Determine if there are still remaining resources to process based on the value of the continuation token or the + * elements remaining on the current batch in the QueryIterator. + * @returns true if there is other elements to process in the QueryIterator. + */ + hasMoreResults() { + return this.queryExecutionContext.hasMoreResults(); + } + /** + * Fetch all pages for the query and return a single FeedResponse. + */ + async fetchAll(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.fetchAllInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async fetchAllInternal(diagnosticNode, options) { + this.reset(); + let response; + try { + response = await this.toArrayImplementation(diagnosticNode, options); + } + catch (error) { + this.handleSplitError(error); + } + return response; + } + /** + * Retrieve the next batch from the feed. + * + * This may or may not fetch more pages from the backend depending on your settings + * and the type of query. Aggregate queries will generally fetch all backend pages + * before returning the first batch of responses. + */ + async fetchNext(options) { + return withDiagnostics(async (diagnosticNode) => { + // Enabling RU metrics for all the fetchNext operations + const ruConsumedManager = new RUConsumedManager(); + this.queryPlanPromise = withMetadataDiagnostics(async (metadataNode) => { + return this.fetchQueryPlan(metadataNode); + }, diagnosticNode, MetadataLookUpType.QueryPlanLookUp); + if (!this.isInitialized) { + await this.init(); + } + let response; + try { + response = await this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager); + } + catch (error) { + if (this.needsQueryPlan(error)) { + await this.createPipelinedExecutionContext(); + try { + response = await this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager); + } + catch (queryError) { + this.handleSplitError(queryError); + } + } + else { + throw error; + } + } + return new FeedResponse(response.result, response.headers, this.queryExecutionContext.hasMoreResults(), getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Reset the QueryIterator to the beginning and clear all the resources inside it + */ + reset() { + this.queryPlanPromise = undefined; + this.fetchAllLastResHeaders = getInitialHeader(); + this.fetchAllTempResources = []; + this.queryExecutionContext = new DefaultQueryExecutionContext(this.options, this.fetchFunctions); + } + async toArrayImplementation(diagnosticNode, options) { + let ruConsumedManager; + if (options && options.ruCapPerOperation) { + ruConsumedManager = new RUConsumedManager(); + } + this.queryPlanPromise = withMetadataDiagnostics(async (metadataNode) => { + return this.fetchQueryPlan(metadataNode); + }, diagnosticNode, MetadataLookUpType.QueryPlanLookUp); + // this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode); + if (!this.isInitialized) { + await this.init(); + } + while (this.queryExecutionContext.hasMoreResults()) { + let response; + try { + response = await this.queryExecutionContext.nextItem(diagnosticNode, options, ruConsumedManager); + } + catch (error) { + if (this.needsQueryPlan(error)) { + await this.createPipelinedExecutionContext(); + response = await this.queryExecutionContext.nextItem(diagnosticNode, options, ruConsumedManager); + } + else if (error.code === RUCapPerOperationExceededErrorCode && error.fetchedResults) { + error.fetchedResults.forEach((item) => { + this.fetchAllTempResources.push(item); + }); + error.fetchedResults = this.fetchAllTempResources; + throw error; + } + else { + throw error; + } + } + const { result, headers } = response; + // concatenate the results and fetch more + mergeHeaders(this.fetchAllLastResHeaders, headers); + if (result !== undefined) { + if (this.nonStreamingOrderBy && + typeof result === "object" && + Object.keys(result).length === 0) { + // ignore empty results from NonStreamingOrderBy Endpoint components. + } + else + this.fetchAllTempResources.push(result); + } + } + return new FeedResponse(this.fetchAllTempResources, this.fetchAllLastResHeaders, this.queryExecutionContext.hasMoreResults(), getEmptyCosmosDiagnostics()); + } + async createPipelinedExecutionContext() { + const queryPlanResponse = await this.queryPlanPromise; + // We always coerce queryPlanPromise to resolved. So if it errored, we need to manually inspect the resolved value + if (queryPlanResponse instanceof Error) { + throw queryPlanResponse; + } + const queryPlan = queryPlanResponse.result; + const queryInfo = queryPlan.queryInfo; + this.nonStreamingOrderBy = queryInfo.hasNonStreamingOrderBy ? true : false; + if (queryInfo.aggregates.length > 0 && queryInfo.hasSelectValue === false) { + throw new Error("Aggregate queries must use the VALUE keyword"); + } + this.queryExecutionContext = new PipelinedQueryExecutionContext(this.clientContext, this.resourceLink, this.query, this.options, queryPlan); + } + async fetchQueryPlan(diagnosticNode) { + if (!this.queryPlanPromise && this.resourceType === ResourceType.item) { + return this.clientContext + .getQueryPlan(getPathFromLink(this.resourceLink) + "/docs", ResourceType.item, this.resourceLink, this.query, this.options, diagnosticNode) + .catch((error) => error); // Without this catch, node reports an unhandled rejection. So we stash the promise as resolved even if it errored. + } + return this.queryPlanPromise; + } + needsQueryPlan(error) { + var _a; + let needsQueryPlanValue = false; + if (((_a = error.body) === null || _a === void 0 ? void 0 : _a.additionalErrorInfo) || + error.message.includes("Cross partition query only supports")) { + needsQueryPlanValue = + error.code === StatusCodes.BadRequest && this.resourceType === ResourceType.item; + } + return needsQueryPlanValue; + } + async init() { + if (this.isInitialized === true) { + return; + } + if (this.initPromise === undefined) { + this.initPromise = this._init(); + } + return this.initPromise; + } + async _init() { + if (this.options.forceQueryPlan === true && this.resourceType === ResourceType.item) { + await this.createPipelinedExecutionContext(); + } + this.isInitialized = true; + } + handleSplitError(err) { + if (err.code === 410) { + const error = new Error("Encountered partition split and could not recover. This request is retryable"); + error.code = 503; + error.originalError = err; + throw error; + } + else { + throw err; + } + } +} +//# sourceMappingURL=queryIterator.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js.map new file mode 100644 index 000000000..990495c18 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryIterator.js.map @@ -0,0 +1 @@ +{"version":3,"file":"queryIterator.js","sourceRoot":"","sources":["../../src/queryIterator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAKlC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MA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,GAAQ;QAC/B,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE;YACpB,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,8EAA8E,CACxE,CAAC;YACT,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC;YACjB,KAAK,CAAC,aAAa,GAAG,GAAG,CAAC;YAC1B,MAAM,KAAK,CAAC;SACb;aAAM;YACL,MAAM,GAAG,CAAC;SACX;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// \n\nimport { ClientContext } from \"./ClientContext\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { getPathFromLink, ResourceType, StatusCodes, RUConsumedManager } from \"./common\";\nimport {\n CosmosHeaders,\n DefaultQueryExecutionContext,\n ExecutionContext,\n FetchFunctionCallback,\n getInitialHeader,\n mergeHeaders,\n PipelinedQueryExecutionContext,\n SqlQuerySpec,\n} from \"./queryExecutionContext\";\nimport { Response } from \"./request\";\nimport { ErrorResponse, PartitionedQueryExecutionInfo } from \"./request/ErrorResponse\";\nimport { FeedOptions } from \"./request/FeedOptions\";\nimport { FeedResponse } from \"./request/FeedResponse\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n withMetadataDiagnostics,\n} from \"./utils/diagnostics\";\nimport { MetadataLookUpType } from \"./CosmosDiagnostics\";\nimport { QueryOperationOptions } from \"./request/OperationOptions\";\nimport { RUCapPerOperationExceededErrorCode } from \"./request/RUCapPerOperationExceededError\";\n\n/**\n * Represents a QueryIterator Object, an implementation of feed or query response that enables\n * traversal and iterating over the response\n * in the Azure Cosmos DB database service.\n */\nexport class QueryIterator {\n private fetchAllTempResources: T[]; // TODO\n private fetchAllLastResHeaders: CosmosHeaders;\n private queryExecutionContext: ExecutionContext;\n private queryPlanPromise: Promise>;\n private isInitialized: boolean;\n private nonStreamingOrderBy: boolean = false;\n /**\n * @hidden\n */\n constructor(\n private clientContext: ClientContext,\n private query: SqlQuerySpec | string,\n private options: FeedOptions,\n private fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[],\n private resourceLink?: string,\n private resourceType?: ResourceType,\n ) {\n this.query = query;\n this.fetchFunctions = fetchFunctions;\n this.options = options || {};\n this.resourceLink = resourceLink;\n this.fetchAllLastResHeaders = getInitialHeader();\n this.reset();\n this.isInitialized = false;\n }\n\n /**\n * Gets an async iterator that will yield results until completion.\n *\n * NOTE: AsyncIterators are a very new feature and you might need to\n * use polyfils/etc. in order to use them in your code.\n *\n * If you're using TypeScript, you can use the following polyfill as long\n * as you target ES6 or higher and are running on Node 6 or higher.\n *\n * ```typescript\n * if (!Symbol || !Symbol.asyncIterator) {\n * (Symbol as any).asyncIterator = Symbol.for(\"Symbol.asyncIterator\");\n * }\n * ```\n *\n * @example Iterate over all databases\n * ```typescript\n * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) {\n * console.log(`Got ${db} from AsyncIterator`);\n * }\n * ```\n */\n public async *getAsyncIterator(options?: QueryOperationOptions): AsyncIterable> {\n this.reset();\n let diagnosticNode = new DiagnosticNodeInternal(\n this.clientContext.diagnosticLevel,\n DiagnosticNodeType.CLIENT_REQUEST_NODE,\n null,\n );\n this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode);\n let ruConsumedManager: RUConsumedManager | undefined;\n if (options && options.ruCapPerOperation) {\n ruConsumedManager = new RUConsumedManager();\n }\n while (this.queryExecutionContext.hasMoreResults()) {\n let response: Response;\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (error: any) {\n if (this.needsQueryPlan(error)) {\n await this.createPipelinedExecutionContext();\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (queryError: any) {\n this.handleSplitError(queryError);\n }\n } else {\n throw error;\n }\n }\n\n const feedResponse = new FeedResponse(\n response.result,\n response.headers,\n this.queryExecutionContext.hasMoreResults(),\n diagnosticNode.toDiagnostic(this.clientContext.getClientConfig()),\n );\n diagnosticNode = new DiagnosticNodeInternal(\n this.clientContext.diagnosticLevel,\n DiagnosticNodeType.CLIENT_REQUEST_NODE,\n null,\n );\n if (response.result !== undefined) {\n yield feedResponse;\n }\n }\n }\n\n /**\n * Determine if there are still remaining resources to process based on the value of the continuation token or the\n * elements remaining on the current batch in the QueryIterator.\n * @returns true if there is other elements to process in the QueryIterator.\n */\n public hasMoreResults(): boolean {\n return this.queryExecutionContext.hasMoreResults();\n }\n\n /**\n * Fetch all pages for the query and return a single FeedResponse.\n */\n\n public async fetchAll(options?: QueryOperationOptions): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.fetchAllInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async fetchAllInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: QueryOperationOptions,\n ): Promise> {\n this.reset();\n let response: FeedResponse;\n try {\n response = await this.toArrayImplementation(diagnosticNode, options);\n } catch (error: any) {\n this.handleSplitError(error);\n }\n return response;\n }\n\n /**\n * Retrieve the next batch from the feed.\n *\n * This may or may not fetch more pages from the backend depending on your settings\n * and the type of query. Aggregate queries will generally fetch all backend pages\n * before returning the first batch of responses.\n */\n public async fetchNext(options?: QueryOperationOptions): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n // Enabling RU metrics for all the fetchNext operations\n const ruConsumedManager: RUConsumedManager = new RUConsumedManager();\n this.queryPlanPromise = withMetadataDiagnostics(\n async (metadataNode: DiagnosticNodeInternal) => {\n return this.fetchQueryPlan(metadataNode);\n },\n diagnosticNode,\n MetadataLookUpType.QueryPlanLookUp,\n );\n if (!this.isInitialized) {\n await this.init();\n }\n\n let response: Response;\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (error: any) {\n if (this.needsQueryPlan(error)) {\n await this.createPipelinedExecutionContext();\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (queryError: any) {\n this.handleSplitError(queryError);\n }\n } else {\n throw error;\n }\n }\n return new FeedResponse(\n response.result,\n response.headers,\n this.queryExecutionContext.hasMoreResults(),\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Reset the QueryIterator to the beginning and clear all the resources inside it\n */\n public reset(): void {\n this.queryPlanPromise = undefined;\n this.fetchAllLastResHeaders = getInitialHeader();\n this.fetchAllTempResources = [];\n this.queryExecutionContext = new DefaultQueryExecutionContext(\n this.options,\n this.fetchFunctions,\n );\n }\n\n private async toArrayImplementation(\n diagnosticNode: DiagnosticNodeInternal,\n options?: QueryOperationOptions,\n ): Promise> {\n let ruConsumedManager: RUConsumedManager | undefined;\n if (options && options.ruCapPerOperation) {\n ruConsumedManager = new RUConsumedManager();\n }\n this.queryPlanPromise = withMetadataDiagnostics(\n async (metadataNode: DiagnosticNodeInternal) => {\n return this.fetchQueryPlan(metadataNode);\n },\n diagnosticNode,\n MetadataLookUpType.QueryPlanLookUp,\n );\n\n // this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode);\n if (!this.isInitialized) {\n await this.init();\n }\n while (this.queryExecutionContext.hasMoreResults()) {\n let response: Response;\n try {\n response = await this.queryExecutionContext.nextItem(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (error: any) {\n if (this.needsQueryPlan(error)) {\n await this.createPipelinedExecutionContext();\n response = await this.queryExecutionContext.nextItem(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } else if (error.code === RUCapPerOperationExceededErrorCode && error.fetchedResults) {\n error.fetchedResults.forEach((item: any) => {\n this.fetchAllTempResources.push(item);\n });\n error.fetchedResults = this.fetchAllTempResources;\n throw error;\n } else {\n throw error;\n }\n }\n const { result, headers } = response;\n // concatenate the results and fetch more\n mergeHeaders(this.fetchAllLastResHeaders, headers);\n if (result !== undefined) {\n if (\n this.nonStreamingOrderBy &&\n typeof result === \"object\" &&\n Object.keys(result).length === 0\n ) {\n // ignore empty results from NonStreamingOrderBy Endpoint components.\n } else this.fetchAllTempResources.push(result);\n }\n }\n return new FeedResponse(\n this.fetchAllTempResources,\n this.fetchAllLastResHeaders,\n this.queryExecutionContext.hasMoreResults(),\n getEmptyCosmosDiagnostics(),\n );\n }\n\n private async createPipelinedExecutionContext(): Promise {\n const queryPlanResponse = await this.queryPlanPromise;\n\n // We always coerce queryPlanPromise to resolved. So if it errored, we need to manually inspect the resolved value\n if (queryPlanResponse instanceof Error) {\n throw queryPlanResponse;\n }\n\n const queryPlan = queryPlanResponse.result;\n const queryInfo = queryPlan.queryInfo;\n this.nonStreamingOrderBy = queryInfo.hasNonStreamingOrderBy ? true : false;\n if (queryInfo.aggregates.length > 0 && queryInfo.hasSelectValue === false) {\n throw new Error(\"Aggregate queries must use the VALUE keyword\");\n }\n this.queryExecutionContext = new PipelinedQueryExecutionContext(\n this.clientContext,\n this.resourceLink,\n this.query,\n this.options,\n queryPlan,\n );\n }\n\n private async fetchQueryPlan(diagnosticNode: DiagnosticNodeInternal): Promise {\n if (!this.queryPlanPromise && this.resourceType === ResourceType.item) {\n return this.clientContext\n .getQueryPlan(\n getPathFromLink(this.resourceLink) + \"/docs\",\n ResourceType.item,\n this.resourceLink,\n this.query,\n this.options,\n diagnosticNode,\n )\n .catch((error: any) => error); // Without this catch, node reports an unhandled rejection. So we stash the promise as resolved even if it errored.\n }\n return this.queryPlanPromise;\n }\n\n private needsQueryPlan(error: ErrorResponse): error is ErrorResponse {\n let needsQueryPlanValue = false;\n if (\n error.body?.additionalErrorInfo ||\n error.message.includes(\"Cross partition query only supports\")\n ) {\n needsQueryPlanValue =\n error.code === StatusCodes.BadRequest && this.resourceType === ResourceType.item;\n }\n return needsQueryPlanValue;\n }\n\n private initPromise: Promise;\n private async init(): Promise {\n if (this.isInitialized === true) {\n return;\n }\n if (this.initPromise === undefined) {\n this.initPromise = this._init();\n }\n return this.initPromise;\n }\n private async _init(): Promise {\n if (this.options.forceQueryPlan === true && this.resourceType === ResourceType.item) {\n await this.createPipelinedExecutionContext();\n }\n this.isInitialized = true;\n }\n\n private handleSplitError(err: any): void {\n if (err.code === 410) {\n const error = new Error(\n \"Encountered partition split and could not recover. This request is retryable\",\n ) as any;\n error.code = 503;\n error.originalError = err;\n throw error;\n } else {\n throw err;\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts new file mode 100644 index 000000000..c7c5c9d5e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts @@ -0,0 +1,11 @@ +export declare class ClientSideMetrics { + readonly requestCharge: number; + constructor(requestCharge: number); + /** + * Adds one or more ClientSideMetrics to a copy of this instance and returns the result. + */ + add(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics; + static readonly zero: ClientSideMetrics; + static createFromArray(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics; +} +//# sourceMappingURL=clientSideMetrics.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts.map new file mode 100644 index 000000000..6fae010fb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"clientSideMetrics.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/clientSideMetrics.ts"],"names":[],"mappings":"AAGA,qBAAa,iBAAiB;aACA,aAAa,EAAE,MAAM;gBAArB,aAAa,EAAE,MAAM;IAEjD;;OAEG;IACI,GAAG,CAAC,GAAG,sBAAsB,EAAE,iBAAiB,EAAE,GAAG,iBAAiB;IAa7E,gBAAuB,IAAI,oBAA4B;WAEzC,eAAe,CAAC,GAAG,sBAAsB,EAAE,iBAAiB,EAAE,GAAG,iBAAiB;CAOjG"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js new file mode 100644 index 000000000..97c0bf805 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export class ClientSideMetrics { + constructor(requestCharge) { + this.requestCharge = requestCharge; + } + /** + * Adds one or more ClientSideMetrics to a copy of this instance and returns the result. + */ + add(...clientSideMetricsArray) { + let requestCharge = this.requestCharge; + for (const clientSideMetrics of clientSideMetricsArray) { + if (clientSideMetrics == null) { + throw new Error("clientSideMetrics has null or undefined item(s)"); + } + requestCharge += clientSideMetrics.requestCharge; + } + return new ClientSideMetrics(requestCharge); + } + static createFromArray(...clientSideMetricsArray) { + if (clientSideMetricsArray == null) { + throw new Error("clientSideMetricsArray is null or undefined item(s)"); + } + return this.zero.add(...clientSideMetricsArray); + } +} +ClientSideMetrics.zero = new ClientSideMetrics(0); +//# sourceMappingURL=clientSideMetrics.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js.map new file mode 100644 index 000000000..1c40cd00f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/clientSideMetrics.js.map @@ -0,0 +1 @@ +{"version":3,"file":"clientSideMetrics.js","sourceRoot":"","sources":["../../../src/queryMetrics/clientSideMetrics.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,OAAO,iBAAiB;IAC5B,YAA4B,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;IAAG,CAAC;IAErD;;OAEG;IACI,GAAG,CAAC,GAAG,sBAA2C;QACvD,IAAI,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACvC,KAAK,MAAM,iBAAiB,IAAI,sBAAsB,EAAE;YACtD,IAAI,iBAAiB,IAAI,IAAI,EAAE;gBAC7B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;aACpE;YAED,aAAa,IAAI,iBAAiB,CAAC,aAAa,CAAC;SAClD;QAED,OAAO,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;IAIM,MAAM,CAAC,eAAe,CAAC,GAAG,sBAA2C;QAC1E,IAAI,sBAAsB,IAAI,IAAI,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;SACxE;QAED,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,CAAC;IAClD,CAAC;;AARsB,sBAAI,GAAG,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport class ClientSideMetrics {\n constructor(public readonly requestCharge: number) {}\n\n /**\n * Adds one or more ClientSideMetrics to a copy of this instance and returns the result.\n */\n public add(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics {\n let requestCharge = this.requestCharge;\n for (const clientSideMetrics of clientSideMetricsArray) {\n if (clientSideMetrics == null) {\n throw new Error(\"clientSideMetrics has null or undefined item(s)\");\n }\n\n requestCharge += clientSideMetrics.requestCharge;\n }\n\n return new ClientSideMetrics(requestCharge);\n }\n\n public static readonly zero = new ClientSideMetrics(0);\n\n public static createFromArray(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics {\n if (clientSideMetricsArray == null) {\n throw new Error(\"clientSideMetricsArray is null or undefined item(s)\");\n }\n\n return this.zero.add(...clientSideMetricsArray);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts new file mode 100644 index 000000000..8181ce40d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts @@ -0,0 +1,7 @@ +export { ClientSideMetrics } from "./clientSideMetrics"; +export { QueryMetrics } from "./queryMetrics"; +export { default as QueryMetricsConstants } from "./queryMetricsConstants"; +export { QueryPreparationTimes } from "./queryPreparationTime"; +export { RuntimeExecutionTimes } from "./runtimeExecutionTimes"; +export { TimeSpan } from "./timeSpan"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts.map new file mode 100644 index 000000000..b1d4fb4ee --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js new file mode 100644 index 000000000..da0ec5c41 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { ClientSideMetrics } from "./clientSideMetrics"; +export { QueryMetrics } from "./queryMetrics"; +export { default as QueryMetricsConstants } from "./queryMetricsConstants"; +export { QueryPreparationTimes } from "./queryPreparationTime"; +export { RuntimeExecutionTimes } from "./runtimeExecutionTimes"; +export { TimeSpan } from "./timeSpan"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js.map new file mode 100644 index 000000000..aa84acf0f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/queryMetrics/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport { ClientSideMetrics } from \"./clientSideMetrics\";\nexport { QueryMetrics } from \"./queryMetrics\";\nexport { default as QueryMetricsConstants } from \"./queryMetricsConstants\";\nexport { QueryPreparationTimes } from \"./queryPreparationTime\";\nexport { RuntimeExecutionTimes } from \"./runtimeExecutionTimes\";\nexport { TimeSpan } from \"./timeSpan\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts new file mode 100644 index 000000000..b2fd5046f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts @@ -0,0 +1,44 @@ +import { ClientSideMetrics } from "./clientSideMetrics"; +import { QueryPreparationTimes } from "./queryPreparationTime"; +import { RuntimeExecutionTimes } from "./runtimeExecutionTimes"; +import { TimeSpan } from "./timeSpan"; +export declare class QueryMetrics { + readonly retrievedDocumentCount: number; + readonly retrievedDocumentSize: number; + readonly outputDocumentCount: number; + readonly outputDocumentSize: number; + readonly indexHitDocumentCount: number; + readonly totalQueryExecutionTime: TimeSpan; + readonly queryPreparationTimes: QueryPreparationTimes; + readonly indexLookupTime: TimeSpan; + readonly documentLoadTime: TimeSpan; + readonly vmExecutionTime: TimeSpan; + readonly runtimeExecutionTimes: RuntimeExecutionTimes; + readonly documentWriteTime: TimeSpan; + readonly clientSideMetrics: ClientSideMetrics; + constructor(retrievedDocumentCount: number, retrievedDocumentSize: number, outputDocumentCount: number, outputDocumentSize: number, indexHitDocumentCount: number, totalQueryExecutionTime: TimeSpan, queryPreparationTimes: QueryPreparationTimes, indexLookupTime: TimeSpan, documentLoadTime: TimeSpan, vmExecutionTime: TimeSpan, runtimeExecutionTimes: RuntimeExecutionTimes, documentWriteTime: TimeSpan, clientSideMetrics: ClientSideMetrics); + /** + * Gets the IndexHitRatio + * @hidden + */ + get indexHitRatio(): number; + /** + * returns a new QueryMetrics instance that is the addition of this and the arguments. + */ + add(queryMetricsArray: QueryMetrics[]): QueryMetrics; + /** + * Output the QueryMetrics as a delimited string. + * @hidden + */ + toDelimitedString(): string; + static readonly zero: QueryMetrics; + /** + * Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics. + */ + static createFromArray(queryMetricsArray: QueryMetrics[]): QueryMetrics; + /** + * Returns a new instance of the QueryMetrics class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString: string, clientSideMetrics?: ClientSideMetrics): QueryMetrics; +} +//# sourceMappingURL=queryMetrics.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts.map new file mode 100644 index 000000000..5768e829a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"queryMetrics.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/queryMetrics.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,YAAY;aAEL,sBAAsB,EAAE,MAAM;aAC9B,qBAAqB,EAAE,MAAM;aAC7B,mBAAmB,EAAE,MAAM;aAC3B,kBAAkB,EAAE,MAAM;aAC1B,qBAAqB,EAAE,MAAM;aAC7B,uBAAuB,EAAE,QAAQ;aACjC,qBAAqB,EAAE,qBAAqB;aAC5C,eAAe,EAAE,QAAQ;aACzB,gBAAgB,EAAE,QAAQ;aAC1B,eAAe,EAAE,QAAQ;aACzB,qBAAqB,EAAE,qBAAqB;aAC5C,iBAAiB,EAAE,QAAQ;aAC3B,iBAAiB,EAAE,iBAAiB;gBAZpC,sBAAsB,EAAE,MAAM,EAC9B,qBAAqB,EAAE,MAAM,EAC7B,mBAAmB,EAAE,MAAM,EAC3B,kBAAkB,EAAE,MAAM,EAC1B,qBAAqB,EAAE,MAAM,EAC7B,uBAAuB,EAAE,QAAQ,EACjC,qBAAqB,EAAE,qBAAqB,EAC5C,eAAe,EAAE,QAAQ,EACzB,gBAAgB,EAAE,QAAQ,EAC1B,eAAe,EAAE,QAAQ,EACzB,qBAAqB,EAAE,qBAAqB,EAC5C,iBAAiB,EAAE,QAAQ,EAC3B,iBAAiB,EAAE,iBAAiB;IAGtD;;;OAGG;IACH,IAAW,aAAa,IAAI,MAAM,CAIjC;IAED;;OAEG;IACI,GAAG,CAAC,iBAAiB,EAAE,YAAY,EAAE,GAAG,YAAY;IAoD3D;;;OAGG;IACI,iBAAiB,IAAI,MAAM;IAgDlC,gBAAuB,IAAI,eAczB;IAEF;;OAEG;WACW,eAAe,CAAC,iBAAiB,EAAE,YAAY,EAAE,GAAG,YAAY;IAQ9E;;OAEG;WACW,yBAAyB,CACrC,eAAe,EAAE,MAAM,EACvB,iBAAiB,CAAC,EAAE,iBAAiB,GACpC,YAAY;CA6BhB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js new file mode 100644 index 000000000..6b8571708 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { ClientSideMetrics } from "./clientSideMetrics"; +import QueryMetricsConstants from "./queryMetricsConstants"; +import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils"; +import { QueryPreparationTimes } from "./queryPreparationTime"; +import { RuntimeExecutionTimes } from "./runtimeExecutionTimes"; +import { TimeSpan } from "./timeSpan"; +export class QueryMetrics { + constructor(retrievedDocumentCount, retrievedDocumentSize, outputDocumentCount, outputDocumentSize, indexHitDocumentCount, totalQueryExecutionTime, queryPreparationTimes, indexLookupTime, documentLoadTime, vmExecutionTime, runtimeExecutionTimes, documentWriteTime, clientSideMetrics) { + this.retrievedDocumentCount = retrievedDocumentCount; + this.retrievedDocumentSize = retrievedDocumentSize; + this.outputDocumentCount = outputDocumentCount; + this.outputDocumentSize = outputDocumentSize; + this.indexHitDocumentCount = indexHitDocumentCount; + this.totalQueryExecutionTime = totalQueryExecutionTime; + this.queryPreparationTimes = queryPreparationTimes; + this.indexLookupTime = indexLookupTime; + this.documentLoadTime = documentLoadTime; + this.vmExecutionTime = vmExecutionTime; + this.runtimeExecutionTimes = runtimeExecutionTimes; + this.documentWriteTime = documentWriteTime; + this.clientSideMetrics = clientSideMetrics; + } + /** + * Gets the IndexHitRatio + * @hidden + */ + get indexHitRatio() { + return this.retrievedDocumentCount === 0 + ? 1 + : this.indexHitDocumentCount / this.retrievedDocumentCount; + } + /** + * returns a new QueryMetrics instance that is the addition of this and the arguments. + */ + add(queryMetricsArray) { + let retrievedDocumentCount = 0; + let retrievedDocumentSize = 0; + let outputDocumentCount = 0; + let outputDocumentSize = 0; + let indexHitDocumentCount = 0; + let totalQueryExecutionTime = TimeSpan.zero; + const queryPreparationTimesArray = []; + let indexLookupTime = TimeSpan.zero; + let documentLoadTime = TimeSpan.zero; + let vmExecutionTime = TimeSpan.zero; + const runtimeExecutionTimesArray = []; + let documentWriteTime = TimeSpan.zero; + const clientSideQueryMetricsArray = []; + queryMetricsArray.push(this); + for (const queryMetrics of queryMetricsArray) { + if (queryMetrics) { + retrievedDocumentCount += queryMetrics.retrievedDocumentCount; + retrievedDocumentSize += queryMetrics.retrievedDocumentSize; + outputDocumentCount += queryMetrics.outputDocumentCount; + outputDocumentSize += queryMetrics.outputDocumentSize; + indexHitDocumentCount += queryMetrics.indexHitDocumentCount; + totalQueryExecutionTime = totalQueryExecutionTime.add(queryMetrics.totalQueryExecutionTime); + queryPreparationTimesArray.push(queryMetrics.queryPreparationTimes); + indexLookupTime = indexLookupTime.add(queryMetrics.indexLookupTime); + documentLoadTime = documentLoadTime.add(queryMetrics.documentLoadTime); + vmExecutionTime = vmExecutionTime.add(queryMetrics.vmExecutionTime); + runtimeExecutionTimesArray.push(queryMetrics.runtimeExecutionTimes); + documentWriteTime = documentWriteTime.add(queryMetrics.documentWriteTime); + clientSideQueryMetricsArray.push(queryMetrics.clientSideMetrics); + } + } + return new QueryMetrics(retrievedDocumentCount, retrievedDocumentSize, outputDocumentCount, outputDocumentSize, indexHitDocumentCount, totalQueryExecutionTime, QueryPreparationTimes.createFromArray(queryPreparationTimesArray), indexLookupTime, documentLoadTime, vmExecutionTime, RuntimeExecutionTimes.createFromArray(runtimeExecutionTimesArray), documentWriteTime, ClientSideMetrics.createFromArray(...clientSideQueryMetricsArray)); + } + /** + * Output the QueryMetrics as a delimited string. + * @hidden + */ + toDelimitedString() { + return (QueryMetricsConstants.RetrievedDocumentCount + + "=" + + this.retrievedDocumentCount + + ";" + + QueryMetricsConstants.RetrievedDocumentSize + + "=" + + this.retrievedDocumentSize + + ";" + + QueryMetricsConstants.OutputDocumentCount + + "=" + + this.outputDocumentCount + + ";" + + QueryMetricsConstants.OutputDocumentSize + + "=" + + this.outputDocumentSize + + ";" + + QueryMetricsConstants.IndexHitRatio + + "=" + + this.indexHitRatio + + ";" + + QueryMetricsConstants.TotalQueryExecutionTimeInMs + + "=" + + this.totalQueryExecutionTime.totalMilliseconds() + + ";" + + this.queryPreparationTimes.toDelimitedString() + + ";" + + QueryMetricsConstants.IndexLookupTimeInMs + + "=" + + this.indexLookupTime.totalMilliseconds() + + ";" + + QueryMetricsConstants.DocumentLoadTimeInMs + + "=" + + this.documentLoadTime.totalMilliseconds() + + ";" + + QueryMetricsConstants.VMExecutionTimeInMs + + "=" + + this.vmExecutionTime.totalMilliseconds() + + ";" + + this.runtimeExecutionTimes.toDelimitedString() + + ";" + + QueryMetricsConstants.DocumentWriteTimeInMs + + "=" + + this.documentWriteTime.totalMilliseconds()); + } + /** + * Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics. + */ + static createFromArray(queryMetricsArray) { + if (!queryMetricsArray) { + throw new Error("queryMetricsArray is null or undefined item(s)"); + } + return QueryMetrics.zero.add(queryMetricsArray); + } + /** + * Returns a new instance of the QueryMetrics class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString, clientSideMetrics) { + const metrics = parseDelimitedString(delimitedString); + const indexHitRatio = metrics[QueryMetricsConstants.IndexHitRatio] || 0; + const retrievedDocumentCount = metrics[QueryMetricsConstants.RetrievedDocumentCount] || 0; + const indexHitCount = indexHitRatio * retrievedDocumentCount; + const outputDocumentCount = metrics[QueryMetricsConstants.OutputDocumentCount] || 0; + const outputDocumentSize = metrics[QueryMetricsConstants.OutputDocumentSize] || 0; + const retrievedDocumentSize = metrics[QueryMetricsConstants.RetrievedDocumentSize] || 0; + const totalQueryExecutionTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.TotalQueryExecutionTimeInMs); + return new QueryMetrics(retrievedDocumentCount, retrievedDocumentSize, outputDocumentCount, outputDocumentSize, indexHitCount, totalQueryExecutionTime, QueryPreparationTimes.createFromDelimitedString(delimitedString), timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentLoadTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs), RuntimeExecutionTimes.createFromDelimitedString(delimitedString), timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentWriteTimeInMs), clientSideMetrics || ClientSideMetrics.zero); + } +} +QueryMetrics.zero = new QueryMetrics(0, 0, 0, 0, 0, TimeSpan.zero, QueryPreparationTimes.zero, TimeSpan.zero, TimeSpan.zero, TimeSpan.zero, RuntimeExecutionTimes.zero, TimeSpan.zero, ClientSideMetrics.zero); +//# sourceMappingURL=queryMetrics.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js.map new file mode 100644 index 000000000..5a6cfd7f0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetrics.js.map @@ -0,0 +1 @@ +{"version":3,"file":"queryMetrics.js","sourceRoot":"","sources":["../../../src/queryMetrics/queryMetrics.ts"],"names":[],"mappings":"AAAA,uCAA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qBAAqB,GAAG,OAAO,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;QACxF,MAAM,uBAAuB,GAAG,mBAAmB,CACjD,OAAO,EACP,qBAAqB,CAAC,2BAA2B,CAClD,CAAC;QACF,OAAO,IAAI,YAAY,CACrB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,qBAAqB,CAAC,yBAAyB,CAAC,eAAe,CAAC,EAChE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,EACvE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,oBAAoB,CAAC,EACxE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,EACvE,qBAAqB,CAAC,yBAAyB,CAAC,eAAe,CAAC,EAChE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,qBAAqB,CAAC,EACzE,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,CAC5C,CAAC;IACJ,CAAC;;AA7DsB,iBAAI,GAAG,IAAI,YAAY,CAC5C,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,CAAC,EACD,QAAQ,CAAC,IAAI,EACb,qBAAqB,CAAC,IAAI,EAC1B,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,EACb,qBAAqB,CAAC,IAAI,EAC1B,QAAQ,CAAC,IAAI,EACb,iBAAiB,CAAC,IAAI,CACvB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientSideMetrics } from \"./clientSideMetrics\";\nimport QueryMetricsConstants from \"./queryMetricsConstants\";\nimport { parseDelimitedString, timeSpanFromMetrics } from \"./queryMetricsUtils\";\nimport { QueryPreparationTimes } from \"./queryPreparationTime\";\nimport { RuntimeExecutionTimes } from \"./runtimeExecutionTimes\";\nimport { TimeSpan } from \"./timeSpan\";\n\nexport class QueryMetrics {\n constructor(\n public readonly retrievedDocumentCount: number,\n public readonly retrievedDocumentSize: number,\n public readonly outputDocumentCount: number,\n public readonly outputDocumentSize: number,\n public readonly indexHitDocumentCount: number,\n public readonly totalQueryExecutionTime: TimeSpan,\n public readonly queryPreparationTimes: QueryPreparationTimes,\n public readonly indexLookupTime: TimeSpan,\n public readonly documentLoadTime: TimeSpan,\n public readonly vmExecutionTime: TimeSpan,\n public readonly runtimeExecutionTimes: RuntimeExecutionTimes,\n public readonly documentWriteTime: TimeSpan,\n public readonly clientSideMetrics: ClientSideMetrics,\n ) {}\n\n /**\n * Gets the IndexHitRatio\n * @hidden\n */\n public get indexHitRatio(): number {\n return this.retrievedDocumentCount === 0\n ? 1\n : this.indexHitDocumentCount / this.retrievedDocumentCount;\n }\n\n /**\n * returns a new QueryMetrics instance that is the addition of this and the arguments.\n */\n public add(queryMetricsArray: QueryMetrics[]): QueryMetrics {\n let retrievedDocumentCount = 0;\n let retrievedDocumentSize = 0;\n let outputDocumentCount = 0;\n let outputDocumentSize = 0;\n let indexHitDocumentCount = 0;\n let totalQueryExecutionTime = TimeSpan.zero;\n const queryPreparationTimesArray = [];\n let indexLookupTime = TimeSpan.zero;\n let documentLoadTime = TimeSpan.zero;\n let vmExecutionTime = TimeSpan.zero;\n const runtimeExecutionTimesArray = [];\n let documentWriteTime = TimeSpan.zero;\n const clientSideQueryMetricsArray = [];\n\n queryMetricsArray.push(this);\n\n for (const queryMetrics of queryMetricsArray) {\n if (queryMetrics) {\n retrievedDocumentCount += queryMetrics.retrievedDocumentCount;\n retrievedDocumentSize += queryMetrics.retrievedDocumentSize;\n outputDocumentCount += queryMetrics.outputDocumentCount;\n outputDocumentSize += queryMetrics.outputDocumentSize;\n indexHitDocumentCount += queryMetrics.indexHitDocumentCount;\n totalQueryExecutionTime = totalQueryExecutionTime.add(queryMetrics.totalQueryExecutionTime);\n queryPreparationTimesArray.push(queryMetrics.queryPreparationTimes);\n indexLookupTime = indexLookupTime.add(queryMetrics.indexLookupTime);\n documentLoadTime = documentLoadTime.add(queryMetrics.documentLoadTime);\n vmExecutionTime = vmExecutionTime.add(queryMetrics.vmExecutionTime);\n runtimeExecutionTimesArray.push(queryMetrics.runtimeExecutionTimes);\n documentWriteTime = documentWriteTime.add(queryMetrics.documentWriteTime);\n clientSideQueryMetricsArray.push(queryMetrics.clientSideMetrics);\n }\n }\n\n return new QueryMetrics(\n retrievedDocumentCount,\n retrievedDocumentSize,\n outputDocumentCount,\n outputDocumentSize,\n indexHitDocumentCount,\n totalQueryExecutionTime,\n QueryPreparationTimes.createFromArray(queryPreparationTimesArray),\n indexLookupTime,\n documentLoadTime,\n vmExecutionTime,\n RuntimeExecutionTimes.createFromArray(runtimeExecutionTimesArray),\n documentWriteTime,\n ClientSideMetrics.createFromArray(...clientSideQueryMetricsArray),\n );\n }\n\n /**\n * Output the QueryMetrics as a delimited string.\n * @hidden\n */\n public toDelimitedString(): string {\n return (\n QueryMetricsConstants.RetrievedDocumentCount +\n \"=\" +\n this.retrievedDocumentCount +\n \";\" +\n QueryMetricsConstants.RetrievedDocumentSize +\n \"=\" +\n this.retrievedDocumentSize +\n \";\" +\n QueryMetricsConstants.OutputDocumentCount +\n \"=\" +\n this.outputDocumentCount +\n \";\" +\n QueryMetricsConstants.OutputDocumentSize +\n \"=\" +\n this.outputDocumentSize +\n \";\" +\n QueryMetricsConstants.IndexHitRatio +\n \"=\" +\n this.indexHitRatio +\n \";\" +\n QueryMetricsConstants.TotalQueryExecutionTimeInMs +\n \"=\" +\n this.totalQueryExecutionTime.totalMilliseconds() +\n \";\" +\n this.queryPreparationTimes.toDelimitedString() +\n \";\" +\n QueryMetricsConstants.IndexLookupTimeInMs +\n \"=\" +\n this.indexLookupTime.totalMilliseconds() +\n \";\" +\n QueryMetricsConstants.DocumentLoadTimeInMs +\n \"=\" +\n this.documentLoadTime.totalMilliseconds() +\n \";\" +\n QueryMetricsConstants.VMExecutionTimeInMs +\n \"=\" +\n this.vmExecutionTime.totalMilliseconds() +\n \";\" +\n this.runtimeExecutionTimes.toDelimitedString() +\n \";\" +\n QueryMetricsConstants.DocumentWriteTimeInMs +\n \"=\" +\n this.documentWriteTime.totalMilliseconds()\n );\n }\n\n public static readonly zero = new QueryMetrics(\n 0,\n 0,\n 0,\n 0,\n 0,\n TimeSpan.zero,\n QueryPreparationTimes.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n RuntimeExecutionTimes.zero,\n TimeSpan.zero,\n ClientSideMetrics.zero,\n );\n\n /**\n * Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics.\n */\n public static createFromArray(queryMetricsArray: QueryMetrics[]): QueryMetrics {\n if (!queryMetricsArray) {\n throw new Error(\"queryMetricsArray is null or undefined item(s)\");\n }\n\n return QueryMetrics.zero.add(queryMetricsArray);\n }\n\n /**\n * Returns a new instance of the QueryMetrics class this is deserialized from a delimited string.\n */\n public static createFromDelimitedString(\n delimitedString: string,\n clientSideMetrics?: ClientSideMetrics,\n ): QueryMetrics {\n const metrics = parseDelimitedString(delimitedString);\n\n const indexHitRatio = metrics[QueryMetricsConstants.IndexHitRatio] || 0;\n const retrievedDocumentCount = metrics[QueryMetricsConstants.RetrievedDocumentCount] || 0;\n const indexHitCount = indexHitRatio * retrievedDocumentCount;\n const outputDocumentCount = metrics[QueryMetricsConstants.OutputDocumentCount] || 0;\n const outputDocumentSize = metrics[QueryMetricsConstants.OutputDocumentSize] || 0;\n const retrievedDocumentSize = metrics[QueryMetricsConstants.RetrievedDocumentSize] || 0;\n const totalQueryExecutionTime = timeSpanFromMetrics(\n metrics,\n QueryMetricsConstants.TotalQueryExecutionTimeInMs,\n );\n return new QueryMetrics(\n retrievedDocumentCount,\n retrievedDocumentSize,\n outputDocumentCount,\n outputDocumentSize,\n indexHitCount,\n totalQueryExecutionTime,\n QueryPreparationTimes.createFromDelimitedString(delimitedString),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentLoadTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs),\n RuntimeExecutionTimes.createFromDelimitedString(delimitedString),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentWriteTimeInMs),\n clientSideMetrics || ClientSideMetrics.zero,\n );\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts new file mode 100644 index 000000000..5dacb1772 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts @@ -0,0 +1,46 @@ +declare const _default: { + RetrievedDocumentCount: string; + RetrievedDocumentSize: string; + OutputDocumentCount: string; + OutputDocumentSize: string; + IndexHitRatio: string; + IndexHitDocumentCount: string; + TotalQueryExecutionTimeInMs: string; + QueryCompileTimeInMs: string; + LogicalPlanBuildTimeInMs: string; + PhysicalPlanBuildTimeInMs: string; + QueryOptimizationTimeInMs: string; + IndexLookupTimeInMs: string; + DocumentLoadTimeInMs: string; + VMExecutionTimeInMs: string; + DocumentWriteTimeInMs: string; + QueryEngineTimes: string; + SystemFunctionExecuteTimeInMs: string; + UserDefinedFunctionExecutionTimeInMs: string; + RetrievedDocumentCountText: string; + RetrievedDocumentSizeText: string; + OutputDocumentCountText: string; + OutputDocumentSizeText: string; + IndexUtilizationText: string; + TotalQueryExecutionTimeText: string; + QueryPreparationTimesText: string; + QueryCompileTimeText: string; + LogicalPlanBuildTimeText: string; + PhysicalPlanBuildTimeText: string; + QueryOptimizationTimeText: string; + QueryEngineTimesText: string; + IndexLookupTimeText: string; + DocumentLoadTimeText: string; + WriteOutputTimeText: string; + RuntimeExecutionTimesText: string; + TotalExecutionTimeText: string; + SystemFunctionExecuteTimeText: string; + UserDefinedFunctionExecutionTimeText: string; + ClientSideQueryMetricsText: string; + RetriesText: string; + RequestChargeText: string; + FetchExecutionRangesText: string; + SchedulingMetricsText: string; +}; +export default _default; +//# sourceMappingURL=queryMetricsConstants.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts.map new file mode 100644 index 000000000..ac033a511 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"queryMetricsConstants.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/queryMetricsConstants.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,wBA4DE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js new file mode 100644 index 000000000..2fc3c0595 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export default { + // QueryMetrics + RetrievedDocumentCount: "retrievedDocumentCount", + RetrievedDocumentSize: "retrievedDocumentSize", + OutputDocumentCount: "outputDocumentCount", + OutputDocumentSize: "outputDocumentSize", + IndexHitRatio: "indexUtilizationRatio", + IndexHitDocumentCount: "indexHitDocumentCount", + TotalQueryExecutionTimeInMs: "totalExecutionTimeInMs", + // QueryPreparationTimes + QueryCompileTimeInMs: "queryCompileTimeInMs", + LogicalPlanBuildTimeInMs: "queryLogicalPlanBuildTimeInMs", + PhysicalPlanBuildTimeInMs: "queryPhysicalPlanBuildTimeInMs", + QueryOptimizationTimeInMs: "queryOptimizationTimeInMs", + // QueryTimes + IndexLookupTimeInMs: "indexLookupTimeInMs", + DocumentLoadTimeInMs: "documentLoadTimeInMs", + VMExecutionTimeInMs: "VMExecutionTimeInMs", + DocumentWriteTimeInMs: "writeOutputTimeInMs", + // RuntimeExecutionTimes + QueryEngineTimes: "queryEngineTimes", + SystemFunctionExecuteTimeInMs: "systemFunctionExecuteTimeInMs", + UserDefinedFunctionExecutionTimeInMs: "userFunctionExecuteTimeInMs", + // QueryMetrics Text + RetrievedDocumentCountText: "Retrieved Document Count", + RetrievedDocumentSizeText: "Retrieved Document Size", + OutputDocumentCountText: "Output Document Count", + OutputDocumentSizeText: "Output Document Size", + IndexUtilizationText: "Index Utilization", + TotalQueryExecutionTimeText: "Total Query Execution Time", + // QueryPreparationTimes Text + QueryPreparationTimesText: "Query Preparation Times", + QueryCompileTimeText: "Query Compilation Time", + LogicalPlanBuildTimeText: "Logical Plan Build Time", + PhysicalPlanBuildTimeText: "Physical Plan Build Time", + QueryOptimizationTimeText: "Query Optimization Time", + // QueryTimes Text + QueryEngineTimesText: "Query Engine Times", + IndexLookupTimeText: "Index Lookup Time", + DocumentLoadTimeText: "Document Load Time", + WriteOutputTimeText: "Document Write Time", + // RuntimeExecutionTimes Text + RuntimeExecutionTimesText: "Runtime Execution Times", + TotalExecutionTimeText: "Query Engine Execution Time", + SystemFunctionExecuteTimeText: "System Function Execution Time", + UserDefinedFunctionExecutionTimeText: "User-defined Function Execution Time", + // ClientSideQueryMetrics Text + ClientSideQueryMetricsText: "Client Side Metrics", + RetriesText: "Retry Count", + RequestChargeText: "Request Charge", + FetchExecutionRangesText: "Partition Execution Timeline", + SchedulingMetricsText: "Scheduling Metrics", +}; +//# sourceMappingURL=queryMetricsConstants.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js.map new file mode 100644 index 000000000..25a587521 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsConstants.js.map @@ -0,0 +1 @@ +{"version":3,"file":"queryMetricsConstants.js","sourceRoot":"","sources":["../../../src/queryMetrics/queryMetricsConstants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,eAAe;IACb,eAAe;IACf,sBAAsB,EAAE,wBAAwB;IAChD,qBAAqB,EAAE,uBAAuB;IAC9C,mBAAmB,EAAE,qBAAqB;IAC1C,kBAAkB,EAAE,oBAAoB;IACxC,aAAa,EAAE,uBAAuB;IACtC,qBAAqB,EAAE,uBAAuB;IAC9C,2BAA2B,EAAE,wBAAwB;IAErD,wBAAwB;IACxB,oBAAoB,EAAE,sBAAsB;IAC5C,wBAAwB,EAAE,+BAA+B;IACzD,yBAAyB,EAAE,gCAAgC;IAC3D,yBAAyB,EAAE,2BAA2B;IAEtD,aAAa;IACb,mBAAmB,EAAE,qBAAqB;IAC1C,oBAAoB,EAAE,sBAAsB;IAC5C,mBAAmB,EAAE,qBAAqB;IAC1C,qBAAqB,EAAE,qBAAqB;IAE5C,wBAAwB;IACxB,gBAAgB,EAAE,kBAAkB;IACpC,6BAA6B,EAAE,+BAA+B;IAC9D,oCAAoC,EAAE,6BAA6B;IAEnE,oBAAoB;IACpB,0BAA0B,EAAE,0BAA0B;IACtD,yBAAyB,EAAE,yBAAyB;IACpD,uBAAuB,EAAE,uBAAuB;IAChD,sBAAsB,EAAE,sBAAsB;IAC9C,oBAAoB,EAAE,mBAAmB;IACzC,2BAA2B,EAAE,4BAA4B;IAEzD,6BAA6B;IAC7B,yBAAyB,EAAE,yBAAyB;IACpD,oBAAoB,EAAE,wBAAwB;IAC9C,wBAAwB,EAAE,yBAAyB;IACnD,yBAAyB,EAAE,0BAA0B;IACrD,yBAAyB,EAAE,yBAAyB;IAEpD,kBAAkB;IAClB,oBAAoB,EAAE,oBAAoB;IAC1C,mBAAmB,EAAE,mBAAmB;IACxC,oBAAoB,EAAE,oBAAoB;IAC1C,mBAAmB,EAAE,qBAAqB;IAE1C,6BAA6B;IAC7B,yBAAyB,EAAE,yBAAyB;IACpD,sBAAsB,EAAE,6BAA6B;IACrD,6BAA6B,EAAE,gCAAgC;IAC/D,oCAAoC,EAAE,sCAAsC;IAE5E,8BAA8B;IAC9B,0BAA0B,EAAE,qBAAqB;IACjD,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,gBAAgB;IACnC,wBAAwB,EAAE,8BAA8B;IACxD,qBAAqB,EAAE,oBAAoB;CAC5C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport default {\n // QueryMetrics\n RetrievedDocumentCount: \"retrievedDocumentCount\",\n RetrievedDocumentSize: \"retrievedDocumentSize\",\n OutputDocumentCount: \"outputDocumentCount\",\n OutputDocumentSize: \"outputDocumentSize\",\n IndexHitRatio: \"indexUtilizationRatio\",\n IndexHitDocumentCount: \"indexHitDocumentCount\",\n TotalQueryExecutionTimeInMs: \"totalExecutionTimeInMs\",\n\n // QueryPreparationTimes\n QueryCompileTimeInMs: \"queryCompileTimeInMs\",\n LogicalPlanBuildTimeInMs: \"queryLogicalPlanBuildTimeInMs\",\n PhysicalPlanBuildTimeInMs: \"queryPhysicalPlanBuildTimeInMs\",\n QueryOptimizationTimeInMs: \"queryOptimizationTimeInMs\",\n\n // QueryTimes\n IndexLookupTimeInMs: \"indexLookupTimeInMs\",\n DocumentLoadTimeInMs: \"documentLoadTimeInMs\",\n VMExecutionTimeInMs: \"VMExecutionTimeInMs\",\n DocumentWriteTimeInMs: \"writeOutputTimeInMs\",\n\n // RuntimeExecutionTimes\n QueryEngineTimes: \"queryEngineTimes\",\n SystemFunctionExecuteTimeInMs: \"systemFunctionExecuteTimeInMs\",\n UserDefinedFunctionExecutionTimeInMs: \"userFunctionExecuteTimeInMs\",\n\n // QueryMetrics Text\n RetrievedDocumentCountText: \"Retrieved Document Count\",\n RetrievedDocumentSizeText: \"Retrieved Document Size\",\n OutputDocumentCountText: \"Output Document Count\",\n OutputDocumentSizeText: \"Output Document Size\",\n IndexUtilizationText: \"Index Utilization\",\n TotalQueryExecutionTimeText: \"Total Query Execution Time\",\n\n // QueryPreparationTimes Text\n QueryPreparationTimesText: \"Query Preparation Times\",\n QueryCompileTimeText: \"Query Compilation Time\",\n LogicalPlanBuildTimeText: \"Logical Plan Build Time\",\n PhysicalPlanBuildTimeText: \"Physical Plan Build Time\",\n QueryOptimizationTimeText: \"Query Optimization Time\",\n\n // QueryTimes Text\n QueryEngineTimesText: \"Query Engine Times\",\n IndexLookupTimeText: \"Index Lookup Time\",\n DocumentLoadTimeText: \"Document Load Time\",\n WriteOutputTimeText: \"Document Write Time\",\n\n // RuntimeExecutionTimes Text\n RuntimeExecutionTimesText: \"Runtime Execution Times\",\n TotalExecutionTimeText: \"Query Engine Execution Time\",\n SystemFunctionExecuteTimeText: \"System Function Execution Time\",\n UserDefinedFunctionExecutionTimeText: \"User-defined Function Execution Time\",\n\n // ClientSideQueryMetrics Text\n ClientSideQueryMetricsText: \"Client Side Metrics\",\n RetriesText: \"Retry Count\",\n RequestChargeText: \"Request Charge\",\n FetchExecutionRangesText: \"Partition Execution Timeline\",\n SchedulingMetricsText: \"Scheduling Metrics\",\n};\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts new file mode 100644 index 000000000..0afbe46ba --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts @@ -0,0 +1,18 @@ +import { TimeSpan } from "./timeSpan"; +/** + * @hidden + */ +export declare function parseDelimitedString(delimitedString: string): { + [key: string]: any; +}; +/** + * @hidden + */ +export declare function timeSpanFromMetrics(metrics: { + [key: string]: any; +}, key: string): TimeSpan; +/** + * @hidden + */ +export declare function isNumeric(input: unknown): boolean; +//# sourceMappingURL=queryMetricsUtils.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts.map new file mode 100644 index 000000000..bd2554aa6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"queryMetricsUtils.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/queryMetricsUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,GAAG;IAC7D,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAsBA;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC/B,GAAG,EAAE,MAAM,GACV,QAAQ,CAMV;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEjD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js new file mode 100644 index 000000000..61157fcbf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { TimeSpan } from "./timeSpan"; +/** + * @hidden + */ +export function parseDelimitedString(delimitedString) { + if (delimitedString == null) { + throw new Error("delimitedString is null or undefined"); + } + const metrics = {}; + const headerAttributes = delimitedString.split(";"); + for (const attribute of headerAttributes) { + const attributeKeyValue = attribute.split("="); + if (attributeKeyValue.length !== 2) { + throw new Error("recieved a malformed delimited string"); + } + const attributeKey = attributeKeyValue[0]; + const attributeValue = parseFloat(attributeKeyValue[1]); + metrics[attributeKey] = attributeValue; + } + return metrics; +} +/** + * @hidden + */ +export function timeSpanFromMetrics(metrics /* TODO: any */, key) { + if (key in metrics) { + return TimeSpan.fromMilliseconds(metrics[key]); + } + return TimeSpan.zero; +} +/** + * @hidden + */ +export function isNumeric(input) { + return !isNaN(parseFloat(input)) && isFinite(input); +} +//# sourceMappingURL=queryMetricsUtils.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js.map new file mode 100644 index 000000000..07fdc0de5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryMetricsUtils.js.map @@ -0,0 +1 @@ +{"version":3,"file":"queryMetricsUtils.js","sourceRoot":"","sources":["../../../src/queryMetrics/queryMetricsUtils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,eAAuB;IAG1D,IAAI,eAAe,IAAI,IAAI,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;KACzD;IAED,MAAM,OAAO,GAA2B,EAAE,CAAC;IAE3C,MAAM,gBAAgB,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE;QACxC,MAAM,iBAAiB,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE/C,IAAI,iBAAiB,CAAC,MAAM,KAAK,CAAC,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;SAC1D;QAED,MAAM,YAAY,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,cAAc,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;QAExD,OAAO,CAAC,YAAY,CAAC,GAAG,cAAc,CAAC;KACxC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,OAA+B,CAAC,eAAe,EAC/C,GAAW;IAEX,IAAI,GAAG,IAAI,OAAO,EAAE;QAClB,OAAO,QAAQ,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;KAChD;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAe,CAAC,CAAC,IAAI,QAAQ,CAAC,KAAe,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { TimeSpan } from \"./timeSpan\";\n\n/**\n * @hidden\n */\nexport function parseDelimitedString(delimitedString: string): {\n [key: string]: any;\n} {\n if (delimitedString == null) {\n throw new Error(\"delimitedString is null or undefined\");\n }\n\n const metrics: { [key: string]: any } = {};\n\n const headerAttributes = delimitedString.split(\";\");\n for (const attribute of headerAttributes) {\n const attributeKeyValue = attribute.split(\"=\");\n\n if (attributeKeyValue.length !== 2) {\n throw new Error(\"recieved a malformed delimited string\");\n }\n\n const attributeKey = attributeKeyValue[0];\n const attributeValue = parseFloat(attributeKeyValue[1]);\n\n metrics[attributeKey] = attributeValue;\n }\n\n return metrics;\n}\n\n/**\n * @hidden\n */\nexport function timeSpanFromMetrics(\n metrics: { [key: string]: any } /* TODO: any */,\n key: string,\n): TimeSpan {\n if (key in metrics) {\n return TimeSpan.fromMilliseconds(metrics[key]);\n }\n\n return TimeSpan.zero;\n}\n\n/**\n * @hidden\n */\nexport function isNumeric(input: unknown): boolean {\n return !isNaN(parseFloat(input as string)) && isFinite(input as number);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts new file mode 100644 index 000000000..834990f55 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts @@ -0,0 +1,27 @@ +import { TimeSpan } from "./timeSpan"; +export declare class QueryPreparationTimes { + readonly queryCompilationTime: TimeSpan; + readonly logicalPlanBuildTime: TimeSpan; + readonly physicalPlanBuildTime: TimeSpan; + readonly queryOptimizationTime: TimeSpan; + constructor(queryCompilationTime: TimeSpan, logicalPlanBuildTime: TimeSpan, physicalPlanBuildTime: TimeSpan, queryOptimizationTime: TimeSpan); + /** + * returns a new QueryPreparationTimes instance that is the addition of this and the arguments. + */ + add(...queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes; + /** + * Output the QueryPreparationTimes as a delimited string. + */ + toDelimitedString(): string; + static readonly zero: QueryPreparationTimes; + /** + * Returns a new instance of the QueryPreparationTimes class that is the + * aggregation of an array of QueryPreparationTimes. + */ + static createFromArray(queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes; + /** + * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString: string): QueryPreparationTimes; +} +//# sourceMappingURL=queryPreparationTime.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts.map new file mode 100644 index 000000000..1ed3b0065 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"queryPreparationTime.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/queryPreparationTime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,qBAAqB;aAEd,oBAAoB,EAAE,QAAQ;aAC9B,oBAAoB,EAAE,QAAQ;aAC9B,qBAAqB,EAAE,QAAQ;aAC/B,qBAAqB,EAAE,QAAQ;gBAH/B,oBAAoB,EAAE,QAAQ,EAC9B,oBAAoB,EAAE,QAAQ,EAC9B,qBAAqB,EAAE,QAAQ,EAC/B,qBAAqB,EAAE,QAAQ;IAGjD;;OAEG;IACI,GAAG,CAAC,GAAG,0BAA0B,EAAE,qBAAqB,EAAE,GAAG,qBAAqB;IA6BzF;;OAEG;IACI,iBAAiB,IAAI,MAAM;IAiBlC,gBAAuB,IAAI,wBAKzB;IAEF;;;OAGG;WACW,eAAe,CAC3B,0BAA0B,EAAE,qBAAqB,EAAE,GAClD,qBAAqB;IAQxB;;OAEG;WACW,yBAAyB,CAAC,eAAe,EAAE,MAAM,GAAG,qBAAqB;CAUxF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js new file mode 100644 index 000000000..6a3616db7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import QueryMetricsConstants from "./queryMetricsConstants"; +import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils"; +import { TimeSpan } from "./timeSpan"; +export class QueryPreparationTimes { + constructor(queryCompilationTime, logicalPlanBuildTime, physicalPlanBuildTime, queryOptimizationTime) { + this.queryCompilationTime = queryCompilationTime; + this.logicalPlanBuildTime = logicalPlanBuildTime; + this.physicalPlanBuildTime = physicalPlanBuildTime; + this.queryOptimizationTime = queryOptimizationTime; + } + /** + * returns a new QueryPreparationTimes instance that is the addition of this and the arguments. + */ + add(...queryPreparationTimesArray) { + let queryCompilationTime = this.queryCompilationTime; + let logicalPlanBuildTime = this.logicalPlanBuildTime; + let physicalPlanBuildTime = this.physicalPlanBuildTime; + let queryOptimizationTime = this.queryOptimizationTime; + for (const queryPreparationTimes of queryPreparationTimesArray) { + if (queryPreparationTimes == null) { + throw new Error("queryPreparationTimesArray has null or undefined item(s)"); + } + queryCompilationTime = queryCompilationTime.add(queryPreparationTimes.queryCompilationTime); + logicalPlanBuildTime = logicalPlanBuildTime.add(queryPreparationTimes.logicalPlanBuildTime); + physicalPlanBuildTime = physicalPlanBuildTime.add(queryPreparationTimes.physicalPlanBuildTime); + queryOptimizationTime = queryOptimizationTime.add(queryPreparationTimes.queryOptimizationTime); + } + return new QueryPreparationTimes(queryCompilationTime, logicalPlanBuildTime, physicalPlanBuildTime, queryOptimizationTime); + } + /** + * Output the QueryPreparationTimes as a delimited string. + */ + toDelimitedString() { + return (`${QueryMetricsConstants.QueryCompileTimeInMs}=${this.queryCompilationTime.totalMilliseconds()};` + + `${QueryMetricsConstants.LogicalPlanBuildTimeInMs}=${this.logicalPlanBuildTime.totalMilliseconds()};` + + `${QueryMetricsConstants.PhysicalPlanBuildTimeInMs}=${this.physicalPlanBuildTime.totalMilliseconds()};` + + `${QueryMetricsConstants.QueryOptimizationTimeInMs}=${this.queryOptimizationTime.totalMilliseconds()}`); + } + /** + * Returns a new instance of the QueryPreparationTimes class that is the + * aggregation of an array of QueryPreparationTimes. + */ + static createFromArray(queryPreparationTimesArray) { + if (queryPreparationTimesArray == null) { + throw new Error("queryPreparationTimesArray is null or undefined item(s)"); + } + return QueryPreparationTimes.zero.add(...queryPreparationTimesArray); + } + /** + * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString) { + const metrics = parseDelimitedString(delimitedString); + return new QueryPreparationTimes(timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryCompileTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.LogicalPlanBuildTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.PhysicalPlanBuildTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryOptimizationTimeInMs)); + } +} +QueryPreparationTimes.zero = new QueryPreparationTimes(TimeSpan.zero, TimeSpan.zero, TimeSpan.zero, TimeSpan.zero); +//# sourceMappingURL=queryPreparationTime.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js.map new file mode 100644 index 000000000..58d196fab --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/queryPreparationTime.js.map @@ -0,0 +1 @@ +{"version":3,"file":"queryPreparationTime.js","sourceRoot":"","sources":["../../../src/queryMetrics/queryPreparationTime.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,OAAO,qBAAqB;IAChC,YACkB,oBAA8B,EAC9B,oBAA8B,EAC9B,qBAA+B,EAC/B,qBAA+B;QAH/B,yBAAoB,GAApB,oBAAoB,CAAU;QAC9B,yBAAoB,GAApB,oBAAoB,CAAU;QAC9B,0BAAqB,GAArB,qBAAqB,CAAU;QAC/B,0BAAqB,GAArB,qBAAqB,CAAU;IAC9C,CAAC;IAEJ;;OAEG;IACI,GAAG,CAAC,GAAG,0BAAmD;QAC/D,IAAI,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC;QACrD,IAAI,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC;QACrD,IAAI,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QACvD,IAAI,qBAAqB,GAAG,IAAI,CAAC,qBAAqB,CAAC;QAEvD,KAAK,M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,MAAM,CAAC,yBAAyB,CAAC,eAAuB;QAC7D,MAAM,OAAO,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;QAEtD,OAAO,IAAI,qBAAqB,CAC9B,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,oBAAoB,CAAC,EACxE,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,wBAAwB,CAAC,EAC5E,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,yBAAyB,CAAC,EAC7E,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,yBAAyB,CAAC,CAC9E,CAAC;IACJ,CAAC;;AAjCsB,0BAAI,GAAG,IAAI,qBAAqB,CACrD,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,CACd,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport QueryMetricsConstants from \"./queryMetricsConstants\";\nimport { parseDelimitedString, timeSpanFromMetrics } from \"./queryMetricsUtils\";\nimport { TimeSpan } from \"./timeSpan\";\n\nexport class QueryPreparationTimes {\n constructor(\n public readonly queryCompilationTime: TimeSpan,\n public readonly logicalPlanBuildTime: TimeSpan,\n public readonly physicalPlanBuildTime: TimeSpan,\n public readonly queryOptimizationTime: TimeSpan,\n ) {}\n\n /**\n * returns a new QueryPreparationTimes instance that is the addition of this and the arguments.\n */\n public add(...queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes {\n let queryCompilationTime = this.queryCompilationTime;\n let logicalPlanBuildTime = this.logicalPlanBuildTime;\n let physicalPlanBuildTime = this.physicalPlanBuildTime;\n let queryOptimizationTime = this.queryOptimizationTime;\n\n for (const queryPreparationTimes of queryPreparationTimesArray) {\n if (queryPreparationTimes == null) {\n throw new Error(\"queryPreparationTimesArray has null or undefined item(s)\");\n }\n\n queryCompilationTime = queryCompilationTime.add(queryPreparationTimes.queryCompilationTime);\n logicalPlanBuildTime = logicalPlanBuildTime.add(queryPreparationTimes.logicalPlanBuildTime);\n physicalPlanBuildTime = physicalPlanBuildTime.add(\n queryPreparationTimes.physicalPlanBuildTime,\n );\n queryOptimizationTime = queryOptimizationTime.add(\n queryPreparationTimes.queryOptimizationTime,\n );\n }\n\n return new QueryPreparationTimes(\n queryCompilationTime,\n logicalPlanBuildTime,\n physicalPlanBuildTime,\n queryOptimizationTime,\n );\n }\n\n /**\n * Output the QueryPreparationTimes as a delimited string.\n */\n public toDelimitedString(): string {\n return (\n `${\n QueryMetricsConstants.QueryCompileTimeInMs\n }=${this.queryCompilationTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.LogicalPlanBuildTimeInMs\n }=${this.logicalPlanBuildTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.PhysicalPlanBuildTimeInMs\n }=${this.physicalPlanBuildTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.QueryOptimizationTimeInMs\n }=${this.queryOptimizationTime.totalMilliseconds()}`\n );\n }\n\n public static readonly zero = new QueryPreparationTimes(\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n );\n\n /**\n * Returns a new instance of the QueryPreparationTimes class that is the\n * aggregation of an array of QueryPreparationTimes.\n */\n public static createFromArray(\n queryPreparationTimesArray: QueryPreparationTimes[],\n ): QueryPreparationTimes {\n if (queryPreparationTimesArray == null) {\n throw new Error(\"queryPreparationTimesArray is null or undefined item(s)\");\n }\n\n return QueryPreparationTimes.zero.add(...queryPreparationTimesArray);\n }\n\n /**\n * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string.\n */\n public static createFromDelimitedString(delimitedString: string): QueryPreparationTimes {\n const metrics = parseDelimitedString(delimitedString);\n\n return new QueryPreparationTimes(\n timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryCompileTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.LogicalPlanBuildTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.PhysicalPlanBuildTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryOptimizationTimeInMs),\n );\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts new file mode 100644 index 000000000..a864ac778 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts @@ -0,0 +1,26 @@ +import { TimeSpan } from "./timeSpan"; +export declare class RuntimeExecutionTimes { + readonly queryEngineExecutionTime: TimeSpan; + readonly systemFunctionExecutionTime: TimeSpan; + readonly userDefinedFunctionExecutionTime: TimeSpan; + constructor(queryEngineExecutionTime: TimeSpan, systemFunctionExecutionTime: TimeSpan, userDefinedFunctionExecutionTime: TimeSpan); + /** + * returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments. + */ + add(...runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes; + /** + * Output the RuntimeExecutionTimes as a delimited string. + */ + toDelimitedString(): string; + static readonly zero: RuntimeExecutionTimes; + /** + * Returns a new instance of the RuntimeExecutionTimes class that is + * the aggregation of an array of RuntimeExecutionTimes. + */ + static createFromArray(runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes; + /** + * Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString: string): RuntimeExecutionTimes; +} +//# sourceMappingURL=runtimeExecutionTimes.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts.map new file mode 100644 index 000000000..a06f62f00 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"runtimeExecutionTimes.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/runtimeExecutionTimes.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,qBAAqB;aAEd,wBAAwB,EAAE,QAAQ;aAClC,2BAA2B,EAAE,QAAQ;aACrC,gCAAgC,EAAE,QAAQ;gBAF1C,wBAAwB,EAAE,QAAQ,EAClC,2BAA2B,EAAE,QAAQ,EACrC,gCAAgC,EAAE,QAAQ;IAG5D;;OAEG;IACI,GAAG,CAAC,GAAG,0BAA0B,EAAE,qBAAqB,EAAE,GAAG,qBAAqB;IA4BzF;;OAEG;IACI,iBAAiB,IAAI,MAAM;IAWlC,gBAAuB,IAAI,wBAIzB;IAEF;;;OAGG;WACW,eAAe,CAC3B,0BAA0B,EAAE,qBAAqB,EAAE,GAClD,qBAAqB;IAQxB;;OAEG;WACW,yBAAyB,CAAC,eAAe,EAAE,MAAM,GAAG,qBAAqB;CAyBxF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js new file mode 100644 index 000000000..3f2d9c6fe --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import QueryMetricsConstants from "./queryMetricsConstants"; +import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils"; +import { TimeSpan } from "./timeSpan"; +export class RuntimeExecutionTimes { + constructor(queryEngineExecutionTime, systemFunctionExecutionTime, userDefinedFunctionExecutionTime) { + this.queryEngineExecutionTime = queryEngineExecutionTime; + this.systemFunctionExecutionTime = systemFunctionExecutionTime; + this.userDefinedFunctionExecutionTime = userDefinedFunctionExecutionTime; + } + /** + * returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments. + */ + add(...runtimeExecutionTimesArray) { + let queryEngineExecutionTime = this.queryEngineExecutionTime; + let systemFunctionExecutionTime = this.systemFunctionExecutionTime; + let userDefinedFunctionExecutionTime = this.userDefinedFunctionExecutionTime; + for (const runtimeExecutionTimes of runtimeExecutionTimesArray) { + if (runtimeExecutionTimes == null) { + throw new Error("runtimeExecutionTimes has null or undefined item(s)"); + } + queryEngineExecutionTime = queryEngineExecutionTime.add(runtimeExecutionTimes.queryEngineExecutionTime); + systemFunctionExecutionTime = systemFunctionExecutionTime.add(runtimeExecutionTimes.systemFunctionExecutionTime); + userDefinedFunctionExecutionTime = userDefinedFunctionExecutionTime.add(runtimeExecutionTimes.userDefinedFunctionExecutionTime); + } + return new RuntimeExecutionTimes(queryEngineExecutionTime, systemFunctionExecutionTime, userDefinedFunctionExecutionTime); + } + /** + * Output the RuntimeExecutionTimes as a delimited string. + */ + toDelimitedString() { + return (`${QueryMetricsConstants.SystemFunctionExecuteTimeInMs}=${this.systemFunctionExecutionTime.totalMilliseconds()};` + + `${QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs}=${this.userDefinedFunctionExecutionTime.totalMilliseconds()}`); + } + /** + * Returns a new instance of the RuntimeExecutionTimes class that is + * the aggregation of an array of RuntimeExecutionTimes. + */ + static createFromArray(runtimeExecutionTimesArray) { + if (runtimeExecutionTimesArray == null) { + throw new Error("runtimeExecutionTimesArray is null or undefined item(s)"); + } + return RuntimeExecutionTimes.zero.add(...runtimeExecutionTimesArray); + } + /** + * Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString) { + const metrics = parseDelimitedString(delimitedString); + const vmExecutionTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs); + const indexLookupTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs); + const documentLoadTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentLoadTimeInMs); + const documentWriteTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentWriteTimeInMs); + let queryEngineExecutionTime = TimeSpan.zero; + queryEngineExecutionTime = queryEngineExecutionTime.add(vmExecutionTime); + queryEngineExecutionTime = queryEngineExecutionTime.subtract(indexLookupTime); + queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentLoadTime); + queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentWriteTime); + return new RuntimeExecutionTimes(queryEngineExecutionTime, timeSpanFromMetrics(metrics, QueryMetricsConstants.SystemFunctionExecuteTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs)); + } +} +RuntimeExecutionTimes.zero = new RuntimeExecutionTimes(TimeSpan.zero, TimeSpan.zero, TimeSpan.zero); +//# sourceMappingURL=runtimeExecutionTimes.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js.map new file mode 100644 index 000000000..61260f772 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/runtimeExecutionTimes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"runtimeExecutionTimes.js","sourceRoot":"","sources":["../../../src/queryMetrics/runtimeExecutionTimes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,OAAO,qBAAqB;IAChC,YACkB,wBAAkC,EAClC,2BAAqC,EACrC,gCAA0C;QAF1C,6BAAwB,GAAxB,wBAAwB,CAAU;QAClC,gCAA2B,GAA3B,2BAA2B,CAAU;QACrC,qCAAg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yBAAyB,CAAC,eAAuB;QAC7D,MAAM,OAAO,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAC;QAEtD,MAAM,eAAe,GAAG,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;QAChG,MAAM,eAAe,GAAG,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;QAChG,MAAM,gBAAgB,GAAG,mBAAmB,CAC1C,OAAO,EACP,qBAAqB,CAAC,oBAAoB,CAC3C,CAAC;QACF,MAAM,iBAAiB,GAAG,mBAAmB,CAC3C,OAAO,EACP,qBAAqB,CAAC,qBAAqB,CAC5C,CAAC;QAEF,IAAI,wBAAwB,GAAG,QAAQ,CAAC,IAAI,CAAC;QAC7C,wBAAwB,GAAG,wBAAwB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACzE,wBAAwB,GAAG,wBAAwB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAC9E,wBAAwB,GAAG,wBAAwB,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAC/E,wBAAwB,GAAG,wBAAwB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QAChF,OAAO,IAAI,qBAAqB,CAC9B,wBAAwB,EACxB,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,6BAA6B,CAAC,EACjF,mBAAmB,CAAC,OAAO,EAAE,qBAAqB,CAAC,oCAAoC,CAAC,CACzF,CAAC;IACJ,CAAC;;AA/CsB,0BAAI,GAAG,IAAI,qBAAqB,CACrD,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,EACb,QAAQ,CAAC,IAAI,CACd,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport QueryMetricsConstants from \"./queryMetricsConstants\";\nimport { parseDelimitedString, timeSpanFromMetrics } from \"./queryMetricsUtils\";\nimport { TimeSpan } from \"./timeSpan\";\n\nexport class RuntimeExecutionTimes {\n constructor(\n public readonly queryEngineExecutionTime: TimeSpan,\n public readonly systemFunctionExecutionTime: TimeSpan,\n public readonly userDefinedFunctionExecutionTime: TimeSpan,\n ) {}\n\n /**\n * returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments.\n */\n public add(...runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes {\n let queryEngineExecutionTime = this.queryEngineExecutionTime;\n let systemFunctionExecutionTime = this.systemFunctionExecutionTime;\n let userDefinedFunctionExecutionTime = this.userDefinedFunctionExecutionTime;\n\n for (const runtimeExecutionTimes of runtimeExecutionTimesArray) {\n if (runtimeExecutionTimes == null) {\n throw new Error(\"runtimeExecutionTimes has null or undefined item(s)\");\n }\n\n queryEngineExecutionTime = queryEngineExecutionTime.add(\n runtimeExecutionTimes.queryEngineExecutionTime,\n );\n systemFunctionExecutionTime = systemFunctionExecutionTime.add(\n runtimeExecutionTimes.systemFunctionExecutionTime,\n );\n userDefinedFunctionExecutionTime = userDefinedFunctionExecutionTime.add(\n runtimeExecutionTimes.userDefinedFunctionExecutionTime,\n );\n }\n\n return new RuntimeExecutionTimes(\n queryEngineExecutionTime,\n systemFunctionExecutionTime,\n userDefinedFunctionExecutionTime,\n );\n }\n\n /**\n * Output the RuntimeExecutionTimes as a delimited string.\n */\n public toDelimitedString(): string {\n return (\n `${\n QueryMetricsConstants.SystemFunctionExecuteTimeInMs\n }=${this.systemFunctionExecutionTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs\n }=${this.userDefinedFunctionExecutionTime.totalMilliseconds()}`\n );\n }\n\n public static readonly zero = new RuntimeExecutionTimes(\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n );\n\n /**\n * Returns a new instance of the RuntimeExecutionTimes class that is\n * the aggregation of an array of RuntimeExecutionTimes.\n */\n public static createFromArray(\n runtimeExecutionTimesArray: RuntimeExecutionTimes[],\n ): RuntimeExecutionTimes {\n if (runtimeExecutionTimesArray == null) {\n throw new Error(\"runtimeExecutionTimesArray is null or undefined item(s)\");\n }\n\n return RuntimeExecutionTimes.zero.add(...runtimeExecutionTimesArray);\n }\n\n /**\n * Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string.\n */\n public static createFromDelimitedString(delimitedString: string): RuntimeExecutionTimes {\n const metrics = parseDelimitedString(delimitedString);\n\n const vmExecutionTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs);\n const indexLookupTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs);\n const documentLoadTime = timeSpanFromMetrics(\n metrics,\n QueryMetricsConstants.DocumentLoadTimeInMs,\n );\n const documentWriteTime = timeSpanFromMetrics(\n metrics,\n QueryMetricsConstants.DocumentWriteTimeInMs,\n );\n\n let queryEngineExecutionTime = TimeSpan.zero;\n queryEngineExecutionTime = queryEngineExecutionTime.add(vmExecutionTime);\n queryEngineExecutionTime = queryEngineExecutionTime.subtract(indexLookupTime);\n queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentLoadTime);\n queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentWriteTime);\n return new RuntimeExecutionTimes(\n queryEngineExecutionTime,\n timeSpanFromMetrics(metrics, QueryMetricsConstants.SystemFunctionExecuteTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs),\n );\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts new file mode 100644 index 000000000..22da0c714 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts @@ -0,0 +1,69 @@ +/** + * Represents a time interval. + * + * @param days - Number of days. + * @param hours - Number of hours. + * @param minutes - Number of minutes. + * @param seconds - Number of seconds. + * @param milliseconds - Number of milliseconds. + * @hidden + */ +export declare class TimeSpan { + protected _ticks: number; + constructor(days: number, hours: number, minutes: number, seconds: number, milliseconds: number); + /** + * Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance. + * @param ts - The time interval to add. + */ + add(ts: TimeSpan): TimeSpan; + /** + * Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance. + * @param ts - The time interval to subtract. + */ + subtract(ts: TimeSpan): TimeSpan; + /** + * Compares this instance to a specified object and returns an integer that indicates whether this + * instance is shorter than, equal to, or longer than the specified object. + * @param value - The time interval to add. + */ + compareTo(value: TimeSpan): 1 | -1 | 0; + /** + * Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object. + */ + duration(): TimeSpan; + /** + * Returns a value indicating whether this instance is equal to a specified object. + * @param value - The time interval to check for equality. + */ + equals(value: TimeSpan): boolean; + /** + * Returns a new TimeSpan object whose value is the negated value of this instance. + * @param value - The time interval to check for equality. + */ + negate(): TimeSpan; + days(): number; + hours(): number; + milliseconds(): number; + seconds(): number; + ticks(): number; + totalDays(): number; + totalHours(): number; + totalMilliseconds(): number; + totalMinutes(): number; + totalSeconds(): number; + static fromTicks(value: number): TimeSpan; + static readonly zero: TimeSpan; + static readonly maxValue: TimeSpan; + static readonly minValue: TimeSpan; + static isTimeSpan(timespan: TimeSpan): number; + static additionDoesOverflow(a: number, b: number): boolean; + static subtractionDoesUnderflow(a: number, b: number): boolean; + static compare(t1: TimeSpan, t2: TimeSpan): 1 | 0 | -1; + static interval(value: number, scale: number): TimeSpan; + static fromMilliseconds(value: number): TimeSpan; + static fromSeconds(value: number): TimeSpan; + static fromMinutes(value: number): TimeSpan; + static fromHours(value: number): TimeSpan; + static fromDays(value: number): TimeSpan; +} +//# sourceMappingURL=timeSpan.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts.map new file mode 100644 index 000000000..d7ca6e907 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"timeSpan.d.ts","sourceRoot":"","sources":["../../../src/queryMetrics/timeSpan.ts"],"names":[],"mappings":"AA8CA;;;;;;;;;GASG;AACH,qBAAa,QAAQ;IACnB,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;gBACb,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;IA+B/F;;;OAGG;IACI,GAAG,CAAC,EAAE,EAAE,QAAQ,GAAG,QAAQ;IASlC;;;OAGG;IACI,QAAQ,CAAC,EAAE,EAAE,QAAQ,GAAG,QAAQ;IASvC;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;IAY7C;;OAEG;IACI,QAAQ,IAAI,QAAQ;IAI3B;;;OAGG;IACI,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAQvC;;;OAGG;IACI,MAAM,IAAI,QAAQ;IAIlB,IAAI,IAAI,MAAM;IAId,KAAK,IAAI,MAAM;IAIf,YAAY,IAAI,MAAM;IAItB,OAAO,IAAI,MAAM;IAIjB,KAAK,IAAI,MAAM;IAIf,SAAS,IAAI,MAAM;IAGnB,UAAU,IAAI,MAAM;IAIpB,iBAAiB,IAAI,MAAM;IAI3B,YAAY,IAAI,MAAM;IAItB,YAAY,IAAI,MAAM;WAIf,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAMhD,gBAAuB,IAAI,WAA+B;IAC1D,gBAAuB,QAAQ,WAA+C;IAC9E,gBAAuB,QAAQ,WAA+C;WAEhE,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM;WAItC,oBAAoB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;WAKnD,wBAAwB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;WAKvD,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;WAU/C,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ;WAahD,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;WAIzC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;WAIpC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;WAIpC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;WAIlC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;CAGhD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js new file mode 100644 index 000000000..c702d7dbc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js @@ -0,0 +1,216 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// Ported this implementation to javascript: +// https://referencesource.microsoft.com/#mscorlib/system/timespan.cs,83e476c1ae112117 +/** @hidden */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const ticksPerMillisecond = 10000; +/** @hidden */ +const millisecondsPerTick = 1.0 / ticksPerMillisecond; +/** @hidden */ +const ticksPerSecond = ticksPerMillisecond * 1000; // 10,000,000 +/** @hidden */ +const secondsPerTick = 1.0 / ticksPerSecond; // 0.0001 +/** @hidden */ +const ticksPerMinute = ticksPerSecond * 60; // 600,000,000 +/** @hidden */ +const minutesPerTick = 1.0 / ticksPerMinute; // 1.6666666666667e-9 +/** @hidden */ +const ticksPerHour = ticksPerMinute * 60; // 36,000,000,000 +/** @hidden */ +const hoursPerTick = 1.0 / ticksPerHour; // 2.77777777777777778e-11 +/** @hidden */ +const ticksPerDay = ticksPerHour * 24; // 864,000,000,000 +/** @hidden */ +const daysPerTick = 1.0 / ticksPerDay; // 1.1574074074074074074e-12 +/** @hidden */ +const millisPerSecond = 1000; +/** @hidden */ +const millisPerMinute = millisPerSecond * 60; // 60,000 +/** @hidden */ +const millisPerHour = millisPerMinute * 60; // 3,600,000 +/** @hidden */ +const millisPerDay = millisPerHour * 24; // 86,400,000 +/** @hidden */ +const maxMilliSeconds = Number.MAX_SAFE_INTEGER / ticksPerMillisecond; +/** @hidden */ +const minMilliSeconds = Number.MIN_SAFE_INTEGER / ticksPerMillisecond; +/** + * Represents a time interval. + * + * @param days - Number of days. + * @param hours - Number of hours. + * @param minutes - Number of minutes. + * @param seconds - Number of seconds. + * @param milliseconds - Number of milliseconds. + * @hidden + */ +export class TimeSpan { + constructor(days, hours, minutes, seconds, milliseconds) { + // Constructor + if (!Number.isInteger(days)) { + throw new Error("days is not an integer"); + } + if (!Number.isInteger(hours)) { + throw new Error("hours is not an integer"); + } + if (!Number.isInteger(minutes)) { + throw new Error("minutes is not an integer"); + } + if (!Number.isInteger(seconds)) { + throw new Error("seconds is not an integer"); + } + if (!Number.isInteger(milliseconds)) { + throw new Error("milliseconds is not an integer"); + } + const totalMilliSeconds = (days * 3600 * 24 + hours * 3600 + minutes * 60 + seconds) * 1000 + milliseconds; + if (totalMilliSeconds > maxMilliSeconds || totalMilliSeconds < minMilliSeconds) { + throw new Error("Total number of milliseconds was either too large or too small"); + } + this._ticks = totalMilliSeconds * ticksPerMillisecond; + } + /** + * Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance. + * @param ts - The time interval to add. + */ + add(ts) { + if (TimeSpan.additionDoesOverflow(this._ticks, ts._ticks)) { + throw new Error("Adding the two timestamps causes an overflow."); + } + const results = this._ticks + ts._ticks; + return TimeSpan.fromTicks(results); + } + /** + * Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance. + * @param ts - The time interval to subtract. + */ + subtract(ts) { + if (TimeSpan.subtractionDoesUnderflow(this._ticks, ts._ticks)) { + throw new Error("Subtracting the two timestamps causes an underflow."); + } + const results = this._ticks - ts._ticks; + return TimeSpan.fromTicks(results); + } + /** + * Compares this instance to a specified object and returns an integer that indicates whether this + * instance is shorter than, equal to, or longer than the specified object. + * @param value - The time interval to add. + */ + compareTo(value) { + if (value == null) { + return 1; + } + if (!TimeSpan.isTimeSpan(value)) { + throw new Error("Argument must be a TimeSpan object"); + } + return TimeSpan.compare(this, value); + } + /** + * Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object. + */ + duration() { + return TimeSpan.fromTicks(this._ticks >= 0 ? this._ticks : -this._ticks); + } + /** + * Returns a value indicating whether this instance is equal to a specified object. + * @param value - The time interval to check for equality. + */ + equals(value) { + if (TimeSpan.isTimeSpan(value)) { + return this._ticks === value._ticks; + } + return false; + } + /** + * Returns a new TimeSpan object whose value is the negated value of this instance. + * @param value - The time interval to check for equality. + */ + negate() { + return TimeSpan.fromTicks(-this._ticks); + } + days() { + return Math.floor(this._ticks / ticksPerDay); + } + hours() { + return Math.floor(this._ticks / ticksPerHour); + } + milliseconds() { + return Math.floor(this._ticks / ticksPerMillisecond); + } + seconds() { + return Math.floor(this._ticks / ticksPerSecond); + } + ticks() { + return this._ticks; + } + totalDays() { + return this._ticks * daysPerTick; + } + totalHours() { + return this._ticks * hoursPerTick; + } + totalMilliseconds() { + return this._ticks * millisecondsPerTick; + } + totalMinutes() { + return this._ticks * minutesPerTick; + } + totalSeconds() { + return this._ticks * secondsPerTick; + } + static fromTicks(value) { + const timeSpan = new TimeSpan(0, 0, 0, 0, 0); + timeSpan._ticks = value; + return timeSpan; + } + static isTimeSpan(timespan) { + return timespan._ticks; + } + static additionDoesOverflow(a, b) { + const c = a + b; + return a !== c - b || b !== c - a; + } + static subtractionDoesUnderflow(a, b) { + const c = a - b; + return a !== c + b || b !== a - c; + } + static compare(t1, t2) { + if (t1._ticks > t2._ticks) { + return 1; + } + if (t1._ticks < t2._ticks) { + return -1; + } + return 0; + } + static interval(value, scale) { + if (isNaN(value)) { + throw new Error("value must be a number"); + } + const milliseconds = value * scale; + if (milliseconds > maxMilliSeconds || milliseconds < minMilliSeconds) { + throw new Error("timespan too long"); + } + return TimeSpan.fromTicks(Math.floor(milliseconds * ticksPerMillisecond)); + } + static fromMilliseconds(value) { + return TimeSpan.interval(value, 1); + } + static fromSeconds(value) { + return TimeSpan.interval(value, millisPerSecond); + } + static fromMinutes(value) { + return TimeSpan.interval(value, millisPerMinute); + } + static fromHours(value) { + return TimeSpan.interval(value, millisPerHour); + } + static fromDays(value) { + return TimeSpan.interval(value, millisPerDay); + } +} +TimeSpan.zero = new TimeSpan(0, 0, 0, 0, 0); +TimeSpan.maxValue = TimeSpan.fromTicks(Number.MAX_SAFE_INTEGER); +TimeSpan.minValue = TimeSpan.fromTicks(Number.MIN_SAFE_INTEGER); +//# sourceMappingURL=timeSpan.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js.map new file mode 100644 index 000000000..c188230bb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/queryMetrics/timeSpan.js.map @@ -0,0 +1 @@ +{"version":3,"file":"timeSpan.js","sourceRoot":"","sources":["../../../src/queryMetrics/timeSpan.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,4CAA4C;AAC5C,sFAAsF;AACtF,cAAc;AACd,uCAAuC;AACvC,kCAAkC;AAClC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAClC,cAAc;AACd,MAAM,mBAAmB,GAAG,GAAG,GAAG,mBAAmB,CAAC;AAEtD,cAAc;AACd,MAAM,cAAc,GAAG,mBAAmB,GAAG,IAAI,CAAC,CAAC,aAAa;AAChE,cAAc;AACd,MAAM,c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C,OAAO,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IAChD,CAAC;;AA3DsB,aAAI,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACnC,iBAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACvD,iBAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// Ported this implementation to javascript:\n// https://referencesource.microsoft.com/#mscorlib/system/timespan.cs,83e476c1ae112117\n/** @hidden */\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nconst ticksPerMillisecond = 10000;\n/** @hidden */\nconst millisecondsPerTick = 1.0 / ticksPerMillisecond;\n\n/** @hidden */\nconst ticksPerSecond = ticksPerMillisecond * 1000; // 10,000,000\n/** @hidden */\nconst secondsPerTick = 1.0 / ticksPerSecond; // 0.0001\n\n/** @hidden */\nconst ticksPerMinute = ticksPerSecond * 60; // 600,000,000\n/** @hidden */\nconst minutesPerTick = 1.0 / ticksPerMinute; // 1.6666666666667e-9\n\n/** @hidden */\nconst ticksPerHour = ticksPerMinute * 60; // 36,000,000,000\n/** @hidden */\nconst hoursPerTick = 1.0 / ticksPerHour; // 2.77777777777777778e-11\n\n/** @hidden */\nconst ticksPerDay = ticksPerHour * 24; // 864,000,000,000\n/** @hidden */\nconst daysPerTick = 1.0 / ticksPerDay; // 1.1574074074074074074e-12\n\n/** @hidden */\nconst millisPerSecond = 1000;\n/** @hidden */\nconst millisPerMinute = millisPerSecond * 60; // 60,000\n/** @hidden */\nconst millisPerHour = millisPerMinute * 60; // 3,600,000\n/** @hidden */\nconst millisPerDay = millisPerHour * 24; // 86,400,000\n\n/** @hidden */\nconst maxMilliSeconds = Number.MAX_SAFE_INTEGER / ticksPerMillisecond;\n/** @hidden */\nconst minMilliSeconds = Number.MIN_SAFE_INTEGER / ticksPerMillisecond;\n\n/**\n * Represents a time interval.\n *\n * @param days - Number of days.\n * @param hours - Number of hours.\n * @param minutes - Number of minutes.\n * @param seconds - Number of seconds.\n * @param milliseconds - Number of milliseconds.\n * @hidden\n */\nexport class TimeSpan {\n protected _ticks: number;\n constructor(days: number, hours: number, minutes: number, seconds: number, milliseconds: number) {\n // Constructor\n if (!Number.isInteger(days)) {\n throw new Error(\"days is not an integer\");\n }\n\n if (!Number.isInteger(hours)) {\n throw new Error(\"hours is not an integer\");\n }\n\n if (!Number.isInteger(minutes)) {\n throw new Error(\"minutes is not an integer\");\n }\n\n if (!Number.isInteger(seconds)) {\n throw new Error(\"seconds is not an integer\");\n }\n\n if (!Number.isInteger(milliseconds)) {\n throw new Error(\"milliseconds is not an integer\");\n }\n\n const totalMilliSeconds =\n (days * 3600 * 24 + hours * 3600 + minutes * 60 + seconds) * 1000 + milliseconds;\n if (totalMilliSeconds > maxMilliSeconds || totalMilliSeconds < minMilliSeconds) {\n throw new Error(\"Total number of milliseconds was either too large or too small\");\n }\n\n this._ticks = totalMilliSeconds * ticksPerMillisecond;\n }\n\n /**\n * Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.\n * @param ts - The time interval to add.\n */\n public add(ts: TimeSpan): TimeSpan {\n if (TimeSpan.additionDoesOverflow(this._ticks, ts._ticks)) {\n throw new Error(\"Adding the two timestamps causes an overflow.\");\n }\n\n const results = this._ticks + ts._ticks;\n return TimeSpan.fromTicks(results);\n }\n\n /**\n * Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance.\n * @param ts - The time interval to subtract.\n */\n public subtract(ts: TimeSpan): TimeSpan {\n if (TimeSpan.subtractionDoesUnderflow(this._ticks, ts._ticks)) {\n throw new Error(\"Subtracting the two timestamps causes an underflow.\");\n }\n\n const results = this._ticks - ts._ticks;\n return TimeSpan.fromTicks(results);\n }\n\n /**\n * Compares this instance to a specified object and returns an integer that indicates whether this\n * instance is shorter than, equal to, or longer than the specified object.\n * @param value - The time interval to add.\n */\n public compareTo(value: TimeSpan): 1 | -1 | 0 {\n if (value == null) {\n return 1;\n }\n\n if (!TimeSpan.isTimeSpan(value)) {\n throw new Error(\"Argument must be a TimeSpan object\");\n }\n\n return TimeSpan.compare(this, value);\n }\n\n /**\n * Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object.\n */\n public duration(): TimeSpan {\n return TimeSpan.fromTicks(this._ticks >= 0 ? this._ticks : -this._ticks);\n }\n\n /**\n * Returns a value indicating whether this instance is equal to a specified object.\n * @param value - The time interval to check for equality.\n */\n public equals(value: TimeSpan): boolean {\n if (TimeSpan.isTimeSpan(value)) {\n return this._ticks === value._ticks;\n }\n\n return false;\n }\n\n /**\n * Returns a new TimeSpan object whose value is the negated value of this instance.\n * @param value - The time interval to check for equality.\n */\n public negate(): TimeSpan {\n return TimeSpan.fromTicks(-this._ticks);\n }\n\n public days(): number {\n return Math.floor(this._ticks / ticksPerDay);\n }\n\n public hours(): number {\n return Math.floor(this._ticks / ticksPerHour);\n }\n\n public milliseconds(): number {\n return Math.floor(this._ticks / ticksPerMillisecond);\n }\n\n public seconds(): number {\n return Math.floor(this._ticks / ticksPerSecond);\n }\n\n public ticks(): number {\n return this._ticks;\n }\n\n public totalDays(): number {\n return this._ticks * daysPerTick;\n }\n public totalHours(): number {\n return this._ticks * hoursPerTick;\n }\n\n public totalMilliseconds(): number {\n return this._ticks * millisecondsPerTick;\n }\n\n public totalMinutes(): number {\n return this._ticks * minutesPerTick;\n }\n\n public totalSeconds(): number {\n return this._ticks * secondsPerTick;\n }\n\n public static fromTicks(value: number): TimeSpan {\n const timeSpan = new TimeSpan(0, 0, 0, 0, 0);\n timeSpan._ticks = value;\n return timeSpan;\n }\n\n public static readonly zero = new TimeSpan(0, 0, 0, 0, 0);\n public static readonly maxValue = TimeSpan.fromTicks(Number.MAX_SAFE_INTEGER);\n public static readonly minValue = TimeSpan.fromTicks(Number.MIN_SAFE_INTEGER);\n\n public static isTimeSpan(timespan: TimeSpan): number {\n return timespan._ticks;\n }\n\n public static additionDoesOverflow(a: number, b: number): boolean {\n const c = a + b;\n return a !== c - b || b !== c - a;\n }\n\n public static subtractionDoesUnderflow(a: number, b: number): boolean {\n const c = a - b;\n return a !== c + b || b !== a - c;\n }\n\n public static compare(t1: TimeSpan, t2: TimeSpan): 1 | 0 | -1 {\n if (t1._ticks > t2._ticks) {\n return 1;\n }\n if (t1._ticks < t2._ticks) {\n return -1;\n }\n return 0;\n }\n\n public static interval(value: number, scale: number): TimeSpan {\n if (isNaN(value)) {\n throw new Error(\"value must be a number\");\n }\n\n const milliseconds = value * scale;\n if (milliseconds > maxMilliSeconds || milliseconds < minMilliSeconds) {\n throw new Error(\"timespan too long\");\n }\n\n return TimeSpan.fromTicks(Math.floor(milliseconds * ticksPerMillisecond));\n }\n\n public static fromMilliseconds(value: number): TimeSpan {\n return TimeSpan.interval(value, 1);\n }\n\n public static fromSeconds(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerSecond);\n }\n\n public static fromMinutes(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerMinute);\n }\n\n public static fromHours(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerHour);\n }\n\n public static fromDays(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerDay);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts new file mode 100644 index 000000000..62b550c88 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts @@ -0,0 +1,66 @@ +import { CosmosDiagnostics, CosmosHeaders } from "../index"; +export interface ErrorBody { + code: string; + message: string; + /** + * @hidden + */ + additionalErrorInfo?: PartitionedQueryExecutionInfo; +} +/** + * @hidden + */ +export interface PartitionedQueryExecutionInfo { + partitionedQueryExecutionInfoVersion: number; + queryInfo: QueryInfo; + queryRanges: QueryRange[]; +} +/** + * @hidden + */ +export interface QueryRange { + min: string; + max: string; + isMinInclusive: boolean; + isMaxInclusive: boolean; +} +/** + * @hidden + */ +export interface QueryInfo { + top?: any; + orderBy?: any[]; + orderByExpressions?: any[]; + offset?: number; + limit?: number; + aggregates?: AggregateType[]; + groupByExpressions?: GroupByExpressions; + groupByAliasToAggregateType: GroupByAliasToAggregateType; + rewrittenQuery?: any; + distinctType: string; + hasSelectValue: boolean; + /** + * determines whether the query is of non streaming orderby type. + */ + hasNonStreamingOrderBy: boolean; +} +export type GroupByExpressions = string[]; +export type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum"; +export interface GroupByAliasToAggregateType { + [key: string]: AggregateType; +} +export declare class ErrorResponse extends Error { + code?: number | string; + substatus?: number; + body?: ErrorBody; + headers?: CosmosHeaders; + activityId?: string; + retryAfterInMs?: number; + retryAfterInMilliseconds?: number; + [key: string]: any; + diagnostics?: CosmosDiagnostics; +} +export declare const nonStreamingEndpointEmptyResult: { + result: string; +}; +//# sourceMappingURL=ErrorResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts.map new file mode 100644 index 000000000..9be779185 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ErrorResponse.d.ts","sourceRoot":"","sources":["../../../src/request/ErrorResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE5D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,mBAAmB,CAAC,EAAE,6BAA6B,CAAC;CACrD;AAED;;GAEG;AACH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;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,eAAO,MAAM,+BAA+B;;CAA+B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js new file mode 100644 index 000000000..72809a008 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js @@ -0,0 +1,4 @@ +export class ErrorResponse extends Error { +} +export const nonStreamingEndpointEmptyResult = { result: "empty response" }; +//# sourceMappingURL=ErrorResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js.map new file mode 100644 index 000000000..ae885f63b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ErrorResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ErrorResponse.js","sourceRoot":"","sources":["../../../src/request/ErrorResponse.ts"],"names":[],"mappings":"AA6DA,MAAM,OAAO,aAAc,SAAQ,KAAK;CAUvC;AAED,MAAM,CAAC,MAAM,+BAA+B,GAAG,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics, CosmosHeaders } from \"../index\";\n\nexport interface ErrorBody {\n code: string;\n message: string;\n /**\n * @hidden\n */\n additionalErrorInfo?: PartitionedQueryExecutionInfo;\n}\n\n/**\n * @hidden\n */\nexport interface PartitionedQueryExecutionInfo {\n partitionedQueryExecutionInfoVersion: number;\n queryInfo: QueryInfo;\n queryRanges: QueryRange[];\n}\n\n/**\n * @hidden\n */\nexport interface QueryRange {\n min: string;\n max: string;\n isMinInclusive: boolean;\n isMaxInclusive: boolean;\n}\n\n/**\n * @hidden\n */\nexport interface QueryInfo {\n top?: any;\n orderBy?: any[];\n orderByExpressions?: any[];\n offset?: number;\n limit?: number;\n aggregates?: AggregateType[];\n groupByExpressions?: GroupByExpressions;\n groupByAliasToAggregateType: GroupByAliasToAggregateType;\n rewrittenQuery?: any;\n distinctType: string;\n hasSelectValue: boolean;\n /**\n * determines whether the query is of non streaming orderby type.\n */\n hasNonStreamingOrderBy: boolean;\n}\n\nexport type GroupByExpressions = string[];\n\nexport type AggregateType = \"Average\" | \"Count\" | \"Max\" | \"Min\" | \"Sum\";\n\nexport interface GroupByAliasToAggregateType {\n [key: string]: AggregateType;\n}\n\nexport class ErrorResponse extends Error {\n code?: number | string;\n substatus?: number;\n body?: ErrorBody;\n headers?: CosmosHeaders;\n activityId?: string;\n retryAfterInMs?: number;\n retryAfterInMilliseconds?: number;\n [key: string]: any;\n diagnostics?: CosmosDiagnostics;\n}\n\nexport const nonStreamingEndpointEmptyResult = { result: \"empty response\" };\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts new file mode 100644 index 000000000..b55808505 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts @@ -0,0 +1,112 @@ +import { PartitionKey } from "../documents"; +import { SharedOptions } from "./SharedOptions"; +/** + * The feed options and query methods. + */ +export interface FeedOptions extends SharedOptions { + /** Opaque token for continuing the enumeration. Default: undefined + * @deprecated Use continuationToken instead. + */ + continuation?: string; + /** Opaque token for continuing the enumeration. Default: undefined */ + continuationToken?: string; + /** + * Limits the size of the continuation token in the response. Default: undefined + * + * Continuation Tokens contain optional data that can be removed from the serialization before writing it out to a header. + * By default we are capping this to 1kb to avoid long headers (Node.js has a global header size limit). + * A user may set this field to allow for longer headers, which can help the backend optimize query execution." + */ + continuationTokenLimitInKB?: number; + /** + * Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths. Default: false + * + * In general, it is best to avoid using this setting. Scans are relatively expensive and take a long time to serve. + */ + enableScanInQuery?: boolean; + /** + * The maximum number of concurrent operations that run client side during parallel query execution in the + * Azure Cosmos DB database service. Negative values make the system automatically decides the number of + * concurrent operations to run. Default: 0 (no parallelism) + */ + maxDegreeOfParallelism?: number; + /** + * Max number of items to be returned in the enumeration operation. Default: undefined (server will defined payload) + * + * Expirimenting with this value can usually result in the biggest performance changes to the query. + * + * The smaller the item count, the faster the first result will be delivered (for non-aggregates). For larger amounts, + * it will take longer to serve the request, but you'll usually get better throughput for large queries (i.e. if you need 1000 items + * before you can do any other actions, set `maxItemCount` to 1000. If you can start doing work after the first 100, set `maxItemCount` to 100.) + */ + maxItemCount?: number; + /** + * Note: consider using changeFeed instead. + * + * Indicates a change feed request. Must be set to "Incremental feed", or omitted otherwise. Default: false + */ + useIncrementalFeed?: boolean; + /** Conditions Associated with the request. */ + accessCondition?: { + /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */ + type: string; + /** Conditional HTTP method header value (the _etag field from the last version you read). */ + condition: string; + }; + /** + * Enable returning query metrics in response headers. Default: false + * + * Used for debugging slow or expensive queries. Also increases response size and if you're using a low max header size in Node.js, + * you can run into issues faster. + */ + populateQueryMetrics?: boolean; + /** + * Enable buffering additional items during queries. Default: false + * + * This will buffer an additional page at a time (multiplied by maxDegreeOfParallelism) from the server in the background. + * This improves latency by fetching pages before they are needed by the client. If you're draining all of the results from the + * server, like `.fetchAll`, you should usually enable this. If you're only fetching one page at a time via continuation token, + * you should avoid this. If you're draining more than one page, but not the entire result set, it may help improve latency, but + * it will increase the total amount of RU/s use to serve the entire query (as some pages will be fetched more than once). + */ + bufferItems?: boolean; + /** + * This setting forces the query to use a query plan. Default: false + * + * Note: this will disable continuation token support, even for single partition queries. + * + * For queries like aggregates and most cross partition queries, this happens anyway. + * However, since the library doesn't know what type of query it is until we get back the first response, + * some optimization can't happen until later. + * + * If this setting is enabled, it will force query plan for the query, which will save some network requests + * and ensure parallelism can happen. Useful for when you know you're doing cross-partition or aggregate queries. + */ + forceQueryPlan?: boolean; + /** Limits the query to a specific partition key. Default: undefined + * + * Scoping a query to a single partition can be accomplished two ways: + * + * `container.items.query('SELECT * from c', { partitionKey: "foo" }).toArray()` + * `container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').toArray()` + * + * The former is useful when the query body is out of your control + * but you still want to restrict it to a single partition. Example: an end user specified query. + */ + partitionKey?: PartitionKey; + /** + * Enable returning index metrics in response headers. Default: false + */ + populateIndexMetrics?: boolean; + /** + * Specifies a custom maximum buffer size for storing final results for nonStreamingOrderBy queries. + * This value is ignored if the query includes top/offset+limit clauses. + */ + vectorSearchBufferSize?: number; + /** + * Disable the nonStreamingOrderBy query feature in supported query features. + * Default: false. Set to true to avoid error from an old gateway that doesn't support this feature. + */ + disableNonStreamingOrderByQuery?: boolean; +} +//# sourceMappingURL=FeedOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts.map new file mode 100644 index 000000000..bcc7d8ffa --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedOptions.d.ts","sourceRoot":"","sources":["../../../src/request/FeedOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,aAAa;IAChD;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sEAAsE;IACtE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;OAMG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,8CAA8C;IAC9C,eAAe,CAAC,EAAE;QAChB,oEAAoE;QACpE,IAAI,EAAE,MAAM,CAAC;QACb,6FAA6F;QAC7F,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;;;;OASG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAC;CAC3C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js new file mode 100644 index 000000000..d6962a020 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=FeedOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js.map new file mode 100644 index 000000000..3d27ed965 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedOptions.js","sourceRoot":"","sources":["../../../src/request/FeedOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../documents\";\nimport { SharedOptions } from \"./SharedOptions\";\n\n/**\n * The feed options and query methods.\n */\nexport interface FeedOptions extends SharedOptions {\n /** Opaque token for continuing the enumeration. Default: undefined\n * @deprecated Use continuationToken instead.\n */\n continuation?: string;\n /** Opaque token for continuing the enumeration. Default: undefined */\n continuationToken?: string;\n /**\n * Limits the size of the continuation token in the response. Default: undefined\n *\n * Continuation Tokens contain optional data that can be removed from the serialization before writing it out to a header.\n * By default we are capping this to 1kb to avoid long headers (Node.js has a global header size limit).\n * A user may set this field to allow for longer headers, which can help the backend optimize query execution.\"\n */\n continuationTokenLimitInKB?: number;\n /**\n * Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths. Default: false\n *\n * In general, it is best to avoid using this setting. Scans are relatively expensive and take a long time to serve.\n */\n enableScanInQuery?: boolean;\n /**\n * The maximum number of concurrent operations that run client side during parallel query execution in the\n * Azure Cosmos DB database service. Negative values make the system automatically decides the number of\n * concurrent operations to run. Default: 0 (no parallelism)\n */\n maxDegreeOfParallelism?: number;\n /**\n * Max number of items to be returned in the enumeration operation. Default: undefined (server will defined payload)\n *\n * Expirimenting with this value can usually result in the biggest performance changes to the query.\n *\n * The smaller the item count, the faster the first result will be delivered (for non-aggregates). For larger amounts,\n * it will take longer to serve the request, but you'll usually get better throughput for large queries (i.e. if you need 1000 items\n * before you can do any other actions, set `maxItemCount` to 1000. If you can start doing work after the first 100, set `maxItemCount` to 100.)\n */\n maxItemCount?: number;\n /**\n * Note: consider using changeFeed instead.\n *\n * Indicates a change feed request. Must be set to \"Incremental feed\", or omitted otherwise. Default: false\n */\n useIncrementalFeed?: boolean;\n /** Conditions Associated with the request. */\n accessCondition?: {\n /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */\n type: string;\n /** Conditional HTTP method header value (the _etag field from the last version you read). */\n condition: string;\n };\n /**\n * Enable returning query metrics in response headers. Default: false\n *\n * Used for debugging slow or expensive queries. Also increases response size and if you're using a low max header size in Node.js,\n * you can run into issues faster.\n */\n populateQueryMetrics?: boolean;\n /**\n * Enable buffering additional items during queries. Default: false\n *\n * This will buffer an additional page at a time (multiplied by maxDegreeOfParallelism) from the server in the background.\n * This improves latency by fetching pages before they are needed by the client. If you're draining all of the results from the\n * server, like `.fetchAll`, you should usually enable this. If you're only fetching one page at a time via continuation token,\n * you should avoid this. If you're draining more than one page, but not the entire result set, it may help improve latency, but\n * it will increase the total amount of RU/s use to serve the entire query (as some pages will be fetched more than once).\n */\n bufferItems?: boolean;\n /**\n * This setting forces the query to use a query plan. Default: false\n *\n * Note: this will disable continuation token support, even for single partition queries.\n *\n * For queries like aggregates and most cross partition queries, this happens anyway.\n * However, since the library doesn't know what type of query it is until we get back the first response,\n * some optimization can't happen until later.\n *\n * If this setting is enabled, it will force query plan for the query, which will save some network requests\n * and ensure parallelism can happen. Useful for when you know you're doing cross-partition or aggregate queries.\n */\n forceQueryPlan?: boolean;\n /** Limits the query to a specific partition key. Default: undefined\n *\n * Scoping a query to a single partition can be accomplished two ways:\n *\n * `container.items.query('SELECT * from c', { partitionKey: \"foo\" }).toArray()`\n * `container.items.query('SELECT * from c WHERE c.yourPartitionKey = \"foo\"').toArray()`\n *\n * The former is useful when the query body is out of your control\n * but you still want to restrict it to a single partition. Example: an end user specified query.\n */\n partitionKey?: PartitionKey;\n /**\n * Enable returning index metrics in response headers. Default: false\n */\n populateIndexMetrics?: boolean;\n /**\n * Specifies a custom maximum buffer size for storing final results for nonStreamingOrderBy queries.\n * This value is ignored if the query includes top/offset+limit clauses.\n */\n vectorSearchBufferSize?: number;\n /**\n * Disable the nonStreamingOrderBy query feature in supported query features.\n * Default: false. Set to true to avoid error from an old gateway that doesn't support this feature.\n */\n disableNonStreamingOrderByQuery?: boolean;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts new file mode 100644 index 000000000..8f215cec5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts @@ -0,0 +1,16 @@ +import { CosmosHeaders } from "../queryExecutionContext/headerUtils"; +import { CosmosDiagnostics } from "../CosmosDiagnostics"; +export declare class FeedResponse { + readonly resources: TResource[]; + private readonly headers; + readonly hasMoreResults: boolean; + readonly diagnostics: CosmosDiagnostics; + constructor(resources: TResource[], headers: CosmosHeaders, hasMoreResults: boolean, diagnostics: CosmosDiagnostics); + get continuation(): string; + get continuationToken(): string; + get queryMetrics(): string; + get requestCharge(): number; + get activityId(): string; + get indexMetrics(): string; +} +//# sourceMappingURL=FeedResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts.map new file mode 100644 index 000000000..ca12ac26f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedResponse.d.ts","sourceRoot":"","sources":["../../../src/request/FeedResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAyB,MAAM,sCAAsC,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,qBAAa,YAAY,CAAC,SAAS;aAEf,SAAS,EAAE,SAAS,EAAE;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO;aACR,cAAc,EAAE,OAAO;aACvB,WAAW,EAAE,iBAAiB;gBAH9B,SAAS,EAAE,SAAS,EAAE,EACrB,OAAO,EAAE,aAAa,EACvB,cAAc,EAAE,OAAO,EACvB,WAAW,EAAE,iBAAiB;IAGhD,IAAW,YAAY,IAAI,MAAM,CAEhC;IACD,IAAW,iBAAiB,IAAI,MAAM,CAErC;IACD,IAAW,YAAY,IAAI,MAAM,CAEhC;IACD,IAAW,aAAa,IAAI,MAAM,CAEjC;IACD,IAAW,UAAU,IAAI,MAAM,CAE9B;IACD,IAAW,YAAY,IAAI,MAAM,CAOhC;CACF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js new file mode 100644 index 000000000..98f4eabbc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants } from "../common"; +import { getRequestChargeIfAny } from "../queryExecutionContext/headerUtils"; +import { IndexMetricWriter, IndexUtilizationInfo } from "../indexMetrics"; +export class FeedResponse { + constructor(resources, headers, hasMoreResults, diagnostics) { + this.resources = resources; + this.headers = headers; + this.hasMoreResults = hasMoreResults; + this.diagnostics = diagnostics; + } + get continuation() { + return this.continuationToken; + } + get continuationToken() { + return this.headers[Constants.HttpHeaders.Continuation]; + } + get queryMetrics() { + return this.headers[Constants.HttpHeaders.QueryMetrics]; + } + get requestCharge() { + return getRequestChargeIfAny(this.headers); + } + get activityId() { + return this.headers[Constants.HttpHeaders.ActivityId]; + } + get indexMetrics() { + const writer = new IndexMetricWriter(); + const indexUtilizationInfo = IndexUtilizationInfo.createFromString(this.headers[Constants.HttpHeaders.IndexUtilization], true); + return writer.writeIndexMetrics(indexUtilizationInfo); + } +} +//# sourceMappingURL=FeedResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js.map new file mode 100644 index 000000000..9cf4cb84d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/FeedResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FeedResponse.js","sourceRoot":"","sources":["../../../src/request/FeedResponse.ts"],"names":[],"mappings":"AAAA,uCA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{ Constants } from \"../common\";\nimport { CosmosHeaders, getRequestChargeIfAny } from \"../queryExecutionContext/headerUtils\";\nimport { IndexMetricWriter, IndexUtilizationInfo } from \"../indexMetrics\";\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\n\nexport class FeedResponse {\n constructor(\n public readonly resources: TResource[],\n private readonly headers: CosmosHeaders,\n public readonly hasMoreResults: boolean,\n public readonly diagnostics: CosmosDiagnostics,\n ) {}\n\n public get continuation(): string {\n return this.continuationToken;\n }\n public get continuationToken(): string {\n return this.headers[Constants.HttpHeaders.Continuation];\n }\n public get queryMetrics(): string {\n return this.headers[Constants.HttpHeaders.QueryMetrics];\n }\n public get requestCharge(): number {\n return getRequestChargeIfAny(this.headers);\n }\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId];\n }\n public get indexMetrics(): string {\n const writer = new IndexMetricWriter();\n const indexUtilizationInfo = IndexUtilizationInfo.createFromString(\n this.headers[Constants.HttpHeaders.IndexUtilization],\n true,\n );\n return writer.writeIndexMetrics(indexUtilizationInfo);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts new file mode 100644 index 000000000..52b1be935 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts @@ -0,0 +1,7 @@ +export interface QueryOperationOptions { + /** + * Request Units(RU) Cap for a given request. Default: Undefined + */ + ruCapPerOperation?: number; +} +//# sourceMappingURL=OperationOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts.map new file mode 100644 index 000000000..60cb69bdc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"OperationOptions.d.ts","sourceRoot":"","sources":["../../../src/request/OperationOptions.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js new file mode 100644 index 000000000..7857fda5a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=OperationOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js.map new file mode 100644 index 000000000..22025c010 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/OperationOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"OperationOptions.js","sourceRoot":"","sources":["../../../src/request/OperationOptions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface QueryOperationOptions {\n /**\n * Request Units(RU) Cap for a given request. Default: Undefined\n */\n ruCapPerOperation?: number;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts new file mode 100644 index 000000000..b4c05e9fb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts @@ -0,0 +1,11 @@ +import { ErrorResponse } from "./ErrorResponse"; +/** + * @hidden + */ +export declare const RUCapPerOperationExceededErrorCode = "OPERATION_RU_LIMIT_EXCEEDED"; +export declare class RUCapPerOperationExceededError extends ErrorResponse { + readonly code: string; + fetchedResults: any[]; + constructor(message?: string, fetchedResults?: any[]); +} +//# sourceMappingURL=RUCapPerOperationExceededError.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts.map new file mode 100644 index 000000000..ed337a62e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"RUCapPerOperationExceededError.d.ts","sourceRoot":"","sources":["../../../src/request/RUCapPerOperationExceededError.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD;;GAEG;AACH,eAAO,MAAM,kCAAkC,gCAAgC,CAAC;AAEhF,qBAAa,8BAA+B,SAAQ,aAAa;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAsC;IACpD,cAAc,EAAE,GAAG,EAAE,CAAC;gBAE3B,OAAO,GAAE,MAAyD,EAClE,cAAc,GAAE,GAAG,EAAO;CAU7B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js new file mode 100644 index 000000000..f18ed856a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { ErrorResponse } from "./ErrorResponse"; +/** + * @hidden + */ +export const RUCapPerOperationExceededErrorCode = "OPERATION_RU_LIMIT_EXCEEDED"; +export class RUCapPerOperationExceededError extends ErrorResponse { + constructor(message = "Request Unit limit per Operation call exceeded", fetchedResults = []) { + super(message); + this.code = RUCapPerOperationExceededErrorCode; + this.code = RUCapPerOperationExceededErrorCode; + this.body = { + code: RUCapPerOperationExceededErrorCode, + message, + }; + this.fetchedResults = fetchedResults; + } +} +//# sourceMappingURL=RUCapPerOperationExceededError.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js.map new file mode 100644 index 000000000..90d424c1f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RUCapPerOperationExceededError.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RUCapPerOperationExceededError.js","sourceRoot":"","sources":["../../../src/request/RUCapPerOperationExceededError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,6BAA6B,CAAC;AAEhF,MAAM,OAAO,8BAA+B,SAAQ,aAAa;IAG/D,YACE,UAAkB,gDAAgD,EAClE,iBAAwB,EAAE;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QANR,SAAI,GAAW,kCAAkC,CAAC;QAOzD,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;QAC/C,IAAI,CAAC,IAAI,GAAG;YACV,IAAI,EAAE,kCAAkC;YACxC,OAAO;SACR,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ErrorResponse } from \"./ErrorResponse\";\n/**\n * @hidden\n */\nexport const RUCapPerOperationExceededErrorCode = \"OPERATION_RU_LIMIT_EXCEEDED\";\n\nexport class RUCapPerOperationExceededError extends ErrorResponse {\n readonly code: string = RUCapPerOperationExceededErrorCode;\n public fetchedResults: any[];\n constructor(\n message: string = \"Request Unit limit per Operation call exceeded\",\n fetchedResults: any[] = [],\n ) {\n super(message);\n this.code = RUCapPerOperationExceededErrorCode;\n this.body = {\n code: RUCapPerOperationExceededErrorCode,\n message,\n };\n this.fetchedResults = fetchedResults;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts new file mode 100644 index 000000000..d85caccf1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts @@ -0,0 +1,34 @@ +import { ClientContext } from "../ClientContext"; +import { HTTPMethod, OperationType, ResourceType } from "../common"; +import { Agent } from "../CosmosClientOptions"; +import { ConnectionPolicy, PartitionKey } from "../documents"; +import { GlobalEndpointManager } from "../globalEndpointManager"; +import { PluginConfig } from "../plugins/Plugin"; +import { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; +import { FeedOptions } from "./FeedOptions"; +import { RequestOptions } from "./RequestOptions"; +import { Pipeline } from "@azure/core-rest-pipeline"; +/** + * @hidden + */ +export interface RequestContext { + path?: string; + operationType?: OperationType; + client?: ClientContext; + retryCount?: number; + resourceType?: ResourceType; + resourceId?: string; + globalEndpointManager: GlobalEndpointManager; + connectionPolicy: ConnectionPolicy; + requestAgent: Agent; + body?: any; + headers?: CosmosHeaders; + endpoint?: string; + method: HTTPMethod; + partitionKeyRangeId?: string; + options: FeedOptions | RequestOptions; + plugins: PluginConfig[]; + partitionKey?: PartitionKey; + pipeline?: Pipeline; +} +//# sourceMappingURL=RequestContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts.map new file mode 100644 index 000000000..26ea28b83 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"RequestContext.d.ts","sourceRoot":"","sources":["../../../src/request/RequestContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC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m/src/request/RequestContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.js new file mode 100644 index 000000000..452fc9e6e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=RequestContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.js.map new file mode 100644 index 000000000..0ace71cd6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RequestContext.js","sourceRoot":"","sources":["../../../src/request/RequestContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { HTTPMethod, OperationType, ResourceType } from \"../common\";\nimport { Agent } from \"../CosmosClientOptions\";\nimport { ConnectionPolicy, PartitionKey } from \"../documents\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { PluginConfig } from \"../plugins/Plugin\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { FeedOptions } from \"./FeedOptions\";\nimport { RequestOptions } from \"./RequestOptions\";\nimport { Pipeline } from \"@azure/core-rest-pipeline\";\n\n/**\n * @hidden\n */\nexport interface RequestContext {\n path?: string;\n operationType?: OperationType;\n client?: ClientContext;\n retryCount?: number;\n resourceType?: ResourceType;\n resourceId?: string;\n globalEndpointManager: GlobalEndpointManager;\n connectionPolicy: ConnectionPolicy;\n requestAgent: Agent;\n body?: any;\n headers?: CosmosHeaders;\n endpoint?: string;\n method: HTTPMethod;\n partitionKeyRangeId?: string;\n options: FeedOptions | RequestOptions;\n plugins: PluginConfig[];\n partitionKey?: PartitionKey;\n pipeline?: Pipeline;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts new file mode 100644 index 000000000..b7075c2d7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts @@ -0,0 +1,12 @@ +import { RequestContext } from "./RequestContext"; +import { Response as CosmosResponse } from "./Response"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +/** + * @hidden + */ +declare function request(requestContext: RequestContext, diagnosticNode: DiagnosticNodeInternal): Promise>; +export declare const RequestHandler: { + request: typeof request; +}; +export {}; +//# sourceMappingURL=RequestHandler.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts.map new file mode 100644 index 000000000..2f13c3b74 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"RequestHandler.d.ts","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,IAAI,cAAc,EAAE,MAAM,YAAY,CAAC;AAIxD,OAAO,EAAE,sBAAsB,EAAsB,MAAM,uCAAuC,CAAC;AA0JnG;;GAEG;AACH,iBAAe,OAAO,CAAC,CAAC,EACtB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAmB5B;AAED,eAAO,MAAM,cAAc;;CAE1B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js new file mode 100644 index 000000000..504f92157 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js @@ -0,0 +1,150 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { AbortController } from "node-abort-controller"; +import { createPipelineRequest, createHttpHeaders, } from "@azure/core-rest-pipeline"; +import { prepareURL } from "../common"; +import { Constants } from "../common/constants"; +import { executePlugins, PluginOn } from "../plugins/Plugin"; +import * as RetryUtility from "../retry/retryUtility"; +import { defaultHttpAgent, defaultHttpsAgent } from "./defaultAgent"; +import { ErrorResponse } from "./ErrorResponse"; +import { bodyFromData } from "./request"; +import { TimeoutError } from "./TimeoutError"; +import { getCachedDefaultHttpClient } from "../utils/cachedClient"; +import { createClientLogger } from "@azure/logger"; +import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; +import { addDignosticChild } from "../utils/diagnostics"; +import { getCurrentTimestampInMs } from "../utils/time"; +const logger = createClientLogger("RequestHandler"); +async function executeRequest(diagnosticNode, requestContext) { + return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request); +} +/** + * @hidden + */ +async function httpRequest(requestContext, diagnosticNode) { + const controller = new AbortController(); + const signal = controller.signal; + // Wrap users passed abort events and call our own internal abort() + const userSignal = requestContext.options && requestContext.options.abortSignal; + if (userSignal) { + if (userSignal.aborted) { + controller.abort(); + } + else { + userSignal.addEventListener("abort", () => { + controller.abort(); + }); + } + } + const timeout = setTimeout(() => { + controller.abort(); + }, requestContext.connectionPolicy.requestTimeout); + let response; + if (requestContext.body) { + requestContext.body = bodyFromData(requestContext.body); + } + const httpsClient = getCachedDefaultHttpClient(); + const url = prepareURL(requestContext.endpoint, requestContext.path); + const reqHeaders = createHttpHeaders(requestContext.headers); + const pipelineRequest = createPipelineRequest({ + url, + headers: reqHeaders, + method: requestContext.method, + abortSignal: signal, + body: requestContext.body, + }); + if (requestContext.requestAgent) { + pipelineRequest.agent = requestContext.requestAgent; + } + else { + const parsedUrl = new URL(url); + pipelineRequest.agent = parsedUrl.protocol === "http" ? defaultHttpAgent : defaultHttpsAgent; + } + const startTimeUTCInMs = getCurrentTimestampInMs(); + try { + if (requestContext.pipeline) { + response = await requestContext.pipeline.sendRequest(httpsClient, pipelineRequest); + } + else { + response = await httpsClient.sendRequest(pipelineRequest); + } + } + catch (error) { + if (error.name === "AbortError") { + // If the user passed signal caused the abort, cancel the timeout and rethrow the error + if (userSignal && userSignal.aborted === true) { + clearTimeout(timeout); + throw error; + } + // If the user didn't cancel, it must be an abort we called due to timeout + throw new TimeoutError(`Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`); + } + throw error; + } + clearTimeout(timeout); + const result = response.status === 204 || response.status === 304 || response.bodyAsText === "" + ? null + : JSON.parse(response.bodyAsText); + const responseHeaders = response.headers.toJSON(); + const substatus = responseHeaders[Constants.HttpHeaders.SubStatus] + ? parseInt(responseHeaders[Constants.HttpHeaders.SubStatus], 10) + : undefined; + diagnosticNode.recordSuccessfulNetworkCall(startTimeUTCInMs, requestContext, response, substatus, url); + if (response.status >= 400) { + const errorResponse = new ErrorResponse(result.message); + logger.warning(response.status + + " " + + requestContext.endpoint + + " " + + requestContext.path + + " " + + result.message); + errorResponse.code = response.status; + errorResponse.body = result; + errorResponse.headers = responseHeaders; + if (Constants.HttpHeaders.ActivityId in responseHeaders) { + errorResponse.activityId = responseHeaders[Constants.HttpHeaders.ActivityId]; + } + if (Constants.HttpHeaders.SubStatus in responseHeaders) { + errorResponse.substatus = substatus; + } + if (Constants.HttpHeaders.RetryAfterInMs in responseHeaders) { + errorResponse.retryAfterInMs = parseInt(responseHeaders[Constants.HttpHeaders.RetryAfterInMs], 10); + Object.defineProperty(errorResponse, "retryAfterInMilliseconds", { + get: () => { + return errorResponse.retryAfterInMs; + }, + }); + } + throw errorResponse; + } + return { + headers: responseHeaders, + result, + code: response.status, + substatus, + }; +} +/** + * @hidden + */ +async function request(requestContext, diagnosticNode) { + if (requestContext.body) { + requestContext.body = bodyFromData(requestContext.body); + if (!requestContext.body) { + throw new Error("parameter data must be a javascript object, string, or Buffer"); + } + } + return addDignosticChild(async (childNode) => { + return RetryUtility.execute({ + diagnosticNode: childNode, + requestContext, + executeRequest, + }); + }, diagnosticNode, DiagnosticNodeType.REQUEST_ATTEMPTS); +} +export const RequestHandler = { + request, +}; +//# sourceMappingURL=RequestHandler.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js.map new file mode 100644 index 000000000..673647bae --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestHandler.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RequestHandler.js","sourceRoot":"","sources":["../../../src/request/RequestHandler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAElB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,KAAK,YAAY,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAe,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAA0B,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,uBAAuB,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c,IAAI,eAAe,EAAE;YAC3D,aAAa,CAAC,cAAc,GAAG,QAAQ,CACrC,eAAe,CAAC,SAAS,CAAC,WAAW,CAAC,cAAc,CAAC,EACrD,EAAE,CACH,CAAC;YACF,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,0BAA0B,EAAE;gBAC/D,GAAG,EAAE,GAAG,EAAE;oBACR,OAAO,aAAa,CAAC,cAAc,CAAC;gBACtC,CAAC;aACF,CAAC,CAAC;SACJ;QAED,MAAM,aAAa,CAAC;KACrB;IACD,OAAO;QACL,OAAO,EAAE,eAAe;QACxB,MAAM;QACN,IAAI,EAAE,QAAQ,CAAC,MAAM;QACrB,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,KAAK,UAAU,OAAO,CACpB,cAA8B,EAC9B,cAAsC;IAEtC,IAAI,cAAc,CAAC,IAAI,EAAE;QACvB,cAAc,CAAC,IAAI,GAAG,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QACxD,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;SAClF;KACF;IAED,OAAO,iBAAiB,CACtB,KAAK,EAAE,SAAiC,EAAE,EAAE;QAC1C,OAAO,YAAY,CAAC,OAAO,CAAC;YAC1B,cAAc,EAAE,SAAS;YACzB,cAAc;YACd,cAAc;SACf,CAAC,CAAC;IACL,CAAC,EACD,cAAc,EACd,kBAAkB,CAAC,gBAAgB,CACpC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;CACR,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AbortController } from \"node-abort-controller\";\nimport {\n createPipelineRequest,\n createHttpHeaders,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\nimport { prepareURL } from \"../common\";\nimport { Constants } from \"../common/constants\";\nimport { executePlugins, PluginOn } from \"../plugins/Plugin\";\nimport * as RetryUtility from \"../retry/retryUtility\";\nimport { defaultHttpAgent, defaultHttpsAgent } from \"./defaultAgent\";\nimport { ErrorResponse } from \"./ErrorResponse\";\nimport { bodyFromData } from \"./request\";\nimport { RequestContext } from \"./RequestContext\";\nimport { Response as CosmosResponse } from \"./Response\";\nimport { TimeoutError } from \"./TimeoutError\";\nimport { getCachedDefaultHttpClient } from \"../utils/cachedClient\";\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\n\nconst logger: AzureLogger = createClientLogger(\"RequestHandler\");\n\nasync function executeRequest(\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n): Promise> {\n return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request);\n}\n\n/**\n * @hidden\n */\nasync function httpRequest(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise<{\n headers: any;\n result: any;\n code: number;\n substatus: number;\n}> {\n const controller = new AbortController();\n const signal = controller.signal;\n\n // Wrap users passed abort events and call our own internal abort()\n const userSignal = requestContext.options && requestContext.options.abortSignal;\n if (userSignal) {\n if (userSignal.aborted) {\n controller.abort();\n } else {\n userSignal.addEventListener(\"abort\", () => {\n controller.abort();\n });\n }\n }\n\n const timeout = setTimeout(() => {\n controller.abort();\n }, requestContext.connectionPolicy.requestTimeout);\n\n let response: PipelineResponse;\n\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n }\n\n const httpsClient = getCachedDefaultHttpClient();\n const url = prepareURL(requestContext.endpoint, requestContext.path);\n const reqHeaders = createHttpHeaders(requestContext.headers as any);\n const pipelineRequest = createPipelineRequest({\n url,\n headers: reqHeaders,\n method: requestContext.method,\n abortSignal: signal,\n body: requestContext.body,\n });\n if (requestContext.requestAgent) {\n pipelineRequest.agent = requestContext.requestAgent;\n } else {\n const parsedUrl = new URL(url);\n pipelineRequest.agent = parsedUrl.protocol === \"http\" ? defaultHttpAgent : defaultHttpsAgent;\n }\n\n const startTimeUTCInMs = getCurrentTimestampInMs();\n try {\n if (requestContext.pipeline) {\n response = await requestContext.pipeline.sendRequest(httpsClient, pipelineRequest);\n } else {\n response = await httpsClient.sendRequest(pipelineRequest);\n }\n } catch (error: any) {\n if (error.name === \"AbortError\") {\n // If the user passed signal caused the abort, cancel the timeout and rethrow the error\n if (userSignal && userSignal.aborted === true) {\n clearTimeout(timeout);\n throw error;\n }\n // If the user didn't cancel, it must be an abort we called due to timeout\n throw new TimeoutError(\n `Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`,\n );\n }\n throw error;\n }\n\n clearTimeout(timeout);\n const result =\n response.status === 204 || response.status === 304 || response.bodyAsText === \"\"\n ? null\n : JSON.parse(response.bodyAsText);\n const responseHeaders = response.headers.toJSON();\n\n const substatus = responseHeaders[Constants.HttpHeaders.SubStatus]\n ? parseInt(responseHeaders[Constants.HttpHeaders.SubStatus], 10)\n : undefined;\n\n diagnosticNode.recordSuccessfulNetworkCall(\n startTimeUTCInMs,\n requestContext,\n response,\n substatus,\n url,\n );\n\n if (response.status >= 400) {\n const errorResponse: ErrorResponse = new ErrorResponse(result.message);\n logger.warning(\n response.status +\n \" \" +\n requestContext.endpoint +\n \" \" +\n requestContext.path +\n \" \" +\n result.message,\n );\n\n errorResponse.code = response.status;\n errorResponse.body = result;\n errorResponse.headers = responseHeaders;\n\n if (Constants.HttpHeaders.ActivityId in responseHeaders) {\n errorResponse.activityId = responseHeaders[Constants.HttpHeaders.ActivityId];\n }\n\n if (Constants.HttpHeaders.SubStatus in responseHeaders) {\n errorResponse.substatus = substatus;\n }\n\n if (Constants.HttpHeaders.RetryAfterInMs in responseHeaders) {\n errorResponse.retryAfterInMs = parseInt(\n responseHeaders[Constants.HttpHeaders.RetryAfterInMs],\n 10,\n );\n Object.defineProperty(errorResponse, \"retryAfterInMilliseconds\", {\n get: () => {\n return errorResponse.retryAfterInMs;\n },\n });\n }\n\n throw errorResponse;\n }\n return {\n headers: responseHeaders,\n result,\n code: response.status,\n substatus,\n };\n}\n\n/**\n * @hidden\n */\nasync function request(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise> {\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n if (!requestContext.body) {\n throw new Error(\"parameter data must be a javascript object, string, or Buffer\");\n }\n }\n\n return addDignosticChild(\n async (childNode: DiagnosticNodeInternal) => {\n return RetryUtility.execute({\n diagnosticNode: childNode,\n requestContext,\n executeRequest,\n });\n },\n diagnosticNode,\n DiagnosticNodeType.REQUEST_ATTEMPTS,\n );\n}\n\nexport const RequestHandler = {\n request,\n};\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts new file mode 100644 index 000000000..31f76d5a3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts @@ -0,0 +1,45 @@ +import { SharedOptions } from ".."; +/** + * Options that can be specified for a requested issued to the Azure Cosmos DB servers.= + */ +export interface RequestOptions extends SharedOptions { + /** Conditions Associated with the request. */ + accessCondition?: { + /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */ + type: string; + /** Conditional HTTP method header value (the _etag field from the last version you read). */ + condition: string; + }; + /** Consistency level required by the client. */ + consistencyLevel?: string; + /** + * DisableRUPerMinuteUsage is used to enable/disable Request Units(RUs)/minute capacity + * to serve the request if regular provisioned RUs/second is exhausted. + */ + disableRUPerMinuteUsage?: boolean; + /** Enables or disables logging in JavaScript stored procedures. */ + enableScriptLogging?: boolean; + /** Specifies indexing directives (index, do not index .. etc). */ + indexingDirective?: string; + /** The offer throughput provisioned for a container in measurement of Requests-per-Unit. */ + offerThroughput?: number; + /** + * Offer type when creating document containers. + * + * This option is only valid when creating a document container. + */ + offerType?: string; + /** Enables/disables getting document container quota related stats for document container read requests. */ + populateQuotaInfo?: boolean; + /** Indicates what is the post trigger to be invoked after the operation. */ + postTriggerInclude?: string | string[]; + /** Indicates what is the pre trigger to be invoked before the operation. */ + preTriggerInclude?: string | string[]; + /** Expiry time (in seconds) for resource token associated with permission (applicable only for requests on permissions). */ + resourceTokenExpirySeconds?: number; + /** (Advanced use case) The url to connect to. */ + urlConnection?: string; + /** Disable automatic id generation (will cause creates to fail if id isn't on the definition) */ + disableAutomaticIdGeneration?: boolean; +} +//# sourceMappingURL=RequestOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts.map new file mode 100644 index 000000000..fc4756dcd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"RequestOptions.d.ts","sourceRoot":"","sources":["../../../src/request/RequestOptions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,8CAA8C;IAC9C,eAAe,CAAC,EAAE;QAChB,oEAAoE;QACpE,IAAI,EAAE,MAAM,CAAC;QACb,6FAA6F;QAC7F,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,gDAAgD;IAChD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mEAAmE;IACnE,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4FAA4F;IAC5F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4GAA4G;IAC5G,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,4EAA4E;IAC5E,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACvC,4EAA4E;IAC5E,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtC,4HAA4H;IAC5H,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,iDAAiD;IACjD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iGAAiG;IACjG,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js new file mode 100644 index 000000000..09d38bf5d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=RequestOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js.map new file mode 100644 index 000000000..77cd9e005 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/RequestOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RequestOptions.js","sourceRoot":"","sources":["../../../src/request/RequestOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { SharedOptions } from \"..\";\n\n/**\n * Options that can be specified for a requested issued to the Azure Cosmos DB servers.=\n */\nexport interface RequestOptions extends SharedOptions {\n /** Conditions Associated with the request. */\n accessCondition?: {\n /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */\n type: string;\n /** Conditional HTTP method header value (the _etag field from the last version you read). */\n condition: string;\n };\n /** Consistency level required by the client. */\n consistencyLevel?: string;\n /**\n * DisableRUPerMinuteUsage is used to enable/disable Request Units(RUs)/minute capacity\n * to serve the request if regular provisioned RUs/second is exhausted.\n */\n disableRUPerMinuteUsage?: boolean;\n /** Enables or disables logging in JavaScript stored procedures. */\n enableScriptLogging?: boolean;\n /** Specifies indexing directives (index, do not index .. etc). */\n indexingDirective?: string;\n /** The offer throughput provisioned for a container in measurement of Requests-per-Unit. */\n offerThroughput?: number;\n /**\n * Offer type when creating document containers.\n *\n * This option is only valid when creating a document container.\n */\n offerType?: string;\n /** Enables/disables getting document container quota related stats for document container read requests. */\n populateQuotaInfo?: boolean;\n /** Indicates what is the post trigger to be invoked after the operation. */\n postTriggerInclude?: string | string[];\n /** Indicates what is the pre trigger to be invoked before the operation. */\n preTriggerInclude?: string | string[];\n /** Expiry time (in seconds) for resource token associated with permission (applicable only for requests on permissions). */\n resourceTokenExpirySeconds?: number;\n /** (Advanced use case) The url to connect to. */\n urlConnection?: string;\n /** Disable automatic id generation (will cause creates to fail if id isn't on the definition) */\n disableAutomaticIdGeneration?: boolean;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts new file mode 100644 index 000000000..36c539def --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts @@ -0,0 +1,15 @@ +import { CosmosDiagnostics } from "../CosmosDiagnostics"; +import { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; +import { StatusCode, SubStatusCode } from "./StatusCodes"; +export declare class ResourceResponse { + readonly resource: TResource | undefined; + readonly headers: CosmosHeaders; + readonly statusCode: StatusCode; + readonly diagnostics: CosmosDiagnostics; + readonly substatus?: SubStatusCode; + constructor(resource: TResource | undefined, headers: CosmosHeaders, statusCode: StatusCode, diagnostics: CosmosDiagnostics, substatus?: SubStatusCode); + get requestCharge(): number; + get activityId(): string; + get etag(): string; +} +//# sourceMappingURL=ResourceResponse.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts.map new file mode 100644 index 000000000..a93c37c70 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ResourceResponse.d.ts","sourceRoot":"","sources":["../../../src/request/ResourceResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1D,qBAAa,gBAAgB,CAAC,SAAS;aAEnB,QAAQ,EAAE,SAAS,GAAG,SAAS;aAC/B,OAAO,EAAE,aAAa;aACtB,UAAU,EAAE,UAAU;aACtB,WAAW,EAAE,iBAAiB;aAC9B,SAAS,CAAC,EAAE,aAAa;gBAJzB,QAAQ,EAAE,SAAS,GAAG,SAAS,EAC/B,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,iBAAiB,EAC9B,SAAS,CAAC,EAAE,aAAa;IAE3C,IAAW,aAAa,IAAI,MAAM,CAEjC;IACD,IAAW,UAAU,IAAI,MAAM,CAE9B;IACD,IAAW,IAAI,IAAI,MAAM,CAExB;CACF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js new file mode 100644 index 000000000..65edae299 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js @@ -0,0 +1,20 @@ +import { Constants } from "../common"; +export class ResourceResponse { + constructor(resource, headers, statusCode, diagnostics, substatus) { + this.resource = resource; + this.headers = headers; + this.statusCode = statusCode; + this.diagnostics = diagnostics; + this.substatus = substatus; + } + get requestCharge() { + return Number(this.headers[Constants.HttpHeaders.RequestCharge]) || 0; + } + get activityId() { + return this.headers[Constants.HttpHeaders.ActivityId]; + } + get etag() { + return this.headers[Constants.HttpHeaders.ETag]; + } +} +//# sourceMappingURL=ResourceResponse.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js.map new file mode 100644 index 000000000..f02fa06fc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/ResourceResponse.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ResourceResponse.js","sourceRoot":"","sources":["../../../src/request/ResourceResponse.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAItC,MAAM,OAAO,gBAAgB;IAC3B,YACkB,QAA+B,EAC/B,OAAsB,EACtB,UAAsB,EACtB,WAA8B,EAC9B,SAAyB;QAJzB,aAAQ,GAAR,QAAQ,CAAuB;QAC/B,YAAO,GAAP,OAAO,CAAe;QACtB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAmB;QAC9B,cAAS,GAAT,SAAS,CAAgB;IACxC,CAAC;IACJ,IAAW,aAAa;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC;IACxE,CAAC;IACD,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,UAAU,CAAW,CAAC;IAClE,CAAC;IACD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAW,CAAC;IAC5D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\nimport { Constants } from \"../common\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { StatusCode, SubStatusCode } from \"./StatusCodes\";\n\nexport class ResourceResponse {\n constructor(\n public readonly resource: TResource | undefined,\n public readonly headers: CosmosHeaders,\n public readonly statusCode: StatusCode,\n public readonly diagnostics: CosmosDiagnostics,\n public readonly substatus?: SubStatusCode,\n ) {}\n public get requestCharge(): number {\n return Number(this.headers[Constants.HttpHeaders.RequestCharge]) || 0;\n }\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId] as string;\n }\n public get etag(): string {\n return this.headers[Constants.HttpHeaders.ETag] as string;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts new file mode 100644 index 000000000..4ebd73d01 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts @@ -0,0 +1,12 @@ +import { CosmosDiagnostics, CosmosHeaders } from "../index"; +/** + * @hidden + */ +export interface Response { + headers: CosmosHeaders; + result?: T; + code?: number; + substatus?: number; + diagnostics?: CosmosDiagnostics; +} +//# sourceMappingURL=Response.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts.map new file mode 100644 index 000000000..09b90e32d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../src/request/Response.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js new file mode 100644 index 000000000..d099adb76 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=Response.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js.map new file mode 100644 index 000000000..f8bc9e637 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/Response.js.map @@ -0,0 +1 @@ +{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../src/request/Response.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics, CosmosHeaders } from \"../index\";\n\n/**\n * @hidden\n */\nexport interface Response {\n headers: CosmosHeaders;\n result?: T;\n code?: number;\n substatus?: number;\n diagnostics?: CosmosDiagnostics;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts new file mode 100644 index 000000000..a837b6ebd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts @@ -0,0 +1,42 @@ +/// +import { PriorityLevel } from "../documents/PriorityLevel"; +import { CosmosHeaders } from "../index"; +import { AbortSignal } from "node-abort-controller"; +/** + * Options that can be specified for a requested issued to the Azure Cosmos DB servers.= + */ +export interface SharedOptions { + /** Enables/disables getting document container quota related stats for document container read requests. */ + sessionToken?: string; + /** (Advanced use case) Initial headers to start with when sending requests to Cosmos */ + initialHeaders?: CosmosHeaders; + /** + * abortSignal to pass to all underlying network requests created by this method call. See https://developer.mozilla.org/en-US/docs/Web/API/AbortController + * @example Cancel a read request + * ```typescript + * const controller = new AbortController() + * const {result: item} = await items.query('SELECT * from c', { abortSignal: controller.signal}); + * controller.abort() + * ``` + */ + abortSignal?: AbortSignal; + /** + * Sets the staleness value associated with the request in the Azure CosmosDB service. For requests where the {@link + * com.azure.cosmos.ConsistencyLevel} is {@link com.azure.cosmos.ConsistencyLevel#EVENTUAL} or {@link com.azure.cosmos.ConsistencyLevel#SESSION}, responses from the + * integrated cache are guaranteed to be no staler than value indicated by this maxIntegratedCacheStaleness. When the + * consistency level is not set, this property is ignored. + * + *

Default value is null

+ * + *

Cache Staleness is supported in milliseconds granularity. Anything smaller than milliseconds will be ignored.

+ */ + maxIntegratedCacheStalenessInMs?: number; + /** + * Priority Level (Low/High) for each request. + * Low priority requests are always throttled before any high priority requests. + * + *

Default value is null. By default all requests are of High priority

+ */ + priorityLevel?: PriorityLevel; +} +//# sourceMappingURL=SharedOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts.map new file mode 100644 index 000000000..b2cb5f1e1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"SharedOptions.d.ts","sourceRoot":"","sources":["../../../src/request/SharedOptions.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4GAA4G;IAC5G,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;OASG;IACH,+BAA+B,CAAC,EAAE,MAAM,CAAC;IAEzC;;;;;OAKG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js new file mode 100644 index 000000000..d2029256f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=SharedOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js.map new file mode 100644 index 000000000..51611daf3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/SharedOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SharedOptions.js","sourceRoot":"","sources":["../../../src/request/SharedOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/// \nimport { PriorityLevel } from \"../documents/PriorityLevel\";\nimport { CosmosHeaders } from \"../index\";\nimport { AbortSignal } from \"node-abort-controller\";\n\n/**\n * Options that can be specified for a requested issued to the Azure Cosmos DB servers.=\n */\nexport interface SharedOptions {\n /** Enables/disables getting document container quota related stats for document container read requests. */\n sessionToken?: string;\n /** (Advanced use case) Initial headers to start with when sending requests to Cosmos */\n initialHeaders?: CosmosHeaders;\n /**\n * abortSignal to pass to all underlying network requests created by this method call. See https://developer.mozilla.org/en-US/docs/Web/API/AbortController\n * @example Cancel a read request\n * ```typescript\n * const controller = new AbortController()\n * const {result: item} = await items.query('SELECT * from c', { abortSignal: controller.signal});\n * controller.abort()\n * ```\n */\n abortSignal?: AbortSignal;\n /**\n * Sets the staleness value associated with the request in the Azure CosmosDB service. For requests where the {@link\n * com.azure.cosmos.ConsistencyLevel} is {@link com.azure.cosmos.ConsistencyLevel#EVENTUAL} or {@link com.azure.cosmos.ConsistencyLevel#SESSION}, responses from the\n * integrated cache are guaranteed to be no staler than value indicated by this maxIntegratedCacheStaleness. When the\n * consistency level is not set, this property is ignored.\n *\n *

Default value is null

\n *\n *

Cache Staleness is supported in milliseconds granularity. Anything smaller than milliseconds will be ignored.

\n */\n maxIntegratedCacheStalenessInMs?: number;\n\n /**\n * Priority Level (Low/High) for each request.\n * Low priority requests are always throttled before any high priority requests.\n *\n *

Default value is null. By default all requests are of High priority

\n */\n priorityLevel?: PriorityLevel;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts new file mode 100644 index 000000000..47e3f2f96 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts @@ -0,0 +1,9 @@ +/** + * @hidden + */ +export type StatusCode = number; +/** + * @hidden + */ +export type SubStatusCode = number; +//# sourceMappingURL=StatusCodes.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts.map new file mode 100644 index 000000000..ba90b67cd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"StatusCodes.d.ts","sourceRoot":"","sources":["../../../src/request/StatusCodes.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAChC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js new file mode 100644 index 000000000..d8bafb177 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=StatusCodes.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js.map new file mode 100644 index 000000000..c2ccb6d7d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/StatusCodes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"StatusCodes.js","sourceRoot":"","sources":["../../../src/request/StatusCodes.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @hidden\n */\nexport type StatusCode = number;\n/**\n * @hidden\n */\nexport type SubStatusCode = number;\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts new file mode 100644 index 000000000..a637179e2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts @@ -0,0 +1,9 @@ +/** + * @hidden + */ +export declare const TimeoutErrorCode = "TimeoutError"; +export declare class TimeoutError extends Error { + readonly code: string; + constructor(message?: string); +} +//# sourceMappingURL=TimeoutError.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts.map new file mode 100644 index 000000000..24d0c9ab4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"TimeoutError.d.ts","sourceRoot":"","sources":["../../../src/request/TimeoutError.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAE/C,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,MAAM,CAAoB;gBACpC,OAAO,GAAE,MAAwB;CAI9C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js new file mode 100644 index 000000000..59d69a158 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +export const TimeoutErrorCode = "TimeoutError"; +export class TimeoutError extends Error { + constructor(message = "Timeout Error") { + super(message); + this.code = TimeoutErrorCode; + this.name = TimeoutErrorCode; + } +} +//# sourceMappingURL=TimeoutError.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js.map new file mode 100644 index 000000000..b9934d237 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/TimeoutError.js.map @@ -0,0 +1 @@ +{"version":3,"file":"TimeoutError.js","sourceRoot":"","sources":["../../../src/request/TimeoutError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,MAAM,OAAO,YAAa,SAAQ,KAAK;IAErC,YAAY,UAAkB,eAAe;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QAFD,SAAI,GAAW,gBAAgB,CAAC;QAG9C,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * @hidden\n */\nexport const TimeoutErrorCode = \"TimeoutError\";\n\nexport class TimeoutError extends Error {\n public readonly code: string = TimeoutErrorCode;\n constructor(message: string = \"Timeout Error\") {\n super(message);\n this.name = TimeoutErrorCode;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts new file mode 100644 index 000000000..78046f50c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts @@ -0,0 +1,11 @@ +/// +import { Agent } from "http"; +/** + * @hidden + */ +export declare let defaultHttpAgent: Agent; +/** + * @hidden + */ +export declare let defaultHttpsAgent: Agent; +//# sourceMappingURL=defaultAgent.browser.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts.map new file mode 100644 index 000000000..af924a87b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultAgent.browser.d.ts","sourceRoot":"","sources":["../../../src/request/defaultAgent.browser.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B;;GAEG;AACH,eAAO,IAAI,gBAAgB,EAAE,KAAK,CAAC;AACnC;;GAEG;AACH,eAAO,IAAI,iBAAiB,EAAE,KAAK,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js new file mode 100644 index 000000000..50fd69a41 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js @@ -0,0 +1,9 @@ +/** + * @hidden + */ +export let defaultHttpAgent; +/** + * @hidden + */ +export let defaultHttpsAgent; +//# sourceMappingURL=defaultAgent.browser.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js.map new file mode 100644 index 000000000..8f5b37551 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultAgent.browser.js","sourceRoot":"","sources":["../../../src/request/defaultAgent.browser.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,IAAI,gBAAuB,CAAC;AACnC;;GAEG;AACH,MAAM,CAAC,IAAI,iBAAwB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Agent } from \"http\";\n/**\n * @hidden\n */\nexport let defaultHttpAgent: Agent;\n/**\n * @hidden\n */\nexport let defaultHttpsAgent: Agent;\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts new file mode 100644 index 000000000..84f9dceca --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts @@ -0,0 +1,7 @@ +/// +import { Agent } from "http"; +/** + * @hidden + */ +export declare let defaultHttpsAgent: Agent; +//# sourceMappingURL=defaultAgent.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts.map new file mode 100644 index 000000000..dd0cfb056 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultAgent.d.ts","sourceRoot":"","sources":["../../../src/request/defaultAgent.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B;;GAEG;AACH,eAAO,IAAI,iBAAiB,EAAE,KAAK,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js new file mode 100644 index 000000000..e7d4ae266 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js @@ -0,0 +1,28 @@ +/** + * @hidden + */ +export let defaultHttpsAgent; +const https = require("https"); // eslint-disable-line @typescript-eslint/no-require-imports +const tls = require("tls"); // eslint-disable-line @typescript-eslint/no-require-imports +// minVersion only available in Node 10+ +if (tls.DEFAULT_MIN_VERSION) { + defaultHttpsAgent = new https.Agent({ + keepAlive: true, + minVersion: "TLSv1.2", + }); +} +else { + // Remove when Node 8 support has been dropped + defaultHttpsAgent = new https.Agent({ + keepAlive: true, + secureProtocol: "TLSv1_2_method", + }); +} +const http = require("http"); // eslint-disable-line @typescript-eslint/no-require-imports +/** + * @internal + */ +export const defaultHttpAgent = new http.Agent({ + keepAlive: true, +}); +//# sourceMappingURL=defaultAgent.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js.map new file mode 100644 index 000000000..b403aa747 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/defaultAgent.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultAgent.js","sourceRoot":"","sources":["../../../src/request/defaultAgent.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,CAAC,IAAI,iBAAwB,CAAC;AAEpC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,4DAA4D;AAC5F,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,4DAA4D;AAExF,wCAAwC;AACxC,IAAI,GAAG,CAAC,mBAAmB,EAAE;IAC3B,iBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;QAClC,SAAS,EAAE,IAAI;QACf,UAAU,EAAE,SAAS;KACtB,CAAC,CAAC;CACJ;KAAM;IACL,8CAA8C;IAC9C,iBAAiB,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;QAClC,SAAS,EAAE,IAAI;QACf,cAAc,EAAE,gBAAgB;KACjC,CAAC,CAAC;CACJ;AACD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,4DAA4D;AAC1F;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAU,IAAI,IAAI,CAAC,KAAK,CAAC;IACpD,SAAS,EAAE,IAAI;CAChB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Agent } from \"http\";\n\n/**\n * @hidden\n */\nexport let defaultHttpsAgent: Agent;\n\nconst https = require(\"https\"); // eslint-disable-line @typescript-eslint/no-require-imports\nconst tls = require(\"tls\"); // eslint-disable-line @typescript-eslint/no-require-imports\n\n// minVersion only available in Node 10+\nif (tls.DEFAULT_MIN_VERSION) {\n defaultHttpsAgent = new https.Agent({\n keepAlive: true,\n minVersion: \"TLSv1.2\",\n });\n} else {\n // Remove when Node 8 support has been dropped\n defaultHttpsAgent = new https.Agent({\n keepAlive: true,\n secureProtocol: \"TLSv1_2_method\",\n });\n}\nconst http = require(\"http\"); // eslint-disable-line @typescript-eslint/no-require-imports\n/**\n * @internal\n */\nexport const defaultHttpAgent: Agent = new http.Agent({\n keepAlive: true,\n});\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts new file mode 100644 index 000000000..2ec892755 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts @@ -0,0 +1,13 @@ +export { ErrorResponse, ErrorBody, PartitionedQueryExecutionInfo, QueryInfo, QueryRange, AggregateType, GroupByExpressions, GroupByAliasToAggregateType, } from "./ErrorResponse"; +export { FeedOptions } from "./FeedOptions"; +export { RequestOptions } from "./RequestOptions"; +export { Response } from "./Response"; +export { ResourceResponse } from "./ResourceResponse"; +export { SharedOptions } from "./SharedOptions"; +export { StatusCode, SubStatusCode } from "./StatusCodes"; +export { FeedResponse } from "./FeedResponse"; +export { RequestContext } from "./RequestContext"; +export { TimeoutError } from "./TimeoutError"; +export { QueryOperationOptions } from "./OperationOptions"; +export { RUCapPerOperationExceededError } from "./RUCapPerOperationExceededError"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts.map new file mode 100644 index 000000000..2af553cd2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/request/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,aAAa,EACb,SAAS,EACT,6BAA6B,EAC7B,SAAS,EACT,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,2BAA2B,GAC5B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.js new file mode 100644 index 000000000..1d1238828 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export { ErrorResponse, } from "./ErrorResponse"; +export { ResourceResponse } from "./ResourceResponse"; +export { FeedResponse } from "./FeedResponse"; +export { TimeoutError } from "./TimeoutError"; +export { RUCapPerOperationExceededError } from "./RUCapPerOperationExceededError"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.js.map new file mode 100644 index 000000000..381900816 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/request/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EACL,aAAa,GAQd,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport {\n ErrorResponse,\n ErrorBody,\n PartitionedQueryExecutionInfo,\n QueryInfo,\n QueryRange,\n AggregateType,\n GroupByExpressions,\n GroupByAliasToAggregateType,\n} from \"./ErrorResponse\";\nexport { FeedOptions } from \"./FeedOptions\";\nexport { RequestOptions } from \"./RequestOptions\";\nexport { Response } from \"./Response\";\nexport { ResourceResponse } from \"./ResourceResponse\";\nexport { SharedOptions } from \"./SharedOptions\";\nexport { StatusCode, SubStatusCode } from \"./StatusCodes\";\nexport { FeedResponse } from \"./FeedResponse\";\nexport { RequestContext } from \"./RequestContext\";\nexport { TimeoutError } from \"./TimeoutError\";\nexport { QueryOperationOptions } from \"./OperationOptions\";\nexport { RUCapPerOperationExceededError } from \"./RUCapPerOperationExceededError\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts new file mode 100644 index 000000000..53e53bfb3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts @@ -0,0 +1,29 @@ +/// +import { HTTPMethod, ResourceType } from "../common"; +import { CosmosClientOptions } from "../CosmosClientOptions"; +import { PartitionKeyInternal } from "../documents"; +import { CosmosHeaders } from "../queryExecutionContext"; +import { FeedOptions, RequestOptions } from "./index"; +/** @hidden */ +export declare function bodyFromData(data: Buffer | string | Record): string; +/** + * @hidden + */ +interface GetHeadersOptions { + clientOptions: CosmosClientOptions; + defaultHeaders: CosmosHeaders; + verb: HTTPMethod; + path: string; + resourceId: string; + resourceType: ResourceType; + options: RequestOptions & FeedOptions; + partitionKeyRangeId?: string; + useMultipleWriteLocations?: boolean; + partitionKey?: PartitionKeyInternal; +} +/** + * @hidden + */ +export declare function getHeaders({ clientOptions, defaultHeaders, verb, path, resourceId, resourceType, options, partitionKeyRangeId, useMultipleWriteLocations, partitionKey, }: GetHeadersOptions): Promise; +export {}; +//# sourceMappingURL=request.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts.map new file mode 100644 index 000000000..3f54c060a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../../src/request/request.ts"],"names":[],"mappings":";AAGA,OAAO,EAAa,UAAU,EAAkC,YAAY,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAetD,cAAc;AACd,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAKpF;AAED;;GAEG;AACH,UAAU,iBAAiB;IACzB,aAAa,EAAE,mBAAmB,CAAC;IACnC,cAAc,EAAE,aAAa,CAAC;IAC9B,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,OAAO,EAAE,cAAc,GAAG,WAAW,CAAC;IACtC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC;AAID;;GAEG;AACH,wBAAsB,UAAU,CAAC,EAC/B,aAAa,EACb,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,OAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,YAAY,GACb,EAAE,iBAAiB,GAAG,OAAO,CAAC,aAAa,CAAC,CA0J5C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/request.js b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.js new file mode 100644 index 000000000..b18d35a3d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.js @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { setAuthorizationHeader } from "../auth"; +import { Constants, HTTPMethod, jsonStringifyAndEscapeNonASCII, ResourceType } from "../common"; +import { defaultLogger } from "../common/logger"; +// ---------------------------------------------------------------------------- +// Utility methods +// +/** @hidden */ +function javaScriptFriendlyJSONStringify(s) { + // two line terminators (Line separator and Paragraph separator) are not needed to be escaped in JSON + // but are needed to be escaped in JavaScript. + return JSON.stringify(s) + .replace(/\u2028/g, "\\u2028") + .replace(/\u2029/g, "\\u2029"); +} +/** @hidden */ +export function bodyFromData(data) { + if (typeof data === "object") { + return javaScriptFriendlyJSONStringify(data); + } + return data; +} +const JsonContentType = "application/json"; +/** + * @hidden + */ +export async function getHeaders({ clientOptions, defaultHeaders, verb, path, resourceId, resourceType, options = {}, partitionKeyRangeId, useMultipleWriteLocations, partitionKey, }) { + const headers = Object.assign({ [Constants.HttpHeaders.ResponseContinuationTokenLimitInKB]: 1, [Constants.HttpHeaders.EnableCrossPartitionQuery]: true }, defaultHeaders); + if (useMultipleWriteLocations) { + headers[Constants.HttpHeaders.ALLOW_MULTIPLE_WRITES] = true; + } + if (options.continuationTokenLimitInKB) { + headers[Constants.HttpHeaders.ResponseContinuationTokenLimitInKB] = + options.continuationTokenLimitInKB; + } + if (options.continuationToken) { + headers[Constants.HttpHeaders.Continuation] = options.continuationToken; + } + else if (options.continuation) { + headers[Constants.HttpHeaders.Continuation] = options.continuation; + } + if (options.preTriggerInclude) { + headers[Constants.HttpHeaders.PreTriggerInclude] = + options.preTriggerInclude.constructor === Array + ? options.preTriggerInclude.join(",") + : options.preTriggerInclude; + } + if (options.postTriggerInclude) { + headers[Constants.HttpHeaders.PostTriggerInclude] = + options.postTriggerInclude.constructor === Array + ? options.postTriggerInclude.join(",") + : options.postTriggerInclude; + } + if (options.offerType) { + headers[Constants.HttpHeaders.OfferType] = options.offerType; + } + if (options.offerThroughput) { + headers[Constants.HttpHeaders.OfferThroughput] = options.offerThroughput; + } + if (options.maxItemCount) { + headers[Constants.HttpHeaders.PageSize] = options.maxItemCount; + } + if (options.accessCondition) { + if (options.accessCondition.type === "IfMatch") { + headers[Constants.HttpHeaders.IfMatch] = options.accessCondition.condition; + } + else { + headers[Constants.HttpHeaders.IfNoneMatch] = options.accessCondition.condition; + } + } + if (options.useIncrementalFeed) { + headers[Constants.HttpHeaders.A_IM] = "Incremental Feed"; + } + if (options.indexingDirective) { + headers[Constants.HttpHeaders.IndexingDirective] = options.indexingDirective; + } + if (options.consistencyLevel) { + headers[Constants.HttpHeaders.ConsistencyLevel] = options.consistencyLevel; + } + if (options.priorityLevel) { + headers[Constants.HttpHeaders.PriorityLevel] = options.priorityLevel; + } + if (options.maxIntegratedCacheStalenessInMs && resourceType === ResourceType.item) { + if (typeof options.maxIntegratedCacheStalenessInMs === "number") { + headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] = + options.maxIntegratedCacheStalenessInMs.toString(); + } + else { + defaultLogger.error(`RangeError: maxIntegratedCacheStalenessInMs "${options.maxIntegratedCacheStalenessInMs}" is not a valid parameter.`); + headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] = "null"; + } + } + if (options.resourceTokenExpirySeconds) { + headers[Constants.HttpHeaders.ResourceTokenExpiry] = options.resourceTokenExpirySeconds; + } + if (options.sessionToken) { + headers[Constants.HttpHeaders.SessionToken] = options.sessionToken; + } + if (options.enableScanInQuery) { + headers[Constants.HttpHeaders.EnableScanInQuery] = options.enableScanInQuery; + } + if (options.populateQuotaInfo) { + headers[Constants.HttpHeaders.PopulateQuotaInfo] = options.populateQuotaInfo; + } + if (options.populateQueryMetrics) { + headers[Constants.HttpHeaders.PopulateQueryMetrics] = options.populateQueryMetrics; + } + if (options.maxDegreeOfParallelism !== undefined) { + headers[Constants.HttpHeaders.ParallelizeCrossPartitionQuery] = true; + } + if (options.populateQuotaInfo) { + headers[Constants.HttpHeaders.PopulateQuotaInfo] = true; + } + if (partitionKey !== undefined && !headers[Constants.HttpHeaders.PartitionKey]) { + headers[Constants.HttpHeaders.PartitionKey] = jsonStringifyAndEscapeNonASCII(partitionKey); + } + if (clientOptions.key || clientOptions.tokenProvider) { + headers[Constants.HttpHeaders.XDate] = new Date().toUTCString(); + } + if (verb === HTTPMethod.post || verb === HTTPMethod.put) { + if (!headers[Constants.HttpHeaders.ContentType]) { + headers[Constants.HttpHeaders.ContentType] = JsonContentType; + } + } + if (!headers[Constants.HttpHeaders.Accept]) { + headers[Constants.HttpHeaders.Accept] = JsonContentType; + } + if (partitionKeyRangeId !== undefined) { + headers[Constants.HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId; + } + if (options.enableScriptLogging) { + headers[Constants.HttpHeaders.EnableScriptLogging] = options.enableScriptLogging; + } + if (options.disableRUPerMinuteUsage) { + headers[Constants.HttpHeaders.DisableRUPerMinuteUsage] = true; + } + if (options.populateIndexMetrics) { + headers[Constants.HttpHeaders.PopulateIndexMetrics] = options.populateIndexMetrics; + } + if (clientOptions.key || + clientOptions.resourceTokens || + clientOptions.tokenProvider || + clientOptions.permissionFeed) { + await setAuthorizationHeader(clientOptions, verb, path, resourceId, resourceType, headers); + } + return headers; +} +//# sourceMappingURL=request.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/request/request.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.js.map new file mode 100644 index 000000000..c3f0b03b4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/request/request.js.map @@ -0,0 +1 @@ +{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/request/request.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,8BAA8B,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAKhG,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,+EAA+E;AAC/E,kBAAkB;AAClB,EAA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CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,eAAe,CAAC;SAC9D;KACF;IAED,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;QAC1C,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC;KACzD;IAED,IAAI,mBAAmB,KAAK,SAAS,EAAE;QACrC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAC;KAC1E;IAED,IAAI,OAAO,CAAC,mBAAmB,EAAE;QAC/B,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC;KAClF;IAED,IAAI,OAAO,CAAC,uBAAuB,EAAE;QACnC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,uBAAuB,CAAC,GAAG,IAAI,CAAC;KAC/D;IAED,IAAI,OAAO,CAAC,oBAAoB,EAAE;QAChC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC;KACpF;IAED,IACE,aAAa,CAAC,GAAG;QACjB,aAAa,CAAC,cAAc;QAC5B,aAAa,CAAC,aAAa;QAC3B,aAAa,CAAC,cAAc,EAC5B;QACA,MAAM,sBAAsB,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;KAC5F;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { setAuthorizationHeader } from \"../auth\";\nimport { Constants, HTTPMethod, jsonStringifyAndEscapeNonASCII, ResourceType } from \"../common\";\nimport { CosmosClientOptions } from \"../CosmosClientOptions\";\nimport { PartitionKeyInternal } from \"../documents\";\nimport { CosmosHeaders } from \"../queryExecutionContext\";\nimport { FeedOptions, RequestOptions } from \"./index\";\nimport { defaultLogger } from \"../common/logger\";\n// ----------------------------------------------------------------------------\n// Utility methods\n//\n\n/** @hidden */\nfunction javaScriptFriendlyJSONStringify(s: unknown): string {\n // two line terminators (Line separator and Paragraph separator) are not needed to be escaped in JSON\n // but are needed to be escaped in JavaScript.\n return JSON.stringify(s)\n .replace(/\\u2028/g, \"\\\\u2028\")\n .replace(/\\u2029/g, \"\\\\u2029\");\n}\n\n/** @hidden */\nexport function bodyFromData(data: Buffer | string | Record): string {\n if (typeof data === \"object\") {\n return javaScriptFriendlyJSONStringify(data);\n }\n return data;\n}\n\n/**\n * @hidden\n */\ninterface GetHeadersOptions {\n clientOptions: CosmosClientOptions;\n defaultHeaders: CosmosHeaders;\n verb: HTTPMethod;\n path: string;\n resourceId: string;\n resourceType: ResourceType;\n options: RequestOptions & FeedOptions;\n partitionKeyRangeId?: string;\n useMultipleWriteLocations?: boolean;\n partitionKey?: PartitionKeyInternal;\n}\n\nconst JsonContentType = \"application/json\";\n\n/**\n * @hidden\n */\nexport async function getHeaders({\n clientOptions,\n defaultHeaders,\n verb,\n path,\n resourceId,\n resourceType,\n options = {},\n partitionKeyRangeId,\n useMultipleWriteLocations,\n partitionKey,\n}: GetHeadersOptions): Promise {\n const headers: CosmosHeaders = {\n [Constants.HttpHeaders.ResponseContinuationTokenLimitInKB]: 1,\n [Constants.HttpHeaders.EnableCrossPartitionQuery]: true,\n ...defaultHeaders,\n };\n\n if (useMultipleWriteLocations) {\n headers[Constants.HttpHeaders.ALLOW_MULTIPLE_WRITES] = true;\n }\n\n if (options.continuationTokenLimitInKB) {\n headers[Constants.HttpHeaders.ResponseContinuationTokenLimitInKB] =\n options.continuationTokenLimitInKB;\n }\n if (options.continuationToken) {\n headers[Constants.HttpHeaders.Continuation] = options.continuationToken;\n } else if (options.continuation) {\n headers[Constants.HttpHeaders.Continuation] = options.continuation;\n }\n\n if (options.preTriggerInclude) {\n headers[Constants.HttpHeaders.PreTriggerInclude] =\n options.preTriggerInclude.constructor === Array\n ? (options.preTriggerInclude as string[]).join(\",\")\n : (options.preTriggerInclude as string);\n }\n\n if (options.postTriggerInclude) {\n headers[Constants.HttpHeaders.PostTriggerInclude] =\n options.postTriggerInclude.constructor === Array\n ? (options.postTriggerInclude as string[]).join(\",\")\n : (options.postTriggerInclude as string);\n }\n\n if (options.offerType) {\n headers[Constants.HttpHeaders.OfferType] = options.offerType;\n }\n\n if (options.offerThroughput) {\n headers[Constants.HttpHeaders.OfferThroughput] = options.offerThroughput;\n }\n\n if (options.maxItemCount) {\n headers[Constants.HttpHeaders.PageSize] = options.maxItemCount;\n }\n\n if (options.accessCondition) {\n if (options.accessCondition.type === \"IfMatch\") {\n headers[Constants.HttpHeaders.IfMatch] = options.accessCondition.condition;\n } else {\n headers[Constants.HttpHeaders.IfNoneMatch] = options.accessCondition.condition;\n }\n }\n\n if (options.useIncrementalFeed) {\n headers[Constants.HttpHeaders.A_IM] = \"Incremental Feed\";\n }\n\n if (options.indexingDirective) {\n headers[Constants.HttpHeaders.IndexingDirective] = options.indexingDirective;\n }\n\n if (options.consistencyLevel) {\n headers[Constants.HttpHeaders.ConsistencyLevel] = options.consistencyLevel;\n }\n\n if (options.priorityLevel) {\n headers[Constants.HttpHeaders.PriorityLevel] = options.priorityLevel;\n }\n\n if (options.maxIntegratedCacheStalenessInMs && resourceType === ResourceType.item) {\n if (typeof options.maxIntegratedCacheStalenessInMs === \"number\") {\n headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] =\n options.maxIntegratedCacheStalenessInMs.toString();\n } else {\n defaultLogger.error(\n `RangeError: maxIntegratedCacheStalenessInMs \"${options.maxIntegratedCacheStalenessInMs}\" is not a valid parameter.`,\n );\n headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] = \"null\";\n }\n }\n\n if (options.resourceTokenExpirySeconds) {\n headers[Constants.HttpHeaders.ResourceTokenExpiry] = options.resourceTokenExpirySeconds;\n }\n\n if (options.sessionToken) {\n headers[Constants.HttpHeaders.SessionToken] = options.sessionToken;\n }\n\n if (options.enableScanInQuery) {\n headers[Constants.HttpHeaders.EnableScanInQuery] = options.enableScanInQuery;\n }\n\n if (options.populateQuotaInfo) {\n headers[Constants.HttpHeaders.PopulateQuotaInfo] = options.populateQuotaInfo;\n }\n\n if (options.populateQueryMetrics) {\n headers[Constants.HttpHeaders.PopulateQueryMetrics] = options.populateQueryMetrics;\n }\n\n if (options.maxDegreeOfParallelism !== undefined) {\n headers[Constants.HttpHeaders.ParallelizeCrossPartitionQuery] = true;\n }\n\n if (options.populateQuotaInfo) {\n headers[Constants.HttpHeaders.PopulateQuotaInfo] = true;\n }\n\n if (partitionKey !== undefined && !headers[Constants.HttpHeaders.PartitionKey]) {\n headers[Constants.HttpHeaders.PartitionKey] = jsonStringifyAndEscapeNonASCII(partitionKey);\n }\n\n if (clientOptions.key || clientOptions.tokenProvider) {\n headers[Constants.HttpHeaders.XDate] = new Date().toUTCString();\n }\n\n if (verb === HTTPMethod.post || verb === HTTPMethod.put) {\n if (!headers[Constants.HttpHeaders.ContentType]) {\n headers[Constants.HttpHeaders.ContentType] = JsonContentType;\n }\n }\n\n if (!headers[Constants.HttpHeaders.Accept]) {\n headers[Constants.HttpHeaders.Accept] = JsonContentType;\n }\n\n if (partitionKeyRangeId !== undefined) {\n headers[Constants.HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId;\n }\n\n if (options.enableScriptLogging) {\n headers[Constants.HttpHeaders.EnableScriptLogging] = options.enableScriptLogging;\n }\n\n if (options.disableRUPerMinuteUsage) {\n headers[Constants.HttpHeaders.DisableRUPerMinuteUsage] = true;\n }\n\n if (options.populateIndexMetrics) {\n headers[Constants.HttpHeaders.PopulateIndexMetrics] = options.populateIndexMetrics;\n }\n\n if (\n clientOptions.key ||\n clientOptions.resourceTokens ||\n clientOptions.tokenProvider ||\n clientOptions.permissionFeed\n ) {\n await setAuthorizationHeader(clientOptions, verb, path, resourceId, resourceType, headers);\n }\n return headers;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts new file mode 100644 index 000000000..981d19954 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts @@ -0,0 +1,11 @@ +export interface RetryContext { + retryCount: number; + retryRequestOnPreferredLocations?: boolean; + clearSessionTokenNotAvailable?: boolean; + /** + * This variable determines the index of specific server in the preferred location list + * where subsequent retry requests should be directed. + */ + retryLocationServerIndex?: number; +} +//# sourceMappingURL=RetryContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts.map new file mode 100644 index 000000000..010f2e7bb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"RetryContext.d.ts","sourceRoot":"","sources":["../../../src/retry/RetryContext.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC,CAAC,EAAE,OAAO,CAAC;IAC3C,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACnC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js new file mode 100644 index 000000000..6e9b0dc22 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=RetryContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js.map new file mode 100644 index 000000000..5074ebad2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RetryContext.js","sourceRoot":"","sources":["../../../src/retry/RetryContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport interface RetryContext {\n retryCount: number;\n retryRequestOnPreferredLocations?: boolean;\n clearSessionTokenNotAvailable?: boolean;\n /**\n * This variable determines the index of specific server in the preferred location list\n * where subsequent retry requests should be directed.\n */\n retryLocationServerIndex?: number;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts new file mode 100644 index 000000000..e414db82d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts @@ -0,0 +1,11 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { ErrorResponse } from "../request"; +import { RetryContext } from "./RetryContext"; +/** + * @hidden + */ +export interface RetryPolicy { + retryAfterInMs: number; + shouldRetry: (errorResponse: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string) => Promise; +} +//# sourceMappingURL=RetryPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts.map new file mode 100644 index 000000000..e4ed81c34 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"RetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/RetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,CACX,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,sBAAsB,EACtC,YAAY,CAAC,EAAE,YAAY,EAC3B,gBAAgB,CAAC,EAAE,MAAM,KACtB,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;CAC3C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js new file mode 100644 index 000000000..618329a04 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=RetryPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js.map new file mode 100644 index 000000000..ff5d5d3b4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/RetryPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"RetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/RetryPolicy.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { ErrorResponse } from \"../request\";\nimport { RetryContext } from \"./RetryContext\";\n\n/**\n * @hidden\n */\nexport interface RetryPolicy {\n retryAfterInMs: number;\n shouldRetry: (\n errorResponse: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n ) => Promise;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts new file mode 100644 index 000000000..5bba7798e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts @@ -0,0 +1,21 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { OperationType } from "../common"; +import { ErrorResponse } from "../request"; +import { RetryPolicy } from "./RetryPolicy"; +/** + * This class implements the default connection retry policy for requests. + * @hidden + */ +export declare class DefaultRetryPolicy implements RetryPolicy { + private operationType; + private maxTries; + private currentRetryAttemptCount; + retryAfterInMs: number; + constructor(operationType: OperationType); + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal): Promise; +} +//# sourceMappingURL=defaultRetryPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts.map new file mode 100644 index 000000000..dcd184075 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/defaultRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAqH5C;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IAKxC,OAAO,CAAC,aAAa;IAJjC,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,wBAAwB,CAAa;IACtC,cAAc,EAAE,MAAM,CAAQ;gBAEjB,aAAa,EAAE,aAAa;IAChD;;;OAGG;IACU,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,OAAO,CAAC;CAapB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js new file mode 100644 index 000000000..317a87aee --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js @@ -0,0 +1,139 @@ +import { OperationType } from "../common"; +import { TimeoutErrorCode } from "../request/TimeoutError"; +/** + * @hidden + */ +// Windows Socket Error Codes +const WindowsInterruptedFunctionCall = 10004; +/** + * @hidden + */ +const WindowsFileHandleNotValid = 10009; +/** + * @hidden + */ +const WindowsPermissionDenied = 10013; +/** + * @hidden + */ +const WindowsBadAddress = 10014; +/** + * @hidden + */ +const WindowsInvalidArgumnet = 10022; +/** + * @hidden + */ +const WindowsResourceTemporarilyUnavailable = 10035; +/** + * @hidden + */ +const WindowsOperationNowInProgress = 10036; +/** + * @hidden + */ +const WindowsAddressAlreadyInUse = 10048; +/** + * @hidden + */ +const WindowsConnectionResetByPeer = 10054; +/** + * @hidden + */ +const WindowsCannotSendAfterSocketShutdown = 10058; +/** + * @hidden + */ +const WindowsConnectionTimedOut = 10060; +/** + * @hidden + */ +const WindowsConnectionRefused = 10061; +/** + * @hidden + */ +const WindowsNameTooLong = 10063; +/** + * @hidden + */ +const WindowsHostIsDown = 10064; +/** + * @hidden + */ +const WindowsNoRouteTohost = 10065; +/** + * @hidden + */ +// Linux Error Codes +/** + * @hidden + */ +const LinuxConnectionReset = "ECONNRESET"; +// Node Error Codes +/** + * @hidden + */ +const BrokenPipe = "EPIPE"; +/** + * @hidden + */ +const CONNECTION_ERROR_CODES = [ + WindowsInterruptedFunctionCall, + WindowsFileHandleNotValid, + WindowsPermissionDenied, + WindowsBadAddress, + WindowsInvalidArgumnet, + WindowsResourceTemporarilyUnavailable, + WindowsOperationNowInProgress, + WindowsAddressAlreadyInUse, + WindowsConnectionResetByPeer, + WindowsCannotSendAfterSocketShutdown, + WindowsConnectionTimedOut, + WindowsConnectionRefused, + WindowsNameTooLong, + WindowsHostIsDown, + WindowsNoRouteTohost, + LinuxConnectionReset, + TimeoutErrorCode, + BrokenPipe, +]; +/** + * @hidden + */ +function needsRetry(operationType, code) { + if ((operationType === OperationType.Read || operationType === OperationType.Query) && + CONNECTION_ERROR_CODES.indexOf(code) !== -1) { + return true; + } + else { + return false; + } +} +/** + * This class implements the default connection retry policy for requests. + * @hidden + */ +export class DefaultRetryPolicy { + constructor(operationType) { + this.operationType = operationType; + this.maxTries = 10; + this.currentRetryAttemptCount = 0; + this.retryAfterInMs = 1000; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + async shouldRetry(err, diagnosticNode) { + if (err) { + if (this.currentRetryAttemptCount < this.maxTries && + needsRetry(this.operationType, err.code)) { + diagnosticNode.addData({ successfulRetryPolicy: "default" }); + this.currentRetryAttemptCount++; + return true; + } + } + return false; + } +} +//# sourceMappingURL=defaultRetryPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js.map new file mode 100644 index 000000000..6dba06b9a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/defaultRetryPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"defaultRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/defaultRetryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D;;GAEG;AACH,6BAA6B;AAC7B,MAAM,8BAA8B,GAAG,K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B;IACrE,IACE,CAAC,aAAa,KAAK,aAAa,CAAC,IAAI,IAAI,aAAa,KAAK,aAAa,CAAC,KAAK,CAAC;QAC/E,sBAAsB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAC3C;QACA,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAK7B,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAJxC,aAAQ,GAAW,EAAE,CAAC;QACtB,6BAAwB,GAAW,CAAC,CAAC;QACtC,mBAAc,GAAW,IAAI,CAAC;IAEc,CAAC;IACpD;;;OAGG;IACI,KAAK,CAAC,WAAW,CACtB,GAAkB,EAClB,cAAsC;QAEtC,IAAI,GAAG,EAAE;YACP,IACE,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,QAAQ;gBAC7C,UAAU,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,IAAI,CAAC,EACxC;gBACA,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC7D,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAChC,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { OperationType } from \"../common\";\nimport { ErrorResponse } from \"../request\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError\";\nimport { RetryPolicy } from \"./RetryPolicy\";\n\n/**\n * @hidden\n */\n// Windows Socket Error Codes\nconst WindowsInterruptedFunctionCall = 10004;\n/**\n * @hidden\n */\nconst WindowsFileHandleNotValid = 10009;\n/**\n * @hidden\n */\nconst WindowsPermissionDenied = 10013;\n/**\n * @hidden\n */\nconst WindowsBadAddress = 10014;\n/**\n * @hidden\n */\nconst WindowsInvalidArgumnet = 10022;\n/**\n * @hidden\n */\nconst WindowsResourceTemporarilyUnavailable = 10035;\n/**\n * @hidden\n */\nconst WindowsOperationNowInProgress = 10036;\n/**\n * @hidden\n */\nconst WindowsAddressAlreadyInUse = 10048;\n/**\n * @hidden\n */\nconst WindowsConnectionResetByPeer = 10054;\n/**\n * @hidden\n */\nconst WindowsCannotSendAfterSocketShutdown = 10058;\n/**\n * @hidden\n */\nconst WindowsConnectionTimedOut = 10060;\n/**\n * @hidden\n */\nconst WindowsConnectionRefused = 10061;\n/**\n * @hidden\n */\nconst WindowsNameTooLong = 10063;\n/**\n * @hidden\n */\nconst WindowsHostIsDown = 10064;\n/**\n * @hidden\n */\nconst WindowsNoRouteTohost = 10065;\n/**\n * @hidden\n */\n\n// Linux Error Codes\n/**\n * @hidden\n */\nconst LinuxConnectionReset = \"ECONNRESET\";\n\n// Node Error Codes\n/**\n * @hidden\n */\nconst BrokenPipe = \"EPIPE\";\n\n/**\n * @hidden\n */\nconst CONNECTION_ERROR_CODES = [\n WindowsInterruptedFunctionCall,\n WindowsFileHandleNotValid,\n WindowsPermissionDenied,\n WindowsBadAddress,\n WindowsInvalidArgumnet,\n WindowsResourceTemporarilyUnavailable,\n WindowsOperationNowInProgress,\n WindowsAddressAlreadyInUse,\n WindowsConnectionResetByPeer,\n WindowsCannotSendAfterSocketShutdown,\n WindowsConnectionTimedOut,\n WindowsConnectionRefused,\n WindowsNameTooLong,\n WindowsHostIsDown,\n WindowsNoRouteTohost,\n LinuxConnectionReset,\n TimeoutErrorCode,\n BrokenPipe,\n];\n\n/**\n * @hidden\n */\nfunction needsRetry(operationType: OperationType, code: number | string): boolean {\n if (\n (operationType === OperationType.Read || operationType === OperationType.Query) &&\n CONNECTION_ERROR_CODES.indexOf(code) !== -1\n ) {\n return true;\n } else {\n return false;\n }\n}\n\n/**\n * This class implements the default connection retry policy for requests.\n * @hidden\n */\nexport class DefaultRetryPolicy implements RetryPolicy {\n private maxTries: number = 10;\n private currentRetryAttemptCount: number = 0;\n public retryAfterInMs: number = 1000;\n\n constructor(private operationType: OperationType) {}\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n if (err) {\n if (\n this.currentRetryAttemptCount < this.maxTries &&\n needsRetry(this.operationType, err.code)\n ) {\n diagnosticNode.addData({ successfulRetryPolicy: \"default\" });\n this.currentRetryAttemptCount++;\n return true;\n }\n }\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts new file mode 100644 index 000000000..e83d9a579 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts @@ -0,0 +1,32 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { OperationType } from "../common"; +import { GlobalEndpointManager } from "../globalEndpointManager"; +import { ErrorResponse } from "../request"; +import { RetryContext } from "./RetryContext"; +import { RetryPolicy } from "./RetryPolicy"; +/** + * This class implements the retry policy for endpoint discovery. + * @hidden + */ +export declare class EndpointDiscoveryRetryPolicy implements RetryPolicy { + private globalEndpointManager; + private operationType; + /** Current retry attempt count. */ + currentRetryAttemptCount: number; + /** Retry interval in milliseconds. */ + retryAfterInMs: number; + /** Max number of retry attempts to perform. */ + private maxTries; + private static readonly maxTries; + private static readonly retryAfterInMs; + /** + * @param globalEndpointManager - The GlobalEndpointManager instance. + */ + constructor(globalEndpointManager: GlobalEndpointManager, operationType: OperationType); + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string): Promise; +} +//# sourceMappingURL=endpointDiscoveryRetryPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts.map new file mode 100644 index 000000000..4c1364090 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"endpointDiscoveryRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,4BAA6B,YAAW,WAAW;IAe5D,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,aAAa;IAfvB,mCAAmC;IAC5B,wBAAwB,EAAE,MAAM,CAAC;IACxC,sCAAsC;IAC/B,cAAc,EAAE,MAAM,CAAC;IAE9B,+CAA+C;IAC/C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAO;IACvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAQ;IAE9C;;OAEG;gBAEO,qBAAqB,EAAE,qBAAqB,EAC5C,aAAa,EAAE,aAAa;IAOtC;;;OAGG;IACU,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,EACtC,YAAY,CAAC,EAAE,YAAY,EAC3B,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;CAqCxC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js new file mode 100644 index 000000000..e25c777b2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js @@ -0,0 +1,50 @@ +import { isReadRequest } from "../common/helper"; +/** + * This class implements the retry policy for endpoint discovery. + * @hidden + */ +export class EndpointDiscoveryRetryPolicy { + /** + * @param globalEndpointManager - The GlobalEndpointManager instance. + */ + constructor(globalEndpointManager, operationType) { + this.globalEndpointManager = globalEndpointManager; + this.operationType = operationType; + this.maxTries = EndpointDiscoveryRetryPolicy.maxTries; + this.currentRetryAttemptCount = 0; + this.retryAfterInMs = EndpointDiscoveryRetryPolicy.retryAfterInMs; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) { + if (!err) { + return false; + } + if (!retryContext || !locationEndpoint) { + return false; + } + if (!this.globalEndpointManager.enableEndpointDiscovery) { + return false; + } + if (this.currentRetryAttemptCount >= this.maxTries) { + return false; + } + this.currentRetryAttemptCount++; + if (isReadRequest(this.operationType)) { + await this.globalEndpointManager.markCurrentLocationUnavailableForRead(diagnosticNode, locationEndpoint); + } + else { + await this.globalEndpointManager.markCurrentLocationUnavailableForWrite(diagnosticNode, locationEndpoint); + } + retryContext.retryCount = this.currentRetryAttemptCount; + retryContext.clearSessionTokenNotAvailable = false; + retryContext.retryRequestOnPreferredLocations = false; + diagnosticNode.addData({ successfulRetryPolicy: "endpointDiscovery" }); + return true; + } +} +EndpointDiscoveryRetryPolicy.maxTries = 120; // TODO: Constant? +EndpointDiscoveryRetryPolicy.retryAfterInMs = 1000; +//# sourceMappingURL=endpointDiscoveryRetryPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js.map new file mode 100644 index 000000000..0f3e496b2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/endpointDiscoveryRetryPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"endpointDiscoveryRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/endpointDiscoveryRetryPolicy.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAWvC;;OAEG;IACH,YACU,qBAA4C,EAC5C,aAA4B;QAD5B,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,kBAAa,GAAb,aAAa,CAAe;QAEpC,IAAI,CAAC,QAAQ,GAAG,4BAA4B,CAAC,QAAQ,CAAC;QACtD,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,cAAc,GAAG,4BAA4B,CAAC,cAAc,CAAC;IACpE,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,WAAW,CACtB,GAAkB,EAClB,cAAsC,EACtC,YAA2B,EAC3B,gBAAyB;QAEzB,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,YAAY,IAAI,CAAC,gBAAgB,EAAE;YACtC,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,uBAAuB,EAAE;YACvD,OAAO,KAAK,CAAC;SACd;QAED,IAAI,IAAI,CAAC,wBAAwB,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClD,OAAO,KAAK,CAAC;SACd;QAED,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAEhC,IAAI,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;YACrC,MAAM,IAAI,CAAC,qBAAqB,CAAC,qCAAqC,CACpE,cAAc,EACd,gBAAgB,CACjB,CAAC;SACH;aAAM;YACL,MAAM,IAAI,CAAC,qBAAqB,CAAC,sCAAsC,CACrE,cAAc,EACd,gBAAgB,CACjB,CAAC;SACH;QAED,YAAY,CAAC,UAAU,GAAG,IAAI,CAAC,wBAAwB,CAAC;QACxD,YAAY,CAAC,6BAA6B,GAAG,KAAK,CAAC;QACnD,YAAY,CAAC,gCAAgC,GAAG,KAAK,CAAC;QACtD,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC,CAAC;QACvE,OAAO,IAAI,CAAC;IACd,CAAC;;AA5DuB,qCAAQ,GAAG,GAAG,CAAC,CAAC,kBAAkB;AAClC,2CAAc,GAAG,IAAI,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { OperationType } from \"../common\";\nimport { isReadRequest } from \"../common/helper\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { ErrorResponse } from \"../request\";\nimport { RetryContext } from \"./RetryContext\";\nimport { RetryPolicy } from \"./RetryPolicy\";\n\n/**\n * This class implements the retry policy for endpoint discovery.\n * @hidden\n */\nexport class EndpointDiscoveryRetryPolicy implements RetryPolicy {\n /** Current retry attempt count. */\n public currentRetryAttemptCount: number;\n /** Retry interval in milliseconds. */\n public retryAfterInMs: number;\n\n /** Max number of retry attempts to perform. */\n private maxTries: number;\n private static readonly maxTries = 120; // TODO: Constant?\n private static readonly retryAfterInMs = 1000;\n\n /**\n * @param globalEndpointManager - The GlobalEndpointManager instance.\n */\n constructor(\n private globalEndpointManager: GlobalEndpointManager,\n private operationType: OperationType,\n ) {\n this.maxTries = EndpointDiscoveryRetryPolicy.maxTries;\n this.currentRetryAttemptCount = 0;\n this.retryAfterInMs = EndpointDiscoveryRetryPolicy.retryAfterInMs;\n }\n\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n ): Promise {\n if (!err) {\n return false;\n }\n\n if (!retryContext || !locationEndpoint) {\n return false;\n }\n\n if (!this.globalEndpointManager.enableEndpointDiscovery) {\n return false;\n }\n\n if (this.currentRetryAttemptCount >= this.maxTries) {\n return false;\n }\n\n this.currentRetryAttemptCount++;\n\n if (isReadRequest(this.operationType)) {\n await this.globalEndpointManager.markCurrentLocationUnavailableForRead(\n diagnosticNode,\n locationEndpoint,\n );\n } else {\n await this.globalEndpointManager.markCurrentLocationUnavailableForWrite(\n diagnosticNode,\n locationEndpoint,\n );\n }\n\n retryContext.retryCount = this.currentRetryAttemptCount;\n retryContext.clearSessionTokenNotAvailable = false;\n retryContext.retryRequestOnPreferredLocations = false;\n diagnosticNode.addData({ successfulRetryPolicy: \"endpointDiscovery\" });\n return true;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts new file mode 100644 index 000000000..3af8fab2c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts @@ -0,0 +1,7 @@ +export * from "./retryOptions"; +export * from "./endpointDiscoveryRetryPolicy"; +export * from "./resourceThrottleRetryPolicy"; +export * from "./sessionRetryPolicy"; +export * from "./retryUtility"; +export * from "./timeoutFailoverRetryPolicy"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts.map new file mode 100644 index 000000000..990cb6ef4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/retry/index.ts"],"names":[],"mappings":"AAEA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js new file mode 100644 index 000000000..340234d5b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export * from "./retryOptions"; +export * from "./endpointDiscoveryRetryPolicy"; +export * from "./resourceThrottleRetryPolicy"; +export * from "./sessionRetryPolicy"; +export * from "./retryUtility"; +export * from "./timeoutFailoverRetryPolicy"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js.map new file mode 100644 index 000000000..d079bc096 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/retry/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./retryOptions\";\nexport * from \"./endpointDiscoveryRetryPolicy\";\nexport * from \"./resourceThrottleRetryPolicy\";\nexport * from \"./sessionRetryPolicy\";\nexport * from \"./retryUtility\";\nexport * from \"./timeoutFailoverRetryPolicy\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts new file mode 100644 index 000000000..e4260efc9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts @@ -0,0 +1,32 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { ErrorResponse } from "../request"; +/** + * This class implements the resource throttle retry policy for requests. + * @hidden + */ +export declare class ResourceThrottleRetryPolicy { + private maxTries; + private fixedRetryIntervalInMs; + /** Current retry attempt count. */ + currentRetryAttemptCount: number; + /** Cummulative wait time in milliseconds for a request while the retries are happening. */ + cummulativeWaitTimeinMs: number; + /** Retry interval in milliseconds to wait before the next request will be sent. */ + retryAfterInMs: number; + /** Max wait time in milliseconds to wait for a request while the retries are happening. */ + private timeoutInMs; + /** + * @param maxTries - Max number of retries to be performed for a request. + * @param fixedRetryIntervalInMs - Fixed retry interval in milliseconds to wait between each + * retry ignoring the retryAfter returned as part of the response. + * @param timeoutInSeconds - Max wait time in seconds to wait for a request while the + * retries are happening. + */ + constructor(maxTries?: number, fixedRetryIntervalInMs?: number, timeoutInSeconds?: number); + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal): Promise; +} +//# sourceMappingURL=resourceThrottleRetryPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts.map new file mode 100644 index 000000000..9fbedaeff --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"resourceThrottleRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/resourceThrottleRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;;GAGG;AACH,qBAAa,2BAA2B;IAkBpC,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,sBAAsB;IAlBhC,mCAAmC;IAC5B,wBAAwB,EAAE,MAAM,CAAK;IAC5C,2FAA2F;IACpF,uBAAuB,EAAE,MAAM,CAAK;IAC3C,mFAAmF;IAC5E,cAAc,EAAE,MAAM,CAAK;IAElC,2FAA2F;IAC3F,OAAO,CAAC,WAAW,CAAS;IAC5B;;;;;;OAMG;gBAEO,QAAQ,GAAE,MAAU,EACpB,sBAAsB,GAAE,MAAU,EAC1C,gBAAgB,GAAE,MAAW;IAM/B;;;OAGG;IACU,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,OAAO,CAAC;CAsBpB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js new file mode 100644 index 000000000..fdc8a4275 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js @@ -0,0 +1,52 @@ +/** + * This class implements the resource throttle retry policy for requests. + * @hidden + */ +export class ResourceThrottleRetryPolicy { + /** + * @param maxTries - Max number of retries to be performed for a request. + * @param fixedRetryIntervalInMs - Fixed retry interval in milliseconds to wait between each + * retry ignoring the retryAfter returned as part of the response. + * @param timeoutInSeconds - Max wait time in seconds to wait for a request while the + * retries are happening. + */ + constructor(maxTries = 9, fixedRetryIntervalInMs = 0, timeoutInSeconds = 30) { + this.maxTries = maxTries; + this.fixedRetryIntervalInMs = fixedRetryIntervalInMs; + /** Current retry attempt count. */ + this.currentRetryAttemptCount = 0; + /** Cummulative wait time in milliseconds for a request while the retries are happening. */ + this.cummulativeWaitTimeinMs = 0; + /** Retry interval in milliseconds to wait before the next request will be sent. */ + this.retryAfterInMs = 0; + this.timeoutInMs = timeoutInSeconds * 1000; + this.currentRetryAttemptCount = 0; + this.cummulativeWaitTimeinMs = 0; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + async shouldRetry(err, diagnosticNode) { + // TODO: any custom error object + if (err) { + if (this.currentRetryAttemptCount < this.maxTries) { + this.currentRetryAttemptCount++; + this.retryAfterInMs = 0; + if (this.fixedRetryIntervalInMs) { + this.retryAfterInMs = this.fixedRetryIntervalInMs; + } + else if (err.retryAfterInMs) { + this.retryAfterInMs = err.retryAfterInMs; + } + if (this.cummulativeWaitTimeinMs < this.timeoutInMs) { + this.cummulativeWaitTimeinMs += this.retryAfterInMs; + diagnosticNode.addData({ successfulRetryPolicy: "resourceThrottle" }); + return true; + } + } + } + return false; + } +} +//# sourceMappingURL=resourceThrottleRetryPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js.map new file mode 100644 index 000000000..0b770d2cd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/resourceThrottleRetryPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"resourceThrottleRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/resourceThrottleRetryPolicy.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,2BAA2B;IAUtC;;;;;;OAMG;IACH,YACU,WAAmB,CAAC,EACpB,yBAAiC,CAAC,EAC1C,mBAA2B,EAAE;QAFrB,aAAQ,GAAR,QAAQ,CAAY;QACpB,2BAAsB,GAAtB,sBAAsB,CAAY;QAlB5C,mCAAmC;QAC5B,6BAAwB,GAAW,CAAC,CAAC;QAC5C,2FAA2F;QACpF,4BAAuB,GAAW,CAAC,CAAC;QAC3C,mFAAmF;QAC5E,mBAAc,GAAW,CAAC,CAAC;QAgBhC,IAAI,CAAC,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAAC;QAC3C,IAAI,CAAC,wBAAwB,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC;IACnC,CAAC;IACD;;;OAGG;IACI,KAAK,CAAC,WAAW,CACtB,GAAkB,EAClB,cAAsC;QAEtC,gCAAgC;QAChC,IAAI,GAAG,EAAE;YACP,IAAI,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC,QAAQ,EAAE;gBACjD,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAChC,IAAI,CAAC,cAAc,GAAG,CAAC,CAAC;gBAExB,IAAI,IAAI,CAAC,sBAAsB,EAAE;oBAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,sBAAsB,CAAC;iBACnD;qBAAM,IAAI,GAAG,CAAC,cAAc,EAAE;oBAC7B,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC,cAAc,CAAC;iBAC1C;gBAED,IAAI,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,WAAW,EAAE;oBACnD,IAAI,CAAC,uBAAuB,IAAI,IAAI,CAAC,cAAc,CAAC;oBACpD,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,CAAC,CAAC;oBACtE,OAAO,IAAI,CAAC;iBACb;aACF;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { ErrorResponse } from \"../request\";\n\n/**\n * This class implements the resource throttle retry policy for requests.\n * @hidden\n */\nexport class ResourceThrottleRetryPolicy {\n /** Current retry attempt count. */\n public currentRetryAttemptCount: number = 0;\n /** Cummulative wait time in milliseconds for a request while the retries are happening. */\n public cummulativeWaitTimeinMs: number = 0;\n /** Retry interval in milliseconds to wait before the next request will be sent. */\n public retryAfterInMs: number = 0;\n\n /** Max wait time in milliseconds to wait for a request while the retries are happening. */\n private timeoutInMs: number;\n /**\n * @param maxTries - Max number of retries to be performed for a request.\n * @param fixedRetryIntervalInMs - Fixed retry interval in milliseconds to wait between each\n * retry ignoring the retryAfter returned as part of the response.\n * @param timeoutInSeconds - Max wait time in seconds to wait for a request while the\n * retries are happening.\n */\n constructor(\n private maxTries: number = 9,\n private fixedRetryIntervalInMs: number = 0,\n timeoutInSeconds: number = 30,\n ) {\n this.timeoutInMs = timeoutInSeconds * 1000;\n this.currentRetryAttemptCount = 0;\n this.cummulativeWaitTimeinMs = 0;\n }\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n // TODO: any custom error object\n if (err) {\n if (this.currentRetryAttemptCount < this.maxTries) {\n this.currentRetryAttemptCount++;\n this.retryAfterInMs = 0;\n\n if (this.fixedRetryIntervalInMs) {\n this.retryAfterInMs = this.fixedRetryIntervalInMs;\n } else if (err.retryAfterInMs) {\n this.retryAfterInMs = err.retryAfterInMs;\n }\n\n if (this.cummulativeWaitTimeinMs < this.timeoutInMs) {\n this.cummulativeWaitTimeinMs += this.retryAfterInMs;\n diagnosticNode.addData({ successfulRetryPolicy: \"resourceThrottle\" });\n return true;\n }\n }\n }\n return false;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts new file mode 100644 index 000000000..87df0abc2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts @@ -0,0 +1,12 @@ +/** + * Represents the Retry policy assocated with throttled requests in the Azure Cosmos DB database service. + */ +export interface RetryOptions { + /** Max number of retries to be performed for a request. Default value 9. */ + maxRetryAttemptCount: number; + /** Fixed retry interval in milliseconds to wait between each retry ignoring the retryAfter returned as part of the response. */ + fixedRetryIntervalInMilliseconds: number; + /** Max wait time in seconds to wait for a request while the retries are happening. Default value 30 seconds. */ + maxWaitTimeInSeconds: number; +} +//# sourceMappingURL=retryOptions.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts.map new file mode 100644 index 000000000..2da9e0f2a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"retryOptions.d.ts","sourceRoot":"","sources":["../../../src/retry/retryOptions.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gIAAgI;IAChI,gCAAgC,EAAE,MAAM,CAAC;IACzC,gHAAgH;IAChH,oBAAoB,EAAE,MAAM,CAAC;CAC9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js new file mode 100644 index 000000000..5b8f771e0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=retryOptions.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js.map new file mode 100644 index 000000000..719a307c4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryOptions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"retryOptions.js","sourceRoot":"","sources":["../../../src/retry/retryOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents the Retry policy assocated with throttled requests in the Azure Cosmos DB database service.\n */\nexport interface RetryOptions {\n /** Max number of retries to be performed for a request. Default value 9. */\n maxRetryAttemptCount: number;\n /** Fixed retry interval in milliseconds to wait between each retry ignoring the retryAfter returned as part of the response. */\n fixedRetryIntervalInMilliseconds: number;\n /** Max wait time in seconds to wait for a request while the retries are happening. Default value 30 seconds. */\n maxWaitTimeInSeconds: number;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts new file mode 100644 index 000000000..c6379a6f4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts @@ -0,0 +1,35 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { Response } from "../request"; +import { RequestContext } from "../request/RequestContext"; +import { DefaultRetryPolicy } from "./defaultRetryPolicy"; +import { EndpointDiscoveryRetryPolicy } from "./endpointDiscoveryRetryPolicy"; +import { ResourceThrottleRetryPolicy } from "./resourceThrottleRetryPolicy"; +import { RetryContext } from "./RetryContext"; +import { SessionRetryPolicy } from "./sessionRetryPolicy"; +import { TimeoutFailoverRetryPolicy } from "./timeoutFailoverRetryPolicy"; +/** + * @hidden + */ +interface ExecuteArgs { + retryContext?: RetryContext; + diagnosticNode: DiagnosticNodeInternal; + retryPolicies?: RetryPolicies; + requestContext: RequestContext; + executeRequest: (diagnosticNode: DiagnosticNodeInternal, requestContext: RequestContext) => Promise>; +} +/** + * @hidden + */ +interface RetryPolicies { + endpointDiscoveryRetryPolicy: EndpointDiscoveryRetryPolicy; + resourceThrottleRetryPolicy: ResourceThrottleRetryPolicy; + sessionReadRetryPolicy: SessionRetryPolicy; + defaultRetryPolicy: DefaultRetryPolicy; + timeoutFailoverRetryPolicy: TimeoutFailoverRetryPolicy; +} +/** + * @hidden + */ +export declare function execute({ diagnosticNode, retryContext, retryPolicies, requestContext, executeRequest, }: ExecuteArgs): Promise>; +export {}; +//# sourceMappingURL=retryUtility.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts.map new file mode 100644 index 000000000..21e6859c7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"retryUtility.d.ts","sourceRoot":"","sources":["../../../src/retry/retryUtility.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,sBAAsB,EAAsB,MAAM,uCAAuC,CAAC;AACnG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAI3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;GAEG;AACH,UAAU,WAAW;IACnB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,cAAc,EAAE,sBAAsB,CAAC;IACvC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,CACd,cAAc,EAAE,sBAAsB,EACtC,cAAc,EAAE,cAAc,KAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,UAAU,aAAa;IACrB,4BAA4B,EAAE,4BAA4B,CAAC;IAC3D,2BAA2B,EAAE,2BAA2B,CAAC;IACzD,sBAAsB,EAAE,kBAAkB,CAAC;IAC3C,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,0BAA0B,EAAE,0BAA0B,CAAC;CACxD;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,EAC5B,cAAc,EACd,YAAgC,EAChC,aAAa,EACb,cAAc,EACd,cAAc,GACf,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CA4HtC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js new file mode 100644 index 000000000..c063b519a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants } from "../common/constants"; +import { sleep } from "../common/helper"; +import { StatusCodes, SubStatusCodes } from "../common/statusCodes"; +import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; +import { TimeoutErrorCode } from "../request/TimeoutError"; +import { addDignosticChild } from "../utils/diagnostics"; +import { getCurrentTimestampInMs } from "../utils/time"; +import { DefaultRetryPolicy } from "./defaultRetryPolicy"; +import { EndpointDiscoveryRetryPolicy } from "./endpointDiscoveryRetryPolicy"; +import { ResourceThrottleRetryPolicy } from "./resourceThrottleRetryPolicy"; +import { SessionRetryPolicy } from "./sessionRetryPolicy"; +import { TimeoutFailoverRetryPolicy } from "./timeoutFailoverRetryPolicy"; +/** + * @hidden + */ +export async function execute({ diagnosticNode, retryContext = { retryCount: 0 }, retryPolicies, requestContext, executeRequest, }) { + // TODO: any response + return addDignosticChild(async (localDiagnosticNode) => { + localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount }); + if (!retryPolicies) { + retryPolicies = { + endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(requestContext.globalEndpointManager, requestContext.operationType), + resourceThrottleRetryPolicy: new ResourceThrottleRetryPolicy(requestContext.connectionPolicy.retryOptions.maxRetryAttemptCount, requestContext.connectionPolicy.retryOptions.fixedRetryIntervalInMilliseconds, requestContext.connectionPolicy.retryOptions.maxWaitTimeInSeconds), + sessionReadRetryPolicy: new SessionRetryPolicy(requestContext.globalEndpointManager, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy), + defaultRetryPolicy: new DefaultRetryPolicy(requestContext.operationType), + timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(requestContext.globalEndpointManager, requestContext.headers, requestContext.method, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy.enableEndpointDiscovery), + }; + } + if (retryContext && retryContext.clearSessionTokenNotAvailable) { + requestContext.client.clearSessionToken(requestContext.path); + delete requestContext.headers["x-ms-session-token"]; + } + if (retryContext && retryContext.retryLocationServerIndex) { + requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(localDiagnosticNode, requestContext.resourceType, requestContext.operationType, retryContext.retryLocationServerIndex); + } + else { + requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(localDiagnosticNode, requestContext.resourceType, requestContext.operationType); + } + const startTimeUTCInMs = getCurrentTimestampInMs(); + try { + const response = await executeRequest(localDiagnosticNode, requestContext); + response.headers[Constants.ThrottleRetryCount] = + retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount; + response.headers[Constants.ThrottleRetryWaitTimeInMs] = + retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs; + return response; + } + catch (err) { + // TODO: any error + let retryPolicy = null; + const headers = err.headers || {}; + if (err.code === StatusCodes.ENOTFOUND || + err.code === "REQUEST_SEND_ERROR" || + (err.code === StatusCodes.Forbidden && + (err.substatus === SubStatusCodes.DatabaseAccountNotFound || + err.substatus === SubStatusCodes.WriteForbidden))) { + retryPolicy = retryPolicies.endpointDiscoveryRetryPolicy; + } + else if (err.code === StatusCodes.TooManyRequests) { + retryPolicy = retryPolicies.resourceThrottleRetryPolicy; + } + else if (err.code === StatusCodes.NotFound && + err.substatus === SubStatusCodes.ReadSessionNotAvailable) { + retryPolicy = retryPolicies.sessionReadRetryPolicy; + } + else if (err.code === StatusCodes.ServiceUnavailable || err.code === TimeoutErrorCode) { + retryPolicy = retryPolicies.timeoutFailoverRetryPolicy; + } + else { + retryPolicy = retryPolicies.defaultRetryPolicy; + } + const results = await retryPolicy.shouldRetry(err, localDiagnosticNode, retryContext, requestContext.endpoint); + if (!results) { + headers[Constants.ThrottleRetryCount] = + retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount; + headers[Constants.ThrottleRetryWaitTimeInMs] = + retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs; + err.headers = Object.assign(Object.assign({}, err.headers), headers); + throw err; + } + else { + requestContext.retryCount++; + const newUrl = results[1]; // TODO: any hack + if (newUrl !== undefined) { + requestContext.endpoint = newUrl; + } + localDiagnosticNode.recordFailedNetworkCall(startTimeUTCInMs, requestContext, retryContext.retryCount, err.code, err.subsstatusCode, headers); + await sleep(retryPolicy.retryAfterInMs); + return execute({ + diagnosticNode, + executeRequest, + requestContext, + retryContext, + retryPolicies, + }); + } + } + }, diagnosticNode, DiagnosticNodeType.HTTP_REQUEST); +} +//# sourceMappingURL=retryUtility.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js.map new file mode 100644 index 000000000..a87549c1f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/retryUtility.js.map @@ -0,0 +1 @@ +{"version":3,"file":"retryUtility.js","sourceRoot":"","sources":["../../../src/retry/retryUtility.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,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B,EACnB,YAAY,EACZ,cAAc,CAAC,QAAQ,CACxB,CAAC;YACF,IAAI,CAAC,OAAO,EAAE;gBACZ,OAAO,CAAC,SAAS,CAAC,kBAAkB,CAAC;oBACnC,aAAa,CAAC,2BAA2B,CAAC,wBAAwB,CAAC;gBACrE,OAAO,CAAC,SAAS,CAAC,yBAAyB,CAAC;oBAC1C,aAAa,CAAC,2BAA2B,CAAC,uBAAuB,CAAC;gBACpE,GAAG,CAAC,OAAO,mCAAQ,GAAG,CAAC,OAAO,GAAK,OAAO,CAAE,CAAC;gBAC7C,MAAM,GAAG,CAAC;aACX;iBAAM;gBACL,cAAc,CAAC,UAAU,EAAE,CAAC;gBAC5B,MAAM,MAAM,GAAI,OAAe,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB;gBACrD,IAAI,MAAM,KAAK,SAAS,EAAE;oBACxB,cAAc,CAAC,QAAQ,GAAG,MAAM,CAAC;iBAClC;gBACD,mBAAmB,CAAC,uBAAuB,CACzC,gBAAgB,EAChB,cAAc,EACd,YAAY,CAAC,UAAU,EACvB,GAAG,CAAC,IAAI,EACR,GAAG,CAAC,cAAc,EAClB,OAAO,CACR,CAAC;gBACF,MAAM,KAAK,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;gBACxC,OAAO,OAAO,CAAC;oBACb,cAAc;oBACd,cAAc;oBACd,cAAc;oBACd,YAAY;oBACZ,aAAa;iBACd,CAAC,CAAC;aACJ;SACF;IACH,CAAC,EACD,cAAc,EACd,kBAAkB,CAAC,YAAY,CAChC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common/constants\";\nimport { sleep } from \"../common/helper\";\nimport { StatusCodes, SubStatusCodes } from \"../common/statusCodes\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { Response } from \"../request\";\nimport { RequestContext } from \"../request/RequestContext\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\nimport { DefaultRetryPolicy } from \"./defaultRetryPolicy\";\nimport { EndpointDiscoveryRetryPolicy } from \"./endpointDiscoveryRetryPolicy\";\nimport { ResourceThrottleRetryPolicy } from \"./resourceThrottleRetryPolicy\";\nimport { RetryContext } from \"./RetryContext\";\nimport { RetryPolicy } from \"./RetryPolicy\";\nimport { SessionRetryPolicy } from \"./sessionRetryPolicy\";\nimport { TimeoutFailoverRetryPolicy } from \"./timeoutFailoverRetryPolicy\";\n\n/**\n * @hidden\n */\ninterface ExecuteArgs {\n retryContext?: RetryContext;\n diagnosticNode: DiagnosticNodeInternal;\n retryPolicies?: RetryPolicies;\n requestContext: RequestContext;\n executeRequest: (\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n ) => Promise>;\n}\n\n/**\n * @hidden\n */\ninterface RetryPolicies {\n endpointDiscoveryRetryPolicy: EndpointDiscoveryRetryPolicy;\n resourceThrottleRetryPolicy: ResourceThrottleRetryPolicy;\n sessionReadRetryPolicy: SessionRetryPolicy;\n defaultRetryPolicy: DefaultRetryPolicy;\n timeoutFailoverRetryPolicy: TimeoutFailoverRetryPolicy;\n}\n\n/**\n * @hidden\n */\nexport async function execute({\n diagnosticNode,\n retryContext = { retryCount: 0 },\n retryPolicies,\n requestContext,\n executeRequest,\n}: ExecuteArgs): Promise> {\n // TODO: any response\n return addDignosticChild(\n async (localDiagnosticNode: DiagnosticNodeInternal) => {\n localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount });\n if (!retryPolicies) {\n retryPolicies = {\n endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.operationType,\n ),\n resourceThrottleRetryPolicy: new ResourceThrottleRetryPolicy(\n requestContext.connectionPolicy.retryOptions.maxRetryAttemptCount,\n requestContext.connectionPolicy.retryOptions.fixedRetryIntervalInMilliseconds,\n requestContext.connectionPolicy.retryOptions.maxWaitTimeInSeconds,\n ),\n sessionReadRetryPolicy: new SessionRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy,\n ),\n defaultRetryPolicy: new DefaultRetryPolicy(requestContext.operationType),\n timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.headers,\n requestContext.method,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy.enableEndpointDiscovery,\n ),\n };\n }\n if (retryContext && retryContext.clearSessionTokenNotAvailable) {\n requestContext.client.clearSessionToken(requestContext.path);\n delete requestContext.headers[\"x-ms-session-token\"];\n }\n if (retryContext && retryContext.retryLocationServerIndex) {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n retryContext.retryLocationServerIndex,\n );\n } else {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n );\n }\n const startTimeUTCInMs = getCurrentTimestampInMs();\n try {\n const response = await executeRequest(localDiagnosticNode, requestContext);\n response.headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n response.headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n return response;\n } catch (err: any) {\n // TODO: any error\n let retryPolicy: RetryPolicy = null;\n const headers = err.headers || {};\n if (\n err.code === StatusCodes.ENOTFOUND ||\n err.code === \"REQUEST_SEND_ERROR\" ||\n (err.code === StatusCodes.Forbidden &&\n (err.substatus === SubStatusCodes.DatabaseAccountNotFound ||\n err.substatus === SubStatusCodes.WriteForbidden))\n ) {\n retryPolicy = retryPolicies.endpointDiscoveryRetryPolicy;\n } else if (err.code === StatusCodes.TooManyRequests) {\n retryPolicy = retryPolicies.resourceThrottleRetryPolicy;\n } else if (\n err.code === StatusCodes.NotFound &&\n err.substatus === SubStatusCodes.ReadSessionNotAvailable\n ) {\n retryPolicy = retryPolicies.sessionReadRetryPolicy;\n } else if (err.code === StatusCodes.ServiceUnavailable || err.code === TimeoutErrorCode) {\n retryPolicy = retryPolicies.timeoutFailoverRetryPolicy;\n } else {\n retryPolicy = retryPolicies.defaultRetryPolicy;\n }\n const results = await retryPolicy.shouldRetry(\n err,\n localDiagnosticNode,\n retryContext,\n requestContext.endpoint,\n );\n if (!results) {\n headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n err.headers = { ...err.headers, ...headers };\n throw err;\n } else {\n requestContext.retryCount++;\n const newUrl = (results as any)[1]; // TODO: any hack\n if (newUrl !== undefined) {\n requestContext.endpoint = newUrl;\n }\n localDiagnosticNode.recordFailedNetworkCall(\n startTimeUTCInMs,\n requestContext,\n retryContext.retryCount,\n err.code,\n err.subsstatusCode,\n headers,\n );\n await sleep(retryPolicy.retryAfterInMs);\n return execute({\n diagnosticNode,\n executeRequest,\n requestContext,\n retryContext,\n retryPolicies,\n });\n }\n }\n },\n diagnosticNode,\n DiagnosticNodeType.HTTP_REQUEST,\n );\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts new file mode 100644 index 000000000..047d046c5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts @@ -0,0 +1,33 @@ +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { OperationType, ResourceType } from "../common"; +import { ConnectionPolicy } from "../documents"; +import { GlobalEndpointManager } from "../globalEndpointManager"; +import { ErrorResponse } from "../request"; +import { RetryContext } from "./RetryContext"; +import { RetryPolicy } from "./RetryPolicy"; +/** + * This class implements the retry policy for session consistent reads. + * @hidden + */ +export declare class SessionRetryPolicy implements RetryPolicy { + private globalEndpointManager; + private resourceType; + private operationType; + private connectionPolicy; + /** Current retry attempt count. */ + currentRetryAttemptCount: number; + /** Retry interval in milliseconds. */ + retryAfterInMs: number; + /** + * @param globalEndpointManager - The GlobalEndpointManager instance. + */ + constructor(globalEndpointManager: GlobalEndpointManager, resourceType: ResourceType, operationType: OperationType, connectionPolicy: ConnectionPolicy); + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + * @param callback - The callback function which takes bool argument which specifies whether the request + * will be retried or not. + */ + shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext): Promise; +} +//# sourceMappingURL=sessionRetryPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts.map new file mode 100644 index 000000000..2006db7ea --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sessionRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/sessionRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAiB,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IAUlD,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,gBAAgB;IAZ1B,mCAAmC;IAC5B,wBAAwB,SAAK;IACpC,sCAAsC;IAC/B,cAAc,SAAK;IAE1B;;OAEG;gBAEO,qBAAqB,EAAE,qBAAqB,EAC5C,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB;IAG5C;;;;;OAKG;IACU,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,EACtC,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,OAAO,CAAC;CA4CpB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js new file mode 100644 index 000000000..91afadc18 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js @@ -0,0 +1,69 @@ +import { isReadRequest } from "../common"; +/** + * This class implements the retry policy for session consistent reads. + * @hidden + */ +export class SessionRetryPolicy { + /** + * @param globalEndpointManager - The GlobalEndpointManager instance. + */ + constructor(globalEndpointManager, resourceType, operationType, connectionPolicy) { + this.globalEndpointManager = globalEndpointManager; + this.resourceType = resourceType; + this.operationType = operationType; + this.connectionPolicy = connectionPolicy; + /** Current retry attempt count. */ + this.currentRetryAttemptCount = 0; + /** Retry interval in milliseconds. */ + this.retryAfterInMs = 0; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + * @param callback - The callback function which takes bool argument which specifies whether the request + * will be retried or not. + */ + async shouldRetry(err, diagnosticNode, retryContext) { + if (!err) { + return false; + } + if (!retryContext) { + return false; + } + if (!this.connectionPolicy.enableEndpointDiscovery) { + return false; + } + if (this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType)) { + // If we can write to multiple locations, we should against every write endpoint until we succeed + const endpoints = isReadRequest(this.operationType) + ? await this.globalEndpointManager.getReadEndpoints() + : await this.globalEndpointManager.getWriteEndpoints(); + if (this.currentRetryAttemptCount > endpoints.length) { + return false; + } + else { + this.currentRetryAttemptCount++; + retryContext.retryCount++; + retryContext.retryRequestOnPreferredLocations = this.currentRetryAttemptCount > 1; + retryContext.clearSessionTokenNotAvailable = + this.currentRetryAttemptCount === endpoints.length; + diagnosticNode.addData({ successfulRetryPolicy: "session" }); + return true; + } + } + else { + if (this.currentRetryAttemptCount > 1) { + return false; + } + else { + this.currentRetryAttemptCount++; + retryContext.retryCount++; + retryContext.retryRequestOnPreferredLocations = false; // Forces all operations to primary write endpoint + retryContext.clearSessionTokenNotAvailable = true; + diagnosticNode.addData({ successfulRetryPolicy: "session" }); + return true; + } + } + } +} +//# sourceMappingURL=sessionRetryPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js.map new file mode 100644 index 000000000..05b079b4d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/sessionRetryPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sessionRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/sessionRetryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAA+B,MAAM,WAAW,CAAC;AAOvE;;;GAGG;AACH,MAAM,OAAO,kBAAkB;IAM7B;;OAEG;IACH,YACU,qBAA4C,EAC5C,YAA0B,EAC1B,aAA4B,EAC5B,gBAAkC;QAHlC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC5C,iBAAY,GAAZ,YAAY,CAAc;QAC1B,kBAAa,GAAb,aAAa,CAAe;QAC5B,qBAAgB,GAAhB,gBAAgB,CAAk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AK,CAAC;aACd;iBAAM;gBACL,IAAI,CAAC,wBAAwB,EAAE,CAAC;gBAChC,YAAY,CAAC,UAAU,EAAE,CAAC;gBAC1B,YAAY,CAAC,gCAAgC,GAAG,KAAK,CAAC,CAAC,kDAAkD;gBACzG,YAAY,CAAC,6BAA6B,GAAG,IAAI,CAAC;gBAClD,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC7D,OAAO,IAAI,CAAC;aACb;SACF;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { isReadRequest, OperationType, ResourceType } from \"../common\";\nimport { ConnectionPolicy } from \"../documents\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { ErrorResponse } from \"../request\";\nimport { RetryContext } from \"./RetryContext\";\nimport { RetryPolicy } from \"./RetryPolicy\";\n\n/**\n * This class implements the retry policy for session consistent reads.\n * @hidden\n */\nexport class SessionRetryPolicy implements RetryPolicy {\n /** Current retry attempt count. */\n public currentRetryAttemptCount = 0;\n /** Retry interval in milliseconds. */\n public retryAfterInMs = 0;\n\n /**\n * @param globalEndpointManager - The GlobalEndpointManager instance.\n */\n constructor(\n private globalEndpointManager: GlobalEndpointManager,\n private resourceType: ResourceType,\n private operationType: OperationType,\n private connectionPolicy: ConnectionPolicy,\n ) {}\n\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n * @param callback - The callback function which takes bool argument which specifies whether the request\n * will be retried or not.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n ): Promise {\n if (!err) {\n return false;\n }\n\n if (!retryContext) {\n return false;\n }\n\n if (!this.connectionPolicy.enableEndpointDiscovery) {\n return false;\n }\n\n if (\n this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType)\n ) {\n // If we can write to multiple locations, we should against every write endpoint until we succeed\n const endpoints = isReadRequest(this.operationType)\n ? await this.globalEndpointManager.getReadEndpoints()\n : await this.globalEndpointManager.getWriteEndpoints();\n if (this.currentRetryAttemptCount > endpoints.length) {\n return false;\n } else {\n this.currentRetryAttemptCount++;\n retryContext.retryCount++;\n retryContext.retryRequestOnPreferredLocations = this.currentRetryAttemptCount > 1;\n retryContext.clearSessionTokenNotAvailable =\n this.currentRetryAttemptCount === endpoints.length;\n diagnosticNode.addData({ successfulRetryPolicy: \"session\" });\n return true;\n }\n } else {\n if (this.currentRetryAttemptCount > 1) {\n return false;\n } else {\n this.currentRetryAttemptCount++;\n retryContext.retryCount++;\n retryContext.retryRequestOnPreferredLocations = false; // Forces all operations to primary write endpoint\n retryContext.clearSessionTokenNotAvailable = true;\n diagnosticNode.addData({ successfulRetryPolicy: \"session\" });\n return true;\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts new file mode 100644 index 000000000..14cf67000 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts @@ -0,0 +1,44 @@ +import { RetryPolicy } from "./RetryPolicy"; +import { GlobalEndpointManager } from "../globalEndpointManager"; +import { HTTPMethod } from "../common"; +import { OperationType, ResourceType } from "../common/constants"; +import { RetryContext } from "./RetryContext"; +import { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; +import { ErrorResponse } from "../request"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +/** + * This class TimeoutFailoverRetryPolicy handles retries for read operations + * (including data plane,metadata, and query plan) in case of request timeouts + * (TimeoutError) or service unavailability (503 status code) by performing failover + * and retrying on other regions. + * @hidden + */ +export declare class TimeoutFailoverRetryPolicy implements RetryPolicy { + private globalEndpointManager; + private headers; + private methodType; + private resourceType; + private operationType; + private enableEndPointDiscovery; + private maxRetryAttemptCount; + private maxServiceUnavailableRetryCount; + retryAfterInMs: number; + failoverRetryCount: number; + request: any; + locationEndpoint: any; + constructor(globalEndpointManager: GlobalEndpointManager, headers: CosmosHeaders, methodType: HTTPMethod, resourceType: ResourceType, operationType: OperationType, enableEndPointDiscovery: boolean); + /** + * Checks if a timeout request is valid for the timeout failover retry policy. + * A valid request should be a data plane, metadata, or query plan request. + * @returns + */ + private isValidRequestForTimeoutError; + shouldRetry(err: ErrorResponse, diagnosticNode: DiagnosticNodeInternal, retryContext?: RetryContext, locationEndpoint?: string): Promise; + /** + * Determines index of endpoint to be used for retry based upon failoverRetryCount and avalable locations + * @param failoverRetryCount - count of failovers + * @returns + */ + private findEndpointIndex; +} +//# sourceMappingURL=timeoutFailoverRetryPolicy.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts.map new file mode 100644 index 000000000..afb0683e1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"timeoutFailoverRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/retry/timeoutFailoverRetryPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,UAAU,EAAiB,MAAM,WAAW,CAAC;AACtD,OAAO,EAAa,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E;;;;;;GAMG;AACH,qBAAa,0BAA2B,YAAW,WAAW;IAS1D,OAAO,CAAC,qBAAqB;IAC7B,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,uBAAuB;IAbjC,OAAO,CAAC,oBAAoB,CAAO;IACnC,OAAO,CAAC,+BAA+B,CAAK;IACrC,cAAc,SAAK;IACnB,kBAAkB,SAAK;IACvB,OAAO,EAAE,GAAG,CAAC;IACb,gBAAgB,EAAE,GAAG,CAAC;gBAGnB,qBAAqB,EAAE,qBAAqB,EAC5C,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,UAAU,EACtB,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,uBAAuB,EAAE,OAAO;IAG1C;;;;OAIG;IACH,OAAO,CAAC,6BAA6B;IASxB,WAAW,CACtB,GAAG,EAAE,aAAa,EAClB,cAAc,EAAE,sBAAsB,EACtC,YAAY,CAAC,EAAE,YAAY,EAC3B,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,OAAO,CAAC;IAyCnB;;;;OAIG;YACW,iBAAiB;CAyBhC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js new file mode 100644 index 000000000..c5548517c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js @@ -0,0 +1,105 @@ +import { StatusCodes } from "../common/statusCodes"; +import { HTTPMethod, isReadRequest } from "../common"; +import { Constants } from "../common/constants"; +import { TimeoutErrorCode } from "../request/TimeoutError"; +/** + * This class TimeoutFailoverRetryPolicy handles retries for read operations + * (including data plane,metadata, and query plan) in case of request timeouts + * (TimeoutError) or service unavailability (503 status code) by performing failover + * and retrying on other regions. + * @hidden + */ +export class TimeoutFailoverRetryPolicy { + constructor(globalEndpointManager, headers, methodType, resourceType, operationType, enableEndPointDiscovery) { + this.globalEndpointManager = globalEndpointManager; + this.headers = headers; + this.methodType = methodType; + this.resourceType = resourceType; + this.operationType = operationType; + this.enableEndPointDiscovery = enableEndPointDiscovery; + this.maxRetryAttemptCount = 120; + this.maxServiceUnavailableRetryCount = 1; + this.retryAfterInMs = 0; + this.failoverRetryCount = 0; + } + /** + * Checks if a timeout request is valid for the timeout failover retry policy. + * A valid request should be a data plane, metadata, or query plan request. + * @returns + */ + isValidRequestForTimeoutError() { + const isQuery = Constants.HttpHeaders.IsQuery in this.headers; + const isQueryPlan = Constants.HttpHeaders.IsQueryPlan in this.headers; + if (this.methodType === HTTPMethod.get || isQuery || isQueryPlan) { + return true; + } + return false; + } + async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) { + if (!err) { + return false; + } + if (!retryContext || !locationEndpoint) { + return false; + } + // Check if the error is a timeout error (TimeoutErrorCode) and if it is not a valid HTTP network timeout request + if (err.code === TimeoutErrorCode && !this.isValidRequestForTimeoutError()) { + return false; + } + if (!this.enableEndPointDiscovery) { + return false; + } + if (err.code === StatusCodes.ServiceUnavailable && + this.failoverRetryCount >= this.maxServiceUnavailableRetryCount) { + return false; + } + if (this.failoverRetryCount >= this.maxRetryAttemptCount) { + return false; + } + const canUseMultipleWriteLocations = this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType); + const readRequest = isReadRequest(this.operationType); + if (!canUseMultipleWriteLocations && !readRequest) { + // Write requests on single master cannot be retried, no other regions available + return false; + } + this.failoverRetryCount++; + // Setting the retryLocationIndex to the next available location for retry. + // The retryLocationIndex is determined based on the failoverRetryCount, starting from zero. + retryContext.retryLocationServerIndex = await this.findEndpointIndex(this.failoverRetryCount); + diagnosticNode.addData({ successfulRetryPolicy: "timeout-failover" }); + return true; + } + /** + * Determines index of endpoint to be used for retry based upon failoverRetryCount and avalable locations + * @param failoverRetryCount - count of failovers + * @returns + */ + async findEndpointIndex(failoverRetryCount) { + // count of preferred locations specified by user + const preferredLocationsCount = this.globalEndpointManager.preferredLocationsCount; + const readRequest = isReadRequest(this.operationType); + let endpointIndex = 0; + // If preferredLocationsCount is not zero, it indicates that the user has specified preferred locations. + if (preferredLocationsCount !== 0) { + // The endpointIndex is set based on the preferred location and the failover retry count. + endpointIndex = failoverRetryCount % preferredLocationsCount; + } + else { + // In the absence of preferred locations, the endpoint selection is based on the failover count and the number of available locations. + if (readRequest) { + const getReadEndpoints = await this.globalEndpointManager.getReadEndpoints(); + if (getReadEndpoints && getReadEndpoints.length > 0) { + endpointIndex = failoverRetryCount % getReadEndpoints.length; + } + } + else { + const getWriteEndpoints = await this.globalEndpointManager.getWriteEndpoints(); + if (getWriteEndpoints && getWriteEndpoints.length > 0) { + endpointIndex = failoverRetryCount % getWriteEndpoints.length; + } + } + } + return endpointIndex; + } +} +//# sourceMappingURL=timeoutFailoverRetryPolicy.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js.map new file mode 100644 index 000000000..8f149ffe9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/retry/timeoutFailoverRetryPolicy.js.map @@ -0,0 +1 @@ +{"version":3,"file":"timeoutFailoverRetryPolicy.js","sourceRoot":"","sources":["../../../src/retry/timeoutFailoverRetryPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,SAAS,EAA+B,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CA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BAAgB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,gBAAgB,EAAE,CAAC;gBAC7E,IAAI,gBAAgB,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;oBACnD,aAAa,GAAG,kBAAkB,GAAG,gBAAgB,CAAC,MAAM,CAAC;iBAC9D;aACF;iBAAM;gBACL,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,iBAAiB,EAAE,CAAC;gBAC/E,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE;oBACrD,aAAa,GAAG,kBAAkB,GAAG,iBAAiB,CAAC,MAAM,CAAC;iBAC/D;aACF;SACF;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { RetryPolicy } from \"./RetryPolicy\";\nimport { StatusCodes } from \"../common/statusCodes\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { HTTPMethod, isReadRequest } from \"../common\";\nimport { Constants, OperationType, ResourceType } from \"../common/constants\";\nimport { RetryContext } from \"./RetryContext\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError\";\nimport { ErrorResponse } from \"../request\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\n\n/**\n * This class TimeoutFailoverRetryPolicy handles retries for read operations\n * (including data plane,metadata, and query plan) in case of request timeouts\n * (TimeoutError) or service unavailability (503 status code) by performing failover\n * and retrying on other regions.\n * @hidden\n */\nexport class TimeoutFailoverRetryPolicy implements RetryPolicy {\n private maxRetryAttemptCount = 120;\n private maxServiceUnavailableRetryCount = 1;\n public retryAfterInMs = 0;\n public failoverRetryCount = 0;\n public request: any;\n public locationEndpoint: any;\n\n constructor(\n private globalEndpointManager: GlobalEndpointManager,\n private headers: CosmosHeaders,\n private methodType: HTTPMethod,\n private resourceType: ResourceType,\n private operationType: OperationType,\n private enableEndPointDiscovery: boolean,\n ) {}\n\n /**\n * Checks if a timeout request is valid for the timeout failover retry policy.\n * A valid request should be a data plane, metadata, or query plan request.\n * @returns\n */\n private isValidRequestForTimeoutError(): boolean {\n const isQuery = Constants.HttpHeaders.IsQuery in this.headers;\n const isQueryPlan = Constants.HttpHeaders.IsQueryPlan in this.headers;\n if (this.methodType === HTTPMethod.get || isQuery || isQueryPlan) {\n return true;\n }\n return false;\n }\n\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n ): Promise {\n if (!err) {\n return false;\n }\n if (!retryContext || !locationEndpoint) {\n return false;\n }\n // Check if the error is a timeout error (TimeoutErrorCode) and if it is not a valid HTTP network timeout request\n if (err.code === TimeoutErrorCode && !this.isValidRequestForTimeoutError()) {\n return false;\n }\n if (!this.enableEndPointDiscovery) {\n return false;\n }\n if (\n err.code === StatusCodes.ServiceUnavailable &&\n this.failoverRetryCount >= this.maxServiceUnavailableRetryCount\n ) {\n return false;\n }\n if (this.failoverRetryCount >= this.maxRetryAttemptCount) {\n return false;\n }\n const canUseMultipleWriteLocations = this.globalEndpointManager.canUseMultipleWriteLocations(\n this.resourceType,\n this.operationType,\n );\n const readRequest = isReadRequest(this.operationType);\n\n if (!canUseMultipleWriteLocations && !readRequest) {\n // Write requests on single master cannot be retried, no other regions available\n return false;\n }\n this.failoverRetryCount++;\n // Setting the retryLocationIndex to the next available location for retry.\n // The retryLocationIndex is determined based on the failoverRetryCount, starting from zero.\n retryContext.retryLocationServerIndex = await this.findEndpointIndex(this.failoverRetryCount);\n diagnosticNode.addData({ successfulRetryPolicy: \"timeout-failover\" });\n return true;\n }\n\n /**\n * Determines index of endpoint to be used for retry based upon failoverRetryCount and avalable locations\n * @param failoverRetryCount - count of failovers\n * @returns\n */\n private async findEndpointIndex(failoverRetryCount: number): Promise {\n // count of preferred locations specified by user\n const preferredLocationsCount = this.globalEndpointManager.preferredLocationsCount;\n const readRequest = isReadRequest(this.operationType);\n let endpointIndex = 0;\n // If preferredLocationsCount is not zero, it indicates that the user has specified preferred locations.\n if (preferredLocationsCount !== 0) {\n // The endpointIndex is set based on the preferred location and the failover retry count.\n endpointIndex = failoverRetryCount % preferredLocationsCount;\n } else {\n // In the absence of preferred locations, the endpoint selection is based on the failover count and the number of available locations.\n if (readRequest) {\n const getReadEndpoints = await this.globalEndpointManager.getReadEndpoints();\n if (getReadEndpoints && getReadEndpoints.length > 0) {\n endpointIndex = failoverRetryCount % getReadEndpoints.length;\n }\n } else {\n const getWriteEndpoints = await this.globalEndpointManager.getWriteEndpoints();\n if (getWriteEndpoints && getWriteEndpoints.length > 0) {\n endpointIndex = failoverRetryCount % getWriteEndpoints.length;\n }\n }\n }\n return endpointIndex;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts new file mode 100644 index 000000000..9f964b5d0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts @@ -0,0 +1,4 @@ +import { InMemoryCollectionRoutingMap } from "./inMemoryCollectionRoutingMap"; +/** @hidden */ +export declare function createCompleteRoutingMap(partitionKeyRangeInfoTuppleList: any[]): InMemoryCollectionRoutingMap; +//# sourceMappingURL=CollectionRoutingMapFactory.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts.map new file mode 100644 index 000000000..188932559 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"CollectionRoutingMapFactory.d.ts","sourceRoot":"","sources":["../../../src/routing/CollectionRoutingMapFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAiB9E,cAAc;AACd,wBAAgB,wBAAwB,CACtC,+BAA+B,EAAE,GAAG,EAAE,GACrC,4BAA4B,CAqB9B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js new file mode 100644 index 000000000..6138cbc73 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js @@ -0,0 +1,72 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants } from "../common/constants"; +import { InMemoryCollectionRoutingMap } from "./inMemoryCollectionRoutingMap"; +/** + * @hidden + */ +function compareRanges(a, b) { + const aVal = a[0][Constants.PartitionKeyRange.MinInclusive]; + const bVal = b[0][Constants.PartitionKeyRange.MinInclusive]; + if (aVal > bVal) { + return 1; + } + if (aVal < bVal) { + return -1; + } + return 0; +} +/** @hidden */ +export function createCompleteRoutingMap(partitionKeyRangeInfoTuppleList) { + const rangeById = {}; // TODO: any + const rangeByInfo = {}; // TODO: any + let sortedRanges = []; + // the for loop doesn't invoke any async callback + for (const r of partitionKeyRangeInfoTuppleList) { + rangeById[r[0][Constants.PartitionKeyRange.Id]] = r; + rangeByInfo[r[1]] = r[0]; + sortedRanges.push(r); + } + sortedRanges = sortedRanges.sort(compareRanges); + const partitionKeyOrderedRange = sortedRanges.map((r) => r[0]); + const orderedPartitionInfo = sortedRanges.map((r) => r[1]); + if (!isCompleteSetOfRange(partitionKeyOrderedRange)) { + return undefined; + } + return new InMemoryCollectionRoutingMap(partitionKeyOrderedRange, orderedPartitionInfo); +} +/** + * @hidden + */ +function isCompleteSetOfRange(partitionKeyOrderedRange) { + // TODO: any + let isComplete = false; + if (partitionKeyOrderedRange.length > 0) { + const firstRange = partitionKeyOrderedRange[0]; + const lastRange = partitionKeyOrderedRange[partitionKeyOrderedRange.length - 1]; + isComplete = + firstRange[Constants.PartitionKeyRange.MinInclusive] === + Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey; + isComplete = + isComplete && + lastRange[Constants.PartitionKeyRange.MaxExclusive] === + Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey; + for (let i = 1; i < partitionKeyOrderedRange.length; i++) { + const previousRange = partitionKeyOrderedRange[i - 1]; + const currentRange = partitionKeyOrderedRange[i]; + isComplete = + isComplete && + previousRange[Constants.PartitionKeyRange.MaxExclusive] === + currentRange[Constants.PartitionKeyRange.MinInclusive]; + if (!isComplete) { + if (previousRange[Constants.PartitionKeyRange.MaxExclusive] > + currentRange[Constants.PartitionKeyRange.MinInclusive]) { + throw Error("Ranges overlap"); + } + break; + } + } + } + return isComplete; +} +//# sourceMappingURL=CollectionRoutingMapFactory.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js.map new file mode 100644 index 000000000..a4253a347 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/CollectionRoutingMapFactory.js.map @@ -0,0 +1 @@ +{"version":3,"file":"CollectionRoutingMapFactory.js","sourceRoot":"","sources":["../../../src/routing/CollectionRoutingMapFactory.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E;;GAEG;AACH,SAAS,aAAa,CAAC,CAAM,EAAE,CAAM;IACnC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,CAA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BAA6B;IACzD,YAAY;IACZ,IAAI,UAAU,GAAG,KAAK,CAAC;IACvB,IAAI,wBAAwB,CAAC,MAAM,GAAG,CAAC,EAAE;QACvC,MAAM,UAAU,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;QAC/C,MAAM,SAAS,GAAG,wBAAwB,CAAC,wBAAwB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChF,UAAU;YACR,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC;gBACpD,SAAS,CAAC,8BAA8B,CAAC,qCAAqC,CAAC;QACjF,UAAU;YACR,UAAU;gBACV,SAAS,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC;oBACjD,SAAS,CAAC,8BAA8B,CAAC,qCAAqC,CAAC;QAEnF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,aAAa,GAAG,wBAAwB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACtD,MAAM,YAAY,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YACjD,UAAU;gBACR,UAAU;oBACV,aAAa,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC;wBACrD,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;YAE3D,IAAI,CAAC,UAAU,EAAE;gBACf,IACE,aAAa,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC;oBACvD,YAAY,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,EACtD;oBACA,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAC;iBAC/B;gBACD,MAAM;aACP;SACF;KACF;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common/constants\";\nimport { InMemoryCollectionRoutingMap } from \"./inMemoryCollectionRoutingMap\";\n\n/**\n * @hidden\n */\nfunction compareRanges(a: any, b: any): 0 | 1 | -1 {\n const aVal = a[0][Constants.PartitionKeyRange.MinInclusive];\n const bVal = b[0][Constants.PartitionKeyRange.MinInclusive];\n if (aVal > bVal) {\n return 1;\n }\n if (aVal < bVal) {\n return -1;\n }\n return 0;\n}\n\n/** @hidden */\nexport function createCompleteRoutingMap(\n partitionKeyRangeInfoTuppleList: any[],\n): InMemoryCollectionRoutingMap {\n const rangeById: any = {}; // TODO: any\n const rangeByInfo: any = {}; // TODO: any\n\n let sortedRanges = [];\n\n // the for loop doesn't invoke any async callback\n for (const r of partitionKeyRangeInfoTuppleList) {\n rangeById[r[0][Constants.PartitionKeyRange.Id]] = r;\n rangeByInfo[r[1]] = r[0];\n sortedRanges.push(r);\n }\n\n sortedRanges = sortedRanges.sort(compareRanges);\n const partitionKeyOrderedRange = sortedRanges.map((r) => r[0]);\n const orderedPartitionInfo = sortedRanges.map((r) => r[1]);\n\n if (!isCompleteSetOfRange(partitionKeyOrderedRange)) {\n return undefined;\n }\n return new InMemoryCollectionRoutingMap(partitionKeyOrderedRange, orderedPartitionInfo);\n}\n\n/**\n * @hidden\n */\nfunction isCompleteSetOfRange(partitionKeyOrderedRange: any): boolean {\n // TODO: any\n let isComplete = false;\n if (partitionKeyOrderedRange.length > 0) {\n const firstRange = partitionKeyOrderedRange[0];\n const lastRange = partitionKeyOrderedRange[partitionKeyOrderedRange.length - 1];\n isComplete =\n firstRange[Constants.PartitionKeyRange.MinInclusive] ===\n Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey;\n isComplete =\n isComplete &&\n lastRange[Constants.PartitionKeyRange.MaxExclusive] ===\n Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey;\n\n for (let i = 1; i < partitionKeyOrderedRange.length; i++) {\n const previousRange = partitionKeyOrderedRange[i - 1];\n const currentRange = partitionKeyOrderedRange[i];\n isComplete =\n isComplete &&\n previousRange[Constants.PartitionKeyRange.MaxExclusive] ===\n currentRange[Constants.PartitionKeyRange.MinInclusive];\n\n if (!isComplete) {\n if (\n previousRange[Constants.PartitionKeyRange.MaxExclusive] >\n currentRange[Constants.PartitionKeyRange.MinInclusive]\n ) {\n throw Error(\"Ranges overlap\");\n }\n break;\n }\n }\n }\n return isComplete;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts new file mode 100644 index 000000000..2d34e844d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts @@ -0,0 +1,35 @@ +import { PartitionKeyRange } from "../client/Container/PartitionKeyRange"; +import { QueryRange as ResponseQueryRange } from "../request/ErrorResponse"; +/** @hidden */ +export declare class QueryRange { + min: string; + max: string; + isMinInclusive: boolean; + isMaxInclusive: boolean; + /** + * Represents a QueryRange. + * + * @param rangeMin - min + * @param rangeMin - max + * @param isMinInclusive - isMinInclusive + * @param isMaxInclusive - isMaxInclusive + * @hidden + */ + constructor(rangeMin: string, rangeMax: string, isMinInclusive: boolean, isMaxInclusive: boolean); + overlaps(other: QueryRange): boolean; + isFullRange(): boolean; + isEmpty(): boolean; + /** + * Parse a QueryRange from a partitionKeyRange + * @returns QueryRange + * @hidden + */ + static parsePartitionKeyRange(partitionKeyRange: PartitionKeyRange): QueryRange; + /** + * Parse a QueryRange from a dictionary + * @returns QueryRange + * @hidden + */ + static parseFromDict(queryRangeDict: ResponseQueryRange): QueryRange; +} +//# sourceMappingURL=QueryRange.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts.map new file mode 100644 index 000000000..4be1a8656 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"QueryRange.d.ts","sourceRoot":"","sources":["../../../src/routing/QueryRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE1E,OAAO,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,cAAc;AACd,qBAAa,UAAU;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,OAAO,CAAC;IAE/B;;;;;;;;OAQG;gBAED,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,OAAO,EACvB,cAAc,EAAE,OAAO;IAOlB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAsBpC,WAAW,IAAI,OAAO;IAStB,OAAO,IAAI,OAAO;IAGzB;;;;OAIG;WACW,sBAAsB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,UAAU;IAQtF;;;;OAIG;WACW,aAAa,CAAC,cAAc,EAAE,kBAAkB,GAAG,UAAU;CAQ5E"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js new file mode 100644 index 000000000..7daa2d2bb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js @@ -0,0 +1,63 @@ +import { Constants } from "../common"; +/** @hidden */ +export class QueryRange { + /** + * Represents a QueryRange. + * + * @param rangeMin - min + * @param rangeMin - max + * @param isMinInclusive - isMinInclusive + * @param isMaxInclusive - isMaxInclusive + * @hidden + */ + constructor(rangeMin, rangeMax, isMinInclusive, isMaxInclusive) { + this.min = rangeMin; + this.max = rangeMax; + this.isMinInclusive = isMinInclusive; + this.isMaxInclusive = isMaxInclusive; + } + overlaps(other) { + const range1 = this; // eslint-disable-line @typescript-eslint/no-this-alias + const range2 = other; + if (range1 === undefined || range2 === undefined) { + return false; + } + if (range1.isEmpty() || range2.isEmpty()) { + return false; + } + if (range1.min <= range2.max || range2.min <= range1.max) { + if ((range1.min === range2.max && !(range1.isMinInclusive && range2.isMaxInclusive)) || + (range2.min === range1.max && !(range2.isMinInclusive && range1.isMaxInclusive))) { + return false; + } + return true; + } + return false; + } + isFullRange() { + return (this.min === Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey && + this.max === Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey && + this.isMinInclusive === true && + this.isMaxInclusive === false); + } + isEmpty() { + return !(this.isMinInclusive && this.isMaxInclusive) && this.min === this.max; + } + /** + * Parse a QueryRange from a partitionKeyRange + * @returns QueryRange + * @hidden + */ + static parsePartitionKeyRange(partitionKeyRange) { + return new QueryRange(partitionKeyRange[Constants.PartitionKeyRange.MinInclusive], partitionKeyRange[Constants.PartitionKeyRange.MaxExclusive], true, false); + } + /** + * Parse a QueryRange from a dictionary + * @returns QueryRange + * @hidden + */ + static parseFromDict(queryRangeDict) { + return new QueryRange(queryRangeDict.min, queryRangeDict.max, queryRangeDict.isMinInclusive, queryRangeDict.isMaxInclusive); + } +} +//# sourceMappingURL=QueryRange.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js.map new file mode 100644 index 000000000..c69ab6acf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/QueryRange.js.map @@ -0,0 +1 @@ +{"version":3,"file":"QueryRange.js","sourceRoot":"","sources":["../../../src/routing/QueryRange.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,cAAc;AACd,MAAM,OAAO,UAAU;IAMrB;;;;;;;;OAQG;IACH,YACE,QAAgB,EAChB,QAAgB,EAChB,cAAuB,EACvB,cAAuB;QAEvB,IAAI,CAAC,GA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Ac,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,CAAC;IAChF,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,sBAAsB,CAAC,iBAAoC;QACvE,OAAO,IAAI,UAAU,CACnB,iBAAiB,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,EAC3D,iBAAiB,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,EAC3D,IAAI,EACJ,KAAK,CACN,CAAC;IACJ,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,cAAkC;QAC5D,OAAO,IAAI,UAAU,CACnB,cAAc,CAAC,GAAG,EAClB,cAAc,CAAC,GAAG,EAClB,cAAc,CAAC,cAAc,EAC7B,cAAc,CAAC,cAAc,CAC9B,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKeyRange } from \"../client/Container/PartitionKeyRange\";\nimport { Constants } from \"../common\";\nimport { QueryRange as ResponseQueryRange } from \"../request/ErrorResponse\";\n\n/** @hidden */\nexport class QueryRange {\n public min: string;\n public max: string;\n public isMinInclusive: boolean;\n public isMaxInclusive: boolean;\n\n /**\n * Represents a QueryRange.\n *\n * @param rangeMin - min\n * @param rangeMin - max\n * @param isMinInclusive - isMinInclusive\n * @param isMaxInclusive - isMaxInclusive\n * @hidden\n */\n constructor(\n rangeMin: string,\n rangeMax: string,\n isMinInclusive: boolean,\n isMaxInclusive: boolean,\n ) {\n this.min = rangeMin;\n this.max = rangeMax;\n this.isMinInclusive = isMinInclusive;\n this.isMaxInclusive = isMaxInclusive;\n }\n public overlaps(other: QueryRange): boolean {\n const range1 = this; // eslint-disable-line @typescript-eslint/no-this-alias\n const range2 = other;\n if (range1 === undefined || range2 === undefined) {\n return false;\n }\n if (range1.isEmpty() || range2.isEmpty()) {\n return false;\n }\n\n if (range1.min <= range2.max || range2.min <= range1.max) {\n if (\n (range1.min === range2.max && !(range1.isMinInclusive && range2.isMaxInclusive)) ||\n (range2.min === range1.max && !(range2.isMinInclusive && range1.isMaxInclusive))\n ) {\n return false;\n }\n return true;\n }\n return false;\n }\n\n public isFullRange(): boolean {\n return (\n this.min === Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey &&\n this.max === Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey &&\n this.isMinInclusive === true &&\n this.isMaxInclusive === false\n );\n }\n\n public isEmpty(): boolean {\n return !(this.isMinInclusive && this.isMaxInclusive) && this.min === this.max;\n }\n /**\n * Parse a QueryRange from a partitionKeyRange\n * @returns QueryRange\n * @hidden\n */\n public static parsePartitionKeyRange(partitionKeyRange: PartitionKeyRange): QueryRange {\n return new QueryRange(\n partitionKeyRange[Constants.PartitionKeyRange.MinInclusive],\n partitionKeyRange[Constants.PartitionKeyRange.MaxExclusive],\n true,\n false,\n );\n }\n /**\n * Parse a QueryRange from a dictionary\n * @returns QueryRange\n * @hidden\n */\n public static parseFromDict(queryRangeDict: ResponseQueryRange): QueryRange {\n return new QueryRange(\n queryRangeDict.min,\n queryRangeDict.max,\n queryRangeDict.isMinInclusive,\n queryRangeDict.isMaxInclusive,\n );\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts new file mode 100644 index 000000000..c5f0ece49 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts @@ -0,0 +1,17 @@ +import { PartitionKeyRange } from "../client"; +import { QueryRange } from "./QueryRange"; +/** @hidden */ +export declare class InMemoryCollectionRoutingMap { + private orderedPartitionKeyRanges; + private orderedRanges; + orderedPartitionInfo: unknown; + /** + * Represents a InMemoryCollectionRoutingMap Object, + * Stores partition key ranges in an efficient way with some additional information and provides + * convenience methods for working with set of ranges. + */ + constructor(orderedPartitionKeyRanges: PartitionKeyRange[], orderedPartitionInfo: unknown); + getOrderedParitionKeyRanges(): PartitionKeyRange[]; + getOverlappingRanges(providedQueryRanges: QueryRange | QueryRange[]): PartitionKeyRange[]; +} +//# sourceMappingURL=inMemoryCollectionRoutingMap.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts.map new file mode 100644 index 000000000..27317eb06 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"inMemoryCollectionRoutingMap.d.ts","sourceRoot":"","sources":["../../../src/routing/inMemoryCollectionRoutingMap.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,4BAA4B;IACvC,OAAO,CAAC,yBAAyB,CAAsB;IACvD,OAAO,CAAC,aAAa,CAAe;IAE7B,oBAAoB,EAAE,OAAO,CAAC;IAErC;;;;OAIG;gBACS,yBAAyB,EAAE,iBAAiB,EAAE,EAAE,oBAAoB,EAAE,OAAO;IAYlF,2BAA2B,IAAI,iBAAiB,EAAE;IAIlD,oBAAoB,CAAC,mBAAmB,EAAE,UAAU,GAAG,UAAU,EAAE,GAAG,iBAAiB,EAAE;CA+EjG"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js new file mode 100644 index 000000000..a618a128d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js @@ -0,0 +1,81 @@ +import { Constants } from "../common"; +import { QueryRange } from "./QueryRange"; +/** @hidden */ +export class InMemoryCollectionRoutingMap { + /** + * Represents a InMemoryCollectionRoutingMap Object, + * Stores partition key ranges in an efficient way with some additional information and provides + * convenience methods for working with set of ranges. + */ + constructor(orderedPartitionKeyRanges, orderedPartitionInfo) { + this.orderedPartitionKeyRanges = orderedPartitionKeyRanges; + this.orderedRanges = orderedPartitionKeyRanges.map((pkr) => { + return new QueryRange(pkr[Constants.PartitionKeyRange.MinInclusive], pkr[Constants.PartitionKeyRange.MaxExclusive], true, false); + }); + this.orderedPartitionInfo = orderedPartitionInfo; + } + getOrderedParitionKeyRanges() { + return this.orderedPartitionKeyRanges; + } + getOverlappingRanges(providedQueryRanges) { + // TODO This code has all kinds of smells. Multiple iterations and sorts just to grab overlapping ranges + // stfaul attempted to bring it down to one for-loop and failed + const pqr = Array.isArray(providedQueryRanges) + ? providedQueryRanges + : [providedQueryRanges]; + const minToPartitionRange = {}; // TODO: any + // this for loop doesn't invoke any async callback + for (const queryRange of pqr) { + if (queryRange.isEmpty()) { + continue; + } + if (queryRange.isFullRange()) { + return this.orderedPartitionKeyRanges; + } + const minIndex = this.orderedRanges.findIndex((range) => { + if (queryRange.min > range.min && queryRange.min < range.max) { + return true; + } + if (queryRange.min === range.min) { + return true; + } + if (queryRange.min === range.max) { + return true; + } + }); + if (minIndex < 0) { + throw new Error("error in collection routing map, queried value is less than the start range."); + } + // Start at the end and work backwards + let maxIndex; + for (let i = this.orderedRanges.length - 1; i >= 0; i--) { + const range = this.orderedRanges[i]; + if (queryRange.max > range.min && queryRange.max < range.max) { + maxIndex = i; + break; + } + if (queryRange.max === range.min) { + maxIndex = i; + break; + } + if (queryRange.max === range.max) { + maxIndex = i; + break; + } + } + if (maxIndex > this.orderedRanges.length) { + throw new Error("error in collection routing map, queried value is greater than the end range."); + } + for (let j = minIndex; j < maxIndex + 1; j++) { + if (queryRange.overlaps(this.orderedRanges[j])) { + minToPartitionRange[this.orderedPartitionKeyRanges[j][Constants.PartitionKeyRange.MinInclusive]] = this.orderedPartitionKeyRanges[j]; + } + } + } + const overlappingPartitionKeyRanges = Object.keys(minToPartitionRange).map((k) => minToPartitionRange[k]); + return overlappingPartitionKeyRanges.sort((a, b) => { + return a[Constants.PartitionKeyRange.MinInclusive].localeCompare(b[Constants.PartitionKeyRange.MinInclusive]); + }); + } +} +//# sourceMappingURL=inMemoryCollectionRoutingMap.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js.map new file mode 100644 index 000000000..e74bf18ce --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/inMemoryCollectionRoutingMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"inMemoryCollectionRoutingMap.js","sourceRoot":"","sources":["../../../src/routing/inMemoryCollectionRoutingMap.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,MAAM,OAAO,4BAA4B;IAMvC;;;;OAIG;IACH,YAAY,yBAA8C,EAAE,oBAA6B;QACvF,IAAI,CAAC,yBAAyB,GAAG,yBAAyB,CAAC;QAC3D,IAAI,CAAC,aAAa,GAAG,yBAAyB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;YACzD,OAAO,IAAI,UAAU,CACnB,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,EAC7C,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,YAAY,CAAC,EAC7C,IAAI,EACJ,KAAK,CACN,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;IACnD,CAAC;IACM,2BAA2B;QAChC,OAAO,IAAI,CAAC,yBAAyB,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;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKeyRange } from \"../client\";\nimport { Constants } from \"../common\";\nimport { QueryRange } from \"./QueryRange\";\n\n/** @hidden */\nexport class InMemoryCollectionRoutingMap {\n private orderedPartitionKeyRanges: PartitionKeyRange[];\n private orderedRanges: QueryRange[];\n // TODO: chrande made this public, even though it is implementation detail for a test\n public orderedPartitionInfo: unknown;\n\n /**\n * Represents a InMemoryCollectionRoutingMap Object,\n * Stores partition key ranges in an efficient way with some additional information and provides\n * convenience methods for working with set of ranges.\n */\n constructor(orderedPartitionKeyRanges: PartitionKeyRange[], orderedPartitionInfo: unknown) {\n this.orderedPartitionKeyRanges = orderedPartitionKeyRanges;\n this.orderedRanges = orderedPartitionKeyRanges.map((pkr) => {\n return new QueryRange(\n pkr[Constants.PartitionKeyRange.MinInclusive],\n pkr[Constants.PartitionKeyRange.MaxExclusive],\n true,\n false,\n );\n });\n this.orderedPartitionInfo = orderedPartitionInfo;\n }\n public getOrderedParitionKeyRanges(): PartitionKeyRange[] {\n return this.orderedPartitionKeyRanges;\n }\n\n public getOverlappingRanges(providedQueryRanges: QueryRange | QueryRange[]): PartitionKeyRange[] {\n // TODO This code has all kinds of smells. Multiple iterations and sorts just to grab overlapping ranges\n // stfaul attempted to bring it down to one for-loop and failed\n const pqr: QueryRange[] = Array.isArray(providedQueryRanges)\n ? providedQueryRanges\n : [providedQueryRanges];\n const minToPartitionRange: any = {}; // TODO: any\n\n // this for loop doesn't invoke any async callback\n for (const queryRange of pqr) {\n if (queryRange.isEmpty()) {\n continue;\n }\n\n if (queryRange.isFullRange()) {\n return this.orderedPartitionKeyRanges;\n }\n\n const minIndex = this.orderedRanges.findIndex((range) => {\n if (queryRange.min > range.min && queryRange.min < range.max) {\n return true;\n }\n if (queryRange.min === range.min) {\n return true;\n }\n if (queryRange.min === range.max) {\n return true;\n }\n });\n\n if (minIndex < 0) {\n throw new Error(\n \"error in collection routing map, queried value is less than the start range.\",\n );\n }\n\n // Start at the end and work backwards\n let maxIndex: number;\n for (let i = this.orderedRanges.length - 1; i >= 0; i--) {\n const range = this.orderedRanges[i];\n if (queryRange.max > range.min && queryRange.max < range.max) {\n maxIndex = i;\n break;\n }\n if (queryRange.max === range.min) {\n maxIndex = i;\n break;\n }\n if (queryRange.max === range.max) {\n maxIndex = i;\n break;\n }\n }\n\n if (maxIndex > this.orderedRanges.length) {\n throw new Error(\n \"error in collection routing map, queried value is greater than the end range.\",\n );\n }\n\n for (let j = minIndex; j < maxIndex + 1; j++) {\n if (queryRange.overlaps(this.orderedRanges[j])) {\n minToPartitionRange[\n this.orderedPartitionKeyRanges[j][Constants.PartitionKeyRange.MinInclusive]\n ] = this.orderedPartitionKeyRanges[j];\n }\n }\n }\n\n const overlappingPartitionKeyRanges = Object.keys(minToPartitionRange).map(\n (k) => minToPartitionRange[k],\n );\n\n return overlappingPartitionKeyRanges.sort((a, b) => {\n return a[Constants.PartitionKeyRange.MinInclusive].localeCompare(\n b[Constants.PartitionKeyRange.MinInclusive],\n );\n });\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts new file mode 100644 index 000000000..3365d942f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts @@ -0,0 +1,5 @@ +export * from "./QueryRange"; +export * from "./inMemoryCollectionRoutingMap"; +export * from "./partitionKeyRangeCache"; +export * from "./smartRoutingMapProvider"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts.map new file mode 100644 index 000000000..ec7fb393f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/routing/index.ts"],"names":[],"mappings":"AAEA,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js new file mode 100644 index 000000000..0b368f5c4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export * from "./QueryRange"; +export * from "./inMemoryCollectionRoutingMap"; +export * from "./partitionKeyRangeCache"; +export * from "./smartRoutingMapProvider"; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js.map new file mode 100644 index 000000000..1e1206f17 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/routing/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport * from \"./QueryRange\";\nexport * from \"./inMemoryCollectionRoutingMap\";\nexport * from \"./partitionKeyRangeCache\";\nexport * from \"./smartRoutingMapProvider\";\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts new file mode 100644 index 000000000..5e721941a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts @@ -0,0 +1,24 @@ +import { PartitionKeyRange } from "../client/Container/PartitionKeyRange"; +import { ClientContext } from "../ClientContext"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { InMemoryCollectionRoutingMap } from "./inMemoryCollectionRoutingMap"; +import { QueryRange } from "./QueryRange"; +/** @hidden */ +export declare class PartitionKeyRangeCache { + private clientContext; + private collectionRoutingMapByCollectionId; + constructor(clientContext: ClientContext); + /** + * Finds or Instantiates the requested Collection Routing Map + * @param collectionLink - Requested collectionLink + * @hidden + */ + onCollectionRoutingMap(collectionLink: string, diagnosticNode: DiagnosticNodeInternal, forceRefresh?: boolean): Promise; + /** + * Given the query ranges and a collection, invokes the callback on the list of overlapping partition key ranges + * @hidden + */ + getOverlappingRanges(collectionLink: string, queryRange: QueryRange, diagnosticNode: DiagnosticNodeInternal, forceRefresh?: boolean): Promise; + private requestCollectionRoutingMap; +} +//# sourceMappingURL=partitionKeyRangeCache.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts.map new file mode 100644 index 000000000..8f364c124 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"partitionKeyRangeCache.d.ts","sourceRoot":"","sources":["../../../src/routing/partitionKeyRangeCache.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAG/E,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,qBAAa,sBAAsB;IAKrB,OAAO,CAAC,aAAa;IAJjC,OAAO,CAAC,kCAAkC,CAExC;gBAEkB,aAAa,EAAE,aAAa;IAGhD;;;;OAIG;IACU,sBAAsB,CACjC,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,sBAAsB,EACtC,YAAY,GAAE,OAAe,GAC5B,OAAO,CAAC,4BAA4B,CAAC;IAWxC;;;OAGG;IACU,oBAAoB,CAC/B,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,sBAAsB,EACtC,YAAY,GAAE,OAAe,GAC5B,OAAO,CAAC,iBAAiB,EAAE,CAAC;YAKjB,2BAA2B;CAe1C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js new file mode 100644 index 000000000..acce67e2a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { MetadataLookUpType } from "../CosmosDiagnostics"; +import { getIdFromLink } from "../common/helper"; +import { withMetadataDiagnostics } from "../utils/diagnostics"; +import { createCompleteRoutingMap } from "./CollectionRoutingMapFactory"; +/** @hidden */ +export class PartitionKeyRangeCache { + constructor(clientContext) { + this.clientContext = clientContext; + this.collectionRoutingMapByCollectionId = {}; + } + /** + * Finds or Instantiates the requested Collection Routing Map + * @param collectionLink - Requested collectionLink + * @hidden + */ + async onCollectionRoutingMap(collectionLink, diagnosticNode, forceRefresh = false) { + const collectionId = getIdFromLink(collectionLink); + if (this.collectionRoutingMapByCollectionId[collectionId] === undefined || forceRefresh) { + this.collectionRoutingMapByCollectionId[collectionId] = this.requestCollectionRoutingMap(collectionLink, diagnosticNode); + } + return this.collectionRoutingMapByCollectionId[collectionId]; + } + /** + * Given the query ranges and a collection, invokes the callback on the list of overlapping partition key ranges + * @hidden + */ + async getOverlappingRanges(collectionLink, queryRange, diagnosticNode, forceRefresh = false) { + const crm = await this.onCollectionRoutingMap(collectionLink, diagnosticNode, forceRefresh); + return crm.getOverlappingRanges(queryRange); + } + async requestCollectionRoutingMap(collectionLink, diagnosticNode) { + const { resources } = await withMetadataDiagnostics(async (metadataDiagnostics) => { + return this.clientContext + .queryPartitionKeyRanges(collectionLink) + .fetchAllInternal(metadataDiagnostics); + }, diagnosticNode, MetadataLookUpType.PartitionKeyRangeLookUp); + return createCompleteRoutingMap(resources.map((r) => [r, true])); + } +} +//# sourceMappingURL=partitionKeyRangeCache.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js.map new file mode 100644 index 000000000..6eed8fad6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/partitionKeyRangeCache.js.map @@ -0,0 +1 @@ +{"version":3,"file":"partitionKeyRangeCache.js","sourceRoot":"","sources":["../../../src/routing/partitionKeyRangeCache.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAIzE,cAAc;AACd,MAAM,OAAO,sBAAsB;IAKjC,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAC9C,IAAI,CAAC,kCAAkC,GAAG,EAAE,CAAC;IAC/C,CAAC;IACD;;;;OAIG;IACI,KAAK,CAAC,sBAAsB,CACjC,cAAsB,EACtB,cAAsC,EACtC,eAAwB,KAAK;QAE7B,MAAM,YAAY,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC,KAAK,SAAS,IAAI,YAAY,EAAE;YACvF,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,2BAA2B,CACtF,cAAc,EACd,cAAc,CACf,CAAC;SACH;QACD,OAAO,IAAI,CAAC,kCAAkC,CAAC,YAAY,CAAC,CAAC;IAC/D,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,oBAAoB,CAC/B,cAAsB,EACtB,UAAsB,EACtB,cAAsC,EACtC,eAAwB,KAAK;QAE7B,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,cAAc,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAC5F,OAAO,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,2BAA2B,CACvC,cAAsB,EACtB,cAAsC;QAEtC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,uBAAuB,CACjD,KAAK,EAAE,mBAA2C,EAAE,EAAE;YACpD,OAAO,IAAI,CAAC,aAAa;iBACtB,uBAAuB,CAAC,cAAc,CAAC;iBACvC,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;QAC3C,CAAC,EACD,cAAc,EACd,kBAAkB,CAAC,uBAAuB,CAC3C,CAAC;QACF,OAAO,wBAAwB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { MetadataLookUpType } from \"../CosmosDiagnostics\";\nimport { PartitionKeyRange } from \"../client/Container/PartitionKeyRange\";\nimport { ClientContext } from \"../ClientContext\";\nimport { getIdFromLink } from \"../common/helper\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { withMetadataDiagnostics } from \"../utils/diagnostics\";\nimport { createCompleteRoutingMap } from \"./CollectionRoutingMapFactory\";\nimport { InMemoryCollectionRoutingMap } from \"./inMemoryCollectionRoutingMap\";\nimport { QueryRange } from \"./QueryRange\";\n\n/** @hidden */\nexport class PartitionKeyRangeCache {\n private collectionRoutingMapByCollectionId: {\n [key: string]: Promise;\n };\n\n constructor(private clientContext: ClientContext) {\n this.collectionRoutingMapByCollectionId = {};\n }\n /**\n * Finds or Instantiates the requested Collection Routing Map\n * @param collectionLink - Requested collectionLink\n * @hidden\n */\n public async onCollectionRoutingMap(\n collectionLink: string,\n diagnosticNode: DiagnosticNodeInternal,\n forceRefresh: boolean = false,\n ): Promise {\n const collectionId = getIdFromLink(collectionLink);\n if (this.collectionRoutingMapByCollectionId[collectionId] === undefined || forceRefresh) {\n this.collectionRoutingMapByCollectionId[collectionId] = this.requestCollectionRoutingMap(\n collectionLink,\n diagnosticNode,\n );\n }\n return this.collectionRoutingMapByCollectionId[collectionId];\n }\n\n /**\n * Given the query ranges and a collection, invokes the callback on the list of overlapping partition key ranges\n * @hidden\n */\n public async getOverlappingRanges(\n collectionLink: string,\n queryRange: QueryRange,\n diagnosticNode: DiagnosticNodeInternal,\n forceRefresh: boolean = false,\n ): Promise {\n const crm = await this.onCollectionRoutingMap(collectionLink, diagnosticNode, forceRefresh);\n return crm.getOverlappingRanges(queryRange);\n }\n\n private async requestCollectionRoutingMap(\n collectionLink: string,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n const { resources } = await withMetadataDiagnostics(\n async (metadataDiagnostics: DiagnosticNodeInternal) => {\n return this.clientContext\n .queryPartitionKeyRanges(collectionLink)\n .fetchAllInternal(metadataDiagnostics);\n },\n diagnosticNode,\n MetadataLookUpType.PartitionKeyRangeLookUp,\n );\n return createCompleteRoutingMap(resources.map((r) => [r, true]));\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts new file mode 100644 index 000000000..1e3c859c8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts @@ -0,0 +1,23 @@ +import { ClientContext } from "../ClientContext"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { QueryRange } from "./QueryRange"; +/** @hidden */ +export declare const PARITIONKEYRANGE: import("../common/constants").PartitionKeyRangePropertiesNames; +/** @hidden */ +export declare class SmartRoutingMapProvider { + private partitionKeyRangeCache; + constructor(clientContext: ClientContext); + private static _secondRangeIsAfterFirstRange; + private static _isSortedAndNonOverlapping; + private static _stringMax; + private static _stringCompare; + private static _subtractRange; + /** + * Given the sorted ranges and a collection, invokes the callback on the list of overlapping partition key ranges + * @param callback - Function execute on the overlapping partition key ranges result, + * takes two parameters error, partition key ranges + * @hidden + */ + getOverlappingRanges(collectionLink: string, sortedRanges: QueryRange[], diagnosticNode: DiagnosticNodeInternal): Promise; +} +//# sourceMappingURL=smartRoutingMapProvider.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts.map new file mode 100644 index 000000000..86ac2c75e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"smartRoutingMapProvider.d.ts","sourceRoot":"","sources":["../../../src/routing/smartRoutingMapProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,eAAO,MAAM,gBAAgB,gEAA8B,CAAC;AAE5D,cAAc;AACd,qBAAa,uBAAuB;IAClC,OAAO,CAAC,sBAAsB,CAAyB;gBAE3C,aAAa,EAAE,aAAa;IAGxC,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAsB5C,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAWzC,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B,OAAO,CAAC,MAAM,CAAC,cAAc;IAM7B;;;;;OAKG;IACU,oBAAoB,CAC/B,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,UAAU,EAAE,EAC1B,cAAc,EAAE,sBAAsB,GACrC,OAAO,CAAC,GAAG,EAAE,CAAC;CAiFlB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js new file mode 100644 index 000000000..35a8520bc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js @@ -0,0 +1,116 @@ +import { Constants } from "../common/constants"; +import { PartitionKeyRangeCache } from "./partitionKeyRangeCache"; +import { QueryRange } from "./QueryRange"; +/** @hidden */ +export const PARITIONKEYRANGE = Constants.PartitionKeyRange; +/** @hidden */ +export class SmartRoutingMapProvider { + constructor(clientContext) { + this.partitionKeyRangeCache = new PartitionKeyRangeCache(clientContext); + } + static _secondRangeIsAfterFirstRange(range1, range2) { + if (typeof range1.max === "undefined") { + throw new Error("range1 must have max"); + } + if (typeof range2.min === "undefined") { + throw new Error("range2 must have min"); + } + if (range1.max > range2.min) { + // r.min < #previous_r.max + return false; + } + else { + if (range1.max === range2.min && range1.isMaxInclusive && range2.isMinInclusive) { + // the inclusive ending endpoint of previous_r is the same as the inclusive beginning endpoint of r + // they share a point + return false; + } + return true; + } + } + static _isSortedAndNonOverlapping(ranges) { + for (let idx = 1; idx < ranges.length; idx++) { + const previousR = ranges[idx - 1]; + const r = ranges[idx]; + if (!this._secondRangeIsAfterFirstRange(previousR, r)) { + return false; + } + } + return true; + } + static _stringMax(a, b) { + return a >= b ? a : b; + } + static _stringCompare(a, b) { + return a === b ? 0 : a > b ? 1 : -1; + } + static _subtractRange(r, partitionKeyRange) { + const left = this._stringMax(partitionKeyRange[PARITIONKEYRANGE.MaxExclusive], r.min); + const leftInclusive = this._stringCompare(left, r.min) === 0 ? r.isMinInclusive : false; + return new QueryRange(left, r.max, leftInclusive, r.isMaxInclusive); + } + /** + * Given the sorted ranges and a collection, invokes the callback on the list of overlapping partition key ranges + * @param callback - Function execute on the overlapping partition key ranges result, + * takes two parameters error, partition key ranges + * @hidden + */ + async getOverlappingRanges(collectionLink, sortedRanges, diagnosticNode) { + // validate if the list is non- overlapping and sorted TODO: any PartitionKeyRanges + if (!SmartRoutingMapProvider._isSortedAndNonOverlapping(sortedRanges)) { + throw new Error("the list of ranges is not a non-overlapping sorted ranges"); + } + let partitionKeyRanges = []; // TODO: any ParitionKeyRanges + if (sortedRanges.length === 0) { + return partitionKeyRanges; + } + const collectionRoutingMap = await this.partitionKeyRangeCache.onCollectionRoutingMap(collectionLink, diagnosticNode); + let index = 0; + let currentProvidedRange = sortedRanges[index]; + for (;;) { + if (currentProvidedRange.isEmpty()) { + // skip and go to the next item + if (++index >= sortedRanges.length) { + return partitionKeyRanges; + } + currentProvidedRange = sortedRanges[index]; + continue; + } + let queryRange; + if (partitionKeyRanges.length > 0) { + queryRange = SmartRoutingMapProvider._subtractRange(currentProvidedRange, partitionKeyRanges[partitionKeyRanges.length - 1]); + } + else { + queryRange = currentProvidedRange; + } + const overlappingRanges = collectionRoutingMap.getOverlappingRanges(queryRange); + if (overlappingRanges.length <= 0) { + throw new Error(`error: returned overlapping ranges for queryRange ${queryRange} is empty`); + } + partitionKeyRanges = partitionKeyRanges.concat(overlappingRanges); + const lastKnownTargetRange = QueryRange.parsePartitionKeyRange(partitionKeyRanges[partitionKeyRanges.length - 1]); + if (!lastKnownTargetRange) { + throw new Error("expected lastKnowTargetRange to be truthy"); + } + // the overlapping ranges must contain the requested range + if (SmartRoutingMapProvider._stringCompare(currentProvidedRange.max, lastKnownTargetRange.max) > + 0) { + throw new Error(`error: returned overlapping ranges ${overlappingRanges} \ + does not contain the requested range ${queryRange}`); + } + // the current range is contained in partitionKeyRanges just move forward + if (++index >= sortedRanges.length) { + return partitionKeyRanges; + } + currentProvidedRange = sortedRanges[index]; + while (SmartRoutingMapProvider._stringCompare(currentProvidedRange.max, lastKnownTargetRange.max) <= 0) { + // the current range is covered too.just move forward + if (++index >= sortedRanges.length) { + return partitionKeyRanges; + } + currentProvidedRange = sortedRanges[index]; + } + } + } +} +//# sourceMappingURL=smartRoutingMapProvider.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js.map new file mode 100644 index 000000000..8c7ef9f95 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/routing/smartRoutingMapProvider.js.map @@ -0,0 +1 @@ +{"version":3,"file":"smartRoutingMapProvider.js","sourceRoot":"","sources":["../../../src/routing/smartRoutingMapProvider.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,cAAc;AACd,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC,iBAAiB,CAAC;AAE5D,cAAc;AACd,MAAM,OAAO,uBAAuB;IAGlC,YAAY,aAA4B;QACtC,IAAI,CAAC,sBAAsB,GAAG,IAAI,sBAAsB,CAAC,aAAa,CAAC,CAAC;IAC1E,CAAC;IACO,MAAM,CAAC,6BAA6B,CAAC,MAAkB,EAAE,MAAkB;QACjF,IAAI,OAAO,MAAM,C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N;gBACA,qDAAqD;gBACrD,IAAI,EAAE,KAAK,IAAI,YAAY,CAAC,MAAM,EAAE;oBAClC,OAAO,kBAAkB,CAAC;iBAC3B;gBACD,oBAAoB,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;aAC5C;SACF;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { Constants } from \"../common/constants\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { PartitionKeyRangeCache } from \"./partitionKeyRangeCache\";\nimport { QueryRange } from \"./QueryRange\";\n\n/** @hidden */\nexport const PARITIONKEYRANGE = Constants.PartitionKeyRange;\n\n/** @hidden */\nexport class SmartRoutingMapProvider {\n private partitionKeyRangeCache: PartitionKeyRangeCache;\n\n constructor(clientContext: ClientContext) {\n this.partitionKeyRangeCache = new PartitionKeyRangeCache(clientContext);\n }\n private static _secondRangeIsAfterFirstRange(range1: QueryRange, range2: QueryRange): boolean {\n if (typeof range1.max === \"undefined\") {\n throw new Error(\"range1 must have max\");\n }\n\n if (typeof range2.min === \"undefined\") {\n throw new Error(\"range2 must have min\");\n }\n\n if (range1.max > range2.min) {\n // r.min < #previous_r.max\n return false;\n } else {\n if (range1.max === range2.min && range1.isMaxInclusive && range2.isMinInclusive) {\n // the inclusive ending endpoint of previous_r is the same as the inclusive beginning endpoint of r\n // they share a point\n return false;\n }\n return true;\n }\n }\n\n private static _isSortedAndNonOverlapping(ranges: QueryRange[]): boolean {\n for (let idx = 1; idx < ranges.length; idx++) {\n const previousR = ranges[idx - 1];\n const r = ranges[idx];\n if (!this._secondRangeIsAfterFirstRange(previousR, r)) {\n return false;\n }\n }\n return true;\n }\n\n private static _stringMax(a: string, b: string): string {\n return a >= b ? a : b;\n }\n\n private static _stringCompare(a: string, b: string): 1 | 0 | -1 {\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n private static _subtractRange(r: QueryRange, partitionKeyRange: any): QueryRange {\n const left = this._stringMax(partitionKeyRange[PARITIONKEYRANGE.MaxExclusive], r.min);\n const leftInclusive = this._stringCompare(left, r.min) === 0 ? r.isMinInclusive : false;\n return new QueryRange(left, r.max, leftInclusive, r.isMaxInclusive);\n }\n\n /**\n * Given the sorted ranges and a collection, invokes the callback on the list of overlapping partition key ranges\n * @param callback - Function execute on the overlapping partition key ranges result,\n * takes two parameters error, partition key ranges\n * @hidden\n */\n public async getOverlappingRanges(\n collectionLink: string,\n sortedRanges: QueryRange[],\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n // validate if the list is non- overlapping and sorted TODO: any PartitionKeyRanges\n if (!SmartRoutingMapProvider._isSortedAndNonOverlapping(sortedRanges)) {\n throw new Error(\"the list of ranges is not a non-overlapping sorted ranges\");\n }\n\n let partitionKeyRanges: any[] = []; // TODO: any ParitionKeyRanges\n\n if (sortedRanges.length === 0) {\n return partitionKeyRanges;\n }\n\n const collectionRoutingMap = await this.partitionKeyRangeCache.onCollectionRoutingMap(\n collectionLink,\n diagnosticNode,\n );\n\n let index = 0;\n let currentProvidedRange = sortedRanges[index];\n for (;;) {\n if (currentProvidedRange.isEmpty()) {\n // skip and go to the next item\n if (++index >= sortedRanges.length) {\n return partitionKeyRanges;\n }\n currentProvidedRange = sortedRanges[index];\n continue;\n }\n\n let queryRange;\n if (partitionKeyRanges.length > 0) {\n queryRange = SmartRoutingMapProvider._subtractRange(\n currentProvidedRange,\n partitionKeyRanges[partitionKeyRanges.length - 1],\n );\n } else {\n queryRange = currentProvidedRange;\n }\n\n const overlappingRanges = collectionRoutingMap.getOverlappingRanges(queryRange);\n if (overlappingRanges.length <= 0) {\n throw new Error(`error: returned overlapping ranges for queryRange ${queryRange} is empty`);\n }\n partitionKeyRanges = partitionKeyRanges.concat(overlappingRanges);\n\n const lastKnownTargetRange = QueryRange.parsePartitionKeyRange(\n partitionKeyRanges[partitionKeyRanges.length - 1],\n );\n if (!lastKnownTargetRange) {\n throw new Error(\"expected lastKnowTargetRange to be truthy\");\n }\n // the overlapping ranges must contain the requested range\n\n if (\n SmartRoutingMapProvider._stringCompare(currentProvidedRange.max, lastKnownTargetRange.max) >\n 0\n ) {\n throw new Error(`error: returned overlapping ranges ${overlappingRanges} \\\n does not contain the requested range ${queryRange}`);\n }\n\n // the current range is contained in partitionKeyRanges just move forward\n if (++index >= sortedRanges.length) {\n return partitionKeyRanges;\n }\n currentProvidedRange = sortedRanges[index];\n\n while (\n SmartRoutingMapProvider._stringCompare(\n currentProvidedRange.max,\n lastKnownTargetRange.max,\n ) <= 0\n ) {\n // the current range is covered too.just move forward\n if (++index >= sortedRanges.length) {\n return partitionKeyRanges;\n }\n currentProvidedRange = sortedRanges[index];\n }\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts new file mode 100644 index 000000000..67d780243 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts @@ -0,0 +1,12 @@ +import { OperationType, ResourceType } from "../common"; +/** + * @hidden + */ +export interface SessionContext { + resourceId?: string; + resourceAddress?: string; + resourceType?: ResourceType; + isNameBased?: boolean; + operationType?: OperationType; +} +//# sourceMappingURL=SessionContext.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts.map new file mode 100644 index 000000000..ec636be7f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"SessionContext.d.ts","sourceRoot":"","sources":["../../../src/session/SessionContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js new file mode 100644 index 000000000..1facdaeff --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=SessionContext.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js.map new file mode 100644 index 000000000..2ff872528 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/SessionContext.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SessionContext.js","sourceRoot":"","sources":["../../../src/session/SessionContext.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OperationType, ResourceType } from \"../common\";\n\n/**\n * @hidden\n */\nexport interface SessionContext {\n resourceId?: string;\n resourceAddress?: string;\n resourceType?: ResourceType;\n isNameBased?: boolean;\n operationType?: OperationType;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts new file mode 100644 index 000000000..6476744bb --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts @@ -0,0 +1,26 @@ +/** + * Models vector clock bases session token. Session token has the following format: + * `{Version}#{GlobalLSN}#{RegionId1}={LocalLsn1}#{RegionId2}={LocalLsn2}....#{RegionIdN}={LocalLsnN}` + * 'Version' captures the configuration number of the partition which returned this session token. + * 'Version' is incremented everytime topology of the partition is updated (say due to Add/Remove/Failover). + * + * The choice of separators '#' and '=' is important. Separators ';' and ',' are used to delimit + * per-partitionKeyRange session token + * @hidden + * + */ +export declare class VectorSessionToken { + private readonly version; + private readonly globalLsn; + private readonly localLsnByregion; + private readonly sessionToken?; + private static readonly SEGMENT_SEPARATOR; + private static readonly REGION_PROGRESS_SEPARATOR; + constructor(version: number, globalLsn: number, localLsnByregion: Map, sessionToken?: string); + static create(sessionToken: string): VectorSessionToken | null; + equals(other: VectorSessionToken): boolean; + merge(other: VectorSessionToken): VectorSessionToken; + toString(): string | undefined; + private areRegionProgressEqual; +} +//# sourceMappingURL=VectorSessionToken.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts.map new file mode 100644 index 000000000..13faed1c4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"VectorSessionToken.d.ts","sourceRoot":"","sources":["../../../src/session/VectorSessionToken.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,qBAAa,kBAAkB;IAK3B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC;IAPhC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAO;gBAGrC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,YAAY,CAAC,EAAE,MAAM;WAgB1B,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI;IAwC9D,MAAM,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO;IAQ1C,KAAK,CAAC,KAAK,EAAE,kBAAkB,GAAG,kBAAkB;IAyCpD,QAAQ,IAAI,MAAM,GAAG,SAAS;IAIrC,OAAO,CAAC,sBAAsB;CAc/B"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js new file mode 100644 index 000000000..3af287b8f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Models vector clock bases session token. Session token has the following format: + * `{Version}#{GlobalLSN}#{RegionId1}={LocalLsn1}#{RegionId2}={LocalLsn2}....#{RegionIdN}={LocalLsnN}` + * 'Version' captures the configuration number of the partition which returned this session token. + * 'Version' is incremented everytime topology of the partition is updated (say due to Add/Remove/Failover). + * + * The choice of separators '#' and '=' is important. Separators ';' and ',' are used to delimit + * per-partitionKeyRange session token + * @hidden + * + */ +export class VectorSessionToken { + constructor(version, globalLsn, localLsnByregion, sessionToken) { + this.version = version; + this.globalLsn = globalLsn; + this.localLsnByregion = localLsnByregion; + this.sessionToken = sessionToken; + if (!this.sessionToken) { + const regionAndLocalLsn = []; + for (const [key, value] of this.localLsnByregion.entries()) { + regionAndLocalLsn.push(`${key}${VectorSessionToken.REGION_PROGRESS_SEPARATOR}${value}`); + } + const regionProgress = regionAndLocalLsn.join(VectorSessionToken.SEGMENT_SEPARATOR); + if (regionProgress === "") { + this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}`; + } + else { + this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}${VectorSessionToken.SEGMENT_SEPARATOR}${regionProgress}`; + } + } + } + static create(sessionToken) { + const [versionStr, globalLsnStr, ...regionSegments] = sessionToken.split(VectorSessionToken.SEGMENT_SEPARATOR); + const version = parseInt(versionStr, 10); + const globalLsn = parseFloat(globalLsnStr); + if (typeof version !== "number" || typeof globalLsn !== "number") { + return null; + } + const lsnByRegion = new Map(); + for (const regionSegment of regionSegments) { + const [regionIdStr, localLsnStr] = regionSegment.split(VectorSessionToken.REGION_PROGRESS_SEPARATOR); + if (!regionIdStr || !localLsnStr) { + return null; + } + const regionId = parseInt(regionIdStr, 10); + let localLsn; + try { + localLsn = localLsnStr; + } + catch (err) { + // TODO: log error + return null; + } + if (typeof regionId !== "number") { + return null; + } + lsnByRegion.set(regionId, localLsn); + } + return new VectorSessionToken(version, globalLsn, lsnByRegion, sessionToken); + } + equals(other) { + return !other + ? false + : this.version === other.version && + this.globalLsn === other.globalLsn && + this.areRegionProgressEqual(other.localLsnByregion); + } + merge(other) { + if (other == null) { + throw new Error("other (Vector Session Token) must not be null"); + } + if (this.version === other.version && + this.localLsnByregion.size !== other.localLsnByregion.size) { + throw new Error(`Compared session tokens ${this.sessionToken} and ${other.sessionToken} have unexpected regions`); + } + const [higherVersionSessionToken, lowerVersionSessionToken] = this.version < other.version ? [other, this] : [this, other]; + const highestLocalLsnByRegion = new Map(); + for (const [regionId, highLocalLsn] of higherVersionSessionToken.localLsnByregion.entries()) { + const lowLocalLsn = lowerVersionSessionToken.localLsnByregion.get(regionId); + if (lowLocalLsn) { + highestLocalLsnByRegion.set(regionId, max(highLocalLsn, lowLocalLsn)); + } + else if (this.version === other.version) { + throw new Error(`Compared session tokens have unexpected regions. Session 1: ${this.sessionToken} - Session 2: ${this.sessionToken}`); + } + else { + highestLocalLsnByRegion.set(regionId, highLocalLsn); + } + } + return new VectorSessionToken(Math.max(this.version, other.version), Math.max(this.globalLsn, other.globalLsn), highestLocalLsnByRegion); + } + toString() { + return this.sessionToken; + } + areRegionProgressEqual(other) { + if (this.localLsnByregion.size !== other.size) { + return false; + } + for (const [regionId, localLsn] of this.localLsnByregion.entries()) { + const otherLocalLsn = other.get(regionId); + if (localLsn !== otherLocalLsn) { + return false; + } + } + return true; + } +} +VectorSessionToken.SEGMENT_SEPARATOR = "#"; +VectorSessionToken.REGION_PROGRESS_SEPARATOR = "="; +/** + * @hidden + */ +function max(int1, int2) { + // NOTE: This only works for positive numbers + if (int1.length === int2.length) { + return int1 > int2 ? int1 : int2; + } + else if (int1.length > int2.length) { + return int1; + } + else { + return int2; + } +} +//# sourceMappingURL=VectorSessionToken.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js.map new file mode 100644 index 000000000..f1b3ea538 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/VectorSessionToken.js.map @@ -0,0 +1 @@ +{"version":3,"file":"VectorSessionToken.js","sourceRoot":"","sources":["../../../src/session/VectorSessionToken.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC;;;;;;;;;;GAUG;AACH,MAAM,OAAO,kBAAkB;IAI7B,YACmB,OAAe,EACf,SAAiB,EACjB,gBAAqC,EACrC,YAAqB;QAHrB,YAAO,GAAP,OAAO,CAAQ;QACf,cAAS,GAAT,SAAS,CAAQ;QACjB,qBAAgB,GAAhB,gBAAgB,CAAqB;QACrC,iBAAY,GAAZ,YAAY,CAAS;QAEtC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,MAAM,iBAAiB,GAAG,EAAE,CAAC;YAC7B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,EAAE;gBAC1D,iBAAiB,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,kBAAkB,CAAC,yBAAyB,GAAG,KAAK,EAAE,CAAC,CAAC;aACzF;YACD,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,C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ACH,SAAS,GAAG,CAAC,IAAY,EAAE,IAAY;IACrC,6CAA6C;IAC7C,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;QAC/B,OAAO,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;KAClC;SAAM,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE;QACpC,OAAO,IAAI,CAAC;KACb;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Models vector clock bases session token. Session token has the following format:\n * `{Version}#{GlobalLSN}#{RegionId1}={LocalLsn1}#{RegionId2}={LocalLsn2}....#{RegionIdN}={LocalLsnN}`\n * 'Version' captures the configuration number of the partition which returned this session token.\n * 'Version' is incremented everytime topology of the partition is updated (say due to Add/Remove/Failover).\n *\n * The choice of separators '#' and '=' is important. Separators ';' and ',' are used to delimit\n * per-partitionKeyRange session token\n * @hidden\n *\n */\nexport class VectorSessionToken {\n private static readonly SEGMENT_SEPARATOR = \"#\";\n private static readonly REGION_PROGRESS_SEPARATOR = \"=\";\n\n constructor(\n private readonly version: number,\n private readonly globalLsn: number,\n private readonly localLsnByregion: Map,\n private readonly sessionToken?: string,\n ) {\n if (!this.sessionToken) {\n const regionAndLocalLsn = [];\n for (const [key, value] of this.localLsnByregion.entries()) {\n regionAndLocalLsn.push(`${key}${VectorSessionToken.REGION_PROGRESS_SEPARATOR}${value}`);\n }\n const regionProgress = regionAndLocalLsn.join(VectorSessionToken.SEGMENT_SEPARATOR);\n if (regionProgress === \"\") {\n this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}`;\n } else {\n this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}${VectorSessionToken.SEGMENT_SEPARATOR}${regionProgress}`;\n }\n }\n }\n\n public static create(sessionToken: string): VectorSessionToken | null {\n const [versionStr, globalLsnStr, ...regionSegments] = sessionToken.split(\n VectorSessionToken.SEGMENT_SEPARATOR,\n );\n\n const version = parseInt(versionStr, 10);\n const globalLsn = parseFloat(globalLsnStr);\n\n if (typeof version !== \"number\" || typeof globalLsn !== \"number\") {\n return null;\n }\n\n const lsnByRegion = new Map();\n for (const regionSegment of regionSegments) {\n const [regionIdStr, localLsnStr] = regionSegment.split(\n VectorSessionToken.REGION_PROGRESS_SEPARATOR,\n );\n\n if (!regionIdStr || !localLsnStr) {\n return null;\n }\n\n const regionId = parseInt(regionIdStr, 10);\n let localLsn: string;\n try {\n localLsn = localLsnStr;\n } catch (err: any) {\n // TODO: log error\n return null;\n }\n if (typeof regionId !== \"number\") {\n return null;\n }\n\n lsnByRegion.set(regionId, localLsn);\n }\n\n return new VectorSessionToken(version, globalLsn, lsnByRegion, sessionToken);\n }\n\n public equals(other: VectorSessionToken): boolean {\n return !other\n ? false\n : this.version === other.version &&\n this.globalLsn === other.globalLsn &&\n this.areRegionProgressEqual(other.localLsnByregion);\n }\n\n public merge(other: VectorSessionToken): VectorSessionToken {\n if (other == null) {\n throw new Error(\"other (Vector Session Token) must not be null\");\n }\n\n if (\n this.version === other.version &&\n this.localLsnByregion.size !== other.localLsnByregion.size\n ) {\n throw new Error(\n `Compared session tokens ${this.sessionToken} and ${other.sessionToken} have unexpected regions`,\n );\n }\n\n const [higherVersionSessionToken, lowerVersionSessionToken]: [\n VectorSessionToken,\n VectorSessionToken,\n ] = this.version < other.version ? [other, this] : [this, other];\n\n const highestLocalLsnByRegion = new Map();\n\n for (const [regionId, highLocalLsn] of higherVersionSessionToken.localLsnByregion.entries()) {\n const lowLocalLsn = lowerVersionSessionToken.localLsnByregion.get(regionId);\n if (lowLocalLsn) {\n highestLocalLsnByRegion.set(regionId, max(highLocalLsn, lowLocalLsn));\n } else if (this.version === other.version) {\n throw new Error(\n `Compared session tokens have unexpected regions. Session 1: ${this.sessionToken} - Session 2: ${this.sessionToken}`,\n );\n } else {\n highestLocalLsnByRegion.set(regionId, highLocalLsn);\n }\n }\n\n return new VectorSessionToken(\n Math.max(this.version, other.version),\n Math.max(this.globalLsn, other.globalLsn),\n highestLocalLsnByRegion,\n );\n }\n\n public toString(): string | undefined {\n return this.sessionToken;\n }\n\n private areRegionProgressEqual(other: Map): boolean {\n if (this.localLsnByregion.size !== other.size) {\n return false;\n }\n\n for (const [regionId, localLsn] of this.localLsnByregion.entries()) {\n const otherLocalLsn = other.get(regionId);\n\n if (localLsn !== otherLocalLsn) {\n return false;\n }\n }\n return true;\n }\n}\n\n/**\n * @hidden\n */\nfunction max(int1: string, int2: string): string {\n // NOTE: This only works for positive numbers\n if (int1.length === int2.length) {\n return int1 > int2 ? int1 : int2;\n } else if (int1.length > int2.length) {\n return int1;\n } else {\n return int2;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts new file mode 100644 index 000000000..20afddd14 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts @@ -0,0 +1,22 @@ +import { CosmosHeaders } from "../queryExecutionContext"; +import { SessionContext } from "./SessionContext"; +import { VectorSessionToken } from "./VectorSessionToken"; +/** @hidden */ +export declare class SessionContainer { + private collectionNameToCollectionResourceId; + private collectionResourceIdToSessionTokens; + private static readonly EMPTY_SESSION_TOKEN; + private static readonly SESSION_TOKEN_SEPARATOR; + private static readonly SESSION_TOKEN_PARTITION_SPLITTER; + constructor(collectionNameToCollectionResourceId?: Map, collectionResourceIdToSessionTokens?: Map>); + get(request: SessionContext): string; + remove(request: SessionContext): void; + set(request: SessionContext, resHeaders: CosmosHeaders): void; + private validateOwnerID; + private getPartitionKeyRangeIdToTokenMap; + private static getCombinedSessionTokenString; + private static compareAndSetToken; + private static isReadingFromMaster; + private getContainerName; +} +//# sourceMappingURL=sessionContainer.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts.map new file mode 100644 index 000000000..e583e1b77 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"sessionContainer.d.ts","sourceRoot":"","sources":["../../../src/session/sessionContainer.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,cAAc;AACd,qBAAa,gBAAgB;IAKzB,OAAO,CAAC,oCAAoC;IAC5C,OAAO,CAAC,mCAAmC;IAL7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAM;IACjD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAO;IACtD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gCAAgC,CAAO;gBAErD,oCAAoC,sBAA4B,EAChE,mCAAmC,+CAGxC;IAGE,GAAG,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM;IASpC,MAAM,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI;IAarC,GAAG,CAAC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,GAAG,IAAI;IAsCpE,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,gCAAgC;IAaxC,OAAO,CAAC,MAAM,CAAC,6BAA6B;IAgB5C,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAyBjC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAqBlC,OAAO,CAAC,gBAAgB;CAQzB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js new file mode 100644 index 000000000..202b83791 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import atob from "../utils/atob"; +import { Constants, getContainerLink, OperationType, trimSlashes } from "../common"; +import { VectorSessionToken } from "./VectorSessionToken"; +/** @hidden */ +export class SessionContainer { + constructor(collectionNameToCollectionResourceId = new Map(), collectionResourceIdToSessionTokens = new Map()) { + this.collectionNameToCollectionResourceId = collectionNameToCollectionResourceId; + this.collectionResourceIdToSessionTokens = collectionResourceIdToSessionTokens; + } + get(request) { + if (!request) { + throw new Error("request cannot be null"); + } + const collectionName = getContainerLink(trimSlashes(request.resourceAddress)); + const rangeIdToTokenMap = this.getPartitionKeyRangeIdToTokenMap(collectionName); + return SessionContainer.getCombinedSessionTokenString(rangeIdToTokenMap); + } + remove(request) { + let collectionResourceId; + const resourceAddress = trimSlashes(request.resourceAddress); + const collectionName = getContainerLink(resourceAddress); + if (collectionName) { + collectionResourceId = this.collectionNameToCollectionResourceId.get(collectionName); + this.collectionNameToCollectionResourceId.delete(collectionName); + } + if (collectionResourceId !== undefined) { + this.collectionResourceIdToSessionTokens.delete(collectionResourceId); + } + } + set(request, resHeaders) { + // TODO: we check the master logic a few different places. Might not need it. + if (!resHeaders || + SessionContainer.isReadingFromMaster(request.resourceType, request.operationType)) { + return; + } + const sessionTokenString = resHeaders[Constants.HttpHeaders.SessionToken]; + if (!sessionTokenString) { + return; + } + const containerName = this.getContainerName(request, resHeaders); + const ownerId = !request.isNameBased + ? request.resourceId + : resHeaders[Constants.HttpHeaders.OwnerId] || request.resourceId; + if (!ownerId) { + return; + } + if (containerName && this.validateOwnerID(ownerId)) { + if (!this.collectionResourceIdToSessionTokens.has(ownerId)) { + this.collectionResourceIdToSessionTokens.set(ownerId, new Map()); + } + if (!this.collectionNameToCollectionResourceId.has(containerName)) { + this.collectionNameToCollectionResourceId.set(containerName, ownerId); + } + const containerSessionContainer = this.collectionResourceIdToSessionTokens.get(ownerId); + SessionContainer.compareAndSetToken(sessionTokenString, containerSessionContainer); + } + } + validateOwnerID(ownerId) { + // If ownerId contains exactly 8 bytes it represents a unique database+collection identifier. Otherwise it represents another resource + // The first 4 bytes are the database. The last 4 bytes are the collection. + // Cosmos rids potentially contain "-" which is an invalid character in the browser atob implementation + // See https://en.wikipedia.org/wiki/Base64#Filenames + return atob(ownerId.replace(/-/g, "/")).length === 8; + } + getPartitionKeyRangeIdToTokenMap(collectionName) { + let rangeIdToTokenMap = null; + if (collectionName && this.collectionNameToCollectionResourceId.has(collectionName)) { + rangeIdToTokenMap = this.collectionResourceIdToSessionTokens.get(this.collectionNameToCollectionResourceId.get(collectionName)); + } + return rangeIdToTokenMap; + } + static getCombinedSessionTokenString(tokens) { + if (!tokens || tokens.size === 0) { + return SessionContainer.EMPTY_SESSION_TOKEN; + } + let result = ""; + for (const [range, token] of tokens.entries()) { + result += + range + + SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER + + token.toString() + + SessionContainer.SESSION_TOKEN_SEPARATOR; + } + return result.slice(0, -1); + } + static compareAndSetToken(newTokenString, containerSessionTokens) { + if (!newTokenString) { + return; + } + const partitionsParts = newTokenString.split(SessionContainer.SESSION_TOKEN_SEPARATOR); + for (const partitionPart of partitionsParts) { + const newTokenParts = partitionPart.split(SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER); + if (newTokenParts.length !== 2) { + return; + } + const range = newTokenParts[0]; + const newToken = VectorSessionToken.create(newTokenParts[1]); + const tokenForRange = !containerSessionTokens.get(range) + ? newToken + : containerSessionTokens.get(range).merge(newToken); + containerSessionTokens.set(range, tokenForRange); + } + } + // TODO: have a assert if the type doesn't mastch known types + static isReadingFromMaster(resourceType, operationType) { + if (resourceType === Constants.Path.OffersPathSegment || + resourceType === Constants.Path.DatabasesPathSegment || + resourceType === Constants.Path.UsersPathSegment || + resourceType === Constants.Path.PermissionsPathSegment || + resourceType === Constants.Path.TopologyPathSegment || + resourceType === Constants.Path.DatabaseAccountPathSegment || + resourceType === Constants.Path.PartitionKeyRangesPathSegment || + (resourceType === Constants.Path.CollectionsPathSegment && + operationType === OperationType.Query)) { + return true; + } + return false; + } + getContainerName(request, headers) { + let ownerFullName = headers[Constants.HttpHeaders.OwnerFullName]; + if (!ownerFullName) { + ownerFullName = trimSlashes(request.resourceAddress); + } + return getContainerLink(ownerFullName); + } +} +SessionContainer.EMPTY_SESSION_TOKEN = ""; +SessionContainer.SESSION_TOKEN_SEPARATOR = ","; +SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER = ":"; +//# sourceMappingURL=sessionContainer.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js.map new file mode 100644 index 000000000..a037dc4b7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/session/sessionContainer.js.map @@ -0,0 +1 @@ +{"version":3,"file":"sessionContainer.js","sourceRoot":"","sources":["../../../src/session/sessionContainer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAgB,WAAW,EAAE,MAAM,WAAW,CAAC;AAGlG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,cAAc;AACd,MAAM,OAAO,gBAAgB;IAI3B,YACU,uCAAuC,IAAI,GAAG,EAAkB,EAChE,sCAAsC,IAAI,GAAG,EAGlD;QAJK,yCAAoC,GAApC,oCAAoC,CAA4B;QAChE,wCAAmC,GAAnC,mCAAmC,CAGxC;IACF,CAAC;IAEG,GAAG,CAAC,OAAuB;QAChC,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QACD,MAAM,cAA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AAmB,CAChC,YAA0B,EAC1B,aAA4B;QAE5B,IACE,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,iBAAiB;YACjD,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,oBAAoB;YACpD,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,gBAAgB;YAChD,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,sBAAsB;YACtD,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,mBAAmB;YACnD,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,0BAA0B;YAC1D,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,6BAA6B;YAC7D,CAAC,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,sBAAsB;gBACrD,aAAa,KAAK,aAAa,CAAC,KAAK,CAAC,EACxC;YACA,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,gBAAgB,CAAC,OAAuB,EAAE,OAAsB;QACtE,IAAI,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;QACjE,IAAI,CAAC,aAAa,EAAE;YAClB,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;SACtD;QAED,OAAO,gBAAgB,CAAC,aAAuB,CAAC,CAAC;IACnD,CAAC;;AAjKuB,oCAAmB,GAAG,EAAE,CAAC;AACzB,wCAAuB,GAAG,GAAG,CAAC;AAC9B,iDAAgC,GAAG,GAAG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport atob from \"../utils/atob\";\nimport { Constants, getContainerLink, OperationType, ResourceType, trimSlashes } from \"../common\";\nimport { CosmosHeaders } from \"../queryExecutionContext\";\nimport { SessionContext } from \"./SessionContext\";\nimport { VectorSessionToken } from \"./VectorSessionToken\";\n\n/** @hidden */\nexport class SessionContainer {\n private static readonly EMPTY_SESSION_TOKEN = \"\";\n private static readonly SESSION_TOKEN_SEPARATOR = \",\";\n private static readonly SESSION_TOKEN_PARTITION_SPLITTER = \":\";\n constructor(\n private collectionNameToCollectionResourceId = new Map(),\n private collectionResourceIdToSessionTokens = new Map<\n string,\n Map\n >(),\n ) {}\n\n public get(request: SessionContext): string {\n if (!request) {\n throw new Error(\"request cannot be null\");\n }\n const collectionName = getContainerLink(trimSlashes(request.resourceAddress));\n const rangeIdToTokenMap = this.getPartitionKeyRangeIdToTokenMap(collectionName);\n return SessionContainer.getCombinedSessionTokenString(rangeIdToTokenMap);\n }\n\n public remove(request: SessionContext): void {\n let collectionResourceId: string;\n const resourceAddress = trimSlashes(request.resourceAddress);\n const collectionName = getContainerLink(resourceAddress);\n if (collectionName) {\n collectionResourceId = this.collectionNameToCollectionResourceId.get(collectionName);\n this.collectionNameToCollectionResourceId.delete(collectionName);\n }\n if (collectionResourceId !== undefined) {\n this.collectionResourceIdToSessionTokens.delete(collectionResourceId);\n }\n }\n\n public set(request: SessionContext, resHeaders: CosmosHeaders): void {\n // TODO: we check the master logic a few different places. Might not need it.\n if (\n !resHeaders ||\n SessionContainer.isReadingFromMaster(request.resourceType, request.operationType)\n ) {\n return;\n }\n\n const sessionTokenString = resHeaders[Constants.HttpHeaders.SessionToken];\n if (!sessionTokenString) {\n return;\n }\n\n const containerName = this.getContainerName(request, resHeaders);\n\n const ownerId = !request.isNameBased\n ? request.resourceId\n : resHeaders[Constants.HttpHeaders.OwnerId] || request.resourceId;\n\n if (!ownerId) {\n return;\n }\n\n if (containerName && this.validateOwnerID(ownerId)) {\n if (!this.collectionResourceIdToSessionTokens.has(ownerId)) {\n this.collectionResourceIdToSessionTokens.set(ownerId, new Map());\n }\n\n if (!this.collectionNameToCollectionResourceId.has(containerName)) {\n this.collectionNameToCollectionResourceId.set(containerName, ownerId);\n }\n\n const containerSessionContainer = this.collectionResourceIdToSessionTokens.get(ownerId);\n SessionContainer.compareAndSetToken(sessionTokenString, containerSessionContainer);\n }\n }\n\n private validateOwnerID(ownerId: string): boolean {\n // If ownerId contains exactly 8 bytes it represents a unique database+collection identifier. Otherwise it represents another resource\n // The first 4 bytes are the database. The last 4 bytes are the collection.\n // Cosmos rids potentially contain \"-\" which is an invalid character in the browser atob implementation\n // See https://en.wikipedia.org/wiki/Base64#Filenames\n return atob(ownerId.replace(/-/g, \"/\")).length === 8;\n }\n\n private getPartitionKeyRangeIdToTokenMap(\n collectionName: string,\n ): Map {\n let rangeIdToTokenMap: Map = null;\n if (collectionName && this.collectionNameToCollectionResourceId.has(collectionName)) {\n rangeIdToTokenMap = this.collectionResourceIdToSessionTokens.get(\n this.collectionNameToCollectionResourceId.get(collectionName),\n );\n }\n\n return rangeIdToTokenMap;\n }\n\n private static getCombinedSessionTokenString(tokens: Map): string {\n if (!tokens || tokens.size === 0) {\n return SessionContainer.EMPTY_SESSION_TOKEN;\n }\n\n let result = \"\";\n for (const [range, token] of tokens.entries()) {\n result +=\n range +\n SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER +\n token.toString() +\n SessionContainer.SESSION_TOKEN_SEPARATOR;\n }\n return result.slice(0, -1);\n }\n\n private static compareAndSetToken(\n newTokenString: string,\n containerSessionTokens: Map,\n ): void {\n if (!newTokenString) {\n return;\n }\n\n const partitionsParts = newTokenString.split(SessionContainer.SESSION_TOKEN_SEPARATOR);\n for (const partitionPart of partitionsParts) {\n const newTokenParts = partitionPart.split(SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER);\n if (newTokenParts.length !== 2) {\n return;\n }\n\n const range = newTokenParts[0];\n const newToken = VectorSessionToken.create(newTokenParts[1]);\n const tokenForRange = !containerSessionTokens.get(range)\n ? newToken\n : containerSessionTokens.get(range).merge(newToken);\n containerSessionTokens.set(range, tokenForRange);\n }\n }\n\n // TODO: have a assert if the type doesn't mastch known types\n private static isReadingFromMaster(\n resourceType: ResourceType,\n operationType: OperationType,\n ): boolean {\n if (\n resourceType === Constants.Path.OffersPathSegment ||\n resourceType === Constants.Path.DatabasesPathSegment ||\n resourceType === Constants.Path.UsersPathSegment ||\n resourceType === Constants.Path.PermissionsPathSegment ||\n resourceType === Constants.Path.TopologyPathSegment ||\n resourceType === Constants.Path.DatabaseAccountPathSegment ||\n resourceType === Constants.Path.PartitionKeyRangesPathSegment ||\n (resourceType === Constants.Path.CollectionsPathSegment &&\n operationType === OperationType.Query)\n ) {\n return true;\n }\n\n return false;\n }\n\n private getContainerName(request: SessionContext, headers: CosmosHeaders): string {\n let ownerFullName = headers[Constants.HttpHeaders.OwnerFullName];\n if (!ownerFullName) {\n ownerFullName = trimSlashes(request.resourceAddress);\n }\n\n return getContainerLink(ownerFullName as string);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts new file mode 100644 index 000000000..d8e78e7d8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts @@ -0,0 +1,11 @@ +import { SasTokenProperties } from "../client/SasToken/SasTokenProperties"; +/** + * Experimental internal only + * Generates the payload representing the permission configuration for the sas token. + */ +export declare function createAuthorizationSasToken(masterKey: string, sasTokenProperties: SasTokenProperties): Promise; +/** + * @hidden + */ +export declare function utcsecondsSinceEpoch(date: Date): number; +//# sourceMappingURL=SasToken.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts.map new file mode 100644 index 000000000..08c5f7704 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"SasToken.d.ts","sourceRoot":"","sources":["../../../src/utils/SasToken.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAK3E;;;GAGG;AAEH,wBAAsB,2BAA2B,CAC/C,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,kBAAkB,GACrC,OAAO,CAAC,MAAM,CAAC,CAmIjB;AACD;;GAEG;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEvD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js new file mode 100644 index 000000000..5d8c01107 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { Constants, CosmosKeyType, SasTokenPermissionKind } from "../common"; +import { encodeUTF8 } from "./encode"; +import { hmac } from "./hmac"; +/** + * Experimental internal only + * Generates the payload representing the permission configuration for the sas token. + */ +export async function createAuthorizationSasToken(masterKey, sasTokenProperties) { + let resourcePrefixPath = ""; + if (typeof sasTokenProperties.databaseName === "string" && + sasTokenProperties.databaseName !== "") { + resourcePrefixPath += `/${Constants.Path.DatabasesPathSegment}/${sasTokenProperties.databaseName}`; + } + if (typeof sasTokenProperties.containerName === "string" && + sasTokenProperties.containerName !== "") { + if (sasTokenProperties.databaseName === "") { + throw new Error(`illegalArgumentException : ${sasTokenProperties.databaseName} \ + is an invalid database name`); + } + resourcePrefixPath += `/${Constants.Path.CollectionsPathSegment}/${sasTokenProperties.containerName}`; + } + if (typeof sasTokenProperties.resourceName === "string" && + sasTokenProperties.resourceName !== "") { + if (sasTokenProperties.containerName === "") { + throw new Error(`illegalArgumentException : ${sasTokenProperties.containerName} \ + is an invalid container name`); + } + switch (sasTokenProperties.resourceKind) { + case "ITEM": + resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.DocumentsPathSegment}`; + break; + case "STORED_PROCEDURE": + resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.StoredProceduresPathSegment}`; + break; + case "USER_DEFINED_FUNCTION": + resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.UserDefinedFunctionsPathSegment}`; + break; + case "TRIGGER": + resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.TriggersPathSegment}`; + break; + default: + throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \ + is an invalid resource kind`); + break; + } + resourcePrefixPath += `${Constants.Path.Root}${sasTokenProperties.resourceName}${Constants.Path.Root}`; + } + sasTokenProperties.resourcePath = resourcePrefixPath.toString(); + let partitionRanges = ""; + if (sasTokenProperties.partitionKeyValueRanges !== undefined && + sasTokenProperties.partitionKeyValueRanges.length > 0) { + if (typeof sasTokenProperties.resourceKind !== "string" && + sasTokenProperties.resourceKind !== "ITEM") { + throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \ + is an invalid partition key value range`); + } + sasTokenProperties.partitionKeyValueRanges.forEach((range) => { + partitionRanges += `${encodeUTF8(range)},`; + }); + } + if (sasTokenProperties.controlPlaneReaderScope === 0) { + sasTokenProperties.controlPlaneReaderScope += SasTokenPermissionKind.ContainerReadAny; + sasTokenProperties.controlPlaneWriterScope += SasTokenPermissionKind.ContainerReadAny; + } + if (sasTokenProperties.dataPlaneReaderScope === 0 && + sasTokenProperties.dataPlaneWriterScope === 0) { + sasTokenProperties.dataPlaneReaderScope = SasTokenPermissionKind.ContainerFullAccess; + sasTokenProperties.dataPlaneWriterScope = SasTokenPermissionKind.ContainerFullAccess; + } + if (typeof sasTokenProperties.keyType !== "number" || + typeof sasTokenProperties.keyType === undefined) { + switch (sasTokenProperties.keyType) { + case CosmosKeyType.PrimaryMaster: + sasTokenProperties.keyType = 1; + break; + case CosmosKeyType.SecondaryMaster: + sasTokenProperties.keyType = 2; + break; + case CosmosKeyType.PrimaryReadOnly: + sasTokenProperties.keyType = 3; + break; + case CosmosKeyType.SecondaryReadOnly: + sasTokenProperties.keyType = 4; + break; + default: + throw new Error(`illegalArgumentException : ${sasTokenProperties.keyType} \ + is an invalid key type`); + break; + } + } + const payload = sasTokenProperties.user + + "\n" + + sasTokenProperties.userTag + + "\n" + + sasTokenProperties.resourcePath + + "\n" + + partitionRanges + + "\n" + + utcsecondsSinceEpoch(sasTokenProperties.startTime).toString(16) + + "\n" + + utcsecondsSinceEpoch(sasTokenProperties.expiryTime).toString(16) + + "\n" + + sasTokenProperties.keyType + + "\n" + + sasTokenProperties.controlPlaneReaderScope.toString(16) + + "\n" + + sasTokenProperties.controlPlaneWriterScope.toString(16) + + "\n" + + sasTokenProperties.dataPlaneReaderScope.toString(16) + + "\n" + + sasTokenProperties.dataPlaneWriterScope.toString(16) + + "\n"; + const signedPayload = await hmac(masterKey, Buffer.from(payload).toString("base64")); + return "type=sas&ver=1.0&sig=" + signedPayload + ";" + Buffer.from(payload).toString("base64"); +} +/** + * @hidden + */ +// TODO: utcMilllisecondsSinceEpoch +export function utcsecondsSinceEpoch(date) { + return Math.round(date.getTime() / 1000); +} +//# sourceMappingURL=SasToken.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js.map new file mode 100644 index 000000000..f827823a6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/SasToken.js.map @@ -0,0 +1 @@ +{"version":3,"file":"SasToken.js","sourceRoot":"","sources":["../../../src/utils/SasToken.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B;;;GAGG;AAEH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,SAAiB,EACjB,kBAAsC;IAEtC,IAAI,kBAAkB,GAAG,EAAE,CAAC;IAC5B,IACE,OAAO,kBAAkB,CAAC,YAAY,KAAK,QAAQ;QACnD,kBAAkB,CAAC,YAAY,KAAK,EAAE,EACtC;QAC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AC,QAAQ,CAAC,EAAE,CAAC;QACpD,IAAI,CAAC;IAEP,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrF,OAAO,uBAAuB,GAAG,aAAa,GAAG,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACjG,CAAC;AACD;;GAEG;AACH,mCAAmC;AACnC,MAAM,UAAU,oBAAoB,CAAC,IAAU;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SasTokenProperties } from \"../client/SasToken/SasTokenProperties\";\nimport { Constants, CosmosKeyType, SasTokenPermissionKind } from \"../common\";\nimport { encodeUTF8 } from \"./encode\";\nimport { hmac } from \"./hmac\";\n\n/**\n * Experimental internal only\n * Generates the payload representing the permission configuration for the sas token.\n */\n\nexport async function createAuthorizationSasToken(\n masterKey: string,\n sasTokenProperties: SasTokenProperties,\n): Promise {\n let resourcePrefixPath = \"\";\n if (\n typeof sasTokenProperties.databaseName === \"string\" &&\n sasTokenProperties.databaseName !== \"\"\n ) {\n resourcePrefixPath += `/${Constants.Path.DatabasesPathSegment}/${sasTokenProperties.databaseName}`;\n }\n\n if (\n typeof sasTokenProperties.containerName === \"string\" &&\n sasTokenProperties.containerName !== \"\"\n ) {\n if (sasTokenProperties.databaseName === \"\") {\n throw new Error(`illegalArgumentException : ${sasTokenProperties.databaseName} \\\n is an invalid database name`);\n }\n resourcePrefixPath += `/${Constants.Path.CollectionsPathSegment}/${sasTokenProperties.containerName}`;\n }\n\n if (\n typeof sasTokenProperties.resourceName === \"string\" &&\n sasTokenProperties.resourceName !== \"\"\n ) {\n if (sasTokenProperties.containerName === \"\") {\n throw new Error(`illegalArgumentException : ${sasTokenProperties.containerName} \\\n is an invalid container name`);\n }\n switch (sasTokenProperties.resourceKind) {\n case \"ITEM\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.DocumentsPathSegment}`;\n break;\n case \"STORED_PROCEDURE\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.StoredProceduresPathSegment}`;\n break;\n case \"USER_DEFINED_FUNCTION\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.UserDefinedFunctionsPathSegment}`;\n break;\n case \"TRIGGER\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.TriggersPathSegment}`;\n break;\n default:\n throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \\\n is an invalid resource kind`);\n break;\n }\n resourcePrefixPath += `${Constants.Path.Root}${sasTokenProperties.resourceName}${Constants.Path.Root}`;\n }\n sasTokenProperties.resourcePath = resourcePrefixPath.toString();\n\n let partitionRanges = \"\";\n\n if (\n sasTokenProperties.partitionKeyValueRanges !== undefined &&\n sasTokenProperties.partitionKeyValueRanges.length > 0\n ) {\n if (\n typeof sasTokenProperties.resourceKind !== \"string\" &&\n sasTokenProperties.resourceKind !== \"ITEM\"\n ) {\n throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \\\n is an invalid partition key value range`);\n }\n sasTokenProperties.partitionKeyValueRanges.forEach((range) => {\n partitionRanges += `${encodeUTF8(range)},`;\n });\n }\n\n if (sasTokenProperties.controlPlaneReaderScope === 0) {\n sasTokenProperties.controlPlaneReaderScope += SasTokenPermissionKind.ContainerReadAny;\n sasTokenProperties.controlPlaneWriterScope += SasTokenPermissionKind.ContainerReadAny;\n }\n\n if (\n sasTokenProperties.dataPlaneReaderScope === 0 &&\n sasTokenProperties.dataPlaneWriterScope === 0\n ) {\n sasTokenProperties.dataPlaneReaderScope = SasTokenPermissionKind.ContainerFullAccess;\n sasTokenProperties.dataPlaneWriterScope = SasTokenPermissionKind.ContainerFullAccess;\n }\n\n if (\n typeof sasTokenProperties.keyType !== \"number\" ||\n typeof sasTokenProperties.keyType === undefined\n ) {\n switch (sasTokenProperties.keyType) {\n case CosmosKeyType.PrimaryMaster:\n sasTokenProperties.keyType = 1;\n break;\n case CosmosKeyType.SecondaryMaster:\n sasTokenProperties.keyType = 2;\n break;\n case CosmosKeyType.PrimaryReadOnly:\n sasTokenProperties.keyType = 3;\n break;\n case CosmosKeyType.SecondaryReadOnly:\n sasTokenProperties.keyType = 4;\n break;\n default:\n throw new Error(`illegalArgumentException : ${sasTokenProperties.keyType} \\\n is an invalid key type`);\n break;\n }\n }\n\n const payload =\n sasTokenProperties.user +\n \"\\n\" +\n sasTokenProperties.userTag +\n \"\\n\" +\n sasTokenProperties.resourcePath +\n \"\\n\" +\n partitionRanges +\n \"\\n\" +\n utcsecondsSinceEpoch(sasTokenProperties.startTime).toString(16) +\n \"\\n\" +\n utcsecondsSinceEpoch(sasTokenProperties.expiryTime).toString(16) +\n \"\\n\" +\n sasTokenProperties.keyType +\n \"\\n\" +\n sasTokenProperties.controlPlaneReaderScope.toString(16) +\n \"\\n\" +\n sasTokenProperties.controlPlaneWriterScope.toString(16) +\n \"\\n\" +\n sasTokenProperties.dataPlaneReaderScope.toString(16) +\n \"\\n\" +\n sasTokenProperties.dataPlaneWriterScope.toString(16) +\n \"\\n\";\n\n const signedPayload = await hmac(masterKey, Buffer.from(payload).toString(\"base64\"));\n return \"type=sas&ver=1.0&sig=\" + signedPayload + \";\" + Buffer.from(payload).toString(\"base64\");\n}\n/**\n * @hidden\n */\n// TODO: utcMilllisecondsSinceEpoch\nexport function utcsecondsSinceEpoch(date: Date): number {\n return Math.round(date.getTime() / 1000);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts new file mode 100644 index 000000000..6a63db1a3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts @@ -0,0 +1,3 @@ +declare let safeatob: any; +export default safeatob; +//# sourceMappingURL=atob.browser.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts.map new file mode 100644 index 000000000..ecfa25713 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"atob.browser.d.ts","sourceRoot":"","sources":["../../../src/utils/atob.browser.ts"],"names":[],"mappings":"AAGA,QAAA,IAAI,QAAQ,EAAE,GAAG,CAAC;AA8ClB,eAAe,QAAQ,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js new file mode 100644 index 000000000..6d9c3ef6b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +let safeatob; +// base64 character set, plus padding character (=) +const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; +// Regular expression to check formal correctness of base64 encoded strings +const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/; +if ("function" !== typeof atob) { + // atob implementation for React Native + safeatob = (str) => { + // atob can work with strings with whitespaces, even inside the encoded part, + // but only \t, \n, \f, \r and ' ', which can be stripped. + str = String(str).replace(/[\t\n\f\r ]+/g, ""); + if (!b64re.test(str)) { + throw new TypeError("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."); + } + // Adding the padding if missing, for simplicity + str += "==".slice(2 - (str.length & 3)); + let bitmap; + let result = ""; + let r1; + let r2; + let i = 0; + for (; i < str.length;) { + bitmap = + (b64.indexOf(str.charAt(i++)) << 18) | + (b64.indexOf(str.charAt(i++)) << 12) | + ((r1 = b64.indexOf(str.charAt(i++))) << 6) | + (r2 = b64.indexOf(str.charAt(i++))); + result += + r1 === 64 + ? String.fromCharCode((bitmap >> 16) & 255) + : r2 === 64 + ? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255) + : String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255); + } + return result; + }; +} +else { + safeatob = atob; +} +export default safeatob; +//# sourceMappingURL=atob.browser.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js.map new file mode 100644 index 000000000..8ed014a24 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"atob.browser.js","sourceRoot":"","sources":["../../../src/utils/atob.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,IAAI,QAAa,CAAC;AAElB,mDAAmD;AACnD,MAAM,GAAG,GAAG,mEAAmE,CAAC;AAChF,2EAA2E;AAC3E,MAAM,KAAK,GAAG,sEAAsE,CAAC;AAErF,IAAI,UAAU,KAAK,OAAO,IAAI,EAAE;IAC9B,uCAAuC;IACvC,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE;QACjC,6EAA6E;QAC7E,0DAA0D;QAC1D,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACpB,MAAM,IAAI,SAAS,CACjB,0FAA0F,CAC3F,CAAC;SACH;QAED,gDAAgD;QAChD,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,M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AAI,CAAC;CACjB;AAED,eAAe,QAAQ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nlet safeatob: any;\n\n// base64 character set, plus padding character (=)\nconst b64 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n// Regular expression to check formal correctness of base64 encoded strings\nconst b64re = /^(?:[A-Za-z\\d+/]{4})*?(?:[A-Za-z\\d+/]{2}(?:==)?|[A-Za-z\\d+/]{3}=?)?$/;\n\nif (\"function\" !== typeof atob) {\n // atob implementation for React Native\n safeatob = (str: string): string => {\n // atob can work with strings with whitespaces, even inside the encoded part,\n // but only \\t, \\n, \\f, \\r and ' ', which can be stripped.\n str = String(str).replace(/[\\t\\n\\f\\r ]+/g, \"\");\n if (!b64re.test(str)) {\n throw new TypeError(\n \"Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.\",\n );\n }\n\n // Adding the padding if missing, for simplicity\n str += \"==\".slice(2 - (str.length & 3));\n let bitmap;\n let result = \"\";\n let r1;\n let r2;\n let i = 0;\n for (; i < str.length; ) {\n bitmap =\n (b64.indexOf(str.charAt(i++)) << 18) |\n (b64.indexOf(str.charAt(i++)) << 12) |\n ((r1 = b64.indexOf(str.charAt(i++))) << 6) |\n (r2 = b64.indexOf(str.charAt(i++)));\n\n result +=\n r1 === 64\n ? String.fromCharCode((bitmap >> 16) & 255)\n : r2 === 64\n ? String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255)\n : String.fromCharCode((bitmap >> 16) & 255, (bitmap >> 8) & 255, bitmap & 255);\n }\n return result;\n };\n} else {\n safeatob = atob;\n}\n\nexport default safeatob;\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts new file mode 100644 index 000000000..d19a8c58c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts @@ -0,0 +1,2 @@ +export default function atob(str: string): string; +//# sourceMappingURL=atob.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts.map new file mode 100644 index 000000000..2cadd1037 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"atob.d.ts","sourceRoot":"","sources":["../../../src/utils/atob.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js new file mode 100644 index 000000000..fcbda7098 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export default function atob(str) { + return Buffer.from(str, "base64").toString("binary"); +} +//# sourceMappingURL=atob.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js.map new file mode 100644 index 000000000..a73d226e7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/atob.js.map @@ -0,0 +1 @@ +{"version":3,"file":"atob.js","sourceRoot":"","sources":["../../../src/utils/atob.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,GAAW;IACtC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACvD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport default function atob(str: string): string {\n return Buffer.from(str, \"base64\").toString(\"binary\");\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts new file mode 100644 index 000000000..fca6a16db --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts @@ -0,0 +1,145 @@ +import { JSONObject } from "../queryExecutionContext"; +import { CosmosDiagnostics, RequestOptions } from ".."; +import { PartitionKey, PartitionKeyDefinition, PrimitivePartitionKeyValue } from "../documents"; +import { PatchRequestBody } from "./patch"; +export type Operation = CreateOperation | UpsertOperation | ReadOperation | DeleteOperation | ReplaceOperation | BulkPatchOperation; +export interface Batch { + min: string; + max: string; + rangeId: string; + indexes: number[]; + operations: Operation[]; +} +export type BulkOperationResponse = OperationResponse[] & { + diagnostics: CosmosDiagnostics; +}; +export interface OperationResponse { + statusCode: number; + requestCharge: number; + eTag?: string; + resourceBody?: JSONObject; +} +/** + * Options object used to modify bulk execution. + * continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE + */ +export interface BulkOptions { + continueOnError?: boolean; +} +export declare function isKeyInRange(min: string, max: string, key: string): boolean; +export interface OperationBase { + partitionKey?: string; + ifMatch?: string; + ifNoneMatch?: string; +} +export declare const BulkOperationType: { + readonly Create: "Create"; + readonly Upsert: "Upsert"; + readonly Read: "Read"; + readonly Delete: "Delete"; + readonly Replace: "Replace"; + readonly Patch: "Patch"; +}; +export type OperationInput = CreateOperationInput | UpsertOperationInput | ReadOperationInput | DeleteOperationInput | ReplaceOperationInput | PatchOperationInput; +export interface CreateOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Create; + resourceBody: JSONObject; +} +export interface UpsertOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Upsert; + resourceBody: JSONObject; +} +export interface ReadOperationInput { + partitionKey?: PartitionKey; + operationType: typeof BulkOperationType.Read; + id: string; +} +export interface DeleteOperationInput { + partitionKey?: PartitionKey; + operationType: typeof BulkOperationType.Delete; + id: string; +} +export interface ReplaceOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Replace; + resourceBody: JSONObject; + id: string; +} +export interface PatchOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Patch; + resourceBody: PatchRequestBody; + id: string; +} +export type OperationWithItem = OperationBase & { + resourceBody: JSONObject; +}; +export type CreateOperation = OperationWithItem & { + operationType: typeof BulkOperationType.Create; +}; +export type UpsertOperation = OperationWithItem & { + operationType: typeof BulkOperationType.Upsert; +}; +export type ReadOperation = OperationBase & { + operationType: typeof BulkOperationType.Read; + id: string; +}; +export type DeleteOperation = OperationBase & { + operationType: typeof BulkOperationType.Delete; + id: string; +}; +export type ReplaceOperation = OperationWithItem & { + operationType: typeof BulkOperationType.Replace; + id: string; +}; +export type BulkPatchOperation = OperationBase & { + operationType: typeof BulkOperationType.Patch; + id: string; +}; +export declare function hasResource(operation: Operation): operation is CreateOperation | UpsertOperation | ReplaceOperation; +/** + * Maps OperationInput to Operation by + * - generating Ids if needed. + * - choosing partitionKey which can be used to choose which batch this + * operation should be part of. The order is - + * 1. If the operationInput itself has partitionKey field set it is used. + * 2. Other wise for create/replace/upsert it is extracted from resource body. + * 3. For read/delete/patch type operations undefined partitionKey is used. + * - Here one nuance is that, the partitionKey field inside Operation needs to + * be serialized as a JSON string. + * @param operationInput - OperationInput + * @param definition - PartitionKeyDefinition + * @param options - RequestOptions + * @returns + */ +export declare function prepareOperations(operationInput: OperationInput, definition: PartitionKeyDefinition, options?: RequestOptions): { + operation: Operation; + partitionKey: PrimitivePartitionKeyValue[]; +}; +/** + * Splits a batch into array of batches based on cumulative size of its operations by making sure + * cumulative size of an individual batch is not larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}. + * If a single operation itself is larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}, that + * operation would be moved into a batch containing only that operation. + * @param originalBatch - A batch of operations needed to be checked. + * @returns + * @hidden + */ +export declare function splitBatchBasedOnBodySize(originalBatch: Batch): Batch[]; +/** + * Calculates size of an JSON object in bytes with utf-8 encoding. + * @hidden + */ +export declare function calculateObjectSizeInBytes(obj: unknown): number; +export declare function decorateBatchOperation(operation: OperationInput, options?: RequestOptions): Operation; +//# sourceMappingURL=batch.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts.map new file mode 100644 index 000000000..f6754045b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/utils/batch.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AACvD,OAAO,EAEL,YAAY,EACZ,sBAAsB,EACtB,0BAA0B,EAE3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAO3C,MAAM,MAAM,SAAS,GACjB,eAAe,GACf,eAAe,GACf,aAAa,GACb,eAAe,GACf,gBAAgB,GAChB,kBAAkB,CAAC;AAEvB,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,EAAE,GAAG;IA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iBAAiB,CAAC,MAAM,CAAC;IAC/C,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG;IACjD,aAAa,EAAE,OAAO,iBAAiB,CAAC,OAAO,CAAC;IAChD,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG;IAC/C,aAAa,EAAE,OAAO,iBAAiB,CAAC,KAAK,CAAC;IAC9C,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,wBAAgB,WAAW,CACzB,SAAS,EAAE,SAAS,GACnB,SAAS,IAAI,eAAe,GAAG,eAAe,GAAG,gBAAgB,CAKnE;AACD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,sBAAsB,EAClC,OAAO,GAAE,cAAmB,GAC3B;IACD,SAAS,EAAE,SAAS,CAAC;IACrB,YAAY,EAAE,0BAA0B,EAAE,CAAC;CAC5C,CA8BA;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,aAAa,EAAE,KAAK,GAAG,KAAK,EAAE,CA4BvE;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAE/D;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,cAAc,EACzB,OAAO,GAAE,cAAmB,GAC3B,SAAS,CAaX"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js new file mode 100644 index 000000000..f49e236c2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js @@ -0,0 +1,132 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { extractPartitionKeys } from "../extractPartitionKey"; +import { NonePartitionKeyLiteral, convertToInternalPartitionKey, } from "../documents"; +import { v4 } from "uuid"; +import { assertNotUndefined } from "./typeChecks"; +import { bodyFromData } from "../request/request"; +import { Constants } from "../common/constants"; +const uuid = v4; +export function isKeyInRange(min, max, key) { + const isAfterMinInclusive = key.localeCompare(min) >= 0; + const isBeforeMax = key.localeCompare(max) < 0; + return isAfterMinInclusive && isBeforeMax; +} +export const BulkOperationType = { + Create: "Create", + Upsert: "Upsert", + Read: "Read", + Delete: "Delete", + Replace: "Replace", + Patch: "Patch", +}; +export function hasResource(operation) { + return (operation.operationType !== "Patch" && + operation.resourceBody !== undefined); +} +/** + * Maps OperationInput to Operation by + * - generating Ids if needed. + * - choosing partitionKey which can be used to choose which batch this + * operation should be part of. The order is - + * 1. If the operationInput itself has partitionKey field set it is used. + * 2. Other wise for create/replace/upsert it is extracted from resource body. + * 3. For read/delete/patch type operations undefined partitionKey is used. + * - Here one nuance is that, the partitionKey field inside Operation needs to + * be serialized as a JSON string. + * @param operationInput - OperationInput + * @param definition - PartitionKeyDefinition + * @param options - RequestOptions + * @returns + */ +export function prepareOperations(operationInput, definition, options = {}) { + populateIdsIfNeeded(operationInput, options); + let partitionKey; + if (Object.prototype.hasOwnProperty.call(operationInput, "partitionKey")) { + if (operationInput.partitionKey === undefined) { + partitionKey = definition.paths.map(() => NonePartitionKeyLiteral); + } + else { + partitionKey = convertToInternalPartitionKey(operationInput.partitionKey); + } + } + else { + switch (operationInput.operationType) { + case BulkOperationType.Create: + case BulkOperationType.Replace: + case BulkOperationType.Upsert: + partitionKey = assertNotUndefined(extractPartitionKeys(operationInput.resourceBody, definition), "Unexpected undefined Partition Key Found."); + break; + case BulkOperationType.Read: + case BulkOperationType.Delete: + case BulkOperationType.Patch: + partitionKey = definition.paths.map(() => NonePartitionKeyLiteral); + } + } + return { + operation: Object.assign(Object.assign({}, operationInput), { partitionKey: JSON.stringify(partitionKey) }), + partitionKey, + }; +} +/** + * For operations requiring Id genrate random uuids. + * @param operationInput - OperationInput to be checked. + * @param options - RequestOptions + */ +function populateIdsIfNeeded(operationInput, options) { + if (operationInput.operationType === BulkOperationType.Create || + operationInput.operationType === BulkOperationType.Upsert) { + if ((operationInput.resourceBody.id === undefined || operationInput.resourceBody.id === "") && + !options.disableAutomaticIdGeneration) { + operationInput.resourceBody.id = uuid(); + } + } +} +/** + * Splits a batch into array of batches based on cumulative size of its operations by making sure + * cumulative size of an individual batch is not larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}. + * If a single operation itself is larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}, that + * operation would be moved into a batch containing only that operation. + * @param originalBatch - A batch of operations needed to be checked. + * @returns + * @hidden + */ +export function splitBatchBasedOnBodySize(originalBatch) { + if ((originalBatch === null || originalBatch === void 0 ? void 0 : originalBatch.operations) === undefined || originalBatch.operations.length < 1) + return []; + let currentBatchSize = calculateObjectSizeInBytes(originalBatch.operations[0]); + let currentBatch = Object.assign(Object.assign({}, originalBatch), { operations: [originalBatch.operations[0]], indexes: [originalBatch.indexes[0]] }); + const processedBatches = []; + processedBatches.push(currentBatch); + for (let index = 1; index < originalBatch.operations.length; index++) { + const operation = originalBatch.operations[index]; + const currentOpSize = calculateObjectSizeInBytes(operation); + if (currentBatchSize + currentOpSize > Constants.DefaultMaxBulkRequestBodySizeInBytes) { + currentBatch = Object.assign(Object.assign({}, originalBatch), { operations: [], indexes: [] }); + processedBatches.push(currentBatch); + currentBatchSize = 0; + } + currentBatch.operations.push(operation); + currentBatch.indexes.push(originalBatch.indexes[index]); + currentBatchSize += currentOpSize; + } + return processedBatches; +} +/** + * Calculates size of an JSON object in bytes with utf-8 encoding. + * @hidden + */ +export function calculateObjectSizeInBytes(obj) { + return new TextEncoder().encode(bodyFromData(obj)).length; +} +export function decorateBatchOperation(operation, options = {}) { + if (operation.operationType === BulkOperationType.Create || + operation.operationType === BulkOperationType.Upsert) { + if ((operation.resourceBody.id === undefined || operation.resourceBody.id === "") && + !options.disableAutomaticIdGeneration) { + operation.resourceBody.id = uuid(); + } + } + return operation; +} +//# sourceMappingURL=batch.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js.map new file mode 100644 index 000000000..0ff335ef5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/batch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"batch.js","sourceRoot":"","sources":["../../../src/utils/batch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EACL,uBAAuB,EAIvB,6BAA6B,GAC9B,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,MAAM,IAAI,GAAG,EAAE,CAAC;AAmChB,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,GAAW,EAAE,GAAW;IAChE,MAAM,mBAAmB,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC/C,OAAO,mBAAmB,IAAI,WAAW,CAAC;AAC5C,CAAC;AAQD,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACN,CAAC;AAwFX,MAAM,UAAU,WAAW,CACzB,SAAoB;IAEpB,OAAO,CACL,SAAS,CAAC,aAAa,KAAK,OA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AAY,mCACP,aAAa,KAChB,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,EAAE,GACZ,CAAC;YACF,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YACpC,gBAAgB,GAAG,CAAC,CAAC;SACtB;QACD,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,gBAAgB,IAAI,aAAa,CAAC;KACnC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAY;IACrD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,GAAU,CAAC,CAAC,CAAC,MAAM,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,SAAyB,EACzB,UAA0B,EAAE;IAE5B,IACE,SAAS,CAAC,aAAa,KAAK,iBAAiB,CAAC,MAAM;QACpD,SAAS,CAAC,aAAa,KAAK,iBAAiB,CAAC,MAAM,EACpD;QACA,IACE,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,KAAK,SAAS,IAAI,SAAS,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC;YAC7E,CAAC,OAAO,CAAC,4BAA4B,EACrC;YACA,SAAS,CAAC,YAAY,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC;SACpC;KACF;IACD,OAAO,SAAsB,CAAC;AAChC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { JSONObject } from \"../queryExecutionContext\";\nimport { extractPartitionKeys } from \"../extractPartitionKey\";\nimport { CosmosDiagnostics, RequestOptions } from \"..\";\nimport {\n NonePartitionKeyLiteral,\n PartitionKey,\n PartitionKeyDefinition,\n PrimitivePartitionKeyValue,\n convertToInternalPartitionKey,\n} from \"../documents\";\nimport { PatchRequestBody } from \"./patch\";\nimport { v4 } from \"uuid\";\nimport { assertNotUndefined } from \"./typeChecks\";\nimport { bodyFromData } from \"../request/request\";\nimport { Constants } from \"../common/constants\";\nconst uuid = v4;\n\nexport type Operation =\n | CreateOperation\n | UpsertOperation\n | ReadOperation\n | DeleteOperation\n | ReplaceOperation\n | BulkPatchOperation;\n\nexport interface Batch {\n min: string;\n max: string;\n rangeId: string;\n indexes: number[];\n operations: Operation[];\n}\n\nexport type BulkOperationResponse = OperationResponse[] & { diagnostics: CosmosDiagnostics };\n\nexport interface OperationResponse {\n statusCode: number;\n requestCharge: number;\n eTag?: string;\n resourceBody?: JSONObject;\n}\n\n/**\n * Options object used to modify bulk execution.\n * continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE\n */\nexport interface BulkOptions {\n continueOnError?: boolean;\n}\n\nexport function isKeyInRange(min: string, max: string, key: string): boolean {\n const isAfterMinInclusive = key.localeCompare(min) >= 0;\n const isBeforeMax = key.localeCompare(max) < 0;\n return isAfterMinInclusive && isBeforeMax;\n}\n\nexport interface OperationBase {\n partitionKey?: string;\n ifMatch?: string;\n ifNoneMatch?: string;\n}\n\nexport const BulkOperationType = {\n Create: \"Create\",\n Upsert: \"Upsert\",\n Read: \"Read\",\n Delete: \"Delete\",\n Replace: \"Replace\",\n Patch: \"Patch\",\n} as const;\n\nexport type OperationInput =\n | CreateOperationInput\n | UpsertOperationInput\n | ReadOperationInput\n | DeleteOperationInput\n | ReplaceOperationInput\n | PatchOperationInput;\n\nexport interface CreateOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Create;\n resourceBody: JSONObject;\n}\n\nexport interface UpsertOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Upsert;\n resourceBody: JSONObject;\n}\n\nexport interface ReadOperationInput {\n partitionKey?: PartitionKey;\n operationType: typeof BulkOperationType.Read;\n id: string;\n}\n\nexport interface DeleteOperationInput {\n partitionKey?: PartitionKey;\n operationType: typeof BulkOperationType.Delete;\n id: string;\n}\n\nexport interface ReplaceOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Replace;\n resourceBody: JSONObject;\n id: string;\n}\n\nexport interface PatchOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Patch;\n resourceBody: PatchRequestBody;\n id: string;\n}\n\nexport type OperationWithItem = OperationBase & {\n resourceBody: JSONObject;\n};\n\nexport type CreateOperation = OperationWithItem & {\n operationType: typeof BulkOperationType.Create;\n};\n\nexport type UpsertOperation = OperationWithItem & {\n operationType: typeof BulkOperationType.Upsert;\n};\n\nexport type ReadOperation = OperationBase & {\n operationType: typeof BulkOperationType.Read;\n id: string;\n};\n\nexport type DeleteOperation = OperationBase & {\n operationType: typeof BulkOperationType.Delete;\n id: string;\n};\n\nexport type ReplaceOperation = OperationWithItem & {\n operationType: typeof BulkOperationType.Replace;\n id: string;\n};\n\nexport type BulkPatchOperation = OperationBase & {\n operationType: typeof BulkOperationType.Patch;\n id: string;\n};\n\nexport function hasResource(\n operation: Operation,\n): operation is CreateOperation | UpsertOperation | ReplaceOperation {\n return (\n operation.operationType !== \"Patch\" &&\n (operation as OperationWithItem).resourceBody !== undefined\n );\n}\n/**\n * Maps OperationInput to Operation by\n * - generating Ids if needed.\n * - choosing partitionKey which can be used to choose which batch this\n * operation should be part of. The order is -\n * 1. If the operationInput itself has partitionKey field set it is used.\n * 2. Other wise for create/replace/upsert it is extracted from resource body.\n * 3. For read/delete/patch type operations undefined partitionKey is used.\n * - Here one nuance is that, the partitionKey field inside Operation needs to\n * be serialized as a JSON string.\n * @param operationInput - OperationInput\n * @param definition - PartitionKeyDefinition\n * @param options - RequestOptions\n * @returns\n */\nexport function prepareOperations(\n operationInput: OperationInput,\n definition: PartitionKeyDefinition,\n options: RequestOptions = {},\n): {\n operation: Operation;\n partitionKey: PrimitivePartitionKeyValue[];\n} {\n populateIdsIfNeeded(operationInput, options);\n\n let partitionKey: PrimitivePartitionKeyValue[];\n if (Object.prototype.hasOwnProperty.call(operationInput, \"partitionKey\")) {\n if (operationInput.partitionKey === undefined) {\n partitionKey = definition.paths.map(() => NonePartitionKeyLiteral);\n } else {\n partitionKey = convertToInternalPartitionKey(operationInput.partitionKey);\n }\n } else {\n switch (operationInput.operationType) {\n case BulkOperationType.Create:\n case BulkOperationType.Replace:\n case BulkOperationType.Upsert:\n partitionKey = assertNotUndefined(\n extractPartitionKeys(operationInput.resourceBody, definition),\n \"Unexpected undefined Partition Key Found.\",\n );\n break;\n case BulkOperationType.Read:\n case BulkOperationType.Delete:\n case BulkOperationType.Patch:\n partitionKey = definition.paths.map(() => NonePartitionKeyLiteral);\n }\n }\n return {\n operation: { ...operationInput, partitionKey: JSON.stringify(partitionKey) } as Operation,\n partitionKey,\n };\n}\n\n/**\n * For operations requiring Id genrate random uuids.\n * @param operationInput - OperationInput to be checked.\n * @param options - RequestOptions\n */\nfunction populateIdsIfNeeded(operationInput: OperationInput, options: RequestOptions) {\n if (\n operationInput.operationType === BulkOperationType.Create ||\n operationInput.operationType === BulkOperationType.Upsert\n ) {\n if (\n (operationInput.resourceBody.id === undefined || operationInput.resourceBody.id === \"\") &&\n !options.disableAutomaticIdGeneration\n ) {\n operationInput.resourceBody.id = uuid();\n }\n }\n}\n\n/**\n * Splits a batch into array of batches based on cumulative size of its operations by making sure\n * cumulative size of an individual batch is not larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}.\n * If a single operation itself is larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}, that\n * operation would be moved into a batch containing only that operation.\n * @param originalBatch - A batch of operations needed to be checked.\n * @returns\n * @hidden\n */\nexport function splitBatchBasedOnBodySize(originalBatch: Batch): Batch[] {\n if (originalBatch?.operations === undefined || originalBatch.operations.length < 1) return [];\n let currentBatchSize = calculateObjectSizeInBytes(originalBatch.operations[0]);\n let currentBatch: Batch = {\n ...originalBatch,\n operations: [originalBatch.operations[0]],\n indexes: [originalBatch.indexes[0]],\n };\n const processedBatches: Batch[] = [];\n processedBatches.push(currentBatch);\n\n for (let index = 1; index < originalBatch.operations.length; index++) {\n const operation = originalBatch.operations[index];\n const currentOpSize = calculateObjectSizeInBytes(operation);\n if (currentBatchSize + currentOpSize > Constants.DefaultMaxBulkRequestBodySizeInBytes) {\n currentBatch = {\n ...originalBatch,\n operations: [],\n indexes: [],\n };\n processedBatches.push(currentBatch);\n currentBatchSize = 0;\n }\n currentBatch.operations.push(operation);\n currentBatch.indexes.push(originalBatch.indexes[index]);\n currentBatchSize += currentOpSize;\n }\n return processedBatches;\n}\n\n/**\n * Calculates size of an JSON object in bytes with utf-8 encoding.\n * @hidden\n */\nexport function calculateObjectSizeInBytes(obj: unknown): number {\n return new TextEncoder().encode(bodyFromData(obj as any)).length;\n}\n\nexport function decorateBatchOperation(\n operation: OperationInput,\n options: RequestOptions = {},\n): Operation {\n if (\n operation.operationType === BulkOperationType.Create ||\n operation.operationType === BulkOperationType.Upsert\n ) {\n if (\n (operation.resourceBody.id === undefined || operation.resourceBody.id === \"\") &&\n !options.disableAutomaticIdGeneration\n ) {\n operation.resourceBody.id = uuid();\n }\n }\n return operation as Operation;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts new file mode 100644 index 000000000..dee1f5657 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts @@ -0,0 +1,3 @@ +import { HttpClient } from "@azure/core-rest-pipeline"; +export declare function getCachedDefaultHttpClient(): HttpClient; +//# sourceMappingURL=cachedClient.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts.map new file mode 100644 index 000000000..9bfe4ca6b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cachedClient.d.ts","sourceRoot":"","sources":["../../../src/utils/cachedClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAA2B,MAAM,2BAA2B,CAAC;AAIhF,wBAAgB,0BAA0B,IAAI,UAAU,CAMvD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js new file mode 100644 index 000000000..49a4d210b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createDefaultHttpClient } from "@azure/core-rest-pipeline"; +let cachedHttpClient; +export function getCachedDefaultHttpClient() { + if (!cachedHttpClient) { + cachedHttpClient = createDefaultHttpClient(); + } + return cachedHttpClient; +} +//# sourceMappingURL=cachedClient.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js.map new file mode 100644 index 000000000..2fbb43bcf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/cachedClient.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cachedClient.js","sourceRoot":"","sources":["../../../src/utils/cachedClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAc,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEhF,IAAI,gBAAwC,CAAC;AAE7C,MAAM,UAAU,0BAA0B;IACxC,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;KAC9C;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpClient, createDefaultHttpClient } from \"@azure/core-rest-pipeline\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\nexport function getCachedDefaultHttpClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts new file mode 100644 index 000000000..36aff2982 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts @@ -0,0 +1,3 @@ +export declare function checkURL(testString: string): URL; +export declare function sanitizeEndpoint(url: string): string; +//# sourceMappingURL=checkURL.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts.map new file mode 100644 index 000000000..2cbabb4e8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"checkURL.d.ts","sourceRoot":"","sources":["../../../src/utils/checkURL.ts"],"names":[],"mappings":"AAGA,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAEhD;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js new file mode 100644 index 000000000..a79f5327f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export function checkURL(testString) { + return new URL(testString); +} +export function sanitizeEndpoint(url) { + return new URL(url).href.replace(/\/$/, ""); +} +//# sourceMappingURL=checkURL.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js.map new file mode 100644 index 000000000..3bd3d6981 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/checkURL.js.map @@ -0,0 +1 @@ +{"version":3,"file":"checkURL.js","sourceRoot":"","sources":["../../../src/utils/checkURL.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,UAAU,QAAQ,CAAC,UAAkB;IACzC,OAAO,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport function checkURL(testString: string): URL {\n return new URL(testString);\n}\n\nexport function sanitizeEndpoint(url: string): string {\n return new URL(url).href.replace(/\\/$/, \"\");\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts new file mode 100644 index 000000000..07c9bf81b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts @@ -0,0 +1,51 @@ +import { CosmosDiagnostics, MetadataLookUpType } from "../CosmosDiagnostics"; +import { DiagnosticDataValue, DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; +import { ClientContext } from "../ClientContext"; +/** + * @hidden + * Utility function to create an Empty CosmosDiagnostic object. + */ +export declare function getEmptyCosmosDiagnostics(): CosmosDiagnostics; +/** + * @hidden + */ +export type ExtractPromise = T extends Promise ? U : never; +/** + * A supporting utility wrapper function, to be used inside a diagnostic session started + * by `withDiagnostics` function. + * Created a Diagnostic node and add it as a child to existing diagnostic session. + * @hidden + */ +export declare function addDignosticChild Promise>(callback: Callback, node: DiagnosticNodeInternal, type: DiagnosticNodeType, data?: Partial): Promise>>; +/** + * A supporting utility wrapper function, to be used inside a diagnostic session started + * by `withDiagnostics` function. + * Treats requests originating in provided `callback` as metadata calls. + * To realize this, starts a temporary diagnostic session, after execution of callback is + * finished. Merges this temporary diagnostic session to the original diagnostic session + * represented by the input parameter `node`. + * @hidden + */ +export declare function withMetadataDiagnostics Promise>(callback: Callback, node: DiagnosticNodeInternal, type: MetadataLookUpType): Promise>>; +/** + * Utility wrapper function to managed lifecycle of a Diagnostic session. + * Meant to be used at the root of the client operation. i.e. item.read(), + * queryIterator.fetchAll(). + * + * This utility starts a new diagnostic session. So using it any where else + * other than start of operation, will result is different diagnostic sessions. + * + * Workings : + * 1. Takes a callback function as input. + * 2. Creates a new instance of DiagnosticNodeInternal, which can be though as starting + * a new diagnostic session. + * 3. Executes the callback function. + * 4. If execution was successful. Converts DiagnosticNodeInternal to CosmosDiagnostics + * and injects it to the response object and returns this object. + * 5. If execution threw an exception. Sill converts DiagnosticNodeInternal to CosmosDiagnostics + * and injects it to the Error object, and rethrows the Error object. + * + * @hidden + */ +export declare function withDiagnostics Promise>(callback: Callback, clientContext: ClientContext, type?: DiagnosticNodeType): Promise>>; +//# sourceMappingURL=diagnostics.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts.map new file mode 100644 index 000000000..4e2784a1e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","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AAO,CAAC,cAAc,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAqB/C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js new file mode 100644 index 000000000..8d13b4ebc --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { CosmosDiagnostics } from "../CosmosDiagnostics"; +import { DiagnosticNodeInternal, DiagnosticNodeType, } from "../diagnostics/DiagnosticNodeInternal"; +import { getCurrentTimestampInMs } from "./time"; +import { v4 } from "uuid"; +import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel"; +/** + * @hidden + * Utility function to create an Empty CosmosDiagnostic object. + */ +export function getEmptyCosmosDiagnostics() { + return new CosmosDiagnostics({ + requestDurationInMs: 0, + requestStartTimeUTCInMs: getCurrentTimestampInMs(), + totalRequestPayloadLengthInBytes: 0, + totalResponsePayloadLengthInBytes: 0, + locationEndpointsContacted: [], + retryDiagnostics: { + failedAttempts: [], + }, + metadataDiagnostics: { + metadataLookups: [], + }, + gatewayStatistics: [], + }, { + id: v4(), + nodeType: DiagnosticNodeType.CLIENT_REQUEST_NODE, + children: [], + data: {}, + startTimeUTCInMs: getCurrentTimestampInMs(), + durationInMs: 0, + }); +} +/** + * A supporting utility wrapper function, to be used inside a diagnostic session started + * by `withDiagnostics` function. + * Created a Diagnostic node and add it as a child to existing diagnostic session. + * @hidden + */ +export async function addDignosticChild(callback, node, type, data = {}) { + const childNode = node.initializeChildNode(type, CosmosDbDiagnosticLevel.debug, data); + try { + const response = await callback(childNode); + childNode.updateTimestamp(); + return response; + } + catch (e) { + childNode.addData({ + failure: true, + }); + childNode.updateTimestamp(); + throw e; + } +} +/** + * A supporting utility wrapper function, to be used inside a diagnostic session started + * by `withDiagnostics` function. + * Treats requests originating in provided `callback` as metadata calls. + * To realize this, starts a temporary diagnostic session, after execution of callback is + * finished. Merges this temporary diagnostic session to the original diagnostic session + * represented by the input parameter `node`. + * @hidden + */ +export async function withMetadataDiagnostics(callback, node, type) { + const diagnosticNodeForMetadataCall = new DiagnosticNodeInternal(node.diagnosticLevel, DiagnosticNodeType.METADATA_REQUEST_NODE, null); + try { + const response = await callback(diagnosticNodeForMetadataCall); + node.addChildNode(diagnosticNodeForMetadataCall, CosmosDbDiagnosticLevel.debug, type); + return response; + } + catch (e) { + node.addChildNode(diagnosticNodeForMetadataCall, CosmosDbDiagnosticLevel.debug, type); + throw e; + } +} +/** + * Utility wrapper function to managed lifecycle of a Diagnostic session. + * Meant to be used at the root of the client operation. i.e. item.read(), + * queryIterator.fetchAll(). + * + * This utility starts a new diagnostic session. So using it any where else + * other than start of operation, will result is different diagnostic sessions. + * + * Workings : + * 1. Takes a callback function as input. + * 2. Creates a new instance of DiagnosticNodeInternal, which can be though as starting + * a new diagnostic session. + * 3. Executes the callback function. + * 4. If execution was successful. Converts DiagnosticNodeInternal to CosmosDiagnostics + * and injects it to the response object and returns this object. + * 5. If execution threw an exception. Sill converts DiagnosticNodeInternal to CosmosDiagnostics + * and injects it to the Error object, and rethrows the Error object. + * + * @hidden + */ +export async function withDiagnostics(callback, clientContext, type = DiagnosticNodeType.CLIENT_REQUEST_NODE) { + const diagnosticNode = new DiagnosticNodeInternal(clientContext.diagnosticLevel, type, null); + try { + const response = await callback(diagnosticNode); + diagnosticNode.updateTimestamp(); + const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig()); + if (typeof response === "object" && response !== null) { + response.diagnostics = diagnostics; + } + clientContext.recordDiagnostics(diagnostics); + return response; + } + catch (e) { + diagnosticNode.updateTimestamp(); + diagnosticNode.addData({ + failure: true, + }); + const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig()); + e.diagnostics = diagnostics; + clientContext.recordDiagnostics(diagnostics); + throw e; + } +} +//# sourceMappingURL=diagnostics.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js.map new file mode 100644 index 000000000..8b3bf3bea --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/diagnostics.js.map @@ -0,0 +1 @@ +{"version":3,"file":"diagnostics.js","sourceRoot":"","sources":["../../../src/utils/diagnostics.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,iBAAiB,EAAsB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF;;;GAGG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,IAAI,iBAAiB,CAC1B;QACE,mBAAmB,EAAE,CAAC;QACtB,uBAAuB,EAAE,uBAAuB,EAAE;QAClD,gCAAgC,EAAE,CAAC;QACnC,iCAAiC,EAAE,CAAC;QACpC,0BAA0B,EAAE,EAAE;QAC9B,gBAAgB,EAAE;YAChB,cAAc,EAAE,EAAE;SACnB;QACD,mBAAmB,EAAE;YACnB,eAAe,EAAE,EAAE;SACpB;QACD,iBAAiB,EAAE,EAAE;KACtB,EACD;QACE,EAAE,EAAE,EAAE,EAAE;QACR,QAAQ,EAAE,kBAAkB,CAAC,mBAAmB;QAChD,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,EAAE;QACR,gBAAgB,EAAE,uBAAuB,EAAE;QAC3C,YAAY,EAAE,CAAC;KAChB,CACF,CAAC;AACJ,CAAC;AAOD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAGrC,QAAkB,EACl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IAAI,EAAE,IAAI,CAAC,CAAC;IAC7F,IAAI;QACF,MAAM,QAAQ,GAAQ,MAAM,QAAQ,CAAC,cAAc,CAAC,CAAC;QACrD,cAAc,CAAC,eAAe,EAAE,CAAC;QACjC,MAAM,WAAW,GAAG,cAAc,CAAC,YAAY,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC,CAAC;QACjF,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,EAAE;YACpD,QAAgB,CAAC,WAAW,GAAG,WAAW,CAAC;SAC7C;QACD,aAAa,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC7C,OAAO,QAAQ,CAAC;KACjB;IAAC,OAAO,CAAM,EAAE;QACf,cAAc,CAAC,eAAe,EAAE,CAAC;QACjC,cAAc,CAAC,OAAO,CAAC;YACrB,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QACH,MAAM,WAAW,GAAG,cAAc,CAAC,YAAY,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC,CAAC;QACjF,CAAC,CAAC,WAAW,GAAG,WAAW,CAAC;QAC5B,aAAa,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAC7C,MAAM,CAAC,CAAC;KACT;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDiagnostics, MetadataLookUpType } from \"../CosmosDiagnostics\";\nimport {\n DiagnosticDataValue,\n DiagnosticNodeInternal,\n DiagnosticNodeType,\n} from \"../diagnostics/DiagnosticNodeInternal\";\nimport { ClientContext } from \"../ClientContext\";\nimport { getCurrentTimestampInMs } from \"./time\";\nimport { v4 } from \"uuid\";\nimport { CosmosDbDiagnosticLevel } from \"../diagnostics/CosmosDbDiagnosticLevel\";\n\n/**\n * @hidden\n * Utility function to create an Empty CosmosDiagnostic object.\n */\nexport function getEmptyCosmosDiagnostics(): CosmosDiagnostics {\n return new CosmosDiagnostics(\n {\n requestDurationInMs: 0,\n requestStartTimeUTCInMs: getCurrentTimestampInMs(),\n totalRequestPayloadLengthInBytes: 0,\n totalResponsePayloadLengthInBytes: 0,\n locationEndpointsContacted: [],\n retryDiagnostics: {\n failedAttempts: [],\n },\n metadataDiagnostics: {\n metadataLookups: [],\n },\n gatewayStatistics: [],\n },\n {\n id: v4(),\n nodeType: DiagnosticNodeType.CLIENT_REQUEST_NODE,\n children: [],\n data: {},\n startTimeUTCInMs: getCurrentTimestampInMs(),\n durationInMs: 0,\n },\n );\n}\n\n/**\n * @hidden\n */\nexport type ExtractPromise = T extends Promise ? U : never;\n\n/**\n * A supporting utility wrapper function, to be used inside a diagnostic session started\n * by `withDiagnostics` function.\n * Created a Diagnostic node and add it as a child to existing diagnostic session.\n * @hidden\n */\nexport async function addDignosticChild<\n Callback extends (node: DiagnosticNodeInternal) => Promise,\n>(\n callback: Callback,\n node: DiagnosticNodeInternal,\n type: DiagnosticNodeType,\n data: Partial = {},\n): Promise>> {\n const childNode = node.initializeChildNode(type, CosmosDbDiagnosticLevel.debug, data);\n try {\n const response = await callback(childNode);\n childNode.updateTimestamp();\n return response;\n } catch (e: any) {\n childNode.addData({\n failure: true,\n });\n childNode.updateTimestamp();\n throw e;\n }\n}\n\n/**\n * A supporting utility wrapper function, to be used inside a diagnostic session started\n * by `withDiagnostics` function.\n * Treats requests originating in provided `callback` as metadata calls.\n * To realize this, starts a temporary diagnostic session, after execution of callback is\n * finished. Merges this temporary diagnostic session to the original diagnostic session\n * represented by the input parameter `node`.\n * @hidden\n */\nexport async function withMetadataDiagnostics<\n Callback extends (node: DiagnosticNodeInternal) => Promise,\n>(\n callback: Callback,\n node: DiagnosticNodeInternal,\n type: MetadataLookUpType,\n): Promise>> {\n const diagnosticNodeForMetadataCall = new DiagnosticNodeInternal(\n node.diagnosticLevel,\n DiagnosticNodeType.METADATA_REQUEST_NODE,\n null,\n );\n try {\n const response: any = await callback(diagnosticNodeForMetadataCall);\n node.addChildNode(diagnosticNodeForMetadataCall, CosmosDbDiagnosticLevel.debug, type);\n return response;\n } catch (e) {\n node.addChildNode(diagnosticNodeForMetadataCall, CosmosDbDiagnosticLevel.debug, type);\n throw e;\n }\n}\n\n/**\n * Utility wrapper function to managed lifecycle of a Diagnostic session.\n * Meant to be used at the root of the client operation. i.e. item.read(),\n * queryIterator.fetchAll().\n *\n * This utility starts a new diagnostic session. So using it any where else\n * other than start of operation, will result is different diagnostic sessions.\n *\n * Workings :\n * 1. Takes a callback function as input.\n * 2. Creates a new instance of DiagnosticNodeInternal, which can be though as starting\n * a new diagnostic session.\n * 3. Executes the callback function.\n * 4. If execution was successful. Converts DiagnosticNodeInternal to CosmosDiagnostics\n * and injects it to the response object and returns this object.\n * 5. If execution threw an exception. Sill converts DiagnosticNodeInternal to CosmosDiagnostics\n * and injects it to the Error object, and rethrows the Error object.\n *\n * @hidden\n */\nexport async function withDiagnostics<\n Callback extends (node: DiagnosticNodeInternal) => Promise,\n>(\n callback: Callback,\n clientContext: ClientContext,\n type: DiagnosticNodeType = DiagnosticNodeType.CLIENT_REQUEST_NODE,\n): Promise>> {\n const diagnosticNode = new DiagnosticNodeInternal(clientContext.diagnosticLevel, type, null);\n try {\n const response: any = await callback(diagnosticNode);\n diagnosticNode.updateTimestamp();\n const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig());\n if (typeof response === \"object\" && response !== null) {\n (response as any).diagnostics = diagnostics;\n }\n clientContext.recordDiagnostics(diagnostics);\n return response;\n } catch (e: any) {\n diagnosticNode.updateTimestamp();\n diagnosticNode.addData({\n failure: true,\n });\n const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig());\n e.diagnostics = diagnostics;\n clientContext.recordDiagnostics(diagnostics);\n throw e;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts new file mode 100644 index 000000000..58e11d203 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts @@ -0,0 +1,2 @@ +export declare function digest(str: string): Promise; +//# sourceMappingURL=digest.browser.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts.map new file mode 100644 index 000000000..63e2e73ec --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"digest.browser.d.ts","sourceRoot":"","sources":["../../../src/utils/digest.browser.ts"],"names":[],"mappings":"AAMA,wBAAsB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIzD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js new file mode 100644 index 000000000..c60174ec2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { encodeUTF8 } from "./encode"; +import { globalCrypto } from "./globalCrypto"; +export async function digest(str) { + const data = encodeUTF8(str); + const hash = await globalCrypto.subtle.digest("SHA-256", data); + return bufferToHex(hash); +} +function bufferToHex(buffer) { + return Array.prototype.map + .call(new Uint8Array(buffer), (item) => ("00" + item.toString(16)).slice(-2)) + .join(""); +} +//# sourceMappingURL=digest.browser.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js.map new file mode 100644 index 000000000..1e01a8c12 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"digest.browser.js","sourceRoot":"","sources":["../../../src/utils/digest.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/D,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,WAAW,CAAC,MAAmB;IACtC,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;SACvB,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SACpF,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { encodeUTF8 } from \"./encode\";\nimport { globalCrypto } from \"./globalCrypto\";\n\nexport async function digest(str: string): Promise {\n const data = encodeUTF8(str);\n const hash = await globalCrypto.subtle.digest(\"SHA-256\", data);\n return bufferToHex(hash);\n}\n\nfunction bufferToHex(buffer: ArrayBuffer): string {\n return Array.prototype.map\n .call(new Uint8Array(buffer), (item: number) => (\"00\" + item.toString(16)).slice(-2))\n .join(\"\");\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts new file mode 100644 index 000000000..6971dbfb5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts @@ -0,0 +1,2 @@ +export declare function digest(str: string): Promise; +//# sourceMappingURL=digest.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts.map new file mode 100644 index 000000000..4bf95bcff --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../src/utils/digest.ts"],"names":[],"mappings":"AAKA,wBAAsB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAIzD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js new file mode 100644 index 000000000..50e8cc1f1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createHash } from "crypto"; +export async function digest(str) { + const hash = createHash("sha256"); + hash.update(str, "utf8"); + return hash.digest("hex"); +} +//# sourceMappingURL=digest.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js.map new file mode 100644 index 000000000..3a064147f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/digest.js.map @@ -0,0 +1 @@ +{"version":3,"file":"digest.js","sourceRoot":"","sources":["../../../src/utils/digest.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,GAAW;IACtC,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHash } from \"crypto\";\n\nexport async function digest(str: string): Promise {\n const hash = createHash(\"sha256\");\n hash.update(str, \"utf8\");\n return hash.digest(\"hex\");\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts new file mode 100644 index 000000000..a9613ec66 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts @@ -0,0 +1,4 @@ +/// +export declare function encodeUTF8(str: string): Uint8Array; +export declare function encodeBase64(value: ArrayBuffer): string; +//# sourceMappingURL=encode.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts.map new file mode 100644 index 000000000..b99d31805 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/utils/encode.ts"],"names":[],"mappings":";AAKA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAMlD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAYvD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js new file mode 100644 index 000000000..07ad71a97 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/// +export function encodeUTF8(str) { + const bytes = new Uint8Array(str.length); + for (let i = 0; i < str.length; i++) { + bytes[i] = str.charCodeAt(i); + } + return bytes; +} +export function encodeBase64(value) { + if ("function" !== typeof btoa) { + throw new Error("Your browser environment is missing the global `btoa` function"); + } + let binary = ""; + const bytes = new Uint8Array(value); + const len = bytes.byteLength; + for (let i = 0; i < len; i++) { + binary += String.fromCharCode(bytes[i]); + } + return btoa(binary); +} +//# sourceMappingURL=encode.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js.map new file mode 100644 index 000000000..e13ca10e6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/encode.js.map @@ -0,0 +1 @@ +{"version":3,"file":"encode.js","sourceRoot":"","sources":["../../../src/utils/encode.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,0BAA0B;AAE1B,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACnC,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAC9B;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAkB;IAC7C,IAAI,UAAU,KAAK,OAAO,IAAI,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;KACnF;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;QAC5B,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;KACzC;IACD,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// \n\nexport function encodeUTF8(str: string): Uint8Array {\n const bytes = new Uint8Array(str.length);\n for (let i = 0; i < str.length; i++) {\n bytes[i] = str.charCodeAt(i);\n }\n return bytes;\n}\n\nexport function encodeBase64(value: ArrayBuffer): string {\n if (\"function\" !== typeof btoa) {\n throw new Error(\"Your browser environment is missing the global `btoa` function\");\n }\n\n let binary = \"\";\n const bytes = new Uint8Array(value);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts new file mode 100644 index 000000000..031468ef5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts @@ -0,0 +1,3 @@ +declare const globalCrypto: Crypto; +export { globalCrypto }; +//# sourceMappingURL=globalCrypto.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts.map new file mode 100644 index 000000000..d161fda18 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"globalCrypto.d.ts","sourceRoot":"","sources":["../../../src/utils/globalCrypto.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,YAAY,EAAE,MAA+C,CAAC;AAMpE,OAAO,EAAE,YAAY,EAAE,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js new file mode 100644 index 000000000..22e96f083 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// eslint-disable-next-line @azure/azure-sdk/ts-no-window +const globalRef = typeof self === "undefined" ? window : self; +if (!globalRef) { + throw new Error("Could not find global"); +} +const globalCrypto = globalRef.crypto || globalRef.msCrypto; +if (!globalCrypto || !globalCrypto.subtle) { + throw new Error("Browser does not support cryptography functions"); +} +export { globalCrypto }; +//# sourceMappingURL=globalCrypto.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js.map new file mode 100644 index 000000000..27fab9079 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.js.map @@ -0,0 +1 @@ +{"version":3,"file":"globalCrypto.js","sourceRoot":"","sources":["../../../src/utils/globalCrypto.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,yDAAyD;AACzD,MAAM,SAAS,GAAQ,OAAO,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAEnE,IAAI,CAAC,SAAS,EAAE;IACd,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;CAC1C;AAED,MAAM,YAAY,GAAW,SAAS,CAAC,MAAM,IAAI,SAAS,CAAC,QAAQ,CAAC;AAEpE,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;IACzC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;CACpE;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// eslint-disable-next-line @azure/azure-sdk/ts-no-window\nconst globalRef: any = typeof self === \"undefined\" ? window : self;\n\nif (!globalRef) {\n throw new Error(\"Could not find global\");\n}\n\nconst globalCrypto: Crypto = globalRef.crypto || globalRef.msCrypto;\n\nif (!globalCrypto || !globalCrypto.subtle) {\n throw new Error(\"Browser does not support cryptography functions\");\n}\n\nexport { globalCrypto };\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts new file mode 100644 index 000000000..635c2c011 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts @@ -0,0 +1,3 @@ +declare const globalCrypto: any; +export { globalCrypto }; +//# sourceMappingURL=globalCrypto.native.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts.map new file mode 100644 index 000000000..5c3d2b757 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"globalCrypto.native.d.ts","sourceRoot":"","sources":["../../../src/utils/globalCrypto.native.ts"],"names":[],"mappings":"AAMA,QAAA,MAAM,YAAY,KAAkC,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js new file mode 100644 index 000000000..1a069eabf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// isomorphic-webcrypto is not listed as a dependency in package.json because +// doing so requires adding a bunch of react packages as peer dependencies. So, +// it is being loaded dynamically here to not cause compiler error. +const globalCrypto = require("isomorphic-webcrypto"); // eslint-disable-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports +export { globalCrypto }; +//# sourceMappingURL=globalCrypto.native.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js.map new file mode 100644 index 000000000..1b92c11b0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/globalCrypto.native.js.map @@ -0,0 +1 @@ +{"version":3,"file":"globalCrypto.native.js","sourceRoot":"","sources":["../../../src/utils/globalCrypto.native.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,6EAA6E;AAC7E,+EAA+E;AAC/E,mEAAmE;AACnE,MAAM,YAAY,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,+FAA+F;AACrJ,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// isomorphic-webcrypto is not listed as a dependency in package.json because\n// doing so requires adding a bunch of react packages as peer dependencies. So,\n// it is being loaded dynamically here to not cause compiler error.\nconst globalCrypto = require(\"isomorphic-webcrypto\"); // eslint-disable-line import/no-extraneous-dependencies, @typescript-eslint/no-require-imports\nexport { globalCrypto };\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts new file mode 100644 index 000000000..28f2a77a2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts @@ -0,0 +1,2 @@ +export declare function hashObject(object: unknown): Promise; +//# sourceMappingURL=hashObject.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts.map new file mode 100644 index 000000000..dfad13a89 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hashObject.d.ts","sourceRoot":"","sources":["../../../src/utils/hashObject.ts"],"names":[],"mappings":"AAMA,wBAAsB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAGjE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js new file mode 100644 index 000000000..5b6cee4f2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { digest } from "./digest"; +import stableStringify from "fast-json-stable-stringify"; +export async function hashObject(object) { + const stringifiedObject = stableStringify(object); + return digest(stringifiedObject); +} +//# sourceMappingURL=hashObject.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js.map new file mode 100644 index 000000000..2c15ae8be --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashObject.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hashObject.js","sourceRoot":"","sources":["../../../src/utils/hashObject.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,eAAe,MAAM,4BAA4B,CAAC;AAEzD,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,MAAe;IAC9C,MAAM,iBAAiB,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAClD,OAAO,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACnC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { digest } from \"./digest\";\nimport stableStringify from \"fast-json-stable-stringify\";\n\nexport async function hashObject(object: unknown): Promise {\n const stringifiedObject = stableStringify(object);\n return digest(stringifiedObject);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts new file mode 100644 index 000000000..9a1de5454 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts @@ -0,0 +1,4 @@ +/// +export declare function writeNumberForBinaryEncodingJSBI(hash: number): Buffer; +export declare function doubleToByteArrayJSBI(double: number): Buffer; +//# sourceMappingURL=number.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts.map new file mode 100644 index 000000000..9ebf48750 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../../src/utils/hashing/encoding/number.ts"],"names":[],"mappings":";AAMA,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAyCrE;AAYD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAY5D"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js new file mode 100644 index 000000000..a1657baaf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import JSBI from "jsbi"; +import { BytePrefix } from "./prefix"; +export function writeNumberForBinaryEncodingJSBI(hash) { + let payload = encodeNumberAsUInt64JSBI(hash); + let outputStream = Buffer.from(BytePrefix.Number, "hex"); + const firstChunk = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56))); + outputStream = Buffer.concat([outputStream, Buffer.from(firstChunk.toString(16), "hex")]); + payload = JSBI.asUintN(64, JSBI.leftShift(JSBI.BigInt(payload), JSBI.BigInt(0x8))); + let byteToWrite = JSBI.BigInt(0); + let firstIteration = false; + let shifted; + let padded; + do { + if (!firstIteration) { + // we pad because after shifting because we will produce characters like "f" or similar, + // which cannot be encoded as hex in a buffer because they are invalid hex + // https://github.com/nodejs/node/issues/24491 + padded = byteToWrite.toString(16).padStart(2, "0"); + if (padded !== "00") { + outputStream = Buffer.concat([outputStream, Buffer.from(padded, "hex")]); + } + } + else { + firstIteration = false; + } + shifted = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56))); + byteToWrite = JSBI.asUintN(64, JSBI.bitwiseOr(shifted, JSBI.BigInt(0x01))); + payload = JSBI.asUintN(64, JSBI.leftShift(payload, JSBI.BigInt(7))); + } while (JSBI.notEqual(payload, JSBI.BigInt(0))); + const lastChunk = JSBI.asUintN(64, JSBI.bitwiseAnd(byteToWrite, JSBI.BigInt(0xfe))); + // we pad because after shifting because we will produce characters like "f" or similar, + // which cannot be encoded as hex in a buffer because they are invalid hex + // https://github.com/nodejs/node/issues/24491 + padded = lastChunk.toString(16).padStart(2, "0"); + if (padded !== "00") { + outputStream = Buffer.concat([outputStream, Buffer.from(padded, "hex")]); + } + return outputStream; +} +function encodeNumberAsUInt64JSBI(value) { + const rawValueBits = getRawBitsJSBI(value); + const mask = JSBI.BigInt(0x8000000000000000); + const returned = rawValueBits < mask + ? JSBI.bitwiseXor(rawValueBits, mask) + : JSBI.add(JSBI.bitwiseNot(rawValueBits), JSBI.BigInt(1)); + return returned; +} +export function doubleToByteArrayJSBI(double) { + const output = Buffer.alloc(8); + const lng = getRawBitsJSBI(double); + for (let i = 0; i < 8; i++) { + output[i] = JSBI.toNumber(JSBI.bitwiseAnd(JSBI.signedRightShift(lng, JSBI.multiply(JSBI.BigInt(i), JSBI.BigInt(8))), JSBI.BigInt(0xff))); + } + return output; +} +function getRawBitsJSBI(value) { + const view = new DataView(new ArrayBuffer(8)); + view.setFloat64(0, value); + return JSBI.BigInt(`0x${buf2hex(view.buffer)}`); +} +function buf2hex(buffer) { + return Array.prototype.map + .call(new Uint8Array(buffer), (x) => ("00" + x.toString(16)).slice(-2)) + .join(""); +} +//# sourceMappingURL=number.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js.map new file mode 100644 index 000000000..a6e911d29 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/number.js.map @@ -0,0 +1 @@ +{"version":3,"file":"number.js","sourceRoot":"","sources":["../../../../../src/utils/hashing/encoding/number.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,UAAU,gCAAgC,CAAC,IAAY;IAC3D,IAAI,OAAO,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAC7C,IAAI,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAErF,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1F,OAAO,GAAG,IAAI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C,GAAG,IAAI,CAAC,QAAQ,CACvB,IAAI,CAAC,UAAU,CACb,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EACzE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAClB,CACF,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9C,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,OAAO,CAAC,MAAmB;IAClC,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;SACvB,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC9E,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport JSBI from \"jsbi\";\nimport { BytePrefix } from \"./prefix\";\n\nexport function writeNumberForBinaryEncodingJSBI(hash: number): Buffer {\n let payload = encodeNumberAsUInt64JSBI(hash);\n let outputStream = Buffer.from(BytePrefix.Number, \"hex\");\n const firstChunk = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56)));\n\n outputStream = Buffer.concat([outputStream, Buffer.from(firstChunk.toString(16), \"hex\")]);\n payload = JSBI.asUintN(64, JSBI.leftShift(JSBI.BigInt(payload), JSBI.BigInt(0x8)));\n\n let byteToWrite = JSBI.BigInt(0);\n let firstIteration = false;\n let shifted: JSBI;\n let padded: string;\n\n do {\n if (!firstIteration) {\n // we pad because after shifting because we will produce characters like \"f\" or similar,\n // which cannot be encoded as hex in a buffer because they are invalid hex\n // https://github.com/nodejs/node/issues/24491\n padded = byteToWrite.toString(16).padStart(2, \"0\");\n if (padded !== \"00\") {\n outputStream = Buffer.concat([outputStream, Buffer.from(padded, \"hex\")]);\n }\n } else {\n firstIteration = false;\n }\n\n shifted = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56)));\n byteToWrite = JSBI.asUintN(64, JSBI.bitwiseOr(shifted, JSBI.BigInt(0x01)));\n payload = JSBI.asUintN(64, JSBI.leftShift(payload, JSBI.BigInt(7)));\n } while (JSBI.notEqual(payload, JSBI.BigInt(0)));\n\n const lastChunk = JSBI.asUintN(64, JSBI.bitwiseAnd(byteToWrite, JSBI.BigInt(0xfe)));\n // we pad because after shifting because we will produce characters like \"f\" or similar,\n // which cannot be encoded as hex in a buffer because they are invalid hex\n // https://github.com/nodejs/node/issues/24491\n padded = lastChunk.toString(16).padStart(2, \"0\");\n if (padded !== \"00\") {\n outputStream = Buffer.concat([outputStream, Buffer.from(padded, \"hex\")]);\n }\n\n return outputStream;\n}\n\nfunction encodeNumberAsUInt64JSBI(value: number): JSBI {\n const rawValueBits = getRawBitsJSBI(value);\n const mask = JSBI.BigInt(0x8000000000000000);\n const returned =\n rawValueBits < mask\n ? JSBI.bitwiseXor(rawValueBits, mask)\n : JSBI.add(JSBI.bitwiseNot(rawValueBits), JSBI.BigInt(1));\n return returned;\n}\n\nexport function doubleToByteArrayJSBI(double: number): Buffer {\n const output: Buffer = Buffer.alloc(8);\n const lng = getRawBitsJSBI(double);\n for (let i = 0; i < 8; i++) {\n output[i] = JSBI.toNumber(\n JSBI.bitwiseAnd(\n JSBI.signedRightShift(lng, JSBI.multiply(JSBI.BigInt(i), JSBI.BigInt(8))),\n JSBI.BigInt(0xff),\n ),\n );\n }\n return output;\n}\n\nfunction getRawBitsJSBI(value: number): JSBI {\n const view = new DataView(new ArrayBuffer(8));\n view.setFloat64(0, value);\n return JSBI.BigInt(`0x${buf2hex(view.buffer)}`);\n}\n\nfunction buf2hex(buffer: ArrayBuffer): string {\n return Array.prototype.map\n .call(new Uint8Array(buffer), (x: number) => (\"00\" + x.toString(16)).slice(-2))\n .join(\"\");\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts new file mode 100644 index 000000000..51300e5ca --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts @@ -0,0 +1,25 @@ +export declare const BytePrefix: { + Undefined: string; + Null: string; + False: string; + True: string; + MinNumber: string; + Number: string; + MaxNumber: string; + MinString: string; + String: string; + MaxString: string; + Int64: string; + Int32: string; + Int16: string; + Int8: string; + Uint64: string; + Uint32: string; + Uint16: string; + Uint8: string; + Binary: string; + Guid: string; + Float: string; + Infinity: string; +}; +//# sourceMappingURL=prefix.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts.map new file mode 100644 index 000000000..aa1713674 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"prefix.d.ts","sourceRoot":"","sources":["../../../../../src/utils/hashing/encoding/prefix.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;CAuBtB,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js new file mode 100644 index 000000000..dd3cf5f93 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export const BytePrefix = { + Undefined: "00", + Null: "01", + False: "02", + True: "03", + MinNumber: "04", + Number: "05", + MaxNumber: "06", + MinString: "07", + String: "08", + MaxString: "09", + Int64: "0a", + Int32: "0b", + Int16: "0c", + Int8: "0d", + Uint64: "0e", + Uint32: "0f", + Uint16: "10", + Uint8: "11", + Binary: "12", + Guid: "13", + Float: "14", + Infinity: "FF", +}; +//# sourceMappingURL=prefix.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js.map new file mode 100644 index 000000000..b0239e74a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/prefix.js.map @@ -0,0 +1 @@ +{"version":3,"file":"prefix.js","sourceRoot":"","sources":["../../../../../src/utils/hashing/encoding/prefix.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,IAAI;IACV,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,IAAI;IACZ,SAAS,EAAE,IAAI;IACf,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,IAAI;CACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const BytePrefix = {\n Undefined: \"00\",\n Null: \"01\",\n False: \"02\",\n True: \"03\",\n MinNumber: \"04\",\n Number: \"05\",\n MaxNumber: \"06\",\n MinString: \"07\",\n String: \"08\",\n MaxString: \"09\",\n Int64: \"0a\",\n Int32: \"0b\",\n Int16: \"0c\",\n Int8: \"0d\",\n Uint64: \"0e\",\n Uint32: \"0f\",\n Uint16: \"10\",\n Uint8: \"11\",\n Binary: \"12\",\n Guid: \"13\",\n Float: \"14\",\n Infinity: \"FF\",\n};\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts new file mode 100644 index 000000000..ec7cc915c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts @@ -0,0 +1,3 @@ +/// +export declare function writeStringForBinaryEncoding(payload: string): Buffer; +//# sourceMappingURL=string.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts.map new file mode 100644 index 000000000..623991884 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../../../src/utils/hashing/encoding/string.ts"],"names":[],"mappings":";AAKA,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAuBpE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js new file mode 100644 index 000000000..ef101d357 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { BytePrefix } from "./prefix"; +export function writeStringForBinaryEncoding(payload) { + let outputStream = Buffer.from(BytePrefix.String, "hex"); + const MAX_STRING_BYTES_TO_APPEND = 100; + const byteArray = [...Buffer.from(payload)]; + const isShortString = payload.length <= MAX_STRING_BYTES_TO_APPEND; + for (let index = 0; index < (isShortString ? byteArray.length : MAX_STRING_BYTES_TO_APPEND + 1); index++) { + let charByte = byteArray[index]; + if (charByte < 0xff) { + charByte++; + } + outputStream = Buffer.concat([outputStream, Buffer.from(charByte.toString(16), "hex")]); + } + if (isShortString) { + outputStream = Buffer.concat([outputStream, Buffer.from(BytePrefix.Undefined, "hex")]); + } + return outputStream; +} +//# sourceMappingURL=string.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js.map new file mode 100644 index 000000000..58542cf75 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/encoding/string.js.map @@ -0,0 +1 @@ +{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../../src/utils/hashing/encoding/string.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,MAAM,UAAU,4BAA4B,CAAC,OAAe;IAC1D,IAAI,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACzD,MAAM,0BAA0B,GAAG,GAAG,CAAC;IACvC,MAAM,SAAS,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE5C,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,IAAI,0BAA0B,CAAC;IAEnE,KACE,IAAI,KAAK,GAAG,CAAC,EACb,KAAK,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,0BAA0B,GAAG,CAAC,CAAC,EAC3E,KAAK,EAAE,EACP;QACA,IAAI,QAAQ,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,QAAQ,GAAG,IAAI,EAAE;YACnB,QAAQ,EAAE,CAAC;SACZ;QACD,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KACzF;IAED,IAAI,aAAa,EAAE;QACjB,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;KACxF;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { BytePrefix } from \"./prefix\";\n\nexport function writeStringForBinaryEncoding(payload: string): Buffer {\n let outputStream = Buffer.from(BytePrefix.String, \"hex\");\n const MAX_STRING_BYTES_TO_APPEND = 100;\n const byteArray = [...Buffer.from(payload)];\n\n const isShortString = payload.length <= MAX_STRING_BYTES_TO_APPEND;\n\n for (\n let index = 0;\n index < (isShortString ? byteArray.length : MAX_STRING_BYTES_TO_APPEND + 1);\n index++\n ) {\n let charByte = byteArray[index];\n if (charByte < 0xff) {\n charByte++;\n }\n outputStream = Buffer.concat([outputStream, Buffer.from(charByte.toString(16), \"hex\")]);\n }\n\n if (isShortString) {\n outputStream = Buffer.concat([outputStream, Buffer.from(BytePrefix.Undefined, \"hex\")]);\n }\n return outputStream;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts new file mode 100644 index 000000000..090389b98 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts @@ -0,0 +1,9 @@ +import { PartitionKeyDefinition, PrimitivePartitionKeyValue } from "../../documents"; +/** + * Generate hash of a PartitonKey based on it PartitionKeyDefinition. + * @param partitionKey - to be hashed. + * @param partitionDefinition - container's partitionKey definition + * @returns + */ +export declare function hashPartitionKey(partitionKey: PrimitivePartitionKeyValue[], partitionDefinition: PartitionKeyDefinition): string; +//# sourceMappingURL=hash.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts.map new file mode 100644 index 000000000..e3b785178 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashing/hash.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EAGtB,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AAKzB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,YAAY,EAAE,0BAA0B,EAAE,EAC1C,mBAAmB,EAAE,sBAAsB,GAC1C,MAAM,CAYR"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js new file mode 100644 index 000000000..97d6ec986 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { PartitionKeyDefinitionVersion, PartitionKeyKind, } from "../../documents"; +import { hashMultiHashPartitionKey } from "./multiHash"; +import { hashV1PartitionKey } from "./v1"; +import { hashV2PartitionKey } from "./v2"; +/** + * Generate hash of a PartitonKey based on it PartitionKeyDefinition. + * @param partitionKey - to be hashed. + * @param partitionDefinition - container's partitionKey definition + * @returns + */ +export function hashPartitionKey(partitionKey, partitionDefinition) { + const kind = (partitionDefinition === null || partitionDefinition === void 0 ? void 0 : partitionDefinition.kind) || PartitionKeyKind.Hash; // Default value. + const isV2 = partitionDefinition && + partitionDefinition.version && + partitionDefinition.version === PartitionKeyDefinitionVersion.V2; + switch (kind) { + case PartitionKeyKind.Hash: + return isV2 ? hashV2PartitionKey(partitionKey) : hashV1PartitionKey(partitionKey); + case PartitionKeyKind.MultiHash: + return hashMultiHashPartitionKey(partitionKey); + } +} +//# sourceMappingURL=hash.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js.map new file mode 100644 index 000000000..21f5c5ba3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/hash.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hash.js","sourceRoot":"","sources":["../../../../src/utils/hashing/hash.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAEL,6BAA6B,EAC7B,gBAAgB,GAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,YAA0C,EAC1C,mBAA2C;IAE3C,MAAM,IAAI,GAAqB,CAAA,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,IAAI,KAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,iBAAiB;IACpG,MAAM,IAAI,GACR,mBAAmB;QACnB,mBAAmB,CAAC,OAAO;QAC3B,mBAAmB,CAAC,OAAO,KAAK,6BAA6B,CAAC,EAAE,CAAC;IACnE,QAAQ,IAAI,EAAE;QACZ,KAAK,gBAAgB,CAAC,IAAI;YACxB,OAAO,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;QACpF,KAAK,gBAAgB,CAAC,SAAS;YAC7B,OAAO,yBAAyB,CAAC,YAAY,CAAC,CAAC;KAClD;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PartitionKeyDefinition,\n PartitionKeyDefinitionVersion,\n PartitionKeyKind,\n PrimitivePartitionKeyValue,\n} from \"../../documents\";\nimport { hashMultiHashPartitionKey } from \"./multiHash\";\nimport { hashV1PartitionKey } from \"./v1\";\nimport { hashV2PartitionKey } from \"./v2\";\n\n/**\n * Generate hash of a PartitonKey based on it PartitionKeyDefinition.\n * @param partitionKey - to be hashed.\n * @param partitionDefinition - container's partitionKey definition\n * @returns\n */\nexport function hashPartitionKey(\n partitionKey: PrimitivePartitionKeyValue[],\n partitionDefinition: PartitionKeyDefinition,\n): string {\n const kind: PartitionKeyKind = partitionDefinition?.kind || PartitionKeyKind.Hash; // Default value.\n const isV2 =\n partitionDefinition &&\n partitionDefinition.version &&\n partitionDefinition.version === PartitionKeyDefinitionVersion.V2;\n switch (kind) {\n case PartitionKeyKind.Hash:\n return isV2 ? hashV2PartitionKey(partitionKey) : hashV1PartitionKey(partitionKey);\n case PartitionKeyKind.MultiHash:\n return hashMultiHashPartitionKey(partitionKey);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts new file mode 100644 index 000000000..05b7a59e4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts @@ -0,0 +1,8 @@ +import { PrimitivePartitionKeyValue } from "../../documents"; +/** + * Generate Hash for a `Multi Hash` type partition. + * @param partitionKey - to be hashed. + * @returns + */ +export declare function hashMultiHashPartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string; +//# sourceMappingURL=multiHash.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts.map new file mode 100644 index 000000000..f32f6802c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"multiHash.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashing/multiHash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAG7D;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,0BAA0B,EAAE,GAAG,MAAM,CAE5F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js new file mode 100644 index 000000000..d9979699d --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js @@ -0,0 +1,10 @@ +import { hashV2PartitionKey } from "./v2"; +/** + * Generate Hash for a `Multi Hash` type partition. + * @param partitionKey - to be hashed. + * @returns + */ +export function hashMultiHashPartitionKey(partitionKey) { + return partitionKey.map((keys) => hashV2PartitionKey([keys])).join(""); +} +//# sourceMappingURL=multiHash.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js.map new file mode 100644 index 000000000..677374010 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/multiHash.js.map @@ -0,0 +1 @@ +{"version":3,"file":"multiHash.js","sourceRoot":"","sources":["../../../../src/utils/hashing/multiHash.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAA0C;IAClF,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PrimitivePartitionKeyValue } from \"../../documents\";\nimport { hashV2PartitionKey } from \"./v2\";\n\n/**\n * Generate Hash for a `Multi Hash` type partition.\n * @param partitionKey - to be hashed.\n * @returns\n */\nexport function hashMultiHashPartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string {\n return partitionKey.map((keys) => hashV2PartitionKey([keys])).join(\"\");\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts new file mode 100644 index 000000000..ece51a7b5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts @@ -0,0 +1,18 @@ +/// +declare function x86Hash32(bytes: Buffer, seed?: number): number; +declare function x86Hash128(bytes: Buffer, seed?: number): string; +declare function x64Hash128(bytes: Buffer, seed?: number): string; +export declare function reverse(buff: Buffer): Buffer; +declare const _default: { + version: string; + x86: { + hash32: typeof x86Hash32; + hash128: typeof x86Hash128; + }; + x64: { + hash128: typeof x64Hash128; + }; + inputValidation: boolean; +}; +export default _default; +//# sourceMappingURL=murmurHash.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts.map new file mode 100644 index 000000000..b5383c3a8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"murmurHash.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashing/murmurHash.ts"],"names":[],"mappings":";AAiLA,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,UAoD9C;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,UAwK/C;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,UAuI/C;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,UAQnC;;;;;;;;;;;;AAED,wBAUE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js new file mode 100644 index 000000000..b12100770 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js @@ -0,0 +1,436 @@ +// +----------------------------------------------------------------------+ +// | murmurHash3js.js v3.0.1 // https://github.com/pid/murmurHash3js +// | A javascript implementation of MurmurHash3's x86 hashing algorithms. | +// |----------------------------------------------------------------------| +// | Copyright (c) 2012-2015 Karan Lyons | +// | https://github.com/karanlyons/murmurHash3.js/blob/c1778f75792abef7bdd74bc85d2d4e1a3d25cfe9/murmurHash3.js | +// | Freely distributable under the MIT license. | +// +----------------------------------------------------------------------+ +// PRIVATE FUNCTIONS +// ----------------- +function _x86Multiply(m, n) { + // + // Given two 32bit ints, returns the two multiplied together as a + // 32bit int. + // + return (m & 0xffff) * n + ((((m >>> 16) * n) & 0xffff) << 16); +} +function _x86Rotl(m, n) { + // + // Given a 32bit int and an int representing a number of bit positions, + // returns the 32bit int rotated left by that number of positions. + // + return (m << n) | (m >>> (32 - n)); +} +function _x86Fmix(h) { + // + // Given a block, returns murmurHash3's final x86 mix of that block. + // + h ^= h >>> 16; + h = _x86Multiply(h, 0x85ebca6b); + h ^= h >>> 13; + h = _x86Multiply(h, 0xc2b2ae35); + h ^= h >>> 16; + return h; +} +function _x64Add(m, n) { + // + // Given two 64bit ints (as an array of two 32bit ints) returns the two + // added together as a 64bit int (as an array of two 32bit ints). + // + m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff]; + n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff]; + const o = [0, 0, 0, 0]; + o[3] += m[3] + n[3]; + o[2] += o[3] >>> 16; + o[3] &= 0xffff; + o[2] += m[2] + n[2]; + o[1] += o[2] >>> 16; + o[2] &= 0xffff; + o[1] += m[1] + n[1]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[0] += m[0] + n[0]; + o[0] &= 0xffff; + return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]]; +} +function _x64Multiply(m, n) { + // + // Given two 64bit ints (as an array of two 32bit ints) returns the two + // multiplied together as a 64bit int (as an array of two 32bit ints). + // + m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff]; + n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff]; + const o = [0, 0, 0, 0]; + o[3] += m[3] * n[3]; + o[2] += o[3] >>> 16; + o[3] &= 0xffff; + o[2] += m[2] * n[3]; + o[1] += o[2] >>> 16; + o[2] &= 0xffff; + o[2] += m[3] * n[2]; + o[1] += o[2] >>> 16; + o[2] &= 0xffff; + o[1] += m[1] * n[3]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[1] += m[2] * n[2]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[1] += m[3] * n[1]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0]; + o[0] &= 0xffff; + return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]]; +} +function _x64Rotl(m, n) { + // + // Given a 64bit int (as an array of two 32bit ints) and an int + // representing a number of bit positions, returns the 64bit int (as an + // array of two 32bit ints) rotated left by that number of positions. + // + n %= 64; + if (n === 32) { + return [m[1], m[0]]; + } + else if (n < 32) { + return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))]; + } + else { + n -= 32; + return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))]; + } +} +function _x64LeftShift(m, n) { + // + // Given a 64bit int (as an array of two 32bit ints) and an int + // representing a number of bit positions, returns the 64bit int (as an + // array of two 32bit ints) shifted left by that number of positions. + // + n %= 64; + if (n === 0) { + return m; + } + else if (n < 32) { + return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n]; + } + else { + return [m[1] << (n - 32), 0]; + } +} +function _x64Xor(m, n) { + // + // Given two 64bit ints (as an array of two 32bit ints) returns the two + // xored together as a 64bit int (as an array of two 32bit ints). + // + return [m[0] ^ n[0], m[1] ^ n[1]]; +} +function _x64Fmix(h) { + // + // Given a block, returns murmurHash3's final x64 mix of that block. + // (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the + // only place where we need to right shift 64bit ints.) + // + h = _x64Xor(h, [0, h[0] >>> 1]); + h = _x64Multiply(h, [0xff51afd7, 0xed558ccd]); + h = _x64Xor(h, [0, h[0] >>> 1]); + h = _x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]); + h = _x64Xor(h, [0, h[0] >>> 1]); + return h; +} +// PUBLIC FUNCTIONS +// ---------------- +function x86Hash32(bytes, seed) { + // + // Given a string and an optional seed as an int, returns a 32 bit hash + // using the x86 flavor of MurmurHash3, as an unsigned int. + // + seed = seed || 0; + const remainder = bytes.length % 4; + const blocks = bytes.length - remainder; + let h1 = seed; + let k1 = 0; + const c1 = 0xcc9e2d51; + const c2 = 0x1b873593; + let j = 0; + for (let i = 0; i < blocks; i = i + 4) { + k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24); + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + h1 = _x86Rotl(h1, 13); + h1 = _x86Multiply(h1, 5) + 0xe6546b64; + j = i + 4; + } + k1 = 0; + switch (remainder) { + case 3: + k1 ^= bytes[j + 2] << 16; + case 2: + k1 ^= bytes[j + 1] << 8; + case 1: + k1 ^= bytes[j]; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + } + h1 ^= bytes.length; + h1 = _x86Fmix(h1); + return h1 >>> 0; +} +function x86Hash128(bytes, seed) { + // + // Given a string and an optional seed as an int, returns a 128 bit + // hash using the x86 flavor of MurmurHash3, as an unsigned hex. + // + seed = seed || 0; + const remainder = bytes.length % 16; + const blocks = bytes.length - remainder; + let h1 = seed; + let h2 = seed; + let h3 = seed; + let h4 = seed; + let k1 = 0; + let k2 = 0; + let k3 = 0; + let k4 = 0; + const c1 = 0x239b961b; + const c2 = 0xab0e9789; + const c3 = 0x38b34ae5; + const c4 = 0xa1e38b93; + let j = 0; + for (let i = 0; i < blocks; i = i + 16) { + k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24); + k2 = bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24); + k3 = bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24); + k4 = bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24); + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + h1 = _x86Rotl(h1, 19); + h1 += h2; + h1 = _x86Multiply(h1, 5) + 0x561ccd1b; + k2 = _x86Multiply(k2, c2); + k2 = _x86Rotl(k2, 16); + k2 = _x86Multiply(k2, c3); + h2 ^= k2; + h2 = _x86Rotl(h2, 17); + h2 += h3; + h2 = _x86Multiply(h2, 5) + 0x0bcaa747; + k3 = _x86Multiply(k3, c3); + k3 = _x86Rotl(k3, 17); + k3 = _x86Multiply(k3, c4); + h3 ^= k3; + h3 = _x86Rotl(h3, 15); + h3 += h4; + h3 = _x86Multiply(h3, 5) + 0x96cd1c35; + k4 = _x86Multiply(k4, c4); + k4 = _x86Rotl(k4, 18); + k4 = _x86Multiply(k4, c1); + h4 ^= k4; + h4 = _x86Rotl(h4, 13); + h4 += h1; + h4 = _x86Multiply(h4, 5) + 0x32ac3b17; + j = i + 16; + } + k1 = 0; + k2 = 0; + k3 = 0; + k4 = 0; + switch (remainder) { + case 15: + k4 ^= bytes[j + 14] << 16; + case 14: + k4 ^= bytes[j + 13] << 8; + case 13: + k4 ^= bytes[j + 12]; + k4 = _x86Multiply(k4, c4); + k4 = _x86Rotl(k4, 18); + k4 = _x86Multiply(k4, c1); + h4 ^= k4; + case 12: + k3 ^= bytes[j + 11] << 24; + case 11: + k3 ^= bytes[j + 10] << 16; + case 10: + k3 ^= bytes[j + 9] << 8; + case 9: + k3 ^= bytes[j + 8]; + k3 = _x86Multiply(k3, c3); + k3 = _x86Rotl(k3, 17); + k3 = _x86Multiply(k3, c4); + h3 ^= k3; + case 8: + k2 ^= bytes[j + 7] << 24; + case 7: + k2 ^= bytes[j + 6] << 16; + case 6: + k2 ^= bytes[j + 5] << 8; + case 5: + k2 ^= bytes[j + 4]; + k2 = _x86Multiply(k2, c2); + k2 = _x86Rotl(k2, 16); + k2 = _x86Multiply(k2, c3); + h2 ^= k2; + case 4: + k1 ^= bytes[j + 3] << 24; + case 3: + k1 ^= bytes[j + 2] << 16; + case 2: + k1 ^= bytes[j + 1] << 8; + case 1: + k1 ^= bytes[j]; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + } + h1 ^= bytes.length; + h2 ^= bytes.length; + h3 ^= bytes.length; + h4 ^= bytes.length; + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + h1 = _x86Fmix(h1); + h2 = _x86Fmix(h2); + h3 = _x86Fmix(h3); + h4 = _x86Fmix(h4); + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + return (("00000000" + (h1 >>> 0).toString(16)).slice(-8) + + ("00000000" + (h2 >>> 0).toString(16)).slice(-8) + + ("00000000" + (h3 >>> 0).toString(16)).slice(-8) + + ("00000000" + (h4 >>> 0).toString(16)).slice(-8)); +} +function x64Hash128(bytes, seed) { + // + // Given a string and an optional seed as an int, returns a 128 bit + // hash using the x64 flavor of MurmurHash3, as an unsigned hex. + // + seed = seed || 0; + const remainder = bytes.length % 16; + const blocks = bytes.length - remainder; + let h1 = [0, seed]; + let h2 = [0, seed]; + let k1 = [0, 0]; + let k2 = [0, 0]; + const c1 = [0x87c37b91, 0x114253d5]; + const c2 = [0x4cf5ad43, 0x2745937f]; + let j = 0; + for (let i = 0; i < blocks; i = i + 16) { + k1 = [ + bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24), + bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24), + ]; + k2 = [ + bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24), + bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24), + ]; + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c2); + h1 = _x64Xor(h1, k1); + h1 = _x64Rotl(h1, 27); + h1 = _x64Add(h1, h2); + h1 = _x64Add(_x64Multiply(h1, [0, 5]), [0, 0x52dce729]); + k2 = _x64Multiply(k2, c2); + k2 = _x64Rotl(k2, 33); + k2 = _x64Multiply(k2, c1); + h2 = _x64Xor(h2, k2); + h2 = _x64Rotl(h2, 31); + h2 = _x64Add(h2, h1); + h2 = _x64Add(_x64Multiply(h2, [0, 5]), [0, 0x38495ab5]); + j = i + 16; + } + k1 = [0, 0]; + k2 = [0, 0]; + switch (remainder) { + case 15: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 14]], 48)); + case 14: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 13]], 40)); + case 13: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 12]], 32)); + case 12: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 11]], 24)); + case 11: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 10]], 16)); + case 10: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 9]], 8)); + case 9: + k2 = _x64Xor(k2, [0, bytes[j + 8]]); + k2 = _x64Multiply(k2, c2); + k2 = _x64Rotl(k2, 33); + k2 = _x64Multiply(k2, c1); + h2 = _x64Xor(h2, k2); + case 8: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 7]], 56)); + case 7: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 6]], 48)); + case 6: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 5]], 40)); + case 5: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 4]], 32)); + case 4: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 3]], 24)); + case 3: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 2]], 16)); + case 2: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 1]], 8)); + case 1: + k1 = _x64Xor(k1, [0, bytes[j]]); + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c2); + h1 = _x64Xor(h1, k1); + } + h1 = _x64Xor(h1, [0, bytes.length]); + h2 = _x64Xor(h2, [0, bytes.length]); + h1 = _x64Add(h1, h2); + h2 = _x64Add(h2, h1); + h1 = _x64Fmix(h1); + h2 = _x64Fmix(h2); + h1 = _x64Add(h1, h2); + h2 = _x64Add(h2, h1); + // Here we reverse h1 and h2 in Cosmos + // This is an implementation detail and not part of the public spec + const h1Buff = Buffer.from(("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8), "hex"); + const h1Reversed = reverse(h1Buff).toString("hex"); + const h2Buff = Buffer.from(("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) + + ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8), "hex"); + const h2Reversed = reverse(h2Buff).toString("hex"); + return h1Reversed + h2Reversed; +} +export function reverse(buff) { + const buffer = Buffer.allocUnsafe(buff.length); + for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) { + buffer[i] = buff[j]; + buffer[j] = buff[i]; + } + return buffer; +} +export default { + version: "3.0.0", + x86: { + hash32: x86Hash32, + hash128: x86Hash128, + }, + x64: { + hash128: x64Hash128, + }, + inputValidation: true, +}; +//# sourceMappingURL=murmurHash.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js.map new file mode 100644 index 000000000..4f4710fef --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/murmurHash.js.map @@ -0,0 +1 @@ +{"version":3,"file":"murmurHash.js","sourceRoot":"","sources":["../../../../src/utils/hashing/murmurHash.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,oEAAoE;AACpE,2EAA2E;AAC3E,2EAA2E;AA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CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnD,OAAO,UAAU,GAAG,UAAU,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE;QACrD,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KACrB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,eAAe;IACb,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE;QACH,MAAM,EAAE,SAAS;QACjB,OAAO,EAAE,UAAU;KACpB;IACD,GAAG,EAAE;QACH,OAAO,EAAE,UAAU;KACpB;IACD,eAAe,EAAE,IAAI;CACtB,CAAC","sourcesContent":["// +----------------------------------------------------------------------+\n// | murmurHash3js.js v3.0.1 // https://github.com/pid/murmurHash3js\n// | A javascript implementation of MurmurHash3's x86 hashing algorithms. |\n// |----------------------------------------------------------------------|\n// | Copyright (c) 2012-2015 Karan Lyons |\n// | https://github.com/karanlyons/murmurHash3.js/blob/c1778f75792abef7bdd74bc85d2d4e1a3d25cfe9/murmurHash3.js |\n// | Freely distributable under the MIT license. |\n// +----------------------------------------------------------------------+\n\n// PRIVATE FUNCTIONS\n// -----------------\n\nfunction _x86Multiply(m: number, n: number) {\n //\n // Given two 32bit ints, returns the two multiplied together as a\n // 32bit int.\n //\n\n return (m & 0xffff) * n + ((((m >>> 16) * n) & 0xffff) << 16);\n}\n\nfunction _x86Rotl(m: number, n: number) {\n //\n // Given a 32bit int and an int representing a number of bit positions,\n // returns the 32bit int rotated left by that number of positions.\n //\n\n return (m << n) | (m >>> (32 - n));\n}\n\nfunction _x86Fmix(h: number) {\n //\n // Given a block, returns murmurHash3's final x86 mix of that block.\n //\n\n h ^= h >>> 16;\n h = _x86Multiply(h, 0x85ebca6b);\n h ^= h >>> 13;\n h = _x86Multiply(h, 0xc2b2ae35);\n h ^= h >>> 16;\n\n return h;\n}\n\nfunction _x64Add(m: number[], n: number[]) {\n //\n // Given two 64bit ints (as an array of two 32bit ints) returns the two\n // added together as a 64bit int (as an array of two 32bit ints).\n //\n\n m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];\n n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];\n const o = [0, 0, 0, 0];\n\n o[3] += m[3] + n[3];\n o[2] += o[3] >>> 16;\n o[3] &= 0xffff;\n\n o[2] += m[2] + n[2];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n\n o[1] += m[1] + n[1];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[0] += m[0] + n[0];\n o[0] &= 0xffff;\n\n return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];\n}\n\nfunction _x64Multiply(m: number[], n: number[]) {\n //\n // Given two 64bit ints (as an array of two 32bit ints) returns the two\n // multiplied together as a 64bit int (as an array of two 32bit ints).\n //\n\n m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];\n n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];\n const o = [0, 0, 0, 0];\n\n o[3] += m[3] * n[3];\n o[2] += o[3] >>> 16;\n o[3] &= 0xffff;\n\n o[2] += m[2] * n[3];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n\n o[2] += m[3] * n[2];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n\n o[1] += m[1] * n[3];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[1] += m[2] * n[2];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[1] += m[3] * n[1];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0];\n o[0] &= 0xffff;\n\n return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];\n}\n\nfunction _x64Rotl(m: number[], n: number) {\n //\n // Given a 64bit int (as an array of two 32bit ints) and an int\n // representing a number of bit positions, returns the 64bit int (as an\n // array of two 32bit ints) rotated left by that number of positions.\n //\n\n n %= 64;\n\n if (n === 32) {\n return [m[1], m[0]];\n } else if (n < 32) {\n return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))];\n } else {\n n -= 32;\n return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))];\n }\n}\n\nfunction _x64LeftShift(m: number[], n: number) {\n //\n // Given a 64bit int (as an array of two 32bit ints) and an int\n // representing a number of bit positions, returns the 64bit int (as an\n // array of two 32bit ints) shifted left by that number of positions.\n //\n\n n %= 64;\n\n if (n === 0) {\n return m;\n } else if (n < 32) {\n return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n];\n } else {\n return [m[1] << (n - 32), 0];\n }\n}\n\nfunction _x64Xor(m: number[], n: number[]) {\n //\n // Given two 64bit ints (as an array of two 32bit ints) returns the two\n // xored together as a 64bit int (as an array of two 32bit ints).\n //\n\n return [m[0] ^ n[0], m[1] ^ n[1]];\n}\n\nfunction _x64Fmix(h: number[]) {\n //\n // Given a block, returns murmurHash3's final x64 mix of that block.\n // (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the\n // only place where we need to right shift 64bit ints.)\n //\n\n h = _x64Xor(h, [0, h[0] >>> 1]);\n h = _x64Multiply(h, [0xff51afd7, 0xed558ccd]);\n h = _x64Xor(h, [0, h[0] >>> 1]);\n h = _x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]);\n h = _x64Xor(h, [0, h[0] >>> 1]);\n\n return h;\n}\n\n// PUBLIC FUNCTIONS\n// ----------------\n\nfunction x86Hash32(bytes: Buffer, seed?: number) {\n //\n // Given a string and an optional seed as an int, returns a 32 bit hash\n // using the x86 flavor of MurmurHash3, as an unsigned int.\n //\n seed = seed || 0;\n\n const remainder = bytes.length % 4;\n const blocks = bytes.length - remainder;\n\n let h1 = seed;\n\n let k1 = 0;\n\n const c1 = 0xcc9e2d51;\n const c2 = 0x1b873593;\n let j = 0;\n\n for (let i = 0; i < blocks; i = i + 4) {\n k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24);\n\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n\n h1 ^= k1;\n h1 = _x86Rotl(h1, 13);\n h1 = _x86Multiply(h1, 5) + 0xe6546b64;\n j = i + 4;\n }\n\n k1 = 0;\n\n switch (remainder) {\n case 3:\n k1 ^= bytes[j + 2] << 16;\n\n case 2:\n k1 ^= bytes[j + 1] << 8;\n\n case 1:\n k1 ^= bytes[j];\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n h1 ^= k1;\n }\n\n h1 ^= bytes.length;\n h1 = _x86Fmix(h1);\n\n return h1 >>> 0;\n}\n\nfunction x86Hash128(bytes: Buffer, seed?: number) {\n //\n // Given a string and an optional seed as an int, returns a 128 bit\n // hash using the x86 flavor of MurmurHash3, as an unsigned hex.\n //\n\n seed = seed || 0;\n const remainder = bytes.length % 16;\n const blocks = bytes.length - remainder;\n\n let h1 = seed;\n let h2 = seed;\n let h3 = seed;\n let h4 = seed;\n\n let k1 = 0;\n let k2 = 0;\n let k3 = 0;\n let k4 = 0;\n\n const c1 = 0x239b961b;\n const c2 = 0xab0e9789;\n const c3 = 0x38b34ae5;\n const c4 = 0xa1e38b93;\n let j = 0;\n\n for (let i = 0; i < blocks; i = i + 16) {\n k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24);\n k2 = bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24);\n k3 = bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24);\n k4 = bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24);\n\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n h1 ^= k1;\n\n h1 = _x86Rotl(h1, 19);\n h1 += h2;\n h1 = _x86Multiply(h1, 5) + 0x561ccd1b;\n\n k2 = _x86Multiply(k2, c2);\n k2 = _x86Rotl(k2, 16);\n k2 = _x86Multiply(k2, c3);\n h2 ^= k2;\n\n h2 = _x86Rotl(h2, 17);\n h2 += h3;\n h2 = _x86Multiply(h2, 5) + 0x0bcaa747;\n\n k3 = _x86Multiply(k3, c3);\n k3 = _x86Rotl(k3, 17);\n k3 = _x86Multiply(k3, c4);\n h3 ^= k3;\n\n h3 = _x86Rotl(h3, 15);\n h3 += h4;\n h3 = _x86Multiply(h3, 5) + 0x96cd1c35;\n\n k4 = _x86Multiply(k4, c4);\n k4 = _x86Rotl(k4, 18);\n k4 = _x86Multiply(k4, c1);\n h4 ^= k4;\n\n h4 = _x86Rotl(h4, 13);\n h4 += h1;\n h4 = _x86Multiply(h4, 5) + 0x32ac3b17;\n j = i + 16;\n }\n\n k1 = 0;\n k2 = 0;\n k3 = 0;\n k4 = 0;\n\n switch (remainder) {\n case 15:\n k4 ^= bytes[j + 14] << 16;\n\n case 14:\n k4 ^= bytes[j + 13] << 8;\n\n case 13:\n k4 ^= bytes[j + 12];\n k4 = _x86Multiply(k4, c4);\n k4 = _x86Rotl(k4, 18);\n k4 = _x86Multiply(k4, c1);\n h4 ^= k4;\n\n case 12:\n k3 ^= bytes[j + 11] << 24;\n\n case 11:\n k3 ^= bytes[j + 10] << 16;\n\n case 10:\n k3 ^= bytes[j + 9] << 8;\n\n case 9:\n k3 ^= bytes[j + 8];\n k3 = _x86Multiply(k3, c3);\n k3 = _x86Rotl(k3, 17);\n k3 = _x86Multiply(k3, c4);\n h3 ^= k3;\n\n case 8:\n k2 ^= bytes[j + 7] << 24;\n\n case 7:\n k2 ^= bytes[j + 6] << 16;\n\n case 6:\n k2 ^= bytes[j + 5] << 8;\n\n case 5:\n k2 ^= bytes[j + 4];\n k2 = _x86Multiply(k2, c2);\n k2 = _x86Rotl(k2, 16);\n k2 = _x86Multiply(k2, c3);\n h2 ^= k2;\n\n case 4:\n k1 ^= bytes[j + 3] << 24;\n\n case 3:\n k1 ^= bytes[j + 2] << 16;\n\n case 2:\n k1 ^= bytes[j + 1] << 8;\n\n case 1:\n k1 ^= bytes[j];\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n h1 ^= k1;\n }\n\n h1 ^= bytes.length;\n h2 ^= bytes.length;\n h3 ^= bytes.length;\n h4 ^= bytes.length;\n\n h1 += h2;\n h1 += h3;\n h1 += h4;\n h2 += h1;\n h3 += h1;\n h4 += h1;\n\n h1 = _x86Fmix(h1);\n h2 = _x86Fmix(h2);\n h3 = _x86Fmix(h3);\n h4 = _x86Fmix(h4);\n\n h1 += h2;\n h1 += h3;\n h1 += h4;\n h2 += h1;\n h3 += h1;\n h4 += h1;\n\n return (\n (\"00000000\" + (h1 >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h2 >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h3 >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h4 >>> 0).toString(16)).slice(-8)\n );\n}\n\nfunction x64Hash128(bytes: Buffer, seed?: number) {\n //\n // Given a string and an optional seed as an int, returns a 128 bit\n // hash using the x64 flavor of MurmurHash3, as an unsigned hex.\n //\n seed = seed || 0;\n\n const remainder = bytes.length % 16;\n const blocks = bytes.length - remainder;\n\n let h1 = [0, seed];\n let h2 = [0, seed];\n\n let k1 = [0, 0];\n let k2 = [0, 0];\n\n const c1 = [0x87c37b91, 0x114253d5];\n const c2 = [0x4cf5ad43, 0x2745937f];\n let j = 0;\n\n for (let i = 0; i < blocks; i = i + 16) {\n k1 = [\n bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24),\n bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24),\n ];\n k2 = [\n bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24),\n bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24),\n ];\n\n k1 = _x64Multiply(k1, c1);\n k1 = _x64Rotl(k1, 31);\n k1 = _x64Multiply(k1, c2);\n h1 = _x64Xor(h1, k1);\n\n h1 = _x64Rotl(h1, 27);\n h1 = _x64Add(h1, h2);\n h1 = _x64Add(_x64Multiply(h1, [0, 5]), [0, 0x52dce729]);\n\n k2 = _x64Multiply(k2, c2);\n k2 = _x64Rotl(k2, 33);\n k2 = _x64Multiply(k2, c1);\n h2 = _x64Xor(h2, k2);\n\n h2 = _x64Rotl(h2, 31);\n h2 = _x64Add(h2, h1);\n h2 = _x64Add(_x64Multiply(h2, [0, 5]), [0, 0x38495ab5]);\n j = i + 16;\n }\n\n k1 = [0, 0];\n k2 = [0, 0];\n\n switch (remainder) {\n case 15:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 14]], 48));\n\n case 14:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 13]], 40));\n\n case 13:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 12]], 32));\n\n case 12:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 11]], 24));\n\n case 11:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 10]], 16));\n\n case 10:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 9]], 8));\n\n case 9:\n k2 = _x64Xor(k2, [0, bytes[j + 8]]);\n k2 = _x64Multiply(k2, c2);\n k2 = _x64Rotl(k2, 33);\n k2 = _x64Multiply(k2, c1);\n h2 = _x64Xor(h2, k2);\n\n case 8:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 7]], 56));\n\n case 7:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 6]], 48));\n\n case 6:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 5]], 40));\n\n case 5:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 4]], 32));\n\n case 4:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 3]], 24));\n\n case 3:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 2]], 16));\n\n case 2:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 1]], 8));\n\n case 1:\n k1 = _x64Xor(k1, [0, bytes[j]]);\n k1 = _x64Multiply(k1, c1);\n k1 = _x64Rotl(k1, 31);\n k1 = _x64Multiply(k1, c2);\n h1 = _x64Xor(h1, k1);\n }\n\n h1 = _x64Xor(h1, [0, bytes.length]);\n h2 = _x64Xor(h2, [0, bytes.length]);\n\n h1 = _x64Add(h1, h2);\n h2 = _x64Add(h2, h1);\n\n h1 = _x64Fmix(h1);\n h2 = _x64Fmix(h2);\n\n h1 = _x64Add(h1, h2);\n h2 = _x64Add(h2, h1);\n\n // Here we reverse h1 and h2 in Cosmos\n // This is an implementation detail and not part of the public spec\n const h1Buff = Buffer.from(\n (\"00000000\" + (h1[0] >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h1[1] >>> 0).toString(16)).slice(-8),\n \"hex\",\n );\n const h1Reversed = reverse(h1Buff).toString(\"hex\");\n const h2Buff = Buffer.from(\n (\"00000000\" + (h2[0] >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h2[1] >>> 0).toString(16)).slice(-8),\n \"hex\",\n );\n const h2Reversed = reverse(h2Buff).toString(\"hex\");\n return h1Reversed + h2Reversed;\n}\n\nexport function reverse(buff: Buffer) {\n const buffer = Buffer.allocUnsafe(buff.length);\n\n for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) {\n buffer[i] = buff[j];\n buffer[j] = buff[i];\n }\n return buffer;\n}\n\nexport default {\n version: \"3.0.0\",\n x86: {\n hash32: x86Hash32,\n hash128: x86Hash128,\n },\n x64: {\n hash128: x64Hash128,\n },\n inputValidation: true,\n};\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts new file mode 100644 index 000000000..c1f9d9592 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts @@ -0,0 +1,3 @@ +import { PrimitivePartitionKeyValue } from "../../documents"; +export declare function hashV1PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string; +//# sourceMappingURL=v1.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts.map new file mode 100644 index 000000000..4441c9d9b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashing/v1.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAI7D,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,0BAA0B,EAAE,GAAG,MAAM,CAQrF"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js new file mode 100644 index 000000000..d3ee20cc0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { doubleToByteArrayJSBI, writeNumberForBinaryEncodingJSBI } from "./encoding/number"; +import { writeStringForBinaryEncoding } from "./encoding/string"; +import { BytePrefix } from "./encoding/prefix"; +import MurmurHash from "./murmurHash"; +const MAX_STRING_CHARS = 100; +export function hashV1PartitionKey(partitionKey) { + const key = partitionKey[0]; + const toHash = prefixKeyByType(key); + const hash = MurmurHash.x86.hash32(toHash); + const encodedJSBI = writeNumberForBinaryEncodingJSBI(hash); + const encodedValue = encodeByType(key); + const finalHash = Buffer.concat([encodedJSBI, encodedValue]).toString("hex").toUpperCase(); + return finalHash; +} +function prefixKeyByType(key) { + let bytes; + switch (typeof key) { + case "string": { + const truncated = key.substr(0, MAX_STRING_CHARS); + bytes = Buffer.concat([ + Buffer.from(BytePrefix.String, "hex"), + Buffer.from(truncated), + Buffer.from(BytePrefix.Undefined, "hex"), + ]); + return bytes; + } + case "number": { + const numberBytes = doubleToByteArrayJSBI(key); + bytes = Buffer.concat([Buffer.from(BytePrefix.Number, "hex"), numberBytes]); + return bytes; + } + case "boolean": { + const prefix = key ? BytePrefix.True : BytePrefix.False; + return Buffer.from(prefix, "hex"); + } + case "object": { + if (key === null) { + return Buffer.from(BytePrefix.Null, "hex"); + } + return Buffer.from(BytePrefix.Undefined, "hex"); + } + case "undefined": { + return Buffer.from(BytePrefix.Undefined, "hex"); + } + default: + throw new Error(`Unexpected type: ${typeof key}`); + } +} +function encodeByType(key) { + switch (typeof key) { + case "string": { + const truncated = key.substr(0, MAX_STRING_CHARS); + return writeStringForBinaryEncoding(truncated); + } + case "number": { + const encodedJSBI = writeNumberForBinaryEncodingJSBI(key); + return encodedJSBI; + } + case "boolean": { + const prefix = key ? BytePrefix.True : BytePrefix.False; + return Buffer.from(prefix, "hex"); + } + case "object": + if (key === null) { + return Buffer.from(BytePrefix.Null, "hex"); + } + return Buffer.from(BytePrefix.Undefined, "hex"); + case "undefined": + return Buffer.from(BytePrefix.Undefined, "hex"); + default: + throw new Error(`Unexpected type: ${typeof key}`); + } +} +//# sourceMappingURL=v1.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js.map new file mode 100644 index 000000000..7baeddd5a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"v1.js","sourceRoot":"","sources":["../../../../src/utils/hashing/v1.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,UAAU,MAAM,cAAc,CAAC;AAGtC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAE7B,MAAM,UAAU,kBAAkB,CAAC,YAA0C;IAC3E,MAAM,GAAG,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,MAAM,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,WAAW,GAAG,gCAAgC,CAAC,IAAI,CAAC,CAAC;IAC3D,MAAM,YAAY,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3F,OAAO,SAAS,CAAC;AACnB,C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AU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SACjD;QACD;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,GAAG,EAAE,CAAC,CAAC;KACrD;AACH,CAAC;AAED,SAAS,YAAY,CAAC,GAA+B;IACnD,QAAQ,OAAO,GAAG,EAAE;QAClB,KAAK,QAAQ,CAAC,CAAC;YACb,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;YAClD,OAAO,4BAA4B,CAAC,SAAS,CAAC,CAAC;SAChD;QACD,KAAK,QAAQ,CAAC,CAAC;YACb,MAAM,WAAW,GAAG,gCAAgC,CAAC,GAAG,CAAC,CAAC;YAC1D,OAAO,WAAW,CAAC;SACpB;QACD,KAAK,SAAS,CAAC,CAAC;YACd,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;YACxD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SACnC;QACD,KAAK,QAAQ;YACX,IAAI,GAAG,KAAK,IAAI,EAAE;gBAChB,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aAC5C;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAClD,KAAK,WAAW;YACd,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;QAClD;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,GAAG,EAAE,CAAC,CAAC;KACrD;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { doubleToByteArrayJSBI, writeNumberForBinaryEncodingJSBI } from \"./encoding/number\";\nimport { writeStringForBinaryEncoding } from \"./encoding/string\";\nimport { BytePrefix } from \"./encoding/prefix\";\nimport MurmurHash from \"./murmurHash\";\nimport { PrimitivePartitionKeyValue } from \"../../documents\";\n\nconst MAX_STRING_CHARS = 100;\n\nexport function hashV1PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string {\n const key = partitionKey[0];\n const toHash = prefixKeyByType(key);\n const hash = MurmurHash.x86.hash32(toHash);\n const encodedJSBI = writeNumberForBinaryEncodingJSBI(hash);\n const encodedValue = encodeByType(key);\n const finalHash = Buffer.concat([encodedJSBI, encodedValue]).toString(\"hex\").toUpperCase();\n return finalHash;\n}\n\nfunction prefixKeyByType(key: PrimitivePartitionKeyValue): Buffer {\n let bytes: Buffer;\n switch (typeof key) {\n case \"string\": {\n const truncated = key.substr(0, MAX_STRING_CHARS);\n bytes = Buffer.concat([\n Buffer.from(BytePrefix.String, \"hex\"),\n Buffer.from(truncated),\n Buffer.from(BytePrefix.Undefined, \"hex\"),\n ]);\n return bytes;\n }\n case \"number\": {\n const numberBytes = doubleToByteArrayJSBI(key);\n bytes = Buffer.concat([Buffer.from(BytePrefix.Number, \"hex\"), numberBytes]);\n return bytes;\n }\n case \"boolean\": {\n const prefix = key ? BytePrefix.True : BytePrefix.False;\n return Buffer.from(prefix, \"hex\");\n }\n case \"object\": {\n if (key === null) {\n return Buffer.from(BytePrefix.Null, \"hex\");\n }\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n case \"undefined\": {\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n default:\n throw new Error(`Unexpected type: ${typeof key}`);\n }\n}\n\nfunction encodeByType(key: PrimitivePartitionKeyValue): Buffer {\n switch (typeof key) {\n case \"string\": {\n const truncated = key.substr(0, MAX_STRING_CHARS);\n return writeStringForBinaryEncoding(truncated);\n }\n case \"number\": {\n const encodedJSBI = writeNumberForBinaryEncodingJSBI(key);\n return encodedJSBI;\n }\n case \"boolean\": {\n const prefix = key ? BytePrefix.True : BytePrefix.False;\n return Buffer.from(prefix, \"hex\");\n }\n case \"object\":\n if (key === null) {\n return Buffer.from(BytePrefix.Null, \"hex\");\n }\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n case \"undefined\":\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n default:\n throw new Error(`Unexpected type: ${typeof key}`);\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts new file mode 100644 index 000000000..b6c63311e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts @@ -0,0 +1,5 @@ +/// +import { PrimitivePartitionKeyValue } from "../../documents"; +export declare function hashV2PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string; +export declare function reverse(buff: Buffer): Buffer; +//# sourceMappingURL=v2.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts.map new file mode 100644 index 000000000..9ad1cfe72 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashing/v2.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAK7D,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,0BAA0B,EAAE,GAAG,MAAM,CAMrF;AAoCD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js new file mode 100644 index 000000000..e94c3750b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { doubleToByteArrayJSBI } from "./encoding/number"; +import { BytePrefix } from "./encoding/prefix"; +import MurmurHash from "./murmurHash"; +export function hashV2PartitionKey(partitionKey) { + const toHash = Buffer.concat(partitionKey.map(prefixKeyByType)); + const hash = MurmurHash.x64.hash128(toHash); + const reverseBuff = reverse(Buffer.from(hash, "hex")); + reverseBuff[0] &= 0x3f; + return reverseBuff.toString("hex").toUpperCase(); +} +function prefixKeyByType(key) { + let bytes; + switch (typeof key) { + case "string": { + bytes = Buffer.concat([ + Buffer.from(BytePrefix.String, "hex"), + Buffer.from(key), + Buffer.from(BytePrefix.Infinity, "hex"), + ]); + return bytes; + } + case "number": { + const numberBytes = doubleToByteArrayJSBI(key); + bytes = Buffer.concat([Buffer.from(BytePrefix.Number, "hex"), numberBytes]); + return bytes; + } + case "boolean": { + const prefix = key ? BytePrefix.True : BytePrefix.False; + return Buffer.from(prefix, "hex"); + } + case "object": { + if (key === null) { + return Buffer.from(BytePrefix.Null, "hex"); + } + return Buffer.from(BytePrefix.Undefined, "hex"); + } + case "undefined": { + return Buffer.from(BytePrefix.Undefined, "hex"); + } + default: + throw new Error(`Unexpected type: ${typeof key}`); + } +} +export function reverse(buff) { + const buffer = Buffer.allocUnsafe(buff.length); + for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) { + buffer[i] = buff[j]; + buffer[j] = buff[i]; + } + return buffer; +} +//# sourceMappingURL=v2.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js.map new file mode 100644 index 000000000..2ac328fc9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hashing/v2.js.map @@ -0,0 +1 @@ +{"version":3,"file":"v2.js","sourceRoot":"","sources":["../../../../src/utils/hashing/v2.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,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,SAAS,CAAC,CAAC;YACd,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;YACxD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SACnC;QACD,KAAK,QAAQ,CAAC,CAAC;YACb,IAAI,GAAG,KAAK,IAAI,EAAE;gBAChB,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;aAC5C;YACD,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SACjD;QACD,KAAK,WAAW,CAAC,CAAC;YAChB,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SACjD;QACD;YACE,MAAM,IAAI,KAAK,CAAC,oBAAoB,OAAO,GAAG,EAAE,CAAC,CAAC;KACrD;AACH,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE;QACrD,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;KACrB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PrimitivePartitionKeyValue } from \"../../documents\";\nimport { doubleToByteArrayJSBI } from \"./encoding/number\";\nimport { BytePrefix } from \"./encoding/prefix\";\nimport MurmurHash from \"./murmurHash\";\n\nexport function hashV2PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string {\n const toHash: Buffer = Buffer.concat(partitionKey.map(prefixKeyByType));\n const hash = MurmurHash.x64.hash128(toHash);\n const reverseBuff: Buffer = reverse(Buffer.from(hash, \"hex\"));\n reverseBuff[0] &= 0x3f;\n return reverseBuff.toString(\"hex\").toUpperCase();\n}\n\nfunction prefixKeyByType(key: PrimitivePartitionKeyValue): Buffer {\n let bytes: Buffer;\n switch (typeof key) {\n case \"string\": {\n bytes = Buffer.concat([\n Buffer.from(BytePrefix.String, \"hex\"),\n Buffer.from(key),\n Buffer.from(BytePrefix.Infinity, \"hex\"),\n ]);\n return bytes;\n }\n case \"number\": {\n const numberBytes = doubleToByteArrayJSBI(key);\n bytes = Buffer.concat([Buffer.from(BytePrefix.Number, \"hex\"), numberBytes]);\n return bytes;\n }\n case \"boolean\": {\n const prefix = key ? BytePrefix.True : BytePrefix.False;\n return Buffer.from(prefix, \"hex\");\n }\n case \"object\": {\n if (key === null) {\n return Buffer.from(BytePrefix.Null, \"hex\");\n }\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n case \"undefined\": {\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n default:\n throw new Error(`Unexpected type: ${typeof key}`);\n }\n}\n\nexport function reverse(buff: Buffer): Buffer {\n const buffer = Buffer.allocUnsafe(buff.length);\n\n for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) {\n buffer[i] = buff[j];\n buffer[j] = buff[i];\n }\n return buffer;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts new file mode 100644 index 000000000..3e9474558 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts @@ -0,0 +1,5 @@ +import { HTTPMethod, ResourceType } from "../common"; +export declare function generateHeaders(masterKey: string, method: HTTPMethod, resourceType?: ResourceType, resourceId?: string, date?: Date): Promise<{ + [x: string]: string; +}>; +//# sourceMappingURL=headers.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts.map new file mode 100644 index 000000000..23c4ff0d3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../../src/utils/headers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAa,MAAM,WAAW,CAAC;AAEhE,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,UAAU,EAClB,YAAY,GAAE,YAAgC,EAC9C,UAAU,GAAE,MAAW,EACvB,IAAI,OAAa,GAChB,OAAO,CAAC;IACT,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB,CAAC,CAaD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js new file mode 100644 index 000000000..d32fefdd2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { hmac } from "./hmac"; +import { ResourceType, Constants } from "../common"; +export async function generateHeaders(masterKey, method, resourceType = ResourceType.none, resourceId = "", date = new Date()) { + if (masterKey.startsWith("type=sas&")) { + return { + [Constants.HttpHeaders.Authorization]: encodeURIComponent(masterKey), + [Constants.HttpHeaders.XDate]: date.toUTCString(), + }; + } + const sig = await signature(masterKey, method, resourceType, resourceId, date); + return { + [Constants.HttpHeaders.Authorization]: sig, + [Constants.HttpHeaders.XDate]: date.toUTCString(), + }; +} +async function signature(masterKey, method, resourceType, resourceId = "", date = new Date()) { + const type = "master"; + const version = "1.0"; + const text = method.toLowerCase() + + "\n" + + resourceType.toLowerCase() + + "\n" + + resourceId + + "\n" + + date.toUTCString().toLowerCase() + + "\n" + + "" + + "\n"; + const signed = await hmac(masterKey, text); + return encodeURIComponent("type=" + type + "&ver=" + version + "&sig=" + signed); +} +//# sourceMappingURL=headers.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js.map new file mode 100644 index 000000000..48d7258c3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/headers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../src/utils/headers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAc,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEhE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,SAAiB,EACjB,MAAkB,EAClB,eAA6B,YAAY,CAAC,IAAI,EAC9C,aAAqB,EAAE,EACvB,IAAI,GAAG,IAAI,IAAI,EAAE;IAIjB,IAAI,SAAS,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QACrC,OAAO;YACL,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC;YACpE,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE;SAClD,CAAC;KACH;IACD,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAE/E,OAAO;QACL,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,GAAG;QAC1C,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE;KAClD,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,SAAS,CACtB,SAAiB,EACjB,MAAkB,EAClB,YAA0B,EAC1B,aAAqB,EAAE,EACvB,IAAI,GAAG,IAAI,IAAI,EAAE;IAEjB,MAAM,IAAI,GAAG,QAAQ,CAAC;IACtB,MAAM,OAAO,GAAG,KAAK,CAAC;IACtB,MAAM,IAAI,GACR,MAAM,CAAC,WAAW,EAAE;QACpB,IAAI;QACJ,YAAY,CAAC,WAAW,EAAE;QAC1B,IAAI;QACJ,UAAU;QACV,IAAI;QACJ,IAAI,CAAC,WAAW,EAAE,CAAC,WAAW,EAAE;QAChC,IAAI;QACJ,EAAE;QACF,IAAI,CAAC;IAEP,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAE3C,OAAO,kBAAkB,CAAC,OAAO,GAAG,IAAI,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC,CAAC;AACnF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { hmac } from \"./hmac\";\nimport { HTTPMethod, ResourceType, Constants } from \"../common\";\n\nexport async function generateHeaders(\n masterKey: string,\n method: HTTPMethod,\n resourceType: ResourceType = ResourceType.none,\n resourceId: string = \"\",\n date = new Date(),\n): Promise<{\n [x: string]: string;\n}> {\n if (masterKey.startsWith(\"type=sas&\")) {\n return {\n [Constants.HttpHeaders.Authorization]: encodeURIComponent(masterKey),\n [Constants.HttpHeaders.XDate]: date.toUTCString(),\n };\n }\n const sig = await signature(masterKey, method, resourceType, resourceId, date);\n\n return {\n [Constants.HttpHeaders.Authorization]: sig,\n [Constants.HttpHeaders.XDate]: date.toUTCString(),\n };\n}\n\nasync function signature(\n masterKey: string,\n method: HTTPMethod,\n resourceType: ResourceType,\n resourceId: string = \"\",\n date = new Date(),\n): Promise {\n const type = \"master\";\n const version = \"1.0\";\n const text =\n method.toLowerCase() +\n \"\\n\" +\n resourceType.toLowerCase() +\n \"\\n\" +\n resourceId +\n \"\\n\" +\n date.toUTCString().toLowerCase() +\n \"\\n\" +\n \"\" +\n \"\\n\";\n\n const signed = await hmac(masterKey, text);\n\n return encodeURIComponent(\"type=\" + type + \"&ver=\" + version + \"&sig=\" + signed);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts new file mode 100644 index 000000000..7402b37bf --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts @@ -0,0 +1,2 @@ +export declare function hmac(key: string, message: string): Promise; +//# sourceMappingURL=hmac.browser.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts.map new file mode 100644 index 000000000..ef214e985 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.browser.d.ts","sourceRoot":"","sources":["../../../src/utils/hmac.browser.ts"],"names":[],"mappings":"AAOA,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYxE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js new file mode 100644 index 000000000..d8ca32dc7 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { encodeUTF8, encodeBase64 } from "./encode"; +import atob from "./atob"; +import { globalCrypto } from "./globalCrypto"; +export async function hmac(key, message) { + const importParams = { name: "HMAC", hash: { name: "SHA-256" } }; + const encodedMessage = new Uint8Array([...unescape(encodeURIComponent(message))].map((c) => c.charCodeAt(0))); + const encodedKey = encodeUTF8(atob(key)); + const cryptoKey = await globalCrypto.subtle.importKey("raw", encodedKey, importParams, false, [ + "sign", + ]); + const signature = await globalCrypto.subtle.sign(importParams, cryptoKey, encodedMessage); + return encodeBase64(signature); +} +//# sourceMappingURL=hmac.browser.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js.map new file mode 100644 index 000000000..2822e2abd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.browser.js","sourceRoot":"","sources":["../../../src/utils/hmac.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,IAAI,MAAM,QAAQ,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,GAAW,EAAE,OAAe;IACrD,MAAM,YAAY,GAAqB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC;IACnF,MAAM,cAAc,GAAG,IAAI,UAAU,CACnC,CAAC,GAAG,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACvE,CAAC;IACF,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE;QAC5F,MAAM;KACP,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC;IAE1F,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { encodeUTF8, encodeBase64 } from \"./encode\";\nimport atob from \"./atob\";\nimport { globalCrypto } from \"./globalCrypto\";\n\nexport async function hmac(key: string, message: string): Promise {\n const importParams: HmacImportParams = { name: \"HMAC\", hash: { name: \"SHA-256\" } };\n const encodedMessage = new Uint8Array(\n [...unescape(encodeURIComponent(message))].map((c) => c.charCodeAt(0)),\n );\n const encodedKey = encodeUTF8(atob(key));\n const cryptoKey = await globalCrypto.subtle.importKey(\"raw\", encodedKey, importParams, false, [\n \"sign\",\n ]);\n const signature = await globalCrypto.subtle.sign(importParams, cryptoKey, encodedMessage);\n\n return encodeBase64(signature);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts new file mode 100644 index 000000000..ba17a3b70 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts @@ -0,0 +1,2 @@ +export declare function hmac(key: string, message: string): Promise; +//# sourceMappingURL=hmac.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts.map new file mode 100644 index 000000000..c6c6f68c2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../../../src/utils/hmac.ts"],"names":[],"mappings":"AAKA,wBAAsB,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAExE"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js new file mode 100644 index 000000000..f188489e9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createHmac } from "crypto"; +export async function hmac(key, message) { + return createHmac("sha256", Buffer.from(key, "base64")).update(message).digest("base64"); +} +//# sourceMappingURL=hmac.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js.map new file mode 100644 index 000000000..42ab3877a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/hmac.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../../src/utils/hmac.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,GAAW,EAAE,OAAe;IACrD,OAAO,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC3F,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHmac } from \"crypto\";\n\nexport async function hmac(key: string, message: string): Promise {\n return createHmac(\"sha256\", Buffer.from(key, \"base64\")).update(message).digest(\"base64\");\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts new file mode 100644 index 000000000..9d0bf78d4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts @@ -0,0 +1,11 @@ +export declare class NonStreamingOrderByMap { + private map; + private compareFn; + constructor(compareFn: (a: T, b: T) => number); + set(key: string, value: T): void; + get(key: string): T | undefined; + getAllValues(): T[]; + private replaceResults; + size(): number; +} +//# sourceMappingURL=nonStreamingOrderByMap.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts.map new file mode 100644 index 000000000..bb5e45864 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByMap.d.ts","sourceRoot":"","sources":["../../../src/utils/nonStreamingOrderByMap.ts"],"names":[],"mappings":"AAGA,qBAAa,sBAAsB,CAAC,CAAC;IACnC,OAAO,CAAC,GAAG,CAAiB;IAC5B,OAAO,CAAC,SAAS,CAAyB;gBAE9B,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM;IAKtC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAWhC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAM/B,YAAY,IAAI,CAAC,EAAE;IAS1B,OAAO,CAAC,cAAc;IAOf,IAAI,IAAI,MAAM;CAGtB"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js new file mode 100644 index 000000000..0534d67d8 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export class NonStreamingOrderByMap { + constructor(compareFn) { + this.compareFn = compareFn; + this.map = new Map(); + } + set(key, value) { + if (!this.map.has(key)) { + this.map.set(key, value); + } + else { + const oldValue = this.map.get(key); + if (this.replaceResults(oldValue, value)) { + this.map.set(key, value); + } + } + } + get(key) { + if (!this.map.has(key)) + return undefined; + return this.map.get(key); + } + getAllValues() { + const res = []; + for (const [key, value] of this.map) { + res.push(value); + this.map.delete(key); + } + return res; + } + replaceResults(res1, res2) { + const res = this.compareFn(res1, res2); + if (res < 0) + return true; + return false; + } + size() { + return this.map.size; + } +} +//# sourceMappingURL=nonStreamingOrderByMap.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js.map new file mode 100644 index 000000000..4abbd3208 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByMap.js.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByMap.js","sourceRoot":"","sources":["../../../src/utils/nonStreamingOrderByMap.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,OAAO,sBAAsB;IAIjC,YAAY,SAAiC;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,EAAa,CAAC;IAClC,CAAC;IAEM,GAAG,CAAC,GAAW,EAAE,KAAQ;QAC9B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACtB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SAC1B;aAAM;YACL,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE;gBACxC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aAC1B;SACF;IACH,CAAC;IAEM,GAAG,CAAC,GAAW;QACpB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,SAAS,CAAC;QAEzC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEM,YAAY;QACjB,MAAM,GAAG,GAAQ,EAAE,CAAC;QACpB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE;YACnC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACtB;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAEO,cAAc,CAAC,IAAmB,EAAE,IAAmB;QAC7D,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAS,EAAE,IAAS,CAAC,CAAC;QACjD,IAAI,GAAG,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QAEzB,OAAO,KAAK,CAAC;IACf,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport class NonStreamingOrderByMap {\n private map: Map;\n private compareFn: (a: T, b: T) => number;\n\n constructor(compareFn: (a: T, b: T) => number) {\n this.compareFn = compareFn;\n this.map = new Map();\n }\n\n public set(key: string, value: T): void {\n if (!this.map.has(key)) {\n this.map.set(key, value);\n } else {\n const oldValue = this.map.get(key);\n if (this.replaceResults(oldValue, value)) {\n this.map.set(key, value);\n }\n }\n }\n\n public get(key: string): T | undefined {\n if (!this.map.has(key)) return undefined;\n\n return this.map.get(key);\n }\n\n public getAllValues(): T[] {\n const res: T[] = [];\n for (const [key, value] of this.map) {\n res.push(value);\n this.map.delete(key);\n }\n return res;\n }\n\n private replaceResults(res1: T | undefined, res2: T | undefined): boolean {\n const res = this.compareFn(res1 as T, res2 as T);\n if (res < 0) return true;\n\n return false;\n }\n\n public size(): number {\n return this.map.size;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts new file mode 100644 index 000000000..d390ee24c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts @@ -0,0 +1,14 @@ +export declare class NonStreamingOrderByPriorityQueue { + private pq; + private compareFn; + private pqMaxSize; + constructor(compareFn: (a: T, b: T) => number, pqMaxSize?: number); + enqueue(item: T): void; + dequeue(): T; + size(): number; + isEmpty(): boolean; + peek(): T; + getTopElements(): T[]; + reverse(): NonStreamingOrderByPriorityQueue; +} +//# sourceMappingURL=nonStreamingOrderByPriorityQueue.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts.map new file mode 100644 index 000000000..3f1104121 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByPriorityQueue.d.ts","sourceRoot":"","sources":["../../../src/utils/nonStreamingOrderByPriorityQueue.ts"],"names":[],"mappings":"AAIA,qBAAa,gCAAgC,CAAC,CAAC;IAC7C,OAAO,CAAC,EAAE,CAAmB;IAC7B,OAAO,CAAC,SAAS,CAAyB;IAC1C,OAAO,CAAC,SAAS,CAAS;gBAEd,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,EAAE,SAAS,GAAE,MAAa;IAMhE,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAYtB,OAAO,IAAI,CAAC;IAIZ,IAAI,IAAI,MAAM;IAId,OAAO,IAAI,OAAO;IAIlB,IAAI,IAAI,CAAC;IAIT,cAAc,IAAI,CAAC,EAAE;IAUrB,OAAO,IAAI,gCAAgC,CAAC,CAAC,CAAC;CAUtD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js new file mode 100644 index 000000000..606c9099e --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import PriorityQueue from "priorityqueuejs"; +export class NonStreamingOrderByPriorityQueue { + constructor(compareFn, pqMaxSize = 2000) { + this.compareFn = compareFn; + this.pq = new PriorityQueue(this.compareFn); + this.pqMaxSize = pqMaxSize; + } + enqueue(item) { + if (this.pq.size() < this.pqMaxSize) { + this.pq.enq(item); + } + else { + const topItem = this.pq.peek(); + if (this.compareFn(topItem, item) > 0) { + this.pq.deq(); + this.pq.enq(item); + } + } + } + dequeue() { + return this.pq.deq(); + } + size() { + return this.pq.size(); + } + isEmpty() { + return this.pq.isEmpty(); + } + peek() { + return this.pq.peek(); + } + getTopElements() { + const elements = []; + while (!this.pq.isEmpty()) { + elements.unshift(this.pq.deq()); + } + return elements; + } + // Create a new instance of NonStreamingOrderByPriorityQueue with a reversed compare function and the same maximum size. + // Enqueue all elements from the current priority queue into the reverse priority queue. + reverse() { + const reversePQ = new NonStreamingOrderByPriorityQueue((a, b) => -this.compareFn(a, b), this.pqMaxSize); + while (!this.pq.isEmpty()) { + reversePQ.enqueue(this.pq.deq()); + } + return reversePQ; + } +} +//# sourceMappingURL=nonStreamingOrderByPriorityQueue.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js.map new file mode 100644 index 000000000..5361a2d9f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/nonStreamingOrderByPriorityQueue.js.map @@ -0,0 +1 @@ +{"version":3,"file":"nonStreamingOrderByPriorityQueue.js","sourceRoot":"","sources":["../../../src/utils/nonStreamingOrderByPriorityQueue.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,gCAAgC;IAK3C,YAAY,SAAiC,EAAE,YAAoB,IAAI;QACrE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,EAAE,GAAG,IAAI,aAAa,CAAI,IAAI,CAAC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAEM,OAAO,CAAC,IAAO;QACpB,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,EAAE;YACnC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACnB;aAAM;YACL,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE;gBACrC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;gBACd,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACnB;SACF;IACH,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC;IACvB,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAEM,IAAI;QACT,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAEM,cAAc;QACnB,MAAM,QAAQ,GAAQ,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE;YACzB,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;SACjC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,wHAAwH;IACxH,wFAAwF;IACjF,OAAO;QACZ,MAAM,SAAS,GAAG,IAAI,gCAAgC,CACpD,CAAC,CAAI,EAAE,CAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EACrC,IAAI,CAAC,SAAS,CACf,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE;YACzB,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;SAClC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport PriorityQueue from \"priorityqueuejs\";\n\nexport class NonStreamingOrderByPriorityQueue {\n private pq: PriorityQueue;\n private compareFn: (a: T, b: T) => number;\n private pqMaxSize: number;\n\n constructor(compareFn: (a: T, b: T) => number, pqMaxSize: number = 2000) {\n this.compareFn = compareFn;\n this.pq = new PriorityQueue(this.compareFn);\n this.pqMaxSize = pqMaxSize;\n }\n\n public enqueue(item: T): void {\n if (this.pq.size() < this.pqMaxSize) {\n this.pq.enq(item);\n } else {\n const topItem = this.pq.peek();\n if (this.compareFn(topItem, item) > 0) {\n this.pq.deq();\n this.pq.enq(item);\n }\n }\n }\n\n public dequeue(): T {\n return this.pq.deq();\n }\n\n public size(): number {\n return this.pq.size();\n }\n\n public isEmpty(): boolean {\n return this.pq.isEmpty();\n }\n\n public peek(): T {\n return this.pq.peek();\n }\n\n public getTopElements(): T[] {\n const elements: T[] = [];\n while (!this.pq.isEmpty()) {\n elements.unshift(this.pq.deq());\n }\n return elements;\n }\n\n // Create a new instance of NonStreamingOrderByPriorityQueue with a reversed compare function and the same maximum size.\n // Enqueue all elements from the current priority queue into the reverse priority queue.\n public reverse(): NonStreamingOrderByPriorityQueue {\n const reversePQ = new NonStreamingOrderByPriorityQueue(\n (a: T, b: T) => -this.compareFn(a, b),\n this.pqMaxSize,\n );\n while (!this.pq.isEmpty()) {\n reversePQ.enqueue(this.pq.deq());\n }\n return reversePQ;\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts new file mode 100644 index 000000000..da44337d4 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts @@ -0,0 +1,3 @@ +import { ContainerRequest } from "../client/Container/ContainerRequest"; +export declare function validateOffer(body: ContainerRequest): void; +//# sourceMappingURL=offers.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts.map new file mode 100644 index 000000000..783a694b1 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"offers.d.ts","sourceRoot":"","sources":["../../../src/utils/offers.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,CAY1D"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js new file mode 100644 index 000000000..9d6442fc2 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export function validateOffer(body) { + if (body.throughput) { + if (body.maxThroughput) { + console.log("should be erroring"); + throw new Error("Cannot specify `throughput` with `maxThroughput`"); + } + if (body.autoUpgradePolicy) { + throw new Error("Cannot specify autoUpgradePolicy with throughput. Use `maxThroughput` instead"); + } + } +} +//# sourceMappingURL=offers.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js.map new file mode 100644 index 000000000..d65b3a8c3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/offers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"offers.js","sourceRoot":"","sources":["../../../src/utils/offers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,UAAU,aAAa,CAAC,IAAsB;IAClD,IAAI,IAAI,CAAC,UAAU,EAAE;QACnB,IAAI,IAAI,CAAC,aAAa,EAAE;YACtB,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;YAClC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;SACrE;QACD,IAAI,IAAI,CAAC,iBAAiB,EAAE;YAC1B,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;SACH;KACF;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ContainerRequest } from \"../client/Container/ContainerRequest\";\n\nexport function validateOffer(body: ContainerRequest): void {\n if (body.throughput) {\n if (body.maxThroughput) {\n console.log(\"should be erroring\");\n throw new Error(\"Cannot specify `throughput` with `maxThroughput`\");\n }\n if (body.autoUpgradePolicy) {\n throw new Error(\n \"Cannot specify autoUpgradePolicy with throughput. Use `maxThroughput` instead\",\n );\n }\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts new file mode 100644 index 000000000..2eb036825 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts @@ -0,0 +1,22 @@ +export type PatchOperation = ExistingKeyOperation | RemoveOperation; +export declare const PatchOperationType: { + readonly add: "add"; + readonly replace: "replace"; + readonly remove: "remove"; + readonly set: "set"; + readonly incr: "incr"; +}; +export type ExistingKeyOperation = { + op: keyof typeof PatchOperationType; + value: any; + path: string; +}; +export type RemoveOperation = { + op: "remove"; + path: string; +}; +export type PatchRequestBody = { + operations: PatchOperation[]; + condition?: string; +} | PatchOperation[]; +//# sourceMappingURL=patch.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts.map new file mode 100644 index 000000000..5cd66dee0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../../src/utils/patch.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,eAAe,CAAC;AAEpE,eAAO,MAAM,kBAAkB;;;;;;CAMrB,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,OAAO,kBAAkB,CAAC;IACpC,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB;IACE,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACD,cAAc,EAAE,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js new file mode 100644 index 000000000..d77198958 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export const PatchOperationType = { + add: "add", + replace: "replace", + remove: "remove", + set: "set", + incr: "incr", +}; +//# sourceMappingURL=patch.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js.map new file mode 100644 index 000000000..c970022de --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/patch.js.map @@ -0,0 +1 @@ +{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../../src/utils/patch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;CACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport type PatchOperation = ExistingKeyOperation | RemoveOperation;\n\nexport const PatchOperationType = {\n add: \"add\",\n replace: \"replace\",\n remove: \"remove\",\n set: \"set\",\n incr: \"incr\",\n} as const;\n\nexport type ExistingKeyOperation = {\n op: keyof typeof PatchOperationType;\n value: any;\n path: string;\n};\n\nexport type RemoveOperation = {\n op: \"remove\";\n path: string;\n};\n\nexport type PatchRequestBody =\n | {\n operations: PatchOperation[];\n condition?: string;\n }\n | PatchOperation[];\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts new file mode 100644 index 000000000..109149bed --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts @@ -0,0 +1,2 @@ +export declare function isNonEmptyString(variable: unknown): boolean; +//# sourceMappingURL=strings.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts.map new file mode 100644 index 000000000..8db10e79a --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../../src/utils/strings.ts"],"names":[],"mappings":"AAGA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAE3D"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js new file mode 100644 index 000000000..7bdde5920 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export function isNonEmptyString(variable) { + return typeof variable === "string" && variable.trim().length > 0; +} +//# sourceMappingURL=strings.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js.map new file mode 100644 index 000000000..ee8872cf6 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/strings.js.map @@ -0,0 +1 @@ +{"version":3,"file":"strings.js","sourceRoot":"","sources":["../../../src/utils/strings.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACpE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport function isNonEmptyString(variable: unknown): boolean {\n return typeof variable === \"string\" && variable.trim().length > 0;\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts new file mode 100644 index 000000000..a51a4605c --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts @@ -0,0 +1,2 @@ +export declare function supportedQueryFeaturesBuilder(disableNonStreamingOrderByQuery?: boolean): string; +//# sourceMappingURL=supportedQueryFeaturesBuilder.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts.map new file mode 100644 index 000000000..d8b82cc8b --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"supportedQueryFeaturesBuilder.d.ts","sourceRoot":"","sources":["../../../src/utils/supportedQueryFeaturesBuilder.ts"],"names":[],"mappings":"AAIA,wBAAgB,6BAA6B,CAAC,+BAA+B,CAAC,EAAE,OAAO,GAAG,MAAM,CAQ/F"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js new file mode 100644 index 000000000..4b8b44978 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { QueryFeature } from "../common"; +export function supportedQueryFeaturesBuilder(disableNonStreamingOrderByQuery) { + if (disableNonStreamingOrderByQuery) { + return Object.keys(QueryFeature) + .filter((k) => k !== QueryFeature.NonStreamingOrderBy) + .join(", "); + } + else { + return Object.keys(QueryFeature).join(", "); + } +} +//# sourceMappingURL=supportedQueryFeaturesBuilder.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js.map new file mode 100644 index 000000000..43d546c38 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/supportedQueryFeaturesBuilder.js.map @@ -0,0 +1 @@ +{"version":3,"file":"supportedQueryFeaturesBuilder.js","sourceRoot":"","sources":["../../../src/utils/supportedQueryFeaturesBuilder.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,UAAU,6BAA6B,CAAC,+BAAyC;IACrF,IAAI,+BAA+B,EAAE;QACnC,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;aAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,CAAC,mBAAmB,CAAC;aACrD,IAAI,CAAC,IAAI,CAAC,CAAC;KACf;SAAM;QACL,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KAC7C;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryFeature } from \"../common\";\n\nexport function supportedQueryFeaturesBuilder(disableNonStreamingOrderByQuery?: boolean): string {\n if (disableNonStreamingOrderByQuery) {\n return Object.keys(QueryFeature)\n .filter((k) => k !== QueryFeature.NonStreamingOrderBy)\n .join(\", \");\n } else {\n return Object.keys(QueryFeature).join(\", \");\n }\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts new file mode 100644 index 000000000..4da104ac0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts @@ -0,0 +1,7 @@ +/** + * @hidden + * Utility function to get currentTime in UTC milliseconds. + * @returns + */ +export declare function getCurrentTimestampInMs(): number; +//# sourceMappingURL=time.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts.map new file mode 100644 index 000000000..93c89fc57 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/utils/time.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js new file mode 100644 index 000000000..8038bba90 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * Utility function to get currentTime in UTC milliseconds. + * @returns + */ +export function getCurrentTimestampInMs() { + return Date.now(); +} +//# sourceMappingURL=time.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js.map new file mode 100644 index 000000000..58f8ca84f --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/time.js.map @@ -0,0 +1 @@ +{"version":3,"file":"time.js","sourceRoot":"","sources":["../../../src/utils/time.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AAEH,MAAM,UAAU,uBAAuB;IACrC,OAAO,IAAI,CAAC,GAAG,EAAE,CAAC;AACpB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @hidden\n * Utility function to get currentTime in UTC milliseconds.\n * @returns\n */\n\nexport function getCurrentTimestampInMs(): number {\n return Date.now();\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts new file mode 100644 index 000000000..706867695 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=tracing.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts.map new file mode 100644 index 000000000..8536c53df --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"tracing.d.ts","sourceRoot":"","sources":["../../../src/utils/tracing.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js new file mode 100644 index 000000000..0ccd81bb5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { createTracingClient } from "@azure/core-tracing"; +import { Constants } from "../common/constants"; +/** + * Global tracing client for this package. + * + * @internal + */ +export const tracingClient = createTracingClient({ + namespace: Constants.AzureNamespace, + packageName: Constants.AzurePackageName, + packageVersion: Constants.SDKVersion, +}); +//# sourceMappingURL=tracing.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js.map new file mode 100644 index 000000000..3fda9fb73 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/tracing.js.map @@ -0,0 +1 @@ +{"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/utils/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,SAAS,CAAC,cAAc;IACnC,WAAW,EAAE,SAAS,CAAC,gBAAgB;IACvC,cAAc,EAAE,SAAS,CAAC,UAAU;CACrC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createTracingClient } from \"@azure/core-tracing\";\nimport { Constants } from \"../common/constants\";\n\n/**\n * Global tracing client for this package.\n *\n * @internal\n */\nexport const tracingClient = createTracingClient({\n namespace: Constants.AzureNamespace,\n packageName: Constants.AzurePackageName,\n packageVersion: Constants.SDKVersion,\n});\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts new file mode 100644 index 000000000..45f76ead9 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts @@ -0,0 +1,13 @@ +/** + * A type which could be any type but undefined + */ +export type NonUndefinable = T extends undefined ? never : T; +/** + * Utility function to avoid writing boilder plate code while checking for + * undefined values. It throws Error if the input value is undefined. + * @param value - Value which is potentially undefined. + * @param msg - Error Message to throw if value is undefined. + * @returns + */ +export declare function assertNotUndefined(value: T, msg?: string): NonUndefinable; +//# sourceMappingURL=typeChecks.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts.map new file mode 100644 index 000000000..48fab79a0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"typeChecks.d.ts","sourceRoot":"","sources":["../../../src/utils/typeChecks.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAK/E"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js new file mode 100644 index 000000000..39a2746be --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { NonePartitionKeyLiteral, NullPartitionKeyLiteral, } from "../documents"; +/** + * Utility function to avoid writing boilder plate code while checking for + * undefined values. It throws Error if the input value is undefined. + * @param value - Value which is potentially undefined. + * @param msg - Error Message to throw if value is undefined. + * @returns + */ +export function assertNotUndefined(value, msg) { + if (value !== undefined) { + return value; + } + throw new Error(msg || "Unexpected 'undefined' value encountered"); +} +/** + * Check for value being PrimitivePartitionKeyValue. + * @internal + */ +export function isPrimitivePartitionKeyValue(value) { + return (isWellDefinedPartitionKeyValue(value) || + isNonePartitionKeyValue(value) || + isNullPartitionKeyValue(value)); +} +/** + * Check for value being string, number or boolean. + * @internal + */ +export function isWellDefinedPartitionKeyValue(value) { + return typeof value === "string" || typeof value === "boolean" || typeof value === "number"; +} +/** + * Check for value being NonePartitionKeyType. + * @internal + */ +export function isNonePartitionKeyValue(value) { + return value !== undefined && JSON.stringify(value) === JSON.stringify(NonePartitionKeyLiteral); +} +/** + * Check for value being NullPartitionKeyType. + * @internal + */ +export function isNullPartitionKeyValue(value) { + return value === NullPartitionKeyLiteral; +} +/** + * Verify validity of partition key. + * @internal + */ +export function isPartitionKey(partitionKey) { + return isPrimitivePartitionKeyValue(partitionKey) || Array.isArray(partitionKey); +} +//# sourceMappingURL=typeChecks.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js.map new file mode 100644 index 000000000..6e7786dbd --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/typeChecks.js.map @@ -0,0 +1 @@ +{"version":3,"file":"typeChecks.js","sourceRoot":"","sources":["../../../src/utils/typeChecks.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EACL,uBAAuB,EAEvB,uBAAuB,GAGxB,MAAM,cAAc,CAAC;AAOtB;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAI,KAAQ,EAAE,GAAY;IAC1D,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,KAA0B,CAAC;KACnC;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,0CAA0C,CAAC,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAc;IACzD,OAAO,CACL,8BAA8B,CAAC,KAAK,CAAC;QACrC,uBAAuB,CAAC,KAAK,CAAC;QAC9B,uBAAuB,CAAC,KAAK,CAAC,CAC/B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAAc;IAC3D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC9F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,OAAO,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;AAClG,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,OAAO,KAAK,KAAK,uBAAuB,CAAC;AAC3C,CAAC;AACD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,YAAqB;IAClD,OAAO,4BAA4B,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AACnF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NonePartitionKeyLiteral,\n NonePartitionKeyType,\n NullPartitionKeyLiteral,\n NullPartitionKeyType,\n PrimitivePartitionKeyValue,\n} from \"../documents\";\n\n/**\n * A type which could be any type but undefined\n */\nexport type NonUndefinable = T extends undefined ? never : T;\n\n/**\n * Utility function to avoid writing boilder plate code while checking for\n * undefined values. It throws Error if the input value is undefined.\n * @param value - Value which is potentially undefined.\n * @param msg - Error Message to throw if value is undefined.\n * @returns\n */\nexport function assertNotUndefined(value: T, msg?: string): NonUndefinable {\n if (value !== undefined) {\n return value as NonUndefinable;\n }\n throw new Error(msg || \"Unexpected 'undefined' value encountered\");\n}\n\n/**\n * Check for value being PrimitivePartitionKeyValue.\n * @internal\n */\nexport function isPrimitivePartitionKeyValue(value: unknown): value is PrimitivePartitionKeyValue {\n return (\n isWellDefinedPartitionKeyValue(value) ||\n isNonePartitionKeyValue(value) ||\n isNullPartitionKeyValue(value)\n );\n}\n\n/**\n * Check for value being string, number or boolean.\n * @internal\n */\nexport function isWellDefinedPartitionKeyValue(value: unknown): value is string | number | boolean {\n return typeof value === \"string\" || typeof value === \"boolean\" || typeof value === \"number\";\n}\n\n/**\n * Check for value being NonePartitionKeyType.\n * @internal\n */\nexport function isNonePartitionKeyValue(value: unknown): value is NonePartitionKeyType {\n return value !== undefined && JSON.stringify(value) === JSON.stringify(NonePartitionKeyLiteral);\n}\n\n/**\n * Check for value being NullPartitionKeyType.\n * @internal\n */\nexport function isNullPartitionKeyValue(value: unknown): value is NullPartitionKeyType {\n return value === NullPartitionKeyLiteral;\n}\n/**\n * Verify validity of partition key.\n * @internal\n */\nexport function isPartitionKey(partitionKey: unknown): boolean {\n return isPrimitivePartitionKeyValue(partitionKey) || Array.isArray(partitionKey);\n}\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts new file mode 100644 index 000000000..c6eaf2dc5 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts @@ -0,0 +1,2 @@ +export type VerboseOmit = Pick>; +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts.map new file mode 100644 index 000000000..7b30b8c77 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js new file mode 100644 index 000000000..26d279a07 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +export {}; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js.map b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js.map new file mode 100644 index 000000000..fa9c8c2e3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist-esm/src/utils/types.js.map @@ -0,0 +1 @@ +{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// Shim for Omit added in TypeScript 3.5\nexport type VerboseOmit = Pick>;\n"]} \ No newline at end of file diff --git a/local_dependencies/@azure/cosmos/dist/index.js b/local_dependencies/@azure/cosmos/dist/index.js new file mode 100644 index 000000000..8819bc170 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist/index.js @@ -0,0 +1,12412 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var crypto = require('crypto'); +var logger$5 = require('@azure/logger'); +var uuid$3 = require('uuid'); +var tslib = require('tslib'); +var semaphore = require('semaphore'); +var stableStringify = require('fast-json-stable-stringify'); +var PriorityQueue = require('priorityqueuejs'); +var coreRestPipeline = require('@azure/core-rest-pipeline'); +var nodeAbortController = require('node-abort-controller'); +var universalUserAgent = require('universal-user-agent'); +var JSBI = require('jsbi'); +var abortController = require('@azure/abort-controller'); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const DEFAULT_PARTITION_KEY_PATH = "/_partitionKey"; // eslint-disable-line @typescript-eslint/prefer-as-const + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +const Constants$1 = { + HttpHeaders: { + Authorization: "authorization", + ETag: "etag", + MethodOverride: "X-HTTP-Method", + Slug: "Slug", + ContentType: "Content-Type", + LastModified: "Last-Modified", + ContentEncoding: "Content-Encoding", + CharacterSet: "CharacterSet", + UserAgent: "User-Agent", + IfModifiedSince: "If-Modified-Since", + IfMatch: "If-Match", + IfNoneMatch: "If-None-Match", + ContentLength: "Content-Length", + AcceptEncoding: "Accept-Encoding", + KeepAlive: "Keep-Alive", + CacheControl: "Cache-Control", + TransferEncoding: "Transfer-Encoding", + ContentLanguage: "Content-Language", + ContentLocation: "Content-Location", + ContentMd5: "Content-Md5", + ContentRange: "Content-Range", + Accept: "Accept", + AcceptCharset: "Accept-Charset", + AcceptLanguage: "Accept-Language", + IfRange: "If-Range", + IfUnmodifiedSince: "If-Unmodified-Since", + MaxForwards: "Max-Forwards", + ProxyAuthorization: "Proxy-Authorization", + AcceptRanges: "Accept-Ranges", + ProxyAuthenticate: "Proxy-Authenticate", + RetryAfter: "Retry-After", + SetCookie: "Set-Cookie", + WwwAuthenticate: "Www-Authenticate", + Origin: "Origin", + Host: "Host", + AccessControlAllowOrigin: "Access-Control-Allow-Origin", + AccessControlAllowHeaders: "Access-Control-Allow-Headers", + KeyValueEncodingFormat: "application/x-www-form-urlencoded", + WrapAssertionFormat: "wrap_assertion_format", + WrapAssertion: "wrap_assertion", + WrapScope: "wrap_scope", + SimpleToken: "SWT", + HttpDate: "date", + Prefer: "Prefer", + Location: "Location", + Referer: "referer", + A_IM: "A-IM", + // Query + Query: "x-ms-documentdb-query", + IsQuery: "x-ms-documentdb-isquery", + IsQueryPlan: "x-ms-cosmos-is-query-plan-request", + SupportedQueryFeatures: "x-ms-cosmos-supported-query-features", + QueryVersion: "x-ms-cosmos-query-version", + // Our custom Azure Cosmos DB headers + Continuation: "x-ms-continuation", + ContinuationToken: "x-ms-continuation-token", + PageSize: "x-ms-max-item-count", + ItemCount: "x-ms-item-count", + // Request sender generated. Simply echoed by backend. + ActivityId: "x-ms-activity-id", + PreTriggerInclude: "x-ms-documentdb-pre-trigger-include", + PreTriggerExclude: "x-ms-documentdb-pre-trigger-exclude", + PostTriggerInclude: "x-ms-documentdb-post-trigger-include", + PostTriggerExclude: "x-ms-documentdb-post-trigger-exclude", + IndexingDirective: "x-ms-indexing-directive", + SessionToken: "x-ms-session-token", + ConsistencyLevel: "x-ms-consistency-level", + XDate: "x-ms-date", + CollectionPartitionInfo: "x-ms-collection-partition-info", + CollectionServiceInfo: "x-ms-collection-service-info", + // Deprecated, use RetryAfterInMs instead. + RetryAfterInMilliseconds: "x-ms-retry-after-ms", + RetryAfterInMs: "x-ms-retry-after-ms", + IsFeedUnfiltered: "x-ms-is-feed-unfiltered", + ResourceTokenExpiry: "x-ms-documentdb-expiry-seconds", + EnableScanInQuery: "x-ms-documentdb-query-enable-scan", + EmitVerboseTracesInQuery: "x-ms-documentdb-query-emit-traces", + EnableCrossPartitionQuery: "x-ms-documentdb-query-enablecrosspartition", + ParallelizeCrossPartitionQuery: "x-ms-documentdb-query-parallelizecrosspartitionquery", + ResponseContinuationTokenLimitInKB: "x-ms-documentdb-responsecontinuationtokenlimitinkb", + // QueryMetrics + // Request header to tell backend to give you query metrics. + PopulateQueryMetrics: "x-ms-documentdb-populatequerymetrics", + // Response header that holds the serialized version of query metrics. + QueryMetrics: "x-ms-documentdb-query-metrics", + // IndexMetrics + // Request header to tell backend to give you index metrics. + PopulateIndexMetrics: "x-ms-cosmos-populateindexmetrics", + // Response header that holds the serialized version of index metrics. + IndexUtilization: "x-ms-cosmos-index-utilization", + // Version headers and values + Version: "x-ms-version", + // Owner name + OwnerFullName: "x-ms-alt-content-path", + // Owner ID used for name based request in session token. + OwnerId: "x-ms-content-path", + // Partition Key + PartitionKey: "x-ms-documentdb-partitionkey", + PartitionKeyRangeID: "x-ms-documentdb-partitionkeyrangeid", + // Epk Range headers + StartEpk: "x-ms-start-epk", + EndEpk: "x-ms-end-epk", + // Read Feed Type + ReadFeedKeyType: "x-ms-read-key-type", + // Quota Info + MaxEntityCount: "x-ms-root-entity-max-count", + CurrentEntityCount: "x-ms-root-entity-current-count", + CollectionQuotaInMb: "x-ms-collection-quota-mb", + CollectionCurrentUsageInMb: "x-ms-collection-usage-mb", + MaxMediaStorageUsageInMB: "x-ms-max-media-storage-usage-mb", + CurrentMediaStorageUsageInMB: "x-ms-media-storage-usage-mb", + RequestCharge: "x-ms-request-charge", + PopulateQuotaInfo: "x-ms-documentdb-populatequotainfo", + MaxResourceQuota: "x-ms-resource-quota", + // Offer header + OfferType: "x-ms-offer-type", + OfferThroughput: "x-ms-offer-throughput", + AutoscaleSettings: "x-ms-cosmos-offer-autopilot-settings", + // Custom RUs/minute headers + DisableRUPerMinuteUsage: "x-ms-documentdb-disable-ru-per-minute-usage", + IsRUPerMinuteUsed: "x-ms-documentdb-is-ru-per-minute-used", + OfferIsRUPerMinuteThroughputEnabled: "x-ms-offer-is-ru-per-minute-throughput-enabled", + // Index progress headers + IndexTransformationProgress: "x-ms-documentdb-collection-index-transformation-progress", + LazyIndexingProgress: "x-ms-documentdb-collection-lazy-indexing-progress", + // Upsert header + IsUpsert: "x-ms-documentdb-is-upsert", + // Sub status of the error + SubStatus: "x-ms-substatus", + // StoredProcedure related headers + EnableScriptLogging: "x-ms-documentdb-script-enable-logging", + ScriptLogResults: "x-ms-documentdb-script-log-results", + // Multi-Region Write + ALLOW_MULTIPLE_WRITES: "x-ms-cosmos-allow-tentative-writes", + // Bulk/Batch header + IsBatchRequest: "x-ms-cosmos-is-batch-request", + IsBatchAtomic: "x-ms-cosmos-batch-atomic", + BatchContinueOnError: "x-ms-cosmos-batch-continue-on-error", + // Dedicated Gateway Headers + DedicatedGatewayPerRequestCacheStaleness: "x-ms-dedicatedgateway-max-age", + // Cache Refresh header + ForceRefresh: "x-ms-force-refresh", + // Priority Based throttling header + PriorityLevel: "x-ms-cosmos-priority-level", + }, + // GlobalDB related constants + WritableLocations: "writableLocations", + ReadableLocations: "readableLocations", + LocationUnavailableExpirationTimeInMs: 5 * 60 * 1000, + // ServiceDocument Resource + ENABLE_MULTIPLE_WRITABLE_LOCATIONS: "enableMultipleWriteLocations", + // Background refresh time + DefaultUnavailableLocationExpirationTimeMS: 5 * 60 * 1000, + // Client generated retry count response header + ThrottleRetryCount: "x-ms-throttle-retry-count", + ThrottleRetryWaitTimeInMs: "x-ms-throttle-retry-wait-time-ms", + // Platform + CurrentVersion: "2020-07-15", + AzureNamespace: "Azure.Cosmos", + AzurePackageName: "@azure/cosmos", + SDKName: "azure-cosmos-js", + SDKVersion: "4.0.1-beta.3", + // Diagnostics + CosmosDbDiagnosticLevelEnvVarName: "AZURE_COSMOSDB_DIAGNOSTICS_LEVEL", + // Bulk Operations + DefaultMaxBulkRequestBodySizeInBytes: 220201, + Quota: { + CollectionSize: "collectionSize", + }, + Path: { + Root: "/", + DatabasesPathSegment: "dbs", + CollectionsPathSegment: "colls", + UsersPathSegment: "users", + DocumentsPathSegment: "docs", + PermissionsPathSegment: "permissions", + StoredProceduresPathSegment: "sprocs", + TriggersPathSegment: "triggers", + UserDefinedFunctionsPathSegment: "udfs", + ConflictsPathSegment: "conflicts", + AttachmentsPathSegment: "attachments", + PartitionKeyRangesPathSegment: "pkranges", + SchemasPathSegment: "schemas", + OffersPathSegment: "offers", + TopologyPathSegment: "topology", + DatabaseAccountPathSegment: "databaseaccount", + }, + PartitionKeyRange: { + // Partition Key Range Constants + MinInclusive: "minInclusive", + MaxExclusive: "maxExclusive", + Id: "id", + }, + QueryRangeConstants: { + // Partition Key Range Constants + MinInclusive: "minInclusive", + MaxExclusive: "maxExclusive", + min: "min", + }, + /** + * @deprecated Use EffectivePartitionKeyConstants instead + */ + EffectiveParitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: "", + MaximumExclusiveEffectivePartitionKey: "FF", + }, + EffectivePartitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: "", + MaximumExclusiveEffectivePartitionKey: "FF", + }, + // NonStreaming queries + NonStreamingQueryDefaultRUThreshold: 5000, +}; +/** + * @hidden + */ +exports.ResourceType = void 0; +(function (ResourceType) { + ResourceType["none"] = ""; + ResourceType["database"] = "dbs"; + ResourceType["offer"] = "offers"; + ResourceType["user"] = "users"; + ResourceType["permission"] = "permissions"; + ResourceType["container"] = "colls"; + ResourceType["conflicts"] = "conflicts"; + ResourceType["sproc"] = "sprocs"; + ResourceType["udf"] = "udfs"; + ResourceType["trigger"] = "triggers"; + ResourceType["item"] = "docs"; + ResourceType["pkranges"] = "pkranges"; + ResourceType["partitionkey"] = "partitionKey"; +})(exports.ResourceType || (exports.ResourceType = {})); +/** + * @hidden + */ +exports.HTTPMethod = void 0; +(function (HTTPMethod) { + HTTPMethod["get"] = "GET"; + HTTPMethod["patch"] = "PATCH"; + HTTPMethod["post"] = "POST"; + HTTPMethod["put"] = "PUT"; + HTTPMethod["delete"] = "DELETE"; +})(exports.HTTPMethod || (exports.HTTPMethod = {})); +/** + * @hidden + */ +exports.OperationType = void 0; +(function (OperationType) { + OperationType["Create"] = "create"; + OperationType["Replace"] = "replace"; + OperationType["Upsert"] = "upsert"; + OperationType["Delete"] = "delete"; + OperationType["Read"] = "read"; + OperationType["Query"] = "query"; + OperationType["Execute"] = "execute"; + OperationType["Batch"] = "batch"; + OperationType["Patch"] = "patch"; +})(exports.OperationType || (exports.OperationType = {})); +/** + * @hidden + */ +var CosmosKeyType; +(function (CosmosKeyType) { + CosmosKeyType["PrimaryMaster"] = "PRIMARY_MASTER"; + CosmosKeyType["SecondaryMaster"] = "SECONDARY_MASTER"; + CosmosKeyType["PrimaryReadOnly"] = "PRIMARY_READONLY"; + CosmosKeyType["SecondaryReadOnly"] = "SECONDARY_READONLY"; +})(CosmosKeyType || (CosmosKeyType = {})); +/** + * @hidden + */ +var CosmosContainerChildResourceKind; +(function (CosmosContainerChildResourceKind) { + CosmosContainerChildResourceKind["Item"] = "ITEM"; + CosmosContainerChildResourceKind["StoredProcedure"] = "STORED_PROCEDURE"; + CosmosContainerChildResourceKind["UserDefinedFunction"] = "USER_DEFINED_FUNCTION"; + CosmosContainerChildResourceKind["Trigger"] = "TRIGGER"; +})(CosmosContainerChildResourceKind || (CosmosContainerChildResourceKind = {})); +/** + * @hidden + */ +var PermissionScopeValues; +(function (PermissionScopeValues) { + /** + * Values which set permission Scope applicable to control plane related operations. + */ + PermissionScopeValues[PermissionScopeValues["ScopeAccountReadValue"] = 1] = "ScopeAccountReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountListDatabasesValue"] = 2] = "ScopeAccountListDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadValue"] = 4] = "ScopeDatabaseReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadOfferValue"] = 8] = "ScopeDatabaseReadOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseListContainerValue"] = 16] = "ScopeDatabaseListContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadValue"] = 32] = "ScopeContainerReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadOfferValue"] = 64] = "ScopeContainerReadOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountCreateDatabasesValue"] = 1] = "ScopeAccountCreateDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountDeleteDatabasesValue"] = 2] = "ScopeAccountDeleteDatabasesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseDeleteValue"] = 4] = "ScopeDatabaseDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReplaceOfferValue"] = 8] = "ScopeDatabaseReplaceOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseCreateContainerValue"] = 16] = "ScopeDatabaseCreateContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseDeleteContainerValue"] = 32] = "ScopeDatabaseDeleteContainerValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceValue"] = 64] = "ScopeContainerReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteValue"] = 128] = "ScopeContainerDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceOfferValue"] = 256] = "ScopeContainerReplaceOfferValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountReadAllAccessValue"] = 65535] = "ScopeAccountReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseReadAllAccessValue"] = 124] = "ScopeDatabaseReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainersReadAllAccessValue"] = 96] = "ScopeContainersReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeAccountWriteAllAccessValue"] = 65535] = "ScopeAccountWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeDatabaseWriteAllAccessValue"] = 508] = "ScopeDatabaseWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainersWriteAllAccessValue"] = 448] = "ScopeContainersWriteAllAccessValue"; + /** + * Values which set permission Scope applicable to data plane related operations. + */ + PermissionScopeValues[PermissionScopeValues["ScopeContainerExecuteQueriesValue"] = 1] = "ScopeContainerExecuteQueriesValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadFeedsValue"] = 2] = "ScopeContainerReadFeedsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadStoredProceduresValue"] = 4] = "ScopeContainerReadStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadUserDefinedFunctionsValue"] = 8] = "ScopeContainerReadUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadTriggersValue"] = 16] = "ScopeContainerReadTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadConflictsValue"] = 32] = "ScopeContainerReadConflictsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReadValue"] = 64] = "ScopeItemReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureReadValue"] = 128] = "ScopeStoredProcedureReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionReadValue"] = 256] = "ScopeUserDefinedFunctionReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerReadValue"] = 512] = "ScopeTriggerReadValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateItemsValue"] = 1] = "ScopeContainerCreateItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceItemsValue"] = 2] = "ScopeContainerReplaceItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerUpsertItemsValue"] = 4] = "ScopeContainerUpsertItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteItemsValue"] = 8] = "ScopeContainerDeleteItemsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateStoredProceduresValue"] = 16] = "ScopeContainerCreateStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceStoredProceduresValue"] = 32] = "ScopeContainerReplaceStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteStoredProceduresValue"] = 64] = "ScopeContainerDeleteStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerExecuteStoredProceduresValue"] = 128] = "ScopeContainerExecuteStoredProceduresValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateTriggersValue"] = 256] = "ScopeContainerCreateTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceTriggersValue"] = 512] = "ScopeContainerReplaceTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteTriggersValue"] = 1024] = "ScopeContainerDeleteTriggersValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerCreateUserDefinedFunctionsValue"] = 2048] = "ScopeContainerCreateUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReplaceUserDefinedFunctionsValue"] = 4096] = "ScopeContainerReplaceUserDefinedFunctionsValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteUserDefinedFunctionSValue"] = 8192] = "ScopeContainerDeleteUserDefinedFunctionSValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerDeleteCONFLICTSValue"] = 16384] = "ScopeContainerDeleteCONFLICTSValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReplaceValue"] = 65536] = "ScopeItemReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemUpsertValue"] = 131072] = "ScopeItemUpsertValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemDeleteValue"] = 262144] = "ScopeItemDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureReplaceValue"] = 1048576] = "ScopeStoredProcedureReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureDeleteValue"] = 2097152] = "ScopeStoredProcedureDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeStoredProcedureExecuteValue"] = 4194304] = "ScopeStoredProcedureExecuteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionReplaceValue"] = 8388608] = "ScopeUserDefinedFunctionReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeUserDefinedFunctionDeleteValue"] = 16777216] = "ScopeUserDefinedFunctionDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerReplaceValue"] = 33554432] = "ScopeTriggerReplaceValue"; + PermissionScopeValues[PermissionScopeValues["ScopeTriggerDeleteValue"] = 67108864] = "ScopeTriggerDeleteValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerReadAllAccessValue"] = 4294967295] = "ScopeContainerReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemReadAllAccessValue"] = 65] = "ScopeItemReadAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeContainerWriteAllAccessValue"] = 4294967295] = "ScopeContainerWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["ScopeItemWriteAllAccessValue"] = 458767] = "ScopeItemWriteAllAccessValue"; + PermissionScopeValues[PermissionScopeValues["NoneValue"] = 0] = "NoneValue"; +})(PermissionScopeValues || (PermissionScopeValues = {})); +/** + * @hidden + */ +exports.SasTokenPermissionKind = void 0; +(function (SasTokenPermissionKind) { + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateItems"] = 1] = "ContainerCreateItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceItems"] = 2] = "ContainerReplaceItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerUpsertItems"] = 4] = "ContainerUpsertItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteItems"] = 128] = "ContainerDeleteItems"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerExecuteQueries"] = 1] = "ContainerExecuteQueries"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadFeeds"] = 2] = "ContainerReadFeeds"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateStoreProcedure"] = 16] = "ContainerCreateStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadStoreProcedure"] = 4] = "ContainerReadStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceStoreProcedure"] = 32] = "ContainerReplaceStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteStoreProcedure"] = 64] = "ContainerDeleteStoreProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateTriggers"] = 256] = "ContainerCreateTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadTriggers"] = 16] = "ContainerReadTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceTriggers"] = 512] = "ContainerReplaceTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteTriggers"] = 1024] = "ContainerDeleteTriggers"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerCreateUserDefinedFunctions"] = 2048] = "ContainerCreateUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadUserDefinedFunctions"] = 8] = "ContainerReadUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReplaceUserDefinedFunctions"] = 4096] = "ContainerReplaceUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteUserDefinedFunctions"] = 8192] = "ContainerDeleteUserDefinedFunctions"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerExecuteStoredProcedure"] = 128] = "ContainerExecuteStoredProcedure"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadConflicts"] = 32] = "ContainerReadConflicts"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerDeleteConflicts"] = 16384] = "ContainerDeleteConflicts"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerReadAny"] = 64] = "ContainerReadAny"; + SasTokenPermissionKind[SasTokenPermissionKind["ContainerFullAccess"] = 4294967295] = "ContainerFullAccess"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemReadAny"] = 65536] = "ItemReadAny"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemFullAccess"] = 65] = "ItemFullAccess"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemRead"] = 64] = "ItemRead"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemReplace"] = 65536] = "ItemReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemUpsert"] = 131072] = "ItemUpsert"; + SasTokenPermissionKind[SasTokenPermissionKind["ItemDelete"] = 262144] = "ItemDelete"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureRead"] = 128] = "StoreProcedureRead"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureReplace"] = 1048576] = "StoreProcedureReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureDelete"] = 2097152] = "StoreProcedureDelete"; + SasTokenPermissionKind[SasTokenPermissionKind["StoreProcedureExecute"] = 4194304] = "StoreProcedureExecute"; + SasTokenPermissionKind[SasTokenPermissionKind["UserDefinedFuntionRead"] = 256] = "UserDefinedFuntionRead"; + SasTokenPermissionKind[SasTokenPermissionKind["UserDefinedFuntionReplace"] = 8388608] = "UserDefinedFuntionReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["UserDefinedFuntionDelete"] = 16777216] = "UserDefinedFuntionDelete"; + SasTokenPermissionKind[SasTokenPermissionKind["TriggerRead"] = 512] = "TriggerRead"; + SasTokenPermissionKind[SasTokenPermissionKind["TriggerReplace"] = 33554432] = "TriggerReplace"; + SasTokenPermissionKind[SasTokenPermissionKind["TriggerDelete"] = 67108864] = "TriggerDelete"; +})(exports.SasTokenPermissionKind || (exports.SasTokenPermissionKind = {})); +var QueryFeature; +(function (QueryFeature) { + QueryFeature["NonValueAggregate"] = "NonValueAggregate"; + QueryFeature["Aggregate"] = "Aggregate"; + QueryFeature["Distinct"] = "Distinct"; + QueryFeature["MultipleOrderBy"] = "MultipleOrderBy"; + QueryFeature["OffsetAndLimit"] = "OffsetAndLimit"; + QueryFeature["OrderBy"] = "OrderBy"; + QueryFeature["Top"] = "Top"; + QueryFeature["CompositeAggregate"] = "CompositeAggregate"; + QueryFeature["GroupBy"] = "GroupBy"; + QueryFeature["MultipleAggregates"] = "MultipleAggregates"; + QueryFeature["NonStreamingOrderBy"] = "NonStreamingOrderBy"; +})(QueryFeature || (QueryFeature = {})); + +const trimLeftSlashes = new RegExp("^[/]+"); +const trimRightSlashes = new RegExp("[/]+$"); +const illegalResourceIdCharacters = new RegExp("[/\\\\?#]"); +const illegalItemResourceIdCharacters = new RegExp("[/\\\\#]"); +/** @hidden */ +function jsonStringifyAndEscapeNonASCII(arg) { + // TODO: better way for this? Not sure. + // escapes non-ASCII characters as \uXXXX + return JSON.stringify(arg).replace(/[\u007F-\uFFFF]/g, (m) => { + return "\\u" + ("0000" + m.charCodeAt(0).toString(16)).slice(-4); + }); +} +/** + * @hidden + */ +function parseLink(resourcePath) { + if (resourcePath.length === 0) { + /* for DatabaseAccount case, both type and objectBody will be undefined. */ + return { + type: undefined, + objectBody: undefined, + }; + } + if (resourcePath[resourcePath.length - 1] !== "/") { + resourcePath = resourcePath + "/"; + } + if (resourcePath[0] !== "/") { + resourcePath = "/" + resourcePath; + } + /* + The path will be in the form of /[resourceType]/[resourceId]/ .... + /[resourceType]//[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/ + or /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/[resourceType]/[resourceId]/ .... + /[resourceType]/[resourceId]/ + The result of split will be in the form of + [[[resourceType], [resourceId] ... ,[resourceType], [resourceId], ""] + In the first case, to extract the resourceId it will the element before last ( at length -2 ) + and the type will be before it ( at length -3 ) + In the second case, to extract the resource type it will the element before last ( at length -2 ) + */ + const pathParts = resourcePath.split("/"); + let id; + let type; + if (pathParts.length % 2 === 0) { + // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]. + id = pathParts[pathParts.length - 2]; + type = pathParts[pathParts.length - 3]; + } + else { + // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/. + id = pathParts[pathParts.length - 3]; + type = pathParts[pathParts.length - 2]; + } + const result = { + type, + objectBody: { + id, + self: resourcePath, + }, + }; + return result; +} +/** + * @hidden + */ +function isReadRequest(operationType) { + return operationType === exports.OperationType.Read || operationType === exports.OperationType.Query; +} +/** + * @hidden + */ +function sleep(time) { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, time); + }); +} +/** + * @hidden + */ +function getContainerLink(link) { + return link.split("/").slice(0, 4).join("/"); +} +/** + * @hidden + */ +function prepareURL(endpoint, path) { + return trimSlashes(endpoint) + path; +} +/** + * @hidden + */ +function trimSlashes(source) { + return source.replace(trimLeftSlashes, "").replace(trimRightSlashes, ""); +} +/** + * @hidden + */ +function parsePath(path) { + const pathParts = []; + let currentIndex = 0; + const throwError = () => { + throw new Error("Path " + path + " is invalid at index " + currentIndex); + }; + const getEscapedToken = () => { + const quote = path[currentIndex]; + let newIndex = ++currentIndex; + for (;;) { + newIndex = path.indexOf(quote, newIndex); + if (newIndex === -1) { + throwError(); + } + if (path[newIndex - 1] !== "\\") { + break; + } + ++newIndex; + } + const token = path.substr(currentIndex, newIndex - currentIndex); + currentIndex = newIndex + 1; + return token; + }; + const getToken = () => { + const newIndex = path.indexOf("/", currentIndex); + let token = null; + if (newIndex === -1) { + token = path.substr(currentIndex); + currentIndex = path.length; + } + else { + token = path.substr(currentIndex, newIndex - currentIndex); + currentIndex = newIndex; + } + token = token.trim(); + return token; + }; + while (currentIndex < path.length) { + if (path[currentIndex] !== "/") { + throwError(); + } + if (++currentIndex === path.length) { + break; + } + if (path[currentIndex] === '"' || path[currentIndex] === "'") { + pathParts.push(getEscapedToken()); + } + else { + pathParts.push(getToken()); + } + } + return pathParts; +} +/** + * @hidden + */ +function isResourceValid(resource, err) { + // TODO: fix strictness issues so that caller contexts respects the types of the functions + if (resource.id) { + if (typeof resource.id !== "string") { + err.message = "Id must be a string."; + return false; + } + if (resource.id.indexOf("/") !== -1 || + resource.id.indexOf("\\") !== -1 || + resource.id.indexOf("?") !== -1 || + resource.id.indexOf("#") !== -1) { + err.message = "Id contains illegal chars."; + return false; + } + if (resource.id[resource.id.length - 1] === " ") { + err.message = "Id ends with a space."; + return false; + } + } + return true; +} +/** + * @hidden + */ +function isItemResourceValid(resource, err) { + // TODO: fix strictness issues so that caller contexts respects the types of the functions + if (resource.id) { + if (typeof resource.id !== "string") { + err.message = "Id must be a string."; + return false; + } + if (resource.id.indexOf("/") !== -1 || + resource.id.indexOf("\\") !== -1 || + resource.id.indexOf("#") !== -1) { + err.message = "Id contains illegal chars."; + return false; + } + } + return true; +} +/** @hidden */ +function getIdFromLink(resourceLink) { + resourceLink = trimSlashes(resourceLink); + return resourceLink; +} +/** @hidden */ +function getPathFromLink(resourceLink, resourceType) { + resourceLink = trimSlashes(resourceLink); + if (resourceType) { + return "/" + encodeURI(resourceLink) + "/" + resourceType; + } + else { + return "/" + encodeURI(resourceLink); + } +} +/** + * @hidden + */ +function isStringNullOrEmpty(inputString) { + // checks whether string is null, undefined, empty or only contains space + return !inputString || /^\s*$/.test(inputString); +} +/** + * @hidden + */ +function trimSlashFromLeftAndRight(inputString) { + if (typeof inputString !== "string") { + throw new Error("invalid input: input is not string"); + } + return inputString.replace(trimLeftSlashes, "").replace(trimRightSlashes, ""); +} +/** + * @hidden + */ +function validateResourceId(resourceId) { + // if resourceId is not a string or is empty throw an error + if (typeof resourceId !== "string" || isStringNullOrEmpty(resourceId)) { + throw new Error("Resource ID must be a string and cannot be undefined, null or empty"); + } + // if resource id contains illegal characters throw an error + if (illegalResourceIdCharacters.test(resourceId)) { + throw new Error("Illegal characters ['/', '\\', '#', '?'] cannot be used in Resource ID"); + } + return true; +} +/** + * @hidden + */ +function validateItemResourceId(resourceId) { + // if resourceId is not a string or is empty throw an error + if (typeof resourceId !== "string" || isStringNullOrEmpty(resourceId)) { + throw new Error("Resource ID must be a string and cannot be undefined, null or empty"); + } + // if resource id contains illegal characters throw an error + if (illegalItemResourceIdCharacters.test(resourceId)) { + throw new Error("Illegal characters ['/', '\\', '#'] cannot be used in Resource ID"); + } + return true; +} +/** + * @hidden + */ +function getResourceIdFromPath(resourcePath) { + if (!resourcePath || typeof resourcePath !== "string") { + return null; + } + const trimmedPath = trimSlashFromLeftAndRight(resourcePath); + const pathSegments = trimmedPath.split("/"); + // number of segments of a path must always be even + if (pathSegments.length % 2 !== 0) { + return null; + } + return pathSegments[pathSegments.length - 1]; +} +/** + * @hidden + */ +function parseConnectionString(connectionString) { + const keyValueStrings = connectionString.split(";"); + const { AccountEndpoint, AccountKey } = keyValueStrings.reduce((connectionObject, keyValueString) => { + const [key, ...value] = keyValueString.split("="); + connectionObject[key] = value.join("="); + return connectionObject; + }, {}); + if (!AccountEndpoint || !AccountKey) { + throw new Error("Could not parse the provided connection string"); + } + return { + endpoint: AccountEndpoint, + key: AccountKey, + }; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +const StatusCodes = { + // Success + Ok: 200, + Created: 201, + Accepted: 202, + NoContent: 204, + NotModified: 304, + // Client error + BadRequest: 400, + Unauthorized: 401, + Forbidden: 403, + NotFound: 404, + MethodNotAllowed: 405, + RequestTimeout: 408, + Conflict: 409, + Gone: 410, + PreconditionFailed: 412, + RequestEntityTooLarge: 413, + TooManyRequests: 429, + RetryWith: 449, + // Server Error + InternalServerError: 500, + ServiceUnavailable: 503, + // System codes + ENOTFOUND: "ENOTFOUND", + // Operation pause and cancel. These are FAKE status codes for QOS logging purpose only. + OperationPaused: 1200, + OperationCancelled: 1201, +}; +/** + * @hidden + */ +const SubStatusCodes = { + Unknown: 0, + // 400: Bad Request Substatus + CrossPartitionQueryNotServable: 1004, + // 410: StatusCodeType_Gone: substatus + PartitionKeyRangeGone: 1002, + CompletingSplit: 1007, + // 404: NotFound Substatus + ReadSessionNotAvailable: 1002, + // 403: Forbidden Substatus + WriteForbidden: 3, + DatabaseAccountNotFound: 1008, +}; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Would be used when creating or deleting a DocumentCollection + * or a User in Azure Cosmos DB database service + * @hidden + * Given a database id, this creates a database link. + * @param databaseId - The database id + * @returns A database link in the format of `dbs/{0}` + * with `{0}` being a Uri escaped version of the databaseId + */ +function createDatabaseUri(databaseId) { + databaseId = trimSlashFromLeftAndRight(databaseId); + validateResourceId(databaseId); + return Constants$1.Path.DatabasesPathSegment + "/" + databaseId; +} +/** + * Given a database and collection id, this creates a collection link. + * Would be used when updating or deleting a DocumentCollection, creating a + * Document, a StoredProcedure, a Trigger, a UserDefinedFunction, or when executing a query + * with CreateDocumentQuery in Azure Cosmos DB database service. + * @param databaseId - The database id + * @param collectionId - The collection id + * @returns A collection link in the format of `dbs/{0}/colls/{1}` + * with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId + * @hidden + */ +function createDocumentCollectionUri(databaseId, collectionId) { + collectionId = trimSlashFromLeftAndRight(collectionId); + validateResourceId(collectionId); + return (createDatabaseUri(databaseId) + "/" + Constants$1.Path.CollectionsPathSegment + "/" + collectionId); +} +/** + * Given a database and user id, this creates a user link. + * Would be used when creating a Permission, or when replacing or deleting + * a User in Azure Cosmos DB database service + * @param databaseId - The database id + * @param userId - The user id + * @returns A user link in the format of `dbs/{0}/users/{1}` + * with `{0}` being a Uri escaped version of the databaseId and `{1}` being userId + * @hidden + */ +function createUserUri(databaseId, userId) { + userId = trimSlashFromLeftAndRight(userId); + validateResourceId(userId); + return createDatabaseUri(databaseId) + "/" + Constants$1.Path.UsersPathSegment + "/" + userId; +} +/** + * Given a database and collection id, this creates a collection link. + * Would be used when creating an Attachment, or when replacing + * or deleting a Document in Azure Cosmos DB database service + * @param databaseId - The database id + * @param collectionId - The collection id + * @param documentId - The document id + * @returns A document link in the format of + * `dbs/{0}/colls/{1}/docs/{2}` with `{0}` being a Uri escaped version of + * the databaseId, `{1}` being collectionId and `{2}` being the documentId + * @hidden + */ +function createDocumentUri(databaseId, collectionId, documentId) { + documentId = trimSlashFromLeftAndRight(documentId); + validateItemResourceId(documentId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants$1.Path.DocumentsPathSegment + + "/" + + documentId); +} +/** + * Given a database, collection and document id, this creates a document link. + * Would be used when replacing or deleting a Permission in Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param userId -The user Id + * @param permissionId - The permissionId + * @returns A permission link in the format of `dbs/{0}/users/{1}/permissions/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being userId and `{2}` being permissionId + * @hidden + */ +function createPermissionUri(databaseId, userId, permissionId) { + permissionId = trimSlashFromLeftAndRight(permissionId); + validateResourceId(permissionId); + return (createUserUri(databaseId, userId) + + "/" + + Constants$1.Path.PermissionsPathSegment + + "/" + + permissionId); +} +/** + * Given a database, collection and stored proc id, this creates a stored proc link. + * Would be used when replacing, executing, or deleting a StoredProcedure in + * Azure Cosmos DB database service. + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param storedProcedureId -The stored procedure Id + * @returns A stored procedure link in the format of + * `dbs/{0}/colls/{1}/sprocs/{2}` with `{0}` being a Uri escaped version of the databaseId, + * `{1}` being collectionId and `{2}` being the storedProcedureId + * @hidden + */ +function createStoredProcedureUri(databaseId, collectionId, storedProcedureId) { + storedProcedureId = trimSlashFromLeftAndRight(storedProcedureId); + validateResourceId(storedProcedureId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants$1.Path.StoredProceduresPathSegment + + "/" + + storedProcedureId); +} +/** + * Given a database, collection and trigger id, this creates a trigger link. + * Would be used when replacing, executing, or deleting a Trigger in Azure Cosmos DB database service + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param triggerId -The trigger Id + * @returns A trigger link in the format of + * `dbs/{0}/colls/{1}/triggers/{2}` with `{0}` being a Uri escaped version of the databaseId, + * `{1}` being collectionId and `{2}` being the triggerId + * @hidden + */ +function createTriggerUri(databaseId, collectionId, triggerId) { + triggerId = trimSlashFromLeftAndRight(triggerId); + validateResourceId(triggerId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants$1.Path.TriggersPathSegment + + "/" + + triggerId); +} +/** + * Given a database, collection and udf id, this creates a udf link. + * Would be used when replacing, executing, or deleting a UserDefinedFunction in + * Azure Cosmos DB database service + * @param databaseId -The database Id + * @param collectionId -The collection Id + * @param udfId -The User Defined Function Id + * @returns A udf link in the format of `dbs/{0}/colls/{1}/udfs/{2}` + * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the udfId + * @hidden + */ +function createUserDefinedFunctionUri(databaseId, collectionId, udfId) { + udfId = trimSlashFromLeftAndRight(udfId); + validateResourceId(udfId); + return (createDocumentCollectionUri(databaseId, collectionId) + + "/" + + Constants$1.Path.UserDefinedFunctionsPathSegment + + "/" + + udfId); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * @hidden + * Specifies Net RUConsumed + */ +class RUConsumedManager { + constructor() { + this.ruConsumed = 0; + this.semaphore = semaphore(1); + } + getRUConsumed() { + return new Promise((resolve) => { + this.semaphore.take(() => { + this.semaphore.leave(); + resolve(this.ruConsumed); + }); + }); + } + addToRUConsumed(value) { + return new Promise((resolve) => { + this.semaphore.take(() => { + this.ruConsumed += value; + this.semaphore.leave(); + resolve(); + }); + }); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +async function hmac(key, message) { + return crypto.createHmac("sha256", Buffer.from(key, "base64")).update(message).digest("base64"); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +async function generateHeaders(masterKey, method, resourceType = exports.ResourceType.none, resourceId = "", date = new Date()) { + if (masterKey.startsWith("type=sas&")) { + return { + [Constants$1.HttpHeaders.Authorization]: encodeURIComponent(masterKey), + [Constants$1.HttpHeaders.XDate]: date.toUTCString(), + }; + } + const sig = await signature(masterKey, method, resourceType, resourceId, date); + return { + [Constants$1.HttpHeaders.Authorization]: sig, + [Constants$1.HttpHeaders.XDate]: date.toUTCString(), + }; +} +async function signature(masterKey, method, resourceType, resourceId = "", date = new Date()) { + const type = "master"; + const version = "1.0"; + const text = method.toLowerCase() + + "\n" + + resourceType.toLowerCase() + + "\n" + + resourceId + + "\n" + + date.toUTCString().toLowerCase() + + "\n" + + "" + + "\n"; + const signed = await hmac(masterKey, text); + return encodeURIComponent("type=" + type + "&ver=" + version + "&sig=" + signed); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +async function setAuthorizationHeader(clientOptions, verb, path, resourceId, resourceType, headers) { + if (clientOptions.permissionFeed) { + clientOptions.resourceTokens = {}; + for (const permission of clientOptions.permissionFeed) { + const id = getResourceIdFromPath(permission.resource); + if (!id) { + throw new Error(`authorization error: ${id} \ + is an invalid resourceId in permissionFeed`); + } + clientOptions.resourceTokens[id] = permission._token; // TODO: any + } + } + if (clientOptions.key) { + await setAuthorizationTokenHeaderUsingMasterKey(verb, resourceId, resourceType, headers, clientOptions.key); + } + else if (clientOptions.resourceTokens) { + headers[Constants$1.HttpHeaders.Authorization] = encodeURIComponent(getAuthorizationTokenUsingResourceTokens(clientOptions.resourceTokens, path, resourceId)); + } + else if (clientOptions.tokenProvider) { + headers[Constants$1.HttpHeaders.Authorization] = encodeURIComponent(await clientOptions.tokenProvider({ verb, path, resourceId, resourceType, headers })); + } +} +/** + * The default function for setting header token using the masterKey + * @hidden + */ +async function setAuthorizationTokenHeaderUsingMasterKey(verb, resourceId, resourceType, headers, masterKey) { + // TODO This should live in cosmos-sign + if (resourceType === exports.ResourceType.offer) { + resourceId = resourceId && resourceId.toLowerCase(); + } + headers = Object.assign(headers, await generateHeaders(masterKey, verb, resourceType, resourceId)); +} +/** + * @hidden + */ +// TODO: Resource tokens +function getAuthorizationTokenUsingResourceTokens(resourceTokens, path, resourceId) { + if (resourceTokens && Object.keys(resourceTokens).length > 0) { + // For database account access(through getDatabaseAccount API), path and resourceId are "", + // so in this case we return the first token to be used for creating the auth header as the + // service will accept any token in this case + if (!path && !resourceId) { + return resourceTokens[Object.keys(resourceTokens)[0]]; + } + // If we have exact resource token for the path use it + if (resourceId && resourceTokens[resourceId]) { + return resourceTokens[resourceId]; + } + // minimum valid path /dbs + if (!path || path.length < 4) { + // TODO: This should throw an error + return null; + } + path = trimSlashFromLeftAndRight(path); + const pathSegments = (path && path.split("/")) || []; + // Item path + if (pathSegments.length === 6) { + // Look for a container token matching the item path + const containerPath = pathSegments.slice(0, 4).map(decodeURIComponent).join("/"); + if (resourceTokens[containerPath]) { + return resourceTokens[containerPath]; + } + } + // TODO remove in v4: This is legacy behavior that lets someone use a resource token pointing ONLY at an ID + // It was used when _rid was exposed by the SDK, but now that we are using user provided ids it is not needed + // However removing it now would be a breaking change + // if it's an incomplete path like /dbs/db1/colls/, start from the parent resource + let index = pathSegments.length % 2 === 0 ? pathSegments.length - 1 : pathSegments.length - 2; + for (; index > 0; index -= 2) { + const id = decodeURI(pathSegments[index]); + if (resourceTokens[id]) { + return resourceTokens[id]; + } + } + } + // TODO: This should throw an error + return null; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */ +exports.ConnectionMode = void 0; +(function (ConnectionMode) { + /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */ + ConnectionMode[ConnectionMode["Gateway"] = 0] = "Gateway"; +})(exports.ConnectionMode || (exports.ConnectionMode = {})); + +/** + * @hidden + */ +const defaultConnectionPolicy = Object.freeze({ + connectionMode: exports.ConnectionMode.Gateway, + requestTimeout: 60000, + enableEndpointDiscovery: true, + preferredLocations: [], + retryOptions: { + maxRetryAttemptCount: 9, + fixedRetryIntervalInMilliseconds: 0, + maxWaitTimeInSeconds: 30, + }, + useMultipleWriteLocations: true, + endpointRefreshRateInMs: 300000, + enableBackgroundEndpointRefreshing: true, +}); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Represents the consistency levels supported for Azure Cosmos DB client operations.
+ * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. + * Consistency levels. + * + * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual. + * + * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels. + */ +exports.ConsistencyLevel = void 0; +(function (ConsistencyLevel) { + /** + * Strong Consistency guarantees that read operations always return the value that was last written. + */ + ConsistencyLevel["Strong"] = "Strong"; + /** + * Bounded Staleness guarantees that reads are not too out-of-date. + * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds). + */ + ConsistencyLevel["BoundedStaleness"] = "BoundedStaleness"; + /** + * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), + * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads) + * within any single session. + */ + ConsistencyLevel["Session"] = "Session"; + /** + * Eventual Consistency guarantees that reads will return a subset of writes. + * All writes will be eventually be available for reads. + */ + ConsistencyLevel["Eventual"] = "Eventual"; + /** + * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. + * All writes will be eventually be available for reads. + */ + ConsistencyLevel["ConsistentPrefix"] = "ConsistentPrefix"; +})(exports.ConsistencyLevel || (exports.ConsistencyLevel = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Represents a DatabaseAccount in the Azure Cosmos DB database service. + */ +class DatabaseAccount { + /** + * The self-link for Databases in the databaseAccount. + * @deprecated Use `databasesLink` + */ + get DatabasesLink() { + return this.databasesLink; + } + /** + * The self-link for Media in the databaseAccount. + * @deprecated Use `mediaLink` + */ + get MediaLink() { + return this.mediaLink; + } + /** + * Attachment content (media) storage quota in MBs ( Retrieved from gateway ). + * @deprecated use `maxMediaStorageUsageInMB` + */ + get MaxMediaStorageUsageInMB() { + return this.maxMediaStorageUsageInMB; + } + /** + * Current attachment content (media) usage in MBs (Retrieved from gateway ) + * + * Value is returned from cached information updated periodically and is not guaranteed + * to be real time. + * + * @deprecated use `currentMediaStorageUsageInMB` + */ + get CurrentMediaStorageUsageInMB() { + return this.currentMediaStorageUsageInMB; + } + /** + * Gets the UserConsistencyPolicy settings. + * @deprecated use `consistencyPolicy` + */ + get ConsistencyPolicy() { + return this.consistencyPolicy; + } + // TODO: body - any + constructor(body, headers) { + /** The list of writable locations for a geo-replicated database account. */ + this.writableLocations = []; + /** The list of readable locations for a geo-replicated database account. */ + this.readableLocations = []; + this.databasesLink = "/dbs/"; + this.mediaLink = "/media/"; + this.maxMediaStorageUsageInMB = headers[Constants$1.HttpHeaders.MaxMediaStorageUsageInMB]; + this.currentMediaStorageUsageInMB = headers[Constants$1.HttpHeaders.CurrentMediaStorageUsageInMB]; + this.consistencyPolicy = body.userConsistencyPolicy + ? body.userConsistencyPolicy.defaultConsistencyLevel + : exports.ConsistencyLevel.Session; + if (body[Constants$1.WritableLocations] && body.id !== "localhost") { + this.writableLocations = body[Constants$1.WritableLocations]; + } + if (body[Constants$1.ReadableLocations] && body.id !== "localhost") { + this.readableLocations = body[Constants$1.ReadableLocations]; + } + if (body[Constants$1.ENABLE_MULTIPLE_WRITABLE_LOCATIONS]) { + this.enableMultipleWritableLocations = + body[Constants$1.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === true || + body[Constants$1.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === "true"; + } + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** Defines a target data type of an index path specification in the Azure Cosmos DB service. */ +exports.DataType = void 0; +(function (DataType) { + /** Represents a numeric data type. */ + DataType["Number"] = "Number"; + /** Represents a string data type. */ + DataType["String"] = "String"; + /** Represents a point data type. */ + DataType["Point"] = "Point"; + /** Represents a line string data type. */ + DataType["LineString"] = "LineString"; + /** Represents a polygon data type. */ + DataType["Polygon"] = "Polygon"; + /** Represents a multi-polygon data type. */ + DataType["MultiPolygon"] = "MultiPolygon"; +})(exports.DataType || (exports.DataType = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Specifies the supported indexing modes. + */ +exports.IndexingMode = void 0; +(function (IndexingMode) { + /** + * Index is updated synchronously with a create or update operation. + * + * With consistent indexing, query behavior is the same as the default consistency level for the container. + * The index is always kept up to date with the data. + */ + IndexingMode["consistent"] = "consistent"; + /** + * Index is updated asynchronously with respect to a create or update operation. + * + * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle. + */ + IndexingMode["lazy"] = "lazy"; + /** No Index is provided. */ + IndexingMode["none"] = "none"; +})(exports.IndexingMode || (exports.IndexingMode = {})); + +/* The target data type of a spatial path */ +exports.SpatialType = void 0; +(function (SpatialType) { + SpatialType["LineString"] = "LineString"; + SpatialType["MultiPolygon"] = "MultiPolygon"; + SpatialType["Point"] = "Point"; + SpatialType["Polygon"] = "Polygon"; +})(exports.SpatialType || (exports.SpatialType = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Specifies the supported Index types. + */ +exports.IndexKind = void 0; +(function (IndexKind) { + /** + * This is supplied for a path which requires sorting. + */ + IndexKind["Range"] = "Range"; + /** + * This is supplied for a path which requires geospatial indexing. + */ + IndexKind["Spatial"] = "Spatial"; +})(exports.IndexKind || (exports.IndexKind = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * None PartitionKey Literal + */ +const NonePartitionKeyLiteral = {}; +/** + * @hidden + * Null PartitionKey Literal + */ +const NullPartitionKeyLiteral = null; +/** + * @hidden + * Maps PartitionKey to InternalPartitionKey. + * @param partitionKey - PartitonKey to be converted. + * @returns PartitionKeyInternal + */ +function convertToInternalPartitionKey(partitionKey) { + if (Array.isArray(partitionKey)) { + return partitionKey.map((key) => (key === undefined ? NonePartitionKeyLiteral : key)); + } + else + return [partitionKey]; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Builder class for building PartitionKey. + */ +class PartitionKeyBuilder { + constructor() { + this.values = []; + } + addValue(value) { + this.values.push(value); + return this; + } + addNullValue() { + this.values.push(NullPartitionKeyLiteral); + return this; + } + addNoneValue() { + this.values.push(NonePartitionKeyLiteral); + return this; + } + build() { + return [...this.values]; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * PartitionKey Definition Version + */ +exports.PartitionKeyDefinitionVersion = void 0; +(function (PartitionKeyDefinitionVersion) { + PartitionKeyDefinitionVersion[PartitionKeyDefinitionVersion["V1"] = 1] = "V1"; + PartitionKeyDefinitionVersion[PartitionKeyDefinitionVersion["V2"] = 2] = "V2"; +})(exports.PartitionKeyDefinitionVersion || (exports.PartitionKeyDefinitionVersion = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Type of PartitionKey i.e. Hash, MultiHash + */ +exports.PartitionKeyKind = void 0; +(function (PartitionKeyKind) { + PartitionKeyKind["Hash"] = "Hash"; + PartitionKeyKind["MultiHash"] = "MultiHash"; +})(exports.PartitionKeyKind || (exports.PartitionKeyKind = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for permission mode values. + */ +exports.PermissionMode = void 0; +(function (PermissionMode) { + /** Permission not valid. */ + PermissionMode["None"] = "none"; + /** Permission applicable for read operations only. */ + PermissionMode["Read"] = "read"; + /** Permission applicable for all operations. */ + PermissionMode["All"] = "all"; +})(exports.PermissionMode || (exports.PermissionMode = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Represents Priority Level associated with each Azure Cosmos DB client requests.
+ * The Low priority requests are always throttled before any High priority requests. + * + * By default all requests are considered as High priority requests. + * + * See https://aka.ms/CosmosDB/PriorityBasedExecution for more detailed documentation on Priority based throttling. + */ +exports.PriorityLevel = void 0; +(function (PriorityLevel) { + /** + * High Priority requests are throttled after Low priority requests. + */ + PriorityLevel["High"] = "High"; + /** + * Low Priority requests are throttled before High priority requests. + */ + PriorityLevel["Low"] = "Low"; +})(exports.PriorityLevel || (exports.PriorityLevel = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for trigger operation values. + * specifies the operations on which a trigger should be executed. + */ +exports.TriggerOperation = void 0; +(function (TriggerOperation) { + /** All operations. */ + TriggerOperation["All"] = "all"; + /** Create operations only. */ + TriggerOperation["Create"] = "create"; + /** Update operations only. */ + TriggerOperation["Update"] = "update"; + /** Delete operations only. */ + TriggerOperation["Delete"] = "delete"; + /** Replace operations only. */ + TriggerOperation["Replace"] = "replace"; +})(exports.TriggerOperation || (exports.TriggerOperation = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for trigger type values. + * Specifies the type of the trigger. + */ +exports.TriggerType = void 0; +(function (TriggerType) { + /** Trigger should be executed before the associated operation(s). */ + TriggerType["Pre"] = "pre"; + /** Trigger should be executed after the associated operation(s). */ + TriggerType["Post"] = "post"; +})(exports.TriggerType || (exports.TriggerType = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum for udf type values. + * Specifies the types of user defined functions. + */ +exports.UserDefinedFunctionType = void 0; +(function (UserDefinedFunctionType) { + /** The User Defined Function is written in JavaScript. This is currently the only option. */ + UserDefinedFunctionType["Javascript"] = "Javascript"; +})(exports.UserDefinedFunctionType || (exports.UserDefinedFunctionType = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +exports.GeospatialType = void 0; +(function (GeospatialType) { + /** Represents data in round-earth coordinate system. */ + GeospatialType["Geography"] = "Geography"; + /** Represents data in Eucledian(flat) coordinate system. */ + GeospatialType["Geometry"] = "Geometry"; +})(exports.GeospatialType || (exports.GeospatialType = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const logger$4 = logger$5.createClientLogger("extractPartitionKey"); +/** + * Function to extract PartitionKey based on {@link PartitionKeyDefinition} + * from an object. + * Retuns + * 1. PartitionKeyInternal[] if extraction is successful. + * 2. undefined if either {@link partitionKeyDefinition} is not well formed + * or an unsupported partitionkey type is encountered. + * @hidden + */ +function extractPartitionKeys(document, partitionKeyDefinition) { + if (partitionKeyDefinition && + partitionKeyDefinition.paths && + partitionKeyDefinition.paths.length > 0) { + if (partitionKeyDefinition.systemKey === true) { + return []; + } + if (partitionKeyDefinition.paths.length === 1 && + partitionKeyDefinition.paths[0] === DEFAULT_PARTITION_KEY_PATH) { + return [extractPartitionKey(DEFAULT_PARTITION_KEY_PATH, document)]; + } + const partitionKeys = []; + partitionKeyDefinition.paths.forEach((path) => { + const obj = extractPartitionKey(path, document); + if (obj === undefined) { + logger$4.warning("Unsupported PartitionKey found."); + return undefined; + } + partitionKeys.push(obj); + }); + return partitionKeys; + } + logger$4.error("Unexpected Partition Key Definition Found."); + return undefined; +} +function extractPartitionKey(path, obj) { + const pathParts = parsePath(path); + for (const part of pathParts) { + if (typeof obj === "object" && obj !== null && part in obj) { + obj = obj[part]; + } + else { + obj = undefined; + break; + } + } + if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean") { + return obj; + } + else if (obj === NullPartitionKeyLiteral) { + return NullPartitionKeyLiteral; + } + else if (obj === undefined || JSON.stringify(obj) === JSON.stringify(NonePartitionKeyLiteral)) { + return NonePartitionKeyLiteral; + } + return undefined; +} +/** + * @hidden + */ +function undefinedPartitionKey(partitionKeyDefinition) { + if (partitionKeyDefinition.systemKey === true) { + return []; + } + else { + return partitionKeyDefinition.paths.map(() => NonePartitionKeyLiteral); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Utility function to avoid writing boilder plate code while checking for + * undefined values. It throws Error if the input value is undefined. + * @param value - Value which is potentially undefined. + * @param msg - Error Message to throw if value is undefined. + * @returns + */ +function assertNotUndefined(value, msg) { + if (value !== undefined) { + return value; + } + throw new Error(msg || "Unexpected 'undefined' value encountered"); +} +/** + * Check for value being PrimitivePartitionKeyValue. + * @internal + */ +function isPrimitivePartitionKeyValue(value) { + return (isWellDefinedPartitionKeyValue(value) || + isNonePartitionKeyValue(value) || + isNullPartitionKeyValue(value)); +} +/** + * Check for value being string, number or boolean. + * @internal + */ +function isWellDefinedPartitionKeyValue(value) { + return typeof value === "string" || typeof value === "boolean" || typeof value === "number"; +} +/** + * Check for value being NonePartitionKeyType. + * @internal + */ +function isNonePartitionKeyValue(value) { + return value !== undefined && JSON.stringify(value) === JSON.stringify(NonePartitionKeyLiteral); +} +/** + * Check for value being NullPartitionKeyType. + * @internal + */ +function isNullPartitionKeyValue(value) { + return value === NullPartitionKeyLiteral; +} +/** + * Verify validity of partition key. + * @internal + */ +function isPartitionKey(partitionKey) { + return isPrimitivePartitionKeyValue(partitionKey) || Array.isArray(partitionKey); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * The \@azure/logger configuration for this package. + */ +const defaultLogger = logger$5.createClientLogger("cosmosdb"); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// ---------------------------------------------------------------------------- +// Utility methods +// +/** @hidden */ +function javaScriptFriendlyJSONStringify(s) { + // two line terminators (Line separator and Paragraph separator) are not needed to be escaped in JSON + // but are needed to be escaped in JavaScript. + return JSON.stringify(s) + .replace(/\u2028/g, "\\u2028") + .replace(/\u2029/g, "\\u2029"); +} +/** @hidden */ +function bodyFromData(data) { + if (typeof data === "object") { + return javaScriptFriendlyJSONStringify(data); + } + return data; +} +const JsonContentType = "application/json"; +/** + * @hidden + */ +async function getHeaders({ clientOptions, defaultHeaders, verb, path, resourceId, resourceType, options = {}, partitionKeyRangeId, useMultipleWriteLocations, partitionKey, }) { + const headers = Object.assign({ [Constants$1.HttpHeaders.ResponseContinuationTokenLimitInKB]: 1, [Constants$1.HttpHeaders.EnableCrossPartitionQuery]: true }, defaultHeaders); + if (useMultipleWriteLocations) { + headers[Constants$1.HttpHeaders.ALLOW_MULTIPLE_WRITES] = true; + } + if (options.continuationTokenLimitInKB) { + headers[Constants$1.HttpHeaders.ResponseContinuationTokenLimitInKB] = + options.continuationTokenLimitInKB; + } + if (options.continuationToken) { + headers[Constants$1.HttpHeaders.Continuation] = options.continuationToken; + } + else if (options.continuation) { + headers[Constants$1.HttpHeaders.Continuation] = options.continuation; + } + if (options.preTriggerInclude) { + headers[Constants$1.HttpHeaders.PreTriggerInclude] = + options.preTriggerInclude.constructor === Array + ? options.preTriggerInclude.join(",") + : options.preTriggerInclude; + } + if (options.postTriggerInclude) { + headers[Constants$1.HttpHeaders.PostTriggerInclude] = + options.postTriggerInclude.constructor === Array + ? options.postTriggerInclude.join(",") + : options.postTriggerInclude; + } + if (options.offerType) { + headers[Constants$1.HttpHeaders.OfferType] = options.offerType; + } + if (options.offerThroughput) { + headers[Constants$1.HttpHeaders.OfferThroughput] = options.offerThroughput; + } + if (options.maxItemCount) { + headers[Constants$1.HttpHeaders.PageSize] = options.maxItemCount; + } + if (options.accessCondition) { + if (options.accessCondition.type === "IfMatch") { + headers[Constants$1.HttpHeaders.IfMatch] = options.accessCondition.condition; + } + else { + headers[Constants$1.HttpHeaders.IfNoneMatch] = options.accessCondition.condition; + } + } + if (options.useIncrementalFeed) { + headers[Constants$1.HttpHeaders.A_IM] = "Incremental Feed"; + } + if (options.indexingDirective) { + headers[Constants$1.HttpHeaders.IndexingDirective] = options.indexingDirective; + } + if (options.consistencyLevel) { + headers[Constants$1.HttpHeaders.ConsistencyLevel] = options.consistencyLevel; + } + if (options.priorityLevel) { + headers[Constants$1.HttpHeaders.PriorityLevel] = options.priorityLevel; + } + if (options.maxIntegratedCacheStalenessInMs && resourceType === exports.ResourceType.item) { + if (typeof options.maxIntegratedCacheStalenessInMs === "number") { + headers[Constants$1.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] = + options.maxIntegratedCacheStalenessInMs.toString(); + } + else { + defaultLogger.error(`RangeError: maxIntegratedCacheStalenessInMs "${options.maxIntegratedCacheStalenessInMs}" is not a valid parameter.`); + headers[Constants$1.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] = "null"; + } + } + if (options.resourceTokenExpirySeconds) { + headers[Constants$1.HttpHeaders.ResourceTokenExpiry] = options.resourceTokenExpirySeconds; + } + if (options.sessionToken) { + headers[Constants$1.HttpHeaders.SessionToken] = options.sessionToken; + } + if (options.enableScanInQuery) { + headers[Constants$1.HttpHeaders.EnableScanInQuery] = options.enableScanInQuery; + } + if (options.populateQuotaInfo) { + headers[Constants$1.HttpHeaders.PopulateQuotaInfo] = options.populateQuotaInfo; + } + if (options.populateQueryMetrics) { + headers[Constants$1.HttpHeaders.PopulateQueryMetrics] = options.populateQueryMetrics; + } + if (options.maxDegreeOfParallelism !== undefined) { + headers[Constants$1.HttpHeaders.ParallelizeCrossPartitionQuery] = true; + } + if (options.populateQuotaInfo) { + headers[Constants$1.HttpHeaders.PopulateQuotaInfo] = true; + } + if (partitionKey !== undefined && !headers[Constants$1.HttpHeaders.PartitionKey]) { + headers[Constants$1.HttpHeaders.PartitionKey] = jsonStringifyAndEscapeNonASCII(partitionKey); + } + if (clientOptions.key || clientOptions.tokenProvider) { + headers[Constants$1.HttpHeaders.XDate] = new Date().toUTCString(); + } + if (verb === exports.HTTPMethod.post || verb === exports.HTTPMethod.put) { + if (!headers[Constants$1.HttpHeaders.ContentType]) { + headers[Constants$1.HttpHeaders.ContentType] = JsonContentType; + } + } + if (!headers[Constants$1.HttpHeaders.Accept]) { + headers[Constants$1.HttpHeaders.Accept] = JsonContentType; + } + if (partitionKeyRangeId !== undefined) { + headers[Constants$1.HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId; + } + if (options.enableScriptLogging) { + headers[Constants$1.HttpHeaders.EnableScriptLogging] = options.enableScriptLogging; + } + if (options.disableRUPerMinuteUsage) { + headers[Constants$1.HttpHeaders.DisableRUPerMinuteUsage] = true; + } + if (options.populateIndexMetrics) { + headers[Constants$1.HttpHeaders.PopulateIndexMetrics] = options.populateIndexMetrics; + } + if (clientOptions.key || + clientOptions.resourceTokens || + clientOptions.tokenProvider || + clientOptions.permissionFeed) { + await setAuthorizationHeader(clientOptions, verb, path, resourceId, resourceType, headers); + } + return headers; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const uuid$2 = uuid$3.v4; +function isKeyInRange(min, max, key) { + const isAfterMinInclusive = key.localeCompare(min) >= 0; + const isBeforeMax = key.localeCompare(max) < 0; + return isAfterMinInclusive && isBeforeMax; +} +const BulkOperationType = { + Create: "Create", + Upsert: "Upsert", + Read: "Read", + Delete: "Delete", + Replace: "Replace", + Patch: "Patch", +}; +/** + * Maps OperationInput to Operation by + * - generating Ids if needed. + * - choosing partitionKey which can be used to choose which batch this + * operation should be part of. The order is - + * 1. If the operationInput itself has partitionKey field set it is used. + * 2. Other wise for create/replace/upsert it is extracted from resource body. + * 3. For read/delete/patch type operations undefined partitionKey is used. + * - Here one nuance is that, the partitionKey field inside Operation needs to + * be serialized as a JSON string. + * @param operationInput - OperationInput + * @param definition - PartitionKeyDefinition + * @param options - RequestOptions + * @returns + */ +function prepareOperations(operationInput, definition, options = {}) { + populateIdsIfNeeded(operationInput, options); + let partitionKey; + if (Object.prototype.hasOwnProperty.call(operationInput, "partitionKey")) { + if (operationInput.partitionKey === undefined) { + partitionKey = definition.paths.map(() => NonePartitionKeyLiteral); + } + else { + partitionKey = convertToInternalPartitionKey(operationInput.partitionKey); + } + } + else { + switch (operationInput.operationType) { + case BulkOperationType.Create: + case BulkOperationType.Replace: + case BulkOperationType.Upsert: + partitionKey = assertNotUndefined(extractPartitionKeys(operationInput.resourceBody, definition), "Unexpected undefined Partition Key Found."); + break; + case BulkOperationType.Read: + case BulkOperationType.Delete: + case BulkOperationType.Patch: + partitionKey = definition.paths.map(() => NonePartitionKeyLiteral); + } + } + return { + operation: Object.assign(Object.assign({}, operationInput), { partitionKey: JSON.stringify(partitionKey) }), + partitionKey, + }; +} +/** + * For operations requiring Id genrate random uuids. + * @param operationInput - OperationInput to be checked. + * @param options - RequestOptions + */ +function populateIdsIfNeeded(operationInput, options) { + if (operationInput.operationType === BulkOperationType.Create || + operationInput.operationType === BulkOperationType.Upsert) { + if ((operationInput.resourceBody.id === undefined || operationInput.resourceBody.id === "") && + !options.disableAutomaticIdGeneration) { + operationInput.resourceBody.id = uuid$2(); + } + } +} +/** + * Splits a batch into array of batches based on cumulative size of its operations by making sure + * cumulative size of an individual batch is not larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}. + * If a single operation itself is larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}, that + * operation would be moved into a batch containing only that operation. + * @param originalBatch - A batch of operations needed to be checked. + * @returns + * @hidden + */ +function splitBatchBasedOnBodySize(originalBatch) { + if ((originalBatch === null || originalBatch === void 0 ? void 0 : originalBatch.operations) === undefined || originalBatch.operations.length < 1) + return []; + let currentBatchSize = calculateObjectSizeInBytes(originalBatch.operations[0]); + let currentBatch = Object.assign(Object.assign({}, originalBatch), { operations: [originalBatch.operations[0]], indexes: [originalBatch.indexes[0]] }); + const processedBatches = []; + processedBatches.push(currentBatch); + for (let index = 1; index < originalBatch.operations.length; index++) { + const operation = originalBatch.operations[index]; + const currentOpSize = calculateObjectSizeInBytes(operation); + if (currentBatchSize + currentOpSize > Constants$1.DefaultMaxBulkRequestBodySizeInBytes) { + currentBatch = Object.assign(Object.assign({}, originalBatch), { operations: [], indexes: [] }); + processedBatches.push(currentBatch); + currentBatchSize = 0; + } + currentBatch.operations.push(operation); + currentBatch.indexes.push(originalBatch.indexes[index]); + currentBatchSize += currentOpSize; + } + return processedBatches; +} +/** + * Calculates size of an JSON object in bytes with utf-8 encoding. + * @hidden + */ +function calculateObjectSizeInBytes(obj) { + return new TextEncoder().encode(bodyFromData(obj)).length; +} +function decorateBatchOperation(operation, options = {}) { + if (operation.operationType === BulkOperationType.Create || + operation.operationType === BulkOperationType.Upsert) { + if ((operation.resourceBody.id === undefined || operation.resourceBody.id === "") && + !options.disableAutomaticIdGeneration) { + operation.resourceBody.id = uuid$2(); + } + } + return operation; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const PatchOperationType = { + add: "add", + replace: "replace", + remove: "remove", + set: "set", + incr: "incr", +}; + +class ErrorResponse extends Error { +} + +class ResourceResponse { + constructor(resource, headers, statusCode, diagnostics, substatus) { + this.resource = resource; + this.headers = headers; + this.statusCode = statusCode; + this.diagnostics = diagnostics; + this.substatus = substatus; + } + get requestCharge() { + return Number(this.headers[Constants$1.HttpHeaders.RequestCharge]) || 0; + } + get activityId() { + return this.headers[Constants$1.HttpHeaders.ActivityId]; + } + get etag() { + return this.headers[Constants$1.HttpHeaders.ETag]; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class ClientSideMetrics { + constructor(requestCharge) { + this.requestCharge = requestCharge; + } + /** + * Adds one or more ClientSideMetrics to a copy of this instance and returns the result. + */ + add(...clientSideMetricsArray) { + let requestCharge = this.requestCharge; + for (const clientSideMetrics of clientSideMetricsArray) { + if (clientSideMetrics == null) { + throw new Error("clientSideMetrics has null or undefined item(s)"); + } + requestCharge += clientSideMetrics.requestCharge; + } + return new ClientSideMetrics(requestCharge); + } + static createFromArray(...clientSideMetricsArray) { + if (clientSideMetricsArray == null) { + throw new Error("clientSideMetricsArray is null or undefined item(s)"); + } + return this.zero.add(...clientSideMetricsArray); + } +} +ClientSideMetrics.zero = new ClientSideMetrics(0); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +var QueryMetricsConstants = { + // QueryMetrics + RetrievedDocumentCount: "retrievedDocumentCount", + RetrievedDocumentSize: "retrievedDocumentSize", + OutputDocumentCount: "outputDocumentCount", + OutputDocumentSize: "outputDocumentSize", + IndexHitRatio: "indexUtilizationRatio", + IndexHitDocumentCount: "indexHitDocumentCount", + TotalQueryExecutionTimeInMs: "totalExecutionTimeInMs", + // QueryPreparationTimes + QueryCompileTimeInMs: "queryCompileTimeInMs", + LogicalPlanBuildTimeInMs: "queryLogicalPlanBuildTimeInMs", + PhysicalPlanBuildTimeInMs: "queryPhysicalPlanBuildTimeInMs", + QueryOptimizationTimeInMs: "queryOptimizationTimeInMs", + // QueryTimes + IndexLookupTimeInMs: "indexLookupTimeInMs", + DocumentLoadTimeInMs: "documentLoadTimeInMs", + VMExecutionTimeInMs: "VMExecutionTimeInMs", + DocumentWriteTimeInMs: "writeOutputTimeInMs", + // RuntimeExecutionTimes + QueryEngineTimes: "queryEngineTimes", + SystemFunctionExecuteTimeInMs: "systemFunctionExecuteTimeInMs", + UserDefinedFunctionExecutionTimeInMs: "userFunctionExecuteTimeInMs", + // QueryMetrics Text + RetrievedDocumentCountText: "Retrieved Document Count", + RetrievedDocumentSizeText: "Retrieved Document Size", + OutputDocumentCountText: "Output Document Count", + OutputDocumentSizeText: "Output Document Size", + IndexUtilizationText: "Index Utilization", + TotalQueryExecutionTimeText: "Total Query Execution Time", + // QueryPreparationTimes Text + QueryPreparationTimesText: "Query Preparation Times", + QueryCompileTimeText: "Query Compilation Time", + LogicalPlanBuildTimeText: "Logical Plan Build Time", + PhysicalPlanBuildTimeText: "Physical Plan Build Time", + QueryOptimizationTimeText: "Query Optimization Time", + // QueryTimes Text + QueryEngineTimesText: "Query Engine Times", + IndexLookupTimeText: "Index Lookup Time", + DocumentLoadTimeText: "Document Load Time", + WriteOutputTimeText: "Document Write Time", + // RuntimeExecutionTimes Text + RuntimeExecutionTimesText: "Runtime Execution Times", + TotalExecutionTimeText: "Query Engine Execution Time", + SystemFunctionExecuteTimeText: "System Function Execution Time", + UserDefinedFunctionExecutionTimeText: "User-defined Function Execution Time", + // ClientSideQueryMetrics Text + ClientSideQueryMetricsText: "Client Side Metrics", + RetriesText: "Retry Count", + RequestChargeText: "Request Charge", + FetchExecutionRangesText: "Partition Execution Timeline", + SchedulingMetricsText: "Scheduling Metrics", +}; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// Ported this implementation to javascript: +// https://referencesource.microsoft.com/#mscorlib/system/timespan.cs,83e476c1ae112117 +/** @hidden */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const ticksPerMillisecond = 10000; +/** @hidden */ +const millisecondsPerTick = 1.0 / ticksPerMillisecond; +/** @hidden */ +const ticksPerSecond = ticksPerMillisecond * 1000; // 10,000,000 +/** @hidden */ +const secondsPerTick = 1.0 / ticksPerSecond; // 0.0001 +/** @hidden */ +const ticksPerMinute = ticksPerSecond * 60; // 600,000,000 +/** @hidden */ +const minutesPerTick = 1.0 / ticksPerMinute; // 1.6666666666667e-9 +/** @hidden */ +const ticksPerHour = ticksPerMinute * 60; // 36,000,000,000 +/** @hidden */ +const hoursPerTick = 1.0 / ticksPerHour; // 2.77777777777777778e-11 +/** @hidden */ +const ticksPerDay = ticksPerHour * 24; // 864,000,000,000 +/** @hidden */ +const daysPerTick = 1.0 / ticksPerDay; // 1.1574074074074074074e-12 +/** @hidden */ +const millisPerSecond = 1000; +/** @hidden */ +const millisPerMinute = millisPerSecond * 60; // 60,000 +/** @hidden */ +const millisPerHour = millisPerMinute * 60; // 3,600,000 +/** @hidden */ +const millisPerDay = millisPerHour * 24; // 86,400,000 +/** @hidden */ +const maxMilliSeconds = Number.MAX_SAFE_INTEGER / ticksPerMillisecond; +/** @hidden */ +const minMilliSeconds = Number.MIN_SAFE_INTEGER / ticksPerMillisecond; +/** + * Represents a time interval. + * + * @param days - Number of days. + * @param hours - Number of hours. + * @param minutes - Number of minutes. + * @param seconds - Number of seconds. + * @param milliseconds - Number of milliseconds. + * @hidden + */ +class TimeSpan { + constructor(days, hours, minutes, seconds, milliseconds) { + // Constructor + if (!Number.isInteger(days)) { + throw new Error("days is not an integer"); + } + if (!Number.isInteger(hours)) { + throw new Error("hours is not an integer"); + } + if (!Number.isInteger(minutes)) { + throw new Error("minutes is not an integer"); + } + if (!Number.isInteger(seconds)) { + throw new Error("seconds is not an integer"); + } + if (!Number.isInteger(milliseconds)) { + throw new Error("milliseconds is not an integer"); + } + const totalMilliSeconds = (days * 3600 * 24 + hours * 3600 + minutes * 60 + seconds) * 1000 + milliseconds; + if (totalMilliSeconds > maxMilliSeconds || totalMilliSeconds < minMilliSeconds) { + throw new Error("Total number of milliseconds was either too large or too small"); + } + this._ticks = totalMilliSeconds * ticksPerMillisecond; + } + /** + * Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance. + * @param ts - The time interval to add. + */ + add(ts) { + if (TimeSpan.additionDoesOverflow(this._ticks, ts._ticks)) { + throw new Error("Adding the two timestamps causes an overflow."); + } + const results = this._ticks + ts._ticks; + return TimeSpan.fromTicks(results); + } + /** + * Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance. + * @param ts - The time interval to subtract. + */ + subtract(ts) { + if (TimeSpan.subtractionDoesUnderflow(this._ticks, ts._ticks)) { + throw new Error("Subtracting the two timestamps causes an underflow."); + } + const results = this._ticks - ts._ticks; + return TimeSpan.fromTicks(results); + } + /** + * Compares this instance to a specified object and returns an integer that indicates whether this + * instance is shorter than, equal to, or longer than the specified object. + * @param value - The time interval to add. + */ + compareTo(value) { + if (value == null) { + return 1; + } + if (!TimeSpan.isTimeSpan(value)) { + throw new Error("Argument must be a TimeSpan object"); + } + return TimeSpan.compare(this, value); + } + /** + * Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object. + */ + duration() { + return TimeSpan.fromTicks(this._ticks >= 0 ? this._ticks : -this._ticks); + } + /** + * Returns a value indicating whether this instance is equal to a specified object. + * @param value - The time interval to check for equality. + */ + equals(value) { + if (TimeSpan.isTimeSpan(value)) { + return this._ticks === value._ticks; + } + return false; + } + /** + * Returns a new TimeSpan object whose value is the negated value of this instance. + * @param value - The time interval to check for equality. + */ + negate() { + return TimeSpan.fromTicks(-this._ticks); + } + days() { + return Math.floor(this._ticks / ticksPerDay); + } + hours() { + return Math.floor(this._ticks / ticksPerHour); + } + milliseconds() { + return Math.floor(this._ticks / ticksPerMillisecond); + } + seconds() { + return Math.floor(this._ticks / ticksPerSecond); + } + ticks() { + return this._ticks; + } + totalDays() { + return this._ticks * daysPerTick; + } + totalHours() { + return this._ticks * hoursPerTick; + } + totalMilliseconds() { + return this._ticks * millisecondsPerTick; + } + totalMinutes() { + return this._ticks * minutesPerTick; + } + totalSeconds() { + return this._ticks * secondsPerTick; + } + static fromTicks(value) { + const timeSpan = new TimeSpan(0, 0, 0, 0, 0); + timeSpan._ticks = value; + return timeSpan; + } + static isTimeSpan(timespan) { + return timespan._ticks; + } + static additionDoesOverflow(a, b) { + const c = a + b; + return a !== c - b || b !== c - a; + } + static subtractionDoesUnderflow(a, b) { + const c = a - b; + return a !== c + b || b !== a - c; + } + static compare(t1, t2) { + if (t1._ticks > t2._ticks) { + return 1; + } + if (t1._ticks < t2._ticks) { + return -1; + } + return 0; + } + static interval(value, scale) { + if (isNaN(value)) { + throw new Error("value must be a number"); + } + const milliseconds = value * scale; + if (milliseconds > maxMilliSeconds || milliseconds < minMilliSeconds) { + throw new Error("timespan too long"); + } + return TimeSpan.fromTicks(Math.floor(milliseconds * ticksPerMillisecond)); + } + static fromMilliseconds(value) { + return TimeSpan.interval(value, 1); + } + static fromSeconds(value) { + return TimeSpan.interval(value, millisPerSecond); + } + static fromMinutes(value) { + return TimeSpan.interval(value, millisPerMinute); + } + static fromHours(value) { + return TimeSpan.interval(value, millisPerHour); + } + static fromDays(value) { + return TimeSpan.interval(value, millisPerDay); + } +} +TimeSpan.zero = new TimeSpan(0, 0, 0, 0, 0); +TimeSpan.maxValue = TimeSpan.fromTicks(Number.MAX_SAFE_INTEGER); +TimeSpan.minValue = TimeSpan.fromTicks(Number.MIN_SAFE_INTEGER); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +function parseDelimitedString(delimitedString) { + if (delimitedString == null) { + throw new Error("delimitedString is null or undefined"); + } + const metrics = {}; + const headerAttributes = delimitedString.split(";"); + for (const attribute of headerAttributes) { + const attributeKeyValue = attribute.split("="); + if (attributeKeyValue.length !== 2) { + throw new Error("recieved a malformed delimited string"); + } + const attributeKey = attributeKeyValue[0]; + const attributeValue = parseFloat(attributeKeyValue[1]); + metrics[attributeKey] = attributeValue; + } + return metrics; +} +/** + * @hidden + */ +function timeSpanFromMetrics(metrics /* TODO: any */, key) { + if (key in metrics) { + return TimeSpan.fromMilliseconds(metrics[key]); + } + return TimeSpan.zero; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class QueryPreparationTimes { + constructor(queryCompilationTime, logicalPlanBuildTime, physicalPlanBuildTime, queryOptimizationTime) { + this.queryCompilationTime = queryCompilationTime; + this.logicalPlanBuildTime = logicalPlanBuildTime; + this.physicalPlanBuildTime = physicalPlanBuildTime; + this.queryOptimizationTime = queryOptimizationTime; + } + /** + * returns a new QueryPreparationTimes instance that is the addition of this and the arguments. + */ + add(...queryPreparationTimesArray) { + let queryCompilationTime = this.queryCompilationTime; + let logicalPlanBuildTime = this.logicalPlanBuildTime; + let physicalPlanBuildTime = this.physicalPlanBuildTime; + let queryOptimizationTime = this.queryOptimizationTime; + for (const queryPreparationTimes of queryPreparationTimesArray) { + if (queryPreparationTimes == null) { + throw new Error("queryPreparationTimesArray has null or undefined item(s)"); + } + queryCompilationTime = queryCompilationTime.add(queryPreparationTimes.queryCompilationTime); + logicalPlanBuildTime = logicalPlanBuildTime.add(queryPreparationTimes.logicalPlanBuildTime); + physicalPlanBuildTime = physicalPlanBuildTime.add(queryPreparationTimes.physicalPlanBuildTime); + queryOptimizationTime = queryOptimizationTime.add(queryPreparationTimes.queryOptimizationTime); + } + return new QueryPreparationTimes(queryCompilationTime, logicalPlanBuildTime, physicalPlanBuildTime, queryOptimizationTime); + } + /** + * Output the QueryPreparationTimes as a delimited string. + */ + toDelimitedString() { + return (`${QueryMetricsConstants.QueryCompileTimeInMs}=${this.queryCompilationTime.totalMilliseconds()};` + + `${QueryMetricsConstants.LogicalPlanBuildTimeInMs}=${this.logicalPlanBuildTime.totalMilliseconds()};` + + `${QueryMetricsConstants.PhysicalPlanBuildTimeInMs}=${this.physicalPlanBuildTime.totalMilliseconds()};` + + `${QueryMetricsConstants.QueryOptimizationTimeInMs}=${this.queryOptimizationTime.totalMilliseconds()}`); + } + /** + * Returns a new instance of the QueryPreparationTimes class that is the + * aggregation of an array of QueryPreparationTimes. + */ + static createFromArray(queryPreparationTimesArray) { + if (queryPreparationTimesArray == null) { + throw new Error("queryPreparationTimesArray is null or undefined item(s)"); + } + return QueryPreparationTimes.zero.add(...queryPreparationTimesArray); + } + /** + * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString) { + const metrics = parseDelimitedString(delimitedString); + return new QueryPreparationTimes(timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryCompileTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.LogicalPlanBuildTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.PhysicalPlanBuildTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryOptimizationTimeInMs)); + } +} +QueryPreparationTimes.zero = new QueryPreparationTimes(TimeSpan.zero, TimeSpan.zero, TimeSpan.zero, TimeSpan.zero); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class RuntimeExecutionTimes { + constructor(queryEngineExecutionTime, systemFunctionExecutionTime, userDefinedFunctionExecutionTime) { + this.queryEngineExecutionTime = queryEngineExecutionTime; + this.systemFunctionExecutionTime = systemFunctionExecutionTime; + this.userDefinedFunctionExecutionTime = userDefinedFunctionExecutionTime; + } + /** + * returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments. + */ + add(...runtimeExecutionTimesArray) { + let queryEngineExecutionTime = this.queryEngineExecutionTime; + let systemFunctionExecutionTime = this.systemFunctionExecutionTime; + let userDefinedFunctionExecutionTime = this.userDefinedFunctionExecutionTime; + for (const runtimeExecutionTimes of runtimeExecutionTimesArray) { + if (runtimeExecutionTimes == null) { + throw new Error("runtimeExecutionTimes has null or undefined item(s)"); + } + queryEngineExecutionTime = queryEngineExecutionTime.add(runtimeExecutionTimes.queryEngineExecutionTime); + systemFunctionExecutionTime = systemFunctionExecutionTime.add(runtimeExecutionTimes.systemFunctionExecutionTime); + userDefinedFunctionExecutionTime = userDefinedFunctionExecutionTime.add(runtimeExecutionTimes.userDefinedFunctionExecutionTime); + } + return new RuntimeExecutionTimes(queryEngineExecutionTime, systemFunctionExecutionTime, userDefinedFunctionExecutionTime); + } + /** + * Output the RuntimeExecutionTimes as a delimited string. + */ + toDelimitedString() { + return (`${QueryMetricsConstants.SystemFunctionExecuteTimeInMs}=${this.systemFunctionExecutionTime.totalMilliseconds()};` + + `${QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs}=${this.userDefinedFunctionExecutionTime.totalMilliseconds()}`); + } + /** + * Returns a new instance of the RuntimeExecutionTimes class that is + * the aggregation of an array of RuntimeExecutionTimes. + */ + static createFromArray(runtimeExecutionTimesArray) { + if (runtimeExecutionTimesArray == null) { + throw new Error("runtimeExecutionTimesArray is null or undefined item(s)"); + } + return RuntimeExecutionTimes.zero.add(...runtimeExecutionTimesArray); + } + /** + * Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString) { + const metrics = parseDelimitedString(delimitedString); + const vmExecutionTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs); + const indexLookupTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs); + const documentLoadTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentLoadTimeInMs); + const documentWriteTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentWriteTimeInMs); + let queryEngineExecutionTime = TimeSpan.zero; + queryEngineExecutionTime = queryEngineExecutionTime.add(vmExecutionTime); + queryEngineExecutionTime = queryEngineExecutionTime.subtract(indexLookupTime); + queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentLoadTime); + queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentWriteTime); + return new RuntimeExecutionTimes(queryEngineExecutionTime, timeSpanFromMetrics(metrics, QueryMetricsConstants.SystemFunctionExecuteTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs)); + } +} +RuntimeExecutionTimes.zero = new RuntimeExecutionTimes(TimeSpan.zero, TimeSpan.zero, TimeSpan.zero); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class QueryMetrics { + constructor(retrievedDocumentCount, retrievedDocumentSize, outputDocumentCount, outputDocumentSize, indexHitDocumentCount, totalQueryExecutionTime, queryPreparationTimes, indexLookupTime, documentLoadTime, vmExecutionTime, runtimeExecutionTimes, documentWriteTime, clientSideMetrics) { + this.retrievedDocumentCount = retrievedDocumentCount; + this.retrievedDocumentSize = retrievedDocumentSize; + this.outputDocumentCount = outputDocumentCount; + this.outputDocumentSize = outputDocumentSize; + this.indexHitDocumentCount = indexHitDocumentCount; + this.totalQueryExecutionTime = totalQueryExecutionTime; + this.queryPreparationTimes = queryPreparationTimes; + this.indexLookupTime = indexLookupTime; + this.documentLoadTime = documentLoadTime; + this.vmExecutionTime = vmExecutionTime; + this.runtimeExecutionTimes = runtimeExecutionTimes; + this.documentWriteTime = documentWriteTime; + this.clientSideMetrics = clientSideMetrics; + } + /** + * Gets the IndexHitRatio + * @hidden + */ + get indexHitRatio() { + return this.retrievedDocumentCount === 0 + ? 1 + : this.indexHitDocumentCount / this.retrievedDocumentCount; + } + /** + * returns a new QueryMetrics instance that is the addition of this and the arguments. + */ + add(queryMetricsArray) { + let retrievedDocumentCount = 0; + let retrievedDocumentSize = 0; + let outputDocumentCount = 0; + let outputDocumentSize = 0; + let indexHitDocumentCount = 0; + let totalQueryExecutionTime = TimeSpan.zero; + const queryPreparationTimesArray = []; + let indexLookupTime = TimeSpan.zero; + let documentLoadTime = TimeSpan.zero; + let vmExecutionTime = TimeSpan.zero; + const runtimeExecutionTimesArray = []; + let documentWriteTime = TimeSpan.zero; + const clientSideQueryMetricsArray = []; + queryMetricsArray.push(this); + for (const queryMetrics of queryMetricsArray) { + if (queryMetrics) { + retrievedDocumentCount += queryMetrics.retrievedDocumentCount; + retrievedDocumentSize += queryMetrics.retrievedDocumentSize; + outputDocumentCount += queryMetrics.outputDocumentCount; + outputDocumentSize += queryMetrics.outputDocumentSize; + indexHitDocumentCount += queryMetrics.indexHitDocumentCount; + totalQueryExecutionTime = totalQueryExecutionTime.add(queryMetrics.totalQueryExecutionTime); + queryPreparationTimesArray.push(queryMetrics.queryPreparationTimes); + indexLookupTime = indexLookupTime.add(queryMetrics.indexLookupTime); + documentLoadTime = documentLoadTime.add(queryMetrics.documentLoadTime); + vmExecutionTime = vmExecutionTime.add(queryMetrics.vmExecutionTime); + runtimeExecutionTimesArray.push(queryMetrics.runtimeExecutionTimes); + documentWriteTime = documentWriteTime.add(queryMetrics.documentWriteTime); + clientSideQueryMetricsArray.push(queryMetrics.clientSideMetrics); + } + } + return new QueryMetrics(retrievedDocumentCount, retrievedDocumentSize, outputDocumentCount, outputDocumentSize, indexHitDocumentCount, totalQueryExecutionTime, QueryPreparationTimes.createFromArray(queryPreparationTimesArray), indexLookupTime, documentLoadTime, vmExecutionTime, RuntimeExecutionTimes.createFromArray(runtimeExecutionTimesArray), documentWriteTime, ClientSideMetrics.createFromArray(...clientSideQueryMetricsArray)); + } + /** + * Output the QueryMetrics as a delimited string. + * @hidden + */ + toDelimitedString() { + return (QueryMetricsConstants.RetrievedDocumentCount + + "=" + + this.retrievedDocumentCount + + ";" + + QueryMetricsConstants.RetrievedDocumentSize + + "=" + + this.retrievedDocumentSize + + ";" + + QueryMetricsConstants.OutputDocumentCount + + "=" + + this.outputDocumentCount + + ";" + + QueryMetricsConstants.OutputDocumentSize + + "=" + + this.outputDocumentSize + + ";" + + QueryMetricsConstants.IndexHitRatio + + "=" + + this.indexHitRatio + + ";" + + QueryMetricsConstants.TotalQueryExecutionTimeInMs + + "=" + + this.totalQueryExecutionTime.totalMilliseconds() + + ";" + + this.queryPreparationTimes.toDelimitedString() + + ";" + + QueryMetricsConstants.IndexLookupTimeInMs + + "=" + + this.indexLookupTime.totalMilliseconds() + + ";" + + QueryMetricsConstants.DocumentLoadTimeInMs + + "=" + + this.documentLoadTime.totalMilliseconds() + + ";" + + QueryMetricsConstants.VMExecutionTimeInMs + + "=" + + this.vmExecutionTime.totalMilliseconds() + + ";" + + this.runtimeExecutionTimes.toDelimitedString() + + ";" + + QueryMetricsConstants.DocumentWriteTimeInMs + + "=" + + this.documentWriteTime.totalMilliseconds()); + } + /** + * Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics. + */ + static createFromArray(queryMetricsArray) { + if (!queryMetricsArray) { + throw new Error("queryMetricsArray is null or undefined item(s)"); + } + return QueryMetrics.zero.add(queryMetricsArray); + } + /** + * Returns a new instance of the QueryMetrics class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString, clientSideMetrics) { + const metrics = parseDelimitedString(delimitedString); + const indexHitRatio = metrics[QueryMetricsConstants.IndexHitRatio] || 0; + const retrievedDocumentCount = metrics[QueryMetricsConstants.RetrievedDocumentCount] || 0; + const indexHitCount = indexHitRatio * retrievedDocumentCount; + const outputDocumentCount = metrics[QueryMetricsConstants.OutputDocumentCount] || 0; + const outputDocumentSize = metrics[QueryMetricsConstants.OutputDocumentSize] || 0; + const retrievedDocumentSize = metrics[QueryMetricsConstants.RetrievedDocumentSize] || 0; + const totalQueryExecutionTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.TotalQueryExecutionTimeInMs); + return new QueryMetrics(retrievedDocumentCount, retrievedDocumentSize, outputDocumentCount, outputDocumentSize, indexHitCount, totalQueryExecutionTime, QueryPreparationTimes.createFromDelimitedString(delimitedString), timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentLoadTimeInMs), timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs), RuntimeExecutionTimes.createFromDelimitedString(delimitedString), timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentWriteTimeInMs), clientSideMetrics || ClientSideMetrics.zero); + } +} +QueryMetrics.zero = new QueryMetrics(0, 0, 0, 0, 0, TimeSpan.zero, QueryPreparationTimes.zero, TimeSpan.zero, TimeSpan.zero, TimeSpan.zero, RuntimeExecutionTimes.zero, TimeSpan.zero, ClientSideMetrics.zero); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +// TODO: docs +function getRequestChargeIfAny(headers) { + if (typeof headers === "number") { + return headers; + } + else if (typeof headers === "string") { + return parseFloat(headers); + } + if (headers) { + const rc = headers[Constants$1.HttpHeaders.RequestCharge]; + if (rc) { + return parseFloat(rc); + } + else { + return 0; + } + } + else { + return 0; + } +} +/** + * @hidden + */ +function getInitialHeader() { + const headers = {}; + headers[Constants$1.HttpHeaders.RequestCharge] = 0; + headers[Constants$1.HttpHeaders.QueryMetrics] = {}; + return headers; +} +/** + * @hidden + */ +// TODO: The name of this method isn't very accurate to what it does +function mergeHeaders(headers, toBeMergedHeaders) { + if (headers[Constants$1.HttpHeaders.RequestCharge] === undefined) { + headers[Constants$1.HttpHeaders.RequestCharge] = 0; + } + if (headers[Constants$1.HttpHeaders.QueryMetrics] === undefined) { + headers[Constants$1.HttpHeaders.QueryMetrics] = QueryMetrics.zero; + } + if (!toBeMergedHeaders) { + return; + } + headers[Constants$1.HttpHeaders.RequestCharge] += getRequestChargeIfAny(toBeMergedHeaders); + if (toBeMergedHeaders[Constants$1.HttpHeaders.IsRUPerMinuteUsed]) { + headers[Constants$1.HttpHeaders.IsRUPerMinuteUsed] = + toBeMergedHeaders[Constants$1.HttpHeaders.IsRUPerMinuteUsed]; + } + if (Constants$1.HttpHeaders.QueryMetrics in toBeMergedHeaders) { + const headerQueryMetrics = headers[Constants$1.HttpHeaders.QueryMetrics]; + const toBeMergedHeaderQueryMetrics = toBeMergedHeaders[Constants$1.HttpHeaders.QueryMetrics]; + for (const partitionId in toBeMergedHeaderQueryMetrics) { + if (headerQueryMetrics[partitionId]) { + const combinedQueryMetrics = headerQueryMetrics[partitionId].add([ + toBeMergedHeaderQueryMetrics[partitionId], + ]); + headerQueryMetrics[partitionId] = combinedQueryMetrics; + } + else { + headerQueryMetrics[partitionId] = toBeMergedHeaderQueryMetrics[partitionId]; + } + } + } + if (Constants$1.HttpHeaders.IndexUtilization in toBeMergedHeaders) { + headers[Constants$1.HttpHeaders.IndexUtilization] = + toBeMergedHeaders[Constants$1.HttpHeaders.IndexUtilization]; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class IndexUtilizationInfo { + constructor(UtilizedSingleIndexes, PotentialSingleIndexes, UtilizedCompositeIndexes, PotentialCompositeIndexes) { + this.UtilizedSingleIndexes = UtilizedSingleIndexes; + this.PotentialSingleIndexes = PotentialSingleIndexes; + this.UtilizedCompositeIndexes = UtilizedCompositeIndexes; + this.PotentialCompositeIndexes = PotentialCompositeIndexes; + } + static tryCreateFromDelimitedBase64String(delimitedString, out) { + if (delimitedString == null) { + out.result = IndexUtilizationInfo.Empty; + return false; + } + return IndexUtilizationInfo.tryCreateFromDelimitedString(Buffer.from(delimitedString, "base64").toString(), out); + } + static tryCreateFromDelimitedString(delimitedString, out) { + if (delimitedString == null) { + out.result = IndexUtilizationInfo.Empty; + return false; + } + try { + out.result = JSON.parse(delimitedString) || IndexUtilizationInfo.Empty; + return true; + } + catch (error) { + out.result = IndexUtilizationInfo.Empty; + return false; + } + } + static createFromString(delimitedString, isBase64Encoded) { + var _a; + const result = { result: undefined }; + if (isBase64Encoded) { + IndexUtilizationInfo.tryCreateFromDelimitedBase64String(delimitedString, result); + } + else { + IndexUtilizationInfo.tryCreateFromDelimitedString(delimitedString, result); + } + return (_a = result.result) !== null && _a !== void 0 ? _a : IndexUtilizationInfo.Empty; + } +} +IndexUtilizationInfo.Empty = new IndexUtilizationInfo([], [], [], []); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +var Constants = { + IndexUtilizationInfo: "Index Utilization Information", + UtilizedSingleIndexes: "Utilized Single Indexes", + PotentialSingleIndexes: "Potential Single Indexes", + UtilizedCompositeIndexes: "Utilized Composite Indexes", + PotentialCompositeIndexes: "Potential Composite Indexes", + IndexExpression: "Index Spec", + IndexImpactScore: "Index Impact Score", + IndexUtilizationSeparator: "---", +}; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class IndexMetricWriter { + writeIndexMetrics(indexUtilizationInfo) { + let result = ""; + result = this.writeBeforeIndexUtilizationInfo(result); + result = this.writeIndexUtilizationInfo(result, indexUtilizationInfo); + result = this.writeAfterIndexUtilizationInfo(result); + return result; + } + writeBeforeIndexUtilizationInfo(result) { + result = this.appendNewlineToResult(result); + result = this.appendHeaderToResult(result, Constants.IndexUtilizationInfo, 0); + return result; + } + writeIndexUtilizationInfo(result, indexUtilizationInfo) { + result = this.appendHeaderToResult(result, Constants.UtilizedSingleIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedSingleIndexes) { + result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity); + } + result = this.appendHeaderToResult(result, Constants.PotentialSingleIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.PotentialSingleIndexes) { + result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity); + } + result = this.appendHeaderToResult(result, Constants.UtilizedCompositeIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedCompositeIndexes) { + result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity); + } + result = this.appendHeaderToResult(result, Constants.PotentialCompositeIndexes, 1); + for (const indexUtilizationEntity of indexUtilizationInfo.PotentialCompositeIndexes) { + result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity); + } + return result; + } + writeAfterIndexUtilizationInfo(result) { + return result; + } + writeSingleIndexUtilizationEntity(result, indexUtilizationEntity) { + result = this.appendHeaderToResult(result, `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpec}`, 2); + result = this.appendHeaderToResult(result, `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`, 2); + result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2); + return result; + } + writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity) { + result = this.appendHeaderToResult(result, `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpecs.join(", ")}`, 2); + result = this.appendHeaderToResult(result, `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`, 2); + result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2); + return result; + } + appendNewlineToResult(result) { + return this.appendHeaderToResult(result, "", 0); + } + appendHeaderToResult(result, headerTitle, indentLevel) { + const Indent = " "; + const header = `${Indent.repeat(indentLevel)}${headerTitle}\n`; + result += header; + return result; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class FeedResponse { + constructor(resources, headers, hasMoreResults, diagnostics) { + this.resources = resources; + this.headers = headers; + this.hasMoreResults = hasMoreResults; + this.diagnostics = diagnostics; + } + get continuation() { + return this.continuationToken; + } + get continuationToken() { + return this.headers[Constants$1.HttpHeaders.Continuation]; + } + get queryMetrics() { + return this.headers[Constants$1.HttpHeaders.QueryMetrics]; + } + get requestCharge() { + return getRequestChargeIfAny(this.headers); + } + get activityId() { + return this.headers[Constants$1.HttpHeaders.ActivityId]; + } + get indexMetrics() { + const writer = new IndexMetricWriter(); + const indexUtilizationInfo = IndexUtilizationInfo.createFromString(this.headers[Constants$1.HttpHeaders.IndexUtilization], true); + return writer.writeIndexMetrics(indexUtilizationInfo); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +const TimeoutErrorCode = "TimeoutError"; +class TimeoutError extends Error { + constructor(message = "Timeout Error") { + super(message); + this.code = TimeoutErrorCode; + this.name = TimeoutErrorCode; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +const RUCapPerOperationExceededErrorCode = "OPERATION_RU_LIMIT_EXCEEDED"; +class RUCapPerOperationExceededError extends ErrorResponse { + constructor(message = "Request Unit limit per Operation call exceeded", fetchedResults = []) { + super(message); + this.code = RUCapPerOperationExceededErrorCode; + this.code = RUCapPerOperationExceededErrorCode; + this.body = { + code: RUCapPerOperationExceededErrorCode, + message, + }; + this.fetchedResults = fetchedResults; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * Utility function to get currentTime in UTC milliseconds. + * @returns + */ +function getCurrentTimestampInMs() { + return Date.now(); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * Internal class to hold CosmosDiagnostic aggregate information all through the lifecycle of a request. + * This object gathers diagnostic information throughout Client operation which may span across multiple + * Server call, retries etc. + * Functions - recordFailedAttempt, recordMetaDataQuery, recordEndpointContactEvent are used to ingest + * data into the context. At the end of operation, getDiagnostics() is used to + * get final CosmosDiagnostic object. + */ +class CosmosDiagnosticContext { + constructor() { + this.failedAttempts = []; + this.metadataLookups = []; + this.gaterwayStatistics = []; + this.locationEndpointsContacted = new Set(); + this.requestStartTimeUTCinMs = getCurrentTimestampInMs(); + } + recordFailedAttempt(gaterwayStatistics, retryAttemptNumber) { + const attempt = { + attemptNumber: retryAttemptNumber, + startTimeUTCInMs: gaterwayStatistics.startTimeUTCInMs, + durationInMs: gaterwayStatistics.durationInMs, + statusCode: gaterwayStatistics.statusCode, + substatusCode: gaterwayStatistics.subStatusCode, + requestPayloadLengthInBytes: gaterwayStatistics.requestPayloadLengthInBytes, + responsePayloadLengthInBytes: gaterwayStatistics.responsePayloadLengthInBytes, + activityId: gaterwayStatistics.activityId, + operationType: gaterwayStatistics.operationType, + resourceType: gaterwayStatistics.resourceType, + }; + this.failedAttempts.push(attempt); + } + recordNetworkCall(gaterwayStatistics) { + this.gaterwayStatistics.push(gaterwayStatistics); + } + /** + * Merge given DiagnosticContext to current node's DiagnosticContext, Treating GatewayRequests of + * given DiagnosticContext, as metadata requests. + */ + mergeDiagnostics(childDiagnostics, metadataType) { + // Copy Location endpoints contacted. + childDiagnostics.locationEndpointsContacted.forEach((endpoint) => this.locationEndpointsContacted.add(endpoint)); + // Copy child nodes's GatewayStatistics to parent's metadata lookups. + childDiagnostics.gaterwayStatistics.forEach((gateway) => this.metadataLookups.push({ + activityId: gateway.activityId, + requestPayloadLengthInBytes: gateway.requestPayloadLengthInBytes, + responsePayloadLengthInBytes: gateway.responsePayloadLengthInBytes, + startTimeUTCInMs: gateway.startTimeUTCInMs, + operationType: gateway.operationType, + resourceType: gateway.resourceType, + durationInMs: gateway.durationInMs, + metaDataType: metadataType, + })); + // Copy child nodes's metadata lookups to parent's metadata lookups. + childDiagnostics.metadataLookups.forEach((lookup) => this.metadataLookups.push(lookup)); + // Copy child nodes's failed attempts to parent's failed attempts. + childDiagnostics.failedAttempts.forEach((lookup) => this.failedAttempts.push(lookup)); + } + getClientSideStats(endTimeUTCInMs = getCurrentTimestampInMs()) { + return { + requestStartTimeUTCInMs: this.requestStartTimeUTCinMs, + requestDurationInMs: endTimeUTCInMs - this.requestStartTimeUTCinMs, + totalRequestPayloadLengthInBytes: this.getTotalRequestPayloadLength(), + totalResponsePayloadLengthInBytes: this.getTotalResponsePayloadLength(), + locationEndpointsContacted: [...this.locationEndpointsContacted.values()], + metadataDiagnostics: { + metadataLookups: [...this.metadataLookups], + }, + retryDiagnostics: { + failedAttempts: [...this.failedAttempts], + }, + gatewayStatistics: this.gaterwayStatistics, + }; + } + getTotalRequestPayloadLength() { + let totalRequestPayloadLength = 0; + this.gaterwayStatistics.forEach((req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes)); + this.metadataLookups.forEach((req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes)); + this.failedAttempts.forEach((req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes)); + return totalRequestPayloadLength; + } + getTotalResponsePayloadLength() { + let totalResponsePayloadLength = 0; + this.gaterwayStatistics.forEach((req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes)); + this.metadataLookups.forEach((req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes)); + this.failedAttempts.forEach((req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes)); + return totalResponsePayloadLength; + } + recordEndpointResolution(location) { + this.locationEndpointsContacted.add(location); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create(). + * It has three members - + * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including - + * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls. + * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call. + * - retries + * - endpoints contacted. + * - request, response payload stats. + * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations + * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation. + * + * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be + * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`. + * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments. + * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used + * in production environment. + * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads. + * Is not meant to be used in production environment. + * 3. clientConfig - Captures information related to how client was configured during initialization. + */ +class CosmosDiagnostics { + /** + * @internal + */ + constructor(clientSideRequestStatistics, diagnosticNode, clientConfig) { + this.clientSideRequestStatistics = clientSideRequestStatistics; + this.diagnosticNode = diagnosticNode; + this.clientConfig = clientConfig; + } +} +/** + * This is enum for Type of Metadata lookups possible. + */ +exports.MetadataLookUpType = void 0; +(function (MetadataLookUpType) { + MetadataLookUpType["PartitionKeyRangeLookUp"] = "PARTITION_KEY_RANGE_LOOK_UP"; + MetadataLookUpType["DatabaseAccountLookUp"] = "DATABASE_ACCOUNT_LOOK_UP"; + MetadataLookUpType["QueryPlanLookUp"] = "QUERY_PLAN_LOOK_UP"; + MetadataLookUpType["DatabaseLookUp"] = "DATABASE_LOOK_UP"; + MetadataLookUpType["ContainerLookUp"] = "CONTAINER_LOOK_UP"; +})(exports.MetadataLookUpType || (exports.MetadataLookUpType = {})); +function getRootNode(node) { + if (node.parent) + return getRootNode(node.parent); + else + return node; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Cosmos DB Diagnostic Level + */ +exports.CosmosDbDiagnosticLevel = void 0; +(function (CosmosDbDiagnosticLevel) { + CosmosDbDiagnosticLevel["info"] = "info"; + CosmosDbDiagnosticLevel["debug"] = "debug"; + CosmosDbDiagnosticLevel["debugUnsafe"] = "debug-unsafe"; +})(exports.CosmosDbDiagnosticLevel || (exports.CosmosDbDiagnosticLevel = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +const CosmosDbDiagnosticLevelOrder = [ + exports.CosmosDbDiagnosticLevel.info, + exports.CosmosDbDiagnosticLevel.debug, + exports.CosmosDbDiagnosticLevel.debugUnsafe, +]; +/** + * @hidden + */ +function allowTracing(levelToCheck, clientDiagnosticLevel) { + const indexOfDiagnosticLevelToCheck = CosmosDbDiagnosticLevelOrder.indexOf(levelToCheck); + const indexOfClientDiagnosticLevel = CosmosDbDiagnosticLevelOrder.indexOf(clientDiagnosticLevel); + if (indexOfDiagnosticLevelToCheck === -1 || indexOfClientDiagnosticLevel === -1) { + return false; + } + return indexOfDiagnosticLevelToCheck <= indexOfClientDiagnosticLevel; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect + * diagnostic information throughout the lifetime of Diagnostic session. + * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart. + */ +class DiagnosticNodeInternal { + /** + * @internal + */ + constructor(diagnosticLevel, type, parent, data = {}, startTimeUTCInMs = getCurrentTimestampInMs(), ctx = new CosmosDiagnosticContext()) { + this.id = uuid$3.v4(); + this.nodeType = type; + this.startTimeUTCInMs = startTimeUTCInMs; + this.data = data; + this.children = []; + this.durationInMs = 0; + this.parent = parent; + this.diagnosticCtx = ctx; + this.diagnosticLevel = diagnosticLevel; + } + /** + * @internal + */ + addLog(msg) { + if (!this.data.log) { + this.data.log = []; + } + this.data.log.push(msg); + } + /** + * @internal + */ + sanitizeHeaders(headers) { + return headers; + } + /** + * Updated durationInMs for node, based on endTimeUTCInMs provided. + * @internal + */ + updateTimestamp(endTimeUTCInMs = getCurrentTimestampInMs()) { + this.durationInMs = endTimeUTCInMs - this.startTimeUTCInMs; + } + /** + * @internal + */ + recordSuccessfulNetworkCall(startTimeUTCInMs, requestContext, pipelineResponse, substatus, url) { + const responseHeaders = pipelineResponse.headers.toJSON(); + const gatewayRequest = { + activityId: responseHeaders[Constants$1.HttpHeaders.ActivityId], + startTimeUTCInMs, + durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs, + statusCode: pipelineResponse.status, + subStatusCode: substatus, + requestPayloadLengthInBytes: calculateRequestPayloadLength(requestContext), + responsePayloadLengthInBytes: calculateResponsePayloadLength(pipelineResponse), + operationType: requestContext.operationType, + resourceType: requestContext.resourceType, + partitionKeyRangeId: requestContext.partitionKeyRangeId, + }; + let requestData = { + OperationType: gatewayRequest.operationType, + resourceType: gatewayRequest.resourceType, + requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes, + }; + if (allowTracing(exports.CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) { + requestData = Object.assign(Object.assign({}, requestData), { headers: this.sanitizeHeaders(requestContext.headers), requestBody: requestContext.body, responseBody: pipelineResponse.bodyAsText, url: url }); + } + this.addData({ + requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes, + responsePayloadLengthInBytes: gatewayRequest.responsePayloadLengthInBytes, + startTimeUTCInMs: gatewayRequest.startTimeUTCInMs, + durationInMs: gatewayRequest.durationInMs, + requestData, + }); + this.diagnosticCtx.recordNetworkCall(gatewayRequest); + } + /** + * @internal + */ + recordFailedNetworkCall(startTimeUTCInMs, requestContext, retryAttemptNumber, statusCode, substatusCode, responseHeaders) { + this.addData({ failedAttempty: true }); + const requestPayloadLengthInBytes = calculateRequestPayloadLength(requestContext); + this.diagnosticCtx.recordFailedAttempt({ + activityId: responseHeaders[Constants$1.HttpHeaders.ActivityId], + startTimeUTCInMs, + durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs, + statusCode, + subStatusCode: substatusCode, + requestPayloadLengthInBytes, + responsePayloadLengthInBytes: 0, + operationType: requestContext.operationType, + resourceType: requestContext.resourceType, + }, retryAttemptNumber); + let requestData = { + OperationType: requestContext.operationType, + resourceType: requestContext.resourceType, + requestPayloadLengthInBytes, + }; + if (allowTracing(exports.CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) { + requestData = Object.assign(Object.assign({}, requestData), { headers: this.sanitizeHeaders(requestContext.headers), requestBody: requestContext.body, url: prepareURL(requestContext.endpoint, requestContext.path) }); + } + this.addData({ + failedAttempty: true, + requestData, + }); + } + /** + * @internal + */ + recordEndpointResolution(location) { + this.addData({ selectedLocation: location }); + this.diagnosticCtx.recordEndpointResolution(location); + } + /** + * @internal + */ + addData(data, msg, level = this.diagnosticLevel) { + if (level !== exports.CosmosDbDiagnosticLevel.info) { + this.data = Object.assign(Object.assign({}, this.data), data); + if (msg) { + this.addLog(msg); + } + } + } + /** + * Merge given DiagnosticNodeInternal's context to current node's DiagnosticContext, Treating GatewayRequests of + * given DiagnosticContext, as metadata requests. Given DiagnosticNodeInternal becomes a child of this node. + * @internal + */ + addChildNode(child, level, metadataType) { + this.diagnosticCtx.mergeDiagnostics(child.diagnosticCtx, metadataType); + if (allowTracing(level, this.diagnosticLevel)) { + child.parent = this; + this.children.push(child); + } + return child; + } + /** + * @internal + */ + initializeChildNode(type, level, data = {}) { + if (allowTracing(level, this.diagnosticLevel)) { + const child = new DiagnosticNodeInternal(this.diagnosticLevel, type, this, data, getCurrentTimestampInMs(), this.diagnosticCtx); + this.children.push(child); + return child; + } + else { + return this; + } + } + /** + * @internal + */ + recordQueryResult(resources, level) { + var _a; + if (allowTracing(level, this.diagnosticLevel)) { + const previousCount = (_a = this.data.queryRecordsRead) !== null && _a !== void 0 ? _a : 0; + if (Array.isArray(resources)) { + this.data.queryRecordsRead = previousCount + resources.length; + } + } + } + /** + * Convert DiagnosticNodeInternal (internal representation) to DiagnosticNode (public, sanitized representation) + * @internal + */ + toDiagnosticNode() { + return { + id: this.id, + nodeType: this.nodeType, + children: this.children.map((child) => child.toDiagnosticNode()), + data: this.data, + startTimeUTCInMs: this.startTimeUTCInMs, + durationInMs: this.durationInMs, + }; + } + /** + * Convert to CosmosDiagnostics + * @internal + */ + toDiagnostic(clientConfigDiagnostic) { + const rootNode = getRootNode(this); + const diagnostiNode = allowTracing(exports.CosmosDbDiagnosticLevel.debug, this.diagnosticLevel) + ? rootNode.toDiagnosticNode() + : undefined; + const clientConfig = allowTracing(exports.CosmosDbDiagnosticLevel.debug, this.diagnosticLevel) + ? clientConfigDiagnostic + : undefined; + const cosmosDiagnostic = new CosmosDiagnostics(this.diagnosticCtx.getClientSideStats(), diagnostiNode, clientConfig); + return cosmosDiagnostic; + } +} +/** + * @hidden + */ +exports.DiagnosticNodeType = void 0; +(function (DiagnosticNodeType) { + DiagnosticNodeType["CLIENT_REQUEST_NODE"] = "CLIENT_REQUEST_NODE"; + DiagnosticNodeType["METADATA_REQUEST_NODE"] = "METADATA_REQUEST_NODE"; + DiagnosticNodeType["HTTP_REQUEST"] = "HTTP_REQUEST"; + DiagnosticNodeType["BATCH_REQUEST"] = "BATCH_REQUEST"; + DiagnosticNodeType["PARALLEL_QUERY_NODE"] = "PARALLEL_QUERY_NODE"; + DiagnosticNodeType["DEFAULT_QUERY_NODE"] = "DEFAULT_QUERY_NODE"; + DiagnosticNodeType["QUERY_REPAIR_NODE"] = "QUERY_REPAIR_NODE"; + DiagnosticNodeType["BACKGROUND_REFRESH_THREAD"] = "BACKGROUND_REFRESH_THREAD"; + DiagnosticNodeType["REQUEST_ATTEMPTS"] = "REQUEST_ATTEMPTS"; +})(exports.DiagnosticNodeType || (exports.DiagnosticNodeType = {})); +function calculateResponsePayloadLength(response) { + var _a; + return ((_a = response === null || response === void 0 ? void 0 : response.bodyAsText) === null || _a === void 0 ? void 0 : _a.length) || 0; +} +function calculateRequestPayloadLength(requestContext) { + return requestContext.body ? requestContext.body.length : 0; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * Utility function to create an Empty CosmosDiagnostic object. + */ +function getEmptyCosmosDiagnostics() { + return new CosmosDiagnostics({ + requestDurationInMs: 0, + requestStartTimeUTCInMs: getCurrentTimestampInMs(), + totalRequestPayloadLengthInBytes: 0, + totalResponsePayloadLengthInBytes: 0, + locationEndpointsContacted: [], + retryDiagnostics: { + failedAttempts: [], + }, + metadataDiagnostics: { + metadataLookups: [], + }, + gatewayStatistics: [], + }, { + id: uuid$3.v4(), + nodeType: exports.DiagnosticNodeType.CLIENT_REQUEST_NODE, + children: [], + data: {}, + startTimeUTCInMs: getCurrentTimestampInMs(), + durationInMs: 0, + }); +} +/** + * A supporting utility wrapper function, to be used inside a diagnostic session started + * by `withDiagnostics` function. + * Created a Diagnostic node and add it as a child to existing diagnostic session. + * @hidden + */ +async function addDignosticChild(callback, node, type, data = {}) { + const childNode = node.initializeChildNode(type, exports.CosmosDbDiagnosticLevel.debug, data); + try { + const response = await callback(childNode); + childNode.updateTimestamp(); + return response; + } + catch (e) { + childNode.addData({ + failure: true, + }); + childNode.updateTimestamp(); + throw e; + } +} +/** + * A supporting utility wrapper function, to be used inside a diagnostic session started + * by `withDiagnostics` function. + * Treats requests originating in provided `callback` as metadata calls. + * To realize this, starts a temporary diagnostic session, after execution of callback is + * finished. Merges this temporary diagnostic session to the original diagnostic session + * represented by the input parameter `node`. + * @hidden + */ +async function withMetadataDiagnostics(callback, node, type) { + const diagnosticNodeForMetadataCall = new DiagnosticNodeInternal(node.diagnosticLevel, exports.DiagnosticNodeType.METADATA_REQUEST_NODE, null); + try { + const response = await callback(diagnosticNodeForMetadataCall); + node.addChildNode(diagnosticNodeForMetadataCall, exports.CosmosDbDiagnosticLevel.debug, type); + return response; + } + catch (e) { + node.addChildNode(diagnosticNodeForMetadataCall, exports.CosmosDbDiagnosticLevel.debug, type); + throw e; + } +} +/** + * Utility wrapper function to managed lifecycle of a Diagnostic session. + * Meant to be used at the root of the client operation. i.e. item.read(), + * queryIterator.fetchAll(). + * + * This utility starts a new diagnostic session. So using it any where else + * other than start of operation, will result is different diagnostic sessions. + * + * Workings : + * 1. Takes a callback function as input. + * 2. Creates a new instance of DiagnosticNodeInternal, which can be though as starting + * a new diagnostic session. + * 3. Executes the callback function. + * 4. If execution was successful. Converts DiagnosticNodeInternal to CosmosDiagnostics + * and injects it to the response object and returns this object. + * 5. If execution threw an exception. Sill converts DiagnosticNodeInternal to CosmosDiagnostics + * and injects it to the Error object, and rethrows the Error object. + * + * @hidden + */ +async function withDiagnostics(callback, clientContext, type = exports.DiagnosticNodeType.CLIENT_REQUEST_NODE) { + const diagnosticNode = new DiagnosticNodeInternal(clientContext.diagnosticLevel, type, null); + try { + const response = await callback(diagnosticNode); + diagnosticNode.updateTimestamp(); + const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig()); + if (typeof response === "object" && response !== null) { + response.diagnostics = diagnostics; + } + clientContext.recordDiagnostics(diagnostics); + return response; + } + catch (e) { + diagnosticNode.updateTimestamp(); + diagnosticNode.addData({ + failure: true, + }); + const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig()); + e.diagnostics = diagnostics; + clientContext.recordDiagnostics(diagnostics); + throw e; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const logger$3 = logger$5.createClientLogger("ClientContext"); +/** @hidden */ +var STATES; +(function (STATES) { + STATES["start"] = "start"; + STATES["inProgress"] = "inProgress"; + STATES["ended"] = "ended"; +})(STATES || (STATES = {})); +/** @hidden */ +class DefaultQueryExecutionContext { + get continuation() { + return this.continuationToken; + } + /** + * Provides the basic Query Execution Context. + * This wraps the internal logic query execution using provided fetch functions + * + * @param clientContext - Is used to read the partitionKeyRanges for split proofing + * @param query - A SQL query. + * @param options - Represents the feed options. + * @param fetchFunctions - A function to retrieve each page of data. + * An array of functions may be used to query more than one partition. + * @hidden + */ + constructor(options, fetchFunctions) { + this.resources = []; + this.currentIndex = 0; + this.currentPartitionIndex = 0; + this.fetchFunctions = Array.isArray(fetchFunctions) ? fetchFunctions : [fetchFunctions]; + this.options = options || {}; + this.continuationToken = this.options.continuationToken || this.options.continuation || null; + this.state = DefaultQueryExecutionContext.STATES.start; + } + /** + * Execute a provided callback on the next element in the execution context. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + ++this.currentIndex; + const response = await this.current(diagnosticNode, operationOptions, ruConsumedManager); + return response; + } + /** + * Retrieve the current element on the execution context. + */ + async current(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.currentIndex < this.resources.length) { + return { + result: this.resources[this.currentIndex], + headers: getInitialHeader(), + }; + } + if (this._canFetchMore()) { + const { result: resources, headers } = await this.fetchMore(diagnosticNode, operationOptions, ruConsumedManager); + this.resources = resources; + if (this.resources.length === 0) { + if (!this.continuationToken && this.currentPartitionIndex >= this.fetchFunctions.length) { + this.state = DefaultQueryExecutionContext.STATES.ended; + return { result: undefined, headers }; + } + else { + return this.current(diagnosticNode, operationOptions, ruConsumedManager); + } + } + return { result: this.resources[this.currentIndex], headers }; + } + else { + this.state = DefaultQueryExecutionContext.STATES.ended; + return { + result: undefined, + headers: getInitialHeader(), + }; + } + } + /** + * Determine if there are still remaining resources to processs based on + * the value of the continuation token or the elements remaining on the current batch in the execution context. + * + * @returns true if there is other elements to process in the DefaultQueryExecutionContext. + */ + hasMoreResults() { + return (this.state === DefaultQueryExecutionContext.STATES.start || + this.continuationToken !== undefined || + this.currentIndex < this.resources.length - 1 || + this.currentPartitionIndex < this.fetchFunctions.length); + } + /** + * Fetches the next batch of the feed and pass them as an array to a callback + */ + async fetchMore(diagnosticNode, operationOptions, ruConsumedManager) { + return addDignosticChild(async (childDiagnosticNode) => { + if (this.currentPartitionIndex >= this.fetchFunctions.length) { + return { + headers: getInitialHeader(), + result: undefined, + }; + } + // Keep to the original continuation and to restore the value after fetchFunction call + const originalContinuation = this.options.continuationToken || this.options.continuation; + this.options.continuationToken = this.continuationToken; + // Return undefined if there is no more results + if (this.currentPartitionIndex >= this.fetchFunctions.length) { + return { + headers: getInitialHeader(), + result: undefined, + }; + } + let resources; + let responseHeaders; + try { + let p; + if (this.nextFetchFunction !== undefined) { + logger$3.verbose("using prefetch"); + p = this.nextFetchFunction; + this.nextFetchFunction = undefined; + } + else { + logger$3.verbose("using fresh fetch"); + p = this.fetchFunctions[this.currentPartitionIndex](childDiagnosticNode, this.options); + } + const response = await p; + resources = response.result; + childDiagnosticNode.recordQueryResult(resources, exports.CosmosDbDiagnosticLevel.debugUnsafe); + responseHeaders = response.headers; + this.continuationToken = responseHeaders[Constants$1.HttpHeaders.Continuation]; + if (!this.continuationToken) { + ++this.currentPartitionIndex; + } + if (this.options && this.options.bufferItems === true) { + const fetchFunction = this.fetchFunctions[this.currentPartitionIndex]; + this.nextFetchFunction = fetchFunction + ? fetchFunction(childDiagnosticNode, Object.assign(Object.assign({}, this.options), { continuationToken: this.continuationToken })) + : undefined; + } + } + catch (err) { + this.state = DefaultQueryExecutionContext.STATES.ended; + // return callback(err, undefined, responseHeaders); + // TODO: Error and data being returned is an antipattern, this might broken + throw err; + } + this.state = DefaultQueryExecutionContext.STATES.inProgress; + this.currentIndex = 0; + this.options.continuationToken = originalContinuation; + this.options.continuation = originalContinuation; + // deserializing query metrics so that we aren't working with delimited strings in the rest of the code base + if (Constants$1.HttpHeaders.QueryMetrics in responseHeaders) { + const delimitedString = responseHeaders[Constants$1.HttpHeaders.QueryMetrics]; + let queryMetrics = QueryMetrics.createFromDelimitedString(delimitedString); + // Add the request charge to the query metrics so that we can have per partition request charge. + if (Constants$1.HttpHeaders.RequestCharge in responseHeaders) { + const requestCharge = Number(responseHeaders[Constants$1.HttpHeaders.RequestCharge]) || 0; + queryMetrics = new QueryMetrics(queryMetrics.retrievedDocumentCount, queryMetrics.retrievedDocumentSize, queryMetrics.outputDocumentCount, queryMetrics.outputDocumentSize, queryMetrics.indexHitDocumentCount, queryMetrics.totalQueryExecutionTime, queryMetrics.queryPreparationTimes, queryMetrics.indexLookupTime, queryMetrics.documentLoadTime, queryMetrics.vmExecutionTime, queryMetrics.runtimeExecutionTimes, queryMetrics.documentWriteTime, new ClientSideMetrics(requestCharge)); + } + // Wraping query metrics in a object where the key is '0' just so single partition + // and partition queries have the same response schema + responseHeaders[Constants$1.HttpHeaders.QueryMetrics] = {}; + responseHeaders[Constants$1.HttpHeaders.QueryMetrics]["0"] = queryMetrics; + } + if (operationOptions && operationOptions.ruCapPerOperation && ruConsumedManager) { + await ruConsumedManager.addToRUConsumed(getRequestChargeIfAny(responseHeaders)); + const ruConsumedValue = await ruConsumedManager.getRUConsumed(); + if (ruConsumedValue > operationOptions.ruCapPerOperation) { + // For RUCapPerOperationExceededError error, we won't be updating the state from + // inProgress as we want to support continue + throw new RUCapPerOperationExceededError("Request Unit limit per Operation call exceeded", resources); + } + } + return { result: resources, headers: responseHeaders }; + }, diagnosticNode, exports.DiagnosticNodeType.DEFAULT_QUERY_NODE, { + queryMethodIdentifier: "fetchMore", + }); + } + _canFetchMore() { + const res = this.state === DefaultQueryExecutionContext.STATES.start || + (this.continuationToken && this.state === DefaultQueryExecutionContext.STATES.inProgress) || + (this.currentPartitionIndex < this.fetchFunctions.length && + this.state === DefaultQueryExecutionContext.STATES.inProgress); + return res; + } +} +DefaultQueryExecutionContext.STATES = STATES; + +/** @hidden */ +class AverageAggregator { + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (other == null || other.sum == null) { + return; + } + if (this.sum == null) { + this.sum = 0.0; + this.count = 0; + } + this.sum += other.sum; + this.count += other.count; + } + /** + * Get the aggregation result. + */ + getResult() { + if (this.sum == null || this.count <= 0) { + return undefined; + } + return this.sum / this.count; + } +} + +/** @hidden */ +class CountAggregator { + /** + * Represents an aggregator for COUNT operator. + * @hidden + */ + constructor() { + this.value = 0; + } + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + this.value += other; + } + /** + * Get the aggregation result. + */ + getResult() { + return this.value; + } +} + +// TODO: this smells funny +/** @hidden */ +const TYPEORDCOMPARATOR$1 = Object.freeze({ + NoValue: { + ord: 0, + }, + undefined: { + ord: 1, + }, + boolean: { + ord: 2, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + number: { + ord: 4, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + string: { + ord: 5, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, +}); +/** @hidden */ +class OrderByDocumentProducerComparator { + constructor(sortOrder) { + this.sortOrder = sortOrder; + } // TODO: This should be an enum + targetPartitionKeyRangeDocProdComparator(docProd1, docProd2) { + const a = docProd1.getTargetParitionKeyRange()["minInclusive"]; + const b = docProd2.getTargetParitionKeyRange()["minInclusive"]; + return a === b ? 0 : a > b ? 1 : -1; + } + compare(docProd1, docProd2) { + // Need to check for split, since we don't want to dereference "item" of undefined / exception + if (docProd1.gotSplit()) { + return -1; + } + if (docProd2.gotSplit()) { + return 1; + } + const orderByItemsRes1 = this.getOrderByItems(docProd1.peekBufferedItems()[0]); + const orderByItemsRes2 = this.getOrderByItems(docProd2.peekBufferedItems()[0]); + // validate order by items and types + // TODO: once V1 order by on different types is fixed this need to change + this.validateOrderByItems(orderByItemsRes1, orderByItemsRes2); + // no async call in the for loop + for (let i = 0; i < orderByItemsRes1.length; i++) { + // compares the orderby items one by one + const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]); + if (compRes !== 0) { + if (this.sortOrder[i] === "Ascending") { + return compRes; + } + else if (this.sortOrder[i] === "Descending") { + return -compRes; + } + } + } + return this.targetPartitionKeyRangeDocProdComparator(docProd1, docProd2); + } + // TODO: This smells funny + compareValue(item1, type1, item2, type2) { + if (type1 === "object" || type2 === "object") { + throw new Error("Tried to compare an object type"); + } + const type1Ord = TYPEORDCOMPARATOR$1[type1].ord; + const type2Ord = TYPEORDCOMPARATOR$1[type2].ord; + const typeCmp = type1Ord - type2Ord; + if (typeCmp !== 0) { + // if the types are different, use type ordinal + return typeCmp; + } + // both are of the same type + if (type1Ord === TYPEORDCOMPARATOR$1["undefined"].ord || + type1Ord === TYPEORDCOMPARATOR$1["NoValue"].ord) { + // if both types are undefined or Null they are equal + return 0; + } + const compFunc = TYPEORDCOMPARATOR$1[type1].compFunc; + if (typeof compFunc === "undefined") { + throw new Error("Cannot find the comparison function"); + } + // same type and type is defined compare the items + return compFunc(item1, item2); + } + compareOrderByItem(orderByItem1, orderByItem2) { + const type1 = this.getType(orderByItem1); + const type2 = this.getType(orderByItem2); + return this.compareValue(orderByItem1["item"], type1, orderByItem2["item"], type2); + } + validateOrderByItems(res1, res2) { + if (res1.length !== res2.length) { + throw new Error(`Expected ${res1.length}, but got ${res2.length}.`); + } + if (res1.length !== this.sortOrder.length) { + throw new Error("orderByItems cannot have a different size than sort orders."); + } + for (let i = 0; i < this.sortOrder.length; i++) { + const type1 = this.getType(res1[i]); + const type2 = this.getType(res2[i]); + if (type1 !== type2) { + throw new Error(`Expected ${type1}, but got ${type2}. Cannot execute cross partition order-by queries on mixed types. Consider filtering your query using IS_STRING or IS_NUMBER to get around this exception.`); + } + } + } + getType(orderByItem) { + // TODO: any item? + if (orderByItem === undefined || orderByItem.item === undefined) { + return "NoValue"; + } + const type = typeof orderByItem.item; + if (TYPEORDCOMPARATOR$1[type] === undefined) { + throw new Error(`unrecognizable type ${type}`); + } + return type; + } + getOrderByItems(res) { + // TODO: any res? + return res["orderByItems"]; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +class MaxAggregator { + /** + * Represents an aggregator for MAX operator. + * @hidden + */ + constructor() { + this.value = undefined; + this.comparer = new OrderByDocumentProducerComparator(["Ascending"]); + } + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (this.value === undefined) { + this.value = other.max; + } + else if (this.comparer.compareValue(other.max, typeof other.max, this.value, typeof this.value) > 0) { + this.value = other.max; + } + } + /** + * Get the aggregation result. + */ + getResult() { + return this.value; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +class MinAggregator { + /** + * Represents an aggregator for MIN operator. + * @hidden + */ + constructor() { + this.value = undefined; + this.comparer = new OrderByDocumentProducerComparator(["Ascending"]); + } + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (this.value === undefined) { + // || typeof this.value === "object" + this.value = other.min; + } + else { + const otherType = other.min === null ? "NoValue" : typeof other.min; // || typeof other === "object" + const thisType = this.value === null ? "NoValue" : typeof this.value; + if (this.comparer.compareValue(other.min, otherType, this.value, thisType) < 0) { + this.value = other.min; + } + } + } + /** + * Get the aggregation result. + */ + getResult() { + return this.value; + } +} + +/** @hidden */ +class SumAggregator { + /** + * Add the provided item to aggregation result. + */ + aggregate(other) { + if (other === undefined) { + return; + } + if (this.sum === undefined) { + this.sum = other; + } + else { + this.sum += other; + } + } + /** + * Get the aggregation result. + */ + getResult() { + return this.sum; + } +} + +/** @hidden */ +class StaticValueAggregator { + aggregate(other) { + if (this.value === undefined) { + this.value = other; + } + } + getResult() { + return this.value; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function createAggregator(aggregateType) { + switch (aggregateType) { + case "Average": + return new AverageAggregator(); + case "Count": + return new CountAggregator(); + case "Max": + return new MaxAggregator(); + case "Min": + return new MinAggregator(); + case "Sum": + return new SumAggregator(); + default: + return new StaticValueAggregator(); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +var FetchResultType; +(function (FetchResultType) { + FetchResultType[FetchResultType["Done"] = 0] = "Done"; + FetchResultType[FetchResultType["Exception"] = 1] = "Exception"; + FetchResultType[FetchResultType["Result"] = 2] = "Result"; +})(FetchResultType || (FetchResultType = {})); +/** @hidden */ +class FetchResult { + /** + * Wraps fetch results for the document producer. + * This allows the document producer to buffer exceptions so that actual results don't get flushed during splits. + * + * @param feedReponse - The response the document producer got back on a successful fetch + * @param error - The exception meant to be buffered on an unsuccessful fetch + * @hidden + */ + constructor(feedResponse, error) { + // TODO: feedResponse/error + if (feedResponse !== undefined) { + this.feedResponse = feedResponse; + this.fetchResultType = FetchResultType.Result; + } + else { + this.error = error; + this.fetchResultType = FetchResultType.Exception; + } + } +} + +/** @hidden */ +class DocumentProducer { + /** + * Provides the Target Partition Range Query Execution Context. + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - Represents collection link + * @param query - A SQL query. + * @param targetPartitionKeyRange - Query Target Partition key Range + * @hidden + */ + constructor(clientContext, collectionLink, query, targetPartitionKeyRange, options) { + this.clientContext = clientContext; + this.generation = 0; + this.fetchFunction = async (diagnosticNode, options) => { + const path = getPathFromLink(this.collectionLink, exports.ResourceType.item); + diagnosticNode.addData({ partitionKeyRangeId: this.targetPartitionKeyRange.id }); + const id = getIdFromLink(this.collectionLink); + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.item, + resourceId: id, + resultFn: (result) => result.Documents, + query: this.query, + options, + diagnosticNode, + partitionKeyRangeId: this.targetPartitionKeyRange["id"], + }); + }; + // TODO: any options + this.collectionLink = collectionLink; + this.query = query; + this.targetPartitionKeyRange = targetPartitionKeyRange; + this.fetchResults = []; + this.allFetched = false; + this.err = undefined; + this.previousContinuationToken = undefined; + this.continuationToken = undefined; + this.respHeaders = getInitialHeader(); + this.internalExecutionContext = new DefaultQueryExecutionContext(options, this.fetchFunction); + } + /** + * Synchronously gives the contiguous buffered results (stops at the first non result) if any + * @returns buffered current items if any + * @hidden + */ + peekBufferedItems() { + const bufferedResults = []; + for (let i = 0, done = false; i < this.fetchResults.length && !done; i++) { + const fetchResult = this.fetchResults[i]; + switch (fetchResult.fetchResultType) { + case FetchResultType.Done: + done = true; + break; + case FetchResultType.Exception: + done = true; + break; + case FetchResultType.Result: + bufferedResults.push(fetchResult.feedResponse); + break; + } + } + return bufferedResults; + } + hasMoreResults() { + return this.internalExecutionContext.hasMoreResults() || this.fetchResults.length !== 0; + } + gotSplit() { + const fetchResult = this.fetchResults[0]; + if (fetchResult.fetchResultType === FetchResultType.Exception) { + if (DocumentProducer._needPartitionKeyRangeCacheRefresh(fetchResult.error)) { + return true; + } + } + return false; + } + _getAndResetActiveResponseHeaders() { + const ret = this.respHeaders; + this.respHeaders = getInitialHeader(); + return ret; + } + _updateStates(err, allFetched) { + // TODO: any Error + if (err) { + this.err = err; + return; + } + if (allFetched) { + this.allFetched = true; + } + if (this.internalExecutionContext.continuationToken === this.continuationToken) { + // nothing changed + return; + } + this.previousContinuationToken = this.continuationToken; + this.continuationToken = this.internalExecutionContext.continuationToken; + } + static _needPartitionKeyRangeCacheRefresh(error) { + // TODO: error + return (error.code === StatusCodes.Gone && + "substatus" in error && + error["substatus"] === SubStatusCodes.PartitionKeyRangeGone); + } + /** + * Fetches and bufferes the next page of results and executes the given callback + */ + async bufferMore(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.err) { + throw this.err; + } + try { + const { result: resources, headers: headerResponse } = await this.internalExecutionContext.fetchMore(diagnosticNode, operationOptions, ruConsumedManager); + ++this.generation; + this._updateStates(undefined, resources === undefined); + if (resources !== undefined) { + // some more results + resources.forEach((element) => { + // TODO: resources any + this.fetchResults.push(new FetchResult(element, undefined)); + }); + } + // need to modify the header response so that the query metrics are per partition + if (headerResponse != null && Constants$1.HttpHeaders.QueryMetrics in headerResponse) { + // "0" is the default partition before one is actually assigned. + const queryMetrics = headerResponse[Constants$1.HttpHeaders.QueryMetrics]["0"]; + // Wraping query metrics in a object where the keys are the partition key range. + headerResponse[Constants$1.HttpHeaders.QueryMetrics] = {}; + headerResponse[Constants$1.HttpHeaders.QueryMetrics][this.targetPartitionKeyRange.id] = + queryMetrics; + } + return { result: resources, headers: headerResponse }; + } + catch (err) { + // TODO: any error + if (DocumentProducer._needPartitionKeyRangeCacheRefresh(err)) { + // Split just happend + // Buffer the error so the execution context can still get the feedResponses in the itemBuffer + const bufferedError = new FetchResult(undefined, err); + this.fetchResults.push(bufferedError); + // Putting a dummy result so that the rest of code flows + return { + result: [bufferedError], + headers: err.headers, + }; + } + else { + this._updateStates(err, err.resources === undefined); + throw err; + } + } + } + /** + * Synchronously gives the bufferend current item if any + * @returns buffered current item if any + * @hidden + */ + getTargetParitionKeyRange() { + return this.targetPartitionKeyRange; + } + /** + * Fetches the next element in the DocumentProducer. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.err) { + this._updateStates(this.err, undefined); + throw this.err; + } + try { + const { result, headers } = await this.current(diagnosticNode, operationOptions, ruConsumedManager); + const fetchResult = this.fetchResults.shift(); + this._updateStates(undefined, result === undefined); + if (fetchResult.feedResponse !== result) { + throw new Error(`Expected ${fetchResult.feedResponse} to equal ${result}`); + } + switch (fetchResult.fetchResultType) { + case FetchResultType.Done: + return { result: undefined, headers }; + case FetchResultType.Exception: + fetchResult.error.headers = headers; + throw fetchResult.error; + case FetchResultType.Result: + return { result: fetchResult.feedResponse, headers }; + } + } + catch (err) { + this._updateStates(err, err.item === undefined); + throw err; + } + } + /** + * Retrieve the current element on the DocumentProducer. + */ + async current(diagnosticNode, operationOptions, ruConsumedManager) { + // If something is buffered just give that + if (this.fetchResults.length > 0) { + const fetchResult = this.fetchResults[0]; + // Need to unwrap fetch results + switch (fetchResult.fetchResultType) { + case FetchResultType.Done: + return { + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }; + case FetchResultType.Exception: + fetchResult.error.headers = this._getAndResetActiveResponseHeaders(); + throw fetchResult.error; + case FetchResultType.Result: + return { + result: fetchResult.feedResponse, + headers: this._getAndResetActiveResponseHeaders(), + }; + } + } + // If there isn't anymore items left to fetch then let the user know. + if (this.allFetched) { + return { + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }; + } + // If there are no more bufferd items and there are still items to be fetched then buffer more + const { result, headers } = await this.bufferMore(diagnosticNode, operationOptions, ruConsumedManager); + mergeHeaders(this.respHeaders, headers); + if (result === undefined) { + return { result: undefined, headers: this.respHeaders }; + } + return this.current(diagnosticNode, operationOptions, ruConsumedManager); + } +} + +/** @hidden */ +class QueryRange { + /** + * Represents a QueryRange. + * + * @param rangeMin - min + * @param rangeMin - max + * @param isMinInclusive - isMinInclusive + * @param isMaxInclusive - isMaxInclusive + * @hidden + */ + constructor(rangeMin, rangeMax, isMinInclusive, isMaxInclusive) { + this.min = rangeMin; + this.max = rangeMax; + this.isMinInclusive = isMinInclusive; + this.isMaxInclusive = isMaxInclusive; + } + overlaps(other) { + const range1 = this; // eslint-disable-line @typescript-eslint/no-this-alias + const range2 = other; + if (range1 === undefined || range2 === undefined) { + return false; + } + if (range1.isEmpty() || range2.isEmpty()) { + return false; + } + if (range1.min <= range2.max || range2.min <= range1.max) { + if ((range1.min === range2.max && !(range1.isMinInclusive && range2.isMaxInclusive)) || + (range2.min === range1.max && !(range2.isMinInclusive && range1.isMaxInclusive))) { + return false; + } + return true; + } + return false; + } + isFullRange() { + return (this.min === Constants$1.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey && + this.max === Constants$1.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey && + this.isMinInclusive === true && + this.isMaxInclusive === false); + } + isEmpty() { + return !(this.isMinInclusive && this.isMaxInclusive) && this.min === this.max; + } + /** + * Parse a QueryRange from a partitionKeyRange + * @returns QueryRange + * @hidden + */ + static parsePartitionKeyRange(partitionKeyRange) { + return new QueryRange(partitionKeyRange[Constants$1.PartitionKeyRange.MinInclusive], partitionKeyRange[Constants$1.PartitionKeyRange.MaxExclusive], true, false); + } + /** + * Parse a QueryRange from a dictionary + * @returns QueryRange + * @hidden + */ + static parseFromDict(queryRangeDict) { + return new QueryRange(queryRangeDict.min, queryRangeDict.max, queryRangeDict.isMinInclusive, queryRangeDict.isMaxInclusive); + } +} + +/** @hidden */ +class InMemoryCollectionRoutingMap { + /** + * Represents a InMemoryCollectionRoutingMap Object, + * Stores partition key ranges in an efficient way with some additional information and provides + * convenience methods for working with set of ranges. + */ + constructor(orderedPartitionKeyRanges, orderedPartitionInfo) { + this.orderedPartitionKeyRanges = orderedPartitionKeyRanges; + this.orderedRanges = orderedPartitionKeyRanges.map((pkr) => { + return new QueryRange(pkr[Constants$1.PartitionKeyRange.MinInclusive], pkr[Constants$1.PartitionKeyRange.MaxExclusive], true, false); + }); + this.orderedPartitionInfo = orderedPartitionInfo; + } + getOrderedParitionKeyRanges() { + return this.orderedPartitionKeyRanges; + } + getOverlappingRanges(providedQueryRanges) { + // TODO This code has all kinds of smells. Multiple iterations and sorts just to grab overlapping ranges + // stfaul attempted to bring it down to one for-loop and failed + const pqr = Array.isArray(providedQueryRanges) + ? providedQueryRanges + : [providedQueryRanges]; + const minToPartitionRange = {}; // TODO: any + // this for loop doesn't invoke any async callback + for (const queryRange of pqr) { + if (queryRange.isEmpty()) { + continue; + } + if (queryRange.isFullRange()) { + return this.orderedPartitionKeyRanges; + } + const minIndex = this.orderedRanges.findIndex((range) => { + if (queryRange.min > range.min && queryRange.min < range.max) { + return true; + } + if (queryRange.min === range.min) { + return true; + } + if (queryRange.min === range.max) { + return true; + } + }); + if (minIndex < 0) { + throw new Error("error in collection routing map, queried value is less than the start range."); + } + // Start at the end and work backwards + let maxIndex; + for (let i = this.orderedRanges.length - 1; i >= 0; i--) { + const range = this.orderedRanges[i]; + if (queryRange.max > range.min && queryRange.max < range.max) { + maxIndex = i; + break; + } + if (queryRange.max === range.min) { + maxIndex = i; + break; + } + if (queryRange.max === range.max) { + maxIndex = i; + break; + } + } + if (maxIndex > this.orderedRanges.length) { + throw new Error("error in collection routing map, queried value is greater than the end range."); + } + for (let j = minIndex; j < maxIndex + 1; j++) { + if (queryRange.overlaps(this.orderedRanges[j])) { + minToPartitionRange[this.orderedPartitionKeyRanges[j][Constants$1.PartitionKeyRange.MinInclusive]] = this.orderedPartitionKeyRanges[j]; + } + } + } + const overlappingPartitionKeyRanges = Object.keys(minToPartitionRange).map((k) => minToPartitionRange[k]); + return overlappingPartitionKeyRanges.sort((a, b) => { + return a[Constants$1.PartitionKeyRange.MinInclusive].localeCompare(b[Constants$1.PartitionKeyRange.MinInclusive]); + }); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +function compareRanges(a, b) { + const aVal = a[0][Constants$1.PartitionKeyRange.MinInclusive]; + const bVal = b[0][Constants$1.PartitionKeyRange.MinInclusive]; + if (aVal > bVal) { + return 1; + } + if (aVal < bVal) { + return -1; + } + return 0; +} +/** @hidden */ +function createCompleteRoutingMap(partitionKeyRangeInfoTuppleList) { + const rangeById = {}; // TODO: any + const rangeByInfo = {}; // TODO: any + let sortedRanges = []; + // the for loop doesn't invoke any async callback + for (const r of partitionKeyRangeInfoTuppleList) { + rangeById[r[0][Constants$1.PartitionKeyRange.Id]] = r; + rangeByInfo[r[1]] = r[0]; + sortedRanges.push(r); + } + sortedRanges = sortedRanges.sort(compareRanges); + const partitionKeyOrderedRange = sortedRanges.map((r) => r[0]); + const orderedPartitionInfo = sortedRanges.map((r) => r[1]); + if (!isCompleteSetOfRange(partitionKeyOrderedRange)) { + return undefined; + } + return new InMemoryCollectionRoutingMap(partitionKeyOrderedRange, orderedPartitionInfo); +} +/** + * @hidden + */ +function isCompleteSetOfRange(partitionKeyOrderedRange) { + // TODO: any + let isComplete = false; + if (partitionKeyOrderedRange.length > 0) { + const firstRange = partitionKeyOrderedRange[0]; + const lastRange = partitionKeyOrderedRange[partitionKeyOrderedRange.length - 1]; + isComplete = + firstRange[Constants$1.PartitionKeyRange.MinInclusive] === + Constants$1.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey; + isComplete = + isComplete && + lastRange[Constants$1.PartitionKeyRange.MaxExclusive] === + Constants$1.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey; + for (let i = 1; i < partitionKeyOrderedRange.length; i++) { + const previousRange = partitionKeyOrderedRange[i - 1]; + const currentRange = partitionKeyOrderedRange[i]; + isComplete = + isComplete && + previousRange[Constants$1.PartitionKeyRange.MaxExclusive] === + currentRange[Constants$1.PartitionKeyRange.MinInclusive]; + if (!isComplete) { + if (previousRange[Constants$1.PartitionKeyRange.MaxExclusive] > + currentRange[Constants$1.PartitionKeyRange.MinInclusive]) { + throw Error("Ranges overlap"); + } + break; + } + } + } + return isComplete; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +class PartitionKeyRangeCache { + constructor(clientContext) { + this.clientContext = clientContext; + this.collectionRoutingMapByCollectionId = {}; + } + /** + * Finds or Instantiates the requested Collection Routing Map + * @param collectionLink - Requested collectionLink + * @hidden + */ + async onCollectionRoutingMap(collectionLink, diagnosticNode, forceRefresh = false) { + const collectionId = getIdFromLink(collectionLink); + if (this.collectionRoutingMapByCollectionId[collectionId] === undefined || forceRefresh) { + this.collectionRoutingMapByCollectionId[collectionId] = this.requestCollectionRoutingMap(collectionLink, diagnosticNode); + } + return this.collectionRoutingMapByCollectionId[collectionId]; + } + /** + * Given the query ranges and a collection, invokes the callback on the list of overlapping partition key ranges + * @hidden + */ + async getOverlappingRanges(collectionLink, queryRange, diagnosticNode, forceRefresh = false) { + const crm = await this.onCollectionRoutingMap(collectionLink, diagnosticNode, forceRefresh); + return crm.getOverlappingRanges(queryRange); + } + async requestCollectionRoutingMap(collectionLink, diagnosticNode) { + const { resources } = await withMetadataDiagnostics(async (metadataDiagnostics) => { + return this.clientContext + .queryPartitionKeyRanges(collectionLink) + .fetchAllInternal(metadataDiagnostics); + }, diagnosticNode, exports.MetadataLookUpType.PartitionKeyRangeLookUp); + return createCompleteRoutingMap(resources.map((r) => [r, true])); + } +} + +/** @hidden */ +const PARITIONKEYRANGE = Constants$1.PartitionKeyRange; +/** @hidden */ +class SmartRoutingMapProvider { + constructor(clientContext) { + this.partitionKeyRangeCache = new PartitionKeyRangeCache(clientContext); + } + static _secondRangeIsAfterFirstRange(range1, range2) { + if (typeof range1.max === "undefined") { + throw new Error("range1 must have max"); + } + if (typeof range2.min === "undefined") { + throw new Error("range2 must have min"); + } + if (range1.max > range2.min) { + // r.min < #previous_r.max + return false; + } + else { + if (range1.max === range2.min && range1.isMaxInclusive && range2.isMinInclusive) { + // the inclusive ending endpoint of previous_r is the same as the inclusive beginning endpoint of r + // they share a point + return false; + } + return true; + } + } + static _isSortedAndNonOverlapping(ranges) { + for (let idx = 1; idx < ranges.length; idx++) { + const previousR = ranges[idx - 1]; + const r = ranges[idx]; + if (!this._secondRangeIsAfterFirstRange(previousR, r)) { + return false; + } + } + return true; + } + static _stringMax(a, b) { + return a >= b ? a : b; + } + static _stringCompare(a, b) { + return a === b ? 0 : a > b ? 1 : -1; + } + static _subtractRange(r, partitionKeyRange) { + const left = this._stringMax(partitionKeyRange[PARITIONKEYRANGE.MaxExclusive], r.min); + const leftInclusive = this._stringCompare(left, r.min) === 0 ? r.isMinInclusive : false; + return new QueryRange(left, r.max, leftInclusive, r.isMaxInclusive); + } + /** + * Given the sorted ranges and a collection, invokes the callback on the list of overlapping partition key ranges + * @param callback - Function execute on the overlapping partition key ranges result, + * takes two parameters error, partition key ranges + * @hidden + */ + async getOverlappingRanges(collectionLink, sortedRanges, diagnosticNode) { + // validate if the list is non- overlapping and sorted TODO: any PartitionKeyRanges + if (!SmartRoutingMapProvider._isSortedAndNonOverlapping(sortedRanges)) { + throw new Error("the list of ranges is not a non-overlapping sorted ranges"); + } + let partitionKeyRanges = []; // TODO: any ParitionKeyRanges + if (sortedRanges.length === 0) { + return partitionKeyRanges; + } + const collectionRoutingMap = await this.partitionKeyRangeCache.onCollectionRoutingMap(collectionLink, diagnosticNode); + let index = 0; + let currentProvidedRange = sortedRanges[index]; + for (;;) { + if (currentProvidedRange.isEmpty()) { + // skip and go to the next item + if (++index >= sortedRanges.length) { + return partitionKeyRanges; + } + currentProvidedRange = sortedRanges[index]; + continue; + } + let queryRange; + if (partitionKeyRanges.length > 0) { + queryRange = SmartRoutingMapProvider._subtractRange(currentProvidedRange, partitionKeyRanges[partitionKeyRanges.length - 1]); + } + else { + queryRange = currentProvidedRange; + } + const overlappingRanges = collectionRoutingMap.getOverlappingRanges(queryRange); + if (overlappingRanges.length <= 0) { + throw new Error(`error: returned overlapping ranges for queryRange ${queryRange} is empty`); + } + partitionKeyRanges = partitionKeyRanges.concat(overlappingRanges); + const lastKnownTargetRange = QueryRange.parsePartitionKeyRange(partitionKeyRanges[partitionKeyRanges.length - 1]); + if (!lastKnownTargetRange) { + throw new Error("expected lastKnowTargetRange to be truthy"); + } + // the overlapping ranges must contain the requested range + if (SmartRoutingMapProvider._stringCompare(currentProvidedRange.max, lastKnownTargetRange.max) > + 0) { + throw new Error(`error: returned overlapping ranges ${overlappingRanges} \ + does not contain the requested range ${queryRange}`); + } + // the current range is contained in partitionKeyRanges just move forward + if (++index >= sortedRanges.length) { + return partitionKeyRanges; + } + currentProvidedRange = sortedRanges[index]; + while (SmartRoutingMapProvider._stringCompare(currentProvidedRange.max, lastKnownTargetRange.max) <= 0) { + // the current range is covered too.just move forward + if (++index >= sortedRanges.length) { + return partitionKeyRanges; + } + currentProvidedRange = sortedRanges[index]; + } + } + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +const logger$2 = logger$5.createClientLogger("parallelQueryExecutionContextBase"); +/** @hidden */ +var ParallelQueryExecutionContextBaseStates; +(function (ParallelQueryExecutionContextBaseStates) { + ParallelQueryExecutionContextBaseStates["started"] = "started"; + ParallelQueryExecutionContextBaseStates["inProgress"] = "inProgress"; + ParallelQueryExecutionContextBaseStates["ended"] = "ended"; +})(ParallelQueryExecutionContextBaseStates || (ParallelQueryExecutionContextBaseStates = {})); +/** @hidden */ +class ParallelQueryExecutionContextBase { + /** + * Provides the ParallelQueryExecutionContextBase. + * This is the base class that ParallelQueryExecutionContext and OrderByQueryExecutionContext will derive from. + * + * When handling a parallelized query, it instantiates one instance of + * DocumentProcuder per target partition key range and aggregates the result of each. + * + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - The Collection Link + * @param options - Represents the feed options. + * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo + * @hidden + */ + constructor(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo) { + this.clientContext = clientContext; + this.collectionLink = collectionLink; + this.query = query; + this.options = options; + this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo; + this.initializedPriorityQueue = false; + this.ruCapExceededError = undefined; + this.clientContext = clientContext; + this.collectionLink = collectionLink; + this.query = query; + this.options = options; + this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo; + this.diagnosticNodeWrapper = { + consumed: false, + diagnosticNode: new DiagnosticNodeInternal(clientContext.diagnosticLevel, exports.DiagnosticNodeType.PARALLEL_QUERY_NODE, null), + }; + this.diagnosticNodeWrapper.diagnosticNode.addData({ stateful: true }); + this.err = undefined; + this.state = ParallelQueryExecutionContextBase.STATES.started; + this.routingProvider = new SmartRoutingMapProvider(this.clientContext); + this.sortOrders = this.partitionedQueryExecutionInfo.queryInfo.orderBy; + this.requestContinuation = options ? options.continuationToken || options.continuation : null; + // response headers of undergoing operation + this.respHeaders = getInitialHeader(); + // Make priority queue for documentProducers + // The comparator is supplied by the derived class + this.orderByPQ = new PriorityQueue((a, b) => this.documentProducerComparator(b, a)); + this.nextItemfetchSemaphore = semaphore(1); + } + _mergeWithActiveResponseHeaders(headers) { + mergeHeaders(this.respHeaders, headers); + } + _getAndResetActiveResponseHeaders() { + const ret = this.respHeaders; + this.respHeaders = getInitialHeader(); + return ret; + } + getDiagnosticNode() { + return this.diagnosticNodeWrapper.diagnosticNode; + } + async _onTargetPartitionRanges() { + // invokes the callback when the target partition ranges are ready + const parsedRanges = this.partitionedQueryExecutionInfo.queryRanges; + const queryRanges = parsedRanges.map((item) => QueryRange.parseFromDict(item)); + return this.routingProvider.getOverlappingRanges(this.collectionLink, queryRanges, this.getDiagnosticNode()); + } + /** + * Gets the replacement ranges for a partitionkeyrange that has been split + */ + async _getReplacementPartitionKeyRanges(documentProducer) { + const partitionKeyRange = documentProducer.targetPartitionKeyRange; + // Download the new routing map + this.routingProvider = new SmartRoutingMapProvider(this.clientContext); + // Get the queryRange that relates to this partitionKeyRange + const queryRange = QueryRange.parsePartitionKeyRange(partitionKeyRange); + return this.routingProvider.getOverlappingRanges(this.collectionLink, [queryRange], this.getDiagnosticNode()); + } + // TODO: P0 Code smell - can barely tell what this is doing + /** + * Removes the current document producer from the priqueue, + * replaces that document producer with child document producers, + * then reexecutes the originFunction with the corrrected executionContext + */ + async _repairExecutionContext(diagnosticNode, originFunction) { + // TODO: any + // Get the replacement ranges + // Removing the invalid documentProducer from the orderByPQ + const parentDocumentProducer = this.orderByPQ.deq(); + try { + const replacementPartitionKeyRanges = await this._getReplacementPartitionKeyRanges(parentDocumentProducer); + const replacementDocumentProducers = []; + // Create the replacement documentProducers + replacementPartitionKeyRanges.forEach((partitionKeyRange) => { + // Create replacment document producers with the parent's continuationToken + const replacementDocumentProducer = this._createTargetPartitionQueryExecutionContext(partitionKeyRange, parentDocumentProducer.continuationToken); + replacementDocumentProducers.push(replacementDocumentProducer); + }); + // We need to check if the documentProducers even has anything left to fetch from before enqueing them + const checkAndEnqueueDocumentProducer = async (documentProducerToCheck, checkNextDocumentProducerCallback) => { + try { + const { result: afterItem } = await documentProducerToCheck.current(diagnosticNode); + if (afterItem === undefined) { + // no more results left in this document producer, so we don't enqueue it + } + else { + // Safe to put document producer back in the queue + this.orderByPQ.enq(documentProducerToCheck); + } + await checkNextDocumentProducerCallback(); + } + catch (err) { + this.err = err; + return; + } + }; + const checkAndEnqueueDocumentProducers = async (rdp) => { + if (rdp.length > 0) { + // We still have a replacementDocumentProducer to check + const replacementDocumentProducer = rdp.shift(); + await checkAndEnqueueDocumentProducer(replacementDocumentProducer, async () => { + await checkAndEnqueueDocumentProducers(rdp); + }); + } + else { + // reexecutes the originFunction with the corrrected executionContext + return originFunction(); + } + }; + // Invoke the recursive function to get the ball rolling + await checkAndEnqueueDocumentProducers(replacementDocumentProducers); + } + catch (err) { + this.err = err; + throw err; + } + } + static _needPartitionKeyRangeCacheRefresh(error) { + // TODO: any error + return (error.code === StatusCodes.Gone && + "substatus" in error && + error["substatus"] === SubStatusCodes.PartitionKeyRangeGone); + } + /** + * Checks to see if the executionContext needs to be repaired. + * if so it repairs the execution context and executes the ifCallback, + * else it continues with the current execution context and executes the elseCallback + */ + async _repairExecutionContextIfNeeded(diagnosticNode, ifCallback, elseCallback, operationOptions, ruConsumedManager) { + const documentProducer = this.orderByPQ.peek(); + // Check if split happened + try { + await documentProducer.current(diagnosticNode, operationOptions, ruConsumedManager); + elseCallback(); + } + catch (err) { + if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) { + // Split has happened so we need to repair execution context before continueing + return addDignosticChild((childNode) => this._repairExecutionContext(childNode, ifCallback), diagnosticNode, exports.DiagnosticNodeType.QUERY_REPAIR_NODE); + } + else { + // Something actually bad happened ... + this.err = err; + throw err; + } + } + } + /** + * Fetches the next element in the ParallelQueryExecutionContextBase. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + if (this.err) { + // if there is a prior error return error + throw this.err; + } + return new Promise((resolve, reject) => { + this.nextItemfetchSemaphore.take(async () => { + // document producer queue initilization + if (!this.initializedPriorityQueue) { + try { + await this._createDocumentProducersAndFillUpPriorityQueue(operationOptions, ruConsumedManager); + this.initializedPriorityQueue = true; + } + catch (err) { + this.err = err; + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + reject(this.err); + return; + } + } + if (!this.diagnosticNodeWrapper.consumed) { + diagnosticNode.addChildNode(this.diagnosticNodeWrapper.diagnosticNode, exports.CosmosDbDiagnosticLevel.debug, exports.MetadataLookUpType.QueryPlanLookUp); + this.diagnosticNodeWrapper.diagnosticNode = undefined; + this.diagnosticNodeWrapper.consumed = true; + } + else { + this.diagnosticNodeWrapper.diagnosticNode = diagnosticNode; + } + // NOTE: lock must be released before invoking quitting + if (this.err) { + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + this.err.headers = this._getAndResetActiveResponseHeaders(); + reject(this.err); + return; + } + if (this.orderByPQ.size() === 0) { + // there is no more results + this.state = ParallelQueryExecutionContextBase.STATES.ended; + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + return resolve({ + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }); + } + const ifCallback = () => { + // Release the semaphore to avoid deadlock + this.nextItemfetchSemaphore.leave(); + // Reexcute the function + return resolve(this.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + }; + const elseCallback = async () => { + let documentProducer; + try { + documentProducer = this.orderByPQ.deq(); + } + catch (e) { + // if comparing elements of the priority queue throws exception + // set that error and return error + this.err = e; + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + this.err.headers = this._getAndResetActiveResponseHeaders(); + reject(this.err); + return; + } + let item; + let headers; + try { + const response = await documentProducer.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + item = response.result; + headers = response.headers; + this._mergeWithActiveResponseHeaders(headers); + if (item === undefined) { + // this should never happen + // because the documentProducer already has buffered an item + // assert item !== undefined + this.err = new Error(`Extracted DocumentProducer from the priority queue \ + doesn't have any buffered item!`); + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + return resolve({ + result: undefined, + headers: this._getAndResetActiveResponseHeaders(), + }); + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + this._updateErrorObjectWithBufferedData(err); + this.err = err; + } + else { + this.err = new Error(`Extracted DocumentProducer from the priority queue fails to get the \ + buffered item. Due to ${JSON.stringify(err)}`); + this.err.headers = this._getAndResetActiveResponseHeaders(); + } + // release the lock before invoking callback + this.nextItemfetchSemaphore.leave(); + reject(this.err); + return; + } + // we need to put back the document producer to the queue if it has more elements. + // the lock will be released after we know document producer must be put back in the queue or not + try { + const { result: afterItem, headers: otherHeaders } = await documentProducer.current(diagnosticNode, operationOptions, ruConsumedManager); + this._mergeWithActiveResponseHeaders(otherHeaders); + if (afterItem === undefined) { + // no more results is left in this document producer + } + else { + try { + const headItem = documentProducer.fetchResults[0]; + if (typeof headItem === "undefined") { + throw new Error("Extracted DocumentProducer from PQ is invalid state with no result!"); + } + this.orderByPQ.enq(documentProducer); + } + catch (e) { + // if comparing elements in priority queue throws exception + // set error + this.err = e; + } + } + } + catch (err) { + if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) { + // We want the document producer enqueued + // So that later parts of the code can repair the execution context + this.orderByPQ.enq(documentProducer); + } + else if (err.code === RUCapPerOperationExceededErrorCode) { + this._updateErrorObjectWithBufferedData(err); + this.err = err; + reject(this.err); + } + else { + // Something actually bad happened + this.err = err; + reject(this.err); + } + } + finally { + // release the lock before returning + this.nextItemfetchSemaphore.leave(); + } + // invoke the callback on the item + return resolve({ + result: item, + headers: this._getAndResetActiveResponseHeaders(), + }); + }; + this._repairExecutionContextIfNeeded(diagnosticNode, ifCallback, elseCallback).catch(reject); + }); + }); + } + _updateErrorObjectWithBufferedData(err) { + this.orderByPQ.forEach((dp) => { + const bufferedItems = dp.peekBufferedItems(); + err.fetchedResults.push(...bufferedItems); + }); + } + /** + * Determine if there are still remaining resources to processs based on the value of the continuation + * token or the elements remaining on the current batch in the QueryIterator. + * @returns true if there is other elements to process in the ParallelQueryExecutionContextBase. + */ + hasMoreResults() { + return !(this.state === ParallelQueryExecutionContextBase.STATES.ended || this.err !== undefined); + } + /** + * Creates document producers + */ + _createTargetPartitionQueryExecutionContext(partitionKeyTargetRange, continuationToken) { + // TODO: any + // creates target partition range Query Execution Context + let rewrittenQuery = this.partitionedQueryExecutionInfo.queryInfo.rewrittenQuery; + let sqlQuerySpec; + const query = this.query; + if (typeof query === "string") { + sqlQuerySpec = { query }; + } + else { + sqlQuerySpec = query; + } + const formatPlaceHolder = "{documentdb-formattableorderbyquery-filter}"; + if (rewrittenQuery) { + sqlQuerySpec = JSON.parse(JSON.stringify(sqlQuerySpec)); + // We hardcode the formattable filter to true for now + rewrittenQuery = rewrittenQuery.replace(formatPlaceHolder, "true"); + sqlQuerySpec["query"] = rewrittenQuery; + } + const options = Object.assign({}, this.options); + options.continuationToken = continuationToken; + return new DocumentProducer(this.clientContext, this.collectionLink, sqlQuerySpec, partitionKeyTargetRange, options); + } + async _createDocumentProducersAndFillUpPriorityQueue(operationOptions, ruConsumedManager) { + try { + const targetPartitionRanges = await this._onTargetPartitionRanges(); + const maxDegreeOfParallelism = this.options.maxDegreeOfParallelism === undefined || this.options.maxDegreeOfParallelism < 1 + ? targetPartitionRanges.length + : Math.min(this.options.maxDegreeOfParallelism, targetPartitionRanges.length); + logger$2.info("Query starting against " + + targetPartitionRanges.length + + " ranges with parallelism of " + + maxDegreeOfParallelism); + let filteredPartitionKeyRanges = []; + // The document producers generated from filteredPartitionKeyRanges + const targetPartitionQueryExecutionContextList = []; + if (this.requestContinuation) { + throw new Error("Continuation tokens are not yet supported for cross partition queries"); + } + else { + filteredPartitionKeyRanges = targetPartitionRanges; + } + // Create one documentProducer for each partitionTargetRange + filteredPartitionKeyRanges.forEach((partitionTargetRange) => { + // TODO: any partitionTargetRange + // no async callback + targetPartitionQueryExecutionContextList.push(this._createTargetPartitionQueryExecutionContext(partitionTargetRange)); + }); + // Fill up our priority queue with documentProducers + let inProgressPromises = []; + for (const documentProducer of targetPartitionQueryExecutionContextList) { + // Don't enqueue any new promise if RU cap exceeded + if (this.ruCapExceededError) { + break; + } + const promise = this._processAndEnqueueDocumentProducer(documentProducer, operationOptions, ruConsumedManager); + inProgressPromises.push(promise); + // Limit concurrent executions + if (inProgressPromises.length === maxDegreeOfParallelism) { + await Promise.all(inProgressPromises); + inProgressPromises = []; + } + } + // Wait for all promises to complete + await Promise.all(inProgressPromises); + if (this.err) { + if (this.ruCapExceededError) { + // merge the buffered items + this.orderByPQ.forEach((dp) => { + const bufferedItems = dp.peekBufferedItems(); + this.ruCapExceededError.fetchedResults.push(...bufferedItems); + }); + throw this.ruCapExceededError; + } + throw this.err; + } + } + catch (err) { + this.err = err; + throw err; + } + } + async _processAndEnqueueDocumentProducer(documentProducer, operationOptions, ruConsumedManager) { + try { + const { result: document, headers } = await documentProducer.current(this.getDiagnosticNode(), operationOptions, ruConsumedManager); + this._mergeWithActiveResponseHeaders(headers); + if (document !== undefined) { + this.orderByPQ.enq(documentProducer); + } + } + catch (err) { + this._mergeWithActiveResponseHeaders(err.headers); + this.err = err; + if (err.code === RUCapPerOperationExceededErrorCode) { + // would be halting further execution of other promises + if (!this.ruCapExceededError) { + this.ruCapExceededError = err; + } + else { + // merge the buffered items + if (err.fetchedResults) { + this.ruCapExceededError.fetchedResults.push(...err.fetchedResults); + } + } + } + else { + throw err; + } + } + return; + } +} +ParallelQueryExecutionContextBase.STATES = ParallelQueryExecutionContextBaseStates; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Provides the ParallelQueryExecutionContext. + * This class is capable of handling parallelized queries and derives from ParallelQueryExecutionContextBase. + * @hidden + */ +class ParallelQueryExecutionContext extends ParallelQueryExecutionContextBase { + // Instance members are inherited + // Overriding documentProducerComparator for ParallelQueryExecutionContexts + /** + * Provides a Comparator for document producers using the min value of the corresponding target partition. + * @returns Comparator Function + * @hidden + */ + documentProducerComparator(docProd1, docProd2) { + return docProd1.generation - docProd2.generation; + } +} + +/** @hidden */ +class OrderByQueryExecutionContext extends ParallelQueryExecutionContextBase { + /** + * Provides the OrderByQueryExecutionContext. + * This class is capable of handling orderby queries and dervives from ParallelQueryExecutionContextBase. + * + * When handling a parallelized query, it instantiates one instance of + * DocumentProcuder per target partition key range and aggregates the result of each. + * + * @param clientContext - The service endpoint to use to create the client. + * @param collectionLink - The Collection Link + * @param options - Represents the feed options. + * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo + * @hidden + */ + constructor(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo) { + // Calling on base class constructor + super(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo); + this.orderByComparator = new OrderByDocumentProducerComparator(this.sortOrders); + } + // Instance members are inherited + // Overriding documentProducerComparator for OrderByQueryExecutionContexts + /** + * Provides a Comparator for document producers which respects orderby sort order. + * @returns Comparator Function + * @hidden + */ + documentProducerComparator(docProd1, docProd2) { + return this.orderByComparator.compare(docProd1, docProd2); + } +} + +/** @hidden */ +class OffsetLimitEndpointComponent { + constructor(executionContext, offset, limit) { + this.executionContext = executionContext; + this.offset = offset; + this.limit = limit; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + const aggregateHeaders = getInitialHeader(); + try { + while (this.offset > 0) { + // Grab next item but ignore the result. We only need the headers + const { headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + this.offset--; + mergeHeaders(aggregateHeaders, headers); + } + if (this.limit > 0) { + const { result, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + this.limit--; + mergeHeaders(aggregateHeaders, headers); + return { result, headers: aggregateHeaders }; + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + // If both limit and offset are 0, return nothing + return { + result: undefined, + headers: getInitialHeader(), + }; + } + hasMoreResults() { + return (this.offset > 0 || this.limit > 0) && this.executionContext.hasMoreResults(); + } +} + +/** @hidden */ +class OrderByEndpointComponent { + /** + * Represents an endpoint in handling an order by query. For each processed orderby + * result it returns 'payload' item of the result + * + * @param executionContext - Underlying Execution Context + * @hidden + */ + constructor(executionContext) { + this.executionContext = executionContext; + } + /** + * Execute a provided function on the next element in the OrderByEndpointComponent. + */ + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { result: item, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + return { + result: item !== undefined ? item.payload : undefined, + headers, + }; + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + /** + * Determine if there are still remaining resources to processs. + * @returns true if there is other elements to process in the OrderByEndpointComponent. + */ + hasMoreResults() { + return this.executionContext.hasMoreResults(); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +async function digest(str) { + const hash = crypto.createHash("sha256"); + hash.update(str, "utf8"); + return hash.digest("hex"); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +async function hashObject(object) { + const stringifiedObject = stableStringify(object); + return digest(stringifiedObject); +} + +/** @hidden */ +class OrderedDistinctEndpointComponent { + constructor(executionContext) { + this.executionContext = executionContext; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { headers, result } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + if (result) { + const hashedResult = await hashObject(result); + if (hashedResult === this.hashedLastResult) { + return { result: undefined, headers }; + } + this.hashedLastResult = hashedResult; + } + return { result, headers }; + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + hasMoreResults() { + return this.executionContext.hasMoreResults(); + } +} + +/** @hidden */ +class UnorderedDistinctEndpointComponent { + constructor(executionContext) { + this.executionContext = executionContext; + this.hashedResults = new Set(); + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { headers, result } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + if (result) { + const hashedResult = await hashObject(result); + if (this.hashedResults.has(hashedResult)) { + return { result: undefined, headers }; + } + this.hashedResults.add(hashedResult); + } + return { result, headers }; + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + hasMoreResults() { + return this.executionContext.hasMoreResults(); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +// All aggregates are effectively a group by operation +// The empty group is used for aggregates without a GROUP BY clause +const emptyGroup = "__empty__"; +// Newer API versions rewrite the query to return `item2`. It fixes some legacy issues with the original `item` result +// Aggregator code should use item2 when available +const extractAggregateResult = (payload) => Object.keys(payload).length > 0 ? (payload.item2 ? payload.item2 : payload.item) : null; + +/** @hidden */ +class GroupByEndpointComponent { + constructor(executionContext, queryInfo) { + this.executionContext = executionContext; + this.queryInfo = queryInfo; + this.groupings = new Map(); + this.aggregateResultArray = []; + this.completed = false; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + // If we have a full result set, begin returning results + if (this.aggregateResultArray.length > 0) { + return { + result: this.aggregateResultArray.pop(), + headers: getInitialHeader(), + }; + } + if (this.completed) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + const aggregateHeaders = getInitialHeader(); + try { + while (this.executionContext.hasMoreResults()) { + // Grab the next result + const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + mergeHeaders(aggregateHeaders, headers); + // If it exists, process it via aggregators + if (result) { + const group = result.groupByItems ? await hashObject(result.groupByItems) : emptyGroup; + const aggregators = this.groupings.get(group); + const payload = result.payload; + if (aggregators) { + // Iterator over all results in the payload + Object.keys(payload).map((key) => { + // in case the value of a group is null make sure we create a dummy payload with item2==null + const effectiveGroupByValue = payload[key] + ? payload[key] + : new Map().set("item2", null); + const aggregateResult = extractAggregateResult(effectiveGroupByValue); + aggregators.get(key).aggregate(aggregateResult); + }); + } + else { + // This is the first time we have seen a grouping. Setup the initial result without aggregate values + const grouping = new Map(); + this.groupings.set(group, grouping); + // Iterator over all results in the payload + Object.keys(payload).map((key) => { + const aggregateType = this.queryInfo.groupByAliasToAggregateType[key]; + // Create a new aggregator for this specific aggregate field + const aggregator = createAggregator(aggregateType); + grouping.set(key, aggregator); + if (aggregateType) { + const aggregateResult = extractAggregateResult(payload[key]); + aggregator.aggregate(aggregateResult); + } + else { + aggregator.aggregate(payload[key]); + } + }); + } + } + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + for (const grouping of this.groupings.values()) { + const groupResult = {}; + for (const [aggregateKey, aggregator] of grouping.entries()) { + groupResult[aggregateKey] = aggregator.getResult(); + } + this.aggregateResultArray.push(groupResult); + } + this.completed = true; + return { + result: this.aggregateResultArray.pop(), + headers: aggregateHeaders, + }; + } + hasMoreResults() { + return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0; + } +} + +/** @hidden */ +class GroupByValueEndpointComponent { + constructor(executionContext, queryInfo) { + this.executionContext = executionContext; + this.queryInfo = queryInfo; + this.aggregators = new Map(); + this.aggregateResultArray = []; + this.completed = false; + // VALUE queries will only every have a single grouping + this.aggregateType = this.queryInfo.aggregates[0]; + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + // Start returning results if we have processed a full results set + if (this.aggregateResultArray.length > 0) { + return { + result: this.aggregateResultArray.pop(), + headers: getInitialHeader(), + }; + } + if (this.completed) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + const aggregateHeaders = getInitialHeader(); + try { + while (this.executionContext.hasMoreResults()) { + // Grab the next result + const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + mergeHeaders(aggregateHeaders, headers); + // If it exists, process it via aggregators + if (result) { + let grouping = emptyGroup; + let payload = result; + if (result.groupByItems) { + // If the query contains a GROUP BY clause, it will have a payload property and groupByItems + payload = result.payload; + grouping = await hashObject(result.groupByItems); + } + const aggregator = this.aggregators.get(grouping); + if (!aggregator) { + // This is the first time we have seen a grouping so create a new aggregator + this.aggregators.set(grouping, createAggregator(this.aggregateType)); + } + if (this.aggregateType) { + const aggregateResult = extractAggregateResult(payload[0]); + // if aggregate result is null, we need to short circuit aggregation and return undefined + if (aggregateResult === null) { + this.completed = true; + } + this.aggregators.get(grouping).aggregate(aggregateResult); + } + else { + // Queries with no aggregates pass the payload directly to the aggregator + // Example: SELECT VALUE c.team FROM c GROUP BY c.team + this.aggregators.get(grouping).aggregate(payload); + } + } + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + // We bail early since we got an undefined result back `[{}]` + if (this.completed) { + return { + result: undefined, + headers: aggregateHeaders, + }; + } + // If no results are left in the underlying execution context, convert our aggregate results to an array + for (const aggregator of this.aggregators.values()) { + this.aggregateResultArray.push(aggregator.getResult()); + } + this.completed = true; + return { + result: this.aggregateResultArray.pop(), + headers: aggregateHeaders, + }; + } + hasMoreResults() { + return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class NonStreamingOrderByPriorityQueue { + constructor(compareFn, pqMaxSize = 2000) { + this.compareFn = compareFn; + this.pq = new PriorityQueue(this.compareFn); + this.pqMaxSize = pqMaxSize; + } + enqueue(item) { + if (this.pq.size() < this.pqMaxSize) { + this.pq.enq(item); + } + else { + const topItem = this.pq.peek(); + if (this.compareFn(topItem, item) > 0) { + this.pq.deq(); + this.pq.enq(item); + } + } + } + dequeue() { + return this.pq.deq(); + } + size() { + return this.pq.size(); + } + isEmpty() { + return this.pq.isEmpty(); + } + peek() { + return this.pq.peek(); + } + getTopElements() { + const elements = []; + while (!this.pq.isEmpty()) { + elements.unshift(this.pq.deq()); + } + return elements; + } + // Create a new instance of NonStreamingOrderByPriorityQueue with a reversed compare function and the same maximum size. + // Enqueue all elements from the current priority queue into the reverse priority queue. + reverse() { + const reversePQ = new NonStreamingOrderByPriorityQueue((a, b) => -this.compareFn(a, b), this.pqMaxSize); + while (!this.pq.isEmpty()) { + reversePQ.enqueue(this.pq.deq()); + } + return reversePQ; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class NonStreamingOrderByMap { + constructor(compareFn) { + this.compareFn = compareFn; + this.map = new Map(); + } + set(key, value) { + if (!this.map.has(key)) { + this.map.set(key, value); + } + else { + const oldValue = this.map.get(key); + if (this.replaceResults(oldValue, value)) { + this.map.set(key, value); + } + } + } + get(key) { + if (!this.map.has(key)) + return undefined; + return this.map.get(key); + } + getAllValues() { + const res = []; + for (const [key, value] of this.map) { + res.push(value); + this.map.delete(key); + } + return res; + } + replaceResults(res1, res2) { + const res = this.compareFn(res1, res2); + if (res < 0) + return true; + return false; + } + size() { + return this.map.size; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +const TYPEORDCOMPARATOR = Object.freeze({ + NoValue: { + ord: 0, + }, + undefined: { + ord: 1, + }, + boolean: { + ord: 2, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + number: { + ord: 4, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, + string: { + ord: 5, + compFunc: (a, b) => { + return a === b ? 0 : a > b ? 1 : -1; + }, + }, +}); +/** @hidden */ +class OrderByComparator { + constructor(sortOrder) { + this.sortOrder = sortOrder; + } + compareItems(item1, item2) { + const orderByItemsRes1 = this.getOrderByItems(item1); + const orderByItemsRes2 = this.getOrderByItems(item2); + for (let i = 0; i < orderByItemsRes1.length; i++) { + // compares the orderby items one by one + const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]); + if (compRes !== 0) { + if (this.sortOrder[i] === "Descending") { + return compRes; + } + else if (this.sortOrder[i] === "Ascending") { + return -compRes; + } + } + } + } + getOrderByItems(res) { + return res["orderByItems"]; + } + compareOrderByItem(orderByItem1, orderByItem2) { + const type1 = this.getType(orderByItem1); + const type2 = this.getType(orderByItem2); + return this.compareValue(orderByItem1["item"], type1, orderByItem2["item"], type2); + } + getType(orderByItem) { + // TODO: any item? + if (orderByItem === undefined || orderByItem.item === undefined) { + return "NoValue"; + } + const type = typeof orderByItem.item; + if (TYPEORDCOMPARATOR[type] === undefined) { + throw new Error(`unrecognizable type ${type}`); + } + return type; + } + compareValue(item1, type1, item2, type2) { + if (type1 === "object" || type2 === "object") { + throw new Error("Tried to compare an object type"); + } + const type1Ord = TYPEORDCOMPARATOR[type1].ord; + const type2Ord = TYPEORDCOMPARATOR[type2].ord; + const typeCmp = type1Ord - type2Ord; + if (typeCmp !== 0) { + // if the types are different, use type ordinal + return typeCmp; + } + // both are of the same type + if (type1Ord === TYPEORDCOMPARATOR["undefined"].ord || + type1Ord === TYPEORDCOMPARATOR["NoValue"].ord) { + // if both types are undefined or Null they are equal + return 0; + } + const compFunc = TYPEORDCOMPARATOR[type1].compFunc; + if (typeof compFunc === "undefined") { + throw new Error("Cannot find the comparison function"); + } + // same type and type is defined compare the items + return compFunc(item1, item2); + } +} + +/** @hidden */ +class NonStreamingOrderByDistinctEndpointComponent { + constructor(executionContext, queryInfo, priorityQueueBufferSize) { + this.executionContext = executionContext; + this.queryInfo = queryInfo; + this.priorityQueueBufferSize = priorityQueueBufferSize; + this.isCompleted = false; + this.sortOrders = this.queryInfo.orderBy; + const comparator = new OrderByComparator(this.sortOrders); + this.aggregateMap = new NonStreamingOrderByMap((a, b) => { + return comparator.compareItems(a, b); + }); + this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue((a, b) => { + return comparator.compareItems(b, a); + }, this.priorityQueueBufferSize); + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + // if size is 0, just return undefined. Valid if query is TOP 0 or LIMIT 0 + if (this.priorityQueueBufferSize === 0) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + let resHeaders = getInitialHeader(); + if (!this.isCompleted && this.executionContext.hasMoreResults()) { + // Grab the next result + const { result, headers } = (await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager)); + resHeaders = headers; + if (result) { + // make hash of result object and update the map if required. + const key = await hashObject(result === null || result === void 0 ? void 0 : result.payload); + this.aggregateMap.set(key, result); + } + if (!this.executionContext.hasMoreResults()) { + this.isCompleted = true; + await this.buildFinalResultArray(); + } + } + if (this.isCompleted) { + // start returning the results if final result is computed. + if (this.finalResultArray.length > 0) { + return { + result: this.finalResultArray.shift(), + headers: resHeaders, + }; + } + else { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + } + else { + // keep returning empty till final results are getting computed. + return { + result: {}, + headers: resHeaders, + }; + } + } + /** + * Build final sorted result array from which responses will be served. + */ + async buildFinalResultArray() { + var _a; + const allValues = this.aggregateMap.getAllValues(); + for (const value of allValues) { + this.nonStreamingOrderByPQ.enqueue(value); + } + const offSet = this.queryInfo.offset ? this.queryInfo.offset : 0; + const queueSize = this.nonStreamingOrderByPQ.size(); + const finalArraySize = queueSize - offSet; + if (finalArraySize <= 0) { + this.finalResultArray = []; + } + else { + this.finalResultArray = new Array(finalArraySize); + for (let count = finalArraySize - 1; count >= 0; count--) { + this.finalResultArray[count] = (_a = this.nonStreamingOrderByPQ.dequeue()) === null || _a === void 0 ? void 0 : _a.payload; + } + } + } + hasMoreResults() { + if (this.priorityQueueBufferSize === 0) + return false; + return this.executionContext.hasMoreResults() || this.finalResultArray.length > 0; + } +} + +class NonStreamingOrderByEndpointComponent { + /** + * Represents an endpoint in handling an non-streaming order by query. For each processed orderby + * result it returns 'payload' item of the result + * + * @param executionContext - Underlying Execution Context + * @hidden + */ + constructor(executionContext, sortOrders, priorityQueueBufferSize = 2000, offset = 0) { + this.executionContext = executionContext; + this.sortOrders = sortOrders; + this.priorityQueueBufferSize = priorityQueueBufferSize; + this.offset = offset; + this.isCompleted = false; + const comparator = new OrderByComparator(this.sortOrders); + this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue((a, b) => { + return comparator.compareItems(b, a); + }, this.priorityQueueBufferSize); + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + var _a, _b; + if (this.priorityQueueBufferSize <= 0 || + (this.isCompleted && this.nonStreamingOrderByPQ.isEmpty())) { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + if (this.isCompleted && !this.nonStreamingOrderByPQ.isEmpty()) { + const item = (_a = this.nonStreamingOrderByPQ.dequeue()) === null || _a === void 0 ? void 0 : _a.payload; + return { + result: item, + headers: getInitialHeader(), + }; + } + try { + if (this.executionContext.hasMoreResults()) { + const { result: item, headers } = await this.executionContext.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + if (item !== undefined) { + this.nonStreamingOrderByPQ.enqueue(item); + } + return { + result: {}, + headers, + }; + } + else { + this.isCompleted = true; + // Reverse the priority queue to get the results in the correct order + this.nonStreamingOrderByPQ = this.nonStreamingOrderByPQ.reverse(); + // For offset limit case we set the size of priority queue to offset + limit + // and we drain offset number of items from the priority queue + while (this.offset < this.priorityQueueBufferSize && this.offset > 0) { + this.nonStreamingOrderByPQ.dequeue(); + this.offset--; + } + if (this.nonStreamingOrderByPQ.size() !== 0) { + const item = (_b = this.nonStreamingOrderByPQ.dequeue()) === null || _b === void 0 ? void 0 : _b.payload; + return { + result: item, + headers: getInitialHeader(), + }; + } + else { + return { + result: undefined, + headers: getInitialHeader(), + }; + } + } + } + catch (err) { + if (err.code === RUCapPerOperationExceededErrorCode) { + err.fetchedResults = undefined; + } + throw err; + } + } + /** + * Determine if there are still remaining resources to processs. + * @returns true if there is other elements to process in the NonStreamingOrderByEndpointComponent. + */ + hasMoreResults() { + return (this.priorityQueueBufferSize > 0 && + (this.executionContext.hasMoreResults() || this.nonStreamingOrderByPQ.size() !== 0)); + } +} + +/** @hidden */ +class PipelinedQueryExecutionContext { + constructor(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo) { + this.clientContext = clientContext; + this.collectionLink = collectionLink; + this.query = query; + this.options = options; + this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo; + this.vectorSearchBufferSize = 0; + this.nonStreamingOrderBy = false; + this.endpoint = null; + this.pageSize = options["maxItemCount"]; + if (this.pageSize === undefined) { + this.pageSize = PipelinedQueryExecutionContext.DEFAULT_PAGE_SIZE; + } + // Pick between Nonstreaming and streaming endpoints + this.nonStreamingOrderBy = partitionedQueryExecutionInfo.queryInfo.hasNonStreamingOrderBy; + // Pick between parallel vs order by execution context + const sortOrders = partitionedQueryExecutionInfo.queryInfo.orderBy; + // TODO: Currently we don't get any field from backend to determine streaming queries + if (this.nonStreamingOrderBy) { + this.vectorSearchBufferSize = this.calculateVectorSearchBufferSize(partitionedQueryExecutionInfo.queryInfo, options); + const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; + const context = new ParallelQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo); + if (distinctType === "None") { + this.endpoint = new NonStreamingOrderByEndpointComponent(context, sortOrders, this.vectorSearchBufferSize, partitionedQueryExecutionInfo.queryInfo.offset); + } + else { + this.endpoint = new NonStreamingOrderByDistinctEndpointComponent(context, partitionedQueryExecutionInfo.queryInfo, this.vectorSearchBufferSize); + } + } + else { + if (Array.isArray(sortOrders) && sortOrders.length > 0) { + // Need to wrap orderby execution context in endpoint component, since the data is nested as a \ + // "payload" property. + this.endpoint = new OrderByEndpointComponent(new OrderByQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo)); + } + else { + this.endpoint = new ParallelQueryExecutionContext(this.clientContext, this.collectionLink, this.query, this.options, this.partitionedQueryExecutionInfo); + } + if (Object.keys(partitionedQueryExecutionInfo.queryInfo.groupByAliasToAggregateType).length > + 0 || + partitionedQueryExecutionInfo.queryInfo.aggregates.length > 0 || + partitionedQueryExecutionInfo.queryInfo.groupByExpressions.length > 0) { + if (partitionedQueryExecutionInfo.queryInfo.hasSelectValue) { + this.endpoint = new GroupByValueEndpointComponent(this.endpoint, partitionedQueryExecutionInfo.queryInfo); + } + else { + this.endpoint = new GroupByEndpointComponent(this.endpoint, partitionedQueryExecutionInfo.queryInfo); + } + } + // If top then add that to the pipeline. TOP N is effectively OFFSET 0 LIMIT N + const top = partitionedQueryExecutionInfo.queryInfo.top; + if (typeof top === "number") { + this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, 0, top); + } + // If offset+limit then add that to the pipeline + const limit = partitionedQueryExecutionInfo.queryInfo.limit; + const offset = partitionedQueryExecutionInfo.queryInfo.offset; + if (typeof limit === "number" && typeof offset === "number") { + this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, offset, limit); + } + // If distinct then add that to the pipeline + const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType; + if (distinctType === "Ordered") { + this.endpoint = new OrderedDistinctEndpointComponent(this.endpoint); + } + if (distinctType === "Unordered") { + this.endpoint = new UnorderedDistinctEndpointComponent(this.endpoint); + } + } + } + async nextItem(diagnosticNode, operationOptions, ruConsumedManager) { + return this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + } + // Removed callback here beacuse it wouldn't have ever worked... + hasMoreResults() { + return this.endpoint.hasMoreResults(); + } + async fetchMore(diagnosticNode, operationOptions, ruConsumedManager) { + // if the wrapped endpoint has different implementation for fetchMore use that + // otherwise use the default implementation + if (typeof this.endpoint.fetchMore === "function") { + return this.endpoint.fetchMore(diagnosticNode, operationOptions, ruConsumedManager); + } + else { + this.fetchBuffer = []; + this.fetchMoreRespHeaders = getInitialHeader(); + return this.nonStreamingOrderBy + ? this._nonStreamingFetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager) + : this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager); + } + } + async _fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { result: item, headers } = await this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + mergeHeaders(this.fetchMoreRespHeaders, headers); + if (item === undefined) { + // no more results + if (this.fetchBuffer.length === 0) { + return { + result: undefined, + headers: this.fetchMoreRespHeaders, + }; + } + else { + // Just give what we have + const temp = this.fetchBuffer; + this.fetchBuffer = []; + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + } + else { + this.fetchBuffer.push(item); + if (this.fetchBuffer.length >= this.pageSize) { + // fetched enough results + const temp = this.fetchBuffer.slice(0, this.pageSize); + this.fetchBuffer = this.fetchBuffer.splice(this.pageSize); + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + else { + // recursively fetch more + // TODO: is recursion a good idea? + return this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager); + } + } + } + catch (err) { + mergeHeaders(this.fetchMoreRespHeaders, err.headers); + err.headers = this.fetchMoreRespHeaders; + if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) { + err.fetchedResults.push(...this.fetchBuffer); + } + if (err) { + throw err; + } + } + } + async _nonStreamingFetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager) { + try { + const { result: item, headers } = await this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager); + mergeHeaders(this.fetchMoreRespHeaders, headers); + if (item === undefined) { + // no more results + if (this.fetchBuffer.length === 0) { + return { + result: undefined, + headers: this.fetchMoreRespHeaders, + }; + } + else { + // Just give what we have + const temp = this.fetchBuffer; + this.fetchBuffer = []; + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + } + else { + const ruConsumed = await ruConsumedManager.getRUConsumed(); + const maxRUAllowed = operationOptions && operationOptions.ruCapPerOperation + ? operationOptions.ruCapPerOperation + : Constants$1.NonStreamingQueryDefaultRUThreshold; + // append the result + if (typeof item !== "object") { + this.fetchBuffer.push(item); + } + else if (Object.keys(item).length !== 0) { + this.fetchBuffer.push(item); + } + if (this.fetchBuffer.length >= this.pageSize) { + // fetched enough results + const temp = this.fetchBuffer.slice(0, this.pageSize); + this.fetchBuffer = this.fetchBuffer.splice(this.pageSize); + return { result: temp, headers: this.fetchMoreRespHeaders }; + } + else if (ruConsumed * 2 < maxRUAllowed) { + // recursively fetch more only if we have more than 50% RUs left. + return this._nonStreamingFetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager); + } + else { + return { result: [], headers: this.fetchMoreRespHeaders }; + } + } + } + catch (err) { + mergeHeaders(this.fetchMoreRespHeaders, err.headers); + err.headers = this.fetchMoreRespHeaders; + if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) { + err.fetchedResults.push(...this.fetchBuffer); + } + if (err) { + throw err; + } + } + } + calculateVectorSearchBufferSize(queryInfo, options) { + if (queryInfo.top === 0 || queryInfo.limit === 0) + return 0; + return queryInfo.top + ? queryInfo.top + : queryInfo.limit + ? queryInfo.offset + queryInfo.limit + : options["vectorSearchBufferSize"] && options["vectorSearchBufferSize"] > 0 + ? options["vectorSearchBufferSize"] + : PipelinedQueryExecutionContext.DEFAULT_VECTOR_SEARCH_BUFFER_SIZE; + } +} +PipelinedQueryExecutionContext.DEFAULT_PAGE_SIZE = 10; +PipelinedQueryExecutionContext.DEFAULT_VECTOR_SEARCH_BUFFER_SIZE = 2000; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Represents a QueryIterator Object, an implementation of feed or query response that enables + * traversal and iterating over the response + * in the Azure Cosmos DB database service. + */ +class QueryIterator { + /** + * @hidden + */ + constructor(clientContext, query, options, fetchFunctions, resourceLink, resourceType) { + this.clientContext = clientContext; + this.query = query; + this.options = options; + this.fetchFunctions = fetchFunctions; + this.resourceLink = resourceLink; + this.resourceType = resourceType; + this.nonStreamingOrderBy = false; + this.query = query; + this.fetchFunctions = fetchFunctions; + this.options = options || {}; + this.resourceLink = resourceLink; + this.fetchAllLastResHeaders = getInitialHeader(); + this.reset(); + this.isInitialized = false; + } + /** + * Gets an async iterator that will yield results until completion. + * + * NOTE: AsyncIterators are a very new feature and you might need to + * use polyfils/etc. in order to use them in your code. + * + * If you're using TypeScript, you can use the following polyfill as long + * as you target ES6 or higher and are running on Node 6 or higher. + * + * ```typescript + * if (!Symbol || !Symbol.asyncIterator) { + * (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator"); + * } + * ``` + * + * @example Iterate over all databases + * ```typescript + * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) { + * console.log(`Got ${db} from AsyncIterator`); + * } + * ``` + */ + getAsyncIterator(options) { + return tslib.__asyncGenerator(this, arguments, function* getAsyncIterator_1() { + this.reset(); + let diagnosticNode = new DiagnosticNodeInternal(this.clientContext.diagnosticLevel, exports.DiagnosticNodeType.CLIENT_REQUEST_NODE, null); + this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode); + let ruConsumedManager; + if (options && options.ruCapPerOperation) { + ruConsumedManager = new RUConsumedManager(); + } + while (this.queryExecutionContext.hasMoreResults()) { + let response; + try { + response = yield tslib.__await(this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager)); + } + catch (error) { + if (this.needsQueryPlan(error)) { + yield tslib.__await(this.createPipelinedExecutionContext()); + try { + response = yield tslib.__await(this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager)); + } + catch (queryError) { + this.handleSplitError(queryError); + } + } + else { + throw error; + } + } + const feedResponse = new FeedResponse(response.result, response.headers, this.queryExecutionContext.hasMoreResults(), diagnosticNode.toDiagnostic(this.clientContext.getClientConfig())); + diagnosticNode = new DiagnosticNodeInternal(this.clientContext.diagnosticLevel, exports.DiagnosticNodeType.CLIENT_REQUEST_NODE, null); + if (response.result !== undefined) { + yield yield tslib.__await(feedResponse); + } + } + }); + } + /** + * Determine if there are still remaining resources to process based on the value of the continuation token or the + * elements remaining on the current batch in the QueryIterator. + * @returns true if there is other elements to process in the QueryIterator. + */ + hasMoreResults() { + return this.queryExecutionContext.hasMoreResults(); + } + /** + * Fetch all pages for the query and return a single FeedResponse. + */ + async fetchAll(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.fetchAllInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async fetchAllInternal(diagnosticNode, options) { + this.reset(); + let response; + try { + response = await this.toArrayImplementation(diagnosticNode, options); + } + catch (error) { + this.handleSplitError(error); + } + return response; + } + /** + * Retrieve the next batch from the feed. + * + * This may or may not fetch more pages from the backend depending on your settings + * and the type of query. Aggregate queries will generally fetch all backend pages + * before returning the first batch of responses. + */ + async fetchNext(options) { + return withDiagnostics(async (diagnosticNode) => { + // Enabling RU metrics for all the fetchNext operations + const ruConsumedManager = new RUConsumedManager(); + this.queryPlanPromise = withMetadataDiagnostics(async (metadataNode) => { + return this.fetchQueryPlan(metadataNode); + }, diagnosticNode, exports.MetadataLookUpType.QueryPlanLookUp); + if (!this.isInitialized) { + await this.init(); + } + let response; + try { + response = await this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager); + } + catch (error) { + if (this.needsQueryPlan(error)) { + await this.createPipelinedExecutionContext(); + try { + response = await this.queryExecutionContext.fetchMore(diagnosticNode, options, ruConsumedManager); + } + catch (queryError) { + this.handleSplitError(queryError); + } + } + else { + throw error; + } + } + return new FeedResponse(response.result, response.headers, this.queryExecutionContext.hasMoreResults(), getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Reset the QueryIterator to the beginning and clear all the resources inside it + */ + reset() { + this.queryPlanPromise = undefined; + this.fetchAllLastResHeaders = getInitialHeader(); + this.fetchAllTempResources = []; + this.queryExecutionContext = new DefaultQueryExecutionContext(this.options, this.fetchFunctions); + } + async toArrayImplementation(diagnosticNode, options) { + let ruConsumedManager; + if (options && options.ruCapPerOperation) { + ruConsumedManager = new RUConsumedManager(); + } + this.queryPlanPromise = withMetadataDiagnostics(async (metadataNode) => { + return this.fetchQueryPlan(metadataNode); + }, diagnosticNode, exports.MetadataLookUpType.QueryPlanLookUp); + // this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode); + if (!this.isInitialized) { + await this.init(); + } + while (this.queryExecutionContext.hasMoreResults()) { + let response; + try { + response = await this.queryExecutionContext.nextItem(diagnosticNode, options, ruConsumedManager); + } + catch (error) { + if (this.needsQueryPlan(error)) { + await this.createPipelinedExecutionContext(); + response = await this.queryExecutionContext.nextItem(diagnosticNode, options, ruConsumedManager); + } + else if (error.code === RUCapPerOperationExceededErrorCode && error.fetchedResults) { + error.fetchedResults.forEach((item) => { + this.fetchAllTempResources.push(item); + }); + error.fetchedResults = this.fetchAllTempResources; + throw error; + } + else { + throw error; + } + } + const { result, headers } = response; + // concatenate the results and fetch more + mergeHeaders(this.fetchAllLastResHeaders, headers); + if (result !== undefined) { + if (this.nonStreamingOrderBy && + typeof result === "object" && + Object.keys(result).length === 0) ; + else + this.fetchAllTempResources.push(result); + } + } + return new FeedResponse(this.fetchAllTempResources, this.fetchAllLastResHeaders, this.queryExecutionContext.hasMoreResults(), getEmptyCosmosDiagnostics()); + } + async createPipelinedExecutionContext() { + const queryPlanResponse = await this.queryPlanPromise; + // We always coerce queryPlanPromise to resolved. So if it errored, we need to manually inspect the resolved value + if (queryPlanResponse instanceof Error) { + throw queryPlanResponse; + } + const queryPlan = queryPlanResponse.result; + const queryInfo = queryPlan.queryInfo; + this.nonStreamingOrderBy = queryInfo.hasNonStreamingOrderBy ? true : false; + if (queryInfo.aggregates.length > 0 && queryInfo.hasSelectValue === false) { + throw new Error("Aggregate queries must use the VALUE keyword"); + } + this.queryExecutionContext = new PipelinedQueryExecutionContext(this.clientContext, this.resourceLink, this.query, this.options, queryPlan); + } + async fetchQueryPlan(diagnosticNode) { + if (!this.queryPlanPromise && this.resourceType === exports.ResourceType.item) { + return this.clientContext + .getQueryPlan(getPathFromLink(this.resourceLink) + "/docs", exports.ResourceType.item, this.resourceLink, this.query, this.options, diagnosticNode) + .catch((error) => error); // Without this catch, node reports an unhandled rejection. So we stash the promise as resolved even if it errored. + } + return this.queryPlanPromise; + } + needsQueryPlan(error) { + var _a; + let needsQueryPlanValue = false; + if (((_a = error.body) === null || _a === void 0 ? void 0 : _a.additionalErrorInfo) || + error.message.includes("Cross partition query only supports")) { + needsQueryPlanValue = + error.code === StatusCodes.BadRequest && this.resourceType === exports.ResourceType.item; + } + return needsQueryPlanValue; + } + async init() { + if (this.isInitialized === true) { + return; + } + if (this.initPromise === undefined) { + this.initPromise = this._init(); + } + return this.initPromise; + } + async _init() { + if (this.options.forceQueryPlan === true && this.resourceType === exports.ResourceType.item) { + await this.createPipelinedExecutionContext(); + } + this.isInitialized = true; + } + handleSplitError(err) { + if (err.code === 410) { + const error = new Error("Encountered partition split and could not recover. This request is retryable"); + error.code = 503; + error.originalError = err; + throw error; + } + else { + throw err; + } + } +} + +class ConflictResponse extends ResourceResponse { + constructor(resource, headers, statusCode, conflict, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.conflict = conflict; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +async function readPartitionKeyDefinition(diagnosticNode, container) { + const partitionKeyDefinition = await container.readPartitionKeyDefinition(diagnosticNode); + return partitionKeyDefinition.resource; +} + +/** + * Use to read or delete a given {@link Conflict} by id. + * + * @see {@link Conflicts} to query or read all conflicts. + */ +class Conflict { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return `/${this.container.url}/${Constants$1.Path.ConflictsPathSegment}/${this.id}`; + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Conflict}. + */ + constructor(container, id, clientContext, partitionKey) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + this.partitionKey = partitionKey; + this.partitionKey = partitionKey; + } + /** + * Read the {@link ConflictDefinition} for the given {@link Conflict}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url, exports.ResourceType.conflicts); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new ConflictResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link ConflictDefinition}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = undefinedPartitionKey(partitionKeyDefinition); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.conflicts, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ConflictResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** + * Use to query or read all conflicts. + * + * @see {@link Conflict} to read or delete a given {@link Conflict} by id. + */ +class Conflicts { + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, exports.ResourceType.conflicts); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.conflicts, + resourceId: id, + resultFn: (result) => result.Conflicts, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }); + } + /** + * Reads all conflicts + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + readAll(options) { + return this.query(undefined, options); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +exports.ConflictResolutionMode = void 0; +(function (ConflictResolutionMode) { + ConflictResolutionMode["Custom"] = "Custom"; + ConflictResolutionMode["LastWriterWins"] = "LastWriterWins"; +})(exports.ConflictResolutionMode || (exports.ConflictResolutionMode = {})); + +class ItemResponse extends ResourceResponse { + constructor(resource, headers, statusCode, subsstatusCode, item, diagnostics) { + super(resource, headers, statusCode, diagnostics, subsstatusCode); + this.item = item; + } +} + +/** + * Used to perform operations on a specific item. + * + * @see {@link Items} for operations on all items; see `container.items`. + */ +class Item { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createDocumentUri(this.container.database.id, this.container.id, this.id); + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Item}. + * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers). + */ + constructor(container, id, clientContext, partitionKey) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + this.partitionKey = + partitionKey === undefined ? undefined : convertToInternalPartitionKey(partitionKey); + } + /** + * Read the item's definition. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype. + * It's recommended to only use interfaces. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Additional options for the request + * + * @example Using custom type for response + * ```typescript + * interface TodoItem { + * title: string; + * done: bool; + * id: string; + * } + * + * let item: TodoItem; + * ({body: item} = await item.read()); + * ``` + */ + async read(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = undefinedPartitionKey(partitionKeyDefinition); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + let response; + try { + response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + } + catch (error) { + if (error.code !== StatusCodes.NotFound) { + throw error; + } + response = error; + } + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + async replace(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = extractPartitionKeys(body, partitionKeyResponse); + } + const err = {}; + if (!isItemResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: exports.ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + async delete(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = undefinedPartitionKey(partitionKeyResponse); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Perform a JSONPatch on the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + async patch(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + if (this.partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + this.partitionKey = extractPartitionKeys(body, partitionKeyResponse); + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.patch({ + body, + path, + resourceType: exports.ResourceType.item, + resourceId: id, + options, + partitionKey: this.partitionKey, + diagnosticNode, + }); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +class ChangeFeedResponse { + /** + * @internal + */ + constructor( + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + result, + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + count, + /** + * Gets the status code of the response from Azure Cosmos DB + */ + statusCode, headers, diagnostics) { + this.result = result; + this.count = count; + this.statusCode = statusCode; + this.diagnostics = diagnostics; + this.headers = Object.freeze(headers); + } + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge() { + const rus = this.headers[Constants$1.HttpHeaders.RequestCharge]; + return rus ? parseInt(rus, 10) : null; + } + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId() { + return this.headers[Constants$1.HttpHeaders.ActivityId]; + } + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + * + * This is equivalent to the `etag` property. + */ + get continuation() { + return this.etag; + } + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken() { + return this.headers[Constants$1.HttpHeaders.SessionToken]; + } + /** + * Gets the entity tag associated with last transaction in the Azure Cosmos DB service, + * which can be used as If-Non-Match Access condition for ReadFeed REST request or + * `continuation` property of `ChangeFeedOptions` parameter for + * `Items.changeFeed()` + * to get feed changes since the transaction specified by this entity tag. + * + * This is equivalent to the `continuation` property. + */ + get etag() { + return this.headers[Constants$1.HttpHeaders.ETag]; + } +} + +/** + * Provides iterator for change feed. + * + * Use `Items.changeFeed()` to get an instance of the iterator. + */ +class ChangeFeedIterator { + /** + * @internal + */ + constructor(clientContext, resourceId, resourceLink, partitionKey, changeFeedOptions) { + this.clientContext = clientContext; + this.resourceId = resourceId; + this.resourceLink = resourceLink; + this.partitionKey = partitionKey; + this.changeFeedOptions = changeFeedOptions; + // partition key XOR partition key range id + const partitionKeyValid = partitionKey !== undefined; + this.isPartitionSpecified = partitionKeyValid; + let canUseStartFromBeginning = true; + if (changeFeedOptions.continuation) { + this.nextIfNoneMatch = changeFeedOptions.continuation; + canUseStartFromBeginning = false; + } + if (changeFeedOptions.startTime) { + // .toUTCString() is platform specific, but most platforms use RFC 1123. + // In ECMAScript 2018, this was standardized to RFC 1123. + // See for more info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString + this.ifModifiedSince = changeFeedOptions.startTime.toUTCString(); + canUseStartFromBeginning = false; + } + if (canUseStartFromBeginning && !changeFeedOptions.startFromBeginning) { + this.nextIfNoneMatch = ChangeFeedIterator.IfNoneMatchAllHeaderValue; + } + } + /** + * Gets a value indicating whether there are potentially additional results that can be retrieved. + * + * Initially returns true. This value is set based on whether the last execution returned a continuation token. + * + * @returns Boolean value representing if whether there are potentially additional results that can be retrieved. + */ + get hasMoreResults() { + return this.lastStatusCode !== StatusCodes.NotModified; + } + /** + * Gets an async iterator which will yield pages of results from Azure Cosmos DB. + */ + getAsyncIterator() { + return tslib.__asyncGenerator(this, arguments, function* getAsyncIterator_1() { + do { + const result = yield tslib.__await(this.fetchNext()); + if (result.count > 0) { + yield yield tslib.__await(result); + } + } while (this.hasMoreResults); + }); + } + /** + * Read feed and retrieves the next page of results in Azure Cosmos DB. + */ + async fetchNext() { + return withDiagnostics(async (diagnosticNode) => { + const response = await this.getFeedResponse(diagnosticNode); + this.lastStatusCode = response.statusCode; + this.nextIfNoneMatch = response.headers[Constants$1.HttpHeaders.ETag]; + return response; + }, this.clientContext); + } + async getFeedResponse(diagnosticNode) { + if (!this.isPartitionSpecified) { + throw new Error("Container is partitioned, but no partition key or partition key range id was specified."); + } + const feedOptions = { initialHeaders: {}, useIncrementalFeed: true }; + if (typeof this.changeFeedOptions.maxItemCount === "number") { + feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount; + } + if (this.changeFeedOptions.sessionToken) { + feedOptions.sessionToken = this.changeFeedOptions.sessionToken; + } + if (this.nextIfNoneMatch) { + feedOptions.accessCondition = { + type: Constants$1.HttpHeaders.IfNoneMatch, + condition: this.nextIfNoneMatch, + }; + } + if (this.ifModifiedSince) { + feedOptions.initialHeaders[Constants$1.HttpHeaders.IfModifiedSince] = this.ifModifiedSince; + } + const response = await this.clientContext.queryFeed({ + path: this.resourceLink, + resourceType: exports.ResourceType.item, + resourceId: this.resourceId, + resultFn: (result) => (result ? result.Documents : []), + query: undefined, + options: feedOptions, + partitionKey: this.partitionKey, + diagnosticNode: diagnosticNode, + }); // TODO: some funky issues with query feed. Probably need to change it up. + return new ChangeFeedResponse(response.result, response.result ? response.result.length : 0, response.code, response.headers, getEmptyCosmosDiagnostics()); + } +} +ChangeFeedIterator.IfNoneMatchAllHeaderValue = "*"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const BytePrefix = { + Undefined: "00", + Null: "01", + False: "02", + True: "03", + MinNumber: "04", + Number: "05", + MaxNumber: "06", + MinString: "07", + String: "08", + MaxString: "09", + Int64: "0a", + Int32: "0b", + Int16: "0c", + Int8: "0d", + Uint64: "0e", + Uint32: "0f", + Uint16: "10", + Uint8: "11", + Binary: "12", + Guid: "13", + Float: "14", + Infinity: "FF", +}; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function writeNumberForBinaryEncodingJSBI(hash) { + let payload = encodeNumberAsUInt64JSBI(hash); + let outputStream = Buffer.from(BytePrefix.Number, "hex"); + const firstChunk = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56))); + outputStream = Buffer.concat([outputStream, Buffer.from(firstChunk.toString(16), "hex")]); + payload = JSBI.asUintN(64, JSBI.leftShift(JSBI.BigInt(payload), JSBI.BigInt(0x8))); + let byteToWrite = JSBI.BigInt(0); + let shifted; + let padded; + do { + { + // we pad because after shifting because we will produce characters like "f" or similar, + // which cannot be encoded as hex in a buffer because they are invalid hex + // https://github.com/nodejs/node/issues/24491 + padded = byteToWrite.toString(16).padStart(2, "0"); + if (padded !== "00") { + outputStream = Buffer.concat([outputStream, Buffer.from(padded, "hex")]); + } + } + shifted = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56))); + byteToWrite = JSBI.asUintN(64, JSBI.bitwiseOr(shifted, JSBI.BigInt(0x01))); + payload = JSBI.asUintN(64, JSBI.leftShift(payload, JSBI.BigInt(7))); + } while (JSBI.notEqual(payload, JSBI.BigInt(0))); + const lastChunk = JSBI.asUintN(64, JSBI.bitwiseAnd(byteToWrite, JSBI.BigInt(0xfe))); + // we pad because after shifting because we will produce characters like "f" or similar, + // which cannot be encoded as hex in a buffer because they are invalid hex + // https://github.com/nodejs/node/issues/24491 + padded = lastChunk.toString(16).padStart(2, "0"); + if (padded !== "00") { + outputStream = Buffer.concat([outputStream, Buffer.from(padded, "hex")]); + } + return outputStream; +} +function encodeNumberAsUInt64JSBI(value) { + const rawValueBits = getRawBitsJSBI(value); + const mask = JSBI.BigInt(0x8000000000000000); + const returned = rawValueBits < mask + ? JSBI.bitwiseXor(rawValueBits, mask) + : JSBI.add(JSBI.bitwiseNot(rawValueBits), JSBI.BigInt(1)); + return returned; +} +function doubleToByteArrayJSBI(double) { + const output = Buffer.alloc(8); + const lng = getRawBitsJSBI(double); + for (let i = 0; i < 8; i++) { + output[i] = JSBI.toNumber(JSBI.bitwiseAnd(JSBI.signedRightShift(lng, JSBI.multiply(JSBI.BigInt(i), JSBI.BigInt(8))), JSBI.BigInt(0xff))); + } + return output; +} +function getRawBitsJSBI(value) { + const view = new DataView(new ArrayBuffer(8)); + view.setFloat64(0, value); + return JSBI.BigInt(`0x${buf2hex(view.buffer)}`); +} +function buf2hex(buffer) { + return Array.prototype.map + .call(new Uint8Array(buffer), (x) => ("00" + x.toString(16)).slice(-2)) + .join(""); +} + +// +----------------------------------------------------------------------+ +// | murmurHash3js.js v3.0.1 // https://github.com/pid/murmurHash3js +// | A javascript implementation of MurmurHash3's x86 hashing algorithms. | +// |----------------------------------------------------------------------| +// | Copyright (c) 2012-2015 Karan Lyons | +// | https://github.com/karanlyons/murmurHash3.js/blob/c1778f75792abef7bdd74bc85d2d4e1a3d25cfe9/murmurHash3.js | +// | Freely distributable under the MIT license. | +// +----------------------------------------------------------------------+ +// PRIVATE FUNCTIONS +// ----------------- +function _x86Multiply(m, n) { + // + // Given two 32bit ints, returns the two multiplied together as a + // 32bit int. + // + return (m & 0xffff) * n + ((((m >>> 16) * n) & 0xffff) << 16); +} +function _x86Rotl(m, n) { + // + // Given a 32bit int and an int representing a number of bit positions, + // returns the 32bit int rotated left by that number of positions. + // + return (m << n) | (m >>> (32 - n)); +} +function _x86Fmix(h) { + // + // Given a block, returns murmurHash3's final x86 mix of that block. + // + h ^= h >>> 16; + h = _x86Multiply(h, 0x85ebca6b); + h ^= h >>> 13; + h = _x86Multiply(h, 0xc2b2ae35); + h ^= h >>> 16; + return h; +} +function _x64Add(m, n) { + // + // Given two 64bit ints (as an array of two 32bit ints) returns the two + // added together as a 64bit int (as an array of two 32bit ints). + // + m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff]; + n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff]; + const o = [0, 0, 0, 0]; + o[3] += m[3] + n[3]; + o[2] += o[3] >>> 16; + o[3] &= 0xffff; + o[2] += m[2] + n[2]; + o[1] += o[2] >>> 16; + o[2] &= 0xffff; + o[1] += m[1] + n[1]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[0] += m[0] + n[0]; + o[0] &= 0xffff; + return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]]; +} +function _x64Multiply(m, n) { + // + // Given two 64bit ints (as an array of two 32bit ints) returns the two + // multiplied together as a 64bit int (as an array of two 32bit ints). + // + m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff]; + n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff]; + const o = [0, 0, 0, 0]; + o[3] += m[3] * n[3]; + o[2] += o[3] >>> 16; + o[3] &= 0xffff; + o[2] += m[2] * n[3]; + o[1] += o[2] >>> 16; + o[2] &= 0xffff; + o[2] += m[3] * n[2]; + o[1] += o[2] >>> 16; + o[2] &= 0xffff; + o[1] += m[1] * n[3]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[1] += m[2] * n[2]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[1] += m[3] * n[1]; + o[0] += o[1] >>> 16; + o[1] &= 0xffff; + o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0]; + o[0] &= 0xffff; + return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]]; +} +function _x64Rotl(m, n) { + // + // Given a 64bit int (as an array of two 32bit ints) and an int + // representing a number of bit positions, returns the 64bit int (as an + // array of two 32bit ints) rotated left by that number of positions. + // + n %= 64; + if (n === 32) { + return [m[1], m[0]]; + } + else if (n < 32) { + return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))]; + } + else { + n -= 32; + return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))]; + } +} +function _x64LeftShift(m, n) { + // + // Given a 64bit int (as an array of two 32bit ints) and an int + // representing a number of bit positions, returns the 64bit int (as an + // array of two 32bit ints) shifted left by that number of positions. + // + n %= 64; + if (n === 0) { + return m; + } + else if (n < 32) { + return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n]; + } + else { + return [m[1] << (n - 32), 0]; + } +} +function _x64Xor(m, n) { + // + // Given two 64bit ints (as an array of two 32bit ints) returns the two + // xored together as a 64bit int (as an array of two 32bit ints). + // + return [m[0] ^ n[0], m[1] ^ n[1]]; +} +function _x64Fmix(h) { + // + // Given a block, returns murmurHash3's final x64 mix of that block. + // (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the + // only place where we need to right shift 64bit ints.) + // + h = _x64Xor(h, [0, h[0] >>> 1]); + h = _x64Multiply(h, [0xff51afd7, 0xed558ccd]); + h = _x64Xor(h, [0, h[0] >>> 1]); + h = _x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]); + h = _x64Xor(h, [0, h[0] >>> 1]); + return h; +} +// PUBLIC FUNCTIONS +// ---------------- +function x86Hash32(bytes, seed) { + // + // Given a string and an optional seed as an int, returns a 32 bit hash + // using the x86 flavor of MurmurHash3, as an unsigned int. + // + seed = seed || 0; + const remainder = bytes.length % 4; + const blocks = bytes.length - remainder; + let h1 = seed; + let k1 = 0; + const c1 = 0xcc9e2d51; + const c2 = 0x1b873593; + let j = 0; + for (let i = 0; i < blocks; i = i + 4) { + k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24); + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + h1 = _x86Rotl(h1, 13); + h1 = _x86Multiply(h1, 5) + 0xe6546b64; + j = i + 4; + } + k1 = 0; + switch (remainder) { + case 3: + k1 ^= bytes[j + 2] << 16; + case 2: + k1 ^= bytes[j + 1] << 8; + case 1: + k1 ^= bytes[j]; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + } + h1 ^= bytes.length; + h1 = _x86Fmix(h1); + return h1 >>> 0; +} +function x86Hash128(bytes, seed) { + // + // Given a string and an optional seed as an int, returns a 128 bit + // hash using the x86 flavor of MurmurHash3, as an unsigned hex. + // + seed = seed || 0; + const remainder = bytes.length % 16; + const blocks = bytes.length - remainder; + let h1 = seed; + let h2 = seed; + let h3 = seed; + let h4 = seed; + let k1 = 0; + let k2 = 0; + let k3 = 0; + let k4 = 0; + const c1 = 0x239b961b; + const c2 = 0xab0e9789; + const c3 = 0x38b34ae5; + const c4 = 0xa1e38b93; + let j = 0; + for (let i = 0; i < blocks; i = i + 16) { + k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24); + k2 = bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24); + k3 = bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24); + k4 = bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24); + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + h1 = _x86Rotl(h1, 19); + h1 += h2; + h1 = _x86Multiply(h1, 5) + 0x561ccd1b; + k2 = _x86Multiply(k2, c2); + k2 = _x86Rotl(k2, 16); + k2 = _x86Multiply(k2, c3); + h2 ^= k2; + h2 = _x86Rotl(h2, 17); + h2 += h3; + h2 = _x86Multiply(h2, 5) + 0x0bcaa747; + k3 = _x86Multiply(k3, c3); + k3 = _x86Rotl(k3, 17); + k3 = _x86Multiply(k3, c4); + h3 ^= k3; + h3 = _x86Rotl(h3, 15); + h3 += h4; + h3 = _x86Multiply(h3, 5) + 0x96cd1c35; + k4 = _x86Multiply(k4, c4); + k4 = _x86Rotl(k4, 18); + k4 = _x86Multiply(k4, c1); + h4 ^= k4; + h4 = _x86Rotl(h4, 13); + h4 += h1; + h4 = _x86Multiply(h4, 5) + 0x32ac3b17; + j = i + 16; + } + k1 = 0; + k2 = 0; + k3 = 0; + k4 = 0; + switch (remainder) { + case 15: + k4 ^= bytes[j + 14] << 16; + case 14: + k4 ^= bytes[j + 13] << 8; + case 13: + k4 ^= bytes[j + 12]; + k4 = _x86Multiply(k4, c4); + k4 = _x86Rotl(k4, 18); + k4 = _x86Multiply(k4, c1); + h4 ^= k4; + case 12: + k3 ^= bytes[j + 11] << 24; + case 11: + k3 ^= bytes[j + 10] << 16; + case 10: + k3 ^= bytes[j + 9] << 8; + case 9: + k3 ^= bytes[j + 8]; + k3 = _x86Multiply(k3, c3); + k3 = _x86Rotl(k3, 17); + k3 = _x86Multiply(k3, c4); + h3 ^= k3; + case 8: + k2 ^= bytes[j + 7] << 24; + case 7: + k2 ^= bytes[j + 6] << 16; + case 6: + k2 ^= bytes[j + 5] << 8; + case 5: + k2 ^= bytes[j + 4]; + k2 = _x86Multiply(k2, c2); + k2 = _x86Rotl(k2, 16); + k2 = _x86Multiply(k2, c3); + h2 ^= k2; + case 4: + k1 ^= bytes[j + 3] << 24; + case 3: + k1 ^= bytes[j + 2] << 16; + case 2: + k1 ^= bytes[j + 1] << 8; + case 1: + k1 ^= bytes[j]; + k1 = _x86Multiply(k1, c1); + k1 = _x86Rotl(k1, 15); + k1 = _x86Multiply(k1, c2); + h1 ^= k1; + } + h1 ^= bytes.length; + h2 ^= bytes.length; + h3 ^= bytes.length; + h4 ^= bytes.length; + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + h1 = _x86Fmix(h1); + h2 = _x86Fmix(h2); + h3 = _x86Fmix(h3); + h4 = _x86Fmix(h4); + h1 += h2; + h1 += h3; + h1 += h4; + h2 += h1; + h3 += h1; + h4 += h1; + return (("00000000" + (h1 >>> 0).toString(16)).slice(-8) + + ("00000000" + (h2 >>> 0).toString(16)).slice(-8) + + ("00000000" + (h3 >>> 0).toString(16)).slice(-8) + + ("00000000" + (h4 >>> 0).toString(16)).slice(-8)); +} +function x64Hash128(bytes, seed) { + // + // Given a string and an optional seed as an int, returns a 128 bit + // hash using the x64 flavor of MurmurHash3, as an unsigned hex. + // + seed = seed || 0; + const remainder = bytes.length % 16; + const blocks = bytes.length - remainder; + let h1 = [0, seed]; + let h2 = [0, seed]; + let k1 = [0, 0]; + let k2 = [0, 0]; + const c1 = [0x87c37b91, 0x114253d5]; + const c2 = [0x4cf5ad43, 0x2745937f]; + let j = 0; + for (let i = 0; i < blocks; i = i + 16) { + k1 = [ + bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24), + bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24), + ]; + k2 = [ + bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24), + bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24), + ]; + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c2); + h1 = _x64Xor(h1, k1); + h1 = _x64Rotl(h1, 27); + h1 = _x64Add(h1, h2); + h1 = _x64Add(_x64Multiply(h1, [0, 5]), [0, 0x52dce729]); + k2 = _x64Multiply(k2, c2); + k2 = _x64Rotl(k2, 33); + k2 = _x64Multiply(k2, c1); + h2 = _x64Xor(h2, k2); + h2 = _x64Rotl(h2, 31); + h2 = _x64Add(h2, h1); + h2 = _x64Add(_x64Multiply(h2, [0, 5]), [0, 0x38495ab5]); + j = i + 16; + } + k1 = [0, 0]; + k2 = [0, 0]; + switch (remainder) { + case 15: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 14]], 48)); + case 14: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 13]], 40)); + case 13: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 12]], 32)); + case 12: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 11]], 24)); + case 11: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 10]], 16)); + case 10: + k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 9]], 8)); + case 9: + k2 = _x64Xor(k2, [0, bytes[j + 8]]); + k2 = _x64Multiply(k2, c2); + k2 = _x64Rotl(k2, 33); + k2 = _x64Multiply(k2, c1); + h2 = _x64Xor(h2, k2); + case 8: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 7]], 56)); + case 7: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 6]], 48)); + case 6: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 5]], 40)); + case 5: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 4]], 32)); + case 4: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 3]], 24)); + case 3: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 2]], 16)); + case 2: + k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 1]], 8)); + case 1: + k1 = _x64Xor(k1, [0, bytes[j]]); + k1 = _x64Multiply(k1, c1); + k1 = _x64Rotl(k1, 31); + k1 = _x64Multiply(k1, c2); + h1 = _x64Xor(h1, k1); + } + h1 = _x64Xor(h1, [0, bytes.length]); + h2 = _x64Xor(h2, [0, bytes.length]); + h1 = _x64Add(h1, h2); + h2 = _x64Add(h2, h1); + h1 = _x64Fmix(h1); + h2 = _x64Fmix(h2); + h1 = _x64Add(h1, h2); + h2 = _x64Add(h2, h1); + // Here we reverse h1 and h2 in Cosmos + // This is an implementation detail and not part of the public spec + const h1Buff = Buffer.from(("00000000" + (h1[0] >>> 0).toString(16)).slice(-8) + + ("00000000" + (h1[1] >>> 0).toString(16)).slice(-8), "hex"); + const h1Reversed = reverse$1(h1Buff).toString("hex"); + const h2Buff = Buffer.from(("00000000" + (h2[0] >>> 0).toString(16)).slice(-8) + + ("00000000" + (h2[1] >>> 0).toString(16)).slice(-8), "hex"); + const h2Reversed = reverse$1(h2Buff).toString("hex"); + return h1Reversed + h2Reversed; +} +function reverse$1(buff) { + const buffer = Buffer.allocUnsafe(buff.length); + for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) { + buffer[i] = buff[j]; + buffer[j] = buff[i]; + } + return buffer; +} +var MurmurHash = { + version: "3.0.0", + x86: { + hash32: x86Hash32, + hash128: x86Hash128, + }, + x64: { + hash128: x64Hash128, + }, + inputValidation: true, +}; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function hashV2PartitionKey(partitionKey) { + const toHash = Buffer.concat(partitionKey.map(prefixKeyByType$1)); + const hash = MurmurHash.x64.hash128(toHash); + const reverseBuff = reverse(Buffer.from(hash, "hex")); + reverseBuff[0] &= 0x3f; + return reverseBuff.toString("hex").toUpperCase(); +} +function prefixKeyByType$1(key) { + let bytes; + switch (typeof key) { + case "string": { + bytes = Buffer.concat([ + Buffer.from(BytePrefix.String, "hex"), + Buffer.from(key), + Buffer.from(BytePrefix.Infinity, "hex"), + ]); + return bytes; + } + case "number": { + const numberBytes = doubleToByteArrayJSBI(key); + bytes = Buffer.concat([Buffer.from(BytePrefix.Number, "hex"), numberBytes]); + return bytes; + } + case "boolean": { + const prefix = key ? BytePrefix.True : BytePrefix.False; + return Buffer.from(prefix, "hex"); + } + case "object": { + if (key === null) { + return Buffer.from(BytePrefix.Null, "hex"); + } + return Buffer.from(BytePrefix.Undefined, "hex"); + } + case "undefined": { + return Buffer.from(BytePrefix.Undefined, "hex"); + } + default: + throw new Error(`Unexpected type: ${typeof key}`); + } +} +function reverse(buff) { + const buffer = Buffer.allocUnsafe(buff.length); + for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) { + buffer[i] = buff[j]; + buffer[j] = buff[i]; + } + return buffer; +} + +/** + * Generate Hash for a `Multi Hash` type partition. + * @param partitionKey - to be hashed. + * @returns + */ +function hashMultiHashPartitionKey(partitionKey) { + return partitionKey.map((keys) => hashV2PartitionKey([keys])).join(""); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function writeStringForBinaryEncoding(payload) { + let outputStream = Buffer.from(BytePrefix.String, "hex"); + const MAX_STRING_BYTES_TO_APPEND = 100; + const byteArray = [...Buffer.from(payload)]; + const isShortString = payload.length <= MAX_STRING_BYTES_TO_APPEND; + for (let index = 0; index < (isShortString ? byteArray.length : MAX_STRING_BYTES_TO_APPEND + 1); index++) { + let charByte = byteArray[index]; + if (charByte < 0xff) { + charByte++; + } + outputStream = Buffer.concat([outputStream, Buffer.from(charByte.toString(16), "hex")]); + } + if (isShortString) { + outputStream = Buffer.concat([outputStream, Buffer.from(BytePrefix.Undefined, "hex")]); + } + return outputStream; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const MAX_STRING_CHARS = 100; +function hashV1PartitionKey(partitionKey) { + const key = partitionKey[0]; + const toHash = prefixKeyByType(key); + const hash = MurmurHash.x86.hash32(toHash); + const encodedJSBI = writeNumberForBinaryEncodingJSBI(hash); + const encodedValue = encodeByType(key); + const finalHash = Buffer.concat([encodedJSBI, encodedValue]).toString("hex").toUpperCase(); + return finalHash; +} +function prefixKeyByType(key) { + let bytes; + switch (typeof key) { + case "string": { + const truncated = key.substr(0, MAX_STRING_CHARS); + bytes = Buffer.concat([ + Buffer.from(BytePrefix.String, "hex"), + Buffer.from(truncated), + Buffer.from(BytePrefix.Undefined, "hex"), + ]); + return bytes; + } + case "number": { + const numberBytes = doubleToByteArrayJSBI(key); + bytes = Buffer.concat([Buffer.from(BytePrefix.Number, "hex"), numberBytes]); + return bytes; + } + case "boolean": { + const prefix = key ? BytePrefix.True : BytePrefix.False; + return Buffer.from(prefix, "hex"); + } + case "object": { + if (key === null) { + return Buffer.from(BytePrefix.Null, "hex"); + } + return Buffer.from(BytePrefix.Undefined, "hex"); + } + case "undefined": { + return Buffer.from(BytePrefix.Undefined, "hex"); + } + default: + throw new Error(`Unexpected type: ${typeof key}`); + } +} +function encodeByType(key) { + switch (typeof key) { + case "string": { + const truncated = key.substr(0, MAX_STRING_CHARS); + return writeStringForBinaryEncoding(truncated); + } + case "number": { + const encodedJSBI = writeNumberForBinaryEncodingJSBI(key); + return encodedJSBI; + } + case "boolean": { + const prefix = key ? BytePrefix.True : BytePrefix.False; + return Buffer.from(prefix, "hex"); + } + case "object": + if (key === null) { + return Buffer.from(BytePrefix.Null, "hex"); + } + return Buffer.from(BytePrefix.Undefined, "hex"); + case "undefined": + return Buffer.from(BytePrefix.Undefined, "hex"); + default: + throw new Error(`Unexpected type: ${typeof key}`); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Generate hash of a PartitonKey based on it PartitionKeyDefinition. + * @param partitionKey - to be hashed. + * @param partitionDefinition - container's partitionKey definition + * @returns + */ +function hashPartitionKey(partitionKey, partitionDefinition) { + const kind = (partitionDefinition === null || partitionDefinition === void 0 ? void 0 : partitionDefinition.kind) || exports.PartitionKeyKind.Hash; // Default value. + const isV2 = partitionDefinition && + partitionDefinition.version && + partitionDefinition.version === exports.PartitionKeyDefinitionVersion.V2; + switch (kind) { + case exports.PartitionKeyKind.Hash: + return isV2 ? hashV2PartitionKey(partitionKey) : hashV1PartitionKey(partitionKey); + case exports.PartitionKeyKind.MultiHash: + return hashMultiHashPartitionKey(partitionKey); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @internal + * FeedRange for which change feed is being requested. + */ +class ChangeFeedRange { + constructor(minInclusive, maxExclusive, continuationToken, epkMinHeader, epkMaxHeader) { + this.minInclusive = minInclusive; + this.maxExclusive = maxExclusive; + this.continuationToken = continuationToken; + this.epkMinHeader = epkMinHeader; + this.epkMaxHeader = epkMaxHeader; + } +} + +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +class ChangeFeedIteratorResponse { + /** + * @internal + */ + constructor( + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + result, + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + count, + /** + * Gets the status code of the response from Azure Cosmos DB + */ + statusCode, + /** + * Headers related to cosmos DB and change feed. + */ + headers, + /** + * Cosmos Diagnostic Object. + */ + diagnostics, + /** + * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone. + */ + subStatusCode) { + this.result = result; + this.count = count; + this.statusCode = statusCode; + this.diagnostics = diagnostics; + this.subStatusCode = subStatusCode; + this.headers = headers; + } + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge() { + const rus = this.headers[Constants$1.HttpHeaders.RequestCharge]; + return rus ? parseInt(rus, 10) : null; + } + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId() { + return this.headers[Constants$1.HttpHeaders.ActivityId]; + } + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + */ + get continuationToken() { + return this.headers[Constants$1.HttpHeaders.ContinuationToken]; + } + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken() { + return this.headers[Constants$1.HttpHeaders.SessionToken]; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * A queue for iterating over specified Epk ranges and fetch change feed for the given epk ranges. + */ +class FeedRangeQueue { + constructor() { + this.elements = []; + } + modifyFirstElement(newItem) { + if (!this.isEmpty()) { + this.elements[0] = newItem; + } + } + enqueue(item) { + this.elements.push(item); + } + dequeue() { + return this.elements.shift(); + } + peek() { + return !this.isEmpty() ? this.elements[0] : undefined; + } + isEmpty() { + return this.elements.length === 0; + } + moveFirstElementToTheEnd() { + if (!this.isEmpty()) { + this.elements.push(this.dequeue()); + } + } + /** + * Returns a snapshot of the queue as an array to be used as Continuation token. + */ + returnSnapshot() { + const allFeedRanges = []; + this.elements.map((element) => { + const minInclusive = element.epkMinHeader ? element.epkMinHeader : element.minInclusive; + const maxExclusive = element.epkMaxHeader ? element.epkMaxHeader : element.maxExclusive; + const feedRangeElement = new ChangeFeedRange(minInclusive, maxExclusive, element.continuationToken); + allFeedRanges.push(feedRangeElement); + }); + return allFeedRanges; + } +} + +/** + * Continuation token for change feed of entire container, or a specific Epk Range. + * @internal + */ +class CompositeContinuationToken { + constructor(rid, Continuation) { + this.rid = rid; + this.Continuation = Continuation; + } +} + +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time. + */ +class ChangeFeedStartFromBeginning { + constructor(cfResource) { + this.cfResource = cfResource; + } + getCfResource() { + return this.cfResource; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time. + */ +class ChangeFeedStartFromNow { + constructor(cfResource) { + this.cfResource = cfResource; + } + getCfResource() { + return this.cfResource; + } +} + +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time. + */ +class ChangeFeedStartFromTime { + constructor(startTime, cfResource) { + this.startTime = startTime; + this.cfResource = cfResource; + } + getCfResource() { + return this.cfResource; + } + getStartTime() { + return this.startTime; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Specifies a feed range for the changefeed. + */ +class FeedRange { + /** + * @internal + */ + constructor(minInclusive, maxExclusive) { + // only way to explictly block users from creating FeedRange directly in JS + if (new.target === FeedRange) { + throw new ErrorResponse("Cannot instantiate abstract class FeedRange"); + } + this.minInclusive = minInclusive; + this.maxExclusive = maxExclusive; + } +} +/** + * @hidden + * Specifies a feed range for the changefeed. + */ +class FeedRangeInternal extends FeedRange { + /* eslint-disable @typescript-eslint/no-useless-constructor */ + constructor(minInclusive, maxExclusive) { + super(minInclusive, maxExclusive); + } +} + +/** + * @hidden + * Validates the change feed options passed by the user + */ +function validateChangeFeedIteratorOptions(options) { + if (!isChangeFeedIteratorOptions(options)) { + throw new ErrorResponse("Invalid Changefeed Iterator Options."); + } + if ((options === null || options === void 0 ? void 0 : options.maxItemCount) && typeof (options === null || options === void 0 ? void 0 : options.maxItemCount) !== "number") { + throw new ErrorResponse("maxItemCount must be number"); + } + if ((options === null || options === void 0 ? void 0 : options.maxItemCount) !== undefined && (options === null || options === void 0 ? void 0 : options.maxItemCount) < 1) { + throw new ErrorResponse("maxItemCount must be a positive number"); + } +} +function isChangeFeedIteratorOptions(options) { + if (typeof options !== "object") { + return false; + } + if (Object.keys(options).length === 0 && JSON.stringify(options) === "{}") { + return true; + } + return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options)); +} +/** + * @hidden + * Checks if pkRange entirely covers the given overLapping range or there is only partial overlap. + * + * If no complete overlap, exact range which overlaps is retured which is used to set minEpk and maxEpk headers while quering change feed. + */ +async function extractOverlappingRanges(epkRange, overLappingRange) { + if (overLappingRange.minInclusive >= epkRange.min && + overLappingRange.maxExclusive <= epkRange.max) { + return [undefined, undefined]; + } + else if (overLappingRange.minInclusive <= epkRange.min && + overLappingRange.maxExclusive >= epkRange.max) { + return [epkRange.min, epkRange.max]; + } + // Right Side of overlapping range is covered + else if (overLappingRange.minInclusive <= epkRange.min && + overLappingRange.maxExclusive <= epkRange.max && + overLappingRange.maxExclusive >= epkRange.min) { + return [epkRange.min, overLappingRange.maxExclusive]; + } + // Left Side of overlapping range is covered + else { + return [overLappingRange.minInclusive, epkRange.max]; + } +} +/** + * @hidden + * Checks if the object is a valid EpkRange + */ +function isEpkRange(obj) { + return (obj instanceof FeedRangeInternal && + typeof obj.minInclusive === "string" && + typeof obj.maxExclusive === "string" && + obj.minInclusive >= + Constants$1.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey && + obj.maxExclusive <= + Constants$1.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey && + obj.maxExclusive > obj.minInclusive); +} +/** + * @hidden + */ +function buildInternalChangeFeedOptions(options, continuationToken, startTime) { + const internalCfOptions = {}; + internalCfOptions.maxItemCount = options === null || options === void 0 ? void 0 : options.maxItemCount; + internalCfOptions.sessionToken = options === null || options === void 0 ? void 0 : options.sessionToken; + internalCfOptions.continuationToken = continuationToken; + // Default option of changefeed is to start from now. + internalCfOptions.startTime = startTime; + return internalCfOptions; +} +/** + * @hidden + */ +function fetchStartTime(changeFeedStartFrom) { + if (changeFeedStartFrom instanceof ChangeFeedStartFromBeginning) { + return undefined; + } + else if (changeFeedStartFrom instanceof ChangeFeedStartFromNow) { + return new Date(); + } + else if (changeFeedStartFrom instanceof ChangeFeedStartFromTime) { + return changeFeedStartFrom.getStartTime(); + } +} +/** + * @hidden + */ +function isNullOrEmpty(text) { + return text === null || text === undefined || text.trim() === ""; +} + +/** + * @hidden + * Provides iterator for change feed for entire container or an epk range. + * + * Use `Items.getChangeFeedIterator()` to get an instance of the iterator. + */ +class ChangeFeedForEpkRange { + /** + * @internal + */ + constructor(clientContext, container, partitionKeyRangeCache, resourceId, resourceLink, url, changeFeedOptions, epkRange) { + this.clientContext = clientContext; + this.container = container; + this.partitionKeyRangeCache = partitionKeyRangeCache; + this.resourceId = resourceId; + this.resourceLink = resourceLink; + this.url = url; + this.changeFeedOptions = changeFeedOptions; + this.epkRange = epkRange; + this.generateContinuationToken = () => { + return JSON.stringify(new CompositeContinuationToken(this.rId, this.queue.returnSnapshot())); + }; + this.queue = new FeedRangeQueue(); + this.continuationToken = changeFeedOptions.continuationToken + ? JSON.parse(changeFeedOptions.continuationToken) + : undefined; + this.startTime = changeFeedOptions.startTime + ? changeFeedOptions.startTime.toUTCString() + : undefined; + this.isInstantiated = false; + } + async setIteratorRid(diagnosticNode) { + const { resource } = await this.container.readInternal(diagnosticNode); + this.rId = resource._rid; + } + continuationTokenRidMatchContainerRid() { + if (this.continuationToken.rid !== this.rId) { + return false; + } + return true; + } + async fillChangeFeedQueue(diagnosticNode) { + if (this.continuationToken) { + // fill the queue with feed ranges in continuation token. + await this.fetchContinuationTokenFeedRanges(diagnosticNode); + } + else { + // fill the queue with feed ranges overlapping the given epk range. + await this.fetchOverLappingFeedRanges(diagnosticNode); + } + this.isInstantiated = true; + } + /** + * Fill the queue with the feed ranges overlapping with the given epk range. + */ + async fetchOverLappingFeedRanges(diagnosticNode) { + try { + const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, this.epkRange, diagnosticNode); + for (const overLappingRange of overLappingRanges) { + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(this.epkRange, overLappingRange); + const feedRange = new ChangeFeedRange(overLappingRange.minInclusive, overLappingRange.maxExclusive, "", epkMinHeader, epkMaxHeader); + this.queue.enqueue(feedRange); + } + } + catch (err) { + throw new ErrorResponse(err.message); + } + } + /** + * Fill the queue with feed ranges from continuation token + */ + async fetchContinuationTokenFeedRanges(diagnosticNode) { + const contToken = this.continuationToken; + if (!this.continuationTokenRidMatchContainerRid()) { + throw new ErrorResponse("The continuation token is not for the current container definition"); + } + else { + for (const cToken of contToken.Continuation) { + const queryRange = new QueryRange(cToken.minInclusive, cToken.maxExclusive, true, false); + try { + const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, queryRange, diagnosticNode); + for (const overLappingRange of overLappingRanges) { + // check if the epk range present in continuation token entirely covers the overlapping range. + // If yes, minInclusive and maxExclusive of the overlapping range will be set. + // If no, i.e. there is only partial overlap, epkMinHeader and epkMaxHeader are set as min and max of overlap. + // This will be used when we make a call to fetch change feed. + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(queryRange, overLappingRange); + const feedRange = new ChangeFeedRange(overLappingRange.minInclusive, overLappingRange.maxExclusive, cToken.continuationToken, epkMinHeader, epkMaxHeader); + this.queue.enqueue(feedRange); + } + } + catch (err) { + throw new ErrorResponse(err.message); + } + } + } + } + /** + * Change feed is an infinite feed. hasMoreResults is always true. + */ + get hasMoreResults() { + return true; + } + /** + * Gets an async iterator which will yield change feed results. + */ + getAsyncIterator() { + return tslib.__asyncGenerator(this, arguments, function* getAsyncIterator_1() { + do { + const result = yield tslib.__await(this.readNext()); + yield yield tslib.__await(result); + } while (this.hasMoreResults); + }); + } + /** + * Gets an async iterator which will yield pages of results from Azure Cosmos DB. + * + * Keeps iterating over the feedranges and checks if any feed range has new result. Keeps note of the last feed range which returned non 304 result. + * + * When same feed range is reached and no new changes are found, a 304 (not Modified) is returned to the end user. Then starts process all over again. + */ + async readNext() { + return withDiagnostics(async (diagnosticNode) => { + // validate if the internal queue is filled up with feed ranges. + if (!this.isInstantiated) { + await this.setIteratorRid(diagnosticNode); + await this.fillChangeFeedQueue(diagnosticNode); + } + // stores the last feedRange for which statusCode is not 304 i.e. there were new changes in that feed range. + let firstNotModifiedFeedRange = undefined; + let result; + do { + const [processedFeedRange, response] = await this.fetchNext(diagnosticNode); + result = response; + if (result !== undefined) { + { + if (firstNotModifiedFeedRange === undefined) { + firstNotModifiedFeedRange = processedFeedRange; + } + // move current feed range to end of queue to fetch result of next feed range. + // This is done to fetch changes in breadth first manner and avoid starvation. + this.queue.moveFirstElementToTheEnd(); + // check if there are new results for the given feed range. + if (result.statusCode === StatusCodes.Ok) { + result.headers[Constants$1.HttpHeaders.ContinuationToken] = + this.generateContinuationToken(); + return result; + } + } + } + } while (!this.checkedAllFeedRanges(firstNotModifiedFeedRange)); + // set the continuation token after processing. + result.headers[Constants$1.HttpHeaders.ContinuationToken] = this.generateContinuationToken(); + return result; + }, this.clientContext); + } + /** + * Read feed and retrieves the next page of results in Azure Cosmos DB. + */ + async fetchNext(diagnosticNode) { + const feedRange = this.queue.peek(); + if (feedRange) { + // fetch results for feed range at the beginning of the queue. + const result = await this.getFeedResponse(feedRange, diagnosticNode); + // check if results need to be fetched again depending on status code returned. + // Eg. in case of paritionSplit, results need to be fetched for the child partitions. + const shouldRetry = await this.shouldRetryOnFailure(feedRange, result, diagnosticNode); + if (shouldRetry) { + this.queue.dequeue(); + return this.fetchNext(diagnosticNode); + } + else { + // update the continuation value for the current feed range. + const continuationValueForFeedRange = result.headers[Constants$1.HttpHeaders.ETag]; + const newFeedRange = this.queue.peek(); + newFeedRange.continuationToken = continuationValueForFeedRange; + return [[newFeedRange.minInclusive, newFeedRange.maxExclusive], result]; + } + } + else { + return [[undefined, undefined], undefined]; + } + } + checkedAllFeedRanges(firstNotModifiedFeedRange) { + if (firstNotModifiedFeedRange === undefined) { + return false; + } + const feedRangeQueueFirstElement = this.queue.peek(); + return (firstNotModifiedFeedRange[0] === (feedRangeQueueFirstElement === null || feedRangeQueueFirstElement === void 0 ? void 0 : feedRangeQueueFirstElement.minInclusive) && + firstNotModifiedFeedRange[1] === (feedRangeQueueFirstElement === null || feedRangeQueueFirstElement === void 0 ? void 0 : feedRangeQueueFirstElement.maxExclusive)); + } + /** + * Checks whether the current EpkRange is split into multiple ranges or not. + * + * If yes, it force refreshes the partitionKeyRange cache and enqueue children epk ranges. + */ + async shouldRetryOnFailure(feedRange, response, diagnosticNode) { + if (response.statusCode === StatusCodes.Ok || response.statusCode === StatusCodes.NotModified) { + return false; + } + const partitionSplit = response.statusCode === StatusCodes.Gone && + (response.subStatusCode === SubStatusCodes.PartitionKeyRangeGone || + response.subStatusCode === SubStatusCodes.CompletingSplit); + if (partitionSplit) { + const queryRange = new QueryRange(feedRange.minInclusive, feedRange.maxExclusive, true, false); + const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, queryRange, diagnosticNode, true); + if (resolvedRanges.length < 1) { + throw new ErrorResponse("Partition split/merge detected but no overlapping ranges found."); + } + // This covers both cases of merge and split. + // resolvedRanges.length > 1 in case of split. + // resolvedRanges.length === 1 in case of merge. EpkRange headers will be added in this case. + if (resolvedRanges.length >= 1) { + await this.handleSplit(false, resolvedRanges, queryRange, feedRange.continuationToken); + } + return true; + } + return false; + } + /* + * Enqueues all the children feed ranges for the given feed range. + */ + async handleSplit(shiftLeft, resolvedRanges, oldFeedRange, continuationToken) { + let flag = 0; + if (shiftLeft) { + // This section is only applicable when handleSplit is called by getPartitionRangeId(). + // used only when existing partition key range cache is used to check for any overlapping ranges. + // Modifies the first element with the first overlapping range. + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(oldFeedRange, resolvedRanges[0]); + const newFeedRange = new ChangeFeedRange(resolvedRanges[0].minInclusive, resolvedRanges[0].maxExclusive, continuationToken, epkMinHeader, epkMaxHeader); + this.queue.modifyFirstElement(newFeedRange); + flag = 1; + } + // Enqueue the overlapping ranges. + for (let i = flag; i < resolvedRanges.length; i++) { + const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(oldFeedRange, resolvedRanges[i]); + const newFeedRange = new ChangeFeedRange(resolvedRanges[i].minInclusive, resolvedRanges[i].maxExclusive, continuationToken, epkMinHeader, epkMaxHeader); + this.queue.enqueue(newFeedRange); + } + } + /** + * Fetch the partitionKeyRangeId for the given feed range. + * + * This partitionKeyRangeId is passed to queryFeed to fetch the results. + */ + async getPartitionRangeId(feedRange, diagnosticNode) { + const min = feedRange.epkMinHeader ? feedRange.epkMinHeader : feedRange.minInclusive; + const max = feedRange.epkMaxHeader ? feedRange.epkMaxHeader : feedRange.maxExclusive; + const queryRange = new QueryRange(min, max, true, false); + const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(this.url, queryRange, diagnosticNode, false); + if (resolvedRanges.length < 1) { + throw new ErrorResponse("No overlapping ranges found."); + } + const firstResolvedRange = resolvedRanges[0]; + if (resolvedRanges.length > 1) { + await this.handleSplit(true, resolvedRanges, queryRange, feedRange.continuationToken); + } + return firstResolvedRange.id; + } + async getFeedResponse(feedRange, diagnosticNode) { + const feedOptions = { initialHeaders: {}, useIncrementalFeed: true }; + if (typeof this.changeFeedOptions.maxItemCount === "number") { + feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount; + } + if (this.changeFeedOptions.sessionToken) { + feedOptions.sessionToken = this.changeFeedOptions.sessionToken; + } + if (feedRange.continuationToken) { + feedOptions.accessCondition = { + type: Constants$1.HttpHeaders.IfNoneMatch, + condition: feedRange.continuationToken, + }; + } + if (this.startTime) { + feedOptions.initialHeaders[Constants$1.HttpHeaders.IfModifiedSince] = this.startTime; + } + const rangeId = await this.getPartitionRangeId(feedRange, diagnosticNode); + try { + // startEpk and endEpk are only valid in case we want to fetch result for a part of partition and not the entire partition. + const response = await this.clientContext.queryFeed({ + path: this.resourceLink, + resourceType: exports.ResourceType.item, + resourceId: this.resourceId, + resultFn: (result) => (result ? result.Documents : []), + query: undefined, + options: feedOptions, + diagnosticNode, + partitionKey: undefined, + partitionKeyRangeId: rangeId, + startEpk: feedRange.epkMinHeader, + endEpk: feedRange.epkMaxHeader, + }); + return new ChangeFeedIteratorResponse(response.result, response.result ? response.result.length : 0, response.code, response.headers, getEmptyCosmosDiagnostics()); + } + catch (err) { + // If any errors are encountered, eg. partition split or gone, handle it based on error code and not break the flow. + return new ChangeFeedIteratorResponse([], 0, err.code, err.headers, getEmptyCosmosDiagnostics(), err.substatus); + } + } +} + +/** + * Continuation token for change feed of entire container, or a specific Epk Range. + * @internal + */ +class ContinuationTokenForPartitionKey { + constructor(rid, partitionKey, continuation) { + this.rid = rid; + this.partitionKey = partitionKey; + this.Continuation = continuation; + } +} + +/** + * @hidden + * Provides iterator for change feed for one partition key. + * + * Use `Items.getChangeFeedIterator()` to get an instance of the iterator. + */ +class ChangeFeedForPartitionKey { + /** + * @internal + */ + constructor(clientContext, container, resourceId, resourceLink, partitionKey, changeFeedOptions) { + this.clientContext = clientContext; + this.container = container; + this.resourceId = resourceId; + this.resourceLink = resourceLink; + this.partitionKey = partitionKey; + this.changeFeedOptions = changeFeedOptions; + this.continuationToken = changeFeedOptions.continuationToken + ? JSON.parse(changeFeedOptions.continuationToken) + : undefined; + this.isInstantiated = false; + if (changeFeedOptions.startTime) { + this.startTime = changeFeedOptions.startTime.toUTCString(); + } + } + async instantiateIterator(diagnosticNode) { + await this.setIteratorRid(diagnosticNode); + if (this.continuationToken) { + if (!this.continuationTokenRidMatchContainerRid()) { + throw new ErrorResponse("The continuation is not for the current container definition."); + } + } + else { + this.continuationToken = new ContinuationTokenForPartitionKey(this.rId, this.partitionKey, ""); + } + this.isInstantiated = true; + } + continuationTokenRidMatchContainerRid() { + if (this.continuationToken.rid !== this.rId) { + return false; + } + return true; + } + async setIteratorRid(diagnosticNode) { + const { resource } = await this.container.readInternal(diagnosticNode); + this.rId = resource._rid; + } + /** + * Change feed is an infinite feed. hasMoreResults is always true. + */ + get hasMoreResults() { + return true; + } + /** + * Gets an async iterator which will yield change feed results. + */ + getAsyncIterator() { + return tslib.__asyncGenerator(this, arguments, function* getAsyncIterator_1() { + do { + const result = yield tslib.__await(this.readNext()); + yield yield tslib.__await(result); + } while (this.hasMoreResults); + }); + } + /** + * Returns the result of change feed from Azure Cosmos DB. + */ + async readNext() { + return withDiagnostics(async (diagnosticNode) => { + if (!this.isInstantiated) { + await this.instantiateIterator(diagnosticNode); + } + const result = await this.fetchNext(diagnosticNode); + return result; + }, this.clientContext); + } + /** + * Read feed and retrieves the next set of results in Azure Cosmos DB. + */ + async fetchNext(diagnosticNode) { + const response = await this.getFeedResponse(diagnosticNode); + this.continuationToken.Continuation = response.headers[Constants$1.HttpHeaders.ETag]; + response.headers[Constants$1.HttpHeaders.ContinuationToken] = JSON.stringify(this.continuationToken); + return response; + } + async getFeedResponse(diagnosticNode) { + const feedOptions = { initialHeaders: {}, useIncrementalFeed: true }; + if (typeof this.changeFeedOptions.maxItemCount === "number") { + feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount; + } + if (this.changeFeedOptions.sessionToken) { + feedOptions.sessionToken = this.changeFeedOptions.sessionToken; + } + const continuation = this.continuationToken.Continuation; + if (continuation) { + feedOptions.accessCondition = { + type: Constants$1.HttpHeaders.IfNoneMatch, + condition: continuation, + }; + } + if (this.startTime) { + feedOptions.initialHeaders[Constants$1.HttpHeaders.IfModifiedSince] = this.startTime; + } + const response = await this.clientContext.queryFeed({ + path: this.resourceLink, + resourceType: exports.ResourceType.item, + resourceId: this.resourceId, + resultFn: (result) => (result ? result.Documents : []), + diagnosticNode, + query: undefined, + options: feedOptions, + partitionKey: this.partitionKey, + }); + return new ChangeFeedIteratorResponse(response.result, response.result ? response.result.length : 0, response.code, response.headers, getEmptyCosmosDiagnostics()); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Enum to specify the resource for which change feed is being fetched. + */ +var ChangeFeedResourceType; +(function (ChangeFeedResourceType) { + ChangeFeedResourceType[ChangeFeedResourceType["FeedRange"] = 0] = "FeedRange"; + ChangeFeedResourceType[ChangeFeedResourceType["PartitionKey"] = 1] = "PartitionKey"; +})(ChangeFeedResourceType || (ChangeFeedResourceType = {})); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a saved point. + */ +class ChangeFeedStartFromContinuation { + constructor(continuation) { + this.continuationToken = continuation; + } + getCfResource() { + return this.continuationToken; + } + getCfResourceJson() { + return JSON.parse(this.continuationToken); + } + getResourceType() { + const cToken = this.getCfResourceJson(); + if (Object.prototype.hasOwnProperty.call(cToken, "partitionKey") && + Object.prototype.hasOwnProperty.call(cToken, "Continuation") && + typeof cToken.Continuation === "string") { + return ChangeFeedResourceType.PartitionKey; + } + else if (Object.prototype.hasOwnProperty.call(cToken, "Continuation") && + Array.isArray(cToken.Continuation) && + cToken.Continuation.length > 0) { + return ChangeFeedResourceType.FeedRange; + } + else { + throw new ErrorResponse("Invalid continuation token."); + } + } +} + +/** + * Base class for where to start a ChangeFeedIterator. + */ +/* eslint-disable @typescript-eslint/no-extraneous-class */ +class ChangeFeedStartFrom { + /** + * Returns an object that tells the ChangeFeedIterator to start from the beginning of time. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Beginning(cfResource) { + return new ChangeFeedStartFromBeginning(cfResource); + } + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + **/ + static Now(cfResource) { + return new ChangeFeedStartFromNow(cfResource); + } + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward. + * @param startTime - Date object specfiying the time to start reading changes from. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Time(startTime, cfResource) { + if (!startTime) { + throw new ErrorResponse("startTime must be present"); + } + if (startTime instanceof Date === true) { + return new ChangeFeedStartFromTime(startTime, cfResource); + } + else { + throw new ErrorResponse("startTime must be a Date object."); + } + } + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point. + * @param continuation - The continuation to resume from. + */ + static Continuation(continuationToken) { + if (!continuationToken) { + throw new ErrorResponse("Argument continuation must be passed."); + } + if (isNullOrEmpty(continuationToken)) { + throw new ErrorResponse("Argument continuationToken must be a non-empty string."); + } + return new ChangeFeedStartFromContinuation(continuationToken); + } +} + +function changeFeedIteratorBuilder(cfOptions, clientContext, container, partitionKeyRangeCache) { + const url = container.url; + const path = getPathFromLink(url, exports.ResourceType.item); + const id = getIdFromLink(url); + let changeFeedStartFrom = cfOptions.changeFeedStartFrom; + if (changeFeedStartFrom === undefined) { + changeFeedStartFrom = ChangeFeedStartFrom.Now(); + } + if (changeFeedStartFrom instanceof ChangeFeedStartFromContinuation) { + const continuationToken = changeFeedStartFrom.getCfResourceJson(); + const resourceType = changeFeedStartFrom.getResourceType(); + const internalCfOptions = buildInternalChangeFeedOptions(cfOptions, changeFeedStartFrom.getCfResource()); + if (resourceType === ChangeFeedResourceType.PartitionKey && + isPartitionKey(continuationToken.partitionKey)) { + return new ChangeFeedForPartitionKey(clientContext, container, id, path, continuationToken.partitionKey, internalCfOptions); + } + else if (resourceType === ChangeFeedResourceType.FeedRange) { + return new ChangeFeedForEpkRange(clientContext, container, partitionKeyRangeCache, id, path, url, internalCfOptions, undefined); + } + else { + throw new ErrorResponse("Invalid continuation token."); + } + } + else if (changeFeedStartFrom instanceof ChangeFeedStartFromNow || + changeFeedStartFrom instanceof ChangeFeedStartFromTime || + changeFeedStartFrom instanceof ChangeFeedStartFromBeginning) { + const startTime = fetchStartTime(changeFeedStartFrom); + const internalCfOptions = buildInternalChangeFeedOptions(cfOptions, undefined, startTime); + const cfResource = changeFeedStartFrom.getCfResource(); + if (isPartitionKey(cfResource)) { + return new ChangeFeedForPartitionKey(clientContext, container, id, path, cfResource, internalCfOptions); + } + else { + let internalCfResource; + if (cfResource === undefined) { + internalCfResource = new QueryRange(Constants$1.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey, Constants$1.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey, true, false); + } + else if (isEpkRange(cfResource)) { + internalCfResource = new QueryRange(cfResource.minInclusive, cfResource.maxExclusive, true, false); + } + else { + throw new ErrorResponse("Invalid feed range."); + } + return new ChangeFeedForEpkRange(clientContext, container, partitionKeyRangeCache, id, path, url, internalCfOptions, internalCfResource); + } + } + else { + throw new ErrorResponse("Invalid change feed start location."); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const uuid$1 = uuid$3.v4; +/** + * @hidden + */ +function isChangeFeedOptions(options) { + return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options)); +} +/** + * Operations for creating new items, and reading/querying all items + * + * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`. + */ +class Items { + /** + * Create an instance of {@link Items} linked to the parent {@link Container}. + * @param container - The parent container. + * @hidden + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + this.partitionKeyRangeCache = new PartitionKeyRangeCache(this.clientContext); + } + query(query, options = {}) { + const path = getPathFromLink(this.container.url, exports.ResourceType.item); + const id = getIdFromLink(this.container.url); + const fetchFunction = async (diagnosticNode, innerOptions) => { + const response = await this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.item, + resourceId: id, + resultFn: (result) => (result ? result.Documents : []), + query, + options: innerOptions, + partitionKey: options.partitionKey, + diagnosticNode, + }); + return response; + }; + return new QueryIterator(this.clientContext, query, options, fetchFunction, this.container.url, exports.ResourceType.item); + } + readChangeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions) { + if (isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) { + return this.changeFeed(partitionKeyOrChangeFeedOptions); + } + else { + return this.changeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions); + } + } + changeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions) { + let partitionKey; + if (!changeFeedOptions && isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) { + partitionKey = undefined; + changeFeedOptions = partitionKeyOrChangeFeedOptions; + } + else if (partitionKeyOrChangeFeedOptions !== undefined && + !isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) { + partitionKey = partitionKeyOrChangeFeedOptions; + } + if (!changeFeedOptions) { + changeFeedOptions = {}; + } + const path = getPathFromLink(this.container.url, exports.ResourceType.item); + const id = getIdFromLink(this.container.url); + return new ChangeFeedIterator(this.clientContext, id, path, partitionKey, changeFeedOptions); + } + /** + * Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container. + */ + getChangeFeedIterator(changeFeedIteratorOptions) { + const cfOptions = changeFeedIteratorOptions !== undefined ? changeFeedIteratorOptions : {}; + validateChangeFeedIteratorOptions(cfOptions); + const iterator = changeFeedIteratorBuilder(cfOptions, this.clientContext, this.container, this.partitionKeyRangeCache); + return iterator; + } + readAll(options) { + return this.query("SELECT * from c", options); + } + /** + * Create an item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + async create(body, options = {}) { + // Generate random document id if the id is missing in the payload and + // options.disableAutomaticIdGeneration != true + return withDiagnostics(async (diagnosticNode) => { + if ((body.id === undefined || body.id === "") && !options.disableAutomaticIdGeneration) { + body.id = uuid$1(); + } + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + const partitionKey = extractPartitionKeys(body, partitionKeyDefinition); + const err = {}; + if (!isItemResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, exports.ResourceType.item); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.item, + resourceId: id, + diagnosticNode, + options, + partitionKey, + }); + const ref = new Item(this.container, response.result.id, this.clientContext, partitionKey); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + async upsert(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + // Generate random document id if the id is missing in the payload and + // options.disableAutomaticIdGeneration != true + if ((body.id === undefined || body.id === "") && !options.disableAutomaticIdGeneration) { + body.id = uuid$1(); + } + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + const partitionKey = extractPartitionKeys(body, partitionKeyDefinition); + const err = {}; + if (!isItemResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, exports.ResourceType.item); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.upsert({ + body, + path, + resourceType: exports.ResourceType.item, + resourceId: id, + options, + partitionKey, + diagnosticNode, + }); + const ref = new Item(this.container, response.result.id, this.clientContext, partitionKey); + return new ItemResponse(response.result, response.headers, response.code, response.substatus, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Execute bulk operations on items. + * + * Bulk takes an array of Operations which are typed based on what the operation does. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is optional at the top level if present in the resourceBody + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.bulk(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param bulkOptions - Optional options object to modify bulk behavior. Pass \{ continueOnError: true \} to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE + * @param options - Used for modifying the request. + */ + async bulk(operations, bulkOptions, options) { + return withDiagnostics(async (diagnosticNode) => { + const { resources: partitionKeyRanges } = await this.container + .readPartitionKeyRanges() + .fetchAll(); + const partitionKeyDefinition = await readPartitionKeyDefinition(diagnosticNode, this.container); + const batches = partitionKeyRanges.map((keyRange) => { + return { + min: keyRange.minInclusive, + max: keyRange.maxExclusive, + rangeId: keyRange.id, + indexes: [], + operations: [], + }; + }); + this.groupOperationsBasedOnPartitionKey(operations, partitionKeyDefinition, options, batches); + const path = getPathFromLink(this.container.url, exports.ResourceType.item); + const orderedResponses = []; + await Promise.all(batches + .filter((batch) => batch.operations.length) + .flatMap((batch) => splitBatchBasedOnBodySize(batch)) + .map(async (batch) => { + if (batch.operations.length > 100) { + throw new Error("Cannot run bulk request with more than 100 operations per partition"); + } + try { + const response = await addDignosticChild(async (childNode) => this.clientContext.bulk({ + body: batch.operations, + partitionKeyRangeId: batch.rangeId, + path, + resourceId: this.container.url, + bulkOptions, + options, + diagnosticNode: childNode, + }), diagnosticNode, exports.DiagnosticNodeType.BATCH_REQUEST); + response.result.forEach((operationResponse, index) => { + orderedResponses[batch.indexes[index]] = operationResponse; + }); + } + catch (err) { + // In the case of 410 errors, we need to recompute the partition key ranges + // and redo the batch request, however, 410 errors occur for unsupported + // partition key types as well since we don't support them, so for now we throw + if (err.code === 410) { + throw new Error("Partition key error. Either the partitions have split or an operation has an unsupported partitionKey type" + + err.message); + } + throw new Error(`Bulk request errored with: ${err.message}`); + } + })); + const response = orderedResponses; + response.diagnostics = diagnosticNode.toDiagnostic(this.clientContext.getClientConfig()); + return response; + }, this.clientContext); + } + /** + * Function to create batches based of partition key Ranges. + * @param operations - operations to group + * @param partitionDefinition - PartitionKey definition of container. + * @param options - Request options for bulk request. + * @param batches - Groups to be filled with operations. + */ + groupOperationsBasedOnPartitionKey(operations, partitionDefinition, options, batches) { + operations.forEach((operationInput, index) => { + const { operation, partitionKey } = prepareOperations(operationInput, partitionDefinition, options); + const hashed = hashPartitionKey(assertNotUndefined(partitionKey, "undefined value for PartitionKey is not expected during grouping of bulk operations."), partitionDefinition); + const batchForKey = assertNotUndefined(batches.find((batch) => { + return isKeyInRange(batch.min, batch.max, hashed); + }), "No suitable Batch found."); + batchForKey.operations.push(operation); + batchForKey.indexes.push(index); + }); + } + /** + * Execute transactional batch operations on items. + * + * Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is required as a second argument to batch, but defaults to the default partition key + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.batch(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param options - Used for modifying the request + */ + async batch(operations, partitionKey, options) { + return withDiagnostics(async (diagnosticNode) => { + operations.map((operation) => decorateBatchOperation(operation, options)); + const path = getPathFromLink(this.container.url, exports.ResourceType.item); + if (operations.length > 100) { + throw new Error("Cannot run batch request with more than 100 operations per partition"); + } + try { + const response = await this.clientContext.batch({ + body: operations, + partitionKey, + path, + resourceId: this.container.url, + options, + diagnosticNode, + }); + return response; + } + catch (err) { + throw new Error(`Batch request error: ${err.message}`); + } + }, this.clientContext); + } +} + +class StoredProcedureResponse extends ResourceResponse { + constructor(resource, headers, statusCode, storedProcedure, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.storedProcedure = storedProcedure; + } + /** + * Alias for storedProcedure. + * + * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to. + */ + get sproc() { + return this.storedProcedure; + } +} + +/** + * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id. + * + * For operations to create, read all, or query Stored Procedures, + */ +class StoredProcedure { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createStoredProcedureUri(this.container.database.id, this.container.id, this.id); + } + /** + * Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}. + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link StoredProcedure}. + * @hidden + */ + constructor(container, id, clientContext) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + return new StoredProcedureResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}. + * @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: exports.ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + return new StoredProcedureResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link StoredProcedure}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + return new StoredProcedureResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Execute the given {@link StoredProcedure}. + * + * The specified type, T, is not enforced by the client. + * Be sure to validate the response from the stored procedure matches the type, T, you provide. + * + * @param partitionKey - The partition key to use when executing the stored procedure + * @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}. + * @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on. + */ + async execute(partitionKey, params, options) { + return withDiagnostics(async (diagnosticNode) => { + if (partitionKey === undefined) { + const partitionKeyResponse = await readPartitionKeyDefinition(diagnosticNode, this.container); + partitionKey = undefinedPartitionKey(partitionKeyResponse); + } + const response = await this.clientContext.execute({ + sprocLink: this.url, + params, + options, + partitionKey, + diagnosticNode, + }); + return new ResourceResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** + * Operations for creating, upserting, or reading/querying all Stored Procedures. + * + * For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`. + */ +class StoredProcedures { + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, exports.ResourceType.sproc); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.sproc, + resourceId: id, + resultFn: (result) => result.StoredProcedures, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }); + } + /** + * Read all stored procedures. + * @example Read all stored procedures to array. + * ```typescript + * const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a StoredProcedure. + * + * Azure Cosmos DB allows stored procedures to be executed in the storage tier, + * directly against an item container. The script + * gets executed under ACID transactions on the primary storage partition of the + * specified container. For additional details, + * refer to the server-side JavaScript API documentation. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, exports.ResourceType.sproc); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.sproc, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new StoredProcedure(this.container, response.result.id, this.clientContext); + return new StoredProcedureResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +class TriggerResponse extends ResourceResponse { + constructor(resource, headers, statusCode, trigger, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.trigger = trigger; + } +} + +/** + * Operations to read, replace, or delete a {@link Trigger}. + * + * Use `container.triggers` to create, upsert, query, or read all. + */ +class Trigger { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createTriggerUri(this.container.database.id, this.container.id, this.id); + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Trigger}. + */ + constructor(container, id, clientContext) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link TriggerDefinition} for the given {@link Trigger}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + return new TriggerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link Trigger} with the specified {@link TriggerDefinition}. + * @param body - The specified {@link TriggerDefinition} to replace the existing definition with. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: exports.ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + return new TriggerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link Trigger}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + return new TriggerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** + * Operations to create, upsert, query, and read all triggers. + * + * Use `container.triggers` to read, replace, or delete a {@link Trigger}. + */ +class Triggers { + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, exports.ResourceType.trigger); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.trigger, + resourceId: id, + resultFn: (result) => result.Triggers, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all Triggers. + * @example Read all trigger to array. + * ```typescript + * const {body: triggerList} = await container.triggers.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a trigger. + * + * Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed + * on creates, updates and deletes. + * + * For additional details, refer to the server-side JavaScript API documentation. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, exports.ResourceType.trigger); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.trigger, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new Trigger(this.container, response.result.id, this.clientContext); + return new TriggerResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +class UserDefinedFunctionResponse extends ResourceResponse { + constructor(resource, headers, statusCode, udf, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.userDefinedFunction = udf; + } + /** + * Alias for `userDefinedFunction(id)`. + * + * A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. + */ + get udf() { + return this.userDefinedFunction; + } +} + +/** + * Used to read, replace, or delete a specified User Definied Function by id. + * + * @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions. + */ +class UserDefinedFunction { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createUserDefinedFunctionUri(this.container.database.id, this.container.id, this.id); + } + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link UserDefinedFunction}. + */ + constructor(container, id, clientContext) { + this.container = container; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}. + * @param options - + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: exports.ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link UserDefined}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** + * Used to create, upsert, query, or read all User Defined Functions. + * + * @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id. + */ +class UserDefinedFunctions { + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.container.url, exports.ResourceType.udf); + const id = getIdFromLink(this.container.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.udf, + resourceId: id, + resultFn: (result) => result.UserDefinedFunctions, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all User Defined Functions. + * @example Read all User Defined Functions to array. + * ```typescript + * const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a UserDefinedFunction. + * + * Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers. + * + * For additional details, refer to the server-side JavaScript API documentation. + * + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + if (body.body) { + body.body = body.body.toString(); + } + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.container.url, exports.ResourceType.udf); + const id = getIdFromLink(this.container.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.udf, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new UserDefinedFunction(this.container, response.result.id, this.clientContext); + return new UserDefinedFunctionResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class Scripts { + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container, clientContext) { + this.container = container; + this.clientContext = clientContext; + } + /** + * Used to read, replace, or delete a specific, existing {@link StoredProcedure} by id. + * + * Use `.storedProcedures` for creating new stored procedures, or querying/reading all stored procedures. + * @param id - The id of the {@link StoredProcedure}. + */ + storedProcedure(id) { + return new StoredProcedure(this.container, id, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link Trigger} by id. + * + * Use `.triggers` for creating new triggers, or querying/reading all triggers. + * @param id - The id of the {@link Trigger}. + */ + trigger(id) { + return new Trigger(this.container, id, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link UserDefinedFunction} by id. + * + * Use `.userDefinedFunctions` for creating new user defined functions, or querying/reading all user defined functions. + * @param id - The id of the {@link UserDefinedFunction}. + */ + userDefinedFunction(id) { + return new UserDefinedFunction(this.container, id, this.clientContext); + } + /** + * Operations for creating new stored procedures, and reading/querying all stored procedures. + * + * For reading, replacing, or deleting an existing stored procedure, use `.storedProcedure(id)`. + */ + get storedProcedures() { + if (!this.$sprocs) { + this.$sprocs = new StoredProcedures(this.container, this.clientContext); + } + return this.$sprocs; + } + /** + * Operations for creating new triggers, and reading/querying all triggers. + * + * For reading, replacing, or deleting an existing trigger, use `.trigger(id)`. + */ + get triggers() { + if (!this.$triggers) { + this.$triggers = new Triggers(this.container, this.clientContext); + } + return this.$triggers; + } + /** + * Operations for creating new user defined functions, and reading/querying all user defined functions. + * + * For reading, replacing, or deleting an existing user defined function, use `.userDefinedFunction(id)`. + */ + get userDefinedFunctions() { + if (!this.$udfs) { + this.$udfs = new UserDefinedFunctions(this.container, this.clientContext); + } + return this.$udfs; + } +} + +/** Response object for Container operations */ +class ContainerResponse extends ResourceResponse { + constructor(resource, headers, statusCode, container, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.container = container; + } +} + +class OfferResponse extends ResourceResponse { + constructor(resource, headers, statusCode, diagnostics, offer) { + super(resource, headers, statusCode, diagnostics); + this.offer = offer; + } +} + +/** + * Use to read or replace an existing {@link Offer} by id. + * + * @see {@link Offers} to query or read all offers. + */ +class Offer { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return `/${Constants$1.Path.OffersPathSegment}/${this.id}`; + } + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database Account. + * @param id - The id of the given {@link Offer}. + */ + constructor(client, id, clientContext) { + this.client = client; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link OfferDefinition} for the given {@link Offer}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const response = await this.clientContext.read({ + path: this.url, + resourceType: exports.ResourceType.offer, + resourceId: this.id, + options, + diagnosticNode, + }); + return new OfferResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics(), this); + }, this.clientContext); + } + /** + * Replace the given {@link Offer} with the specified {@link OfferDefinition}. + * @param body - The specified {@link OfferDefinition} + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const response = await this.clientContext.replace({ + body, + path: this.url, + resourceType: exports.ResourceType.offer, + resourceId: this.id, + options, + diagnosticNode, + }); + return new OfferResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics(), this); + }, this.clientContext); + } +} + +/** + * Use to query or read all Offers. + * + * @see {@link Offer} to read or replace an existing {@link Offer} by id. + */ +class Offers { + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the offers. + */ + constructor(client, clientContext) { + this.client = client; + this.clientContext = clientContext; + } + query(query, options) { + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path: "/offers", + resourceType: exports.ResourceType.offer, + resourceId: "", + resultFn: (result) => result.Offers, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all offers. + * @example Read all offers to array. + * ```typescript + * const {body: offerList} = await client.offers.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } +} + +/** + * Operations for reading, replacing, or deleting a specific, existing container by id. + * + * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ +class Container { + /** + * Operations for creating new items, and reading/querying all items + * + * For reading, replacing, or deleting an existing item, use `.item(id)`. + * + * @example Create a new item + * ```typescript + * const {body: createdItem} = await container.items.create({id: "", properties: {}}); + * ``` + */ + get items() { + if (!this.$items) { + this.$items = new Items(this, this.clientContext); + } + return this.$items; + } + /** + * All operations for Stored Procedures, Triggers, and User Defined Functions + */ + get scripts() { + if (!this.$scripts) { + this.$scripts = new Scripts(this, this.clientContext); + } + return this.$scripts; + } + /** + * Operations for reading and querying conflicts for the given container. + * + * For reading or deleting a specific conflict, use `.conflict(id)`. + */ + get conflicts() { + if (!this.$conflicts) { + this.$conflicts = new Conflicts(this, this.clientContext); + } + return this.$conflicts; + } + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createDocumentCollectionUri(this.database.id, this.id); + } + /** + * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object. + * @param database - The parent {@link Database}. + * @param id - The id of the given container. + * @hidden + */ + constructor(database, id, clientContext) { + this.database = database; + this.id = id; + this.clientContext = clientContext; + } + /** + * Used to read, replace, or delete a specific, existing {@link Item} by id. + * + * Use `.items` for creating new items, or querying/reading all items. + * + * @param id - The id of the {@link Item}. + * @param partitionKeyValue - The value of the {@link Item} partition key + * @example Replace an item + * `const {body: replacedItem} = await container.item("", "").replace({id: "", title: "Updated post", authorID: 5});` + */ + item(id, partitionKeyValue) { + return new Item(this, id, this.clientContext, partitionKeyValue); + } + /** + * Used to read, replace, or delete a specific, existing {@link Conflict} by id. + * + * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts. + * @param id - The id of the {@link Conflict}. + */ + conflict(id, partitionKey) { + return new Conflict(this, id, this.clientContext, partitionKey); + } + /** Read the container's definition */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.readInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async readInternal(diagnosticNode, options) { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.container, + resourceId: id, + options, + diagnosticNode, + }); + this.clientContext.partitionKeyDefinitionCache[this.url] = response.result.partitionKey; + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + } + /** Replace the container's definition */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: exports.ResourceType.container, + resourceId: id, + options, + diagnosticNode, + }); + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** Delete the container */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.container, + resourceId: id, + options, + diagnosticNode, + }); + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @deprecated This method has been renamed to readPartitionKeyDefinition. + */ + async getPartitionKeyDefinition() { + return withDiagnostics(async (diagnosticNode) => { + return this.readPartitionKeyDefinition(diagnosticNode); + }, this.clientContext); + } + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @hidden + */ + async readPartitionKeyDefinition(diagnosticNode) { + // $ISSUE-felixfan-2016-03-17: Make name based path and link based path use the same key + // $ISSUE-felixfan-2016-03-17: Refresh partitionKeyDefinitionCache when necessary + if (this.url in this.clientContext.partitionKeyDefinitionCache) { + diagnosticNode.addData({ readFromCache: true }); + return new ResourceResponse(this.clientContext.partitionKeyDefinitionCache[this.url], {}, 0, getEmptyCosmosDiagnostics()); + } + const { headers, statusCode, diagnostics } = await withMetadataDiagnostics(async (node) => { + return this.readInternal(node); + }, diagnosticNode, exports.MetadataLookUpType.ContainerLookUp); + return new ResourceResponse(this.clientContext.partitionKeyDefinitionCache[this.url], headers, statusCode, diagnostics); + } + /** + * Gets offer on container. If none exists, returns an OfferResponse with undefined. + */ + async readOffer(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + const { resource: container } = await this.read(); + const path = "/offers"; + const url = container._self; + const response = await this.clientContext.queryFeed({ + path, + resourceId: "", + resourceType: exports.ResourceType.offer, + query: `SELECT * from root where root.resource = "${url}"`, + resultFn: (result) => result.Offers, + options, + diagnosticNode, + }); + const offer = response.result[0] + ? new Offer(this.database.client, response.result[0].id, this.clientContext) + : undefined; + return new OfferResponse(response.result[0], response.headers, response.code, getEmptyCosmosDiagnostics(), offer); + }, this.clientContext); + } + async getQueryPlan(query) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + return this.clientContext.getQueryPlan(path + "/docs", exports.ResourceType.item, getIdFromLink(this.url), query, {}, diagnosticNode); + }, this.clientContext); + } + readPartitionKeyRanges(feedOptions) { + feedOptions = feedOptions || {}; + return this.clientContext.queryPartitionKeyRanges(this.url, undefined, feedOptions); + } + /** + * + * @returns all the feed ranges for which changefeed could be fetched. + */ + async getFeedRanges() { + return withDiagnostics(async (diagnosticNode) => { + const { resources } = await this.readPartitionKeyRanges().fetchAllInternal(diagnosticNode); + const feedRanges = []; + for (const resource of resources) { + const feedRange = new FeedRangeInternal(resource.minInclusive, resource.maxExclusive); + Object.freeze(feedRange); + feedRanges.push(feedRange); + } + return feedRanges; + }, this.clientContext); + } + /** + * Delete all documents belong to the container for the provided partition key value + * @param partitionKey - The partition key value of the items to be deleted + */ + async deleteAllItemsForPartitionKey(partitionKey, options) { + return withDiagnostics(async (diagnosticNode) => { + let path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + path = path + "/operations/partitionkeydelete"; + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.container, + resourceId: id, + options, + partitionKey: partitionKey, + method: exports.HTTPMethod.post, + diagnosticNode, + }); + return new ContainerResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function validateOffer(body) { + if (body.throughput) { + if (body.maxThroughput) { + console.log("should be erroring"); + throw new Error("Cannot specify `throughput` with `maxThroughput`"); + } + if (body.autoUpgradePolicy) { + throw new Error("Cannot specify autoUpgradePolicy with throughput. Use `maxThroughput` instead"); + } + } +} + +/** + * Operations for creating new containers, and reading/querying all containers + * + * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ +class Containers { + constructor(database, clientContext) { + this.database = database; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.database.url, exports.ResourceType.container); + const id = getIdFromLink(this.database.url); + return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.container, + resourceId: id, + resultFn: (result) => result.DocumentCollections, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }); + } + /** + * Creates a container. + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + async create(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + return this.createInternal(diagnosticNode, body, options); + }, this.clientContext); + } + /** + * @hidden + */ + async createInternal(diagnosticNode, body, options = {}) { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.database.url, exports.ResourceType.container); + const id = getIdFromLink(this.database.url); + validateOffer(body); + if (body.maxThroughput) { + const autoscaleParams = { + maxThroughput: body.maxThroughput, + }; + if (body.autoUpgradePolicy) { + autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy; + } + const autoscaleHeader = JSON.stringify(autoscaleParams); + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants$1.HttpHeaders.AutoscaleSettings]: autoscaleHeader, + }); + delete body.maxThroughput; + delete body.autoUpgradePolicy; + } + if (body.throughput) { + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants$1.HttpHeaders.OfferThroughput]: body.throughput, + }); + delete body.throughput; + } + if (typeof body.partitionKey === "string") { + if (!body.partitionKey.startsWith("/")) { + throw new Error("Partition key must start with '/'"); + } + body.partitionKey = { + paths: [body.partitionKey], + }; + } + // If they don't specify a partition key, use the default path + if (!body.partitionKey || !body.partitionKey.paths) { + body.partitionKey = { + paths: [DEFAULT_PARTITION_KEY_PATH], + }; + } + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.container, + resourceId: id, + diagnosticNode, + options, + }); + const ref = new Container(this.database, response.result.id, this.clientContext); + return new ContainerResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + } + /** + * Checks if a Container exists, and, if it doesn't, creates it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.) + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + async createIfNotExists(body, options) { + if (!body || body.id === null || body.id === undefined) { + throw new Error("body parameter must be an object with an id property"); + } + /* + 1. Attempt to read the Container (based on an assumption that most containers will already exist, so its faster) + 2. If it fails with NotFound error, attempt to create the container. Else, return the read results. + */ + return withDiagnostics(async (diagnosticNode) => { + try { + const readResponse = await this.database + .container(body.id) + .readInternal(diagnosticNode, options); + return readResponse; + } + catch (err) { + if (err.code === StatusCodes.NotFound) { + const createResponse = await this.createInternal(diagnosticNode, body, options); + // Must merge the headers to capture RU costskaty + mergeHeaders(createResponse.headers, err.headers); + return createResponse; + } + else { + throw err; + } + } + }, this.clientContext); + } + /** + * Read all containers. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const {body: containerList} = await client.database("").containers.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } +} + +class PermissionResponse extends ResourceResponse { + constructor(resource, headers, statusCode, permission, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.permission = permission; + } +} + +/** + * Use to read, replace, or delete a given {@link Permission} by id. + * + * @see {@link Permissions} to create, upsert, query, or read all Permissions. + */ +class Permission { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createPermissionUri(this.user.database.id, this.user.id, this.id); + } + /** + * @hidden + * @param user - The parent {@link User}. + * @param id - The id of the given {@link Permission}. + */ + constructor(user, id, clientContext) { + this.user = user; + this.id = id; + this.clientContext = clientContext; + } + /** + * Read the {@link PermissionDefinition} of the given {@link Permission}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + return new PermissionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link Permission} with the specified {@link PermissionDefinition}. + * @param body - The specified {@link PermissionDefinition}. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: exports.ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + return new PermissionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link Permission}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + return new PermissionResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** + * Use to create, replace, query, and read all Permissions. + * + * @see {@link Permission} to read, replace, or delete a specific permission by id. + */ +class Permissions { + /** + * @hidden + * @param user - The parent {@link User}. + */ + constructor(user, clientContext) { + this.user = user; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.user.url, exports.ResourceType.permission); + const id = getIdFromLink(this.user.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.permission, + resourceId: id, + resultFn: (result) => result.Permissions, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all permissions. + * @example Read all permissions to array. + * ```typescript + * const {body: permissionList} = await user.permissions.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a permission. + * + * A permission represents a per-User Permission to access a specific resource + * e.g. Item or Container. + * @param body - Represents the body of the permission. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.user.url, exports.ResourceType.permission); + const id = getIdFromLink(this.user.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.permission, + resourceId: id, + diagnosticNode, + options, + }); + const ref = new Permission(this.user, response.result.id, this.clientContext); + return new PermissionResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Upsert a permission. + * + * A permission represents a per-User Permission to access a + * specific resource e.g. Item or Container. + */ + async upsert(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.user.url, exports.ResourceType.permission); + const id = getIdFromLink(this.user.url); + const response = await this.clientContext.upsert({ + body, + path, + resourceType: exports.ResourceType.permission, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new Permission(this.user, response.result.id, this.clientContext); + return new PermissionResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +class UserResponse extends ResourceResponse { + constructor(resource, headers, statusCode, user, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.user = user; + } +} + +/** + * Used to read, replace, and delete Users. + * + * Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`. + * + * @see {@link Users} to create, upsert, query, or read all. + */ +class User { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createUserUri(this.database.id, this.id); + } + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database, id, clientContext) { + this.database = database; + this.id = id; + this.clientContext = clientContext; + this.permissions = new Permissions(this, this.clientContext); + } + /** + * Operations to read, replace, or delete a specific Permission by id. + * + * See `client.permissions` for creating, upserting, querying, or reading all operations. + */ + permission(id) { + return new Permission(this, id, this.clientContext); + } + /** + * Read the {@link UserDefinition} for the given {@link User}. + */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new UserResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Replace the given {@link User}'s definition with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition} to replace the definition. + */ + async replace(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.replace({ + body, + path, + resourceType: exports.ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new UserResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Delete the given {@link User}. + */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + return new UserResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** + * Used to create, upsert, query, and read all users. + * + * @see {@link User} to read, replace, or delete a specific User by id. + */ +class Users { + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database, clientContext) { + this.database = database; + this.clientContext = clientContext; + } + query(query, options) { + const path = getPathFromLink(this.database.url, exports.ResourceType.user); + const id = getIdFromLink(this.database.url); + return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => { + return this.clientContext.queryFeed({ + path, + resourceType: exports.ResourceType.user, + resourceId: id, + resultFn: (result) => result.Users, + query, + options: innerOptions, + diagnosticNode, + }); + }); + } + /** + * Read all users.- + * @example Read all users to array. + * ```typescript + * const {body: usersList} = await database.users.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } + /** + * Create a database user with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + async create(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.database.url, exports.ResourceType.user); + const id = getIdFromLink(this.database.url); + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new User(this.database, response.result.id, this.clientContext); + return new UserResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Upsert a database user with a specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + async upsert(body, options) { + return withDiagnostics(async (diagnosticNode) => { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + const path = getPathFromLink(this.database.url, exports.ResourceType.user); + const id = getIdFromLink(this.database.url); + const response = await this.clientContext.upsert({ + body, + path, + resourceType: exports.ResourceType.user, + resourceId: id, + options, + diagnosticNode, + }); + const ref = new User(this.database, response.result.id, this.clientContext); + return new UserResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } +} + +/** Response object for Database operations */ +class DatabaseResponse extends ResourceResponse { + constructor(resource, headers, statusCode, database, diagnostics) { + super(resource, headers, statusCode, diagnostics); + this.database = database; + } +} + +/** + * Operations for reading or deleting an existing database. + * + * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ +class Database { + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url() { + return createDatabaseUri(this.id); + } + /** Returns a new {@link Database} instance. + * + * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself. + */ + constructor(client, id, clientContext) { + this.client = client; + this.id = id; + this.clientContext = clientContext; + this.containers = new Containers(this, this.clientContext); + this.users = new Users(this, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link Database} by id. + * + * Use `.containers` creating new containers, or querying/reading all containers. + * + * @example Delete a container + * ```typescript + * await client.database("").container("").delete(); + * ``` + */ + container(id) { + return new Container(this, id, this.clientContext); + } + /** + * Used to read, replace, or delete a specific, existing {@link User} by id. + * + * Use `.users` for creating new users, or querying/reading all users. + */ + user(id) { + return new User(this, id, this.clientContext); + } + /** Read the definition of the given Database. */ + async read(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.readInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async readInternal(diagnosticNode, options) { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.read({ + path, + resourceType: exports.ResourceType.database, + resourceId: id, + options, + diagnosticNode, + }); + return new DatabaseResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + } + /** Delete the given Database. */ + async delete(options) { + return withDiagnostics(async (diagnosticNode) => { + const path = getPathFromLink(this.url); + const id = getIdFromLink(this.url); + const response = await this.clientContext.delete({ + path, + resourceType: exports.ResourceType.database, + resourceId: id, + options, + diagnosticNode, + }); + return new DatabaseResponse(response.result, response.headers, response.code, this, getEmptyCosmosDiagnostics()); + }, this.clientContext); + } + /** + * Gets offer on database. If none exists, returns an OfferResponse with undefined. + */ + async readOffer(options = {}) { + return withDiagnostics(async (diagnosticNode) => { + const { resource: record } = await withMetadataDiagnostics(async (node) => { + return this.readInternal(node); + }, diagnosticNode, exports.MetadataLookUpType.DatabaseLookUp); + const path = "/offers"; + const url = record._self; + const response = await this.clientContext.queryFeed({ + path, + resourceId: "", + resourceType: exports.ResourceType.offer, + query: `SELECT * from root where root.resource = "${url}"`, + resultFn: (result) => result.Offers, + options, + diagnosticNode, + }); + const offer = response.result[0] + ? new Offer(this.client, response.result[0].id, this.clientContext) + : undefined; + return new OfferResponse(response.result[0], response.headers, response.code, getEmptyCosmosDiagnostics(), offer); + }, this.clientContext); + } +} + +/** + * Operations for creating new databases, and reading/querying all databases + * + * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ +class Databases { + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database. + */ + constructor(client, clientContext) { + this.client = client; + this.clientContext = clientContext; + } + query(query, options) { + const cb = (diagNode, innerOptions) => { + return this.clientContext.queryFeed({ + path: "/dbs", + resourceType: exports.ResourceType.database, + resourceId: "", + resultFn: (result) => result.Databases, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + }; + return new QueryIterator(this.clientContext, query, options, cb); + } + /** + * Send a request for creating a database. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + async create(body, options = {}) { + return withDiagnostics(async (diagnosticNode) => { + return this.createInternal(diagnosticNode, body, options); + }, this.clientContext); + } + /** + * @hidden + */ + async createInternal(diagnosticNode, body, options = {}) { + const err = {}; + if (!isResourceValid(body, err)) { + throw err; + } + validateOffer(body); + if (body.maxThroughput) { + const autoscaleParams = { + maxThroughput: body.maxThroughput, + }; + if (body.autoUpgradePolicy) { + autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy; + } + const autoscaleHeaders = JSON.stringify(autoscaleParams); + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants$1.HttpHeaders.AutoscaleSettings]: autoscaleHeaders, + }); + delete body.maxThroughput; + delete body.autoUpgradePolicy; + } + if (body.throughput) { + options.initialHeaders = Object.assign({}, options.initialHeaders, { + [Constants$1.HttpHeaders.OfferThroughput]: body.throughput, + }); + delete body.throughput; + } + const path = "/dbs"; // TODO: constant + const response = await this.clientContext.create({ + body, + path, + resourceType: exports.ResourceType.database, + resourceId: undefined, + diagnosticNode, + options, + }); + const ref = new Database(this.client, body.id, this.clientContext); + return new DatabaseResponse(response.result, response.headers, response.code, ref, getEmptyCosmosDiagnostics()); + } + /** + * Check if a database exists, and if it doesn't, create it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Additional options for the request + */ + async createIfNotExists(body, options) { + if (!body || body.id === null || body.id === undefined) { + throw new Error("body parameter must be an object with an id property"); + } + /* + 1. Attempt to read the Database (based on an assumption that most databases will already exist, so its faster) + 2. If it fails with NotFound error, attempt to create the db. Else, return the read results. + */ + return withDiagnostics(async (diagnosticNode) => { + try { + const readResponse = await this.client + .database(body.id) + .readInternal(diagnosticNode, options); + return readResponse; + } + catch (err) { + if (err.code === StatusCodes.NotFound) { + const createResponse = await this.createInternal(diagnosticNode, body, options); + // Must merge the headers to capture RU costskaty + mergeHeaders(createResponse.headers, err.headers); + return createResponse; + } + else { + throw err; + } + } + }, this.clientContext); + } + // TODO: DatabaseResponse for QueryIterator? + /** + * Reads all databases. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const {body: databaseList} = await client.databases.readAll().fetchAll(); + * ``` + */ + readAll(options) { + return this.query(undefined, options); + } +} + +/** + * Used to specify which type of events to execute this plug in on. + * + * @hidden + */ +exports.PluginOn = void 0; +(function (PluginOn) { + /** + * Will be executed per network request + */ + PluginOn["request"] = "request"; + /** + * Will be executed per API operation + */ + PluginOn["operation"] = "operation"; +})(exports.PluginOn || (exports.PluginOn = {})); +/** + * @internal + */ +async function executePlugins(diagnosticNode, requestContext, next, on) { + if (!requestContext.plugins) { + return next(requestContext, diagnosticNode, undefined); + } + let level = 0; + const _ = (inner) => { + if (++level >= inner.plugins.length) { + return next(requestContext, diagnosticNode, undefined); + } + else if (inner.plugins[level].on !== on) { + return _(requestContext); + } + else { + return inner.plugins[level].plugin(inner, diagnosticNode, _); + } + }; + if (requestContext.plugins[level].on !== on) { + return _(requestContext); + } + else { + return requestContext.plugins[level].plugin(requestContext, diagnosticNode, _); + } +} + +/** + * @hidden + */ +// Windows Socket Error Codes +const WindowsInterruptedFunctionCall = 10004; +/** + * @hidden + */ +const WindowsFileHandleNotValid = 10009; +/** + * @hidden + */ +const WindowsPermissionDenied = 10013; +/** + * @hidden + */ +const WindowsBadAddress = 10014; +/** + * @hidden + */ +const WindowsInvalidArgumnet = 10022; +/** + * @hidden + */ +const WindowsResourceTemporarilyUnavailable = 10035; +/** + * @hidden + */ +const WindowsOperationNowInProgress = 10036; +/** + * @hidden + */ +const WindowsAddressAlreadyInUse = 10048; +/** + * @hidden + */ +const WindowsConnectionResetByPeer = 10054; +/** + * @hidden + */ +const WindowsCannotSendAfterSocketShutdown = 10058; +/** + * @hidden + */ +const WindowsConnectionTimedOut = 10060; +/** + * @hidden + */ +const WindowsConnectionRefused = 10061; +/** + * @hidden + */ +const WindowsNameTooLong = 10063; +/** + * @hidden + */ +const WindowsHostIsDown = 10064; +/** + * @hidden + */ +const WindowsNoRouteTohost = 10065; +/** + * @hidden + */ +// Linux Error Codes +/** + * @hidden + */ +const LinuxConnectionReset = "ECONNRESET"; +// Node Error Codes +/** + * @hidden + */ +const BrokenPipe = "EPIPE"; +/** + * @hidden + */ +const CONNECTION_ERROR_CODES = [ + WindowsInterruptedFunctionCall, + WindowsFileHandleNotValid, + WindowsPermissionDenied, + WindowsBadAddress, + WindowsInvalidArgumnet, + WindowsResourceTemporarilyUnavailable, + WindowsOperationNowInProgress, + WindowsAddressAlreadyInUse, + WindowsConnectionResetByPeer, + WindowsCannotSendAfterSocketShutdown, + WindowsConnectionTimedOut, + WindowsConnectionRefused, + WindowsNameTooLong, + WindowsHostIsDown, + WindowsNoRouteTohost, + LinuxConnectionReset, + TimeoutErrorCode, + BrokenPipe, +]; +/** + * @hidden + */ +function needsRetry(operationType, code) { + if ((operationType === exports.OperationType.Read || operationType === exports.OperationType.Query) && + CONNECTION_ERROR_CODES.indexOf(code) !== -1) { + return true; + } + else { + return false; + } +} +/** + * This class implements the default connection retry policy for requests. + * @hidden + */ +class DefaultRetryPolicy { + constructor(operationType) { + this.operationType = operationType; + this.maxTries = 10; + this.currentRetryAttemptCount = 0; + this.retryAfterInMs = 1000; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + async shouldRetry(err, diagnosticNode) { + if (err) { + if (this.currentRetryAttemptCount < this.maxTries && + needsRetry(this.operationType, err.code)) { + diagnosticNode.addData({ successfulRetryPolicy: "default" }); + this.currentRetryAttemptCount++; + return true; + } + } + return false; + } +} + +/** + * This class implements the retry policy for endpoint discovery. + * @hidden + */ +class EndpointDiscoveryRetryPolicy { + /** + * @param globalEndpointManager - The GlobalEndpointManager instance. + */ + constructor(globalEndpointManager, operationType) { + this.globalEndpointManager = globalEndpointManager; + this.operationType = operationType; + this.maxTries = EndpointDiscoveryRetryPolicy.maxTries; + this.currentRetryAttemptCount = 0; + this.retryAfterInMs = EndpointDiscoveryRetryPolicy.retryAfterInMs; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) { + if (!err) { + return false; + } + if (!retryContext || !locationEndpoint) { + return false; + } + if (!this.globalEndpointManager.enableEndpointDiscovery) { + return false; + } + if (this.currentRetryAttemptCount >= this.maxTries) { + return false; + } + this.currentRetryAttemptCount++; + if (isReadRequest(this.operationType)) { + await this.globalEndpointManager.markCurrentLocationUnavailableForRead(diagnosticNode, locationEndpoint); + } + else { + await this.globalEndpointManager.markCurrentLocationUnavailableForWrite(diagnosticNode, locationEndpoint); + } + retryContext.retryCount = this.currentRetryAttemptCount; + retryContext.clearSessionTokenNotAvailable = false; + retryContext.retryRequestOnPreferredLocations = false; + diagnosticNode.addData({ successfulRetryPolicy: "endpointDiscovery" }); + return true; + } +} +EndpointDiscoveryRetryPolicy.maxTries = 120; // TODO: Constant? +EndpointDiscoveryRetryPolicy.retryAfterInMs = 1000; + +/** + * This class implements the resource throttle retry policy for requests. + * @hidden + */ +class ResourceThrottleRetryPolicy { + /** + * @param maxTries - Max number of retries to be performed for a request. + * @param fixedRetryIntervalInMs - Fixed retry interval in milliseconds to wait between each + * retry ignoring the retryAfter returned as part of the response. + * @param timeoutInSeconds - Max wait time in seconds to wait for a request while the + * retries are happening. + */ + constructor(maxTries = 9, fixedRetryIntervalInMs = 0, timeoutInSeconds = 30) { + this.maxTries = maxTries; + this.fixedRetryIntervalInMs = fixedRetryIntervalInMs; + /** Current retry attempt count. */ + this.currentRetryAttemptCount = 0; + /** Cummulative wait time in milliseconds for a request while the retries are happening. */ + this.cummulativeWaitTimeinMs = 0; + /** Retry interval in milliseconds to wait before the next request will be sent. */ + this.retryAfterInMs = 0; + this.timeoutInMs = timeoutInSeconds * 1000; + this.currentRetryAttemptCount = 0; + this.cummulativeWaitTimeinMs = 0; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + */ + async shouldRetry(err, diagnosticNode) { + // TODO: any custom error object + if (err) { + if (this.currentRetryAttemptCount < this.maxTries) { + this.currentRetryAttemptCount++; + this.retryAfterInMs = 0; + if (this.fixedRetryIntervalInMs) { + this.retryAfterInMs = this.fixedRetryIntervalInMs; + } + else if (err.retryAfterInMs) { + this.retryAfterInMs = err.retryAfterInMs; + } + if (this.cummulativeWaitTimeinMs < this.timeoutInMs) { + this.cummulativeWaitTimeinMs += this.retryAfterInMs; + diagnosticNode.addData({ successfulRetryPolicy: "resourceThrottle" }); + return true; + } + } + } + return false; + } +} + +/** + * This class implements the retry policy for session consistent reads. + * @hidden + */ +class SessionRetryPolicy { + /** + * @param globalEndpointManager - The GlobalEndpointManager instance. + */ + constructor(globalEndpointManager, resourceType, operationType, connectionPolicy) { + this.globalEndpointManager = globalEndpointManager; + this.resourceType = resourceType; + this.operationType = operationType; + this.connectionPolicy = connectionPolicy; + /** Current retry attempt count. */ + this.currentRetryAttemptCount = 0; + /** Retry interval in milliseconds. */ + this.retryAfterInMs = 0; + } + /** + * Determines whether the request should be retried or not. + * @param err - Error returned by the request. + * @param callback - The callback function which takes bool argument which specifies whether the request + * will be retried or not. + */ + async shouldRetry(err, diagnosticNode, retryContext) { + if (!err) { + return false; + } + if (!retryContext) { + return false; + } + if (!this.connectionPolicy.enableEndpointDiscovery) { + return false; + } + if (this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType)) { + // If we can write to multiple locations, we should against every write endpoint until we succeed + const endpoints = isReadRequest(this.operationType) + ? await this.globalEndpointManager.getReadEndpoints() + : await this.globalEndpointManager.getWriteEndpoints(); + if (this.currentRetryAttemptCount > endpoints.length) { + return false; + } + else { + this.currentRetryAttemptCount++; + retryContext.retryCount++; + retryContext.retryRequestOnPreferredLocations = this.currentRetryAttemptCount > 1; + retryContext.clearSessionTokenNotAvailable = + this.currentRetryAttemptCount === endpoints.length; + diagnosticNode.addData({ successfulRetryPolicy: "session" }); + return true; + } + } + else { + if (this.currentRetryAttemptCount > 1) { + return false; + } + else { + this.currentRetryAttemptCount++; + retryContext.retryCount++; + retryContext.retryRequestOnPreferredLocations = false; // Forces all operations to primary write endpoint + retryContext.clearSessionTokenNotAvailable = true; + diagnosticNode.addData({ successfulRetryPolicy: "session" }); + return true; + } + } + } +} + +/** + * This class TimeoutFailoverRetryPolicy handles retries for read operations + * (including data plane,metadata, and query plan) in case of request timeouts + * (TimeoutError) or service unavailability (503 status code) by performing failover + * and retrying on other regions. + * @hidden + */ +class TimeoutFailoverRetryPolicy { + constructor(globalEndpointManager, headers, methodType, resourceType, operationType, enableEndPointDiscovery) { + this.globalEndpointManager = globalEndpointManager; + this.headers = headers; + this.methodType = methodType; + this.resourceType = resourceType; + this.operationType = operationType; + this.enableEndPointDiscovery = enableEndPointDiscovery; + this.maxRetryAttemptCount = 120; + this.maxServiceUnavailableRetryCount = 1; + this.retryAfterInMs = 0; + this.failoverRetryCount = 0; + } + /** + * Checks if a timeout request is valid for the timeout failover retry policy. + * A valid request should be a data plane, metadata, or query plan request. + * @returns + */ + isValidRequestForTimeoutError() { + const isQuery = Constants$1.HttpHeaders.IsQuery in this.headers; + const isQueryPlan = Constants$1.HttpHeaders.IsQueryPlan in this.headers; + if (this.methodType === exports.HTTPMethod.get || isQuery || isQueryPlan) { + return true; + } + return false; + } + async shouldRetry(err, diagnosticNode, retryContext, locationEndpoint) { + if (!err) { + return false; + } + if (!retryContext || !locationEndpoint) { + return false; + } + // Check if the error is a timeout error (TimeoutErrorCode) and if it is not a valid HTTP network timeout request + if (err.code === TimeoutErrorCode && !this.isValidRequestForTimeoutError()) { + return false; + } + if (!this.enableEndPointDiscovery) { + return false; + } + if (err.code === StatusCodes.ServiceUnavailable && + this.failoverRetryCount >= this.maxServiceUnavailableRetryCount) { + return false; + } + if (this.failoverRetryCount >= this.maxRetryAttemptCount) { + return false; + } + const canUseMultipleWriteLocations = this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType); + const readRequest = isReadRequest(this.operationType); + if (!canUseMultipleWriteLocations && !readRequest) { + // Write requests on single master cannot be retried, no other regions available + return false; + } + this.failoverRetryCount++; + // Setting the retryLocationIndex to the next available location for retry. + // The retryLocationIndex is determined based on the failoverRetryCount, starting from zero. + retryContext.retryLocationServerIndex = await this.findEndpointIndex(this.failoverRetryCount); + diagnosticNode.addData({ successfulRetryPolicy: "timeout-failover" }); + return true; + } + /** + * Determines index of endpoint to be used for retry based upon failoverRetryCount and avalable locations + * @param failoverRetryCount - count of failovers + * @returns + */ + async findEndpointIndex(failoverRetryCount) { + // count of preferred locations specified by user + const preferredLocationsCount = this.globalEndpointManager.preferredLocationsCount; + const readRequest = isReadRequest(this.operationType); + let endpointIndex = 0; + // If preferredLocationsCount is not zero, it indicates that the user has specified preferred locations. + if (preferredLocationsCount !== 0) { + // The endpointIndex is set based on the preferred location and the failover retry count. + endpointIndex = failoverRetryCount % preferredLocationsCount; + } + else { + // In the absence of preferred locations, the endpoint selection is based on the failover count and the number of available locations. + if (readRequest) { + const getReadEndpoints = await this.globalEndpointManager.getReadEndpoints(); + if (getReadEndpoints && getReadEndpoints.length > 0) { + endpointIndex = failoverRetryCount % getReadEndpoints.length; + } + } + else { + const getWriteEndpoints = await this.globalEndpointManager.getWriteEndpoints(); + if (getWriteEndpoints && getWriteEndpoints.length > 0) { + endpointIndex = failoverRetryCount % getWriteEndpoints.length; + } + } + } + return endpointIndex; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +async function execute({ diagnosticNode, retryContext = { retryCount: 0 }, retryPolicies, requestContext, executeRequest, }) { + // TODO: any response + return addDignosticChild(async (localDiagnosticNode) => { + localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount }); + if (!retryPolicies) { + retryPolicies = { + endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(requestContext.globalEndpointManager, requestContext.operationType), + resourceThrottleRetryPolicy: new ResourceThrottleRetryPolicy(requestContext.connectionPolicy.retryOptions.maxRetryAttemptCount, requestContext.connectionPolicy.retryOptions.fixedRetryIntervalInMilliseconds, requestContext.connectionPolicy.retryOptions.maxWaitTimeInSeconds), + sessionReadRetryPolicy: new SessionRetryPolicy(requestContext.globalEndpointManager, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy), + defaultRetryPolicy: new DefaultRetryPolicy(requestContext.operationType), + timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(requestContext.globalEndpointManager, requestContext.headers, requestContext.method, requestContext.resourceType, requestContext.operationType, requestContext.connectionPolicy.enableEndpointDiscovery), + }; + } + if (retryContext && retryContext.clearSessionTokenNotAvailable) { + requestContext.client.clearSessionToken(requestContext.path); + delete requestContext.headers["x-ms-session-token"]; + } + if (retryContext && retryContext.retryLocationServerIndex) { + requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(localDiagnosticNode, requestContext.resourceType, requestContext.operationType, retryContext.retryLocationServerIndex); + } + else { + requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(localDiagnosticNode, requestContext.resourceType, requestContext.operationType); + } + const startTimeUTCInMs = getCurrentTimestampInMs(); + try { + const response = await executeRequest(localDiagnosticNode, requestContext); + response.headers[Constants$1.ThrottleRetryCount] = + retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount; + response.headers[Constants$1.ThrottleRetryWaitTimeInMs] = + retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs; + return response; + } + catch (err) { + // TODO: any error + let retryPolicy = null; + const headers = err.headers || {}; + if (err.code === StatusCodes.ENOTFOUND || + err.code === "REQUEST_SEND_ERROR" || + (err.code === StatusCodes.Forbidden && + (err.substatus === SubStatusCodes.DatabaseAccountNotFound || + err.substatus === SubStatusCodes.WriteForbidden))) { + retryPolicy = retryPolicies.endpointDiscoveryRetryPolicy; + } + else if (err.code === StatusCodes.TooManyRequests) { + retryPolicy = retryPolicies.resourceThrottleRetryPolicy; + } + else if (err.code === StatusCodes.NotFound && + err.substatus === SubStatusCodes.ReadSessionNotAvailable) { + retryPolicy = retryPolicies.sessionReadRetryPolicy; + } + else if (err.code === StatusCodes.ServiceUnavailable || err.code === TimeoutErrorCode) { + retryPolicy = retryPolicies.timeoutFailoverRetryPolicy; + } + else { + retryPolicy = retryPolicies.defaultRetryPolicy; + } + const results = await retryPolicy.shouldRetry(err, localDiagnosticNode, retryContext, requestContext.endpoint); + if (!results) { + headers[Constants$1.ThrottleRetryCount] = + retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount; + headers[Constants$1.ThrottleRetryWaitTimeInMs] = + retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs; + err.headers = Object.assign(Object.assign({}, err.headers), headers); + throw err; + } + else { + requestContext.retryCount++; + const newUrl = results[1]; // TODO: any hack + if (newUrl !== undefined) { + requestContext.endpoint = newUrl; + } + localDiagnosticNode.recordFailedNetworkCall(startTimeUTCInMs, requestContext, retryContext.retryCount, err.code, err.subsstatusCode, headers); + await sleep(retryPolicy.retryAfterInMs); + return execute({ + diagnosticNode, + executeRequest, + requestContext, + retryContext, + retryPolicies, + }); + } + } + }, diagnosticNode, exports.DiagnosticNodeType.HTTP_REQUEST); +} + +/** + * @hidden + */ +let defaultHttpsAgent; +const https = require("https"); // eslint-disable-line @typescript-eslint/no-require-imports +const tls = require("tls"); // eslint-disable-line @typescript-eslint/no-require-imports +// minVersion only available in Node 10+ +if (tls.DEFAULT_MIN_VERSION) { + defaultHttpsAgent = new https.Agent({ + keepAlive: true, + minVersion: "TLSv1.2", + }); +} +else { + // Remove when Node 8 support has been dropped + defaultHttpsAgent = new https.Agent({ + keepAlive: true, + secureProtocol: "TLSv1_2_method", + }); +} +const http = require("http"); // eslint-disable-line @typescript-eslint/no-require-imports +/** + * @internal + */ +const defaultHttpAgent = new http.Agent({ + keepAlive: true, +}); + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +let cachedHttpClient; +function getCachedDefaultHttpClient() { + if (!cachedHttpClient) { + cachedHttpClient = coreRestPipeline.createDefaultHttpClient(); + } + return cachedHttpClient; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const logger$1 = logger$5.createClientLogger("RequestHandler"); +async function executeRequest(diagnosticNode, requestContext) { + return executePlugins(diagnosticNode, requestContext, httpRequest, exports.PluginOn.request); +} +/** + * @hidden + */ +async function httpRequest(requestContext, diagnosticNode) { + const controller = new nodeAbortController.AbortController(); + const signal = controller.signal; + // Wrap users passed abort events and call our own internal abort() + const userSignal = requestContext.options && requestContext.options.abortSignal; + if (userSignal) { + if (userSignal.aborted) { + controller.abort(); + } + else { + userSignal.addEventListener("abort", () => { + controller.abort(); + }); + } + } + const timeout = setTimeout(() => { + controller.abort(); + }, requestContext.connectionPolicy.requestTimeout); + let response; + if (requestContext.body) { + requestContext.body = bodyFromData(requestContext.body); + } + const httpsClient = getCachedDefaultHttpClient(); + const url = prepareURL(requestContext.endpoint, requestContext.path); + const reqHeaders = coreRestPipeline.createHttpHeaders(requestContext.headers); + const pipelineRequest = coreRestPipeline.createPipelineRequest({ + url, + headers: reqHeaders, + method: requestContext.method, + abortSignal: signal, + body: requestContext.body, + }); + if (requestContext.requestAgent) { + pipelineRequest.agent = requestContext.requestAgent; + } + else { + const parsedUrl = new URL(url); + pipelineRequest.agent = parsedUrl.protocol === "http" ? defaultHttpAgent : defaultHttpsAgent; + } + const startTimeUTCInMs = getCurrentTimestampInMs(); + try { + if (requestContext.pipeline) { + response = await requestContext.pipeline.sendRequest(httpsClient, pipelineRequest); + } + else { + response = await httpsClient.sendRequest(pipelineRequest); + } + } + catch (error) { + if (error.name === "AbortError") { + // If the user passed signal caused the abort, cancel the timeout and rethrow the error + if (userSignal && userSignal.aborted === true) { + clearTimeout(timeout); + throw error; + } + // If the user didn't cancel, it must be an abort we called due to timeout + throw new TimeoutError(`Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`); + } + throw error; + } + clearTimeout(timeout); + const result = response.status === 204 || response.status === 304 || response.bodyAsText === "" + ? null + : JSON.parse(response.bodyAsText); + const responseHeaders = response.headers.toJSON(); + const substatus = responseHeaders[Constants$1.HttpHeaders.SubStatus] + ? parseInt(responseHeaders[Constants$1.HttpHeaders.SubStatus], 10) + : undefined; + diagnosticNode.recordSuccessfulNetworkCall(startTimeUTCInMs, requestContext, response, substatus, url); + if (response.status >= 400) { + const errorResponse = new ErrorResponse(result.message); + logger$1.warning(response.status + + " " + + requestContext.endpoint + + " " + + requestContext.path + + " " + + result.message); + errorResponse.code = response.status; + errorResponse.body = result; + errorResponse.headers = responseHeaders; + if (Constants$1.HttpHeaders.ActivityId in responseHeaders) { + errorResponse.activityId = responseHeaders[Constants$1.HttpHeaders.ActivityId]; + } + if (Constants$1.HttpHeaders.SubStatus in responseHeaders) { + errorResponse.substatus = substatus; + } + if (Constants$1.HttpHeaders.RetryAfterInMs in responseHeaders) { + errorResponse.retryAfterInMs = parseInt(responseHeaders[Constants$1.HttpHeaders.RetryAfterInMs], 10); + Object.defineProperty(errorResponse, "retryAfterInMilliseconds", { + get: () => { + return errorResponse.retryAfterInMs; + }, + }); + } + throw errorResponse; + } + return { + headers: responseHeaders, + result, + code: response.status, + substatus, + }; +} +/** + * @hidden + */ +async function request(requestContext, diagnosticNode) { + if (requestContext.body) { + requestContext.body = bodyFromData(requestContext.body); + if (!requestContext.body) { + throw new Error("parameter data must be a javascript object, string, or Buffer"); + } + } + return addDignosticChild(async (childNode) => { + return execute({ + diagnosticNode: childNode, + requestContext, + executeRequest, + }); + }, diagnosticNode, exports.DiagnosticNodeType.REQUEST_ATTEMPTS); +} +const RequestHandler = { + request, +}; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function atob(str) { + return Buffer.from(str, "base64").toString("binary"); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Models vector clock bases session token. Session token has the following format: + * `{Version}#{GlobalLSN}#{RegionId1}={LocalLsn1}#{RegionId2}={LocalLsn2}....#{RegionIdN}={LocalLsnN}` + * 'Version' captures the configuration number of the partition which returned this session token. + * 'Version' is incremented everytime topology of the partition is updated (say due to Add/Remove/Failover). + * + * The choice of separators '#' and '=' is important. Separators ';' and ',' are used to delimit + * per-partitionKeyRange session token + * @hidden + * + */ +class VectorSessionToken { + constructor(version, globalLsn, localLsnByregion, sessionToken) { + this.version = version; + this.globalLsn = globalLsn; + this.localLsnByregion = localLsnByregion; + this.sessionToken = sessionToken; + if (!this.sessionToken) { + const regionAndLocalLsn = []; + for (const [key, value] of this.localLsnByregion.entries()) { + regionAndLocalLsn.push(`${key}${VectorSessionToken.REGION_PROGRESS_SEPARATOR}${value}`); + } + const regionProgress = regionAndLocalLsn.join(VectorSessionToken.SEGMENT_SEPARATOR); + if (regionProgress === "") { + this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}`; + } + else { + this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}${VectorSessionToken.SEGMENT_SEPARATOR}${regionProgress}`; + } + } + } + static create(sessionToken) { + const [versionStr, globalLsnStr, ...regionSegments] = sessionToken.split(VectorSessionToken.SEGMENT_SEPARATOR); + const version = parseInt(versionStr, 10); + const globalLsn = parseFloat(globalLsnStr); + if (typeof version !== "number" || typeof globalLsn !== "number") { + return null; + } + const lsnByRegion = new Map(); + for (const regionSegment of regionSegments) { + const [regionIdStr, localLsnStr] = regionSegment.split(VectorSessionToken.REGION_PROGRESS_SEPARATOR); + if (!regionIdStr || !localLsnStr) { + return null; + } + const regionId = parseInt(regionIdStr, 10); + let localLsn; + try { + localLsn = localLsnStr; + } + catch (err) { + // TODO: log error + return null; + } + if (typeof regionId !== "number") { + return null; + } + lsnByRegion.set(regionId, localLsn); + } + return new VectorSessionToken(version, globalLsn, lsnByRegion, sessionToken); + } + equals(other) { + return !other + ? false + : this.version === other.version && + this.globalLsn === other.globalLsn && + this.areRegionProgressEqual(other.localLsnByregion); + } + merge(other) { + if (other == null) { + throw new Error("other (Vector Session Token) must not be null"); + } + if (this.version === other.version && + this.localLsnByregion.size !== other.localLsnByregion.size) { + throw new Error(`Compared session tokens ${this.sessionToken} and ${other.sessionToken} have unexpected regions`); + } + const [higherVersionSessionToken, lowerVersionSessionToken] = this.version < other.version ? [other, this] : [this, other]; + const highestLocalLsnByRegion = new Map(); + for (const [regionId, highLocalLsn] of higherVersionSessionToken.localLsnByregion.entries()) { + const lowLocalLsn = lowerVersionSessionToken.localLsnByregion.get(regionId); + if (lowLocalLsn) { + highestLocalLsnByRegion.set(regionId, max(highLocalLsn, lowLocalLsn)); + } + else if (this.version === other.version) { + throw new Error(`Compared session tokens have unexpected regions. Session 1: ${this.sessionToken} - Session 2: ${this.sessionToken}`); + } + else { + highestLocalLsnByRegion.set(regionId, highLocalLsn); + } + } + return new VectorSessionToken(Math.max(this.version, other.version), Math.max(this.globalLsn, other.globalLsn), highestLocalLsnByRegion); + } + toString() { + return this.sessionToken; + } + areRegionProgressEqual(other) { + if (this.localLsnByregion.size !== other.size) { + return false; + } + for (const [regionId, localLsn] of this.localLsnByregion.entries()) { + const otherLocalLsn = other.get(regionId); + if (localLsn !== otherLocalLsn) { + return false; + } + } + return true; + } +} +VectorSessionToken.SEGMENT_SEPARATOR = "#"; +VectorSessionToken.REGION_PROGRESS_SEPARATOR = "="; +/** + * @hidden + */ +function max(int1, int2) { + // NOTE: This only works for positive numbers + if (int1.length === int2.length) { + return int1 > int2 ? int1 : int2; + } + else if (int1.length > int2.length) { + return int1; + } + else { + return int2; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** @hidden */ +class SessionContainer { + constructor(collectionNameToCollectionResourceId = new Map(), collectionResourceIdToSessionTokens = new Map()) { + this.collectionNameToCollectionResourceId = collectionNameToCollectionResourceId; + this.collectionResourceIdToSessionTokens = collectionResourceIdToSessionTokens; + } + get(request) { + if (!request) { + throw new Error("request cannot be null"); + } + const collectionName = getContainerLink(trimSlashes(request.resourceAddress)); + const rangeIdToTokenMap = this.getPartitionKeyRangeIdToTokenMap(collectionName); + return SessionContainer.getCombinedSessionTokenString(rangeIdToTokenMap); + } + remove(request) { + let collectionResourceId; + const resourceAddress = trimSlashes(request.resourceAddress); + const collectionName = getContainerLink(resourceAddress); + if (collectionName) { + collectionResourceId = this.collectionNameToCollectionResourceId.get(collectionName); + this.collectionNameToCollectionResourceId.delete(collectionName); + } + if (collectionResourceId !== undefined) { + this.collectionResourceIdToSessionTokens.delete(collectionResourceId); + } + } + set(request, resHeaders) { + // TODO: we check the master logic a few different places. Might not need it. + if (!resHeaders || + SessionContainer.isReadingFromMaster(request.resourceType, request.operationType)) { + return; + } + const sessionTokenString = resHeaders[Constants$1.HttpHeaders.SessionToken]; + if (!sessionTokenString) { + return; + } + const containerName = this.getContainerName(request, resHeaders); + const ownerId = !request.isNameBased + ? request.resourceId + : resHeaders[Constants$1.HttpHeaders.OwnerId] || request.resourceId; + if (!ownerId) { + return; + } + if (containerName && this.validateOwnerID(ownerId)) { + if (!this.collectionResourceIdToSessionTokens.has(ownerId)) { + this.collectionResourceIdToSessionTokens.set(ownerId, new Map()); + } + if (!this.collectionNameToCollectionResourceId.has(containerName)) { + this.collectionNameToCollectionResourceId.set(containerName, ownerId); + } + const containerSessionContainer = this.collectionResourceIdToSessionTokens.get(ownerId); + SessionContainer.compareAndSetToken(sessionTokenString, containerSessionContainer); + } + } + validateOwnerID(ownerId) { + // If ownerId contains exactly 8 bytes it represents a unique database+collection identifier. Otherwise it represents another resource + // The first 4 bytes are the database. The last 4 bytes are the collection. + // Cosmos rids potentially contain "-" which is an invalid character in the browser atob implementation + // See https://en.wikipedia.org/wiki/Base64#Filenames + return atob(ownerId.replace(/-/g, "/")).length === 8; + } + getPartitionKeyRangeIdToTokenMap(collectionName) { + let rangeIdToTokenMap = null; + if (collectionName && this.collectionNameToCollectionResourceId.has(collectionName)) { + rangeIdToTokenMap = this.collectionResourceIdToSessionTokens.get(this.collectionNameToCollectionResourceId.get(collectionName)); + } + return rangeIdToTokenMap; + } + static getCombinedSessionTokenString(tokens) { + if (!tokens || tokens.size === 0) { + return SessionContainer.EMPTY_SESSION_TOKEN; + } + let result = ""; + for (const [range, token] of tokens.entries()) { + result += + range + + SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER + + token.toString() + + SessionContainer.SESSION_TOKEN_SEPARATOR; + } + return result.slice(0, -1); + } + static compareAndSetToken(newTokenString, containerSessionTokens) { + if (!newTokenString) { + return; + } + const partitionsParts = newTokenString.split(SessionContainer.SESSION_TOKEN_SEPARATOR); + for (const partitionPart of partitionsParts) { + const newTokenParts = partitionPart.split(SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER); + if (newTokenParts.length !== 2) { + return; + } + const range = newTokenParts[0]; + const newToken = VectorSessionToken.create(newTokenParts[1]); + const tokenForRange = !containerSessionTokens.get(range) + ? newToken + : containerSessionTokens.get(range).merge(newToken); + containerSessionTokens.set(range, tokenForRange); + } + } + // TODO: have a assert if the type doesn't mastch known types + static isReadingFromMaster(resourceType, operationType) { + if (resourceType === Constants$1.Path.OffersPathSegment || + resourceType === Constants$1.Path.DatabasesPathSegment || + resourceType === Constants$1.Path.UsersPathSegment || + resourceType === Constants$1.Path.PermissionsPathSegment || + resourceType === Constants$1.Path.TopologyPathSegment || + resourceType === Constants$1.Path.DatabaseAccountPathSegment || + resourceType === Constants$1.Path.PartitionKeyRangesPathSegment || + (resourceType === Constants$1.Path.CollectionsPathSegment && + operationType === exports.OperationType.Query)) { + return true; + } + return false; + } + getContainerName(request, headers) { + let ownerFullName = headers[Constants$1.HttpHeaders.OwnerFullName]; + if (!ownerFullName) { + ownerFullName = trimSlashes(request.resourceAddress); + } + return getContainerLink(ownerFullName); + } +} +SessionContainer.EMPTY_SESSION_TOKEN = ""; +SessionContainer.SESSION_TOKEN_SEPARATOR = ","; +SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER = ":"; + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function checkURL(testString) { + return new URL(testString); +} +function sanitizeEndpoint(url) { + return new URL(url).href.replace(/\/$/, ""); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function supportedQueryFeaturesBuilder(disableNonStreamingOrderByQuery) { + if (disableNonStreamingOrderByQuery) { + return Object.keys(QueryFeature) + .filter((k) => k !== QueryFeature.NonStreamingOrderBy) + .join(", "); + } + else { + return Object.keys(QueryFeature).join(", "); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Implementation of DiagnosticWriter, which uses \@azure/logger to write + * diagnostics. + * @hidden + */ +class LogDiagnosticWriter { + constructor() { + this.logger = logger$5.createClientLogger("CosmosDBDiagnostics"); + } + async write(diagnosticsData) { + this.logger.verbose(diagnosticsData); + } +} +/** + * Implementation of a no-op DiagnosticWriter. + * @hidden + */ +class NoOpDiagnosticWriter { + async write(_diagnosticsData) { + // No op + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class DefaultDiagnosticFormatter { + format(cosmosDiagnostic) { + return JSON.stringify(cosmosDiagnostic); + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const uuid = uuid$3.v4; +const logger = logger$5.createClientLogger("ClientContext"); +const QueryJsonContentType = "application/query+json"; +const HttpHeaders = Constants$1.HttpHeaders; +/** + * @hidden + * @hidden + */ +class ClientContext { + constructor(cosmosClientOptions, globalEndpointManager, clientConfig, diagnosticLevel) { + this.cosmosClientOptions = cosmosClientOptions; + this.globalEndpointManager = globalEndpointManager; + this.clientConfig = clientConfig; + this.diagnosticLevel = diagnosticLevel; + this.connectionPolicy = cosmosClientOptions.connectionPolicy; + this.sessionContainer = new SessionContainer(); + this.partitionKeyDefinitionCache = {}; + this.pipeline = null; + if (cosmosClientOptions.aadCredentials) { + this.pipeline = coreRestPipeline.createEmptyPipeline(); + const hrefEndpoint = sanitizeEndpoint(cosmosClientOptions.endpoint); + const scope = `${hrefEndpoint}/.default`; + this.pipeline.addPolicy(coreRestPipeline.bearerTokenAuthenticationPolicy({ + credential: cosmosClientOptions.aadCredentials, + scopes: scope, + challengeCallbacks: { + async authorizeRequest({ request, getAccessToken }) { + const tokenResponse = await getAccessToken([scope], {}); + const AUTH_PREFIX = `type=aad&ver=1.0&sig=`; + const authorizationToken = `${AUTH_PREFIX}${tokenResponse.token}`; + request.headers.set("Authorization", authorizationToken); + }, + }, + })); + } + this.initializeDiagnosticSettings(diagnosticLevel); + } + /** @hidden */ + async read({ path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.get, path, operationType: exports.OperationType.Read, resourceId, + options, + resourceType, + partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Read, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // read will use ReadEndpoint since it uses GET operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + this.captureSessionToken(undefined, path, exports.OperationType.Read, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + async queryFeed({ path, resourceType, resourceId, resultFn, query, options, diagnosticNode, partitionKeyRangeId, partitionKey, startEpk, endEpk, }) { + // Query operations will use ReadEndpoint even though it uses + // GET(for queryFeed) and POST(for regular query operations) + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.get, path, operationType: exports.OperationType.Query, partitionKeyRangeId, + resourceId, + resourceType, + options, body: query, partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Query, + resourceType, + }); + const requestId = uuid(); + if (query !== undefined) { + request.method = exports.HTTPMethod.post; + } + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + request.headers = await this.buildHeaders(request); + if (startEpk !== undefined && endEpk !== undefined) { + request.headers[HttpHeaders.StartEpk] = startEpk; + request.headers[HttpHeaders.EndEpk] = endEpk; + request.headers[HttpHeaders.ReadFeedKeyType] = "EffectivePartitionKeyRange"; + } + if (query !== undefined) { + request.headers[HttpHeaders.IsQuery] = "true"; + request.headers[HttpHeaders.ContentType] = QueryJsonContentType; + if (typeof query === "string") { + request.body = { query }; // Converts query text to query object. + } + } + this.applySessionToken(request); + logger.info("query " + + requestId + + " started" + + (request.partitionKeyRangeId ? " pkrid: " + request.partitionKeyRangeId : "")); + logger.verbose(request); + const start = Date.now(); + const response = await RequestHandler.request(request, diagnosticNode); + logger.info("query " + requestId + " finished - " + (Date.now() - start) + "ms"); + this.captureSessionToken(undefined, path, exports.OperationType.Query, response.headers); + return this.processQueryFeedResponse(response, !!query, resultFn); + } + async getQueryPlan(path, resourceType, resourceId, query, options = {}, diagnosticNode) { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.post, path, operationType: exports.OperationType.Read, resourceId, + resourceType, + options, body: query }); + diagnosticNode.addData({ + operationType: exports.OperationType.Read, + resourceType, + }); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsQueryPlan] = "True"; + request.headers[HttpHeaders.QueryVersion] = "1.4"; + request.headers[HttpHeaders.ContentType] = QueryJsonContentType; + request.headers[HttpHeaders.SupportedQueryFeatures] = supportedQueryFeaturesBuilder(options.disableNonStreamingOrderByQuery); + if (typeof query === "string") { + request.body = { query }; // Converts query text to query object. + } + this.applySessionToken(request); + const response = await RequestHandler.request(request, diagnosticNode); + this.captureSessionToken(undefined, path, exports.OperationType.Query, response.headers); + return response; + } + queryPartitionKeyRanges(collectionLink, query, options) { + const path = getPathFromLink(collectionLink, exports.ResourceType.pkranges); + const id = getIdFromLink(collectionLink); + const cb = async (diagNode, innerOptions) => { + const response = await this.queryFeed({ + path, + resourceType: exports.ResourceType.pkranges, + resourceId: id, + resultFn: (result) => result.PartitionKeyRanges, + query, + options: innerOptions, + diagnosticNode: diagNode, + }); + return response; + }; + return new QueryIterator(this, query, options, cb); + } + async delete({ path, resourceType, resourceId, options = {}, partitionKey, method = exports.HTTPMethod.delete, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: method, operationType: exports.OperationType.Delete, path, + resourceType, + options, + resourceId, + partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Delete, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // deleteResource will use WriteEndpoint since it uses DELETE operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + if (parseLink(path).type !== "colls") { + this.captureSessionToken(undefined, path, exports.OperationType.Delete, response.headers); + } + else { + this.clearSessionToken(path); + } + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + async patch({ body, path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.patch, operationType: exports.OperationType.Patch, path, + resourceType, + body, + resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Patch, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // patch will use WriteEndpoint + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + this.captureSessionToken(undefined, path, exports.OperationType.Patch, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + async create({ body, path, resourceType, resourceId, diagnosticNode, options = {}, partitionKey, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.post, operationType: exports.OperationType.Create, path, + resourceType, + resourceId, + body, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Create, + resourceType, + }); + request.headers = await this.buildHeaders(request); + // create will use WriteEndpoint since it uses POST operation + this.applySessionToken(request); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + this.captureSessionToken(undefined, path, exports.OperationType.Create, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + processQueryFeedResponse(res, isQuery, resultFn) { + if (isQuery) { + return { + result: resultFn(res.result), + headers: res.headers, + code: res.code, + }; + } + else { + const newResult = resultFn(res.result).map((body) => body); + return { + result: newResult, + headers: res.headers, + code: res.code, + }; + } + } + applySessionToken(requestContext) { + const request = this.getSessionParams(requestContext.path); + if (requestContext.headers && requestContext.headers[HttpHeaders.SessionToken]) { + return; + } + const sessionConsistency = requestContext.headers[HttpHeaders.ConsistencyLevel]; + if (!sessionConsistency) { + return; + } + if (sessionConsistency !== exports.ConsistencyLevel.Session) { + return; + } + if (request.resourceAddress) { + const sessionToken = this.sessionContainer.get(request); + if (sessionToken) { + requestContext.headers[HttpHeaders.SessionToken] = sessionToken; + } + } + } + async replace({ body, path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.put, operationType: exports.OperationType.Replace, path, + resourceType, + body, + resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Replace, + resourceType, + }); + request.headers = await this.buildHeaders(request); + this.applySessionToken(request); + // replace will use WriteEndpoint since it uses PUT operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + this.captureSessionToken(undefined, path, exports.OperationType.Replace, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + async upsert({ body, path, resourceType, resourceId, options = {}, partitionKey, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.post, operationType: exports.OperationType.Upsert, path, + resourceType, + body, + resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Upsert, + resourceType, + }); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsUpsert] = true; + this.applySessionToken(request); + // upsert will use WriteEndpoint since it uses POST operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + this.captureSessionToken(undefined, path, exports.OperationType.Upsert, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + async execute({ sprocLink, params, options = {}, partitionKey, diagnosticNode, }) { + // Accept a single parameter or an array of parameters. + // Didn't add type annotation for this because we should legacy this behavior + if (params !== null && params !== undefined && !Array.isArray(params)) { + params = [params]; + } + const path = getPathFromLink(sprocLink); + const id = getIdFromLink(sprocLink); + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.post, operationType: exports.OperationType.Execute, path, resourceType: exports.ResourceType.sproc, options, resourceId: id, body: params, partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Execute, + resourceType: exports.ResourceType.sproc, + }); + request.headers = await this.buildHeaders(request); + // executeStoredProcedure will use WriteEndpoint since it uses POST operation + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + return response; + } + /** + * Gets the Database account information. + * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved. + * If not present, current client's url will be used. + */ + async getDatabaseAccount(diagnosticNode, options = {}) { + const endpoint = options.urlConnection || this.cosmosClientOptions.endpoint; + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { endpoint, method: exports.HTTPMethod.get, operationType: exports.OperationType.Read, path: "", resourceType: exports.ResourceType.none, options }); + diagnosticNode.addData({ + operationType: exports.OperationType.Read, + resourceType: exports.ResourceType.none, + }); + request.headers = await this.buildHeaders(request); + // await options.beforeOperation({ endpoint, request, headers: requestHeaders }); + const { result, headers, code, substatus, diagnostics } = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + const databaseAccount = new DatabaseAccount(result, headers); + return { + result: databaseAccount, + headers, + diagnostics, + code: code, + substatus: substatus, + }; + } + getWriteEndpoint(diagnosticNode) { + return this.globalEndpointManager.getWriteEndpoint(diagnosticNode); + } + getReadEndpoint(diagnosticNode) { + return this.globalEndpointManager.getReadEndpoint(diagnosticNode); + } + getWriteEndpoints() { + return this.globalEndpointManager.getWriteEndpoints(); + } + getReadEndpoints() { + return this.globalEndpointManager.getReadEndpoints(); + } + async batch({ body, path, partitionKey, resourceId, options = {}, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.post, operationType: exports.OperationType.Batch, path, + body, resourceType: exports.ResourceType.item, resourceId, + options, + partitionKey }); + diagnosticNode.addData({ + operationType: exports.OperationType.Batch, + resourceType: exports.ResourceType.item, + }); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsBatchRequest] = true; + request.headers[HttpHeaders.IsBatchAtomic] = true; + this.applySessionToken(request); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + this.captureSessionToken(undefined, path, exports.OperationType.Batch, response.headers); + response.diagnostics = diagnosticNode.toDiagnostic(this.getClientConfig()); + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + async bulk({ body, path, partitionKeyRangeId, resourceId, bulkOptions = {}, options = {}, diagnosticNode, }) { + try { + const request = Object.assign(Object.assign({}, this.getContextDerivedPropsForRequestCreation()), { method: exports.HTTPMethod.post, operationType: exports.OperationType.Batch, path, + body, resourceType: exports.ResourceType.item, resourceId, + options }); + diagnosticNode.addData({ + operationType: exports.OperationType.Batch, + resourceType: exports.ResourceType.item, + }); + request.headers = await this.buildHeaders(request); + request.headers[HttpHeaders.IsBatchRequest] = true; + request.headers[HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId; + request.headers[HttpHeaders.IsBatchAtomic] = false; + request.headers[HttpHeaders.BatchContinueOnError] = bulkOptions.continueOnError || false; + this.applySessionToken(request); + request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(diagnosticNode, request.resourceType, request.operationType); + const response = await executePlugins(diagnosticNode, request, RequestHandler.request, exports.PluginOn.operation); + this.captureSessionToken(undefined, path, exports.OperationType.Batch, response.headers); + return response; + } + catch (err) { + this.captureSessionToken(err, path, exports.OperationType.Upsert, err.headers); + throw err; + } + } + captureSessionToken(err, path, operationType, resHeaders) { + const request = this.getSessionParams(path); + request.operationType = operationType; + if (!err || + (!this.isMasterResource(request.resourceType) && + (err.code === StatusCodes.PreconditionFailed || + err.code === StatusCodes.Conflict || + (err.code === StatusCodes.NotFound && + err.substatus !== SubStatusCodes.ReadSessionNotAvailable)))) { + this.sessionContainer.set(request, resHeaders); + } + } + clearSessionToken(path) { + const request = this.getSessionParams(path); + this.sessionContainer.remove(request); + } + recordDiagnostics(diagnostic) { + const formatted = this.diagnosticFormatter.format(diagnostic); + this.diagnosticWriter.write(formatted); + } + initializeDiagnosticSettings(diagnosticLevel) { + this.diagnosticFormatter = new DefaultDiagnosticFormatter(); + switch (diagnosticLevel) { + case exports.CosmosDbDiagnosticLevel.info: + this.diagnosticWriter = new NoOpDiagnosticWriter(); + break; + default: + this.diagnosticWriter = new LogDiagnosticWriter(); + } + } + // TODO: move + getSessionParams(resourceLink) { + const resourceId = null; + let resourceAddress = null; + const parserOutput = parseLink(resourceLink); + resourceAddress = parserOutput.objectBody.self; + const resourceType = parserOutput.type; + return { + resourceId, + resourceAddress, + resourceType, + isNameBased: true, + }; + } + isMasterResource(resourceType) { + if (resourceType === Constants$1.Path.OffersPathSegment || + resourceType === Constants$1.Path.DatabasesPathSegment || + resourceType === Constants$1.Path.UsersPathSegment || + resourceType === Constants$1.Path.PermissionsPathSegment || + resourceType === Constants$1.Path.TopologyPathSegment || + resourceType === Constants$1.Path.DatabaseAccountPathSegment || + resourceType === Constants$1.Path.PartitionKeyRangesPathSegment || + resourceType === Constants$1.Path.CollectionsPathSegment) { + return true; + } + return false; + } + buildHeaders(requestContext) { + return getHeaders({ + clientOptions: this.cosmosClientOptions, + defaultHeaders: Object.assign(Object.assign({}, this.cosmosClientOptions.defaultHeaders), requestContext.options.initialHeaders), + verb: requestContext.method, + path: requestContext.path, + resourceId: requestContext.resourceId, + resourceType: requestContext.resourceType, + options: requestContext.options, + partitionKeyRangeId: requestContext.partitionKeyRangeId, + useMultipleWriteLocations: this.connectionPolicy.useMultipleWriteLocations, + partitionKey: requestContext.partitionKey !== undefined + ? convertToInternalPartitionKey(requestContext.partitionKey) + : undefined, // TODO: Move this check from here to PartitionKey + }); + } + /** + * Returns collection of properties which are derived from the context for Request Creation. + * These properties have client wide scope, as opposed to request specific scope. + * @returns + */ + getContextDerivedPropsForRequestCreation() { + return { + globalEndpointManager: this.globalEndpointManager, + requestAgent: this.cosmosClientOptions.agent, + connectionPolicy: this.connectionPolicy, + client: this, + plugins: this.cosmosClientOptions.plugins, + pipeline: this.pipeline, + }; + } + getClientConfig() { + return this.clientConfig; + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + */ +function getUserAgent(suffix) { + const ua = `${universalUserAgent.getUserAgent()} ${Constants$1.SDKName}/${Constants$1.SDKVersion}`; + if (suffix) { + return ua + " " + suffix; + } + return ua; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +function isNonEmptyString(variable) { + return typeof variable === "string" && variable.trim().length > 0; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +const DefaultDiagnosticLevelValue = exports.CosmosDbDiagnosticLevel.info; +const diagnosticLevelFromEnv = (typeof process !== "undefined" && + process.env && + process.env[Constants$1.CosmosDbDiagnosticLevelEnvVarName]) || + undefined; +const acceptableDiagnosticLevelValues = Object.values(exports.CosmosDbDiagnosticLevel).map((x) => x.toString()); +let cosmosDiagnosticLevel; +if (isNonEmptyString(diagnosticLevelFromEnv)) { + // avoid calling setDiagnosticLevel because we don't want a mis-set environment variable to crash + if (isCosmosDiagnosticLevel(diagnosticLevelFromEnv)) { + setDiagnosticLevel(diagnosticLevelFromEnv); + } + else { + console.error(`${Constants$1.CosmosDbDiagnosticLevelEnvVarName} set to unknown diagnostic level '${diagnosticLevelFromEnv}'; Setting Cosmos Db diagnostic level to info. Acceptable values: ${acceptableDiagnosticLevelValues.join(", ")}.`); + } +} +function setDiagnosticLevel(level) { + if (level && !isCosmosDiagnosticLevel(level)) { + throw new Error(`Unknown diagnostic level '${level}'. Acceptable values: ${acceptableDiagnosticLevelValues.join(",")}`); + } + cosmosDiagnosticLevel = level; +} +function getDiagnosticLevelFromEnvironment() { + return cosmosDiagnosticLevel; +} +function isCosmosDiagnosticLevel(diagnosticLevel) { + return acceptableDiagnosticLevelValues.includes(diagnosticLevel); +} +function determineDiagnosticLevel(diagnosticLevelFromClientConfig, diagnosticLevelFromEnvironment) { + const diagnosticLevelFromEnvOrClient = diagnosticLevelFromEnvironment !== null && diagnosticLevelFromEnvironment !== void 0 ? diagnosticLevelFromEnvironment : diagnosticLevelFromClientConfig; // Diagnostic Setting from environment gets first priority. + return diagnosticLevelFromEnvOrClient !== null && diagnosticLevelFromEnvOrClient !== void 0 ? diagnosticLevelFromEnvOrClient : DefaultDiagnosticLevelValue; // Diagnostic Setting supplied in Client config gets second priority. +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * @hidden + * This internal class implements the logic for endpoint management for geo-replicated database accounts. + */ +class GlobalEndpointManager { + /** + * @param options - The document client instance. + * @internal + */ + constructor(options, readDatabaseAccount) { + this.readDatabaseAccount = readDatabaseAccount; + this.writeableLocations = []; + this.readableLocations = []; + this.unavailableReadableLocations = []; + this.unavailableWriteableLocations = []; + this.options = options; + this.defaultEndpoint = options.endpoint; + this.enableEndpointDiscovery = options.connectionPolicy.enableEndpointDiscovery; + this.isRefreshing = false; + this.preferredLocations = this.options.connectionPolicy.preferredLocations; + this.preferredLocationsCount = this.preferredLocations ? this.preferredLocations.length : 0; + } + /** + * Gets the current read endpoint from the endpoint cache. + */ + async getReadEndpoint(diagnosticNode) { + return this.resolveServiceEndpoint(diagnosticNode, exports.ResourceType.item, exports.OperationType.Read); + } + /** + * Gets the current write endpoint from the endpoint cache. + */ + async getWriteEndpoint(diagnosticNode) { + return this.resolveServiceEndpoint(diagnosticNode, exports.ResourceType.item, exports.OperationType.Replace); + } + async getReadEndpoints() { + return this.readableLocations.map((loc) => loc.databaseAccountEndpoint); + } + async getWriteEndpoints() { + return this.writeableLocations.map((loc) => loc.databaseAccountEndpoint); + } + async markCurrentLocationUnavailableForRead(diagnosticNode, endpoint) { + await this.refreshEndpointList(diagnosticNode); + const location = this.readableLocations.find((loc) => loc.databaseAccountEndpoint === endpoint); + if (location) { + location.unavailable = true; + location.lastUnavailabilityTimestampInMs = Date.now(); + this.unavailableReadableLocations.push(location); + } + } + async markCurrentLocationUnavailableForWrite(diagnosticNode, endpoint) { + await this.refreshEndpointList(diagnosticNode); + const location = this.writeableLocations.find((loc) => loc.databaseAccountEndpoint === endpoint); + if (location) { + location.unavailable = true; + location.lastUnavailabilityTimestampInMs = Date.now(); + this.unavailableWriteableLocations.push(location); + } + } + canUseMultipleWriteLocations(resourceType, operationType) { + let canUse = this.options.connectionPolicy.useMultipleWriteLocations; + if (resourceType) { + canUse = + canUse && + (resourceType === exports.ResourceType.item || + (resourceType === exports.ResourceType.sproc && operationType === exports.OperationType.Execute)); + } + return canUse; + } + async resolveServiceEndpoint(diagnosticNode, resourceType, operationType, startServiceEndpointIndex = 0) { + // If endpoint discovery is disabled, always use the user provided endpoint + if (!this.options.connectionPolicy.enableEndpointDiscovery) { + diagnosticNode.addData({ readFromCache: true }, "default_endpoint"); + diagnosticNode.recordEndpointResolution(this.defaultEndpoint); + return this.defaultEndpoint; + } + // If getting the database account, always use the user provided endpoint + if (resourceType === exports.ResourceType.none) { + diagnosticNode.addData({ readFromCache: true }, "none_resource"); + diagnosticNode.recordEndpointResolution(this.defaultEndpoint); + return this.defaultEndpoint; + } + if (this.readableLocations.length === 0 || this.writeableLocations.length === 0) { + const resourceResponse = await withMetadataDiagnostics(async (metadataNode) => { + return this.readDatabaseAccount(metadataNode, { + urlConnection: this.defaultEndpoint, + }); + }, diagnosticNode, exports.MetadataLookUpType.DatabaseAccountLookUp); + this.writeableLocations = resourceResponse.resource.writableLocations; + this.readableLocations = resourceResponse.resource.readableLocations; + } + const locations = isReadRequest(operationType) + ? this.readableLocations + : this.writeableLocations; + let location; + // If we have preferred locations, try each one in order and use the first available one + if (this.preferredLocations && + this.preferredLocations.length > 0 && + startServiceEndpointIndex < this.preferredLocations.length) { + for (let i = startServiceEndpointIndex; i < this.preferredLocations.length; i++) { + const preferredLocation = this.preferredLocations[i]; + location = locations.find((loc) => loc.unavailable !== true && + normalizeEndpoint(loc.name) === normalizeEndpoint(preferredLocation)); + if (location) { + break; + } + } + } + // If no preferred locations or one did not match, just grab the first one that is available + if (!location) { + const startIndexValid = startServiceEndpointIndex >= 0 && startServiceEndpointIndex < locations.length; + const locationsToSearch = startIndexValid + ? locations.slice(startServiceEndpointIndex) + : locations; + location = locationsToSearch.find((loc) => { + return loc.unavailable !== true; + }); + } + location = location ? location : { name: "", databaseAccountEndpoint: this.defaultEndpoint }; + diagnosticNode.recordEndpointResolution(location.databaseAccountEndpoint); + return location.databaseAccountEndpoint; + } + /** + * Refreshes the endpoint list by clearning stale unavailability and then + * retrieving the writable and readable locations from the geo-replicated database account + * and then updating the locations cache. + * We skip the refreshing if enableEndpointDiscovery is set to False + */ + async refreshEndpointList(diagnosticNode) { + if (!this.isRefreshing && this.enableEndpointDiscovery) { + this.isRefreshing = true; + const databaseAccount = await this.getDatabaseAccountFromAnyEndpoint(diagnosticNode); + if (databaseAccount) { + this.refreshStaleUnavailableLocations(); + this.refreshEndpoints(databaseAccount); + } + this.isRefreshing = false; + } + } + refreshEndpoints(databaseAccount) { + for (const location of databaseAccount.writableLocations) { + const existingLocation = this.writeableLocations.find((loc) => loc.name === location.name); + if (!existingLocation) { + this.writeableLocations.push(location); + } + } + for (const location of databaseAccount.readableLocations) { + const existingLocation = this.readableLocations.find((loc) => loc.name === location.name); + if (!existingLocation) { + this.readableLocations.push(location); + } + } + } + refreshStaleUnavailableLocations() { + const now = Date.now(); + this.updateLocation(now, this.unavailableReadableLocations, this.readableLocations); + this.unavailableReadableLocations = this.cleanUnavailableLocationList(now, this.unavailableReadableLocations); + this.updateLocation(now, this.unavailableWriteableLocations, this.writeableLocations); + this.unavailableWriteableLocations = this.cleanUnavailableLocationList(now, this.unavailableWriteableLocations); + } + /** + * update the locationUnavailability to undefined if the location is available again + * @param now - current time + * @param unavailableLocations - list of unavailable locations + * @param allLocations - list of all locations + */ + updateLocation(now, unavailableLocations, allLocations) { + for (const location of unavailableLocations) { + const unavaialableLocation = allLocations.find((loc) => loc.name === location.name); + if (unavaialableLocation && + now - unavaialableLocation.lastUnavailabilityTimestampInMs > + Constants$1.LocationUnavailableExpirationTimeInMs) { + unavaialableLocation.unavailable = false; + } + } + } + cleanUnavailableLocationList(now, unavailableLocations) { + return unavailableLocations.filter((loc) => { + if (loc && + now - loc.lastUnavailabilityTimestampInMs >= Constants$1.LocationUnavailableExpirationTimeInMs) { + return false; + } + return true; + }); + } + /** + * Gets the database account first by using the default endpoint, and if that doesn't returns + * use the endpoints for the preferred locations in the order they are specified to get + * the database account. + */ + async getDatabaseAccountFromAnyEndpoint(diagnosticNode) { + try { + const options = { urlConnection: this.defaultEndpoint }; + const { resource: databaseAccount } = await this.readDatabaseAccount(diagnosticNode, options); + return databaseAccount; + // If for any reason(non - globaldb related), we are not able to get the database + // account from the above call to readDatabaseAccount, + // we would try to get this information from any of the preferred locations that the user + // might have specified (by creating a locational endpoint) + // and keeping eating the exception until we get the database account and return None at the end, + // if we are not able to get that info from any endpoints + } + catch (err) { + // TODO: Tracing + } + if (this.preferredLocations) { + for (const location of this.preferredLocations) { + try { + const locationalEndpoint = GlobalEndpointManager.getLocationalEndpoint(this.defaultEndpoint, location); + const options = { urlConnection: locationalEndpoint }; + const { resource: databaseAccount } = await this.readDatabaseAccount(diagnosticNode, options); + if (databaseAccount) { + return databaseAccount; + } + } + catch (err) { + // TODO: Tracing + } + } + } + } + /** + * Gets the locational endpoint using the location name passed to it using the default endpoint. + * + * @param defaultEndpoint - The default endpoint to use for the endpoint. + * @param locationName - The location name for the azure region like "East US". + */ + static getLocationalEndpoint(defaultEndpoint, locationName) { + // For defaultEndpoint like 'https://contoso.documents.azure.com:443/' parse it to generate URL format + // This defaultEndpoint should be global endpoint(and cannot be a locational endpoint) + // and we agreed to document that + const endpointUrl = new URL(defaultEndpoint); + // hostname attribute in endpointUrl will return 'contoso.documents.azure.com' + if (endpointUrl.hostname) { + const hostnameParts = endpointUrl.hostname.toString().toLowerCase().split("."); + if (hostnameParts) { + // globalDatabaseAccountName will return 'contoso' + const globalDatabaseAccountName = hostnameParts[0]; + // Prepare the locationalDatabaseAccountName as contoso-EastUS for location_name 'East US' + const locationalDatabaseAccountName = globalDatabaseAccountName + "-" + locationName.replace(" ", ""); + // Replace 'contoso' with 'contoso-EastUS' and + // return locationalEndpoint as https://contoso-EastUS.documents.azure.com:443/ + const locationalEndpoint = defaultEndpoint + .toLowerCase() + .replace(globalDatabaseAccountName, locationalDatabaseAccountName); + return locationalEndpoint; + } + } + return null; + } +} +function normalizeEndpoint(endpoint) { + return endpoint.split(" ").join("").toLowerCase(); +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Provides a client-side logical representation of the Azure Cosmos DB database account. + * This client is used to configure and execute requests in the Azure Cosmos DB database service. + * @example Instantiate a client and create a new database + * ```typescript + * const client = new CosmosClient({endpoint: "", auth: {masterKey: ""}}); + * await client.databases.create({id: ""}); + * ``` + * @example Instantiate a client with custom Connection Policy + * ```typescript + * const connectionPolicy = new ConnectionPolicy(); + * connectionPolicy.RequestTimeout = 10000; + * const client = new CosmosClient({ + * endpoint: "", + * auth: {masterKey: ""}, + * connectionPolicy + * }); + * ``` + */ +class CosmosClient { + constructor(optionsOrConnectionString) { + var _a, _b; + if (typeof optionsOrConnectionString === "string") { + optionsOrConnectionString = parseConnectionString(optionsOrConnectionString); + } + const endpoint = checkURL(optionsOrConnectionString.endpoint); + if (!endpoint) { + throw new Error("Invalid endpoint specified"); + } + const clientConfig = this.initializeClientConfigDiagnostic(optionsOrConnectionString); + optionsOrConnectionString.connectionPolicy = Object.assign({}, defaultConnectionPolicy, optionsOrConnectionString.connectionPolicy); + optionsOrConnectionString.defaultHeaders = optionsOrConnectionString.defaultHeaders || {}; + optionsOrConnectionString.defaultHeaders[Constants$1.HttpHeaders.CacheControl] = "no-cache"; + optionsOrConnectionString.defaultHeaders[Constants$1.HttpHeaders.Version] = + Constants$1.CurrentVersion; + if (optionsOrConnectionString.consistencyLevel !== undefined) { + optionsOrConnectionString.defaultHeaders[Constants$1.HttpHeaders.ConsistencyLevel] = + optionsOrConnectionString.consistencyLevel; + } + optionsOrConnectionString.defaultHeaders[Constants$1.HttpHeaders.UserAgent] = getUserAgent(optionsOrConnectionString.userAgentSuffix); + const globalEndpointManager = new GlobalEndpointManager(optionsOrConnectionString, async (diagnosticNode, opts) => this.getDatabaseAccountInternal(diagnosticNode, opts)); + this.clientContext = new ClientContext(optionsOrConnectionString, globalEndpointManager, clientConfig, determineDiagnosticLevel(optionsOrConnectionString.diagnosticLevel, getDiagnosticLevelFromEnvironment())); + if (((_a = optionsOrConnectionString.connectionPolicy) === null || _a === void 0 ? void 0 : _a.enableEndpointDiscovery) && + ((_b = optionsOrConnectionString.connectionPolicy) === null || _b === void 0 ? void 0 : _b.enableBackgroundEndpointRefreshing)) { + this.backgroundRefreshEndpointList(globalEndpointManager, optionsOrConnectionString.connectionPolicy.endpointRefreshRateInMs || + defaultConnectionPolicy.endpointRefreshRateInMs); + } + this.databases = new Databases(this, this.clientContext); + this.offers = new Offers(this, this.clientContext); + } + initializeClientConfigDiagnostic(optionsOrConnectionString) { + return { + endpoint: optionsOrConnectionString.endpoint, + resourceTokensConfigured: optionsOrConnectionString.resourceTokens !== undefined, + tokenProviderConfigured: optionsOrConnectionString.tokenProvider !== undefined, + aadCredentialsConfigured: optionsOrConnectionString.aadCredentials !== undefined, + connectionPolicyConfigured: optionsOrConnectionString.connectionPolicy !== undefined, + consistencyLevel: optionsOrConnectionString.consistencyLevel, + defaultHeaders: optionsOrConnectionString.defaultHeaders, + agentConfigured: optionsOrConnectionString.agent !== undefined, + userAgentSuffix: optionsOrConnectionString.userAgentSuffix, + diagnosticLevel: optionsOrConnectionString.diagnosticLevel, + pluginsConfigured: optionsOrConnectionString.plugins !== undefined, + sDKVersion: Constants$1.SDKVersion, + }; + } + /** + * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.) + */ + async getDatabaseAccount(options) { + return withDiagnostics(async (diagnosticNode) => { + return this.getDatabaseAccountInternal(diagnosticNode, options); + }, this.clientContext); + } + /** + * @hidden + */ + async getDatabaseAccountInternal(diagnosticNode, options) { + const response = await this.clientContext.getDatabaseAccount(diagnosticNode, options); + return new ResourceResponse(response.result, response.headers, response.code, getEmptyCosmosDiagnostics(), response.substatus); + } + /** + * Gets the currently used write endpoint url. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + async getWriteEndpoint() { + return withDiagnostics(async (diagnosticNode) => { + return this.clientContext.getWriteEndpoint(diagnosticNode); + }, this.clientContext); + } + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + async getReadEndpoint() { + return withDiagnostics(async (diagnosticNode) => { + return this.clientContext.getReadEndpoint(diagnosticNode); + }, this.clientContext); + } + /** + * Gets the known write endpoints. Useful for troubleshooting purposes. + * + * The urls may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getWriteEndpoints() { + return this.clientContext.getWriteEndpoints(); + } + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getReadEndpoints() { + return this.clientContext.getReadEndpoints(); + } + /** + * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database. + * + * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object. + * + * @param id - The id of the database. + * @example Create a new container off of an existing database + * ```typescript + * const container = client.database("").containers.create(""); + * ``` + * + * @example Delete an existing database + * ```typescript + * await client.database("").delete(); + * ``` + */ + database(id) { + return new Database(this, id, this.clientContext); + } + /** + * Used for reading, or updating a existing offer by id. + * @param id - The id of the offer. + */ + offer(id) { + return new Offer(this, id, this.clientContext); + } + /** + * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process. + */ + dispose() { + clearTimeout(this.endpointRefresher); + } + async backgroundRefreshEndpointList(globalEndpointManager, refreshRate) { + this.endpointRefresher = setInterval(() => { + try { + return withDiagnostics(async (diagnosticNode) => { + return globalEndpointManager.refreshEndpointList(diagnosticNode); + }, this.clientContext, exports.DiagnosticNodeType.BACKGROUND_REFRESH_THREAD); + } + catch (e) { + console.warn("Failed to refresh endpoints", e); + } + }, refreshRate); + if (this.endpointRefresher.unref && typeof this.endpointRefresher.unref === "function") { + this.endpointRefresher.unref(); + } + } +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +class SasTokenProperties { +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/// +function encodeUTF8(str) { + const bytes = new Uint8Array(str.length); + for (let i = 0; i < str.length; i++) { + bytes[i] = str.charCodeAt(i); + } + return bytes; +} + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +/** + * Experimental internal only + * Generates the payload representing the permission configuration for the sas token. + */ +async function createAuthorizationSasToken(masterKey, sasTokenProperties) { + let resourcePrefixPath = ""; + if (typeof sasTokenProperties.databaseName === "string" && + sasTokenProperties.databaseName !== "") { + resourcePrefixPath += `/${Constants$1.Path.DatabasesPathSegment}/${sasTokenProperties.databaseName}`; + } + if (typeof sasTokenProperties.containerName === "string" && + sasTokenProperties.containerName !== "") { + if (sasTokenProperties.databaseName === "") { + throw new Error(`illegalArgumentException : ${sasTokenProperties.databaseName} \ + is an invalid database name`); + } + resourcePrefixPath += `/${Constants$1.Path.CollectionsPathSegment}/${sasTokenProperties.containerName}`; + } + if (typeof sasTokenProperties.resourceName === "string" && + sasTokenProperties.resourceName !== "") { + if (sasTokenProperties.containerName === "") { + throw new Error(`illegalArgumentException : ${sasTokenProperties.containerName} \ + is an invalid container name`); + } + switch (sasTokenProperties.resourceKind) { + case "ITEM": + resourcePrefixPath += `${Constants$1.Path.Root}${Constants$1.Path.DocumentsPathSegment}`; + break; + case "STORED_PROCEDURE": + resourcePrefixPath += `${Constants$1.Path.Root}${Constants$1.Path.StoredProceduresPathSegment}`; + break; + case "USER_DEFINED_FUNCTION": + resourcePrefixPath += `${Constants$1.Path.Root}${Constants$1.Path.UserDefinedFunctionsPathSegment}`; + break; + case "TRIGGER": + resourcePrefixPath += `${Constants$1.Path.Root}${Constants$1.Path.TriggersPathSegment}`; + break; + default: + throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \ + is an invalid resource kind`); + } + resourcePrefixPath += `${Constants$1.Path.Root}${sasTokenProperties.resourceName}${Constants$1.Path.Root}`; + } + sasTokenProperties.resourcePath = resourcePrefixPath.toString(); + let partitionRanges = ""; + if (sasTokenProperties.partitionKeyValueRanges !== undefined && + sasTokenProperties.partitionKeyValueRanges.length > 0) { + if (typeof sasTokenProperties.resourceKind !== "string" && + sasTokenProperties.resourceKind !== "ITEM") { + throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \ + is an invalid partition key value range`); + } + sasTokenProperties.partitionKeyValueRanges.forEach((range) => { + partitionRanges += `${encodeUTF8(range)},`; + }); + } + if (sasTokenProperties.controlPlaneReaderScope === 0) { + sasTokenProperties.controlPlaneReaderScope += exports.SasTokenPermissionKind.ContainerReadAny; + sasTokenProperties.controlPlaneWriterScope += exports.SasTokenPermissionKind.ContainerReadAny; + } + if (sasTokenProperties.dataPlaneReaderScope === 0 && + sasTokenProperties.dataPlaneWriterScope === 0) { + sasTokenProperties.dataPlaneReaderScope = exports.SasTokenPermissionKind.ContainerFullAccess; + sasTokenProperties.dataPlaneWriterScope = exports.SasTokenPermissionKind.ContainerFullAccess; + } + if (typeof sasTokenProperties.keyType !== "number" || + typeof sasTokenProperties.keyType === undefined) { + switch (sasTokenProperties.keyType) { + case CosmosKeyType.PrimaryMaster: + sasTokenProperties.keyType = 1; + break; + case CosmosKeyType.SecondaryMaster: + sasTokenProperties.keyType = 2; + break; + case CosmosKeyType.PrimaryReadOnly: + sasTokenProperties.keyType = 3; + break; + case CosmosKeyType.SecondaryReadOnly: + sasTokenProperties.keyType = 4; + break; + default: + throw new Error(`illegalArgumentException : ${sasTokenProperties.keyType} \ + is an invalid key type`); + } + } + const payload = sasTokenProperties.user + + "\n" + + sasTokenProperties.userTag + + "\n" + + sasTokenProperties.resourcePath + + "\n" + + partitionRanges + + "\n" + + utcsecondsSinceEpoch(sasTokenProperties.startTime).toString(16) + + "\n" + + utcsecondsSinceEpoch(sasTokenProperties.expiryTime).toString(16) + + "\n" + + sasTokenProperties.keyType + + "\n" + + sasTokenProperties.controlPlaneReaderScope.toString(16) + + "\n" + + sasTokenProperties.controlPlaneWriterScope.toString(16) + + "\n" + + sasTokenProperties.dataPlaneReaderScope.toString(16) + + "\n" + + sasTokenProperties.dataPlaneWriterScope.toString(16) + + "\n"; + const signedPayload = await hmac(masterKey, Buffer.from(payload).toString("base64")); + return "type=sas&ver=1.0&sig=" + signedPayload + ";" + Buffer.from(payload).toString("base64"); +} +/** + * @hidden + */ +// TODO: utcMilllisecondsSinceEpoch +function utcsecondsSinceEpoch(date) { + return Math.round(date.getTime() / 1000); +} + +Object.defineProperty(exports, "RestError", { + enumerable: true, + get: function () { return coreRestPipeline.RestError; } +}); +Object.defineProperty(exports, "AbortError", { + enumerable: true, + get: function () { return abortController.AbortError; } +}); +exports.BulkOperationType = BulkOperationType; +exports.ChangeFeedIterator = ChangeFeedIterator; +exports.ChangeFeedIteratorResponse = ChangeFeedIteratorResponse; +exports.ChangeFeedResponse = ChangeFeedResponse; +exports.ChangeFeedStartFrom = ChangeFeedStartFrom; +exports.ClientContext = ClientContext; +exports.ClientSideMetrics = ClientSideMetrics; +exports.Conflict = Conflict; +exports.ConflictResponse = ConflictResponse; +exports.Conflicts = Conflicts; +exports.Constants = Constants$1; +exports.Container = Container; +exports.ContainerResponse = ContainerResponse; +exports.Containers = Containers; +exports.CosmosClient = CosmosClient; +exports.CosmosDiagnostics = CosmosDiagnostics; +exports.DEFAULT_PARTITION_KEY_PATH = DEFAULT_PARTITION_KEY_PATH; +exports.Database = Database; +exports.DatabaseAccount = DatabaseAccount; +exports.DatabaseResponse = DatabaseResponse; +exports.Databases = Databases; +exports.DiagnosticNodeInternal = DiagnosticNodeInternal; +exports.ErrorResponse = ErrorResponse; +exports.FeedRange = FeedRange; +exports.FeedResponse = FeedResponse; +exports.GlobalEndpointManager = GlobalEndpointManager; +exports.Item = Item; +exports.ItemResponse = ItemResponse; +exports.Items = Items; +exports.Offer = Offer; +exports.OfferResponse = OfferResponse; +exports.Offers = Offers; +exports.PartitionKeyBuilder = PartitionKeyBuilder; +exports.PatchOperationType = PatchOperationType; +exports.Permission = Permission; +exports.PermissionResponse = PermissionResponse; +exports.Permissions = Permissions; +exports.QueryIterator = QueryIterator; +exports.QueryMetrics = QueryMetrics; +exports.QueryMetricsConstants = QueryMetricsConstants; +exports.QueryPreparationTimes = QueryPreparationTimes; +exports.RUCapPerOperationExceededError = RUCapPerOperationExceededError; +exports.ResourceResponse = ResourceResponse; +exports.RuntimeExecutionTimes = RuntimeExecutionTimes; +exports.SasTokenProperties = SasTokenProperties; +exports.Scripts = Scripts; +exports.StatusCodes = StatusCodes; +exports.StoredProcedure = StoredProcedure; +exports.StoredProcedureResponse = StoredProcedureResponse; +exports.StoredProcedures = StoredProcedures; +exports.TimeSpan = TimeSpan; +exports.TimeoutError = TimeoutError; +exports.Trigger = Trigger; +exports.TriggerResponse = TriggerResponse; +exports.Triggers = Triggers; +exports.User = User; +exports.UserDefinedFunction = UserDefinedFunction; +exports.UserDefinedFunctionResponse = UserDefinedFunctionResponse; +exports.UserDefinedFunctions = UserDefinedFunctions; +exports.UserResponse = UserResponse; +exports.Users = Users; +exports.createAuthorizationSasToken = createAuthorizationSasToken; +exports.setAuthorizationTokenHeaderUsingMasterKey = setAuthorizationTokenHeaderUsingMasterKey; +//# sourceMappingURL=index.js.map diff --git a/local_dependencies/@azure/cosmos/dist/index.js.map b/local_dependencies/@azure/cosmos/dist/index.js.map new file mode 100644 index 000000000..2e6951792 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["../src/common/partitionKeys.ts","../src/common/constants.ts","../src/common/helper.ts","../src/common/statusCodes.ts","../src/common/uriFactory.ts","../src/common/RUConsumedManager.ts","../src/utils/hmac.ts","../src/utils/headers.ts","../src/auth.ts","../src/documents/ConnectionMode.ts","../src/documents/ConnectionPolicy.ts","../src/documents/ConsistencyLevel.ts","../src/documents/DatabaseAccount.ts","../src/documents/DataType.ts","../src/documents/IndexingMode.ts","../src/documents/IndexingPolicy.ts","../src/documents/IndexKind.ts","../src/documents/PartitionKeyInternal.ts","../src/documents/PartitionKey.ts","../src/documents/PartitionKeyDefinitionVersion.ts","../src/documents/PartitionKeyKind.ts","../src/documents/PermissionMode.ts","../src/documents/PriorityLevel.ts","../src/documents/TriggerOperation.ts","../src/documents/TriggerType.ts","../src/documents/UserDefinedFunctionType.ts","../src/documents/GeospatialType.ts","../src/extractPartitionKey.ts","../src/utils/typeChecks.ts","../src/common/logger.ts","../src/request/request.ts","../src/utils/batch.ts","../src/utils/patch.ts","../src/request/ErrorResponse.ts","../src/request/ResourceResponse.ts","../src/queryMetrics/clientSideMetrics.ts","../src/queryMetrics/queryMetricsConstants.ts","../src/queryMetrics/timeSpan.ts","../src/queryMetrics/queryMetricsUtils.ts","../src/queryMetrics/queryPreparationTime.ts","../src/queryMetrics/runtimeExecutionTimes.ts","../src/queryMetrics/queryMetrics.ts","../src/queryExecutionContext/headerUtils.ts","../src/indexMetrics/IndexUtilizationInfo.ts","../src/indexMetrics/Constants.ts","../src/indexMetrics/IndexMetricWriter.ts","../src/request/FeedResponse.ts","../src/request/TimeoutError.ts","../src/request/RUCapPerOperationExceededError.ts","../src/utils/time.ts","../src/diagnostics/CosmosDiagnosticsContext.ts","../src/CosmosDiagnostics.ts","../src/diagnostics/CosmosDbDiagnosticLevel.ts","../src/diagnostics/diagnosticLevelComparator.ts","../src/diagnostics/DiagnosticNodeInternal.ts","../src/utils/diagnostics.ts","../src/queryExecutionContext/defaultQueryExecutionContext.ts","../src/queryExecutionContext/Aggregators/AverageAggregator.ts","../src/queryExecutionContext/Aggregators/CountAggregator.ts","../src/queryExecutionContext/orderByDocumentProducerComparator.ts","../src/queryExecutionContext/Aggregators/MaxAggregator.ts","../src/queryExecutionContext/Aggregators/MinAggregator.ts","../src/queryExecutionContext/Aggregators/SumAggregator.ts","../src/queryExecutionContext/Aggregators/StaticValueAggregator.ts","../src/queryExecutionContext/Aggregators/index.ts","../src/queryExecutionContext/FetchResult.ts","../src/queryExecutionContext/documentProducer.ts","../src/routing/QueryRange.ts","../src/routing/inMemoryCollectionRoutingMap.ts","../src/routing/CollectionRoutingMapFactory.ts","../src/routing/partitionKeyRangeCache.ts","../src/routing/smartRoutingMapProvider.ts","../src/queryExecutionContext/parallelQueryExecutionContextBase.ts","../src/queryExecutionContext/parallelQueryExecutionContext.ts","../src/queryExecutionContext/orderByQueryExecutionContext.ts","../src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts","../src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts","../src/utils/digest.ts","../src/utils/hashObject.ts","../src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts","../src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts","../src/queryExecutionContext/EndpointComponent/emptyGroup.ts","../src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts","../src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts","../src/utils/nonStreamingOrderByPriorityQueue.ts","../src/utils/nonStreamingOrderByMap.ts","../src/queryExecutionContext/orderByComparator.ts","../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts","../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts","../src/queryExecutionContext/pipelinedQueryExecutionContext.ts","../src/queryIterator.ts","../src/client/Conflict/ConflictResponse.ts","../src/client/ClientUtils.ts","../src/client/Conflict/Conflict.ts","../src/client/Conflict/Conflicts.ts","../src/client/Conflict/ConflictResolutionMode.ts","../src/client/Item/ItemResponse.ts","../src/client/Item/Item.ts","../src/ChangeFeedResponse.ts","../src/ChangeFeedIterator.ts","../src/utils/hashing/encoding/prefix.ts","../src/utils/hashing/encoding/number.ts","../src/utils/hashing/murmurHash.ts","../src/utils/hashing/v2.ts","../src/utils/hashing/multiHash.ts","../src/utils/hashing/encoding/string.ts","../src/utils/hashing/v1.ts","../src/utils/hashing/hash.ts","../src/client/ChangeFeed/ChangeFeedRange.ts","../src/client/ChangeFeed/ChangeFeedIteratorResponse.ts","../src/client/ChangeFeed/FeedRangeQueue.ts","../src/client/ChangeFeed/CompositeContinuationToken.ts","../src/client/ChangeFeed/ChangeFeedStartFromBeginning.ts","../src/client/ChangeFeed/ChangeFeedStartFromNow.ts","../src/client/ChangeFeed/ChangeFeedStartFromTime.ts","../src/client/ChangeFeed/FeedRange.ts","../src/client/ChangeFeed/changeFeedUtils.ts","../src/client/ChangeFeed/ChangeFeedForEpkRange.ts","../src/client/ChangeFeed/ContinuationTokenForPartitionKey.ts","../src/client/ChangeFeed/ChangeFeedForPartitionKey.ts","../src/client/ChangeFeed/ChangeFeedEnums.ts","../src/client/ChangeFeed/ChangeFeedStartFromContinuation.ts","../src/client/ChangeFeed/ChangeFeedStartFrom.ts","../src/client/ChangeFeed/changeFeedIteratorBuilder.ts","../src/client/Item/Items.ts","../src/client/StoredProcedure/StoredProcedureResponse.ts","../src/client/StoredProcedure/StoredProcedure.ts","../src/client/StoredProcedure/StoredProcedures.ts","../src/client/Trigger/TriggerResponse.ts","../src/client/Trigger/Trigger.ts","../src/client/Trigger/Triggers.ts","../src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts","../src/client/UserDefinedFunction/UserDefinedFunction.ts","../src/client/UserDefinedFunction/UserDefinedFunctions.ts","../src/client/Script/Scripts.ts","../src/client/Container/ContainerResponse.ts","../src/client/Offer/OfferResponse.ts","../src/client/Offer/Offer.ts","../src/client/Offer/Offers.ts","../src/client/Container/Container.ts","../src/utils/offers.ts","../src/client/Container/Containers.ts","../src/client/Permission/PermissionResponse.ts","../src/client/Permission/Permission.ts","../src/client/Permission/Permissions.ts","../src/client/User/UserResponse.ts","../src/client/User/User.ts","../src/client/User/Users.ts","../src/client/Database/DatabaseResponse.ts","../src/client/Database/Database.ts","../src/client/Database/Databases.ts","../src/plugins/Plugin.ts","../src/retry/defaultRetryPolicy.ts","../src/retry/endpointDiscoveryRetryPolicy.ts","../src/retry/resourceThrottleRetryPolicy.ts","../src/retry/sessionRetryPolicy.ts","../src/retry/timeoutFailoverRetryPolicy.ts","../src/retry/retryUtility.ts","../src/request/defaultAgent.ts","../src/utils/cachedClient.ts","../src/request/RequestHandler.ts","../src/utils/atob.ts","../src/session/VectorSessionToken.ts","../src/session/sessionContainer.ts","../src/utils/checkURL.ts","../src/utils/supportedQueryFeaturesBuilder.ts","../src/diagnostics/DiagnosticWriter.ts","../src/diagnostics/DiagnosticFormatter.ts","../src/ClientContext.ts","../src/common/platform.ts","../src/utils/strings.ts","../src/diagnostics/index.ts","../src/globalEndpointManager.ts","../src/CosmosClient.ts","../src/client/SasToken/SasTokenProperties.ts","../src/utils/encode.ts","../src/utils/SasToken.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport const DEFAULT_PARTITION_KEY_PATH = \"/_partitionKey\" as \"/_partitionKey\"; // eslint-disable-line @typescript-eslint/prefer-as-const\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport interface PartitionKeyRangePropertiesNames {\n // Partition Key Range Constants\n MinInclusive: \"minInclusive\";\n MaxExclusive: \"maxExclusive\";\n Id: \"id\";\n}\n\n/**\n * @hidden\n */\nexport const Constants = {\n HttpHeaders: {\n Authorization: \"authorization\",\n ETag: \"etag\",\n MethodOverride: \"X-HTTP-Method\",\n Slug: \"Slug\",\n ContentType: \"Content-Type\",\n LastModified: \"Last-Modified\",\n ContentEncoding: \"Content-Encoding\",\n CharacterSet: \"CharacterSet\",\n UserAgent: \"User-Agent\",\n IfModifiedSince: \"If-Modified-Since\",\n IfMatch: \"If-Match\",\n IfNoneMatch: \"If-None-Match\",\n ContentLength: \"Content-Length\",\n AcceptEncoding: \"Accept-Encoding\",\n KeepAlive: \"Keep-Alive\",\n CacheControl: \"Cache-Control\",\n TransferEncoding: \"Transfer-Encoding\",\n ContentLanguage: \"Content-Language\",\n ContentLocation: \"Content-Location\",\n ContentMd5: \"Content-Md5\",\n ContentRange: \"Content-Range\",\n Accept: \"Accept\",\n AcceptCharset: \"Accept-Charset\",\n AcceptLanguage: \"Accept-Language\",\n IfRange: \"If-Range\",\n IfUnmodifiedSince: \"If-Unmodified-Since\",\n MaxForwards: \"Max-Forwards\",\n ProxyAuthorization: \"Proxy-Authorization\",\n AcceptRanges: \"Accept-Ranges\",\n ProxyAuthenticate: \"Proxy-Authenticate\",\n RetryAfter: \"Retry-After\",\n SetCookie: \"Set-Cookie\",\n WwwAuthenticate: \"Www-Authenticate\",\n Origin: \"Origin\",\n Host: \"Host\",\n AccessControlAllowOrigin: \"Access-Control-Allow-Origin\",\n AccessControlAllowHeaders: \"Access-Control-Allow-Headers\",\n KeyValueEncodingFormat: \"application/x-www-form-urlencoded\",\n WrapAssertionFormat: \"wrap_assertion_format\",\n WrapAssertion: \"wrap_assertion\",\n WrapScope: \"wrap_scope\",\n SimpleToken: \"SWT\",\n HttpDate: \"date\",\n Prefer: \"Prefer\",\n Location: \"Location\",\n Referer: \"referer\",\n A_IM: \"A-IM\",\n\n // Query\n Query: \"x-ms-documentdb-query\",\n IsQuery: \"x-ms-documentdb-isquery\",\n IsQueryPlan: \"x-ms-cosmos-is-query-plan-request\",\n SupportedQueryFeatures: \"x-ms-cosmos-supported-query-features\",\n QueryVersion: \"x-ms-cosmos-query-version\",\n\n // Our custom Azure Cosmos DB headers\n Continuation: \"x-ms-continuation\",\n ContinuationToken: \"x-ms-continuation-token\",\n PageSize: \"x-ms-max-item-count\",\n ItemCount: \"x-ms-item-count\",\n\n // Request sender generated. Simply echoed by backend.\n ActivityId: \"x-ms-activity-id\",\n PreTriggerInclude: \"x-ms-documentdb-pre-trigger-include\",\n PreTriggerExclude: \"x-ms-documentdb-pre-trigger-exclude\",\n PostTriggerInclude: \"x-ms-documentdb-post-trigger-include\",\n PostTriggerExclude: \"x-ms-documentdb-post-trigger-exclude\",\n IndexingDirective: \"x-ms-indexing-directive\",\n SessionToken: \"x-ms-session-token\",\n ConsistencyLevel: \"x-ms-consistency-level\",\n XDate: \"x-ms-date\",\n CollectionPartitionInfo: \"x-ms-collection-partition-info\",\n CollectionServiceInfo: \"x-ms-collection-service-info\",\n // Deprecated, use RetryAfterInMs instead.\n RetryAfterInMilliseconds: \"x-ms-retry-after-ms\",\n RetryAfterInMs: \"x-ms-retry-after-ms\",\n IsFeedUnfiltered: \"x-ms-is-feed-unfiltered\",\n ResourceTokenExpiry: \"x-ms-documentdb-expiry-seconds\",\n EnableScanInQuery: \"x-ms-documentdb-query-enable-scan\",\n EmitVerboseTracesInQuery: \"x-ms-documentdb-query-emit-traces\",\n EnableCrossPartitionQuery: \"x-ms-documentdb-query-enablecrosspartition\",\n ParallelizeCrossPartitionQuery: \"x-ms-documentdb-query-parallelizecrosspartitionquery\",\n ResponseContinuationTokenLimitInKB: \"x-ms-documentdb-responsecontinuationtokenlimitinkb\",\n\n // QueryMetrics\n // Request header to tell backend to give you query metrics.\n PopulateQueryMetrics: \"x-ms-documentdb-populatequerymetrics\",\n // Response header that holds the serialized version of query metrics.\n QueryMetrics: \"x-ms-documentdb-query-metrics\",\n\n // IndexMetrics\n // Request header to tell backend to give you index metrics.\n PopulateIndexMetrics: \"x-ms-cosmos-populateindexmetrics\",\n // Response header that holds the serialized version of index metrics.\n IndexUtilization: \"x-ms-cosmos-index-utilization\",\n // Version headers and values\n Version: \"x-ms-version\",\n\n // Owner name\n OwnerFullName: \"x-ms-alt-content-path\",\n\n // Owner ID used for name based request in session token.\n OwnerId: \"x-ms-content-path\",\n\n // Partition Key\n PartitionKey: \"x-ms-documentdb-partitionkey\",\n PartitionKeyRangeID: \"x-ms-documentdb-partitionkeyrangeid\",\n\n // Epk Range headers\n StartEpk: \"x-ms-start-epk\",\n EndEpk: \"x-ms-end-epk\",\n\n // Read Feed Type\n ReadFeedKeyType: \"x-ms-read-key-type\",\n\n // Quota Info\n MaxEntityCount: \"x-ms-root-entity-max-count\",\n CurrentEntityCount: \"x-ms-root-entity-current-count\",\n CollectionQuotaInMb: \"x-ms-collection-quota-mb\",\n CollectionCurrentUsageInMb: \"x-ms-collection-usage-mb\",\n MaxMediaStorageUsageInMB: \"x-ms-max-media-storage-usage-mb\",\n CurrentMediaStorageUsageInMB: \"x-ms-media-storage-usage-mb\",\n RequestCharge: \"x-ms-request-charge\",\n PopulateQuotaInfo: \"x-ms-documentdb-populatequotainfo\",\n MaxResourceQuota: \"x-ms-resource-quota\",\n\n // Offer header\n OfferType: \"x-ms-offer-type\",\n OfferThroughput: \"x-ms-offer-throughput\",\n AutoscaleSettings: \"x-ms-cosmos-offer-autopilot-settings\",\n\n // Custom RUs/minute headers\n DisableRUPerMinuteUsage: \"x-ms-documentdb-disable-ru-per-minute-usage\",\n IsRUPerMinuteUsed: \"x-ms-documentdb-is-ru-per-minute-used\",\n OfferIsRUPerMinuteThroughputEnabled: \"x-ms-offer-is-ru-per-minute-throughput-enabled\",\n\n // Index progress headers\n IndexTransformationProgress: \"x-ms-documentdb-collection-index-transformation-progress\",\n LazyIndexingProgress: \"x-ms-documentdb-collection-lazy-indexing-progress\",\n\n // Upsert header\n IsUpsert: \"x-ms-documentdb-is-upsert\",\n\n // Sub status of the error\n SubStatus: \"x-ms-substatus\",\n\n // StoredProcedure related headers\n EnableScriptLogging: \"x-ms-documentdb-script-enable-logging\",\n ScriptLogResults: \"x-ms-documentdb-script-log-results\",\n\n // Multi-Region Write\n ALLOW_MULTIPLE_WRITES: \"x-ms-cosmos-allow-tentative-writes\",\n\n // Bulk/Batch header\n IsBatchRequest: \"x-ms-cosmos-is-batch-request\",\n IsBatchAtomic: \"x-ms-cosmos-batch-atomic\",\n BatchContinueOnError: \"x-ms-cosmos-batch-continue-on-error\",\n\n // Dedicated Gateway Headers\n DedicatedGatewayPerRequestCacheStaleness: \"x-ms-dedicatedgateway-max-age\",\n\n // Cache Refresh header\n ForceRefresh: \"x-ms-force-refresh\",\n\n // Priority Based throttling header\n PriorityLevel: \"x-ms-cosmos-priority-level\",\n },\n\n // GlobalDB related constants\n WritableLocations: \"writableLocations\",\n ReadableLocations: \"readableLocations\",\n LocationUnavailableExpirationTimeInMs: 5 * 60 * 1000, // 5 minutes\n\n // ServiceDocument Resource\n ENABLE_MULTIPLE_WRITABLE_LOCATIONS: \"enableMultipleWriteLocations\",\n\n // Background refresh time\n DefaultUnavailableLocationExpirationTimeMS: 5 * 60 * 1000,\n\n // Client generated retry count response header\n ThrottleRetryCount: \"x-ms-throttle-retry-count\",\n ThrottleRetryWaitTimeInMs: \"x-ms-throttle-retry-wait-time-ms\",\n\n // Platform\n CurrentVersion: \"2020-07-15\",\n AzureNamespace: \"Azure.Cosmos\",\n AzurePackageName: \"@azure/cosmos\",\n SDKName: \"azure-cosmos-js\",\n SDKVersion: \"4.0.1-beta.3\",\n\n // Diagnostics\n CosmosDbDiagnosticLevelEnvVarName: \"AZURE_COSMOSDB_DIAGNOSTICS_LEVEL\",\n\n // Bulk Operations\n DefaultMaxBulkRequestBodySizeInBytes: 220201,\n\n Quota: {\n CollectionSize: \"collectionSize\",\n },\n\n Path: {\n Root: \"/\",\n DatabasesPathSegment: \"dbs\",\n CollectionsPathSegment: \"colls\",\n UsersPathSegment: \"users\",\n DocumentsPathSegment: \"docs\",\n PermissionsPathSegment: \"permissions\",\n StoredProceduresPathSegment: \"sprocs\",\n TriggersPathSegment: \"triggers\",\n UserDefinedFunctionsPathSegment: \"udfs\",\n ConflictsPathSegment: \"conflicts\",\n AttachmentsPathSegment: \"attachments\",\n PartitionKeyRangesPathSegment: \"pkranges\",\n SchemasPathSegment: \"schemas\",\n OffersPathSegment: \"offers\",\n TopologyPathSegment: \"topology\",\n DatabaseAccountPathSegment: \"databaseaccount\",\n },\n\n PartitionKeyRange: {\n // Partition Key Range Constants\n MinInclusive: \"minInclusive\",\n MaxExclusive: \"maxExclusive\",\n Id: \"id\",\n } as PartitionKeyRangePropertiesNames,\n\n QueryRangeConstants: {\n // Partition Key Range Constants\n MinInclusive: \"minInclusive\",\n MaxExclusive: \"maxExclusive\",\n min: \"min\",\n },\n\n /**\n * @deprecated Use EffectivePartitionKeyConstants instead\n */\n EffectiveParitionKeyConstants: {\n MinimumInclusiveEffectivePartitionKey: \"\",\n MaximumExclusiveEffectivePartitionKey: \"FF\",\n },\n\n EffectivePartitionKeyConstants: {\n MinimumInclusiveEffectivePartitionKey: \"\",\n MaximumExclusiveEffectivePartitionKey: \"FF\",\n },\n\n // NonStreaming queries\n NonStreamingQueryDefaultRUThreshold: 5000,\n};\n\n/**\n * @hidden\n */\nexport enum ResourceType {\n none = \"\",\n database = \"dbs\",\n offer = \"offers\",\n user = \"users\",\n permission = \"permissions\",\n container = \"colls\",\n conflicts = \"conflicts\",\n sproc = \"sprocs\",\n udf = \"udfs\",\n trigger = \"triggers\",\n item = \"docs\",\n pkranges = \"pkranges\",\n partitionkey = \"partitionKey\",\n}\n\n/**\n * @hidden\n */\nexport enum HTTPMethod {\n get = \"GET\",\n patch = \"PATCH\",\n post = \"POST\",\n put = \"PUT\",\n delete = \"DELETE\",\n}\n\n/**\n * @hidden\n */\nexport enum OperationType {\n Create = \"create\",\n Replace = \"replace\",\n Upsert = \"upsert\",\n Delete = \"delete\",\n Read = \"read\",\n Query = \"query\",\n Execute = \"execute\",\n Batch = \"batch\",\n Patch = \"patch\",\n}\n\n/**\n * @hidden\n */\nexport enum CosmosKeyType {\n PrimaryMaster = \"PRIMARY_MASTER\",\n SecondaryMaster = \"SECONDARY_MASTER\",\n PrimaryReadOnly = \"PRIMARY_READONLY\",\n SecondaryReadOnly = \"SECONDARY_READONLY\",\n}\n\n/**\n * @hidden\n */\nexport enum CosmosContainerChildResourceKind {\n Item = \"ITEM\",\n StoredProcedure = \"STORED_PROCEDURE\",\n UserDefinedFunction = \"USER_DEFINED_FUNCTION\",\n Trigger = \"TRIGGER\",\n}\n/**\n * @hidden\n */\nexport enum PermissionScopeValues {\n /**\n * Values which set permission Scope applicable to control plane related operations.\n */\n ScopeAccountReadValue = 0x0001,\n ScopeAccountListDatabasesValue = 0x0002,\n ScopeDatabaseReadValue = 0x0004,\n ScopeDatabaseReadOfferValue = 0x0008,\n ScopeDatabaseListContainerValue = 0x0010,\n ScopeContainerReadValue = 0x0020,\n ScopeContainerReadOfferValue = 0x0040,\n\n ScopeAccountCreateDatabasesValue = 0x0001,\n ScopeAccountDeleteDatabasesValue = 0x0002,\n ScopeDatabaseDeleteValue = 0x0004,\n ScopeDatabaseReplaceOfferValue = 0x0008,\n ScopeDatabaseCreateContainerValue = 0x0010,\n ScopeDatabaseDeleteContainerValue = 0x0020,\n ScopeContainerReplaceValue = 0x0040,\n ScopeContainerDeleteValue = 0x0080,\n ScopeContainerReplaceOfferValue = 0x0100,\n\n ScopeAccountReadAllAccessValue = 0xffff,\n ScopeDatabaseReadAllAccessValue = PermissionScopeValues.ScopeDatabaseReadValue |\n PermissionScopeValues.ScopeDatabaseReadOfferValue |\n PermissionScopeValues.ScopeDatabaseListContainerValue |\n PermissionScopeValues.ScopeContainerReadValue |\n PermissionScopeValues.ScopeContainerReadOfferValue,\n\n ScopeContainersReadAllAccessValue = PermissionScopeValues.ScopeContainerReadValue |\n PermissionScopeValues.ScopeContainerReadOfferValue,\n\n ScopeAccountWriteAllAccessValue = 0xffff,\n ScopeDatabaseWriteAllAccessValue = PermissionScopeValues.ScopeDatabaseDeleteValue |\n PermissionScopeValues.ScopeDatabaseReplaceOfferValue |\n PermissionScopeValues.ScopeDatabaseCreateContainerValue |\n PermissionScopeValues.ScopeDatabaseDeleteContainerValue |\n PermissionScopeValues.ScopeContainerReplaceValue |\n PermissionScopeValues.ScopeContainerDeleteValue |\n PermissionScopeValues.ScopeContainerReplaceOfferValue,\n\n ScopeContainersWriteAllAccessValue = PermissionScopeValues.ScopeContainerReplaceValue |\n PermissionScopeValues.ScopeContainerDeleteValue |\n PermissionScopeValues.ScopeContainerReplaceOfferValue,\n\n /**\n * Values which set permission Scope applicable to data plane related operations.\n */\n ScopeContainerExecuteQueriesValue = 0x00000001,\n ScopeContainerReadFeedsValue = 0x00000002,\n ScopeContainerReadStoredProceduresValue = 0x00000004,\n ScopeContainerReadUserDefinedFunctionsValue = 0x00000008,\n ScopeContainerReadTriggersValue = 0x00000010,\n ScopeContainerReadConflictsValue = 0x00000020,\n ScopeItemReadValue = 0x00000040,\n ScopeStoredProcedureReadValue = 0x00000080,\n ScopeUserDefinedFunctionReadValue = 0x00000100,\n ScopeTriggerReadValue = 0x00000200,\n\n ScopeContainerCreateItemsValue = 0x00000001,\n ScopeContainerReplaceItemsValue = 0x00000002,\n ScopeContainerUpsertItemsValue = 0x00000004,\n ScopeContainerDeleteItemsValue = 0x00000008,\n ScopeContainerCreateStoredProceduresValue = 0x00000010,\n ScopeContainerReplaceStoredProceduresValue = 0x00000020,\n ScopeContainerDeleteStoredProceduresValue = 0x00000040,\n ScopeContainerExecuteStoredProceduresValue = 0x00000080,\n ScopeContainerCreateTriggersValue = 0x00000100,\n ScopeContainerReplaceTriggersValue = 0x00000200,\n ScopeContainerDeleteTriggersValue = 0x00000400,\n ScopeContainerCreateUserDefinedFunctionsValue = 0x00000800,\n ScopeContainerReplaceUserDefinedFunctionsValue = 0x00001000,\n ScopeContainerDeleteUserDefinedFunctionSValue = 0x00002000,\n ScopeContainerDeleteCONFLICTSValue = 0x00004000,\n ScopeItemReplaceValue = 0x00010000,\n ScopeItemUpsertValue = 0x00020000,\n ScopeItemDeleteValue = 0x00040000,\n ScopeStoredProcedureReplaceValue = 0x00100000,\n ScopeStoredProcedureDeleteValue = 0x00200000,\n ScopeStoredProcedureExecuteValue = 0x00400000,\n ScopeUserDefinedFunctionReplaceValue = 0x00800000,\n ScopeUserDefinedFunctionDeleteValue = 0x01000000,\n ScopeTriggerReplaceValue = 0x02000000,\n ScopeTriggerDeleteValue = 0x04000000,\n\n ScopeContainerReadAllAccessValue = 0xffffffff,\n ScopeItemReadAllAccessValue = PermissionScopeValues.ScopeContainerExecuteQueriesValue |\n PermissionScopeValues.ScopeItemReadValue,\n ScopeContainerWriteAllAccessValue = 0xffffffff,\n ScopeItemWriteAllAccessValue = PermissionScopeValues.ScopeContainerCreateItemsValue |\n PermissionScopeValues.ScopeContainerReplaceItemsValue |\n PermissionScopeValues.ScopeContainerUpsertItemsValue |\n PermissionScopeValues.ScopeContainerDeleteItemsValue |\n PermissionScopeValues.ScopeItemReplaceValue |\n PermissionScopeValues.ScopeItemUpsertValue |\n PermissionScopeValues.ScopeItemDeleteValue,\n\n NoneValue = 0,\n}\n/**\n * @hidden\n */\nexport enum SasTokenPermissionKind {\n ContainerCreateItems = PermissionScopeValues.ScopeContainerCreateItemsValue,\n ContainerReplaceItems = PermissionScopeValues.ScopeContainerReplaceItemsValue,\n ContainerUpsertItems = PermissionScopeValues.ScopeContainerUpsertItemsValue,\n ContainerDeleteItems = PermissionScopeValues.ScopeContainerDeleteValue,\n ContainerExecuteQueries = PermissionScopeValues.ScopeContainerExecuteQueriesValue,\n ContainerReadFeeds = PermissionScopeValues.ScopeContainerReadFeedsValue,\n ContainerCreateStoreProcedure = PermissionScopeValues.ScopeContainerCreateStoredProceduresValue,\n ContainerReadStoreProcedure = PermissionScopeValues.ScopeContainerReadStoredProceduresValue,\n ContainerReplaceStoreProcedure = PermissionScopeValues.ScopeContainerReplaceStoredProceduresValue,\n ContainerDeleteStoreProcedure = PermissionScopeValues.ScopeContainerDeleteStoredProceduresValue,\n ContainerCreateTriggers = PermissionScopeValues.ScopeContainerCreateTriggersValue,\n ContainerReadTriggers = PermissionScopeValues.ScopeContainerReadTriggersValue,\n ContainerReplaceTriggers = PermissionScopeValues.ScopeContainerReplaceTriggersValue,\n ContainerDeleteTriggers = PermissionScopeValues.ScopeContainerDeleteTriggersValue,\n ContainerCreateUserDefinedFunctions = PermissionScopeValues.ScopeContainerCreateUserDefinedFunctionsValue,\n ContainerReadUserDefinedFunctions = PermissionScopeValues.ScopeContainerReadUserDefinedFunctionsValue,\n ContainerReplaceUserDefinedFunctions = PermissionScopeValues.ScopeContainerReplaceUserDefinedFunctionsValue,\n ContainerDeleteUserDefinedFunctions = PermissionScopeValues.ScopeContainerDeleteUserDefinedFunctionSValue,\n ContainerExecuteStoredProcedure = PermissionScopeValues.ScopeContainerExecuteStoredProceduresValue,\n ContainerReadConflicts = PermissionScopeValues.ScopeContainerReadConflictsValue,\n ContainerDeleteConflicts = PermissionScopeValues.ScopeContainerDeleteCONFLICTSValue,\n ContainerReadAny = PermissionScopeValues.ScopeContainerReadOfferValue,\n ContainerFullAccess = PermissionScopeValues.ScopeContainerReadAllAccessValue,\n ItemReadAny = PermissionScopeValues.ScopeItemReplaceValue,\n ItemFullAccess = PermissionScopeValues.ScopeItemReadAllAccessValue,\n ItemRead = PermissionScopeValues.ScopeItemReadValue,\n ItemReplace = PermissionScopeValues.ScopeItemReplaceValue,\n ItemUpsert = PermissionScopeValues.ScopeItemUpsertValue,\n ItemDelete = PermissionScopeValues.ScopeItemDeleteValue,\n StoreProcedureRead = PermissionScopeValues.ScopeStoredProcedureReadValue,\n StoreProcedureReplace = PermissionScopeValues.ScopeStoredProcedureReplaceValue,\n StoreProcedureDelete = PermissionScopeValues.ScopeStoredProcedureDeleteValue,\n StoreProcedureExecute = PermissionScopeValues.ScopeStoredProcedureExecuteValue,\n UserDefinedFuntionRead = PermissionScopeValues.ScopeUserDefinedFunctionReadValue,\n UserDefinedFuntionReplace = PermissionScopeValues.ScopeUserDefinedFunctionReplaceValue,\n UserDefinedFuntionDelete = PermissionScopeValues.ScopeUserDefinedFunctionDeleteValue,\n TriggerRead = PermissionScopeValues.ScopeTriggerReadValue,\n TriggerReplace = PermissionScopeValues.ScopeTriggerReplaceValue,\n TriggerDelete = PermissionScopeValues.ScopeTriggerDeleteValue,\n}\n\nexport enum QueryFeature {\n NonValueAggregate = \"NonValueAggregate\",\n Aggregate = \"Aggregate\",\n Distinct = \"Distinct\",\n MultipleOrderBy = \"MultipleOrderBy\",\n OffsetAndLimit = \"OffsetAndLimit\",\n OrderBy = \"OrderBy\",\n Top = \"Top\",\n CompositeAggregate = \"CompositeAggregate\",\n GroupBy = \"GroupBy\",\n MultipleAggregates = \"MultipleAggregates\",\n NonStreamingOrderBy = \"NonStreamingOrderBy\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosClientOptions } from \"../CosmosClientOptions\";\nimport { OperationType, ResourceType } from \"./constants\";\n\nconst trimLeftSlashes = new RegExp(\"^[/]+\");\nconst trimRightSlashes = new RegExp(\"[/]+$\");\nconst illegalResourceIdCharacters = new RegExp(\"[/\\\\\\\\?#]\");\nconst illegalItemResourceIdCharacters = new RegExp(\"[/\\\\\\\\#]\");\n\n/** @hidden */\nexport function jsonStringifyAndEscapeNonASCII(arg: unknown): string {\n // TODO: better way for this? Not sure.\n // escapes non-ASCII characters as \\uXXXX\n return JSON.stringify(arg).replace(/[\\u007F-\\uFFFF]/g, (m) => {\n return \"\\\\u\" + (\"0000\" + m.charCodeAt(0).toString(16)).slice(-4);\n });\n}\n\n/**\n * @hidden\n */\nexport function parseLink(resourcePath: string): {\n type: ResourceType;\n objectBody: {\n id: string;\n self: string;\n };\n} {\n if (resourcePath.length === 0) {\n /* for DatabaseAccount case, both type and objectBody will be undefined. */\n return {\n type: undefined,\n objectBody: undefined,\n };\n }\n\n if (resourcePath[resourcePath.length - 1] !== \"/\") {\n resourcePath = resourcePath + \"/\";\n }\n\n if (resourcePath[0] !== \"/\") {\n resourcePath = \"/\" + resourcePath;\n }\n\n /*\n The path will be in the form of /[resourceType]/[resourceId]/ ....\n /[resourceType]//[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/\n or /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId]/[resourceType]/[resourceId]/ ....\n /[resourceType]/[resourceId]/\n The result of split will be in the form of\n [[[resourceType], [resourceId] ... ,[resourceType], [resourceId], \"\"]\n In the first case, to extract the resourceId it will the element before last ( at length -2 )\n and the type will be before it ( at length -3 )\n In the second case, to extract the resource type it will the element before last ( at length -2 )\n */\n const pathParts = resourcePath.split(\"/\");\n let id;\n let type: ResourceType;\n if (pathParts.length % 2 === 0) {\n // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/[resourceId].\n id = pathParts[pathParts.length - 2];\n type = pathParts[pathParts.length - 3] as ResourceType;\n } else {\n // request in form /[resourceType]/[resourceId]/ .... /[resourceType]/.\n id = pathParts[pathParts.length - 3];\n type = pathParts[pathParts.length - 2] as ResourceType;\n }\n\n const result = {\n type,\n objectBody: {\n id,\n self: resourcePath,\n },\n };\n\n return result;\n}\n\n/**\n * @hidden\n */\nexport function isReadRequest(operationType: OperationType): boolean {\n return operationType === OperationType.Read || operationType === OperationType.Query;\n}\n\n/**\n * @hidden\n */\nexport function sleep(time: number): Promise {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve();\n }, time);\n });\n}\n\n/**\n * @hidden\n */\nexport function getContainerLink(link: string): string {\n return link.split(\"/\").slice(0, 4).join(\"/\");\n}\n\n/**\n * @hidden\n */\nexport function prepareURL(endpoint: string, path: string): string {\n return trimSlashes(endpoint) + path;\n}\n\n/**\n * @hidden\n */\nexport function trimSlashes(source: string): string {\n return source.replace(trimLeftSlashes, \"\").replace(trimRightSlashes, \"\");\n}\n\n/**\n * @hidden\n */\nexport function getHexaDigit(): string {\n return Math.floor(Math.random() * 16).toString(16);\n}\n\n/**\n * @hidden\n */\nexport function parsePath(path: string): string[] {\n const pathParts = [];\n let currentIndex = 0;\n\n const throwError = (): never => {\n throw new Error(\"Path \" + path + \" is invalid at index \" + currentIndex);\n };\n\n const getEscapedToken = (): string => {\n const quote = path[currentIndex];\n let newIndex = ++currentIndex;\n\n for (;;) {\n newIndex = path.indexOf(quote, newIndex);\n if (newIndex === -1) {\n throwError();\n }\n\n if (path[newIndex - 1] !== \"\\\\\") {\n break;\n }\n\n ++newIndex;\n }\n\n const token = path.substr(currentIndex, newIndex - currentIndex);\n currentIndex = newIndex + 1;\n return token;\n };\n\n const getToken = (): string => {\n const newIndex = path.indexOf(\"/\", currentIndex);\n let token = null;\n if (newIndex === -1) {\n token = path.substr(currentIndex);\n currentIndex = path.length;\n } else {\n token = path.substr(currentIndex, newIndex - currentIndex);\n currentIndex = newIndex;\n }\n\n token = token.trim();\n return token;\n };\n\n while (currentIndex < path.length) {\n if (path[currentIndex] !== \"/\") {\n throwError();\n }\n\n if (++currentIndex === path.length) {\n break;\n }\n\n if (path[currentIndex] === '\"' || path[currentIndex] === \"'\") {\n pathParts.push(getEscapedToken());\n } else {\n pathParts.push(getToken());\n }\n }\n\n return pathParts;\n}\n\n/**\n * @hidden\n */\nexport function isResourceValid(resource: { id?: string }, err: { message?: string }): boolean {\n // TODO: fix strictness issues so that caller contexts respects the types of the functions\n if (resource.id) {\n if (typeof resource.id !== \"string\") {\n err.message = \"Id must be a string.\";\n return false;\n }\n\n if (\n resource.id.indexOf(\"/\") !== -1 ||\n resource.id.indexOf(\"\\\\\") !== -1 ||\n resource.id.indexOf(\"?\") !== -1 ||\n resource.id.indexOf(\"#\") !== -1\n ) {\n err.message = \"Id contains illegal chars.\";\n return false;\n }\n\n if (resource.id[resource.id.length - 1] === \" \") {\n err.message = \"Id ends with a space.\";\n return false;\n }\n }\n return true;\n}\n\n/**\n * @hidden\n */\nexport function isItemResourceValid(resource: { id?: string }, err: { message?: string }): boolean {\n // TODO: fix strictness issues so that caller contexts respects the types of the functions\n if (resource.id) {\n if (typeof resource.id !== \"string\") {\n err.message = \"Id must be a string.\";\n return false;\n }\n\n if (\n resource.id.indexOf(\"/\") !== -1 ||\n resource.id.indexOf(\"\\\\\") !== -1 ||\n resource.id.indexOf(\"#\") !== -1\n ) {\n err.message = \"Id contains illegal chars.\";\n return false;\n }\n }\n return true;\n}\n\n/** @hidden */\nexport function getIdFromLink(resourceLink: string): string {\n resourceLink = trimSlashes(resourceLink);\n return resourceLink;\n}\n\n/** @hidden */\nexport function getPathFromLink(resourceLink: string, resourceType?: string): string {\n resourceLink = trimSlashes(resourceLink);\n if (resourceType) {\n return \"/\" + encodeURI(resourceLink) + \"/\" + resourceType;\n } else {\n return \"/\" + encodeURI(resourceLink);\n }\n}\n\n/**\n * @hidden\n */\nexport function isStringNullOrEmpty(inputString: string): boolean {\n // checks whether string is null, undefined, empty or only contains space\n return !inputString || /^\\s*$/.test(inputString);\n}\n\n/**\n * @hidden\n */\nexport function trimSlashFromLeftAndRight(inputString: string): string {\n if (typeof inputString !== \"string\") {\n throw new Error(\"invalid input: input is not string\");\n }\n\n return inputString.replace(trimLeftSlashes, \"\").replace(trimRightSlashes, \"\");\n}\n\n/**\n * @hidden\n */\nexport function validateResourceId(resourceId: string): boolean {\n // if resourceId is not a string or is empty throw an error\n if (typeof resourceId !== \"string\" || isStringNullOrEmpty(resourceId)) {\n throw new Error(\"Resource ID must be a string and cannot be undefined, null or empty\");\n }\n\n // if resource id contains illegal characters throw an error\n if (illegalResourceIdCharacters.test(resourceId)) {\n throw new Error(\"Illegal characters ['/', '\\\\', '#', '?'] cannot be used in Resource ID\");\n }\n\n return true;\n}\n\n/**\n * @hidden\n */\nexport function validateItemResourceId(resourceId: string): boolean {\n // if resourceId is not a string or is empty throw an error\n if (typeof resourceId !== \"string\" || isStringNullOrEmpty(resourceId)) {\n throw new Error(\"Resource ID must be a string and cannot be undefined, null or empty\");\n }\n\n // if resource id contains illegal characters throw an error\n if (illegalItemResourceIdCharacters.test(resourceId)) {\n throw new Error(\"Illegal characters ['/', '\\\\', '#'] cannot be used in Resource ID\");\n }\n\n return true;\n}\n\n/**\n * @hidden\n */\nexport function getResourceIdFromPath(resourcePath: string): string {\n if (!resourcePath || typeof resourcePath !== \"string\") {\n return null;\n }\n\n const trimmedPath = trimSlashFromLeftAndRight(resourcePath);\n const pathSegments = trimmedPath.split(\"/\");\n\n // number of segments of a path must always be even\n if (pathSegments.length % 2 !== 0) {\n return null;\n }\n\n return pathSegments[pathSegments.length - 1];\n}\n\n/**\n * @hidden\n */\ninterface ConnectionObject {\n AccountEndpoint: string;\n AccountKey: string;\n}\n\n/**\n * @hidden\n */\nexport function parseConnectionString(connectionString: string): CosmosClientOptions {\n const keyValueStrings = connectionString.split(\";\");\n const { AccountEndpoint, AccountKey } = keyValueStrings.reduce(\n (connectionObject, keyValueString: string) => {\n const [key, ...value] = keyValueString.split(\"=\");\n (connectionObject as any)[key] = value.join(\"=\");\n return connectionObject;\n },\n {} as ConnectionObject,\n );\n if (!AccountEndpoint || !AccountKey) {\n throw new Error(\"Could not parse the provided connection string\");\n }\n return {\n endpoint: AccountEndpoint,\n key: AccountKey,\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @hidden\n */\nexport interface StatusCodesType {\n // Success\n Ok: 200;\n Created: 201;\n Accepted: 202;\n NoContent: 204;\n NotModified: 304;\n\n // Client error\n BadRequest: 400;\n Unauthorized: 401;\n Forbidden: 403;\n NotFound: 404;\n MethodNotAllowed: 405;\n RequestTimeout: 408;\n Conflict: 409;\n Gone: 410;\n PreconditionFailed: 412;\n RequestEntityTooLarge: 413;\n TooManyRequests: 429;\n RetryWith: 449;\n\n // Server Error\n InternalServerError: 500;\n ServiceUnavailable: 503;\n\n // System codes\n ENOTFOUND: \"ENOTFOUND\";\n\n // Operation pause and cancel. These are FAKE status codes for QOS logging purpose only.\n OperationPaused: 1200;\n OperationCancelled: 1201;\n}\n\n/**\n * @hidden\n */\nexport const StatusCodes: StatusCodesType = {\n // Success\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NoContent: 204,\n NotModified: 304,\n\n // Client error\n BadRequest: 400,\n Unauthorized: 401,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n PreconditionFailed: 412,\n RequestEntityTooLarge: 413,\n TooManyRequests: 429,\n RetryWith: 449,\n\n // Server Error\n InternalServerError: 500,\n ServiceUnavailable: 503,\n\n // System codes\n ENOTFOUND: \"ENOTFOUND\",\n\n // Operation pause and cancel. These are FAKE status codes for QOS logging purpose only.\n OperationPaused: 1200,\n OperationCancelled: 1201,\n};\n\n/**\n * @hidden\n */\nexport interface SubStatusCodesType {\n Unknown: 0;\n\n // 400: Bad Request Substatus\n CrossPartitionQueryNotServable: 1004;\n\n // 410: StatusCodeType_Gone: substatus\n PartitionKeyRangeGone: 1002;\n CompletingSplit: 1007;\n\n // 404: NotFound Substatus\n ReadSessionNotAvailable: 1002;\n\n // 403: Forbidden Substatus\n WriteForbidden: 3;\n DatabaseAccountNotFound: 1008;\n}\n\n/**\n * @hidden\n */\nexport const SubStatusCodes: SubStatusCodesType = {\n Unknown: 0,\n\n // 400: Bad Request Substatus\n CrossPartitionQueryNotServable: 1004,\n\n // 410: StatusCodeType_Gone: substatus\n PartitionKeyRangeGone: 1002,\n CompletingSplit: 1007,\n // 404: NotFound Substatus\n ReadSessionNotAvailable: 1002,\n\n // 403: Forbidden Substatus\n WriteForbidden: 3,\n DatabaseAccountNotFound: 1008,\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"./constants\";\nimport { trimSlashFromLeftAndRight, validateResourceId, validateItemResourceId } from \"./helper\";\n\n/**\n * Would be used when creating or deleting a DocumentCollection\n * or a User in Azure Cosmos DB database service\n * @hidden\n * Given a database id, this creates a database link.\n * @param databaseId - The database id\n * @returns A database link in the format of `dbs/{0}`\n * with `{0}` being a Uri escaped version of the databaseId\n */\nexport function createDatabaseUri(databaseId: string): string {\n databaseId = trimSlashFromLeftAndRight(databaseId);\n validateResourceId(databaseId);\n\n return Constants.Path.DatabasesPathSegment + \"/\" + databaseId;\n}\n\n/**\n * Given a database and collection id, this creates a collection link.\n * Would be used when updating or deleting a DocumentCollection, creating a\n * Document, a StoredProcedure, a Trigger, a UserDefinedFunction, or when executing a query\n * with CreateDocumentQuery in Azure Cosmos DB database service.\n * @param databaseId - The database id\n * @param collectionId - The collection id\n * @returns A collection link in the format of `dbs/{0}/colls/{1}`\n * with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId\n * @hidden\n */\nexport function createDocumentCollectionUri(databaseId: string, collectionId: string): string {\n collectionId = trimSlashFromLeftAndRight(collectionId);\n validateResourceId(collectionId);\n\n return (\n createDatabaseUri(databaseId) + \"/\" + Constants.Path.CollectionsPathSegment + \"/\" + collectionId\n );\n}\n\n/**\n * Given a database and user id, this creates a user link.\n * Would be used when creating a Permission, or when replacing or deleting\n * a User in Azure Cosmos DB database service\n * @param databaseId - The database id\n * @param userId - The user id\n * @returns A user link in the format of `dbs/{0}/users/{1}`\n * with `{0}` being a Uri escaped version of the databaseId and `{1}` being userId\n * @hidden\n */\nexport function createUserUri(databaseId: string, userId: string): string {\n userId = trimSlashFromLeftAndRight(userId);\n validateResourceId(userId);\n\n return createDatabaseUri(databaseId) + \"/\" + Constants.Path.UsersPathSegment + \"/\" + userId;\n}\n\n/**\n * Given a database and collection id, this creates a collection link.\n * Would be used when creating an Attachment, or when replacing\n * or deleting a Document in Azure Cosmos DB database service\n * @param databaseId - The database id\n * @param collectionId - The collection id\n * @param documentId - The document id\n * @returns A document link in the format of\n * `dbs/{0}/colls/{1}/docs/{2}` with `{0}` being a Uri escaped version of\n * the databaseId, `{1}` being collectionId and `{2}` being the documentId\n * @hidden\n */\nexport function createDocumentUri(\n databaseId: string,\n collectionId: string,\n documentId: string,\n): string {\n documentId = trimSlashFromLeftAndRight(documentId);\n validateItemResourceId(documentId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.DocumentsPathSegment +\n \"/\" +\n documentId\n );\n}\n\n/**\n * Given a database, collection and document id, this creates a document link.\n * Would be used when replacing or deleting a Permission in Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param userId -The user Id\n * @param permissionId - The permissionId\n * @returns A permission link in the format of `dbs/{0}/users/{1}/permissions/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being userId and `{2}` being permissionId\n * @hidden\n */\nexport function createPermissionUri(\n databaseId: string,\n userId: string,\n permissionId: string,\n): string {\n permissionId = trimSlashFromLeftAndRight(permissionId);\n validateResourceId(permissionId);\n\n return (\n createUserUri(databaseId, userId) +\n \"/\" +\n Constants.Path.PermissionsPathSegment +\n \"/\" +\n permissionId\n );\n}\n\n/**\n * Given a database, collection and stored proc id, this creates a stored proc link.\n * Would be used when replacing, executing, or deleting a StoredProcedure in\n * Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param storedProcedureId -The stored procedure Id\n * @returns A stored procedure link in the format of\n * `dbs/{0}/colls/{1}/sprocs/{2}` with `{0}` being a Uri escaped version of the databaseId,\n * `{1}` being collectionId and `{2}` being the storedProcedureId\n * @hidden\n */\nexport function createStoredProcedureUri(\n databaseId: string,\n collectionId: string,\n storedProcedureId: string,\n): string {\n storedProcedureId = trimSlashFromLeftAndRight(storedProcedureId);\n validateResourceId(storedProcedureId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.StoredProceduresPathSegment +\n \"/\" +\n storedProcedureId\n );\n}\n\n/**\n * Given a database, collection and trigger id, this creates a trigger link.\n * Would be used when replacing, executing, or deleting a Trigger in Azure Cosmos DB database service\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param triggerId -The trigger Id\n * @returns A trigger link in the format of\n * `dbs/{0}/colls/{1}/triggers/{2}` with `{0}` being a Uri escaped version of the databaseId,\n * `{1}` being collectionId and `{2}` being the triggerId\n * @hidden\n */\nexport function createTriggerUri(\n databaseId: string,\n collectionId: string,\n triggerId: string,\n): string {\n triggerId = trimSlashFromLeftAndRight(triggerId);\n validateResourceId(triggerId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.TriggersPathSegment +\n \"/\" +\n triggerId\n );\n}\n\n/**\n * Given a database, collection and udf id, this creates a udf link.\n * Would be used when replacing, executing, or deleting a UserDefinedFunction in\n * Azure Cosmos DB database service\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param udfId -The User Defined Function Id\n * @returns A udf link in the format of `dbs/{0}/colls/{1}/udfs/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the udfId\n * @hidden\n */\nexport function createUserDefinedFunctionUri(\n databaseId: string,\n collectionId: string,\n udfId: string,\n): string {\n udfId = trimSlashFromLeftAndRight(udfId);\n validateResourceId(udfId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.UserDefinedFunctionsPathSegment +\n \"/\" +\n udfId\n );\n}\n\n/**\n * Given a database, collection and conflict id, this creates a conflict link.\n * Would be used when creating a Conflict in Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param conflictId -The conflict Id\n * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId\n * @hidden\n */\nexport function createConflictUri(\n databaseId: string,\n collectionId: string,\n conflictId: string,\n): string {\n conflictId = trimSlashFromLeftAndRight(conflictId);\n validateResourceId(conflictId);\n\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.ConflictsPathSegment +\n \"/\" +\n conflictId\n );\n}\n\n/**\n * Given a database, collection and conflict id, this creates a conflict link.\n * Would be used when creating a Conflict in Azure Cosmos DB database service.\n * @param databaseId -The database Id\n * @param collectionId -The collection Id\n * @param documentId -The document Id\n * @param attachmentId -The attachment Id\n * @returns A conflict link in the format of `dbs/{0}/colls/{1}/conflicts/{2}`\n * with `{0}` being a Uri escaped version of the databaseId, `{1}` being collectionId and `{2}` being the conflictId\n * @hidden\n */\nexport function createAttachmentUri(\n databaseId: string,\n collectionId: string,\n documentId: string,\n attachmentId: string,\n): string {\n attachmentId = trimSlashFromLeftAndRight(attachmentId);\n validateResourceId(attachmentId);\n\n return (\n createDocumentUri(databaseId, collectionId, documentId) +\n \"/\" +\n Constants.Path.AttachmentsPathSegment +\n \"/\" +\n attachmentId\n );\n}\n\n/**\n * Given a database and collection, this creates a partition key ranges link in\n * the Azure Cosmos DB database service.\n * @param databaseId - The database Id\n * @param collectionId - The collection Id\n * @returns A partition key ranges link in the format of\n * `dbs/{0}/colls/{1}/pkranges` with `{0}` being a Uri escaped version of the databaseId and `{1}` being collectionId\n * @hidden\n */\nexport function createPartitionKeyRangesUri(databaseId: string, collectionId: string): string {\n return (\n createDocumentCollectionUri(databaseId, collectionId) +\n \"/\" +\n Constants.Path.PartitionKeyRangesPathSegment\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport semaphore from \"semaphore\";\n\n/**\n * @hidden\n * @hidden\n * Specifies Net RUConsumed\n */\nexport class RUConsumedManager {\n private ruConsumed: number = 0;\n private semaphore: any;\n\n constructor() {\n this.semaphore = semaphore(1);\n }\n\n getRUConsumed(): Promise {\n return new Promise((resolve) => {\n this.semaphore.take(() => {\n this.semaphore.leave();\n resolve(this.ruConsumed);\n });\n });\n }\n\n addToRUConsumed(value: number): Promise {\n return new Promise((resolve) => {\n this.semaphore.take(() => {\n this.ruConsumed += value;\n this.semaphore.leave();\n resolve();\n });\n });\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHmac } from \"crypto\";\n\nexport async function hmac(key: string, message: string): Promise {\n return createHmac(\"sha256\", Buffer.from(key, \"base64\")).update(message).digest(\"base64\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { hmac } from \"./hmac\";\nimport { HTTPMethod, ResourceType, Constants } from \"../common\";\n\nexport async function generateHeaders(\n masterKey: string,\n method: HTTPMethod,\n resourceType: ResourceType = ResourceType.none,\n resourceId: string = \"\",\n date = new Date(),\n): Promise<{\n [x: string]: string;\n}> {\n if (masterKey.startsWith(\"type=sas&\")) {\n return {\n [Constants.HttpHeaders.Authorization]: encodeURIComponent(masterKey),\n [Constants.HttpHeaders.XDate]: date.toUTCString(),\n };\n }\n const sig = await signature(masterKey, method, resourceType, resourceId, date);\n\n return {\n [Constants.HttpHeaders.Authorization]: sig,\n [Constants.HttpHeaders.XDate]: date.toUTCString(),\n };\n}\n\nasync function signature(\n masterKey: string,\n method: HTTPMethod,\n resourceType: ResourceType,\n resourceId: string = \"\",\n date = new Date(),\n): Promise {\n const type = \"master\";\n const version = \"1.0\";\n const text =\n method.toLowerCase() +\n \"\\n\" +\n resourceType.toLowerCase() +\n \"\\n\" +\n resourceId +\n \"\\n\" +\n date.toUTCString().toLowerCase() +\n \"\\n\" +\n \"\" +\n \"\\n\";\n\n const signed = await hmac(masterKey, text);\n\n return encodeURIComponent(\"type=\" + type + \"&ver=\" + version + \"&sig=\" + signed);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { generateHeaders } from \"./utils/headers\";\nimport {\n Constants,\n getResourceIdFromPath,\n HTTPMethod,\n ResourceType,\n trimSlashFromLeftAndRight,\n} from \"./common\";\nimport { CosmosClientOptions } from \"./CosmosClientOptions\";\nimport { CosmosHeaders } from \"./queryExecutionContext\";\n\n/** @hidden */\nexport interface RequestInfo {\n verb: HTTPMethod;\n path: string;\n resourceId: string;\n resourceType: ResourceType;\n headers: CosmosHeaders;\n}\n\nexport type TokenProvider = (requestInfo: RequestInfo) => Promise;\n\n/**\n * @hidden\n */\nexport async function setAuthorizationHeader(\n clientOptions: CosmosClientOptions,\n verb: HTTPMethod,\n path: string,\n resourceId: string,\n resourceType: ResourceType,\n headers: CosmosHeaders,\n): Promise {\n if (clientOptions.permissionFeed) {\n clientOptions.resourceTokens = {};\n for (const permission of clientOptions.permissionFeed) {\n const id = getResourceIdFromPath(permission.resource);\n if (!id) {\n throw new Error(`authorization error: ${id} \\\n is an invalid resourceId in permissionFeed`);\n }\n\n clientOptions.resourceTokens[id] = (permission as any)._token; // TODO: any\n }\n }\n\n if (clientOptions.key) {\n await setAuthorizationTokenHeaderUsingMasterKey(\n verb,\n resourceId,\n resourceType,\n headers,\n clientOptions.key,\n );\n } else if (clientOptions.resourceTokens) {\n headers[Constants.HttpHeaders.Authorization] = encodeURIComponent(\n getAuthorizationTokenUsingResourceTokens(clientOptions.resourceTokens, path, resourceId),\n );\n } else if (clientOptions.tokenProvider) {\n headers[Constants.HttpHeaders.Authorization] = encodeURIComponent(\n await clientOptions.tokenProvider({ verb, path, resourceId, resourceType, headers }),\n );\n }\n}\n\n/**\n * The default function for setting header token using the masterKey\n * @hidden\n */\nexport async function setAuthorizationTokenHeaderUsingMasterKey(\n verb: HTTPMethod,\n resourceId: string,\n resourceType: ResourceType,\n headers: CosmosHeaders,\n masterKey: string,\n): Promise {\n // TODO This should live in cosmos-sign\n if (resourceType === ResourceType.offer) {\n resourceId = resourceId && resourceId.toLowerCase();\n }\n headers = Object.assign(\n headers,\n await generateHeaders(masterKey, verb, resourceType, resourceId),\n );\n}\n\n/**\n * @hidden\n */\n// TODO: Resource tokens\nexport function getAuthorizationTokenUsingResourceTokens(\n resourceTokens: { [resourceId: string]: string },\n path: string,\n resourceId: string,\n): string {\n if (resourceTokens && Object.keys(resourceTokens).length > 0) {\n // For database account access(through getDatabaseAccount API), path and resourceId are \"\",\n // so in this case we return the first token to be used for creating the auth header as the\n // service will accept any token in this case\n if (!path && !resourceId) {\n return resourceTokens[Object.keys(resourceTokens)[0]];\n }\n\n // If we have exact resource token for the path use it\n if (resourceId && resourceTokens[resourceId]) {\n return resourceTokens[resourceId];\n }\n\n // minimum valid path /dbs\n if (!path || path.length < 4) {\n // TODO: This should throw an error\n return null;\n }\n\n path = trimSlashFromLeftAndRight(path);\n const pathSegments = (path && path.split(\"/\")) || [];\n\n // Item path\n if (pathSegments.length === 6) {\n // Look for a container token matching the item path\n const containerPath = pathSegments.slice(0, 4).map(decodeURIComponent).join(\"/\");\n if (resourceTokens[containerPath]) {\n return resourceTokens[containerPath];\n }\n }\n\n // TODO remove in v4: This is legacy behavior that lets someone use a resource token pointing ONLY at an ID\n // It was used when _rid was exposed by the SDK, but now that we are using user provided ids it is not needed\n // However removing it now would be a breaking change\n // if it's an incomplete path like /dbs/db1/colls/, start from the parent resource\n let index = pathSegments.length % 2 === 0 ? pathSegments.length - 1 : pathSegments.length - 2;\n for (; index > 0; index -= 2) {\n const id = decodeURI(pathSegments[index]);\n if (resourceTokens[id]) {\n return resourceTokens[id];\n }\n }\n }\n\n // TODO: This should throw an error\n return null;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */\nexport enum ConnectionMode {\n /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */\n Gateway = 0,\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { RetryOptions } from \"../retry/retryOptions\";\nimport { ConnectionMode } from \"./ConnectionMode\";\n/**\n * Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service.\n */\nexport interface ConnectionPolicy {\n /** Determines which mode to connect to Cosmos with. (Currently only supports Gateway option) */\n connectionMode?: ConnectionMode;\n /** Request timeout (time to wait for response from network peer). Represented in milliseconds. */\n requestTimeout?: number;\n /**\n * Flag to enable/disable automatic redirecting of requests based on read/write operations. Default true.\n * Required to call client.dispose() when this is set to true after destroying the CosmosClient inside another process or in the browser.\n */\n enableEndpointDiscovery?: boolean;\n /** List of azure regions to be used as preferred locations for read requests. */\n preferredLocations?: string[];\n /** RetryOptions object which defines several configurable properties used during retry. */\n retryOptions?: RetryOptions;\n /**\n * The flag that enables writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service.\n * Default is `false`.\n */\n useMultipleWriteLocations?: boolean;\n /** Rate in milliseconds at which the client will refresh the endpoints list in the background */\n endpointRefreshRateInMs?: number;\n /** Flag to enable/disable background refreshing of endpoints. Defaults to false.\n * Endpoint discovery using `enableEndpointsDiscovery` will still work for failed requests. */\n enableBackgroundEndpointRefreshing?: boolean;\n}\n\n/**\n * @hidden\n */\nexport const defaultConnectionPolicy: ConnectionPolicy = Object.freeze({\n connectionMode: ConnectionMode.Gateway,\n requestTimeout: 60000,\n enableEndpointDiscovery: true,\n preferredLocations: [],\n retryOptions: {\n maxRetryAttemptCount: 9,\n fixedRetryIntervalInMilliseconds: 0,\n maxWaitTimeInSeconds: 30,\n },\n useMultipleWriteLocations: true,\n endpointRefreshRateInMs: 300000,\n enableBackgroundEndpointRefreshing: true,\n});\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents the consistency levels supported for Azure Cosmos DB client operations.
\n * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account.\n * Consistency levels.\n *\n * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual.\n *\n * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels.\n */\nexport enum ConsistencyLevel {\n /**\n * Strong Consistency guarantees that read operations always return the value that was last written.\n */\n Strong = \"Strong\",\n /**\n * Bounded Staleness guarantees that reads are not too out-of-date.\n * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds).\n */\n BoundedStaleness = \"BoundedStaleness\",\n /**\n * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again),\n * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads)\n * within any single session.\n */\n Session = \"Session\",\n /**\n * Eventual Consistency guarantees that reads will return a subset of writes.\n * All writes will be eventually be available for reads.\n */\n Eventual = \"Eventual\",\n /**\n * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps.\n * All writes will be eventually be available for reads.\n */\n ConsistentPrefix = \"ConsistentPrefix\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common\";\nimport { CosmosHeaders } from \"../queryExecutionContext\";\nimport { ConsistencyLevel } from \"./ConsistencyLevel\";\n\n/**\n * Represents a DatabaseAccount in the Azure Cosmos DB database service.\n */\nexport class DatabaseAccount {\n /** The list of writable locations for a geo-replicated database account. */\n public readonly writableLocations: Location[] = [];\n /** The list of readable locations for a geo-replicated database account. */\n public readonly readableLocations: Location[] = [];\n /**\n * The self-link for Databases in the databaseAccount.\n * @deprecated Use `databasesLink`\n */\n public get DatabasesLink(): string {\n return this.databasesLink;\n }\n /** The self-link for Databases in the databaseAccount. */\n public readonly databasesLink: string;\n /**\n * The self-link for Media in the databaseAccount.\n * @deprecated Use `mediaLink`\n */\n public get MediaLink(): string {\n return this.mediaLink;\n }\n /** The self-link for Media in the databaseAccount. */\n public readonly mediaLink: string;\n /**\n * Attachment content (media) storage quota in MBs ( Retrieved from gateway ).\n * @deprecated use `maxMediaStorageUsageInMB`\n */\n public get MaxMediaStorageUsageInMB(): number {\n return this.maxMediaStorageUsageInMB;\n }\n /** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */\n public readonly maxMediaStorageUsageInMB: number;\n /**\n * Current attachment content (media) usage in MBs (Retrieved from gateway )\n *\n * Value is returned from cached information updated periodically and is not guaranteed\n * to be real time.\n *\n * @deprecated use `currentMediaStorageUsageInMB`\n */\n public get CurrentMediaStorageUsageInMB(): number {\n return this.currentMediaStorageUsageInMB;\n }\n /**\n * Current attachment content (media) usage in MBs (Retrieved from gateway )\n *\n * Value is returned from cached information updated periodically and is not guaranteed\n * to be real time.\n */\n public readonly currentMediaStorageUsageInMB: number;\n /**\n * Gets the UserConsistencyPolicy settings.\n * @deprecated use `consistencyPolicy`\n */\n public get ConsistencyPolicy(): ConsistencyLevel {\n return this.consistencyPolicy;\n }\n /** Gets the UserConsistencyPolicy settings. */\n public readonly consistencyPolicy: ConsistencyLevel;\n public readonly enableMultipleWritableLocations: boolean;\n\n // TODO: body - any\n public constructor(body: { [key: string]: any }, headers: CosmosHeaders) {\n this.databasesLink = \"/dbs/\";\n this.mediaLink = \"/media/\";\n this.maxMediaStorageUsageInMB = headers[Constants.HttpHeaders.MaxMediaStorageUsageInMB];\n this.currentMediaStorageUsageInMB = headers[Constants.HttpHeaders.CurrentMediaStorageUsageInMB];\n this.consistencyPolicy = body.userConsistencyPolicy\n ? (body.userConsistencyPolicy.defaultConsistencyLevel as ConsistencyLevel)\n : ConsistencyLevel.Session;\n if (body[Constants.WritableLocations] && body.id !== \"localhost\") {\n this.writableLocations = body[Constants.WritableLocations] as Location[];\n }\n if (body[Constants.ReadableLocations] && body.id !== \"localhost\") {\n this.readableLocations = body[Constants.ReadableLocations] as Location[];\n }\n if (body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS]) {\n this.enableMultipleWritableLocations =\n body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === true ||\n body[Constants.ENABLE_MULTIPLE_WRITABLE_LOCATIONS] === \"true\";\n }\n }\n}\n\n/**\n * Used to specify the locations that are available, read is index 1 and write is index 0.\n */\nexport interface Location {\n name: string;\n databaseAccountEndpoint: string;\n unavailable?: boolean;\n lastUnavailabilityTimestampInMs?: number;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** Defines a target data type of an index path specification in the Azure Cosmos DB service. */\nexport enum DataType {\n /** Represents a numeric data type. */\n Number = \"Number\",\n /** Represents a string data type. */\n String = \"String\",\n /** Represents a point data type. */\n Point = \"Point\",\n /** Represents a line string data type. */\n LineString = \"LineString\",\n /** Represents a polygon data type. */\n Polygon = \"Polygon\",\n /** Represents a multi-polygon data type. */\n MultiPolygon = \"MultiPolygon\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Specifies the supported indexing modes.\n */\nexport enum IndexingMode {\n /**\n * Index is updated synchronously with a create or update operation.\n *\n * With consistent indexing, query behavior is the same as the default consistency level for the container.\n * The index is always kept up to date with the data.\n */\n consistent = \"consistent\",\n /**\n * Index is updated asynchronously with respect to a create or update operation.\n *\n * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle.\n */\n lazy = \"lazy\",\n /** No Index is provided. */\n none = \"none\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DataType, IndexingMode, IndexKind } from \"./index\";\n\nexport interface IndexingPolicy {\n /** The indexing mode (consistent or lazy) {@link IndexingMode}. */\n indexingMode?: keyof typeof IndexingMode;\n automatic?: boolean;\n /** An array of {@link IncludedPath} represents the paths to be included for indexing. */\n includedPaths?: IndexedPath[];\n /** An array of {@link IncludedPath} represents the paths to be excluded for indexing. */\n excludedPaths?: IndexedPath[];\n spatialIndexes?: SpatialIndex[];\n /** An array of {@link VectorIndex} represents the vector index paths to be included for indexing. */\n vectorIndexes?: VectorIndex[];\n}\n\n/* The target data type of a spatial path */\nexport enum SpatialType {\n LineString = \"LineString\",\n MultiPolygon = \"MultiPolygon\",\n Point = \"Point\",\n Polygon = \"Polygon\",\n}\n\nexport interface SpatialIndex {\n /* Path in JSON document to index */\n path: string;\n types: SpatialType[];\n /* Bounding box for geometry spatial path */\n boundingBox: {\n /* X-coordinate of the lower-left corner of the bounding box. */\n xmin: number;\n /* Y-coordinate of the lower-left corner of the bounding box. */\n ymin: number;\n /* X-coordinate of the upper-right corner of the bounding box. */\n xmax: number;\n /* Y-coordinate of the upper-right corner of the bounding box. */\n ymax: number;\n };\n}\n\nexport interface IndexedPath {\n path: string;\n indexes?: Index[];\n}\n\nexport interface Index {\n kind: keyof typeof IndexKind;\n dataType: keyof typeof DataType;\n precision?: number;\n}\n/**\n * Represents a vector index in the Azure Cosmos DB service.\n * A vector index is used to index vector fields in the documents.\n */\nexport interface VectorIndex {\n /**\n * The path to the vector field in the document.\n * for example, path: \"/path/to/vector\".\n */\n path: string;\n /**\n * The index type of the vector.\n * Currently, flat, diskANN, and quantizedFlat are supported.\n */\n type: \"flat\" | \"diskANN\" | \"quantizedFlat\";\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Specifies the supported Index types.\n */\nexport enum IndexKind {\n /**\n * This is supplied for a path which requires sorting.\n */\n Range = \"Range\",\n /**\n * This is supplied for a path which requires geospatial indexing.\n */\n Spatial = \"Spatial\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NonePartitionKeyType,\n NullPartitionKeyType,\n PartitionKey,\n PrimitivePartitionKeyValue,\n} from \"./PartitionKey\";\n\n/**\n * @hidden\n * Internal Representation Of Partition Key. TODO: Make sure {@link ClientContext} working with only {@link PartitionKeyInternal}\n */\nexport type PartitionKeyInternal = PrimitivePartitionKeyValue[];\n/**\n * @hidden\n * None PartitionKey Literal\n */\nexport const NonePartitionKeyLiteral: NonePartitionKeyType = {};\n/**\n * @hidden\n * Null PartitionKey Literal\n */\nexport const NullPartitionKeyLiteral: NullPartitionKeyType = null;\n/**\n * @hidden\n * Maps PartitionKey to InternalPartitionKey.\n * @param partitionKey - PartitonKey to be converted.\n * @returns PartitionKeyInternal\n */\nexport function convertToInternalPartitionKey(partitionKey: PartitionKey): PartitionKeyInternal {\n if (Array.isArray(partitionKey)) {\n return partitionKey.map((key) => (key === undefined ? NonePartitionKeyLiteral : key));\n } else return [partitionKey];\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from \"./PartitionKeyInternal\";\n\n/**\n * PartitionKey of a container.\n * @remarks\n * - PartitionKeyDefinition is no longer part of PartitionKey. So please use PartitionKeyDefinition\n * type directly where appropriate.\n */\nexport type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[];\n\n/**\n * A primitive Partition Key value.\n */\nexport type PrimitivePartitionKeyValue =\n | string\n | number\n | boolean\n | NullPartitionKeyType\n | NonePartitionKeyType;\n\n/**\n * The returned object represents a partition key value that allows creating and accessing items\n * with a null value for the partition key.\n */\nexport type NullPartitionKeyType = null;\n\n/**\n * The returned object represents a partition key value that allows creating and accessing items\n * without a value for partition key\n */\nexport type NonePartitionKeyType = {\n [K in any]: never;\n};\n\n/**\n * Builder class for building PartitionKey.\n */\nexport class PartitionKeyBuilder {\n readonly values: PrimitivePartitionKeyValue[] = [];\n public addValue(value: string | boolean | number): PartitionKeyBuilder {\n this.values.push(value);\n return this;\n }\n public addNullValue(): PartitionKeyBuilder {\n this.values.push(NullPartitionKeyLiteral);\n return this;\n }\n public addNoneValue(): PartitionKeyBuilder {\n this.values.push(NonePartitionKeyLiteral);\n return this;\n }\n public build(): PartitionKey {\n return [...this.values];\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * PartitionKey Definition Version\n */\nexport enum PartitionKeyDefinitionVersion {\n V1 = 1,\n V2 = 2,\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Type of PartitionKey i.e. Hash, MultiHash\n */\nexport enum PartitionKeyKind {\n Hash = \"Hash\",\n MultiHash = \"MultiHash\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for permission mode values.\n */\nexport enum PermissionMode {\n /** Permission not valid. */\n None = \"none\",\n /** Permission applicable for read operations only. */\n Read = \"read\",\n /** Permission applicable for all operations. */\n All = \"all\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Represents Priority Level associated with each Azure Cosmos DB client requests.
\n * The Low priority requests are always throttled before any High priority requests.\n *\n * By default all requests are considered as High priority requests.\n *\n * See https://aka.ms/CosmosDB/PriorityBasedExecution for more detailed documentation on Priority based throttling.\n */\nexport enum PriorityLevel {\n /**\n * High Priority requests are throttled after Low priority requests.\n */\n High = \"High\",\n /**\n * Low Priority requests are throttled before High priority requests.\n */\n Low = \"Low\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for trigger operation values.\n * specifies the operations on which a trigger should be executed.\n */\nexport enum TriggerOperation {\n /** All operations. */\n All = \"all\",\n /** Create operations only. */\n Create = \"create\",\n /** Update operations only. */\n Update = \"update\",\n /** Delete operations only. */\n Delete = \"delete\",\n /** Replace operations only. */\n Replace = \"replace\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for trigger type values.\n * Specifies the type of the trigger.\n */\nexport enum TriggerType {\n /** Trigger should be executed before the associated operation(s). */\n Pre = \"pre\",\n /** Trigger should be executed after the associated operation(s). */\n Post = \"post\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Enum for udf type values.\n * Specifies the types of user defined functions.\n */\nexport enum UserDefinedFunctionType {\n /** The User Defined Function is written in JavaScript. This is currently the only option. */\n Javascript = \"Javascript\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport enum GeospatialType {\n /** Represents data in round-earth coordinate system. */\n Geography = \"Geography\",\n /** Represents data in Eucledian(flat) coordinate system. */\n Geometry = \"Geometry\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { parsePath } from \"./common\";\nimport {\n NonePartitionKeyLiteral,\n NullPartitionKeyLiteral,\n PartitionKeyDefinition,\n PartitionKeyInternal,\n PrimitivePartitionKeyValue,\n} from \"./documents\";\nimport { DEFAULT_PARTITION_KEY_PATH } from \"./common/partitionKeys\";\n\nconst logger: AzureLogger = createClientLogger(\"extractPartitionKey\");\n\n/**\n * Function to extract PartitionKey based on {@link PartitionKeyDefinition}\n * from an object.\n * Retuns\n * 1. PartitionKeyInternal[] if extraction is successful.\n * 2. undefined if either {@link partitionKeyDefinition} is not well formed\n * or an unsupported partitionkey type is encountered.\n * @hidden\n */\nexport function extractPartitionKeys(\n document: unknown,\n partitionKeyDefinition?: PartitionKeyDefinition,\n): PartitionKeyInternal | undefined {\n if (\n partitionKeyDefinition &&\n partitionKeyDefinition.paths &&\n partitionKeyDefinition.paths.length > 0\n ) {\n if (partitionKeyDefinition.systemKey === true) {\n return [];\n }\n\n if (\n partitionKeyDefinition.paths.length === 1 &&\n partitionKeyDefinition.paths[0] === DEFAULT_PARTITION_KEY_PATH\n ) {\n return [extractPartitionKey(DEFAULT_PARTITION_KEY_PATH, document)];\n }\n\n const partitionKeys: PrimitivePartitionKeyValue[] = [];\n partitionKeyDefinition.paths.forEach((path: string) => {\n const obj = extractPartitionKey(path, document);\n if (obj === undefined) {\n logger.warning(\"Unsupported PartitionKey found.\");\n return undefined;\n }\n partitionKeys.push(obj);\n });\n return partitionKeys;\n }\n logger.error(\"Unexpected Partition Key Definition Found.\");\n return undefined;\n}\n\nfunction extractPartitionKey(path: string, obj: unknown): any {\n const pathParts: string[] = parsePath(path);\n for (const part of pathParts) {\n if (typeof obj === \"object\" && obj !== null && part in obj) {\n obj = (obj as Record)[part];\n } else {\n obj = undefined;\n break;\n }\n }\n if (typeof obj === \"string\" || typeof obj === \"number\" || typeof obj === \"boolean\") {\n return obj;\n } else if (obj === NullPartitionKeyLiteral) {\n return NullPartitionKeyLiteral;\n } else if (obj === undefined || JSON.stringify(obj) === JSON.stringify(NonePartitionKeyLiteral)) {\n return NonePartitionKeyLiteral;\n }\n return undefined;\n}\n\n/**\n * @hidden\n */\nexport function undefinedPartitionKey(\n partitionKeyDefinition: PartitionKeyDefinition,\n): PartitionKeyInternal {\n if (partitionKeyDefinition.systemKey === true) {\n return [];\n } else {\n return partitionKeyDefinition.paths.map(() => NonePartitionKeyLiteral);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NonePartitionKeyLiteral,\n NonePartitionKeyType,\n NullPartitionKeyLiteral,\n NullPartitionKeyType,\n PrimitivePartitionKeyValue,\n} from \"../documents\";\n\n/**\n * A type which could be any type but undefined\n */\nexport type NonUndefinable = T extends undefined ? never : T;\n\n/**\n * Utility function to avoid writing boilder plate code while checking for\n * undefined values. It throws Error if the input value is undefined.\n * @param value - Value which is potentially undefined.\n * @param msg - Error Message to throw if value is undefined.\n * @returns\n */\nexport function assertNotUndefined(value: T, msg?: string): NonUndefinable {\n if (value !== undefined) {\n return value as NonUndefinable;\n }\n throw new Error(msg || \"Unexpected 'undefined' value encountered\");\n}\n\n/**\n * Check for value being PrimitivePartitionKeyValue.\n * @internal\n */\nexport function isPrimitivePartitionKeyValue(value: unknown): value is PrimitivePartitionKeyValue {\n return (\n isWellDefinedPartitionKeyValue(value) ||\n isNonePartitionKeyValue(value) ||\n isNullPartitionKeyValue(value)\n );\n}\n\n/**\n * Check for value being string, number or boolean.\n * @internal\n */\nexport function isWellDefinedPartitionKeyValue(value: unknown): value is string | number | boolean {\n return typeof value === \"string\" || typeof value === \"boolean\" || typeof value === \"number\";\n}\n\n/**\n * Check for value being NonePartitionKeyType.\n * @internal\n */\nexport function isNonePartitionKeyValue(value: unknown): value is NonePartitionKeyType {\n return value !== undefined && JSON.stringify(value) === JSON.stringify(NonePartitionKeyLiteral);\n}\n\n/**\n * Check for value being NullPartitionKeyType.\n * @internal\n */\nexport function isNullPartitionKeyValue(value: unknown): value is NullPartitionKeyType {\n return value === NullPartitionKeyLiteral;\n}\n/**\n * Verify validity of partition key.\n * @internal\n */\nexport function isPartitionKey(partitionKey: unknown): boolean {\n return isPrimitivePartitionKeyValue(partitionKey) || Array.isArray(partitionKey);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { createClientLogger, AzureLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure/logger configuration for this package.\n */\nexport const defaultLogger: AzureLogger = createClientLogger(\"cosmosdb\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { setAuthorizationHeader } from \"../auth\";\nimport { Constants, HTTPMethod, jsonStringifyAndEscapeNonASCII, ResourceType } from \"../common\";\nimport { CosmosClientOptions } from \"../CosmosClientOptions\";\nimport { PartitionKeyInternal } from \"../documents\";\nimport { CosmosHeaders } from \"../queryExecutionContext\";\nimport { FeedOptions, RequestOptions } from \"./index\";\nimport { defaultLogger } from \"../common/logger\";\n// ----------------------------------------------------------------------------\n// Utility methods\n//\n\n/** @hidden */\nfunction javaScriptFriendlyJSONStringify(s: unknown): string {\n // two line terminators (Line separator and Paragraph separator) are not needed to be escaped in JSON\n // but are needed to be escaped in JavaScript.\n return JSON.stringify(s)\n .replace(/\\u2028/g, \"\\\\u2028\")\n .replace(/\\u2029/g, \"\\\\u2029\");\n}\n\n/** @hidden */\nexport function bodyFromData(data: Buffer | string | Record): string {\n if (typeof data === \"object\") {\n return javaScriptFriendlyJSONStringify(data);\n }\n return data;\n}\n\n/**\n * @hidden\n */\ninterface GetHeadersOptions {\n clientOptions: CosmosClientOptions;\n defaultHeaders: CosmosHeaders;\n verb: HTTPMethod;\n path: string;\n resourceId: string;\n resourceType: ResourceType;\n options: RequestOptions & FeedOptions;\n partitionKeyRangeId?: string;\n useMultipleWriteLocations?: boolean;\n partitionKey?: PartitionKeyInternal;\n}\n\nconst JsonContentType = \"application/json\";\n\n/**\n * @hidden\n */\nexport async function getHeaders({\n clientOptions,\n defaultHeaders,\n verb,\n path,\n resourceId,\n resourceType,\n options = {},\n partitionKeyRangeId,\n useMultipleWriteLocations,\n partitionKey,\n}: GetHeadersOptions): Promise {\n const headers: CosmosHeaders = {\n [Constants.HttpHeaders.ResponseContinuationTokenLimitInKB]: 1,\n [Constants.HttpHeaders.EnableCrossPartitionQuery]: true,\n ...defaultHeaders,\n };\n\n if (useMultipleWriteLocations) {\n headers[Constants.HttpHeaders.ALLOW_MULTIPLE_WRITES] = true;\n }\n\n if (options.continuationTokenLimitInKB) {\n headers[Constants.HttpHeaders.ResponseContinuationTokenLimitInKB] =\n options.continuationTokenLimitInKB;\n }\n if (options.continuationToken) {\n headers[Constants.HttpHeaders.Continuation] = options.continuationToken;\n } else if (options.continuation) {\n headers[Constants.HttpHeaders.Continuation] = options.continuation;\n }\n\n if (options.preTriggerInclude) {\n headers[Constants.HttpHeaders.PreTriggerInclude] =\n options.preTriggerInclude.constructor === Array\n ? (options.preTriggerInclude as string[]).join(\",\")\n : (options.preTriggerInclude as string);\n }\n\n if (options.postTriggerInclude) {\n headers[Constants.HttpHeaders.PostTriggerInclude] =\n options.postTriggerInclude.constructor === Array\n ? (options.postTriggerInclude as string[]).join(\",\")\n : (options.postTriggerInclude as string);\n }\n\n if (options.offerType) {\n headers[Constants.HttpHeaders.OfferType] = options.offerType;\n }\n\n if (options.offerThroughput) {\n headers[Constants.HttpHeaders.OfferThroughput] = options.offerThroughput;\n }\n\n if (options.maxItemCount) {\n headers[Constants.HttpHeaders.PageSize] = options.maxItemCount;\n }\n\n if (options.accessCondition) {\n if (options.accessCondition.type === \"IfMatch\") {\n headers[Constants.HttpHeaders.IfMatch] = options.accessCondition.condition;\n } else {\n headers[Constants.HttpHeaders.IfNoneMatch] = options.accessCondition.condition;\n }\n }\n\n if (options.useIncrementalFeed) {\n headers[Constants.HttpHeaders.A_IM] = \"Incremental Feed\";\n }\n\n if (options.indexingDirective) {\n headers[Constants.HttpHeaders.IndexingDirective] = options.indexingDirective;\n }\n\n if (options.consistencyLevel) {\n headers[Constants.HttpHeaders.ConsistencyLevel] = options.consistencyLevel;\n }\n\n if (options.priorityLevel) {\n headers[Constants.HttpHeaders.PriorityLevel] = options.priorityLevel;\n }\n\n if (options.maxIntegratedCacheStalenessInMs && resourceType === ResourceType.item) {\n if (typeof options.maxIntegratedCacheStalenessInMs === \"number\") {\n headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] =\n options.maxIntegratedCacheStalenessInMs.toString();\n } else {\n defaultLogger.error(\n `RangeError: maxIntegratedCacheStalenessInMs \"${options.maxIntegratedCacheStalenessInMs}\" is not a valid parameter.`,\n );\n headers[Constants.HttpHeaders.DedicatedGatewayPerRequestCacheStaleness] = \"null\";\n }\n }\n\n if (options.resourceTokenExpirySeconds) {\n headers[Constants.HttpHeaders.ResourceTokenExpiry] = options.resourceTokenExpirySeconds;\n }\n\n if (options.sessionToken) {\n headers[Constants.HttpHeaders.SessionToken] = options.sessionToken;\n }\n\n if (options.enableScanInQuery) {\n headers[Constants.HttpHeaders.EnableScanInQuery] = options.enableScanInQuery;\n }\n\n if (options.populateQuotaInfo) {\n headers[Constants.HttpHeaders.PopulateQuotaInfo] = options.populateQuotaInfo;\n }\n\n if (options.populateQueryMetrics) {\n headers[Constants.HttpHeaders.PopulateQueryMetrics] = options.populateQueryMetrics;\n }\n\n if (options.maxDegreeOfParallelism !== undefined) {\n headers[Constants.HttpHeaders.ParallelizeCrossPartitionQuery] = true;\n }\n\n if (options.populateQuotaInfo) {\n headers[Constants.HttpHeaders.PopulateQuotaInfo] = true;\n }\n\n if (partitionKey !== undefined && !headers[Constants.HttpHeaders.PartitionKey]) {\n headers[Constants.HttpHeaders.PartitionKey] = jsonStringifyAndEscapeNonASCII(partitionKey);\n }\n\n if (clientOptions.key || clientOptions.tokenProvider) {\n headers[Constants.HttpHeaders.XDate] = new Date().toUTCString();\n }\n\n if (verb === HTTPMethod.post || verb === HTTPMethod.put) {\n if (!headers[Constants.HttpHeaders.ContentType]) {\n headers[Constants.HttpHeaders.ContentType] = JsonContentType;\n }\n }\n\n if (!headers[Constants.HttpHeaders.Accept]) {\n headers[Constants.HttpHeaders.Accept] = JsonContentType;\n }\n\n if (partitionKeyRangeId !== undefined) {\n headers[Constants.HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId;\n }\n\n if (options.enableScriptLogging) {\n headers[Constants.HttpHeaders.EnableScriptLogging] = options.enableScriptLogging;\n }\n\n if (options.disableRUPerMinuteUsage) {\n headers[Constants.HttpHeaders.DisableRUPerMinuteUsage] = true;\n }\n\n if (options.populateIndexMetrics) {\n headers[Constants.HttpHeaders.PopulateIndexMetrics] = options.populateIndexMetrics;\n }\n\n if (\n clientOptions.key ||\n clientOptions.resourceTokens ||\n clientOptions.tokenProvider ||\n clientOptions.permissionFeed\n ) {\n await setAuthorizationHeader(clientOptions, verb, path, resourceId, resourceType, headers);\n }\n return headers;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { JSONObject } from \"../queryExecutionContext\";\nimport { extractPartitionKeys } from \"../extractPartitionKey\";\nimport { CosmosDiagnostics, RequestOptions } from \"..\";\nimport {\n NonePartitionKeyLiteral,\n PartitionKey,\n PartitionKeyDefinition,\n PrimitivePartitionKeyValue,\n convertToInternalPartitionKey,\n} from \"../documents\";\nimport { PatchRequestBody } from \"./patch\";\nimport { v4 } from \"uuid\";\nimport { assertNotUndefined } from \"./typeChecks\";\nimport { bodyFromData } from \"../request/request\";\nimport { Constants } from \"../common/constants\";\nconst uuid = v4;\n\nexport type Operation =\n | CreateOperation\n | UpsertOperation\n | ReadOperation\n | DeleteOperation\n | ReplaceOperation\n | BulkPatchOperation;\n\nexport interface Batch {\n min: string;\n max: string;\n rangeId: string;\n indexes: number[];\n operations: Operation[];\n}\n\nexport type BulkOperationResponse = OperationResponse[] & { diagnostics: CosmosDiagnostics };\n\nexport interface OperationResponse {\n statusCode: number;\n requestCharge: number;\n eTag?: string;\n resourceBody?: JSONObject;\n}\n\n/**\n * Options object used to modify bulk execution.\n * continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE\n */\nexport interface BulkOptions {\n continueOnError?: boolean;\n}\n\nexport function isKeyInRange(min: string, max: string, key: string): boolean {\n const isAfterMinInclusive = key.localeCompare(min) >= 0;\n const isBeforeMax = key.localeCompare(max) < 0;\n return isAfterMinInclusive && isBeforeMax;\n}\n\nexport interface OperationBase {\n partitionKey?: string;\n ifMatch?: string;\n ifNoneMatch?: string;\n}\n\nexport const BulkOperationType = {\n Create: \"Create\",\n Upsert: \"Upsert\",\n Read: \"Read\",\n Delete: \"Delete\",\n Replace: \"Replace\",\n Patch: \"Patch\",\n} as const;\n\nexport type OperationInput =\n | CreateOperationInput\n | UpsertOperationInput\n | ReadOperationInput\n | DeleteOperationInput\n | ReplaceOperationInput\n | PatchOperationInput;\n\nexport interface CreateOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Create;\n resourceBody: JSONObject;\n}\n\nexport interface UpsertOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Upsert;\n resourceBody: JSONObject;\n}\n\nexport interface ReadOperationInput {\n partitionKey?: PartitionKey;\n operationType: typeof BulkOperationType.Read;\n id: string;\n}\n\nexport interface DeleteOperationInput {\n partitionKey?: PartitionKey;\n operationType: typeof BulkOperationType.Delete;\n id: string;\n}\n\nexport interface ReplaceOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Replace;\n resourceBody: JSONObject;\n id: string;\n}\n\nexport interface PatchOperationInput {\n partitionKey?: PartitionKey;\n ifMatch?: string;\n ifNoneMatch?: string;\n operationType: typeof BulkOperationType.Patch;\n resourceBody: PatchRequestBody;\n id: string;\n}\n\nexport type OperationWithItem = OperationBase & {\n resourceBody: JSONObject;\n};\n\nexport type CreateOperation = OperationWithItem & {\n operationType: typeof BulkOperationType.Create;\n};\n\nexport type UpsertOperation = OperationWithItem & {\n operationType: typeof BulkOperationType.Upsert;\n};\n\nexport type ReadOperation = OperationBase & {\n operationType: typeof BulkOperationType.Read;\n id: string;\n};\n\nexport type DeleteOperation = OperationBase & {\n operationType: typeof BulkOperationType.Delete;\n id: string;\n};\n\nexport type ReplaceOperation = OperationWithItem & {\n operationType: typeof BulkOperationType.Replace;\n id: string;\n};\n\nexport type BulkPatchOperation = OperationBase & {\n operationType: typeof BulkOperationType.Patch;\n id: string;\n};\n\nexport function hasResource(\n operation: Operation,\n): operation is CreateOperation | UpsertOperation | ReplaceOperation {\n return (\n operation.operationType !== \"Patch\" &&\n (operation as OperationWithItem).resourceBody !== undefined\n );\n}\n/**\n * Maps OperationInput to Operation by\n * - generating Ids if needed.\n * - choosing partitionKey which can be used to choose which batch this\n * operation should be part of. The order is -\n * 1. If the operationInput itself has partitionKey field set it is used.\n * 2. Other wise for create/replace/upsert it is extracted from resource body.\n * 3. For read/delete/patch type operations undefined partitionKey is used.\n * - Here one nuance is that, the partitionKey field inside Operation needs to\n * be serialized as a JSON string.\n * @param operationInput - OperationInput\n * @param definition - PartitionKeyDefinition\n * @param options - RequestOptions\n * @returns\n */\nexport function prepareOperations(\n operationInput: OperationInput,\n definition: PartitionKeyDefinition,\n options: RequestOptions = {},\n): {\n operation: Operation;\n partitionKey: PrimitivePartitionKeyValue[];\n} {\n populateIdsIfNeeded(operationInput, options);\n\n let partitionKey: PrimitivePartitionKeyValue[];\n if (Object.prototype.hasOwnProperty.call(operationInput, \"partitionKey\")) {\n if (operationInput.partitionKey === undefined) {\n partitionKey = definition.paths.map(() => NonePartitionKeyLiteral);\n } else {\n partitionKey = convertToInternalPartitionKey(operationInput.partitionKey);\n }\n } else {\n switch (operationInput.operationType) {\n case BulkOperationType.Create:\n case BulkOperationType.Replace:\n case BulkOperationType.Upsert:\n partitionKey = assertNotUndefined(\n extractPartitionKeys(operationInput.resourceBody, definition),\n \"Unexpected undefined Partition Key Found.\",\n );\n break;\n case BulkOperationType.Read:\n case BulkOperationType.Delete:\n case BulkOperationType.Patch:\n partitionKey = definition.paths.map(() => NonePartitionKeyLiteral);\n }\n }\n return {\n operation: { ...operationInput, partitionKey: JSON.stringify(partitionKey) } as Operation,\n partitionKey,\n };\n}\n\n/**\n * For operations requiring Id genrate random uuids.\n * @param operationInput - OperationInput to be checked.\n * @param options - RequestOptions\n */\nfunction populateIdsIfNeeded(operationInput: OperationInput, options: RequestOptions) {\n if (\n operationInput.operationType === BulkOperationType.Create ||\n operationInput.operationType === BulkOperationType.Upsert\n ) {\n if (\n (operationInput.resourceBody.id === undefined || operationInput.resourceBody.id === \"\") &&\n !options.disableAutomaticIdGeneration\n ) {\n operationInput.resourceBody.id = uuid();\n }\n }\n}\n\n/**\n * Splits a batch into array of batches based on cumulative size of its operations by making sure\n * cumulative size of an individual batch is not larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}.\n * If a single operation itself is larger than {@link Constants.DefaultMaxBulkRequestBodySizeInBytes}, that\n * operation would be moved into a batch containing only that operation.\n * @param originalBatch - A batch of operations needed to be checked.\n * @returns\n * @hidden\n */\nexport function splitBatchBasedOnBodySize(originalBatch: Batch): Batch[] {\n if (originalBatch?.operations === undefined || originalBatch.operations.length < 1) return [];\n let currentBatchSize = calculateObjectSizeInBytes(originalBatch.operations[0]);\n let currentBatch: Batch = {\n ...originalBatch,\n operations: [originalBatch.operations[0]],\n indexes: [originalBatch.indexes[0]],\n };\n const processedBatches: Batch[] = [];\n processedBatches.push(currentBatch);\n\n for (let index = 1; index < originalBatch.operations.length; index++) {\n const operation = originalBatch.operations[index];\n const currentOpSize = calculateObjectSizeInBytes(operation);\n if (currentBatchSize + currentOpSize > Constants.DefaultMaxBulkRequestBodySizeInBytes) {\n currentBatch = {\n ...originalBatch,\n operations: [],\n indexes: [],\n };\n processedBatches.push(currentBatch);\n currentBatchSize = 0;\n }\n currentBatch.operations.push(operation);\n currentBatch.indexes.push(originalBatch.indexes[index]);\n currentBatchSize += currentOpSize;\n }\n return processedBatches;\n}\n\n/**\n * Calculates size of an JSON object in bytes with utf-8 encoding.\n * @hidden\n */\nexport function calculateObjectSizeInBytes(obj: unknown): number {\n return new TextEncoder().encode(bodyFromData(obj as any)).length;\n}\n\nexport function decorateBatchOperation(\n operation: OperationInput,\n options: RequestOptions = {},\n): Operation {\n if (\n operation.operationType === BulkOperationType.Create ||\n operation.operationType === BulkOperationType.Upsert\n ) {\n if (\n (operation.resourceBody.id === undefined || operation.resourceBody.id === \"\") &&\n !options.disableAutomaticIdGeneration\n ) {\n operation.resourceBody.id = uuid();\n }\n }\n return operation as Operation;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport type PatchOperation = ExistingKeyOperation | RemoveOperation;\n\nexport const PatchOperationType = {\n add: \"add\",\n replace: \"replace\",\n remove: \"remove\",\n set: \"set\",\n incr: \"incr\",\n} as const;\n\nexport type ExistingKeyOperation = {\n op: keyof typeof PatchOperationType;\n value: any;\n path: string;\n};\n\nexport type RemoveOperation = {\n op: \"remove\";\n path: string;\n};\n\nexport type PatchRequestBody =\n | {\n operations: PatchOperation[];\n condition?: string;\n }\n | PatchOperation[];\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics, CosmosHeaders } from \"../index\";\n\nexport interface ErrorBody {\n code: string;\n message: string;\n /**\n * @hidden\n */\n additionalErrorInfo?: PartitionedQueryExecutionInfo;\n}\n\n/**\n * @hidden\n */\nexport interface PartitionedQueryExecutionInfo {\n partitionedQueryExecutionInfoVersion: number;\n queryInfo: QueryInfo;\n queryRanges: QueryRange[];\n}\n\n/**\n * @hidden\n */\nexport interface QueryRange {\n min: string;\n max: string;\n isMinInclusive: boolean;\n isMaxInclusive: boolean;\n}\n\n/**\n * @hidden\n */\nexport interface QueryInfo {\n top?: any;\n orderBy?: any[];\n orderByExpressions?: any[];\n offset?: number;\n limit?: number;\n aggregates?: AggregateType[];\n groupByExpressions?: GroupByExpressions;\n groupByAliasToAggregateType: GroupByAliasToAggregateType;\n rewrittenQuery?: any;\n distinctType: string;\n hasSelectValue: boolean;\n /**\n * determines whether the query is of non streaming orderby type.\n */\n hasNonStreamingOrderBy: boolean;\n}\n\nexport type GroupByExpressions = string[];\n\nexport type AggregateType = \"Average\" | \"Count\" | \"Max\" | \"Min\" | \"Sum\";\n\nexport interface GroupByAliasToAggregateType {\n [key: string]: AggregateType;\n}\n\nexport class ErrorResponse extends Error {\n code?: number | string;\n substatus?: number;\n body?: ErrorBody;\n headers?: CosmosHeaders;\n activityId?: string;\n retryAfterInMs?: number;\n retryAfterInMilliseconds?: number;\n [key: string]: any;\n diagnostics?: CosmosDiagnostics;\n}\n\nexport const nonStreamingEndpointEmptyResult = { result: \"empty response\" };\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\nimport { Constants } from \"../common\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { StatusCode, SubStatusCode } from \"./StatusCodes\";\n\nexport class ResourceResponse {\n constructor(\n public readonly resource: TResource | undefined,\n public readonly headers: CosmosHeaders,\n public readonly statusCode: StatusCode,\n public readonly diagnostics: CosmosDiagnostics,\n public readonly substatus?: SubStatusCode,\n ) {}\n public get requestCharge(): number {\n return Number(this.headers[Constants.HttpHeaders.RequestCharge]) || 0;\n }\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId] as string;\n }\n public get etag(): string {\n return this.headers[Constants.HttpHeaders.ETag] as string;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport class ClientSideMetrics {\n constructor(public readonly requestCharge: number) {}\n\n /**\n * Adds one or more ClientSideMetrics to a copy of this instance and returns the result.\n */\n public add(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics {\n let requestCharge = this.requestCharge;\n for (const clientSideMetrics of clientSideMetricsArray) {\n if (clientSideMetrics == null) {\n throw new Error(\"clientSideMetrics has null or undefined item(s)\");\n }\n\n requestCharge += clientSideMetrics.requestCharge;\n }\n\n return new ClientSideMetrics(requestCharge);\n }\n\n public static readonly zero = new ClientSideMetrics(0);\n\n public static createFromArray(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics {\n if (clientSideMetricsArray == null) {\n throw new Error(\"clientSideMetricsArray is null or undefined item(s)\");\n }\n\n return this.zero.add(...clientSideMetricsArray);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport default {\n // QueryMetrics\n RetrievedDocumentCount: \"retrievedDocumentCount\",\n RetrievedDocumentSize: \"retrievedDocumentSize\",\n OutputDocumentCount: \"outputDocumentCount\",\n OutputDocumentSize: \"outputDocumentSize\",\n IndexHitRatio: \"indexUtilizationRatio\",\n IndexHitDocumentCount: \"indexHitDocumentCount\",\n TotalQueryExecutionTimeInMs: \"totalExecutionTimeInMs\",\n\n // QueryPreparationTimes\n QueryCompileTimeInMs: \"queryCompileTimeInMs\",\n LogicalPlanBuildTimeInMs: \"queryLogicalPlanBuildTimeInMs\",\n PhysicalPlanBuildTimeInMs: \"queryPhysicalPlanBuildTimeInMs\",\n QueryOptimizationTimeInMs: \"queryOptimizationTimeInMs\",\n\n // QueryTimes\n IndexLookupTimeInMs: \"indexLookupTimeInMs\",\n DocumentLoadTimeInMs: \"documentLoadTimeInMs\",\n VMExecutionTimeInMs: \"VMExecutionTimeInMs\",\n DocumentWriteTimeInMs: \"writeOutputTimeInMs\",\n\n // RuntimeExecutionTimes\n QueryEngineTimes: \"queryEngineTimes\",\n SystemFunctionExecuteTimeInMs: \"systemFunctionExecuteTimeInMs\",\n UserDefinedFunctionExecutionTimeInMs: \"userFunctionExecuteTimeInMs\",\n\n // QueryMetrics Text\n RetrievedDocumentCountText: \"Retrieved Document Count\",\n RetrievedDocumentSizeText: \"Retrieved Document Size\",\n OutputDocumentCountText: \"Output Document Count\",\n OutputDocumentSizeText: \"Output Document Size\",\n IndexUtilizationText: \"Index Utilization\",\n TotalQueryExecutionTimeText: \"Total Query Execution Time\",\n\n // QueryPreparationTimes Text\n QueryPreparationTimesText: \"Query Preparation Times\",\n QueryCompileTimeText: \"Query Compilation Time\",\n LogicalPlanBuildTimeText: \"Logical Plan Build Time\",\n PhysicalPlanBuildTimeText: \"Physical Plan Build Time\",\n QueryOptimizationTimeText: \"Query Optimization Time\",\n\n // QueryTimes Text\n QueryEngineTimesText: \"Query Engine Times\",\n IndexLookupTimeText: \"Index Lookup Time\",\n DocumentLoadTimeText: \"Document Load Time\",\n WriteOutputTimeText: \"Document Write Time\",\n\n // RuntimeExecutionTimes Text\n RuntimeExecutionTimesText: \"Runtime Execution Times\",\n TotalExecutionTimeText: \"Query Engine Execution Time\",\n SystemFunctionExecuteTimeText: \"System Function Execution Time\",\n UserDefinedFunctionExecutionTimeText: \"User-defined Function Execution Time\",\n\n // ClientSideQueryMetrics Text\n ClientSideQueryMetricsText: \"Client Side Metrics\",\n RetriesText: \"Retry Count\",\n RequestChargeText: \"Request Charge\",\n FetchExecutionRangesText: \"Partition Execution Timeline\",\n SchedulingMetricsText: \"Scheduling Metrics\",\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// Ported this implementation to javascript:\n// https://referencesource.microsoft.com/#mscorlib/system/timespan.cs,83e476c1ae112117\n/** @hidden */\n// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nconst ticksPerMillisecond = 10000;\n/** @hidden */\nconst millisecondsPerTick = 1.0 / ticksPerMillisecond;\n\n/** @hidden */\nconst ticksPerSecond = ticksPerMillisecond * 1000; // 10,000,000\n/** @hidden */\nconst secondsPerTick = 1.0 / ticksPerSecond; // 0.0001\n\n/** @hidden */\nconst ticksPerMinute = ticksPerSecond * 60; // 600,000,000\n/** @hidden */\nconst minutesPerTick = 1.0 / ticksPerMinute; // 1.6666666666667e-9\n\n/** @hidden */\nconst ticksPerHour = ticksPerMinute * 60; // 36,000,000,000\n/** @hidden */\nconst hoursPerTick = 1.0 / ticksPerHour; // 2.77777777777777778e-11\n\n/** @hidden */\nconst ticksPerDay = ticksPerHour * 24; // 864,000,000,000\n/** @hidden */\nconst daysPerTick = 1.0 / ticksPerDay; // 1.1574074074074074074e-12\n\n/** @hidden */\nconst millisPerSecond = 1000;\n/** @hidden */\nconst millisPerMinute = millisPerSecond * 60; // 60,000\n/** @hidden */\nconst millisPerHour = millisPerMinute * 60; // 3,600,000\n/** @hidden */\nconst millisPerDay = millisPerHour * 24; // 86,400,000\n\n/** @hidden */\nconst maxMilliSeconds = Number.MAX_SAFE_INTEGER / ticksPerMillisecond;\n/** @hidden */\nconst minMilliSeconds = Number.MIN_SAFE_INTEGER / ticksPerMillisecond;\n\n/**\n * Represents a time interval.\n *\n * @param days - Number of days.\n * @param hours - Number of hours.\n * @param minutes - Number of minutes.\n * @param seconds - Number of seconds.\n * @param milliseconds - Number of milliseconds.\n * @hidden\n */\nexport class TimeSpan {\n protected _ticks: number;\n constructor(days: number, hours: number, minutes: number, seconds: number, milliseconds: number) {\n // Constructor\n if (!Number.isInteger(days)) {\n throw new Error(\"days is not an integer\");\n }\n\n if (!Number.isInteger(hours)) {\n throw new Error(\"hours is not an integer\");\n }\n\n if (!Number.isInteger(minutes)) {\n throw new Error(\"minutes is not an integer\");\n }\n\n if (!Number.isInteger(seconds)) {\n throw new Error(\"seconds is not an integer\");\n }\n\n if (!Number.isInteger(milliseconds)) {\n throw new Error(\"milliseconds is not an integer\");\n }\n\n const totalMilliSeconds =\n (days * 3600 * 24 + hours * 3600 + minutes * 60 + seconds) * 1000 + milliseconds;\n if (totalMilliSeconds > maxMilliSeconds || totalMilliSeconds < minMilliSeconds) {\n throw new Error(\"Total number of milliseconds was either too large or too small\");\n }\n\n this._ticks = totalMilliSeconds * ticksPerMillisecond;\n }\n\n /**\n * Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance.\n * @param ts - The time interval to add.\n */\n public add(ts: TimeSpan): TimeSpan {\n if (TimeSpan.additionDoesOverflow(this._ticks, ts._ticks)) {\n throw new Error(\"Adding the two timestamps causes an overflow.\");\n }\n\n const results = this._ticks + ts._ticks;\n return TimeSpan.fromTicks(results);\n }\n\n /**\n * Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance.\n * @param ts - The time interval to subtract.\n */\n public subtract(ts: TimeSpan): TimeSpan {\n if (TimeSpan.subtractionDoesUnderflow(this._ticks, ts._ticks)) {\n throw new Error(\"Subtracting the two timestamps causes an underflow.\");\n }\n\n const results = this._ticks - ts._ticks;\n return TimeSpan.fromTicks(results);\n }\n\n /**\n * Compares this instance to a specified object and returns an integer that indicates whether this\n * instance is shorter than, equal to, or longer than the specified object.\n * @param value - The time interval to add.\n */\n public compareTo(value: TimeSpan): 1 | -1 | 0 {\n if (value == null) {\n return 1;\n }\n\n if (!TimeSpan.isTimeSpan(value)) {\n throw new Error(\"Argument must be a TimeSpan object\");\n }\n\n return TimeSpan.compare(this, value);\n }\n\n /**\n * Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object.\n */\n public duration(): TimeSpan {\n return TimeSpan.fromTicks(this._ticks >= 0 ? this._ticks : -this._ticks);\n }\n\n /**\n * Returns a value indicating whether this instance is equal to a specified object.\n * @param value - The time interval to check for equality.\n */\n public equals(value: TimeSpan): boolean {\n if (TimeSpan.isTimeSpan(value)) {\n return this._ticks === value._ticks;\n }\n\n return false;\n }\n\n /**\n * Returns a new TimeSpan object whose value is the negated value of this instance.\n * @param value - The time interval to check for equality.\n */\n public negate(): TimeSpan {\n return TimeSpan.fromTicks(-this._ticks);\n }\n\n public days(): number {\n return Math.floor(this._ticks / ticksPerDay);\n }\n\n public hours(): number {\n return Math.floor(this._ticks / ticksPerHour);\n }\n\n public milliseconds(): number {\n return Math.floor(this._ticks / ticksPerMillisecond);\n }\n\n public seconds(): number {\n return Math.floor(this._ticks / ticksPerSecond);\n }\n\n public ticks(): number {\n return this._ticks;\n }\n\n public totalDays(): number {\n return this._ticks * daysPerTick;\n }\n public totalHours(): number {\n return this._ticks * hoursPerTick;\n }\n\n public totalMilliseconds(): number {\n return this._ticks * millisecondsPerTick;\n }\n\n public totalMinutes(): number {\n return this._ticks * minutesPerTick;\n }\n\n public totalSeconds(): number {\n return this._ticks * secondsPerTick;\n }\n\n public static fromTicks(value: number): TimeSpan {\n const timeSpan = new TimeSpan(0, 0, 0, 0, 0);\n timeSpan._ticks = value;\n return timeSpan;\n }\n\n public static readonly zero = new TimeSpan(0, 0, 0, 0, 0);\n public static readonly maxValue = TimeSpan.fromTicks(Number.MAX_SAFE_INTEGER);\n public static readonly minValue = TimeSpan.fromTicks(Number.MIN_SAFE_INTEGER);\n\n public static isTimeSpan(timespan: TimeSpan): number {\n return timespan._ticks;\n }\n\n public static additionDoesOverflow(a: number, b: number): boolean {\n const c = a + b;\n return a !== c - b || b !== c - a;\n }\n\n public static subtractionDoesUnderflow(a: number, b: number): boolean {\n const c = a - b;\n return a !== c + b || b !== a - c;\n }\n\n public static compare(t1: TimeSpan, t2: TimeSpan): 1 | 0 | -1 {\n if (t1._ticks > t2._ticks) {\n return 1;\n }\n if (t1._ticks < t2._ticks) {\n return -1;\n }\n return 0;\n }\n\n public static interval(value: number, scale: number): TimeSpan {\n if (isNaN(value)) {\n throw new Error(\"value must be a number\");\n }\n\n const milliseconds = value * scale;\n if (milliseconds > maxMilliSeconds || milliseconds < minMilliSeconds) {\n throw new Error(\"timespan too long\");\n }\n\n return TimeSpan.fromTicks(Math.floor(milliseconds * ticksPerMillisecond));\n }\n\n public static fromMilliseconds(value: number): TimeSpan {\n return TimeSpan.interval(value, 1);\n }\n\n public static fromSeconds(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerSecond);\n }\n\n public static fromMinutes(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerMinute);\n }\n\n public static fromHours(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerHour);\n }\n\n public static fromDays(value: number): TimeSpan {\n return TimeSpan.interval(value, millisPerDay);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { TimeSpan } from \"./timeSpan\";\n\n/**\n * @hidden\n */\nexport function parseDelimitedString(delimitedString: string): {\n [key: string]: any;\n} {\n if (delimitedString == null) {\n throw new Error(\"delimitedString is null or undefined\");\n }\n\n const metrics: { [key: string]: any } = {};\n\n const headerAttributes = delimitedString.split(\";\");\n for (const attribute of headerAttributes) {\n const attributeKeyValue = attribute.split(\"=\");\n\n if (attributeKeyValue.length !== 2) {\n throw new Error(\"recieved a malformed delimited string\");\n }\n\n const attributeKey = attributeKeyValue[0];\n const attributeValue = parseFloat(attributeKeyValue[1]);\n\n metrics[attributeKey] = attributeValue;\n }\n\n return metrics;\n}\n\n/**\n * @hidden\n */\nexport function timeSpanFromMetrics(\n metrics: { [key: string]: any } /* TODO: any */,\n key: string,\n): TimeSpan {\n if (key in metrics) {\n return TimeSpan.fromMilliseconds(metrics[key]);\n }\n\n return TimeSpan.zero;\n}\n\n/**\n * @hidden\n */\nexport function isNumeric(input: unknown): boolean {\n return !isNaN(parseFloat(input as string)) && isFinite(input as number);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport QueryMetricsConstants from \"./queryMetricsConstants\";\nimport { parseDelimitedString, timeSpanFromMetrics } from \"./queryMetricsUtils\";\nimport { TimeSpan } from \"./timeSpan\";\n\nexport class QueryPreparationTimes {\n constructor(\n public readonly queryCompilationTime: TimeSpan,\n public readonly logicalPlanBuildTime: TimeSpan,\n public readonly physicalPlanBuildTime: TimeSpan,\n public readonly queryOptimizationTime: TimeSpan,\n ) {}\n\n /**\n * returns a new QueryPreparationTimes instance that is the addition of this and the arguments.\n */\n public add(...queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes {\n let queryCompilationTime = this.queryCompilationTime;\n let logicalPlanBuildTime = this.logicalPlanBuildTime;\n let physicalPlanBuildTime = this.physicalPlanBuildTime;\n let queryOptimizationTime = this.queryOptimizationTime;\n\n for (const queryPreparationTimes of queryPreparationTimesArray) {\n if (queryPreparationTimes == null) {\n throw new Error(\"queryPreparationTimesArray has null or undefined item(s)\");\n }\n\n queryCompilationTime = queryCompilationTime.add(queryPreparationTimes.queryCompilationTime);\n logicalPlanBuildTime = logicalPlanBuildTime.add(queryPreparationTimes.logicalPlanBuildTime);\n physicalPlanBuildTime = physicalPlanBuildTime.add(\n queryPreparationTimes.physicalPlanBuildTime,\n );\n queryOptimizationTime = queryOptimizationTime.add(\n queryPreparationTimes.queryOptimizationTime,\n );\n }\n\n return new QueryPreparationTimes(\n queryCompilationTime,\n logicalPlanBuildTime,\n physicalPlanBuildTime,\n queryOptimizationTime,\n );\n }\n\n /**\n * Output the QueryPreparationTimes as a delimited string.\n */\n public toDelimitedString(): string {\n return (\n `${\n QueryMetricsConstants.QueryCompileTimeInMs\n }=${this.queryCompilationTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.LogicalPlanBuildTimeInMs\n }=${this.logicalPlanBuildTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.PhysicalPlanBuildTimeInMs\n }=${this.physicalPlanBuildTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.QueryOptimizationTimeInMs\n }=${this.queryOptimizationTime.totalMilliseconds()}`\n );\n }\n\n public static readonly zero = new QueryPreparationTimes(\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n );\n\n /**\n * Returns a new instance of the QueryPreparationTimes class that is the\n * aggregation of an array of QueryPreparationTimes.\n */\n public static createFromArray(\n queryPreparationTimesArray: QueryPreparationTimes[],\n ): QueryPreparationTimes {\n if (queryPreparationTimesArray == null) {\n throw new Error(\"queryPreparationTimesArray is null or undefined item(s)\");\n }\n\n return QueryPreparationTimes.zero.add(...queryPreparationTimesArray);\n }\n\n /**\n * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string.\n */\n public static createFromDelimitedString(delimitedString: string): QueryPreparationTimes {\n const metrics = parseDelimitedString(delimitedString);\n\n return new QueryPreparationTimes(\n timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryCompileTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.LogicalPlanBuildTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.PhysicalPlanBuildTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.QueryOptimizationTimeInMs),\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport QueryMetricsConstants from \"./queryMetricsConstants\";\nimport { parseDelimitedString, timeSpanFromMetrics } from \"./queryMetricsUtils\";\nimport { TimeSpan } from \"./timeSpan\";\n\nexport class RuntimeExecutionTimes {\n constructor(\n public readonly queryEngineExecutionTime: TimeSpan,\n public readonly systemFunctionExecutionTime: TimeSpan,\n public readonly userDefinedFunctionExecutionTime: TimeSpan,\n ) {}\n\n /**\n * returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments.\n */\n public add(...runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes {\n let queryEngineExecutionTime = this.queryEngineExecutionTime;\n let systemFunctionExecutionTime = this.systemFunctionExecutionTime;\n let userDefinedFunctionExecutionTime = this.userDefinedFunctionExecutionTime;\n\n for (const runtimeExecutionTimes of runtimeExecutionTimesArray) {\n if (runtimeExecutionTimes == null) {\n throw new Error(\"runtimeExecutionTimes has null or undefined item(s)\");\n }\n\n queryEngineExecutionTime = queryEngineExecutionTime.add(\n runtimeExecutionTimes.queryEngineExecutionTime,\n );\n systemFunctionExecutionTime = systemFunctionExecutionTime.add(\n runtimeExecutionTimes.systemFunctionExecutionTime,\n );\n userDefinedFunctionExecutionTime = userDefinedFunctionExecutionTime.add(\n runtimeExecutionTimes.userDefinedFunctionExecutionTime,\n );\n }\n\n return new RuntimeExecutionTimes(\n queryEngineExecutionTime,\n systemFunctionExecutionTime,\n userDefinedFunctionExecutionTime,\n );\n }\n\n /**\n * Output the RuntimeExecutionTimes as a delimited string.\n */\n public toDelimitedString(): string {\n return (\n `${\n QueryMetricsConstants.SystemFunctionExecuteTimeInMs\n }=${this.systemFunctionExecutionTime.totalMilliseconds()};` +\n `${\n QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs\n }=${this.userDefinedFunctionExecutionTime.totalMilliseconds()}`\n );\n }\n\n public static readonly zero = new RuntimeExecutionTimes(\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n );\n\n /**\n * Returns a new instance of the RuntimeExecutionTimes class that is\n * the aggregation of an array of RuntimeExecutionTimes.\n */\n public static createFromArray(\n runtimeExecutionTimesArray: RuntimeExecutionTimes[],\n ): RuntimeExecutionTimes {\n if (runtimeExecutionTimesArray == null) {\n throw new Error(\"runtimeExecutionTimesArray is null or undefined item(s)\");\n }\n\n return RuntimeExecutionTimes.zero.add(...runtimeExecutionTimesArray);\n }\n\n /**\n * Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string.\n */\n public static createFromDelimitedString(delimitedString: string): RuntimeExecutionTimes {\n const metrics = parseDelimitedString(delimitedString);\n\n const vmExecutionTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs);\n const indexLookupTime = timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs);\n const documentLoadTime = timeSpanFromMetrics(\n metrics,\n QueryMetricsConstants.DocumentLoadTimeInMs,\n );\n const documentWriteTime = timeSpanFromMetrics(\n metrics,\n QueryMetricsConstants.DocumentWriteTimeInMs,\n );\n\n let queryEngineExecutionTime = TimeSpan.zero;\n queryEngineExecutionTime = queryEngineExecutionTime.add(vmExecutionTime);\n queryEngineExecutionTime = queryEngineExecutionTime.subtract(indexLookupTime);\n queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentLoadTime);\n queryEngineExecutionTime = queryEngineExecutionTime.subtract(documentWriteTime);\n return new RuntimeExecutionTimes(\n queryEngineExecutionTime,\n timeSpanFromMetrics(metrics, QueryMetricsConstants.SystemFunctionExecuteTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.UserDefinedFunctionExecutionTimeInMs),\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientSideMetrics } from \"./clientSideMetrics\";\nimport QueryMetricsConstants from \"./queryMetricsConstants\";\nimport { parseDelimitedString, timeSpanFromMetrics } from \"./queryMetricsUtils\";\nimport { QueryPreparationTimes } from \"./queryPreparationTime\";\nimport { RuntimeExecutionTimes } from \"./runtimeExecutionTimes\";\nimport { TimeSpan } from \"./timeSpan\";\n\nexport class QueryMetrics {\n constructor(\n public readonly retrievedDocumentCount: number,\n public readonly retrievedDocumentSize: number,\n public readonly outputDocumentCount: number,\n public readonly outputDocumentSize: number,\n public readonly indexHitDocumentCount: number,\n public readonly totalQueryExecutionTime: TimeSpan,\n public readonly queryPreparationTimes: QueryPreparationTimes,\n public readonly indexLookupTime: TimeSpan,\n public readonly documentLoadTime: TimeSpan,\n public readonly vmExecutionTime: TimeSpan,\n public readonly runtimeExecutionTimes: RuntimeExecutionTimes,\n public readonly documentWriteTime: TimeSpan,\n public readonly clientSideMetrics: ClientSideMetrics,\n ) {}\n\n /**\n * Gets the IndexHitRatio\n * @hidden\n */\n public get indexHitRatio(): number {\n return this.retrievedDocumentCount === 0\n ? 1\n : this.indexHitDocumentCount / this.retrievedDocumentCount;\n }\n\n /**\n * returns a new QueryMetrics instance that is the addition of this and the arguments.\n */\n public add(queryMetricsArray: QueryMetrics[]): QueryMetrics {\n let retrievedDocumentCount = 0;\n let retrievedDocumentSize = 0;\n let outputDocumentCount = 0;\n let outputDocumentSize = 0;\n let indexHitDocumentCount = 0;\n let totalQueryExecutionTime = TimeSpan.zero;\n const queryPreparationTimesArray = [];\n let indexLookupTime = TimeSpan.zero;\n let documentLoadTime = TimeSpan.zero;\n let vmExecutionTime = TimeSpan.zero;\n const runtimeExecutionTimesArray = [];\n let documentWriteTime = TimeSpan.zero;\n const clientSideQueryMetricsArray = [];\n\n queryMetricsArray.push(this);\n\n for (const queryMetrics of queryMetricsArray) {\n if (queryMetrics) {\n retrievedDocumentCount += queryMetrics.retrievedDocumentCount;\n retrievedDocumentSize += queryMetrics.retrievedDocumentSize;\n outputDocumentCount += queryMetrics.outputDocumentCount;\n outputDocumentSize += queryMetrics.outputDocumentSize;\n indexHitDocumentCount += queryMetrics.indexHitDocumentCount;\n totalQueryExecutionTime = totalQueryExecutionTime.add(queryMetrics.totalQueryExecutionTime);\n queryPreparationTimesArray.push(queryMetrics.queryPreparationTimes);\n indexLookupTime = indexLookupTime.add(queryMetrics.indexLookupTime);\n documentLoadTime = documentLoadTime.add(queryMetrics.documentLoadTime);\n vmExecutionTime = vmExecutionTime.add(queryMetrics.vmExecutionTime);\n runtimeExecutionTimesArray.push(queryMetrics.runtimeExecutionTimes);\n documentWriteTime = documentWriteTime.add(queryMetrics.documentWriteTime);\n clientSideQueryMetricsArray.push(queryMetrics.clientSideMetrics);\n }\n }\n\n return new QueryMetrics(\n retrievedDocumentCount,\n retrievedDocumentSize,\n outputDocumentCount,\n outputDocumentSize,\n indexHitDocumentCount,\n totalQueryExecutionTime,\n QueryPreparationTimes.createFromArray(queryPreparationTimesArray),\n indexLookupTime,\n documentLoadTime,\n vmExecutionTime,\n RuntimeExecutionTimes.createFromArray(runtimeExecutionTimesArray),\n documentWriteTime,\n ClientSideMetrics.createFromArray(...clientSideQueryMetricsArray),\n );\n }\n\n /**\n * Output the QueryMetrics as a delimited string.\n * @hidden\n */\n public toDelimitedString(): string {\n return (\n QueryMetricsConstants.RetrievedDocumentCount +\n \"=\" +\n this.retrievedDocumentCount +\n \";\" +\n QueryMetricsConstants.RetrievedDocumentSize +\n \"=\" +\n this.retrievedDocumentSize +\n \";\" +\n QueryMetricsConstants.OutputDocumentCount +\n \"=\" +\n this.outputDocumentCount +\n \";\" +\n QueryMetricsConstants.OutputDocumentSize +\n \"=\" +\n this.outputDocumentSize +\n \";\" +\n QueryMetricsConstants.IndexHitRatio +\n \"=\" +\n this.indexHitRatio +\n \";\" +\n QueryMetricsConstants.TotalQueryExecutionTimeInMs +\n \"=\" +\n this.totalQueryExecutionTime.totalMilliseconds() +\n \";\" +\n this.queryPreparationTimes.toDelimitedString() +\n \";\" +\n QueryMetricsConstants.IndexLookupTimeInMs +\n \"=\" +\n this.indexLookupTime.totalMilliseconds() +\n \";\" +\n QueryMetricsConstants.DocumentLoadTimeInMs +\n \"=\" +\n this.documentLoadTime.totalMilliseconds() +\n \";\" +\n QueryMetricsConstants.VMExecutionTimeInMs +\n \"=\" +\n this.vmExecutionTime.totalMilliseconds() +\n \";\" +\n this.runtimeExecutionTimes.toDelimitedString() +\n \";\" +\n QueryMetricsConstants.DocumentWriteTimeInMs +\n \"=\" +\n this.documentWriteTime.totalMilliseconds()\n );\n }\n\n public static readonly zero = new QueryMetrics(\n 0,\n 0,\n 0,\n 0,\n 0,\n TimeSpan.zero,\n QueryPreparationTimes.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n TimeSpan.zero,\n RuntimeExecutionTimes.zero,\n TimeSpan.zero,\n ClientSideMetrics.zero,\n );\n\n /**\n * Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics.\n */\n public static createFromArray(queryMetricsArray: QueryMetrics[]): QueryMetrics {\n if (!queryMetricsArray) {\n throw new Error(\"queryMetricsArray is null or undefined item(s)\");\n }\n\n return QueryMetrics.zero.add(queryMetricsArray);\n }\n\n /**\n * Returns a new instance of the QueryMetrics class this is deserialized from a delimited string.\n */\n public static createFromDelimitedString(\n delimitedString: string,\n clientSideMetrics?: ClientSideMetrics,\n ): QueryMetrics {\n const metrics = parseDelimitedString(delimitedString);\n\n const indexHitRatio = metrics[QueryMetricsConstants.IndexHitRatio] || 0;\n const retrievedDocumentCount = metrics[QueryMetricsConstants.RetrievedDocumentCount] || 0;\n const indexHitCount = indexHitRatio * retrievedDocumentCount;\n const outputDocumentCount = metrics[QueryMetricsConstants.OutputDocumentCount] || 0;\n const outputDocumentSize = metrics[QueryMetricsConstants.OutputDocumentSize] || 0;\n const retrievedDocumentSize = metrics[QueryMetricsConstants.RetrievedDocumentSize] || 0;\n const totalQueryExecutionTime = timeSpanFromMetrics(\n metrics,\n QueryMetricsConstants.TotalQueryExecutionTimeInMs,\n );\n return new QueryMetrics(\n retrievedDocumentCount,\n retrievedDocumentSize,\n outputDocumentCount,\n outputDocumentSize,\n indexHitCount,\n totalQueryExecutionTime,\n QueryPreparationTimes.createFromDelimitedString(delimitedString),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.IndexLookupTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentLoadTimeInMs),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.VMExecutionTimeInMs),\n RuntimeExecutionTimes.createFromDelimitedString(delimitedString),\n timeSpanFromMetrics(metrics, QueryMetricsConstants.DocumentWriteTimeInMs),\n clientSideMetrics || ClientSideMetrics.zero,\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common\";\nimport { QueryMetrics } from \"../queryMetrics/queryMetrics\";\n\nexport interface CosmosHeaders {\n [key: string]: any;\n}\n\n/** @hidden */\n// TODO: docs\nexport function getRequestChargeIfAny(headers: CosmosHeaders | number): number {\n if (typeof headers === \"number\") {\n return headers;\n } else if (typeof headers === \"string\") {\n return parseFloat(headers);\n }\n\n if (headers) {\n const rc = headers[Constants.HttpHeaders.RequestCharge];\n if (rc) {\n return parseFloat(rc as string);\n } else {\n return 0;\n }\n } else {\n return 0;\n }\n}\n\n/**\n * @hidden\n */\nexport function getInitialHeader(): CosmosHeaders {\n const headers: CosmosHeaders = {};\n headers[Constants.HttpHeaders.RequestCharge] = 0;\n headers[Constants.HttpHeaders.QueryMetrics] = {};\n return headers;\n}\n\n/**\n * @hidden\n */\n// TODO: The name of this method isn't very accurate to what it does\nexport function mergeHeaders(headers: CosmosHeaders, toBeMergedHeaders: CosmosHeaders): void {\n if (headers[Constants.HttpHeaders.RequestCharge] === undefined) {\n headers[Constants.HttpHeaders.RequestCharge] = 0;\n }\n\n if (headers[Constants.HttpHeaders.QueryMetrics] === undefined) {\n headers[Constants.HttpHeaders.QueryMetrics] = QueryMetrics.zero;\n }\n\n if (!toBeMergedHeaders) {\n return;\n }\n\n headers[Constants.HttpHeaders.RequestCharge] += getRequestChargeIfAny(toBeMergedHeaders);\n if (toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed]) {\n headers[Constants.HttpHeaders.IsRUPerMinuteUsed] =\n toBeMergedHeaders[Constants.HttpHeaders.IsRUPerMinuteUsed];\n }\n\n if (Constants.HttpHeaders.QueryMetrics in toBeMergedHeaders) {\n const headerQueryMetrics = headers[Constants.HttpHeaders.QueryMetrics];\n const toBeMergedHeaderQueryMetrics = toBeMergedHeaders[Constants.HttpHeaders.QueryMetrics];\n\n for (const partitionId in toBeMergedHeaderQueryMetrics) {\n if (headerQueryMetrics[partitionId]) {\n const combinedQueryMetrics = headerQueryMetrics[partitionId].add([\n toBeMergedHeaderQueryMetrics[partitionId],\n ]);\n headerQueryMetrics[partitionId] = combinedQueryMetrics;\n } else {\n headerQueryMetrics[partitionId] = toBeMergedHeaderQueryMetrics[partitionId];\n }\n }\n }\n\n if (Constants.HttpHeaders.IndexUtilization in toBeMergedHeaders) {\n headers[Constants.HttpHeaders.IndexUtilization] =\n toBeMergedHeaders[Constants.HttpHeaders.IndexUtilization];\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SingleIndexUtilizationEntity } from \"./SingleIndexUtilizationEntity\";\nimport { CompositeIndexUtilizationEntity } from \"./CompositeIndexUtilizationEntity\";\nexport class IndexUtilizationInfo {\n public static readonly Empty = new IndexUtilizationInfo([], [], [], []);\n\n constructor(\n public readonly UtilizedSingleIndexes: SingleIndexUtilizationEntity[],\n public readonly PotentialSingleIndexes: SingleIndexUtilizationEntity[],\n public readonly UtilizedCompositeIndexes: CompositeIndexUtilizationEntity[],\n public readonly PotentialCompositeIndexes: CompositeIndexUtilizationEntity[],\n ) {}\n\n public static tryCreateFromDelimitedBase64String(\n delimitedString: string,\n out: { result?: IndexUtilizationInfo },\n ): boolean {\n if (delimitedString == null) {\n out.result = IndexUtilizationInfo.Empty;\n return false;\n }\n\n return IndexUtilizationInfo.tryCreateFromDelimitedString(\n Buffer.from(delimitedString, \"base64\").toString(),\n out,\n );\n }\n\n public static tryCreateFromDelimitedString(\n delimitedString: string,\n out: { result?: IndexUtilizationInfo },\n ): boolean {\n if (delimitedString == null) {\n out.result = IndexUtilizationInfo.Empty;\n return false;\n }\n\n try {\n out.result = JSON.parse(delimitedString) || IndexUtilizationInfo.Empty;\n return true;\n } catch (error) {\n out.result = IndexUtilizationInfo.Empty;\n return false;\n }\n }\n\n public static createFromString(\n delimitedString: string,\n isBase64Encoded: boolean,\n ): IndexUtilizationInfo {\n const result: { result?: IndexUtilizationInfo } = { result: undefined };\n\n if (isBase64Encoded) {\n IndexUtilizationInfo.tryCreateFromDelimitedBase64String(delimitedString, result);\n } else {\n IndexUtilizationInfo.tryCreateFromDelimitedString(delimitedString, result);\n }\n\n return result.result ?? IndexUtilizationInfo.Empty;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport default {\n IndexUtilizationInfo: \"Index Utilization Information\",\n UtilizedSingleIndexes: \"Utilized Single Indexes\",\n PotentialSingleIndexes: \"Potential Single Indexes\",\n UtilizedCompositeIndexes: \"Utilized Composite Indexes\",\n PotentialCompositeIndexes: \"Potential Composite Indexes\",\n IndexExpression: \"Index Spec\",\n IndexImpactScore: \"Index Impact Score\",\n IndexUtilizationSeparator: \"---\",\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport Constants from \"./Constants\";\nimport { CompositeIndexUtilizationEntity } from \"./CompositeIndexUtilizationEntity\";\nimport { IndexUtilizationInfo } from \"./IndexUtilizationInfo\";\nimport { SingleIndexUtilizationEntity } from \"./SingleIndexUtilizationEntity\";\n\nexport class IndexMetricWriter {\n public writeIndexMetrics(indexUtilizationInfo: IndexUtilizationInfo): string {\n let result = \"\";\n result = this.writeBeforeIndexUtilizationInfo(result);\n result = this.writeIndexUtilizationInfo(result, indexUtilizationInfo);\n result = this.writeAfterIndexUtilizationInfo(result);\n return result;\n }\n\n protected writeBeforeIndexUtilizationInfo(result: string): string {\n result = this.appendNewlineToResult(result);\n result = this.appendHeaderToResult(result, Constants.IndexUtilizationInfo, 0);\n return result;\n }\n\n protected writeIndexUtilizationInfo(\n result: string,\n indexUtilizationInfo: IndexUtilizationInfo,\n ): string {\n result = this.appendHeaderToResult(result, Constants.UtilizedSingleIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedSingleIndexes) {\n result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n result = this.appendHeaderToResult(result, Constants.PotentialSingleIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.PotentialSingleIndexes) {\n result = this.writeSingleIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n\n result = this.appendHeaderToResult(result, Constants.UtilizedCompositeIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.UtilizedCompositeIndexes) {\n result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n\n result = this.appendHeaderToResult(result, Constants.PotentialCompositeIndexes, 1);\n\n for (const indexUtilizationEntity of indexUtilizationInfo.PotentialCompositeIndexes) {\n result = this.writeCompositeIndexUtilizationEntity(result, indexUtilizationEntity);\n }\n return result;\n }\n\n protected writeAfterIndexUtilizationInfo(result: string): string {\n return result;\n }\n\n private writeSingleIndexUtilizationEntity(\n result: string,\n indexUtilizationEntity: SingleIndexUtilizationEntity,\n ): string {\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpec}`,\n 2,\n );\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`,\n 2,\n );\n result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2);\n return result;\n }\n\n private writeCompositeIndexUtilizationEntity(\n result: string,\n indexUtilizationEntity: CompositeIndexUtilizationEntity,\n ): string {\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexExpression}: ${indexUtilizationEntity.IndexSpecs.join(\", \")}`,\n 2,\n );\n result = this.appendHeaderToResult(\n result,\n `${Constants.IndexImpactScore}: ${indexUtilizationEntity.IndexImpactScore}`,\n 2,\n );\n result = this.appendHeaderToResult(result, Constants.IndexUtilizationSeparator, 2);\n return result;\n }\n\n private appendNewlineToResult(result: string): string {\n return this.appendHeaderToResult(result, \"\", 0);\n }\n\n private appendHeaderToResult(result: string, headerTitle: string, indentLevel: number): string {\n const Indent = \" \";\n const header = `${Indent.repeat(indentLevel)}${headerTitle}\\n`;\n result += header;\n return result;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common\";\nimport { CosmosHeaders, getRequestChargeIfAny } from \"../queryExecutionContext/headerUtils\";\nimport { IndexMetricWriter, IndexUtilizationInfo } from \"../indexMetrics\";\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\n\nexport class FeedResponse {\n constructor(\n public readonly resources: TResource[],\n private readonly headers: CosmosHeaders,\n public readonly hasMoreResults: boolean,\n public readonly diagnostics: CosmosDiagnostics,\n ) {}\n\n public get continuation(): string {\n return this.continuationToken;\n }\n public get continuationToken(): string {\n return this.headers[Constants.HttpHeaders.Continuation];\n }\n public get queryMetrics(): string {\n return this.headers[Constants.HttpHeaders.QueryMetrics];\n }\n public get requestCharge(): number {\n return getRequestChargeIfAny(this.headers);\n }\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId];\n }\n public get indexMetrics(): string {\n const writer = new IndexMetricWriter();\n const indexUtilizationInfo = IndexUtilizationInfo.createFromString(\n this.headers[Constants.HttpHeaders.IndexUtilization],\n true,\n );\n return writer.writeIndexMetrics(indexUtilizationInfo);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * @hidden\n */\nexport const TimeoutErrorCode = \"TimeoutError\";\n\nexport class TimeoutError extends Error {\n public readonly code: string = TimeoutErrorCode;\n constructor(message: string = \"Timeout Error\") {\n super(message);\n this.name = TimeoutErrorCode;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ErrorResponse } from \"./ErrorResponse\";\n/**\n * @hidden\n */\nexport const RUCapPerOperationExceededErrorCode = \"OPERATION_RU_LIMIT_EXCEEDED\";\n\nexport class RUCapPerOperationExceededError extends ErrorResponse {\n readonly code: string = RUCapPerOperationExceededErrorCode;\n public fetchedResults: any[];\n constructor(\n message: string = \"Request Unit limit per Operation call exceeded\",\n fetchedResults: any[] = [],\n ) {\n super(message);\n this.code = RUCapPerOperationExceededErrorCode;\n this.body = {\n code: RUCapPerOperationExceededErrorCode,\n message,\n };\n this.fetchedResults = fetchedResults;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @hidden\n * Utility function to get currentTime in UTC milliseconds.\n * @returns\n */\n\nexport function getCurrentTimestampInMs(): number {\n return Date.now();\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ClientSideRequestStatistics,\n FailedRequestAttemptDiagnostic,\n GatewayStatistics,\n MetadataLookUpDiagnostic,\n MetadataLookUpType,\n} from \"../CosmosDiagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\n\n/**\n * @hidden\n * Internal class to hold CosmosDiagnostic aggregate information all through the lifecycle of a request.\n * This object gathers diagnostic information throughout Client operation which may span across multiple\n * Server call, retries etc.\n * Functions - recordFailedAttempt, recordMetaDataQuery, recordEndpointContactEvent are used to ingest\n * data into the context. At the end of operation, getDiagnostics() is used to\n * get final CosmosDiagnostic object.\n */\nexport class CosmosDiagnosticContext {\n private requestStartTimeUTCinMs: number;\n private failedAttempts: FailedRequestAttemptDiagnostic[] = [];\n private metadataLookups: MetadataLookUpDiagnostic[] = [];\n private gaterwayStatistics: GatewayStatistics[] = [];\n public locationEndpointsContacted: Set = new Set();\n\n public constructor() {\n this.requestStartTimeUTCinMs = getCurrentTimestampInMs();\n }\n\n public recordFailedAttempt(\n gaterwayStatistics: GatewayStatistics,\n retryAttemptNumber: number,\n ): void {\n const attempt: FailedRequestAttemptDiagnostic = {\n attemptNumber: retryAttemptNumber,\n startTimeUTCInMs: gaterwayStatistics.startTimeUTCInMs,\n durationInMs: gaterwayStatistics.durationInMs,\n statusCode: gaterwayStatistics.statusCode,\n substatusCode: gaterwayStatistics.subStatusCode,\n requestPayloadLengthInBytes: gaterwayStatistics.requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: gaterwayStatistics.responsePayloadLengthInBytes,\n activityId: gaterwayStatistics.activityId,\n operationType: gaterwayStatistics.operationType,\n resourceType: gaterwayStatistics.resourceType,\n };\n this.failedAttempts.push(attempt);\n }\n\n public recordNetworkCall(gaterwayStatistics: GatewayStatistics): void {\n this.gaterwayStatistics.push(gaterwayStatistics);\n }\n\n /**\n * Merge given DiagnosticContext to current node's DiagnosticContext, Treating GatewayRequests of\n * given DiagnosticContext, as metadata requests.\n */\n public mergeDiagnostics(\n childDiagnostics: CosmosDiagnosticContext,\n metadataType: MetadataLookUpType,\n ): void {\n // Copy Location endpoints contacted.\n childDiagnostics.locationEndpointsContacted.forEach((endpoint) =>\n this.locationEndpointsContacted.add(endpoint),\n );\n\n // Copy child nodes's GatewayStatistics to parent's metadata lookups.\n childDiagnostics.gaterwayStatistics.forEach((gateway) =>\n this.metadataLookups.push({\n activityId: gateway.activityId,\n requestPayloadLengthInBytes: gateway.requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: gateway.responsePayloadLengthInBytes,\n startTimeUTCInMs: gateway.startTimeUTCInMs,\n operationType: gateway.operationType,\n resourceType: gateway.resourceType,\n durationInMs: gateway.durationInMs,\n metaDataType: metadataType,\n }),\n );\n\n // Copy child nodes's metadata lookups to parent's metadata lookups.\n childDiagnostics.metadataLookups.forEach((lookup) => this.metadataLookups.push(lookup));\n\n // Copy child nodes's failed attempts to parent's failed attempts.\n childDiagnostics.failedAttempts.forEach((lookup) => this.failedAttempts.push(lookup));\n }\n\n public getClientSideStats(\n endTimeUTCInMs: number = getCurrentTimestampInMs(),\n ): ClientSideRequestStatistics {\n return {\n requestStartTimeUTCInMs: this.requestStartTimeUTCinMs,\n requestDurationInMs: endTimeUTCInMs - this.requestStartTimeUTCinMs,\n totalRequestPayloadLengthInBytes: this.getTotalRequestPayloadLength(),\n totalResponsePayloadLengthInBytes: this.getTotalResponsePayloadLength(),\n locationEndpointsContacted: [...this.locationEndpointsContacted.values()],\n metadataDiagnostics: {\n metadataLookups: [...this.metadataLookups],\n },\n retryDiagnostics: {\n failedAttempts: [...this.failedAttempts],\n },\n gatewayStatistics: this.gaterwayStatistics,\n };\n }\n\n public getTotalRequestPayloadLength(): number {\n let totalRequestPayloadLength = 0;\n this.gaterwayStatistics.forEach(\n (req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes),\n );\n this.metadataLookups.forEach(\n (req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes),\n );\n this.failedAttempts.forEach(\n (req) => (totalRequestPayloadLength += req.requestPayloadLengthInBytes),\n );\n return totalRequestPayloadLength;\n }\n\n public getTotalResponsePayloadLength(): number {\n let totalResponsePayloadLength = 0;\n this.gaterwayStatistics.forEach(\n (req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes),\n );\n this.metadataLookups.forEach(\n (req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes),\n );\n this.failedAttempts.forEach(\n (req) => (totalResponsePayloadLength += req.responsePayloadLengthInBytes),\n );\n return totalResponsePayloadLength;\n }\n\n public recordEndpointResolution(location: string): void {\n this.locationEndpointsContacted.add(location);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { OperationType, ResourceType } from \"./common\";\nimport { CosmosDbDiagnosticLevel } from \"./diagnostics/CosmosDbDiagnosticLevel\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { ConsistencyLevel } from \"./documents\";\n\n/**\n * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create().\n * It has three members -\n * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including -\n * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls.\n * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call.\n * - retries\n * - endpoints contacted.\n * - request, response payload stats.\n * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations\n * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation.\n *\n * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be\n * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`.\n * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments.\n * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used\n * in production environment.\n * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads.\n * Is not meant to be used in production environment.\n * 3. clientConfig - Captures information related to how client was configured during initialization.\n */\nexport class CosmosDiagnostics {\n public readonly clientSideRequestStatistics: ClientSideRequestStatistics;\n public readonly diagnosticNode: DiagnosticNode;\n public readonly clientConfig?: ClientConfigDiagnostic;\n /**\n * @internal\n */\n constructor(\n clientSideRequestStatistics: ClientSideRequestStatistics,\n diagnosticNode?: DiagnosticNode,\n clientConfig?: ClientConfigDiagnostic,\n ) {\n this.clientSideRequestStatistics = clientSideRequestStatistics;\n this.diagnosticNode = diagnosticNode;\n this.clientConfig = clientConfig;\n }\n}\n\n/**\n * This type holds information related to initialization of `CosmosClient`\n */\nexport type ClientConfigDiagnostic = {\n /**\n * End point configured during client initialization.\n */\n endpoint: string;\n /**\n * True if `resourceTokens` was supplied during client initialization.\n */\n resourceTokensConfigured: boolean;\n /**\n * True if `tokenProvider` was supplied during client initialization.\n */\n tokenProviderConfigured: boolean;\n /**\n * True if `aadCredentials` was supplied during client initialization.\n */\n aadCredentialsConfigured: boolean;\n /**\n * True if `connectionPolicy` was supplied during client initialization.\n */\n connectionPolicyConfigured: boolean;\n /**\n * `consistencyLevel` supplied during client initialization.\n */\n consistencyLevel?: keyof typeof ConsistencyLevel;\n /**\n * `defaultHeaders` supplied during client initialization.\n */\n defaultHeaders?: { [key: string]: any };\n /**\n * True if `connectionPolicy` were supplied during client initialization.\n */\n agentConfigured: boolean;\n /**\n * `userAgentSuffix` supplied during client initialization.\n */\n userAgentSuffix: string;\n /**\n * `diagnosticLevel` supplied during client initialization.\n */\n diagnosticLevel?: CosmosDbDiagnosticLevel;\n /**\n * True if `plugins` were supplied during client initialization.\n */\n pluginsConfigured: boolean;\n /**\n * SDK version\n */\n sDKVersion: string;\n};\n\n/**\n * This type contains diagnostic information regarding all metadata request to server during an CosmosDB client operation.\n */\nexport type MetadataLookUpDiagnostics = {\n metadataLookups: MetadataLookUpDiagnostic[];\n};\n\n/**\n * This type captures diagnostic information regarding retries attempt during an CosmosDB client operation.\n */\nexport type RetryDiagnostics = {\n failedAttempts: FailedRequestAttemptDiagnostic[];\n};\n\nexport type GatewayStatistics = {\n /**\n * This is the activityId for request, made to server for fetching the requested resource. (As opposed to other potential meta data requests)\n */\n activityId?: string;\n startTimeUTCInMs: number;\n durationInMs: number;\n operationType?: OperationType;\n resourceType?: ResourceType;\n statusCode?: number;\n subStatusCode?: number;\n requestCharge?: number;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n};\n\n/**\n * This type contains diagnostic information regarding a single metadata request to server.\n */\nexport interface MetadataLookUpDiagnostic {\n activityId: string;\n startTimeUTCInMs: number;\n durationInMs: number;\n operationType?: OperationType;\n resourceType?: ResourceType;\n metaDataType: MetadataLookUpType;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n}\n\n/**\n * This type captures diagnostic information regarding a failed request to server api.\n */\nexport interface FailedRequestAttemptDiagnostic {\n attemptNumber: number;\n activityId: string;\n startTimeUTCInMs: number;\n durationInMs: number;\n operationType?: OperationType;\n resourceType?: ResourceType;\n statusCode: number;\n substatusCode?: number;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n}\n\n/**\n * This is enum for Type of Metadata lookups possible.\n */\nexport enum MetadataLookUpType {\n PartitionKeyRangeLookUp = \"PARTITION_KEY_RANGE_LOOK_UP\",\n DatabaseAccountLookUp = \"DATABASE_ACCOUNT_LOOK_UP\",\n QueryPlanLookUp = \"QUERY_PLAN_LOOK_UP\",\n DatabaseLookUp = \"DATABASE_LOOK_UP\",\n ContainerLookUp = \"CONTAINER_LOOK_UP\",\n}\n\n/**\n * This is a collection type for all client side diagnostic information.\n */\nexport type ClientSideRequestStatistics = {\n /**\n * This is the UTC timestamp for start of client operation.\n */\n requestStartTimeUTCInMs: number;\n /**\n * This is the duration in milli seconds taken by client operation.\n */\n requestDurationInMs: number;\n /**\n * This is the list of Location Endpoints contacted during the client operation.\n */\n locationEndpointsContacted: string[];\n /**\n * This field captures diagnostic information for retries happened during client operation.\n */\n retryDiagnostics: RetryDiagnostics;\n /**\n * This field captures diagnostic information for meta data lookups happened during client operation.\n */\n metadataDiagnostics: MetadataLookUpDiagnostics;\n /**\n * These are the statistics for main point look operation.\n */\n gatewayStatistics: GatewayStatistics[];\n /**\n * This is the cumulated Request Payload Length n bytes, this includes metadata calls along with the main operation.\n */\n totalRequestPayloadLengthInBytes: number;\n /**\n * This is the cumulated Response Payload Length n bytes, this includes metadata calls along with the main operation.\n */\n totalResponsePayloadLengthInBytes: number;\n};\n\nexport function getRootNode(node: DiagnosticNodeInternal): DiagnosticNodeInternal {\n if (node.parent) return getRootNode(node.parent);\n else return node;\n}\n\n/**\n * Represents a tree like structure, for capturing diagnostic information.\n */\nexport interface DiagnosticNode {\n id: string;\n nodeType: string;\n children: DiagnosticNode[];\n data: { [key: string]: any };\n startTimeUTCInMs: number;\n durationInMs: number;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Cosmos DB Diagnostic Level\n */\nexport enum CosmosDbDiagnosticLevel {\n info = \"info\",\n debug = \"debug\",\n debugUnsafe = \"debug-unsafe\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDbDiagnosticLevel } from \"./CosmosDbDiagnosticLevel\";\n\n/**\n * @hidden\n */\nexport const CosmosDbDiagnosticLevelOrder = [\n CosmosDbDiagnosticLevel.info,\n CosmosDbDiagnosticLevel.debug,\n CosmosDbDiagnosticLevel.debugUnsafe,\n];\n\n/**\n * @hidden\n */\nexport function allowTracing(\n levelToCheck: CosmosDbDiagnosticLevel,\n clientDiagnosticLevel: CosmosDbDiagnosticLevel,\n): boolean {\n const indexOfDiagnosticLevelToCheck = CosmosDbDiagnosticLevelOrder.indexOf(levelToCheck);\n const indexOfClientDiagnosticLevel = CosmosDbDiagnosticLevelOrder.indexOf(clientDiagnosticLevel);\n if (indexOfDiagnosticLevelToCheck === -1 || indexOfClientDiagnosticLevel === -1) {\n return false;\n }\n return indexOfDiagnosticLevelToCheck <= indexOfClientDiagnosticLevel;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDiagnosticContext } from \"./CosmosDiagnosticsContext\";\nimport { RequestContext } from \"../request\";\nimport { v4 } from \"uuid\";\nimport {\n DiagnosticNode,\n MetadataLookUpType,\n CosmosDiagnostics,\n getRootNode,\n ClientConfigDiagnostic,\n} from \"../CosmosDiagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\nimport { CosmosDbDiagnosticLevel } from \"./CosmosDbDiagnosticLevel\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { HttpHeaders, PipelineResponse } from \"@azure/core-rest-pipeline\";\nimport { Constants, OperationType, ResourceType, prepareURL } from \"../common\";\nimport { allowTracing } from \"./diagnosticLevelComparator\";\n\n/**\n * @hidden\n * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect\n * diagnostic information throughout the lifetime of Diagnostic session.\n * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart.\n */\nexport class DiagnosticNodeInternal implements DiagnosticNode {\n public id: string;\n public nodeType: DiagnosticNodeType;\n public parent: DiagnosticNodeInternal;\n public children: DiagnosticNodeInternal[];\n public data: Partial;\n public startTimeUTCInMs: number;\n public durationInMs: number;\n public diagnosticLevel: CosmosDbDiagnosticLevel;\n private diagnosticCtx: CosmosDiagnosticContext;\n\n /**\n * @internal\n */\n constructor(\n diagnosticLevel: CosmosDbDiagnosticLevel,\n type: DiagnosticNodeType,\n parent: DiagnosticNodeInternal,\n data: Partial = {},\n startTimeUTCInMs: number = getCurrentTimestampInMs(),\n ctx: CosmosDiagnosticContext = new CosmosDiagnosticContext(),\n ) {\n this.id = v4();\n this.nodeType = type;\n this.startTimeUTCInMs = startTimeUTCInMs;\n this.data = data;\n this.children = [];\n this.durationInMs = 0;\n this.parent = parent;\n this.diagnosticCtx = ctx;\n this.diagnosticLevel = diagnosticLevel;\n }\n\n /**\n * @internal\n */\n private addLog(msg: string): void {\n if (!this.data.log) {\n this.data.log = [];\n }\n this.data.log.push(msg);\n }\n\n /**\n * @internal\n */\n private sanitizeHeaders(headers?: CosmosHeaders | HttpHeaders): CosmosHeaders | HttpHeaders {\n return headers;\n }\n\n /**\n * Updated durationInMs for node, based on endTimeUTCInMs provided.\n * @internal\n */\n public updateTimestamp(endTimeUTCInMs: number = getCurrentTimestampInMs()): void {\n this.durationInMs = endTimeUTCInMs - this.startTimeUTCInMs;\n }\n\n /**\n * @internal\n */\n public recordSuccessfulNetworkCall(\n startTimeUTCInMs: number,\n requestContext: RequestContext,\n pipelineResponse: PipelineResponse,\n substatus: number,\n url: string,\n ): void {\n const responseHeaders = pipelineResponse.headers.toJSON();\n const gatewayRequest = {\n activityId: responseHeaders[Constants.HttpHeaders.ActivityId],\n startTimeUTCInMs,\n durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs,\n statusCode: pipelineResponse.status,\n subStatusCode: substatus,\n requestPayloadLengthInBytes: calculateRequestPayloadLength(requestContext),\n responsePayloadLengthInBytes: calculateResponsePayloadLength(pipelineResponse),\n operationType: requestContext.operationType,\n resourceType: requestContext.resourceType,\n partitionKeyRangeId: requestContext.partitionKeyRangeId,\n };\n let requestData: any = {\n OperationType: gatewayRequest.operationType,\n resourceType: gatewayRequest.resourceType,\n requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes,\n };\n\n if (allowTracing(CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) {\n requestData = {\n ...requestData,\n headers: this.sanitizeHeaders(requestContext.headers),\n requestBody: requestContext.body,\n responseBody: pipelineResponse.bodyAsText,\n url: url,\n };\n }\n this.addData({\n requestPayloadLengthInBytes: gatewayRequest.requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: gatewayRequest.responsePayloadLengthInBytes,\n startTimeUTCInMs: gatewayRequest.startTimeUTCInMs,\n durationInMs: gatewayRequest.durationInMs,\n requestData,\n });\n this.diagnosticCtx.recordNetworkCall(gatewayRequest);\n }\n\n /**\n * @internal\n */\n public recordFailedNetworkCall(\n startTimeUTCInMs: number,\n requestContext: RequestContext,\n retryAttemptNumber: number,\n statusCode: number,\n substatusCode: number,\n responseHeaders: CosmosHeaders,\n ): void {\n this.addData({ failedAttempty: true });\n const requestPayloadLengthInBytes = calculateRequestPayloadLength(requestContext);\n this.diagnosticCtx.recordFailedAttempt(\n {\n activityId: responseHeaders[Constants.HttpHeaders.ActivityId] as string,\n startTimeUTCInMs,\n durationInMs: getCurrentTimestampInMs() - startTimeUTCInMs,\n statusCode,\n subStatusCode: substatusCode,\n requestPayloadLengthInBytes,\n responsePayloadLengthInBytes: 0,\n operationType: requestContext.operationType,\n resourceType: requestContext.resourceType,\n },\n retryAttemptNumber,\n );\n let requestData: any = {\n OperationType: requestContext.operationType,\n resourceType: requestContext.resourceType,\n requestPayloadLengthInBytes,\n };\n if (allowTracing(CosmosDbDiagnosticLevel.debugUnsafe, this.diagnosticLevel)) {\n requestData = {\n ...requestData,\n headers: this.sanitizeHeaders(requestContext.headers),\n requestBody: requestContext.body,\n url: prepareURL(requestContext.endpoint, requestContext.path),\n };\n }\n this.addData({\n failedAttempty: true,\n requestData,\n });\n }\n\n /**\n * @internal\n */\n public recordEndpointResolution(location: string): void {\n this.addData({ selectedLocation: location });\n this.diagnosticCtx.recordEndpointResolution(location);\n }\n\n /**\n * @internal\n */\n public addData(\n data: Partial,\n msg?: string,\n level: CosmosDbDiagnosticLevel = this.diagnosticLevel,\n ): void {\n if (level !== CosmosDbDiagnosticLevel.info) {\n this.data = { ...this.data, ...data };\n if (msg) {\n this.addLog(msg);\n }\n }\n }\n\n /**\n * Merge given DiagnosticNodeInternal's context to current node's DiagnosticContext, Treating GatewayRequests of\n * given DiagnosticContext, as metadata requests. Given DiagnosticNodeInternal becomes a child of this node.\n * @internal\n */\n public addChildNode(\n child: DiagnosticNodeInternal,\n level: CosmosDbDiagnosticLevel,\n metadataType?: MetadataLookUpType,\n ): DiagnosticNodeInternal {\n this.diagnosticCtx.mergeDiagnostics(child.diagnosticCtx, metadataType);\n if (allowTracing(level, this.diagnosticLevel)) {\n child.parent = this;\n this.children.push(child);\n }\n return child;\n }\n\n /**\n * @internal\n */\n public initializeChildNode(\n type: DiagnosticNodeType,\n level: CosmosDbDiagnosticLevel,\n data: Partial = {},\n ): DiagnosticNodeInternal {\n if (allowTracing(level, this.diagnosticLevel)) {\n const child = new DiagnosticNodeInternal(\n this.diagnosticLevel,\n type,\n this,\n data,\n getCurrentTimestampInMs(),\n this.diagnosticCtx,\n );\n this.children.push(child);\n return child;\n } else {\n return this;\n }\n }\n\n /**\n * @internal\n */\n public recordQueryResult(resources: unknown, level: CosmosDbDiagnosticLevel): void {\n if (allowTracing(level, this.diagnosticLevel)) {\n const previousCount = this.data.queryRecordsRead ?? 0;\n if (Array.isArray(resources)) {\n this.data.queryRecordsRead = previousCount + resources.length;\n }\n }\n }\n\n /**\n * Convert DiagnosticNodeInternal (internal representation) to DiagnosticNode (public, sanitized representation)\n * @internal\n */\n public toDiagnosticNode(): DiagnosticNode {\n return {\n id: this.id,\n nodeType: this.nodeType,\n children: this.children.map((child) => child.toDiagnosticNode()),\n data: this.data,\n startTimeUTCInMs: this.startTimeUTCInMs,\n durationInMs: this.durationInMs,\n };\n }\n\n /**\n * Convert to CosmosDiagnostics\n * @internal\n */\n public toDiagnostic(clientConfigDiagnostic: ClientConfigDiagnostic): CosmosDiagnostics {\n const rootNode = getRootNode(this);\n const diagnostiNode = allowTracing(CosmosDbDiagnosticLevel.debug, this.diagnosticLevel)\n ? rootNode.toDiagnosticNode()\n : undefined;\n const clientConfig = allowTracing(CosmosDbDiagnosticLevel.debug, this.diagnosticLevel)\n ? clientConfigDiagnostic\n : undefined;\n const cosmosDiagnostic = new CosmosDiagnostics(\n this.diagnosticCtx.getClientSideStats(),\n diagnostiNode,\n clientConfig,\n );\n return cosmosDiagnostic;\n }\n}\n\n/**\n * @hidden\n */\nexport type DiagnosticDataValue = {\n selectedLocation: string;\n activityId: string;\n requestAttempNumber: number;\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n responseStatus: number;\n readFromCache: boolean;\n operationType: OperationType;\n metadatOperationType: MetadataLookUpType;\n resourceType: ResourceType;\n failedAttempty: boolean;\n successfulRetryPolicy: string;\n partitionKeyRangeId: string;\n stateful: boolean;\n queryRecordsRead: number;\n queryMethodIdentifier: string;\n log: string[];\n failure: boolean;\n startTimeUTCInMs: number;\n durationInMs: number;\n requestData: Partial<{\n requestPayloadLengthInBytes: number;\n responsePayloadLengthInBytes: number;\n operationType: OperationType;\n resourceType: ResourceType;\n headers: CosmosHeaders;\n requestBody: any;\n responseBody: any;\n url: string;\n }>;\n};\n\n/**\n * @hidden\n */\nexport enum DiagnosticNodeType {\n CLIENT_REQUEST_NODE = \"CLIENT_REQUEST_NODE\", // Top most node representing client operations.\n METADATA_REQUEST_NODE = \"METADATA_REQUEST_NODE\", // Node representing a metadata request.\n HTTP_REQUEST = \"HTTP_REQUEST\", // Node representing REST call to backend services.\n BATCH_REQUEST = \"BATCH_REQUEST\", // Node representing batch request.\n PARALLEL_QUERY_NODE = \"PARALLEL_QUERY_NODE\", // Node representing parallel query execution.\n DEFAULT_QUERY_NODE = \"DEFAULT_QUERY_NODE\", // Node representing default query execution.\n QUERY_REPAIR_NODE = \"QUERY_REPAIR_NODE\", // Node representing query repair.\n BACKGROUND_REFRESH_THREAD = \"BACKGROUND_REFRESH_THREAD\", // Node representing background refresh.\n REQUEST_ATTEMPTS = \"REQUEST_ATTEMPTS\", // Node representing request attempts.\n}\n\nfunction calculateResponsePayloadLength(response: PipelineResponse) {\n return response?.bodyAsText?.length || 0;\n}\n\nfunction calculateRequestPayloadLength(requestContext: RequestContext) {\n return requestContext.body ? requestContext.body.length : 0;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDiagnostics, MetadataLookUpType } from \"../CosmosDiagnostics\";\nimport {\n DiagnosticDataValue,\n DiagnosticNodeInternal,\n DiagnosticNodeType,\n} from \"../diagnostics/DiagnosticNodeInternal\";\nimport { ClientContext } from \"../ClientContext\";\nimport { getCurrentTimestampInMs } from \"./time\";\nimport { v4 } from \"uuid\";\nimport { CosmosDbDiagnosticLevel } from \"../diagnostics/CosmosDbDiagnosticLevel\";\n\n/**\n * @hidden\n * Utility function to create an Empty CosmosDiagnostic object.\n */\nexport function getEmptyCosmosDiagnostics(): CosmosDiagnostics {\n return new CosmosDiagnostics(\n {\n requestDurationInMs: 0,\n requestStartTimeUTCInMs: getCurrentTimestampInMs(),\n totalRequestPayloadLengthInBytes: 0,\n totalResponsePayloadLengthInBytes: 0,\n locationEndpointsContacted: [],\n retryDiagnostics: {\n failedAttempts: [],\n },\n metadataDiagnostics: {\n metadataLookups: [],\n },\n gatewayStatistics: [],\n },\n {\n id: v4(),\n nodeType: DiagnosticNodeType.CLIENT_REQUEST_NODE,\n children: [],\n data: {},\n startTimeUTCInMs: getCurrentTimestampInMs(),\n durationInMs: 0,\n },\n );\n}\n\n/**\n * @hidden\n */\nexport type ExtractPromise = T extends Promise ? U : never;\n\n/**\n * A supporting utility wrapper function, to be used inside a diagnostic session started\n * by `withDiagnostics` function.\n * Created a Diagnostic node and add it as a child to existing diagnostic session.\n * @hidden\n */\nexport async function addDignosticChild<\n Callback extends (node: DiagnosticNodeInternal) => Promise,\n>(\n callback: Callback,\n node: DiagnosticNodeInternal,\n type: DiagnosticNodeType,\n data: Partial = {},\n): Promise>> {\n const childNode = node.initializeChildNode(type, CosmosDbDiagnosticLevel.debug, data);\n try {\n const response = await callback(childNode);\n childNode.updateTimestamp();\n return response;\n } catch (e: any) {\n childNode.addData({\n failure: true,\n });\n childNode.updateTimestamp();\n throw e;\n }\n}\n\n/**\n * A supporting utility wrapper function, to be used inside a diagnostic session started\n * by `withDiagnostics` function.\n * Treats requests originating in provided `callback` as metadata calls.\n * To realize this, starts a temporary diagnostic session, after execution of callback is\n * finished. Merges this temporary diagnostic session to the original diagnostic session\n * represented by the input parameter `node`.\n * @hidden\n */\nexport async function withMetadataDiagnostics<\n Callback extends (node: DiagnosticNodeInternal) => Promise,\n>(\n callback: Callback,\n node: DiagnosticNodeInternal,\n type: MetadataLookUpType,\n): Promise>> {\n const diagnosticNodeForMetadataCall = new DiagnosticNodeInternal(\n node.diagnosticLevel,\n DiagnosticNodeType.METADATA_REQUEST_NODE,\n null,\n );\n try {\n const response: any = await callback(diagnosticNodeForMetadataCall);\n node.addChildNode(diagnosticNodeForMetadataCall, CosmosDbDiagnosticLevel.debug, type);\n return response;\n } catch (e) {\n node.addChildNode(diagnosticNodeForMetadataCall, CosmosDbDiagnosticLevel.debug, type);\n throw e;\n }\n}\n\n/**\n * Utility wrapper function to managed lifecycle of a Diagnostic session.\n * Meant to be used at the root of the client operation. i.e. item.read(),\n * queryIterator.fetchAll().\n *\n * This utility starts a new diagnostic session. So using it any where else\n * other than start of operation, will result is different diagnostic sessions.\n *\n * Workings :\n * 1. Takes a callback function as input.\n * 2. Creates a new instance of DiagnosticNodeInternal, which can be though as starting\n * a new diagnostic session.\n * 3. Executes the callback function.\n * 4. If execution was successful. Converts DiagnosticNodeInternal to CosmosDiagnostics\n * and injects it to the response object and returns this object.\n * 5. If execution threw an exception. Sill converts DiagnosticNodeInternal to CosmosDiagnostics\n * and injects it to the Error object, and rethrows the Error object.\n *\n * @hidden\n */\nexport async function withDiagnostics<\n Callback extends (node: DiagnosticNodeInternal) => Promise,\n>(\n callback: Callback,\n clientContext: ClientContext,\n type: DiagnosticNodeType = DiagnosticNodeType.CLIENT_REQUEST_NODE,\n): Promise>> {\n const diagnosticNode = new DiagnosticNodeInternal(clientContext.diagnosticLevel, type, null);\n try {\n const response: any = await callback(diagnosticNode);\n diagnosticNode.updateTimestamp();\n const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig());\n if (typeof response === \"object\" && response !== null) {\n (response as any).diagnostics = diagnostics;\n }\n clientContext.recordDiagnostics(diagnostics);\n return response;\n } catch (e: any) {\n diagnosticNode.updateTimestamp();\n diagnosticNode.addData({\n failure: true,\n });\n const diagnostics = diagnosticNode.toDiagnostic(clientContext.getClientConfig());\n e.diagnostics = diagnostics;\n clientContext.recordDiagnostics(diagnostics);\n throw e;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { Constants, RUConsumedManager } from \"../common\";\nimport { ClientSideMetrics, QueryMetrics } from \"../queryMetrics\";\nimport { FeedOptions, QueryOperationOptions, Response } from \"../request\";\nimport { getInitialHeader, getRequestChargeIfAny } from \"./headerUtils\";\nimport { ExecutionContext } from \"./index\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { CosmosDbDiagnosticLevel } from \"../diagnostics/CosmosDbDiagnosticLevel\";\nimport { RUCapPerOperationExceededError } from \"../request/RUCapPerOperationExceededError\";\n\nconst logger: AzureLogger = createClientLogger(\"ClientContext\");\n/** @hidden */\nexport type FetchFunctionCallback = (\n diagnosticNode: DiagnosticNodeInternal,\n options: FeedOptions,\n) => Promise>;\n\n/** @hidden */\nenum STATES {\n start = \"start\",\n inProgress = \"inProgress\",\n ended = \"ended\",\n}\n\n/** @hidden */\nexport class DefaultQueryExecutionContext implements ExecutionContext {\n private static readonly STATES = STATES;\n private resources: any[]; // TODO: any resources\n private currentIndex: number;\n private currentPartitionIndex: number;\n private fetchFunctions: FetchFunctionCallback[];\n private options: FeedOptions; // TODO: any options\n public continuationToken: string; // TODO: any continuation\n public get continuation(): string {\n return this.continuationToken;\n }\n private state: STATES;\n private nextFetchFunction: Promise>;\n /**\n * Provides the basic Query Execution Context.\n * This wraps the internal logic query execution using provided fetch functions\n *\n * @param clientContext - Is used to read the partitionKeyRanges for split proofing\n * @param query - A SQL query.\n * @param options - Represents the feed options.\n * @param fetchFunctions - A function to retrieve each page of data.\n * An array of functions may be used to query more than one partition.\n * @hidden\n */\n constructor(\n options: FeedOptions,\n fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[],\n ) {\n this.resources = [];\n this.currentIndex = 0;\n this.currentPartitionIndex = 0;\n this.fetchFunctions = Array.isArray(fetchFunctions) ? fetchFunctions : [fetchFunctions];\n this.options = options || {};\n this.continuationToken = this.options.continuationToken || this.options.continuation || null;\n this.state = DefaultQueryExecutionContext.STATES.start;\n }\n\n /**\n * Execute a provided callback on the next element in the execution context.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n ++this.currentIndex;\n const response = await this.current(diagnosticNode, operationOptions, ruConsumedManager);\n return response;\n }\n\n /**\n * Retrieve the current element on the execution context.\n */\n public async current(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.currentIndex < this.resources.length) {\n return {\n result: this.resources[this.currentIndex],\n headers: getInitialHeader(),\n };\n }\n if (this._canFetchMore()) {\n const { result: resources, headers } = await this.fetchMore(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.resources = resources;\n if (this.resources.length === 0) {\n if (!this.continuationToken && this.currentPartitionIndex >= this.fetchFunctions.length) {\n this.state = DefaultQueryExecutionContext.STATES.ended;\n return { result: undefined, headers };\n } else {\n return this.current(diagnosticNode, operationOptions, ruConsumedManager);\n }\n }\n return { result: this.resources[this.currentIndex], headers };\n } else {\n this.state = DefaultQueryExecutionContext.STATES.ended;\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n }\n\n /**\n * Determine if there are still remaining resources to processs based on\n * the value of the continuation token or the elements remaining on the current batch in the execution context.\n *\n * @returns true if there is other elements to process in the DefaultQueryExecutionContext.\n */\n public hasMoreResults(): boolean {\n return (\n this.state === DefaultQueryExecutionContext.STATES.start ||\n this.continuationToken !== undefined ||\n this.currentIndex < this.resources.length - 1 ||\n this.currentPartitionIndex < this.fetchFunctions.length\n );\n }\n\n /**\n * Fetches the next batch of the feed and pass them as an array to a callback\n */\n public async fetchMore(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n return addDignosticChild(\n async (childDiagnosticNode: DiagnosticNodeInternal) => {\n if (this.currentPartitionIndex >= this.fetchFunctions.length) {\n return {\n headers: getInitialHeader(),\n result: undefined,\n };\n }\n\n // Keep to the original continuation and to restore the value after fetchFunction call\n const originalContinuation = this.options.continuationToken || this.options.continuation;\n this.options.continuationToken = this.continuationToken;\n\n // Return undefined if there is no more results\n if (this.currentPartitionIndex >= this.fetchFunctions.length) {\n return {\n headers: getInitialHeader(),\n result: undefined,\n };\n }\n\n let resources;\n let responseHeaders;\n try {\n let p: Promise>;\n if (this.nextFetchFunction !== undefined) {\n logger.verbose(\"using prefetch\");\n p = this.nextFetchFunction;\n this.nextFetchFunction = undefined;\n } else {\n logger.verbose(\"using fresh fetch\");\n p = this.fetchFunctions[this.currentPartitionIndex](childDiagnosticNode, this.options);\n }\n const response = await p;\n resources = response.result;\n childDiagnosticNode.recordQueryResult(resources, CosmosDbDiagnosticLevel.debugUnsafe);\n responseHeaders = response.headers;\n this.continuationToken = responseHeaders[Constants.HttpHeaders.Continuation];\n if (!this.continuationToken) {\n ++this.currentPartitionIndex;\n }\n\n if (this.options && this.options.bufferItems === true) {\n const fetchFunction = this.fetchFunctions[this.currentPartitionIndex];\n this.nextFetchFunction = fetchFunction\n ? fetchFunction(childDiagnosticNode, {\n ...this.options,\n continuationToken: this.continuationToken,\n })\n : undefined;\n }\n } catch (err: any) {\n this.state = DefaultQueryExecutionContext.STATES.ended;\n // return callback(err, undefined, responseHeaders);\n // TODO: Error and data being returned is an antipattern, this might broken\n throw err;\n }\n\n this.state = DefaultQueryExecutionContext.STATES.inProgress;\n this.currentIndex = 0;\n this.options.continuationToken = originalContinuation;\n this.options.continuation = originalContinuation;\n\n // deserializing query metrics so that we aren't working with delimited strings in the rest of the code base\n if (Constants.HttpHeaders.QueryMetrics in responseHeaders) {\n const delimitedString = responseHeaders[Constants.HttpHeaders.QueryMetrics];\n let queryMetrics = QueryMetrics.createFromDelimitedString(delimitedString);\n\n // Add the request charge to the query metrics so that we can have per partition request charge.\n if (Constants.HttpHeaders.RequestCharge in responseHeaders) {\n const requestCharge = Number(responseHeaders[Constants.HttpHeaders.RequestCharge]) || 0;\n queryMetrics = new QueryMetrics(\n queryMetrics.retrievedDocumentCount,\n queryMetrics.retrievedDocumentSize,\n queryMetrics.outputDocumentCount,\n queryMetrics.outputDocumentSize,\n queryMetrics.indexHitDocumentCount,\n queryMetrics.totalQueryExecutionTime,\n queryMetrics.queryPreparationTimes,\n queryMetrics.indexLookupTime,\n queryMetrics.documentLoadTime,\n queryMetrics.vmExecutionTime,\n queryMetrics.runtimeExecutionTimes,\n queryMetrics.documentWriteTime,\n new ClientSideMetrics(requestCharge),\n );\n }\n\n // Wraping query metrics in a object where the key is '0' just so single partition\n // and partition queries have the same response schema\n responseHeaders[Constants.HttpHeaders.QueryMetrics] = {};\n responseHeaders[Constants.HttpHeaders.QueryMetrics][\"0\"] = queryMetrics;\n }\n\n if (operationOptions && operationOptions.ruCapPerOperation && ruConsumedManager) {\n await ruConsumedManager.addToRUConsumed(getRequestChargeIfAny(responseHeaders));\n const ruConsumedValue = await ruConsumedManager.getRUConsumed();\n if (ruConsumedValue > operationOptions.ruCapPerOperation) {\n // For RUCapPerOperationExceededError error, we won't be updating the state from\n // inProgress as we want to support continue\n throw new RUCapPerOperationExceededError(\n \"Request Unit limit per Operation call exceeded\",\n resources,\n );\n }\n }\n return { result: resources, headers: responseHeaders };\n },\n diagnosticNode,\n DiagnosticNodeType.DEFAULT_QUERY_NODE,\n {\n queryMethodIdentifier: \"fetchMore\",\n },\n );\n }\n\n private _canFetchMore(): boolean {\n const res =\n this.state === DefaultQueryExecutionContext.STATES.start ||\n (this.continuationToken && this.state === DefaultQueryExecutionContext.STATES.inProgress) ||\n (this.currentPartitionIndex < this.fetchFunctions.length &&\n this.state === DefaultQueryExecutionContext.STATES.inProgress);\n return res;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DocumentProducer } from \"./documentProducer\";\n\n// TODO: this smells funny\n/** @hidden */\nconst TYPEORDCOMPARATOR: {\n [type: string]: { ord: number; compFunc?: (a: any, b: any) => number };\n} = Object.freeze({\n NoValue: {\n ord: 0,\n },\n undefined: {\n ord: 1,\n },\n boolean: {\n ord: 2,\n compFunc: (a: boolean, b: boolean) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n number: {\n ord: 4,\n compFunc: (a: number, b: number) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n string: {\n ord: 5,\n compFunc: (a: string, b: string) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n});\n\n/** @hidden */\nexport class OrderByDocumentProducerComparator {\n constructor(public sortOrder: string[]) {} // TODO: This should be an enum\n\n private targetPartitionKeyRangeDocProdComparator(\n docProd1: DocumentProducer,\n docProd2: DocumentProducer,\n ): 0 | 1 | -1 {\n const a = docProd1.getTargetParitionKeyRange()[\"minInclusive\"];\n const b = docProd2.getTargetParitionKeyRange()[\"minInclusive\"];\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n public compare(docProd1: DocumentProducer, docProd2: DocumentProducer): number {\n // Need to check for split, since we don't want to dereference \"item\" of undefined / exception\n if (docProd1.gotSplit()) {\n return -1;\n }\n if (docProd2.gotSplit()) {\n return 1;\n }\n\n const orderByItemsRes1 = this.getOrderByItems(docProd1.peekBufferedItems()[0]);\n const orderByItemsRes2 = this.getOrderByItems(docProd2.peekBufferedItems()[0]);\n\n // validate order by items and types\n // TODO: once V1 order by on different types is fixed this need to change\n this.validateOrderByItems(orderByItemsRes1, orderByItemsRes2);\n\n // no async call in the for loop\n for (let i = 0; i < orderByItemsRes1.length; i++) {\n // compares the orderby items one by one\n const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]);\n if (compRes !== 0) {\n if (this.sortOrder[i] === \"Ascending\") {\n return compRes;\n } else if (this.sortOrder[i] === \"Descending\") {\n return -compRes;\n }\n }\n }\n\n return this.targetPartitionKeyRangeDocProdComparator(docProd1, docProd2);\n }\n\n // TODO: This smells funny\n public compareValue(item1: unknown, type1: string, item2: unknown, type2: string): number {\n if (type1 === \"object\" || type2 === \"object\") {\n throw new Error(\"Tried to compare an object type\");\n }\n const type1Ord = TYPEORDCOMPARATOR[type1].ord;\n const type2Ord = TYPEORDCOMPARATOR[type2].ord;\n const typeCmp = type1Ord - type2Ord;\n\n if (typeCmp !== 0) {\n // if the types are different, use type ordinal\n return typeCmp;\n }\n\n // both are of the same type\n if (\n type1Ord === TYPEORDCOMPARATOR[\"undefined\"].ord ||\n type1Ord === TYPEORDCOMPARATOR[\"NoValue\"].ord\n ) {\n // if both types are undefined or Null they are equal\n return 0;\n }\n\n const compFunc = TYPEORDCOMPARATOR[type1].compFunc;\n if (typeof compFunc === \"undefined\") {\n throw new Error(\"Cannot find the comparison function\");\n }\n // same type and type is defined compare the items\n return compFunc(item1, item2);\n }\n\n private compareOrderByItem(orderByItem1: any, orderByItem2: any): number {\n const type1 = this.getType(orderByItem1);\n const type2 = this.getType(orderByItem2);\n return this.compareValue(orderByItem1[\"item\"], type1, orderByItem2[\"item\"], type2);\n }\n\n private validateOrderByItems(res1: string[], res2: string[]): void {\n if (res1.length !== res2.length) {\n throw new Error(`Expected ${res1.length}, but got ${res2.length}.`);\n }\n if (res1.length !== this.sortOrder.length) {\n throw new Error(\"orderByItems cannot have a different size than sort orders.\");\n }\n\n for (let i = 0; i < this.sortOrder.length; i++) {\n const type1 = this.getType(res1[i]);\n const type2 = this.getType(res2[i]);\n if (type1 !== type2) {\n throw new Error(\n `Expected ${type1}, but got ${type2}. Cannot execute cross partition order-by queries on mixed types. Consider filtering your query using IS_STRING or IS_NUMBER to get around this exception.`,\n );\n }\n }\n }\n\n private getType(\n orderByItem: any,\n ):\n | \"string\"\n | \"number\"\n | \"bigint\"\n | \"boolean\"\n | \"symbol\"\n | \"undefined\"\n | \"object\"\n | \"function\"\n | \"NoValue\" {\n // TODO: any item?\n if (orderByItem === undefined || orderByItem.item === undefined) {\n return \"NoValue\";\n }\n const type = typeof orderByItem.item;\n if (TYPEORDCOMPARATOR[type] === undefined) {\n throw new Error(`unrecognizable type ${type}`);\n }\n return type;\n }\n\n private getOrderByItems(res: any): any {\n // TODO: any res?\n return res[\"orderByItems\"];\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator\";\nimport { Aggregator } from \"./Aggregator\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OrderByDocumentProducerComparator } from \"../orderByDocumentProducerComparator\";\nimport { Aggregator } from \"./Aggregator\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Aggregator } from \"./Aggregator\";\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","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AverageAggregator } from \"./AverageAggregator\";\nimport { CountAggregator } from \"./CountAggregator\";\nimport { MaxAggregator } from \"./MaxAggregator\";\nimport { MinAggregator } from \"./MinAggregator\";\nimport { SumAggregator } from \"./SumAggregator\";\nimport { StaticValueAggregator } from \"./StaticValueAggregator\";\nimport { AggregateType } from \"../../request/ErrorResponse\";\n\nexport function createAggregator(\n aggregateType: AggregateType,\n):\n | AverageAggregator\n | CountAggregator\n | MaxAggregator\n | MinAggregator\n | SumAggregator\n | StaticValueAggregator {\n switch (aggregateType) {\n case \"Average\":\n return new AverageAggregator();\n case \"Count\":\n return new CountAggregator();\n case \"Max\":\n return new MaxAggregator();\n case \"Min\":\n return new MinAggregator();\n case \"Sum\":\n return new SumAggregator();\n default:\n return new StaticValueAggregator();\n }\n}\n\nexport { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator };\nexport { Aggregator } from \"./Aggregator\";\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/** @hidden */\nexport enum FetchResultType {\n \"Done\" = 0,\n \"Exception\" = 1,\n \"Result\" = 2,\n}\n\n/** @hidden */\nexport class FetchResult {\n public feedResponse: any;\n public fetchResultType: FetchResultType;\n public error: any;\n /**\n * Wraps fetch results for the document producer.\n * This allows the document producer to buffer exceptions so that actual results don't get flushed during splits.\n *\n * @param feedReponse - The response the document producer got back on a successful fetch\n * @param error - The exception meant to be buffered on an unsuccessful fetch\n * @hidden\n */\n constructor(feedResponse: unknown, error: unknown) {\n // TODO: feedResponse/error\n if (feedResponse !== undefined) {\n this.feedResponse = feedResponse;\n this.fetchResultType = FetchResultType.Result;\n } else {\n this.error = error;\n this.fetchResultType = FetchResultType.Exception;\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKeyRange, Resource } from \"../client\";\nimport { ClientContext } from \"../ClientContext\";\nimport {\n Constants,\n getIdFromLink,\n getPathFromLink,\n ResourceType,\n StatusCodes,\n SubStatusCodes,\n RUConsumedManager,\n} from \"../common\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { FeedOptions, QueryOperationOptions } from \"../request\";\nimport { Response } from \"../request\";\nimport { DefaultQueryExecutionContext } from \"./defaultQueryExecutionContext\";\nimport { FetchResult, FetchResultType } from \"./FetchResult\";\nimport { CosmosHeaders, getInitialHeader, mergeHeaders } from \"./headerUtils\";\nimport { SqlQuerySpec } from \"./index\";\n\n/** @hidden */\nexport class DocumentProducer {\n private collectionLink: string;\n private query: string | SqlQuerySpec;\n public targetPartitionKeyRange: PartitionKeyRange;\n public fetchResults: FetchResult[];\n public allFetched: boolean;\n private err: Error;\n public previousContinuationToken: string;\n public continuationToken: string;\n public generation: number = 0;\n private respHeaders: CosmosHeaders;\n private internalExecutionContext: DefaultQueryExecutionContext;\n\n /**\n * Provides the Target Partition Range Query Execution Context.\n * @param clientContext - The service endpoint to use to create the client.\n * @param collectionLink - Represents collection link\n * @param query - A SQL query.\n * @param targetPartitionKeyRange - Query Target Partition key Range\n * @hidden\n */\n constructor(\n private clientContext: ClientContext,\n collectionLink: string,\n query: SqlQuerySpec,\n targetPartitionKeyRange: PartitionKeyRange,\n options: FeedOptions,\n ) {\n // TODO: any options\n this.collectionLink = collectionLink;\n this.query = query;\n this.targetPartitionKeyRange = targetPartitionKeyRange;\n this.fetchResults = [];\n\n this.allFetched = false;\n this.err = undefined;\n\n this.previousContinuationToken = undefined;\n this.continuationToken = undefined;\n this.respHeaders = getInitialHeader();\n\n this.internalExecutionContext = new DefaultQueryExecutionContext(options, this.fetchFunction);\n }\n /**\n * Synchronously gives the contiguous buffered results (stops at the first non result) if any\n * @returns buffered current items if any\n * @hidden\n */\n public peekBufferedItems(): any[] {\n const bufferedResults = [];\n for (let i = 0, done = false; i < this.fetchResults.length && !done; i++) {\n const fetchResult = this.fetchResults[i];\n switch (fetchResult.fetchResultType) {\n case FetchResultType.Done:\n done = true;\n break;\n case FetchResultType.Exception:\n done = true;\n break;\n case FetchResultType.Result:\n bufferedResults.push(fetchResult.feedResponse);\n break;\n }\n }\n return bufferedResults;\n }\n\n public fetchFunction = async (\n diagnosticNode: DiagnosticNodeInternal,\n options: FeedOptions,\n ): Promise> => {\n const path = getPathFromLink(this.collectionLink, ResourceType.item);\n diagnosticNode.addData({ partitionKeyRangeId: this.targetPartitionKeyRange.id });\n const id = getIdFromLink(this.collectionLink);\n\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n resultFn: (result: any) => result.Documents,\n query: this.query,\n options,\n diagnosticNode,\n partitionKeyRangeId: this.targetPartitionKeyRange[\"id\"],\n });\n };\n\n public hasMoreResults(): boolean {\n return this.internalExecutionContext.hasMoreResults() || this.fetchResults.length !== 0;\n }\n\n public gotSplit(): boolean {\n const fetchResult = this.fetchResults[0];\n if (fetchResult.fetchResultType === FetchResultType.Exception) {\n if (DocumentProducer._needPartitionKeyRangeCacheRefresh(fetchResult.error)) {\n return true;\n }\n }\n\n return false;\n }\n\n private _getAndResetActiveResponseHeaders(): CosmosHeaders {\n const ret = this.respHeaders;\n this.respHeaders = getInitialHeader();\n return ret;\n }\n\n private _updateStates(err: any, allFetched: boolean): void {\n // TODO: any Error\n if (err) {\n this.err = err;\n return;\n }\n if (allFetched) {\n this.allFetched = true;\n }\n if (this.internalExecutionContext.continuationToken === this.continuationToken) {\n // nothing changed\n return;\n }\n this.previousContinuationToken = this.continuationToken;\n this.continuationToken = this.internalExecutionContext.continuationToken;\n }\n\n private static _needPartitionKeyRangeCacheRefresh(error: any): boolean {\n // TODO: error\n return (\n error.code === StatusCodes.Gone &&\n \"substatus\" in error &&\n error[\"substatus\"] === SubStatusCodes.PartitionKeyRangeGone\n );\n }\n\n /**\n * Fetches and bufferes the next page of results and executes the given callback\n */\n public async bufferMore(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.err) {\n throw this.err;\n }\n\n try {\n const { result: resources, headers: headerResponse } =\n await this.internalExecutionContext.fetchMore(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n ++this.generation;\n this._updateStates(undefined, resources === undefined);\n if (resources !== undefined) {\n // some more results\n resources.forEach((element: any) => {\n // TODO: resources any\n this.fetchResults.push(new FetchResult(element, undefined));\n });\n }\n\n // need to modify the header response so that the query metrics are per partition\n if (headerResponse != null && Constants.HttpHeaders.QueryMetrics in headerResponse) {\n // \"0\" is the default partition before one is actually assigned.\n const queryMetrics = headerResponse[Constants.HttpHeaders.QueryMetrics][\"0\"];\n\n // Wraping query metrics in a object where the keys are the partition key range.\n headerResponse[Constants.HttpHeaders.QueryMetrics] = {};\n headerResponse[Constants.HttpHeaders.QueryMetrics][this.targetPartitionKeyRange.id] =\n queryMetrics;\n }\n\n return { result: resources, headers: headerResponse };\n } catch (err: any) {\n // TODO: any error\n if (DocumentProducer._needPartitionKeyRangeCacheRefresh(err)) {\n // Split just happend\n // Buffer the error so the execution context can still get the feedResponses in the itemBuffer\n const bufferedError = new FetchResult(undefined, err);\n this.fetchResults.push(bufferedError);\n // Putting a dummy result so that the rest of code flows\n return {\n result: [bufferedError],\n headers: err.headers,\n };\n } else {\n this._updateStates(err, err.resources === undefined);\n throw err;\n }\n }\n }\n\n /**\n * Synchronously gives the bufferend current item if any\n * @returns buffered current item if any\n * @hidden\n */\n public getTargetParitionKeyRange(): PartitionKeyRange {\n return this.targetPartitionKeyRange;\n }\n\n /**\n * Fetches the next element in the DocumentProducer.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.err) {\n this._updateStates(this.err, undefined);\n throw this.err;\n }\n\n try {\n const { result, headers } = await this.current(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n\n const fetchResult = this.fetchResults.shift();\n this._updateStates(undefined, result === undefined);\n if (fetchResult.feedResponse !== result) {\n throw new Error(`Expected ${fetchResult.feedResponse} to equal ${result}`);\n }\n switch (fetchResult.fetchResultType) {\n case FetchResultType.Done:\n return { result: undefined, headers };\n case FetchResultType.Exception:\n fetchResult.error.headers = headers;\n throw fetchResult.error;\n case FetchResultType.Result:\n return { result: fetchResult.feedResponse, headers };\n }\n } catch (err: any) {\n this._updateStates(err, err.item === undefined);\n throw err;\n }\n }\n\n /**\n * Retrieve the current element on the DocumentProducer.\n */\n public async current(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // If something is buffered just give that\n if (this.fetchResults.length > 0) {\n const fetchResult = this.fetchResults[0];\n // Need to unwrap fetch results\n switch (fetchResult.fetchResultType) {\n case FetchResultType.Done:\n return {\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n };\n case FetchResultType.Exception:\n fetchResult.error.headers = this._getAndResetActiveResponseHeaders();\n throw fetchResult.error;\n case FetchResultType.Result:\n return {\n result: fetchResult.feedResponse,\n headers: this._getAndResetActiveResponseHeaders(),\n };\n }\n }\n\n // If there isn't anymore items left to fetch then let the user know.\n if (this.allFetched) {\n return {\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n };\n }\n\n // If there are no more bufferd items and there are still items to be fetched then buffer more\n const { result, headers } = await this.bufferMore(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n mergeHeaders(this.respHeaders, headers);\n if (result === undefined) {\n return { result: undefined, headers: this.respHeaders };\n }\n return this.current(diagnosticNode, operationOptions, ruConsumedManager);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKeyRange } from \"../client/Container/PartitionKeyRange\";\nimport { Constants } from \"../common\";\nimport { QueryRange as ResponseQueryRange } from \"../request/ErrorResponse\";\n\n/** @hidden */\nexport class QueryRange {\n public min: string;\n public max: string;\n public isMinInclusive: boolean;\n public isMaxInclusive: boolean;\n\n /**\n * Represents a QueryRange.\n *\n * @param rangeMin - min\n * @param rangeMin - max\n * @param isMinInclusive - isMinInclusive\n * @param isMaxInclusive - isMaxInclusive\n * @hidden\n */\n constructor(\n rangeMin: string,\n rangeMax: string,\n isMinInclusive: boolean,\n isMaxInclusive: boolean,\n ) {\n this.min = rangeMin;\n this.max = rangeMax;\n this.isMinInclusive = isMinInclusive;\n this.isMaxInclusive = isMaxInclusive;\n }\n public overlaps(other: QueryRange): boolean {\n const range1 = this; // eslint-disable-line @typescript-eslint/no-this-alias\n const range2 = other;\n if (range1 === undefined || range2 === undefined) {\n return false;\n }\n if (range1.isEmpty() || range2.isEmpty()) {\n return false;\n }\n\n if (range1.min <= range2.max || range2.min <= range1.max) {\n if (\n (range1.min === range2.max && !(range1.isMinInclusive && range2.isMaxInclusive)) ||\n (range2.min === range1.max && !(range2.isMinInclusive && range1.isMaxInclusive))\n ) {\n return false;\n }\n return true;\n }\n return false;\n }\n\n public isFullRange(): boolean {\n return (\n this.min === Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey &&\n this.max === Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey &&\n this.isMinInclusive === true &&\n this.isMaxInclusive === false\n );\n }\n\n public isEmpty(): boolean {\n return !(this.isMinInclusive && this.isMaxInclusive) && this.min === this.max;\n }\n /**\n * Parse a QueryRange from a partitionKeyRange\n * @returns QueryRange\n * @hidden\n */\n public static parsePartitionKeyRange(partitionKeyRange: PartitionKeyRange): QueryRange {\n return new QueryRange(\n partitionKeyRange[Constants.PartitionKeyRange.MinInclusive],\n partitionKeyRange[Constants.PartitionKeyRange.MaxExclusive],\n true,\n false,\n );\n }\n /**\n * Parse a QueryRange from a dictionary\n * @returns QueryRange\n * @hidden\n */\n public static parseFromDict(queryRangeDict: ResponseQueryRange): QueryRange {\n return new QueryRange(\n queryRangeDict.min,\n queryRangeDict.max,\n queryRangeDict.isMinInclusive,\n queryRangeDict.isMaxInclusive,\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKeyRange } from \"../client\";\nimport { Constants } from \"../common\";\nimport { QueryRange } from \"./QueryRange\";\n\n/** @hidden */\nexport class InMemoryCollectionRoutingMap {\n private orderedPartitionKeyRanges: PartitionKeyRange[];\n private orderedRanges: QueryRange[];\n // TODO: chrande made this public, even though it is implementation detail for a test\n public orderedPartitionInfo: unknown;\n\n /**\n * Represents a InMemoryCollectionRoutingMap Object,\n * Stores partition key ranges in an efficient way with some additional information and provides\n * convenience methods for working with set of ranges.\n */\n constructor(orderedPartitionKeyRanges: PartitionKeyRange[], orderedPartitionInfo: unknown) {\n this.orderedPartitionKeyRanges = orderedPartitionKeyRanges;\n this.orderedRanges = orderedPartitionKeyRanges.map((pkr) => {\n return new QueryRange(\n pkr[Constants.PartitionKeyRange.MinInclusive],\n pkr[Constants.PartitionKeyRange.MaxExclusive],\n true,\n false,\n );\n });\n this.orderedPartitionInfo = orderedPartitionInfo;\n }\n public getOrderedParitionKeyRanges(): PartitionKeyRange[] {\n return this.orderedPartitionKeyRanges;\n }\n\n public getOverlappingRanges(providedQueryRanges: QueryRange | QueryRange[]): PartitionKeyRange[] {\n // TODO This code has all kinds of smells. Multiple iterations and sorts just to grab overlapping ranges\n // stfaul attempted to bring it down to one for-loop and failed\n const pqr: QueryRange[] = Array.isArray(providedQueryRanges)\n ? providedQueryRanges\n : [providedQueryRanges];\n const minToPartitionRange: any = {}; // TODO: any\n\n // this for loop doesn't invoke any async callback\n for (const queryRange of pqr) {\n if (queryRange.isEmpty()) {\n continue;\n }\n\n if (queryRange.isFullRange()) {\n return this.orderedPartitionKeyRanges;\n }\n\n const minIndex = this.orderedRanges.findIndex((range) => {\n if (queryRange.min > range.min && queryRange.min < range.max) {\n return true;\n }\n if (queryRange.min === range.min) {\n return true;\n }\n if (queryRange.min === range.max) {\n return true;\n }\n });\n\n if (minIndex < 0) {\n throw new Error(\n \"error in collection routing map, queried value is less than the start range.\",\n );\n }\n\n // Start at the end and work backwards\n let maxIndex: number;\n for (let i = this.orderedRanges.length - 1; i >= 0; i--) {\n const range = this.orderedRanges[i];\n if (queryRange.max > range.min && queryRange.max < range.max) {\n maxIndex = i;\n break;\n }\n if (queryRange.max === range.min) {\n maxIndex = i;\n break;\n }\n if (queryRange.max === range.max) {\n maxIndex = i;\n break;\n }\n }\n\n if (maxIndex > this.orderedRanges.length) {\n throw new Error(\n \"error in collection routing map, queried value is greater than the end range.\",\n );\n }\n\n for (let j = minIndex; j < maxIndex + 1; j++) {\n if (queryRange.overlaps(this.orderedRanges[j])) {\n minToPartitionRange[\n this.orderedPartitionKeyRanges[j][Constants.PartitionKeyRange.MinInclusive]\n ] = this.orderedPartitionKeyRanges[j];\n }\n }\n }\n\n const overlappingPartitionKeyRanges = Object.keys(minToPartitionRange).map(\n (k) => minToPartitionRange[k],\n );\n\n return overlappingPartitionKeyRanges.sort((a, b) => {\n return a[Constants.PartitionKeyRange.MinInclusive].localeCompare(\n b[Constants.PartitionKeyRange.MinInclusive],\n );\n });\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common/constants\";\nimport { InMemoryCollectionRoutingMap } from \"./inMemoryCollectionRoutingMap\";\n\n/**\n * @hidden\n */\nfunction compareRanges(a: any, b: any): 0 | 1 | -1 {\n const aVal = a[0][Constants.PartitionKeyRange.MinInclusive];\n const bVal = b[0][Constants.PartitionKeyRange.MinInclusive];\n if (aVal > bVal) {\n return 1;\n }\n if (aVal < bVal) {\n return -1;\n }\n return 0;\n}\n\n/** @hidden */\nexport function createCompleteRoutingMap(\n partitionKeyRangeInfoTuppleList: any[],\n): InMemoryCollectionRoutingMap {\n const rangeById: any = {}; // TODO: any\n const rangeByInfo: any = {}; // TODO: any\n\n let sortedRanges = [];\n\n // the for loop doesn't invoke any async callback\n for (const r of partitionKeyRangeInfoTuppleList) {\n rangeById[r[0][Constants.PartitionKeyRange.Id]] = r;\n rangeByInfo[r[1]] = r[0];\n sortedRanges.push(r);\n }\n\n sortedRanges = sortedRanges.sort(compareRanges);\n const partitionKeyOrderedRange = sortedRanges.map((r) => r[0]);\n const orderedPartitionInfo = sortedRanges.map((r) => r[1]);\n\n if (!isCompleteSetOfRange(partitionKeyOrderedRange)) {\n return undefined;\n }\n return new InMemoryCollectionRoutingMap(partitionKeyOrderedRange, orderedPartitionInfo);\n}\n\n/**\n * @hidden\n */\nfunction isCompleteSetOfRange(partitionKeyOrderedRange: any): boolean {\n // TODO: any\n let isComplete = false;\n if (partitionKeyOrderedRange.length > 0) {\n const firstRange = partitionKeyOrderedRange[0];\n const lastRange = partitionKeyOrderedRange[partitionKeyOrderedRange.length - 1];\n isComplete =\n firstRange[Constants.PartitionKeyRange.MinInclusive] ===\n Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey;\n isComplete =\n isComplete &&\n lastRange[Constants.PartitionKeyRange.MaxExclusive] ===\n Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey;\n\n for (let i = 1; i < partitionKeyOrderedRange.length; i++) {\n const previousRange = partitionKeyOrderedRange[i - 1];\n const currentRange = partitionKeyOrderedRange[i];\n isComplete =\n isComplete &&\n previousRange[Constants.PartitionKeyRange.MaxExclusive] ===\n currentRange[Constants.PartitionKeyRange.MinInclusive];\n\n if (!isComplete) {\n if (\n previousRange[Constants.PartitionKeyRange.MaxExclusive] >\n currentRange[Constants.PartitionKeyRange.MinInclusive]\n ) {\n throw Error(\"Ranges overlap\");\n }\n break;\n }\n }\n }\n return isComplete;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { MetadataLookUpType } from \"../CosmosDiagnostics\";\nimport { PartitionKeyRange } from \"../client/Container/PartitionKeyRange\";\nimport { ClientContext } from \"../ClientContext\";\nimport { getIdFromLink } from \"../common/helper\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { withMetadataDiagnostics } from \"../utils/diagnostics\";\nimport { createCompleteRoutingMap } from \"./CollectionRoutingMapFactory\";\nimport { InMemoryCollectionRoutingMap } from \"./inMemoryCollectionRoutingMap\";\nimport { QueryRange } from \"./QueryRange\";\n\n/** @hidden */\nexport class PartitionKeyRangeCache {\n private collectionRoutingMapByCollectionId: {\n [key: string]: Promise;\n };\n\n constructor(private clientContext: ClientContext) {\n this.collectionRoutingMapByCollectionId = {};\n }\n /**\n * Finds or Instantiates the requested Collection Routing Map\n * @param collectionLink - Requested collectionLink\n * @hidden\n */\n public async onCollectionRoutingMap(\n collectionLink: string,\n diagnosticNode: DiagnosticNodeInternal,\n forceRefresh: boolean = false,\n ): Promise {\n const collectionId = getIdFromLink(collectionLink);\n if (this.collectionRoutingMapByCollectionId[collectionId] === undefined || forceRefresh) {\n this.collectionRoutingMapByCollectionId[collectionId] = this.requestCollectionRoutingMap(\n collectionLink,\n diagnosticNode,\n );\n }\n return this.collectionRoutingMapByCollectionId[collectionId];\n }\n\n /**\n * Given the query ranges and a collection, invokes the callback on the list of overlapping partition key ranges\n * @hidden\n */\n public async getOverlappingRanges(\n collectionLink: string,\n queryRange: QueryRange,\n diagnosticNode: DiagnosticNodeInternal,\n forceRefresh: boolean = false,\n ): Promise {\n const crm = await this.onCollectionRoutingMap(collectionLink, diagnosticNode, forceRefresh);\n return crm.getOverlappingRanges(queryRange);\n }\n\n private async requestCollectionRoutingMap(\n collectionLink: string,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n const { resources } = await withMetadataDiagnostics(\n async (metadataDiagnostics: DiagnosticNodeInternal) => {\n return this.clientContext\n .queryPartitionKeyRanges(collectionLink)\n .fetchAllInternal(metadataDiagnostics);\n },\n diagnosticNode,\n MetadataLookUpType.PartitionKeyRangeLookUp,\n );\n return createCompleteRoutingMap(resources.map((r) => [r, true]));\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { Constants } from \"../common/constants\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { PartitionKeyRangeCache } from \"./partitionKeyRangeCache\";\nimport { QueryRange } from \"./QueryRange\";\n\n/** @hidden */\nexport const PARITIONKEYRANGE = Constants.PartitionKeyRange;\n\n/** @hidden */\nexport class SmartRoutingMapProvider {\n private partitionKeyRangeCache: PartitionKeyRangeCache;\n\n constructor(clientContext: ClientContext) {\n this.partitionKeyRangeCache = new PartitionKeyRangeCache(clientContext);\n }\n private static _secondRangeIsAfterFirstRange(range1: QueryRange, range2: QueryRange): boolean {\n if (typeof range1.max === \"undefined\") {\n throw new Error(\"range1 must have max\");\n }\n\n if (typeof range2.min === \"undefined\") {\n throw new Error(\"range2 must have min\");\n }\n\n if (range1.max > range2.min) {\n // r.min < #previous_r.max\n return false;\n } else {\n if (range1.max === range2.min && range1.isMaxInclusive && range2.isMinInclusive) {\n // the inclusive ending endpoint of previous_r is the same as the inclusive beginning endpoint of r\n // they share a point\n return false;\n }\n return true;\n }\n }\n\n private static _isSortedAndNonOverlapping(ranges: QueryRange[]): boolean {\n for (let idx = 1; idx < ranges.length; idx++) {\n const previousR = ranges[idx - 1];\n const r = ranges[idx];\n if (!this._secondRangeIsAfterFirstRange(previousR, r)) {\n return false;\n }\n }\n return true;\n }\n\n private static _stringMax(a: string, b: string): string {\n return a >= b ? a : b;\n }\n\n private static _stringCompare(a: string, b: string): 1 | 0 | -1 {\n return a === b ? 0 : a > b ? 1 : -1;\n }\n\n private static _subtractRange(r: QueryRange, partitionKeyRange: any): QueryRange {\n const left = this._stringMax(partitionKeyRange[PARITIONKEYRANGE.MaxExclusive], r.min);\n const leftInclusive = this._stringCompare(left, r.min) === 0 ? r.isMinInclusive : false;\n return new QueryRange(left, r.max, leftInclusive, r.isMaxInclusive);\n }\n\n /**\n * Given the sorted ranges and a collection, invokes the callback on the list of overlapping partition key ranges\n * @param callback - Function execute on the overlapping partition key ranges result,\n * takes two parameters error, partition key ranges\n * @hidden\n */\n public async getOverlappingRanges(\n collectionLink: string,\n sortedRanges: QueryRange[],\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n // validate if the list is non- overlapping and sorted TODO: any PartitionKeyRanges\n if (!SmartRoutingMapProvider._isSortedAndNonOverlapping(sortedRanges)) {\n throw new Error(\"the list of ranges is not a non-overlapping sorted ranges\");\n }\n\n let partitionKeyRanges: any[] = []; // TODO: any ParitionKeyRanges\n\n if (sortedRanges.length === 0) {\n return partitionKeyRanges;\n }\n\n const collectionRoutingMap = await this.partitionKeyRangeCache.onCollectionRoutingMap(\n collectionLink,\n diagnosticNode,\n );\n\n let index = 0;\n let currentProvidedRange = sortedRanges[index];\n for (;;) {\n if (currentProvidedRange.isEmpty()) {\n // skip and go to the next item\n if (++index >= sortedRanges.length) {\n return partitionKeyRanges;\n }\n currentProvidedRange = sortedRanges[index];\n continue;\n }\n\n let queryRange;\n if (partitionKeyRanges.length > 0) {\n queryRange = SmartRoutingMapProvider._subtractRange(\n currentProvidedRange,\n partitionKeyRanges[partitionKeyRanges.length - 1],\n );\n } else {\n queryRange = currentProvidedRange;\n }\n\n const overlappingRanges = collectionRoutingMap.getOverlappingRanges(queryRange);\n if (overlappingRanges.length <= 0) {\n throw new Error(`error: returned overlapping ranges for queryRange ${queryRange} is empty`);\n }\n partitionKeyRanges = partitionKeyRanges.concat(overlappingRanges);\n\n const lastKnownTargetRange = QueryRange.parsePartitionKeyRange(\n partitionKeyRanges[partitionKeyRanges.length - 1],\n );\n if (!lastKnownTargetRange) {\n throw new Error(\"expected lastKnowTargetRange to be truthy\");\n }\n // the overlapping ranges must contain the requested range\n\n if (\n SmartRoutingMapProvider._stringCompare(currentProvidedRange.max, lastKnownTargetRange.max) >\n 0\n ) {\n throw new Error(`error: returned overlapping ranges ${overlappingRanges} \\\n does not contain the requested range ${queryRange}`);\n }\n\n // the current range is contained in partitionKeyRanges just move forward\n if (++index >= sortedRanges.length) {\n return partitionKeyRanges;\n }\n currentProvidedRange = sortedRanges[index];\n\n while (\n SmartRoutingMapProvider._stringCompare(\n currentProvidedRange.max,\n lastKnownTargetRange.max,\n ) <= 0\n ) {\n // the current range is covered too.just move forward\n if (++index >= sortedRanges.length) {\n return partitionKeyRanges;\n }\n currentProvidedRange = sortedRanges[index];\n }\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport PriorityQueue from \"priorityqueuejs\";\nimport { ClientContext } from \"../ClientContext\";\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { StatusCodes, SubStatusCodes, RUConsumedManager } from \"../common\";\nimport { FeedOptions, QueryOperationOptions, Response } from \"../request\";\nimport { PartitionedQueryExecutionInfo } from \"../request/ErrorResponse\";\nimport { QueryRange } from \"../routing/QueryRange\";\nimport { SmartRoutingMapProvider } from \"../routing/smartRoutingMapProvider\";\nimport { CosmosHeaders } from \"./CosmosHeaders\";\nimport { DocumentProducer } from \"./documentProducer\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { getInitialHeader, mergeHeaders } from \"./headerUtils\";\nimport { SqlQuerySpec } from \"./SqlQuerySpec\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { MetadataLookUpType } from \"../CosmosDiagnostics\";\nimport { CosmosDbDiagnosticLevel } from \"../diagnostics/CosmosDbDiagnosticLevel\";\nimport {\n RUCapPerOperationExceededError,\n RUCapPerOperationExceededErrorCode,\n} from \"../request/RUCapPerOperationExceededError\";\nimport semaphore from \"semaphore\";\n\n/** @hidden */\nconst logger: AzureLogger = createClientLogger(\"parallelQueryExecutionContextBase\");\n\n/** @hidden */\nexport enum ParallelQueryExecutionContextBaseStates {\n started = \"started\",\n inProgress = \"inProgress\",\n ended = \"ended\",\n}\n\n/** @hidden */\nexport abstract class ParallelQueryExecutionContextBase implements ExecutionContext {\n private err: any;\n private state: any;\n private static STATES = ParallelQueryExecutionContextBaseStates;\n private routingProvider: SmartRoutingMapProvider;\n protected sortOrders: any;\n private requestContinuation: any;\n private respHeaders: CosmosHeaders;\n private orderByPQ: PriorityQueue;\n private diagnosticNodeWrapper: {\n consumed: boolean;\n diagnosticNode: DiagnosticNodeInternal;\n };\n private initializedPriorityQueue: boolean = false;\n private ruCapExceededError: RUCapPerOperationExceededError = undefined;\n /**\n * Semaphore for Controlling Concurrent Access to the `nextItem` Method\n *\n * serializes access to the `nextItem` method,\n * preventing concurrent issues during initialization, document producer\n * handling, diagnostic node updates, and error propagation.\n */\n private nextItemfetchSemaphore;\n /**\n * Provides the ParallelQueryExecutionContextBase.\n * This is the base class that ParallelQueryExecutionContext and OrderByQueryExecutionContext will derive from.\n *\n * When handling a parallelized query, it instantiates one instance of\n * DocumentProcuder per target partition key range and aggregates the result of each.\n *\n * @param clientContext - The service endpoint to use to create the client.\n * @param collectionLink - The Collection Link\n * @param options - Represents the feed options.\n * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo\n * @hidden\n */\n constructor(\n private clientContext: ClientContext,\n private collectionLink: string,\n private query: string | SqlQuerySpec,\n private options: FeedOptions,\n private partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo,\n ) {\n this.clientContext = clientContext;\n this.collectionLink = collectionLink;\n this.query = query;\n this.options = options;\n this.partitionedQueryExecutionInfo = partitionedQueryExecutionInfo;\n this.diagnosticNodeWrapper = {\n consumed: false,\n diagnosticNode: new DiagnosticNodeInternal(\n clientContext.diagnosticLevel,\n DiagnosticNodeType.PARALLEL_QUERY_NODE,\n null,\n ),\n };\n this.diagnosticNodeWrapper.diagnosticNode.addData({ stateful: true });\n this.err = undefined;\n this.state = ParallelQueryExecutionContextBase.STATES.started;\n this.routingProvider = new SmartRoutingMapProvider(this.clientContext);\n this.sortOrders = this.partitionedQueryExecutionInfo.queryInfo.orderBy;\n\n this.requestContinuation = options ? options.continuationToken || options.continuation : null;\n // response headers of undergoing operation\n this.respHeaders = getInitialHeader();\n\n // Make priority queue for documentProducers\n // The comparator is supplied by the derived class\n this.orderByPQ = new PriorityQueue(\n (a: DocumentProducer, b: DocumentProducer) => this.documentProducerComparator(b, a),\n );\n this.nextItemfetchSemaphore = semaphore(1);\n }\n\n protected abstract documentProducerComparator(\n dp1: DocumentProducer,\n dp2: DocumentProducer,\n ): number;\n\n private _mergeWithActiveResponseHeaders(headers: CosmosHeaders): void {\n mergeHeaders(this.respHeaders, headers);\n }\n\n private _getAndResetActiveResponseHeaders(): CosmosHeaders {\n const ret = this.respHeaders;\n this.respHeaders = getInitialHeader();\n return ret;\n }\n\n private getDiagnosticNode(): DiagnosticNodeInternal {\n return this.diagnosticNodeWrapper.diagnosticNode;\n }\n\n private async _onTargetPartitionRanges(): Promise {\n // invokes the callback when the target partition ranges are ready\n const parsedRanges = this.partitionedQueryExecutionInfo.queryRanges;\n const queryRanges = parsedRanges.map((item) => QueryRange.parseFromDict(item));\n return this.routingProvider.getOverlappingRanges(\n this.collectionLink,\n queryRanges,\n this.getDiagnosticNode(),\n );\n }\n\n /**\n * Gets the replacement ranges for a partitionkeyrange that has been split\n */\n private async _getReplacementPartitionKeyRanges(\n documentProducer: DocumentProducer,\n ): Promise {\n const partitionKeyRange = documentProducer.targetPartitionKeyRange;\n // Download the new routing map\n this.routingProvider = new SmartRoutingMapProvider(this.clientContext);\n // Get the queryRange that relates to this partitionKeyRange\n const queryRange = QueryRange.parsePartitionKeyRange(partitionKeyRange);\n return this.routingProvider.getOverlappingRanges(\n this.collectionLink,\n [queryRange],\n this.getDiagnosticNode(),\n );\n }\n\n // TODO: P0 Code smell - can barely tell what this is doing\n /**\n * Removes the current document producer from the priqueue,\n * replaces that document producer with child document producers,\n * then reexecutes the originFunction with the corrrected executionContext\n */\n private async _repairExecutionContext(\n diagnosticNode: DiagnosticNodeInternal,\n originFunction: any,\n ): Promise {\n // TODO: any\n // Get the replacement ranges\n // Removing the invalid documentProducer from the orderByPQ\n const parentDocumentProducer = this.orderByPQ.deq();\n try {\n const replacementPartitionKeyRanges: any[] =\n await this._getReplacementPartitionKeyRanges(parentDocumentProducer);\n const replacementDocumentProducers: DocumentProducer[] = [];\n // Create the replacement documentProducers\n replacementPartitionKeyRanges.forEach((partitionKeyRange) => {\n // Create replacment document producers with the parent's continuationToken\n const replacementDocumentProducer = this._createTargetPartitionQueryExecutionContext(\n partitionKeyRange,\n parentDocumentProducer.continuationToken,\n );\n replacementDocumentProducers.push(replacementDocumentProducer);\n });\n // We need to check if the documentProducers even has anything left to fetch from before enqueing them\n const checkAndEnqueueDocumentProducer = async (\n documentProducerToCheck: DocumentProducer,\n checkNextDocumentProducerCallback: any,\n ): Promise => {\n try {\n const { result: afterItem } = await documentProducerToCheck.current(diagnosticNode);\n if (afterItem === undefined) {\n // no more results left in this document producer, so we don't enqueue it\n } else {\n // Safe to put document producer back in the queue\n this.orderByPQ.enq(documentProducerToCheck);\n }\n\n await checkNextDocumentProducerCallback();\n } catch (err: any) {\n this.err = err;\n return;\n }\n };\n const checkAndEnqueueDocumentProducers = async (rdp: DocumentProducer[]): Promise => {\n if (rdp.length > 0) {\n // We still have a replacementDocumentProducer to check\n const replacementDocumentProducer = rdp.shift();\n await checkAndEnqueueDocumentProducer(replacementDocumentProducer, async () => {\n await checkAndEnqueueDocumentProducers(rdp);\n });\n } else {\n // reexecutes the originFunction with the corrrected executionContext\n return originFunction();\n }\n };\n // Invoke the recursive function to get the ball rolling\n await checkAndEnqueueDocumentProducers(replacementDocumentProducers);\n } catch (err: any) {\n this.err = err;\n throw err;\n }\n }\n\n private static _needPartitionKeyRangeCacheRefresh(error: any): boolean {\n // TODO: any error\n return (\n error.code === StatusCodes.Gone &&\n \"substatus\" in error &&\n error[\"substatus\"] === SubStatusCodes.PartitionKeyRangeGone\n );\n }\n\n /**\n * Checks to see if the executionContext needs to be repaired.\n * if so it repairs the execution context and executes the ifCallback,\n * else it continues with the current execution context and executes the elseCallback\n */\n private async _repairExecutionContextIfNeeded(\n diagnosticNode: DiagnosticNodeInternal,\n ifCallback: any,\n elseCallback: any,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise {\n const documentProducer = this.orderByPQ.peek();\n // Check if split happened\n try {\n await documentProducer.current(diagnosticNode, operationOptions, ruConsumedManager);\n elseCallback();\n } catch (err: any) {\n if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) {\n // Split has happened so we need to repair execution context before continueing\n return addDignosticChild(\n (childNode) => this._repairExecutionContext(childNode, ifCallback),\n diagnosticNode,\n DiagnosticNodeType.QUERY_REPAIR_NODE,\n );\n } else {\n // Something actually bad happened ...\n this.err = err;\n throw err;\n }\n }\n }\n\n /**\n * Fetches the next element in the ParallelQueryExecutionContextBase.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (this.err) {\n // if there is a prior error return error\n throw this.err;\n }\n return new Promise>((resolve, reject) => {\n this.nextItemfetchSemaphore.take(async () => {\n // document producer queue initilization\n if (!this.initializedPriorityQueue) {\n try {\n await this._createDocumentProducersAndFillUpPriorityQueue(\n operationOptions,\n ruConsumedManager,\n );\n this.initializedPriorityQueue = true;\n } catch (err: any) {\n this.err = err;\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n reject(this.err);\n return;\n }\n }\n\n if (!this.diagnosticNodeWrapper.consumed) {\n diagnosticNode.addChildNode(\n this.diagnosticNodeWrapper.diagnosticNode,\n CosmosDbDiagnosticLevel.debug,\n MetadataLookUpType.QueryPlanLookUp,\n );\n this.diagnosticNodeWrapper.diagnosticNode = undefined;\n this.diagnosticNodeWrapper.consumed = true;\n } else {\n this.diagnosticNodeWrapper.diagnosticNode = diagnosticNode;\n }\n // NOTE: lock must be released before invoking quitting\n if (this.err) {\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n this.err.headers = this._getAndResetActiveResponseHeaders();\n reject(this.err);\n return;\n }\n\n if (this.orderByPQ.size() === 0) {\n // there is no more results\n this.state = ParallelQueryExecutionContextBase.STATES.ended;\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n return resolve({\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n });\n }\n\n const ifCallback = (): void => {\n // Release the semaphore to avoid deadlock\n this.nextItemfetchSemaphore.leave();\n // Reexcute the function\n return resolve(this.nextItem(diagnosticNode, operationOptions, ruConsumedManager));\n };\n const elseCallback = async (): Promise => {\n let documentProducer: DocumentProducer;\n try {\n documentProducer = this.orderByPQ.deq();\n } catch (e: any) {\n // if comparing elements of the priority queue throws exception\n // set that error and return error\n this.err = e;\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n this.err.headers = this._getAndResetActiveResponseHeaders();\n reject(this.err);\n return;\n }\n\n let item: any;\n let headers: CosmosHeaders;\n try {\n const response = await documentProducer.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n item = response.result;\n headers = response.headers;\n this._mergeWithActiveResponseHeaders(headers);\n if (item === undefined) {\n // this should never happen\n // because the documentProducer already has buffered an item\n // assert item !== undefined\n this.err = new Error(\n `Extracted DocumentProducer from the priority queue \\\n doesn't have any buffered item!`,\n );\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n return resolve({\n result: undefined,\n headers: this._getAndResetActiveResponseHeaders(),\n });\n }\n } catch (err: any) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n this._updateErrorObjectWithBufferedData(err);\n this.err = err;\n } else {\n this.err = new Error(\n `Extracted DocumentProducer from the priority queue fails to get the \\\n buffered item. Due to ${JSON.stringify(err)}`,\n );\n this.err.headers = this._getAndResetActiveResponseHeaders();\n }\n // release the lock before invoking callback\n this.nextItemfetchSemaphore.leave();\n reject(this.err);\n return;\n }\n\n // we need to put back the document producer to the queue if it has more elements.\n // the lock will be released after we know document producer must be put back in the queue or not\n try {\n const { result: afterItem, headers: otherHeaders } = await documentProducer.current(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this._mergeWithActiveResponseHeaders(otherHeaders);\n if (afterItem === undefined) {\n // no more results is left in this document producer\n } else {\n try {\n const headItem = documentProducer.fetchResults[0];\n if (typeof headItem === \"undefined\") {\n throw new Error(\n \"Extracted DocumentProducer from PQ is invalid state with no result!\",\n );\n }\n this.orderByPQ.enq(documentProducer);\n } catch (e: any) {\n // if comparing elements in priority queue throws exception\n // set error\n this.err = e;\n }\n }\n } catch (err: any) {\n if (ParallelQueryExecutionContextBase._needPartitionKeyRangeCacheRefresh(err)) {\n // We want the document producer enqueued\n // So that later parts of the code can repair the execution context\n this.orderByPQ.enq(documentProducer);\n } else if (err.code === RUCapPerOperationExceededErrorCode) {\n this._updateErrorObjectWithBufferedData(err);\n this.err = err;\n reject(this.err);\n } else {\n // Something actually bad happened\n this.err = err;\n reject(this.err);\n }\n } finally {\n // release the lock before returning\n this.nextItemfetchSemaphore.leave();\n }\n // invoke the callback on the item\n return resolve({\n result: item,\n headers: this._getAndResetActiveResponseHeaders(),\n });\n };\n this._repairExecutionContextIfNeeded(diagnosticNode, ifCallback, elseCallback).catch(\n reject,\n );\n });\n });\n }\n\n private _updateErrorObjectWithBufferedData(err: any) {\n this.orderByPQ.forEach((dp) => {\n const bufferedItems = dp.peekBufferedItems();\n err.fetchedResults.push(...bufferedItems);\n });\n }\n\n /**\n * Determine if there are still remaining resources to processs based on the value of the continuation\n * token or the elements remaining on the current batch in the QueryIterator.\n * @returns true if there is other elements to process in the ParallelQueryExecutionContextBase.\n */\n public hasMoreResults(): boolean {\n return !(\n this.state === ParallelQueryExecutionContextBase.STATES.ended || this.err !== undefined\n );\n }\n\n /**\n * Creates document producers\n */\n private _createTargetPartitionQueryExecutionContext(\n partitionKeyTargetRange: any,\n continuationToken?: any,\n ): DocumentProducer {\n // TODO: any\n // creates target partition range Query Execution Context\n let rewrittenQuery = this.partitionedQueryExecutionInfo.queryInfo.rewrittenQuery;\n let sqlQuerySpec: SqlQuerySpec;\n const query = this.query;\n if (typeof query === \"string\") {\n sqlQuerySpec = { query };\n } else {\n sqlQuerySpec = query;\n }\n\n const formatPlaceHolder = \"{documentdb-formattableorderbyquery-filter}\";\n if (rewrittenQuery) {\n sqlQuerySpec = JSON.parse(JSON.stringify(sqlQuerySpec));\n // We hardcode the formattable filter to true for now\n rewrittenQuery = rewrittenQuery.replace(formatPlaceHolder, \"true\");\n sqlQuerySpec[\"query\"] = rewrittenQuery;\n }\n\n const options = { ...this.options };\n options.continuationToken = continuationToken;\n\n return new DocumentProducer(\n this.clientContext,\n this.collectionLink,\n sqlQuerySpec,\n partitionKeyTargetRange,\n options,\n );\n }\n\n private async _createDocumentProducersAndFillUpPriorityQueue(\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise {\n try {\n const targetPartitionRanges = await this._onTargetPartitionRanges();\n const maxDegreeOfParallelism =\n this.options.maxDegreeOfParallelism === undefined || this.options.maxDegreeOfParallelism < 1\n ? targetPartitionRanges.length\n : Math.min(this.options.maxDegreeOfParallelism, targetPartitionRanges.length);\n\n logger.info(\n \"Query starting against \" +\n targetPartitionRanges.length +\n \" ranges with parallelism of \" +\n maxDegreeOfParallelism,\n );\n\n let filteredPartitionKeyRanges = [];\n // The document producers generated from filteredPartitionKeyRanges\n const targetPartitionQueryExecutionContextList: DocumentProducer[] = [];\n\n if (this.requestContinuation) {\n throw new Error(\"Continuation tokens are not yet supported for cross partition queries\");\n } else {\n filteredPartitionKeyRanges = targetPartitionRanges;\n }\n\n // Create one documentProducer for each partitionTargetRange\n filteredPartitionKeyRanges.forEach((partitionTargetRange: any) => {\n // TODO: any partitionTargetRange\n // no async callback\n targetPartitionQueryExecutionContextList.push(\n this._createTargetPartitionQueryExecutionContext(partitionTargetRange),\n );\n });\n\n // Fill up our priority queue with documentProducers\n let inProgressPromises: Promise[] = [];\n for (const documentProducer of targetPartitionQueryExecutionContextList) {\n // Don't enqueue any new promise if RU cap exceeded\n if (this.ruCapExceededError) {\n break;\n }\n const promise: Promise = this._processAndEnqueueDocumentProducer(\n documentProducer,\n operationOptions,\n ruConsumedManager,\n );\n inProgressPromises.push(promise);\n\n // Limit concurrent executions\n if (inProgressPromises.length === maxDegreeOfParallelism) {\n await Promise.all(inProgressPromises);\n inProgressPromises = [];\n }\n }\n // Wait for all promises to complete\n await Promise.all(inProgressPromises);\n if (this.err) {\n if (this.ruCapExceededError) {\n // merge the buffered items\n this.orderByPQ.forEach((dp) => {\n const bufferedItems = dp.peekBufferedItems();\n this.ruCapExceededError.fetchedResults.push(...bufferedItems);\n });\n throw this.ruCapExceededError;\n }\n throw this.err;\n }\n } catch (err: any) {\n this.err = err;\n throw err;\n }\n }\n\n private async _processAndEnqueueDocumentProducer(\n documentProducer: DocumentProducer,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise {\n try {\n const { result: document, headers } = await documentProducer.current(\n this.getDiagnosticNode(),\n operationOptions,\n ruConsumedManager,\n );\n this._mergeWithActiveResponseHeaders(headers);\n\n if (document !== undefined) {\n this.orderByPQ.enq(documentProducer);\n }\n } catch (err) {\n this._mergeWithActiveResponseHeaders(err.headers);\n this.err = err;\n if (err.code === RUCapPerOperationExceededErrorCode) {\n // would be halting further execution of other promises\n if (!this.ruCapExceededError) {\n this.ruCapExceededError = err;\n } else {\n // merge the buffered items\n if (err.fetchedResults) {\n this.ruCapExceededError.fetchedResults.push(...err.fetchedResults);\n }\n }\n } else {\n throw err;\n }\n }\n return;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { DocumentProducer } from \"./documentProducer\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { ParallelQueryExecutionContextBase } from \"./parallelQueryExecutionContextBase\";\n\n/**\n * Provides the ParallelQueryExecutionContext.\n * This class is capable of handling parallelized queries and derives from ParallelQueryExecutionContextBase.\n * @hidden\n */\nexport class ParallelQueryExecutionContext\n extends ParallelQueryExecutionContextBase\n implements ExecutionContext\n{\n // Instance members are inherited\n\n // Overriding documentProducerComparator for ParallelQueryExecutionContexts\n /**\n * Provides a Comparator for document producers using the min value of the corresponding target partition.\n * @returns Comparator Function\n * @hidden\n */\n public documentProducerComparator(\n docProd1: DocumentProducer,\n docProd2: DocumentProducer,\n ): number {\n return docProd1.generation - docProd2.generation;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { PartitionedQueryExecutionInfo } from \"../request/ErrorResponse\";\nimport { FeedOptions } from \"../request/FeedOptions\";\nimport { DocumentProducer } from \"./documentProducer\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { OrderByDocumentProducerComparator } from \"./orderByDocumentProducerComparator\";\nimport { ParallelQueryExecutionContextBase } from \"./parallelQueryExecutionContextBase\";\nimport { SqlQuerySpec } from \"./SqlQuerySpec\";\n\n/** @hidden */\nexport class OrderByQueryExecutionContext\n extends ParallelQueryExecutionContextBase\n implements ExecutionContext\n{\n private orderByComparator: any;\n /**\n * Provides the OrderByQueryExecutionContext.\n * This class is capable of handling orderby queries and dervives from ParallelQueryExecutionContextBase.\n *\n * When handling a parallelized query, it instantiates one instance of\n * DocumentProcuder per target partition key range and aggregates the result of each.\n *\n * @param clientContext - The service endpoint to use to create the client.\n * @param collectionLink - The Collection Link\n * @param options - Represents the feed options.\n * @param partitionedQueryExecutionInfo - PartitionedQueryExecutionInfo\n * @hidden\n */\n constructor(\n clientContext: ClientContext,\n collectionLink: string,\n query: string | SqlQuerySpec,\n options: FeedOptions,\n partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo,\n ) {\n // Calling on base class constructor\n super(clientContext, collectionLink, query, options, partitionedQueryExecutionInfo);\n this.orderByComparator = new OrderByDocumentProducerComparator(this.sortOrders);\n }\n // Instance members are inherited\n\n // Overriding documentProducerComparator for OrderByQueryExecutionContexts\n /**\n * Provides a Comparator for document producers which respects orderby sort order.\n * @returns Comparator Function\n * @hidden\n */\n public documentProducerComparator(docProd1: DocumentProducer, docProd2: DocumentProducer): any {\n return this.orderByComparator.compare(docProd1, docProd2);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OffsetLimitEndpointComponent implements ExecutionContext {\n constructor(\n private executionContext: ExecutionContext,\n private offset: number,\n private limit: number,\n ) {}\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n const aggregateHeaders = getInitialHeader();\n try {\n while (this.offset > 0) {\n // Grab next item but ignore the result. We only need the headers\n const { headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.offset--;\n mergeHeaders(aggregateHeaders, headers);\n }\n if (this.limit > 0) {\n const { result, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n this.limit--;\n mergeHeaders(aggregateHeaders, headers);\n return { result, headers: aggregateHeaders };\n }\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n // If both limit and offset are 0, return nothing\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n public hasMoreResults(): boolean {\n return (this.offset > 0 || this.limit > 0) && this.executionContext.hasMoreResults();\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OrderByEndpointComponent implements ExecutionContext {\n /**\n * Represents an endpoint in handling an order by query. For each processed orderby\n * result it returns 'payload' item of the result\n *\n * @param executionContext - Underlying Execution Context\n * @hidden\n */\n constructor(private executionContext: ExecutionContext) {}\n /**\n * Execute a provided function on the next element in the OrderByEndpointComponent.\n */\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { result: item, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n return {\n result: item !== undefined ? item.payload : undefined,\n headers,\n };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n /**\n * Determine if there are still remaining resources to processs.\n * @returns true if there is other elements to process in the OrderByEndpointComponent.\n */\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createHash } from \"crypto\";\n\nexport async function digest(str: string): Promise {\n const hash = createHash(\"sha256\");\n hash.update(str, \"utf8\");\n return hash.digest(\"hex\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { digest } from \"./digest\";\nimport stableStringify from \"fast-json-stable-stringify\";\n\nexport async function hashObject(object: unknown): Promise {\n const stringifiedObject = stableStringify(object);\n return digest(stringifiedObject);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class OrderedDistinctEndpointComponent implements ExecutionContext {\n private hashedLastResult: string;\n constructor(private executionContext: ExecutionContext) {}\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { headers, result } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (result) {\n const hashedResult = await hashObject(result);\n if (hashedResult === this.hashedLastResult) {\n return { result: undefined, headers };\n }\n this.hashedLastResult = hashedResult;\n }\n return { result, headers };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\n/** @hidden */\nexport class UnorderedDistinctEndpointComponent implements ExecutionContext {\n private hashedResults: Set;\n constructor(private executionContext: ExecutionContext) {\n this.hashedResults = new Set();\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { headers, result } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (result) {\n const hashedResult = await hashObject(result);\n if (this.hashedResults.has(hashedResult)) {\n return { result: undefined, headers };\n }\n this.hashedResults.add(hashedResult);\n }\n return { result, headers };\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults();\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// All aggregates are effectively a group by operation\n// The empty group is used for aggregates without a GROUP BY clause\nexport const emptyGroup = \"__empty__\";\n\n// Newer API versions rewrite the query to return `item2`. It fixes some legacy issues with the original `item` result\n// Aggregator code should use item2 when available\nexport const extractAggregateResult = (payload: { item2?: unknown; item: unknown }): any =>\n Object.keys(payload).length > 0 ? (payload.item2 ? payload.item2 : payload.item) : null;\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { CosmosHeaders } from \"../CosmosHeaders\";\nimport { QueryInfo } from \"../../request/ErrorResponse\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { Aggregator, createAggregator } from \"../Aggregators\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils\";\nimport { emptyGroup, extractAggregateResult } from \"./emptyGroup\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\ninterface GroupByResponse {\n result: GroupByResult;\n headers: CosmosHeaders;\n}\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> = new Map();\n private readonly aggregateResultArray: any[] = [];\n private completed: boolean = false;\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // If we have a full result set, begin returning results\n if (this.aggregateResultArray.length > 0) {\n return {\n result: this.aggregateResultArray.pop(),\n headers: getInitialHeader(),\n };\n }\n\n if (this.completed) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n const aggregateHeaders = getInitialHeader();\n try {\n while (this.executionContext.hasMoreResults()) {\n // Grab the next result\n const { result, headers } = (await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )) as GroupByResponse;\n mergeHeaders(aggregateHeaders, headers);\n\n // If it exists, process it via aggregators\n if (result) {\n const group = result.groupByItems ? await hashObject(result.groupByItems) : emptyGroup;\n const aggregators = this.groupings.get(group);\n const payload = result.payload;\n if (aggregators) {\n // Iterator over all results in the payload\n Object.keys(payload).map((key) => {\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 Object.keys(payload).map((key) => {\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 } catch (err: any) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n\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 {\n result: this.aggregateResultArray.pop(),\n headers: aggregateHeaders,\n };\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { CosmosHeaders } from \"../CosmosHeaders\";\nimport { AggregateType, QueryInfo } from \"../../request/ErrorResponse\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { Aggregator, createAggregator } from \"../Aggregators\";\nimport { getInitialHeader, mergeHeaders } from \"../headerUtils\";\nimport { emptyGroup, extractAggregateResult } from \"./emptyGroup\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nimport { RUConsumedManager } from \"../../common\";\n\ninterface GroupByResponse {\n result: GroupByResult;\n headers: CosmosHeaders;\n}\n\ninterface GroupByResult {\n groupByItems: any[];\n payload: any;\n}\n\n/** @hidden */\nexport class GroupByValueEndpointComponent implements ExecutionContext {\n private readonly aggregators: Map = new Map();\n private readonly aggregateResultArray: any[] = [];\n private aggregateType: AggregateType;\n private completed: boolean = false;\n\n constructor(\n private executionContext: ExecutionContext,\n private queryInfo: QueryInfo,\n ) {\n // VALUE queries will only every have a single grouping\n this.aggregateType = this.queryInfo.aggregates[0];\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // Start returning results if we have processed a full results set\n if (this.aggregateResultArray.length > 0) {\n return {\n result: this.aggregateResultArray.pop(),\n headers: getInitialHeader(),\n };\n }\n\n if (this.completed) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n const aggregateHeaders = getInitialHeader();\n try {\n while (this.executionContext.hasMoreResults()) {\n // Grab the next result\n const { result, headers } = (await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )) as GroupByResponse;\n mergeHeaders(aggregateHeaders, headers);\n\n // If it exists, process it via aggregators\n if (result) {\n let grouping: string = emptyGroup;\n let payload: any = result;\n if (result.groupByItems) {\n // If the query contains a GROUP BY clause, it will have a payload property and groupByItems\n payload = result.payload;\n grouping = await hashObject(result.groupByItems);\n }\n\n const aggregator = this.aggregators.get(grouping);\n if (!aggregator) {\n // This is the first time we have seen a grouping so create a new aggregator\n this.aggregators.set(grouping, createAggregator(this.aggregateType));\n }\n\n if (this.aggregateType) {\n const aggregateResult = extractAggregateResult(payload[0]);\n // if aggregate result is null, we need to short circuit aggregation and return undefined\n if (aggregateResult === null) {\n this.completed = true;\n }\n this.aggregators.get(grouping).aggregate(aggregateResult);\n } else {\n // Queries with no aggregates pass the payload directly to the aggregator\n // Example: SELECT VALUE c.team FROM c GROUP BY c.team\n this.aggregators.get(grouping).aggregate(payload);\n }\n }\n }\n } catch (err: any) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n\n // We bail early since we got an undefined result back `[{}]`\n if (this.completed) {\n return {\n result: undefined,\n headers: aggregateHeaders,\n };\n }\n // If no results are left in the underlying execution context, convert our aggregate results to an array\n for (const aggregator of this.aggregators.values()) {\n this.aggregateResultArray.push(aggregator.getResult());\n }\n this.completed = true;\n return {\n result: this.aggregateResultArray.pop(),\n headers: aggregateHeaders,\n };\n }\n\n public hasMoreResults(): boolean {\n return this.executionContext.hasMoreResults() || this.aggregateResultArray.length > 0;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport PriorityQueue from \"priorityqueuejs\";\n\nexport class NonStreamingOrderByPriorityQueue {\n private pq: PriorityQueue;\n private compareFn: (a: T, b: T) => number;\n private pqMaxSize: number;\n\n constructor(compareFn: (a: T, b: T) => number, pqMaxSize: number = 2000) {\n this.compareFn = compareFn;\n this.pq = new PriorityQueue(this.compareFn);\n this.pqMaxSize = pqMaxSize;\n }\n\n public enqueue(item: T): void {\n if (this.pq.size() < this.pqMaxSize) {\n this.pq.enq(item);\n } else {\n const topItem = this.pq.peek();\n if (this.compareFn(topItem, item) > 0) {\n this.pq.deq();\n this.pq.enq(item);\n }\n }\n }\n\n public dequeue(): T {\n return this.pq.deq();\n }\n\n public size(): number {\n return this.pq.size();\n }\n\n public isEmpty(): boolean {\n return this.pq.isEmpty();\n }\n\n public peek(): T {\n return this.pq.peek();\n }\n\n public getTopElements(): T[] {\n const elements: T[] = [];\n while (!this.pq.isEmpty()) {\n elements.unshift(this.pq.deq());\n }\n return elements;\n }\n\n // Create a new instance of NonStreamingOrderByPriorityQueue with a reversed compare function and the same maximum size.\n // Enqueue all elements from the current priority queue into the reverse priority queue.\n public reverse(): NonStreamingOrderByPriorityQueue {\n const reversePQ = new NonStreamingOrderByPriorityQueue(\n (a: T, b: T) => -this.compareFn(a, b),\n this.pqMaxSize,\n );\n while (!this.pq.isEmpty()) {\n reversePQ.enqueue(this.pq.deq());\n }\n return reversePQ;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport class NonStreamingOrderByMap {\n private map: Map;\n private compareFn: (a: T, b: T) => number;\n\n constructor(compareFn: (a: T, b: T) => number) {\n this.compareFn = compareFn;\n this.map = new Map();\n }\n\n public set(key: string, value: T): void {\n if (!this.map.has(key)) {\n this.map.set(key, value);\n } else {\n const oldValue = this.map.get(key);\n if (this.replaceResults(oldValue, value)) {\n this.map.set(key, value);\n }\n }\n }\n\n public get(key: string): T | undefined {\n if (!this.map.has(key)) return undefined;\n\n return this.map.get(key);\n }\n\n public getAllValues(): T[] {\n const res: T[] = [];\n for (const [key, value] of this.map) {\n res.push(value);\n this.map.delete(key);\n }\n return res;\n }\n\n private replaceResults(res1: T | undefined, res2: T | undefined): boolean {\n const res = this.compareFn(res1 as T, res2 as T);\n if (res < 0) return true;\n\n return false;\n }\n\n public size(): number {\n return this.map.size;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { NonStreamingOrderByResult } from \"./nonStreamingOrderByResult\";\n\n/** @hidden */\nconst TYPEORDCOMPARATOR: {\n [type: string]: { ord: number; compFunc?: (a: any, b: any) => number };\n} = Object.freeze({\n NoValue: {\n ord: 0,\n },\n undefined: {\n ord: 1,\n },\n boolean: {\n ord: 2,\n compFunc: (a: boolean, b: boolean) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n number: {\n ord: 4,\n compFunc: (a: number, b: number) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n string: {\n ord: 5,\n compFunc: (a: string, b: string) => {\n return a === b ? 0 : a > b ? 1 : -1;\n },\n },\n});\n\n/** @hidden */\nexport class OrderByComparator {\n constructor(public sortOrder: string[]) {}\n\n public compareItems(item1: NonStreamingOrderByResult, item2: NonStreamingOrderByResult): number {\n const orderByItemsRes1 = this.getOrderByItems(item1);\n const orderByItemsRes2 = this.getOrderByItems(item2);\n\n for (let i = 0; i < orderByItemsRes1.length; i++) {\n // compares the orderby items one by one\n const compRes = this.compareOrderByItem(orderByItemsRes1[i], orderByItemsRes2[i]);\n if (compRes !== 0) {\n if (this.sortOrder[i] === \"Descending\") {\n return compRes;\n } else if (this.sortOrder[i] === \"Ascending\") {\n return -compRes;\n }\n }\n }\n }\n\n private getOrderByItems(res: any): any {\n return res[\"orderByItems\"];\n }\n\n private compareOrderByItem(orderByItem1: any, orderByItem2: any): number {\n const type1 = this.getType(orderByItem1);\n const type2 = this.getType(orderByItem2);\n return this.compareValue(orderByItem1[\"item\"], type1, orderByItem2[\"item\"], type2);\n }\n\n private getType(\n orderByItem: any,\n ):\n | \"string\"\n | \"number\"\n | \"bigint\"\n | \"boolean\"\n | \"symbol\"\n | \"undefined\"\n | \"object\"\n | \"function\"\n | \"NoValue\" {\n // TODO: any item?\n if (orderByItem === undefined || orderByItem.item === undefined) {\n return \"NoValue\";\n }\n const type = typeof orderByItem.item;\n if (TYPEORDCOMPARATOR[type] === undefined) {\n throw new Error(`unrecognizable type ${type}`);\n }\n return type;\n }\n\n private compareValue(item1: unknown, type1: string, item2: unknown, type2: string): number {\n if (type1 === \"object\" || type2 === \"object\") {\n throw new Error(\"Tried to compare an object type\");\n }\n const type1Ord = TYPEORDCOMPARATOR[type1].ord;\n const type2Ord = TYPEORDCOMPARATOR[type2].ord;\n const typeCmp = type1Ord - type2Ord;\n\n if (typeCmp !== 0) {\n // if the types are different, use type ordinal\n return typeCmp;\n }\n\n // both are of the same type\n if (\n type1Ord === TYPEORDCOMPARATOR[\"undefined\"].ord ||\n type1Ord === TYPEORDCOMPARATOR[\"NoValue\"].ord\n ) {\n // if both types are undefined or Null they are equal\n return 0;\n }\n\n const compFunc = TYPEORDCOMPARATOR[type1].compFunc;\n if (typeof compFunc === \"undefined\") {\n throw new Error(\"Cannot find the comparison function\");\n }\n // same type and type is defined compare the items\n return compFunc(item1, item2);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryInfo, QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { getInitialHeader } from \"../headerUtils\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { hashObject } from \"../../utils/hashObject\";\nimport { RUConsumedManager } from \"../../common\";\nimport { NonStreamingOrderByResult } from \"../nonStreamingOrderByResult\";\nimport { NonStreamingOrderByResponse } from \"../nonStreamingOrderByResponse\";\nimport { NonStreamingOrderByPriorityQueue } from \"../../utils/nonStreamingOrderByPriorityQueue\";\nimport { NonStreamingOrderByMap } from \"../../utils/nonStreamingOrderByMap\";\nimport { OrderByComparator } from \"../orderByComparator\";\n\n/** @hidden */\nexport class NonStreamingOrderByDistinctEndpointComponent implements ExecutionContext {\n private aggregateMap: NonStreamingOrderByMap; // map to store distinct values before storing in pq.\n private nonStreamingOrderByPQ: NonStreamingOrderByPriorityQueue; // pq to compute final orderBy results\n private finalResultArray: NonStreamingOrderByResult[]; // result array to store final sorted and orderBy results.\n private sortOrders: string[];\n private isCompleted: boolean = false;\n\n constructor(\n private executionContext: ExecutionContext,\n private queryInfo: QueryInfo,\n private priorityQueueBufferSize: number,\n ) {\n this.sortOrders = this.queryInfo.orderBy;\n const comparator = new OrderByComparator(this.sortOrders);\n this.aggregateMap = new NonStreamingOrderByMap(\n (a: NonStreamingOrderByResult, b: NonStreamingOrderByResult) => {\n return comparator.compareItems(a, b);\n },\n );\n this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue(\n (a: NonStreamingOrderByResult, b: NonStreamingOrderByResult) => {\n return comparator.compareItems(b, a);\n },\n this.priorityQueueBufferSize,\n );\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // if size is 0, just return undefined. Valid if query is TOP 0 or LIMIT 0\n if (this.priorityQueueBufferSize === 0) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n let resHeaders = getInitialHeader();\n if (!this.isCompleted && this.executionContext.hasMoreResults()) {\n // Grab the next result\n const { result, headers } = (await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )) as NonStreamingOrderByResponse;\n resHeaders = headers;\n if (result) {\n // make hash of result object and update the map if required.\n const key = await hashObject(result?.payload);\n this.aggregateMap.set(key, result);\n }\n\n if (!this.executionContext.hasMoreResults()) {\n this.isCompleted = true;\n await this.buildFinalResultArray();\n }\n }\n if (this.isCompleted) {\n // start returning the results if final result is computed.\n if (this.finalResultArray.length > 0) {\n return {\n result: this.finalResultArray.shift(),\n headers: resHeaders,\n };\n } else {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n } else {\n // keep returning empty till final results are getting computed.\n return {\n result: {},\n headers: resHeaders,\n };\n }\n }\n /**\n * Build final sorted result array from which responses will be served.\n */\n private async buildFinalResultArray(): Promise {\n const allValues = this.aggregateMap.getAllValues();\n for (const value of allValues) {\n this.nonStreamingOrderByPQ.enqueue(value);\n }\n const offSet = this.queryInfo.offset ? this.queryInfo.offset : 0;\n const queueSize = this.nonStreamingOrderByPQ.size();\n const finalArraySize = queueSize - offSet;\n\n if (finalArraySize <= 0) {\n this.finalResultArray = [];\n } else {\n this.finalResultArray = new Array(finalArraySize);\n\n for (let count = finalArraySize - 1; count >= 0; count--) {\n this.finalResultArray[count] = this.nonStreamingOrderByPQ.dequeue()?.payload;\n }\n }\n }\n\n public hasMoreResults(): boolean {\n if (this.priorityQueueBufferSize === 0) return false;\n return this.executionContext.hasMoreResults() || this.finalResultArray.length > 0;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { RUConsumedManager } from \"../../common/RUConsumedManager\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { QueryOperationOptions, Response } from \"../../request\";\nimport { ExecutionContext } from \"../ExecutionContext\";\nimport { OrderByComparator } from \"../orderByComparator\";\nimport { NonStreamingOrderByResult } from \"../nonStreamingOrderByResult\";\nimport { NonStreamingOrderByPriorityQueue } from \"../../utils/nonStreamingOrderByPriorityQueue\";\nimport { getInitialHeader } from \"../headerUtils\";\nimport { RUCapPerOperationExceededErrorCode } from \"../../request/RUCapPerOperationExceededError\";\nexport class NonStreamingOrderByEndpointComponent implements ExecutionContext {\n private nonStreamingOrderByPQ: NonStreamingOrderByPriorityQueue;\n private isCompleted: boolean = false;\n /**\n * Represents an endpoint in handling an non-streaming order by query. For each processed orderby\n * result it returns 'payload' item of the result\n *\n * @param executionContext - Underlying Execution Context\n * @hidden\n */\n constructor(\n private executionContext: ExecutionContext,\n private sortOrders: any[],\n private priorityQueueBufferSize: number = 2000,\n private offset: number = 0,\n ) {\n const comparator = new OrderByComparator(this.sortOrders);\n this.nonStreamingOrderByPQ = new NonStreamingOrderByPriorityQueue(\n (a: NonStreamingOrderByResult, b: NonStreamingOrderByResult) => {\n return comparator.compareItems(b, a);\n },\n this.priorityQueueBufferSize,\n );\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n if (\n this.priorityQueueBufferSize <= 0 ||\n (this.isCompleted && this.nonStreamingOrderByPQ.isEmpty())\n ) {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n\n if (this.isCompleted && !this.nonStreamingOrderByPQ.isEmpty()) {\n const item = this.nonStreamingOrderByPQ.dequeue()?.payload;\n return {\n result: item,\n headers: getInitialHeader(),\n };\n }\n try {\n if (this.executionContext.hasMoreResults()) {\n const { result: item, headers } = await this.executionContext.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n if (item !== undefined) {\n this.nonStreamingOrderByPQ.enqueue(item);\n }\n return {\n result: {},\n headers,\n };\n } else {\n this.isCompleted = true;\n // Reverse the priority queue to get the results in the correct order\n this.nonStreamingOrderByPQ = this.nonStreamingOrderByPQ.reverse();\n // For offset limit case we set the size of priority queue to offset + limit\n // and we drain offset number of items from the priority queue\n while (this.offset < this.priorityQueueBufferSize && this.offset > 0) {\n this.nonStreamingOrderByPQ.dequeue();\n this.offset--;\n }\n\n if (this.nonStreamingOrderByPQ.size() !== 0) {\n const item = this.nonStreamingOrderByPQ.dequeue()?.payload;\n return {\n result: item,\n headers: getInitialHeader(),\n };\n } else {\n return {\n result: undefined,\n headers: getInitialHeader(),\n };\n }\n }\n } catch (err) {\n if (err.code === RUCapPerOperationExceededErrorCode) {\n err.fetchedResults = undefined;\n }\n throw err;\n }\n }\n\n /**\n * Determine if there are still remaining resources to processs.\n * @returns true if there is other elements to process in the NonStreamingOrderByEndpointComponent.\n */\n public hasMoreResults(): boolean {\n return (\n this.priorityQueueBufferSize > 0 &&\n (this.executionContext.hasMoreResults() || this.nonStreamingOrderByPQ.size() !== 0)\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../ClientContext\";\nimport { Response, FeedOptions, QueryOperationOptions } from \"../request\";\nimport { PartitionedQueryExecutionInfo, QueryInfo } from \"../request/ErrorResponse\";\nimport { CosmosHeaders } from \"./CosmosHeaders\";\nimport { OffsetLimitEndpointComponent } from \"./EndpointComponent/OffsetLimitEndpointComponent\";\nimport { OrderByEndpointComponent } from \"./EndpointComponent/OrderByEndpointComponent\";\nimport { OrderedDistinctEndpointComponent } from \"./EndpointComponent/OrderedDistinctEndpointComponent\";\nimport { UnorderedDistinctEndpointComponent } from \"./EndpointComponent/UnorderedDistinctEndpointComponent\";\nimport { GroupByEndpointComponent } from \"./EndpointComponent/GroupByEndpointComponent\";\nimport { ExecutionContext } from \"./ExecutionContext\";\nimport { getInitialHeader, mergeHeaders } from \"./headerUtils\";\nimport { OrderByQueryExecutionContext } from \"./orderByQueryExecutionContext\";\nimport { ParallelQueryExecutionContext } from \"./parallelQueryExecutionContext\";\nimport { GroupByValueEndpointComponent } from \"./EndpointComponent/GroupByValueEndpointComponent\";\nimport { SqlQuerySpec } from \"./SqlQuerySpec\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { RUCapPerOperationExceededErrorCode } from \"../request/RUCapPerOperationExceededError\";\nimport { Constants, RUConsumedManager } from \"../common\";\nimport { NonStreamingOrderByDistinctEndpointComponent } from \"./EndpointComponent/NonStreamingOrderByDistinctEndpointComponent\";\nimport { NonStreamingOrderByEndpointComponent } from \"./EndpointComponent/NonStreamingOrderByEndpointComponent\";\n\n/** @hidden */\nexport class PipelinedQueryExecutionContext implements ExecutionContext {\n private fetchBuffer: any[];\n private fetchMoreRespHeaders: CosmosHeaders;\n private endpoint: ExecutionContext;\n private pageSize: number;\n private vectorSearchBufferSize: number = 0;\n private static DEFAULT_PAGE_SIZE = 10;\n private static DEFAULT_VECTOR_SEARCH_BUFFER_SIZE = 2000;\n private nonStreamingOrderBy = false;\n\n constructor(\n private clientContext: ClientContext,\n private collectionLink: string,\n private query: string | SqlQuerySpec,\n private options: FeedOptions,\n private partitionedQueryExecutionInfo: PartitionedQueryExecutionInfo,\n ) {\n this.endpoint = null;\n this.pageSize = options[\"maxItemCount\"];\n if (this.pageSize === undefined) {\n this.pageSize = PipelinedQueryExecutionContext.DEFAULT_PAGE_SIZE;\n }\n // Pick between Nonstreaming and streaming endpoints\n this.nonStreamingOrderBy = partitionedQueryExecutionInfo.queryInfo.hasNonStreamingOrderBy;\n\n // Pick between parallel vs order by execution context\n const sortOrders = partitionedQueryExecutionInfo.queryInfo.orderBy;\n // TODO: Currently we don't get any field from backend to determine streaming queries\n if (this.nonStreamingOrderBy) {\n this.vectorSearchBufferSize = this.calculateVectorSearchBufferSize(\n partitionedQueryExecutionInfo.queryInfo,\n options,\n );\n\n const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType;\n const context: ExecutionContext = new ParallelQueryExecutionContext(\n this.clientContext,\n this.collectionLink,\n this.query,\n this.options,\n this.partitionedQueryExecutionInfo,\n );\n\n if (distinctType === \"None\") {\n this.endpoint = new NonStreamingOrderByEndpointComponent(\n context,\n sortOrders,\n this.vectorSearchBufferSize,\n partitionedQueryExecutionInfo.queryInfo.offset,\n );\n } else {\n this.endpoint = new NonStreamingOrderByDistinctEndpointComponent(\n context,\n partitionedQueryExecutionInfo.queryInfo,\n this.vectorSearchBufferSize,\n );\n }\n } else {\n if (Array.isArray(sortOrders) && sortOrders.length > 0) {\n // Need to wrap orderby execution context in endpoint component, since the data is nested as a \\\n // \"payload\" property.\n this.endpoint = new OrderByEndpointComponent(\n new OrderByQueryExecutionContext(\n this.clientContext,\n this.collectionLink,\n this.query,\n this.options,\n this.partitionedQueryExecutionInfo,\n ),\n );\n } else {\n this.endpoint = new ParallelQueryExecutionContext(\n this.clientContext,\n this.collectionLink,\n this.query,\n this.options,\n this.partitionedQueryExecutionInfo,\n );\n }\n if (\n Object.keys(partitionedQueryExecutionInfo.queryInfo.groupByAliasToAggregateType).length >\n 0 ||\n partitionedQueryExecutionInfo.queryInfo.aggregates.length > 0 ||\n partitionedQueryExecutionInfo.queryInfo.groupByExpressions.length > 0\n ) {\n if (partitionedQueryExecutionInfo.queryInfo.hasSelectValue) {\n this.endpoint = new GroupByValueEndpointComponent(\n this.endpoint,\n partitionedQueryExecutionInfo.queryInfo,\n );\n } else {\n this.endpoint = new GroupByEndpointComponent(\n this.endpoint,\n partitionedQueryExecutionInfo.queryInfo,\n );\n }\n }\n // If top then add that to the pipeline. TOP N is effectively OFFSET 0 LIMIT N\n const top = partitionedQueryExecutionInfo.queryInfo.top;\n if (typeof top === \"number\") {\n this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, 0, top);\n }\n\n // If offset+limit then add that to the pipeline\n const limit = partitionedQueryExecutionInfo.queryInfo.limit;\n const offset = partitionedQueryExecutionInfo.queryInfo.offset;\n if (typeof limit === \"number\" && typeof offset === \"number\") {\n this.endpoint = new OffsetLimitEndpointComponent(this.endpoint, offset, limit);\n }\n\n // If distinct then add that to the pipeline\n const distinctType = partitionedQueryExecutionInfo.queryInfo.distinctType;\n if (distinctType === \"Ordered\") {\n this.endpoint = new OrderedDistinctEndpointComponent(this.endpoint);\n }\n if (distinctType === \"Unordered\") {\n this.endpoint = new UnorderedDistinctEndpointComponent(this.endpoint);\n }\n }\n }\n\n public async nextItem(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n return this.endpoint.nextItem(diagnosticNode, operationOptions, ruConsumedManager);\n }\n\n // Removed callback here beacuse it wouldn't have ever worked...\n public hasMoreResults(): boolean {\n return this.endpoint.hasMoreResults();\n }\n\n public async fetchMore(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n // if the wrapped endpoint has different implementation for fetchMore use that\n // otherwise use the default implementation\n if (typeof this.endpoint.fetchMore === \"function\") {\n return this.endpoint.fetchMore(diagnosticNode, operationOptions, ruConsumedManager);\n } else {\n this.fetchBuffer = [];\n this.fetchMoreRespHeaders = getInitialHeader();\n return this.nonStreamingOrderBy\n ? this._nonStreamingFetchMoreImplementation(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n )\n : this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager);\n }\n }\n\n private async _fetchMoreImplementation(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { result: item, headers } = await this.endpoint.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n mergeHeaders(this.fetchMoreRespHeaders, headers);\n if (item === undefined) {\n // no more results\n if (this.fetchBuffer.length === 0) {\n return {\n result: undefined,\n headers: this.fetchMoreRespHeaders,\n };\n } else {\n // Just give what we have\n const temp = this.fetchBuffer;\n this.fetchBuffer = [];\n return { result: temp, headers: this.fetchMoreRespHeaders };\n }\n } else {\n this.fetchBuffer.push(item);\n if (this.fetchBuffer.length >= this.pageSize) {\n // fetched enough results\n const temp = this.fetchBuffer.slice(0, this.pageSize);\n this.fetchBuffer = this.fetchBuffer.splice(this.pageSize);\n return { result: temp, headers: this.fetchMoreRespHeaders };\n } else {\n // recursively fetch more\n // TODO: is recursion a good idea?\n return this._fetchMoreImplementation(diagnosticNode, operationOptions, ruConsumedManager);\n }\n }\n } catch (err: any) {\n mergeHeaders(this.fetchMoreRespHeaders, err.headers);\n err.headers = this.fetchMoreRespHeaders;\n if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) {\n err.fetchedResults.push(...this.fetchBuffer);\n }\n if (err) {\n throw err;\n }\n }\n }\n\n private async _nonStreamingFetchMoreImplementation(\n diagnosticNode: DiagnosticNodeInternal,\n operationOptions?: QueryOperationOptions,\n ruConsumedManager?: RUConsumedManager,\n ): Promise> {\n try {\n const { result: item, headers } = await this.endpoint.nextItem(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n mergeHeaders(this.fetchMoreRespHeaders, headers);\n if (item === undefined) {\n // no more results\n if (this.fetchBuffer.length === 0) {\n return {\n result: undefined,\n headers: this.fetchMoreRespHeaders,\n };\n } else {\n // Just give what we have\n const temp = this.fetchBuffer;\n this.fetchBuffer = [];\n return { result: temp, headers: this.fetchMoreRespHeaders };\n }\n } else {\n const ruConsumed = await ruConsumedManager.getRUConsumed();\n const maxRUAllowed =\n operationOptions && operationOptions.ruCapPerOperation\n ? operationOptions.ruCapPerOperation\n : Constants.NonStreamingQueryDefaultRUThreshold;\n // append the result\n if (typeof item !== \"object\") {\n this.fetchBuffer.push(item);\n } else if (Object.keys(item).length !== 0) {\n this.fetchBuffer.push(item);\n }\n if (this.fetchBuffer.length >= this.pageSize) {\n // fetched enough results\n const temp = this.fetchBuffer.slice(0, this.pageSize);\n this.fetchBuffer = this.fetchBuffer.splice(this.pageSize);\n return { result: temp, headers: this.fetchMoreRespHeaders };\n } else if (ruConsumed * 2 < maxRUAllowed) {\n // recursively fetch more only if we have more than 50% RUs left.\n return this._nonStreamingFetchMoreImplementation(\n diagnosticNode,\n operationOptions,\n ruConsumedManager,\n );\n } else {\n return { result: [], headers: this.fetchMoreRespHeaders };\n }\n }\n } catch (err: any) {\n mergeHeaders(this.fetchMoreRespHeaders, err.headers);\n err.headers = this.fetchMoreRespHeaders;\n if (err.code === RUCapPerOperationExceededErrorCode && err.fetchedResults) {\n err.fetchedResults.push(...this.fetchBuffer);\n }\n if (err) {\n throw err;\n }\n }\n }\n\n private calculateVectorSearchBufferSize(queryInfo: QueryInfo, options: FeedOptions): number {\n if (queryInfo.top === 0 || queryInfo.limit === 0) return 0;\n return queryInfo.top\n ? queryInfo.top\n : queryInfo.limit\n ? queryInfo.offset + queryInfo.limit\n : options[\"vectorSearchBufferSize\"] && options[\"vectorSearchBufferSize\"] > 0\n ? options[\"vectorSearchBufferSize\"]\n : PipelinedQueryExecutionContext.DEFAULT_VECTOR_SEARCH_BUFFER_SIZE;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// \n\nimport { ClientContext } from \"./ClientContext\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { getPathFromLink, ResourceType, StatusCodes, RUConsumedManager } from \"./common\";\nimport {\n CosmosHeaders,\n DefaultQueryExecutionContext,\n ExecutionContext,\n FetchFunctionCallback,\n getInitialHeader,\n mergeHeaders,\n PipelinedQueryExecutionContext,\n SqlQuerySpec,\n} from \"./queryExecutionContext\";\nimport { Response } from \"./request\";\nimport { ErrorResponse, PartitionedQueryExecutionInfo } from \"./request/ErrorResponse\";\nimport { FeedOptions } from \"./request/FeedOptions\";\nimport { FeedResponse } from \"./request/FeedResponse\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n withMetadataDiagnostics,\n} from \"./utils/diagnostics\";\nimport { MetadataLookUpType } from \"./CosmosDiagnostics\";\nimport { QueryOperationOptions } from \"./request/OperationOptions\";\nimport { RUCapPerOperationExceededErrorCode } from \"./request/RUCapPerOperationExceededError\";\n\n/**\n * Represents a QueryIterator Object, an implementation of feed or query response that enables\n * traversal and iterating over the response\n * in the Azure Cosmos DB database service.\n */\nexport class QueryIterator {\n private fetchAllTempResources: T[]; // TODO\n private fetchAllLastResHeaders: CosmosHeaders;\n private queryExecutionContext: ExecutionContext;\n private queryPlanPromise: Promise>;\n private isInitialized: boolean;\n private nonStreamingOrderBy: boolean = false;\n /**\n * @hidden\n */\n constructor(\n private clientContext: ClientContext,\n private query: SqlQuerySpec | string,\n private options: FeedOptions,\n private fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[],\n private resourceLink?: string,\n private resourceType?: ResourceType,\n ) {\n this.query = query;\n this.fetchFunctions = fetchFunctions;\n this.options = options || {};\n this.resourceLink = resourceLink;\n this.fetchAllLastResHeaders = getInitialHeader();\n this.reset();\n this.isInitialized = false;\n }\n\n /**\n * Gets an async iterator that will yield results until completion.\n *\n * NOTE: AsyncIterators are a very new feature and you might need to\n * use polyfils/etc. in order to use them in your code.\n *\n * If you're using TypeScript, you can use the following polyfill as long\n * as you target ES6 or higher and are running on Node 6 or higher.\n *\n * ```typescript\n * if (!Symbol || !Symbol.asyncIterator) {\n * (Symbol as any).asyncIterator = Symbol.for(\"Symbol.asyncIterator\");\n * }\n * ```\n *\n * @example Iterate over all databases\n * ```typescript\n * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) {\n * console.log(`Got ${db} from AsyncIterator`);\n * }\n * ```\n */\n public async *getAsyncIterator(options?: QueryOperationOptions): AsyncIterable> {\n this.reset();\n let diagnosticNode = new DiagnosticNodeInternal(\n this.clientContext.diagnosticLevel,\n DiagnosticNodeType.CLIENT_REQUEST_NODE,\n null,\n );\n this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode);\n let ruConsumedManager: RUConsumedManager | undefined;\n if (options && options.ruCapPerOperation) {\n ruConsumedManager = new RUConsumedManager();\n }\n while (this.queryExecutionContext.hasMoreResults()) {\n let response: Response;\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (error: any) {\n if (this.needsQueryPlan(error)) {\n await this.createPipelinedExecutionContext();\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (queryError: any) {\n this.handleSplitError(queryError);\n }\n } else {\n throw error;\n }\n }\n\n const feedResponse = new FeedResponse(\n response.result,\n response.headers,\n this.queryExecutionContext.hasMoreResults(),\n diagnosticNode.toDiagnostic(this.clientContext.getClientConfig()),\n );\n diagnosticNode = new DiagnosticNodeInternal(\n this.clientContext.diagnosticLevel,\n DiagnosticNodeType.CLIENT_REQUEST_NODE,\n null,\n );\n if (response.result !== undefined) {\n yield feedResponse;\n }\n }\n }\n\n /**\n * Determine if there are still remaining resources to process based on the value of the continuation token or the\n * elements remaining on the current batch in the QueryIterator.\n * @returns true if there is other elements to process in the QueryIterator.\n */\n public hasMoreResults(): boolean {\n return this.queryExecutionContext.hasMoreResults();\n }\n\n /**\n * Fetch all pages for the query and return a single FeedResponse.\n */\n\n public async fetchAll(options?: QueryOperationOptions): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.fetchAllInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async fetchAllInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: QueryOperationOptions,\n ): Promise> {\n this.reset();\n let response: FeedResponse;\n try {\n response = await this.toArrayImplementation(diagnosticNode, options);\n } catch (error: any) {\n this.handleSplitError(error);\n }\n return response;\n }\n\n /**\n * Retrieve the next batch from the feed.\n *\n * This may or may not fetch more pages from the backend depending on your settings\n * and the type of query. Aggregate queries will generally fetch all backend pages\n * before returning the first batch of responses.\n */\n public async fetchNext(options?: QueryOperationOptions): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n // Enabling RU metrics for all the fetchNext operations\n const ruConsumedManager: RUConsumedManager = new RUConsumedManager();\n this.queryPlanPromise = withMetadataDiagnostics(\n async (metadataNode: DiagnosticNodeInternal) => {\n return this.fetchQueryPlan(metadataNode);\n },\n diagnosticNode,\n MetadataLookUpType.QueryPlanLookUp,\n );\n if (!this.isInitialized) {\n await this.init();\n }\n\n let response: Response;\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (error: any) {\n if (this.needsQueryPlan(error)) {\n await this.createPipelinedExecutionContext();\n try {\n response = await this.queryExecutionContext.fetchMore(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (queryError: any) {\n this.handleSplitError(queryError);\n }\n } else {\n throw error;\n }\n }\n return new FeedResponse(\n response.result,\n response.headers,\n this.queryExecutionContext.hasMoreResults(),\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Reset the QueryIterator to the beginning and clear all the resources inside it\n */\n public reset(): void {\n this.queryPlanPromise = undefined;\n this.fetchAllLastResHeaders = getInitialHeader();\n this.fetchAllTempResources = [];\n this.queryExecutionContext = new DefaultQueryExecutionContext(\n this.options,\n this.fetchFunctions,\n );\n }\n\n private async toArrayImplementation(\n diagnosticNode: DiagnosticNodeInternal,\n options?: QueryOperationOptions,\n ): Promise> {\n let ruConsumedManager: RUConsumedManager | undefined;\n if (options && options.ruCapPerOperation) {\n ruConsumedManager = new RUConsumedManager();\n }\n this.queryPlanPromise = withMetadataDiagnostics(\n async (metadataNode: DiagnosticNodeInternal) => {\n return this.fetchQueryPlan(metadataNode);\n },\n diagnosticNode,\n MetadataLookUpType.QueryPlanLookUp,\n );\n\n // this.queryPlanPromise = this.fetchQueryPlan(diagnosticNode);\n if (!this.isInitialized) {\n await this.init();\n }\n while (this.queryExecutionContext.hasMoreResults()) {\n let response: Response;\n try {\n response = await this.queryExecutionContext.nextItem(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } catch (error: any) {\n if (this.needsQueryPlan(error)) {\n await this.createPipelinedExecutionContext();\n response = await this.queryExecutionContext.nextItem(\n diagnosticNode,\n options,\n ruConsumedManager,\n );\n } else if (error.code === RUCapPerOperationExceededErrorCode && error.fetchedResults) {\n error.fetchedResults.forEach((item: any) => {\n this.fetchAllTempResources.push(item);\n });\n error.fetchedResults = this.fetchAllTempResources;\n throw error;\n } else {\n throw error;\n }\n }\n const { result, headers } = response;\n // concatenate the results and fetch more\n mergeHeaders(this.fetchAllLastResHeaders, headers);\n if (result !== undefined) {\n if (\n this.nonStreamingOrderBy &&\n typeof result === \"object\" &&\n Object.keys(result).length === 0\n ) {\n // ignore empty results from NonStreamingOrderBy Endpoint components.\n } else this.fetchAllTempResources.push(result);\n }\n }\n return new FeedResponse(\n this.fetchAllTempResources,\n this.fetchAllLastResHeaders,\n this.queryExecutionContext.hasMoreResults(),\n getEmptyCosmosDiagnostics(),\n );\n }\n\n private async createPipelinedExecutionContext(): Promise {\n const queryPlanResponse = await this.queryPlanPromise;\n\n // We always coerce queryPlanPromise to resolved. So if it errored, we need to manually inspect the resolved value\n if (queryPlanResponse instanceof Error) {\n throw queryPlanResponse;\n }\n\n const queryPlan = queryPlanResponse.result;\n const queryInfo = queryPlan.queryInfo;\n this.nonStreamingOrderBy = queryInfo.hasNonStreamingOrderBy ? true : false;\n if (queryInfo.aggregates.length > 0 && queryInfo.hasSelectValue === false) {\n throw new Error(\"Aggregate queries must use the VALUE keyword\");\n }\n this.queryExecutionContext = new PipelinedQueryExecutionContext(\n this.clientContext,\n this.resourceLink,\n this.query,\n this.options,\n queryPlan,\n );\n }\n\n private async fetchQueryPlan(diagnosticNode: DiagnosticNodeInternal): Promise {\n if (!this.queryPlanPromise && this.resourceType === ResourceType.item) {\n return this.clientContext\n .getQueryPlan(\n getPathFromLink(this.resourceLink) + \"/docs\",\n ResourceType.item,\n this.resourceLink,\n this.query,\n this.options,\n diagnosticNode,\n )\n .catch((error: any) => error); // Without this catch, node reports an unhandled rejection. So we stash the promise as resolved even if it errored.\n }\n return this.queryPlanPromise;\n }\n\n private needsQueryPlan(error: ErrorResponse): error is ErrorResponse {\n let needsQueryPlanValue = false;\n if (\n error.body?.additionalErrorInfo ||\n error.message.includes(\"Cross partition query only supports\")\n ) {\n needsQueryPlanValue =\n error.code === StatusCodes.BadRequest && this.resourceType === ResourceType.item;\n }\n return needsQueryPlanValue;\n }\n\n private initPromise: Promise;\n private async init(): Promise {\n if (this.isInitialized === true) {\n return;\n }\n if (this.initPromise === undefined) {\n this.initPromise = this._init();\n }\n return this.initPromise;\n }\n private async _init(): Promise {\n if (this.options.forceQueryPlan === true && this.resourceType === ResourceType.item) {\n await this.createPipelinedExecutionContext();\n }\n this.isInitialized = true;\n }\n\n private handleSplitError(err: any): void {\n if (err.code === 410) {\n const error = new Error(\n \"Encountered partition split and could not recover. This request is retryable\",\n ) as any;\n error.code = 503;\n error.originalError = err;\n throw error;\n } else {\n throw err;\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Conflict } from \"./Conflict\";\nimport { ConflictDefinition } from \"./ConflictDefinition\";\n\nexport class ConflictResponse extends ResourceResponse {\n constructor(\n resource: ConflictDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n conflict: Conflict,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.conflict = conflict;\n }\n /** A reference to the {@link Conflict} corresponding to the returned {@link ConflictDefinition}. */\n public readonly conflict: Conflict;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { PartitionKeyDefinition } from \"../documents\";\nimport { Container } from \"./Container\";\n\nexport async function readPartitionKeyDefinition(\n diagnosticNode: DiagnosticNodeInternal,\n container: Container,\n): Promise {\n const partitionKeyDefinition = await container.readPartitionKeyDefinition(diagnosticNode);\n return partitionKeyDefinition.resource;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, getIdFromLink, getPathFromLink, ResourceType } from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { ConflictDefinition } from \"./ConflictDefinition\";\nimport { ConflictResponse } from \"./ConflictResponse\";\nimport { undefinedPartitionKey } from \"../../extractPartitionKey\";\nimport { PartitionKey } from \"../../documents\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Use to read or delete a given {@link Conflict} by id.\n *\n * @see {@link Conflicts} to query or read all conflicts.\n */\nexport class Conflict {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return `/${this.container.url}/${Constants.Path.ConflictsPathSegment}/${this.id}`;\n }\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link Conflict}.\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n private partitionKey?: PartitionKey,\n ) {\n this.partitionKey = partitionKey;\n }\n\n /**\n * Read the {@link ConflictDefinition} for the given {@link Conflict}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url, ResourceType.conflicts);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n\n return new ConflictResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link ConflictDefinition}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = undefinedPartitionKey(partitionKeyDefinition);\n }\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.conflicts,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n return new ConflictResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { ConflictDefinition } from \"./ConflictDefinition\";\n\n/**\n * Use to query or read all conflicts.\n *\n * @see {@link Conflict} to read or delete a given {@link Conflict} by id.\n */\nexport class Conflicts {\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Queries all conflicts.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all conflicts.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time.\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.conflicts);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(\n this.clientContext,\n query,\n options,\n (diagNode: DiagnosticNodeInternal, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.conflicts,\n resourceId: id,\n resultFn: (result) => result.Conflicts,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n },\n );\n }\n\n /**\n * Reads all conflicts\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nexport enum ConflictResolutionMode {\n Custom = \"Custom\",\n LastWriterWins = \"LastWriterWins\",\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request/ResourceResponse\";\nimport { Resource } from \"../Resource\";\nimport { Item } from \"./Item\";\nimport { ItemDefinition } from \"./ItemDefinition\";\n\nexport class ItemResponse extends ResourceResponse {\n constructor(\n resource: T & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n subsstatusCode: number,\n item: Item,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics, subsstatusCode);\n this.item = item;\n }\n /** Reference to the {@link Item} the response corresponds to. */\n public readonly item: Item;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createDocumentUri,\n getIdFromLink,\n getPathFromLink,\n isItemResourceValid,\n ResourceType,\n StatusCodes,\n} from \"../../common\";\nimport { PartitionKey, PartitionKeyInternal, convertToInternalPartitionKey } from \"../../documents\";\nimport { extractPartitionKeys, undefinedPartitionKey } from \"../../extractPartitionKey\";\nimport { RequestOptions, Response } from \"../../request\";\nimport { PatchRequestBody } from \"../../utils/patch\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { ItemDefinition } from \"./ItemDefinition\";\nimport { ItemResponse } from \"./ItemResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to perform operations on a specific item.\n *\n * @see {@link Items} for operations on all items; see `container.items`.\n */\nexport class Item {\n private partitionKey: PartitionKeyInternal;\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createDocumentUri(this.container.database.id, this.container.id, this.id);\n }\n\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link Item}.\n * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers).\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n partitionKey?: PartitionKey,\n ) {\n this.partitionKey =\n partitionKey === undefined ? undefined : convertToInternalPartitionKey(partitionKey);\n }\n\n /**\n * Read the item's definition.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype.\n * It's recommended to only use interfaces.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param options - Additional options for the request\n *\n * @example Using custom type for response\n * ```typescript\n * interface TodoItem {\n * title: string;\n * done: bool;\n * id: string;\n * }\n *\n * let item: TodoItem;\n * ({body: item} = await item.read());\n * ```\n */\n public async read(\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = undefinedPartitionKey(partitionKeyDefinition);\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n let response: Response;\n try {\n response = await this.clientContext.read({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n } catch (error: any) {\n if (error.code !== StatusCodes.NotFound) {\n throw error;\n }\n response = error;\n }\n\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the item's definition.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - The definition to replace the existing {@link Item}'s definition with.\n * @param options - Additional options for the request\n */\n public replace(\n body: ItemDefinition,\n options?: RequestOptions,\n ): Promise>;\n /**\n * Replace the item's definition.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - The definition to replace the existing {@link Item}'s definition with.\n * @param options - Additional options for the request\n */\n public replace(\n body: T,\n options?: RequestOptions,\n ): Promise>;\n public async replace(\n body: T,\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = extractPartitionKeys(body, partitionKeyResponse);\n }\n\n const err = {};\n if (!isItemResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * @param options - Additional options for the request\n */\n public async delete(\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = undefinedPartitionKey(partitionKeyResponse);\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Perform a JSONPatch on the item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * @param options - Additional options for the request\n */\n public async patch(\n body: PatchRequestBody,\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (this.partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n this.partitionKey = extractPartitionKeys(body, partitionKeyResponse);\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.patch({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey: this.partitionKey,\n diagnosticNode,\n });\n\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"./CosmosDiagnostics\";\nimport { Constants } from \"./common\";\nimport { CosmosHeaders } from \"./queryExecutionContext\";\n\n/**\n * A single response page from the Azure Cosmos DB Change Feed\n */\nexport class ChangeFeedResponse {\n /**\n * @internal\n */\n constructor(\n /**\n * Gets the items returned in the response from Azure Cosmos DB\n */\n public readonly result: T,\n /**\n * Gets the number of items returned in the response from Azure Cosmos DB\n */\n public readonly count: number,\n /**\n * Gets the status code of the response from Azure Cosmos DB\n */\n public readonly statusCode: number,\n headers: CosmosHeaders,\n public readonly diagnostics: CosmosDiagnostics,\n ) {\n this.headers = Object.freeze(headers);\n }\n\n /**\n * Gets the request charge for this request from the Azure Cosmos DB service.\n */\n public get requestCharge(): number {\n const rus = this.headers[Constants.HttpHeaders.RequestCharge];\n return rus ? parseInt(rus, 10) : null;\n }\n\n /**\n * Gets the activity ID for the request from the Azure Cosmos DB service.\n */\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId];\n }\n\n /**\n * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.\n *\n * This is equivalent to the `etag` property.\n */\n public get continuation(): string {\n return this.etag;\n }\n\n /**\n * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.\n */\n public get sessionToken(): string {\n return this.headers[Constants.HttpHeaders.SessionToken];\n }\n\n /**\n * Gets the entity tag associated with last transaction in the Azure Cosmos DB service,\n * which can be used as If-Non-Match Access condition for ReadFeed REST request or\n * `continuation` property of `ChangeFeedOptions` parameter for\n * `Items.changeFeed()`\n * to get feed changes since the transaction specified by this entity tag.\n *\n * This is equivalent to the `continuation` property.\n */\n public get etag(): string {\n return this.headers[Constants.HttpHeaders.ETag];\n }\n\n /**\n * Response headers of the response from Azure Cosmos DB\n */\n public headers: CosmosHeaders;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/// \nimport { ChangeFeedOptions } from \"./ChangeFeedOptions\";\nimport { ChangeFeedResponse } from \"./ChangeFeedResponse\";\nimport { Resource } from \"./client\";\nimport { ClientContext } from \"./ClientContext\";\nimport { Constants, ResourceType, StatusCodes } from \"./common\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { PartitionKey } from \"./documents\";\nimport { FeedOptions } from \"./request\";\nimport { Response } from \"./request\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"./utils/diagnostics\";\n\n/**\n * Provides iterator for change feed.\n *\n * Use `Items.changeFeed()` to get an instance of the iterator.\n */\nexport class ChangeFeedIterator {\n private static readonly IfNoneMatchAllHeaderValue = \"*\";\n private nextIfNoneMatch: string;\n private ifModifiedSince: string;\n private lastStatusCode: number;\n private isPartitionSpecified: boolean;\n\n /**\n * @internal\n */\n constructor(\n private clientContext: ClientContext,\n private resourceId: string,\n private resourceLink: string,\n private partitionKey: PartitionKey,\n private changeFeedOptions: ChangeFeedOptions,\n ) {\n // partition key XOR partition key range id\n const partitionKeyValid = partitionKey !== undefined;\n this.isPartitionSpecified = partitionKeyValid;\n\n let canUseStartFromBeginning = true;\n if (changeFeedOptions.continuation) {\n this.nextIfNoneMatch = changeFeedOptions.continuation;\n canUseStartFromBeginning = false;\n }\n\n if (changeFeedOptions.startTime) {\n // .toUTCString() is platform specific, but most platforms use RFC 1123.\n // In ECMAScript 2018, this was standardized to RFC 1123.\n // See for more info: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString\n this.ifModifiedSince = changeFeedOptions.startTime.toUTCString();\n canUseStartFromBeginning = false;\n }\n\n if (canUseStartFromBeginning && !changeFeedOptions.startFromBeginning) {\n this.nextIfNoneMatch = ChangeFeedIterator.IfNoneMatchAllHeaderValue;\n }\n }\n\n /**\n * Gets a value indicating whether there are potentially additional results that can be retrieved.\n *\n * Initially returns true. This value is set based on whether the last execution returned a continuation token.\n *\n * @returns Boolean value representing if whether there are potentially additional results that can be retrieved.\n */\n get hasMoreResults(): boolean {\n return this.lastStatusCode !== StatusCodes.NotModified;\n }\n\n /**\n * Gets an async iterator which will yield pages of results from Azure Cosmos DB.\n */\n public async *getAsyncIterator(): AsyncIterable>> {\n do {\n const result = await this.fetchNext();\n if (result.count > 0) {\n yield result;\n }\n } while (this.hasMoreResults);\n }\n\n /**\n * Read feed and retrieves the next page of results in Azure Cosmos DB.\n */\n public async fetchNext(): Promise>> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const response = await this.getFeedResponse(diagnosticNode);\n this.lastStatusCode = response.statusCode;\n this.nextIfNoneMatch = response.headers[Constants.HttpHeaders.ETag];\n return response;\n }, this.clientContext);\n }\n\n private async getFeedResponse(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n if (!this.isPartitionSpecified) {\n throw new Error(\n \"Container is partitioned, but no partition key or partition key range id was specified.\",\n );\n }\n const feedOptions: FeedOptions = { initialHeaders: {}, useIncrementalFeed: true };\n\n if (typeof this.changeFeedOptions.maxItemCount === \"number\") {\n feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount;\n }\n\n if (this.changeFeedOptions.sessionToken) {\n feedOptions.sessionToken = this.changeFeedOptions.sessionToken;\n }\n\n if (this.nextIfNoneMatch) {\n feedOptions.accessCondition = {\n type: Constants.HttpHeaders.IfNoneMatch,\n condition: this.nextIfNoneMatch,\n };\n }\n\n if (this.ifModifiedSince) {\n feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.ifModifiedSince;\n }\n\n const response: Response> = await (this.clientContext.queryFeed({\n path: this.resourceLink,\n resourceType: ResourceType.item,\n resourceId: this.resourceId,\n resultFn: (result) => (result ? result.Documents : []),\n query: undefined,\n options: feedOptions,\n partitionKey: this.partitionKey,\n diagnosticNode: diagnosticNode,\n }) as Promise); // TODO: some funky issues with query feed. Probably need to change it up.\n\n return new ChangeFeedResponse(\n response.result,\n response.result ? response.result.length : 0,\n response.code,\n response.headers,\n getEmptyCosmosDiagnostics(),\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const BytePrefix = {\n Undefined: \"00\",\n Null: \"01\",\n False: \"02\",\n True: \"03\",\n MinNumber: \"04\",\n Number: \"05\",\n MaxNumber: \"06\",\n MinString: \"07\",\n String: \"08\",\n MaxString: \"09\",\n Int64: \"0a\",\n Int32: \"0b\",\n Int16: \"0c\",\n Int8: \"0d\",\n Uint64: \"0e\",\n Uint32: \"0f\",\n Uint16: \"10\",\n Uint8: \"11\",\n Binary: \"12\",\n Guid: \"13\",\n Float: \"14\",\n Infinity: \"FF\",\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport JSBI from \"jsbi\";\nimport { BytePrefix } from \"./prefix\";\n\nexport function writeNumberForBinaryEncodingJSBI(hash: number): Buffer {\n let payload = encodeNumberAsUInt64JSBI(hash);\n let outputStream = Buffer.from(BytePrefix.Number, \"hex\");\n const firstChunk = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56)));\n\n outputStream = Buffer.concat([outputStream, Buffer.from(firstChunk.toString(16), \"hex\")]);\n payload = JSBI.asUintN(64, JSBI.leftShift(JSBI.BigInt(payload), JSBI.BigInt(0x8)));\n\n let byteToWrite = JSBI.BigInt(0);\n let firstIteration = false;\n let shifted: JSBI;\n let padded: string;\n\n do {\n if (!firstIteration) {\n // we pad because after shifting because we will produce characters like \"f\" or similar,\n // which cannot be encoded as hex in a buffer because they are invalid hex\n // https://github.com/nodejs/node/issues/24491\n padded = byteToWrite.toString(16).padStart(2, \"0\");\n if (padded !== \"00\") {\n outputStream = Buffer.concat([outputStream, Buffer.from(padded, \"hex\")]);\n }\n } else {\n firstIteration = false;\n }\n\n shifted = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56)));\n byteToWrite = JSBI.asUintN(64, JSBI.bitwiseOr(shifted, JSBI.BigInt(0x01)));\n payload = JSBI.asUintN(64, JSBI.leftShift(payload, JSBI.BigInt(7)));\n } while (JSBI.notEqual(payload, JSBI.BigInt(0)));\n\n const lastChunk = JSBI.asUintN(64, JSBI.bitwiseAnd(byteToWrite, JSBI.BigInt(0xfe)));\n // we pad because after shifting because we will produce characters like \"f\" or similar,\n // which cannot be encoded as hex in a buffer because they are invalid hex\n // https://github.com/nodejs/node/issues/24491\n padded = lastChunk.toString(16).padStart(2, \"0\");\n if (padded !== \"00\") {\n outputStream = Buffer.concat([outputStream, Buffer.from(padded, \"hex\")]);\n }\n\n return outputStream;\n}\n\nfunction encodeNumberAsUInt64JSBI(value: number): JSBI {\n const rawValueBits = getRawBitsJSBI(value);\n const mask = JSBI.BigInt(0x8000000000000000);\n const returned =\n rawValueBits < mask\n ? JSBI.bitwiseXor(rawValueBits, mask)\n : JSBI.add(JSBI.bitwiseNot(rawValueBits), JSBI.BigInt(1));\n return returned;\n}\n\nexport function doubleToByteArrayJSBI(double: number): Buffer {\n const output: Buffer = Buffer.alloc(8);\n const lng = getRawBitsJSBI(double);\n for (let i = 0; i < 8; i++) {\n output[i] = JSBI.toNumber(\n JSBI.bitwiseAnd(\n JSBI.signedRightShift(lng, JSBI.multiply(JSBI.BigInt(i), JSBI.BigInt(8))),\n JSBI.BigInt(0xff),\n ),\n );\n }\n return output;\n}\n\nfunction getRawBitsJSBI(value: number): JSBI {\n const view = new DataView(new ArrayBuffer(8));\n view.setFloat64(0, value);\n return JSBI.BigInt(`0x${buf2hex(view.buffer)}`);\n}\n\nfunction buf2hex(buffer: ArrayBuffer): string {\n return Array.prototype.map\n .call(new Uint8Array(buffer), (x: number) => (\"00\" + x.toString(16)).slice(-2))\n .join(\"\");\n}\n","// +----------------------------------------------------------------------+\n// | murmurHash3js.js v3.0.1 // https://github.com/pid/murmurHash3js\n// | A javascript implementation of MurmurHash3's x86 hashing algorithms. |\n// |----------------------------------------------------------------------|\n// | Copyright (c) 2012-2015 Karan Lyons |\n// | https://github.com/karanlyons/murmurHash3.js/blob/c1778f75792abef7bdd74bc85d2d4e1a3d25cfe9/murmurHash3.js |\n// | Freely distributable under the MIT license. |\n// +----------------------------------------------------------------------+\n\n// PRIVATE FUNCTIONS\n// -----------------\n\nfunction _x86Multiply(m: number, n: number) {\n //\n // Given two 32bit ints, returns the two multiplied together as a\n // 32bit int.\n //\n\n return (m & 0xffff) * n + ((((m >>> 16) * n) & 0xffff) << 16);\n}\n\nfunction _x86Rotl(m: number, n: number) {\n //\n // Given a 32bit int and an int representing a number of bit positions,\n // returns the 32bit int rotated left by that number of positions.\n //\n\n return (m << n) | (m >>> (32 - n));\n}\n\nfunction _x86Fmix(h: number) {\n //\n // Given a block, returns murmurHash3's final x86 mix of that block.\n //\n\n h ^= h >>> 16;\n h = _x86Multiply(h, 0x85ebca6b);\n h ^= h >>> 13;\n h = _x86Multiply(h, 0xc2b2ae35);\n h ^= h >>> 16;\n\n return h;\n}\n\nfunction _x64Add(m: number[], n: number[]) {\n //\n // Given two 64bit ints (as an array of two 32bit ints) returns the two\n // added together as a 64bit int (as an array of two 32bit ints).\n //\n\n m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];\n n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];\n const o = [0, 0, 0, 0];\n\n o[3] += m[3] + n[3];\n o[2] += o[3] >>> 16;\n o[3] &= 0xffff;\n\n o[2] += m[2] + n[2];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n\n o[1] += m[1] + n[1];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[0] += m[0] + n[0];\n o[0] &= 0xffff;\n\n return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];\n}\n\nfunction _x64Multiply(m: number[], n: number[]) {\n //\n // Given two 64bit ints (as an array of two 32bit ints) returns the two\n // multiplied together as a 64bit int (as an array of two 32bit ints).\n //\n\n m = [m[0] >>> 16, m[0] & 0xffff, m[1] >>> 16, m[1] & 0xffff];\n n = [n[0] >>> 16, n[0] & 0xffff, n[1] >>> 16, n[1] & 0xffff];\n const o = [0, 0, 0, 0];\n\n o[3] += m[3] * n[3];\n o[2] += o[3] >>> 16;\n o[3] &= 0xffff;\n\n o[2] += m[2] * n[3];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n\n o[2] += m[3] * n[2];\n o[1] += o[2] >>> 16;\n o[2] &= 0xffff;\n\n o[1] += m[1] * n[3];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[1] += m[2] * n[2];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[1] += m[3] * n[1];\n o[0] += o[1] >>> 16;\n o[1] &= 0xffff;\n\n o[0] += m[0] * n[3] + m[1] * n[2] + m[2] * n[1] + m[3] * n[0];\n o[0] &= 0xffff;\n\n return [(o[0] << 16) | o[1], (o[2] << 16) | o[3]];\n}\n\nfunction _x64Rotl(m: number[], n: number) {\n //\n // Given a 64bit int (as an array of two 32bit ints) and an int\n // representing a number of bit positions, returns the 64bit int (as an\n // array of two 32bit ints) rotated left by that number of positions.\n //\n\n n %= 64;\n\n if (n === 32) {\n return [m[1], m[0]];\n } else if (n < 32) {\n return [(m[0] << n) | (m[1] >>> (32 - n)), (m[1] << n) | (m[0] >>> (32 - n))];\n } else {\n n -= 32;\n return [(m[1] << n) | (m[0] >>> (32 - n)), (m[0] << n) | (m[1] >>> (32 - n))];\n }\n}\n\nfunction _x64LeftShift(m: number[], n: number) {\n //\n // Given a 64bit int (as an array of two 32bit ints) and an int\n // representing a number of bit positions, returns the 64bit int (as an\n // array of two 32bit ints) shifted left by that number of positions.\n //\n\n n %= 64;\n\n if (n === 0) {\n return m;\n } else if (n < 32) {\n return [(m[0] << n) | (m[1] >>> (32 - n)), m[1] << n];\n } else {\n return [m[1] << (n - 32), 0];\n }\n}\n\nfunction _x64Xor(m: number[], n: number[]) {\n //\n // Given two 64bit ints (as an array of two 32bit ints) returns the two\n // xored together as a 64bit int (as an array of two 32bit ints).\n //\n\n return [m[0] ^ n[0], m[1] ^ n[1]];\n}\n\nfunction _x64Fmix(h: number[]) {\n //\n // Given a block, returns murmurHash3's final x64 mix of that block.\n // (`[0, h[0] >>> 1]` is a 33 bit unsigned right shift. This is the\n // only place where we need to right shift 64bit ints.)\n //\n\n h = _x64Xor(h, [0, h[0] >>> 1]);\n h = _x64Multiply(h, [0xff51afd7, 0xed558ccd]);\n h = _x64Xor(h, [0, h[0] >>> 1]);\n h = _x64Multiply(h, [0xc4ceb9fe, 0x1a85ec53]);\n h = _x64Xor(h, [0, h[0] >>> 1]);\n\n return h;\n}\n\n// PUBLIC FUNCTIONS\n// ----------------\n\nfunction x86Hash32(bytes: Buffer, seed?: number) {\n //\n // Given a string and an optional seed as an int, returns a 32 bit hash\n // using the x86 flavor of MurmurHash3, as an unsigned int.\n //\n seed = seed || 0;\n\n const remainder = bytes.length % 4;\n const blocks = bytes.length - remainder;\n\n let h1 = seed;\n\n let k1 = 0;\n\n const c1 = 0xcc9e2d51;\n const c2 = 0x1b873593;\n let j = 0;\n\n for (let i = 0; i < blocks; i = i + 4) {\n k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24);\n\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n\n h1 ^= k1;\n h1 = _x86Rotl(h1, 13);\n h1 = _x86Multiply(h1, 5) + 0xe6546b64;\n j = i + 4;\n }\n\n k1 = 0;\n\n switch (remainder) {\n case 3:\n k1 ^= bytes[j + 2] << 16;\n\n case 2:\n k1 ^= bytes[j + 1] << 8;\n\n case 1:\n k1 ^= bytes[j];\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n h1 ^= k1;\n }\n\n h1 ^= bytes.length;\n h1 = _x86Fmix(h1);\n\n return h1 >>> 0;\n}\n\nfunction x86Hash128(bytes: Buffer, seed?: number) {\n //\n // Given a string and an optional seed as an int, returns a 128 bit\n // hash using the x86 flavor of MurmurHash3, as an unsigned hex.\n //\n\n seed = seed || 0;\n const remainder = bytes.length % 16;\n const blocks = bytes.length - remainder;\n\n let h1 = seed;\n let h2 = seed;\n let h3 = seed;\n let h4 = seed;\n\n let k1 = 0;\n let k2 = 0;\n let k3 = 0;\n let k4 = 0;\n\n const c1 = 0x239b961b;\n const c2 = 0xab0e9789;\n const c3 = 0x38b34ae5;\n const c4 = 0xa1e38b93;\n let j = 0;\n\n for (let i = 0; i < blocks; i = i + 16) {\n k1 = bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24);\n k2 = bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24);\n k3 = bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24);\n k4 = bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24);\n\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n h1 ^= k1;\n\n h1 = _x86Rotl(h1, 19);\n h1 += h2;\n h1 = _x86Multiply(h1, 5) + 0x561ccd1b;\n\n k2 = _x86Multiply(k2, c2);\n k2 = _x86Rotl(k2, 16);\n k2 = _x86Multiply(k2, c3);\n h2 ^= k2;\n\n h2 = _x86Rotl(h2, 17);\n h2 += h3;\n h2 = _x86Multiply(h2, 5) + 0x0bcaa747;\n\n k3 = _x86Multiply(k3, c3);\n k3 = _x86Rotl(k3, 17);\n k3 = _x86Multiply(k3, c4);\n h3 ^= k3;\n\n h3 = _x86Rotl(h3, 15);\n h3 += h4;\n h3 = _x86Multiply(h3, 5) + 0x96cd1c35;\n\n k4 = _x86Multiply(k4, c4);\n k4 = _x86Rotl(k4, 18);\n k4 = _x86Multiply(k4, c1);\n h4 ^= k4;\n\n h4 = _x86Rotl(h4, 13);\n h4 += h1;\n h4 = _x86Multiply(h4, 5) + 0x32ac3b17;\n j = i + 16;\n }\n\n k1 = 0;\n k2 = 0;\n k3 = 0;\n k4 = 0;\n\n switch (remainder) {\n case 15:\n k4 ^= bytes[j + 14] << 16;\n\n case 14:\n k4 ^= bytes[j + 13] << 8;\n\n case 13:\n k4 ^= bytes[j + 12];\n k4 = _x86Multiply(k4, c4);\n k4 = _x86Rotl(k4, 18);\n k4 = _x86Multiply(k4, c1);\n h4 ^= k4;\n\n case 12:\n k3 ^= bytes[j + 11] << 24;\n\n case 11:\n k3 ^= bytes[j + 10] << 16;\n\n case 10:\n k3 ^= bytes[j + 9] << 8;\n\n case 9:\n k3 ^= bytes[j + 8];\n k3 = _x86Multiply(k3, c3);\n k3 = _x86Rotl(k3, 17);\n k3 = _x86Multiply(k3, c4);\n h3 ^= k3;\n\n case 8:\n k2 ^= bytes[j + 7] << 24;\n\n case 7:\n k2 ^= bytes[j + 6] << 16;\n\n case 6:\n k2 ^= bytes[j + 5] << 8;\n\n case 5:\n k2 ^= bytes[j + 4];\n k2 = _x86Multiply(k2, c2);\n k2 = _x86Rotl(k2, 16);\n k2 = _x86Multiply(k2, c3);\n h2 ^= k2;\n\n case 4:\n k1 ^= bytes[j + 3] << 24;\n\n case 3:\n k1 ^= bytes[j + 2] << 16;\n\n case 2:\n k1 ^= bytes[j + 1] << 8;\n\n case 1:\n k1 ^= bytes[j];\n k1 = _x86Multiply(k1, c1);\n k1 = _x86Rotl(k1, 15);\n k1 = _x86Multiply(k1, c2);\n h1 ^= k1;\n }\n\n h1 ^= bytes.length;\n h2 ^= bytes.length;\n h3 ^= bytes.length;\n h4 ^= bytes.length;\n\n h1 += h2;\n h1 += h3;\n h1 += h4;\n h2 += h1;\n h3 += h1;\n h4 += h1;\n\n h1 = _x86Fmix(h1);\n h2 = _x86Fmix(h2);\n h3 = _x86Fmix(h3);\n h4 = _x86Fmix(h4);\n\n h1 += h2;\n h1 += h3;\n h1 += h4;\n h2 += h1;\n h3 += h1;\n h4 += h1;\n\n return (\n (\"00000000\" + (h1 >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h2 >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h3 >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h4 >>> 0).toString(16)).slice(-8)\n );\n}\n\nfunction x64Hash128(bytes: Buffer, seed?: number) {\n //\n // Given a string and an optional seed as an int, returns a 128 bit\n // hash using the x64 flavor of MurmurHash3, as an unsigned hex.\n //\n seed = seed || 0;\n\n const remainder = bytes.length % 16;\n const blocks = bytes.length - remainder;\n\n let h1 = [0, seed];\n let h2 = [0, seed];\n\n let k1 = [0, 0];\n let k2 = [0, 0];\n\n const c1 = [0x87c37b91, 0x114253d5];\n const c2 = [0x4cf5ad43, 0x2745937f];\n let j = 0;\n\n for (let i = 0; i < blocks; i = i + 16) {\n k1 = [\n bytes[i + 4] | (bytes[i + 5] << 8) | (bytes[i + 6] << 16) | (bytes[i + 7] << 24),\n bytes[i] | (bytes[i + 1] << 8) | (bytes[i + 2] << 16) | (bytes[i + 3] << 24),\n ];\n k2 = [\n bytes[i + 12] | (bytes[i + 13] << 8) | (bytes[i + 14] << 16) | (bytes[i + 15] << 24),\n bytes[i + 8] | (bytes[i + 9] << 8) | (bytes[i + 10] << 16) | (bytes[i + 11] << 24),\n ];\n\n k1 = _x64Multiply(k1, c1);\n k1 = _x64Rotl(k1, 31);\n k1 = _x64Multiply(k1, c2);\n h1 = _x64Xor(h1, k1);\n\n h1 = _x64Rotl(h1, 27);\n h1 = _x64Add(h1, h2);\n h1 = _x64Add(_x64Multiply(h1, [0, 5]), [0, 0x52dce729]);\n\n k2 = _x64Multiply(k2, c2);\n k2 = _x64Rotl(k2, 33);\n k2 = _x64Multiply(k2, c1);\n h2 = _x64Xor(h2, k2);\n\n h2 = _x64Rotl(h2, 31);\n h2 = _x64Add(h2, h1);\n h2 = _x64Add(_x64Multiply(h2, [0, 5]), [0, 0x38495ab5]);\n j = i + 16;\n }\n\n k1 = [0, 0];\n k2 = [0, 0];\n\n switch (remainder) {\n case 15:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 14]], 48));\n\n case 14:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 13]], 40));\n\n case 13:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 12]], 32));\n\n case 12:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 11]], 24));\n\n case 11:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 10]], 16));\n\n case 10:\n k2 = _x64Xor(k2, _x64LeftShift([0, bytes[j + 9]], 8));\n\n case 9:\n k2 = _x64Xor(k2, [0, bytes[j + 8]]);\n k2 = _x64Multiply(k2, c2);\n k2 = _x64Rotl(k2, 33);\n k2 = _x64Multiply(k2, c1);\n h2 = _x64Xor(h2, k2);\n\n case 8:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 7]], 56));\n\n case 7:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 6]], 48));\n\n case 6:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 5]], 40));\n\n case 5:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 4]], 32));\n\n case 4:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 3]], 24));\n\n case 3:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 2]], 16));\n\n case 2:\n k1 = _x64Xor(k1, _x64LeftShift([0, bytes[j + 1]], 8));\n\n case 1:\n k1 = _x64Xor(k1, [0, bytes[j]]);\n k1 = _x64Multiply(k1, c1);\n k1 = _x64Rotl(k1, 31);\n k1 = _x64Multiply(k1, c2);\n h1 = _x64Xor(h1, k1);\n }\n\n h1 = _x64Xor(h1, [0, bytes.length]);\n h2 = _x64Xor(h2, [0, bytes.length]);\n\n h1 = _x64Add(h1, h2);\n h2 = _x64Add(h2, h1);\n\n h1 = _x64Fmix(h1);\n h2 = _x64Fmix(h2);\n\n h1 = _x64Add(h1, h2);\n h2 = _x64Add(h2, h1);\n\n // Here we reverse h1 and h2 in Cosmos\n // This is an implementation detail and not part of the public spec\n const h1Buff = Buffer.from(\n (\"00000000\" + (h1[0] >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h1[1] >>> 0).toString(16)).slice(-8),\n \"hex\",\n );\n const h1Reversed = reverse(h1Buff).toString(\"hex\");\n const h2Buff = Buffer.from(\n (\"00000000\" + (h2[0] >>> 0).toString(16)).slice(-8) +\n (\"00000000\" + (h2[1] >>> 0).toString(16)).slice(-8),\n \"hex\",\n );\n const h2Reversed = reverse(h2Buff).toString(\"hex\");\n return h1Reversed + h2Reversed;\n}\n\nexport function reverse(buff: Buffer) {\n const buffer = Buffer.allocUnsafe(buff.length);\n\n for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) {\n buffer[i] = buff[j];\n buffer[j] = buff[i];\n }\n return buffer;\n}\n\nexport default {\n version: \"3.0.0\",\n x86: {\n hash32: x86Hash32,\n hash128: x86Hash128,\n },\n x64: {\n hash128: x64Hash128,\n },\n inputValidation: true,\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PrimitivePartitionKeyValue } from \"../../documents\";\nimport { doubleToByteArrayJSBI } from \"./encoding/number\";\nimport { BytePrefix } from \"./encoding/prefix\";\nimport MurmurHash from \"./murmurHash\";\n\nexport function hashV2PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string {\n const toHash: Buffer = Buffer.concat(partitionKey.map(prefixKeyByType));\n const hash = MurmurHash.x64.hash128(toHash);\n const reverseBuff: Buffer = reverse(Buffer.from(hash, \"hex\"));\n reverseBuff[0] &= 0x3f;\n return reverseBuff.toString(\"hex\").toUpperCase();\n}\n\nfunction prefixKeyByType(key: PrimitivePartitionKeyValue): Buffer {\n let bytes: Buffer;\n switch (typeof key) {\n case \"string\": {\n bytes = Buffer.concat([\n Buffer.from(BytePrefix.String, \"hex\"),\n Buffer.from(key),\n Buffer.from(BytePrefix.Infinity, \"hex\"),\n ]);\n return bytes;\n }\n case \"number\": {\n const numberBytes = doubleToByteArrayJSBI(key);\n bytes = Buffer.concat([Buffer.from(BytePrefix.Number, \"hex\"), numberBytes]);\n return bytes;\n }\n case \"boolean\": {\n const prefix = key ? BytePrefix.True : BytePrefix.False;\n return Buffer.from(prefix, \"hex\");\n }\n case \"object\": {\n if (key === null) {\n return Buffer.from(BytePrefix.Null, \"hex\");\n }\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n case \"undefined\": {\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n default:\n throw new Error(`Unexpected type: ${typeof key}`);\n }\n}\n\nexport function reverse(buff: Buffer): Buffer {\n const buffer = Buffer.allocUnsafe(buff.length);\n\n for (let i = 0, j = buff.length - 1; i <= j; ++i, --j) {\n buffer[i] = buff[j];\n buffer[j] = buff[i];\n }\n return buffer;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PrimitivePartitionKeyValue } from \"../../documents\";\nimport { hashV2PartitionKey } from \"./v2\";\n\n/**\n * Generate Hash for a `Multi Hash` type partition.\n * @param partitionKey - to be hashed.\n * @returns\n */\nexport function hashMultiHashPartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string {\n return partitionKey.map((keys) => hashV2PartitionKey([keys])).join(\"\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { BytePrefix } from \"./prefix\";\n\nexport function writeStringForBinaryEncoding(payload: string): Buffer {\n let outputStream = Buffer.from(BytePrefix.String, \"hex\");\n const MAX_STRING_BYTES_TO_APPEND = 100;\n const byteArray = [...Buffer.from(payload)];\n\n const isShortString = payload.length <= MAX_STRING_BYTES_TO_APPEND;\n\n for (\n let index = 0;\n index < (isShortString ? byteArray.length : MAX_STRING_BYTES_TO_APPEND + 1);\n index++\n ) {\n let charByte = byteArray[index];\n if (charByte < 0xff) {\n charByte++;\n }\n outputStream = Buffer.concat([outputStream, Buffer.from(charByte.toString(16), \"hex\")]);\n }\n\n if (isShortString) {\n outputStream = Buffer.concat([outputStream, Buffer.from(BytePrefix.Undefined, \"hex\")]);\n }\n return outputStream;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { doubleToByteArrayJSBI, writeNumberForBinaryEncodingJSBI } from \"./encoding/number\";\nimport { writeStringForBinaryEncoding } from \"./encoding/string\";\nimport { BytePrefix } from \"./encoding/prefix\";\nimport MurmurHash from \"./murmurHash\";\nimport { PrimitivePartitionKeyValue } from \"../../documents\";\n\nconst MAX_STRING_CHARS = 100;\n\nexport function hashV1PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string {\n const key = partitionKey[0];\n const toHash = prefixKeyByType(key);\n const hash = MurmurHash.x86.hash32(toHash);\n const encodedJSBI = writeNumberForBinaryEncodingJSBI(hash);\n const encodedValue = encodeByType(key);\n const finalHash = Buffer.concat([encodedJSBI, encodedValue]).toString(\"hex\").toUpperCase();\n return finalHash;\n}\n\nfunction prefixKeyByType(key: PrimitivePartitionKeyValue): Buffer {\n let bytes: Buffer;\n switch (typeof key) {\n case \"string\": {\n const truncated = key.substr(0, MAX_STRING_CHARS);\n bytes = Buffer.concat([\n Buffer.from(BytePrefix.String, \"hex\"),\n Buffer.from(truncated),\n Buffer.from(BytePrefix.Undefined, \"hex\"),\n ]);\n return bytes;\n }\n case \"number\": {\n const numberBytes = doubleToByteArrayJSBI(key);\n bytes = Buffer.concat([Buffer.from(BytePrefix.Number, \"hex\"), numberBytes]);\n return bytes;\n }\n case \"boolean\": {\n const prefix = key ? BytePrefix.True : BytePrefix.False;\n return Buffer.from(prefix, \"hex\");\n }\n case \"object\": {\n if (key === null) {\n return Buffer.from(BytePrefix.Null, \"hex\");\n }\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n case \"undefined\": {\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n }\n default:\n throw new Error(`Unexpected type: ${typeof key}`);\n }\n}\n\nfunction encodeByType(key: PrimitivePartitionKeyValue): Buffer {\n switch (typeof key) {\n case \"string\": {\n const truncated = key.substr(0, MAX_STRING_CHARS);\n return writeStringForBinaryEncoding(truncated);\n }\n case \"number\": {\n const encodedJSBI = writeNumberForBinaryEncodingJSBI(key);\n return encodedJSBI;\n }\n case \"boolean\": {\n const prefix = key ? BytePrefix.True : BytePrefix.False;\n return Buffer.from(prefix, \"hex\");\n }\n case \"object\":\n if (key === null) {\n return Buffer.from(BytePrefix.Null, \"hex\");\n }\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n case \"undefined\":\n return Buffer.from(BytePrefix.Undefined, \"hex\");\n default:\n throw new Error(`Unexpected type: ${typeof key}`);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n PartitionKeyDefinition,\n PartitionKeyDefinitionVersion,\n PartitionKeyKind,\n PrimitivePartitionKeyValue,\n} from \"../../documents\";\nimport { hashMultiHashPartitionKey } from \"./multiHash\";\nimport { hashV1PartitionKey } from \"./v1\";\nimport { hashV2PartitionKey } from \"./v2\";\n\n/**\n * Generate hash of a PartitonKey based on it PartitionKeyDefinition.\n * @param partitionKey - to be hashed.\n * @param partitionDefinition - container's partitionKey definition\n * @returns\n */\nexport function hashPartitionKey(\n partitionKey: PrimitivePartitionKeyValue[],\n partitionDefinition: PartitionKeyDefinition,\n): string {\n const kind: PartitionKeyKind = partitionDefinition?.kind || PartitionKeyKind.Hash; // Default value.\n const isV2 =\n partitionDefinition &&\n partitionDefinition.version &&\n partitionDefinition.version === PartitionKeyDefinitionVersion.V2;\n switch (kind) {\n case PartitionKeyKind.Hash:\n return isV2 ? hashV2PartitionKey(partitionKey) : hashV1PartitionKey(partitionKey);\n case PartitionKeyKind.MultiHash:\n return hashMultiHashPartitionKey(partitionKey);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * @internal\n * FeedRange for which change feed is being requested.\n */\nexport class ChangeFeedRange {\n /**\n * Min value for the range.\n */\n public minInclusive: string;\n /**\n * Max value for the range.\n */\n public maxExclusive: string;\n /**\n * Continuation token from where to start reading changes.\n */\n public continuationToken?: string;\n /**\n * Min epk value to begin reading changes from in case changefeed of entire partition is not requested.\n */\n public epkMinHeader?: string;\n /**\n * Max epk value to begin reading changes from in case changefeed of entire partition is not requested.\n */\n public epkMaxHeader?: string;\n\n constructor(\n minInclusive: string,\n maxExclusive: string,\n continuationToken?: string,\n epkMinHeader?: string,\n epkMaxHeader?: string,\n ) {\n this.minInclusive = minInclusive;\n this.maxExclusive = maxExclusive;\n this.continuationToken = continuationToken;\n this.epkMinHeader = epkMinHeader;\n this.epkMaxHeader = epkMaxHeader;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { Constants } from \"../../common\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\n\n/**\n * A single response page from the Azure Cosmos DB Change Feed\n */\nexport class ChangeFeedIteratorResponse {\n /**\n * @internal\n */\n constructor(\n /**\n * Gets the items returned in the response from Azure Cosmos DB\n */\n public readonly result: T,\n /**\n * Gets the number of items returned in the response from Azure Cosmos DB\n */\n public readonly count: number,\n /**\n * Gets the status code of the response from Azure Cosmos DB\n */\n public readonly statusCode: number,\n /**\n * Headers related to cosmos DB and change feed.\n */\n headers: CosmosHeaders,\n /**\n * Cosmos Diagnostic Object.\n */\n public readonly diagnostics: CosmosDiagnostics,\n /**\n * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone.\n */\n public readonly subStatusCode?: number,\n ) {\n this.headers = headers;\n }\n\n /**\n * Gets the request charge for this request from the Azure Cosmos DB service.\n */\n public get requestCharge(): number {\n const rus = this.headers[Constants.HttpHeaders.RequestCharge];\n return rus ? parseInt(rus, 10) : null;\n }\n\n /**\n * Gets the activity ID for the request from the Azure Cosmos DB service.\n */\n public get activityId(): string {\n return this.headers[Constants.HttpHeaders.ActivityId];\n }\n\n /**\n * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service.\n */\n public get continuationToken(): string {\n return this.headers[Constants.HttpHeaders.ContinuationToken];\n }\n /**\n * Gets the session token for use in session consistency reads from the Azure Cosmos DB service.\n */\n public get sessionToken(): string {\n return this.headers[Constants.HttpHeaders.SessionToken];\n }\n /**\n * Response headers of the response from Azure Cosmos DB\n */\n public headers: CosmosHeaders;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedRange } from \"./ChangeFeedRange\";\n/**\n * @hidden\n * A queue for iterating over specified Epk ranges and fetch change feed for the given epk ranges.\n */\nexport class FeedRangeQueue {\n private elements: ChangeFeedRange[];\n\n constructor() {\n this.elements = [];\n }\n\n public modifyFirstElement(newItem: ChangeFeedRange): void {\n if (!this.isEmpty()) {\n this.elements[0] = newItem;\n }\n }\n\n public enqueue(item: ChangeFeedRange): void {\n this.elements.push(item);\n }\n\n public dequeue(): ChangeFeedRange {\n return this.elements.shift();\n }\n\n public peek(): T | ChangeFeedRange {\n return !this.isEmpty() ? this.elements[0] : undefined;\n }\n\n public isEmpty(): boolean {\n return this.elements.length === 0;\n }\n\n public moveFirstElementToTheEnd(): void {\n if (!this.isEmpty()) {\n this.elements.push(this.dequeue());\n }\n }\n /**\n * Returns a snapshot of the queue as an array to be used as Continuation token.\n */\n public returnSnapshot(): ChangeFeedRange[] {\n const allFeedRanges: ChangeFeedRange[] = [];\n this.elements.map((element) => {\n const minInclusive = element.epkMinHeader ? element.epkMinHeader : element.minInclusive;\n const maxExclusive = element.epkMaxHeader ? element.epkMaxHeader : element.maxExclusive;\n const feedRangeElement = new ChangeFeedRange(\n minInclusive,\n maxExclusive,\n element.continuationToken,\n );\n allFeedRanges.push(feedRangeElement);\n });\n return allFeedRanges;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedRange } from \"./ChangeFeedRange\";\n/**\n * Continuation token for change feed of entire container, or a specific Epk Range.\n * @internal\n */\nexport class CompositeContinuationToken {\n /**\n * rid of the container for which the continuation token is issued.\n */\n public readonly rid: string;\n /**\n * List of Epk Ranges part of the continuation token\n */\n public readonly Continuation: ChangeFeedRange[];\n\n constructor(rid: string, Continuation: ChangeFeedRange[]) {\n this.rid = rid;\n this.Continuation = Continuation;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\n\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time.\n */\nexport class ChangeFeedStartFromBeginning {\n private cfResource?: PartitionKey | FeedRange;\n\n constructor(cfResource?: PartitionKey | FeedRange) {\n this.cfResource = cfResource;\n }\n\n public getCfResource(): PartitionKey | FeedRange | undefined {\n return this.cfResource;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time.\n */\nexport class ChangeFeedStartFromNow {\n public cfResource?: PartitionKey | FeedRange;\n\n constructor(cfResource?: PartitionKey | FeedRange) {\n this.cfResource = cfResource;\n }\n\n public getCfResource(): PartitionKey | FeedRange | undefined {\n return this.cfResource;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time.\n */\nexport class ChangeFeedStartFromTime {\n private cfResource?: PartitionKey | FeedRange;\n\n private startTime: Date;\n\n constructor(startTime: Date, cfResource?: PartitionKey | FeedRange) {\n this.startTime = startTime;\n this.cfResource = cfResource;\n }\n\n public getCfResource(): PartitionKey | FeedRange | undefined {\n return this.cfResource;\n }\n\n public getStartTime(): Date {\n return this.startTime;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ErrorResponse } from \"../../request\";\n\n/**\n * Specifies a feed range for the changefeed.\n */\nexport abstract class FeedRange {\n /**\n * Min value for the feed range.\n */\n readonly minInclusive: string;\n /**\n * Max value for the feed range.\n */\n readonly maxExclusive: string;\n /**\n * @internal\n */\n protected constructor(minInclusive: string, maxExclusive: string) {\n // only way to explictly block users from creating FeedRange directly in JS\n if (new.target === FeedRange) {\n throw new ErrorResponse(\"Cannot instantiate abstract class FeedRange\");\n }\n\n this.minInclusive = minInclusive;\n this.maxExclusive = maxExclusive;\n }\n}\n\n/**\n * @hidden\n * Specifies a feed range for the changefeed.\n */\nexport class FeedRangeInternal extends FeedRange {\n /* eslint-disable @typescript-eslint/no-useless-constructor */\n constructor(minInclusive: string, maxExclusive: string) {\n super(minInclusive, maxExclusive);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedIteratorOptions } from \"./ChangeFeedIteratorOptions\";\nimport { ErrorResponse } from \"../../request\";\nimport { PartitionKeyRange } from \"../Container\";\nimport { InternalChangeFeedIteratorOptions } from \"./InternalChangeFeedOptions\";\nimport { isPrimitivePartitionKeyValue } from \"../../utils/typeChecks\";\nimport { ChangeFeedStartFrom } from \"./ChangeFeedStartFrom\";\nimport { ChangeFeedStartFromBeginning } from \"./ChangeFeedStartFromBeginning\";\nimport { ChangeFeedStartFromNow } from \"./ChangeFeedStartFromNow\";\nimport { Constants } from \"../../common\";\nimport { ChangeFeedStartFromTime } from \"./ChangeFeedStartFromTime\";\nimport { QueryRange } from \"../../routing\";\nimport { FeedRangeInternal } from \"./FeedRange\";\n\n/**\n * @hidden\n * Validates the change feed options passed by the user\n */\nexport function validateChangeFeedIteratorOptions(options: ChangeFeedIteratorOptions): void {\n if (!isChangeFeedIteratorOptions(options)) {\n throw new ErrorResponse(\"Invalid Changefeed Iterator Options.\");\n }\n if (options?.maxItemCount && typeof options?.maxItemCount !== \"number\") {\n throw new ErrorResponse(\"maxItemCount must be number\");\n }\n if (options?.maxItemCount !== undefined && options?.maxItemCount < 1) {\n throw new ErrorResponse(\"maxItemCount must be a positive number\");\n }\n}\n\nfunction isChangeFeedIteratorOptions(options: unknown): options is ChangeFeedIteratorOptions {\n if (typeof options !== \"object\") {\n return false;\n }\n if (Object.keys(options).length === 0 && JSON.stringify(options) === \"{}\") {\n return true;\n }\n return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options));\n}\n\n/**\n * @hidden\n * Checks if pkRange entirely covers the given overLapping range or there is only partial overlap.\n *\n * If no complete overlap, exact range which overlaps is retured which is used to set minEpk and maxEpk headers while quering change feed.\n */\nexport async function extractOverlappingRanges(\n epkRange: QueryRange,\n overLappingRange: PartitionKeyRange,\n): Promise<[string, string]> {\n if (\n overLappingRange.minInclusive >= epkRange.min &&\n overLappingRange.maxExclusive <= epkRange.max\n ) {\n return [undefined, undefined];\n } else if (\n overLappingRange.minInclusive <= epkRange.min &&\n overLappingRange.maxExclusive >= epkRange.max\n ) {\n return [epkRange.min, epkRange.max];\n }\n // Right Side of overlapping range is covered\n else if (\n overLappingRange.minInclusive <= epkRange.min &&\n overLappingRange.maxExclusive <= epkRange.max &&\n overLappingRange.maxExclusive >= epkRange.min\n ) {\n return [epkRange.min, overLappingRange.maxExclusive];\n }\n // Left Side of overlapping range is covered\n else {\n return [overLappingRange.minInclusive, epkRange.max];\n }\n}\n\n/**\n * @hidden\n * Checks if the object is a valid EpkRange\n */\nexport function isEpkRange(obj: unknown): boolean {\n return (\n obj instanceof FeedRangeInternal &&\n typeof obj.minInclusive === \"string\" &&\n typeof obj.maxExclusive === \"string\" &&\n obj.minInclusive >=\n Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey &&\n obj.maxExclusive <=\n Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey &&\n obj.maxExclusive > obj.minInclusive\n );\n}\n\n/**\n * @hidden\n */\nexport function buildInternalChangeFeedOptions(\n options: ChangeFeedIteratorOptions,\n continuationToken?: string,\n startTime?: Date,\n): InternalChangeFeedIteratorOptions {\n const internalCfOptions = {} as InternalChangeFeedIteratorOptions;\n internalCfOptions.maxItemCount = options?.maxItemCount;\n internalCfOptions.sessionToken = options?.sessionToken;\n internalCfOptions.continuationToken = continuationToken;\n\n // Default option of changefeed is to start from now.\n internalCfOptions.startTime = startTime;\n return internalCfOptions;\n}\n/**\n * @hidden\n */\nexport function fetchStartTime(changeFeedStartFrom: ChangeFeedStartFrom): Date | undefined {\n if (changeFeedStartFrom instanceof ChangeFeedStartFromBeginning) {\n return undefined;\n } else if (changeFeedStartFrom instanceof ChangeFeedStartFromNow) {\n return new Date();\n } else if (changeFeedStartFrom instanceof ChangeFeedStartFromTime) {\n return changeFeedStartFrom.getStartTime();\n }\n}\n\n/**\n * @hidden\n */\nexport function isNullOrEmpty(text: string | null | undefined): boolean {\n return text === null || text === undefined || text.trim() === \"\";\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ChangeFeedRange } from \"./ChangeFeedRange\";\nimport { ChangeFeedIteratorResponse } from \"./ChangeFeedIteratorResponse\";\nimport { PartitionKeyRangeCache, QueryRange } from \"../../routing\";\nimport { FeedRangeQueue } from \"./FeedRangeQueue\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { Container, Resource } from \"../../client\";\nimport { Constants, SubStatusCodes, StatusCodes, ResourceType } from \"../../common\";\nimport { Response, FeedOptions, ErrorResponse } from \"../../request\";\nimport { CompositeContinuationToken } from \"./CompositeContinuationToken\";\nimport { ChangeFeedPullModelIterator } from \"./ChangeFeedPullModelIterator\";\nimport { extractOverlappingRanges } from \"./changeFeedUtils\";\nimport { InternalChangeFeedIteratorOptions } from \"./InternalChangeFeedOptions\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n/**\n * @hidden\n * Provides iterator for change feed for entire container or an epk range.\n *\n * Use `Items.getChangeFeedIterator()` to get an instance of the iterator.\n */\nexport class ChangeFeedForEpkRange implements ChangeFeedPullModelIterator {\n private continuationToken?: CompositeContinuationToken;\n private queue: FeedRangeQueue;\n private startTime: string;\n private isInstantiated: boolean;\n private rId: string;\n /**\n * @internal\n */\n constructor(\n private clientContext: ClientContext,\n private container: Container,\n private partitionKeyRangeCache: PartitionKeyRangeCache,\n private resourceId: string,\n private resourceLink: string,\n private url: string,\n private changeFeedOptions: InternalChangeFeedIteratorOptions,\n private epkRange: QueryRange,\n ) {\n this.queue = new FeedRangeQueue();\n this.continuationToken = changeFeedOptions.continuationToken\n ? JSON.parse(changeFeedOptions.continuationToken)\n : undefined;\n this.startTime = changeFeedOptions.startTime\n ? changeFeedOptions.startTime.toUTCString()\n : undefined;\n this.isInstantiated = false;\n }\n\n private async setIteratorRid(diagnosticNode: DiagnosticNodeInternal): Promise {\n const { resource } = await this.container.readInternal(diagnosticNode);\n this.rId = resource._rid;\n }\n\n private continuationTokenRidMatchContainerRid(): boolean {\n if (this.continuationToken.rid !== this.rId) {\n return false;\n }\n return true;\n }\n\n private async fillChangeFeedQueue(diagnosticNode: DiagnosticNodeInternal): Promise {\n if (this.continuationToken) {\n // fill the queue with feed ranges in continuation token.\n await this.fetchContinuationTokenFeedRanges(diagnosticNode);\n } else {\n // fill the queue with feed ranges overlapping the given epk range.\n await this.fetchOverLappingFeedRanges(diagnosticNode);\n }\n this.isInstantiated = true;\n }\n\n /**\n * Fill the queue with the feed ranges overlapping with the given epk range.\n */\n private async fetchOverLappingFeedRanges(diagnosticNode: DiagnosticNodeInternal): Promise {\n try {\n const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n this.epkRange,\n diagnosticNode,\n );\n for (const overLappingRange of overLappingRanges) {\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n this.epkRange,\n overLappingRange,\n );\n const feedRange: ChangeFeedRange = new ChangeFeedRange(\n overLappingRange.minInclusive,\n overLappingRange.maxExclusive,\n \"\",\n epkMinHeader,\n epkMaxHeader,\n );\n this.queue.enqueue(feedRange);\n }\n } catch (err) {\n throw new ErrorResponse(err.message);\n }\n }\n /**\n * Fill the queue with feed ranges from continuation token\n */\n private async fetchContinuationTokenFeedRanges(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n const contToken = this.continuationToken;\n if (!this.continuationTokenRidMatchContainerRid()) {\n throw new ErrorResponse(\"The continuation token is not for the current container definition\");\n } else {\n for (const cToken of contToken.Continuation) {\n const queryRange = new QueryRange(cToken.minInclusive, cToken.maxExclusive, true, false);\n try {\n const overLappingRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n queryRange,\n diagnosticNode,\n );\n for (const overLappingRange of overLappingRanges) {\n // check if the epk range present in continuation token entirely covers the overlapping range.\n // If yes, minInclusive and maxExclusive of the overlapping range will be set.\n // If no, i.e. there is only partial overlap, epkMinHeader and epkMaxHeader are set as min and max of overlap.\n // This will be used when we make a call to fetch change feed.\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n queryRange,\n overLappingRange,\n );\n const feedRange: ChangeFeedRange = new ChangeFeedRange(\n overLappingRange.minInclusive,\n overLappingRange.maxExclusive,\n cToken.continuationToken,\n epkMinHeader,\n epkMaxHeader,\n );\n this.queue.enqueue(feedRange);\n }\n } catch (err) {\n throw new ErrorResponse(err.message);\n }\n }\n }\n }\n\n /**\n * Change feed is an infinite feed. hasMoreResults is always true.\n */\n get hasMoreResults(): boolean {\n return true;\n }\n\n /**\n * Gets an async iterator which will yield change feed results.\n */\n public async *getAsyncIterator(): AsyncIterable>> {\n do {\n const result = await this.readNext();\n yield result;\n } while (this.hasMoreResults);\n }\n\n /**\n * Gets an async iterator which will yield pages of results from Azure Cosmos DB.\n *\n * Keeps iterating over the feedranges and checks if any feed range has new result. Keeps note of the last feed range which returned non 304 result.\n *\n * When same feed range is reached and no new changes are found, a 304 (not Modified) is returned to the end user. Then starts process all over again.\n */\n public async readNext(): Promise>> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n // validate if the internal queue is filled up with feed ranges.\n if (!this.isInstantiated) {\n await this.setIteratorRid(diagnosticNode);\n await this.fillChangeFeedQueue(diagnosticNode);\n }\n\n // stores the last feedRange for which statusCode is not 304 i.e. there were new changes in that feed range.\n let firstNotModifiedFeedRange: [string, string] = undefined;\n let result: ChangeFeedIteratorResponse>;\n do {\n const [processedFeedRange, response] = await this.fetchNext(diagnosticNode);\n result = response;\n if (result !== undefined) {\n {\n if (firstNotModifiedFeedRange === undefined) {\n firstNotModifiedFeedRange = processedFeedRange;\n }\n // move current feed range to end of queue to fetch result of next feed range.\n // This is done to fetch changes in breadth first manner and avoid starvation.\n this.queue.moveFirstElementToTheEnd();\n // check if there are new results for the given feed range.\n if (result.statusCode === StatusCodes.Ok) {\n result.headers[Constants.HttpHeaders.ContinuationToken] =\n this.generateContinuationToken();\n return result;\n }\n }\n }\n } while (!this.checkedAllFeedRanges(firstNotModifiedFeedRange));\n // set the continuation token after processing.\n result.headers[Constants.HttpHeaders.ContinuationToken] = this.generateContinuationToken();\n return result;\n }, this.clientContext);\n }\n\n private generateContinuationToken = (): string => {\n return JSON.stringify(new CompositeContinuationToken(this.rId, this.queue.returnSnapshot()));\n };\n\n /**\n * Read feed and retrieves the next page of results in Azure Cosmos DB.\n */\n private async fetchNext(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise<[[string, string], ChangeFeedIteratorResponse>]> {\n const feedRange = this.queue.peek();\n if (feedRange) {\n // fetch results for feed range at the beginning of the queue.\n const result = await this.getFeedResponse(feedRange, diagnosticNode);\n\n // check if results need to be fetched again depending on status code returned.\n // Eg. in case of paritionSplit, results need to be fetched for the child partitions.\n const shouldRetry: boolean = await this.shouldRetryOnFailure(\n feedRange,\n result,\n diagnosticNode,\n );\n\n if (shouldRetry) {\n this.queue.dequeue();\n return this.fetchNext(diagnosticNode);\n } else {\n // update the continuation value for the current feed range.\n const continuationValueForFeedRange = result.headers[Constants.HttpHeaders.ETag];\n const newFeedRange = this.queue.peek();\n newFeedRange.continuationToken = continuationValueForFeedRange;\n\n return [[newFeedRange.minInclusive, newFeedRange.maxExclusive], result];\n }\n } else {\n return [[undefined, undefined], undefined];\n }\n }\n\n private checkedAllFeedRanges(firstNotModifiedFeedRange: [string, string]): boolean {\n if (firstNotModifiedFeedRange === undefined) {\n return false;\n }\n const feedRangeQueueFirstElement = this.queue.peek();\n return (\n firstNotModifiedFeedRange[0] === feedRangeQueueFirstElement?.minInclusive &&\n firstNotModifiedFeedRange[1] === feedRangeQueueFirstElement?.maxExclusive\n );\n }\n\n /**\n * Checks whether the current EpkRange is split into multiple ranges or not.\n *\n * If yes, it force refreshes the partitionKeyRange cache and enqueue children epk ranges.\n */\n private async shouldRetryOnFailure(\n feedRange: ChangeFeedRange,\n response: ChangeFeedIteratorResponse>,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n if (response.statusCode === StatusCodes.Ok || response.statusCode === StatusCodes.NotModified) {\n return false;\n }\n\n const partitionSplit =\n response.statusCode === StatusCodes.Gone &&\n (response.subStatusCode === SubStatusCodes.PartitionKeyRangeGone ||\n response.subStatusCode === SubStatusCodes.CompletingSplit);\n\n if (partitionSplit) {\n const queryRange = new QueryRange(\n feedRange.minInclusive,\n feedRange.maxExclusive,\n true,\n false,\n );\n const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n queryRange,\n diagnosticNode,\n true,\n );\n if (resolvedRanges.length < 1) {\n throw new ErrorResponse(\"Partition split/merge detected but no overlapping ranges found.\");\n }\n // This covers both cases of merge and split.\n // resolvedRanges.length > 1 in case of split.\n // resolvedRanges.length === 1 in case of merge. EpkRange headers will be added in this case.\n if (resolvedRanges.length >= 1) {\n await this.handleSplit(false, resolvedRanges, queryRange, feedRange.continuationToken);\n }\n return true;\n }\n return false;\n }\n /*\n * Enqueues all the children feed ranges for the given feed range.\n */\n private async handleSplit(\n shiftLeft: boolean,\n resolvedRanges: any,\n oldFeedRange: QueryRange,\n continuationToken: string,\n ): Promise {\n let flag = 0;\n if (shiftLeft) {\n // This section is only applicable when handleSplit is called by getPartitionRangeId().\n // used only when existing partition key range cache is used to check for any overlapping ranges.\n // Modifies the first element with the first overlapping range.\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n oldFeedRange,\n resolvedRanges[0],\n );\n const newFeedRange = new ChangeFeedRange(\n resolvedRanges[0].minInclusive,\n resolvedRanges[0].maxExclusive,\n continuationToken,\n epkMinHeader,\n epkMaxHeader,\n );\n\n this.queue.modifyFirstElement(newFeedRange);\n flag = 1;\n }\n // Enqueue the overlapping ranges.\n for (let i = flag; i < resolvedRanges.length; i++) {\n const [epkMinHeader, epkMaxHeader] = await extractOverlappingRanges(\n oldFeedRange,\n resolvedRanges[i],\n );\n\n const newFeedRange = new ChangeFeedRange(\n resolvedRanges[i].minInclusive,\n resolvedRanges[i].maxExclusive,\n continuationToken,\n epkMinHeader,\n epkMaxHeader,\n );\n this.queue.enqueue(newFeedRange);\n }\n }\n\n /**\n * Fetch the partitionKeyRangeId for the given feed range.\n *\n * This partitionKeyRangeId is passed to queryFeed to fetch the results.\n */\n private async getPartitionRangeId(\n feedRange: ChangeFeedRange,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n const min = feedRange.epkMinHeader ? feedRange.epkMinHeader : feedRange.minInclusive;\n const max = feedRange.epkMaxHeader ? feedRange.epkMaxHeader : feedRange.maxExclusive;\n const queryRange = new QueryRange(min, max, true, false);\n const resolvedRanges = await this.partitionKeyRangeCache.getOverlappingRanges(\n this.url,\n queryRange,\n diagnosticNode,\n false,\n );\n if (resolvedRanges.length < 1) {\n throw new ErrorResponse(\"No overlapping ranges found.\");\n }\n const firstResolvedRange = resolvedRanges[0];\n if (resolvedRanges.length > 1) {\n await this.handleSplit(true, resolvedRanges, queryRange, feedRange.continuationToken);\n }\n return firstResolvedRange.id;\n }\n\n private async getFeedResponse(\n feedRange: ChangeFeedRange,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n const feedOptions: FeedOptions = { initialHeaders: {}, useIncrementalFeed: true };\n\n if (typeof this.changeFeedOptions.maxItemCount === \"number\") {\n feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount;\n }\n\n if (this.changeFeedOptions.sessionToken) {\n feedOptions.sessionToken = this.changeFeedOptions.sessionToken;\n }\n\n if (feedRange.continuationToken) {\n feedOptions.accessCondition = {\n type: Constants.HttpHeaders.IfNoneMatch,\n condition: feedRange.continuationToken,\n };\n }\n\n if (this.startTime) {\n feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.startTime;\n }\n const rangeId = await this.getPartitionRangeId(feedRange, diagnosticNode);\n try {\n // startEpk and endEpk are only valid in case we want to fetch result for a part of partition and not the entire partition.\n const response: Response> = await (this.clientContext.queryFeed({\n path: this.resourceLink,\n resourceType: ResourceType.item,\n resourceId: this.resourceId,\n resultFn: (result) => (result ? result.Documents : []),\n query: undefined,\n options: feedOptions,\n diagnosticNode,\n partitionKey: undefined,\n partitionKeyRangeId: rangeId,\n startEpk: feedRange.epkMinHeader,\n endEpk: feedRange.epkMaxHeader,\n }) as Promise);\n\n return new ChangeFeedIteratorResponse(\n response.result,\n response.result ? response.result.length : 0,\n response.code,\n response.headers,\n getEmptyCosmosDiagnostics(),\n );\n } catch (err) {\n // If any errors are encountered, eg. partition split or gone, handle it based on error code and not break the flow.\n return new ChangeFeedIteratorResponse(\n [],\n 0,\n err.code,\n err.headers,\n getEmptyCosmosDiagnostics(),\n err.substatus,\n );\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\n/**\n * Continuation token for change feed of entire container, or a specific Epk Range.\n * @internal\n */\nexport class ContinuationTokenForPartitionKey {\n /**\n * rid of the container for which the continuation token is issued.\n */\n public readonly rid: string;\n /**\n * A specific Partition key in the container for which the continuation token is issued.\n */\n public readonly partitionKey: PartitionKey;\n /**\n * Continuation value for the specific Partition key in the container.\n */\n public Continuation: string;\n\n constructor(rid: string, partitionKey: PartitionKey, continuation: string) {\n this.rid = rid;\n this.partitionKey = partitionKey;\n this.Continuation = continuation;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { InternalChangeFeedIteratorOptions } from \"./InternalChangeFeedOptions\";\nimport { ChangeFeedIteratorResponse } from \"./ChangeFeedIteratorResponse\";\nimport { Container, Resource } from \"../../client\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, ResourceType } from \"../../common\";\nimport { FeedOptions, Response, ErrorResponse } from \"../../request\";\nimport { ContinuationTokenForPartitionKey } from \"./ContinuationTokenForPartitionKey\";\nimport { ChangeFeedPullModelIterator } from \"./ChangeFeedPullModelIterator\";\nimport { PartitionKey } from \"../../documents\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n/**\n * @hidden\n * Provides iterator for change feed for one partition key.\n *\n * Use `Items.getChangeFeedIterator()` to get an instance of the iterator.\n */\nexport class ChangeFeedForPartitionKey implements ChangeFeedPullModelIterator {\n private continuationToken: ContinuationTokenForPartitionKey;\n private startTime: string;\n private rId: string;\n private isInstantiated: boolean;\n /**\n * @internal\n */\n constructor(\n private clientContext: ClientContext,\n private container: Container,\n private resourceId: string,\n private resourceLink: string,\n private partitionKey: PartitionKey,\n private changeFeedOptions: InternalChangeFeedIteratorOptions,\n ) {\n this.continuationToken = changeFeedOptions.continuationToken\n ? JSON.parse(changeFeedOptions.continuationToken)\n : undefined;\n this.isInstantiated = false;\n\n if (changeFeedOptions.startTime) {\n this.startTime = changeFeedOptions.startTime.toUTCString();\n }\n }\n\n private async instantiateIterator(diagnosticNode: DiagnosticNodeInternal): Promise {\n await this.setIteratorRid(diagnosticNode);\n if (this.continuationToken) {\n if (!this.continuationTokenRidMatchContainerRid()) {\n throw new ErrorResponse(\"The continuation is not for the current container definition.\");\n }\n } else {\n this.continuationToken = new ContinuationTokenForPartitionKey(\n this.rId,\n this.partitionKey,\n \"\",\n );\n }\n\n this.isInstantiated = true;\n }\n\n private continuationTokenRidMatchContainerRid(): boolean {\n if (this.continuationToken.rid !== this.rId) {\n return false;\n }\n return true;\n }\n\n private async setIteratorRid(diagnosticNode: DiagnosticNodeInternal): Promise {\n const { resource } = await this.container.readInternal(diagnosticNode);\n this.rId = resource._rid;\n }\n\n /**\n * Change feed is an infinite feed. hasMoreResults is always true.\n */\n get hasMoreResults(): boolean {\n return true;\n }\n\n /**\n * Gets an async iterator which will yield change feed results.\n */\n public async *getAsyncIterator(): AsyncIterable>> {\n do {\n const result = await this.readNext();\n yield result;\n } while (this.hasMoreResults);\n }\n\n /**\n * Returns the result of change feed from Azure Cosmos DB.\n */\n public async readNext(): Promise>> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (!this.isInstantiated) {\n await this.instantiateIterator(diagnosticNode);\n }\n const result = await this.fetchNext(diagnosticNode);\n return result;\n }, this.clientContext);\n }\n\n /**\n * Read feed and retrieves the next set of results in Azure Cosmos DB.\n */\n private async fetchNext(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n const response = await this.getFeedResponse(diagnosticNode);\n this.continuationToken.Continuation = response.headers[Constants.HttpHeaders.ETag];\n response.headers[Constants.HttpHeaders.ContinuationToken] = JSON.stringify(\n this.continuationToken,\n );\n return response;\n }\n\n private async getFeedResponse(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise>> {\n const feedOptions: FeedOptions = { initialHeaders: {}, useIncrementalFeed: true };\n\n if (typeof this.changeFeedOptions.maxItemCount === \"number\") {\n feedOptions.maxItemCount = this.changeFeedOptions.maxItemCount;\n }\n\n if (this.changeFeedOptions.sessionToken) {\n feedOptions.sessionToken = this.changeFeedOptions.sessionToken;\n }\n\n const continuation = this.continuationToken.Continuation;\n if (continuation) {\n feedOptions.accessCondition = {\n type: Constants.HttpHeaders.IfNoneMatch,\n condition: continuation,\n };\n }\n\n if (this.startTime) {\n feedOptions.initialHeaders[Constants.HttpHeaders.IfModifiedSince] = this.startTime;\n }\n\n const response: Response> = await (this.clientContext.queryFeed({\n path: this.resourceLink,\n resourceType: ResourceType.item,\n resourceId: this.resourceId,\n resultFn: (result) => (result ? result.Documents : []),\n diagnosticNode,\n query: undefined,\n options: feedOptions,\n partitionKey: this.partitionKey,\n }) as Promise);\n\n return new ChangeFeedIteratorResponse(\n response.result,\n response.result ? response.result.length : 0,\n response.code,\n response.headers,\n getEmptyCosmosDiagnostics(),\n );\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Enum to specify the resource for which change feed is being fetched.\n */\nexport enum ChangeFeedResourceType {\n FeedRange,\n PartitionKey,\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ErrorResponse } from \"../../request\";\nimport { ChangeFeedResourceType } from \"./ChangeFeedEnums\";\n/**\n * @hidden\n * Class which specifies the ChangeFeedIterator to start reading changes from a saved point.\n */\nexport class ChangeFeedStartFromContinuation {\n private continuationToken: string;\n\n constructor(continuation: string) {\n this.continuationToken = continuation;\n }\n\n public getCfResource(): string {\n return this.continuationToken;\n }\n public getCfResourceJson(): any {\n return JSON.parse(this.continuationToken);\n }\n\n public getResourceType(): any {\n const cToken = this.getCfResourceJson();\n if (\n Object.prototype.hasOwnProperty.call(cToken, \"partitionKey\") &&\n Object.prototype.hasOwnProperty.call(cToken, \"Continuation\") &&\n typeof cToken.Continuation === \"string\"\n ) {\n return ChangeFeedResourceType.PartitionKey;\n } else if (\n Object.prototype.hasOwnProperty.call(cToken, \"Continuation\") &&\n Array.isArray(cToken.Continuation) &&\n cToken.Continuation.length > 0\n ) {\n return ChangeFeedResourceType.FeedRange;\n } else {\n throw new ErrorResponse(\"Invalid continuation token.\");\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { PartitionKey } from \"../../documents\";\nimport { FeedRange } from \"./FeedRange\";\nimport { ChangeFeedStartFromNow } from \"./ChangeFeedStartFromNow\";\nimport { ChangeFeedStartFromBeginning } from \"./ChangeFeedStartFromBeginning\";\nimport { ChangeFeedStartFromTime } from \"./ChangeFeedStartFromTime\";\nimport { ChangeFeedStartFromContinuation } from \"./ChangeFeedStartFromContinuation\";\nimport { ErrorResponse } from \"../../request/ErrorResponse\";\nimport { isNullOrEmpty } from \"./changeFeedUtils\";\n\n/**\n * Base class for where to start a ChangeFeedIterator.\n */\n/* eslint-disable @typescript-eslint/no-extraneous-class */\nexport abstract class ChangeFeedStartFrom {\n /**\n * Returns an object that tells the ChangeFeedIterator to start from the beginning of time.\n * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.\n */\n public static Beginning(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromBeginning {\n return new ChangeFeedStartFromBeginning(cfResource);\n }\n /**\n * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward.\n * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.\n **/\n public static Now(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromNow {\n return new ChangeFeedStartFromNow(cfResource);\n }\n /**\n * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward.\n * @param startTime - Date object specfiying the time to start reading changes from.\n * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container.\n */\n public static Time(\n startTime: Date,\n cfResource?: PartitionKey | FeedRange,\n ): ChangeFeedStartFromTime {\n if (!startTime) {\n throw new ErrorResponse(\"startTime must be present\");\n }\n if (startTime instanceof Date === true) {\n return new ChangeFeedStartFromTime(startTime, cfResource);\n } else {\n throw new ErrorResponse(\"startTime must be a Date object.\");\n }\n }\n /**\n * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point.\n * @param continuation - The continuation to resume from.\n */\n public static Continuation(continuationToken: string): ChangeFeedStartFromContinuation {\n if (!continuationToken) {\n throw new ErrorResponse(\"Argument continuation must be passed.\");\n }\n if (isNullOrEmpty(continuationToken)) {\n throw new ErrorResponse(\"Argument continuationToken must be a non-empty string.\");\n }\n return new ChangeFeedStartFromContinuation(continuationToken);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { PartitionKey } from \"../../documents\";\nimport { QueryRange, PartitionKeyRangeCache } from \"../../routing\";\nimport { ChangeFeedIteratorOptions } from \"./ChangeFeedIteratorOptions\";\nimport { ChangeFeedStartFrom } from \"./ChangeFeedStartFrom\";\nimport { ChangeFeedStartFromBeginning } from \"./ChangeFeedStartFromBeginning\";\nimport { ChangeFeedStartFromContinuation } from \"./ChangeFeedStartFromContinuation\";\nimport { ChangeFeedStartFromNow } from \"./ChangeFeedStartFromNow\";\nimport { ChangeFeedStartFromTime } from \"./ChangeFeedStartFromTime\";\nimport { ChangeFeedResourceType } from \"./ChangeFeedEnums\";\nimport { ChangeFeedForPartitionKey } from \"./ChangeFeedForPartitionKey\";\nimport { ErrorResponse } from \"../../request\";\nimport { ChangeFeedForEpkRange } from \"./ChangeFeedForEpkRange\";\nimport { getIdFromLink, getPathFromLink, ResourceType, Constants } from \"../../common\";\nimport { buildInternalChangeFeedOptions, fetchStartTime, isEpkRange } from \"./changeFeedUtils\";\nimport { isPartitionKey } from \"../../utils/typeChecks\";\nimport { Container } from \"../Container\";\nimport { FeedRangeInternal } from \"./FeedRange\";\n\nexport function changeFeedIteratorBuilder(\n cfOptions: ChangeFeedIteratorOptions,\n clientContext: ClientContext,\n container: Container,\n partitionKeyRangeCache: PartitionKeyRangeCache,\n): any {\n const url = container.url;\n const path = getPathFromLink(url, ResourceType.item);\n const id = getIdFromLink(url);\n\n let changeFeedStartFrom = cfOptions.changeFeedStartFrom;\n\n if (changeFeedStartFrom === undefined) {\n changeFeedStartFrom = ChangeFeedStartFrom.Now();\n }\n\n if (changeFeedStartFrom instanceof ChangeFeedStartFromContinuation) {\n const continuationToken = changeFeedStartFrom.getCfResourceJson();\n const resourceType = changeFeedStartFrom.getResourceType();\n const internalCfOptions = buildInternalChangeFeedOptions(\n cfOptions,\n changeFeedStartFrom.getCfResource(),\n );\n\n if (\n resourceType === ChangeFeedResourceType.PartitionKey &&\n isPartitionKey(continuationToken.partitionKey)\n ) {\n return new ChangeFeedForPartitionKey(\n clientContext,\n container,\n id,\n path,\n continuationToken.partitionKey,\n internalCfOptions,\n );\n } else if (resourceType === ChangeFeedResourceType.FeedRange) {\n return new ChangeFeedForEpkRange(\n clientContext,\n container,\n partitionKeyRangeCache,\n id,\n path,\n url,\n internalCfOptions,\n undefined,\n );\n } else {\n throw new ErrorResponse(\"Invalid continuation token.\");\n }\n } else if (\n changeFeedStartFrom instanceof ChangeFeedStartFromNow ||\n changeFeedStartFrom instanceof ChangeFeedStartFromTime ||\n changeFeedStartFrom instanceof ChangeFeedStartFromBeginning\n ) {\n const startTime = fetchStartTime(changeFeedStartFrom);\n const internalCfOptions = buildInternalChangeFeedOptions(cfOptions, undefined, startTime);\n const cfResource = changeFeedStartFrom.getCfResource();\n if (isPartitionKey(cfResource)) {\n return new ChangeFeedForPartitionKey(\n clientContext,\n container,\n id,\n path,\n cfResource as PartitionKey,\n internalCfOptions,\n );\n } else {\n let internalCfResource: QueryRange;\n if (cfResource === undefined) {\n internalCfResource = new QueryRange(\n Constants.EffectivePartitionKeyConstants.MinimumInclusiveEffectivePartitionKey,\n Constants.EffectivePartitionKeyConstants.MaximumExclusiveEffectivePartitionKey,\n true,\n false,\n );\n } else if (isEpkRange(cfResource)) {\n internalCfResource = new QueryRange(\n (cfResource as FeedRangeInternal).minInclusive,\n (cfResource as FeedRangeInternal).maxExclusive,\n true,\n false,\n );\n } else {\n throw new ErrorResponse(\"Invalid feed range.\");\n }\n return new ChangeFeedForEpkRange(\n clientContext,\n container,\n partitionKeyRangeCache,\n id,\n path,\n url,\n internalCfOptions,\n internalCfResource,\n );\n }\n } else {\n throw new ErrorResponse(\"Invalid change feed start location.\");\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { v4 } from \"uuid\";\nconst uuid = v4;\nimport { ChangeFeedIterator } from \"../../ChangeFeedIterator\";\nimport { ChangeFeedOptions } from \"../../ChangeFeedOptions\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { getIdFromLink, getPathFromLink, isItemResourceValid, ResourceType } from \"../../common\";\nimport { extractPartitionKeys } from \"../../extractPartitionKey\";\nimport { FetchFunctionCallback, SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions, Response } from \"../../request\";\nimport { Container, PartitionKeyRange } from \"../Container\";\nimport { Item } from \"./Item\";\nimport { ItemDefinition } from \"./ItemDefinition\";\nimport { ItemResponse } from \"./ItemResponse\";\nimport {\n Batch,\n isKeyInRange,\n prepareOperations,\n OperationResponse,\n OperationInput,\n BulkOptions,\n decorateBatchOperation,\n splitBatchBasedOnBodySize,\n BulkOperationResponse,\n} from \"../../utils/batch\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { assertNotUndefined, isPrimitivePartitionKeyValue } from \"../../utils/typeChecks\";\nimport { hashPartitionKey } from \"../../utils/hashing/hash\";\nimport { PartitionKey, PartitionKeyDefinition } from \"../../documents\";\nimport { PartitionKeyRangeCache } from \"../../routing\";\nimport {\n ChangeFeedPullModelIterator,\n ChangeFeedIteratorOptions,\n changeFeedIteratorBuilder,\n} from \"../../client/ChangeFeed\";\nimport { validateChangeFeedIteratorOptions } from \"../../client/ChangeFeed/changeFeedUtils\";\nimport {\n DiagnosticNodeInternal,\n DiagnosticNodeType,\n} from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n addDignosticChild,\n} from \"../../utils/diagnostics\";\n\n/**\n * @hidden\n */\nfunction isChangeFeedOptions(options: unknown): options is ChangeFeedOptions {\n return options && !(isPrimitivePartitionKeyValue(options) || Array.isArray(options));\n}\n\n/**\n * Operations for creating new items, and reading/querying all items\n *\n * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`.\n */\nexport class Items {\n private partitionKeyRangeCache: PartitionKeyRangeCache;\n /**\n * Create an instance of {@link Items} linked to the parent {@link Container}.\n * @param container - The parent container.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {\n this.partitionKeyRangeCache = new PartitionKeyRangeCache(this.clientContext);\n }\n\n /**\n * Queries all items.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM Families f WHERE f.lastName = @lastName\",\n * parameters: [\n * {name: \"@lastName\", value: \"Hendricks\"}\n * ]\n * };\n * const {result: items} = await items.query(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all items.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT firstname FROM Families f WHERE f.lastName = @lastName\",\n * parameters: [\n * {name: \"@lastName\", value: \"Hendricks\"}\n * ]\n * };\n * const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: string | SqlQuerySpec, options: FeedOptions = {}): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n\n const fetchFunction: FetchFunctionCallback = async (\n diagnosticNode: DiagnosticNodeInternal,\n innerOptions: FeedOptions,\n ) => {\n const response = await this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n resultFn: (result) => (result ? result.Documents : []),\n query,\n options: innerOptions,\n partitionKey: options.partitionKey,\n diagnosticNode,\n });\n return response;\n };\n\n return new QueryIterator(\n this.clientContext,\n query,\n options,\n fetchFunction,\n this.container.url,\n ResourceType.item,\n );\n }\n\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n *\n * @deprecated Use `changeFeed` instead.\n *\n * @example Read from the beginning of the change feed.\n * ```javascript\n * const iterator = items.readChangeFeed({ startFromBeginning: true });\n * const firstPage = await iterator.fetchNext();\n * const firstPageResults = firstPage.result\n * const secondPage = await iterator.fetchNext();\n * ```\n */\n public readChangeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n * @deprecated Use `changeFeed` instead.\n *\n */\n public readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n * @deprecated Use `changeFeed` instead.\n */\n public readChangeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n * @deprecated Use `changeFeed` instead.\n */\n public readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n public readChangeFeed(\n partitionKeyOrChangeFeedOptions?: PartitionKey | ChangeFeedOptions,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator {\n if (isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) {\n return this.changeFeed(partitionKeyOrChangeFeedOptions);\n } else {\n return this.changeFeed(partitionKeyOrChangeFeedOptions, changeFeedOptions);\n }\n }\n\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n *\n * @example Read from the beginning of the change feed.\n * ```javascript\n * const iterator = items.readChangeFeed({ startFromBeginning: true });\n * const firstPage = await iterator.fetchNext();\n * const firstPageResults = firstPage.result\n * const secondPage = await iterator.fetchNext();\n * ```\n */\n public changeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n */\n public changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n */\n public changeFeed(\n partitionKey: PartitionKey,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator;\n /**\n * Create a `ChangeFeedIterator` to iterate over pages of changes\n */\n public changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator;\n public changeFeed(\n partitionKeyOrChangeFeedOptions?: PartitionKey | ChangeFeedOptions,\n changeFeedOptions?: ChangeFeedOptions,\n ): ChangeFeedIterator {\n let partitionKey: PartitionKey;\n if (!changeFeedOptions && isChangeFeedOptions(partitionKeyOrChangeFeedOptions)) {\n partitionKey = undefined;\n changeFeedOptions = partitionKeyOrChangeFeedOptions;\n } else if (\n partitionKeyOrChangeFeedOptions !== undefined &&\n !isChangeFeedOptions(partitionKeyOrChangeFeedOptions)\n ) {\n partitionKey = partitionKeyOrChangeFeedOptions;\n }\n\n if (!changeFeedOptions) {\n changeFeedOptions = {};\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n return new ChangeFeedIterator(this.clientContext, id, path, partitionKey, changeFeedOptions);\n }\n\n /**\n * Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container.\n */\n public getChangeFeedIterator(\n changeFeedIteratorOptions?: ChangeFeedIteratorOptions,\n ): ChangeFeedPullModelIterator {\n const cfOptions = changeFeedIteratorOptions !== undefined ? changeFeedIteratorOptions : {};\n validateChangeFeedIteratorOptions(cfOptions);\n const iterator = changeFeedIteratorBuilder(\n cfOptions,\n this.clientContext,\n this.container,\n this.partitionKeyRangeCache,\n );\n return iterator;\n }\n\n /**\n * Read all items.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const {body: containerList} = await items.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator;\n /**\n * Read all items.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n * @example Read all items to array.\n * ```typescript\n * const {body: containerList} = await items.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator;\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(\"SELECT * from c\", options);\n }\n\n /**\n * Create an item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - Represents the body of the item. Can contain any number of user defined properties.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n */\n public async create(\n body: T,\n options: RequestOptions = {},\n ): Promise> {\n // Generate random document id if the id is missing in the payload and\n // options.disableAutomaticIdGeneration != true\n\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if ((body.id === undefined || body.id === \"\") && !options.disableAutomaticIdGeneration) {\n body.id = uuid();\n }\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n const partitionKey = extractPartitionKeys(body, partitionKeyDefinition);\n\n const err = {};\n if (!isItemResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n diagnosticNode,\n options,\n partitionKey,\n });\n\n const ref = new Item(\n this.container,\n (response.result as any).id,\n this.clientContext,\n partitionKey,\n );\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Upsert an item.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - Represents the body of the item. Can contain any number of user defined properties.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n */\n public async upsert(\n body: unknown,\n options?: RequestOptions,\n ): Promise>;\n /**\n * Upsert an item.\n *\n * Any provided type, T, is not necessarily enforced by the SDK.\n * You may get more or less properties and it's up to your logic to enforce it.\n *\n * There is no set schema for JSON items. They may contain any number of custom properties.\n *\n * @param body - Represents the body of the item. Can contain any number of user defined properties.\n * @param options - Used for modifying the request (for instance, specifying the partition key).\n */\n public async upsert(\n body: T,\n options?: RequestOptions,\n ): Promise>;\n public async upsert(\n body: T,\n options: RequestOptions = {},\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n // Generate random document id if the id is missing in the payload and\n // options.disableAutomaticIdGeneration != true\n if ((body.id === undefined || body.id === \"\") && !options.disableAutomaticIdGeneration) {\n body.id = uuid();\n }\n\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n const partitionKey = extractPartitionKeys(body, partitionKeyDefinition);\n\n const err = {};\n if (!isItemResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.upsert({\n body,\n path,\n resourceType: ResourceType.item,\n resourceId: id,\n options,\n partitionKey,\n diagnosticNode,\n });\n\n const ref = new Item(\n this.container,\n (response.result as any).id,\n this.clientContext,\n partitionKey,\n );\n return new ItemResponse(\n response.result,\n response.headers,\n response.code,\n response.substatus,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Execute bulk operations on items.\n *\n * Bulk takes an array of Operations which are typed based on what the operation does.\n * The choices are: Create, Upsert, Read, Replace, and Delete\n *\n * Usage example:\n * ```typescript\n * // partitionKey is optional at the top level if present in the resourceBody\n * const operations: OperationInput[] = [\n * {\n * operationType: \"Create\",\n * resourceBody: { id: \"doc1\", name: \"sample\", key: \"A\" }\n * },\n * {\n * operationType: \"Upsert\",\n * partitionKey: 'A',\n * resourceBody: { id: \"doc2\", name: \"other\", key: \"A\" }\n * }\n * ]\n *\n * await database.container.items.bulk(operations)\n * ```\n *\n * @param operations - List of operations. Limit 100\n * @param bulkOptions - Optional options object to modify bulk behavior. Pass \\{ continueOnError: true \\} to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE\n * @param options - Used for modifying the request.\n */\n public async bulk(\n operations: OperationInput[],\n bulkOptions?: BulkOptions,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resources: partitionKeyRanges } = await this.container\n .readPartitionKeyRanges()\n .fetchAll();\n const partitionKeyDefinition = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n const batches: Batch[] = partitionKeyRanges.map((keyRange: PartitionKeyRange) => {\n return {\n min: keyRange.minInclusive,\n max: keyRange.maxExclusive,\n rangeId: keyRange.id,\n indexes: [],\n operations: [],\n };\n });\n\n this.groupOperationsBasedOnPartitionKey(operations, partitionKeyDefinition, options, batches);\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n\n const orderedResponses: OperationResponse[] = [];\n await Promise.all(\n batches\n .filter((batch: Batch) => batch.operations.length)\n .flatMap((batch: Batch) => splitBatchBasedOnBodySize(batch))\n .map(async (batch: Batch) => {\n if (batch.operations.length > 100) {\n throw new Error(\n \"Cannot run bulk request with more than 100 operations per partition\",\n );\n }\n try {\n const response = await addDignosticChild(\n async (childNode: DiagnosticNodeInternal) =>\n this.clientContext.bulk({\n body: batch.operations,\n partitionKeyRangeId: batch.rangeId,\n path,\n resourceId: this.container.url,\n bulkOptions,\n options,\n diagnosticNode: childNode,\n }),\n diagnosticNode,\n DiagnosticNodeType.BATCH_REQUEST,\n );\n response.result.forEach((operationResponse: OperationResponse, index: number) => {\n orderedResponses[batch.indexes[index]] = operationResponse;\n });\n } catch (err: any) {\n // In the case of 410 errors, we need to recompute the partition key ranges\n // and redo the batch request, however, 410 errors occur for unsupported\n // partition key types as well since we don't support them, so for now we throw\n if (err.code === 410) {\n throw new Error(\n \"Partition key error. Either the partitions have split or an operation has an unsupported partitionKey type\" +\n err.message,\n );\n }\n throw new Error(`Bulk request errored with: ${err.message}`);\n }\n }),\n );\n const response: any = orderedResponses;\n response.diagnostics = diagnosticNode.toDiagnostic(this.clientContext.getClientConfig());\n return response;\n }, this.clientContext);\n }\n\n /**\n * Function to create batches based of partition key Ranges.\n * @param operations - operations to group\n * @param partitionDefinition - PartitionKey definition of container.\n * @param options - Request options for bulk request.\n * @param batches - Groups to be filled with operations.\n */\n private groupOperationsBasedOnPartitionKey(\n operations: OperationInput[],\n partitionDefinition: PartitionKeyDefinition,\n options: RequestOptions | undefined,\n batches: Batch[],\n ) {\n operations.forEach((operationInput, index: number) => {\n const { operation, partitionKey } = prepareOperations(\n operationInput,\n partitionDefinition,\n options,\n );\n const hashed = hashPartitionKey(\n assertNotUndefined(\n partitionKey,\n \"undefined value for PartitionKey is not expected during grouping of bulk operations.\",\n ),\n partitionDefinition,\n );\n const batchForKey = assertNotUndefined(\n batches.find((batch: Batch) => {\n return isKeyInRange(batch.min, batch.max, hashed);\n }),\n \"No suitable Batch found.\",\n );\n batchForKey.operations.push(operation);\n batchForKey.indexes.push(index);\n });\n }\n\n /**\n * Execute transactional batch operations on items.\n *\n * Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails.\n * The choices are: Create, Upsert, Read, Replace, and Delete\n *\n * Usage example:\n * ```typescript\n * // partitionKey is required as a second argument to batch, but defaults to the default partition key\n * const operations: OperationInput[] = [\n * {\n * operationType: \"Create\",\n * resourceBody: { id: \"doc1\", name: \"sample\", key: \"A\" }\n * },\n * {\n * operationType: \"Upsert\",\n * partitionKey: 'A',\n * resourceBody: { id: \"doc2\", name: \"other\", key: \"A\" }\n * }\n * ]\n *\n * await database.container.items.batch(operations)\n * ```\n *\n * @param operations - List of operations. Limit 100\n * @param options - Used for modifying the request\n */\n public async batch(\n operations: OperationInput[],\n partitionKey?: PartitionKey,\n options?: RequestOptions,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n operations.map((operation) => decorateBatchOperation(operation, options));\n\n const path = getPathFromLink(this.container.url, ResourceType.item);\n\n if (operations.length > 100) {\n throw new Error(\"Cannot run batch request with more than 100 operations per partition\");\n }\n try {\n const response: Response = await this.clientContext.batch({\n body: operations,\n partitionKey,\n path,\n resourceId: this.container.url,\n options,\n diagnosticNode,\n });\n return response;\n } catch (err: any) {\n throw new Error(`Batch request error: ${err.message}`);\n }\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { StoredProcedure } from \"./StoredProcedure\";\nimport { StoredProcedureDefinition } from \"./StoredProcedureDefinition\";\n\nexport class StoredProcedureResponse extends ResourceResponse<\n StoredProcedureDefinition & Resource\n> {\n constructor(\n resource: StoredProcedureDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n storedProcedure: StoredProcedure,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.storedProcedure = storedProcedure;\n }\n /**\n * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.\n */\n public readonly storedProcedure: StoredProcedure;\n\n /**\n * Alias for storedProcedure.\n *\n * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to.\n */\n public get sproc(): StoredProcedure {\n return this.storedProcedure;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createStoredProcedureUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { PartitionKey } from \"../../documents/PartitionKey\";\nimport { undefinedPartitionKey } from \"../../extractPartitionKey\";\nimport { RequestOptions, ResourceResponse } from \"../../request\";\nimport { readPartitionKeyDefinition } from \"../ClientUtils\";\nimport { Container } from \"../Container\";\nimport { StoredProcedureDefinition } from \"./StoredProcedureDefinition\";\nimport { StoredProcedureResponse } from \"./StoredProcedureResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id.\n *\n * For operations to create, read all, or query Stored Procedures,\n */\nexport class StoredProcedure {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createStoredProcedureUri(this.container.database.id, this.container.id, this.id);\n }\n /**\n * Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}.\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link StoredProcedure}.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}.\n * @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition.\n */\n public async replace(\n body: StoredProcedureDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link StoredProcedure}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Execute the given {@link StoredProcedure}.\n *\n * The specified type, T, is not enforced by the client.\n * Be sure to validate the response from the stored procedure matches the type, T, you provide.\n *\n * @param partitionKey - The partition key to use when executing the stored procedure\n * @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}.\n * @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on.\n */\n public async execute(\n partitionKey: PartitionKey,\n params?: any[],\n options?: RequestOptions,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (partitionKey === undefined) {\n const partitionKeyResponse = await readPartitionKeyDefinition(\n diagnosticNode,\n this.container,\n );\n partitionKey = undefinedPartitionKey(partitionKeyResponse);\n }\n const response = await this.clientContext.execute({\n sprocLink: this.url,\n params,\n options,\n partitionKey,\n diagnosticNode,\n });\n return new ResourceResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { StoredProcedure } from \"./StoredProcedure\";\nimport { StoredProcedureDefinition } from \"./StoredProcedureDefinition\";\nimport { StoredProcedureResponse } from \"./StoredProcedureResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for creating, upserting, or reading/querying all Stored Procedures.\n *\n * For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`.\n */\nexport class StoredProcedures {\n /**\n * @param container - The parent {@link Container}.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all Stored Procedures.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @example Read all stored procedures to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @sproc\",\n * parameters: [\n * {name: \"@sproc\", value: \"Todo\"}\n * ]\n * };\n * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all Stored Procedures.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @example Read all stored procedures to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @sproc\",\n * parameters: [\n * {name: \"@sproc\", value: \"Todo\"}\n * ]\n * };\n * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.sproc);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n resultFn: (result) => result.StoredProcedures,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n });\n }\n\n /**\n * Read all stored procedures.\n * @example Read all stored procedures to array.\n * ```typescript\n * const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a StoredProcedure.\n *\n * Azure Cosmos DB allows stored procedures to be executed in the storage tier,\n * directly against an item container. The script\n * gets executed under ACID transactions on the primary storage partition of the\n * specified container. For additional details,\n * refer to the server-side JavaScript API documentation.\n */\n public async create(\n body: StoredProcedureDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.sproc);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.sproc,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new StoredProcedure(this.container, response.result.id, this.clientContext);\n return new StoredProcedureResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Trigger } from \"./index\";\nimport { TriggerDefinition } from \"./TriggerDefinition\";\n\nexport class TriggerResponse extends ResourceResponse {\n constructor(\n resource: TriggerDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n trigger: Trigger,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.trigger = trigger;\n }\n /** A reference to the {@link Trigger} corresponding to the returned {@link TriggerDefinition}. */\n public readonly trigger: Trigger;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createTriggerUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { TriggerDefinition } from \"./TriggerDefinition\";\nimport { TriggerResponse } from \"./TriggerResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations to read, replace, or delete a {@link Trigger}.\n *\n * Use `container.triggers` to create, upsert, query, or read all.\n */\nexport class Trigger {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createTriggerUri(this.container.database.id, this.container.id, this.id);\n }\n\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link Trigger}.\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link TriggerDefinition} for the given {@link Trigger}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link Trigger} with the specified {@link TriggerDefinition}.\n * @param body - The specified {@link TriggerDefinition} to replace the existing definition with.\n */\n public async replace(\n body: TriggerDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link Trigger}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { Trigger } from \"./Trigger\";\nimport { TriggerDefinition } from \"./TriggerDefinition\";\nimport { TriggerResponse } from \"./TriggerResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations to create, upsert, query, and read all triggers.\n *\n * Use `container.triggers` to read, replace, or delete a {@link Trigger}.\n */\nexport class Triggers {\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all Triggers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all Triggers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.trigger);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n resultFn: (result) => result.Triggers,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all Triggers.\n * @example Read all trigger to array.\n * ```typescript\n * const {body: triggerList} = await container.triggers.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n /**\n * Create a trigger.\n *\n * Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed\n * on creates, updates and deletes.\n *\n * For additional details, refer to the server-side JavaScript API documentation.\n */\n public async create(body: TriggerDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.trigger);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.trigger,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new Trigger(this.container, response.result.id, this.clientContext);\n return new TriggerResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { UserDefinedFunction } from \"./UserDefinedFunction\";\nimport { UserDefinedFunctionDefinition } from \"./UserDefinedFunctionDefinition\";\n\nexport class UserDefinedFunctionResponse extends ResourceResponse<\n UserDefinedFunctionDefinition & Resource\n> {\n constructor(\n resource: UserDefinedFunctionDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n udf: UserDefinedFunction,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.userDefinedFunction = udf;\n }\n /** A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. */\n public readonly userDefinedFunction: UserDefinedFunction;\n /**\n * Alias for `userDefinedFunction(id)`.\n *\n * A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}.\n */\n public get udf(): UserDefinedFunction {\n return this.userDefinedFunction;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createUserDefinedFunctionUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { UserDefinedFunctionDefinition } from \"./UserDefinedFunctionDefinition\";\nimport { UserDefinedFunctionResponse } from \"./UserDefinedFunctionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to read, replace, or delete a specified User Definied Function by id.\n *\n * @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions.\n */\nexport class UserDefinedFunction {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createUserDefinedFunctionUri(this.container.database.id, this.container.id, this.id);\n }\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n * @param id - The id of the given {@link UserDefinedFunction}.\n */\n constructor(\n public readonly container: Container,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}.\n * @param options -\n */\n public async replace(\n body: UserDefinedFunctionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link UserDefined}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Container } from \"../Container\";\nimport { Resource } from \"../Resource\";\nimport { UserDefinedFunction } from \"./UserDefinedFunction\";\nimport { UserDefinedFunctionDefinition } from \"./UserDefinedFunctionDefinition\";\nimport { UserDefinedFunctionResponse } from \"./UserDefinedFunctionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to create, upsert, query, or read all User Defined Functions.\n *\n * @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id.\n */\nexport class UserDefinedFunctions {\n /**\n * @hidden\n * @param container - The parent {@link Container}.\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all User Defined Functions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all User Defined Functions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.container.url, ResourceType.udf);\n const id = getIdFromLink(this.container.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n resultFn: (result) => result.UserDefinedFunctions,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all User Defined Functions.\n * @example Read all User Defined Functions to array.\n * ```typescript\n * const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a UserDefinedFunction.\n *\n * Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers.\n *\n * For additional details, refer to the server-side JavaScript API documentation.\n *\n */\n public async create(\n body: UserDefinedFunctionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n if (body.body) {\n body.body = body.body.toString();\n }\n\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.container.url, ResourceType.udf);\n const id = getIdFromLink(this.container.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.udf,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new UserDefinedFunction(this.container, response.result.id, this.clientContext);\n return new UserDefinedFunctionResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { StoredProcedures, StoredProcedure } from \"../StoredProcedure\";\nimport { Trigger, Triggers } from \"../Trigger\";\nimport { UserDefinedFunction, UserDefinedFunctions } from \"../UserDefinedFunction\";\nimport { ClientContext } from \"../../ClientContext\";\nimport { Container } from \"../Container/Container\";\n\nexport class Scripts {\n /**\n * @param container - The parent {@link Container}.\n * @hidden\n */\n constructor(\n public readonly container: Container,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Used to read, replace, or delete a specific, existing {@link StoredProcedure} by id.\n *\n * Use `.storedProcedures` for creating new stored procedures, or querying/reading all stored procedures.\n * @param id - The id of the {@link StoredProcedure}.\n */\n public storedProcedure(id: string): StoredProcedure {\n return new StoredProcedure(this.container, id, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Trigger} by id.\n *\n * Use `.triggers` for creating new triggers, or querying/reading all triggers.\n * @param id - The id of the {@link Trigger}.\n */\n public trigger(id: string): Trigger {\n return new Trigger(this.container, id, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link UserDefinedFunction} by id.\n *\n * Use `.userDefinedFunctions` for creating new user defined functions, or querying/reading all user defined functions.\n * @param id - The id of the {@link UserDefinedFunction}.\n */\n public userDefinedFunction(id: string): UserDefinedFunction {\n return new UserDefinedFunction(this.container, id, this.clientContext);\n }\n\n private $sprocs: StoredProcedures;\n /**\n * Operations for creating new stored procedures, and reading/querying all stored procedures.\n *\n * For reading, replacing, or deleting an existing stored procedure, use `.storedProcedure(id)`.\n */\n public get storedProcedures(): StoredProcedures {\n if (!this.$sprocs) {\n this.$sprocs = new StoredProcedures(this.container, this.clientContext);\n }\n return this.$sprocs;\n }\n\n private $triggers: Triggers;\n /**\n * Operations for creating new triggers, and reading/querying all triggers.\n *\n * For reading, replacing, or deleting an existing trigger, use `.trigger(id)`.\n */\n public get triggers(): Triggers {\n if (!this.$triggers) {\n this.$triggers = new Triggers(this.container, this.clientContext);\n }\n return this.$triggers;\n }\n\n private $udfs: UserDefinedFunctions;\n /**\n * Operations for creating new user defined functions, and reading/querying all user defined functions.\n *\n * For reading, replacing, or deleting an existing user defined function, use `.userDefinedFunction(id)`.\n */\n public get userDefinedFunctions(): UserDefinedFunctions {\n if (!this.$udfs) {\n this.$udfs = new UserDefinedFunctions(this.container, this.clientContext);\n }\n return this.$udfs;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request/ResourceResponse\";\nimport { Resource } from \"../Resource\";\nimport { ContainerDefinition } from \"./ContainerDefinition\";\nimport { Container } from \"./index\";\n\n/** Response object for Container operations */\nexport class ContainerResponse extends ResourceResponse {\n constructor(\n resource: ContainerDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n container: Container,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.container = container;\n }\n /** A reference to the {@link Container} that the returned {@link ContainerDefinition} corresponds to. */\n public readonly container: Container;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Offer } from \"./Offer\";\nimport { OfferDefinition } from \"./OfferDefinition\";\n\nexport class OfferResponse extends ResourceResponse {\n constructor(\n resource: OfferDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n diagnostics: CosmosDiagnostics,\n offer?: Offer,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.offer = offer;\n }\n /** A reference to the {@link Offer} corresponding to the returned {@link OfferDefinition}. */\n public readonly offer: Offer;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, isResourceValid, ResourceType } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { RequestOptions } from \"../../request\";\nimport { OfferDefinition } from \"./OfferDefinition\";\nimport { OfferResponse } from \"./OfferResponse\";\n\n/**\n * Use to read or replace an existing {@link Offer} by id.\n *\n * @see {@link Offers} to query or read all offers.\n */\nexport class Offer {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return `/${Constants.Path.OffersPathSegment}/${this.id}`;\n }\n /**\n * @hidden\n * @param client - The parent {@link CosmosClient} for the Database Account.\n * @param id - The id of the given {@link Offer}.\n */\n constructor(\n public readonly client: CosmosClient,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link OfferDefinition} for the given {@link Offer}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const response = await this.clientContext.read({\n path: this.url,\n resourceType: ResourceType.offer,\n resourceId: this.id,\n options,\n diagnosticNode,\n });\n return new OfferResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n this,\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link Offer} with the specified {@link OfferDefinition}.\n * @param body - The specified {@link OfferDefinition}\n */\n public async replace(body: OfferDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n const response = await this.clientContext.replace({\n body,\n path: this.url,\n resourceType: ResourceType.offer,\n resourceId: this.id,\n options,\n diagnosticNode,\n });\n return new OfferResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n this,\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { ResourceType } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { OfferDefinition } from \"./OfferDefinition\";\n\n/**\n * Use to query or read all Offers.\n *\n * @see {@link Offer} to read or replace an existing {@link Offer} by id.\n */\nexport class Offers {\n /**\n * @hidden\n * @param client - The parent {@link CosmosClient} for the offers.\n */\n constructor(\n public readonly client: CosmosClient,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all offers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all offers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path: \"/offers\",\n resourceType: ResourceType.offer,\n resourceId: \"\",\n resultFn: (result) => result.Offers,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all offers.\n * @example Read all offers to array.\n * ```typescript\n * const {body: offerList} = await client.offers.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport {\n createDocumentCollectionUri,\n getIdFromLink,\n getPathFromLink,\n HTTPMethod,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { PartitionKey, PartitionKeyDefinition } from \"../../documents\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions, ResourceResponse, Response } from \"../../request\";\nimport { PartitionedQueryExecutionInfo } from \"../../request/ErrorResponse\";\nimport { Conflict, Conflicts } from \"../Conflict\";\nimport { Database } from \"../Database\";\nimport { Item, Items } from \"../Item\";\nimport { Scripts } from \"../Script/Scripts\";\nimport { ContainerDefinition } from \"./ContainerDefinition\";\nimport { ContainerResponse } from \"./ContainerResponse\";\nimport { PartitionKeyRange } from \"./PartitionKeyRange\";\nimport { Offer, OfferDefinition } from \"../Offer\";\nimport { OfferResponse } from \"../Offer/OfferResponse\";\nimport { Resource } from \"../Resource\";\nimport { FeedRange, FeedRangeInternal } from \"../ChangeFeed\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n withMetadataDiagnostics,\n} from \"../../utils/diagnostics\";\nimport { MetadataLookUpType } from \"../../CosmosDiagnostics\";\n\n/**\n * Operations for reading, replacing, or deleting a specific, existing container by id.\n *\n * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists;\n * do this once on application start up.\n */\nexport class Container {\n private $items: Items;\n /**\n * Operations for creating new items, and reading/querying all items\n *\n * For reading, replacing, or deleting an existing item, use `.item(id)`.\n *\n * @example Create a new item\n * ```typescript\n * const {body: createdItem} = await container.items.create({id: \"\", properties: {}});\n * ```\n */\n public get items(): Items {\n if (!this.$items) {\n this.$items = new Items(this, this.clientContext);\n }\n return this.$items;\n }\n\n private $scripts: Scripts;\n /**\n * All operations for Stored Procedures, Triggers, and User Defined Functions\n */\n public get scripts(): Scripts {\n if (!this.$scripts) {\n this.$scripts = new Scripts(this, this.clientContext);\n }\n return this.$scripts;\n }\n\n private $conflicts: Conflicts;\n /**\n * Operations for reading and querying conflicts for the given container.\n *\n * For reading or deleting a specific conflict, use `.conflict(id)`.\n */\n public get conflicts(): Conflicts {\n if (!this.$conflicts) {\n this.$conflicts = new Conflicts(this, this.clientContext);\n }\n return this.$conflicts;\n }\n\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createDocumentCollectionUri(this.database.id, this.id);\n }\n\n /**\n * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object.\n * @param database - The parent {@link Database}.\n * @param id - The id of the given container.\n * @hidden\n */\n constructor(\n public readonly database: Database,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Item} by id.\n *\n * Use `.items` for creating new items, or querying/reading all items.\n *\n * @param id - The id of the {@link Item}.\n * @param partitionKeyValue - The value of the {@link Item} partition key\n * @example Replace an item\n * `const {body: replacedItem} = await container.item(\"\", \"\").replace({id: \"\", title: \"Updated post\", authorID: 5});`\n */\n public item(id: string, partitionKeyValue?: PartitionKey): Item {\n return new Item(this, id, this.clientContext, partitionKeyValue);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Conflict} by id.\n *\n * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts.\n * @param id - The id of the {@link Conflict}.\n */\n public conflict(id: string, partitionKey?: PartitionKey): Conflict {\n return new Conflict(this, id, this.clientContext, partitionKey);\n }\n\n /** Read the container's definition */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.readInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async readInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: RequestOptions,\n ): Promise {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n diagnosticNode,\n });\n this.clientContext.partitionKeyDefinitionCache[this.url] = response.result.partitionKey;\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /** Replace the container's definition */\n public async replace(\n body: ContainerDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /** Delete the container */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Gets the partition key definition first by looking into the cache otherwise by reading the collection.\n * @deprecated This method has been renamed to readPartitionKeyDefinition.\n */\n public async getPartitionKeyDefinition(): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.readPartitionKeyDefinition(diagnosticNode);\n }, this.clientContext);\n }\n\n /**\n * Gets the partition key definition first by looking into the cache otherwise by reading the collection.\n * @hidden\n */\n public async readPartitionKeyDefinition(\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise> {\n // $ISSUE-felixfan-2016-03-17: Make name based path and link based path use the same key\n // $ISSUE-felixfan-2016-03-17: Refresh partitionKeyDefinitionCache when necessary\n if (this.url in this.clientContext.partitionKeyDefinitionCache) {\n diagnosticNode.addData({ readFromCache: true });\n return new ResourceResponse(\n this.clientContext.partitionKeyDefinitionCache[this.url],\n {},\n 0,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n const { headers, statusCode, diagnostics } = await withMetadataDiagnostics(\n async (node: DiagnosticNodeInternal) => {\n return this.readInternal(node);\n },\n diagnosticNode,\n MetadataLookUpType.ContainerLookUp,\n );\n\n return new ResourceResponse(\n this.clientContext.partitionKeyDefinitionCache[this.url],\n headers,\n statusCode,\n diagnostics,\n );\n }\n\n /**\n * Gets offer on container. If none exists, returns an OfferResponse with undefined.\n */\n public async readOffer(options: RequestOptions = {}): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resource: container } = await this.read();\n const path = \"/offers\";\n const url = container._self;\n\n const response = await this.clientContext.queryFeed({\n path,\n resourceId: \"\",\n resourceType: ResourceType.offer,\n query: `SELECT * from root where root.resource = \"${url}\"`,\n resultFn: (result) => result.Offers,\n options,\n diagnosticNode,\n });\n const offer = response.result[0]\n ? new Offer(this.database.client, response.result[0].id, this.clientContext)\n : undefined;\n return new OfferResponse(\n response.result[0],\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n offer,\n );\n }, this.clientContext);\n }\n\n public async getQueryPlan(\n query: string | SqlQuerySpec,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n\n return this.clientContext.getQueryPlan(\n path + \"/docs\",\n ResourceType.item,\n getIdFromLink(this.url),\n query,\n {},\n diagnosticNode,\n );\n }, this.clientContext);\n }\n\n public readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator {\n feedOptions = feedOptions || {};\n return this.clientContext.queryPartitionKeyRanges(this.url, undefined, feedOptions);\n }\n /**\n *\n * @returns all the feed ranges for which changefeed could be fetched.\n */\n public async getFeedRanges(): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resources } = await this.readPartitionKeyRanges().fetchAllInternal(diagnosticNode);\n\n const feedRanges: FeedRange[] = [];\n for (const resource of resources) {\n const feedRange = new FeedRangeInternal(resource.minInclusive, resource.maxExclusive);\n Object.freeze(feedRange);\n feedRanges.push(feedRange);\n }\n return feedRanges;\n }, this.clientContext);\n }\n\n /**\n * Delete all documents belong to the container for the provided partition key value\n * @param partitionKey - The partition key value of the items to be deleted\n */\n public async deleteAllItemsForPartitionKey(\n partitionKey: PartitionKey,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n let path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n path = path + \"/operations/partitionkeydelete\";\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n options,\n partitionKey: partitionKey,\n method: HTTPMethod.post,\n diagnosticNode,\n });\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { ContainerRequest } from \"../client/Container/ContainerRequest\";\n\nexport function validateOffer(body: ContainerRequest): void {\n if (body.throughput) {\n if (body.maxThroughput) {\n console.log(\"should be erroring\");\n throw new Error(\"Cannot specify `throughput` with `maxThroughput`\");\n }\n if (body.autoUpgradePolicy) {\n throw new Error(\n \"Cannot specify autoUpgradePolicy with throughput. Use `maxThroughput` instead\",\n );\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport {\n Constants,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n StatusCodes,\n} from \"../../common\";\nimport { DEFAULT_PARTITION_KEY_PATH } from \"../../common/partitionKeys\";\nimport { mergeHeaders, SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Database } from \"../Database\";\nimport { Resource } from \"../Resource\";\nimport { Container } from \"./Container\";\nimport { ContainerDefinition } from \"./ContainerDefinition\";\nimport { ContainerRequest } from \"./ContainerRequest\";\nimport { ContainerResponse } from \"./ContainerResponse\";\nimport { validateOffer } from \"../../utils/offers\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for creating new containers, and reading/querying all containers\n *\n * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists;\n * do this once on application start up.\n */\nexport class Containers {\n constructor(\n public readonly database: Database,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Queries all containers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.\n * @example Read all containers to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @container\",\n * parameters: [\n * {name: \"@container\", value: \"Todo\"}\n * ]\n * };\n * const {body: containerList} = await client.database(\"\").containers.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all containers.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time.\n * @example Read all containers to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @container\",\n * parameters: [\n * {name: \"@container\", value: \"Todo\"}\n * ]\n * };\n * const {body: containerList} = await client.database(\"\").containers.query(querySpec).fetchAll();\n * ```\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.database.url, ResourceType.container);\n const id = getIdFromLink(this.database.url);\n\n return new QueryIterator(\n this.clientContext,\n query,\n options,\n (diagNode: DiagnosticNodeInternal, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n resultFn: (result) => result.DocumentCollections,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n },\n );\n }\n\n /**\n * Creates a container.\n *\n * A container is a named logical container for items.\n *\n * A database may contain zero or more named containers and each container consists of\n * zero or more JSON items.\n *\n * Being schema-free, the items in a container do not need to share the same structure or fields.\n *\n *\n * Since containers are application resources, they can be authorized using either the\n * master key or resource keys.\n *\n * @param body - Represents the body of the container.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public async create(\n body: ContainerRequest,\n options: RequestOptions = {},\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.createInternal(diagnosticNode, body, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async createInternal(\n diagnosticNode: DiagnosticNodeInternal,\n body: ContainerRequest,\n options: RequestOptions = {},\n ): Promise {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n const path = getPathFromLink(this.database.url, ResourceType.container);\n const id = getIdFromLink(this.database.url);\n\n validateOffer(body);\n\n if (body.maxThroughput) {\n const autoscaleParams: {\n maxThroughput: number;\n autoUpgradePolicy?: {\n throughputPolicy: {\n incrementPercent: number;\n };\n };\n } = {\n maxThroughput: body.maxThroughput,\n };\n if (body.autoUpgradePolicy) {\n autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy;\n }\n const autoscaleHeader = JSON.stringify(autoscaleParams);\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.AutoscaleSettings]: autoscaleHeader,\n });\n delete body.maxThroughput;\n delete body.autoUpgradePolicy;\n }\n\n if (body.throughput) {\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.OfferThroughput]: body.throughput,\n });\n delete body.throughput;\n }\n\n if (typeof body.partitionKey === \"string\") {\n if (!body.partitionKey.startsWith(\"/\")) {\n throw new Error(\"Partition key must start with '/'\");\n }\n body.partitionKey = {\n paths: [body.partitionKey],\n };\n }\n\n // If they don't specify a partition key, use the default path\n if (!body.partitionKey || !body.partitionKey.paths) {\n body.partitionKey = {\n paths: [DEFAULT_PARTITION_KEY_PATH],\n };\n }\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.container,\n resourceId: id,\n diagnosticNode,\n options,\n });\n const ref = new Container(this.database, response.result.id, this.clientContext);\n return new ContainerResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /**\n * Checks if a Container exists, and, if it doesn't, creates it.\n * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.\n * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.)\n *\n * A container is a named logical container for items.\n *\n * A database may contain zero or more named containers and each container consists of\n * zero or more JSON items.\n *\n * Being schema-free, the items in a container do not need to share the same structure or fields.\n *\n *\n * Since containers are application resources, they can be authorized using either the\n * master key or resource keys.\n *\n * @param body - Represents the body of the container.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public async createIfNotExists(\n body: ContainerRequest,\n options?: RequestOptions,\n ): Promise {\n if (!body || body.id === null || body.id === undefined) {\n throw new Error(\"body parameter must be an object with an id property\");\n }\n /*\n 1. Attempt to read the Container (based on an assumption that most containers will already exist, so its faster)\n 2. If it fails with NotFound error, attempt to create the container. Else, return the read results.\n */\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n try {\n const readResponse = await this.database\n .container(body.id)\n .readInternal(diagnosticNode, options);\n return readResponse;\n } catch (err: any) {\n if (err.code === StatusCodes.NotFound) {\n const createResponse = await this.createInternal(diagnosticNode, body, options);\n // Must merge the headers to capture RU costskaty\n mergeHeaders(createResponse.headers, err.headers);\n return createResponse;\n } else {\n throw err;\n }\n }\n }, this.clientContext);\n }\n\n /**\n * Read all containers.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time.\n * @example Read all containers to array.\n * ```typescript\n * const {body: containerList} = await client.database(\"\").containers.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Permission } from \"./Permission\";\nimport { PermissionBody } from \"./PermissionBody\";\nimport { PermissionDefinition } from \"./PermissionDefinition\";\n\nexport class PermissionResponse extends ResourceResponse<\n PermissionDefinition & PermissionBody & Resource\n> {\n constructor(\n resource: PermissionDefinition & PermissionBody & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n permission: Permission,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.permission = permission;\n }\n /** A reference to the {@link Permission} corresponding to the returned {@link PermissionDefinition}. */\n public readonly permission: Permission;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createPermissionUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request/RequestOptions\";\nimport { User } from \"../User\";\nimport { PermissionBody } from \"./PermissionBody\";\nimport { PermissionDefinition } from \"./PermissionDefinition\";\nimport { PermissionResponse } from \"./PermissionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Use to read, replace, or delete a given {@link Permission} by id.\n *\n * @see {@link Permissions} to create, upsert, query, or read all Permissions.\n */\nexport class Permission {\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createPermissionUri(this.user.database.id, this.user.id, this.id);\n }\n /**\n * @hidden\n * @param user - The parent {@link User}.\n * @param id - The id of the given {@link Permission}.\n */\n constructor(\n public readonly user: User,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Read the {@link PermissionDefinition} of the given {@link Permission}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link Permission} with the specified {@link PermissionDefinition}.\n * @param body - The specified {@link PermissionDefinition}.\n */\n public async replace(\n body: PermissionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link Permission}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { User } from \"../User\";\nimport { Permission } from \"./Permission\";\nimport { PermissionBody } from \"./PermissionBody\";\nimport { PermissionDefinition } from \"./PermissionDefinition\";\nimport { PermissionResponse } from \"./PermissionResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Use to create, replace, query, and read all Permissions.\n *\n * @see {@link Permission} to read, replace, or delete a specific permission by id.\n */\nexport class Permissions {\n /**\n * @hidden\n * @param user - The parent {@link User}.\n */\n constructor(\n public readonly user: User,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all permissions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all permissions.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.user.url, ResourceType.permission);\n const id = getIdFromLink(this.user.url);\n\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n resultFn: (result) => result.Permissions,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all permissions.\n * @example Read all permissions to array.\n * ```typescript\n * const {body: permissionList} = await user.permissions.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a permission.\n *\n * A permission represents a per-User Permission to access a specific resource\n * e.g. Item or Container.\n * @param body - Represents the body of the permission.\n */\n public async create(\n body: PermissionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.user.url, ResourceType.permission);\n const id = getIdFromLink(this.user.url);\n\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n diagnosticNode,\n options,\n });\n const ref = new Permission(this.user, response.result.id, this.clientContext);\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Upsert a permission.\n *\n * A permission represents a per-User Permission to access a\n * specific resource e.g. Item or Container.\n */\n public async upsert(\n body: PermissionDefinition,\n options?: RequestOptions,\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.user.url, ResourceType.permission);\n const id = getIdFromLink(this.user.url);\n\n const response = await this.clientContext.upsert({\n body,\n path,\n resourceType: ResourceType.permission,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new Permission(this.user, response.result.id, this.clientContext);\n return new PermissionResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { User } from \"./User\";\nimport { UserDefinition } from \"./UserDefinition\";\n\nexport class UserResponse extends ResourceResponse {\n constructor(\n resource: UserDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n user: User,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.user = user;\n }\n /** A reference to the {@link User} corresponding to the returned {@link UserDefinition}. */\n public readonly user: User;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n createUserUri,\n getIdFromLink,\n getPathFromLink,\n isResourceValid,\n ResourceType,\n} from \"../../common\";\nimport { RequestOptions } from \"../../request\";\nimport { Database } from \"../Database\";\nimport { Permission, Permissions } from \"../Permission\";\nimport { UserDefinition } from \"./UserDefinition\";\nimport { UserResponse } from \"./UserResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to read, replace, and delete Users.\n *\n * Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`.\n *\n * @see {@link Users} to create, upsert, query, or read all.\n */\nexport class User {\n /**\n * Operations for creating, upserting, querying, or reading all operations.\n *\n * See `client.permission(id)` to read, replace, or delete a specific Permission by id.\n */\n public readonly permissions: Permissions;\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createUserUri(this.database.id, this.id);\n }\n /**\n * @hidden\n * @param database - The parent {@link Database}.\n */\n constructor(\n public readonly database: Database,\n public readonly id: string,\n private readonly clientContext: ClientContext,\n ) {\n this.permissions = new Permissions(this, this.clientContext);\n }\n\n /**\n * Operations to read, replace, or delete a specific Permission by id.\n *\n * See `client.permissions` for creating, upserting, querying, or reading all operations.\n */\n public permission(id: string): Permission {\n return new Permission(this, id, this.clientContext);\n }\n\n /**\n * Read the {@link UserDefinition} for the given {@link User}.\n */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Replace the given {@link User}'s definition with the specified {@link UserDefinition}.\n * @param body - The specified {@link UserDefinition} to replace the definition.\n */\n public async replace(body: UserDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.replace({\n body,\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Delete the given {@link User}.\n */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from \"../../common\";\nimport { SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Database } from \"../Database\";\nimport { Resource } from \"../Resource\";\nimport { User } from \"./User\";\nimport { UserDefinition } from \"./UserDefinition\";\nimport { UserResponse } from \"./UserResponse\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Used to create, upsert, query, and read all users.\n *\n * @see {@link User} to read, replace, or delete a specific User by id.\n */\nexport class Users {\n /**\n * @hidden\n * @param database - The parent {@link Database}.\n */\n constructor(\n public readonly database: Database,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Query all users.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Query all users.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n */\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const path = getPathFromLink(this.database.url, ResourceType.user);\n const id = getIdFromLink(this.database.url);\n return new QueryIterator(this.clientContext, query, options, (diagnosticNode, innerOptions) => {\n return this.clientContext.queryFeed({\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n resultFn: (result) => result.Users,\n query,\n options: innerOptions,\n diagnosticNode,\n });\n });\n }\n\n /**\n * Read all users.-\n * @example Read all users to array.\n * ```typescript\n * const {body: usersList} = await database.users.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n\n /**\n * Create a database user with the specified {@link UserDefinition}.\n * @param body - The specified {@link UserDefinition}.\n */\n public async create(body: UserDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.database.url, ResourceType.user);\n const id = getIdFromLink(this.database.url);\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new User(this.database, response.result.id, this.clientContext);\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Upsert a database user with a specified {@link UserDefinition}.\n * @param body - The specified {@link UserDefinition}.\n */\n public async upsert(body: UserDefinition, options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n const path = getPathFromLink(this.database.url, ResourceType.user);\n const id = getIdFromLink(this.database.url);\n\n const response = await this.clientContext.upsert({\n body,\n path,\n resourceType: ResourceType.user,\n resourceId: id,\n options,\n diagnosticNode,\n });\n const ref = new User(this.database, response.result.id, this.clientContext);\n return new UserResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { CosmosDiagnostics } from \"../../CosmosDiagnostics\";\nimport { CosmosHeaders } from \"../../queryExecutionContext\";\nimport { ResourceResponse } from \"../../request/ResourceResponse\";\nimport { Resource } from \"../Resource\";\nimport { Database } from \"./Database\";\nimport { DatabaseDefinition } from \"./DatabaseDefinition\";\n\n/** Response object for Database operations */\nexport class DatabaseResponse extends ResourceResponse {\n constructor(\n resource: DatabaseDefinition & Resource,\n headers: CosmosHeaders,\n statusCode: number,\n database: Database,\n diagnostics: CosmosDiagnostics,\n ) {\n super(resource, headers, statusCode, diagnostics);\n this.database = database;\n }\n /** A reference to the {@link Database} that the returned {@link DatabaseDefinition} corresponds to. */\n public readonly database: Database;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { createDatabaseUri, getIdFromLink, getPathFromLink, ResourceType } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { RequestOptions } from \"../../request\";\nimport { Container, Containers } from \"../Container\";\nimport { User, Users } from \"../User\";\nimport { DatabaseDefinition } from \"./DatabaseDefinition\";\nimport { DatabaseResponse } from \"./DatabaseResponse\";\nimport { OfferResponse, OfferDefinition, Offer } from \"../Offer\";\nimport { Resource } from \"../Resource\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport {\n getEmptyCosmosDiagnostics,\n withDiagnostics,\n withMetadataDiagnostics,\n} from \"../../utils/diagnostics\";\nimport { MetadataLookUpType } from \"../../CosmosDiagnostics\";\n\n/**\n * Operations for reading or deleting an existing database.\n *\n * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists;\n * do this once on application start up.\n */\nexport class Database {\n /**\n * Used for creating new containers, or querying/reading all containers.\n *\n * Use `.database(id)` to read, replace, or delete a specific, existing {@link Database} by id.\n *\n * @example Create a new container\n * ```typescript\n * const {body: containerDefinition, container} = await client.database(\"\").containers.create({id: \"\"});\n * ```\n */\n public readonly containers: Containers;\n /**\n * Used for creating new users, or querying/reading all users.\n *\n * Use `.user(id)` to read, replace, or delete a specific, existing {@link User} by id.\n */\n public readonly users: Users;\n\n /**\n * Returns a reference URL to the resource. Used for linking in Permissions.\n */\n public get url(): string {\n return createDatabaseUri(this.id);\n }\n\n /** Returns a new {@link Database} instance.\n *\n * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself.\n */\n constructor(\n public readonly client: CosmosClient,\n public readonly id: string,\n private clientContext: ClientContext,\n ) {\n this.containers = new Containers(this, this.clientContext);\n this.users = new Users(this, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link Database} by id.\n *\n * Use `.containers` creating new containers, or querying/reading all containers.\n *\n * @example Delete a container\n * ```typescript\n * await client.database(\"\").container(\"\").delete();\n * ```\n */\n public container(id: string): Container {\n return new Container(this, id, this.clientContext);\n }\n\n /**\n * Used to read, replace, or delete a specific, existing {@link User} by id.\n *\n * Use `.users` for creating new users, or querying/reading all users.\n */\n public user(id: string): User {\n return new User(this, id, this.clientContext);\n }\n\n /** Read the definition of the given Database. */\n public async read(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.readInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async readInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: RequestOptions,\n ): Promise {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n const response = await this.clientContext.read({\n path,\n resourceType: ResourceType.database,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new DatabaseResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /** Delete the given Database. */\n public async delete(options?: RequestOptions): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const path = getPathFromLink(this.url);\n const id = getIdFromLink(this.url);\n\n const response = await this.clientContext.delete({\n path,\n resourceType: ResourceType.database,\n resourceId: id,\n options,\n diagnosticNode,\n });\n return new DatabaseResponse(\n response.result,\n response.headers,\n response.code,\n this,\n getEmptyCosmosDiagnostics(),\n );\n }, this.clientContext);\n }\n\n /**\n * Gets offer on database. If none exists, returns an OfferResponse with undefined.\n */\n public async readOffer(options: RequestOptions = {}): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n const { resource: record } = await withMetadataDiagnostics(\n async (node: DiagnosticNodeInternal) => {\n return this.readInternal(node);\n },\n diagnosticNode,\n MetadataLookUpType.DatabaseLookUp,\n );\n\n const path = \"/offers\";\n const url = record._self;\n\n const response = await this.clientContext.queryFeed({\n path,\n resourceId: \"\",\n resourceType: ResourceType.offer,\n query: `SELECT * from root where root.resource = \"${url}\"`,\n resultFn: (result) => result.Offers,\n options,\n diagnosticNode,\n });\n const offer = response.result[0]\n ? new Offer(this.client, response.result[0].id, this.clientContext)\n : undefined;\n return new OfferResponse(\n response.result[0],\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n offer,\n );\n }, this.clientContext);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { ClientContext } from \"../../ClientContext\";\nimport { Constants, isResourceValid, ResourceType, StatusCodes } from \"../../common\";\nimport { CosmosClient } from \"../../CosmosClient\";\nimport { FetchFunctionCallback, mergeHeaders, SqlQuerySpec } from \"../../queryExecutionContext\";\nimport { QueryIterator } from \"../../queryIterator\";\nimport { FeedOptions, RequestOptions } from \"../../request\";\nimport { Resource } from \"../Resource\";\nimport { Database } from \"./Database\";\nimport { DatabaseDefinition } from \"./DatabaseDefinition\";\nimport { DatabaseRequest } from \"./DatabaseRequest\";\nimport { DatabaseResponse } from \"./DatabaseResponse\";\nimport { validateOffer } from \"../../utils/offers\";\nimport { DiagnosticNodeInternal } from \"../../diagnostics/DiagnosticNodeInternal\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"../../utils/diagnostics\";\n\n/**\n * Operations for creating new databases, and reading/querying all databases\n *\n * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`.\n *\n * Note: all these operations make calls against a fixed budget.\n * You should design your system such that these calls scale sublinearly with your application.\n * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists;\n * do this once on application start up.\n */\nexport class Databases {\n /**\n * @hidden\n * @param client - The parent {@link CosmosClient} for the Database.\n */\n constructor(\n public readonly client: CosmosClient,\n private readonly clientContext: ClientContext,\n ) {}\n\n /**\n * Queries all databases.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.\n * @example Read all databases to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @db\",\n * parameters: [\n * {name: \"@db\", value: \"Todo\"}\n * ]\n * };\n * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n /**\n * Queries all databases.\n * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.\n * @example Read all databases to array.\n * ```typescript\n * const querySpec: SqlQuerySpec = {\n * query: \"SELECT * FROM root r WHERE r.id = @db\",\n * parameters: [\n * {name: \"@db\", value: \"Todo\"}\n * ]\n * };\n * const {body: databaseList} = await client.databases.query(querySpec).fetchAll();\n * ```\n */\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator;\n public query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator {\n const cb: FetchFunctionCallback = (diagNode: DiagnosticNodeInternal, innerOptions) => {\n return this.clientContext.queryFeed({\n path: \"/dbs\",\n resourceType: ResourceType.database,\n resourceId: \"\",\n resultFn: (result) => result.Databases,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n };\n return new QueryIterator(this.clientContext, query, options, cb);\n }\n\n /**\n * Send a request for creating a database.\n *\n * A database manages users, permissions and a set of containers.\n * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,\n * with the database being the logical container for data.\n *\n * Each Database consists of one or more containers, each of which in turn contain one or more\n * documents. Since databases are an administrative resource, the Service Master Key will be\n * required in order to access and successfully complete any action using the User APIs.\n *\n * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n */\n public async create(\n body: DatabaseRequest,\n options: RequestOptions = {},\n ): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.createInternal(diagnosticNode, body, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async createInternal(\n diagnosticNode: DiagnosticNodeInternal,\n body: DatabaseRequest,\n options: RequestOptions = {},\n ): Promise {\n const err = {};\n if (!isResourceValid(body, err)) {\n throw err;\n }\n\n validateOffer(body);\n\n if (body.maxThroughput) {\n const autoscaleParams: {\n maxThroughput: number;\n autoUpgradePolicy?: {\n throughputPolicy: {\n incrementPercent: number;\n };\n };\n } = {\n maxThroughput: body.maxThroughput,\n };\n if (body.autoUpgradePolicy) {\n autoscaleParams.autoUpgradePolicy = body.autoUpgradePolicy;\n }\n const autoscaleHeaders = JSON.stringify(autoscaleParams);\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.AutoscaleSettings]: autoscaleHeaders,\n });\n delete body.maxThroughput;\n delete body.autoUpgradePolicy;\n }\n\n if (body.throughput) {\n options.initialHeaders = Object.assign({}, options.initialHeaders, {\n [Constants.HttpHeaders.OfferThroughput]: body.throughput,\n });\n delete body.throughput;\n }\n\n const path = \"/dbs\"; // TODO: constant\n const response = await this.clientContext.create({\n body,\n path,\n resourceType: ResourceType.database,\n resourceId: undefined,\n diagnosticNode,\n options,\n });\n const ref = new Database(this.client, body.id, this.clientContext);\n return new DatabaseResponse(\n response.result,\n response.headers,\n response.code,\n ref,\n getEmptyCosmosDiagnostics(),\n );\n }\n\n /**\n * Check if a database exists, and if it doesn't, create it.\n * This will make a read operation based on the id in the `body`, then if it is not found, a create operation.\n *\n * A database manages users, permissions and a set of containers.\n * Each Azure Cosmos DB Database Account is able to support multiple independent named databases,\n * with the database being the logical container for data.\n *\n * Each Database consists of one or more containers, each of which in turn contain one or more\n * documents. Since databases are an an administrative resource, the Service Master Key will be\n * required in order to access and successfully complete any action using the User APIs.\n *\n * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created.\n * @param options - Additional options for the request\n */\n public async createIfNotExists(\n body: DatabaseRequest,\n options?: RequestOptions,\n ): Promise {\n if (!body || body.id === null || body.id === undefined) {\n throw new Error(\"body parameter must be an object with an id property\");\n }\n /*\n 1. Attempt to read the Database (based on an assumption that most databases will already exist, so its faster)\n 2. If it fails with NotFound error, attempt to create the db. Else, return the read results.\n */\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n try {\n const readResponse = await this.client\n .database(body.id)\n .readInternal(diagnosticNode, options);\n return readResponse;\n } catch (err: any) {\n if (err.code === StatusCodes.NotFound) {\n const createResponse = await this.createInternal(diagnosticNode, body, options);\n // Must merge the headers to capture RU costskaty\n mergeHeaders(createResponse.headers, err.headers);\n return createResponse;\n } else {\n throw err;\n }\n }\n }, this.clientContext);\n }\n\n // TODO: DatabaseResponse for QueryIterator?\n /**\n * Reads all databases.\n * @param options - Use to set options like response page size, continuation tokens, etc.\n * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time.\n * @example Read all databases to array.\n * ```typescript\n * const {body: databaseList} = await client.databases.readAll().fetchAll();\n * ```\n */\n public readAll(options?: FeedOptions): QueryIterator {\n return this.query(undefined, options);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { RequestContext } from \"../request/RequestContext\";\nimport { Response } from \"../request/Response\";\n\n/**\n * Used to specify which type of events to execute this plug in on.\n *\n * @hidden\n */\nexport enum PluginOn {\n /**\n * Will be executed per network request\n */\n request = \"request\",\n /**\n * Will be executed per API operation\n */\n operation = \"operation\",\n}\n\n/**\n * Specifies which event to run for the specified plugin\n *\n * @hidden\n */\nexport interface PluginConfig {\n /**\n * The event to run the plugin on\n */\n on: keyof typeof PluginOn;\n /**\n * The plugin to run\n */\n plugin: Plugin;\n}\n\n/**\n * Plugins allow you to customize the behavior of the SDk with additional logging, retry, or additional functionality.\n *\n * A plugin is a function which returns a `Promise>`, and is passed a RequestContext and Next object.\n *\n * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins,\n * allowing you to log those results or handle errors.\n *\n * RequestContext is an object which controls what operation is happening, against which endpoint, and more. Modifying this and passing it along via next is how\n * you modify future SDK behavior.\n *\n * @hidden\n */\nexport type Plugin = (\n context: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n next: Next,\n) => Promise>;\n\n/**\n * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins,\n * allowing you to log those results or handle errors.\n * @hidden\n */\nexport type Next = (context: RequestContext) => Promise>;\n\n/**\n * @internal\n */\nexport async function executePlugins(\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n next: Plugin,\n on: PluginOn,\n): Promise> {\n if (!requestContext.plugins) {\n return next(requestContext, diagnosticNode, undefined);\n }\n let level = 0;\n const _: Next = (inner: RequestContext): Promise> => {\n if (++level >= inner.plugins.length) {\n return next(requestContext, diagnosticNode, undefined);\n } else if (inner.plugins[level].on !== on) {\n return _(requestContext);\n } else {\n return inner.plugins[level].plugin(inner, diagnosticNode, _);\n }\n };\n if (requestContext.plugins[level].on !== on) {\n return _(requestContext);\n } else {\n return requestContext.plugins[level].plugin(requestContext, diagnosticNode, _);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { OperationType } from \"../common\";\nimport { ErrorResponse } from \"../request\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError\";\nimport { RetryPolicy } from \"./RetryPolicy\";\n\n/**\n * @hidden\n */\n// Windows Socket Error Codes\nconst WindowsInterruptedFunctionCall = 10004;\n/**\n * @hidden\n */\nconst WindowsFileHandleNotValid = 10009;\n/**\n * @hidden\n */\nconst WindowsPermissionDenied = 10013;\n/**\n * @hidden\n */\nconst WindowsBadAddress = 10014;\n/**\n * @hidden\n */\nconst WindowsInvalidArgumnet = 10022;\n/**\n * @hidden\n */\nconst WindowsResourceTemporarilyUnavailable = 10035;\n/**\n * @hidden\n */\nconst WindowsOperationNowInProgress = 10036;\n/**\n * @hidden\n */\nconst WindowsAddressAlreadyInUse = 10048;\n/**\n * @hidden\n */\nconst WindowsConnectionResetByPeer = 10054;\n/**\n * @hidden\n */\nconst WindowsCannotSendAfterSocketShutdown = 10058;\n/**\n * @hidden\n */\nconst WindowsConnectionTimedOut = 10060;\n/**\n * @hidden\n */\nconst WindowsConnectionRefused = 10061;\n/**\n * @hidden\n */\nconst WindowsNameTooLong = 10063;\n/**\n * @hidden\n */\nconst WindowsHostIsDown = 10064;\n/**\n * @hidden\n */\nconst WindowsNoRouteTohost = 10065;\n/**\n * @hidden\n */\n\n// Linux Error Codes\n/**\n * @hidden\n */\nconst LinuxConnectionReset = \"ECONNRESET\";\n\n// Node Error Codes\n/**\n * @hidden\n */\nconst BrokenPipe = \"EPIPE\";\n\n/**\n * @hidden\n */\nconst CONNECTION_ERROR_CODES = [\n WindowsInterruptedFunctionCall,\n WindowsFileHandleNotValid,\n WindowsPermissionDenied,\n WindowsBadAddress,\n WindowsInvalidArgumnet,\n WindowsResourceTemporarilyUnavailable,\n WindowsOperationNowInProgress,\n WindowsAddressAlreadyInUse,\n WindowsConnectionResetByPeer,\n WindowsCannotSendAfterSocketShutdown,\n WindowsConnectionTimedOut,\n WindowsConnectionRefused,\n WindowsNameTooLong,\n WindowsHostIsDown,\n WindowsNoRouteTohost,\n LinuxConnectionReset,\n TimeoutErrorCode,\n BrokenPipe,\n];\n\n/**\n * @hidden\n */\nfunction needsRetry(operationType: OperationType, code: number | string): boolean {\n if (\n (operationType === OperationType.Read || operationType === OperationType.Query) &&\n CONNECTION_ERROR_CODES.indexOf(code) !== -1\n ) {\n return true;\n } else {\n return false;\n }\n}\n\n/**\n * This class implements the default connection retry policy for requests.\n * @hidden\n */\nexport class DefaultRetryPolicy implements RetryPolicy {\n private maxTries: number = 10;\n private currentRetryAttemptCount: number = 0;\n public retryAfterInMs: number = 1000;\n\n constructor(private operationType: OperationType) {}\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n if (err) {\n if (\n this.currentRetryAttemptCount < this.maxTries &&\n needsRetry(this.operationType, err.code)\n ) {\n diagnosticNode.addData({ successfulRetryPolicy: \"default\" });\n this.currentRetryAttemptCount++;\n return true;\n }\n }\n return false;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { OperationType } from \"../common\";\nimport { isReadRequest } from \"../common/helper\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { ErrorResponse } from \"../request\";\nimport { RetryContext } from \"./RetryContext\";\nimport { RetryPolicy } from \"./RetryPolicy\";\n\n/**\n * This class implements the retry policy for endpoint discovery.\n * @hidden\n */\nexport class EndpointDiscoveryRetryPolicy implements RetryPolicy {\n /** Current retry attempt count. */\n public currentRetryAttemptCount: number;\n /** Retry interval in milliseconds. */\n public retryAfterInMs: number;\n\n /** Max number of retry attempts to perform. */\n private maxTries: number;\n private static readonly maxTries = 120; // TODO: Constant?\n private static readonly retryAfterInMs = 1000;\n\n /**\n * @param globalEndpointManager - The GlobalEndpointManager instance.\n */\n constructor(\n private globalEndpointManager: GlobalEndpointManager,\n private operationType: OperationType,\n ) {\n this.maxTries = EndpointDiscoveryRetryPolicy.maxTries;\n this.currentRetryAttemptCount = 0;\n this.retryAfterInMs = EndpointDiscoveryRetryPolicy.retryAfterInMs;\n }\n\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n ): Promise {\n if (!err) {\n return false;\n }\n\n if (!retryContext || !locationEndpoint) {\n return false;\n }\n\n if (!this.globalEndpointManager.enableEndpointDiscovery) {\n return false;\n }\n\n if (this.currentRetryAttemptCount >= this.maxTries) {\n return false;\n }\n\n this.currentRetryAttemptCount++;\n\n if (isReadRequest(this.operationType)) {\n await this.globalEndpointManager.markCurrentLocationUnavailableForRead(\n diagnosticNode,\n locationEndpoint,\n );\n } else {\n await this.globalEndpointManager.markCurrentLocationUnavailableForWrite(\n diagnosticNode,\n locationEndpoint,\n );\n }\n\n retryContext.retryCount = this.currentRetryAttemptCount;\n retryContext.clearSessionTokenNotAvailable = false;\n retryContext.retryRequestOnPreferredLocations = false;\n diagnosticNode.addData({ successfulRetryPolicy: \"endpointDiscovery\" });\n return true;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { ErrorResponse } from \"../request\";\n\n/**\n * This class implements the resource throttle retry policy for requests.\n * @hidden\n */\nexport class ResourceThrottleRetryPolicy {\n /** Current retry attempt count. */\n public currentRetryAttemptCount: number = 0;\n /** Cummulative wait time in milliseconds for a request while the retries are happening. */\n public cummulativeWaitTimeinMs: number = 0;\n /** Retry interval in milliseconds to wait before the next request will be sent. */\n public retryAfterInMs: number = 0;\n\n /** Max wait time in milliseconds to wait for a request while the retries are happening. */\n private timeoutInMs: number;\n /**\n * @param maxTries - Max number of retries to be performed for a request.\n * @param fixedRetryIntervalInMs - Fixed retry interval in milliseconds to wait between each\n * retry ignoring the retryAfter returned as part of the response.\n * @param timeoutInSeconds - Max wait time in seconds to wait for a request while the\n * retries are happening.\n */\n constructor(\n private maxTries: number = 9,\n private fixedRetryIntervalInMs: number = 0,\n timeoutInSeconds: number = 30,\n ) {\n this.timeoutInMs = timeoutInSeconds * 1000;\n this.currentRetryAttemptCount = 0;\n this.cummulativeWaitTimeinMs = 0;\n }\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise {\n // TODO: any custom error object\n if (err) {\n if (this.currentRetryAttemptCount < this.maxTries) {\n this.currentRetryAttemptCount++;\n this.retryAfterInMs = 0;\n\n if (this.fixedRetryIntervalInMs) {\n this.retryAfterInMs = this.fixedRetryIntervalInMs;\n } else if (err.retryAfterInMs) {\n this.retryAfterInMs = err.retryAfterInMs;\n }\n\n if (this.cummulativeWaitTimeinMs < this.timeoutInMs) {\n this.cummulativeWaitTimeinMs += this.retryAfterInMs;\n diagnosticNode.addData({ successfulRetryPolicy: \"resourceThrottle\" });\n return true;\n }\n }\n }\n return false;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { isReadRequest, OperationType, ResourceType } from \"../common\";\nimport { ConnectionPolicy } from \"../documents\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { ErrorResponse } from \"../request\";\nimport { RetryContext } from \"./RetryContext\";\nimport { RetryPolicy } from \"./RetryPolicy\";\n\n/**\n * This class implements the retry policy for session consistent reads.\n * @hidden\n */\nexport class SessionRetryPolicy implements RetryPolicy {\n /** Current retry attempt count. */\n public currentRetryAttemptCount = 0;\n /** Retry interval in milliseconds. */\n public retryAfterInMs = 0;\n\n /**\n * @param globalEndpointManager - The GlobalEndpointManager instance.\n */\n constructor(\n private globalEndpointManager: GlobalEndpointManager,\n private resourceType: ResourceType,\n private operationType: OperationType,\n private connectionPolicy: ConnectionPolicy,\n ) {}\n\n /**\n * Determines whether the request should be retried or not.\n * @param err - Error returned by the request.\n * @param callback - The callback function which takes bool argument which specifies whether the request\n * will be retried or not.\n */\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n ): Promise {\n if (!err) {\n return false;\n }\n\n if (!retryContext) {\n return false;\n }\n\n if (!this.connectionPolicy.enableEndpointDiscovery) {\n return false;\n }\n\n if (\n this.globalEndpointManager.canUseMultipleWriteLocations(this.resourceType, this.operationType)\n ) {\n // If we can write to multiple locations, we should against every write endpoint until we succeed\n const endpoints = isReadRequest(this.operationType)\n ? await this.globalEndpointManager.getReadEndpoints()\n : await this.globalEndpointManager.getWriteEndpoints();\n if (this.currentRetryAttemptCount > endpoints.length) {\n return false;\n } else {\n this.currentRetryAttemptCount++;\n retryContext.retryCount++;\n retryContext.retryRequestOnPreferredLocations = this.currentRetryAttemptCount > 1;\n retryContext.clearSessionTokenNotAvailable =\n this.currentRetryAttemptCount === endpoints.length;\n diagnosticNode.addData({ successfulRetryPolicy: \"session\" });\n return true;\n }\n } else {\n if (this.currentRetryAttemptCount > 1) {\n return false;\n } else {\n this.currentRetryAttemptCount++;\n retryContext.retryCount++;\n retryContext.retryRequestOnPreferredLocations = false; // Forces all operations to primary write endpoint\n retryContext.clearSessionTokenNotAvailable = true;\n diagnosticNode.addData({ successfulRetryPolicy: \"session\" });\n return true;\n }\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { RetryPolicy } from \"./RetryPolicy\";\nimport { StatusCodes } from \"../common/statusCodes\";\nimport { GlobalEndpointManager } from \"../globalEndpointManager\";\nimport { HTTPMethod, isReadRequest } from \"../common\";\nimport { Constants, OperationType, ResourceType } from \"../common/constants\";\nimport { RetryContext } from \"./RetryContext\";\nimport { CosmosHeaders } from \"../queryExecutionContext/CosmosHeaders\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError\";\nimport { ErrorResponse } from \"../request\";\nimport { DiagnosticNodeInternal } from \"../diagnostics/DiagnosticNodeInternal\";\n\n/**\n * This class TimeoutFailoverRetryPolicy handles retries for read operations\n * (including data plane,metadata, and query plan) in case of request timeouts\n * (TimeoutError) or service unavailability (503 status code) by performing failover\n * and retrying on other regions.\n * @hidden\n */\nexport class TimeoutFailoverRetryPolicy implements RetryPolicy {\n private maxRetryAttemptCount = 120;\n private maxServiceUnavailableRetryCount = 1;\n public retryAfterInMs = 0;\n public failoverRetryCount = 0;\n public request: any;\n public locationEndpoint: any;\n\n constructor(\n private globalEndpointManager: GlobalEndpointManager,\n private headers: CosmosHeaders,\n private methodType: HTTPMethod,\n private resourceType: ResourceType,\n private operationType: OperationType,\n private enableEndPointDiscovery: boolean,\n ) {}\n\n /**\n * Checks if a timeout request is valid for the timeout failover retry policy.\n * A valid request should be a data plane, metadata, or query plan request.\n * @returns\n */\n private isValidRequestForTimeoutError(): boolean {\n const isQuery = Constants.HttpHeaders.IsQuery in this.headers;\n const isQueryPlan = Constants.HttpHeaders.IsQueryPlan in this.headers;\n if (this.methodType === HTTPMethod.get || isQuery || isQueryPlan) {\n return true;\n }\n return false;\n }\n\n public async shouldRetry(\n err: ErrorResponse,\n diagnosticNode: DiagnosticNodeInternal,\n retryContext?: RetryContext,\n locationEndpoint?: string,\n ): Promise {\n if (!err) {\n return false;\n }\n if (!retryContext || !locationEndpoint) {\n return false;\n }\n // Check if the error is a timeout error (TimeoutErrorCode) and if it is not a valid HTTP network timeout request\n if (err.code === TimeoutErrorCode && !this.isValidRequestForTimeoutError()) {\n return false;\n }\n if (!this.enableEndPointDiscovery) {\n return false;\n }\n if (\n err.code === StatusCodes.ServiceUnavailable &&\n this.failoverRetryCount >= this.maxServiceUnavailableRetryCount\n ) {\n return false;\n }\n if (this.failoverRetryCount >= this.maxRetryAttemptCount) {\n return false;\n }\n const canUseMultipleWriteLocations = this.globalEndpointManager.canUseMultipleWriteLocations(\n this.resourceType,\n this.operationType,\n );\n const readRequest = isReadRequest(this.operationType);\n\n if (!canUseMultipleWriteLocations && !readRequest) {\n // Write requests on single master cannot be retried, no other regions available\n return false;\n }\n this.failoverRetryCount++;\n // Setting the retryLocationIndex to the next available location for retry.\n // The retryLocationIndex is determined based on the failoverRetryCount, starting from zero.\n retryContext.retryLocationServerIndex = await this.findEndpointIndex(this.failoverRetryCount);\n diagnosticNode.addData({ successfulRetryPolicy: \"timeout-failover\" });\n return true;\n }\n\n /**\n * Determines index of endpoint to be used for retry based upon failoverRetryCount and avalable locations\n * @param failoverRetryCount - count of failovers\n * @returns\n */\n private async findEndpointIndex(failoverRetryCount: number): Promise {\n // count of preferred locations specified by user\n const preferredLocationsCount = this.globalEndpointManager.preferredLocationsCount;\n const readRequest = isReadRequest(this.operationType);\n let endpointIndex = 0;\n // If preferredLocationsCount is not zero, it indicates that the user has specified preferred locations.\n if (preferredLocationsCount !== 0) {\n // The endpointIndex is set based on the preferred location and the failover retry count.\n endpointIndex = failoverRetryCount % preferredLocationsCount;\n } else {\n // In the absence of preferred locations, the endpoint selection is based on the failover count and the number of available locations.\n if (readRequest) {\n const getReadEndpoints = await this.globalEndpointManager.getReadEndpoints();\n if (getReadEndpoints && getReadEndpoints.length > 0) {\n endpointIndex = failoverRetryCount % getReadEndpoints.length;\n }\n } else {\n const getWriteEndpoints = await this.globalEndpointManager.getWriteEndpoints();\n if (getWriteEndpoints && getWriteEndpoints.length > 0) {\n endpointIndex = failoverRetryCount % getWriteEndpoints.length;\n }\n }\n }\n return endpointIndex;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Constants } from \"../common/constants\";\nimport { sleep } from \"../common/helper\";\nimport { StatusCodes, SubStatusCodes } from \"../common/statusCodes\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { Response } from \"../request\";\nimport { RequestContext } from \"../request/RequestContext\";\nimport { TimeoutErrorCode } from \"../request/TimeoutError\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\nimport { DefaultRetryPolicy } from \"./defaultRetryPolicy\";\nimport { EndpointDiscoveryRetryPolicy } from \"./endpointDiscoveryRetryPolicy\";\nimport { ResourceThrottleRetryPolicy } from \"./resourceThrottleRetryPolicy\";\nimport { RetryContext } from \"./RetryContext\";\nimport { RetryPolicy } from \"./RetryPolicy\";\nimport { SessionRetryPolicy } from \"./sessionRetryPolicy\";\nimport { TimeoutFailoverRetryPolicy } from \"./timeoutFailoverRetryPolicy\";\n\n/**\n * @hidden\n */\ninterface ExecuteArgs {\n retryContext?: RetryContext;\n diagnosticNode: DiagnosticNodeInternal;\n retryPolicies?: RetryPolicies;\n requestContext: RequestContext;\n executeRequest: (\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n ) => Promise>;\n}\n\n/**\n * @hidden\n */\ninterface RetryPolicies {\n endpointDiscoveryRetryPolicy: EndpointDiscoveryRetryPolicy;\n resourceThrottleRetryPolicy: ResourceThrottleRetryPolicy;\n sessionReadRetryPolicy: SessionRetryPolicy;\n defaultRetryPolicy: DefaultRetryPolicy;\n timeoutFailoverRetryPolicy: TimeoutFailoverRetryPolicy;\n}\n\n/**\n * @hidden\n */\nexport async function execute({\n diagnosticNode,\n retryContext = { retryCount: 0 },\n retryPolicies,\n requestContext,\n executeRequest,\n}: ExecuteArgs): Promise> {\n // TODO: any response\n return addDignosticChild(\n async (localDiagnosticNode: DiagnosticNodeInternal) => {\n localDiagnosticNode.addData({ requestAttempNumber: retryContext.retryCount });\n if (!retryPolicies) {\n retryPolicies = {\n endpointDiscoveryRetryPolicy: new EndpointDiscoveryRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.operationType,\n ),\n resourceThrottleRetryPolicy: new ResourceThrottleRetryPolicy(\n requestContext.connectionPolicy.retryOptions.maxRetryAttemptCount,\n requestContext.connectionPolicy.retryOptions.fixedRetryIntervalInMilliseconds,\n requestContext.connectionPolicy.retryOptions.maxWaitTimeInSeconds,\n ),\n sessionReadRetryPolicy: new SessionRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy,\n ),\n defaultRetryPolicy: new DefaultRetryPolicy(requestContext.operationType),\n timeoutFailoverRetryPolicy: new TimeoutFailoverRetryPolicy(\n requestContext.globalEndpointManager,\n requestContext.headers,\n requestContext.method,\n requestContext.resourceType,\n requestContext.operationType,\n requestContext.connectionPolicy.enableEndpointDiscovery,\n ),\n };\n }\n if (retryContext && retryContext.clearSessionTokenNotAvailable) {\n requestContext.client.clearSessionToken(requestContext.path);\n delete requestContext.headers[\"x-ms-session-token\"];\n }\n if (retryContext && retryContext.retryLocationServerIndex) {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n retryContext.retryLocationServerIndex,\n );\n } else {\n requestContext.endpoint = await requestContext.globalEndpointManager.resolveServiceEndpoint(\n localDiagnosticNode,\n requestContext.resourceType,\n requestContext.operationType,\n );\n }\n const startTimeUTCInMs = getCurrentTimestampInMs();\n try {\n const response = await executeRequest(localDiagnosticNode, requestContext);\n response.headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n response.headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n return response;\n } catch (err: any) {\n // TODO: any error\n let retryPolicy: RetryPolicy = null;\n const headers = err.headers || {};\n if (\n err.code === StatusCodes.ENOTFOUND ||\n err.code === \"REQUEST_SEND_ERROR\" ||\n (err.code === StatusCodes.Forbidden &&\n (err.substatus === SubStatusCodes.DatabaseAccountNotFound ||\n err.substatus === SubStatusCodes.WriteForbidden))\n ) {\n retryPolicy = retryPolicies.endpointDiscoveryRetryPolicy;\n } else if (err.code === StatusCodes.TooManyRequests) {\n retryPolicy = retryPolicies.resourceThrottleRetryPolicy;\n } else if (\n err.code === StatusCodes.NotFound &&\n err.substatus === SubStatusCodes.ReadSessionNotAvailable\n ) {\n retryPolicy = retryPolicies.sessionReadRetryPolicy;\n } else if (err.code === StatusCodes.ServiceUnavailable || err.code === TimeoutErrorCode) {\n retryPolicy = retryPolicies.timeoutFailoverRetryPolicy;\n } else {\n retryPolicy = retryPolicies.defaultRetryPolicy;\n }\n const results = await retryPolicy.shouldRetry(\n err,\n localDiagnosticNode,\n retryContext,\n requestContext.endpoint,\n );\n if (!results) {\n headers[Constants.ThrottleRetryCount] =\n retryPolicies.resourceThrottleRetryPolicy.currentRetryAttemptCount;\n headers[Constants.ThrottleRetryWaitTimeInMs] =\n retryPolicies.resourceThrottleRetryPolicy.cummulativeWaitTimeinMs;\n err.headers = { ...err.headers, ...headers };\n throw err;\n } else {\n requestContext.retryCount++;\n const newUrl = (results as any)[1]; // TODO: any hack\n if (newUrl !== undefined) {\n requestContext.endpoint = newUrl;\n }\n localDiagnosticNode.recordFailedNetworkCall(\n startTimeUTCInMs,\n requestContext,\n retryContext.retryCount,\n err.code,\n err.subsstatusCode,\n headers,\n );\n await sleep(retryPolicy.retryAfterInMs);\n return execute({\n diagnosticNode,\n executeRequest,\n requestContext,\n retryContext,\n retryPolicies,\n });\n }\n }\n },\n diagnosticNode,\n DiagnosticNodeType.HTTP_REQUEST,\n );\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Agent } from \"http\";\n\n/**\n * @hidden\n */\nexport let defaultHttpsAgent: Agent;\n\nconst https = require(\"https\"); // eslint-disable-line @typescript-eslint/no-require-imports\nconst tls = require(\"tls\"); // eslint-disable-line @typescript-eslint/no-require-imports\n\n// minVersion only available in Node 10+\nif (tls.DEFAULT_MIN_VERSION) {\n defaultHttpsAgent = new https.Agent({\n keepAlive: true,\n minVersion: \"TLSv1.2\",\n });\n} else {\n // Remove when Node 8 support has been dropped\n defaultHttpsAgent = new https.Agent({\n keepAlive: true,\n secureProtocol: \"TLSv1_2_method\",\n });\n}\nconst http = require(\"http\"); // eslint-disable-line @typescript-eslint/no-require-imports\n/**\n * @internal\n */\nexport const defaultHttpAgent: Agent = new http.Agent({\n keepAlive: true,\n});\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { HttpClient, createDefaultHttpClient } from \"@azure/core-rest-pipeline\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\nexport function getCachedDefaultHttpClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { AbortController } from \"node-abort-controller\";\nimport {\n createPipelineRequest,\n createHttpHeaders,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\nimport { prepareURL } from \"../common\";\nimport { Constants } from \"../common/constants\";\nimport { executePlugins, PluginOn } from \"../plugins/Plugin\";\nimport * as RetryUtility from \"../retry/retryUtility\";\nimport { defaultHttpAgent, defaultHttpsAgent } from \"./defaultAgent\";\nimport { ErrorResponse } from \"./ErrorResponse\";\nimport { bodyFromData } from \"./request\";\nimport { RequestContext } from \"./RequestContext\";\nimport { Response as CosmosResponse } from \"./Response\";\nimport { TimeoutError } from \"./TimeoutError\";\nimport { getCachedDefaultHttpClient } from \"../utils/cachedClient\";\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"../diagnostics/DiagnosticNodeInternal\";\nimport { addDignosticChild } from \"../utils/diagnostics\";\nimport { getCurrentTimestampInMs } from \"../utils/time\";\n\nconst logger: AzureLogger = createClientLogger(\"RequestHandler\");\n\nasync function executeRequest(\n diagnosticNode: DiagnosticNodeInternal,\n requestContext: RequestContext,\n): Promise> {\n return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request);\n}\n\n/**\n * @hidden\n */\nasync function httpRequest(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise<{\n headers: any;\n result: any;\n code: number;\n substatus: number;\n}> {\n const controller = new AbortController();\n const signal = controller.signal;\n\n // Wrap users passed abort events and call our own internal abort()\n const userSignal = requestContext.options && requestContext.options.abortSignal;\n if (userSignal) {\n if (userSignal.aborted) {\n controller.abort();\n } else {\n userSignal.addEventListener(\"abort\", () => {\n controller.abort();\n });\n }\n }\n\n const timeout = setTimeout(() => {\n controller.abort();\n }, requestContext.connectionPolicy.requestTimeout);\n\n let response: PipelineResponse;\n\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n }\n\n const httpsClient = getCachedDefaultHttpClient();\n const url = prepareURL(requestContext.endpoint, requestContext.path);\n const reqHeaders = createHttpHeaders(requestContext.headers as any);\n const pipelineRequest = createPipelineRequest({\n url,\n headers: reqHeaders,\n method: requestContext.method,\n abortSignal: signal,\n body: requestContext.body,\n });\n if (requestContext.requestAgent) {\n pipelineRequest.agent = requestContext.requestAgent;\n } else {\n const parsedUrl = new URL(url);\n pipelineRequest.agent = parsedUrl.protocol === \"http\" ? defaultHttpAgent : defaultHttpsAgent;\n }\n\n const startTimeUTCInMs = getCurrentTimestampInMs();\n try {\n if (requestContext.pipeline) {\n response = await requestContext.pipeline.sendRequest(httpsClient, pipelineRequest);\n } else {\n response = await httpsClient.sendRequest(pipelineRequest);\n }\n } catch (error: any) {\n if (error.name === \"AbortError\") {\n // If the user passed signal caused the abort, cancel the timeout and rethrow the error\n if (userSignal && userSignal.aborted === true) {\n clearTimeout(timeout);\n throw error;\n }\n // If the user didn't cancel, it must be an abort we called due to timeout\n throw new TimeoutError(\n `Timeout Error! Request took more than ${requestContext.connectionPolicy.requestTimeout} ms`,\n );\n }\n throw error;\n }\n\n clearTimeout(timeout);\n const result =\n response.status === 204 || response.status === 304 || response.bodyAsText === \"\"\n ? null\n : JSON.parse(response.bodyAsText);\n const responseHeaders = response.headers.toJSON();\n\n const substatus = responseHeaders[Constants.HttpHeaders.SubStatus]\n ? parseInt(responseHeaders[Constants.HttpHeaders.SubStatus], 10)\n : undefined;\n\n diagnosticNode.recordSuccessfulNetworkCall(\n startTimeUTCInMs,\n requestContext,\n response,\n substatus,\n url,\n );\n\n if (response.status >= 400) {\n const errorResponse: ErrorResponse = new ErrorResponse(result.message);\n logger.warning(\n response.status +\n \" \" +\n requestContext.endpoint +\n \" \" +\n requestContext.path +\n \" \" +\n result.message,\n );\n\n errorResponse.code = response.status;\n errorResponse.body = result;\n errorResponse.headers = responseHeaders;\n\n if (Constants.HttpHeaders.ActivityId in responseHeaders) {\n errorResponse.activityId = responseHeaders[Constants.HttpHeaders.ActivityId];\n }\n\n if (Constants.HttpHeaders.SubStatus in responseHeaders) {\n errorResponse.substatus = substatus;\n }\n\n if (Constants.HttpHeaders.RetryAfterInMs in responseHeaders) {\n errorResponse.retryAfterInMs = parseInt(\n responseHeaders[Constants.HttpHeaders.RetryAfterInMs],\n 10,\n );\n Object.defineProperty(errorResponse, \"retryAfterInMilliseconds\", {\n get: () => {\n return errorResponse.retryAfterInMs;\n },\n });\n }\n\n throw errorResponse;\n }\n return {\n headers: responseHeaders,\n result,\n code: response.status,\n substatus,\n };\n}\n\n/**\n * @hidden\n */\nasync function request(\n requestContext: RequestContext,\n diagnosticNode: DiagnosticNodeInternal,\n): Promise> {\n if (requestContext.body) {\n requestContext.body = bodyFromData(requestContext.body);\n if (!requestContext.body) {\n throw new Error(\"parameter data must be a javascript object, string, or Buffer\");\n }\n }\n\n return addDignosticChild(\n async (childNode: DiagnosticNodeInternal) => {\n return RetryUtility.execute({\n diagnosticNode: childNode,\n requestContext,\n executeRequest,\n });\n },\n diagnosticNode,\n DiagnosticNodeType.REQUEST_ATTEMPTS,\n );\n}\n\nexport const RequestHandler = {\n request,\n};\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport default function atob(str: string): string {\n return Buffer.from(str, \"base64\").toString(\"binary\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/**\n * Models vector clock bases session token. Session token has the following format:\n * `{Version}#{GlobalLSN}#{RegionId1}={LocalLsn1}#{RegionId2}={LocalLsn2}....#{RegionIdN}={LocalLsnN}`\n * 'Version' captures the configuration number of the partition which returned this session token.\n * 'Version' is incremented everytime topology of the partition is updated (say due to Add/Remove/Failover).\n *\n * The choice of separators '#' and '=' is important. Separators ';' and ',' are used to delimit\n * per-partitionKeyRange session token\n * @hidden\n *\n */\nexport class VectorSessionToken {\n private static readonly SEGMENT_SEPARATOR = \"#\";\n private static readonly REGION_PROGRESS_SEPARATOR = \"=\";\n\n constructor(\n private readonly version: number,\n private readonly globalLsn: number,\n private readonly localLsnByregion: Map,\n private readonly sessionToken?: string,\n ) {\n if (!this.sessionToken) {\n const regionAndLocalLsn = [];\n for (const [key, value] of this.localLsnByregion.entries()) {\n regionAndLocalLsn.push(`${key}${VectorSessionToken.REGION_PROGRESS_SEPARATOR}${value}`);\n }\n const regionProgress = regionAndLocalLsn.join(VectorSessionToken.SEGMENT_SEPARATOR);\n if (regionProgress === \"\") {\n this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}`;\n } else {\n this.sessionToken = `${this.version}${VectorSessionToken.SEGMENT_SEPARATOR}${this.globalLsn}${VectorSessionToken.SEGMENT_SEPARATOR}${regionProgress}`;\n }\n }\n }\n\n public static create(sessionToken: string): VectorSessionToken | null {\n const [versionStr, globalLsnStr, ...regionSegments] = sessionToken.split(\n VectorSessionToken.SEGMENT_SEPARATOR,\n );\n\n const version = parseInt(versionStr, 10);\n const globalLsn = parseFloat(globalLsnStr);\n\n if (typeof version !== \"number\" || typeof globalLsn !== \"number\") {\n return null;\n }\n\n const lsnByRegion = new Map();\n for (const regionSegment of regionSegments) {\n const [regionIdStr, localLsnStr] = regionSegment.split(\n VectorSessionToken.REGION_PROGRESS_SEPARATOR,\n );\n\n if (!regionIdStr || !localLsnStr) {\n return null;\n }\n\n const regionId = parseInt(regionIdStr, 10);\n let localLsn: string;\n try {\n localLsn = localLsnStr;\n } catch (err: any) {\n // TODO: log error\n return null;\n }\n if (typeof regionId !== \"number\") {\n return null;\n }\n\n lsnByRegion.set(regionId, localLsn);\n }\n\n return new VectorSessionToken(version, globalLsn, lsnByRegion, sessionToken);\n }\n\n public equals(other: VectorSessionToken): boolean {\n return !other\n ? false\n : this.version === other.version &&\n this.globalLsn === other.globalLsn &&\n this.areRegionProgressEqual(other.localLsnByregion);\n }\n\n public merge(other: VectorSessionToken): VectorSessionToken {\n if (other == null) {\n throw new Error(\"other (Vector Session Token) must not be null\");\n }\n\n if (\n this.version === other.version &&\n this.localLsnByregion.size !== other.localLsnByregion.size\n ) {\n throw new Error(\n `Compared session tokens ${this.sessionToken} and ${other.sessionToken} have unexpected regions`,\n );\n }\n\n const [higherVersionSessionToken, lowerVersionSessionToken]: [\n VectorSessionToken,\n VectorSessionToken,\n ] = this.version < other.version ? [other, this] : [this, other];\n\n const highestLocalLsnByRegion = new Map();\n\n for (const [regionId, highLocalLsn] of higherVersionSessionToken.localLsnByregion.entries()) {\n const lowLocalLsn = lowerVersionSessionToken.localLsnByregion.get(regionId);\n if (lowLocalLsn) {\n highestLocalLsnByRegion.set(regionId, max(highLocalLsn, lowLocalLsn));\n } else if (this.version === other.version) {\n throw new Error(\n `Compared session tokens have unexpected regions. Session 1: ${this.sessionToken} - Session 2: ${this.sessionToken}`,\n );\n } else {\n highestLocalLsnByRegion.set(regionId, highLocalLsn);\n }\n }\n\n return new VectorSessionToken(\n Math.max(this.version, other.version),\n Math.max(this.globalLsn, other.globalLsn),\n highestLocalLsnByRegion,\n );\n }\n\n public toString(): string | undefined {\n return this.sessionToken;\n }\n\n private areRegionProgressEqual(other: Map): boolean {\n if (this.localLsnByregion.size !== other.size) {\n return false;\n }\n\n for (const [regionId, localLsn] of this.localLsnByregion.entries()) {\n const otherLocalLsn = other.get(regionId);\n\n if (localLsn !== otherLocalLsn) {\n return false;\n }\n }\n return true;\n }\n}\n\n/**\n * @hidden\n */\nfunction max(int1: string, int2: string): string {\n // NOTE: This only works for positive numbers\n if (int1.length === int2.length) {\n return int1 > int2 ? int1 : int2;\n } else if (int1.length > int2.length) {\n return int1;\n } else {\n return int2;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport atob from \"../utils/atob\";\nimport { Constants, getContainerLink, OperationType, ResourceType, trimSlashes } from \"../common\";\nimport { CosmosHeaders } from \"../queryExecutionContext\";\nimport { SessionContext } from \"./SessionContext\";\nimport { VectorSessionToken } from \"./VectorSessionToken\";\n\n/** @hidden */\nexport class SessionContainer {\n private static readonly EMPTY_SESSION_TOKEN = \"\";\n private static readonly SESSION_TOKEN_SEPARATOR = \",\";\n private static readonly SESSION_TOKEN_PARTITION_SPLITTER = \":\";\n constructor(\n private collectionNameToCollectionResourceId = new Map(),\n private collectionResourceIdToSessionTokens = new Map<\n string,\n Map\n >(),\n ) {}\n\n public get(request: SessionContext): string {\n if (!request) {\n throw new Error(\"request cannot be null\");\n }\n const collectionName = getContainerLink(trimSlashes(request.resourceAddress));\n const rangeIdToTokenMap = this.getPartitionKeyRangeIdToTokenMap(collectionName);\n return SessionContainer.getCombinedSessionTokenString(rangeIdToTokenMap);\n }\n\n public remove(request: SessionContext): void {\n let collectionResourceId: string;\n const resourceAddress = trimSlashes(request.resourceAddress);\n const collectionName = getContainerLink(resourceAddress);\n if (collectionName) {\n collectionResourceId = this.collectionNameToCollectionResourceId.get(collectionName);\n this.collectionNameToCollectionResourceId.delete(collectionName);\n }\n if (collectionResourceId !== undefined) {\n this.collectionResourceIdToSessionTokens.delete(collectionResourceId);\n }\n }\n\n public set(request: SessionContext, resHeaders: CosmosHeaders): void {\n // TODO: we check the master logic a few different places. Might not need it.\n if (\n !resHeaders ||\n SessionContainer.isReadingFromMaster(request.resourceType, request.operationType)\n ) {\n return;\n }\n\n const sessionTokenString = resHeaders[Constants.HttpHeaders.SessionToken];\n if (!sessionTokenString) {\n return;\n }\n\n const containerName = this.getContainerName(request, resHeaders);\n\n const ownerId = !request.isNameBased\n ? request.resourceId\n : resHeaders[Constants.HttpHeaders.OwnerId] || request.resourceId;\n\n if (!ownerId) {\n return;\n }\n\n if (containerName && this.validateOwnerID(ownerId)) {\n if (!this.collectionResourceIdToSessionTokens.has(ownerId)) {\n this.collectionResourceIdToSessionTokens.set(ownerId, new Map());\n }\n\n if (!this.collectionNameToCollectionResourceId.has(containerName)) {\n this.collectionNameToCollectionResourceId.set(containerName, ownerId);\n }\n\n const containerSessionContainer = this.collectionResourceIdToSessionTokens.get(ownerId);\n SessionContainer.compareAndSetToken(sessionTokenString, containerSessionContainer);\n }\n }\n\n private validateOwnerID(ownerId: string): boolean {\n // If ownerId contains exactly 8 bytes it represents a unique database+collection identifier. Otherwise it represents another resource\n // The first 4 bytes are the database. The last 4 bytes are the collection.\n // Cosmos rids potentially contain \"-\" which is an invalid character in the browser atob implementation\n // See https://en.wikipedia.org/wiki/Base64#Filenames\n return atob(ownerId.replace(/-/g, \"/\")).length === 8;\n }\n\n private getPartitionKeyRangeIdToTokenMap(\n collectionName: string,\n ): Map {\n let rangeIdToTokenMap: Map = null;\n if (collectionName && this.collectionNameToCollectionResourceId.has(collectionName)) {\n rangeIdToTokenMap = this.collectionResourceIdToSessionTokens.get(\n this.collectionNameToCollectionResourceId.get(collectionName),\n );\n }\n\n return rangeIdToTokenMap;\n }\n\n private static getCombinedSessionTokenString(tokens: Map): string {\n if (!tokens || tokens.size === 0) {\n return SessionContainer.EMPTY_SESSION_TOKEN;\n }\n\n let result = \"\";\n for (const [range, token] of tokens.entries()) {\n result +=\n range +\n SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER +\n token.toString() +\n SessionContainer.SESSION_TOKEN_SEPARATOR;\n }\n return result.slice(0, -1);\n }\n\n private static compareAndSetToken(\n newTokenString: string,\n containerSessionTokens: Map,\n ): void {\n if (!newTokenString) {\n return;\n }\n\n const partitionsParts = newTokenString.split(SessionContainer.SESSION_TOKEN_SEPARATOR);\n for (const partitionPart of partitionsParts) {\n const newTokenParts = partitionPart.split(SessionContainer.SESSION_TOKEN_PARTITION_SPLITTER);\n if (newTokenParts.length !== 2) {\n return;\n }\n\n const range = newTokenParts[0];\n const newToken = VectorSessionToken.create(newTokenParts[1]);\n const tokenForRange = !containerSessionTokens.get(range)\n ? newToken\n : containerSessionTokens.get(range).merge(newToken);\n containerSessionTokens.set(range, tokenForRange);\n }\n }\n\n // TODO: have a assert if the type doesn't mastch known types\n private static isReadingFromMaster(\n resourceType: ResourceType,\n operationType: OperationType,\n ): boolean {\n if (\n resourceType === Constants.Path.OffersPathSegment ||\n resourceType === Constants.Path.DatabasesPathSegment ||\n resourceType === Constants.Path.UsersPathSegment ||\n resourceType === Constants.Path.PermissionsPathSegment ||\n resourceType === Constants.Path.TopologyPathSegment ||\n resourceType === Constants.Path.DatabaseAccountPathSegment ||\n resourceType === Constants.Path.PartitionKeyRangesPathSegment ||\n (resourceType === Constants.Path.CollectionsPathSegment &&\n operationType === OperationType.Query)\n ) {\n return true;\n }\n\n return false;\n }\n\n private getContainerName(request: SessionContext, headers: CosmosHeaders): string {\n let ownerFullName = headers[Constants.HttpHeaders.OwnerFullName];\n if (!ownerFullName) {\n ownerFullName = trimSlashes(request.resourceAddress);\n }\n\n return getContainerLink(ownerFullName as string);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport function checkURL(testString: string): URL {\n return new URL(testString);\n}\n\nexport function sanitizeEndpoint(url: string): string {\n return new URL(url).href.replace(/\\/$/, \"\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { QueryFeature } from \"../common\";\n\nexport function supportedQueryFeaturesBuilder(disableNonStreamingOrderByQuery?: boolean): string {\n if (disableNonStreamingOrderByQuery) {\n return Object.keys(QueryFeature)\n .filter((k) => k !== QueryFeature.NonStreamingOrderBy)\n .join(\", \");\n } else {\n return Object.keys(QueryFeature).join(\", \");\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\n\n/**\n * Interface for a Diagnostic Writer.\n * @hidden\n */\nexport interface DiagnosticWriter {\n write(message: string): Promise;\n}\n\n/**\n * Implementation of DiagnosticWriter, which uses \\@azure/logger to write\n * diagnostics.\n * @hidden\n */\nexport class LogDiagnosticWriter implements DiagnosticWriter {\n private logger: AzureLogger = createClientLogger(\"CosmosDBDiagnostics\");\n public async write(diagnosticsData: string): Promise {\n this.logger.verbose(diagnosticsData);\n }\n}\n\n/**\n * Implementation of a no-op DiagnosticWriter.\n * @hidden\n */\nexport class NoOpDiagnosticWriter implements DiagnosticWriter {\n public async write(_diagnosticsData: string): Promise {\n // No op\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosDiagnostics } from \"../CosmosDiagnostics\";\n\nexport interface DiagnosticFormatter {\n format(cosmosDiagnostic: CosmosDiagnostics): string;\n}\n\nexport class DefaultDiagnosticFormatter implements DiagnosticFormatter {\n format(cosmosDiagnostic: CosmosDiagnostics): string {\n return JSON.stringify(cosmosDiagnostic);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { v4 } from \"uuid\";\nconst uuid = v4;\nimport {\n Pipeline,\n bearerTokenAuthenticationPolicy,\n createEmptyPipeline,\n} from \"@azure/core-rest-pipeline\";\nimport { PartitionKeyRange } from \"./client/Container/PartitionKeyRange\";\nimport { Resource } from \"./client/Resource\";\nimport { Constants, HTTPMethod, OperationType, ResourceType } from \"./common/constants\";\nimport { getIdFromLink, getPathFromLink, parseLink } from \"./common/helper\";\nimport { StatusCodes, SubStatusCodes } from \"./common/statusCodes\";\nimport { Agent, CosmosClientOptions } from \"./CosmosClientOptions\";\nimport {\n ConnectionPolicy,\n ConsistencyLevel,\n DatabaseAccount,\n PartitionKey,\n convertToInternalPartitionKey,\n} from \"./documents\";\nimport { GlobalEndpointManager } from \"./globalEndpointManager\";\nimport { PluginConfig, PluginOn, executePlugins } from \"./plugins/Plugin\";\nimport { FetchFunctionCallback, SqlQuerySpec } from \"./queryExecutionContext\";\nimport { CosmosHeaders } from \"./queryExecutionContext/CosmosHeaders\";\nimport { QueryIterator } from \"./queryIterator\";\nimport { ErrorResponse } from \"./request\";\nimport { FeedOptions, RequestOptions, Response } from \"./request\";\nimport { PartitionedQueryExecutionInfo } from \"./request/ErrorResponse\";\nimport { getHeaders } from \"./request/request\";\nimport { RequestContext } from \"./request/RequestContext\";\nimport { RequestHandler } from \"./request/RequestHandler\";\nimport { SessionContainer } from \"./session/sessionContainer\";\nimport { SessionContext } from \"./session/SessionContext\";\nimport { BulkOptions } from \"./utils/batch\";\nimport { sanitizeEndpoint } from \"./utils/checkURL\";\nimport { supportedQueryFeaturesBuilder } from \"./utils/supportedQueryFeaturesBuilder\";\nimport { AzureLogger, createClientLogger } from \"@azure/logger\";\nimport { ClientConfigDiagnostic, CosmosDiagnostics } from \"./CosmosDiagnostics\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport {\n DiagnosticWriter,\n LogDiagnosticWriter,\n NoOpDiagnosticWriter,\n} from \"./diagnostics/DiagnosticWriter\";\nimport { DefaultDiagnosticFormatter, DiagnosticFormatter } from \"./diagnostics/DiagnosticFormatter\";\nimport { CosmosDbDiagnosticLevel } from \"./diagnostics/CosmosDbDiagnosticLevel\";\n\nconst logger: AzureLogger = createClientLogger(\"ClientContext\");\n\nconst QueryJsonContentType = \"application/query+json\";\nconst HttpHeaders = Constants.HttpHeaders;\n/**\n * @hidden\n * @hidden\n */\nexport class ClientContext {\n private readonly sessionContainer: SessionContainer;\n private connectionPolicy: ConnectionPolicy;\n private pipeline: Pipeline;\n private diagnosticWriter: DiagnosticWriter;\n private diagnosticFormatter: DiagnosticFormatter;\n public partitionKeyDefinitionCache: { [containerUrl: string]: any }; // TODO: PartitionKeyDefinitionCache\n public constructor(\n private cosmosClientOptions: CosmosClientOptions,\n private globalEndpointManager: GlobalEndpointManager,\n private clientConfig: ClientConfigDiagnostic,\n public diagnosticLevel: CosmosDbDiagnosticLevel,\n ) {\n this.connectionPolicy = cosmosClientOptions.connectionPolicy;\n this.sessionContainer = new SessionContainer();\n this.partitionKeyDefinitionCache = {};\n this.pipeline = null;\n if (cosmosClientOptions.aadCredentials) {\n this.pipeline = createEmptyPipeline();\n const hrefEndpoint = sanitizeEndpoint(cosmosClientOptions.endpoint);\n const scope = `${hrefEndpoint}/.default`;\n this.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential: cosmosClientOptions.aadCredentials,\n scopes: scope,\n challengeCallbacks: {\n async authorizeRequest({ request, getAccessToken }) {\n const tokenResponse = await getAccessToken([scope], {});\n const AUTH_PREFIX = `type=aad&ver=1.0&sig=`;\n const authorizationToken = `${AUTH_PREFIX}${tokenResponse.token}`;\n request.headers.set(\"Authorization\", authorizationToken);\n },\n },\n }),\n );\n }\n this.initializeDiagnosticSettings(diagnosticLevel);\n }\n /** @hidden */\n public async read({\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.get,\n path,\n operationType: OperationType.Read,\n resourceId,\n options,\n resourceType,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Read,\n resourceType,\n });\n\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n\n // read will use ReadEndpoint since it uses GET operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Read, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async queryFeed({\n path,\n resourceType,\n resourceId,\n resultFn,\n query,\n options,\n diagnosticNode,\n partitionKeyRangeId,\n partitionKey,\n startEpk,\n endEpk,\n }: {\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n resultFn: (result: { [key: string]: any }) => any[];\n query: SqlQuerySpec | string;\n options: FeedOptions;\n diagnosticNode: DiagnosticNodeInternal;\n partitionKeyRangeId?: string;\n partitionKey?: PartitionKey;\n startEpk?: string | undefined;\n endEpk?: string | undefined;\n }): Promise> {\n // Query operations will use ReadEndpoint even though it uses\n // GET(for queryFeed) and POST(for regular query operations)\n\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.get,\n path,\n operationType: OperationType.Query,\n partitionKeyRangeId,\n resourceId,\n resourceType,\n options,\n body: query,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Query,\n resourceType,\n });\n const requestId = uuid();\n if (query !== undefined) {\n request.method = HTTPMethod.post;\n }\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n request.headers = await this.buildHeaders(request);\n\n if (startEpk !== undefined && endEpk !== undefined) {\n request.headers[HttpHeaders.StartEpk] = startEpk;\n request.headers[HttpHeaders.EndEpk] = endEpk;\n request.headers[HttpHeaders.ReadFeedKeyType] = \"EffectivePartitionKeyRange\";\n }\n\n if (query !== undefined) {\n request.headers[HttpHeaders.IsQuery] = \"true\";\n request.headers[HttpHeaders.ContentType] = QueryJsonContentType;\n if (typeof query === \"string\") {\n request.body = { query }; // Converts query text to query object.\n }\n }\n this.applySessionToken(request);\n logger.info(\n \"query \" +\n requestId +\n \" started\" +\n (request.partitionKeyRangeId ? \" pkrid: \" + request.partitionKeyRangeId : \"\"),\n );\n logger.verbose(request);\n const start = Date.now();\n const response = await RequestHandler.request(request, diagnosticNode);\n logger.info(\"query \" + requestId + \" finished - \" + (Date.now() - start) + \"ms\");\n this.captureSessionToken(undefined, path, OperationType.Query, response.headers);\n return this.processQueryFeedResponse(response, !!query, resultFn);\n }\n\n public async getQueryPlan(\n path: string,\n resourceType: ResourceType,\n resourceId: string,\n query: SqlQuerySpec | string,\n options: FeedOptions = {},\n diagnosticNode: DiagnosticNodeInternal,\n ): Promise> {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n path,\n operationType: OperationType.Read,\n resourceId,\n resourceType,\n options,\n body: query,\n };\n diagnosticNode.addData({\n operationType: OperationType.Read,\n resourceType,\n });\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsQueryPlan] = \"True\";\n request.headers[HttpHeaders.QueryVersion] = \"1.4\";\n request.headers[HttpHeaders.ContentType] = QueryJsonContentType;\n request.headers[HttpHeaders.SupportedQueryFeatures] = supportedQueryFeaturesBuilder(\n options.disableNonStreamingOrderByQuery,\n );\n if (typeof query === \"string\") {\n request.body = { query }; // Converts query text to query object.\n }\n\n this.applySessionToken(request);\n const response = await RequestHandler.request(request, diagnosticNode);\n this.captureSessionToken(undefined, path, OperationType.Query, response.headers);\n return response as any;\n }\n\n public queryPartitionKeyRanges(\n collectionLink: string,\n query?: string | SqlQuerySpec,\n options?: FeedOptions,\n ): QueryIterator {\n const path = getPathFromLink(collectionLink, ResourceType.pkranges);\n const id = getIdFromLink(collectionLink);\n const cb: FetchFunctionCallback = async (diagNode, innerOptions) => {\n const response = await this.queryFeed({\n path,\n resourceType: ResourceType.pkranges,\n resourceId: id,\n resultFn: (result) => result.PartitionKeyRanges,\n query,\n options: innerOptions,\n diagnosticNode: diagNode,\n });\n return response;\n };\n return new QueryIterator(this, query, options, cb);\n }\n\n public async delete({\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n method = HTTPMethod.delete,\n diagnosticNode,\n }: {\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n method?: HTTPMethod;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: method,\n operationType: OperationType.Delete,\n path,\n resourceType,\n options,\n resourceId,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Delete,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n // deleteResource will use WriteEndpoint since it uses DELETE operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n if (parseLink(path).type !== \"colls\") {\n this.captureSessionToken(undefined, path, OperationType.Delete, response.headers);\n } else {\n this.clearSessionToken(path);\n }\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async patch({\n body,\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n body: any;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.patch,\n operationType: OperationType.Patch,\n path,\n resourceType,\n body,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Patch,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n\n // patch will use WriteEndpoint\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Patch, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async create({\n body,\n path,\n resourceType,\n resourceId,\n diagnosticNode,\n options = {},\n partitionKey,\n }: {\n body: T;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n diagnosticNode: DiagnosticNodeInternal;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Create,\n path,\n resourceType,\n resourceId,\n body,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Create,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n // create will use WriteEndpoint since it uses POST operation\n this.applySessionToken(request);\n\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Create, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n private processQueryFeedResponse(\n res: Response,\n isQuery: boolean,\n resultFn: (result: { [key: string]: any }) => any[],\n ): Response {\n if (isQuery) {\n return {\n result: resultFn(res.result),\n headers: res.headers,\n code: res.code,\n };\n } else {\n const newResult = resultFn(res.result).map((body: any) => body);\n return {\n result: newResult,\n headers: res.headers,\n code: res.code,\n };\n }\n }\n\n private applySessionToken(requestContext: RequestContext): void {\n const request = this.getSessionParams(requestContext.path);\n\n if (requestContext.headers && requestContext.headers[HttpHeaders.SessionToken]) {\n return;\n }\n\n const sessionConsistency: ConsistencyLevel = requestContext.headers[\n HttpHeaders.ConsistencyLevel\n ] as ConsistencyLevel;\n if (!sessionConsistency) {\n return;\n }\n\n if (sessionConsistency !== ConsistencyLevel.Session) {\n return;\n }\n\n if (request.resourceAddress) {\n const sessionToken = this.sessionContainer.get(request);\n if (sessionToken) {\n requestContext.headers[HttpHeaders.SessionToken] = sessionToken;\n }\n }\n }\n\n public async replace({\n body,\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n body: any;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.put,\n operationType: OperationType.Replace,\n path,\n resourceType,\n body,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Replace,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n this.applySessionToken(request);\n\n // replace will use WriteEndpoint since it uses PUT operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Replace, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async upsert({\n body,\n path,\n resourceType,\n resourceId,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n body: T;\n path: string;\n resourceType: ResourceType;\n resourceId: string;\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Upsert,\n path,\n resourceType,\n body,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Upsert,\n resourceType,\n });\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsUpsert] = true;\n this.applySessionToken(request);\n\n // upsert will use WriteEndpoint since it uses POST operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Upsert, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async execute({\n sprocLink,\n params,\n options = {},\n partitionKey,\n diagnosticNode,\n }: {\n sprocLink: string;\n params?: any[];\n options?: RequestOptions;\n partitionKey?: PartitionKey;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n // Accept a single parameter or an array of parameters.\n // Didn't add type annotation for this because we should legacy this behavior\n if (params !== null && params !== undefined && !Array.isArray(params)) {\n params = [params];\n }\n const path = getPathFromLink(sprocLink);\n const id = getIdFromLink(sprocLink);\n\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Execute,\n path,\n resourceType: ResourceType.sproc,\n options,\n resourceId: id,\n body: params,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Execute,\n resourceType: ResourceType.sproc,\n });\n request.headers = await this.buildHeaders(request);\n // executeStoredProcedure will use WriteEndpoint since it uses POST operation\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n return response;\n }\n\n /**\n * Gets the Database account information.\n * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved.\n * If not present, current client's url will be used.\n */\n public async getDatabaseAccount(\n diagnosticNode: DiagnosticNodeInternal,\n options: RequestOptions = {},\n ): Promise> {\n const endpoint = options.urlConnection || this.cosmosClientOptions.endpoint;\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n endpoint,\n method: HTTPMethod.get,\n operationType: OperationType.Read,\n path: \"\",\n resourceType: ResourceType.none,\n options,\n };\n diagnosticNode.addData({\n operationType: OperationType.Read,\n resourceType: ResourceType.none,\n });\n request.headers = await this.buildHeaders(request);\n // await options.beforeOperation({ endpoint, request, headers: requestHeaders });\n const { result, headers, code, substatus, diagnostics } = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n\n const databaseAccount = new DatabaseAccount(result, headers);\n return {\n result: databaseAccount,\n headers,\n diagnostics,\n code: code,\n substatus: substatus,\n };\n }\n\n public getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise {\n return this.globalEndpointManager.getWriteEndpoint(diagnosticNode);\n }\n\n public getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise {\n return this.globalEndpointManager.getReadEndpoint(diagnosticNode);\n }\n\n public getWriteEndpoints(): Promise {\n return this.globalEndpointManager.getWriteEndpoints();\n }\n\n public getReadEndpoints(): Promise {\n return this.globalEndpointManager.getReadEndpoints();\n }\n\n public async batch({\n body,\n path,\n partitionKey,\n resourceId,\n options = {},\n diagnosticNode,\n }: {\n body: T;\n path: string;\n partitionKey: PartitionKey;\n resourceId: string;\n options?: RequestOptions;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Batch,\n path,\n body,\n resourceType: ResourceType.item,\n resourceId,\n options,\n partitionKey,\n };\n diagnosticNode.addData({\n operationType: OperationType.Batch,\n resourceType: ResourceType.item,\n });\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsBatchRequest] = true;\n request.headers[HttpHeaders.IsBatchAtomic] = true;\n\n this.applySessionToken(request);\n\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Batch, response.headers);\n response.diagnostics = diagnosticNode.toDiagnostic(this.getClientConfig());\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n public async bulk({\n body,\n path,\n partitionKeyRangeId,\n resourceId,\n bulkOptions = {},\n options = {},\n diagnosticNode,\n }: {\n body: T;\n path: string;\n partitionKeyRangeId: string;\n resourceId: string;\n bulkOptions?: BulkOptions;\n options?: RequestOptions;\n diagnosticNode: DiagnosticNodeInternal;\n }): Promise> {\n try {\n const request: RequestContext = {\n ...this.getContextDerivedPropsForRequestCreation(),\n method: HTTPMethod.post,\n operationType: OperationType.Batch,\n path,\n body,\n resourceType: ResourceType.item,\n resourceId,\n options,\n };\n diagnosticNode.addData({\n operationType: OperationType.Batch,\n resourceType: ResourceType.item,\n });\n request.headers = await this.buildHeaders(request);\n request.headers[HttpHeaders.IsBatchRequest] = true;\n request.headers[HttpHeaders.PartitionKeyRangeID] = partitionKeyRangeId;\n request.headers[HttpHeaders.IsBatchAtomic] = false;\n request.headers[HttpHeaders.BatchContinueOnError] = bulkOptions.continueOnError || false;\n\n this.applySessionToken(request);\n\n request.endpoint = await this.globalEndpointManager.resolveServiceEndpoint(\n diagnosticNode,\n request.resourceType,\n request.operationType,\n );\n const response = await executePlugins(\n diagnosticNode,\n request,\n RequestHandler.request,\n PluginOn.operation,\n );\n this.captureSessionToken(undefined, path, OperationType.Batch, response.headers);\n return response;\n } catch (err: any) {\n this.captureSessionToken(err, path, OperationType.Upsert, (err as ErrorResponse).headers);\n throw err;\n }\n }\n\n private captureSessionToken(\n err: ErrorResponse,\n path: string,\n operationType: OperationType,\n resHeaders: CosmosHeaders,\n ): void {\n const request = this.getSessionParams(path);\n request.operationType = operationType;\n if (\n !err ||\n (!this.isMasterResource(request.resourceType) &&\n (err.code === StatusCodes.PreconditionFailed ||\n err.code === StatusCodes.Conflict ||\n (err.code === StatusCodes.NotFound &&\n err.substatus !== SubStatusCodes.ReadSessionNotAvailable)))\n ) {\n this.sessionContainer.set(request, resHeaders);\n }\n }\n\n public clearSessionToken(path: string): void {\n const request = this.getSessionParams(path);\n this.sessionContainer.remove(request);\n }\n\n public recordDiagnostics(diagnostic: CosmosDiagnostics): void {\n const formatted = this.diagnosticFormatter.format(diagnostic);\n this.diagnosticWriter.write(formatted);\n }\n\n public initializeDiagnosticSettings(diagnosticLevel: CosmosDbDiagnosticLevel): void {\n this.diagnosticFormatter = new DefaultDiagnosticFormatter();\n switch (diagnosticLevel) {\n case CosmosDbDiagnosticLevel.info:\n this.diagnosticWriter = new NoOpDiagnosticWriter();\n break;\n default:\n this.diagnosticWriter = new LogDiagnosticWriter();\n }\n }\n\n // TODO: move\n private getSessionParams(resourceLink: string): SessionContext {\n const resourceId: string = null;\n let resourceAddress: string = null;\n const parserOutput = parseLink(resourceLink);\n\n resourceAddress = parserOutput.objectBody.self;\n\n const resourceType = parserOutput.type;\n return {\n resourceId,\n resourceAddress,\n resourceType,\n isNameBased: true,\n };\n }\n\n private isMasterResource(resourceType: string): boolean {\n if (\n resourceType === Constants.Path.OffersPathSegment ||\n resourceType === Constants.Path.DatabasesPathSegment ||\n resourceType === Constants.Path.UsersPathSegment ||\n resourceType === Constants.Path.PermissionsPathSegment ||\n resourceType === Constants.Path.TopologyPathSegment ||\n resourceType === Constants.Path.DatabaseAccountPathSegment ||\n resourceType === Constants.Path.PartitionKeyRangesPathSegment ||\n resourceType === Constants.Path.CollectionsPathSegment\n ) {\n return true;\n }\n\n return false;\n }\n\n private buildHeaders(requestContext: RequestContext): Promise {\n return getHeaders({\n clientOptions: this.cosmosClientOptions,\n defaultHeaders: {\n ...this.cosmosClientOptions.defaultHeaders,\n ...requestContext.options.initialHeaders,\n },\n verb: requestContext.method,\n path: requestContext.path,\n resourceId: requestContext.resourceId,\n resourceType: requestContext.resourceType,\n options: requestContext.options,\n partitionKeyRangeId: requestContext.partitionKeyRangeId,\n useMultipleWriteLocations: this.connectionPolicy.useMultipleWriteLocations,\n partitionKey:\n requestContext.partitionKey !== undefined\n ? convertToInternalPartitionKey(requestContext.partitionKey)\n : undefined, // TODO: Move this check from here to PartitionKey\n });\n }\n\n /**\n * Returns collection of properties which are derived from the context for Request Creation.\n * These properties have client wide scope, as opposed to request specific scope.\n * @returns\n */\n private getContextDerivedPropsForRequestCreation(): {\n globalEndpointManager: GlobalEndpointManager;\n connectionPolicy: ConnectionPolicy;\n requestAgent: Agent;\n client?: ClientContext;\n pipeline?: Pipeline;\n plugins: PluginConfig[];\n } {\n return {\n globalEndpointManager: this.globalEndpointManager,\n requestAgent: this.cosmosClientOptions.agent,\n connectionPolicy: this.connectionPolicy,\n client: this,\n plugins: this.cosmosClientOptions.plugins,\n pipeline: this.pipeline,\n };\n }\n\n public getClientConfig(): ClientConfigDiagnostic {\n return this.clientConfig;\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { getUserAgent as userAgent } from \"universal-user-agent\";\nimport { Constants } from \"./constants\";\n\n/**\n * @hidden\n */\nexport function getUserAgent(suffix?: string): string {\n const ua = `${userAgent()} ${Constants.SDKName}/${Constants.SDKVersion}`;\n if (suffix) {\n return ua + \" \" + suffix;\n }\n return ua;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport function isNonEmptyString(variable: unknown): boolean {\n return typeof variable === \"string\" && variable.trim().length > 0;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Constants } from \"../common\";\nimport { isNonEmptyString } from \"../utils/strings\";\nimport { CosmosDbDiagnosticLevel } from \"./CosmosDbDiagnosticLevel\";\n\nexport * from \"./DiagnosticWriter\";\nexport * from \"./DiagnosticFormatter\";\n\nexport const DefaultDiagnosticLevelValue = CosmosDbDiagnosticLevel.info;\n\nconst diagnosticLevelFromEnv =\n (typeof process !== \"undefined\" &&\n process.env &&\n process.env[Constants.CosmosDbDiagnosticLevelEnvVarName]) ||\n undefined;\n\nconst acceptableDiagnosticLevelValues = Object.values(CosmosDbDiagnosticLevel).map((x) =>\n x.toString(),\n);\n\nlet cosmosDiagnosticLevel: CosmosDbDiagnosticLevel | undefined;\n\nif (isNonEmptyString(diagnosticLevelFromEnv)) {\n // avoid calling setDiagnosticLevel because we don't want a mis-set environment variable to crash\n if (isCosmosDiagnosticLevel(diagnosticLevelFromEnv)) {\n setDiagnosticLevel(diagnosticLevelFromEnv as CosmosDbDiagnosticLevel);\n } else {\n console.error(\n `${\n Constants.CosmosDbDiagnosticLevelEnvVarName\n } set to unknown diagnostic level '${diagnosticLevelFromEnv}'; Setting Cosmos Db diagnostic level to info. Acceptable values: ${acceptableDiagnosticLevelValues.join(\n \", \",\n )}.`,\n );\n }\n}\n\nexport function setDiagnosticLevel(level?: CosmosDbDiagnosticLevel): void {\n if (level && !isCosmosDiagnosticLevel(level)) {\n throw new Error(\n `Unknown diagnostic level '${level}'. Acceptable values: ${acceptableDiagnosticLevelValues.join(\n \",\",\n )}`,\n );\n }\n cosmosDiagnosticLevel = level;\n}\n\nexport function getDiagnosticLevelFromEnvironment(): CosmosDbDiagnosticLevel | undefined {\n return cosmosDiagnosticLevel;\n}\n\nfunction isCosmosDiagnosticLevel(\n diagnosticLevel: string,\n): diagnosticLevel is CosmosDbDiagnosticLevel {\n return acceptableDiagnosticLevelValues.includes(diagnosticLevel);\n}\n\nexport function determineDiagnosticLevel(\n diagnosticLevelFromClientConfig: CosmosDbDiagnosticLevel,\n diagnosticLevelFromEnvironment: CosmosDbDiagnosticLevel,\n): CosmosDbDiagnosticLevel {\n const diagnosticLevelFromEnvOrClient =\n diagnosticLevelFromEnvironment ?? diagnosticLevelFromClientConfig; // Diagnostic Setting from environment gets first priority.\n return diagnosticLevelFromEnvOrClient ?? DefaultDiagnosticLevelValue; // Diagnostic Setting supplied in Client config gets second priority.\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { OperationType, ResourceType, isReadRequest } from \"./common\";\nimport { CosmosClientOptions } from \"./CosmosClientOptions\";\nimport { Location, DatabaseAccount } from \"./documents\";\nimport { RequestOptions } from \"./index\";\nimport { Constants } from \"./common/constants\";\nimport { ResourceResponse } from \"./request\";\nimport { MetadataLookUpType } from \"./CosmosDiagnostics\";\nimport { DiagnosticNodeInternal } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { withMetadataDiagnostics } from \"./utils/diagnostics\";\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\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>,\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 {\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 {\n return this.resolveServiceEndpoint(diagnosticNode, ResourceType.item, OperationType.Replace);\n }\n\n public async getReadEndpoints(): Promise> {\n return this.readableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n public async getWriteEndpoints(): Promise> {\n return this.writeableLocations.map((loc) => loc.databaseAccountEndpoint);\n }\n\n public async markCurrentLocationUnavailableForRead(\n diagnosticNode: DiagnosticNodeInternal,\n endpoint: string,\n ): Promise {\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 {\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 = this.options.connectionPolicy.useMultipleWriteLocations;\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 {\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 }\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 {\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 {\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\nfunction normalizeEndpoint(endpoint: string): string {\n return endpoint.split(\" \").join(\"\").toLowerCase();\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { Database, Databases } from \"./client/Database\";\nimport { Offer, Offers } from \"./client/Offer\";\nimport { ClientContext } from \"./ClientContext\";\nimport { parseConnectionString } from \"./common\";\nimport { Constants } from \"./common/constants\";\nimport { getUserAgent } from \"./common/platform\";\nimport { CosmosClientOptions } from \"./CosmosClientOptions\";\nimport { ClientConfigDiagnostic } from \"./CosmosDiagnostics\";\nimport { determineDiagnosticLevel, getDiagnosticLevelFromEnvironment } from \"./diagnostics\";\nimport { DiagnosticNodeInternal, DiagnosticNodeType } from \"./diagnostics/DiagnosticNodeInternal\";\nimport { DatabaseAccount, defaultConnectionPolicy } from \"./documents\";\nimport { GlobalEndpointManager } from \"./globalEndpointManager\";\nimport { RequestOptions, ResourceResponse } from \"./request\";\nimport { checkURL } from \"./utils/checkURL\";\nimport { getEmptyCosmosDiagnostics, withDiagnostics } from \"./utils/diagnostics\";\n\n/**\n * Provides a client-side logical representation of the Azure Cosmos DB database account.\n * This client is used to configure and execute requests in the Azure Cosmos DB database service.\n * @example Instantiate a client and create a new database\n * ```typescript\n * const client = new CosmosClient({endpoint: \"\", auth: {masterKey: \"\"}});\n * await client.databases.create({id: \"\"});\n * ```\n * @example Instantiate a client with custom Connection Policy\n * ```typescript\n * const connectionPolicy = new ConnectionPolicy();\n * connectionPolicy.RequestTimeout = 10000;\n * const client = new CosmosClient({\n * endpoint: \"\",\n * auth: {masterKey: \"\"},\n * connectionPolicy\n * });\n * ```\n */\nexport class CosmosClient {\n /**\n * Used for creating new databases, or querying/reading all databases.\n *\n * Use `.database(id)` to read, replace, or delete a specific, existing database by id.\n *\n * @example Create a new database\n * ```typescript\n * const {resource: databaseDefinition, database} = await client.databases.create({id: \"\"});\n * ```\n */\n public readonly databases: Databases;\n /**\n * Used for querying & reading all offers.\n *\n * Use `.offer(id)` to read, or replace existing offers.\n */\n public readonly offers: Offers;\n private clientContext: ClientContext;\n private endpointRefresher: NodeJS.Timeout;\n /**\n * Creates a new {@link CosmosClient} object from a connection string. Your database connection string can be found in the Azure Portal\n */\n constructor(connectionString: string);\n /**\n * Creates a new {@link CosmosClient} object. See {@link CosmosClientOptions} for more details on what options you can use.\n * @param options - bag of options; require at least endpoint and auth to be configured\n */\n constructor(options: CosmosClientOptions);\n constructor(optionsOrConnectionString: string | CosmosClientOptions) {\n if (typeof optionsOrConnectionString === \"string\") {\n optionsOrConnectionString = parseConnectionString(optionsOrConnectionString);\n }\n\n const endpoint = checkURL(optionsOrConnectionString.endpoint);\n if (!endpoint) {\n throw new Error(\"Invalid endpoint specified\");\n }\n\n const clientConfig: ClientConfigDiagnostic =\n this.initializeClientConfigDiagnostic(optionsOrConnectionString);\n\n optionsOrConnectionString.connectionPolicy = Object.assign(\n {},\n defaultConnectionPolicy,\n optionsOrConnectionString.connectionPolicy,\n );\n\n optionsOrConnectionString.defaultHeaders = optionsOrConnectionString.defaultHeaders || {};\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.CacheControl] = \"no-cache\";\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.Version] =\n Constants.CurrentVersion;\n if (optionsOrConnectionString.consistencyLevel !== undefined) {\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.ConsistencyLevel] =\n optionsOrConnectionString.consistencyLevel;\n }\n\n optionsOrConnectionString.defaultHeaders[Constants.HttpHeaders.UserAgent] = getUserAgent(\n optionsOrConnectionString.userAgentSuffix,\n );\n\n const globalEndpointManager = new GlobalEndpointManager(\n optionsOrConnectionString,\n async (diagnosticNode: DiagnosticNodeInternal, opts: RequestOptions) =>\n this.getDatabaseAccountInternal(diagnosticNode, opts),\n );\n\n this.clientContext = new ClientContext(\n optionsOrConnectionString,\n globalEndpointManager,\n clientConfig,\n determineDiagnosticLevel(\n optionsOrConnectionString.diagnosticLevel,\n getDiagnosticLevelFromEnvironment(),\n ),\n );\n if (\n optionsOrConnectionString.connectionPolicy?.enableEndpointDiscovery &&\n optionsOrConnectionString.connectionPolicy?.enableBackgroundEndpointRefreshing\n ) {\n this.backgroundRefreshEndpointList(\n globalEndpointManager,\n optionsOrConnectionString.connectionPolicy.endpointRefreshRateInMs ||\n defaultConnectionPolicy.endpointRefreshRateInMs,\n );\n }\n\n this.databases = new Databases(this, this.clientContext);\n this.offers = new Offers(this, this.clientContext);\n }\n\n private initializeClientConfigDiagnostic(\n optionsOrConnectionString: CosmosClientOptions,\n ): ClientConfigDiagnostic {\n return {\n endpoint: optionsOrConnectionString.endpoint,\n resourceTokensConfigured: optionsOrConnectionString.resourceTokens !== undefined,\n tokenProviderConfigured: optionsOrConnectionString.tokenProvider !== undefined,\n aadCredentialsConfigured: optionsOrConnectionString.aadCredentials !== undefined,\n connectionPolicyConfigured: optionsOrConnectionString.connectionPolicy !== undefined,\n consistencyLevel: optionsOrConnectionString.consistencyLevel,\n defaultHeaders: optionsOrConnectionString.defaultHeaders,\n agentConfigured: optionsOrConnectionString.agent !== undefined,\n userAgentSuffix: optionsOrConnectionString.userAgentSuffix,\n diagnosticLevel: optionsOrConnectionString.diagnosticLevel,\n pluginsConfigured: optionsOrConnectionString.plugins !== undefined,\n sDKVersion: Constants.SDKVersion,\n };\n }\n\n /**\n * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.)\n */\n public async getDatabaseAccount(\n options?: RequestOptions,\n ): Promise> {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.getDatabaseAccountInternal(diagnosticNode, options);\n }, this.clientContext);\n }\n\n /**\n * @hidden\n */\n public async getDatabaseAccountInternal(\n diagnosticNode: DiagnosticNodeInternal,\n options?: RequestOptions,\n ): Promise> {\n const response = await this.clientContext.getDatabaseAccount(diagnosticNode, options);\n return new ResourceResponse(\n response.result,\n response.headers,\n response.code,\n getEmptyCosmosDiagnostics(),\n response.substatus,\n );\n }\n\n /**\n * Gets the currently used write endpoint url. Useful for troubleshooting purposes.\n *\n * The url may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public async getWriteEndpoint(): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.clientContext.getWriteEndpoint(diagnosticNode);\n }, this.clientContext);\n }\n\n /**\n * Gets the currently used read endpoint. Useful for troubleshooting purposes.\n *\n * The url may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public async getReadEndpoint(): Promise {\n return withDiagnostics(async (diagnosticNode: DiagnosticNodeInternal) => {\n return this.clientContext.getReadEndpoint(diagnosticNode);\n }, this.clientContext);\n }\n\n /**\n * Gets the known write endpoints. Useful for troubleshooting purposes.\n *\n * The urls may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public getWriteEndpoints(): Promise {\n return this.clientContext.getWriteEndpoints();\n }\n\n /**\n * Gets the currently used read endpoint. Useful for troubleshooting purposes.\n *\n * The url may contain a region suffix (e.g. \"-eastus\") if we're using location specific endpoints.\n */\n public getReadEndpoints(): Promise {\n return this.clientContext.getReadEndpoints();\n }\n\n /**\n * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database.\n *\n * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object.\n *\n * @param id - The id of the database.\n * @example Create a new container off of an existing database\n * ```typescript\n * const container = client.database(\"\").containers.create(\"\");\n * ```\n *\n * @example Delete an existing database\n * ```typescript\n * await client.database(\"\").delete();\n * ```\n */\n public database(id: string): Database {\n return new Database(this, id, this.clientContext);\n }\n\n /**\n * Used for reading, or updating a existing offer by id.\n * @param id - The id of the offer.\n */\n public offer(id: string): Offer {\n return new Offer(this, id, this.clientContext);\n }\n\n /**\n * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process.\n */\n public dispose(): void {\n clearTimeout(this.endpointRefresher);\n }\n\n private async backgroundRefreshEndpointList(\n globalEndpointManager: GlobalEndpointManager,\n refreshRate: number,\n ) {\n this.endpointRefresher = setInterval(() => {\n try {\n return withDiagnostics(\n async (diagnosticNode: DiagnosticNodeInternal) => {\n return globalEndpointManager.refreshEndpointList(diagnosticNode);\n },\n this.clientContext,\n DiagnosticNodeType.BACKGROUND_REFRESH_THREAD,\n );\n } catch (e: any) {\n console.warn(\"Failed to refresh endpoints\", e);\n }\n }, refreshRate);\n if (this.endpointRefresher.unref && typeof this.endpointRefresher.unref === \"function\") {\n this.endpointRefresher.unref();\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CosmosContainerChildResourceKind } from \"../../common/constants\";\nimport { CosmosKeyType } from \"../../common/constants\";\n\nexport class SasTokenProperties {\n user: string;\n userTag: string;\n databaseName: string;\n containerName: string;\n resourceName: string;\n resourcePath: string;\n resourceKind: CosmosContainerChildResourceKind;\n partitionKeyValueRanges: string[];\n startTime: Date;\n expiryTime: Date;\n keyType: CosmosKeyType | number;\n controlPlaneReaderScope: number;\n controlPlaneWriterScope: number;\n dataPlaneReaderScope: number;\n dataPlaneWriterScope: number;\n cosmosContainerChildResourceKind: CosmosContainerChildResourceKind;\n cosmosKeyType: CosmosKeyType;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/// \n\nexport function encodeUTF8(str: string): Uint8Array {\n const bytes = new Uint8Array(str.length);\n for (let i = 0; i < str.length; i++) {\n bytes[i] = str.charCodeAt(i);\n }\n return bytes;\n}\n\nexport function encodeBase64(value: ArrayBuffer): string {\n if (\"function\" !== typeof btoa) {\n throw new Error(\"Your browser environment is missing the global `btoa` function\");\n }\n\n let binary = \"\";\n const bytes = new Uint8Array(value);\n const len = bytes.byteLength;\n for (let i = 0; i < len; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SasTokenProperties } from \"../client/SasToken/SasTokenProperties\";\nimport { Constants, CosmosKeyType, SasTokenPermissionKind } from \"../common\";\nimport { encodeUTF8 } from \"./encode\";\nimport { hmac } from \"./hmac\";\n\n/**\n * Experimental internal only\n * Generates the payload representing the permission configuration for the sas token.\n */\n\nexport async function createAuthorizationSasToken(\n masterKey: string,\n sasTokenProperties: SasTokenProperties,\n): Promise {\n let resourcePrefixPath = \"\";\n if (\n typeof sasTokenProperties.databaseName === \"string\" &&\n sasTokenProperties.databaseName !== \"\"\n ) {\n resourcePrefixPath += `/${Constants.Path.DatabasesPathSegment}/${sasTokenProperties.databaseName}`;\n }\n\n if (\n typeof sasTokenProperties.containerName === \"string\" &&\n sasTokenProperties.containerName !== \"\"\n ) {\n if (sasTokenProperties.databaseName === \"\") {\n throw new Error(`illegalArgumentException : ${sasTokenProperties.databaseName} \\\n is an invalid database name`);\n }\n resourcePrefixPath += `/${Constants.Path.CollectionsPathSegment}/${sasTokenProperties.containerName}`;\n }\n\n if (\n typeof sasTokenProperties.resourceName === \"string\" &&\n sasTokenProperties.resourceName !== \"\"\n ) {\n if (sasTokenProperties.containerName === \"\") {\n throw new Error(`illegalArgumentException : ${sasTokenProperties.containerName} \\\n is an invalid container name`);\n }\n switch (sasTokenProperties.resourceKind) {\n case \"ITEM\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.DocumentsPathSegment}`;\n break;\n case \"STORED_PROCEDURE\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.StoredProceduresPathSegment}`;\n break;\n case \"USER_DEFINED_FUNCTION\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.UserDefinedFunctionsPathSegment}`;\n break;\n case \"TRIGGER\":\n resourcePrefixPath += `${Constants.Path.Root}${Constants.Path.TriggersPathSegment}`;\n break;\n default:\n throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \\\n is an invalid resource kind`);\n break;\n }\n resourcePrefixPath += `${Constants.Path.Root}${sasTokenProperties.resourceName}${Constants.Path.Root}`;\n }\n sasTokenProperties.resourcePath = resourcePrefixPath.toString();\n\n let partitionRanges = \"\";\n\n if (\n sasTokenProperties.partitionKeyValueRanges !== undefined &&\n sasTokenProperties.partitionKeyValueRanges.length > 0\n ) {\n if (\n typeof sasTokenProperties.resourceKind !== \"string\" &&\n sasTokenProperties.resourceKind !== \"ITEM\"\n ) {\n throw new Error(`illegalArgumentException : ${sasTokenProperties.resourceKind} \\\n is an invalid partition key value range`);\n }\n sasTokenProperties.partitionKeyValueRanges.forEach((range) => {\n partitionRanges += `${encodeUTF8(range)},`;\n });\n }\n\n if (sasTokenProperties.controlPlaneReaderScope === 0) {\n sasTokenProperties.controlPlaneReaderScope += SasTokenPermissionKind.ContainerReadAny;\n sasTokenProperties.controlPlaneWriterScope += SasTokenPermissionKind.ContainerReadAny;\n }\n\n if (\n sasTokenProperties.dataPlaneReaderScope === 0 &&\n sasTokenProperties.dataPlaneWriterScope === 0\n ) {\n sasTokenProperties.dataPlaneReaderScope = SasTokenPermissionKind.ContainerFullAccess;\n sasTokenProperties.dataPlaneWriterScope = SasTokenPermissionKind.ContainerFullAccess;\n }\n\n if (\n typeof sasTokenProperties.keyType !== \"number\" ||\n typeof sasTokenProperties.keyType === undefined\n ) {\n switch (sasTokenProperties.keyType) {\n case CosmosKeyType.PrimaryMaster:\n sasTokenProperties.keyType = 1;\n break;\n case CosmosKeyType.SecondaryMaster:\n sasTokenProperties.keyType = 2;\n break;\n case CosmosKeyType.PrimaryReadOnly:\n sasTokenProperties.keyType = 3;\n break;\n case CosmosKeyType.SecondaryReadOnly:\n sasTokenProperties.keyType = 4;\n break;\n default:\n throw new Error(`illegalArgumentException : ${sasTokenProperties.keyType} \\\n is an invalid key type`);\n break;\n }\n }\n\n const payload =\n sasTokenProperties.user +\n \"\\n\" +\n sasTokenProperties.userTag +\n \"\\n\" +\n sasTokenProperties.resourcePath +\n \"\\n\" +\n partitionRanges +\n \"\\n\" +\n utcsecondsSinceEpoch(sasTokenProperties.startTime).toString(16) +\n \"\\n\" +\n utcsecondsSinceEpoch(sasTokenProperties.expiryTime).toString(16) +\n \"\\n\" +\n sasTokenProperties.keyType +\n \"\\n\" +\n sasTokenProperties.controlPlaneReaderScope.toString(16) +\n \"\\n\" +\n sasTokenProperties.controlPlaneWriterScope.toString(16) +\n \"\\n\" +\n sasTokenProperties.dataPlaneReaderScope.toString(16) +\n \"\\n\" +\n sasTokenProperties.dataPlaneWriterScope.toString(16) +\n \"\\n\";\n\n const signedPayload = await hmac(masterKey, Buffer.from(payload).toString(\"base64\"));\n return \"type=sas&ver=1.0&sig=\" + signedPayload + \";\" + Buffer.from(payload).toString(\"base64\");\n}\n/**\n * @hidden\n */\n// TODO: utcMilllisecondsSinceEpoch\nexport function utcsecondsSinceEpoch(date: Date): number {\n return Math.round(date.getTime() / 1000);\n}\n"],"names":["Constants","ResourceType","HTTPMethod","OperationType","SasTokenPermissionKind","createHmac","ConnectionMode","ConsistencyLevel","DataType","IndexingMode","SpatialType","IndexKind","PartitionKeyDefinitionVersion","PartitionKeyKind","PermissionMode","PriorityLevel","TriggerOperation","TriggerType","UserDefinedFunctionType","GeospatialType","logger","createClientLogger","uuid","v4","MetadataLookUpType","CosmosDbDiagnosticLevel","DiagnosticNodeType","TYPEORDCOMPARATOR","createHash","__await","ConflictResolutionMode","reverse","prefixKeyByType","PluginOn","createDefaultHttpClient","AbortController","createHttpHeaders","createPipelineRequest","RetryUtility.execute","createEmptyPipeline","bearerTokenAuthenticationPolicy","userAgent"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACa,MAAA,0BAA0B,GAAG,iBAAqC;;ACF/E;AACA;AASA;;AAEG;AACU,MAAAA,WAAS,GAAG;AACvB,IAAA,WAAW,EAAE;AACX,QAAA,aAAa,EAAE,eAAe;AAC9B,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,cAAc,EAAE,eAAe;AAC/B,QAAA,IAAI,EAAE,MAAM;AACZ,QAAA,WAAW,EAAE,cAAc;AAC3B,QAAA,YAAY,EAAE,eAAe;AAC7B,QAAA,eAAe,EAAE,kBAAkB;AACnC,QAAA,YAAY,EAAE,cAAc;AAC5B,QAAA,SAAS,EAAE,YAAY;AACvB,QAAA,eAAe,EAAE,mBAAmB;AACpC,QAAA,OAAO,EAAE,UAAU;AACnB,QAAA,WAAW,EAAE,eAAe;AAC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100644 index 000000000..ade3d9b53 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist/types/latest/cosmos.d.ts @@ -0,0 +1,4285 @@ +/// +/// + +import { AbortError } from '@azure/abort-controller'; +import { AbortSignal as AbortSignal_2 } from 'node-abort-controller'; +import { Pipeline } from '@azure/core-rest-pipeline'; +import { RestError } from '@azure/core-rest-pipeline'; +import { TokenCredential } from '@azure/core-auth'; + +export { AbortError } + +export declare interface Agent { + maxFreeSockets: number; + maxSockets: number; + sockets: any; + requests: any; + destroy(): void; +} + +export declare type AggregateType = "Average" | "Count" | "Max" | "Min" | "Sum"; + +export declare type BulkOperationResponse = OperationResponse[] & { + diagnostics: CosmosDiagnostics; +}; + +export declare const BulkOperationType: { + readonly Create: "Create"; + readonly Upsert: "Upsert"; + readonly Read: "Read"; + readonly Delete: "Delete"; + readonly Replace: "Replace"; + readonly Patch: "Patch"; +}; + +/** + * Options object used to modify bulk execution. + * continueOnError (Default value: false) - Continues bulk execution when an operation fails ** NOTE THIS WILL DEFAULT TO TRUE IN the 4.0 RELEASE + */ +export declare interface BulkOptions { + continueOnError?: boolean; +} + +export declare type BulkPatchOperation = OperationBase & { + operationType: typeof BulkOperationType.Patch; + id: string; +}; + +/** + * Provides iterator for change feed. + * + * Use `Items.changeFeed()` to get an instance of the iterator. + */ +export declare class ChangeFeedIterator { + private clientContext; + private resourceId; + private resourceLink; + private partitionKey; + private changeFeedOptions; + private static readonly IfNoneMatchAllHeaderValue; + private nextIfNoneMatch; + private ifModifiedSince; + private lastStatusCode; + private isPartitionSpecified; + /** + * Gets a value indicating whether there are potentially additional results that can be retrieved. + * + * Initially returns true. This value is set based on whether the last execution returned a continuation token. + * + * @returns Boolean value representing if whether there are potentially additional results that can be retrieved. + */ + get hasMoreResults(): boolean; + /** + * Gets an async iterator which will yield pages of results from Azure Cosmos DB. + */ + getAsyncIterator(): AsyncIterable>>; + /** + * Read feed and retrieves the next page of results in Azure Cosmos DB. + */ + fetchNext(): Promise>>; + private getFeedResponse; +} + +/** + * Specifies options for the change feed + * + * If none of those options are set, it will start reading changes from now for the entire container. + */ +export declare interface ChangeFeedIteratorOptions { + /** + * Max amount of items to return per page + */ + maxItemCount?: number; + /** + * The session token to use. If not specified, will use the most recent captured session token to start with. + */ + sessionToken?: string; + /** + * Signals where to start from in the change feed. + */ + changeFeedStartFrom?: ChangeFeedStartFrom; +} + +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +export declare class ChangeFeedIteratorResponse { + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + readonly result: T; + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + readonly count: number; + /** + * Gets the status code of the response from Azure Cosmos DB + */ + readonly statusCode: number; + /** + * Cosmos Diagnostic Object. + */ + readonly diagnostics: CosmosDiagnostics; + /** + * Gets the subStatusCodes of the response from Azure Cosmos DB. Useful in partition split or partition gone. + */ + readonly subStatusCode?: number; + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge(): number; + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId(): string; + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + */ + get continuationToken(): string; + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken(): string; + /** + * Response headers of the response from Azure Cosmos DB + */ + headers: CosmosHeaders; +} + +/** + * Specifies options for the change feed + * + * Some of these options control where and when to start reading from the change feed. The order of precedence is: + * - continuation + * - startTime + * - startFromBeginning + * + * If none of those options are set, it will start reading changes from the first `ChangeFeedIterator.fetchNext()` call. + */ +export declare interface ChangeFeedOptions { + /** + * Max amount of items to return per page + */ + maxItemCount?: number; + /** + * The continuation token to start from. + * + * This is equivalent to the etag and continuation value from the `ChangeFeedResponse` + */ + continuation?: string; + /** + * The session token to use. If not specified, will use the most recent captured session token to start with. + */ + sessionToken?: string; + /** + * Signals whether to start from the beginning or not. + */ + startFromBeginning?: boolean; + /** + * Specified the start time to start reading changes from. + */ + startTime?: Date; +} + +/** + * Use `Items.getChangeFeedIterator()` to return an iterator that can iterate over all the changes for a partition key, feed range or an entire container. + */ +export declare interface ChangeFeedPullModelIterator { + /** + * Always returns true, changefeed is an infinite stream. + */ + readonly hasMoreResults: boolean; + /** + * Returns next set of results for the change feed. + */ + readNext(): Promise>>; + /** + * Gets an async iterator which will yield change feed results. + * @example Get changefeed for an entire container from now + * ```typescript + * const options = { changeFeedStartFrom: ChangeFeedStartFrom.Now() }; + * for await(const res of container.items.getChangeFeedIterator(options).getAsyncIterator()) { + * //process res + * } + * ``` + */ + getAsyncIterator(): AsyncIterable>>; +} + +/** + * A single response page from the Azure Cosmos DB Change Feed + */ +export declare class ChangeFeedResponse { + /** + * Gets the items returned in the response from Azure Cosmos DB + */ + readonly result: T; + /** + * Gets the number of items returned in the response from Azure Cosmos DB + */ + readonly count: number; + /** + * Gets the status code of the response from Azure Cosmos DB + */ + readonly statusCode: number; + readonly diagnostics: CosmosDiagnostics; + /** + * Gets the request charge for this request from the Azure Cosmos DB service. + */ + get requestCharge(): number; + /** + * Gets the activity ID for the request from the Azure Cosmos DB service. + */ + get activityId(): string; + /** + * Gets the continuation token to be used for continuing enumeration of the Azure Cosmos DB service. + * + * This is equivalent to the `etag` property. + */ + get continuation(): string; + /** + * Gets the session token for use in session consistency reads from the Azure Cosmos DB service. + */ + get sessionToken(): string; + /** + * Gets the entity tag associated with last transaction in the Azure Cosmos DB service, + * which can be used as If-Non-Match Access condition for ReadFeed REST request or + * `continuation` property of `ChangeFeedOptions` parameter for + * `Items.changeFeed()` + * to get feed changes since the transaction specified by this entity tag. + * + * This is equivalent to the `continuation` property. + */ + get etag(): string; + /** + * Response headers of the response from Azure Cosmos DB + */ + headers: CosmosHeaders; +} + +/** + * Base class for where to start a ChangeFeedIterator. + */ +export declare abstract class ChangeFeedStartFrom { + /** + * Returns an object that tells the ChangeFeedIterator to start from the beginning of time. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Beginning(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromBeginning; + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from this moment onward. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + **/ + static Now(cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromNow; + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from some point in time onward. + * @param startTime - Date object specfiying the time to start reading changes from. + * @param cfResource - PartitionKey or FeedRange for which changes are to be fetched. Leave blank for fetching changes for entire container. + */ + static Time(startTime: Date, cfResource?: PartitionKey | FeedRange): ChangeFeedStartFromTime; + /** + * Returns an object that tells the ChangeFeedIterator to start reading changes from a save point. + * @param continuation - The continuation to resume from. + */ + static Continuation(continuationToken: string): ChangeFeedStartFromContinuation; +} + +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from beginning of time. + */ +declare class ChangeFeedStartFromBeginning { + private cfResource?; + constructor(cfResource?: PartitionKey | FeedRange); + getCfResource(): PartitionKey | FeedRange | undefined; +} + +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a saved point. + */ +declare class ChangeFeedStartFromContinuation { + private continuationToken; + constructor(continuation: string); + getCfResource(): string; + getCfResourceJson(): any; + getResourceType(): any; +} + +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time. + */ +declare class ChangeFeedStartFromNow { + cfResource?: PartitionKey | FeedRange; + constructor(cfResource?: PartitionKey | FeedRange); + getCfResource(): PartitionKey | FeedRange | undefined; +} + +/** + * @hidden + * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time. + */ +declare class ChangeFeedStartFromTime { + private cfResource?; + private startTime; + constructor(startTime: Date, cfResource?: PartitionKey | FeedRange); + getCfResource(): PartitionKey | FeedRange | undefined; + getStartTime(): Date; +} + +/** + * This type holds information related to initialization of `CosmosClient` + */ +export declare type ClientConfigDiagnostic = { + /** + * End point configured during client initialization. + */ + endpoint: string; + /** + * True if `resourceTokens` was supplied during client initialization. + */ + resourceTokensConfigured: boolean; + /** + * True if `tokenProvider` was supplied during client initialization. + */ + tokenProviderConfigured: boolean; + /** + * True if `aadCredentials` was supplied during client initialization. + */ + aadCredentialsConfigured: boolean; + /** + * True if `connectionPolicy` was supplied during client initialization. + */ + connectionPolicyConfigured: boolean; + /** + * `consistencyLevel` supplied during client initialization. + */ + consistencyLevel?: keyof typeof ConsistencyLevel; + /** + * `defaultHeaders` supplied during client initialization. + */ + defaultHeaders?: { + [key: string]: any; + }; + /** + * True if `connectionPolicy` were supplied during client initialization. + */ + agentConfigured: boolean; + /** + * `userAgentSuffix` supplied during client initialization. + */ + userAgentSuffix: string; + /** + * `diagnosticLevel` supplied during client initialization. + */ + diagnosticLevel?: CosmosDbDiagnosticLevel; + /** + * True if `plugins` were supplied during client initialization. + */ + pluginsConfigured: boolean; + /** + * SDK version + */ + sDKVersion: string; +}; + +/** + * @hidden + * @hidden + */ +export declare class ClientContext { + private cosmosClientOptions; + private globalEndpointManager; + private clientConfig; + diagnosticLevel: CosmosDbDiagnosticLevel; + private readonly sessionContainer; + private connectionPolicy; + private pipeline; + private diagnosticWriter; + private diagnosticFormatter; + partitionKeyDefinitionCache: { + [containerUrl: string]: any; + }; + constructor(cosmosClientOptions: CosmosClientOptions, globalEndpointManager: GlobalEndpointManager, clientConfig: ClientConfigDiagnostic, diagnosticLevel: CosmosDbDiagnosticLevel); + /** @hidden */ + read({ path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + queryFeed({ path, resourceType, resourceId, resultFn, query, options, diagnosticNode, partitionKeyRangeId, partitionKey, startEpk, endEpk, }: { + path: string; + resourceType: ResourceType; + resourceId: string; + resultFn: (result: { + [key: string]: any; + }) => any[]; + query: SqlQuerySpec | string; + options: FeedOptions; + diagnosticNode: DiagnosticNodeInternal; + partitionKeyRangeId?: string; + partitionKey?: PartitionKey; + startEpk?: string | undefined; + endEpk?: string | undefined; + }): Promise>; + getQueryPlan(path: string, resourceType: ResourceType, resourceId: string, query: SqlQuerySpec | string, options: FeedOptions, diagnosticNode: DiagnosticNodeInternal): Promise>; + queryPartitionKeyRanges(collectionLink: string, query?: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + delete({ path, resourceType, resourceId, options, partitionKey, method, diagnosticNode, }: { + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + method?: HTTPMethod; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + patch({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + body: any; + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + create({ body, path, resourceType, resourceId, diagnosticNode, options, partitionKey, }: { + body: T; + path: string; + resourceType: ResourceType; + resourceId: string; + diagnosticNode: DiagnosticNodeInternal; + options?: RequestOptions; + partitionKey?: PartitionKey; + }): Promise>; + private processQueryFeedResponse; + private applySessionToken; + replace({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + body: any; + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + upsert({ body, path, resourceType, resourceId, options, partitionKey, diagnosticNode, }: { + body: T; + path: string; + resourceType: ResourceType; + resourceId: string; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + execute({ sprocLink, params, options, partitionKey, diagnosticNode, }: { + sprocLink: string; + params?: any[]; + options?: RequestOptions; + partitionKey?: PartitionKey; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + /** + * Gets the Database account information. + * @param options - `urlConnection` in the options is the endpoint url whose database account needs to be retrieved. + * If not present, current client's url will be used. + */ + getDatabaseAccount(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise>; + getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + getWriteEndpoints(): Promise; + getReadEndpoints(): Promise; + batch({ body, path, partitionKey, resourceId, options, diagnosticNode, }: { + body: T; + path: string; + partitionKey: PartitionKey; + resourceId: string; + options?: RequestOptions; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + bulk({ body, path, partitionKeyRangeId, resourceId, bulkOptions, options, diagnosticNode, }: { + body: T; + path: string; + partitionKeyRangeId: string; + resourceId: string; + bulkOptions?: BulkOptions; + options?: RequestOptions; + diagnosticNode: DiagnosticNodeInternal; + }): Promise>; + private captureSessionToken; + clearSessionToken(path: string): void; + recordDiagnostics(diagnostic: CosmosDiagnostics): void; + initializeDiagnosticSettings(diagnosticLevel: CosmosDbDiagnosticLevel): void; + private getSessionParams; + private isMasterResource; + private buildHeaders; + /** + * Returns collection of properties which are derived from the context for Request Creation. + * These properties have client wide scope, as opposed to request specific scope. + * @returns + */ + private getContextDerivedPropsForRequestCreation; + getClientConfig(): ClientConfigDiagnostic; +} + +export declare class ClientSideMetrics { + readonly requestCharge: number; + constructor(requestCharge: number); + /** + * Adds one or more ClientSideMetrics to a copy of this instance and returns the result. + */ + add(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics; + static readonly zero: ClientSideMetrics; + static createFromArray(...clientSideMetricsArray: ClientSideMetrics[]): ClientSideMetrics; +} + +/** + * This is a collection type for all client side diagnostic information. + */ +export declare type ClientSideRequestStatistics = { + /** + * This is the UTC timestamp for start of client operation. + */ + requestStartTimeUTCInMs: number; + /** + * This is the duration in milli seconds taken by client operation. + */ + requestDurationInMs: number; + /** + * This is the list of Location Endpoints contacted during the client operation. + */ + locationEndpointsContacted: string[]; + /** + * This field captures diagnostic information for retries happened during client operation. + */ + retryDiagnostics: RetryDiagnostics; + /** + * This field captures diagnostic information for meta data lookups happened during client operation. + */ + metadataDiagnostics: MetadataLookUpDiagnostics; + /** + * These are the statistics for main point look operation. + */ + gatewayStatistics: GatewayStatistics[]; + /** + * This is the cumulated Request Payload Length n bytes, this includes metadata calls along with the main operation. + */ + totalRequestPayloadLengthInBytes: number; + /** + * This is the cumulated Response Payload Length n bytes, this includes metadata calls along with the main operation. + */ + totalResponsePayloadLengthInBytes: number; +}; + +/** + * Use to read or delete a given {@link Conflict} by id. + * + * @see {@link Conflicts} to query or read all conflicts. + */ +export declare class Conflict { + readonly container: Container; + readonly id: string; + private readonly clientContext; + private partitionKey?; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Conflict}. + */ + constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey); + /** + * Read the {@link ConflictDefinition} for the given {@link Conflict}. + */ + read(options?: RequestOptions): Promise; + /** + * Delete the given {@link ConflictDefinition}. + */ + delete(options?: RequestOptions): Promise; +} + +export declare interface ConflictDefinition { + /** The id of the conflict */ + id?: string; + /** Source resource id */ + resourceId?: string; + resourceType?: ResourceType; + operationType?: OperationType; + content?: string; +} + +export declare enum ConflictResolutionMode { + Custom = "Custom", + LastWriterWins = "LastWriterWins" +} + +/** + * Represents the conflict resolution policy configuration for specifying how to resolve conflicts + * in case writes from different regions result in conflicts on documents in the collection in the Azure Cosmos DB service. + */ +export declare interface ConflictResolutionPolicy { + /** + * Gets or sets the in the Azure Cosmos DB service. By default it is {@link ConflictResolutionMode.LastWriterWins}. + */ + mode?: keyof typeof ConflictResolutionMode; + /** + * Gets or sets the path which is present in each document in the Azure Cosmos DB service for last writer wins conflict-resolution. + * This path must be present in each document and must be an integer value. + * In case of a conflict occurring on a document, the document with the higher integer value in the specified path will be picked. + * If the path is unspecified, by default the timestamp path will be used. + * + * This value should only be set when using {@link ConflictResolutionMode.LastWriterWins}. + * + * ```typescript + * conflictResolutionPolicy.ConflictResolutionPath = "/name/first"; + * ``` + * + */ + conflictResolutionPath?: string; + /** + * Gets or sets the {@link StoredProcedure} which is used for conflict resolution in the Azure Cosmos DB service. + * This stored procedure may be created after the {@link Container} is created and can be changed as required. + * + * 1. This value should only be set when using {@link ConflictResolutionMode.Custom}. + * 2. In case the stored procedure fails or throws an exception, the conflict resolution will default to registering conflicts in the conflicts feed. + * + * ```typescript + * conflictResolutionPolicy.ConflictResolutionProcedure = "resolveConflict" + * ``` + */ + conflictResolutionProcedure?: string; +} + +export declare class ConflictResponse extends ResourceResponse { + constructor(resource: ConflictDefinition & Resource, headers: CosmosHeaders, statusCode: number, conflict: Conflict, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Conflict} corresponding to the returned {@link ConflictDefinition}. */ + readonly conflict: Conflict; +} + +/** + * Use to query or read all conflicts. + * + * @see {@link Conflict} to read or delete a given {@link Conflict} by id. + */ +export declare class Conflicts { + readonly container: Container; + private readonly clientContext; + constructor(container: Container, clientContext: ClientContext); + /** + * Queries all conflicts. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time. + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all conflicts. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return results in an array or iterate over them one at a time. + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Reads all conflicts + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + readAll(options?: FeedOptions): QueryIterator; + } + + /** Determines the connection behavior of the CosmosClient. Note, we currently only support Gateway Mode. */ + export declare enum ConnectionMode { + /** Gateway mode talks to an intermediate gateway which handles the direct communication with your individual partitions. */ + Gateway = 0 + } + + /** + * Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service. + */ + export declare interface ConnectionPolicy { + /** Determines which mode to connect to Cosmos with. (Currently only supports Gateway option) */ + connectionMode?: ConnectionMode; + /** Request timeout (time to wait for response from network peer). Represented in milliseconds. */ + requestTimeout?: number; + /** + * Flag to enable/disable automatic redirecting of requests based on read/write operations. Default true. + * Required to call client.dispose() when this is set to true after destroying the CosmosClient inside another process or in the browser. + */ + enableEndpointDiscovery?: boolean; + /** List of azure regions to be used as preferred locations for read requests. */ + preferredLocations?: string[]; + /** RetryOptions object which defines several configurable properties used during retry. */ + retryOptions?: RetryOptions; + /** + * The flag that enables writes on any locations (regions) for geo-replicated database accounts in the Azure Cosmos DB service. + * Default is `false`. + */ + useMultipleWriteLocations?: boolean; + /** Rate in milliseconds at which the client will refresh the endpoints list in the background */ + endpointRefreshRateInMs?: number; + /** Flag to enable/disable background refreshing of endpoints. Defaults to false. + * Endpoint discovery using `enableEndpointsDiscovery` will still work for failed requests. */ + enableBackgroundEndpointRefreshing?: boolean; + } + + /** + * Represents the consistency levels supported for Azure Cosmos DB client operations.
+ * The requested ConsistencyLevel must match or be weaker than that provisioned for the database account. + * Consistency levels. + * + * Consistency levels by order of strength are Strong, BoundedStaleness, Session, Consistent Prefix, and Eventual. + * + * See https://aka.ms/cosmos-consistency for more detailed documentation on Consistency Levels. + */ + export declare enum ConsistencyLevel { + /** + * Strong Consistency guarantees that read operations always return the value that was last written. + */ + Strong = "Strong", + /** + * Bounded Staleness guarantees that reads are not too out-of-date. + * This can be configured based on number of operations (MaxStalenessPrefix) or time (MaxStalenessIntervalInSeconds). + */ + BoundedStaleness = "BoundedStaleness", + /** + * Session Consistency guarantees monotonic reads (you never read old data, then new, then old again), + * monotonic writes (writes are ordered) and read your writes (your writes are immediately visible to your reads) + * within any single session. + */ + Session = "Session", + /** + * Eventual Consistency guarantees that reads will return a subset of writes. + * All writes will be eventually be available for reads. + */ + Eventual = "Eventual", + /** + * ConsistentPrefix Consistency guarantees that reads will return some prefix of all writes with no gaps. + * All writes will be eventually be available for reads. + */ + ConsistentPrefix = "ConsistentPrefix" + } + + /** + * @hidden + */ + export declare const Constants: { + HttpHeaders: { + Authorization: string; + ETag: string; + MethodOverride: string; + Slug: string; + ContentType: string; + LastModified: string; + ContentEncoding: string; + CharacterSet: string; + UserAgent: string; + IfModifiedSince: string; + IfMatch: string; + IfNoneMatch: string; + ContentLength: string; + AcceptEncoding: string; + KeepAlive: string; + CacheControl: string; + TransferEncoding: string; + ContentLanguage: string; + ContentLocation: string; + ContentMd5: string; + ContentRange: string; + Accept: string; + AcceptCharset: string; + AcceptLanguage: string; + IfRange: string; + IfUnmodifiedSince: string; + MaxForwards: string; + ProxyAuthorization: string; + AcceptRanges: string; + ProxyAuthenticate: string; + RetryAfter: string; + SetCookie: string; + WwwAuthenticate: string; + Origin: string; + Host: string; + AccessControlAllowOrigin: string; + AccessControlAllowHeaders: string; + KeyValueEncodingFormat: string; + WrapAssertionFormat: string; + WrapAssertion: string; + WrapScope: string; + SimpleToken: string; + HttpDate: string; + Prefer: string; + Location: string; + Referer: string; + A_IM: string; + Query: string; + IsQuery: string; + IsQueryPlan: string; + SupportedQueryFeatures: string; + QueryVersion: string; + Continuation: string; + ContinuationToken: string; + PageSize: string; + ItemCount: string; + ActivityId: string; + PreTriggerInclude: string; + PreTriggerExclude: string; + PostTriggerInclude: string; + PostTriggerExclude: string; + IndexingDirective: string; + SessionToken: string; + ConsistencyLevel: string; + XDate: string; + CollectionPartitionInfo: string; + CollectionServiceInfo: string; + RetryAfterInMilliseconds: string; + RetryAfterInMs: string; + IsFeedUnfiltered: string; + ResourceTokenExpiry: string; + EnableScanInQuery: string; + EmitVerboseTracesInQuery: string; + EnableCrossPartitionQuery: string; + ParallelizeCrossPartitionQuery: string; + ResponseContinuationTokenLimitInKB: string; + PopulateQueryMetrics: string; + QueryMetrics: string; + PopulateIndexMetrics: string; + IndexUtilization: string; + Version: string; + OwnerFullName: string; + OwnerId: string; + PartitionKey: string; + PartitionKeyRangeID: string; + StartEpk: string; + EndEpk: string; + ReadFeedKeyType: string; + MaxEntityCount: string; + CurrentEntityCount: string; + CollectionQuotaInMb: string; + CollectionCurrentUsageInMb: string; + MaxMediaStorageUsageInMB: string; + CurrentMediaStorageUsageInMB: string; + RequestCharge: string; + PopulateQuotaInfo: string; + MaxResourceQuota: string; + OfferType: string; + OfferThroughput: string; + AutoscaleSettings: string; + DisableRUPerMinuteUsage: string; + IsRUPerMinuteUsed: string; + OfferIsRUPerMinuteThroughputEnabled: string; + IndexTransformationProgress: string; + LazyIndexingProgress: string; + IsUpsert: string; + SubStatus: string; + EnableScriptLogging: string; + ScriptLogResults: string; + ALLOW_MULTIPLE_WRITES: string; + IsBatchRequest: string; + IsBatchAtomic: string; + BatchContinueOnError: string; + DedicatedGatewayPerRequestCacheStaleness: string; + ForceRefresh: string; + PriorityLevel: string; + }; + WritableLocations: string; + ReadableLocations: string; + LocationUnavailableExpirationTimeInMs: number; + ENABLE_MULTIPLE_WRITABLE_LOCATIONS: string; + DefaultUnavailableLocationExpirationTimeMS: number; + ThrottleRetryCount: string; + ThrottleRetryWaitTimeInMs: string; + CurrentVersion: string; + AzureNamespace: string; + AzurePackageName: string; + SDKName: string; + SDKVersion: string; + CosmosDbDiagnosticLevelEnvVarName: string; + DefaultMaxBulkRequestBodySizeInBytes: number; + Quota: { + CollectionSize: string; + }; + Path: { + Root: string; + DatabasesPathSegment: string; + CollectionsPathSegment: string; + UsersPathSegment: string; + DocumentsPathSegment: string; + PermissionsPathSegment: string; + StoredProceduresPathSegment: string; + TriggersPathSegment: string; + UserDefinedFunctionsPathSegment: string; + ConflictsPathSegment: string; + AttachmentsPathSegment: string; + PartitionKeyRangesPathSegment: string; + SchemasPathSegment: string; + OffersPathSegment: string; + TopologyPathSegment: string; + DatabaseAccountPathSegment: string; + }; + PartitionKeyRange: PartitionKeyRangePropertiesNames; + QueryRangeConstants: { + MinInclusive: string; + MaxExclusive: string; + min: string; + }; + /** + * @deprecated Use EffectivePartitionKeyConstants instead + */ + EffectiveParitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: string; + MaximumExclusiveEffectivePartitionKey: string; + }; + EffectivePartitionKeyConstants: { + MinimumInclusiveEffectivePartitionKey: string; + MaximumExclusiveEffectivePartitionKey: string; + }; + NonStreamingQueryDefaultRUThreshold: number; + }; + + /** + * Operations for reading, replacing, or deleting a specific, existing container by id. + * + * @see {@link Containers} for creating new containers, and reading/querying all containers; use `.containers`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `container(id).read()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ + export declare class Container { + readonly database: Database; + readonly id: string; + private readonly clientContext; + private $items; + /** + * Operations for creating new items, and reading/querying all items + * + * For reading, replacing, or deleting an existing item, use `.item(id)`. + * + * @example Create a new item + * ```typescript + * const {body: createdItem} = await container.items.create({id: "", properties: {}}); + * ``` + */ + get items(): Items; + private $scripts; + /** + * All operations for Stored Procedures, Triggers, and User Defined Functions + */ + get scripts(): Scripts; + private $conflicts; + /** + * Operations for reading and querying conflicts for the given container. + * + * For reading or deleting a specific conflict, use `.conflict(id)`. + */ + get conflicts(): Conflicts; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * Returns a container instance. Note: You should get this from `database.container(id)`, rather than creating your own object. + * @param database - The parent {@link Database}. + * @param id - The id of the given container. + * @hidden + */ + constructor(database: Database, id: string, clientContext: ClientContext); + /** + * Used to read, replace, or delete a specific, existing {@link Item} by id. + * + * Use `.items` for creating new items, or querying/reading all items. + * + * @param id - The id of the {@link Item}. + * @param partitionKeyValue - The value of the {@link Item} partition key + * @example Replace an item + * `const {body: replacedItem} = await container.item("", "").replace({id: "", title: "Updated post", authorID: 5});` + */ + item(id: string, partitionKeyValue?: PartitionKey): Item; + /** + * Used to read, replace, or delete a specific, existing {@link Conflict} by id. + * + * Use `.conflicts` for creating new conflicts, or querying/reading all conflicts. + * @param id - The id of the {@link Conflict}. + */ + conflict(id: string, partitionKey?: PartitionKey): Conflict; + /** Read the container's definition */ + read(options?: RequestOptions): Promise; + /** + * @hidden + */ + readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise; + /** Replace the container's definition */ + replace(body: ContainerDefinition, options?: RequestOptions): Promise; + /** Delete the container */ + delete(options?: RequestOptions): Promise; + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @deprecated This method has been renamed to readPartitionKeyDefinition. + */ + getPartitionKeyDefinition(): Promise>; + /** + * Gets the partition key definition first by looking into the cache otherwise by reading the collection. + * @hidden + */ + readPartitionKeyDefinition(diagnosticNode: DiagnosticNodeInternal): Promise>; + /** + * Gets offer on container. If none exists, returns an OfferResponse with undefined. + */ + readOffer(options?: RequestOptions): Promise; + getQueryPlan(query: string | SqlQuerySpec): Promise>; + readPartitionKeyRanges(feedOptions?: FeedOptions): QueryIterator; + /** + * + * @returns all the feed ranges for which changefeed could be fetched. + */ + getFeedRanges(): Promise>; + /** + * Delete all documents belong to the container for the provided partition key value + * @param partitionKey - The partition key value of the items to be deleted + */ + deleteAllItemsForPartitionKey(partitionKey: PartitionKey, options?: RequestOptions): Promise; + } + + export declare interface ContainerDefinition { + /** The id of the container. */ + id?: string; + /** The partition key for the container. */ + partitionKey?: PartitionKeyDefinition; + /** The indexing policy associated with the container. */ + indexingPolicy?: IndexingPolicy; + /** The default time to live in seconds for items in a container. */ + defaultTtl?: number; + /** The conflict resolution policy used to resolve conflicts in a container. */ + conflictResolutionPolicy?: ConflictResolutionPolicy; + /** Policy for additional keys that must be unique per partition key */ + uniqueKeyPolicy?: UniqueKeyPolicy; + /** Geospatial configuration for a collection. Type is set to Geography by default */ + geospatialConfig?: { + type: GeospatialType; + }; + /** The vector embedding policy information for storing items in a container. */ + vectorEmbeddingPolicy?: VectorEmbeddingPolicy; + } + + export declare interface ContainerRequest extends VerboseOmit { + throughput?: number; + maxThroughput?: number; + autoUpgradePolicy?: { + throughputPolicy: { + incrementPercent: number; + }; + }; + partitionKey?: string | PartitionKeyDefinition; + } + + /** Response object for Container operations */ + export declare class ContainerResponse extends ResourceResponse { + constructor(resource: ContainerDefinition & Resource, headers: CosmosHeaders, statusCode: number, container: Container, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Container} that the returned {@link ContainerDefinition} corresponds to. */ + readonly container: Container; + } + + /** + * Operations for creating new containers, and reading/querying all containers + * + * @see {@link Container} for reading, replacing, or deleting an existing container; use `.container(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `containers.readAll()` before every single `item.read()` call, to ensure the container exists; + * do this once on application start up. + */ + export declare class Containers { + readonly database: Database; + private readonly clientContext; + constructor(database: Database, clientContext: ClientContext); + /** + * Queries all containers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @container", + * parameters: [ + * {name: "@container", value: "Todo"} + * ] + * }; + * const {body: containerList} = await client.database("").containers.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all containers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return specific containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @container", + * parameters: [ + * {name: "@container", value: "Todo"} + * ] + * }; + * const {body: containerList} = await client.database("").containers.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Creates a container. + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + create(body: ContainerRequest, options?: RequestOptions): Promise; + /** + * @hidden + */ + createInternal(diagnosticNode: DiagnosticNodeInternal, body: ContainerRequest, options?: RequestOptions): Promise; + /** + * Checks if a Container exists, and, if it doesn't, creates it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * You should confirm that the output matches the body you passed in for non-default properties (i.e. indexing policy/etc.) + * + * A container is a named logical container for items. + * + * A database may contain zero or more named containers and each container consists of + * zero or more JSON items. + * + * Being schema-free, the items in a container do not need to share the same structure or fields. + * + * + * Since containers are application resources, they can be authorized using either the + * master key or resource keys. + * + * @param body - Represents the body of the container. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + createIfNotExists(body: ContainerRequest, options?: RequestOptions): Promise; + /** + * Read all containers. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all containers in an array or iterate over them one at a time. + * @example Read all containers to array. + * ```typescript + * const {body: containerList} = await client.database("").containers.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + } + + /** + * Provides a client-side logical representation of the Azure Cosmos DB database account. + * This client is used to configure and execute requests in the Azure Cosmos DB database service. + * @example Instantiate a client and create a new database + * ```typescript + * const client = new CosmosClient({endpoint: "", auth: {masterKey: ""}}); + * await client.databases.create({id: ""}); + * ``` + * @example Instantiate a client with custom Connection Policy + * ```typescript + * const connectionPolicy = new ConnectionPolicy(); + * connectionPolicy.RequestTimeout = 10000; + * const client = new CosmosClient({ + * endpoint: "", + * auth: {masterKey: ""}, + * connectionPolicy + * }); + * ``` + */ + export declare class CosmosClient { + /** + * Used for creating new databases, or querying/reading all databases. + * + * Use `.database(id)` to read, replace, or delete a specific, existing database by id. + * + * @example Create a new database + * ```typescript + * const {resource: databaseDefinition, database} = await client.databases.create({id: ""}); + * ``` + */ + readonly databases: Databases; + /** + * Used for querying & reading all offers. + * + * Use `.offer(id)` to read, or replace existing offers. + */ + readonly offers: Offers; + private clientContext; + private endpointRefresher; + /** + * Creates a new {@link CosmosClient} object from a connection string. Your database connection string can be found in the Azure Portal + */ + constructor(connectionString: string); + /** + * Creates a new {@link CosmosClient} object. See {@link CosmosClientOptions} for more details on what options you can use. + * @param options - bag of options; require at least endpoint and auth to be configured + */ + constructor(options: CosmosClientOptions); + private initializeClientConfigDiagnostic; + /** + * Get information about the current {@link DatabaseAccount} (including which regions are supported, etc.) + */ + getDatabaseAccount(options?: RequestOptions): Promise>; + /** + * @hidden + */ + getDatabaseAccountInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise>; + /** + * Gets the currently used write endpoint url. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getWriteEndpoint(): Promise; + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getReadEndpoint(): Promise; + /** + * Gets the known write endpoints. Useful for troubleshooting purposes. + * + * The urls may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getWriteEndpoints(): Promise; + /** + * Gets the currently used read endpoint. Useful for troubleshooting purposes. + * + * The url may contain a region suffix (e.g. "-eastus") if we're using location specific endpoints. + */ + getReadEndpoints(): Promise; + /** + * Used for reading, updating, or deleting a existing database by id or accessing containers belonging to that database. + * + * This does not make a network call. Use `.read` to get info about the database after getting the {@link Database} object. + * + * @param id - The id of the database. + * @example Create a new container off of an existing database + * ```typescript + * const container = client.database("").containers.create(""); + * ``` + * + * @example Delete an existing database + * ```typescript + * await client.database("").delete(); + * ``` + */ + database(id: string): Database; + /** + * Used for reading, or updating a existing offer by id. + * @param id - The id of the offer. + */ + offer(id: string): Offer; + /** + * Clears background endpoint refresher. Use client.dispose() when destroying the CosmosClient within another process. + */ + dispose(): void; + private backgroundRefreshEndpointList; + } + + export declare interface CosmosClientOptions { + /** The service endpoint to use to create the client. */ + endpoint: string; + /** The account master or readonly key */ + key?: string; + /** An object that contains resources tokens. + * Keys for the object are resource Ids and values are the resource tokens. + */ + resourceTokens?: { + [resourcePath: string]: string; + }; + /** A user supplied function for resolving header authorization tokens. + * Allows users to generating their own auth tokens, potentially using a separate service + */ + tokenProvider?: TokenProvider; + /** AAD token from `@azure/identity` + * Obtain a credential object by creating an `@azure/identity` credential object + * We will then use your credential object and a scope URL (your cosmos db endpoint) + * to authenticate requests to Cosmos + */ + aadCredentials?: TokenCredential; + /** An array of {@link Permission} objects. */ + permissionFeed?: PermissionDefinition[]; + /** An instance of {@link ConnectionPolicy} class. + * This parameter is optional and the default connectionPolicy will be used if omitted. + */ + connectionPolicy?: ConnectionPolicy; + /** An optional parameter that represents the consistency level. + * It can take any value from {@link ConsistencyLevel}. + */ + consistencyLevel?: keyof typeof ConsistencyLevel; + defaultHeaders?: CosmosHeaders_2; + /** An optional custom http(s) Agent to be used in NodeJS enironments + * Use an agent such as https://github.com/TooTallNate/node-proxy-agent if you need to connect to Cosmos via a proxy + */ + agent?: Agent; + /** A custom string to append to the default SDK user agent. */ + userAgentSuffix?: string; + diagnosticLevel?: CosmosDbDiagnosticLevel; + } + + /** + * @hidden + */ + declare enum CosmosContainerChildResourceKind { + Item = "ITEM", + StoredProcedure = "STORED_PROCEDURE", + UserDefinedFunction = "USER_DEFINED_FUNCTION", + Trigger = "TRIGGER" + } + + /** + * Cosmos DB Diagnostic Level + */ + export declare enum CosmosDbDiagnosticLevel { + info = "info", + debug = "debug", + debugUnsafe = "debug-unsafe" + } + + /** + * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create(). + * It has three members - + * 1. `clientSideRequestStatistics` member contains aggregate diagnostic information, including - + * - metadata lookups. Here all the server requests, apart from the final intended resource are considered as metadata calls. + * i.e. for item.read(id), if the client makes server call to discover endpoints it would be considered as metadata call. + * - retries + * - endpoints contacted. + * - request, response payload stats. + * - gatewayStatistics - Information corresponding to main operation. For example during Item.read(), the client might perform many operations + * i.e. metadata lookup etc, but gatewayStatistics represents the diagnostics information for actual read operation. + * + * 2. diagnosticNode - Is a tree like structure which captures detailed diagnostic information. By default it is disabled, and is intended to be + * used only for debugging on non production environments. The kind of details captured in diagnosticNode is controlled by `CosmosDbDiagnosticLevel`. + * - CosmosDbDiagnosticLevel.info - Is default value. In this level only clientSideRequestStatistics are captured. Is is meant for production environments. + * - CosmosDbDiagnosticLevel.debug - Captures diagnosticNode and clientConfig. No request and response payloads are captured. Is not meant to be used + * in production environment. + * - CosmosDbDiagnosticLevel.debug-unsafe - In addition to data captured in CosmosDbDiagnosticLevel.debug, also captures request and response payloads. + * Is not meant to be used in production environment. + * 3. clientConfig - Captures information related to how client was configured during initialization. + */ + export declare class CosmosDiagnostics { + readonly clientSideRequestStatistics: ClientSideRequestStatistics; + readonly diagnosticNode: DiagnosticNode; + readonly clientConfig?: ClientConfigDiagnostic; + } + + export declare interface CosmosHeaders { + [key: string]: any; + } + + declare interface CosmosHeaders_2 { + [key: string]: string | boolean | number; + } + + /** + * @hidden + */ + declare enum CosmosKeyType { + PrimaryMaster = "PRIMARY_MASTER", + SecondaryMaster = "SECONDARY_MASTER", + PrimaryReadOnly = "PRIMARY_READONLY", + SecondaryReadOnly = "SECONDARY_READONLY" + } + + /** + * Experimental internal only + * Generates the payload representing the permission configuration for the sas token. + */ + export declare function createAuthorizationSasToken(masterKey: string, sasTokenProperties: SasTokenProperties): Promise; + + export declare type CreateOperation = OperationWithItem & { + operationType: typeof BulkOperationType.Create; + }; + + export declare interface CreateOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Create; + resourceBody: JSONObject; + } + + /** + * Operations for reading or deleting an existing database. + * + * @see {@link Databases} for creating new databases, and reading/querying all databases; use `client.databases`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `database.read()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ + export declare class Database { + readonly client: CosmosClient; + readonly id: string; + private clientContext; + /** + * Used for creating new containers, or querying/reading all containers. + * + * Use `.database(id)` to read, replace, or delete a specific, existing {@link Database} by id. + * + * @example Create a new container + * ```typescript + * const {body: containerDefinition, container} = await client.database("").containers.create({id: ""}); + * ``` + */ + readonly containers: Containers; + /** + * Used for creating new users, or querying/reading all users. + * + * Use `.user(id)` to read, replace, or delete a specific, existing {@link User} by id. + */ + readonly users: Users; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** Returns a new {@link Database} instance. + * + * Note: the intention is to get this object from {@link CosmosClient} via `client.database(id)`, not to instantiate it yourself. + */ + constructor(client: CosmosClient, id: string, clientContext: ClientContext); + /** + * Used to read, replace, or delete a specific, existing {@link Database} by id. + * + * Use `.containers` creating new containers, or querying/reading all containers. + * + * @example Delete a container + * ```typescript + * await client.database("").container("").delete(); + * ``` + */ + container(id: string): Container; + /** + * Used to read, replace, or delete a specific, existing {@link User} by id. + * + * Use `.users` for creating new users, or querying/reading all users. + */ + user(id: string): User; + /** Read the definition of the given Database. */ + read(options?: RequestOptions): Promise; + /** + * @hidden + */ + readInternal(diagnosticNode: DiagnosticNodeInternal, options?: RequestOptions): Promise; + /** Delete the given Database. */ + delete(options?: RequestOptions): Promise; + /** + * Gets offer on database. If none exists, returns an OfferResponse with undefined. + */ + readOffer(options?: RequestOptions): Promise; + } + + /** + * Represents a DatabaseAccount in the Azure Cosmos DB database service. + */ + export declare class DatabaseAccount { + /** The list of writable locations for a geo-replicated database account. */ + readonly writableLocations: Location_2[]; + /** The list of readable locations for a geo-replicated database account. */ + readonly readableLocations: Location_2[]; + /** + * The self-link for Databases in the databaseAccount. + * @deprecated Use `databasesLink` + */ + get DatabasesLink(): string; + /** The self-link for Databases in the databaseAccount. */ + readonly databasesLink: string; + /** + * The self-link for Media in the databaseAccount. + * @deprecated Use `mediaLink` + */ + get MediaLink(): string; + /** The self-link for Media in the databaseAccount. */ + readonly mediaLink: string; + /** + * Attachment content (media) storage quota in MBs ( Retrieved from gateway ). + * @deprecated use `maxMediaStorageUsageInMB` + */ + get MaxMediaStorageUsageInMB(): number; + /** Attachment content (media) storage quota in MBs ( Retrieved from gateway ). */ + readonly maxMediaStorageUsageInMB: number; + /** + * Current attachment content (media) usage in MBs (Retrieved from gateway ) + * + * Value is returned from cached information updated periodically and is not guaranteed + * to be real time. + * + * @deprecated use `currentMediaStorageUsageInMB` + */ + get CurrentMediaStorageUsageInMB(): number; + /** + * Current attachment content (media) usage in MBs (Retrieved from gateway ) + * + * Value is returned from cached information updated periodically and is not guaranteed + * to be real time. + */ + readonly currentMediaStorageUsageInMB: number; + /** + * Gets the UserConsistencyPolicy settings. + * @deprecated use `consistencyPolicy` + */ + get ConsistencyPolicy(): ConsistencyLevel; + /** Gets the UserConsistencyPolicy settings. */ + readonly consistencyPolicy: ConsistencyLevel; + readonly enableMultipleWritableLocations: boolean; + constructor(body: { + [key: string]: any; + }, headers: CosmosHeaders); + } + + export declare interface DatabaseDefinition { + /** The id of the database. */ + id?: string; + } + + export declare interface DatabaseRequest extends DatabaseDefinition { + /** Throughput for this database. */ + throughput?: number; + maxThroughput?: number; + autoUpgradePolicy?: { + throughputPolicy: { + incrementPercent: number; + }; + }; + } + + /** Response object for Database operations */ + export declare class DatabaseResponse extends ResourceResponse { + constructor(resource: DatabaseDefinition & Resource, headers: CosmosHeaders, statusCode: number, database: Database, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Database} that the returned {@link DatabaseDefinition} corresponds to. */ + readonly database: Database; + } + + /** + * Operations for creating new databases, and reading/querying all databases + * + * @see {@link Database} for reading or deleting an existing database; use `client.database(id)`. + * + * Note: all these operations make calls against a fixed budget. + * You should design your system such that these calls scale sublinearly with your application. + * For instance, do not call `databases.readAll()` before every single `item.read()` call, to ensure the database exists; + * do this once on application start up. + */ + export declare class Databases { + readonly client: CosmosClient; + private readonly clientContext; + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database. + */ + constructor(client: CosmosClient, clientContext: ClientContext); + /** + * Queries all databases. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @db", + * parameters: [ + * {name: "@db", value: "Todo"} + * ] + * }; + * const {body: databaseList} = await client.databases.query(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all databases. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @db", + * parameters: [ + * {name: "@db", value: "Todo"} + * ] + * }; + * const {body: databaseList} = await client.databases.query(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Send a request for creating a database. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Use to set options like response page size, continuation tokens, etc. + */ + create(body: DatabaseRequest, options?: RequestOptions): Promise; + /** + * @hidden + */ + createInternal(diagnosticNode: DiagnosticNodeInternal, body: DatabaseRequest, options?: RequestOptions): Promise; + /** + * Check if a database exists, and if it doesn't, create it. + * This will make a read operation based on the id in the `body`, then if it is not found, a create operation. + * + * A database manages users, permissions and a set of containers. + * Each Azure Cosmos DB Database Account is able to support multiple independent named databases, + * with the database being the logical container for data. + * + * Each Database consists of one or more containers, each of which in turn contain one or more + * documents. Since databases are an an administrative resource, the Service Master Key will be + * required in order to access and successfully complete any action using the User APIs. + * + * @param body - The {@link DatabaseDefinition} that represents the {@link Database} to be created. + * @param options - Additional options for the request + */ + createIfNotExists(body: DatabaseRequest, options?: RequestOptions): Promise; + /** + * Reads all databases. + * @param options - Use to set options like response page size, continuation tokens, etc. + * @returns {@link QueryIterator} Allows you to return all databases in an array or iterate over them one at a time. + * @example Read all databases to array. + * ```typescript + * const {body: databaseList} = await client.databases.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + } + + /** Defines a target data type of an index path specification in the Azure Cosmos DB service. */ + export declare enum DataType { + /** Represents a numeric data type. */ + Number = "Number", + /** Represents a string data type. */ + String = "String", + /** Represents a point data type. */ + Point = "Point", + /** Represents a line string data type. */ + LineString = "LineString", + /** Represents a polygon data type. */ + Polygon = "Polygon", + /** Represents a multi-polygon data type. */ + MultiPolygon = "MultiPolygon" + } + + export declare const DEFAULT_PARTITION_KEY_PATH: "/_partitionKey"; + + export declare type DeleteOperation = OperationBase & { + operationType: typeof BulkOperationType.Delete; + id: string; + }; + + export declare interface DeleteOperationInput { + partitionKey?: PartitionKey; + operationType: typeof BulkOperationType.Delete; + id: string; + } + + /** + * @hidden + */ + export declare type DiagnosticDataValue = { + selectedLocation: string; + activityId: string; + requestAttempNumber: number; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; + responseStatus: number; + readFromCache: boolean; + operationType: OperationType; + metadatOperationType: MetadataLookUpType; + resourceType: ResourceType; + failedAttempty: boolean; + successfulRetryPolicy: string; + partitionKeyRangeId: string; + stateful: boolean; + queryRecordsRead: number; + queryMethodIdentifier: string; + log: string[]; + failure: boolean; + startTimeUTCInMs: number; + durationInMs: number; + requestData: Partial<{ + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; + operationType: OperationType; + resourceType: ResourceType; + headers: CosmosHeaders_2; + requestBody: any; + responseBody: any; + url: string; + }>; + }; + + /** + * Represents a tree like structure, for capturing diagnostic information. + */ + export declare interface DiagnosticNode { + id: string; + nodeType: string; + children: DiagnosticNode[]; + data: { + [key: string]: any; + }; + startTimeUTCInMs: number; + durationInMs: number; + } + + /** + * @hidden + * This is Internal Representation for DiagnosticNode. It contains useful helper functions to collect + * diagnostic information throughout the lifetime of Diagnostic session. + * The functions toDiagnosticNode() & toDiagnostic() are given to convert it to public facing counterpart. + */ + export declare class DiagnosticNodeInternal implements DiagnosticNode { + id: string; + nodeType: DiagnosticNodeType; + parent: DiagnosticNodeInternal; + children: DiagnosticNodeInternal[]; + data: Partial; + startTimeUTCInMs: number; + durationInMs: number; + diagnosticLevel: CosmosDbDiagnosticLevel; + private diagnosticCtx; + } + + /** + * @hidden + */ + export declare enum DiagnosticNodeType { + CLIENT_REQUEST_NODE = "CLIENT_REQUEST_NODE", + METADATA_REQUEST_NODE = "METADATA_REQUEST_NODE", + HTTP_REQUEST = "HTTP_REQUEST", + BATCH_REQUEST = "BATCH_REQUEST", + PARALLEL_QUERY_NODE = "PARALLEL_QUERY_NODE", + DEFAULT_QUERY_NODE = "DEFAULT_QUERY_NODE", + QUERY_REPAIR_NODE = "QUERY_REPAIR_NODE", + BACKGROUND_REFRESH_THREAD = "BACKGROUND_REFRESH_THREAD", + REQUEST_ATTEMPTS = "REQUEST_ATTEMPTS" + } + + export declare interface ErrorBody { + code: string; + message: string; + /** + * @hidden + */ + additionalErrorInfo?: PartitionedQueryExecutionInfo; + } + + export declare class ErrorResponse extends Error { + code?: number | string; + substatus?: number; + body?: ErrorBody; + headers?: CosmosHeaders; + activityId?: string; + retryAfterInMs?: number; + retryAfterInMilliseconds?: number; + [key: string]: any; + diagnostics?: CosmosDiagnostics; + } + + export declare type ExistingKeyOperation = { + op: keyof typeof PatchOperationType; + value: any; + path: string; + }; + + /** + * This type captures diagnostic information regarding a failed request to server api. + */ + export declare interface FailedRequestAttemptDiagnostic { + attemptNumber: number; + activityId: string; + startTimeUTCInMs: number; + durationInMs: number; + operationType?: OperationType; + resourceType?: ResourceType; + statusCode: number; + substatusCode?: number; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; + } + + /** + * The feed options and query methods. + */ + export declare interface FeedOptions extends SharedOptions { + /** Opaque token for continuing the enumeration. Default: undefined + * @deprecated Use continuationToken instead. + */ + continuation?: string; + /** Opaque token for continuing the enumeration. Default: undefined */ + continuationToken?: string; + /** + * Limits the size of the continuation token in the response. Default: undefined + * + * Continuation Tokens contain optional data that can be removed from the serialization before writing it out to a header. + * By default we are capping this to 1kb to avoid long headers (Node.js has a global header size limit). + * A user may set this field to allow for longer headers, which can help the backend optimize query execution." + */ + continuationTokenLimitInKB?: number; + /** + * Allow scan on the queries which couldn't be served as indexing was opted out on the requested paths. Default: false + * + * In general, it is best to avoid using this setting. Scans are relatively expensive and take a long time to serve. + */ + enableScanInQuery?: boolean; + /** + * The maximum number of concurrent operations that run client side during parallel query execution in the + * Azure Cosmos DB database service. Negative values make the system automatically decides the number of + * concurrent operations to run. Default: 0 (no parallelism) + */ + maxDegreeOfParallelism?: number; + /** + * Max number of items to be returned in the enumeration operation. Default: undefined (server will defined payload) + * + * Expirimenting with this value can usually result in the biggest performance changes to the query. + * + * The smaller the item count, the faster the first result will be delivered (for non-aggregates). For larger amounts, + * it will take longer to serve the request, but you'll usually get better throughput for large queries (i.e. if you need 1000 items + * before you can do any other actions, set `maxItemCount` to 1000. If you can start doing work after the first 100, set `maxItemCount` to 100.) + */ + maxItemCount?: number; + /** + * Note: consider using changeFeed instead. + * + * Indicates a change feed request. Must be set to "Incremental feed", or omitted otherwise. Default: false + */ + useIncrementalFeed?: boolean; + /** Conditions Associated with the request. */ + accessCondition?: { + /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */ + type: string; + /** Conditional HTTP method header value (the _etag field from the last version you read). */ + condition: string; + }; + /** + * Enable returning query metrics in response headers. Default: false + * + * Used for debugging slow or expensive queries. Also increases response size and if you're using a low max header size in Node.js, + * you can run into issues faster. + */ + populateQueryMetrics?: boolean; + /** + * Enable buffering additional items during queries. Default: false + * + * This will buffer an additional page at a time (multiplied by maxDegreeOfParallelism) from the server in the background. + * This improves latency by fetching pages before they are needed by the client. If you're draining all of the results from the + * server, like `.fetchAll`, you should usually enable this. If you're only fetching one page at a time via continuation token, + * you should avoid this. If you're draining more than one page, but not the entire result set, it may help improve latency, but + * it will increase the total amount of RU/s use to serve the entire query (as some pages will be fetched more than once). + */ + bufferItems?: boolean; + /** + * This setting forces the query to use a query plan. Default: false + * + * Note: this will disable continuation token support, even for single partition queries. + * + * For queries like aggregates and most cross partition queries, this happens anyway. + * However, since the library doesn't know what type of query it is until we get back the first response, + * some optimization can't happen until later. + * + * If this setting is enabled, it will force query plan for the query, which will save some network requests + * and ensure parallelism can happen. Useful for when you know you're doing cross-partition or aggregate queries. + */ + forceQueryPlan?: boolean; + /** Limits the query to a specific partition key. Default: undefined + * + * Scoping a query to a single partition can be accomplished two ways: + * + * `container.items.query('SELECT * from c', { partitionKey: "foo" }).toArray()` + * `container.items.query('SELECT * from c WHERE c.yourPartitionKey = "foo"').toArray()` + * + * The former is useful when the query body is out of your control + * but you still want to restrict it to a single partition. Example: an end user specified query. + */ + partitionKey?: PartitionKey; + /** + * Enable returning index metrics in response headers. Default: false + */ + populateIndexMetrics?: boolean; + /** + * Specifies a custom maximum buffer size for storing final results for nonStreamingOrderBy queries. + * This value is ignored if the query includes top/offset+limit clauses. + */ + vectorSearchBufferSize?: number; + /** + * Disable the nonStreamingOrderBy query feature in supported query features. + * Default: false. Set to true to avoid error from an old gateway that doesn't support this feature. + */ + disableNonStreamingOrderByQuery?: boolean; + } + + /** + * Specifies a feed range for the changefeed. + */ + export declare abstract class FeedRange { + /** + * Min value for the feed range. + */ + readonly minInclusive: string; + /** + * Max value for the feed range. + */ + readonly maxExclusive: string; + } + + export declare class FeedResponse { + readonly resources: TResource[]; + private readonly headers; + readonly hasMoreResults: boolean; + readonly diagnostics: CosmosDiagnostics; + constructor(resources: TResource[], headers: CosmosHeaders, hasMoreResults: boolean, diagnostics: CosmosDiagnostics); + get continuation(): string; + get continuationToken(): string; + get queryMetrics(): string; + get requestCharge(): number; + get activityId(): string; + get indexMetrics(): string; + } + + /** @hidden */ + declare type FetchFunctionCallback = (diagnosticNode: DiagnosticNodeInternal, options: FeedOptions) => Promise>; + + export declare type GatewayStatistics = { + /** + * This is the activityId for request, made to server for fetching the requested resource. (As opposed to other potential meta data requests) + */ + activityId?: string; + startTimeUTCInMs: number; + durationInMs: number; + operationType?: OperationType; + resourceType?: ResourceType; + statusCode?: number; + subStatusCode?: number; + requestCharge?: number; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; + }; + + export declare enum GeospatialType { + /** Represents data in round-earth coordinate system. */ + Geography = "Geography", + /** Represents data in Eucledian(flat) coordinate system. */ + Geometry = "Geometry" + } + + /** + * @hidden + * This internal class implements the logic for endpoint management for geo-replicated database accounts. + */ + export declare class GlobalEndpointManager { + private readDatabaseAccount; + /** + * The endpoint used to create the client instance. + */ + private defaultEndpoint; + /** + * Flag to enable/disable automatic redirecting of requests based on read/write operations. + */ + enableEndpointDiscovery: boolean; + private isRefreshing; + private options; + /** + * List of azure regions to be used as preferred locations for read requests. + */ + private preferredLocations; + private writeableLocations; + private readableLocations; + private unavailableReadableLocations; + private unavailableWriteableLocations; + preferredLocationsCount: number; + /** + * Gets the current read endpoint from the endpoint cache. + */ + getReadEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + /** + * Gets the current write endpoint from the endpoint cache. + */ + getWriteEndpoint(diagnosticNode: DiagnosticNodeInternal): Promise; + getReadEndpoints(): Promise>; + getWriteEndpoints(): Promise>; + markCurrentLocationUnavailableForRead(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise; + markCurrentLocationUnavailableForWrite(diagnosticNode: DiagnosticNodeInternal, endpoint: string): Promise; + canUseMultipleWriteLocations(resourceType?: ResourceType, operationType?: OperationType): boolean; + resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number): Promise; + /** + * Refreshes the endpoint list by clearning stale unavailability and then + * retrieving the writable and readable locations from the geo-replicated database account + * and then updating the locations cache. + * We skip the refreshing if enableEndpointDiscovery is set to False + */ + refreshEndpointList(diagnosticNode: DiagnosticNodeInternal): Promise; + private refreshEndpoints; + private refreshStaleUnavailableLocations; + /** + * update the locationUnavailability to undefined if the location is available again + * @param now - current time + * @param unavailableLocations - list of unavailable locations + * @param allLocations - list of all locations + */ + private updateLocation; + private cleanUnavailableLocationList; + /** + * Gets the database account first by using the default endpoint, and if that doesn't returns + * use the endpoints for the preferred locations in the order they are specified to get + * the database account. + */ + private getDatabaseAccountFromAnyEndpoint; + /** + * Gets the locational endpoint using the location name passed to it using the default endpoint. + * + * @param defaultEndpoint - The default endpoint to use for the endpoint. + * @param locationName - The location name for the azure region like "East US". + */ + private static getLocationalEndpoint; + } + + export declare interface GroupByAliasToAggregateType { + [key: string]: AggregateType; + } + + export declare type GroupByExpressions = string[]; + + /** + * @hidden + */ + export declare enum HTTPMethod { + get = "GET", + patch = "PATCH", + post = "POST", + put = "PUT", + delete = "DELETE" + } + + export declare interface Index { + kind: keyof typeof IndexKind; + dataType: keyof typeof DataType; + precision?: number; + } + + export declare interface IndexedPath { + path: string; + indexes?: Index[]; + } + + /** + * Specifies the supported indexing modes. + */ + export declare enum IndexingMode { + /** + * Index is updated synchronously with a create or update operation. + * + * With consistent indexing, query behavior is the same as the default consistency level for the container. + * The index is always kept up to date with the data. + */ + consistent = "consistent", + /** + * Index is updated asynchronously with respect to a create or update operation. + * + * With lazy indexing, queries are eventually consistent. The index is updated when the container is idle. + */ + lazy = "lazy", + /** No Index is provided. */ + none = "none" + } + + export declare interface IndexingPolicy { + /** The indexing mode (consistent or lazy) {@link IndexingMode}. */ + indexingMode?: keyof typeof IndexingMode; + automatic?: boolean; + /** An array of {@link IncludedPath} represents the paths to be included for indexing. */ + includedPaths?: IndexedPath[]; + /** An array of {@link IncludedPath} represents the paths to be excluded for indexing. */ + excludedPaths?: IndexedPath[]; + spatialIndexes?: SpatialIndex[]; + /** An array of {@link VectorIndex} represents the vector index paths to be included for indexing. */ + vectorIndexes?: VectorIndex[]; + } + + /** + * Specifies the supported Index types. + */ + export declare enum IndexKind { + /** + * This is supplied for a path which requires sorting. + */ + Range = "Range", + /** + * This is supplied for a path which requires geospatial indexing. + */ + Spatial = "Spatial" + } + + /** + * Used to perform operations on a specific item. + * + * @see {@link Items} for operations on all items; see `container.items`. + */ + export declare class Item { + readonly container: Container; + readonly id: string; + private readonly clientContext; + private partitionKey; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Item}. + * @param partitionKey - The primary key of the given {@link Item} (only for partitioned containers). + */ + constructor(container: Container, id: string, clientContext: ClientContext, partitionKey?: PartitionKey); + /** + * Read the item's definition. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * If the type, T, is a class, it won't pass `typeof` comparisons, because it won't have a match prototype. + * It's recommended to only use interfaces. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Additional options for the request + * + * @example Using custom type for response + * ```typescript + * interface TodoItem { + * title: string; + * done: bool; + * id: string; + * } + * + * let item: TodoItem; + * ({body: item} = await item.read()); + * ``` + */ + read(options?: RequestOptions): Promise>; + /** + * Replace the item's definition. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - The definition to replace the existing {@link Item}'s definition with. + * @param options - Additional options for the request + */ + replace(body: ItemDefinition, options?: RequestOptions): Promise>; + /** + * Replace the item's definition. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - The definition to replace the existing {@link Item}'s definition with. + * @param options - Additional options for the request + */ + replace(body: T, options?: RequestOptions): Promise>; + /** + * Delete the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + delete(options?: RequestOptions): Promise>; + /** + * Perform a JSONPatch on the item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * @param options - Additional options for the request + */ + patch(body: PatchRequestBody, options?: RequestOptions): Promise>; + } + + /** + * Items in Cosmos DB are simply JSON objects. + * Most of the Item operations allow for your to provide your own type + * that extends the very simple ItemDefinition. + * + * You cannot use any reserved keys. You can see the reserved key list + * in {@link ItemBody} + */ + export declare interface ItemDefinition { + /** The id of the item. User settable property. Uniquely identifies the item along with the partition key */ + id?: string; + /** Time to live in seconds for collections with TTL enabled */ + ttl?: number; + [key: string]: any; + } + + export declare class ItemResponse extends ResourceResponse { + constructor(resource: T & Resource, headers: CosmosHeaders, statusCode: number, subsstatusCode: number, item: Item, diagnostics: CosmosDiagnostics); + /** Reference to the {@link Item} the response corresponds to. */ + readonly item: Item; + } + + /** + * Operations for creating new items, and reading/querying all items + * + * @see {@link Item} for reading, replacing, or deleting an existing container; use `.item(id)`. + */ + export declare class Items { + readonly container: Container; + private readonly clientContext; + private partitionKeyRangeCache; + /** + * Create an instance of {@link Items} linked to the parent {@link Container}. + * @param container - The parent container. + * @hidden + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Queries all items. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM Families f WHERE f.lastName = @lastName", + * parameters: [ + * {name: "@lastName", value: "Hendricks"} + * ] + * }; + * const {result: items} = await items.query(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Queries all items. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT firstname FROM Families f WHERE f.lastName = @lastName", + * parameters: [ + * {name: "@lastName", value: "Hendricks"} + * ] + * }; + * const {result: items} = await items.query<{firstName: string}>(querySpec).fetchAll(); + * ``` + */ + query(query: string | SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * + * @deprecated Use `changeFeed` instead. + * + * @example Read from the beginning of the change feed. + * ```javascript + * const iterator = items.readChangeFeed({ startFromBeginning: true }); + * const firstPage = await iterator.fetchNext(); + * const firstPageResults = firstPage.result + * const secondPage = await iterator.fetchNext(); + * ``` + */ + readChangeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * @deprecated Use `changeFeed` instead. + * + */ + readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * @deprecated Use `changeFeed` instead. + */ + readChangeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * @deprecated Use `changeFeed` instead. + */ + readChangeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + * + * @example Read from the beginning of the change feed. + * ```javascript + * const iterator = items.readChangeFeed({ startFromBeginning: true }); + * const firstPage = await iterator.fetchNext(); + * const firstPageResults = firstPage.result + * const secondPage = await iterator.fetchNext(); + * ``` + */ + changeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + */ + changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + */ + changeFeed(partitionKey: PartitionKey, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Create a `ChangeFeedIterator` to iterate over pages of changes + */ + changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator; + /** + * Returns an iterator to iterate over pages of changes. The iterator returned can be used to fetch changes for a single partition key, feed range or an entire container. + */ + getChangeFeedIterator(changeFeedIteratorOptions?: ChangeFeedIteratorOptions): ChangeFeedPullModelIterator; + /** + * Read all items. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const {body: containerList} = await items.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Read all items. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param options - Used for modifying the request (for instance, specifying the partition key). + * @example Read all items to array. + * ```typescript + * const {body: containerList} = await items.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create an item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + create(body: T, options?: RequestOptions): Promise>; + /** + * Upsert an item. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + upsert(body: unknown, options?: RequestOptions): Promise>; + /** + * Upsert an item. + * + * Any provided type, T, is not necessarily enforced by the SDK. + * You may get more or less properties and it's up to your logic to enforce it. + * + * There is no set schema for JSON items. They may contain any number of custom properties. + * + * @param body - Represents the body of the item. Can contain any number of user defined properties. + * @param options - Used for modifying the request (for instance, specifying the partition key). + */ + upsert(body: T, options?: RequestOptions): Promise>; + /** + * Execute bulk operations on items. + * + * Bulk takes an array of Operations which are typed based on what the operation does. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is optional at the top level if present in the resourceBody + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.bulk(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param bulkOptions - Optional options object to modify bulk behavior. Pass \{ continueOnError: true \} to continue executing operations when one fails. (Defaults to false) ** NOTE: THIS WILL DEFAULT TO TRUE IN THE 4.0 RELEASE + * @param options - Used for modifying the request. + */ + bulk(operations: OperationInput[], bulkOptions?: BulkOptions, options?: RequestOptions): Promise; + /** + * Function to create batches based of partition key Ranges. + * @param operations - operations to group + * @param partitionDefinition - PartitionKey definition of container. + * @param options - Request options for bulk request. + * @param batches - Groups to be filled with operations. + */ + private groupOperationsBasedOnPartitionKey; + /** + * Execute transactional batch operations on items. + * + * Batch takes an array of Operations which are typed based on what the operation does. Batch is transactional and will rollback all operations if one fails. + * The choices are: Create, Upsert, Read, Replace, and Delete + * + * Usage example: + * ```typescript + * // partitionKey is required as a second argument to batch, but defaults to the default partition key + * const operations: OperationInput[] = [ + * { + * operationType: "Create", + * resourceBody: { id: "doc1", name: "sample", key: "A" } + * }, + * { + * operationType: "Upsert", + * partitionKey: 'A', + * resourceBody: { id: "doc2", name: "other", key: "A" } + * } + * ] + * + * await database.container.items.batch(operations) + * ``` + * + * @param operations - List of operations. Limit 100 + * @param options - Used for modifying the request + */ + batch(operations: OperationInput[], partitionKey?: PartitionKey, options?: RequestOptions): Promise>; + } + + export declare interface JSONArray extends ArrayLike { + } + + export declare interface JSONObject { + [key: string]: JSONValue; + } + + export declare type JSONValue = boolean | number | string | null | JSONArray | JSONObject; + + /** + * Used to specify the locations that are available, read is index 1 and write is index 0. + */ + declare interface Location_2 { + name: string; + databaseAccountEndpoint: string; + unavailable?: boolean; + lastUnavailabilityTimestampInMs?: number; + } + export { Location_2 as Location } + + /** + * This type contains diagnostic information regarding a single metadata request to server. + */ + export declare interface MetadataLookUpDiagnostic { + activityId: string; + startTimeUTCInMs: number; + durationInMs: number; + operationType?: OperationType; + resourceType?: ResourceType; + metaDataType: MetadataLookUpType; + requestPayloadLengthInBytes: number; + responsePayloadLengthInBytes: number; + } + + /** + * This type contains diagnostic information regarding all metadata request to server during an CosmosDB client operation. + */ + export declare type MetadataLookUpDiagnostics = { + metadataLookups: MetadataLookUpDiagnostic[]; + }; + + /** + * This is enum for Type of Metadata lookups possible. + */ + export declare enum MetadataLookUpType { + PartitionKeyRangeLookUp = "PARTITION_KEY_RANGE_LOOK_UP", + DatabaseAccountLookUp = "DATABASE_ACCOUNT_LOOK_UP", + QueryPlanLookUp = "QUERY_PLAN_LOOK_UP", + DatabaseLookUp = "DATABASE_LOOK_UP", + ContainerLookUp = "CONTAINER_LOOK_UP" + } + + /** + * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins, + * allowing you to log those results or handle errors. + * @hidden + */ + export declare type Next = (context: RequestContext) => Promise>; + + /** + * The returned object represents a partition key value that allows creating and accessing items + * without a value for partition key + */ + export declare type NonePartitionKeyType = { + [K in any]: never; + }; + + /** + * The returned object represents a partition key value that allows creating and accessing items + * with a null value for the partition key. + */ + export declare type NullPartitionKeyType = null; + + /** + * Use to read or replace an existing {@link Offer} by id. + * + * @see {@link Offers} to query or read all offers. + */ + export declare class Offer { + readonly client: CosmosClient; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the Database Account. + * @param id - The id of the given {@link Offer}. + */ + constructor(client: CosmosClient, id: string, clientContext: ClientContext); + /** + * Read the {@link OfferDefinition} for the given {@link Offer}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link Offer} with the specified {@link OfferDefinition}. + * @param body - The specified {@link OfferDefinition} + */ + replace(body: OfferDefinition, options?: RequestOptions): Promise; + } + + export declare interface OfferDefinition { + id?: string; + offerType?: string; + offerVersion?: string; + resource?: string; + offerResourceId?: string; + content?: { + offerThroughput: number; + offerIsRUPerMinuteThroughputEnabled: boolean; + offerMinimumThroughputParameters?: { + maxThroughputEverProvisioned: number; + maxConsumedStorageEverInKB: number; + }; + offerAutopilotSettings?: { + tier: number; + maximumTierThroughput: number; + autoUpgrade: boolean; + maxThroughput: number; + }; + }; + } + + export declare class OfferResponse extends ResourceResponse { + constructor(resource: OfferDefinition & Resource, headers: CosmosHeaders, statusCode: number, diagnostics: CosmosDiagnostics, offer?: Offer); + /** A reference to the {@link Offer} corresponding to the returned {@link OfferDefinition}. */ + readonly offer: Offer; + } + + /** + * Use to query or read all Offers. + * + * @see {@link Offer} to read or replace an existing {@link Offer} by id. + */ + export declare class Offers { + readonly client: CosmosClient; + private readonly clientContext; + /** + * @hidden + * @param client - The parent {@link CosmosClient} for the offers. + */ + constructor(client: CosmosClient, clientContext: ClientContext); + /** + * Query all offers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all offers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all offers. + * @example Read all offers to array. + * ```typescript + * const {body: offerList} = await client.offers.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + } + + export declare type Operation = CreateOperation | UpsertOperation | ReadOperation | DeleteOperation | ReplaceOperation | BulkPatchOperation; + + export declare interface OperationBase { + partitionKey?: string; + ifMatch?: string; + ifNoneMatch?: string; + } + + export declare type OperationInput = CreateOperationInput | UpsertOperationInput | ReadOperationInput | DeleteOperationInput | ReplaceOperationInput | PatchOperationInput; + + export declare interface OperationResponse { + statusCode: number; + requestCharge: number; + eTag?: string; + resourceBody?: JSONObject; + } + + /** + * @hidden + */ + export declare enum OperationType { + Create = "create", + Replace = "replace", + Upsert = "upsert", + Delete = "delete", + Read = "read", + Query = "query", + Execute = "execute", + Batch = "batch", + Patch = "patch" + } + + export declare type OperationWithItem = OperationBase & { + resourceBody: JSONObject; + }; + + /** + * @hidden + */ + export declare interface PartitionedQueryExecutionInfo { + partitionedQueryExecutionInfoVersion: number; + queryInfo: QueryInfo; + queryRanges: QueryRange[]; + } + + /** + * PartitionKey of a container. + * @remarks + * - PartitionKeyDefinition is no longer part of PartitionKey. So please use PartitionKeyDefinition + * type directly where appropriate. + */ + export declare type PartitionKey = PrimitivePartitionKeyValue | PrimitivePartitionKeyValue[]; + + /** + * Builder class for building PartitionKey. + */ + export declare class PartitionKeyBuilder { + readonly values: PrimitivePartitionKeyValue[]; + addValue(value: string | boolean | number): PartitionKeyBuilder; + addNullValue(): PartitionKeyBuilder; + addNoneValue(): PartitionKeyBuilder; + build(): PartitionKey; + } + + export declare interface PartitionKeyDefinition { + /** + * An array of paths for which data within the collection can be partitioned. Paths must not contain a wildcard or + * a trailing slash. For example, the JSON property “AccountNumber” is specified as “/AccountNumber”. The array must + * contain only a single value. + */ + paths: string[]; + /** + * An optional field, if not specified the default value is 1. To use the large partition key set the version to 2. + * To learn about large partition keys, see [how to create containers with large partition key](https://docs.microsoft.com/en-us/azure/cosmos-db/large-partition-keys) article. + */ + version?: PartitionKeyDefinitionVersion; + systemKey?: boolean; + /** + * What kind of partition key is being defined (default: "Hash") + */ + kind?: PartitionKeyKind; + } + + /** + * PartitionKey Definition Version + */ + export declare enum PartitionKeyDefinitionVersion { + V1 = 1, + V2 = 2 + } + + /** + * Type of PartitionKey i.e. Hash, MultiHash + */ + export declare enum PartitionKeyKind { + Hash = "Hash", + MultiHash = "MultiHash" + } + + /** + * @hidden + */ + export declare interface PartitionKeyRange { + id: string; + minInclusive: string; + maxExclusive: string; + ridPrefix: number; + throughputFraction: number; + status: string; + parents: string[]; + } + + export declare interface PartitionKeyRangePropertiesNames { + MinInclusive: "minInclusive"; + MaxExclusive: "maxExclusive"; + Id: "id"; + } + + export declare type PatchOperation = ExistingKeyOperation | RemoveOperation; + + export declare interface PatchOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Patch; + resourceBody: PatchRequestBody; + id: string; + } + + export declare const PatchOperationType: { + readonly add: "add"; + readonly replace: "replace"; + readonly remove: "remove"; + readonly set: "set"; + readonly incr: "incr"; + }; + + export declare type PatchRequestBody = { + operations: PatchOperation[]; + condition?: string; + } | PatchOperation[]; + + /** + * Use to read, replace, or delete a given {@link Permission} by id. + * + * @see {@link Permissions} to create, upsert, query, or read all Permissions. + */ + export declare class Permission { + readonly user: User; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param user - The parent {@link User}. + * @param id - The id of the given {@link Permission}. + */ + constructor(user: User, id: string, clientContext: ClientContext); + /** + * Read the {@link PermissionDefinition} of the given {@link Permission}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link Permission} with the specified {@link PermissionDefinition}. + * @param body - The specified {@link PermissionDefinition}. + */ + replace(body: PermissionDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link Permission}. + */ + delete(options?: RequestOptions): Promise; + } + + export declare interface PermissionBody { + /** System generated resource token for the particular resource and user */ + _token: string; + } + + export declare interface PermissionDefinition { + /** The id of the permission */ + id: string; + /** The mode of the permission, must be a value of {@link PermissionMode} */ + permissionMode: PermissionMode; + /** The link of the resource that the permission will be applied to. */ + resource: string; + resourcePartitionKey?: string | any[]; + } + + /** + * Enum for permission mode values. + */ + export declare enum PermissionMode { + /** Permission not valid. */ + None = "none", + /** Permission applicable for read operations only. */ + Read = "read", + /** Permission applicable for all operations. */ + All = "all" + } + + export declare class PermissionResponse extends ResourceResponse { + constructor(resource: PermissionDefinition & PermissionBody & Resource, headers: CosmosHeaders, statusCode: number, permission: Permission, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Permission} corresponding to the returned {@link PermissionDefinition}. */ + readonly permission: Permission; + } + + /** + * Use to create, replace, query, and read all Permissions. + * + * @see {@link Permission} to read, replace, or delete a specific permission by id. + */ + declare class Permissions_2 { + readonly user: User; + private readonly clientContext; + /** + * @hidden + * @param user - The parent {@link User}. + */ + constructor(user: User, clientContext: ClientContext); + /** + * Query all permissions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all permissions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all permissions. + * @example Read all permissions to array. + * ```typescript + * const {body: permissionList} = await user.permissions.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a permission. + * + * A permission represents a per-User Permission to access a specific resource + * e.g. Item or Container. + * @param body - Represents the body of the permission. + */ + create(body: PermissionDefinition, options?: RequestOptions): Promise; + /** + * Upsert a permission. + * + * A permission represents a per-User Permission to access a + * specific resource e.g. Item or Container. + */ + upsert(body: PermissionDefinition, options?: RequestOptions): Promise; + } + export { Permissions_2 as Permissions } + + /** + * Plugins allow you to customize the behavior of the SDk with additional logging, retry, or additional functionality. + * + * A plugin is a function which returns a `Promise>`, and is passed a RequestContext and Next object. + * + * Next is a function which takes in requestContext returns a promise. You must await/then that promise which will contain the response from further plugins, + * allowing you to log those results or handle errors. + * + * RequestContext is an object which controls what operation is happening, against which endpoint, and more. Modifying this and passing it along via next is how + * you modify future SDK behavior. + * + * @hidden + */ + declare type Plugin_2 = (context: RequestContext, diagnosticNode: DiagnosticNodeInternal, next: Next) => Promise>; + export { Plugin_2 as Plugin } + + /** + * Specifies which event to run for the specified plugin + * + * @hidden + */ + export declare interface PluginConfig { + /** + * The event to run the plugin on + */ + on: keyof typeof PluginOn; + /** + * The plugin to run + */ + plugin: Plugin_2; + } + + /** + * Used to specify which type of events to execute this plug in on. + * + * @hidden + */ + export declare enum PluginOn { + /** + * Will be executed per network request + */ + request = "request", + /** + * Will be executed per API operation + */ + operation = "operation" + } + + /** + * A primitive Partition Key value. + */ + export declare type PrimitivePartitionKeyValue = string | number | boolean | NullPartitionKeyType | NonePartitionKeyType; + + /** + * Represents Priority Level associated with each Azure Cosmos DB client requests.
+ * The Low priority requests are always throttled before any High priority requests. + * + * By default all requests are considered as High priority requests. + * + * See https://aka.ms/CosmosDB/PriorityBasedExecution for more detailed documentation on Priority based throttling. + */ + export declare enum PriorityLevel { + /** + * High Priority requests are throttled after Low priority requests. + */ + High = "High", + /** + * Low Priority requests are throttled before High priority requests. + */ + Low = "Low" + } + + /** + * @hidden + */ + export declare interface QueryInfo { + top?: any; + orderBy?: any[]; + orderByExpressions?: any[]; + offset?: number; + limit?: number; + aggregates?: AggregateType[]; + groupByExpressions?: GroupByExpressions; + groupByAliasToAggregateType: GroupByAliasToAggregateType; + rewrittenQuery?: any; + distinctType: string; + hasSelectValue: boolean; + /** + * determines whether the query is of non streaming orderby type. + */ + hasNonStreamingOrderBy: boolean; + } + + /** + * Represents a QueryIterator Object, an implementation of feed or query response that enables + * traversal and iterating over the response + * in the Azure Cosmos DB database service. + */ + export declare class QueryIterator { + private clientContext; + private query; + private options; + private fetchFunctions; + private resourceLink?; + private resourceType?; + private fetchAllTempResources; + private fetchAllLastResHeaders; + private queryExecutionContext; + private queryPlanPromise; + private isInitialized; + private nonStreamingOrderBy; + /** + * @hidden + */ + constructor(clientContext: ClientContext, query: SqlQuerySpec | string, options: FeedOptions, fetchFunctions: FetchFunctionCallback | FetchFunctionCallback[], resourceLink?: string, resourceType?: ResourceType); + /** + * Gets an async iterator that will yield results until completion. + * + * NOTE: AsyncIterators are a very new feature and you might need to + * use polyfils/etc. in order to use them in your code. + * + * If you're using TypeScript, you can use the following polyfill as long + * as you target ES6 or higher and are running on Node 6 or higher. + * + * ```typescript + * if (!Symbol || !Symbol.asyncIterator) { + * (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator"); + * } + * ``` + * + * @example Iterate over all databases + * ```typescript + * for await(const { resources: db } of client.databases.readAll().getAsyncIterator()) { + * console.log(`Got ${db} from AsyncIterator`); + * } + * ``` + */ + getAsyncIterator(options?: QueryOperationOptions): AsyncIterable>; + /** + * Determine if there are still remaining resources to process based on the value of the continuation token or the + * elements remaining on the current batch in the QueryIterator. + * @returns true if there is other elements to process in the QueryIterator. + */ + hasMoreResults(): boolean; + /** + * Fetch all pages for the query and return a single FeedResponse. + */ + fetchAll(options?: QueryOperationOptions): Promise>; + /** + * @hidden + */ + fetchAllInternal(diagnosticNode: DiagnosticNodeInternal, options?: QueryOperationOptions): Promise>; + /** + * Retrieve the next batch from the feed. + * + * This may or may not fetch more pages from the backend depending on your settings + * and the type of query. Aggregate queries will generally fetch all backend pages + * before returning the first batch of responses. + */ + fetchNext(options?: QueryOperationOptions): Promise>; + /** + * Reset the QueryIterator to the beginning and clear all the resources inside it + */ + reset(): void; + private toArrayImplementation; + private createPipelinedExecutionContext; + private fetchQueryPlan; + private needsQueryPlan; + private initPromise; + private init; + private _init; + private handleSplitError; + } + + export declare class QueryMetrics { + readonly retrievedDocumentCount: number; + readonly retrievedDocumentSize: number; + readonly outputDocumentCount: number; + readonly outputDocumentSize: number; + readonly indexHitDocumentCount: number; + readonly totalQueryExecutionTime: TimeSpan; + readonly queryPreparationTimes: QueryPreparationTimes; + readonly indexLookupTime: TimeSpan; + readonly documentLoadTime: TimeSpan; + readonly vmExecutionTime: TimeSpan; + readonly runtimeExecutionTimes: RuntimeExecutionTimes; + readonly documentWriteTime: TimeSpan; + readonly clientSideMetrics: ClientSideMetrics; + constructor(retrievedDocumentCount: number, retrievedDocumentSize: number, outputDocumentCount: number, outputDocumentSize: number, indexHitDocumentCount: number, totalQueryExecutionTime: TimeSpan, queryPreparationTimes: QueryPreparationTimes, indexLookupTime: TimeSpan, documentLoadTime: TimeSpan, vmExecutionTime: TimeSpan, runtimeExecutionTimes: RuntimeExecutionTimes, documentWriteTime: TimeSpan, clientSideMetrics: ClientSideMetrics); + /** + * Gets the IndexHitRatio + * @hidden + */ + get indexHitRatio(): number; + /** + * returns a new QueryMetrics instance that is the addition of this and the arguments. + */ + add(queryMetricsArray: QueryMetrics[]): QueryMetrics; + /** + * Output the QueryMetrics as a delimited string. + * @hidden + */ + toDelimitedString(): string; + static readonly zero: QueryMetrics; + /** + * Returns a new instance of the QueryMetrics class that is the aggregation of an array of query metrics. + */ + static createFromArray(queryMetricsArray: QueryMetrics[]): QueryMetrics; + /** + * Returns a new instance of the QueryMetrics class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString: string, clientSideMetrics?: ClientSideMetrics): QueryMetrics; + } + + export declare const QueryMetricsConstants: { + RetrievedDocumentCount: string; + RetrievedDocumentSize: string; + OutputDocumentCount: string; + OutputDocumentSize: string; + IndexHitRatio: string; + IndexHitDocumentCount: string; + TotalQueryExecutionTimeInMs: string; + QueryCompileTimeInMs: string; + LogicalPlanBuildTimeInMs: string; + PhysicalPlanBuildTimeInMs: string; + QueryOptimizationTimeInMs: string; + IndexLookupTimeInMs: string; + DocumentLoadTimeInMs: string; + VMExecutionTimeInMs: string; + DocumentWriteTimeInMs: string; + QueryEngineTimes: string; + SystemFunctionExecuteTimeInMs: string; + UserDefinedFunctionExecutionTimeInMs: string; + RetrievedDocumentCountText: string; + RetrievedDocumentSizeText: string; + OutputDocumentCountText: string; + OutputDocumentSizeText: string; + IndexUtilizationText: string; + TotalQueryExecutionTimeText: string; + QueryPreparationTimesText: string; + QueryCompileTimeText: string; + LogicalPlanBuildTimeText: string; + PhysicalPlanBuildTimeText: string; + QueryOptimizationTimeText: string; + QueryEngineTimesText: string; + IndexLookupTimeText: string; + DocumentLoadTimeText: string; + WriteOutputTimeText: string; + RuntimeExecutionTimesText: string; + TotalExecutionTimeText: string; + SystemFunctionExecuteTimeText: string; + UserDefinedFunctionExecutionTimeText: string; + ClientSideQueryMetricsText: string; + RetriesText: string; + RequestChargeText: string; + FetchExecutionRangesText: string; + SchedulingMetricsText: string; + }; + + export declare interface QueryOperationOptions { + /** + * Request Units(RU) Cap for a given request. Default: Undefined + */ + ruCapPerOperation?: number; + } + + export declare class QueryPreparationTimes { + readonly queryCompilationTime: TimeSpan; + readonly logicalPlanBuildTime: TimeSpan; + readonly physicalPlanBuildTime: TimeSpan; + readonly queryOptimizationTime: TimeSpan; + constructor(queryCompilationTime: TimeSpan, logicalPlanBuildTime: TimeSpan, physicalPlanBuildTime: TimeSpan, queryOptimizationTime: TimeSpan); + /** + * returns a new QueryPreparationTimes instance that is the addition of this and the arguments. + */ + add(...queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes; + /** + * Output the QueryPreparationTimes as a delimited string. + */ + toDelimitedString(): string; + static readonly zero: QueryPreparationTimes; + /** + * Returns a new instance of the QueryPreparationTimes class that is the + * aggregation of an array of QueryPreparationTimes. + */ + static createFromArray(queryPreparationTimesArray: QueryPreparationTimes[]): QueryPreparationTimes; + /** + * Returns a new instance of the QueryPreparationTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString: string): QueryPreparationTimes; + } + + /** + * @hidden + */ + export declare interface QueryRange { + min: string; + max: string; + isMinInclusive: boolean; + isMaxInclusive: boolean; + } + + export declare type ReadOperation = OperationBase & { + operationType: typeof BulkOperationType.Read; + id: string; + }; + + export declare interface ReadOperationInput { + partitionKey?: PartitionKey; + operationType: typeof BulkOperationType.Read; + id: string; + } + + export declare type RemoveOperation = { + op: "remove"; + path: string; + }; + + export declare type ReplaceOperation = OperationWithItem & { + operationType: typeof BulkOperationType.Replace; + id: string; + }; + + export declare interface ReplaceOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Replace; + resourceBody: JSONObject; + id: string; + } + + /** + * @hidden + */ + export declare interface RequestContext { + path?: string; + operationType?: OperationType; + client?: ClientContext; + retryCount?: number; + resourceType?: ResourceType; + resourceId?: string; + globalEndpointManager: GlobalEndpointManager; + connectionPolicy: ConnectionPolicy; + requestAgent: Agent; + body?: any; + headers?: CosmosHeaders_2; + endpoint?: string; + method: HTTPMethod; + partitionKeyRangeId?: string; + options: FeedOptions | RequestOptions; + plugins: PluginConfig[]; + partitionKey?: PartitionKey; + pipeline?: Pipeline; + } + + /** @hidden */ + declare interface RequestInfo_2 { + verb: HTTPMethod; + path: string; + resourceId: string; + resourceType: ResourceType; + headers: CosmosHeaders; + } + export { RequestInfo_2 as RequestInfo } + + /** + * Options that can be specified for a requested issued to the Azure Cosmos DB servers.= + */ + export declare interface RequestOptions extends SharedOptions { + /** Conditions Associated with the request. */ + accessCondition?: { + /** Conditional HTTP method header type (IfMatch or IfNoneMatch). */ + type: string; + /** Conditional HTTP method header value (the _etag field from the last version you read). */ + condition: string; + }; + /** Consistency level required by the client. */ + consistencyLevel?: string; + /** + * DisableRUPerMinuteUsage is used to enable/disable Request Units(RUs)/minute capacity + * to serve the request if regular provisioned RUs/second is exhausted. + */ + disableRUPerMinuteUsage?: boolean; + /** Enables or disables logging in JavaScript stored procedures. */ + enableScriptLogging?: boolean; + /** Specifies indexing directives (index, do not index .. etc). */ + indexingDirective?: string; + /** The offer throughput provisioned for a container in measurement of Requests-per-Unit. */ + offerThroughput?: number; + /** + * Offer type when creating document containers. + * + * This option is only valid when creating a document container. + */ + offerType?: string; + /** Enables/disables getting document container quota related stats for document container read requests. */ + populateQuotaInfo?: boolean; + /** Indicates what is the post trigger to be invoked after the operation. */ + postTriggerInclude?: string | string[]; + /** Indicates what is the pre trigger to be invoked before the operation. */ + preTriggerInclude?: string | string[]; + /** Expiry time (in seconds) for resource token associated with permission (applicable only for requests on permissions). */ + resourceTokenExpirySeconds?: number; + /** (Advanced use case) The url to connect to. */ + urlConnection?: string; + /** Disable automatic id generation (will cause creates to fail if id isn't on the definition) */ + disableAutomaticIdGeneration?: boolean; + } + + export declare interface Resource { + /** Required. User settable property. Unique name that identifies the item, that is, no two items share the same ID within a database. The id must not exceed 255 characters. */ + id: string; + /** System generated property. The resource ID (_rid) is a unique identifier that is also hierarchical per the resource stack on the resource model. It is used internally for placement and navigation of the item resource. */ + _rid: string; + /** System generated property. Specifies the last updated timestamp of the resource. The value is a timestamp. */ + _ts: number; + /** System generated property. The unique addressable URI for the resource. */ + _self: string; + /** System generated property. Represents the resource etag required for optimistic concurrency control. */ + _etag: string; + } + + export declare class ResourceResponse { + readonly resource: TResource | undefined; + readonly headers: CosmosHeaders_2; + readonly statusCode: StatusCode; + readonly diagnostics: CosmosDiagnostics; + readonly substatus?: SubStatusCode; + constructor(resource: TResource | undefined, headers: CosmosHeaders_2, statusCode: StatusCode, diagnostics: CosmosDiagnostics, substatus?: SubStatusCode); + get requestCharge(): number; + get activityId(): string; + get etag(): string; + } + + /** + * @hidden + */ + export declare enum ResourceType { + none = "", + database = "dbs", + offer = "offers", + user = "users", + permission = "permissions", + container = "colls", + conflicts = "conflicts", + sproc = "sprocs", + udf = "udfs", + trigger = "triggers", + item = "docs", + pkranges = "pkranges", + partitionkey = "partitionKey" + } + + /** + * @hidden + */ + declare interface Response_2 { + headers: CosmosHeaders; + result?: T; + code?: number; + substatus?: number; + diagnostics?: CosmosDiagnostics; + } + export { Response_2 as Response } + + export { RestError } + + /** + * This type captures diagnostic information regarding retries attempt during an CosmosDB client operation. + */ + export declare type RetryDiagnostics = { + failedAttempts: FailedRequestAttemptDiagnostic[]; + }; + + /** + * Represents the Retry policy assocated with throttled requests in the Azure Cosmos DB database service. + */ + export declare interface RetryOptions { + /** Max number of retries to be performed for a request. Default value 9. */ + maxRetryAttemptCount: number; + /** Fixed retry interval in milliseconds to wait between each retry ignoring the retryAfter returned as part of the response. */ + fixedRetryIntervalInMilliseconds: number; + /** Max wait time in seconds to wait for a request while the retries are happening. Default value 30 seconds. */ + maxWaitTimeInSeconds: number; + } + + export declare class RUCapPerOperationExceededError extends ErrorResponse { + readonly code: string; + fetchedResults: any[]; + constructor(message?: string, fetchedResults?: any[]); + } + + export declare class RuntimeExecutionTimes { + readonly queryEngineExecutionTime: TimeSpan; + readonly systemFunctionExecutionTime: TimeSpan; + readonly userDefinedFunctionExecutionTime: TimeSpan; + constructor(queryEngineExecutionTime: TimeSpan, systemFunctionExecutionTime: TimeSpan, userDefinedFunctionExecutionTime: TimeSpan); + /** + * returns a new RuntimeExecutionTimes instance that is the addition of this and the arguments. + */ + add(...runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes; + /** + * Output the RuntimeExecutionTimes as a delimited string. + */ + toDelimitedString(): string; + static readonly zero: RuntimeExecutionTimes; + /** + * Returns a new instance of the RuntimeExecutionTimes class that is + * the aggregation of an array of RuntimeExecutionTimes. + */ + static createFromArray(runtimeExecutionTimesArray: RuntimeExecutionTimes[]): RuntimeExecutionTimes; + /** + * Returns a new instance of the RuntimeExecutionTimes class this is deserialized from a delimited string. + */ + static createFromDelimitedString(delimitedString: string): RuntimeExecutionTimes; + } + + /** + * @hidden + */ + export declare enum SasTokenPermissionKind { + ContainerCreateItems = 1, + ContainerReplaceItems = 2, + ContainerUpsertItems = 4, + ContainerDeleteItems = 128, + ContainerExecuteQueries = 1, + ContainerReadFeeds = 2, + ContainerCreateStoreProcedure = 16, + ContainerReadStoreProcedure = 4, + ContainerReplaceStoreProcedure = 32, + ContainerDeleteStoreProcedure = 64, + ContainerCreateTriggers = 256, + ContainerReadTriggers = 16, + ContainerReplaceTriggers = 512, + ContainerDeleteTriggers = 1024, + ContainerCreateUserDefinedFunctions = 2048, + ContainerReadUserDefinedFunctions = 8, + ContainerReplaceUserDefinedFunctions = 4096, + ContainerDeleteUserDefinedFunctions = 8192, + ContainerExecuteStoredProcedure = 128, + ContainerReadConflicts = 32, + ContainerDeleteConflicts = 16384, + ContainerReadAny = 64, + ContainerFullAccess = 4294967295, + ItemReadAny = 65536, + ItemFullAccess = 65, + ItemRead = 64, + ItemReplace = 65536, + ItemUpsert = 131072, + ItemDelete = 262144, + StoreProcedureRead = 128, + StoreProcedureReplace = 1048576, + StoreProcedureDelete = 2097152, + StoreProcedureExecute = 4194304, + UserDefinedFuntionRead = 256, + UserDefinedFuntionReplace = 8388608, + UserDefinedFuntionDelete = 16777216, + TriggerRead = 512, + TriggerReplace = 33554432, + TriggerDelete = 67108864 + } + + export declare class SasTokenProperties { + user: string; + userTag: string; + databaseName: string; + containerName: string; + resourceName: string; + resourcePath: string; + resourceKind: CosmosContainerChildResourceKind; + partitionKeyValueRanges: string[]; + startTime: Date; + expiryTime: Date; + keyType: CosmosKeyType | number; + controlPlaneReaderScope: number; + controlPlaneWriterScope: number; + dataPlaneReaderScope: number; + dataPlaneWriterScope: number; + cosmosContainerChildResourceKind: CosmosContainerChildResourceKind; + cosmosKeyType: CosmosKeyType; + } + + export declare class Scripts { + readonly container: Container; + private readonly clientContext; + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Used to read, replace, or delete a specific, existing {@link StoredProcedure} by id. + * + * Use `.storedProcedures` for creating new stored procedures, or querying/reading all stored procedures. + * @param id - The id of the {@link StoredProcedure}. + */ + storedProcedure(id: string): StoredProcedure; + /** + * Used to read, replace, or delete a specific, existing {@link Trigger} by id. + * + * Use `.triggers` for creating new triggers, or querying/reading all triggers. + * @param id - The id of the {@link Trigger}. + */ + trigger(id: string): Trigger; + /** + * Used to read, replace, or delete a specific, existing {@link UserDefinedFunction} by id. + * + * Use `.userDefinedFunctions` for creating new user defined functions, or querying/reading all user defined functions. + * @param id - The id of the {@link UserDefinedFunction}. + */ + userDefinedFunction(id: string): UserDefinedFunction; + private $sprocs; + /** + * Operations for creating new stored procedures, and reading/querying all stored procedures. + * + * For reading, replacing, or deleting an existing stored procedure, use `.storedProcedure(id)`. + */ + get storedProcedures(): StoredProcedures; + private $triggers; + /** + * Operations for creating new triggers, and reading/querying all triggers. + * + * For reading, replacing, or deleting an existing trigger, use `.trigger(id)`. + */ + get triggers(): Triggers; + private $udfs; + /** + * Operations for creating new user defined functions, and reading/querying all user defined functions. + * + * For reading, replacing, or deleting an existing user defined function, use `.userDefinedFunction(id)`. + */ + get userDefinedFunctions(): UserDefinedFunctions; + } + + /** + * The default function for setting header token using the masterKey + * @hidden + */ + export declare function setAuthorizationTokenHeaderUsingMasterKey(verb: HTTPMethod, resourceId: string, resourceType: ResourceType, headers: CosmosHeaders, masterKey: string): Promise; + + /** + * Options that can be specified for a requested issued to the Azure Cosmos DB servers.= + */ + export declare interface SharedOptions { + /** Enables/disables getting document container quota related stats for document container read requests. */ + sessionToken?: string; + /** (Advanced use case) Initial headers to start with when sending requests to Cosmos */ + initialHeaders?: CosmosHeaders; + /** + * abortSignal to pass to all underlying network requests created by this method call. See https://developer.mozilla.org/en-US/docs/Web/API/AbortController + * @example Cancel a read request + * ```typescript + * const controller = new AbortController() + * const {result: item} = await items.query('SELECT * from c', { abortSignal: controller.signal}); + * controller.abort() + * ``` + */ + abortSignal?: AbortSignal_2; + /** + * Sets the staleness value associated with the request in the Azure CosmosDB service. For requests where the {@link + * com.azure.cosmos.ConsistencyLevel} is {@link com.azure.cosmos.ConsistencyLevel#EVENTUAL} or {@link com.azure.cosmos.ConsistencyLevel#SESSION}, responses from the + * integrated cache are guaranteed to be no staler than value indicated by this maxIntegratedCacheStaleness. When the + * consistency level is not set, this property is ignored. + * + *

Default value is null

+ * + *

Cache Staleness is supported in milliseconds granularity. Anything smaller than milliseconds will be ignored.

+ */ + maxIntegratedCacheStalenessInMs?: number; + /** + * Priority Level (Low/High) for each request. + * Low priority requests are always throttled before any high priority requests. + * + *

Default value is null. By default all requests are of High priority

+ */ + priorityLevel?: PriorityLevel; + } + + export declare interface SpatialIndex { + path: string; + types: SpatialType[]; + boundingBox: { + xmin: number; + ymin: number; + xmax: number; + ymax: number; + }; + } + + export declare enum SpatialType { + LineString = "LineString", + MultiPolygon = "MultiPolygon", + Point = "Point", + Polygon = "Polygon" + } + + /** + * Represents a parameter in a Parameterized SQL query, specified in {@link SqlQuerySpec} + */ + export declare interface SqlParameter { + /** Name of the parameter. (i.e. `@lastName`) */ + name: string; + /** Value of the parameter (this is safe to come from users, assuming they are authorized) */ + value: JSONValue; + } + + /** + * Represents a SQL query in the Azure Cosmos DB service. + * + * Queries with inputs should be parameterized to protect against SQL injection. + * + * @example Parameterized SQL Query + * ```typescript + * const query: SqlQuerySpec = { + * query: "SELECT * FROM Families f where f.lastName = @lastName", + * parameters: [ + * {name: "@lastName", value: "Wakefield"} + * ] + * }; + * ``` + */ + export declare interface SqlQuerySpec { + /** The text of the SQL query */ + query: string; + /** The parameters you provide in the query */ + parameters?: SqlParameter[]; + } + + /** + * @hidden + */ + export declare type StatusCode = number; + + /** + * @hidden + */ + export declare const StatusCodes: StatusCodesType; + + /** + * @hidden + */ + export declare interface StatusCodesType { + Ok: 200; + Created: 201; + Accepted: 202; + NoContent: 204; + NotModified: 304; + BadRequest: 400; + Unauthorized: 401; + Forbidden: 403; + NotFound: 404; + MethodNotAllowed: 405; + RequestTimeout: 408; + Conflict: 409; + Gone: 410; + PreconditionFailed: 412; + RequestEntityTooLarge: 413; + TooManyRequests: 429; + RetryWith: 449; + InternalServerError: 500; + ServiceUnavailable: 503; + ENOTFOUND: "ENOTFOUND"; + OperationPaused: 1200; + OperationCancelled: 1201; + } + + /** + * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id. + * + * For operations to create, read all, or query Stored Procedures, + */ + export declare class StoredProcedure { + readonly container: Container; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * Creates a new instance of {@link StoredProcedure} linked to the parent {@link Container}. + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link StoredProcedure}. + * @hidden + */ + constructor(container: Container, id: string, clientContext: ClientContext); + /** + * Read the {@link StoredProcedureDefinition} for the given {@link StoredProcedure}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link StoredProcedure} with the specified {@link StoredProcedureDefinition}. + * @param body - The specified {@link StoredProcedureDefinition} to replace the existing definition. + */ + replace(body: StoredProcedureDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link StoredProcedure}. + */ + delete(options?: RequestOptions): Promise; + /** + * Execute the given {@link StoredProcedure}. + * + * The specified type, T, is not enforced by the client. + * Be sure to validate the response from the stored procedure matches the type, T, you provide. + * + * @param partitionKey - The partition key to use when executing the stored procedure + * @param params - Array of parameters to pass as arguments to the given {@link StoredProcedure}. + * @param options - Additional options, such as the partition key to invoke the {@link StoredProcedure} on. + */ + execute(partitionKey: PartitionKey, params?: any[], options?: RequestOptions): Promise>; + } + + export declare interface StoredProcedureDefinition { + /** + * The id of the {@link StoredProcedure}. + */ + id?: string; + /** + * The body of the {@link StoredProcedure}. This is a JavaScript function. + */ + body?: string | ((...inputs: any[]) => void); + } + + export declare class StoredProcedureResponse extends ResourceResponse { + constructor(resource: StoredProcedureDefinition & Resource, headers: CosmosHeaders, statusCode: number, storedProcedure: StoredProcedure, diagnostics: CosmosDiagnostics); + /** + * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to. + */ + readonly storedProcedure: StoredProcedure; + /** + * Alias for storedProcedure. + * + * A reference to the {@link StoredProcedure} which the {@link StoredProcedureDefinition} corresponds to. + */ + get sproc(): StoredProcedure; + } + + /** + * Operations for creating, upserting, or reading/querying all Stored Procedures. + * + * For operations to read, replace, delete, or execute a specific, existing stored procedure by id, see `container.storedProcedure()`. + */ + export declare class StoredProcedures { + readonly container: Container; + private readonly clientContext; + /** + * @param container - The parent {@link Container}. + * @hidden + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Query all Stored Procedures. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @example Read all stored procedures to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @sproc", + * parameters: [ + * {name: "@sproc", value: "Todo"} + * ] + * }; + * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all Stored Procedures. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + * @example Read all stored procedures to array. + * ```typescript + * const querySpec: SqlQuerySpec = { + * query: "SELECT * FROM root r WHERE r.id = @sproc", + * parameters: [ + * {name: "@sproc", value: "Todo"} + * ] + * }; + * const {body: sprocList} = await containers.storedProcedures.query(querySpec).fetchAll(); + * ``` + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all stored procedures. + * @example Read all stored procedures to array. + * ```typescript + * const {body: sprocList} = await containers.storedProcedures.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a StoredProcedure. + * + * Azure Cosmos DB allows stored procedures to be executed in the storage tier, + * directly against an item container. The script + * gets executed under ACID transactions on the primary storage partition of the + * specified container. For additional details, + * refer to the server-side JavaScript API documentation. + */ + create(body: StoredProcedureDefinition, options?: RequestOptions): Promise; + } + + /** + * @hidden + */ + export declare type SubStatusCode = number; + + export declare class TimeoutError extends Error { + readonly code: string; + constructor(message?: string); + } + + /** + * Represents a time interval. + * + * @param days - Number of days. + * @param hours - Number of hours. + * @param minutes - Number of minutes. + * @param seconds - Number of seconds. + * @param milliseconds - Number of milliseconds. + * @hidden + */ + export declare class TimeSpan { + protected _ticks: number; + constructor(days: number, hours: number, minutes: number, seconds: number, milliseconds: number); + /** + * Returns a new TimeSpan object whose value is the sum of the specified TimeSpan object and this instance. + * @param ts - The time interval to add. + */ + add(ts: TimeSpan): TimeSpan; + /** + * Returns a new TimeSpan object whose value is the difference of the specified TimeSpan object and this instance. + * @param ts - The time interval to subtract. + */ + subtract(ts: TimeSpan): TimeSpan; + /** + * Compares this instance to a specified object and returns an integer that indicates whether this + * instance is shorter than, equal to, or longer than the specified object. + * @param value - The time interval to add. + */ + compareTo(value: TimeSpan): 1 | -1 | 0; + /** + * Returns a new TimeSpan object whose value is the absolute value of the current TimeSpan object. + */ + duration(): TimeSpan; + /** + * Returns a value indicating whether this instance is equal to a specified object. + * @param value - The time interval to check for equality. + */ + equals(value: TimeSpan): boolean; + /** + * Returns a new TimeSpan object whose value is the negated value of this instance. + * @param value - The time interval to check for equality. + */ + negate(): TimeSpan; + days(): number; + hours(): number; + milliseconds(): number; + seconds(): number; + ticks(): number; + totalDays(): number; + totalHours(): number; + totalMilliseconds(): number; + totalMinutes(): number; + totalSeconds(): number; + static fromTicks(value: number): TimeSpan; + static readonly zero: TimeSpan; + static readonly maxValue: TimeSpan; + static readonly minValue: TimeSpan; + static isTimeSpan(timespan: TimeSpan): number; + static additionDoesOverflow(a: number, b: number): boolean; + static subtractionDoesUnderflow(a: number, b: number): boolean; + static compare(t1: TimeSpan, t2: TimeSpan): 1 | 0 | -1; + static interval(value: number, scale: number): TimeSpan; + static fromMilliseconds(value: number): TimeSpan; + static fromSeconds(value: number): TimeSpan; + static fromMinutes(value: number): TimeSpan; + static fromHours(value: number): TimeSpan; + static fromDays(value: number): TimeSpan; + } + + export declare type TokenProvider = (requestInfo: RequestInfo_2) => Promise; + + /** + * Operations to read, replace, or delete a {@link Trigger}. + * + * Use `container.triggers` to create, upsert, query, or read all. + */ + export declare class Trigger { + readonly container: Container; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link Trigger}. + */ + constructor(container: Container, id: string, clientContext: ClientContext); + /** + * Read the {@link TriggerDefinition} for the given {@link Trigger}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link Trigger} with the specified {@link TriggerDefinition}. + * @param body - The specified {@link TriggerDefinition} to replace the existing definition with. + */ + replace(body: TriggerDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link Trigger}. + */ + delete(options?: RequestOptions): Promise; + } + + export declare interface TriggerDefinition { + /** The id of the trigger. */ + id?: string; + /** The body of the trigger, it can also be passed as a stringifed function */ + body: (() => void) | string; + /** The type of the trigger, should be one of the values of {@link TriggerType}. */ + triggerType: TriggerType; + /** The trigger operation, should be one of the values of {@link TriggerOperation}. */ + triggerOperation: TriggerOperation; + } + + /** + * Enum for trigger operation values. + * specifies the operations on which a trigger should be executed. + */ + export declare enum TriggerOperation { + /** All operations. */ + All = "all", + /** Create operations only. */ + Create = "create", + /** Update operations only. */ + Update = "update", + /** Delete operations only. */ + Delete = "delete", + /** Replace operations only. */ + Replace = "replace" + } + + export declare class TriggerResponse extends ResourceResponse { + constructor(resource: TriggerDefinition & Resource, headers: CosmosHeaders, statusCode: number, trigger: Trigger, diagnostics: CosmosDiagnostics); + /** A reference to the {@link Trigger} corresponding to the returned {@link TriggerDefinition}. */ + readonly trigger: Trigger; + } + + /** + * Operations to create, upsert, query, and read all triggers. + * + * Use `container.triggers` to read, replace, or delete a {@link Trigger}. + */ + export declare class Triggers { + readonly container: Container; + private readonly clientContext; + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Query all Triggers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all Triggers. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all Triggers. + * @example Read all trigger to array. + * ```typescript + * const {body: triggerList} = await container.triggers.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a trigger. + * + * Azure Cosmos DB supports pre and post triggers defined in JavaScript to be executed + * on creates, updates and deletes. + * + * For additional details, refer to the server-side JavaScript API documentation. + */ + create(body: TriggerDefinition, options?: RequestOptions): Promise; + } + + /** + * Enum for trigger type values. + * Specifies the type of the trigger. + */ + export declare enum TriggerType { + /** Trigger should be executed before the associated operation(s). */ + Pre = "pre", + /** Trigger should be executed after the associated operation(s). */ + Post = "post" + } + + /** Interface for a single unique key passed as part of UniqueKeyPolicy */ + export declare interface UniqueKey { + paths: string[]; + } + + /** Interface for setting unique keys on container creation */ + export declare interface UniqueKeyPolicy { + uniqueKeys: UniqueKey[]; + } + + export declare type UpsertOperation = OperationWithItem & { + operationType: typeof BulkOperationType.Upsert; + }; + + export declare interface UpsertOperationInput { + partitionKey?: PartitionKey; + ifMatch?: string; + ifNoneMatch?: string; + operationType: typeof BulkOperationType.Upsert; + resourceBody: JSONObject; + } + + /** + * Used to read, replace, and delete Users. + * + * Additionally, you can access the permissions for a given user via `user.permission` and `user.permissions`. + * + * @see {@link Users} to create, upsert, query, or read all. + */ + export declare class User { + readonly database: Database; + readonly id: string; + private readonly clientContext; + /** + * Operations for creating, upserting, querying, or reading all operations. + * + * See `client.permission(id)` to read, replace, or delete a specific Permission by id. + */ + readonly permissions: Permissions_2; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database: Database, id: string, clientContext: ClientContext); + /** + * Operations to read, replace, or delete a specific Permission by id. + * + * See `client.permissions` for creating, upserting, querying, or reading all operations. + */ + permission(id: string): Permission; + /** + * Read the {@link UserDefinition} for the given {@link User}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link User}'s definition with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition} to replace the definition. + */ + replace(body: UserDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link User}. + */ + delete(options?: RequestOptions): Promise; + } + + /** + * Used to read, replace, or delete a specified User Definied Function by id. + * + * @see {@link UserDefinedFunction} to create, upsert, query, read all User Defined Functions. + */ + export declare class UserDefinedFunction { + readonly container: Container; + readonly id: string; + private readonly clientContext; + /** + * Returns a reference URL to the resource. Used for linking in Permissions. + */ + get url(): string; + /** + * @hidden + * @param container - The parent {@link Container}. + * @param id - The id of the given {@link UserDefinedFunction}. + */ + constructor(container: Container, id: string, clientContext: ClientContext); + /** + * Read the {@link UserDefinedFunctionDefinition} for the given {@link UserDefinedFunction}. + */ + read(options?: RequestOptions): Promise; + /** + * Replace the given {@link UserDefinedFunction} with the specified {@link UserDefinedFunctionDefinition}. + * @param options - + */ + replace(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise; + /** + * Delete the given {@link UserDefined}. + */ + delete(options?: RequestOptions): Promise; + } + + export declare interface UserDefinedFunctionDefinition { + /** The id of the {@link UserDefinedFunction} */ + id?: string; + /** The body of the user defined function, it can also be passed as a stringifed function */ + body?: string | (() => void); + } + + export declare class UserDefinedFunctionResponse extends ResourceResponse { + constructor(resource: UserDefinedFunctionDefinition & Resource, headers: CosmosHeaders, statusCode: number, udf: UserDefinedFunction, diagnostics: CosmosDiagnostics); + /** A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. */ + readonly userDefinedFunction: UserDefinedFunction; + /** + * Alias for `userDefinedFunction(id)`. + * + * A reference to the {@link UserDefinedFunction} corresponding to the returned {@link UserDefinedFunctionDefinition}. + */ + get udf(): UserDefinedFunction; + } + + /** + * Used to create, upsert, query, or read all User Defined Functions. + * + * @see {@link UserDefinedFunction} to read, replace, or delete a given User Defined Function by id. + */ + export declare class UserDefinedFunctions { + readonly container: Container; + private readonly clientContext; + /** + * @hidden + * @param container - The parent {@link Container}. + */ + constructor(container: Container, clientContext: ClientContext); + /** + * Query all User Defined Functions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all User Defined Functions. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all User Defined Functions. + * @example Read all User Defined Functions to array. + * ```typescript + * const {body: udfList} = await container.userDefinedFunctions.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a UserDefinedFunction. + * + * Azure Cosmos DB supports JavaScript UDFs which can be used inside queries, stored procedures and triggers. + * + * For additional details, refer to the server-side JavaScript API documentation. + * + */ + create(body: UserDefinedFunctionDefinition, options?: RequestOptions): Promise; + } + + /** + * Enum for udf type values. + * Specifies the types of user defined functions. + */ + export declare enum UserDefinedFunctionType { + /** The User Defined Function is written in JavaScript. This is currently the only option. */ + Javascript = "Javascript" + } + + export declare interface UserDefinition { + /** The id of the user. */ + id?: string; + } + + export declare class UserResponse extends ResourceResponse { + constructor(resource: UserDefinition & Resource, headers: CosmosHeaders, statusCode: number, user: User, diagnostics: CosmosDiagnostics); + /** A reference to the {@link User} corresponding to the returned {@link UserDefinition}. */ + readonly user: User; + } + + /** + * Used to create, upsert, query, and read all users. + * + * @see {@link User} to read, replace, or delete a specific User by id. + */ + export declare class Users { + readonly database: Database; + private readonly clientContext; + /** + * @hidden + * @param database - The parent {@link Database}. + */ + constructor(database: Database, clientContext: ClientContext); + /** + * Query all users. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Query all users. + * @param query - Query configuration for the operation. See {@link SqlQuerySpec} for more info on how to configure a query. + */ + query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; + /** + * Read all users.- + * @example Read all users to array. + * ```typescript + * const {body: usersList} = await database.users.readAll().fetchAll(); + * ``` + */ + readAll(options?: FeedOptions): QueryIterator; + /** + * Create a database user with the specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + create(body: UserDefinition, options?: RequestOptions): Promise; + /** + * Upsert a database user with a specified {@link UserDefinition}. + * @param body - The specified {@link UserDefinition}. + */ + upsert(body: UserDefinition, options?: RequestOptions): Promise; + } + + /** + * Represents a vector embedding. + * A vector embedding is used to define a vector field in the documents. + */ + export declare interface VectorEmbedding { + /** + * The path to the vector field in the document. + */ + path: string; + /** + * The number of dimensions in the vector. + */ + dimensions: number; + /** + * The data type of the vector. + */ + dataType: "float16" | "float32" | "uint8" | "int8"; + /** + * The distance function to use for distance calculation in between vectors. + */ + distanceFunction: "euclidean" | "cosine" | "dotproduct"; + } + + /** + * Represents the policy configuration for vector embeddings in the Azure Cosmos DB service. + */ + export declare interface VectorEmbeddingPolicy { + /** + * The vector embeddings to be configured. + */ + vectorEmbeddings: VectorEmbedding[]; + } + + /** + * Represents a vector index in the Azure Cosmos DB service. + * A vector index is used to index vector fields in the documents. + */ + export declare interface VectorIndex { + /** + * The path to the vector field in the document. + * for example, path: "/path/to/vector". + */ + path: string; + /** + * The index type of the vector. + * Currently, flat, diskANN, and quantizedFlat are supported. + */ + type: "flat" | "diskANN" | "quantizedFlat"; + } + + declare type VerboseOmit = Pick>; + + export { } diff --git a/local_dependencies/@azure/cosmos/dist/types/latest/tsdoc-metadata.json b/local_dependencies/@azure/cosmos/dist/types/latest/tsdoc-metadata.json new file mode 100644 index 000000000..a34accfb0 --- /dev/null +++ b/local_dependencies/@azure/cosmos/dist/types/latest/tsdoc-metadata.json @@ -0,0 +1,11 @@ +// This file is read by tools that parse documentation comments conforming to the TSDoc standard. +// It should be published with your NPM package. It should not be tracked by Git. +{ + "tsdocVersion": "0.12", + "toolPackages": [ + { + "packageName": "@microsoft/api-extractor", + "packageVersion": "7.39.0" + } + ] +} diff --git a/local_dependencies/@azure/cosmos/package.json b/local_dependencies/@azure/cosmos/package.json new file mode 100644 index 000000000..b1b902af3 --- /dev/null +++ b/local_dependencies/@azure/cosmos/package.json @@ -0,0 +1,136 @@ +{ + "name": "@azure/cosmos", + "version": "4.0.1-beta.3", + "description": "Microsoft Azure Cosmos DB Service Node.js SDK for NOSQL API", + "sdk-type": "client", + "keywords": [ + "cosmosdb", + "cosmos db", + "documentdb", + "document database", + "azure", + "nosql", + "database", + "cloud", + "azure" + ], + "author": "Microsoft Corporation", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "react-native": "./dist-esm/src/index.js", + "browser": { + "./dist-esm/src/request/defaultAgent.js": "./dist-esm/src/request/defaultAgent.browser.js", + "./dist-esm/src/utils/atob.js": "./dist-esm/src/utils/atob.browser.js", + "./dist-esm/src/utils/digest.js": "./dist-esm/src/utils/digest.browser.js", + "./dist-esm/src/utils/hmac.js": "./dist-esm/src/utils/hmac.browser.js" + }, + "files": [ + "changelog.md", + "dist/", + "dist-esm/src/", + "README.md", + "LICENSE" + ], + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/cosmosdb/cosmos/README.md", + "sideEffects": false, + "//metadata": { + "constantPaths": [ + { + "path": "src/common/constants.ts", + "prefix": "SDKVersion" + } + ] + }, + "types": "./dist/types/latest/cosmos.d.ts", + "engines": { + "node": ">=18.0.0" + }, + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:samples": "echo Obsolete.", + "check:src:strict": "tsc --pretty --project tsconfig.strict.json", + "build:src": "echo Using TypeScript && tsc --version && tsc -b --pretty", + "build:test": "tsc", + "build": "npm run clean && npm run extract-api && npm run bundle", + "bundle": "dev-tool run bundle", + "bundle-types": "node bundle-types.js", + "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"samples-dev/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "clean": "rimraf dist dist-esm temp types *.tgz *.html *.log *.tsbuildinfo test/**/*.{js,js.map,d.ts}", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "npm run check:src:strict && npm run build:src && api-extractor run --local", + "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"samples-dev/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "integration-test:browser": "echo skipped", + "integration-test:node": "cross-env NODE_OPTIONS='--dns-result-order=ipv4first' mocha -r test/mocha.env.ts -r ts-node/register -r esm -r dotenv/config -r ./test/public/common/setup.ts --reporter ../../../common/tools/mocha-multi-reporter.js \"./test/internal/**/*.spec.ts\" \"./test/public/**/*.spec.ts\" --timeout 100000", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", + "lint": "eslint package.json api-extractor.json src test --ext .ts", + "pack": "npm pack 2>&1", + "test:browser": "npm run unit-test:browser && npm run integration-test:browser", + "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", + "test-consumer": "rimraf consumer-test/node_modules consumer-test/package-lock.json && node consumer-test.js 2>&1", + "test": "npm run unit-test && npm run integration-test", + "test:signoff": "npm run integration-test:node -- --fgrep \"nosignoff\" --invert", + "unit-test:browser": "echo skipped", + "unit-test:node": "echo skipped", + "unit-test": "npm run unit-test:node && npm run unit-test:browser" + }, + "repository": "github:Azure/azure-sdk-for-js", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "tsdoc": { + "tsdocFlavor": "AEDoc" + }, + "dependencies": { + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.2.0", + "@azure/core-tracing": "^1.0.0", + "debug": "^4.1.1", + "fast-json-stable-stringify": "^2.1.0", + "jsbi": "^3.1.3", + "node-abort-controller": "^3.0.0", + "priorityqueuejs": "^2.0.0", + "semaphore": "^1.0.5", + "tslib": "^2.2.0", + "universal-user-agent": "^6.0.0", + "uuid": "^8.3.0", + "@azure/abort-controller": "^1.0.0" + }, + "//sampleConfiguration": { + "skip": [ + "AADAuth.ts", + "AlterQueryThroughput.ts", + "Bulk.ts", + "BulkUpdateWithSproc.ts", + "ChangeFeed.ts", + "ContainerManagement.ts", + "ItemManagement.ts", + "IndexManagement.ts", + "DatabaseManagement.ts", + "QueryThroughput.ts", + "SasTokenAuth.ts", + "ServerSideScripts.ts", + "handleError.ts", + "ChangeFeedIteratorEntireContainer.ts", + "ChangeFeedIteratorEpkRange.ts", + "ChangeFeedPartitionKey.ts", + "ChangeFeedHierarchicalPartitionKey.ts", + "Diagnostics.ts", + "HierarchicalPartitioning.ts" + ], + "productName": "Azure Cosmos DB", + "productSlugs": [ + "azure-cosmos-db" + ], + "requiredResources": { + "Azure Cosmos DB account": "https://docs.microsoft.com/azure/cosmos-db/how-to-manage-database-account#create-an-account" + }, + "extraFiles": { + "./samples-dev/Data/Families.json": [ + "typescript/src/Data/Families.json", + "javascript/Data/Families.json" + ] + } + } +} diff --git a/package-lock.json b/package-lock.json index c05feec0a..2a5364c62 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "dependencies": { "@azure/arm-cosmosdb": "9.1.0", - "@azure/cosmos": "4.2.0-beta.1", + "@azure/cosmos": "4.0.1-beta.3", "@azure/cosmos-language-service": "0.0.5", "@azure/identity": "1.5.2", "@azure/ms-rest-nodeauth": "3.1.1", @@ -204,6 +204,10 @@ "webpack-dev-server": "4.15.2" } }, + "canvas": { + "version": "1.0.0", + "license": "ISC" + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "license": "MIT", @@ -378,20 +382,23 @@ "license": "0BSD" }, "node_modules/@azure/cosmos": { - "version": "4.2.0-beta.1", - "resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-4.2.0-beta.1.tgz", - "integrity": "sha512-mREONehm1DxjEKXGaNU6Wmpf9Ckb9IrhKFXhDFVs45pxmoEb3y2s/Ub0owuFmqlphpcS1zgtYQn5exn+lwnJuQ==", + "version": "4.0.1-beta.3", + "resolved": "https://registry.npmjs.org/@azure/cosmos/-/cosmos-4.0.1-beta.3.tgz", + "integrity": "sha512-CpRGt+S5jnvtGUi4TmlS79YvxpbNc8/5/QHgIvvQ9D2ZFUqO0MjbMCU3lVZV2NAJT02BsbLfRAFe+FPn8nMRQw==", "dependencies": { - "@azure/abort-controller": "^2.0.0", - "@azure/core-auth": "^1.7.1", - "@azure/core-rest-pipeline": "^1.15.1", - "@azure/core-tracing": "^1.1.1", - "@azure/core-util": "^1.8.1", + "@azure/abort-controller": "^1.0.0", + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.2.0", + "@azure/core-tracing": "^1.0.0", + "debug": "^4.1.1", "fast-json-stable-stringify": "^2.1.0", - "jsbi": "^4.3.0", + "jsbi": "^3.1.3", + "node-abort-controller": "^3.0.0", "priorityqueuejs": "^2.0.0", - "semaphore": "^1.1.0", - "tslib": "^2.6.2" + "semaphore": "^1.0.5", + "tslib": "^2.2.0", + "universal-user-agent": "^6.0.0", + "uuid": "^8.3.0" }, "engines": { "node": ">=18.0.0" @@ -425,7 +432,8 @@ }, "node_modules/@azure/cosmos/node_modules/tslib": { "version": "2.6.2", - "license": "0BSD" + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/@azure/identity": { "version": "1.5.2", diff --git a/src/ConfigContext.ts b/src/ConfigContext.ts index b0cffbe05..64f1f71dd 100644 --- a/src/ConfigContext.ts +++ b/src/ConfigContext.ts @@ -202,7 +202,7 @@ export function updateConfigContext(newContext: Partial): void { if (process.env.NODE_ENV === "development") { updateConfigContext({ PROXY_PATH: "/proxy", - EMULATOR_ENDPOINT: "https://localhost:10443", + EMULATOR_ENDPOINT: "https://localhost:8081", PORTAL_BACKEND_ENDPOINT: PortalBackendEndpoints.Mpac, MONGO_PROXY_ENDPOINT: MongoProxyEndpoints.Mpac, CASSANDRA_PROXY_ENDPOINT: CassandraProxyEndpoints.Mpac, diff --git a/src/Utils/EndpointUtils.ts b/src/Utils/EndpointUtils.ts index 349d7df0c..3172deed3 100644 --- a/src/Utils/EndpointUtils.ts +++ b/src/Utils/EndpointUtils.ts @@ -131,7 +131,7 @@ export const CassandraProxyOutboundIPs: { [key: string]: string[] } = { [CassandraProxyEndpoints.Mooncake]: ["40.73.99.146", "143.64.62.47"], }; -export const allowedEmulatorEndpoints: ReadonlyArray = ["https://localhost:10443"]; +export const allowedEmulatorEndpoints: ReadonlyArray = ["https://localhost:8081"]; export const allowedMongoBackendEndpoints: ReadonlyArray = ["https://localhost:1234"]; diff --git a/src/quickstart.html b/src/quickstart.html index 4922c2e60..e369724e6 100644 --- a/src/quickstart.html +++ b/src/quickstart.html @@ -14,7 +14,7 @@

Now, let's connect a sample app to it.

URI

- +

Primary Key

Mongo Connection String