From c58f0e96f4ccbf7c72b337a06ae96d33f9cc4d87 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:06 -0500 Subject: [PATCH 01/45] Migration: Update package.json, tsconfig.json, and api-extractor.json --- sdk/cosmosdb/cosmos/api-extractor.json | 4 +- sdk/cosmosdb/cosmos/package.json | 48 ++++++++++--------- ...nt.browser.ts => defaultAgent-browser.mts} | 0 .../{atob.browser.ts => atob-browser.mts} | 0 .../{digest.browser.ts => digest-browser.mts} | 0 ...vUtils.browser.ts => envUtils-browser.mts} | 0 .../{hmac.browser.ts => hmac-browser.mts} | 0 sdk/cosmosdb/cosmos/tsconfig.json | 26 +++++++--- 8 files changed, 47 insertions(+), 31 deletions(-) rename sdk/cosmosdb/cosmos/src/request/{defaultAgent.browser.ts => defaultAgent-browser.mts} (100%) rename sdk/cosmosdb/cosmos/src/utils/{atob.browser.ts => atob-browser.mts} (100%) rename sdk/cosmosdb/cosmos/src/utils/{digest.browser.ts => digest-browser.mts} (100%) rename sdk/cosmosdb/cosmos/src/utils/{envUtils.browser.ts => envUtils-browser.mts} (100%) rename sdk/cosmosdb/cosmos/src/utils/{hmac.browser.ts => hmac-browser.mts} (100%) diff --git a/sdk/cosmosdb/cosmos/api-extractor.json b/sdk/cosmosdb/cosmos/api-extractor.json index 7ff0ac6b0c2d..4211b71d79c3 100644 --- a/sdk/cosmosdb/cosmos/api-extractor.json +++ b/sdk/cosmosdb/cosmos/api-extractor.json @@ -1,6 +1,6 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/api-extractor.schema.json", - "mainEntryPointFilePath": "./dist-esm/src/index.d.ts", + "mainEntryPointFilePath": "dist/esm/index.d.ts", "docModel": { "enabled": true }, @@ -11,7 +11,7 @@ "dtsRollup": { "enabled": true, "untrimmedFilePath": "", - "publicTrimmedFilePath": "./dist/types/latest/cosmos.d.ts" + "publicTrimmedFilePath": "dist/cosmos.d.ts" }, "messages": { "tsdocMessageReporting": { diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 61254fca837a..cd39f82e342d 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -17,18 +17,9 @@ "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", - "./dist-esm/src/utils/envUtils.js": "./dist-esm/src/utils/envUtils.browser.js" - }, + "browser": "./dist/browser/index.js", "files": [ - "changelog.md", "dist/", - "dist-esm/src/", "README.md", "LICENSE" ], @@ -47,7 +38,7 @@ "node": ">=18.0.0" }, "scripts": { - "build": "npm run clean && npm run extract-api && npm run bundle", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", "build:samples": "echo Obsolete.", "build:src": "echo Using TypeScript && tsc --version && tsc -b --pretty", "build:test": "tsc", @@ -71,8 +62,8 @@ "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", "test:signoff": "npm run integration-test:node -- --fgrep \"nosignoff\" --invert", "unit-test": "npm run unit-test:node && npm run unit-test:browser", - "unit-test:browser": "echo skipped", - "unit-test:node": "echo skipped", + "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser", + "unit-test:node": "dev-tool run test:vitest", "update-snippets": "echo skipped" }, "repository": "github:Azure/azure-sdk-for-js", @@ -96,31 +87,28 @@ "tslib": "^2.6.2" }, "devDependencies": { + "@azure-tools/test-utils-vitest": "^1.0.0", "@azure/dev-tool": "^1.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0", "@azure/identity": "^4.0.1", "@azure/logger": "^1.0.0", "@sinonjs/fake-timers": "^11.0.0", - "@types/chai": "~4.3.6", "@types/debug": "^4.1.4", - "@types/mocha": "^10.0.0", "@types/node": "^18.0.0", "@types/priorityqueuejs": "^1.0.1", "@types/semaphore": "^1.1.0", - "@types/sinon": "^17.0.0", "@types/sinonjs__fake-timers": "~8.1.2", "@types/underscore": "^1.8.8", - "chai": "~4.3.8", + "@vitest/browser": "^2.1.8", + "@vitest/coverage-istanbul": "^2.1.8", "dotenv": "^16.0.0", "eslint": "^9.9.0", "execa": "^5.0.0", - "mocha": "^10.0.0", "nock": "^13.5.4", + "playwright": "^1.49.0", "requirejs": "^2.3.5", - "sinon": "^17.0.0", - "source-map-support": "^0.5.9", - "ts-node": "^10.0.0", - "typescript": "~5.6.2" + "typescript": "~5.6.2", + "vitest": "^2.1.8" }, "//sampleConfiguration": { "skip": [ @@ -157,5 +145,21 @@ "javascript/Data/Families.json" ] } + }, + "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false } } diff --git a/sdk/cosmosdb/cosmos/src/request/defaultAgent.browser.ts b/sdk/cosmosdb/cosmos/src/request/defaultAgent-browser.mts similarity index 100% rename from sdk/cosmosdb/cosmos/src/request/defaultAgent.browser.ts rename to sdk/cosmosdb/cosmos/src/request/defaultAgent-browser.mts diff --git a/sdk/cosmosdb/cosmos/src/utils/atob.browser.ts b/sdk/cosmosdb/cosmos/src/utils/atob-browser.mts similarity index 100% rename from sdk/cosmosdb/cosmos/src/utils/atob.browser.ts rename to sdk/cosmosdb/cosmos/src/utils/atob-browser.mts diff --git a/sdk/cosmosdb/cosmos/src/utils/digest.browser.ts b/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts similarity index 100% rename from sdk/cosmosdb/cosmos/src/utils/digest.browser.ts rename to sdk/cosmosdb/cosmos/src/utils/digest-browser.mts diff --git a/sdk/cosmosdb/cosmos/src/utils/envUtils.browser.ts b/sdk/cosmosdb/cosmos/src/utils/envUtils-browser.mts similarity index 100% rename from sdk/cosmosdb/cosmos/src/utils/envUtils.browser.ts rename to sdk/cosmosdb/cosmos/src/utils/envUtils-browser.mts diff --git a/sdk/cosmosdb/cosmos/src/utils/hmac.browser.ts b/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts similarity index 100% rename from sdk/cosmosdb/cosmos/src/utils/hmac.browser.ts rename to sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts diff --git a/sdk/cosmosdb/cosmos/tsconfig.json b/sdk/cosmosdb/cosmos/tsconfig.json index 0d2abe3c9f6c..314c7c675ce3 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.json +++ b/sdk/cosmosdb/cosmos/tsconfig.json @@ -1,24 +1,36 @@ { "extends": "../../../tsconfig", "compilerOptions": { - "module": "esnext", + "module": "NodeNext", "strict": false, "noImplicitAny": true, "noImplicitReturns": false, "noFallthroughCasesInSwitch": false, - "outDir": "./dist-esm", "preserveConstEnums": true, "removeComments": false, "target": "ES2017", "newLine": "LF", "resolveJsonModule": true, - "lib": ["es2019"], - "moduleResolution": "node", + "lib": [ + "es2019" + ], + "moduleResolution": "NodeNext", "composite": true, "stripInternal": true, "paths": { - "@azure/cosmos": ["./src/index"] - } + "@azure/cosmos": [ + "./src/index" + ] + }, + "rootDir": "." }, - "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.(ts|json)"] + "include": [ + "src/**/*.ts", + "src/**/*.mts", + "src/**/*.cts", + "samples-dev/**/*.ts", + "test/**/*.ts", + "test/**/*.mts", + "test/**/*.cts" + ] } From 6ab182b38dda255fb2d9c662b800370fd3c5e709 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:07 -0500 Subject: [PATCH 02/45] Migration: Update test config --- .../cosmos/tsconfig.browser.config.json | 17 +++++++++++++++++ sdk/cosmosdb/cosmos/vitest.browser.config.ts | 17 +++++++++++++++++ sdk/cosmosdb/cosmos/vitest.config.ts | 15 +++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 sdk/cosmosdb/cosmos/tsconfig.browser.config.json create mode 100644 sdk/cosmosdb/cosmos/vitest.browser.config.ts create mode 100644 sdk/cosmosdb/cosmos/vitest.config.ts diff --git a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json new file mode 100644 index 000000000000..b6586181d006 --- /dev/null +++ b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json @@ -0,0 +1,17 @@ +{ + "extends": "./.tshy/build.json", + "include": [ + "./src/**/*.ts", + "./src/**/*.mts", + "./test/**/*.spec.ts", + "./test/**/*.mts" + ], + "exclude": [ + "./test/**/node/**/*.ts" + ], + "compilerOptions": { + "outDir": "./dist-test/browser", + "rootDir": ".", + "skipLibCheck": true + } +} diff --git a/sdk/cosmosdb/cosmos/vitest.browser.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.config.ts new file mode 100644 index 000000000000..b48c61b2ef46 --- /dev/null +++ b/sdk/cosmosdb/cosmos/vitest.browser.config.ts @@ -0,0 +1,17 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.browser.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: [ + "dist-test/browser/test/**/*.spec.js", + ], + }, + }), +); diff --git a/sdk/cosmosdb/cosmos/vitest.config.ts b/sdk/cosmosdb/cosmos/vitest.config.ts new file mode 100644 index 000000000000..39267dd2f56f --- /dev/null +++ b/sdk/cosmosdb/cosmos/vitest.config.ts @@ -0,0 +1,15 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ["test/**/*.spec.ts"], + }, + }), +); From 98a392644c57afef76d830f2a36b0599afe342d0 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:07 -0500 Subject: [PATCH 03/45] Migration: Clean up files From f388a8bc0d1bad0038c027b01ce8327414e0ed83 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:09 -0500 Subject: [PATCH 04/45] Migration: Apply codemod: "fixSourceFile" --- .../samples-dev/AlterQueryThroughput.ts | 2 +- sdk/cosmosdb/cosmos/samples-dev/Bulk.ts | 2 +- .../cosmos/samples-dev/BulkUpdateWithSproc.ts | 2 +- sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts | 2 +- .../ChangeFeedHierarchicalPartitionKey.ts | 2 +- ...ChangeFeedIteratorAllVersionsAndDeletes.ts | 2 +- .../ChangeFeedIteratorLatestVersion.ts | 2 +- .../cosmos/samples-dev/ContainerManagement.ts | 2 +- .../cosmos/samples-dev/DatabaseManagement.ts | 4 +- .../cosmos/samples-dev/Diagnostics.ts | 2 +- sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts | 2 +- .../samples-dev/HierarchicalPartitioning.ts | 2 +- .../cosmos/samples-dev/IndexManagement.ts | 2 +- .../cosmos/samples-dev/ItemManagement.ts | 4 +- .../samples-dev/Query/FullTextSearch.ts | 2 +- .../cosmos/samples-dev/SasTokenAuth.ts | 2 +- .../cosmos/samples-dev/ServerSideScripts.ts | 2 +- sdk/cosmosdb/cosmos/src/ChangeFeedIterator.ts | 20 +++--- sdk/cosmosdb/cosmos/src/ChangeFeedResponse.ts | 6 +- sdk/cosmosdb/cosmos/src/ClientContext.ts | 64 +++++++++---------- sdk/cosmosdb/cosmos/src/CosmosClient.ts | 36 +++++------ .../cosmos/src/CosmosClientOptions.ts | 12 ++-- sdk/cosmosdb/cosmos/src/CosmosDiagnostics.ts | 8 +-- sdk/cosmosdb/cosmos/src/auth.ts | 10 +-- .../ChangeFeed/ChangeFeedForEpkRange.ts | 34 +++++----- .../ChangeFeed/ChangeFeedForPartitionKey.ts | 26 ++++---- .../ChangeFeed/ChangeFeedIteratorOptions.ts | 4 +- .../ChangeFeed/ChangeFeedIteratorResponse.ts | 6 +- .../src/client/ChangeFeed/ChangeFeedPolicy.ts | 2 +- .../ChangeFeed/ChangeFeedPullModelIterator.ts | 4 +- .../ChangeFeed/ChangeFeedRetentionTimeSpan.ts | 2 +- .../client/ChangeFeed/ChangeFeedStartFrom.ts | 16 ++--- .../ChangeFeedStartFromBeginning.ts | 4 +- .../ChangeFeedStartFromContinuation.ts | 4 +- .../ChangeFeed/ChangeFeedStartFromNow.ts | 4 +- .../ChangeFeed/ChangeFeedStartFromTime.ts | 4 +- .../ChangeFeed/CompositeContinuationToken.ts | 2 +- .../ContinuationTokenForPartitionKey.ts | 2 +- .../cosmos/src/client/ChangeFeed/FeedRange.ts | 2 +- .../src/client/ChangeFeed/FeedRangeQueue.ts | 2 +- .../ChangeFeed/InternalChangeFeedOptions.ts | 2 +- .../ChangeFeed/changeFeedIteratorBuilder.ts | 38 +++++------ .../src/client/ChangeFeed/changeFeedUtils.ts | 22 +++---- .../cosmos/src/client/ChangeFeed/index.ts | 24 +++---- sdk/cosmosdb/cosmos/src/client/ClientUtils.ts | 6 +- .../cosmos/src/client/Conflict/Conflict.ts | 22 +++---- .../src/client/Conflict/ConflictDefinition.ts | 2 +- .../Conflict/ConflictResolutionPolicy.ts | 2 +- .../src/client/Conflict/ConflictResponse.ts | 12 ++-- .../cosmos/src/client/Conflict/Conflicts.ts | 18 +++--- .../cosmos/src/client/Conflict/index.ts | 12 ++-- .../cosmos/src/client/Container/Container.ts | 48 +++++++------- .../client/Container/ContainerDefinition.ts | 16 ++--- .../src/client/Container/ContainerRequest.ts | 6 +- .../src/client/Container/ContainerResponse.ts | 12 ++-- .../cosmos/src/client/Container/Containers.ts | 32 +++++----- .../cosmos/src/client/Container/index.ts | 14 ++-- .../cosmos/src/client/Database/Database.ts | 28 ++++---- .../src/client/Database/DatabaseRequest.ts | 2 +- .../src/client/Database/DatabaseResponse.ts | 12 ++-- .../cosmos/src/client/Database/Databases.ts | 30 ++++----- .../cosmos/src/client/Database/index.ts | 10 +-- sdk/cosmosdb/cosmos/src/client/Item/Item.ts | 26 ++++---- .../cosmos/src/client/Item/ItemResponse.ts | 12 ++-- sdk/cosmosdb/cosmos/src/client/Item/Items.ts | 50 +++++++-------- sdk/cosmosdb/cosmos/src/client/Item/index.ts | 8 +-- sdk/cosmosdb/cosmos/src/client/Offer/Offer.ts | 16 ++--- .../cosmos/src/client/Offer/OfferResponse.ts | 12 ++-- .../cosmos/src/client/Offer/Offers.ts | 16 ++--- sdk/cosmosdb/cosmos/src/client/Offer/index.ts | 8 +-- .../src/client/Permission/Permission.ts | 18 +++--- .../client/Permission/PermissionDefinition.ts | 2 +- .../client/Permission/PermissionResponse.ts | 14 ++-- .../src/client/Permission/Permissions.ts | 26 ++++---- .../cosmos/src/client/Permission/index.ts | 10 +-- .../src/client/SasToken/SasTokenProperties.ts | 4 +- .../cosmos/src/client/Script/Scripts.ts | 10 +-- .../client/StoredProcedure/StoredProcedure.ts | 24 +++---- .../StoredProcedureResponse.ts | 12 ++-- .../StoredProcedure/StoredProcedures.ts | 24 +++---- .../src/client/StoredProcedure/index.ts | 8 +-- .../cosmos/src/client/Trigger/Trigger.ts | 16 ++--- .../src/client/Trigger/TriggerDefinition.ts | 2 +- .../src/client/Trigger/TriggerResponse.ts | 12 ++-- .../cosmos/src/client/Trigger/Triggers.ts | 24 +++---- .../cosmos/src/client/Trigger/index.ts | 8 +-- sdk/cosmosdb/cosmos/src/client/User/User.ts | 18 +++--- .../cosmos/src/client/User/UserResponse.ts | 12 ++-- sdk/cosmosdb/cosmos/src/client/User/Users.ts | 24 +++---- sdk/cosmosdb/cosmos/src/client/User/index.ts | 8 +-- .../UserDefinedFunction.ts | 16 ++--- .../UserDefinedFunctionResponse.ts | 12 ++-- .../UserDefinedFunctions.ts | 24 +++---- .../src/client/UserDefinedFunction/index.ts | 8 +-- sdk/cosmosdb/cosmos/src/client/index.ts | 24 +++---- sdk/cosmosdb/cosmos/src/common/helper.ts | 6 +- sdk/cosmosdb/cosmos/src/common/index.ts | 8 +-- sdk/cosmosdb/cosmos/src/common/platform.ts | 2 +- sdk/cosmosdb/cosmos/src/common/uriFactory.ts | 4 +- .../diagnostics/CosmosDiagnosticsContext.ts | 4 +- .../src/diagnostics/DiagnosticFormatter.ts | 2 +- .../src/diagnostics/DiagnosticNodeInternal.ts | 20 +++--- .../diagnostics/diagnosticLevelComparator.ts | 2 +- sdk/cosmosdb/cosmos/src/diagnostics/index.ts | 12 ++-- .../cosmos/src/documents/ConnectionPolicy.ts | 4 +- .../cosmos/src/documents/DatabaseAccount.ts | 6 +- .../cosmos/src/documents/IndexingPolicy.ts | 2 +- .../cosmos/src/documents/PartitionKey.ts | 2 +- .../src/documents/PartitionKeyDefinition.ts | 4 +- .../src/documents/PartitionKeyInternal.ts | 2 +- sdk/cosmosdb/cosmos/src/documents/index.ts | 46 ++++++------- .../cosmos/src/extractPartitionKey.ts | 14 ++-- .../cosmos/src/globalEndpointManager.ts | 18 +++--- sdk/cosmosdb/cosmos/src/index.ts | 62 +++++++++--------- .../src/indexMetrics/IndexMetricWriter.ts | 8 +-- .../src/indexMetrics/IndexUtilizationInfo.ts | 4 +- sdk/cosmosdb/cosmos/src/indexMetrics/index.ts | 8 +-- sdk/cosmosdb/cosmos/src/plugins/Plugin.ts | 6 +- .../Aggregators/AverageAggregator.ts | 2 +- .../Aggregators/CountAggregator.ts | 2 +- .../Aggregators/GlobalStatisticsAggregator.ts | 4 +- .../Aggregators/MakeListAggregator.ts | 2 +- .../Aggregators/MakeSetAggregator.ts | 2 +- .../Aggregators/MaxAggregator.ts | 4 +- .../Aggregators/MinAggregator.ts | 4 +- .../Aggregators/StaticValueAggregator.ts | 2 +- .../Aggregators/SumAggregator.ts | 2 +- .../Aggregators/index.ts | 20 +++--- .../GroupByEndpointComponent.ts | 20 +++--- .../GroupByValueEndpointComponent.ts | 20 +++--- ...reamingOrderByDistinctEndpointComponent.ts | 20 +++--- .../NonStreamingOrderByEndpointComponent.ts | 14 ++-- .../OffsetLimitEndpointComponent.ts | 8 +-- .../OrderByEndpointComponent.ts | 6 +- .../OrderedDistinctEndpointComponent.ts | 8 +-- .../UnorderedDistinctEndpointComponent.ts | 8 +-- .../queryExecutionContext/ExecutionContext.ts | 4 +- .../defaultQueryExecutionContext.ts | 18 +++--- .../queryExecutionContext/documentProducer.ts | 24 +++---- .../src/queryExecutionContext/headerUtils.ts | 4 +- .../hybridQueryExecutionContext.ts | 20 +++--- .../cosmos/src/queryExecutionContext/index.ts | 26 ++++---- .../nonStreamingOrderByResponse.ts | 4 +- .../orderByComparator.ts | 2 +- .../orderByDocumentProducerComparator.ts | 2 +- .../orderByQueryExecutionContext.ts | 16 ++--- .../parallelQueryExecutionContext.ts | 6 +- .../parallelQueryExecutionContextBase.ts | 30 ++++----- .../pipelinedQueryExecutionContext.ts | 38 +++++------ sdk/cosmosdb/cosmos/src/queryIterator.ts | 26 ++++---- sdk/cosmosdb/cosmos/src/queryMetrics/index.ts | 12 ++-- .../cosmos/src/queryMetrics/queryMetrics.ts | 12 ++-- .../src/queryMetrics/queryMetricsUtils.ts | 2 +- .../src/queryMetrics/queryPreparationTime.ts | 6 +- .../src/queryMetrics/runtimeExecutionTimes.ts | 6 +- .../cosmos/src/request/ErrorResponse.ts | 2 +- .../cosmos/src/request/FeedOptions.ts | 4 +- .../cosmos/src/request/FeedResponse.ts | 10 +-- .../cosmos/src/request/RequestContext.ts | 18 +++--- .../cosmos/src/request/RequestHandler.ts | 30 ++++----- .../cosmos/src/request/RequestOptions.ts | 2 +- .../cosmos/src/request/ResourceResponse.ts | 8 +-- sdk/cosmosdb/cosmos/src/request/Response.ts | 2 +- .../cosmos/src/request/SharedOptions.ts | 4 +- .../src/request/defaultAgent-browser.mts | 2 +- .../cosmos/src/request/defaultAgent.ts | 2 +- .../src/request/hybridSearchQueryResult.ts | 2 +- sdk/cosmosdb/cosmos/src/request/index.ts | 22 +++---- sdk/cosmosdb/cosmos/src/request/request.ts | 16 ++--- sdk/cosmosdb/cosmos/src/retry/RetryPolicy.ts | 6 +- .../cosmos/src/retry/defaultRetryPolicy.ts | 10 +-- .../src/retry/endpointDiscoveryRetryPolicy.ts | 14 ++-- sdk/cosmosdb/cosmos/src/retry/index.ts | 12 ++-- .../src/retry/resourceThrottleRetryPolicy.ts | 4 +- sdk/cosmosdb/cosmos/src/retry/retryUtility.ts | 34 +++++----- .../cosmos/src/retry/sessionRetryPolicy.ts | 16 ++--- .../src/retry/timeoutFailoverRetryPolicy.ts | 22 +++---- .../routing/CollectionRoutingMapFactory.ts | 4 +- sdk/cosmosdb/cosmos/src/routing/QueryRange.ts | 6 +- .../routing/inMemoryCollectionRoutingMap.ts | 6 +- sdk/cosmosdb/cosmos/src/routing/index.ts | 8 +-- .../src/routing/partitionKeyRangeCache.ts | 18 +++--- .../src/routing/smartRoutingMapProvider.ts | 10 +-- .../cosmos/src/session/SessionContext.ts | 2 +- .../cosmos/src/session/sessionContainer.ts | 12 ++-- sdk/cosmosdb/cosmos/src/utils/SasToken.ts | 8 +-- sdk/cosmosdb/cosmos/src/utils/batch.ts | 18 +++--- sdk/cosmosdb/cosmos/src/utils/diagnostics.ts | 14 ++-- .../cosmos/src/utils/digest-browser.mts | 4 +- sdk/cosmosdb/cosmos/src/utils/digest.ts | 2 +- sdk/cosmosdb/cosmos/src/utils/envUtils.ts | 2 +- sdk/cosmosdb/cosmos/src/utils/hashObject.ts | 2 +- .../src/utils/hashing/encoding/number.ts | 2 +- .../src/utils/hashing/encoding/string.ts | 2 +- sdk/cosmosdb/cosmos/src/utils/hashing/hash.ts | 10 +-- .../cosmos/src/utils/hashing/multiHash.ts | 4 +- sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts | 10 +-- sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts | 8 +-- sdk/cosmosdb/cosmos/src/utils/headers.ts | 6 +- .../cosmos/src/utils/hmac-browser.mts | 6 +- sdk/cosmosdb/cosmos/src/utils/hmac.ts | 2 +- sdk/cosmosdb/cosmos/src/utils/offers.ts | 2 +- .../utils/supportedQueryFeaturesBuilder.ts | 2 +- sdk/cosmosdb/cosmos/src/utils/tracing.ts | 2 +- sdk/cosmosdb/cosmos/src/utils/typeChecks.ts | 4 +- .../cosmos/test/internal/session.spec.ts | 24 +++---- .../cosmos/test/internal/unit/auth.spec.ts | 4 +- .../changeFeedRetentionTimeSpan.spec.ts | 4 +- .../unit/changeFeed/changeFeedUtils.spec.ts | 14 ++-- .../unit/changeFeed/feedRangeQueue.spec.ts | 6 +- .../cosmos/test/internal/unit/client.spec.ts | 14 ++-- .../unit/defaultQueryExecutionContext.spec.ts | 14 ++-- .../test/internal/unit/diagnostics.spec.ts | 16 ++--- .../test/internal/unit/getHeader.spec.ts | 8 +-- .../unit/globalStatisticsAggregator.spec.ts | 6 +- .../test/internal/unit/hashing/v1.spec.ts | 4 +- .../test/internal/unit/hashing/v2.spec.ts | 4 +- .../cosmos/test/internal/unit/helper.spec.ts | 4 +- .../unit/inMemoryCollectionRoutingMap.spec.ts | 6 +- .../test/internal/unit/platform.spec.ts | 6 +- .../test/internal/unit/sasToken.spec.ts | 14 ++-- .../internal/unit/sessionContainer.spec.ts | 10 +-- .../unit/smartRoutingMapProvider.spec.ts | 10 +-- .../unit/timeoutFailoverRetryPolicy.spec.ts | 24 +++---- .../test/internal/unit/utils/batch.spec.ts | 8 +-- .../test/internal/unit/utils/checkURL.spec.ts | 4 +- .../unit/utils/nonStreamingOrderByMap.spec.ts | 4 +- .../nonStreamingOrderByPriorityQueue.spec.ts | 4 +- .../test/internal/unit/utils/offer.spec.ts | 6 +- .../supportedQueryFeaturesBuilder.spec.ts | 6 +- .../test/public/common/MockClientContext.ts | 2 +- .../cosmos/test/public/common/TestHelpers.ts | 26 ++++---- .../cosmos/test/public/common/setup.ts | 2 +- .../NonStreamingQueryPolicy.spec.ts | 12 ++-- .../public/functional/authorization.spec.ts | 12 ++-- .../test/public/functional/client.spec.ts | 14 ++-- .../functional/computedProperties.spec.ts | 10 +-- .../test/public/functional/conflict.spec.ts | 6 +- .../test/public/functional/container.spec.ts | 20 +++--- .../test/public/functional/database.spec.ts | 14 ++-- .../public/functional/databaseaccount.spec.ts | 12 ++-- ...ngOrderByDistinctEndpointComponent.spec.ts | 8 +-- ...nStreamingOrderByEndpointComponent.spec.ts | 6 +- .../functional/globalEndpointManager.spec.ts | 14 ++-- .../public/functional/item/batch.item.spec.ts | 20 +++--- .../public/functional/item/bulk.item.spec.ts | 26 ++++---- .../test/public/functional/item/item.spec.ts | 22 +++---- .../functional/item/itemIdEncoding.spec.ts | 6 +- .../public/functional/npcontainer.spec.ts | 14 ++-- .../test/public/functional/offer.spec.ts | 12 ++-- .../test/public/functional/permission.spec.ts | 8 +-- .../test/public/functional/plugin.spec.ts | 14 ++-- .../test/public/functional/query.spec.ts | 16 ++--- .../public/functional/queryIterator.spec.ts | 12 ++-- .../test/public/functional/spatial.spec.ts | 8 +-- .../test/public/functional/sproc.spec.ts | 14 ++-- .../test/public/functional/trigger.spec.ts | 8 +-- .../cosmos/test/public/functional/ttl.spec.ts | 8 +-- .../cosmos/test/public/functional/udf.spec.ts | 6 +- .../test/public/functional/user.spec.ts | 6 +- .../cosmos/test/public/indexMetrics.spec.ts | 4 +- .../public/integration/aggregateQuery.spec.ts | 18 +++--- .../integration/aggregates/groupBy.spec.ts | 10 +-- .../public/integration/authorization.spec.ts | 12 ++-- .../public/integration/changeFeed.spec.ts | 10 +-- .../integration/changeFeedIterator.spec.ts | 18 +++--- .../public/integration/client.retry.spec.ts | 14 ++-- .../public/integration/crossPartition.spec.ts | 16 ++--- .../test/public/integration/encoding.spec.ts | 6 +- .../integration/extractPartitionKey.spec.ts | 4 +- .../test/public/integration/failover.spec.ts | 10 +-- .../public/integration/fullTextSearch.spec.ts | 8 +-- .../public/integration/multiregion.spec.ts | 12 ++-- .../nonStreamingDistinctOrderBy.spec.ts | 16 ++--- .../nonStreamingOrderBy.spec.ts | 16 ++--- .../test/public/integration/query.spec.ts | 6 +- .../public/integration/queryMetrics.spec.ts | 4 +- .../test/public/integration/split.spec.ts | 16 ++--- .../integration/sslVerification.spec.ts | 8 +-- .../test/public/integration/timeout.spec.ts | 12 ++-- 280 files changed, 1531 insertions(+), 1531 deletions(-) diff --git a/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts b/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts index 0e025090a462..4bc4da53ffc4 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { finish, handleError, logStep, logSampleHeader } from "./Shared/handleError"; +import { finish, handleError, logStep, logSampleHeader } from "./Shared/handleError.js"; import { CosmosClient, OfferDefinition, diff --git a/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts b/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts index 2d0e6eb93e3a..19a8e4bdafee 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { handleError, finish, logStep } from "./Shared/handleError"; +import { handleError, finish, logStep } from "./Shared/handleError.js"; import { BulkOperationType, CosmosClient, diff --git a/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts b/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts index 1b2eec2ca2b9..b012fb269812 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError"; +import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError.js"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { CosmosClient } from "@azure/cosmos"; diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts index 593434efbb45..e136d54c0b67 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { finish, handleError, logSampleHeader } from "./Shared/handleError"; +import { finish, handleError, logSampleHeader } from "./Shared/handleError.js"; import { CosmosClient } from "@azure/cosmos"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts index dc2c9644464f..29c5e06b4d56 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { finish, handleError, logSampleHeader } from "../Shared/handleError"; +import { finish, handleError, logSampleHeader } from "../Shared/handleError.js"; import { CosmosClient, PartitionKeyDefinitionVersion, diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts index 6065c3514d15..c355520d5c95 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { finish, handleError, logSampleHeader, logStep } from "../Shared/handleError"; +import { finish, handleError, logSampleHeader, logStep } from "../Shared/handleError.js"; import { CosmosClient, PartitionKeyDefinitionVersion, diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts index 6931fbeb9321..38ec46603fd6 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { finish, handleError, logSampleHeader, logStep } from "../Shared/handleError"; +import { finish, handleError, logSampleHeader, logStep } from "../Shared/handleError.js"; import { CosmosClient, PartitionKeyDefinitionVersion, diff --git a/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts index ae24c6ba785e..bda9b9bab69f 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { finish, handleError, logStep, logSampleHeader } from "./Shared/handleError"; +import { finish, handleError, logStep, logSampleHeader } from "./Shared/handleError.js"; import { ContainerDefinition, CosmosClient, diff --git a/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts index 911e160883c8..aa6a1ddd7e4c 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts @@ -8,9 +8,9 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { handleError, logStep, logSampleHeader, finish } from "./Shared/handleError"; +import { handleError, logStep, logSampleHeader, finish } from "./Shared/handleError.js"; import { CosmosClient } from "@azure/cosmos"; -import assert from "assert"; +import assert from "node:assert"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts b/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts index 31bf370c6762..975d13c7e1cd 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { handleError, logSampleHeader, finish } from "./Shared/handleError"; +import { handleError, logSampleHeader, finish } from "./Shared/handleError.js"; import { CosmosClient, BulkOperationType, diff --git a/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts b/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts index 1a7b71d1f832..73356e58efef 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts @@ -12,7 +12,7 @@ import { UsernamePasswordCredential } from "@azure/identity"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore import { CosmosClient } from "@azure/cosmos"; -import { handleError, finish, logStep } from "./Shared/handleError"; +import { handleError, finish, logStep } from "./Shared/handleError.js"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts b/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts index c254cd4e46b2..4a96575dbb68 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { handleError, logSampleHeader, finish } from "./Shared/handleError"; +import { handleError, logSampleHeader, finish } from "./Shared/handleError.js"; import { CosmosClient, BulkOperationType, diff --git a/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts index 8117fe12afc2..f6d303758409 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError"; +import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError.js"; import { CosmosClient, IndexKind, diff --git a/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts index e8e6d12e3e2e..95f9996a9e06 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts @@ -8,10 +8,10 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError"; +import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError.js"; import { CosmosClient, PatchOperation, PriorityLevel } from "@azure/cosmos"; -import { Families } from "./Data/Families.json"; +import { Families } from "./Data/Families.json.js"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts b/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts index 5a917a5380c8..8c807bef0026 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { finish, handleError, logSampleHeader } from "./../Shared/handleError"; +import { finish, handleError, logSampleHeader } from "./../Shared/handleError.js"; import { CosmosClient, IndexingPolicy } from "@azure/cosmos"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts b/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts index dfd2f7ed2106..c63bd12bb862 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts @@ -14,7 +14,7 @@ import { createAuthorizationSasToken, SasTokenPermissionKind, } from "@azure/cosmos"; -import { handleError, finish, logStep } from "./Shared/handleError"; +import { handleError, finish, logStep } from "./Shared/handleError.js"; const masterKey = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const sasToken = "your-sas-token"; diff --git a/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts b/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts index b8af039fb77d..42a735761f0b 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts @@ -8,7 +8,7 @@ import * as dotenv from "dotenv"; dotenv.config(); -import { logSampleHeader, logStep, finish, handleError } from "./Shared/handleError"; +import { logSampleHeader, logStep, finish, handleError } from "./Shared/handleError.js"; import { CosmosClient, ErrorResponse, FeedOptions, Item, Resource } from "@azure/cosmos"; logSampleHeader("Server Side Scripts"); const key = process.env.COSMOS_KEY || ""; diff --git a/sdk/cosmosdb/cosmos/src/ChangeFeedIterator.ts b/sdk/cosmosdb/cosmos/src/ChangeFeedIterator.ts index 2fb13dc951d9..ebc2435b7f20 100644 --- a/sdk/cosmosdb/cosmos/src/ChangeFeedIterator.ts +++ b/sdk/cosmosdb/cosmos/src/ChangeFeedIterator.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /// -import type { ChangeFeedOptions } from "./ChangeFeedOptions"; -import { ChangeFeedResponse } from "./ChangeFeedResponse"; -import type { Resource } from "./client"; -import type { ClientContext } from "./ClientContext"; -import { Constants, ResourceType, StatusCodes } from "./common"; -import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; -import type { PartitionKey } from "./documents"; -import type { FeedOptions } from "./request"; -import type { Response } from "./request"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "./utils/diagnostics"; +import type { ChangeFeedOptions } from "./ChangeFeedOptions.js"; +import { ChangeFeedResponse } from "./ChangeFeedResponse.js"; +import type { Resource } from "./client/index.js"; +import type { ClientContext } from "./ClientContext.js"; +import { Constants, ResourceType, StatusCodes } from "./common/index.js"; +import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js"; +import type { PartitionKey } from "./documents/index.js"; +import type { FeedOptions } from "./request/index.js"; +import type { Response } from "./request/index.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "./utils/diagnostics.js"; /** * Provides iterator for change feed. diff --git a/sdk/cosmosdb/cosmos/src/ChangeFeedResponse.ts b/sdk/cosmosdb/cosmos/src/ChangeFeedResponse.ts index a6109c6eea86..27c56c37d296 100644 --- a/sdk/cosmosdb/cosmos/src/ChangeFeedResponse.ts +++ b/sdk/cosmosdb/cosmos/src/ChangeFeedResponse.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "./CosmosDiagnostics"; -import { Constants } from "./common"; -import type { CosmosHeaders } from "./queryExecutionContext"; +import type { CosmosDiagnostics } from "./CosmosDiagnostics.js"; +import { Constants } from "./common/index.js"; +import type { CosmosHeaders } from "./queryExecutionContext/index.js"; /** * A single response page from the Azure Cosmos DB Change Feed diff --git a/sdk/cosmosdb/cosmos/src/ClientContext.ts b/sdk/cosmosdb/cosmos/src/ClientContext.ts index 16a4bcd22ce5..4bbcced1a067 100644 --- a/sdk/cosmosdb/cosmos/src/ClientContext.ts +++ b/sdk/cosmosdb/cosmos/src/ClientContext.ts @@ -3,40 +3,40 @@ import type { HttpClient, Pipeline } from "@azure/core-rest-pipeline"; import { bearerTokenAuthenticationPolicy, createEmptyPipeline } from "@azure/core-rest-pipeline"; -import type { PartitionKeyRange } from "./client/Container/PartitionKeyRange"; -import type { Resource } from "./client/Resource"; -import { Constants, HTTPMethod, OperationType, ResourceType } from "./common/constants"; -import { getIdFromLink, getPathFromLink, parseLink } from "./common/helper"; -import { StatusCodes, SubStatusCodes } from "./common/statusCodes"; -import type { Agent, CosmosClientOptions } from "./CosmosClientOptions"; -import type { ConnectionPolicy, PartitionKey } from "./documents"; -import { ConsistencyLevel, DatabaseAccount, convertToInternalPartitionKey } from "./documents"; -import type { GlobalEndpointManager } from "./globalEndpointManager"; -import type { PluginConfig } from "./plugins/Plugin"; -import { PluginOn, executePlugins } from "./plugins/Plugin"; -import type { FetchFunctionCallback, SqlQuerySpec } from "./queryExecutionContext"; -import type { CosmosHeaders } from "./queryExecutionContext/CosmosHeaders"; -import { QueryIterator } from "./queryIterator"; -import type { ErrorResponse } from "./request"; -import type { FeedOptions, RequestOptions, Response } from "./request"; -import type { PartitionedQueryExecutionInfo } from "./request/ErrorResponse"; -import { getHeaders } from "./request/request"; -import type { RequestContext } from "./request/RequestContext"; -import { RequestHandler } from "./request/RequestHandler"; -import { SessionContainer } from "./session/sessionContainer"; -import type { SessionContext } from "./session/SessionContext"; -import type { BulkOptions } from "./utils/batch"; -import { sanitizeEndpoint } from "./utils/checkURL"; -import { supportedQueryFeaturesBuilder } from "./utils/supportedQueryFeaturesBuilder"; +import type { PartitionKeyRange } from "./client/Container/PartitionKeyRange.js"; +import type { Resource } from "./client/Resource.js"; +import { Constants, HTTPMethod, OperationType, ResourceType } from "./common/constants.js"; +import { getIdFromLink, getPathFromLink, parseLink } from "./common/helper.js"; +import { StatusCodes, SubStatusCodes } from "./common/statusCodes.js"; +import type { Agent, CosmosClientOptions } from "./CosmosClientOptions.js"; +import type { ConnectionPolicy, PartitionKey } from "./documents/index.js"; +import { ConsistencyLevel, DatabaseAccount, convertToInternalPartitionKey } from "./documents/index.js"; +import type { GlobalEndpointManager } from "./globalEndpointManager.js"; +import type { PluginConfig } from "./plugins/Plugin.js"; +import { PluginOn, executePlugins } from "./plugins/Plugin.js"; +import type { FetchFunctionCallback, SqlQuerySpec } from "./queryExecutionContext/index.js"; +import type { CosmosHeaders } from "./queryExecutionContext/CosmosHeaders.js"; +import { QueryIterator } from "./queryIterator.js"; +import type { ErrorResponse } from "./request/index.js"; +import type { FeedOptions, RequestOptions, Response } from "./request/index.js"; +import type { PartitionedQueryExecutionInfo } from "./request/ErrorResponse.js"; +import { getHeaders } from "./request/request.js"; +import type { RequestContext } from "./request/RequestContext.js"; +import { RequestHandler } from "./request/RequestHandler.js"; +import { SessionContainer } from "./session/sessionContainer.js"; +import type { SessionContext } from "./session/SessionContext.js"; +import type { BulkOptions } from "./utils/batch.js"; +import { sanitizeEndpoint } from "./utils/checkURL.js"; +import { supportedQueryFeaturesBuilder } from "./utils/supportedQueryFeaturesBuilder.js"; import type { AzureLogger } from "@azure/logger"; import { createClientLogger } from "@azure/logger"; -import type { ClientConfigDiagnostic, CosmosDiagnostics } from "./CosmosDiagnostics"; -import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; -import type { DiagnosticWriter } from "./diagnostics/DiagnosticWriter"; -import { LogDiagnosticWriter, NoOpDiagnosticWriter } from "./diagnostics/DiagnosticWriter"; -import type { DiagnosticFormatter } from "./diagnostics/DiagnosticFormatter"; -import { DefaultDiagnosticFormatter } from "./diagnostics/DiagnosticFormatter"; -import { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +import type { ClientConfigDiagnostic, CosmosDiagnostics } from "./CosmosDiagnostics.js"; +import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js"; +import type { DiagnosticWriter } from "./diagnostics/DiagnosticWriter.js"; +import { LogDiagnosticWriter, NoOpDiagnosticWriter } from "./diagnostics/DiagnosticWriter.js"; +import type { DiagnosticFormatter } from "./diagnostics/DiagnosticFormatter.js"; +import { DefaultDiagnosticFormatter } from "./diagnostics/DiagnosticFormatter.js"; +import { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel.js"; import { randomUUID } from "@azure/core-util"; const logger: AzureLogger = createClientLogger("ClientContext"); diff --git a/sdk/cosmosdb/cosmos/src/CosmosClient.ts b/sdk/cosmosdb/cosmos/src/CosmosClient.ts index f72c337654e0..4c5396fc713f 100644 --- a/sdk/cosmosdb/cosmos/src/CosmosClient.ts +++ b/sdk/cosmosdb/cosmos/src/CosmosClient.ts @@ -1,23 +1,23 @@ // 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 type { CosmosClientOptions } from "./CosmosClientOptions"; -import type { ClientConfigDiagnostic } from "./CosmosDiagnostics"; -import { determineDiagnosticLevel, getDiagnosticLevelFromEnvironment } from "./diagnostics"; -import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; -import { DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal"; -import type { DatabaseAccount } from "./documents"; -import { defaultConnectionPolicy } from "./documents"; -import { GlobalEndpointManager } from "./globalEndpointManager"; -import type { RequestOptions } from "./request"; -import { ResourceResponse } from "./request"; -import { checkURL } from "./utils/checkURL"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "./utils/diagnostics"; +import { Database, Databases } from "./client/Database/index.js"; +import { Offer, Offers } from "./client/Offer/index.js"; +import { ClientContext } from "./ClientContext.js"; +import { parseConnectionString } from "./common/index.js"; +import { Constants } from "./common/constants.js"; +import { getUserAgent } from "./common/platform.js"; +import type { CosmosClientOptions } from "./CosmosClientOptions.js"; +import type { ClientConfigDiagnostic } from "./CosmosDiagnostics.js"; +import { determineDiagnosticLevel, getDiagnosticLevelFromEnvironment } from "./diagnostics/index.js"; +import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js"; +import { DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal.js"; +import type { DatabaseAccount } from "./documents/index.js"; +import { defaultConnectionPolicy } from "./documents/index.js"; +import { GlobalEndpointManager } from "./globalEndpointManager.js"; +import type { RequestOptions } from "./request/index.js"; +import { ResourceResponse } from "./request/index.js"; +import { checkURL } from "./utils/checkURL.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "./utils/diagnostics.js"; /** * Provides a client-side logical representation of the Azure Cosmos DB database account. diff --git a/sdk/cosmosdb/cosmos/src/CosmosClientOptions.ts b/sdk/cosmosdb/cosmos/src/CosmosClientOptions.ts index 02de08505ea9..15d829b69e72 100644 --- a/sdk/cosmosdb/cosmos/src/CosmosClientOptions.ts +++ b/sdk/cosmosdb/cosmos/src/CosmosClientOptions.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import type { TokenCredential } from "@azure/core-auth"; -import type { TokenProvider } from "./auth"; -import type { PermissionDefinition } from "./client"; -import type { ConnectionPolicy, ConsistencyLevel } from "./documents"; -import type { PluginConfig } from "./plugins/Plugin"; -import type { CosmosHeaders } from "./queryExecutionContext/CosmosHeaders"; -import type { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +import type { TokenProvider } from "./auth.js"; +import type { PermissionDefinition } from "./client/index.js"; +import type { ConnectionPolicy, ConsistencyLevel } from "./documents/index.js"; +import type { PluginConfig } from "./plugins/Plugin.js"; +import type { CosmosHeaders } from "./queryExecutionContext/CosmosHeaders.js"; +import type { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel.js"; import type { HttpClient } from "@azure/core-rest-pipeline"; // We expose our own Agent interface to avoid taking a dependency on and leaking node types. This interface should mirror the node Agent interface diff --git a/sdk/cosmosdb/cosmos/src/CosmosDiagnostics.ts b/sdk/cosmosdb/cosmos/src/CosmosDiagnostics.ts index 54e9de89d421..eb95c60c538b 100644 --- a/sdk/cosmosdb/cosmos/src/CosmosDiagnostics.ts +++ b/sdk/cosmosdb/cosmos/src/CosmosDiagnostics.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { OperationType, ResourceType } from "./common"; -import type { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; -import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; -import type { ConsistencyLevel } from "./documents"; +import type { OperationType, ResourceType } from "./common/index.js"; +import type { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel.js"; +import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js"; +import type { ConsistencyLevel } from "./documents/index.js"; /** * * This is a Cosmos Diagnostic type that holds collected diagnostic information during a client operations. ie. Item.read(), Container.create(). diff --git a/sdk/cosmosdb/cosmos/src/auth.ts b/sdk/cosmosdb/cosmos/src/auth.ts index 4d85bc7a4f72..e2a95e0f99a4 100644 --- a/sdk/cosmosdb/cosmos/src/auth.ts +++ b/sdk/cosmosdb/cosmos/src/auth.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { generateHeaders } from "./utils/headers"; -import type { HTTPMethod } from "./common"; +import { generateHeaders } from "./utils/headers.js"; +import type { HTTPMethod } from "./common/index.js"; import { Constants, getResourceIdFromPath, ResourceType, trimSlashFromLeftAndRight, -} from "./common"; -import type { CosmosClientOptions } from "./CosmosClientOptions"; -import type { CosmosHeaders } from "./queryExecutionContext"; +} from "./common/index.js"; +import type { CosmosClientOptions } from "./CosmosClientOptions.js"; +import type { CosmosHeaders } from "./queryExecutionContext/index.js"; /** @hidden */ export interface RequestInfo { diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForEpkRange.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForEpkRange.ts index 915253736743..8d2af6ec63c4 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForEpkRange.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForEpkRange.ts @@ -1,22 +1,22 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ChangeFeedRange } from "./ChangeFeedRange"; -import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; -import type { PartitionKeyRangeCache } from "../../routing"; -import { QueryRange } from "../../routing"; -import { FeedRangeQueue } from "./FeedRangeQueue"; -import type { ClientContext } from "../../ClientContext"; -import type { Container, Resource } from "../../client"; -import { Constants, SubStatusCodes, StatusCodes, ResourceType } from "../../common"; -import type { Response, FeedOptions } from "../../request"; -import { ErrorResponse } from "../../request"; -import { CompositeContinuationToken } from "./CompositeContinuationToken"; -import type { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator"; -import { extractOverlappingRanges } from "./changeFeedUtils"; -import type { InternalChangeFeedIteratorOptions } from "./InternalChangeFeedOptions"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; -import { ChangeFeedMode } from "./ChangeFeedMode"; +import { ChangeFeedRange } from "./ChangeFeedRange.js"; +import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse.js"; +import type { PartitionKeyRangeCache } from "../../routing/index.js"; +import { QueryRange } from "../../routing/index.js"; +import { FeedRangeQueue } from "./FeedRangeQueue.js"; +import type { ClientContext } from "../../ClientContext.js"; +import type { Container, Resource } from "../../client/index.js"; +import { Constants, SubStatusCodes, StatusCodes, ResourceType } from "../../common/index.js"; +import type { Response, FeedOptions } from "../../request/index.js"; +import { ErrorResponse } from "../../request/index.js"; +import { CompositeContinuationToken } from "./CompositeContinuationToken.js"; +import type { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator.js"; +import { extractOverlappingRanges } from "./changeFeedUtils.js"; +import type { InternalChangeFeedIteratorOptions } from "./InternalChangeFeedOptions.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; +import { ChangeFeedMode } from "./ChangeFeedMode.js"; /** * @hidden * Provides iterator for change feed for entire container or an epk range. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForPartitionKey.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForPartitionKey.ts index fa72b5d44d59..cb3f2fb3c5fa 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForPartitionKey.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForPartitionKey.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { InternalChangeFeedIteratorOptions } from "./InternalChangeFeedOptions"; -import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; -import type { Container, Resource } from "../../client"; -import type { ClientContext } from "../../ClientContext"; -import { Constants, ResourceType, StatusCodes } from "../../common"; -import type { FeedOptions, Response } from "../../request"; -import { ErrorResponse } from "../../request"; -import { ContinuationTokenForPartitionKey } from "./ContinuationTokenForPartitionKey"; -import type { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator"; -import type { PartitionKey } from "../../documents"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; -import { ChangeFeedMode } from "./ChangeFeedMode"; +import type { InternalChangeFeedIteratorOptions } from "./InternalChangeFeedOptions.js"; +import { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse.js"; +import type { Container, Resource } from "../../client/index.js"; +import type { ClientContext } from "../../ClientContext.js"; +import { Constants, ResourceType, StatusCodes } from "../../common/index.js"; +import type { FeedOptions, Response } from "../../request/index.js"; +import { ErrorResponse } from "../../request/index.js"; +import { ContinuationTokenForPartitionKey } from "./ContinuationTokenForPartitionKey.js"; +import type { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator.js"; +import type { PartitionKey } from "../../documents/index.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; +import { ChangeFeedMode } from "./ChangeFeedMode.js"; /** * @hidden * Provides iterator for change feed for one partition key. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorOptions.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorOptions.ts index 4b6896e25f80..9102e566d381 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorOptions.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorOptions.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ChangeFeedStartFrom } from "./ChangeFeedStartFrom"; -import type { ChangeFeedMode } from "./ChangeFeedMode"; +import type { ChangeFeedStartFrom } from "./ChangeFeedStartFrom.js"; +import type { ChangeFeedMode } from "./ChangeFeedMode.js"; /** * Specifies options for the change feed * diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorResponse.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorResponse.ts index 0fa30f3fab09..85a5c827a128 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedIteratorResponse.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import { Constants } from "../../common"; -import type { CosmosHeaders } from "../../queryExecutionContext"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import { Constants } from "../../common/index.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; /** * A single response page from the Azure Cosmos DB Change Feed diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPolicy.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPolicy.ts index 07a959ba2a1d..e01099da4ee3 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPolicy.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ChangeFeedRetentionTimeSpan } from "./ChangeFeedRetentionTimeSpan"; +import type { ChangeFeedRetentionTimeSpan } from "./ChangeFeedRetentionTimeSpan.js"; /** * Represents the change feed policy configuration for a container in the Azure Cosmos DB service. */ diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPullModelIterator.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPullModelIterator.ts index 6004c8ada2cb..619837df6855 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPullModelIterator.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedPullModelIterator.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Resource } from "../Resource"; -import type { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse"; +import type { Resource } from "../Resource.js"; +import type { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse.js"; /** * Use `Items.getChangeFeedIterator()` to return an iterator that can iterate over all the changes for a partition key, feed range or an entire container. */ diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedRetentionTimeSpan.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedRetentionTimeSpan.ts index f4214e5fec2a..8ec7a0c49988 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedRetentionTimeSpan.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedRetentionTimeSpan.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ErrorResponse } from "../../request"; +import { ErrorResponse } from "../../request/index.js"; /* * Represents the change feed policy configuration for a container in the Azure Cosmos DB service. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFrom.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFrom.ts index 7becdef9133e..9eb2021e6219 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFrom.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFrom.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKey } from "../../documents"; -import type { FeedRange } from "./FeedRange"; -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"; +import type { PartitionKey } from "../../documents/index.js"; +import type { FeedRange } from "./FeedRange.js"; +import { ChangeFeedStartFromNow } from "./ChangeFeedStartFromNow.js"; +import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning.js"; +import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime.js"; +import { ChangeFeedStartFromContinuation } from "./ChangeFeedStartFromContinuation.js"; +import { ErrorResponse } from "../../request/ErrorResponse.js"; +import { isNullOrEmpty } from "./changeFeedUtils.js"; /** * Base class for where to start a ChangeFeedIterator. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromBeginning.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromBeginning.ts index ddca435efb34..273896e557f4 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromBeginning.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromBeginning.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKey } from "../../documents"; -import type { FeedRange } from "./FeedRange"; +import type { PartitionKey } from "../../documents/index.js"; +import type { FeedRange } from "./FeedRange.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromContinuation.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromContinuation.ts index b5997cdf4103..ef422f3bdc7d 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromContinuation.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromContinuation.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ErrorResponse } from "../../request"; -import { ChangeFeedResourceType } from "./ChangeFeedEnums"; +import { ErrorResponse } from "../../request/index.js"; +import { ChangeFeedResourceType } from "./ChangeFeedEnums.js"; /** * @hidden * Class which specifies the ChangeFeedIterator to start reading changes from a saved point. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromNow.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromNow.ts index cf7aba4776b8..5143cd80df90 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromNow.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromNow.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKey } from "../../documents"; -import type { FeedRange } from "./FeedRange"; +import type { PartitionKey } from "../../documents/index.js"; +import type { FeedRange } from "./FeedRange.js"; /** * @hidden * Class which specifies the ChangeFeedIterator to start reading changes from this moment in time. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromTime.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromTime.ts index 9ce0c3ba43a4..2915a0a9ef50 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromTime.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedStartFromTime.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKey } from "../../documents"; -import type { FeedRange } from "./FeedRange"; +import type { PartitionKey } from "../../documents/index.js"; +import type { FeedRange } from "./FeedRange.js"; /** * @hidden * Class which specifies the ChangeFeedIterator to start reading changes from a particular point of time. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/CompositeContinuationToken.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/CompositeContinuationToken.ts index 8cc2102aba85..6bc3ff61c99e 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/CompositeContinuationToken.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/CompositeContinuationToken.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ChangeFeedRange } from "./ChangeFeedRange"; +import type { ChangeFeedRange } from "./ChangeFeedRange.js"; /** * Continuation token for change feed of entire container, or a specific Epk Range. * @internal diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ContinuationTokenForPartitionKey.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ContinuationTokenForPartitionKey.ts index 9cd6acc23ccd..4fc207b46cc9 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ContinuationTokenForPartitionKey.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/ContinuationTokenForPartitionKey.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKey } from "../../documents"; +import type { PartitionKey } from "../../documents/index.js"; /** * Continuation token for change feed of entire container, or a specific Epk Range. * @internal diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRange.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRange.ts index d4128ec4953d..445d2045977c 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRange.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRange.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ErrorResponse } from "../../request"; +import { ErrorResponse } from "../../request/index.js"; /** * Specifies a feed range for the changefeed. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRangeQueue.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRangeQueue.ts index f8adf72c94e4..827fa707727a 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRangeQueue.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/FeedRangeQueue.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ChangeFeedRange } from "./ChangeFeedRange"; +import { ChangeFeedRange } from "./ChangeFeedRange.js"; /** * @hidden * A queue for iterating over specified Epk ranges and fetch change feed for the given epk ranges. diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/InternalChangeFeedOptions.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/InternalChangeFeedOptions.ts index 8d34e109d9e3..787f91a21c3e 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/InternalChangeFeedOptions.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/InternalChangeFeedOptions.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ChangeFeedMode } from "./ChangeFeedMode"; +import type { ChangeFeedMode } from "./ChangeFeedMode.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedIteratorBuilder.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedIteratorBuilder.ts index af90a08e2b1f..d772f028154b 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedIteratorBuilder.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedIteratorBuilder.ts @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { PartitionKey } from "../../documents"; -import type { PartitionKeyRangeCache } from "../../routing"; -import { QueryRange } from "../../routing"; -import type { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions"; -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"; -import type { Container } from "../Container"; -import type { FeedRangeInternal } from "./FeedRange"; +import type { ClientContext } from "../../ClientContext.js"; +import type { PartitionKey } from "../../documents/index.js"; +import type { PartitionKeyRangeCache } from "../../routing/index.js"; +import { QueryRange } from "../../routing/index.js"; +import type { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions.js"; +import { ChangeFeedStartFrom } from "./ChangeFeedStartFrom.js"; +import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning.js"; +import { ChangeFeedStartFromContinuation } from "./ChangeFeedStartFromContinuation.js"; +import { ChangeFeedStartFromNow } from "./ChangeFeedStartFromNow.js"; +import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime.js"; +import { ChangeFeedResourceType } from "./ChangeFeedEnums.js"; +import { ChangeFeedForPartitionKey } from "./ChangeFeedForPartitionKey.js"; +import { ErrorResponse } from "../../request/index.js"; +import { ChangeFeedForEpkRange } from "./ChangeFeedForEpkRange.js"; +import { getIdFromLink, getPathFromLink, ResourceType, Constants } from "../../common/index.js"; +import { buildInternalChangeFeedOptions, fetchStartTime, isEpkRange } from "./changeFeedUtils.js"; +import { isPartitionKey } from "../../utils/typeChecks.js"; +import type { Container } from "../Container/index.js"; +import type { FeedRangeInternal } from "./FeedRange.js"; export function changeFeedIteratorBuilder( cfOptions: ChangeFeedIteratorOptions, diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedUtils.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedUtils.ts index 642582c17e1a..84d1dc62f9cf 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedUtils.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/changeFeedUtils.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions"; -import { ErrorResponse } from "../../request"; -import type { PartitionKeyRange } from "../Container"; -import type { InternalChangeFeedIteratorOptions } from "./InternalChangeFeedOptions"; -import { isPrimitivePartitionKeyValue } from "../../utils/typeChecks"; -import type { ChangeFeedStartFrom } from "./ChangeFeedStartFrom"; -import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning"; -import { Constants } from "../../common"; -import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime"; -import type { QueryRange } from "../../routing"; -import { FeedRangeInternal } from "./FeedRange"; +import type { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions.js"; +import { ErrorResponse } from "../../request/index.js"; +import type { PartitionKeyRange } from "../Container/index.js"; +import type { InternalChangeFeedIteratorOptions } from "./InternalChangeFeedOptions.js"; +import { isPrimitivePartitionKeyValue } from "../../utils/typeChecks.js"; +import type { ChangeFeedStartFrom } from "./ChangeFeedStartFrom.js"; +import { ChangeFeedStartFromBeginning } from "./ChangeFeedStartFromBeginning.js"; +import { Constants } from "../../common/index.js"; +import { ChangeFeedStartFromTime } from "./ChangeFeedStartFromTime.js"; +import type { QueryRange } from "../../routing/index.js"; +import { FeedRangeInternal } from "./FeedRange.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/index.ts b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/index.ts index 60e21520f695..2445b49a5322 100644 --- a/sdk/cosmosdb/cosmos/src/client/ChangeFeed/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/ChangeFeed/index.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -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 { ChangeFeedMode } from "./ChangeFeedMode"; -export { buildInternalChangeFeedOptions } from "./changeFeedUtils"; -export { changeFeedIteratorBuilder } from "./changeFeedIteratorBuilder"; -export { ChangeFeedRetentionTimeSpan } from "./ChangeFeedRetentionTimeSpan"; -export { ChangeFeedPolicy } from "./ChangeFeedPolicy"; +export { ChangeFeedForEpkRange } from "./ChangeFeedForEpkRange.js"; +export { ChangeFeedIteratorOptions } from "./ChangeFeedIteratorOptions.js"; +export { ChangeFeedForPartitionKey } from "./ChangeFeedForPartitionKey.js"; +export { ChangeFeedIteratorResponse } from "./ChangeFeedIteratorResponse.js"; +export { ChangeFeedPullModelIterator } from "./ChangeFeedPullModelIterator.js"; +export { FeedRangeInternal, FeedRange } from "./FeedRange.js"; +export { ChangeFeedStartFrom } from "./ChangeFeedStartFrom.js"; +export { ChangeFeedMode } from "./ChangeFeedMode.js"; +export { buildInternalChangeFeedOptions } from "./changeFeedUtils.js"; +export { changeFeedIteratorBuilder } from "./changeFeedIteratorBuilder.js"; +export { ChangeFeedRetentionTimeSpan } from "./ChangeFeedRetentionTimeSpan.js"; +export { ChangeFeedPolicy } from "./ChangeFeedPolicy.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/ClientUtils.ts b/sdk/cosmosdb/cosmos/src/client/ClientUtils.ts index 3f3c6675edb8..d1487221b853 100644 --- a/sdk/cosmosdb/cosmos/src/client/ClientUtils.ts +++ b/sdk/cosmosdb/cosmos/src/client/ClientUtils.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { PartitionKeyDefinition } from "../documents"; -import type { Container } from "./Container"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { PartitionKeyDefinition } from "../documents/index.js"; +import type { Container } from "./Container/index.js"; export async function readPartitionKeyDefinition( diagnosticNode: DiagnosticNodeInternal, diff --git a/sdk/cosmosdb/cosmos/src/client/Conflict/Conflict.ts b/sdk/cosmosdb/cosmos/src/client/Conflict/Conflict.ts index 799d115afcea..2f26003a284d 100644 --- a/sdk/cosmosdb/cosmos/src/client/Conflict/Conflict.ts +++ b/sdk/cosmosdb/cosmos/src/client/Conflict/Conflict.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import { Constants, getIdFromLink, getPathFromLink, ResourceType } from "../../common"; -import type { RequestOptions } from "../../request"; -import type { Container } from "../Container"; -import type { ConflictDefinition } from "./ConflictDefinition"; -import { ConflictResponse } from "./ConflictResponse"; -import { undefinedPartitionKey } from "../../extractPartitionKey"; -import type { PartitionKey } from "../../documents"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { readPartitionKeyDefinition } from "../ClientUtils"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import type { ClientContext } from "../../ClientContext.js"; +import { Constants, getIdFromLink, getPathFromLink, ResourceType } from "../../common/index.js"; +import type { RequestOptions } from "../../request/index.js"; +import type { Container } from "../Container/index.js"; +import type { ConflictDefinition } from "./ConflictDefinition.js"; +import { ConflictResponse } from "./ConflictResponse.js"; +import { undefinedPartitionKey } from "../../extractPartitionKey.js"; +import type { PartitionKey } from "../../documents/index.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { readPartitionKeyDefinition } from "../ClientUtils.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Use to read or delete a given {@link Conflict} by id. diff --git a/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictDefinition.ts b/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictDefinition.ts index eeca505221e8..29a7530221af 100644 --- a/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictDefinition.ts +++ b/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictDefinition.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { OperationType, ResourceType } from "../../common"; +import type { OperationType, ResourceType } from "../../common/index.js"; export interface ConflictDefinition { /** The id of the conflict */ diff --git a/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResolutionPolicy.ts b/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResolutionPolicy.ts index bd28eda75dd5..587d3548b011 100644 --- a/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResolutionPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResolutionPolicy.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ConflictResolutionMode } from "./ConflictResolutionMode"; +import type { ConflictResolutionMode } from "./ConflictResolutionMode.js"; /** * Represents the conflict resolution policy configuration for specifying how to resolve conflicts diff --git a/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResponse.ts b/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResponse.ts index 61964d838e55..7d58708c5095 100644 --- a/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/Conflict/ConflictResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request"; -import type { Resource } from "../Resource"; -import type { Conflict } from "./Conflict"; -import type { ConflictDefinition } from "./ConflictDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { Conflict } from "./Conflict.js"; +import type { ConflictDefinition } from "./ConflictDefinition.js"; export class ConflictResponse extends ResourceResponse { constructor( diff --git a/sdk/cosmosdb/cosmos/src/client/Conflict/Conflicts.ts b/sdk/cosmosdb/cosmos/src/client/Conflict/Conflicts.ts index d4a248acad67..b801c2815423 100644 --- a/sdk/cosmosdb/cosmos/src/client/Conflict/Conflicts.ts +++ b/sdk/cosmosdb/cosmos/src/client/Conflict/Conflicts.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getIdFromLink, getPathFromLink, ResourceType } from "../../common"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions } from "../../request"; -import type { Container } from "../Container"; -import type { Resource } from "../Resource"; -import type { ConflictDefinition } from "./ConflictDefinition"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getIdFromLink, getPathFromLink, ResourceType } from "../../common/index.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions } from "../../request/index.js"; +import type { Container } from "../Container/index.js"; +import type { Resource } from "../Resource.js"; +import type { ConflictDefinition } from "./ConflictDefinition.js"; /** * Use to query or read all conflicts. diff --git a/sdk/cosmosdb/cosmos/src/client/Conflict/index.ts b/sdk/cosmosdb/cosmos/src/client/Conflict/index.ts index a15f0cd56f7e..6623e8635376 100644 --- a/sdk/cosmosdb/cosmos/src/client/Conflict/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/Conflict/index.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { Conflict } from "./Conflict"; -export { Conflicts } from "./Conflicts"; -export { ConflictDefinition } from "./ConflictDefinition"; -export { ConflictResponse } from "./ConflictResponse"; -export { ConflictResolutionPolicy } from "./ConflictResolutionPolicy"; -export { ConflictResolutionMode } from "./ConflictResolutionMode"; +export { Conflict } from "./Conflict.js"; +export { Conflicts } from "./Conflicts.js"; +export { ConflictDefinition } from "./ConflictDefinition.js"; +export { ConflictResponse } from "./ConflictResponse.js"; +export { ConflictResolutionPolicy } from "./ConflictResolutionPolicy.js"; +export { ConflictResolutionMode } from "./ConflictResolutionMode.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Container/Container.ts b/sdk/cosmosdb/cosmos/src/client/Container/Container.ts index 89048c56c8e4..ef795bda077d 100644 --- a/sdk/cosmosdb/cosmos/src/client/Container/Container.ts +++ b/sdk/cosmosdb/cosmos/src/client/Container/Container.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; +import type { ClientContext } from "../../ClientContext.js"; import { createDocumentCollectionUri, getIdFromLink, @@ -8,33 +8,33 @@ import { HTTPMethod, isResourceValid, ResourceType, -} from "../../common"; -import type { PartitionKey, PartitionKeyDefinition } from "../../documents"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import type { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions, Response } from "../../request"; -import { ResourceResponse } from "../../request"; -import type { PartitionedQueryExecutionInfo } from "../../request/ErrorResponse"; -import { Conflict, Conflicts } from "../Conflict"; -import type { Database } from "../Database"; -import { Item, Items } from "../Item"; -import { Scripts } from "../Script/Scripts"; -import type { ContainerDefinition } from "./ContainerDefinition"; -import { ContainerResponse } from "./ContainerResponse"; -import type { PartitionKeyRange } from "./PartitionKeyRange"; -import type { OfferDefinition } from "../Offer"; -import { Offer } from "../Offer"; -import { OfferResponse } from "../Offer/OfferResponse"; -import type { Resource } from "../Resource"; -import type { FeedRange } from "../ChangeFeed"; -import { FeedRangeInternal } from "../ChangeFeed"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +} from "../../common/index.js"; +import type { PartitionKey, PartitionKeyDefinition } from "../../documents/index.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import type { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions, Response } from "../../request/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { PartitionedQueryExecutionInfo } from "../../request/ErrorResponse.js"; +import { Conflict, Conflicts } from "../Conflict/index.js"; +import type { Database } from "../Database/index.js"; +import { Item, Items } from "../Item/index.js"; +import { Scripts } from "../Script/Scripts.js"; +import type { ContainerDefinition } from "./ContainerDefinition.js"; +import { ContainerResponse } from "./ContainerResponse.js"; +import type { PartitionKeyRange } from "./PartitionKeyRange.js"; +import type { OfferDefinition } from "../Offer/index.js"; +import { Offer } from "../Offer/index.js"; +import { OfferResponse } from "../Offer/OfferResponse.js"; +import type { Resource } from "../Resource.js"; +import type { FeedRange } from "../ChangeFeed/index.js"; +import { FeedRangeInternal } from "../ChangeFeed/index.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { getEmptyCosmosDiagnostics, withDiagnostics, withMetadataDiagnostics, -} from "../../utils/diagnostics"; -import { MetadataLookUpType } from "../../CosmosDiagnostics"; +} from "../../utils/diagnostics.js"; +import { MetadataLookUpType } from "../../CosmosDiagnostics.js"; /** * Operations for reading, replacing, or deleting a specific, existing container by id. diff --git a/sdk/cosmosdb/cosmos/src/client/Container/ContainerDefinition.ts b/sdk/cosmosdb/cosmos/src/client/Container/ContainerDefinition.ts index 62c4da0ae301..d1732e5a1fb6 100644 --- a/sdk/cosmosdb/cosmos/src/client/Container/ContainerDefinition.ts +++ b/sdk/cosmosdb/cosmos/src/client/Container/ContainerDefinition.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { IndexingPolicy, PartitionKeyDefinition } from "../../documents"; -import type { ConflictResolutionPolicy } from "../Conflict/ConflictResolutionPolicy"; -import type { UniqueKeyPolicy } from "./UniqueKeyPolicy"; -import type { GeospatialType } from "../../documents/GeospatialType"; -import type { ChangeFeedPolicy } from "../ChangeFeed/ChangeFeedPolicy"; -import type { ComputedProperty } from "../../documents/ComputedProperty"; -import type { VectorEmbeddingPolicy } from "../../documents/VectorEmbeddingPolicy"; -import type { FullTextPolicy } from "../../documents/FullTextPolicy"; +import type { IndexingPolicy, PartitionKeyDefinition } from "../../documents/index.js"; +import type { ConflictResolutionPolicy } from "../Conflict/ConflictResolutionPolicy.js"; +import type { UniqueKeyPolicy } from "./UniqueKeyPolicy.js"; +import type { GeospatialType } from "../../documents/GeospatialType.js"; +import type { ChangeFeedPolicy } from "../ChangeFeed/ChangeFeedPolicy.js"; +import type { ComputedProperty } from "../../documents/ComputedProperty.js"; +import type { VectorEmbeddingPolicy } from "../../documents/VectorEmbeddingPolicy.js"; +import type { FullTextPolicy } from "../../documents/FullTextPolicy.js"; export interface ContainerDefinition { /** The id of the container. */ diff --git a/sdk/cosmosdb/cosmos/src/client/Container/ContainerRequest.ts b/sdk/cosmosdb/cosmos/src/client/Container/ContainerRequest.ts index 991a31c83d9b..de1dc9a83382 100644 --- a/sdk/cosmosdb/cosmos/src/client/Container/ContainerRequest.ts +++ b/sdk/cosmosdb/cosmos/src/client/Container/ContainerRequest.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ContainerDefinition } from "./ContainerDefinition"; -import type { PartitionKeyDefinition } from "../../documents"; -import type { VerboseOmit } from "../../utils/types"; +import type { ContainerDefinition } from "./ContainerDefinition.js"; +import type { PartitionKeyDefinition } from "../../documents/index.js"; +import type { VerboseOmit } from "../../utils/types.js"; export interface ContainerRequest extends VerboseOmit { /* Throughput for this container. Cannot use with maxThroughput */ diff --git a/sdk/cosmosdb/cosmos/src/client/Container/ContainerResponse.ts b/sdk/cosmosdb/cosmos/src/client/Container/ContainerResponse.ts index e970674b6684..70867a64c855 100644 --- a/sdk/cosmosdb/cosmos/src/client/Container/ContainerResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/Container/ContainerResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request/ResourceResponse"; -import type { Resource } from "../Resource"; -import type { ContainerDefinition } from "./ContainerDefinition"; -import type { Container } from "./index"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/ResourceResponse.js"; +import type { Resource } from "../Resource.js"; +import type { ContainerDefinition } from "./ContainerDefinition.js"; +import type { Container } from "./index.js"; /** Response object for Container operations */ export class ContainerResponse extends ResourceResponse { diff --git a/sdk/cosmosdb/cosmos/src/client/Container/Containers.ts b/sdk/cosmosdb/cosmos/src/client/Container/Containers.ts index 839b84229a1a..47ef422e4802 100644 --- a/sdk/cosmosdb/cosmos/src/client/Container/Containers.ts +++ b/sdk/cosmosdb/cosmos/src/client/Container/Containers.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; +import type { ClientContext } from "../../ClientContext.js"; import { Constants, getIdFromLink, @@ -8,21 +8,21 @@ import { isResourceValid, ResourceType, StatusCodes, -} from "../../common"; -import { DEFAULT_PARTITION_KEY_PATH } from "../../common/partitionKeys"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { mergeHeaders } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions } from "../../request"; -import type { Database } from "../Database"; -import type { Resource } from "../Resource"; -import { Container } from "./Container"; -import type { ContainerDefinition } from "./ContainerDefinition"; -import type { ContainerRequest } from "./ContainerRequest"; -import { ContainerResponse } from "./ContainerResponse"; -import { validateOffer } from "../../utils/offers"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +} from "../../common/index.js"; +import { DEFAULT_PARTITION_KEY_PATH } from "../../common/partitionKeys.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { mergeHeaders } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions } from "../../request/index.js"; +import type { Database } from "../Database/index.js"; +import type { Resource } from "../Resource.js"; +import { Container } from "./Container.js"; +import type { ContainerDefinition } from "./ContainerDefinition.js"; +import type { ContainerRequest } from "./ContainerRequest.js"; +import { ContainerResponse } from "./ContainerResponse.js"; +import { validateOffer } from "../../utils/offers.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Operations for creating new containers, and reading/querying all containers diff --git a/sdk/cosmosdb/cosmos/src/client/Container/index.ts b/sdk/cosmosdb/cosmos/src/client/Container/index.ts index aa193a46adc2..3275b9c7251d 100644 --- a/sdk/cosmosdb/cosmos/src/client/Container/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/Container/index.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -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"; +export { Container } from "./Container.js"; +export { Containers } from "./Containers.js"; +export { ContainerDefinition } from "./ContainerDefinition.js"; +export { ContainerResponse } from "./ContainerResponse.js"; +export { PartitionKeyRange } from "./PartitionKeyRange.js"; +export { UniqueKeyPolicy, UniqueKey } from "./UniqueKeyPolicy.js"; +export { ContainerRequest } from "./ContainerRequest.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Database/Database.ts b/sdk/cosmosdb/cosmos/src/client/Database/Database.ts index 1c56c00c3f9f..486884331a83 100644 --- a/sdk/cosmosdb/cosmos/src/client/Database/Database.ts +++ b/sdk/cosmosdb/cosmos/src/client/Database/Database.ts @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import { createDatabaseUri, getIdFromLink, getPathFromLink, ResourceType } from "../../common"; -import type { CosmosClient } from "../../CosmosClient"; -import type { RequestOptions } from "../../request"; -import { Container, Containers } from "../Container"; -import { User, Users } from "../User"; -import type { DatabaseDefinition } from "./DatabaseDefinition"; -import { DatabaseResponse } from "./DatabaseResponse"; -import type { OfferDefinition } from "../Offer"; -import { OfferResponse, Offer } from "../Offer"; -import type { Resource } from "../Resource"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { ClientContext } from "../../ClientContext.js"; +import { createDatabaseUri, getIdFromLink, getPathFromLink, ResourceType } from "../../common/index.js"; +import type { CosmosClient } from "../../CosmosClient.js"; +import type { RequestOptions } from "../../request/index.js"; +import { Container, Containers } from "../Container/index.js"; +import { User, Users } from "../User/index.js"; +import type { DatabaseDefinition } from "./DatabaseDefinition.js"; +import { DatabaseResponse } from "./DatabaseResponse.js"; +import type { OfferDefinition } from "../Offer/index.js"; +import { OfferResponse, Offer } from "../Offer/index.js"; +import type { Resource } from "../Resource.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { getEmptyCosmosDiagnostics, withDiagnostics, withMetadataDiagnostics, -} from "../../utils/diagnostics"; -import { MetadataLookUpType } from "../../CosmosDiagnostics"; +} from "../../utils/diagnostics.js"; +import { MetadataLookUpType } from "../../CosmosDiagnostics.js"; /** * Operations for reading or deleting an existing database. diff --git a/sdk/cosmosdb/cosmos/src/client/Database/DatabaseRequest.ts b/sdk/cosmosdb/cosmos/src/client/Database/DatabaseRequest.ts index 511c2b6f21d2..61db545bf70b 100644 --- a/sdk/cosmosdb/cosmos/src/client/Database/DatabaseRequest.ts +++ b/sdk/cosmosdb/cosmos/src/client/Database/DatabaseRequest.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DatabaseDefinition } from "./DatabaseDefinition"; +import type { DatabaseDefinition } from "./DatabaseDefinition.js"; export interface DatabaseRequest extends DatabaseDefinition { /** Throughput for this database. */ diff --git a/sdk/cosmosdb/cosmos/src/client/Database/DatabaseResponse.ts b/sdk/cosmosdb/cosmos/src/client/Database/DatabaseResponse.ts index f4865d55afc8..050db080b504 100644 --- a/sdk/cosmosdb/cosmos/src/client/Database/DatabaseResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/Database/DatabaseResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request/ResourceResponse"; -import type { Resource } from "../Resource"; -import type { Database } from "./Database"; -import type { DatabaseDefinition } from "./DatabaseDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/ResourceResponse.js"; +import type { Resource } from "../Resource.js"; +import type { Database } from "./Database.js"; +import type { DatabaseDefinition } from "./DatabaseDefinition.js"; /** Response object for Database operations */ export class DatabaseResponse extends ResourceResponse { diff --git a/sdk/cosmosdb/cosmos/src/client/Database/Databases.ts b/sdk/cosmosdb/cosmos/src/client/Database/Databases.ts index a22450af06be..53cc99b862b7 100644 --- a/sdk/cosmosdb/cosmos/src/client/Database/Databases.ts +++ b/sdk/cosmosdb/cosmos/src/client/Database/Databases.ts @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import { Constants, isResourceValid, ResourceType, StatusCodes } from "../../common"; -import type { CosmosClient } from "../../CosmosClient"; -import type { FetchFunctionCallback, SqlQuerySpec } from "../../queryExecutionContext"; -import { mergeHeaders } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions } from "../../request"; -import type { Resource } from "../Resource"; -import { Database } from "./Database"; -import type { DatabaseDefinition } from "./DatabaseDefinition"; -import type { DatabaseRequest } from "./DatabaseRequest"; -import { DatabaseResponse } from "./DatabaseResponse"; -import { validateOffer } from "../../utils/offers"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import type { ClientContext } from "../../ClientContext.js"; +import { Constants, isResourceValid, ResourceType, StatusCodes } from "../../common/index.js"; +import type { CosmosClient } from "../../CosmosClient.js"; +import type { FetchFunctionCallback, SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { mergeHeaders } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import { Database } from "./Database.js"; +import type { DatabaseDefinition } from "./DatabaseDefinition.js"; +import type { DatabaseRequest } from "./DatabaseRequest.js"; +import { DatabaseResponse } from "./DatabaseResponse.js"; +import { validateOffer } from "../../utils/offers.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Operations for creating new databases, and reading/querying all databases diff --git a/sdk/cosmosdb/cosmos/src/client/Database/index.ts b/sdk/cosmosdb/cosmos/src/client/Database/index.ts index 833021f415e0..d62178ab1612 100644 --- a/sdk/cosmosdb/cosmos/src/client/Database/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/Database/index.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { Database } from "./Database"; -export { Databases } from "./Databases"; -export { DatabaseDefinition } from "./DatabaseDefinition"; -export { DatabaseResponse } from "./DatabaseResponse"; -export { DatabaseRequest } from "./DatabaseRequest"; +export { Database } from "./Database.js"; +export { Databases } from "./Databases.js"; +export { DatabaseDefinition } from "./DatabaseDefinition.js"; +export { DatabaseResponse } from "./DatabaseResponse.js"; +export { DatabaseRequest } from "./DatabaseRequest.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Item/Item.ts b/sdk/cosmosdb/cosmos/src/client/Item/Item.ts index 136118d3b047..5ed0fec56d25 100644 --- a/sdk/cosmosdb/cosmos/src/client/Item/Item.ts +++ b/sdk/cosmosdb/cosmos/src/client/Item/Item.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { createDocumentUri, getIdFromLink, @@ -9,17 +9,17 @@ import { isItemResourceValid, ResourceType, StatusCodes, -} from "../../common"; -import type { PartitionKey, PartitionKeyInternal } from "../../documents"; -import { convertToInternalPartitionKey } from "../../documents"; -import type { RequestOptions, Response } from "../../request"; -import type { PatchRequestBody } from "../../utils/patch"; -import type { Container } from "../Container"; -import type { Resource } from "../Resource"; -import type { ItemDefinition } from "./ItemDefinition"; -import { ItemResponse } from "./ItemResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; -import { setPartitionKeyIfUndefined } from "../../extractPartitionKey"; +} from "../../common/index.js"; +import type { PartitionKey, PartitionKeyInternal } from "../../documents/index.js"; +import { convertToInternalPartitionKey } from "../../documents/index.js"; +import type { RequestOptions, Response } from "../../request/index.js"; +import type { PatchRequestBody } from "../../utils/patch.js"; +import type { Container } from "../Container/index.js"; +import type { Resource } from "../Resource.js"; +import type { ItemDefinition } from "./ItemDefinition.js"; +import { ItemResponse } from "./ItemResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; +import { setPartitionKeyIfUndefined } from "../../extractPartitionKey.js"; /** * Used to perform operations on a specific item. diff --git a/sdk/cosmosdb/cosmos/src/client/Item/ItemResponse.ts b/sdk/cosmosdb/cosmos/src/client/Item/ItemResponse.ts index 72a0a3433f7e..eeb8f027638e 100644 --- a/sdk/cosmosdb/cosmos/src/client/Item/ItemResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/Item/ItemResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request/ResourceResponse"; -import type { Resource } from "../Resource"; -import type { Item } from "./Item"; -import type { ItemDefinition } from "./ItemDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/ResourceResponse.js"; +import type { Resource } from "../Resource.js"; +import type { Item } from "./Item.js"; +import type { ItemDefinition } from "./ItemDefinition.js"; export class ItemResponse extends ResourceResponse { constructor( diff --git a/sdk/cosmosdb/cosmos/src/client/Item/Items.ts b/sdk/cosmosdb/cosmos/src/client/Item/Items.ts index f37d9476501b..a50de126e4b1 100644 --- a/sdk/cosmosdb/cosmos/src/client/Item/Items.ts +++ b/sdk/cosmosdb/cosmos/src/client/Item/Items.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ChangeFeedIterator } from "../../ChangeFeedIterator"; -import type { ChangeFeedOptions } from "../../ChangeFeedOptions"; -import type { ClientContext } from "../../ClientContext"; +import { ChangeFeedIterator } from "../../ChangeFeedIterator.js"; +import type { ChangeFeedOptions } from "../../ChangeFeedOptions.js"; +import type { ClientContext } from "../../ClientContext.js"; import { getIdFromLink, getPathFromLink, @@ -11,47 +11,47 @@ import { ResourceType, StatusCodes, SubStatusCodes, -} from "../../common"; -import { extractPartitionKeys, setPartitionKeyIfUndefined } from "../../extractPartitionKey"; -import type { FetchFunctionCallback, SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions, Response } from "../../request"; -import type { Container, PartitionKeyRange } from "../Container"; -import { Item } from "./Item"; -import type { ItemDefinition } from "./ItemDefinition"; -import { ItemResponse } from "./ItemResponse"; +} from "../../common/index.js"; +import { extractPartitionKeys, setPartitionKeyIfUndefined } from "../../extractPartitionKey.js"; +import type { FetchFunctionCallback, SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions, Response } from "../../request/index.js"; +import type { Container, PartitionKeyRange } from "../Container/index.js"; +import { Item } from "./Item.js"; +import type { ItemDefinition } from "./ItemDefinition.js"; +import { ItemResponse } from "./ItemResponse.js"; import type { Batch, OperationResponse, OperationInput, BulkOptions, BulkOperationResponse, -} from "../../utils/batch"; +} from "../../utils/batch.js"; import { isKeyInRange, prepareOperations, decorateBatchOperation, splitBatchBasedOnBodySize, -} from "../../utils/batch"; -import { assertNotUndefined, isPrimitivePartitionKeyValue } from "../../utils/typeChecks"; -import { hashPartitionKey } from "../../utils/hashing/hash"; -import type { PartitionKey, PartitionKeyDefinition } from "../../documents"; -import { PartitionKeyRangeCache, QueryRange } from "../../routing"; +} from "../../utils/batch.js"; +import { assertNotUndefined, isPrimitivePartitionKeyValue } from "../../utils/typeChecks.js"; +import { hashPartitionKey } from "../../utils/hashing/hash.js"; +import type { PartitionKey, PartitionKeyDefinition } from "../../documents/index.js"; +import { PartitionKeyRangeCache, QueryRange } from "../../routing/index.js"; import type { ChangeFeedPullModelIterator, ChangeFeedIteratorOptions, -} from "../../client/ChangeFeed"; -import { changeFeedIteratorBuilder } from "../../client/ChangeFeed"; -import { validateChangeFeedIteratorOptions } from "../../client/ChangeFeed/changeFeedUtils"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { DiagnosticNodeType } from "../../diagnostics/DiagnosticNodeInternal"; +} from "../../client/ChangeFeed/index.js"; +import { changeFeedIteratorBuilder } from "../../client/ChangeFeed/index.js"; +import { validateChangeFeedIteratorOptions } from "../../client/ChangeFeed/changeFeedUtils.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { DiagnosticNodeType } from "../../diagnostics/DiagnosticNodeInternal.js"; import { getEmptyCosmosDiagnostics, withDiagnostics, addDignosticChild, -} from "../../utils/diagnostics"; +} from "../../utils/diagnostics.js"; import { randomUUID } from "@azure/core-util"; -import { readPartitionKeyDefinition } from "../ClientUtils"; +import { readPartitionKeyDefinition } from "../ClientUtils.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/client/Item/index.ts b/sdk/cosmosdb/cosmos/src/client/Item/index.ts index 90e06f8ba5fa..c97cce81c13b 100644 --- a/sdk/cosmosdb/cosmos/src/client/Item/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/Item/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { Item } from "./Item"; -export { Items } from "./Items"; -export { ItemResponse } from "./ItemResponse"; -export { ItemDefinition } from "./ItemDefinition"; +export { Item } from "./Item.js"; +export { Items } from "./Items.js"; +export { ItemResponse } from "./ItemResponse.js"; +export { ItemDefinition } from "./ItemDefinition.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Offer/Offer.ts b/sdk/cosmosdb/cosmos/src/client/Offer/Offer.ts index c290196bc715..e8b2dfbbf40c 100644 --- a/sdk/cosmosdb/cosmos/src/client/Offer/Offer.ts +++ b/sdk/cosmosdb/cosmos/src/client/Offer/Offer.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import { Constants, isResourceValid, ResourceType } from "../../common"; -import type { CosmosClient } from "../../CosmosClient"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import type { RequestOptions } from "../../request"; -import type { OfferDefinition } from "./OfferDefinition"; -import { OfferResponse } from "./OfferResponse"; +import type { ClientContext } from "../../ClientContext.js"; +import { Constants, isResourceValid, ResourceType } from "../../common/index.js"; +import type { CosmosClient } from "../../CosmosClient.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import type { RequestOptions } from "../../request/index.js"; +import type { OfferDefinition } from "./OfferDefinition.js"; +import { OfferResponse } from "./OfferResponse.js"; /** * Use to read or replace an existing {@link Offer} by id. diff --git a/sdk/cosmosdb/cosmos/src/client/Offer/OfferResponse.ts b/sdk/cosmosdb/cosmos/src/client/Offer/OfferResponse.ts index 4246a0d893d3..d179b84cf9c5 100644 --- a/sdk/cosmosdb/cosmos/src/client/Offer/OfferResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/Offer/OfferResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request"; -import type { Resource } from "../Resource"; -import type { Offer } from "./Offer"; -import type { OfferDefinition } from "./OfferDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { Offer } from "./Offer.js"; +import type { OfferDefinition } from "./OfferDefinition.js"; export class OfferResponse extends ResourceResponse { constructor( diff --git a/sdk/cosmosdb/cosmos/src/client/Offer/Offers.ts b/sdk/cosmosdb/cosmos/src/client/Offer/Offers.ts index b522156a53ed..0512fb3e57f2 100644 --- a/sdk/cosmosdb/cosmos/src/client/Offer/Offers.ts +++ b/sdk/cosmosdb/cosmos/src/client/Offer/Offers.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import { ResourceType } from "../../common"; -import type { CosmosClient } from "../../CosmosClient"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions } from "../../request"; -import type { Resource } from "../Resource"; -import type { OfferDefinition } from "./OfferDefinition"; +import type { ClientContext } from "../../ClientContext.js"; +import { ResourceType } from "../../common/index.js"; +import type { CosmosClient } from "../../CosmosClient.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { OfferDefinition } from "./OfferDefinition.js"; /** * Use to query or read all Offers. diff --git a/sdk/cosmosdb/cosmos/src/client/Offer/index.ts b/sdk/cosmosdb/cosmos/src/client/Offer/index.ts index 5c00b05600fb..17e66e2ff61a 100644 --- a/sdk/cosmosdb/cosmos/src/client/Offer/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/Offer/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { Offer } from "./Offer"; -export { Offers } from "./Offers"; -export { OfferDefinition } from "./OfferDefinition"; -export { OfferResponse } from "./OfferResponse"; +export { Offer } from "./Offer.js"; +export { Offers } from "./Offers.js"; +export { OfferDefinition } from "./OfferDefinition.js"; +export { OfferResponse } from "./OfferResponse.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Permission/Permission.ts b/sdk/cosmosdb/cosmos/src/client/Permission/Permission.ts index 2a9f43e3f49c..fec8a330dc06 100644 --- a/sdk/cosmosdb/cosmos/src/client/Permission/Permission.ts +++ b/sdk/cosmosdb/cosmos/src/client/Permission/Permission.ts @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { createPermissionUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, -} from "../../common"; -import type { RequestOptions } from "../../request/RequestOptions"; -import type { User } from "../User"; -import type { PermissionBody } from "./PermissionBody"; -import type { PermissionDefinition } from "./PermissionDefinition"; -import { PermissionResponse } from "./PermissionResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +} from "../../common/index.js"; +import type { RequestOptions } from "../../request/RequestOptions.js"; +import type { User } from "../User/index.js"; +import type { PermissionBody } from "./PermissionBody.js"; +import type { PermissionDefinition } from "./PermissionDefinition.js"; +import { PermissionResponse } from "./PermissionResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Use to read, replace, or delete a given {@link Permission} by id. diff --git a/sdk/cosmosdb/cosmos/src/client/Permission/PermissionDefinition.ts b/sdk/cosmosdb/cosmos/src/client/Permission/PermissionDefinition.ts index e5018b88d951..6ff6e684e165 100644 --- a/sdk/cosmosdb/cosmos/src/client/Permission/PermissionDefinition.ts +++ b/sdk/cosmosdb/cosmos/src/client/Permission/PermissionDefinition.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PermissionMode } from "../../documents"; +import type { PermissionMode } from "../../documents/index.js"; export interface PermissionDefinition { /** The id of the permission */ diff --git a/sdk/cosmosdb/cosmos/src/client/Permission/PermissionResponse.ts b/sdk/cosmosdb/cosmos/src/client/Permission/PermissionResponse.ts index de8b5869e77a..91ddb3dcd1cc 100644 --- a/sdk/cosmosdb/cosmos/src/client/Permission/PermissionResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/Permission/PermissionResponse.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request"; -import type { Resource } from "../Resource"; -import type { Permission } from "./Permission"; -import type { PermissionBody } from "./PermissionBody"; -import type { PermissionDefinition } from "./PermissionDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { Permission } from "./Permission.js"; +import type { PermissionBody } from "./PermissionBody.js"; +import type { PermissionDefinition } from "./PermissionDefinition.js"; export class PermissionResponse extends ResourceResponse< PermissionDefinition & PermissionBody & Resource diff --git a/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts b/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts index 56349fe98c4d..70f5e146774b 100644 --- a/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts +++ b/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions } from "../../request"; -import type { Resource } from "../Resource"; -import type { User } from "../User"; -import { Permission } from "./Permission"; -import type { PermissionBody } from "./PermissionBody"; -import type { PermissionDefinition } from "./PermissionDefinition"; -import { PermissionResponse } from "./PermissionResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { User } from "../User/index.js"; +import { Permission } from "./Permission.js"; +import type { PermissionBody } from "./PermissionBody.js"; +import type { PermissionDefinition } from "./PermissionDefinition.js"; +import { PermissionResponse } from "./PermissionResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Use to create, replace, query, and read all Permissions. diff --git a/sdk/cosmosdb/cosmos/src/client/Permission/index.ts b/sdk/cosmosdb/cosmos/src/client/Permission/index.ts index b183a98179f6..d615f7ad4cc6 100644 --- a/sdk/cosmosdb/cosmos/src/client/Permission/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/Permission/index.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { Permission } from "./Permission"; -export { Permissions } from "./Permissions"; -export { PermissionDefinition } from "./PermissionDefinition"; -export { PermissionResponse } from "./PermissionResponse"; -export { PermissionBody } from "./PermissionBody"; +export { Permission } from "./Permission.js"; +export { Permissions } from "./Permissions.js"; +export { PermissionDefinition } from "./PermissionDefinition.js"; +export { PermissionResponse } from "./PermissionResponse.js"; +export { PermissionBody } from "./PermissionBody.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/SasToken/SasTokenProperties.ts b/sdk/cosmosdb/cosmos/src/client/SasToken/SasTokenProperties.ts index 3cd3df61299f..9bef5c1ebb9b 100644 --- a/sdk/cosmosdb/cosmos/src/client/SasToken/SasTokenProperties.ts +++ b/sdk/cosmosdb/cosmos/src/client/SasToken/SasTokenProperties.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosContainerChildResourceKind } from "../../common/constants"; -import type { CosmosKeyType } from "../../common/constants"; +import type { CosmosContainerChildResourceKind } from "../../common/constants.js"; +import type { CosmosKeyType } from "../../common/constants.js"; export class SasTokenProperties { user: string; diff --git a/sdk/cosmosdb/cosmos/src/client/Script/Scripts.ts b/sdk/cosmosdb/cosmos/src/client/Script/Scripts.ts index 0ebeff96072c..6245e0410768 100644 --- a/sdk/cosmosdb/cosmos/src/client/Script/Scripts.ts +++ b/sdk/cosmosdb/cosmos/src/client/Script/Scripts.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { StoredProcedures, StoredProcedure } from "../StoredProcedure"; -import { Trigger, Triggers } from "../Trigger"; -import { UserDefinedFunction, UserDefinedFunctions } from "../UserDefinedFunction"; -import type { ClientContext } from "../../ClientContext"; -import type { Container } from "../Container/Container"; +import { StoredProcedures, StoredProcedure } from "../StoredProcedure/index.js"; +import { Trigger, Triggers } from "../Trigger/index.js"; +import { UserDefinedFunction, UserDefinedFunctions } from "../UserDefinedFunction/index.js"; +import type { ClientContext } from "../../ClientContext.js"; +import type { Container } from "../Container/Container.js"; export class Scripts { /** diff --git a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedure.ts b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedure.ts index cddd65080ad0..cdad728e8e24 100644 --- a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedure.ts +++ b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedure.ts @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { createStoredProcedureUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, -} from "../../common"; -import type { PartitionKey } from "../../documents/PartitionKey"; -import { undefinedPartitionKey } from "../../extractPartitionKey"; -import type { RequestOptions } from "../../request"; -import { ResourceResponse } from "../../request"; -import { readPartitionKeyDefinition } from "../ClientUtils"; -import type { Container } from "../Container"; -import type { StoredProcedureDefinition } from "./StoredProcedureDefinition"; -import { StoredProcedureResponse } from "./StoredProcedureResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +} from "../../common/index.js"; +import type { PartitionKey } from "../../documents/PartitionKey.js"; +import { undefinedPartitionKey } from "../../extractPartitionKey.js"; +import type { RequestOptions } from "../../request/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import { readPartitionKeyDefinition } from "../ClientUtils.js"; +import type { Container } from "../Container/index.js"; +import type { StoredProcedureDefinition } from "./StoredProcedureDefinition.js"; +import { StoredProcedureResponse } from "./StoredProcedureResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Operations for reading, replacing, deleting, or executing a specific, existing stored procedure by id. diff --git a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedureResponse.ts b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedureResponse.ts index 468d3623984f..d8d30950584f 100644 --- a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedureResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedureResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request"; -import type { Resource } from "../Resource"; -import type { StoredProcedure } from "./StoredProcedure"; -import type { StoredProcedureDefinition } from "./StoredProcedureDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { StoredProcedure } from "./StoredProcedure.js"; +import type { StoredProcedureDefinition } from "./StoredProcedureDefinition.js"; export class StoredProcedureResponse extends ResourceResponse< StoredProcedureDefinition & Resource diff --git a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts index be219df4c48a..c67960e0d384 100644 --- a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts +++ b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions } from "../../request"; -import type { Container } from "../Container"; -import type { Resource } from "../Resource"; -import { StoredProcedure } from "./StoredProcedure"; -import type { StoredProcedureDefinition } from "./StoredProcedureDefinition"; -import { StoredProcedureResponse } from "./StoredProcedureResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions } from "../../request/index.js"; +import type { Container } from "../Container/index.js"; +import type { Resource } from "../Resource.js"; +import { StoredProcedure } from "./StoredProcedure.js"; +import type { StoredProcedureDefinition } from "./StoredProcedureDefinition.js"; +import { StoredProcedureResponse } from "./StoredProcedureResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Operations for creating, upserting, or reading/querying all Stored Procedures. diff --git a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/index.ts b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/index.ts index 7ef0755fddfa..70d049415187 100644 --- a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { StoredProcedure } from "./StoredProcedure"; -export { StoredProcedures } from "./StoredProcedures"; -export { StoredProcedureDefinition } from "./StoredProcedureDefinition"; -export { StoredProcedureResponse } from "./StoredProcedureResponse"; +export { StoredProcedure } from "./StoredProcedure.js"; +export { StoredProcedures } from "./StoredProcedures.js"; +export { StoredProcedureDefinition } from "./StoredProcedureDefinition.js"; +export { StoredProcedureResponse } from "./StoredProcedureResponse.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Trigger/Trigger.ts b/sdk/cosmosdb/cosmos/src/client/Trigger/Trigger.ts index 392e4146770f..c7aa4e9a3cde 100644 --- a/sdk/cosmosdb/cosmos/src/client/Trigger/Trigger.ts +++ b/sdk/cosmosdb/cosmos/src/client/Trigger/Trigger.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { createTriggerUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, -} from "../../common"; -import type { RequestOptions } from "../../request"; -import type { Container } from "../Container"; -import type { TriggerDefinition } from "./TriggerDefinition"; -import { TriggerResponse } from "./TriggerResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +} from "../../common/index.js"; +import type { RequestOptions } from "../../request/index.js"; +import type { Container } from "../Container/index.js"; +import type { TriggerDefinition } from "./TriggerDefinition.js"; +import { TriggerResponse } from "./TriggerResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Operations to read, replace, or delete a {@link Trigger}. diff --git a/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerDefinition.ts b/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerDefinition.ts index e15a35442307..57eff23e0493 100644 --- a/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerDefinition.ts +++ b/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerDefinition.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { TriggerOperation, TriggerType } from "../../documents"; +import type { TriggerOperation, TriggerType } from "../../documents/index.js"; export interface TriggerDefinition { /** The id of the trigger. */ diff --git a/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerResponse.ts b/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerResponse.ts index 9351ae59bd87..aa5c92a7d40c 100644 --- a/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/Trigger/TriggerResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request"; -import type { Resource } from "../Resource"; -import type { Trigger } from "./index"; -import type { TriggerDefinition } from "./TriggerDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { Trigger } from "./index.js"; +import type { TriggerDefinition } from "./TriggerDefinition.js"; export class TriggerResponse extends ResourceResponse { constructor( diff --git a/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts b/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts index 558fb656a8bf..344bba5d8850 100644 --- a/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts +++ b/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions } from "../../request"; -import type { Container } from "../Container"; -import type { Resource } from "../Resource"; -import { Trigger } from "./Trigger"; -import type { TriggerDefinition } from "./TriggerDefinition"; -import { TriggerResponse } from "./TriggerResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions } from "../../request/index.js"; +import type { Container } from "../Container/index.js"; +import type { Resource } from "../Resource.js"; +import { Trigger } from "./Trigger.js"; +import type { TriggerDefinition } from "./TriggerDefinition.js"; +import { TriggerResponse } from "./TriggerResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Operations to create, upsert, query, and read all triggers. diff --git a/sdk/cosmosdb/cosmos/src/client/Trigger/index.ts b/sdk/cosmosdb/cosmos/src/client/Trigger/index.ts index e5490c657c57..0e083035c362 100644 --- a/sdk/cosmosdb/cosmos/src/client/Trigger/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/Trigger/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { Trigger } from "./Trigger"; -export { Triggers } from "./Triggers"; -export { TriggerDefinition } from "./TriggerDefinition"; -export { TriggerResponse } from "./TriggerResponse"; +export { Trigger } from "./Trigger.js"; +export { Triggers } from "./Triggers.js"; +export { TriggerDefinition } from "./TriggerDefinition.js"; +export { TriggerResponse } from "./TriggerResponse.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/User/User.ts b/sdk/cosmosdb/cosmos/src/client/User/User.ts index a8c49b9500ff..5b29647f6920 100644 --- a/sdk/cosmosdb/cosmos/src/client/User/User.ts +++ b/sdk/cosmosdb/cosmos/src/client/User/User.ts @@ -1,20 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { createUserUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, -} from "../../common"; -import type { RequestOptions } from "../../request"; -import type { Database } from "../Database"; -import { Permission, Permissions } from "../Permission"; -import type { UserDefinition } from "./UserDefinition"; -import { UserResponse } from "./UserResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +} from "../../common/index.js"; +import type { RequestOptions } from "../../request/index.js"; +import type { Database } from "../Database/index.js"; +import { Permission, Permissions } from "../Permission/index.js"; +import type { UserDefinition } from "./UserDefinition.js"; +import { UserResponse } from "./UserResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Used to read, replace, and delete Users. diff --git a/sdk/cosmosdb/cosmos/src/client/User/UserResponse.ts b/sdk/cosmosdb/cosmos/src/client/User/UserResponse.ts index 54900f7008b3..91962e7e3e20 100644 --- a/sdk/cosmosdb/cosmos/src/client/User/UserResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/User/UserResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request"; -import type { Resource } from "../Resource"; -import type { User } from "./User"; -import type { UserDefinition } from "./UserDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { User } from "./User.js"; +import type { UserDefinition } from "./UserDefinition.js"; export class UserResponse extends ResourceResponse { constructor( diff --git a/sdk/cosmosdb/cosmos/src/client/User/Users.ts b/sdk/cosmosdb/cosmos/src/client/User/Users.ts index 348dc22d180c..7055194cf4f9 100644 --- a/sdk/cosmosdb/cosmos/src/client/User/Users.ts +++ b/sdk/cosmosdb/cosmos/src/client/User/Users.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions } from "../../request"; -import type { Database } from "../Database"; -import type { Resource } from "../Resource"; -import { User } from "./User"; -import type { UserDefinition } from "./UserDefinition"; -import { UserResponse } from "./UserResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions } from "../../request/index.js"; +import type { Database } from "../Database/index.js"; +import type { Resource } from "../Resource.js"; +import { User } from "./User.js"; +import type { UserDefinition } from "./UserDefinition.js"; +import { UserResponse } from "./UserResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Used to create, upsert, query, and read all users. diff --git a/sdk/cosmosdb/cosmos/src/client/User/index.ts b/sdk/cosmosdb/cosmos/src/client/User/index.ts index 29f78e968801..c3c32087d486 100644 --- a/sdk/cosmosdb/cosmos/src/client/User/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/User/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { User } from "./User"; -export { Users } from "./Users"; -export { UserDefinition } from "./UserDefinition"; -export { UserResponse } from "./UserResponse"; +export { User } from "./User.js"; +export { Users } from "./Users.js"; +export { UserDefinition } from "./UserDefinition.js"; +export { UserResponse } from "./UserResponse.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunction.ts b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunction.ts index 69adfc7fdb74..5bbe9babefe0 100644 --- a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunction.ts +++ b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunction.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; import { createUserDefinedFunctionUri, getIdFromLink, getPathFromLink, isResourceValid, ResourceType, -} from "../../common"; -import type { RequestOptions } from "../../request"; -import type { Container } from "../Container"; -import type { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; -import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +} from "../../common/index.js"; +import type { RequestOptions } from "../../request/index.js"; +import type { Container } from "../Container/index.js"; +import type { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition.js"; +import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Used to read, replace, or delete a specified User Definied Function by id. diff --git a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts index 555383a06de0..38ec4bd20b4d 100644 --- a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts +++ b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../../CosmosDiagnostics"; -import type { CosmosHeaders } from "../../queryExecutionContext"; -import { ResourceResponse } from "../../request"; -import type { Resource } from "../Resource"; -import type { UserDefinedFunction } from "./UserDefinedFunction"; -import type { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; +import type { CosmosDiagnostics } from "../../CosmosDiagnostics.js"; +import type { CosmosHeaders } from "../../queryExecutionContext/index.js"; +import { ResourceResponse } from "../../request/index.js"; +import type { Resource } from "../Resource.js"; +import type { UserDefinedFunction } from "./UserDefinedFunction.js"; +import type { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition.js"; export class UserDefinedFunctionResponse extends ResourceResponse< UserDefinedFunctionDefinition & Resource diff --git a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts index d2236a12708f..47e00e0476ca 100644 --- a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts +++ b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../../ClientContext"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common"; -import type { SqlQuerySpec } from "../../queryExecutionContext"; -import { QueryIterator } from "../../queryIterator"; -import type { FeedOptions, RequestOptions } from "../../request"; -import type { Container } from "../Container"; -import type { Resource } from "../Resource"; -import { UserDefinedFunction } from "./UserDefinedFunction"; -import type { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; -import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; -import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics"; +import type { ClientContext } from "../../ClientContext.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; +import { QueryIterator } from "../../queryIterator.js"; +import type { FeedOptions, RequestOptions } from "../../request/index.js"; +import type { Container } from "../Container/index.js"; +import type { Resource } from "../Resource.js"; +import { UserDefinedFunction } from "./UserDefinedFunction.js"; +import type { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition.js"; +import { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse.js"; +import { getEmptyCosmosDiagnostics, withDiagnostics } from "../../utils/diagnostics.js"; /** * Used to create, upsert, query, or read all User Defined Functions. diff --git a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/index.ts b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/index.ts index 8fc930ac2198..c5face1c935b 100644 --- a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { UserDefinedFunction } from "./UserDefinedFunction"; -export { UserDefinedFunctions } from "./UserDefinedFunctions"; -export { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition"; -export { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse"; +export { UserDefinedFunction } from "./UserDefinedFunction.js"; +export { UserDefinedFunctions } from "./UserDefinedFunctions.js"; +export { UserDefinedFunctionDefinition } from "./UserDefinedFunctionDefinition.js"; +export { UserDefinedFunctionResponse } from "./UserDefinedFunctionResponse.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/index.ts b/sdk/cosmosdb/cosmos/src/client/index.ts index 58e3e4c4a825..88effdfae765 100644 --- a/sdk/cosmosdb/cosmos/src/client/index.ts +++ b/sdk/cosmosdb/cosmos/src/client/index.ts @@ -1,14 +1,14 @@ // 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"; +export * from "./Conflict/index.js"; +export * from "./Container/index.js"; +export * from "./Database/index.js"; +export * from "./Item/index.js"; +export * from "./Offer/index.js"; +export * from "./Permission/index.js"; +export * from "./StoredProcedure/index.js"; +export * from "./Trigger/index.js"; +export * from "./User/index.js"; +export * from "./UserDefinedFunction/index.js"; +export * from "./Resource.js"; +export * from "./SasToken/SasTokenProperties.js"; diff --git a/sdk/cosmosdb/cosmos/src/common/helper.ts b/sdk/cosmosdb/cosmos/src/common/helper.ts index 2e201ecebc53..449bba9fd9b1 100644 --- a/sdk/cosmosdb/cosmos/src/common/helper.ts +++ b/sdk/cosmosdb/cosmos/src/common/helper.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosClientOptions } from "../CosmosClientOptions"; -import type { ResourceType } from "./constants"; -import { OperationType } from "./constants"; +import type { CosmosClientOptions } from "../CosmosClientOptions.js"; +import type { ResourceType } from "./constants.js"; +import { OperationType } from "./constants.js"; const trimLeftSlashes = new RegExp("^[/]+"); const trimRightSlashes = new RegExp("[/]+$"); diff --git a/sdk/cosmosdb/cosmos/src/common/index.ts b/sdk/cosmosdb/cosmos/src/common/index.ts index 084d328f7a56..3b89aa86d6a8 100644 --- a/sdk/cosmosdb/cosmos/src/common/index.ts +++ b/sdk/cosmosdb/cosmos/src/common/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export * from "./constants"; -export * from "./helper"; -export * from "./statusCodes"; -export * from "./uriFactory"; +export * from "./constants.js"; +export * from "./helper.js"; +export * from "./statusCodes.js"; +export * from "./uriFactory.js"; diff --git a/sdk/cosmosdb/cosmos/src/common/platform.ts b/sdk/cosmosdb/cosmos/src/common/platform.ts index d7756ff2afab..1059b8a1bdcf 100644 --- a/sdk/cosmosdb/cosmos/src/common/platform.ts +++ b/sdk/cosmosdb/cosmos/src/common/platform.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Constants } from "./constants"; +import { Constants } from "./constants.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/common/uriFactory.ts b/sdk/cosmosdb/cosmos/src/common/uriFactory.ts index 654b1a0170ec..b5b0a08e1e16 100644 --- a/sdk/cosmosdb/cosmos/src/common/uriFactory.ts +++ b/sdk/cosmosdb/cosmos/src/common/uriFactory.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Constants } from "./constants"; -import { trimSlashFromLeftAndRight, validateResourceId, validateItemResourceId } from "./helper"; +import { Constants } from "./constants.js"; +import { trimSlashFromLeftAndRight, validateResourceId, validateItemResourceId } from "./helper.js"; /** * Would be used when creating or deleting a DocumentCollection diff --git a/sdk/cosmosdb/cosmos/src/diagnostics/CosmosDiagnosticsContext.ts b/sdk/cosmosdb/cosmos/src/diagnostics/CosmosDiagnosticsContext.ts index e69abe8661b5..b06281180354 100644 --- a/sdk/cosmosdb/cosmos/src/diagnostics/CosmosDiagnosticsContext.ts +++ b/sdk/cosmosdb/cosmos/src/diagnostics/CosmosDiagnosticsContext.ts @@ -7,8 +7,8 @@ import type { GatewayStatistics, MetadataLookUpDiagnostic, MetadataLookUpType, -} from "../CosmosDiagnostics"; -import { getCurrentTimestampInMs } from "../utils/time"; +} from "../CosmosDiagnostics.js"; +import { getCurrentTimestampInMs } from "../utils/time.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticFormatter.ts b/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticFormatter.ts index 3a7c516a28b5..7b7b12905651 100644 --- a/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticFormatter.ts +++ b/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticFormatter.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../CosmosDiagnostics"; +import type { CosmosDiagnostics } from "../CosmosDiagnostics.js"; export interface DiagnosticFormatter { format(cosmosDiagnostic: CosmosDiagnostics): string; diff --git a/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticNodeInternal.ts b/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticNodeInternal.ts index a95ddfbf4372..f279e7c2eb53 100644 --- a/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticNodeInternal.ts +++ b/sdk/cosmosdb/cosmos/src/diagnostics/DiagnosticNodeInternal.ts @@ -1,21 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { CosmosDiagnosticContext } from "./CosmosDiagnosticsContext"; -import type { RequestContext } from "../request"; +import { CosmosDiagnosticContext } from "./CosmosDiagnosticsContext.js"; +import type { RequestContext } from "../request/index.js"; import type { DiagnosticNode, MetadataLookUpType, ClientConfigDiagnostic, -} from "../CosmosDiagnostics"; -import { CosmosDiagnostics, getRootNode } from "../CosmosDiagnostics"; -import { getCurrentTimestampInMs } from "../utils/time"; -import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; -import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; +} from "../CosmosDiagnostics.js"; +import { CosmosDiagnostics, getRootNode } from "../CosmosDiagnostics.js"; +import { getCurrentTimestampInMs } from "../utils/time.js"; +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel.js"; +import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders.js"; import type { HttpHeaders, PipelineResponse } from "@azure/core-rest-pipeline"; -import type { OperationType, ResourceType } from "../common"; -import { Constants, prepareURL } from "../common"; -import { allowTracing } from "./diagnosticLevelComparator"; +import type { OperationType, ResourceType } from "../common/index.js"; +import { Constants, prepareURL } from "../common/index.js"; +import { allowTracing } from "./diagnosticLevelComparator.js"; import { randomUUID } from "@azure/core-util"; /** diff --git a/sdk/cosmosdb/cosmos/src/diagnostics/diagnosticLevelComparator.ts b/sdk/cosmosdb/cosmos/src/diagnostics/diagnosticLevelComparator.ts index 4d68d62447d4..f0783c45d496 100644 --- a/sdk/cosmosdb/cosmos/src/diagnostics/diagnosticLevelComparator.ts +++ b/sdk/cosmosdb/cosmos/src/diagnostics/diagnosticLevelComparator.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/diagnostics/index.ts b/sdk/cosmosdb/cosmos/src/diagnostics/index.ts index af2f29de8906..7087e04b653f 100644 --- a/sdk/cosmosdb/cosmos/src/diagnostics/index.ts +++ b/sdk/cosmosdb/cosmos/src/diagnostics/index.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Constants } from "../common"; -import { isNonEmptyString } from "../utils/strings"; -import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel"; -import { diagnosticLevelFromEnv } from "../utils/envUtils"; +import { Constants } from "../common/index.js"; +import { isNonEmptyString } from "../utils/strings.js"; +import { CosmosDbDiagnosticLevel } from "./CosmosDbDiagnosticLevel.js"; +import { diagnosticLevelFromEnv } from "../utils/envUtils.js"; -export * from "./DiagnosticWriter"; -export * from "./DiagnosticFormatter"; +export * from "./DiagnosticWriter.js"; +export * from "./DiagnosticFormatter.js"; export const DefaultDiagnosticLevelValue = CosmosDbDiagnosticLevel.info; diff --git a/sdk/cosmosdb/cosmos/src/documents/ConnectionPolicy.ts b/sdk/cosmosdb/cosmos/src/documents/ConnectionPolicy.ts index 10a01ac2fe2e..cb59207a65e8 100644 --- a/sdk/cosmosdb/cosmos/src/documents/ConnectionPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/documents/ConnectionPolicy.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { RetryOptions } from "../retry/retryOptions"; -import { ConnectionMode } from "./ConnectionMode"; +import type { RetryOptions } from "../retry/retryOptions.js"; +import { ConnectionMode } from "./ConnectionMode.js"; /** * Represents the Connection policy associated with a CosmosClient in the Azure Cosmos DB database service. */ diff --git a/sdk/cosmosdb/cosmos/src/documents/DatabaseAccount.ts b/sdk/cosmosdb/cosmos/src/documents/DatabaseAccount.ts index 04d161c44224..aff26bf76cb4 100644 --- a/sdk/cosmosdb/cosmos/src/documents/DatabaseAccount.ts +++ b/sdk/cosmosdb/cosmos/src/documents/DatabaseAccount.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Constants } from "../common"; -import type { CosmosHeaders } from "../queryExecutionContext"; -import { ConsistencyLevel } from "./ConsistencyLevel"; +import { Constants } from "../common/index.js"; +import type { CosmosHeaders } from "../queryExecutionContext/index.js"; +import { ConsistencyLevel } from "./ConsistencyLevel.js"; /** * Represents a DatabaseAccount in the Azure Cosmos DB database service. diff --git a/sdk/cosmosdb/cosmos/src/documents/IndexingPolicy.ts b/sdk/cosmosdb/cosmos/src/documents/IndexingPolicy.ts index e60c52c2bc51..abb8542297fd 100644 --- a/sdk/cosmosdb/cosmos/src/documents/IndexingPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/documents/IndexingPolicy.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DataType, IndexingMode, IndexKind } from "./index"; +import type { DataType, IndexingMode, IndexKind } from "./index.js"; export interface IndexingPolicy { /** The indexing mode (consistent or lazy) {@link IndexingMode}. */ diff --git a/sdk/cosmosdb/cosmos/src/documents/PartitionKey.ts b/sdk/cosmosdb/cosmos/src/documents/PartitionKey.ts index b2c31a064a3a..ed070590f556 100644 --- a/sdk/cosmosdb/cosmos/src/documents/PartitionKey.ts +++ b/sdk/cosmosdb/cosmos/src/documents/PartitionKey.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from "./PartitionKeyInternal"; +import { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from "./PartitionKeyInternal.js"; /** * PartitionKey of a container. diff --git a/sdk/cosmosdb/cosmos/src/documents/PartitionKeyDefinition.ts b/sdk/cosmosdb/cosmos/src/documents/PartitionKeyDefinition.ts index c52e03c30a6f..8b41c1ad4f8f 100644 --- a/sdk/cosmosdb/cosmos/src/documents/PartitionKeyDefinition.ts +++ b/sdk/cosmosdb/cosmos/src/documents/PartitionKeyDefinition.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKeyDefinitionVersion } from "./PartitionKeyDefinitionVersion"; -import type { PartitionKeyKind } from "./PartitionKeyKind"; +import type { PartitionKeyDefinitionVersion } from "./PartitionKeyDefinitionVersion.js"; +import type { PartitionKeyKind } from "./PartitionKeyKind.js"; export interface PartitionKeyDefinition { /** diff --git a/sdk/cosmosdb/cosmos/src/documents/PartitionKeyInternal.ts b/sdk/cosmosdb/cosmos/src/documents/PartitionKeyInternal.ts index a92602e70101..fa2ca16869b6 100644 --- a/sdk/cosmosdb/cosmos/src/documents/PartitionKeyInternal.ts +++ b/sdk/cosmosdb/cosmos/src/documents/PartitionKeyInternal.ts @@ -6,7 +6,7 @@ import type { NullPartitionKeyType, PartitionKey, PrimitivePartitionKeyValue, -} from "./PartitionKey"; +} from "./PartitionKey.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/documents/index.ts b/sdk/cosmosdb/cosmos/src/documents/index.ts index 5887935b233a..6dff46df320c 100644 --- a/sdk/cosmosdb/cosmos/src/documents/index.ts +++ b/sdk/cosmosdb/cosmos/src/documents/index.ts @@ -1,25 +1,25 @@ // 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 "./ComputedProperty"; -export * from "./VectorEmbeddingPolicy"; -export * from "./FullTextPolicy"; +export * from "./ConnectionMode.js"; +export * from "./ConnectionPolicy.js"; +export * from "./ConsistencyLevel.js"; +export * from "./DatabaseAccount.js"; +export * from "./DataType.js"; +export * from "./Document.js"; +export * from "./IndexingMode.js"; +export * from "./IndexingPolicy.js"; +export * from "./IndexKind.js"; +export * from "./PartitionKey.js"; +export * from "./PartitionKeyInternal.js"; +export * from "./PartitionKeyDefinitionVersion.js"; +export * from "./PartitionKeyKind.js"; +export * from "./PartitionKeyDefinition.js"; +export * from "./PermissionMode.js"; +export * from "./PriorityLevel.js"; +export * from "./TriggerOperation.js"; +export * from "./TriggerType.js"; +export * from "./UserDefinedFunctionType.js"; +export * from "./GeospatialType.js"; +export * from "./ComputedProperty.js"; +export * from "./VectorEmbeddingPolicy.js"; +export * from "./FullTextPolicy.js"; diff --git a/sdk/cosmosdb/cosmos/src/extractPartitionKey.ts b/sdk/cosmosdb/cosmos/src/extractPartitionKey.ts index 0b2ce7289601..dee14062aa4f 100644 --- a/sdk/cosmosdb/cosmos/src/extractPartitionKey.ts +++ b/sdk/cosmosdb/cosmos/src/extractPartitionKey.ts @@ -2,22 +2,22 @@ // Licensed under the MIT License. import type { AzureLogger } from "@azure/logger"; import { createClientLogger } from "@azure/logger"; -import { parsePath } from "./common"; +import { parsePath } from "./common/index.js"; import type { PartitionKey, PartitionKeyDefinition, PartitionKeyInternal, PrimitivePartitionKeyValue, -} from "./documents"; +} from "./documents/index.js"; import { convertToInternalPartitionKey, NonePartitionKeyLiteral, NullPartitionKeyLiteral, -} from "./documents"; -import { DEFAULT_PARTITION_KEY_PATH } from "./common/partitionKeys"; -import type { Container } from "./client"; -import { readPartitionKeyDefinition } from "./client/ClientUtils"; -import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; +} from "./documents/index.js"; +import { DEFAULT_PARTITION_KEY_PATH } from "./common/partitionKeys.js"; +import type { Container } from "./client/index.js"; +import { readPartitionKeyDefinition } from "./client/ClientUtils.js"; +import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js"; const logger: AzureLogger = createClientLogger("extractPartitionKey"); diff --git a/sdk/cosmosdb/cosmos/src/globalEndpointManager.ts b/sdk/cosmosdb/cosmos/src/globalEndpointManager.ts index 30766ae99590..4fbb011a1c11 100644 --- a/sdk/cosmosdb/cosmos/src/globalEndpointManager.ts +++ b/sdk/cosmosdb/cosmos/src/globalEndpointManager.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { OperationType, ResourceType, isReadRequest } from "./common"; -import type { CosmosClientOptions } from "./CosmosClientOptions"; -import type { Location, DatabaseAccount } from "./documents"; -import type { RequestOptions } from "./index"; -import { Constants } from "./common/constants"; -import type { ResourceResponse } from "./request"; -import { MetadataLookUpType } from "./CosmosDiagnostics"; -import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal"; -import { withMetadataDiagnostics } from "./utils/diagnostics"; +import { OperationType, ResourceType, isReadRequest } from "./common/index.js"; +import type { CosmosClientOptions } from "./CosmosClientOptions.js"; +import type { Location, DatabaseAccount } from "./documents/index.js"; +import type { RequestOptions } from "./index.js"; +import { Constants } from "./common/constants.js"; +import type { ResourceResponse } from "./request/index.js"; +import { MetadataLookUpType } from "./CosmosDiagnostics.js"; +import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js"; +import { withMetadataDiagnostics } from "./utils/diagnostics.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/index.ts b/sdk/cosmosdb/cosmos/src/index.ts index fb9ee1e5cc46..78e30d34befb 100644 --- a/sdk/cosmosdb/cosmos/src/index.ts +++ b/sdk/cosmosdb/cosmos/src/index.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export { DEFAULT_PARTITION_KEY_PATH } from "./common/partitionKeys"; -export { StatusCodes, StatusCodesType, PartitionKeyRangePropertiesNames } from "./common"; -export { setAuthorizationTokenHeaderUsingMasterKey } from "./auth"; +export { DEFAULT_PARTITION_KEY_PATH } from "./common/partitionKeys.js"; +export { StatusCodes, StatusCodesType, PartitionKeyRangePropertiesNames } from "./common/index.js"; +export { setAuthorizationTokenHeaderUsingMasterKey } from "./auth.js"; export { Operation, OperationResponse, @@ -24,14 +24,14 @@ export { DeleteOperationInput, PatchOperationInput, BulkPatchOperation, -} from "./utils/batch"; +} from "./utils/batch.js"; export { PatchOperation, PatchOperationType, ExistingKeyOperation, RemoveOperation, PatchRequestBody, -} from "./utils/patch"; +} from "./utils/patch.js"; export { ConnectionMode, ConsistencyLevel, @@ -71,19 +71,19 @@ export { FullTextIndex, FullTextPolicy, FullTextPath, -} from "./documents"; +} from "./documents/index.js"; -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 { UniqueKeyPolicy, UniqueKey } from "./client/Container/UniqueKeyPolicy.js"; +export { ContainerRequest } from "./client/Container/ContainerRequest.js"; +export { Constants, OperationType, ResourceType, HTTPMethod } from "./common/index.js"; +export { RetryOptions } from "./retry/index.js"; +export * from "./request/index.js"; export { DiagnosticNodeInternal, DiagnosticDataValue, DiagnosticNodeType, -} from "./diagnostics/DiagnosticNodeInternal"; +} from "./diagnostics/DiagnosticNodeInternal.js"; export { CosmosHeaders, @@ -92,20 +92,20 @@ export { 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"; +} from "./queryExecutionContext/index.js"; +export { QueryIterator } from "./queryIterator.js"; +export * from "./queryMetrics/index.js"; +export { CosmosClient } from "./CosmosClient.js"; +export { CosmosClientOptions, Agent } from "./CosmosClientOptions.js"; +export * from "./client/index.js"; +export { Scripts } from "./client/Script/Scripts.js"; +export { Next, Plugin, PluginConfig, PluginOn } from "./plugins/Plugin.js"; +export { TokenProvider, RequestInfo } from "./auth.js"; -export { ChangeFeedIterator } from "./ChangeFeedIterator"; -export { ChangeFeedOptions } from "./ChangeFeedOptions"; -export { ChangeFeedResponse } from "./ChangeFeedResponse"; -export { ClientContext } from "./ClientContext"; +export { ChangeFeedIterator } from "./ChangeFeedIterator.js"; +export { ChangeFeedOptions } from "./ChangeFeedOptions.js"; +export { ChangeFeedResponse } from "./ChangeFeedResponse.js"; +export { ClientContext } from "./ClientContext.js"; export { CosmosDiagnostics, @@ -118,7 +118,7 @@ export { ClientSideRequestStatistics, ClientConfigDiagnostic, DiagnosticNode, -} from "./CosmosDiagnostics"; +} from "./CosmosDiagnostics.js"; export { ChangeFeedPullModelIterator, @@ -129,11 +129,11 @@ export { ChangeFeedMode, ChangeFeedPolicy, ChangeFeedRetentionTimeSpan, -} from "./client/ChangeFeed"; -export { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel"; +} from "./client/ChangeFeed/index.js"; +export { CosmosDbDiagnosticLevel } from "./diagnostics/CosmosDbDiagnosticLevel.js"; -export { GlobalEndpointManager } from "./globalEndpointManager"; -export { SasTokenPermissionKind } from "./common/constants"; -export { createAuthorizationSasToken } from "./utils/SasToken"; +export { GlobalEndpointManager } from "./globalEndpointManager.js"; +export { SasTokenPermissionKind } from "./common/constants.js"; +export { createAuthorizationSasToken } from "./utils/SasToken.js"; export { RestError } from "@azure/core-rest-pipeline"; export { AbortError } from "@azure/abort-controller"; diff --git a/sdk/cosmosdb/cosmos/src/indexMetrics/IndexMetricWriter.ts b/sdk/cosmosdb/cosmos/src/indexMetrics/IndexMetricWriter.ts index 30fadc038f9d..cc5e316b7033 100644 --- a/sdk/cosmosdb/cosmos/src/indexMetrics/IndexMetricWriter.ts +++ b/sdk/cosmosdb/cosmos/src/indexMetrics/IndexMetricWriter.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import Constants from "./Constants"; -import type { CompositeIndexUtilizationEntity } from "./CompositeIndexUtilizationEntity"; -import type { IndexUtilizationInfo } from "./IndexUtilizationInfo"; -import type { SingleIndexUtilizationEntity } from "./SingleIndexUtilizationEntity"; +import Constants from "./Constants.js"; +import type { CompositeIndexUtilizationEntity } from "./CompositeIndexUtilizationEntity.js"; +import type { IndexUtilizationInfo } from "./IndexUtilizationInfo.js"; +import type { SingleIndexUtilizationEntity } from "./SingleIndexUtilizationEntity.js"; export class IndexMetricWriter { public writeIndexMetrics(indexUtilizationInfo: IndexUtilizationInfo): string { diff --git a/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts b/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts index 5b7bf9337c1c..a55c9b5d26a2 100644 --- a/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts +++ b/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { SingleIndexUtilizationEntity } from "./SingleIndexUtilizationEntity"; -import type { CompositeIndexUtilizationEntity } from "./CompositeIndexUtilizationEntity"; +import type { SingleIndexUtilizationEntity } from "./SingleIndexUtilizationEntity.js"; +import type { CompositeIndexUtilizationEntity } from "./CompositeIndexUtilizationEntity.js"; export class IndexUtilizationInfo { public static readonly Empty = new IndexUtilizationInfo([], [], [], []); diff --git a/sdk/cosmosdb/cosmos/src/indexMetrics/index.ts b/sdk/cosmosdb/cosmos/src/indexMetrics/index.ts index f0b6d9be4a9e..603a19487e03 100644 --- a/sdk/cosmosdb/cosmos/src/indexMetrics/index.ts +++ b/sdk/cosmosdb/cosmos/src/indexMetrics/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export * from "./IndexUtilizationInfo"; -export * from "./CompositeIndexUtilizationEntity"; -export * from "./SingleIndexUtilizationEntity"; -export * from "./IndexMetricWriter"; +export * from "./IndexUtilizationInfo.js"; +export * from "./CompositeIndexUtilizationEntity.js"; +export * from "./SingleIndexUtilizationEntity.js"; +export * from "./IndexMetricWriter.js"; diff --git a/sdk/cosmosdb/cosmos/src/plugins/Plugin.ts b/sdk/cosmosdb/cosmos/src/plugins/Plugin.ts index a5afac15627e..c7548989a783 100644 --- a/sdk/cosmosdb/cosmos/src/plugins/Plugin.ts +++ b/sdk/cosmosdb/cosmos/src/plugins/Plugin.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { RequestContext } from "../request/RequestContext"; -import type { Response } from "../request/Response"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { RequestContext } from "../request/RequestContext.js"; +import type { Response } from "../request/Response.js"; /** * Used to specify which type of events to execute this plug in on. diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/AverageAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/AverageAggregator.ts index 6ca4688f0d21..33398ab56ba6 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/AverageAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/AverageAggregator.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Aggregator } from "./Aggregator"; +import type { Aggregator } from "./Aggregator.js"; /** @hidden */ export interface AverageAggregateResult { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/CountAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/CountAggregator.ts index fcbc54d725c4..990fa7df4442 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/CountAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/CountAggregator.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Aggregator } from "./Aggregator"; +import type { Aggregator } from "./Aggregator.js"; /** @hidden */ export class CountAggregator implements Aggregator { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts index 8b548cd72b32..ebfa016dd111 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { GlobalStatistics } from "../../request/globalStatistics"; -import { Aggregator } from "./Aggregator"; +import { GlobalStatistics } from "../../request/globalStatistics.js"; +import { Aggregator } from "./Aggregator.js"; export class GlobalStatisticsAggregator implements Aggregator { private globalStatistics: GlobalStatistics; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeListAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeListAggregator.ts index 3789bd7cc22a..aac60a21f5fa 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeListAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeListAggregator.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Aggregator } from "./Aggregator"; +import type { Aggregator } from "./Aggregator.js"; /** @hidden */ export class MakeListAggregator implements Aggregator { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeSetAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeSetAggregator.ts index d1775c39028f..912bcf1717c8 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeSetAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MakeSetAggregator.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Aggregator } from "./Aggregator"; +import type { Aggregator } from "./Aggregator.js"; /** @hidden */ /** diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MaxAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MaxAggregator.ts index 8b6c75ee06c1..5b9248e28d54 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MaxAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MaxAggregator.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator"; -import type { Aggregator } from "./Aggregator"; +import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator.js"; +import type { Aggregator } from "./Aggregator.js"; interface MaxAggregateResult { count: number; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MinAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MinAggregator.ts index 6308e0634f59..d8f612a709bd 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MinAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/MinAggregator.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator"; -import type { Aggregator } from "./Aggregator"; +import { OrderByDocumentProducerComparator } from "../orderByDocumentProducerComparator.js"; +import type { Aggregator } from "./Aggregator.js"; export interface MinAggregateResult { min: number; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/StaticValueAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/StaticValueAggregator.ts index a8f2b0037124..345aed7d1f84 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/StaticValueAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/StaticValueAggregator.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Aggregator } from "./Aggregator"; +import type { Aggregator } from "./Aggregator.js"; /** @hidden */ export class StaticValueAggregator implements Aggregator { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/SumAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/SumAggregator.ts index 6164f7a5113f..44dae23ac290 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/SumAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/SumAggregator.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Aggregator } from "./Aggregator"; +import type { Aggregator } from "./Aggregator.js"; /** @hidden */ export class SumAggregator implements Aggregator { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/index.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/index.ts index 20a8ba981fdf..a7d132971cd2 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/index.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/index.ts @@ -1,14 +1,14 @@ // 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"; -import type { AggregateType } from "../../request/ErrorResponse"; -import { MakeListAggregator } from "./MakeListAggregator"; -import { MakeSetAggregator } from "./MakeSetAggregator"; +import { AverageAggregator } from "./AverageAggregator.js"; +import { CountAggregator } from "./CountAggregator.js"; +import { MaxAggregator } from "./MaxAggregator.js"; +import { MinAggregator } from "./MinAggregator.js"; +import { SumAggregator } from "./SumAggregator.js"; +import { StaticValueAggregator } from "./StaticValueAggregator.js"; +import type { AggregateType } from "../../request/ErrorResponse.js"; +import { MakeListAggregator } from "./MakeListAggregator.js"; +import { MakeSetAggregator } from "./MakeSetAggregator.js"; export function createAggregator( aggregateType: AggregateType, @@ -40,4 +40,4 @@ export function createAggregator( } export { AverageAggregator, CountAggregator, MaxAggregator, MinAggregator, SumAggregator }; -export { Aggregator } from "./Aggregator"; +export { Aggregator } from "./Aggregator.js"; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts index 7a8d1205ab2a..6156311d8ace 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; -import type { CosmosHeaders } from "../CosmosHeaders"; -import type { QueryInfo } from "../../request/ErrorResponse"; -import { hashObject } from "../../utils/hashObject"; -import type { Aggregator } from "../Aggregators"; -import { createAggregator } from "../Aggregators"; -import { getInitialHeader, mergeHeaders } from "../headerUtils"; -import { emptyGroup, extractAggregateResult } from "./emptyGroup"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; +import type { CosmosHeaders } from "../CosmosHeaders.js"; +import type { QueryInfo } from "../../request/ErrorResponse.js"; +import { hashObject } from "../../utils/hashObject.js"; +import type { Aggregator } from "../Aggregators/index.js"; +import { createAggregator } from "../Aggregators/index.js"; +import { getInitialHeader, mergeHeaders } from "../headerUtils.js"; +import { emptyGroup, extractAggregateResult } from "./emptyGroup.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; interface GroupByResponse { result: GroupByResult; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts index a1ff1c109638..5cae33906995 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; -import type { CosmosHeaders } from "../CosmosHeaders"; -import type { AggregateType, QueryInfo } from "../../request/ErrorResponse"; -import { hashObject } from "../../utils/hashObject"; -import type { Aggregator } from "../Aggregators"; -import { createAggregator } from "../Aggregators"; -import { getInitialHeader, mergeHeaders } from "../headerUtils"; -import { emptyGroup, extractAggregateResult } from "./emptyGroup"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; +import type { CosmosHeaders } from "../CosmosHeaders.js"; +import type { AggregateType, QueryInfo } from "../../request/ErrorResponse.js"; +import { hashObject } from "../../utils/hashObject.js"; +import type { Aggregator } from "../Aggregators/index.js"; +import { createAggregator } from "../Aggregators/index.js"; +import { getInitialHeader, mergeHeaders } from "../headerUtils.js"; +import { emptyGroup, extractAggregateResult } from "./emptyGroup.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; interface GroupByResponse { result: GroupByResult; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts index b70612c0520a..bba6c353b2a6 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { QueryInfo, Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; -import { getInitialHeader } from "../headerUtils"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import { hashObject } from "../../utils/hashObject"; -import type { NonStreamingOrderByResult } from "../nonStreamingOrderByResult"; -import type { NonStreamingOrderByResponse } from "../nonStreamingOrderByResponse"; -import { FixedSizePriorityQueue } from "../../utils/fixedSizePriorityQueue"; -import { NonStreamingOrderByMap } from "../../utils/nonStreamingOrderByMap"; -import { OrderByComparator } from "../orderByComparator"; +import type { QueryInfo, Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; +import { getInitialHeader } from "../headerUtils.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import { hashObject } from "../../utils/hashObject.js"; +import type { NonStreamingOrderByResult } from "../nonStreamingOrderByResult.js"; +import type { NonStreamingOrderByResponse } from "../nonStreamingOrderByResponse.js"; +import { FixedSizePriorityQueue } from "../../utils/fixedSizePriorityQueue.js"; +import { NonStreamingOrderByMap } from "../../utils/nonStreamingOrderByMap.js"; +import { OrderByComparator } from "../orderByComparator.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts index 05b2213309cc..dacea476c419 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import type { Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; -import { OrderByComparator } from "../orderByComparator"; -import type { NonStreamingOrderByResult } from "../nonStreamingOrderByResult"; -import { FixedSizePriorityQueue } from "../../utils/fixedSizePriorityQueue"; -import { getInitialHeader } from "../headerUtils"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import type { Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; +import { OrderByComparator } from "../orderByComparator.js"; +import type { NonStreamingOrderByResult } from "../nonStreamingOrderByResult.js"; +import { FixedSizePriorityQueue } from "../../utils/fixedSizePriorityQueue.js"; +import { getInitialHeader } from "../headerUtils.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts index c5a69636852a..aefce93940de 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import type { Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; -import { getInitialHeader, mergeHeaders } from "../headerUtils"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import type { Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; +import { getInitialHeader, mergeHeaders } from "../headerUtils.js"; /** @hidden */ export class OffsetLimitEndpointComponent implements ExecutionContext { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts index 3588dd752e8b..ec240377f640 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; -import type { Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; +import type { Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; /** @hidden */ export class OrderByEndpointComponent implements ExecutionContext { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts index 9046a1023fe7..4ebc4e349542 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; -import { hashObject } from "../../utils/hashObject"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; +import { hashObject } from "../../utils/hashObject.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; /** @hidden */ export class OrderedDistinctEndpointComponent implements ExecutionContext { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts index 2a75f011c650..08f6b387e875 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Response } from "../../request"; -import type { ExecutionContext } from "../ExecutionContext"; -import { hashObject } from "../../utils/hashObject"; -import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal"; +import type { Response } from "../../request/index.js"; +import type { ExecutionContext } from "../ExecutionContext.js"; +import { hashObject } from "../../utils/hashObject.js"; +import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; /** @hidden */ export class UnorderedDistinctEndpointComponent implements ExecutionContext { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/ExecutionContext.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/ExecutionContext.ts index 353c84bf2a7a..0f562b196eac 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/ExecutionContext.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/ExecutionContext.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { Response } from "../request"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { Response } from "../request/index.js"; /** @hidden */ export interface ExecutionContext { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts index 0aa0273d1187..13923ecb21ea 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/defaultQueryExecutionContext.ts @@ -2,15 +2,15 @@ // Licensed under the MIT License. import type { AzureLogger } from "@azure/logger"; import { createClientLogger } from "@azure/logger"; -import { Constants } from "../common"; -import { ClientSideMetrics, QueryMetrics } from "../queryMetrics"; -import type { FeedOptions, Response } from "../request"; -import { getInitialHeader } from "./headerUtils"; -import type { ExecutionContext } from "./index"; -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; -import { addDignosticChild } from "../utils/diagnostics"; -import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel"; +import { Constants } from "../common/index.js"; +import { ClientSideMetrics, QueryMetrics } from "../queryMetrics/index.js"; +import type { FeedOptions, Response } from "../request/index.js"; +import { getInitialHeader } from "./headerUtils.js"; +import type { ExecutionContext } from "./index.js"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal.js"; +import { addDignosticChild } from "../utils/diagnostics.js"; +import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel.js"; const logger: AzureLogger = createClientLogger("ClientContext"); /** @hidden */ diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/documentProducer.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/documentProducer.ts index 67bb7aba629d..de59675143e8 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/documentProducer.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/documentProducer.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKeyRange, Resource } from "../client"; -import type { ClientContext } from "../ClientContext"; +import type { PartitionKeyRange, Resource } from "../client/index.js"; +import type { ClientContext } from "../ClientContext.js"; import { Constants, getIdFromLink, @@ -9,16 +9,16 @@ import { ResourceType, StatusCodes, SubStatusCodes, -} from "../common"; -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { FeedOptions } from "../request"; -import type { Response } from "../request"; -import type { FetchFunctionCallback } from "./defaultQueryExecutionContext"; -import { DefaultQueryExecutionContext } from "./defaultQueryExecutionContext"; -import { FetchResult, FetchResultType } from "./FetchResult"; -import type { CosmosHeaders } from "./headerUtils"; -import { getInitialHeader, mergeHeaders } from "./headerUtils"; -import type { SqlQuerySpec } from "./index"; +} from "../common/index.js"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { FeedOptions } from "../request/index.js"; +import type { Response } from "../request/index.js"; +import type { FetchFunctionCallback } from "./defaultQueryExecutionContext.js"; +import { DefaultQueryExecutionContext } from "./defaultQueryExecutionContext.js"; +import { FetchResult, FetchResultType } from "./FetchResult.js"; +import type { CosmosHeaders } from "./headerUtils.js"; +import { getInitialHeader, mergeHeaders } from "./headerUtils.js"; +import type { SqlQuerySpec } from "./index.js"; /** @hidden */ export class DocumentProducer { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/headerUtils.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/headerUtils.ts index fb4e6933dddb..7fb0b36e4b1b 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/headerUtils.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/headerUtils.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Constants } from "../common"; -import { QueryMetrics } from "../queryMetrics/queryMetrics"; +import { Constants } from "../common/index.js"; +import { QueryMetrics } from "../queryMetrics/queryMetrics.js"; export interface CosmosHeaders { [key: string]: any; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/hybridQueryExecutionContext.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/hybridQueryExecutionContext.ts index 4e687fa335d1..cd5cd513de37 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/hybridQueryExecutionContext.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/hybridQueryExecutionContext.ts @@ -2,8 +2,8 @@ // Licensed under the MIT License. import { AzureLogger, createClientLogger } from "@azure/logger"; -import { ClientContext } from "../ClientContext"; -import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import { ClientContext } from "../ClientContext.js"; +import { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; import { FeedOptions, GlobalStatistics, @@ -11,14 +11,14 @@ import { QueryInfo, QueryRange, Response, -} from "../request"; -import { HybridSearchQueryResult } from "../request/hybridSearchQueryResult"; -import { GlobalStatisticsAggregator } from "./Aggregators/GlobalStatisticsAggregator"; -import { CosmosHeaders } from "./CosmosHeaders"; -import { ExecutionContext } from "./ExecutionContext"; -import { getInitialHeader, mergeHeaders } from "./headerUtils"; -import { ParallelQueryExecutionContext } from "./parallelQueryExecutionContext"; -import { PipelinedQueryExecutionContext } from "./pipelinedQueryExecutionContext"; +} from "../request/index.js"; +import { HybridSearchQueryResult } from "../request/hybridSearchQueryResult.js"; +import { GlobalStatisticsAggregator } from "./Aggregators/GlobalStatisticsAggregator.js"; +import { CosmosHeaders } from "./CosmosHeaders.js"; +import { ExecutionContext } from "./ExecutionContext.js"; +import { getInitialHeader, mergeHeaders } from "./headerUtils.js"; +import { ParallelQueryExecutionContext } from "./parallelQueryExecutionContext.js"; +import { PipelinedQueryExecutionContext } from "./pipelinedQueryExecutionContext.js"; /** @hidden */ export enum HybridQueryExecutionContextBaseStates { diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/index.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/index.ts index 503e4d2c43a8..2bd46bcb3239 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/index.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/index.ts @@ -1,15 +1,15 @@ // 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"; +export * from "./headerUtils.js"; +export * from "./SqlQuerySpec.js"; +export * from "./defaultQueryExecutionContext.js"; +export * from "./Aggregators/index.js"; +export * from "./documentProducer.js"; +export * from "./FetchResult.js"; +export * from "./orderByDocumentProducerComparator.js"; +export * from "./ExecutionContext.js"; +export * from "./parallelQueryExecutionContextBase.js"; +export * from "./parallelQueryExecutionContext.js"; +export * from "./orderByQueryExecutionContext.js"; +export * from "./pipelinedQueryExecutionContext.js"; +export * from "./orderByComparator.js"; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/nonStreamingOrderByResponse.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/nonStreamingOrderByResponse.ts index d13a63e77cba..ac7bc83b7b17 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/nonStreamingOrderByResponse.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/nonStreamingOrderByResponse.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosHeaders } from "./CosmosHeaders"; -import type { NonStreamingOrderByResult } from "./nonStreamingOrderByResult"; +import type { CosmosHeaders } from "./CosmosHeaders.js"; +import type { NonStreamingOrderByResult } from "./nonStreamingOrderByResult.js"; export interface NonStreamingOrderByResponse { result: NonStreamingOrderByResult; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByComparator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByComparator.ts index caa9cc1c5066..c6cd91f4616b 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByComparator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByComparator.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { NonStreamingOrderByResult } from "./nonStreamingOrderByResult"; +import type { NonStreamingOrderByResult } from "./nonStreamingOrderByResult.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByDocumentProducerComparator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByDocumentProducerComparator.ts index f01aa09f8cd4..a57d719f08f3 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByDocumentProducerComparator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByDocumentProducerComparator.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DocumentProducer } from "./documentProducer"; +import type { DocumentProducer } from "./documentProducer.js"; // TODO: this smells funny /** @hidden */ diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByQueryExecutionContext.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByQueryExecutionContext.ts index e98a9353e4cb..c6ca3b0bdd38 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByQueryExecutionContext.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/orderByQueryExecutionContext.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../ClientContext"; -import type { PartitionedQueryExecutionInfo } from "../request/ErrorResponse"; -import type { FeedOptions } from "../request/FeedOptions"; -import type { DocumentProducer } from "./documentProducer"; -import type { ExecutionContext } from "./ExecutionContext"; -import { OrderByDocumentProducerComparator } from "./orderByDocumentProducerComparator"; -import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase"; -import type { SqlQuerySpec } from "./SqlQuerySpec"; +import type { ClientContext } from "../ClientContext.js"; +import type { PartitionedQueryExecutionInfo } from "../request/ErrorResponse.js"; +import type { FeedOptions } from "../request/FeedOptions.js"; +import type { DocumentProducer } from "./documentProducer.js"; +import type { ExecutionContext } from "./ExecutionContext.js"; +import { OrderByDocumentProducerComparator } from "./orderByDocumentProducerComparator.js"; +import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase.js"; +import type { SqlQuerySpec } from "./SqlQuerySpec.js"; /** @hidden */ export class OrderByQueryExecutionContext diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContext.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContext.ts index 3eb70eda4570..cdcea19693b1 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContext.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContext.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DocumentProducer } from "./documentProducer"; -import type { ExecutionContext } from "./ExecutionContext"; -import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase"; +import type { DocumentProducer } from "./documentProducer.js"; +import type { ExecutionContext } from "./ExecutionContext.js"; +import { ParallelQueryExecutionContextBase } from "./parallelQueryExecutionContextBase.js"; /** * Provides the ParallelQueryExecutionContext. diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts index 2ef38260fdc3..474e53a33cef 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts @@ -2,23 +2,23 @@ // Licensed under the MIT License. import PriorityQueue from "priorityqueuejs"; import semaphore from "semaphore"; -import type { ClientContext } from "../ClientContext"; +import type { ClientContext } from "../ClientContext.js"; import type { AzureLogger } from "@azure/logger"; import { createClientLogger } from "@azure/logger"; -import { StatusCodes, SubStatusCodes } from "../common/statusCodes"; -import type { FeedOptions, Response } from "../request"; -import type { PartitionedQueryExecutionInfo } from "../request/ErrorResponse"; -import { QueryRange } from "../routing/QueryRange"; -import { SmartRoutingMapProvider } from "../routing/smartRoutingMapProvider"; -import type { CosmosHeaders } from "./CosmosHeaders"; -import { DocumentProducer } from "./documentProducer"; -import type { ExecutionContext } from "./ExecutionContext"; -import { getInitialHeader, mergeHeaders } from "./headerUtils"; -import type { SqlQuerySpec } from "./SqlQuerySpec"; -import { DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; -import { addDignosticChild } from "../utils/diagnostics"; -import { MetadataLookUpType } from "../CosmosDiagnostics"; -import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel"; +import { StatusCodes, SubStatusCodes } from "../common/statusCodes.js"; +import type { FeedOptions, Response } from "../request/index.js"; +import type { PartitionedQueryExecutionInfo } from "../request/ErrorResponse.js"; +import { QueryRange } from "../routing/QueryRange.js"; +import { SmartRoutingMapProvider } from "../routing/smartRoutingMapProvider.js"; +import type { CosmosHeaders } from "./CosmosHeaders.js"; +import { DocumentProducer } from "./documentProducer.js"; +import type { ExecutionContext } from "./ExecutionContext.js"; +import { getInitialHeader, mergeHeaders } from "./headerUtils.js"; +import type { SqlQuerySpec } from "./SqlQuerySpec.js"; +import { DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal.js"; +import { addDignosticChild } from "../utils/diagnostics.js"; +import { MetadataLookUpType } from "../CosmosDiagnostics.js"; +import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel.js"; /** @hidden */ const logger: AzureLogger = createClientLogger("parallelQueryExecutionContextBase"); diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/pipelinedQueryExecutionContext.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/pipelinedQueryExecutionContext.ts index fac35e33cdd7..5bafb46c9483 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/pipelinedQueryExecutionContext.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/pipelinedQueryExecutionContext.ts @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../ClientContext"; -import type { Response, FeedOptions } from "../request"; -import type { PartitionedQueryExecutionInfo, QueryInfo } from "../request/ErrorResponse"; -import { ErrorResponse } from "../request/ErrorResponse"; -import type { CosmosHeaders } from "./CosmosHeaders"; -import { OffsetLimitEndpointComponent } from "./EndpointComponent/OffsetLimitEndpointComponent"; -import { OrderByEndpointComponent } from "./EndpointComponent/OrderByEndpointComponent"; -import { OrderedDistinctEndpointComponent } from "./EndpointComponent/OrderedDistinctEndpointComponent"; -import { UnorderedDistinctEndpointComponent } from "./EndpointComponent/UnorderedDistinctEndpointComponent"; -import { GroupByEndpointComponent } from "./EndpointComponent/GroupByEndpointComponent"; -import type { ExecutionContext } from "./ExecutionContext"; -import { getInitialHeader, mergeHeaders } from "./headerUtils"; -import { OrderByQueryExecutionContext } from "./orderByQueryExecutionContext"; -import { ParallelQueryExecutionContext } from "./parallelQueryExecutionContext"; -import { GroupByValueEndpointComponent } from "./EndpointComponent/GroupByValueEndpointComponent"; -import type { SqlQuerySpec } from "./SqlQuerySpec"; -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import { NonStreamingOrderByDistinctEndpointComponent } from "./EndpointComponent/NonStreamingOrderByDistinctEndpointComponent"; -import { NonStreamingOrderByEndpointComponent } from "./EndpointComponent/NonStreamingOrderByEndpointComponent"; +import type { ClientContext } from "../ClientContext.js"; +import type { Response, FeedOptions } from "../request/index.js"; +import type { PartitionedQueryExecutionInfo, QueryInfo } from "../request/ErrorResponse.js"; +import { ErrorResponse } from "../request/ErrorResponse.js"; +import type { CosmosHeaders } from "./CosmosHeaders.js"; +import { OffsetLimitEndpointComponent } from "./EndpointComponent/OffsetLimitEndpointComponent.js"; +import { OrderByEndpointComponent } from "./EndpointComponent/OrderByEndpointComponent.js"; +import { OrderedDistinctEndpointComponent } from "./EndpointComponent/OrderedDistinctEndpointComponent.js"; +import { UnorderedDistinctEndpointComponent } from "./EndpointComponent/UnorderedDistinctEndpointComponent.js"; +import { GroupByEndpointComponent } from "./EndpointComponent/GroupByEndpointComponent.js"; +import type { ExecutionContext } from "./ExecutionContext.js"; +import { getInitialHeader, mergeHeaders } from "./headerUtils.js"; +import { OrderByQueryExecutionContext } from "./orderByQueryExecutionContext.js"; +import { ParallelQueryExecutionContext } from "./parallelQueryExecutionContext.js"; +import { GroupByValueEndpointComponent } from "./EndpointComponent/GroupByValueEndpointComponent.js"; +import type { SqlQuerySpec } from "./SqlQuerySpec.js"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import { NonStreamingOrderByDistinctEndpointComponent } from "./EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js"; +import { NonStreamingOrderByEndpointComponent } from "./EndpointComponent/NonStreamingOrderByEndpointComponent.js"; /** @hidden */ export class PipelinedQueryExecutionContext implements ExecutionContext { diff --git a/sdk/cosmosdb/cosmos/src/queryIterator.ts b/sdk/cosmosdb/cosmos/src/queryIterator.ts index 937438f2ef1a..eb252c5914be 100644 --- a/sdk/cosmosdb/cosmos/src/queryIterator.ts +++ b/sdk/cosmosdb/cosmos/src/queryIterator.ts @@ -2,38 +2,38 @@ // Licensed under the MIT License. /// -import type { ClientContext } from "./ClientContext"; -import { DiagnosticNodeInternal, DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal"; -import { getPathFromLink, ResourceType, StatusCodes } from "./common"; +import type { ClientContext } from "./ClientContext.js"; +import { DiagnosticNodeInternal, DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal.js"; +import { getPathFromLink, ResourceType, StatusCodes } from "./common/index.js"; import type { CosmosHeaders, ExecutionContext, FetchFunctionCallback, SqlQuerySpec, -} from "./queryExecutionContext"; +} from "./queryExecutionContext/index.js"; import { DefaultQueryExecutionContext, getInitialHeader, mergeHeaders, PipelinedQueryExecutionContext, -} from "./queryExecutionContext"; -import type { Response } from "./request"; +} from "./queryExecutionContext/index.js"; +import type { Response } from "./request/index.js"; import type { ErrorResponse, PartitionedQueryExecutionInfo, QueryRange, -} from "./request/ErrorResponse"; -import type { FeedOptions } from "./request/FeedOptions"; -import { FeedResponse } from "./request/FeedResponse"; +} from "./request/ErrorResponse.js"; +import type { FeedOptions } from "./request/FeedOptions.js"; +import { FeedResponse } from "./request/FeedResponse.js"; import { getEmptyCosmosDiagnostics, withDiagnostics, withMetadataDiagnostics, -} from "./utils/diagnostics"; -import { MetadataLookUpType } from "./CosmosDiagnostics"; +} from "./utils/diagnostics.js"; +import { MetadataLookUpType } from "./CosmosDiagnostics.js"; import { randomUUID } from "@azure/core-util"; -import { HybridQueryExecutionContext } from "./queryExecutionContext/hybridQueryExecutionContext"; -import { PartitionKeyRangeCache } from "./routing"; +import { HybridQueryExecutionContext } from "./queryExecutionContext/hybridQueryExecutionContext.js"; +import { PartitionKeyRangeCache } from "./routing/index.js"; /** * Represents a QueryIterator Object, an implementation of feed or query response that enables diff --git a/sdk/cosmosdb/cosmos/src/queryMetrics/index.ts b/sdk/cosmosdb/cosmos/src/queryMetrics/index.ts index 050fd6bcb007..50b610339a65 100644 --- a/sdk/cosmosdb/cosmos/src/queryMetrics/index.ts +++ b/sdk/cosmosdb/cosmos/src/queryMetrics/index.ts @@ -1,8 +1,8 @@ // 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"; +export { ClientSideMetrics } from "./clientSideMetrics.js"; +export { QueryMetrics } from "./queryMetrics.js"; +export { default as QueryMetricsConstants } from "./queryMetricsConstants.js"; +export { QueryPreparationTimes } from "./queryPreparationTime.js"; +export { RuntimeExecutionTimes } from "./runtimeExecutionTimes.js"; +export { TimeSpan } from "./timeSpan.js"; diff --git a/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetrics.ts b/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetrics.ts index 646d45531a25..643da017ef5b 100644 --- a/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetrics.ts +++ b/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetrics.ts @@ -1,11 +1,11 @@ // 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"; +import { ClientSideMetrics } from "./clientSideMetrics.js"; +import QueryMetricsConstants from "./queryMetricsConstants.js"; +import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils.js"; +import { QueryPreparationTimes } from "./queryPreparationTime.js"; +import { RuntimeExecutionTimes } from "./runtimeExecutionTimes.js"; +import { TimeSpan } from "./timeSpan.js"; export class QueryMetrics { constructor( diff --git a/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetricsUtils.ts b/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetricsUtils.ts index b2284a014414..fd786281601c 100644 --- a/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetricsUtils.ts +++ b/sdk/cosmosdb/cosmos/src/queryMetrics/queryMetricsUtils.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { TimeSpan } from "./timeSpan"; +import { TimeSpan } from "./timeSpan.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/queryMetrics/queryPreparationTime.ts b/sdk/cosmosdb/cosmos/src/queryMetrics/queryPreparationTime.ts index 1dc11ab822e0..0229edfb7a6e 100644 --- a/sdk/cosmosdb/cosmos/src/queryMetrics/queryPreparationTime.ts +++ b/sdk/cosmosdb/cosmos/src/queryMetrics/queryPreparationTime.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import QueryMetricsConstants from "./queryMetricsConstants"; -import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils"; -import { TimeSpan } from "./timeSpan"; +import QueryMetricsConstants from "./queryMetricsConstants.js"; +import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils.js"; +import { TimeSpan } from "./timeSpan.js"; export class QueryPreparationTimes { constructor( diff --git a/sdk/cosmosdb/cosmos/src/queryMetrics/runtimeExecutionTimes.ts b/sdk/cosmosdb/cosmos/src/queryMetrics/runtimeExecutionTimes.ts index fae244ec778e..c63efefc2c2f 100644 --- a/sdk/cosmosdb/cosmos/src/queryMetrics/runtimeExecutionTimes.ts +++ b/sdk/cosmosdb/cosmos/src/queryMetrics/runtimeExecutionTimes.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import QueryMetricsConstants from "./queryMetricsConstants"; -import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils"; -import { TimeSpan } from "./timeSpan"; +import QueryMetricsConstants from "./queryMetricsConstants.js"; +import { parseDelimitedString, timeSpanFromMetrics } from "./queryMetricsUtils.js"; +import { TimeSpan } from "./timeSpan.js"; export class RuntimeExecutionTimes { constructor( diff --git a/sdk/cosmosdb/cosmos/src/request/ErrorResponse.ts b/sdk/cosmosdb/cosmos/src/request/ErrorResponse.ts index 944928f4462f..95011c330883 100644 --- a/sdk/cosmosdb/cosmos/src/request/ErrorResponse.ts +++ b/sdk/cosmosdb/cosmos/src/request/ErrorResponse.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics, CosmosHeaders } from "../index"; +import type { CosmosDiagnostics, CosmosHeaders } from "../index.js"; export interface ErrorBody { code: string; diff --git a/sdk/cosmosdb/cosmos/src/request/FeedOptions.ts b/sdk/cosmosdb/cosmos/src/request/FeedOptions.ts index a5c76a89d194..e953281c2822 100644 --- a/sdk/cosmosdb/cosmos/src/request/FeedOptions.ts +++ b/sdk/cosmosdb/cosmos/src/request/FeedOptions.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKey } from "../documents"; -import type { SharedOptions } from "./SharedOptions"; +import type { PartitionKey } from "../documents/index.js"; +import type { SharedOptions } from "./SharedOptions.js"; /** * The feed options and query methods. diff --git a/sdk/cosmosdb/cosmos/src/request/FeedResponse.ts b/sdk/cosmosdb/cosmos/src/request/FeedResponse.ts index 9508b41b6efe..bd484ad076bf 100644 --- a/sdk/cosmosdb/cosmos/src/request/FeedResponse.ts +++ b/sdk/cosmosdb/cosmos/src/request/FeedResponse.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Constants } from "../common"; -import type { CosmosHeaders } from "../queryExecutionContext/headerUtils"; -import { getRequestChargeIfAny } from "../queryExecutionContext/headerUtils"; -import { IndexMetricWriter, IndexUtilizationInfo } from "../indexMetrics"; -import type { CosmosDiagnostics } from "../CosmosDiagnostics"; +import { Constants } from "../common/index.js"; +import type { CosmosHeaders } from "../queryExecutionContext/headerUtils.js"; +import { getRequestChargeIfAny } from "../queryExecutionContext/headerUtils.js"; +import { IndexMetricWriter, IndexUtilizationInfo } from "../indexMetrics/index.js"; +import type { CosmosDiagnostics } from "../CosmosDiagnostics.js"; export class FeedResponse { constructor( diff --git a/sdk/cosmosdb/cosmos/src/request/RequestContext.ts b/sdk/cosmosdb/cosmos/src/request/RequestContext.ts index c1868a159d8d..b38d3682155b 100644 --- a/sdk/cosmosdb/cosmos/src/request/RequestContext.ts +++ b/sdk/cosmosdb/cosmos/src/request/RequestContext.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../ClientContext"; -import type { HTTPMethod, OperationType, ResourceType } from "../common"; -import type { Agent } from "../CosmosClientOptions"; -import type { ConnectionPolicy, PartitionKey } from "../documents"; -import type { GlobalEndpointManager } from "../globalEndpointManager"; -import type { PluginConfig } from "../plugins/Plugin"; -import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; -import type { FeedOptions } from "./FeedOptions"; -import type { RequestOptions } from "./RequestOptions"; +import type { ClientContext } from "../ClientContext.js"; +import type { HTTPMethod, OperationType, ResourceType } from "../common/index.js"; +import type { Agent } from "../CosmosClientOptions.js"; +import type { ConnectionPolicy, PartitionKey } from "../documents/index.js"; +import type { GlobalEndpointManager } from "../globalEndpointManager.js"; +import type { PluginConfig } from "../plugins/Plugin.js"; +import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders.js"; +import type { FeedOptions } from "./FeedOptions.js"; +import type { RequestOptions } from "./RequestOptions.js"; import type { HttpClient, Pipeline } from "@azure/core-rest-pipeline"; /** diff --git a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts index c917559d6353..e12e0f30e292 100644 --- a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts +++ b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts @@ -3,23 +3,23 @@ import type { PipelineResponse } from "@azure/core-rest-pipeline"; 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 type { RequestContext } from "./RequestContext"; -import type { Response as CosmosResponse } from "./Response"; -import { TimeoutError } from "./TimeoutError"; -import { getCachedDefaultHttpClient } from "../utils/cachedClient"; +import { prepareURL } from "../common/index.js"; +import { Constants } from "../common/constants.js"; +import { executePlugins, PluginOn } from "../plugins/Plugin.js"; +import * as RetryUtility from "../retry/retryUtility.js"; +import { defaultHttpAgent, defaultHttpsAgent } from "./defaultAgent.js"; +import { ErrorResponse } from "./ErrorResponse.js"; +import { bodyFromData } from "./request.js"; +import type { RequestContext } from "./RequestContext.js"; +import type { Response as CosmosResponse } from "./Response.js"; +import { TimeoutError } from "./TimeoutError.js"; +import { getCachedDefaultHttpClient } from "../utils/cachedClient.js"; import type { AzureLogger } from "@azure/logger"; import { createClientLogger } from "@azure/logger"; -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; -import { addDignosticChild } from "../utils/diagnostics"; -import { getCurrentTimestampInMs } from "../utils/time"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal.js"; +import { addDignosticChild } from "../utils/diagnostics.js"; +import { getCurrentTimestampInMs } from "../utils/time.js"; const logger: AzureLogger = createClientLogger("RequestHandler"); diff --git a/sdk/cosmosdb/cosmos/src/request/RequestOptions.ts b/sdk/cosmosdb/cosmos/src/request/RequestOptions.ts index b24e6df37147..05daa0067626 100644 --- a/sdk/cosmosdb/cosmos/src/request/RequestOptions.ts +++ b/sdk/cosmosdb/cosmos/src/request/RequestOptions.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { SharedOptions } from ".."; +import type { SharedOptions } from "../index.js"; /** * Options that can be specified for a requested issued to the Azure Cosmos DB servers.= diff --git a/sdk/cosmosdb/cosmos/src/request/ResourceResponse.ts b/sdk/cosmosdb/cosmos/src/request/ResourceResponse.ts index 2a1cae8c083c..43cf1e155579 100644 --- a/sdk/cosmosdb/cosmos/src/request/ResourceResponse.ts +++ b/sdk/cosmosdb/cosmos/src/request/ResourceResponse.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics } from "../CosmosDiagnostics"; -import { Constants } from "../common"; -import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; -import type { StatusCode, SubStatusCode } from "./StatusCodes"; +import type { CosmosDiagnostics } from "../CosmosDiagnostics.js"; +import { Constants } from "../common/index.js"; +import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders.js"; +import type { StatusCode, SubStatusCode } from "./StatusCodes.js"; export class ResourceResponse { constructor( diff --git a/sdk/cosmosdb/cosmos/src/request/Response.ts b/sdk/cosmosdb/cosmos/src/request/Response.ts index 3e743b8f3c08..16212981bb91 100644 --- a/sdk/cosmosdb/cosmos/src/request/Response.ts +++ b/sdk/cosmosdb/cosmos/src/request/Response.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { CosmosDiagnostics, CosmosHeaders } from "../index"; +import type { CosmosDiagnostics, CosmosHeaders } from "../index.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/request/SharedOptions.ts b/sdk/cosmosdb/cosmos/src/request/SharedOptions.ts index 3914f201d85f..684bc0b6abef 100644 --- a/sdk/cosmosdb/cosmos/src/request/SharedOptions.ts +++ b/sdk/cosmosdb/cosmos/src/request/SharedOptions.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /// -import type { PriorityLevel } from "../documents/PriorityLevel"; -import type { CosmosHeaders } from "../index"; +import type { PriorityLevel } from "../documents/PriorityLevel.js"; +import type { CosmosHeaders } from "../index.js"; /** * Options that can be specified for a requested issued to the Azure Cosmos DB servers.= diff --git a/sdk/cosmosdb/cosmos/src/request/defaultAgent-browser.mts b/sdk/cosmosdb/cosmos/src/request/defaultAgent-browser.mts index ac2e3e7fd238..d6565d17d2bc 100644 --- a/sdk/cosmosdb/cosmos/src/request/defaultAgent-browser.mts +++ b/sdk/cosmosdb/cosmos/src/request/defaultAgent-browser.mts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Agent } from "http"; +import type { Agent } from "node:http"; /** * @hidden */ diff --git a/sdk/cosmosdb/cosmos/src/request/defaultAgent.ts b/sdk/cosmosdb/cosmos/src/request/defaultAgent.ts index 8cd14d185cfb..a8c5fb6f0c71 100644 --- a/sdk/cosmosdb/cosmos/src/request/defaultAgent.ts +++ b/sdk/cosmosdb/cosmos/src/request/defaultAgent.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Agent } from "http"; +import type { Agent } from "node:http"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/request/hybridSearchQueryResult.ts b/sdk/cosmosdb/cosmos/src/request/hybridSearchQueryResult.ts index 828534eb7907..a7751cfda98d 100644 --- a/sdk/cosmosdb/cosmos/src/request/hybridSearchQueryResult.ts +++ b/sdk/cosmosdb/cosmos/src/request/hybridSearchQueryResult.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ItemDefinition } from "../client"; +import { ItemDefinition } from "../client/index.js"; const FieldNames = { Rid: "_rid", diff --git a/sdk/cosmosdb/cosmos/src/request/index.ts b/sdk/cosmosdb/cosmos/src/request/index.ts index 1061b85c2e77..c09df738af20 100644 --- a/sdk/cosmosdb/cosmos/src/request/index.ts +++ b/sdk/cosmosdb/cosmos/src/request/index.ts @@ -10,14 +10,14 @@ export { GroupByExpressions, GroupByAliasToAggregateType, HybridSearchQueryInfo, -} 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 * from "./globalStatistics"; +} from "./ErrorResponse.js"; +export { FeedOptions } from "./FeedOptions.js"; +export { RequestOptions } from "./RequestOptions.js"; +export { Response } from "./Response.js"; +export { ResourceResponse } from "./ResourceResponse.js"; +export { SharedOptions } from "./SharedOptions.js"; +export { StatusCode, SubStatusCode } from "./StatusCodes.js"; +export { FeedResponse } from "./FeedResponse.js"; +export { RequestContext } from "./RequestContext.js"; +export { TimeoutError } from "./TimeoutError.js"; +export * from "./globalStatistics.js"; diff --git a/sdk/cosmosdb/cosmos/src/request/request.ts b/sdk/cosmosdb/cosmos/src/request/request.ts index ce731aa20ef3..695706454175 100644 --- a/sdk/cosmosdb/cosmos/src/request/request.ts +++ b/sdk/cosmosdb/cosmos/src/request/request.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { setAuthorizationHeader } from "../auth"; -import { Constants, HTTPMethod, jsonStringifyAndEscapeNonASCII, ResourceType } from "../common"; -import type { CosmosClientOptions } from "../CosmosClientOptions"; -import type { PartitionKeyInternal } from "../documents"; -import type { CosmosHeaders } from "../queryExecutionContext"; -import type { FeedOptions, RequestOptions } from "./index"; -import { defaultLogger } from "../common/logger"; -import { ChangeFeedMode } from "../client/ChangeFeed"; +import { setAuthorizationHeader } from "../auth.js"; +import { Constants, HTTPMethod, jsonStringifyAndEscapeNonASCII, ResourceType } from "../common/index.js"; +import type { CosmosClientOptions } from "../CosmosClientOptions.js"; +import type { PartitionKeyInternal } from "../documents/index.js"; +import type { CosmosHeaders } from "../queryExecutionContext/index.js"; +import type { FeedOptions, RequestOptions } from "./index.js"; +import { defaultLogger } from "../common/logger.js"; +import { ChangeFeedMode } from "../client/ChangeFeed/index.js"; // ---------------------------------------------------------------------------- // Utility methods // diff --git a/sdk/cosmosdb/cosmos/src/retry/RetryPolicy.ts b/sdk/cosmosdb/cosmos/src/retry/RetryPolicy.ts index 5d0a8e6813c5..cf2f0f9527d8 100644 --- a/sdk/cosmosdb/cosmos/src/retry/RetryPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/retry/RetryPolicy.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { ErrorResponse } from "../request"; -import type { RetryContext } from "./RetryContext"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { ErrorResponse } from "../request/index.js"; +import type { RetryContext } from "./RetryContext.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/retry/defaultRetryPolicy.ts b/sdk/cosmosdb/cosmos/src/retry/defaultRetryPolicy.ts index 741da781c9d9..5d7116459d4f 100644 --- a/sdk/cosmosdb/cosmos/src/retry/defaultRetryPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/retry/defaultRetryPolicy.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import { OperationType } from "../common"; -import type { ErrorResponse } from "../request"; -import { TimeoutErrorCode } from "../request/TimeoutError"; -import type { RetryPolicy } from "./RetryPolicy"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import { OperationType } from "../common/index.js"; +import type { ErrorResponse } from "../request/index.js"; +import { TimeoutErrorCode } from "../request/TimeoutError.js"; +import type { RetryPolicy } from "./RetryPolicy.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/retry/endpointDiscoveryRetryPolicy.ts b/sdk/cosmosdb/cosmos/src/retry/endpointDiscoveryRetryPolicy.ts index 35a7747f863a..e2178c150478 100644 --- a/sdk/cosmosdb/cosmos/src/retry/endpointDiscoveryRetryPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/retry/endpointDiscoveryRetryPolicy.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { OperationType } from "../common"; -import { isReadRequest } from "../common/helper"; -import type { GlobalEndpointManager } from "../globalEndpointManager"; -import type { ErrorResponse } from "../request"; -import type { RetryContext } from "./RetryContext"; -import type { RetryPolicy } from "./RetryPolicy"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { OperationType } from "../common/index.js"; +import { isReadRequest } from "../common/helper.js"; +import type { GlobalEndpointManager } from "../globalEndpointManager.js"; +import type { ErrorResponse } from "../request/index.js"; +import type { RetryContext } from "./RetryContext.js"; +import type { RetryPolicy } from "./RetryPolicy.js"; /** * This class implements the retry policy for endpoint discovery. diff --git a/sdk/cosmosdb/cosmos/src/retry/index.ts b/sdk/cosmosdb/cosmos/src/retry/index.ts index 9669f1739fea..62b3f2887475 100644 --- a/sdk/cosmosdb/cosmos/src/retry/index.ts +++ b/sdk/cosmosdb/cosmos/src/retry/index.ts @@ -1,8 +1,8 @@ // 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"; +export * from "./retryOptions.js"; +export * from "./endpointDiscoveryRetryPolicy.js"; +export * from "./resourceThrottleRetryPolicy.js"; +export * from "./sessionRetryPolicy.js"; +export * from "./retryUtility.js"; +export * from "./timeoutFailoverRetryPolicy.js"; diff --git a/sdk/cosmosdb/cosmos/src/retry/resourceThrottleRetryPolicy.ts b/sdk/cosmosdb/cosmos/src/retry/resourceThrottleRetryPolicy.ts index ca2862cf99de..fc14b98c67ee 100644 --- a/sdk/cosmosdb/cosmos/src/retry/resourceThrottleRetryPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/retry/resourceThrottleRetryPolicy.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { ErrorResponse } from "../request"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { ErrorResponse } from "../request/index.js"; /** * This class implements the resource throttle retry policy for requests. diff --git a/sdk/cosmosdb/cosmos/src/retry/retryUtility.ts b/sdk/cosmosdb/cosmos/src/retry/retryUtility.ts index 0ea63c8010ec..bbbc13572b96 100644 --- a/sdk/cosmosdb/cosmos/src/retry/retryUtility.ts +++ b/sdk/cosmosdb/cosmos/src/retry/retryUtility.ts @@ -1,22 +1,22 @@ // 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 type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; -import type { Response } from "../request"; -import type { RequestContext } from "../request/RequestContext"; -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 type { RetryContext } from "./RetryContext"; -import type { RetryPolicy } from "./RetryPolicy"; -import { SessionRetryPolicy } from "./sessionRetryPolicy"; -import { TimeoutFailoverRetryPolicy } from "./timeoutFailoverRetryPolicy"; +import { Constants } from "../common/constants.js"; +import { sleep } from "../common/helper.js"; +import { StatusCodes, SubStatusCodes } from "../common/statusCodes.js"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import { DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { Response } from "../request/index.js"; +import type { RequestContext } from "../request/RequestContext.js"; +import { TimeoutErrorCode } from "../request/TimeoutError.js"; +import { addDignosticChild } from "../utils/diagnostics.js"; +import { getCurrentTimestampInMs } from "../utils/time.js"; +import { DefaultRetryPolicy } from "./defaultRetryPolicy.js"; +import { EndpointDiscoveryRetryPolicy } from "./endpointDiscoveryRetryPolicy.js"; +import { ResourceThrottleRetryPolicy } from "./resourceThrottleRetryPolicy.js"; +import type { RetryContext } from "./RetryContext.js"; +import type { RetryPolicy } from "./RetryPolicy.js"; +import { SessionRetryPolicy } from "./sessionRetryPolicy.js"; +import { TimeoutFailoverRetryPolicy } from "./timeoutFailoverRetryPolicy.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/retry/sessionRetryPolicy.ts b/sdk/cosmosdb/cosmos/src/retry/sessionRetryPolicy.ts index 11ca526ff458..4c5ad89730c2 100644 --- a/sdk/cosmosdb/cosmos/src/retry/sessionRetryPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/retry/sessionRetryPolicy.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import type { OperationType, ResourceType } from "../common"; -import { isReadRequest } from "../common"; -import type { ConnectionPolicy } from "../documents"; -import type { GlobalEndpointManager } from "../globalEndpointManager"; -import type { ErrorResponse } from "../request"; -import type { RetryContext } from "./RetryContext"; -import type { RetryPolicy } from "./RetryPolicy"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { OperationType, ResourceType } from "../common/index.js"; +import { isReadRequest } from "../common/index.js"; +import type { ConnectionPolicy } from "../documents/index.js"; +import type { GlobalEndpointManager } from "../globalEndpointManager.js"; +import type { ErrorResponse } from "../request/index.js"; +import type { RetryContext } from "./RetryContext.js"; +import type { RetryPolicy } from "./RetryPolicy.js"; /** * This class implements the retry policy for session consistent reads. diff --git a/sdk/cosmosdb/cosmos/src/retry/timeoutFailoverRetryPolicy.ts b/sdk/cosmosdb/cosmos/src/retry/timeoutFailoverRetryPolicy.ts index cc9cf53237b3..dd832f17b417 100644 --- a/sdk/cosmosdb/cosmos/src/retry/timeoutFailoverRetryPolicy.ts +++ b/sdk/cosmosdb/cosmos/src/retry/timeoutFailoverRetryPolicy.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { RetryPolicy } from "./RetryPolicy"; -import { StatusCodes } from "../common/statusCodes"; -import type { GlobalEndpointManager } from "../globalEndpointManager"; -import { HTTPMethod, isReadRequest } from "../common"; -import type { OperationType, ResourceType } from "../common/constants"; -import { Constants } from "../common/constants"; -import type { RetryContext } from "./RetryContext"; -import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders"; -import { TimeoutErrorCode } from "../request/TimeoutError"; -import type { ErrorResponse } from "../request"; -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; +import type { RetryPolicy } from "./RetryPolicy.js"; +import { StatusCodes } from "../common/statusCodes.js"; +import type { GlobalEndpointManager } from "../globalEndpointManager.js"; +import { HTTPMethod, isReadRequest } from "../common/index.js"; +import type { OperationType, ResourceType } from "../common/constants.js"; +import { Constants } from "../common/constants.js"; +import type { RetryContext } from "./RetryContext.js"; +import type { CosmosHeaders } from "../queryExecutionContext/CosmosHeaders.js"; +import { TimeoutErrorCode } from "../request/TimeoutError.js"; +import type { ErrorResponse } from "../request/index.js"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; /** * This class TimeoutFailoverRetryPolicy handles retries for read operations diff --git a/sdk/cosmosdb/cosmos/src/routing/CollectionRoutingMapFactory.ts b/sdk/cosmosdb/cosmos/src/routing/CollectionRoutingMapFactory.ts index 13737780cd66..fe82ec3adb75 100644 --- a/sdk/cosmosdb/cosmos/src/routing/CollectionRoutingMapFactory.ts +++ b/sdk/cosmosdb/cosmos/src/routing/CollectionRoutingMapFactory.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Constants } from "../common/constants"; -import { InMemoryCollectionRoutingMap } from "./inMemoryCollectionRoutingMap"; +import { Constants } from "../common/constants.js"; +import { InMemoryCollectionRoutingMap } from "./inMemoryCollectionRoutingMap.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/routing/QueryRange.ts b/sdk/cosmosdb/cosmos/src/routing/QueryRange.ts index e8ca0ed80e99..ec45cfe630ee 100644 --- a/sdk/cosmosdb/cosmos/src/routing/QueryRange.ts +++ b/sdk/cosmosdb/cosmos/src/routing/QueryRange.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKeyRange } from "../client/Container/PartitionKeyRange"; -import { Constants } from "../common"; -import type { QueryRange as ResponseQueryRange } from "../request/ErrorResponse"; +import type { PartitionKeyRange } from "../client/Container/PartitionKeyRange.js"; +import { Constants } from "../common/index.js"; +import type { QueryRange as ResponseQueryRange } from "../request/ErrorResponse.js"; /** @hidden */ export class QueryRange { diff --git a/sdk/cosmosdb/cosmos/src/routing/inMemoryCollectionRoutingMap.ts b/sdk/cosmosdb/cosmos/src/routing/inMemoryCollectionRoutingMap.ts index 39d68e475c1b..08720fd9d791 100644 --- a/sdk/cosmosdb/cosmos/src/routing/inMemoryCollectionRoutingMap.ts +++ b/sdk/cosmosdb/cosmos/src/routing/inMemoryCollectionRoutingMap.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKeyRange } from "../client"; -import { Constants } from "../common"; -import { QueryRange } from "./QueryRange"; +import type { PartitionKeyRange } from "../client/index.js"; +import { Constants } from "../common/index.js"; +import { QueryRange } from "./QueryRange.js"; /** @hidden */ export class InMemoryCollectionRoutingMap { diff --git a/sdk/cosmosdb/cosmos/src/routing/index.ts b/sdk/cosmosdb/cosmos/src/routing/index.ts index faeb306b85d1..cd2c7e6e1326 100644 --- a/sdk/cosmosdb/cosmos/src/routing/index.ts +++ b/sdk/cosmosdb/cosmos/src/routing/index.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -export * from "./QueryRange"; -export * from "./inMemoryCollectionRoutingMap"; -export * from "./partitionKeyRangeCache"; -export * from "./smartRoutingMapProvider"; +export * from "./QueryRange.js"; +export * from "./inMemoryCollectionRoutingMap.js"; +export * from "./partitionKeyRangeCache.js"; +export * from "./smartRoutingMapProvider.js"; diff --git a/sdk/cosmosdb/cosmos/src/routing/partitionKeyRangeCache.ts b/sdk/cosmosdb/cosmos/src/routing/partitionKeyRangeCache.ts index a72a1a3f465b..702bc8a9e5e0 100644 --- a/sdk/cosmosdb/cosmos/src/routing/partitionKeyRangeCache.ts +++ b/sdk/cosmosdb/cosmos/src/routing/partitionKeyRangeCache.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { MetadataLookUpType } from "../CosmosDiagnostics"; -import type { PartitionKeyRange } from "../client/Container/PartitionKeyRange"; -import type { ClientContext } from "../ClientContext"; -import { getIdFromLink } from "../common/helper"; -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import { withMetadataDiagnostics } from "../utils/diagnostics"; -import { createCompleteRoutingMap } from "./CollectionRoutingMapFactory"; -import type { InMemoryCollectionRoutingMap } from "./inMemoryCollectionRoutingMap"; -import type { QueryRange } from "./QueryRange"; +import { MetadataLookUpType } from "../CosmosDiagnostics.js"; +import type { PartitionKeyRange } from "../client/Container/PartitionKeyRange.js"; +import type { ClientContext } from "../ClientContext.js"; +import { getIdFromLink } from "../common/helper.js"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import { withMetadataDiagnostics } from "../utils/diagnostics.js"; +import { createCompleteRoutingMap } from "./CollectionRoutingMapFactory.js"; +import type { InMemoryCollectionRoutingMap } from "./inMemoryCollectionRoutingMap.js"; +import type { QueryRange } from "./QueryRange.js"; /** @hidden */ export class PartitionKeyRangeCache { diff --git a/sdk/cosmosdb/cosmos/src/routing/smartRoutingMapProvider.ts b/sdk/cosmosdb/cosmos/src/routing/smartRoutingMapProvider.ts index 88f857ceab20..9835bffdf3ff 100644 --- a/sdk/cosmosdb/cosmos/src/routing/smartRoutingMapProvider.ts +++ b/sdk/cosmosdb/cosmos/src/routing/smartRoutingMapProvider.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext } from "../ClientContext"; -import { Constants } from "../common/constants"; -import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal"; -import { PartitionKeyRangeCache } from "./partitionKeyRangeCache"; -import { QueryRange } from "./QueryRange"; +import type { ClientContext } from "../ClientContext.js"; +import { Constants } from "../common/constants.js"; +import type { DiagnosticNodeInternal } from "../diagnostics/DiagnosticNodeInternal.js"; +import { PartitionKeyRangeCache } from "./partitionKeyRangeCache.js"; +import { QueryRange } from "./QueryRange.js"; /** @hidden */ export const PARITIONKEYRANGE = Constants.PartitionKeyRange; diff --git a/sdk/cosmosdb/cosmos/src/session/SessionContext.ts b/sdk/cosmosdb/cosmos/src/session/SessionContext.ts index eab84cdda519..4747cd095985 100644 --- a/sdk/cosmosdb/cosmos/src/session/SessionContext.ts +++ b/sdk/cosmosdb/cosmos/src/session/SessionContext.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { OperationType, ResourceType } from "../common"; +import type { OperationType, ResourceType } from "../common/index.js"; /** * @hidden diff --git a/sdk/cosmosdb/cosmos/src/session/sessionContainer.ts b/sdk/cosmosdb/cosmos/src/session/sessionContainer.ts index ad540f946317..2ec55541cb92 100644 --- a/sdk/cosmosdb/cosmos/src/session/sessionContainer.ts +++ b/sdk/cosmosdb/cosmos/src/session/sessionContainer.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import atob from "../utils/atob"; -import type { ResourceType } from "../common"; -import { Constants, getContainerLink, OperationType, trimSlashes } from "../common"; -import type { CosmosHeaders } from "../queryExecutionContext"; -import type { SessionContext } from "./SessionContext"; -import { VectorSessionToken } from "./VectorSessionToken"; +import atob from "../utils/atob.js"; +import type { ResourceType } from "../common/index.js"; +import { Constants, getContainerLink, OperationType, trimSlashes } from "../common/index.js"; +import type { CosmosHeaders } from "../queryExecutionContext/index.js"; +import type { SessionContext } from "./SessionContext.js"; +import { VectorSessionToken } from "./VectorSessionToken.js"; /** @hidden */ export class SessionContainer { diff --git a/sdk/cosmosdb/cosmos/src/utils/SasToken.ts b/sdk/cosmosdb/cosmos/src/utils/SasToken.ts index 23a6e6f2d960..f5024a7ab493 100644 --- a/sdk/cosmosdb/cosmos/src/utils/SasToken.ts +++ b/sdk/cosmosdb/cosmos/src/utils/SasToken.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { SasTokenProperties } from "../client/SasToken/SasTokenProperties"; -import { Constants, CosmosKeyType, SasTokenPermissionKind } from "../common"; -import { encodeUTF8 } from "./encode"; -import { hmac } from "./hmac"; +import type { SasTokenProperties } from "../client/SasToken/SasTokenProperties.js"; +import { Constants, CosmosKeyType, SasTokenPermissionKind } from "../common/index.js"; +import { encodeUTF8 } from "./encode.js"; +import { hmac } from "./hmac.js"; /** * Experimental internal only diff --git a/sdk/cosmosdb/cosmos/src/utils/batch.ts b/sdk/cosmosdb/cosmos/src/utils/batch.ts index cb8bdcf68c00..556ee24d62d6 100644 --- a/sdk/cosmosdb/cosmos/src/utils/batch.ts +++ b/sdk/cosmosdb/cosmos/src/utils/batch.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { JSONObject } from "../queryExecutionContext"; -import { extractPartitionKeys, undefinedPartitionKey } from "../extractPartitionKey"; -import type { CosmosDiagnostics, RequestOptions } from ".."; +import type { JSONObject } from "../queryExecutionContext/index.js"; +import { extractPartitionKeys, undefinedPartitionKey } from "../extractPartitionKey.js"; +import type { CosmosDiagnostics, RequestOptions } from "../index.js"; import type { PartitionKey, PartitionKeyDefinition, PrimitivePartitionKeyValue, -} from "../documents"; -import { NonePartitionKeyLiteral, convertToInternalPartitionKey } from "../documents"; -import type { PatchRequestBody } from "./patch"; -import { assertNotUndefined } from "./typeChecks"; -import { bodyFromData } from "../request/request"; -import { Constants } from "../common/constants"; +} from "../documents/index.js"; +import { NonePartitionKeyLiteral, convertToInternalPartitionKey } from "../documents/index.js"; +import type { PatchRequestBody } from "./patch.js"; +import { assertNotUndefined } from "./typeChecks.js"; +import { bodyFromData } from "../request/request.js"; +import { Constants } from "../common/constants.js"; import { randomUUID } from "@azure/core-util"; export type Operation = diff --git a/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts b/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts index 1fe8c2543f3a..888df422f48f 100644 --- a/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts +++ b/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { MetadataLookUpType } from "../CosmosDiagnostics"; -import { CosmosDiagnostics } from "../CosmosDiagnostics"; -import type { DiagnosticDataValue } from "../diagnostics/DiagnosticNodeInternal"; -import { DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal"; -import type { ClientContext } from "../ClientContext"; -import { getCurrentTimestampInMs } from "./time"; -import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel"; +import type { MetadataLookUpType } from "../CosmosDiagnostics.js"; +import { CosmosDiagnostics } from "../CosmosDiagnostics.js"; +import type { DiagnosticDataValue } from "../diagnostics/DiagnosticNodeInternal.js"; +import { DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal.js"; +import type { ClientContext } from "../ClientContext.js"; +import { getCurrentTimestampInMs } from "./time.js"; +import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel.js"; import { randomUUID } from "@azure/core-util"; /** diff --git a/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts b/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts index 0053d53f6e22..5277438c2739 100644 --- a/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts +++ b/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { encodeUTF8 } from "./encode"; -import { globalCrypto } from "./globalCrypto"; +import { encodeUTF8 } from "./encode.js"; +import { globalCrypto } from "./globalCrypto.js"; export async function digest(str: string): Promise { const data = encodeUTF8(str); diff --git a/sdk/cosmosdb/cosmos/src/utils/digest.ts b/sdk/cosmosdb/cosmos/src/utils/digest.ts index e65d3d6cd835..ee5372fd0b7a 100644 --- a/sdk/cosmosdb/cosmos/src/utils/digest.ts +++ b/sdk/cosmosdb/cosmos/src/utils/digest.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { createHash } from "crypto"; +import { createHash } from "node:crypto"; export async function digest(str: string): Promise { const hash = createHash("sha256"); diff --git a/sdk/cosmosdb/cosmos/src/utils/envUtils.ts b/sdk/cosmosdb/cosmos/src/utils/envUtils.ts index 6450718b3b89..afadace3b57a 100644 --- a/sdk/cosmosdb/cosmos/src/utils/envUtils.ts +++ b/sdk/cosmosdb/cosmos/src/utils/envUtils.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import process from "node:process"; -import { Constants } from "../common/constants"; +import { Constants } from "../common/constants.js"; export const diagnosticLevelFromEnv: string | undefined = process.env[Constants.CosmosDbDiagnosticLevelEnvVarName]; diff --git a/sdk/cosmosdb/cosmos/src/utils/hashObject.ts b/sdk/cosmosdb/cosmos/src/utils/hashObject.ts index 9c2ac58f845a..31977ef37444 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashObject.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashObject.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { digest } from "./digest"; +import { digest } from "./digest.js"; import stableStringify from "fast-json-stable-stringify"; export async function hashObject(object: unknown): Promise { diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts index 660b7136f312..c6ade43b95f0 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import JSBI from "jsbi"; -import { BytePrefix } from "./prefix"; +import { BytePrefix } from "./prefix.js"; export function writeNumberForBinaryEncodingJSBI(hash: number): Buffer { let payload = encodeNumberAsUInt64JSBI(hash); diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts index e3af7372e72c..181c70ca2a02 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { BytePrefix } from "./prefix"; +import { BytePrefix } from "./prefix.js"; export function writeStringForBinaryEncoding(payload: string): Buffer { let outputStream = Buffer.from(BytePrefix.String, "hex"); diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/hash.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/hash.ts index 338a74a57b8d..e0ba21f1368b 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/hash.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/hash.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PartitionKeyDefinition, PrimitivePartitionKeyValue } from "../../documents"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../documents"; -import { hashMultiHashPartitionKey } from "./multiHash"; -import { hashV1PartitionKey } from "./v1"; -import { hashV2PartitionKey } from "./v2"; +import type { PartitionKeyDefinition, PrimitivePartitionKeyValue } from "../../documents/index.js"; +import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../documents/index.js"; +import { hashMultiHashPartitionKey } from "./multiHash.js"; +import { hashV1PartitionKey } from "./v1.js"; +import { hashV2PartitionKey } from "./v2.js"; /** * Generate hash of a PartitonKey based on it PartitionKeyDefinition. diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts index 8dad5e787ac3..3e3e6756c59f 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PrimitivePartitionKeyValue } from "../../documents"; -import { hashV2PartitionKey } from "./v2"; +import type { PrimitivePartitionKeyValue } from "../../documents/index.js"; +import { hashV2PartitionKey } from "./v2.js"; /** * Generate Hash for a `Multi Hash` type partition. diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts index a027a0bf0687..c07f7affc18b 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts @@ -1,11 +1,11 @@ // 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"; -import type { PrimitivePartitionKeyValue } from "../../documents"; +import { doubleToByteArrayJSBI, writeNumberForBinaryEncodingJSBI } from "./encoding/number.js"; +import { writeStringForBinaryEncoding } from "./encoding/string.js"; +import { BytePrefix } from "./encoding/prefix.js"; +import MurmurHash from "./murmurHash.js"; +import type { PrimitivePartitionKeyValue } from "../../documents/index.js"; const MAX_STRING_CHARS = 100; diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts index 66d9a32df974..c8f73ae821bb 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { PrimitivePartitionKeyValue } from "../../documents"; -import { doubleToByteArrayJSBI } from "./encoding/number"; -import { BytePrefix } from "./encoding/prefix"; -import MurmurHash from "./murmurHash"; +import type { PrimitivePartitionKeyValue } from "../../documents/index.js"; +import { doubleToByteArrayJSBI } from "./encoding/number.js"; +import { BytePrefix } from "./encoding/prefix.js"; +import MurmurHash from "./murmurHash.js"; export function hashV2PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string { const toHash: Buffer = Buffer.concat(partitionKey.map(prefixKeyByType)); diff --git a/sdk/cosmosdb/cosmos/src/utils/headers.ts b/sdk/cosmosdb/cosmos/src/utils/headers.ts index a49ded200d36..33f5830007ad 100644 --- a/sdk/cosmosdb/cosmos/src/utils/headers.ts +++ b/sdk/cosmosdb/cosmos/src/utils/headers.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { hmac } from "./hmac"; -import type { HTTPMethod } from "../common"; -import { ResourceType, Constants } from "../common"; +import { hmac } from "./hmac.js"; +import type { HTTPMethod } from "../common/index.js"; +import { ResourceType, Constants } from "../common/index.js"; export async function generateHeaders( masterKey: string, diff --git a/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts b/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts index 6414a19a60ae..9ecc786cfaab 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts +++ b/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { encodeUTF8, encodeBase64 } from "./encode"; -import atob from "./atob"; -import { globalCrypto } from "./globalCrypto"; +import { encodeUTF8, encodeBase64 } from "./encode.js"; +import atob from "./atob.js"; +import { globalCrypto } from "./globalCrypto.js"; export async function hmac(key: string, message: string): Promise { const importParams: HmacImportParams = { name: "HMAC", hash: { name: "SHA-256" } }; diff --git a/sdk/cosmosdb/cosmos/src/utils/hmac.ts b/sdk/cosmosdb/cosmos/src/utils/hmac.ts index 9ad1755b7779..a57bf69a5122 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hmac.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hmac.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { createHmac } from "crypto"; +import { createHmac } from "node:crypto"; export async function hmac(key: string, message: string): Promise { return createHmac("sha256", Buffer.from(key, "base64")).update(message).digest("base64"); diff --git a/sdk/cosmosdb/cosmos/src/utils/offers.ts b/sdk/cosmosdb/cosmos/src/utils/offers.ts index 0844debcd776..b4e2124b86c1 100644 --- a/sdk/cosmosdb/cosmos/src/utils/offers.ts +++ b/sdk/cosmosdb/cosmos/src/utils/offers.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ContainerRequest } from "../client/Container/ContainerRequest"; +import type { ContainerRequest } from "../client/Container/ContainerRequest.js"; export function validateOffer(body: ContainerRequest): void { if (body.throughput) { diff --git a/sdk/cosmosdb/cosmos/src/utils/supportedQueryFeaturesBuilder.ts b/sdk/cosmosdb/cosmos/src/utils/supportedQueryFeaturesBuilder.ts index be415f769fe5..a67b690cf041 100644 --- a/sdk/cosmosdb/cosmos/src/utils/supportedQueryFeaturesBuilder.ts +++ b/sdk/cosmosdb/cosmos/src/utils/supportedQueryFeaturesBuilder.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { QueryFeature } from "../common"; +import { QueryFeature } from "../common/index.js"; export function supportedQueryFeaturesBuilder(disableNonStreamingOrderByQuery?: boolean): string { if (disableNonStreamingOrderByQuery) { diff --git a/sdk/cosmosdb/cosmos/src/utils/tracing.ts b/sdk/cosmosdb/cosmos/src/utils/tracing.ts index 64311f1b9707..5bc5538d7c16 100644 --- a/sdk/cosmosdb/cosmos/src/utils/tracing.ts +++ b/sdk/cosmosdb/cosmos/src/utils/tracing.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { createTracingClient } from "@azure/core-tracing"; -import { Constants } from "../common/constants"; +import { Constants } from "../common/constants.js"; /** * Global tracing client for this package. diff --git a/sdk/cosmosdb/cosmos/src/utils/typeChecks.ts b/sdk/cosmosdb/cosmos/src/utils/typeChecks.ts index c9bbde1f5ff1..794f1b69111e 100644 --- a/sdk/cosmosdb/cosmos/src/utils/typeChecks.ts +++ b/sdk/cosmosdb/cosmos/src/utils/typeChecks.ts @@ -5,8 +5,8 @@ import type { NonePartitionKeyType, NullPartitionKeyType, PrimitivePartitionKeyValue, -} from "../documents"; -import { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from "../documents"; +} from "../documents/index.js"; +import { NonePartitionKeyLiteral, NullPartitionKeyLiteral } from "../documents/index.js"; /** * A type which could be any type but undefined diff --git a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts index f4ab194981c9..25d4f5a7a003 100644 --- a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { ClientContext, Container, PluginConfig } from "../../src"; -import { PluginOn } from "../../src"; -import { OperationType, ResourceType } from "../../src/common"; -import { ConsistencyLevel } from "../../src"; -import { CosmosClient } from "../../src"; -import type { SessionContainer } from "../../src/session/sessionContainer"; -import { endpoint } from "../public/common/_testConfig"; -import { masterKey } from "../public/common/_fakeTestSecrets"; -import { addEntropy, getTestDatabase, removeAllDatabases } from "../public/common/TestHelpers"; -import type { RequestContext } from "../../src"; -import type { Response } from "../../src/request/Response"; +import type { ClientContext, Container, PluginConfig } from "../../src/index.js"; +import { PluginOn } from "../../src/index.js"; +import { OperationType, ResourceType } from "../../src/common/index.js"; +import { ConsistencyLevel } from "../../src/index.js"; +import { CosmosClient } from "../../src/index.js"; +import type { SessionContainer } from "../../src/session/sessionContainer.js"; +import { endpoint } from "../public/common/_testConfig.js"; +import { masterKey } from "../public/common/_fakeTestSecrets.js"; +import { addEntropy, getTestDatabase, removeAllDatabases } from "../public/common/TestHelpers.js"; +import type { RequestContext } from "../../src/index.js"; +import type { Response } from "../../src/request/Response.js"; import { expect } from "chai"; describe("New session token", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts index 8102975c5549..5a2726e98e3d 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { getAuthorizationTokenUsingResourceTokens } from "../../../src/auth"; +import { getAuthorizationTokenUsingResourceTokens } from "../../../src/auth.js"; import type { Suite } from "mocha"; -import assert from "assert"; +import assert from "node:assert"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts index 49b31ac124ba..acbcdf2eaef9 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { ChangeFeedRetentionTimeSpan } from "../../../../src/client/ChangeFeed/ChangeFeedRetentionTimeSpan"; -import assert from "assert"; +import { ChangeFeedRetentionTimeSpan } from "../../../../src/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js"; +import assert from "node:assert"; describe("test ChangeFeedRetentionTimeSpan", function () { it("timeSpan should be positive number", async function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts index 979e208a9a90..c2c2c47126a6 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import { extractOverlappingRanges, isNullOrEmpty, fetchStartTime, -} from "../../../../src/client/ChangeFeed/changeFeedUtils"; -import type { PartitionKeyRange } from "../../../../src/"; -import { ChangeFeedStartFrom } from "../../../../src/"; -import { FeedRangeInternal } from "../../../../src/client/ChangeFeed/FeedRange"; -import { isEpkRange } from "../../../../src/client/ChangeFeed/changeFeedUtils"; -import { QueryRange } from "../../../../src/routing"; +} from "../../../../src/client/ChangeFeed/changeFeedUtils.js"; +import type { PartitionKeyRange } from "../../../../src/index.js"; +import { ChangeFeedStartFrom } from "../../../../src/index.js"; +import { FeedRangeInternal } from "../../../../src/client/ChangeFeed/FeedRange.js"; +import { isEpkRange } from "../../../../src/client/ChangeFeed/changeFeedUtils.js"; +import { QueryRange } from "../../../../src/routing/index.js"; describe("test extractOverlappingRanges", function () { it("exact overlap", async function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts index ff1727c8ebca..9226c25f3c66 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { FeedRangeQueue } from "../../../../src/client/ChangeFeed/FeedRangeQueue"; -import { ChangeFeedRange } from "../../../../src/client/ChangeFeed/ChangeFeedRange"; +import assert from "node:assert"; +import { FeedRangeQueue } from "../../../../src/client/ChangeFeed/FeedRangeQueue.js"; +import { ChangeFeedRange } from "../../../../src/client/ChangeFeed/ChangeFeedRange.js"; const feedRanges = [ { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts index 36da9fbc6f14..d97d95dbc8dc 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Container, RequestContext } from "../../../src"; -import { CosmosClient, PatchOperationType, ResourceType } from "../../../src"; -import assert from "assert"; +import type { Container, RequestContext } from "../../../src/index.js"; +import { CosmosClient, PatchOperationType, ResourceType } from "../../../src/index.js"; +import assert from "node:assert"; import type { Suite } from "mocha"; import type { SinonSandbox, SinonSpy } from "sinon"; import Sinon from "sinon"; -import { getTestContainer } from "../../public/common/TestHelpers"; +import { getTestContainer } from "../../public/common/TestHelpers.js"; import type { AccessToken, TokenCredential } from "@azure/identity"; import nock from "nock"; -import { RequestHandler } from "../../../src/request/RequestHandler"; -import { masterKey } from "../../public/common/_fakeTestSecrets"; -import { endpoint } from "../../public/common/_testConfig"; +import { RequestHandler } from "../../../src/request/RequestHandler.js"; +import { masterKey } from "../../public/common/_fakeTestSecrets.js"; +import { endpoint } from "../../public/common/_testConfig.js"; class MockCredential implements TokenCredential { constructor(public returnPromise: Promise) {} diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts index afebf8c10211..d951c4745683 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { FetchFunctionCallback } from "../../../src/queryExecutionContext"; -import { DefaultQueryExecutionContext } from "../../../src/queryExecutionContext"; -import type { FeedOptions } from "../../../src"; -import assert from "assert"; -import { sleep } from "../../../src/common"; -import { createDummyDiagnosticNode } from "../../public/common/TestHelpers"; -import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics"; +import type { FetchFunctionCallback } from "../../../src/queryExecutionContext/index.js"; +import { DefaultQueryExecutionContext } from "../../../src/queryExecutionContext/index.js"; +import type { FeedOptions } from "../../../src/index.js"; +import assert from "node:assert"; +import { sleep } from "../../../src/common/index.js"; +import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; +import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; describe("defaultQueryExecutionContext", function () { it("should not buffer items if bufferItems is false", async function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts index 5b6f2610cc4e..2b0a23e5dfea 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts @@ -6,14 +6,14 @@ import { addDignosticChild, getEmptyCosmosDiagnostics, withDiagnostics, -} from "../../../src/utils/diagnostics"; -import { CosmosDbDiagnosticLevel } from "../../../src/diagnostics/CosmosDbDiagnosticLevel"; +} from "../../../src/utils/diagnostics.js"; +import { CosmosDbDiagnosticLevel } from "../../../src/diagnostics/CosmosDbDiagnosticLevel.js"; import type { ClientConfigDiagnostic, CosmosClientOptions, RequestOptions, Resource, -} from "../../../src"; +} from "../../../src/index.js"; import { ClientContext, ConsistencyLevel, @@ -22,19 +22,19 @@ import { ErrorResponse, GlobalEndpointManager, ItemResponse, -} from "../../../src"; +} from "../../../src/index.js"; import { expect } from "chai"; -import { getCurrentTimestampInMs } from "../../../src/utils/time"; +import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { DiagnosticNodeInternal, DiagnosticNodeType, -} from "../../../src/diagnostics/DiagnosticNodeInternal"; -import { allowTracing } from "../../../src/diagnostics/diagnosticLevelComparator"; +} from "../../../src/diagnostics/DiagnosticNodeInternal.js"; +import { allowTracing } from "../../../src/diagnostics/diagnosticLevelComparator.js"; import { determineDiagnosticLevel, getDiagnosticLevelFromEnvironment, setDiagnosticLevel, -} from "../../../src/diagnostics"; +} from "../../../src/diagnostics/index.js"; describe("Diagnostic Unit Tests", function (this: Suite) { describe("Test withDiagnostics utility function", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts index c1c759bfa889..c51ac0680340 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { Constants } from "../../../src/common/constants"; -import { getHeaders } from "../../../src/request/request"; -import { CosmosHeaders, FeedOptions } from "../../../src"; +import assert from "node:assert"; +import { Constants } from "../../../src/common/constants.js"; +import { getHeaders } from "../../../src/request/request.js"; +import { CosmosHeaders, FeedOptions } from "../../../src/index.js"; describe("Test x-ms-documentdb-query-parallelizecrosspartitionquery header value", function () { const mockedEndpoint = "https://localhost:8081"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts index 5e79e544a66d..c9bf4ce21388 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { Suite } from "mocha"; -import assert from "assert"; -import { GlobalStatisticsAggregator } from "../../../src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator"; -import { GlobalStatistics } from "../../../src/request/globalStatistics"; +import assert from "node:assert"; +import { GlobalStatisticsAggregator } from "../../../src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js"; +import { GlobalStatistics } from "../../../src/request/globalStatistics.js"; describe("global statistics aggregator", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts index cb9744c7d4fa..e80323048446 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { hashV1PartitionKey } from "../../../../src/utils/hashing/v1"; +import assert from "node:assert"; +import { hashV1PartitionKey } from "../../../../src/utils/hashing/v1.js"; describe("effectivePartitionKey", function () { describe("computes v1 key", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts index 7b6a8e57aefd..f6f49b8af654 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { hashV2PartitionKey } from "../../../../src/utils/hashing/v2"; +import assert from "node:assert"; +import { hashV2PartitionKey } from "../../../../src/utils/hashing/v2.js"; describe("effectivePartitionKey", function () { describe("computes v2 key", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts index d053e8622b77..e2b88943af17 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { parseConnectionString } from "../../../src/common"; +import assert from "node:assert"; +import { parseConnectionString } from "../../../src/common/index.js"; describe("Helper methods", function () { describe("parseConnectionString", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts index d6fa7dfa29ea..348eeccd9118 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { QueryRange } from "../../../src/routing"; -import { createCompleteRoutingMap } from "../../../src/routing/CollectionRoutingMapFactory"; +import assert from "node:assert"; +import { QueryRange } from "../../../src/routing/index.js"; +import { createCompleteRoutingMap } from "../../../src/routing/CollectionRoutingMapFactory.js"; describe("InMemoryCollectionRoutingMap Tests", function () { describe("getOverlappingRanges", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts index 3c7052ef9be9..6378ab65407a 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { Constants } from "../../../src/common/constants"; -import { getUserAgent } from "../../../src/common/platform"; +import assert from "node:assert"; +import { Constants } from "../../../src/common/constants.js"; +import { getUserAgent } from "../../../src/common/platform.js"; // eslint-disable-next-line @typescript-eslint/no-require-imports const packageJson = require("../../../package.json"); const packageVersion = packageJson["version"]; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts index 08d2ef0a90f2..0bcc9a8f4266 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { CosmosClient } from "../../../src"; -import { endpoint } from "../../public/common/_testConfig"; -import { masterKey, userSasTokenKey } from "../../public/common/_fakeTestSecrets"; -import { SasTokenPermissionKind } from "../../../src/common"; -import { createAuthorizationSasToken } from "../../../src/utils/SasToken"; -import type { SasTokenProperties } from "../../../src/client/SasToken/SasTokenProperties"; +import assert from "node:assert"; +import { CosmosClient } from "../../../src/index.js"; +import { endpoint } from "../../public/common/_testConfig.js"; +import { masterKey, userSasTokenKey } from "../../public/common/_fakeTestSecrets.js"; +import { SasTokenPermissionKind } from "../../../src/common/index.js"; +import { createAuthorizationSasToken } from "../../../src/utils/SasToken.js"; +import type { SasTokenProperties } from "../../../src/client/SasToken/SasTokenProperties.js"; describe.skip("SAS Token Authorization", function () { const sasTokenProperties = { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts index 736d010bc5d4..ef32f89b3df4 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { Constants, OperationType, ResourceType } from "../../../src/common"; -import type { CosmosHeaders } from "../../../src/queryExecutionContext/CosmosHeaders"; -import { SessionContainer } from "../../../src/session/sessionContainer"; -import type { SessionContext } from "../../../src/session/SessionContext"; +import assert from "node:assert"; +import { Constants, OperationType, ResourceType } from "../../../src/common/index.js"; +import type { CosmosHeaders } from "../../../src/queryExecutionContext/CosmosHeaders.js"; +import { SessionContainer } from "../../../src/session/sessionContainer.js"; +import type { SessionContext } from "../../../src/session/SessionContext.js"; describe("SessionContainer", function () { const collectionLink = "dbs/testDatabase/colls/testCollection"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts index ccad0a395a04..3fbc53f248f6 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { ClientContext } from "../../../src/ClientContext"; -import { PartitionKeyRangeCache, QueryRange, SmartRoutingMapProvider } from "../../../src/routing"; -import { MockedClientContext } from "../../public/common/MockClientContext"; -import { createDummyDiagnosticNode } from "../../public/common/TestHelpers"; +import assert from "node:assert"; +import type { ClientContext } from "../../../src/ClientContext.js"; +import { PartitionKeyRangeCache, QueryRange, SmartRoutingMapProvider } from "../../../src/routing/index.js"; +import { MockedClientContext } from "../../public/common/MockClientContext.js"; +import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; describe("Smart Routing Map Provider OverlappingRanges", function () { const containerLink = "dbs/7JZZAA==/colls/7JZZAOS-JQA=/"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts index 872f257024f8..89e5584d5fa1 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { TimeoutFailoverRetryPolicy } from "../../../src/retry/timeoutFailoverRetryPolicy"; -import { GlobalEndpointManager } from "../../../src/globalEndpointManager"; -import { HTTPMethod, OperationType, ResourceType } from "../../../src/common/constants"; -import { DatabaseAccount } from "../../../src/documents/DatabaseAccount"; -import { ResourceResponse } from "../../../src/request/ResourceResponse"; -import type { ErrorResponse } from "../../../src/request/ErrorResponse"; -import type { RetryContext } from "../../../src/retry/RetryContext"; -import { StatusCodes } from "../../../src/common/statusCodes"; -import { TimeoutError } from "../../../src/request/TimeoutError"; -import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics"; -import { createDummyDiagnosticNode } from "../../public/common/TestHelpers"; +import assert from "node:assert"; +import { TimeoutFailoverRetryPolicy } from "../../../src/retry/timeoutFailoverRetryPolicy.js"; +import { GlobalEndpointManager } from "../../../src/globalEndpointManager.js"; +import { HTTPMethod, OperationType, ResourceType } from "../../../src/common/constants.js"; +import { DatabaseAccount } from "../../../src/documents/DatabaseAccount.js"; +import { ResourceResponse } from "../../../src/request/ResourceResponse.js"; +import type { ErrorResponse } from "../../../src/request/ErrorResponse.js"; +import type { RetryContext } from "../../../src/retry/RetryContext.js"; +import { StatusCodes } from "../../../src/common/statusCodes.js"; +import { TimeoutError } from "../../../src/request/TimeoutError.js"; +import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; +import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; describe("TimeoutFailoverRetryPolicy", function () { const databaseAccountBody: any = { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts index 8a3a8f14d952..d9059911acfe 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { Constants } from "../../../../src"; -import type { Batch, Operation } from "../../../../src/utils/batch"; +import assert from "node:assert"; +import { Constants } from "../../../../src/index.js"; +import type { Batch, Operation } from "../../../../src/utils/batch.js"; import { BulkOperationType, calculateObjectSizeInBytes, splitBatchBasedOnBodySize, -} from "../../../../src/utils/batch"; +} from "../../../../src/utils/batch.js"; const operationSkeleton: Operation = { operationType: BulkOperationType.Create, diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts index dcbdd6957f20..6ba48aa8ef14 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { sanitizeEndpoint } from "../../../../src/utils/checkURL"; +import assert from "node:assert"; +import { sanitizeEndpoint } from "../../../../src/utils/checkURL.js"; describe("URL utils", function () { describe("sanitizeEndpoint", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts index f0cbbfc13196..09fa3444e5b5 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { NonStreamingOrderByMap } from "../../../../src/utils/nonStreamingOrderByMap"; +import assert from "node:assert"; +import { NonStreamingOrderByMap } from "../../../../src/utils/nonStreamingOrderByMap.js"; describe("NonStreamingOrderByMap", () => { it("should insert items", () => { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts index 375ac61162c2..5954d22eaec5 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { FixedSizePriorityQueue } from "../../../../src/utils/fixedSizePriorityQueue"; +import assert from "node:assert"; +import { FixedSizePriorityQueue } from "../../../../src/utils/fixedSizePriorityQueue.js"; describe("FixedSizePriorityQueue", () => { it("should enqueue items", () => { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts index dd81809c02ef..ad6ff4b73a8e 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { validateOffer } from "../../../../src/utils/offers"; -import type { ContainerRequest } from "../../../../src"; +import assert from "node:assert"; +import { validateOffer } from "../../../../src/utils/offers.js"; +import type { ContainerRequest } from "../../../../src/index.js"; describe("Offer utils", function () { describe("validateOffer", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts index 10b6ba4de233..72c1cf9b617b 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { supportedQueryFeaturesBuilder } from "../../../../src/utils/supportedQueryFeaturesBuilder"; -import type { FeedOptions } from "../../../../src/request/FeedOptions"; +import assert from "node:assert"; +import { supportedQueryFeaturesBuilder } from "../../../../src/utils/supportedQueryFeaturesBuilder.js"; +import type { FeedOptions } from "../../../../src/request/FeedOptions.js"; describe("validate supportedQueryFeaturesBuilder", function () { it("should contain nonStreamingOrderBy feature", () => { diff --git a/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts b/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts index 722a4b776f7a..428942579b6d 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { MockedQueryIterator } from "./MockQueryIterator"; +import { MockedQueryIterator } from "./MockQueryIterator.js"; export class MockedClientContext { constructor(private partitionKeyRanges: unknown) {} public readPartitionKeyRanges(): MockedQueryIterator { diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts index 4a9f80b7650b..6b7e7bd19620 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import assert from "assert"; +import assert from "node:assert"; import type { Container, CosmosDiagnostics, @@ -16,28 +16,28 @@ import type { RequestOptions, Response, UserDefinition, -} from "../../../src"; -import { CosmosClient, CosmosDbDiagnosticLevel, MetadataLookUpType } from "../../../src"; +} from "../../../src/index.js"; +import { CosmosClient, CosmosDbDiagnosticLevel, MetadataLookUpType } from "../../../src/index.js"; import type { ItemDefinition, ItemResponse, PermissionResponse, Resource, User, -} from "../../../src"; -import type { UserResponse } from "../../../src"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; -import type { DatabaseRequest } from "../../../src"; -import type { ContainerRequest } from "../../../src"; +} from "../../../src/index.js"; +import type { UserResponse } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import type { DatabaseRequest } from "../../../src/index.js"; +import type { ContainerRequest } from "../../../src/index.js"; import { AssertionError, expect } from "chai"; import { DiagnosticNodeInternal, DiagnosticNodeType, -} from "../../../src/diagnostics/DiagnosticNodeInternal"; -import type { ExtractPromise } from "../../../src/utils/diagnostics"; -import { getCurrentTimestampInMs } from "../../../src/utils/time"; -import { extractPartitionKeys } from "../../../src/extractPartitionKey"; +} from "../../../src/diagnostics/DiagnosticNodeInternal.js"; +import type { ExtractPromise } from "../../../src/utils/diagnostics.js"; +import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; +import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; const defaultRoutingGatewayPort: string = ":8081"; const defaultComputeGatewayPort: string = ":8903"; diff --git a/sdk/cosmosdb/cosmos/test/public/common/setup.ts b/sdk/cosmosdb/cosmos/test/public/common/setup.ts index a581a214678e..435d4557b6e9 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/setup.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/setup.ts @@ -3,7 +3,7 @@ // eslint-disable-next-line @typescript-eslint/no-require-imports require("source-map-support").install(); -import util from "util"; +import util from "node:util"; process.on("unhandledRejection", (error: any) => { if (error.body) { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts index 9670dfddcacc..f7bdf3904ae4 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { IndexingPolicy, VectorEmbeddingPolicy } from "../../../src/documents"; +import assert from "node:assert"; +import type { IndexingPolicy, VectorEmbeddingPolicy } from "../../../src/documents/index.js"; import { VectorEmbeddingDataType, VectorEmbeddingDistanceFunction, VectorIndexType, -} from "../../../src/documents"; -import { getTestDatabase } from "../common/TestHelpers"; -import type { Database } from "../../../src/client/Database/Database"; -import type { Container } from "../../../src/client"; +} from "../../../src/documents/index.js"; +import { getTestDatabase } from "../common/TestHelpers.js"; +import type { Database } from "../../../src/client/Database/Database.js"; +import type { Container } from "../../../src/client/index.js"; // Skipping these tests as they are not supported by public emulator describe("Vector search feature", async () => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts index ee54130e819b..604f74bcf186 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { CosmosClient, PermissionMode } from "../../../src"; -import type { PermissionDefinition } from "../../../src/"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; +import { CosmosClient, PermissionMode } from "../../../src/index.js"; +import type { PermissionDefinition } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; import { createOrUpsertPermission, getTestContainer, getTestDatabase, removeAllDatabases, -} from "../common/TestHelpers"; +} from "../common/TestHelpers.js"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts index 656262064494..e665228deeb4 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { Agent } from "http"; -import { CosmosClient } from "../../../src"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; +import { Agent } from "node:http"; +import { CosmosClient } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; import { getTestDatabase, getTestContainer, generateDocuments, bulkInsertItems, -} from "../common/TestHelpers"; +} from "../common/TestHelpers.js"; import { UsernamePasswordCredential } from "@azure/identity"; -import { defaultConnectionPolicy } from "../../../src/documents"; +import { defaultConnectionPolicy } from "../../../src/documents/index.js"; describe("Client Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 200000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts index 5d7e6ceb4b86..23b55385ef5a 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { ComputedProperty } from "../../../src/documents/ComputedProperty"; -import type { IndexingPolicy } from "../../../src/documents/IndexingPolicy"; -import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; -import type { Container } from "../../../src/client/Container/Container"; +import assert from "node:assert"; +import type { ComputedProperty } from "../../../src/documents/ComputedProperty.js"; +import type { IndexingPolicy } from "../../../src/documents/IndexingPolicy.js"; +import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; +import type { Container } from "../../../src/client/Container/Container.js"; // As of the current emulator release (March 23), computed properties are not supported, // hence, we are temporarily excluding these tests. diff --git a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts index f65e78a5caa0..9798fb1d0ef5 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { removeAllDatabases, getTestContainer, testForDiagnostics } from "../common/TestHelpers"; -import { getCurrentTimestampInMs } from "../../../src/utils/time"; +import { removeAllDatabases, getTestContainer, testForDiagnostics } from "../common/TestHelpers.js"; +import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; describe("Conflicts", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts index 528da324203c..d489bb7b26a9 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { ContainerResponse, PartitionKeyDefinition } from "../../../src"; +import type { ContainerResponse, PartitionKeyDefinition } from "../../../src/index.js"; import { Constants, OperationType, PartitionKeyKind, ResourceType, StatusCodes, -} from "../../../src"; -import type { ContainerDefinition, Database, Container } from "../../../src"; -import type { ContainerRequest } from "../../../src"; -import type { IndexedPath, IndexingPolicy } from "../../../src"; -import { DataType, IndexingMode, IndexKind } from "../../../src"; +} from "../../../src/index.js"; +import type { ContainerDefinition, Database, Container } from "../../../src/index.js"; +import type { ContainerRequest } from "../../../src/index.js"; +import type { IndexedPath, IndexingPolicy } from "../../../src/index.js"; +import { DataType, IndexingMode, IndexKind } from "../../../src/index.js"; import { getTestDatabase, removeAllDatabases, @@ -21,9 +21,9 @@ import { assertThrowsAsync, addEntropy, testForDiagnostics, -} from "../common/TestHelpers"; -import { SpatialType } from "../../../src"; -import { GeospatialType } from "../../../src"; +} from "../common/TestHelpers.js"; +import { SpatialType } from "../../../src/index.js"; +import { GeospatialType } from "../../../src/index.js"; describe("Containers", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts index 781ef2bdd0de..7fd31e526a8b 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { DatabaseDefinition, Database } from "../../../src"; -import { CosmosClient } from "../../../src"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; +import type { DatabaseDefinition, Database } from "../../../src/index.js"; +import { CosmosClient } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; import { addEntropy, removeAllDatabases, getTestDatabase, assertThrowsAsync, testForDiagnostics, -} from "../common/TestHelpers"; -import type { DatabaseRequest } from "../../../src"; +} from "../common/TestHelpers.js"; +import type { DatabaseRequest } from "../../../src/index.js"; const client = new CosmosClient({ endpoint, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts index 841fd17ae662..9ab5ffeaea80 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Context } from "mocha"; import type { Suite } from "mocha"; -import { CosmosClient, OperationType } from "../../../src"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; -import { testForDiagnostics } from "../common/TestHelpers"; +import { CosmosClient, OperationType } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import { testForDiagnostics } from "../common/TestHelpers.js"; const client = new CosmosClient({ endpoint, @@ -16,7 +16,7 @@ const client = new CosmosClient({ describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function (this: Context) { + beforeEach(async function (ctx) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts index 7ed548541db2..ca1812d9afce 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { ExecutionContext } from "../../../../src/queryExecutionContext"; -import { NonStreamingOrderByDistinctEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent"; -import type { QueryInfo } from "../../../../src/request/ErrorResponse"; +import assert from "node:assert"; +import type { ExecutionContext } from "../../../../src/queryExecutionContext/index.js"; +import { NonStreamingOrderByDistinctEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js"; +import type { QueryInfo } from "../../../../src/request/ErrorResponse.js"; describe("NonStreamingOrderByDistinctEndpointComponent", () => { it("should initialize correctly with sort orders and priority queue buffer size", () => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts index 9f074e1f4def..0f9fa68ac9b4 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { ExecutionContext } from "../../../../src/queryExecutionContext"; -import { NonStreamingOrderByEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent"; +import assert from "node:assert"; +import type { ExecutionContext } from "../../../../src/queryExecutionContext/index.js"; +import { NonStreamingOrderByEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js"; describe("NonStreamingOrderByEndpointComponent", () => { it("should initialize correctly with sort orders and priority queue buffer size", () => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts index 6a9b07023473..aa3cb8ef8d23 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { DatabaseAccount, ResourceResponse } from "../../../src"; -import { masterKey } from "../common/_fakeTestSecrets"; -import { GlobalEndpointManager } from "../../../src"; -import { OperationType, ResourceType } from "../../../src"; +import { DatabaseAccount, ResourceResponse } from "../../../src/index.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import { GlobalEndpointManager } from "../../../src/index.js"; +import { OperationType, ResourceType } from "../../../src/index.js"; import * as fakeTimers from "@sinonjs/fake-timers"; -import assert from "assert"; -import { createDummyDiagnosticNode } from "../common/TestHelpers"; -import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics"; +import assert from "node:assert"; +import { createDummyDiagnosticNode } from "../common/TestHelpers.js"; +import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; const locationUnavailabilityExpiratationTime = 6 * 60 * 1000; const headers = { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts index 6c7c9a89c894..4845433ef7e8 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { Container, OperationResponse } from "../../../../src"; -import { CosmosClient, OperationType, PatchOperationType, ResourceType } from "../../../../src"; -import { addEntropy, testForDiagnostics } from "../../common/TestHelpers"; -import type { OperationInput } from "../../../../src"; -import { BulkOperationType } from "../../../../src"; -import { PartitionKeyKind } from "../../../../src/documents"; -import { endpoint } from "../../common/_testConfig"; -import { masterKey } from "../../common/_fakeTestSecrets"; -import { getCurrentTimestampInMs } from "../../../../src/utils/time"; +import assert from "node:assert"; +import type { Container, OperationResponse } from "../../../../src/index.js"; +import { CosmosClient, OperationType, PatchOperationType, ResourceType } from "../../../../src/index.js"; +import { addEntropy, testForDiagnostics } from "../../common/TestHelpers.js"; +import type { OperationInput } from "../../../../src/index.js"; +import { BulkOperationType } from "../../../../src/index.js"; +import { PartitionKeyKind } from "../../../../src/documents/index.js"; +import { endpoint } from "../../common/_testConfig.js"; +import { masterKey } from "../../common/_fakeTestSecrets.js"; +import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; describe("test batch operations", function () { describe("v2 multi partition container", async function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts index 47421b8ef298..412c7b3c39fa 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { BulkOptions, Container, ContainerRequest, OperationResponse, PluginConfig, -} from "../../../../src"; +} from "../../../../src/index.js"; import { Constants, CosmosClient, @@ -17,17 +17,17 @@ import { PluginOn, StatusCodes, ErrorResponse, -} from "../../../../src"; -import { addEntropy, getTestContainer, testForDiagnostics } from "../../common/TestHelpers"; -import type { OperationInput } from "../../../../src"; -import { BulkOperationType } from "../../../../src"; -import { generateOperationOfSize } from "../../../internal/unit/utils/batch.spec"; -import type { PartitionKey } from "../../../../src/documents"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../../src/documents"; -import { endpoint } from "../../common/_testConfig"; -import { masterKey } from "../../common/_fakeTestSecrets"; -import { getCurrentTimestampInMs } from "../../../../src/utils/time"; -import { SubStatusCodes } from "../../../../src/common"; +} from "../../../../src/index.js"; +import { addEntropy, getTestContainer, testForDiagnostics } from "../../common/TestHelpers.js"; +import type { OperationInput } from "../../../../src/index.js"; +import { BulkOperationType } from "../../../../src/index.js"; +import { generateOperationOfSize } from "../../../internal/unit/utils/batch.spec.js"; +import type { PartitionKey } from "../../../../src/documents/index.js"; +import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../../src/documents/index.js"; +import { endpoint } from "../../common/_testConfig.js"; +import { masterKey } from "../../common/_fakeTestSecrets.js"; +import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; +import { SubStatusCodes } from "../../../../src/common/index.js"; describe("test bulk operations", async function () { describe("Check size based splitting of batches", function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts index afdace989037..f3417dbef6af 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; import type { Container, @@ -8,9 +8,9 @@ import type { ContainerRequest, PatchOperation, RequestOptions, -} from "../../../../src"; -import { CosmosClient } from "../../../../src"; -import type { ItemDefinition } from "../../../../src"; +} from "../../../../src/index.js"; +import { CosmosClient } from "../../../../src/index.js"; +import type { ItemDefinition } from "../../../../src/index.js"; import { bulkDeleteItems, bulkInsertItems, @@ -24,13 +24,13 @@ import { addEntropy, getTestContainer, testForDiagnostics, -} from "../../common/TestHelpers"; -import { endpoint } from "../../common/_testConfig"; -import { masterKey } from "../../common/_fakeTestSecrets"; -import type { PartitionKey, PartitionKeyDefinition } from "../../../../src/documents"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../../src/documents"; -import { PriorityLevel } from "../../../../src/documents/PriorityLevel"; -import { getCurrentTimestampInMs } from "../../../../src/utils/time"; +} from "../../common/TestHelpers.js"; +import { endpoint } from "../../common/_testConfig.js"; +import { masterKey } from "../../common/_fakeTestSecrets.js"; +import type { PartitionKey, PartitionKeyDefinition } from "../../../../src/documents/index.js"; +import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../../src/documents/index.js"; +import { PriorityLevel } from "../../../../src/documents/PriorityLevel.js"; +import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; /** * Tests Item api. diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts index 25572e24a183..aba731af9694 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { Container, CosmosClient } from "../../../../src"; +import type { Container, CosmosClient } from "../../../../src/index.js"; import { getTestContainer, removeAllDatabases, defaultClient, defaultComputeGatewayClient, -} from "../../common/TestHelpers"; +} from "../../common/TestHelpers.js"; interface ItemPayload { id?: string; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts index 87b3b155c8c5..d80ead89bec8 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import assert from "assert"; -import type { Container, PluginConfig, CosmosClientOptions, OperationInput } from "../../../src"; -import { CosmosClient, Constants, PatchOperationType } from "../../../src"; -import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; -import { ResourceType, HTTPMethod, StatusCodes } from "../../../src"; +import assert from "node:assert"; +import type { Container, PluginConfig, CosmosClientOptions, OperationInput } from "../../../src/index.js"; +import { CosmosClient, Constants, PatchOperationType } from "../../../src/index.js"; +import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import { ResourceType, HTTPMethod, StatusCodes } from "../../../src/index.js"; import { expect } from "chai"; const plugins: PluginConfig[] = [ diff --git a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts index 0638eaef8b05..736af41c212e 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Context } from "mocha"; import type { Suite } from "mocha"; -import { Constants, CosmosClient } from "../../../src"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; -import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; +import { Constants, CosmosClient } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; const client = new CosmosClient({ endpoint, @@ -25,7 +25,7 @@ const validateOfferResponseBody = function (offer: any): void { describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function (this: Context) { + beforeEach(async function (ctx) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); await removeAllDatabases(); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts index 1bc7e1477698..d4d3cd7ddf87 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { PermissionMode } from "../../../src"; -import type { PermissionDefinition } from "../../../src"; +import { PermissionMode } from "../../../src/index.js"; +import type { PermissionDefinition } from "../../../src/index.js"; import { createOrUpsertPermission, getTestContainer, removeAllDatabases, replaceOrUpsertPermission, -} from "../common/TestHelpers"; +} from "../common/TestHelpers.js"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts index 5f79d1d7d70c..4c5351cdd37a 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import type { CosmosClientOptions } from "../../../src"; -import { CosmosClient } from "../../../src"; -import type { RequestContext } from "../../../src"; -import type { Plugin, Next, PluginConfig } from "../../../src"; +import type { CosmosClientOptions } from "../../../src/index.js"; +import { CosmosClient } from "../../../src/index.js"; +import type { RequestContext } from "../../../src/index.js"; +import type { Plugin, Next, PluginConfig } from "../../../src/index.js"; -import * as assert from "assert"; -import type { DiagnosticNodeInternal } from "../../../src/diagnostics/DiagnosticNodeInternal"; +import * as assert from "node:assert"; +import type { DiagnosticNodeInternal } from "../../../src/diagnostics/DiagnosticNodeInternal.js"; import { expect } from "chai"; -import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics"; +import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; describe("Plugin", function () { it("should handle all requests", async function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts index 065ceae49f00..863418cb638d 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { ContainerDefinition } from "../../../src"; -import { CosmosClient } from "../../../src"; -import type { Container } from "../../../src/"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; +import type { ContainerDefinition } from "../../../src/index.js"; +import { CosmosClient } from "../../../src/index.js"; +import type { Container } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; import { getTestContainer, getTestDatabase, removeAllDatabases, testForDiagnostics, -} from "../common/TestHelpers"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents"; +} from "../common/TestHelpers.js"; +import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; const client = new CosmosClient({ endpoint, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts index 764cd6fcb3f1..7fa420166b7a 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts @@ -2,16 +2,16 @@ // Licensed under the MIT License. // Import the required modules -import assert from "assert"; -import type { Container, FeedOptions } from "../../../src"; -import { CosmosClient, OperationType, ResourceType } from "../../../src"; -import { endpoint } from "../../public/common/_testConfig"; -import { masterKey } from "../../public/common/_fakeTestSecrets"; +import assert from "node:assert"; +import type { Container, FeedOptions } from "../../../src/index.js"; +import { CosmosClient, OperationType, ResourceType } from "../../../src/index.js"; +import { endpoint } from "../../public/common/_testConfig.js"; +import { masterKey } from "../../public/common/_fakeTestSecrets.js"; import { getTestContainer, isValidV4UUID, removeAllDatabases, -} from "../../public/common/TestHelpers"; +} from "../../public/common/TestHelpers.js"; describe("Correlated Activity Id", function () { this.timeout(process.env.MOCHA_TIMEOUT || 30000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts index cb4e9f0c69ce..5be5c7de1d51 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { Database } from "../../../src"; -import { DataType, IndexKind } from "../../../src"; -import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; +import type { Database } from "../../../src/index.js"; +import { DataType, IndexKind } from "../../../src/index.js"; +import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; describe("Spatial Indexes", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts index 1cdd72b10614..934cc5e142b2 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Context } from "mocha"; import type { Suite } from "mocha"; -import { Constants } from "../../../src"; -import type { Container, StoredProcedureDefinition } from "../../../src/"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents"; +import { Constants } from "../../../src/index.js"; +import type { Container, StoredProcedureDefinition } from "../../../src/index.js"; +import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; import { bulkInsertItems, getTestContainer, getTestDatabase, removeAllDatabases, -} from "../common/TestHelpers"; +} from "../common/TestHelpers.js"; // Used for sproc declare let getContext: any; @@ -23,7 +23,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { }); describe("Validate sproc CRUD", function () { let container: Container; - beforeEach(async function (this: Context) { + beforeEach(async function (ctx) { container = await getTestContainer(this.test.fullTitle()); }); @@ -95,7 +95,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { describe("Validate stored procedure functionality", function () { let container: Container; - beforeEach(async function (this: Context) { + beforeEach(async function (ctx) { container = await getTestContainer(this.test.fullTitle()); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts index da7f0e0d552f..9e7af799eab7 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { TriggerOperation, TriggerType } from "../../../src"; -import type { TriggerDefinition, Container } from "../../../src"; -import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; +import { TriggerOperation, TriggerType } from "../../../src/index.js"; +import type { TriggerDefinition, Container } from "../../../src/index.js"; +import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; const notFoundErrorCode = 404; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts index 8f2709554863..a1e54f6fbc93 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { Container, ContainerDefinition, Database } from "../../../src"; -import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; -import { StatusCodes } from "../../../src"; +import type { Container, ContainerDefinition, Database } from "../../../src/index.js"; +import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; +import { StatusCodes } from "../../../src/index.js"; async function sleep(time: number): Promise { return new Promise((resolve) => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts index 8e755cc51cc3..8408b20ccefe 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { UserDefinedFunctionDefinition, Container } from "../../../src"; -import { removeAllDatabases, getTestContainer } from "../common/TestHelpers"; +import type { UserDefinedFunctionDefinition, Container } from "../../../src/index.js"; +import { removeAllDatabases, getTestContainer } from "../common/TestHelpers.js"; describe("User Defined Function", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts index d3f5f57a7c06..4714cfe1ec7e 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { UserDefinition } from "../../../src"; -import { createOrUpsertUser, getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; +import type { UserDefinition } from "../../../src/index.js"; +import { createOrUpsertUser, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts index 6610fa3e50ac..6c22623cb1c6 100644 --- a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { IndexMetricWriter, IndexUtilizationInfo } from "../../src/indexMetrics"; +import { IndexMetricWriter, IndexUtilizationInfo } from "../../src/indexMetrics/index.js"; describe("Test Index Metrics Writer", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts index e0aa7d812602..682ca3f66852 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { Container, ContainerDefinition } from "../../../src"; -import { IndexingMode } from "../../../src"; -import { DataType, IndexKind } from "../../../src"; -import type { QueryIterator } from "../../../src"; -import type { SqlQuerySpec } from "../../../src"; -import type { FeedOptions } from "../../../src"; -import { TestData } from "../common/TestData"; -import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers"; +import type { Container, ContainerDefinition } from "../../../src/index.js"; +import { IndexingMode } from "../../../src/index.js"; +import { DataType, IndexKind } from "../../../src/index.js"; +import type { QueryIterator } from "../../../src/index.js"; +import type { SqlQuerySpec } from "../../../src/index.js"; +import type { FeedOptions } from "../../../src/index.js"; +import { TestData } from "../common/TestData.js"; +import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; import { expect } from "chai"; describe("Aggregate Query", function (this: Suite) { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts index dbac0aa8fbef..6572c93f92d1 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Container, ContainerDefinition } from "../../../../src"; -import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../../common/TestHelpers"; -import assert from "assert"; -import groupBySnapshot from "./groupBy.snapshot"; +import type { Container, ContainerDefinition } from "../../../../src/index.js"; +import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../../common/TestHelpers.js"; +import assert from "node:assert"; +import groupBySnapshot from "./groupBy.snapshot.js"; import type { Context } from "mocha"; const options = { @@ -544,7 +544,7 @@ describe("Cross partition GROUP BY", () => { assert.deepStrictEqual(actual, groupBySnapshot[`${currentTestTitle} ${snapshotNumber++}`]); }; - beforeEach(function (this: Context) { + beforeEach(function (ctx) { currentTestTitle = this.currentTest.fullTitle(); snapshotNumber = 1; }); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts index e4439435f685..da2d9bd68baf 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { Container } from "../../../src"; -import { CosmosClient, PermissionMode } from "../../../src"; -import type { Database } from "../../../src"; -import { endpoint } from "../common/_testConfig"; -import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; +import type { Container } from "../../../src/index.js"; +import { CosmosClient, PermissionMode } from "../../../src/index.js"; +import type { Database } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; describe("Authorization", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts index badc024d7fd3..a30f2b17815f 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { RequestOptions } from "../../../src"; -import type { Container, ContainerDefinition } from "../../../src"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents"; -import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; +import type { RequestOptions } from "../../../src/index.js"; +import type { Container, ContainerDefinition } from "../../../src/index.js"; +import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; +import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; describe("Change Feed Iterator", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts index 56a6924c2046..b8d4934a29da 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { ChangeFeedIteratorOptions, RequestOptions } from "../../../src"; +import type { ChangeFeedIteratorOptions, RequestOptions } from "../../../src/index.js"; import { ChangeFeedStartFrom, ChangeFeedRetentionTimeSpan, ChangeFeedPolicy, ChangeFeedMode, -} from "../../../src"; -import type { Container, ContainerDefinition } from "../../../src"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents"; +} from "../../../src/index.js"; +import type { Container, ContainerDefinition } from "../../../src/index.js"; +import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; import { getTestContainer, removeAllDatabases, @@ -18,10 +18,10 @@ import { changeFeedAllVersionsInsertItems, changeFeedAllVersionsUpsertItems, changeFeedAllVersionsDeleteItems, -} from "../common/TestHelpers"; -import { FeedRangeInternal } from "../../../src/client/ChangeFeed/FeedRange"; -import { getCurrentTimestampInMs } from "../../../src/utils/time"; -import { StatusCodes } from "../../../src/common/statusCodes"; +} from "../common/TestHelpers.js"; +import { FeedRangeInternal } from "../../../src/client/ChangeFeed/FeedRange.js"; +import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; +import { StatusCodes } from "../../../src/common/statusCodes.js"; describe("Change Feed Iterator", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts index b85f41622865..86e0e0a5cc74 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { RequestContext } from "../../../src"; -import { CosmosClient } from "../../../src"; -import { masterKey } from "../common/_fakeTestSecrets"; -import { PluginOn } from "../../../src"; -import { TimeoutErrorCode } from "../../../src/request/TimeoutError"; -import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics"; +import assert from "node:assert"; +import type { RequestContext } from "../../../src/index.js"; +import { CosmosClient } from "../../../src/index.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import { PluginOn } from "../../../src/index.js"; +import { TimeoutErrorCode } from "../../../src/request/TimeoutError.js"; +import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; const endpoint = "https://failovertest.documents.azure.com/"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts index 279bdd014879..e049d566fc53 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import * as util from "util"; -import type { Container, ContainerDefinition } from "../../../src"; -import { DataType, IndexKind } from "../../../src"; -import type { SqlQuerySpec } from "../../../src"; -import type { QueryIterator } from "../../../src"; +import * as util from "node:util"; +import type { Container, ContainerDefinition } from "../../../src/index.js"; +import { DataType, IndexKind } from "../../../src/index.js"; +import type { SqlQuerySpec } from "../../../src/index.js"; +import type { QueryIterator } from "../../../src/index.js"; import { bulkInsertItems, getTestContainer, removeAllDatabases, generateDocuments, -} from "../common/TestHelpers"; -import type { FeedResponse, FeedOptions } from "../../../src"; +} from "../common/TestHelpers.js"; +import type { FeedResponse, FeedOptions } from "../../../src/index.js"; function compare(key: string) { return function (a: any, b: any): number { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts index b3b10c578a8a..b552e85e7130 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { IndexingMode } from "../../../src"; -import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; +import { IndexingMode } from "../../../src/index.js"; +import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; const testDoc = { id: "ABC", diff --git a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts index bbb32d9fa0ce..7fb78a0fa2fb 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { extractPartitionKeys } from "../../../src/extractPartitionKey"; +import assert from "node:assert"; +import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; describe("extractPartitionKey", function () { describe("With undefined partitionKeyDefinition", function () { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts index a863342ec983..c6e3f5fcfd51 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts @@ -2,11 +2,11 @@ // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ import { expect } from "chai"; -import type { CosmosClientOptions, PluginConfig } from "../../../src"; -import { CosmosClient, PluginOn } from "../../../src"; -import { masterKey } from "../common/_fakeTestSecrets"; -import assert from "assert"; -import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics"; +import type { CosmosClientOptions, PluginConfig } from "../../../src/index.js"; +import { CosmosClient, PluginOn } from "../../../src/index.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import assert from "node:assert"; +import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; const endpoint = "https://failovertest.documents.azure.com/"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts index 74d2b247b002..5698a0c66dcf 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts @@ -2,10 +2,10 @@ // Licensed under the MIT License. import { Suite } from "mocha"; -import assert from "assert"; -import { ContainerDefinition, Container } from "../../../src"; -import items from "./text-3properties-1536dimensions-100documents"; -import { getTestContainer, removeAllDatabases } from "../common/TestHelpers"; +import assert from "node:assert"; +import { ContainerDefinition, Container } from "../../../src/index.js"; +import items from "./text-3properties-1536dimensions-100documents.js"; +import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; describe.skip("Validate full text search queries", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts index c4b6cf06eb6a..8007057120c0 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import { CosmosClient } from "../../../src"; -import { masterKey } from "../common/_fakeTestSecrets"; -import type { PluginConfig, CosmosClientOptions } from "../../../src"; -import { PluginOn } from "../../../src"; +import { CosmosClient } from "../../../src/index.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import type { PluginConfig, CosmosClientOptions } from "../../../src/index.js"; +import { PluginOn } from "../../../src/index.js"; import { expect } from "chai"; -import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics"; +import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; const endpoint = "https://failovertest.documents.azure.com/"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts index 0a6e9bcfde0e..531c2a79ee7a 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { Container } from "../../../../src"; -import { CosmosClient } from "../../../../src"; -import { endpoint } from "../../common/_testConfig"; -import { masterKey } from "../../common/_fakeTestSecrets"; -import { getTestContainer, removeAllDatabases } from "../../common/TestHelpers"; -import type { IndexingPolicy, VectorEmbeddingPolicy } from "../../../../src"; +import assert from "node:assert"; +import type { Container } from "../../../../src/index.js"; +import { CosmosClient } from "../../../../src/index.js"; +import { endpoint } from "../../common/_testConfig.js"; +import { masterKey } from "../../common/_fakeTestSecrets.js"; +import { getTestContainer, removeAllDatabases } from "../../common/TestHelpers.js"; +import type { IndexingPolicy, VectorEmbeddingPolicy } from "../../../../src/index.js"; import { VectorEmbeddingDataType, VectorEmbeddingDistanceFunction, VectorIndexType, -} from "../../../../src/documents"; +} from "../../../../src/documents/index.js"; describe("Test nonStreaming Queries", function () { this.timeout(process.env.MOCHA_TIMEOUT || 30000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts index 4250bb1ff0b4..abc18cb5249e 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import type { Container } from "../../../../src"; -import { CosmosClient } from "../../../../src"; -import { endpoint } from "../../common/_testConfig"; -import { masterKey } from "../../common/_fakeTestSecrets"; -import { getTestContainer, removeAllDatabases } from "../../common/TestHelpers"; -import type { IndexingPolicy, VectorEmbeddingPolicy } from "../../../../src"; +import assert from "node:assert"; +import type { Container } from "../../../../src/index.js"; +import { CosmosClient } from "../../../../src/index.js"; +import { endpoint } from "../../common/_testConfig.js"; +import { masterKey } from "../../common/_fakeTestSecrets.js"; +import { getTestContainer, removeAllDatabases } from "../../common/TestHelpers.js"; +import type { IndexingPolicy, VectorEmbeddingPolicy } from "../../../../src/index.js"; import { VectorEmbeddingDataType, VectorEmbeddingDistanceFunction, VectorIndexType, -} from "../../../../src/documents"; +} from "../../../../src/documents/index.js"; describe("Test nonStreaming Queries", function () { this.timeout(process.env.MOCHA_TIMEOUT || 30000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts index b2c1747ad21e..9cb490496104 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import type { Suite } from "mocha"; -import type { Container, FeedOptions } from "../../../src"; -import { getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers"; +import type { Container, FeedOptions } from "../../../src/index.js"; +import { getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; const doc = { id: "myId", pk: "pk" }; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts index daf1a9ff7784..ab1b414fbb9a 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; +import assert from "node:assert"; import { ClientSideMetrics, QueryMetrics, QueryPreparationTimes, RuntimeExecutionTimes, TimeSpan, -} from "../../../src"; +} from "../../../src/index.js"; describe("QueryMetrics", function () { // Properties diff --git a/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts index 5d717541f38b..96d7bf4c04d6 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import type { Container } from "../../../src"; -import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers"; -import type { CosmosClientOptions, PluginConfig } from "../../../src"; -import { Constants, CosmosClient, PluginOn } from "../../../src"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; -import { SubStatusCodes } from "../../../src/common"; -import assert from "assert"; +import type { Container } from "../../../src/index.js"; +import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; +import type { CosmosClientOptions, PluginConfig } from "../../../src/index.js"; +import { Constants, CosmosClient, PluginOn } from "../../../src/index.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; +import { SubStatusCodes } from "../../../src/common/index.js"; +import assert from "node:assert"; import { expect } from "chai"; const splitError = new Error("Fake Partition Split") as any; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts index 0ad5fb183290..6fdf93fbd89d 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "assert"; -import { CosmosClient } from "../../../src"; -import { getTestDatabase } from "../common/TestHelpers"; -import https from "https"; +import assert from "node:assert"; +import { CosmosClient } from "../../../src/index.js"; +import { getTestDatabase } from "../common/TestHelpers.js"; +import https from "node:https"; const endpoint = "https://localhost:8081"; const masterKey = diff --git a/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts index 577e5ec3ac27..8495800ce950 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import assert from "assert"; -import type { Container } from "../../../src"; -import { CosmosClient } from "../../../src"; -import { addEntropy, removeAllDatabases } from "../common/TestHelpers"; -import { endpoint } from "../common/_testConfig"; -import { masterKey } from "../common/_fakeTestSecrets"; +import assert from "node:assert"; +import type { Container } from "../../../src/index.js"; +import { CosmosClient } from "../../../src/index.js"; +import { addEntropy, removeAllDatabases } from "../common/TestHelpers.js"; +import { endpoint } from "../common/_testConfig.js"; +import { masterKey } from "../common/_fakeTestSecrets.js"; import { expect } from "chai"; describe("Timeout", function () { From aee8a163890d1fbd8a2d4410eedf0604f133ca37 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:10 -0500 Subject: [PATCH 05/45] Migration: Apply codemod: "fixTestingImports" --- sdk/cosmosdb/cosmos/test/internal/session.spec.ts | 3 +-- sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts | 2 +- .../unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts | 1 + .../test/internal/unit/changeFeed/changeFeedUtils.spec.ts | 1 + .../test/internal/unit/changeFeed/feedRangeQueue.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts | 4 +--- .../test/internal/unit/defaultQueryExecutionContext.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts | 4 +--- sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts | 1 + .../test/internal/unit/globalStatisticsAggregator.spec.ts | 3 +-- sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts | 1 + .../test/internal/unit/inMemoryCollectionRoutingMap.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts | 2 ++ sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts | 1 + .../cosmos/test/internal/unit/sessionContainer.spec.ts | 1 + .../cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts | 1 + .../test/internal/unit/timeoutFailoverRetryPolicy.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts | 1 + .../test/internal/unit/utils/nonStreamingOrderByMap.spec.ts | 1 + .../unit/utils/nonStreamingOrderByPriorityQueue.spec.ts | 1 + sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts | 1 + .../internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts | 2 +- .../test/public/functional/NonStreamingQueryPolicy.spec.ts | 1 + .../cosmos/test/public/functional/authorization.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts | 2 +- .../cosmos/test/public/functional/computedProperties.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts | 2 +- .../cosmos/test/public/functional/databaseaccount.spec.ts | 3 +-- .../NonStreamingOrderByDistinctEndpointComponent.spec.ts | 1 + .../NonStreamingOrderByEndpointComponent.spec.ts | 1 + .../test/public/functional/globalEndpointManager.spec.ts | 1 + .../cosmos/test/public/functional/item/batch.item.spec.ts | 1 + .../cosmos/test/public/functional/item/bulk.item.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts | 2 +- .../cosmos/test/public/functional/item/itemIdEncoding.spec.ts | 2 +- .../cosmos/test/public/functional/npcontainer.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts | 3 +-- sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts | 2 +- .../cosmos/test/public/functional/queryIterator.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts | 3 +-- sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts | 3 ++- .../cosmos/test/public/integration/aggregateQuery.spec.ts | 3 +-- .../cosmos/test/public/integration/aggregates/groupBy.spec.ts | 2 +- .../cosmos/test/public/integration/authorization.spec.ts | 2 +- .../cosmos/test/public/integration/changeFeed.spec.ts | 2 +- .../cosmos/test/public/integration/changeFeedIterator.spec.ts | 2 +- .../cosmos/test/public/integration/client.retry.spec.ts | 1 + .../cosmos/test/public/integration/crossPartition.spec.ts | 2 +- sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts | 2 +- .../test/public/integration/extractPartitionKey.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts | 2 +- .../cosmos/test/public/integration/fullTextSearch.spec.ts | 3 +-- .../cosmos/test/public/integration/multiregion.spec.ts | 4 +--- .../nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts | 1 + .../nonStreamingOrderBy/nonStreamingOrderBy.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts | 4 +++- sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts | 2 +- .../cosmos/test/public/integration/queryMetrics.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts | 2 ++ sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts | 2 +- .../cosmos/test/public/integration/sslVerification.spec.ts | 1 + sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts | 2 +- 75 files changed, 80 insertions(+), 53 deletions(-) diff --git a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts index 25d4f5a7a003..b59b06ac6738 100644 --- a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts @@ -2,7 +2,6 @@ // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ import assert from "node:assert"; -import type { Suite } from "mocha"; import type { ClientContext, Container, PluginConfig } from "../../src/index.js"; import { PluginOn } from "../../src/index.js"; import { OperationType, ResourceType } from "../../src/common/index.js"; @@ -14,7 +13,7 @@ import { masterKey } from "../public/common/_fakeTestSecrets.js"; import { addEntropy, getTestDatabase, removeAllDatabases } from "../public/common/TestHelpers.js"; import type { RequestContext } from "../../src/index.js"; import type { Response } from "../../src/request/Response.js"; -import { expect } from "chai"; +import { describe, it, assert } from "vitest"; describe("New session token", function () { it("preserves tokens", async function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts index 5a2726e98e3d..73d300e12e9d 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts @@ -2,8 +2,8 @@ // Licensed under the MIT License. import { getAuthorizationTokenUsingResourceTokens } from "../../../src/auth.js"; -import type { Suite } from "mocha"; import assert from "node:assert"; +import { describe, it, assert } from "vitest"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts index acbcdf2eaef9..ac50f90de152 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts @@ -3,6 +3,7 @@ import { ChangeFeedRetentionTimeSpan } from "../../../../src/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js"; import assert from "node:assert"; +import { describe, it, assert } from "vitest"; describe("test ChangeFeedRetentionTimeSpan", function () { it("timeSpan should be positive number", async function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts index c2c2c47126a6..24f3466ce060 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts @@ -12,6 +12,7 @@ import { ChangeFeedStartFrom } from "../../../../src/index.js"; import { FeedRangeInternal } from "../../../../src/client/ChangeFeed/FeedRange.js"; import { isEpkRange } from "../../../../src/client/ChangeFeed/changeFeedUtils.js"; import { QueryRange } from "../../../../src/routing/index.js"; +import { describe, it, assert } from "vitest"; describe("test extractOverlappingRanges", function () { it("exact overlap", async function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts index 9226c25f3c66..619b7606042a 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts @@ -4,6 +4,7 @@ import assert from "node:assert"; import { FeedRangeQueue } from "../../../../src/client/ChangeFeed/FeedRangeQueue.js"; import { ChangeFeedRange } from "../../../../src/client/ChangeFeed/ChangeFeedRange.js"; +import { describe, it, assert } from "vitest"; const feedRanges = [ { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts index d97d95dbc8dc..26cd848afe9d 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts @@ -4,15 +4,13 @@ import type { Container, RequestContext } from "../../../src/index.js"; import { CosmosClient, PatchOperationType, ResourceType } from "../../../src/index.js"; import assert from "node:assert"; -import type { Suite } from "mocha"; -import type { SinonSandbox, SinonSpy } from "sinon"; -import Sinon from "sinon"; import { getTestContainer } from "../../public/common/TestHelpers.js"; import type { AccessToken, TokenCredential } from "@azure/identity"; import nock from "nock"; import { RequestHandler } from "../../../src/request/RequestHandler.js"; import { masterKey } from "../../public/common/_fakeTestSecrets.js"; import { endpoint } from "../../public/common/_testConfig.js"; +import { describe, it, assert, expect, vi, beforeEach, afterEach } from "vitest"; class MockCredential implements TokenCredential { constructor(public returnPromise: Promise) {} diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts index d951c4745683..62e3d501da06 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts @@ -7,6 +7,7 @@ import assert from "node:assert"; import { sleep } from "../../../src/common/index.js"; import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; +import { describe, it, assert } from "vitest"; describe("defaultQueryExecutionContext", function () { it("should not buffer items if bufferItems is false", async function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts index 2b0a23e5dfea..78bcfce5a475 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts @@ -1,7 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - -import type { Suite } from "mocha"; import { addDignosticChild, getEmptyCosmosDiagnostics, @@ -23,7 +21,6 @@ import { GlobalEndpointManager, ItemResponse, } from "../../../src/index.js"; -import { expect } from "chai"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { DiagnosticNodeInternal, @@ -35,6 +32,7 @@ import { getDiagnosticLevelFromEnvironment, setDiagnosticLevel, } from "../../../src/diagnostics/index.js"; +import { describe, it, assert } from "vitest"; describe("Diagnostic Unit Tests", function (this: Suite) { describe("Test withDiagnostics utility function", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts index c51ac0680340..ec155d35ff34 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts @@ -4,6 +4,7 @@ import assert from "node:assert"; import { Constants } from "../../../src/common/constants.js"; import { getHeaders } from "../../../src/request/request.js"; import { CosmosHeaders, FeedOptions } from "../../../src/index.js"; +import { describe, it, assert } from "vitest"; describe("Test x-ms-documentdb-query-parallelizecrosspartitionquery header value", function () { const mockedEndpoint = "https://localhost:8081"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts index c9bf4ce21388..4544480f54c1 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - -import { Suite } from "mocha"; import assert from "node:assert"; import { GlobalStatisticsAggregator } from "../../../src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js"; import { GlobalStatistics } from "../../../src/request/globalStatistics.js"; +import { describe, it, assert } from "vitest"; describe("global statistics aggregator", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts index e80323048446..cb9ce730344c 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts @@ -3,6 +3,7 @@ import assert from "node:assert"; import { hashV1PartitionKey } from "../../../../src/utils/hashing/v1.js"; +import { describe, it, assert } from "vitest"; describe("effectivePartitionKey", function () { describe("computes v1 key", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts index f6f49b8af654..508fdf74b22c 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts @@ -3,6 +3,7 @@ import assert from "node:assert"; import { hashV2PartitionKey } from "../../../../src/utils/hashing/v2.js"; +import { describe, it, assert } from "vitest"; describe("effectivePartitionKey", function () { describe("computes v2 key", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts index e2b88943af17..93c12aa8373e 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import assert from "node:assert"; import { parseConnectionString } from "../../../src/common/index.js"; +import { describe, it, assert } from "vitest"; describe("Helper methods", function () { describe("parseConnectionString", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts index 348eeccd9118..3d11684ed805 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts @@ -3,6 +3,7 @@ import assert from "node:assert"; import { QueryRange } from "../../../src/routing/index.js"; import { createCompleteRoutingMap } from "../../../src/routing/CollectionRoutingMapFactory.js"; +import { describe, it, assert } from "vitest"; describe("InMemoryCollectionRoutingMap Tests", function () { describe("getOverlappingRanges", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts index 6378ab65407a..a36566dc336f 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts @@ -3,6 +3,8 @@ import assert from "node:assert"; import { Constants } from "../../../src/common/constants.js"; import { getUserAgent } from "../../../src/common/platform.js"; +import { describe, it, assert } from "vitest"; + // eslint-disable-next-line @typescript-eslint/no-require-imports const packageJson = require("../../../package.json"); const packageVersion = packageJson["version"]; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts index 0bcc9a8f4266..985bbdf0be01 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts @@ -7,6 +7,7 @@ import { masterKey, userSasTokenKey } from "../../public/common/_fakeTestSecrets import { SasTokenPermissionKind } from "../../../src/common/index.js"; import { createAuthorizationSasToken } from "../../../src/utils/SasToken.js"; import type { SasTokenProperties } from "../../../src/client/SasToken/SasTokenProperties.js"; +import { describe, it, assert } from "vitest"; describe.skip("SAS Token Authorization", function () { const sasTokenProperties = { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts index ef32f89b3df4..138870dcf55e 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts @@ -5,6 +5,7 @@ import { Constants, OperationType, ResourceType } from "../../../src/common/inde import type { CosmosHeaders } from "../../../src/queryExecutionContext/CosmosHeaders.js"; import { SessionContainer } from "../../../src/session/sessionContainer.js"; import type { SessionContext } from "../../../src/session/SessionContext.js"; +import { describe, it, assert } from "vitest"; describe("SessionContainer", function () { const collectionLink = "dbs/testDatabase/colls/testCollection"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts index 3fbc53f248f6..2cd9bdb56eab 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts @@ -5,6 +5,7 @@ import type { ClientContext } from "../../../src/ClientContext.js"; import { PartitionKeyRangeCache, QueryRange, SmartRoutingMapProvider } from "../../../src/routing/index.js"; import { MockedClientContext } from "../../public/common/MockClientContext.js"; import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("Smart Routing Map Provider OverlappingRanges", function () { const containerLink = "dbs/7JZZAA==/colls/7JZZAOS-JQA=/"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts index 89e5584d5fa1..cf58149b4f06 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts @@ -12,6 +12,7 @@ import { StatusCodes } from "../../../src/common/statusCodes.js"; import { TimeoutError } from "../../../src/request/TimeoutError.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("TimeoutFailoverRetryPolicy", function () { const databaseAccountBody: any = { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts index d9059911acfe..1878e26e0779 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts @@ -9,6 +9,7 @@ import { calculateObjectSizeInBytes, splitBatchBasedOnBodySize, } from "../../../../src/utils/batch.js"; +import { describe, it, assert } from "vitest"; const operationSkeleton: Operation = { operationType: BulkOperationType.Create, diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts index 6ba48aa8ef14..c49a20c8be82 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import assert from "node:assert"; import { sanitizeEndpoint } from "../../../../src/utils/checkURL.js"; +import { describe, it, assert } from "vitest"; describe("URL utils", function () { describe("sanitizeEndpoint", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts index 09fa3444e5b5..f723cea28b4c 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import assert from "node:assert"; import { NonStreamingOrderByMap } from "../../../../src/utils/nonStreamingOrderByMap.js"; +import { describe, it, assert } from "vitest"; describe("NonStreamingOrderByMap", () => { it("should insert items", () => { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts index 5954d22eaec5..b2342839326a 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import assert from "node:assert"; import { FixedSizePriorityQueue } from "../../../../src/utils/fixedSizePriorityQueue.js"; +import { describe, it, assert } from "vitest"; describe("FixedSizePriorityQueue", () => { it("should enqueue items", () => { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts index ad6ff4b73a8e..6d945b85ac26 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts @@ -3,6 +3,7 @@ import assert from "node:assert"; import { validateOffer } from "../../../../src/utils/offers.js"; import type { ContainerRequest } from "../../../../src/index.js"; +import { describe, it, assert } from "vitest"; describe("Offer utils", function () { describe("validateOffer", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts index 72c1cf9b617b..82dfe5e69b5f 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts @@ -3,6 +3,7 @@ import assert from "node:assert"; import { supportedQueryFeaturesBuilder } from "../../../../src/utils/supportedQueryFeaturesBuilder.js"; import type { FeedOptions } from "../../../../src/request/FeedOptions.js"; +import { describe, it, assert } from "vitest"; describe("validate supportedQueryFeaturesBuilder", function () { it("should contain nonStreamingOrderBy feature", () => { diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts index 6b7e7bd19620..a478cea486a0 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts @@ -30,7 +30,6 @@ import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import type { DatabaseRequest } from "../../../src/index.js"; import type { ContainerRequest } from "../../../src/index.js"; -import { AssertionError, expect } from "chai"; import { DiagnosticNodeInternal, DiagnosticNodeType, @@ -38,6 +37,7 @@ import { import type { ExtractPromise } from "../../../src/utils/diagnostics.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; +import { assert } from "vitest"; const defaultRoutingGatewayPort: string = ":8081"; const defaultComputeGatewayPort: string = ":8903"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts index f7bdf3904ae4..492114588059 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts @@ -10,6 +10,7 @@ import { import { getTestDatabase } from "../common/TestHelpers.js"; import type { Database } from "../../../src/client/Database/Database.js"; import type { Container } from "../../../src/client/index.js"; +import { describe, it, assert } from "vitest"; // Skipping these tests as they are not supported by public emulator describe("Vector search feature", async () => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts index 604f74bcf186..115900dd928f 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import { CosmosClient, PermissionMode } from "../../../src/index.js"; import type { PermissionDefinition } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; @@ -12,6 +11,7 @@ import { getTestDatabase, removeAllDatabases, } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts index e665228deeb4..4302f2f6f509 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import { Agent } from "node:http"; import { CosmosClient } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; @@ -14,6 +13,7 @@ import { } from "../common/TestHelpers.js"; import { UsernamePasswordCredential } from "@azure/identity"; import { defaultConnectionPolicy } from "../../../src/documents/index.js"; +import { describe, it, assert } from "vitest"; describe("Client Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 200000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts index 23b55385ef5a..f0dad900d48b 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts @@ -5,6 +5,7 @@ import type { ComputedProperty } from "../../../src/documents/ComputedProperty.j import type { IndexingPolicy } from "../../../src/documents/IndexingPolicy.js"; import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; import type { Container } from "../../../src/client/Container/Container.js"; +import { describe, it, assert } from "vitest"; // As of the current emulator release (March 23), computed properties are not supported, // hence, we are temporarily excluding these tests. diff --git a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts index 9798fb1d0ef5..475452f04b79 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import { removeAllDatabases, getTestContainer, testForDiagnostics } from "../common/TestHelpers.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; +import { describe, it, assert } from "vitest"; describe("Conflicts", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts index d489bb7b26a9..092456e2540f 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { ContainerResponse, PartitionKeyDefinition } from "../../../src/index.js"; import { Constants, @@ -24,6 +23,7 @@ import { } from "../common/TestHelpers.js"; import { SpatialType } from "../../../src/index.js"; import { GeospatialType } from "../../../src/index.js"; +import { describe, it, assert } from "vitest"; describe("Containers", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts index 7fd31e526a8b..d376c9098931 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { DatabaseDefinition, Database } from "../../../src/index.js"; import { CosmosClient } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; @@ -14,6 +13,7 @@ import { testForDiagnostics, } from "../common/TestHelpers.js"; import type { DatabaseRequest } from "../../../src/index.js"; +import { describe, it, assert } from "vitest"; const client = new CosmosClient({ endpoint, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts index 9ab5ffeaea80..2960ab1cf441 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Context } from "mocha"; -import type { Suite } from "mocha"; import { CosmosClient, OperationType } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { testForDiagnostics } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; const client = new CosmosClient({ endpoint, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts index ca1812d9afce..60ba73c5283f 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts @@ -4,6 +4,7 @@ import assert from "node:assert"; import type { ExecutionContext } from "../../../../src/queryExecutionContext/index.js"; import { NonStreamingOrderByDistinctEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js"; import type { QueryInfo } from "../../../../src/request/ErrorResponse.js"; +import { describe, it, assert } from "vitest"; describe("NonStreamingOrderByDistinctEndpointComponent", () => { it("should initialize correctly with sort orders and priority queue buffer size", () => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts index 0f9fa68ac9b4..49c11f9ee373 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts @@ -3,6 +3,7 @@ import assert from "node:assert"; import type { ExecutionContext } from "../../../../src/queryExecutionContext/index.js"; import { NonStreamingOrderByEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js"; +import { describe, it, assert } from "vitest"; describe("NonStreamingOrderByEndpointComponent", () => { it("should initialize correctly with sort orders and priority queue buffer size", () => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts index aa3cb8ef8d23..227331d0cc97 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts @@ -9,6 +9,7 @@ import * as fakeTimers from "@sinonjs/fake-timers"; import assert from "node:assert"; import { createDummyDiagnosticNode } from "../common/TestHelpers.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; +import { describe, it, assert } from "vitest"; const locationUnavailabilityExpiratationTime = 6 * 60 * 1000; const headers = { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts index 4845433ef7e8..b50db4e1a8de 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts @@ -11,6 +11,7 @@ import { PartitionKeyKind } from "../../../../src/documents/index.js"; import { endpoint } from "../../common/_testConfig.js"; import { masterKey } from "../../common/_fakeTestSecrets.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; +import { describe, it, assert } from "vitest"; describe("test batch operations", function () { describe("v2 multi partition container", async function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts index 412c7b3c39fa..0dc0e7a26927 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts @@ -28,6 +28,7 @@ import { endpoint } from "../../common/_testConfig.js"; import { masterKey } from "../../common/_fakeTestSecrets.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; import { SubStatusCodes } from "../../../../src/common/index.js"; +import { describe, it, assert } from "vitest"; describe("test bulk operations", async function () { describe("Check size based splitting of batches", function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts index f3417dbef6af..45cf73a7e62b 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { Container, ContainerDefinition, @@ -31,6 +30,7 @@ import type { PartitionKey, PartitionKeyDefinition } from "../../../../src/docum import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../../src/documents/index.js"; import { PriorityLevel } from "../../../../src/documents/PriorityLevel.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; +import { describe, it, assert } from "vitest"; /** * Tests Item api. diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts index aba731af9694..e5486e0d49d8 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { Container, CosmosClient } from "../../../../src/index.js"; import { getTestContainer, @@ -9,6 +8,7 @@ import { defaultClient, defaultComputeGatewayClient, } from "../../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; interface ItemPayload { id?: string; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts index d80ead89bec8..48f26d0a9809 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts @@ -8,7 +8,7 @@ import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { ResourceType, HTTPMethod, StatusCodes } from "../../../src/index.js"; -import { expect } from "chai"; +import { describe, it, assert } from "vitest"; const plugins: PluginConfig[] = [ { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts index 736af41c212e..28110b7d866a 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Context } from "mocha"; -import type { Suite } from "mocha"; import { Constants, CosmosClient } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; const client = new CosmosClient({ endpoint, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts index d4d3cd7ddf87..83de0fbcaa08 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import { PermissionMode } from "../../../src/index.js"; import type { PermissionDefinition } from "../../../src/index.js"; import { @@ -10,6 +9,7 @@ import { removeAllDatabases, replaceOrUpsertPermission, } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts index 4c5351cdd37a..80814c97e8cc 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts @@ -8,8 +8,8 @@ import type { Plugin, Next, PluginConfig } from "../../../src/index.js"; import * as assert from "node:assert"; import type { DiagnosticNodeInternal } from "../../../src/diagnostics/DiagnosticNodeInternal.js"; -import { expect } from "chai"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; +import { describe, it, assert } from "vitest"; describe("Plugin", function () { it("should handle all requests", async function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts index 863418cb638d..e782404b0b7d 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { ContainerDefinition } from "../../../src/index.js"; import { CosmosClient } from "../../../src/index.js"; import type { Container } from "../../../src/index.js"; @@ -14,6 +13,7 @@ import { testForDiagnostics, } from "../common/TestHelpers.js"; import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; +import { describe, it, assert } from "vitest"; const client = new CosmosClient({ endpoint, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts index 7fa420166b7a..f9c6af72935b 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts @@ -12,6 +12,7 @@ import { isValidV4UUID, removeAllDatabases, } from "../../public/common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("Correlated Activity Id", function () { this.timeout(process.env.MOCHA_TIMEOUT || 30000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts index 5be5c7de1d51..61627c6155c7 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { Database } from "../../../src/index.js"; import { DataType, IndexKind } from "../../../src/index.js"; import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("Spatial Indexes", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts index 934cc5e142b2..41e4bb428ae1 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Context } from "mocha"; -import type { Suite } from "mocha"; import { Constants } from "../../../src/index.js"; import type { Container, StoredProcedureDefinition } from "../../../src/index.js"; import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; @@ -12,6 +10,7 @@ import { getTestDatabase, removeAllDatabases, } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; // Used for sproc declare let getContext: any; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts index 9e7af799eab7..8aefa6f751d0 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import { TriggerOperation, TriggerType } from "../../../src/index.js"; import type { TriggerDefinition, Container } from "../../../src/index.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; const notFoundErrorCode = 404; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts index a1e54f6fbc93..f81bb78efa8c 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { Container, ContainerDefinition, Database } from "../../../src/index.js"; import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; import { StatusCodes } from "../../../src/index.js"; +import { describe, it, assert } from "vitest"; async function sleep(time: number): Promise { return new Promise((resolve) => { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts index 8408b20ccefe..aee2d55888ac 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { UserDefinedFunctionDefinition, Container } from "../../../src/index.js"; import { removeAllDatabases, getTestContainer } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("User Defined Function", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts index 4714cfe1ec7e..c5831f49a77b 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { UserDefinition } from "../../../src/index.js"; import { createOrUpsertUser, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("NodeJS CRUD Tests", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts index 6c22623cb1c6..b8c930673c3a 100644 --- a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts @@ -2,8 +2,9 @@ // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import { IndexMetricWriter, IndexUtilizationInfo } from "../../src/indexMetrics/index.js"; +import { describe, it, assert } from "vitest"; + describe("Test Index Metrics Writer", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts index 682ca3f66852..00946ebc2d46 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { Container, ContainerDefinition } from "../../../src/index.js"; import { IndexingMode } from "../../../src/index.js"; import { DataType, IndexKind } from "../../../src/index.js"; @@ -10,7 +9,7 @@ import type { SqlQuerySpec } from "../../../src/index.js"; import type { FeedOptions } from "../../../src/index.js"; import { TestData } from "../common/TestData.js"; import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; -import { expect } from "chai"; +import { describe, it, assert } from "vitest"; describe("Aggregate Query", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts index 6572c93f92d1..da41bc9a73d1 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts @@ -4,7 +4,7 @@ import type { Container, ContainerDefinition } from "../../../../src/index.js"; import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../../common/TestHelpers.js"; import assert from "node:assert"; import groupBySnapshot from "./groupBy.snapshot.js"; -import type { Context } from "mocha"; +import { describe, it, assert } from "vitest"; const options = { maxItemCount: 100, diff --git a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts index da2d9bd68baf..2e65680613bb 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { Container } from "../../../src/index.js"; import { CosmosClient, PermissionMode } from "../../../src/index.js"; import type { Database } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("Authorization", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 10000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts index a30f2b17815f..f354f3f4ded5 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { RequestOptions } from "../../../src/index.js"; import type { Container, ContainerDefinition } from "../../../src/index.js"; import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe("Change Feed Iterator", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts index b8d4934a29da..75411853dc9c 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { ChangeFeedIteratorOptions, RequestOptions } from "../../../src/index.js"; import { ChangeFeedStartFrom, @@ -22,6 +21,7 @@ import { import { FeedRangeInternal } from "../../../src/client/ChangeFeed/FeedRange.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { StatusCodes } from "../../../src/common/statusCodes.js"; +import { describe, it, assert } from "vitest"; describe("Change Feed Iterator", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts index 86e0e0a5cc74..bcc93a05e4b1 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts @@ -7,6 +7,7 @@ import { masterKey } from "../common/_fakeTestSecrets.js"; import { PluginOn } from "../../../src/index.js"; import { TimeoutErrorCode } from "../../../src/request/TimeoutError.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; +import { describe, it, assert } from "vitest"; const endpoint = "https://failovertest.documents.azure.com/"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts index e049d566fc53..cd4c3812880b 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import * as util from "node:util"; import type { Container, ContainerDefinition } from "../../../src/index.js"; import { DataType, IndexKind } from "../../../src/index.js"; @@ -14,6 +13,7 @@ import { generateDocuments, } from "../common/TestHelpers.js"; import type { FeedResponse, FeedOptions } from "../../../src/index.js"; +import { describe, it, assert } from "vitest"; function compare(key: string) { return function (a: any, b: any): number { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts index b552e85e7130..3f8976954fd2 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import { IndexingMode } from "../../../src/index.js"; import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; const testDoc = { id: "ABC", diff --git a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts index 7fb78a0fa2fb..4dad20aa38cb 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import assert from "node:assert"; import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; +import { describe, it, assert } from "vitest"; describe("extractPartitionKey", function () { describe("With undefined partitionKeyDefinition", function () { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts index c6e3f5fcfd51..c64b43290d86 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ -import { expect } from "chai"; import type { CosmosClientOptions, PluginConfig } from "../../../src/index.js"; import { CosmosClient, PluginOn } from "../../../src/index.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import assert from "node:assert"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; +import { describe, it, assert } from "vitest"; const endpoint = "https://failovertest.documents.azure.com/"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts index 5698a0c66dcf..2687c4b38f12 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - -import { Suite } from "mocha"; import assert from "node:assert"; import { ContainerDefinition, Container } from "../../../src/index.js"; import items from "./text-3properties-1536dimensions-100documents.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; describe.skip("Validate full text search queries", function (this: Suite) { this.timeout(process.env.MOCHA_TIMEOUT || 20000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts index 8007057120c0..4ad90c525867 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts @@ -2,14 +2,12 @@ // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ import assert from "node:assert"; -import type { Suite } from "mocha"; - import { CosmosClient } from "../../../src/index.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import type { PluginConfig, CosmosClientOptions } from "../../../src/index.js"; import { PluginOn } from "../../../src/index.js"; -import { expect } from "chai"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; +import { describe, it, assert } from "vitest"; const endpoint = "https://failovertest.documents.azure.com/"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts index 531c2a79ee7a..cbdc8d886eef 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts @@ -13,6 +13,7 @@ import { VectorEmbeddingDistanceFunction, VectorIndexType, } from "../../../../src/documents/index.js"; +import { describe, it, assert } from "vitest"; describe("Test nonStreaming Queries", function () { this.timeout(process.env.MOCHA_TIMEOUT || 30000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts index abc18cb5249e..794f666119c8 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts @@ -13,6 +13,7 @@ import { VectorEmbeddingDistanceFunction, VectorIndexType, } from "../../../../src/documents/index.js"; +import { describe, it, assert } from "vitest"; describe("Test nonStreaming Queries", function () { this.timeout(process.env.MOCHA_TIMEOUT || 30000); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts index c29d200ca572..fc1c0894bec8 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts @@ -1,4 +1,6 @@ -// Copyright (c) Microsoft Corporation. +import { describe, it, assert } from "vitest"; + +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. // import * as http from "http"; // import { Context } from "mocha"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts index 9cb490496104..db2296d9bfcd 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import assert from "node:assert"; -import type { Suite } from "mocha"; import type { Container, FeedOptions } from "../../../src/index.js"; import { getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; +import { describe, it, assert } from "vitest"; const doc = { id: "myId", pk: "pk" }; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts index ab1b414fbb9a..c4df8e01141f 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts @@ -8,6 +8,7 @@ import { RuntimeExecutionTimes, TimeSpan, } from "../../../src/index.js"; +import { describe, it, assert } from "vitest"; describe("QueryMetrics", function () { // Properties diff --git a/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts index 6826ceedceda..438f529550a1 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts @@ -1,3 +1,5 @@ +import { describe, it, assert } from "vitest"; + // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. // import assert from "assert"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts index 96d7bf4c04d6..356c2bea8e09 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts @@ -9,7 +9,7 @@ import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { SubStatusCodes } from "../../../src/common/index.js"; import assert from "node:assert"; -import { expect } from "chai"; +import { describe, it, assert } from "vitest"; const splitError = new Error("Fake Partition Split") as any; splitError.code = 410; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts index 6fdf93fbd89d..6ac7068b4dea 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts @@ -4,6 +4,7 @@ import assert from "node:assert"; import { CosmosClient } from "../../../src/index.js"; import { getTestDatabase } from "../common/TestHelpers.js"; import https from "node:https"; +import { describe, it, assert } from "vitest"; const endpoint = "https://localhost:8081"; const masterKey = diff --git a/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts index 8495800ce950..ffadf9271a7b 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts @@ -7,7 +7,7 @@ import { CosmosClient } from "../../../src/index.js"; import { addEntropy, removeAllDatabases } from "../common/TestHelpers.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; -import { expect } from "chai"; +import { describe, it, assert } from "vitest"; describe("Timeout", function () { beforeEach(async function () { From 8468ff8c84a8ae78b740a2a343965068fcac53a8 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:11 -0500 Subject: [PATCH 06/45] Migration: Apply codemod: "replaceAssertIsRejected" From 82e7e88f2e752b5a72e011cfed8a19892ba3cafc Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:11 -0500 Subject: [PATCH 07/45] Migration: Apply codemod: "replaceSinonStub" --- sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts index 26cd848afe9d..c0bcad1aa0ad 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts @@ -80,7 +80,7 @@ describe("Testing Credentials integration for Client", function (this: Suite) { } afterEach(function () { - sandbox.restore(); + vi.restoreAllMocks(); }); describe("Client Test With AAD Credentials", function () { let client: CosmosClient; From ebf0412700ee91effa9eddaa4c0e2572406abfe1 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:13 -0500 Subject: [PATCH 08/45] Migration: Apply codemod: "addViHelper" From 3c5385001d1ec66f39bbfd12d575ada3144aed68 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:13 -0500 Subject: [PATCH 09/45] Migration: Apply codemod: "replaceSupportTracing" From bd1b6b629e370f57224a7039cd8d0fae95659fd5 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:14 -0500 Subject: [PATCH 10/45] Migration: Apply codemod: "replaceTestUtils" From e82de5a5b10edd05b9286a1368ca3ea06480c407 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 17:34:18 -0500 Subject: [PATCH 11/45] Migration: rushx format --- sdk/cosmosdb/cosmos/src/ClientContext.ts | 6 +++++- sdk/cosmosdb/cosmos/src/CosmosClient.ts | 5 ++++- sdk/cosmosdb/cosmos/src/client/Database/Database.ts | 7 ++++++- .../cosmos/src/client/Permission/Permissions.ts | 7 ++++++- .../src/client/StoredProcedure/StoredProcedures.ts | 7 ++++++- sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts | 7 ++++++- sdk/cosmosdb/cosmos/src/client/User/Users.ts | 7 ++++++- .../UserDefinedFunction/UserDefinedFunctions.ts | 7 ++++++- .../parallelQueryExecutionContextBase.ts | 5 ++++- sdk/cosmosdb/cosmos/src/queryIterator.ts | 5 ++++- sdk/cosmosdb/cosmos/src/request/request.ts | 7 ++++++- sdk/cosmosdb/cosmos/src/utils/diagnostics.ts | 5 ++++- .../internal/unit/smartRoutingMapProvider.spec.ts | 6 +++++- .../test/public/functional/item/batch.item.spec.ts | 7 ++++++- .../test/public/functional/item/bulk.item.spec.ts | 5 ++++- .../cosmos/test/public/functional/item/item.spec.ts | 5 ++++- .../cosmos/test/public/functional/npcontainer.spec.ts | 7 ++++++- sdk/cosmosdb/cosmos/tsconfig.browser.config.json | 11 ++--------- sdk/cosmosdb/cosmos/tsconfig.json | 8 ++------ 19 files changed, 92 insertions(+), 32 deletions(-) diff --git a/sdk/cosmosdb/cosmos/src/ClientContext.ts b/sdk/cosmosdb/cosmos/src/ClientContext.ts index 4bbcced1a067..23c8252bc908 100644 --- a/sdk/cosmosdb/cosmos/src/ClientContext.ts +++ b/sdk/cosmosdb/cosmos/src/ClientContext.ts @@ -10,7 +10,11 @@ import { getIdFromLink, getPathFromLink, parseLink } from "./common/helper.js"; import { StatusCodes, SubStatusCodes } from "./common/statusCodes.js"; import type { Agent, CosmosClientOptions } from "./CosmosClientOptions.js"; import type { ConnectionPolicy, PartitionKey } from "./documents/index.js"; -import { ConsistencyLevel, DatabaseAccount, convertToInternalPartitionKey } from "./documents/index.js"; +import { + ConsistencyLevel, + DatabaseAccount, + convertToInternalPartitionKey, +} from "./documents/index.js"; import type { GlobalEndpointManager } from "./globalEndpointManager.js"; import type { PluginConfig } from "./plugins/Plugin.js"; import { PluginOn, executePlugins } from "./plugins/Plugin.js"; diff --git a/sdk/cosmosdb/cosmos/src/CosmosClient.ts b/sdk/cosmosdb/cosmos/src/CosmosClient.ts index 4c5396fc713f..e9c92f7ca181 100644 --- a/sdk/cosmosdb/cosmos/src/CosmosClient.ts +++ b/sdk/cosmosdb/cosmos/src/CosmosClient.ts @@ -8,7 +8,10 @@ import { Constants } from "./common/constants.js"; import { getUserAgent } from "./common/platform.js"; import type { CosmosClientOptions } from "./CosmosClientOptions.js"; import type { ClientConfigDiagnostic } from "./CosmosDiagnostics.js"; -import { determineDiagnosticLevel, getDiagnosticLevelFromEnvironment } from "./diagnostics/index.js"; +import { + determineDiagnosticLevel, + getDiagnosticLevelFromEnvironment, +} from "./diagnostics/index.js"; import type { DiagnosticNodeInternal } from "./diagnostics/DiagnosticNodeInternal.js"; import { DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal.js"; import type { DatabaseAccount } from "./documents/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Database/Database.ts b/sdk/cosmosdb/cosmos/src/client/Database/Database.ts index 486884331a83..1b3e198c06ce 100644 --- a/sdk/cosmosdb/cosmos/src/client/Database/Database.ts +++ b/sdk/cosmosdb/cosmos/src/client/Database/Database.ts @@ -1,7 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import type { ClientContext } from "../../ClientContext.js"; -import { createDatabaseUri, getIdFromLink, getPathFromLink, ResourceType } from "../../common/index.js"; +import { + createDatabaseUri, + getIdFromLink, + getPathFromLink, + ResourceType, +} from "../../common/index.js"; import type { CosmosClient } from "../../CosmosClient.js"; import type { RequestOptions } from "../../request/index.js"; import { Container, Containers } from "../Container/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts b/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts index 70f5e146774b..44a4359ac49a 100644 --- a/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts +++ b/sdk/cosmosdb/cosmos/src/client/Permission/Permissions.ts @@ -2,7 +2,12 @@ // Licensed under the MIT License. import type { ClientContext } from "../../ClientContext.js"; import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import { + getIdFromLink, + getPathFromLink, + isResourceValid, + ResourceType, +} from "../../common/index.js"; import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; import { QueryIterator } from "../../queryIterator.js"; import type { FeedOptions, RequestOptions } from "../../request/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts index c67960e0d384..cf43ec86de50 100644 --- a/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts +++ b/sdk/cosmosdb/cosmos/src/client/StoredProcedure/StoredProcedures.ts @@ -2,7 +2,12 @@ // Licensed under the MIT License. import type { ClientContext } from "../../ClientContext.js"; import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import { + getIdFromLink, + getPathFromLink, + isResourceValid, + ResourceType, +} from "../../common/index.js"; import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; import { QueryIterator } from "../../queryIterator.js"; import type { FeedOptions, RequestOptions } from "../../request/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts b/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts index 344bba5d8850..472914708444 100644 --- a/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts +++ b/sdk/cosmosdb/cosmos/src/client/Trigger/Triggers.ts @@ -2,7 +2,12 @@ // Licensed under the MIT License. import type { ClientContext } from "../../ClientContext.js"; import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import { + getIdFromLink, + getPathFromLink, + isResourceValid, + ResourceType, +} from "../../common/index.js"; import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; import { QueryIterator } from "../../queryIterator.js"; import type { FeedOptions, RequestOptions } from "../../request/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/User/Users.ts b/sdk/cosmosdb/cosmos/src/client/User/Users.ts index 7055194cf4f9..fb3b6fd7ae0f 100644 --- a/sdk/cosmosdb/cosmos/src/client/User/Users.ts +++ b/sdk/cosmosdb/cosmos/src/client/User/Users.ts @@ -2,7 +2,12 @@ // Licensed under the MIT License. import type { ClientContext } from "../../ClientContext.js"; import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import { + getIdFromLink, + getPathFromLink, + isResourceValid, + ResourceType, +} from "../../common/index.js"; import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; import { QueryIterator } from "../../queryIterator.js"; import type { FeedOptions, RequestOptions } from "../../request/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts index 47e00e0476ca..c8c9bae2cdae 100644 --- a/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts +++ b/sdk/cosmosdb/cosmos/src/client/UserDefinedFunction/UserDefinedFunctions.ts @@ -2,7 +2,12 @@ // Licensed under the MIT License. import type { ClientContext } from "../../ClientContext.js"; import type { DiagnosticNodeInternal } from "../../diagnostics/DiagnosticNodeInternal.js"; -import { getIdFromLink, getPathFromLink, isResourceValid, ResourceType } from "../../common/index.js"; +import { + getIdFromLink, + getPathFromLink, + isResourceValid, + ResourceType, +} from "../../common/index.js"; import type { SqlQuerySpec } from "../../queryExecutionContext/index.js"; import { QueryIterator } from "../../queryIterator.js"; import type { FeedOptions, RequestOptions } from "../../request/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts index 474e53a33cef..c6d8100dc5e7 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/parallelQueryExecutionContextBase.ts @@ -15,7 +15,10 @@ import { DocumentProducer } from "./documentProducer.js"; import type { ExecutionContext } from "./ExecutionContext.js"; import { getInitialHeader, mergeHeaders } from "./headerUtils.js"; import type { SqlQuerySpec } from "./SqlQuerySpec.js"; -import { DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal.js"; +import { + DiagnosticNodeInternal, + DiagnosticNodeType, +} from "../diagnostics/DiagnosticNodeInternal.js"; import { addDignosticChild } from "../utils/diagnostics.js"; import { MetadataLookUpType } from "../CosmosDiagnostics.js"; import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel.js"; diff --git a/sdk/cosmosdb/cosmos/src/queryIterator.ts b/sdk/cosmosdb/cosmos/src/queryIterator.ts index eb252c5914be..dbcc4d2c23c4 100644 --- a/sdk/cosmosdb/cosmos/src/queryIterator.ts +++ b/sdk/cosmosdb/cosmos/src/queryIterator.ts @@ -3,7 +3,10 @@ /// import type { ClientContext } from "./ClientContext.js"; -import { DiagnosticNodeInternal, DiagnosticNodeType } from "./diagnostics/DiagnosticNodeInternal.js"; +import { + DiagnosticNodeInternal, + DiagnosticNodeType, +} from "./diagnostics/DiagnosticNodeInternal.js"; import { getPathFromLink, ResourceType, StatusCodes } from "./common/index.js"; import type { CosmosHeaders, diff --git a/sdk/cosmosdb/cosmos/src/request/request.ts b/sdk/cosmosdb/cosmos/src/request/request.ts index 695706454175..191aae33d6b1 100644 --- a/sdk/cosmosdb/cosmos/src/request/request.ts +++ b/sdk/cosmosdb/cosmos/src/request/request.ts @@ -1,7 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { setAuthorizationHeader } from "../auth.js"; -import { Constants, HTTPMethod, jsonStringifyAndEscapeNonASCII, ResourceType } from "../common/index.js"; +import { + Constants, + HTTPMethod, + jsonStringifyAndEscapeNonASCII, + ResourceType, +} from "../common/index.js"; import type { CosmosClientOptions } from "../CosmosClientOptions.js"; import type { PartitionKeyInternal } from "../documents/index.js"; import type { CosmosHeaders } from "../queryExecutionContext/index.js"; diff --git a/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts b/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts index 888df422f48f..c6cae7411db3 100644 --- a/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts +++ b/sdk/cosmosdb/cosmos/src/utils/diagnostics.ts @@ -4,7 +4,10 @@ import type { MetadataLookUpType } from "../CosmosDiagnostics.js"; import { CosmosDiagnostics } from "../CosmosDiagnostics.js"; import type { DiagnosticDataValue } from "../diagnostics/DiagnosticNodeInternal.js"; -import { DiagnosticNodeInternal, DiagnosticNodeType } from "../diagnostics/DiagnosticNodeInternal.js"; +import { + DiagnosticNodeInternal, + DiagnosticNodeType, +} from "../diagnostics/DiagnosticNodeInternal.js"; import type { ClientContext } from "../ClientContext.js"; import { getCurrentTimestampInMs } from "./time.js"; import { CosmosDbDiagnosticLevel } from "../diagnostics/CosmosDbDiagnosticLevel.js"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts index 2cd9bdb56eab..317af09d10db 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts @@ -2,7 +2,11 @@ // Licensed under the MIT License. import assert from "node:assert"; import type { ClientContext } from "../../../src/ClientContext.js"; -import { PartitionKeyRangeCache, QueryRange, SmartRoutingMapProvider } from "../../../src/routing/index.js"; +import { + PartitionKeyRangeCache, + QueryRange, + SmartRoutingMapProvider, +} from "../../../src/routing/index.js"; import { MockedClientContext } from "../../public/common/MockClientContext.js"; import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts index b50db4e1a8de..4093c4527e43 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts @@ -3,7 +3,12 @@ import assert from "node:assert"; import type { Container, OperationResponse } from "../../../../src/index.js"; -import { CosmosClient, OperationType, PatchOperationType, ResourceType } from "../../../../src/index.js"; +import { + CosmosClient, + OperationType, + PatchOperationType, + ResourceType, +} from "../../../../src/index.js"; import { addEntropy, testForDiagnostics } from "../../common/TestHelpers.js"; import type { OperationInput } from "../../../../src/index.js"; import { BulkOperationType } from "../../../../src/index.js"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts index 0dc0e7a26927..ea71cc15e5b4 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts @@ -23,7 +23,10 @@ import type { OperationInput } from "../../../../src/index.js"; import { BulkOperationType } from "../../../../src/index.js"; import { generateOperationOfSize } from "../../../internal/unit/utils/batch.spec.js"; import type { PartitionKey } from "../../../../src/documents/index.js"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../../src/documents/index.js"; +import { + PartitionKeyDefinitionVersion, + PartitionKeyKind, +} from "../../../../src/documents/index.js"; import { endpoint } from "../../common/_testConfig.js"; import { masterKey } from "../../common/_fakeTestSecrets.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts index 45cf73a7e62b..aaf402d1de92 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts @@ -27,7 +27,10 @@ import { import { endpoint } from "../../common/_testConfig.js"; import { masterKey } from "../../common/_fakeTestSecrets.js"; import type { PartitionKey, PartitionKeyDefinition } from "../../../../src/documents/index.js"; -import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../../src/documents/index.js"; +import { + PartitionKeyDefinitionVersion, + PartitionKeyKind, +} from "../../../../src/documents/index.js"; import { PriorityLevel } from "../../../../src/documents/PriorityLevel.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts index 48f26d0a9809..5ce52128f291 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts @@ -2,7 +2,12 @@ // Licensed under the MIT License. /* eslint-disable no-unused-expressions */ import assert from "node:assert"; -import type { Container, PluginConfig, CosmosClientOptions, OperationInput } from "../../../src/index.js"; +import type { + Container, + PluginConfig, + CosmosClientOptions, + OperationInput, +} from "../../../src/index.js"; import { CosmosClient, Constants, PatchOperationType } from "../../../src/index.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; import { endpoint } from "../common/_testConfig.js"; diff --git a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json index b6586181d006..f772e6eb3b76 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json +++ b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json @@ -1,14 +1,7 @@ { "extends": "./.tshy/build.json", - "include": [ - "./src/**/*.ts", - "./src/**/*.mts", - "./test/**/*.spec.ts", - "./test/**/*.mts" - ], - "exclude": [ - "./test/**/node/**/*.ts" - ], + "include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"], + "exclude": ["./test/**/node/**/*.ts"], "compilerOptions": { "outDir": "./dist-test/browser", "rootDir": ".", diff --git a/sdk/cosmosdb/cosmos/tsconfig.json b/sdk/cosmosdb/cosmos/tsconfig.json index 314c7c675ce3..133e19ad75b0 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.json +++ b/sdk/cosmosdb/cosmos/tsconfig.json @@ -11,16 +11,12 @@ "target": "ES2017", "newLine": "LF", "resolveJsonModule": true, - "lib": [ - "es2019" - ], + "lib": ["es2019"], "moduleResolution": "NodeNext", "composite": true, "stripInternal": true, "paths": { - "@azure/cosmos": [ - "./src/index" - ] + "@azure/cosmos": ["./src/index"] }, "rootDir": "." }, From deefef2b703d9c037ba34defa16502172d13cec2 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 19:14:37 -0500 Subject: [PATCH 12/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 25 ++++- sdk/cosmosdb/cosmos/package.json | 21 ++-- .../samples-dev/AlterQueryThroughput.ts | 8 +- sdk/cosmosdb/cosmos/samples-dev/Bulk.ts | 14 +-- .../cosmos/samples-dev/BulkUpdateWithSproc.ts | 3 +- sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts | 3 +- .../ChangeFeedHierarchicalPartitionKey.ts | 3 +- ...ChangeFeedIteratorAllVersionsAndDeletes.ts | 3 +- .../ChangeFeedIteratorLatestVersion.ts | 3 +- .../cosmos/samples-dev/ContainerManagement.ts | 8 +- .../cosmos/samples-dev/DatabaseManagement.ts | 3 +- .../cosmos/samples-dev/Diagnostics.ts | 13 +-- sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts | 7 +- .../samples-dev/HierarchicalPartitioning.ts | 10 +- .../cosmos/samples-dev/IndexManagement.ts | 16 +--- .../cosmos/samples-dev/ItemManagement.ts | 14 +-- .../samples-dev/Query/FullTextSearch.ts | 6 +- .../cosmos/samples-dev/QueryThroughput.ts | 8 +- .../cosmos/samples-dev/SasTokenAuth.ts | 15 +-- .../cosmos/samples-dev/ServerSideScripts.ts | 7 +- .../cosmos/test/internal/session.spec.ts | 32 +++---- sdk/cosmosdb/cosmos/test/mocha.env.ts | 7 -- .../test/public/common/MockClientContext.ts | 1 + .../test/public/common/MockQueryIterator.ts | 1 + .../cosmos/test/public/common/TestData.ts | 1 + .../cosmos/test/public/common/TestHelpers.ts | 14 +-- .../cosmos/test/public/common/setup.ts | 21 ---- .../NonStreamingQueryPolicy.spec.ts | 66 ++++++------- .../public/functional/authorization.spec.ts | 21 ++-- .../test/public/functional/client.spec.ts | 96 +++++++++---------- .../functional/computedProperties.spec.ts | 27 +++--- .../test/public/functional/conflict.spec.ts | 17 ++-- .../test/public/functional/container.spec.ts | 92 +++++++++--------- .../test/public/functional/database.spec.ts | 51 +++++----- .../public/functional/databaseaccount.spec.ts | 9 +- .../functional/globalEndpointManager.spec.ts | 35 +++---- .../public/functional/npcontainer.spec.ts | 11 +-- .../test/public/functional/offer.spec.ts | 17 ++-- .../test/public/functional/permission.spec.ts | 7 +- .../test/public/functional/plugin.spec.ts | 12 +-- .../test/public/functional/query.spec.ts | 80 +++++++--------- .../public/functional/queryIterator.spec.ts | 14 +-- .../test/public/functional/spatial.spec.ts | 13 ++- .../test/public/functional/sproc.spec.ts | 15 ++- .../test/public/functional/trigger.spec.ts | 7 +- .../cosmos/test/public/functional/ttl.spec.ts | 7 +- .../cosmos/test/public/functional/udf.spec.ts | 19 ++-- .../test/public/functional/user.spec.ts | 15 ++- .../cosmos/test/public/indexMetrics.spec.ts | 7 +- .../public/integration/aggregateQuery.spec.ts | 9 +- .../integration/aggregates/groupBy.spec.ts | 10 +- .../public/integration/authorization.spec.ts | 24 +++-- .../public/integration/changeFeed.spec.ts | 26 +++-- .../integration/changeFeedIterator.spec.ts | 84 ++++++++-------- .../public/integration/client.retry.spec.ts | 11 ++- .../public/integration/crossPartition.spec.ts | 82 ++++++++-------- .../test/public/integration/encoding.spec.ts | 14 ++- .../integration/extractPartitionKey.spec.ts | 2 +- .../test/public/integration/failover.spec.ts | 5 +- .../public/integration/fullTextSearch.spec.ts | 16 ++-- .../public/integration/multiregion.spec.ts | 13 +-- .../test/public/integration/proxy.spec.ts | 5 +- .../test/public/integration/query.spec.ts | 52 +++++----- .../public/integration/queryMetrics.spec.ts | 2 +- .../test/public/integration/retry.spec.ts | 14 +-- .../test/public/integration/split.spec.ts | 7 +- .../integration/sslVerification.spec.ts | 8 +- .../test/public/integration/timeout.spec.ts | 13 ++- sdk/cosmosdb/cosmos/test/tsconfig.json | 19 ---- sdk/cosmosdb/cosmos/tsconfig.json | 1 + 70 files changed, 599 insertions(+), 723 deletions(-) delete mode 100644 sdk/cosmosdb/cosmos/test/mocha.env.ts delete mode 100644 sdk/cosmosdb/cosmos/test/public/common/setup.ts delete mode 100644 sdk/cosmosdb/cosmos/test/tsconfig.json diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b171ab79c63a..8e6a664fa94f 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -19807,7 +19807,7 @@ packages: dev: false file:projects/cosmos.tgz: - resolution: {integrity: sha512-l5rV9Yu/fjvbShmu02iwVLOdLChhvsru7Ke7u8yG6uoPVQJK8Ruto5Y6gWeWaNiJ57yHruwQ+8iOiJj+fHuGuQ==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-VCukeh0cbGECw36Kqu24/Mv+Iit84c8qLx/Yy2K4z/3asAKsCj8ZzFEiVGRg6+wGqw2a30RyVseWQ+rUp6F31g==, tarball: file:projects/cosmos.tgz} name: '@rush-temp/cosmos' version: 0.0.0 dependencies: @@ -19821,6 +19821,8 @@ packages: '@types/sinon': 17.0.3 '@types/sinonjs__fake-timers': 8.1.5 '@types/underscore': 1.13.0 + '@vitest/browser': 2.1.8(@types/node@18.19.67)(playwright@1.49.0)(typescript@5.6.3)(vitest@2.1.8) + '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) chai: 4.3.10 dotenv: 16.4.5 eslint: 9.16.0 @@ -19829,6 +19831,7 @@ packages: jsbi: 4.3.0 mocha: 10.8.2 nock: 13.5.6 + playwright: 1.49.0 priorityqueuejs: 2.0.0 requirejs: 2.3.7 semaphore: 1.1.0 @@ -19837,11 +19840,27 @@ packages: ts-node: 10.9.2(@types/node@18.19.67)(typescript@5.6.3) tslib: 2.8.1 typescript: 5.6.3 + vitest: 2.1.8(@types/node@18.19.67)(@vitest/browser@2.1.8) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - utf-8-validate + - vite + - webdriverio dev: false file:projects/create-microsoft-playwright-testing.tgz: diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index cd39f82e342d..841cbcb6ea41 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -40,8 +40,7 @@ "scripts": { "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", "build:samples": "echo Obsolete.", - "build:src": "echo Using TypeScript && tsc --version && tsc -b --pretty", - "build:test": "tsc", + "build:test": "echo", "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}\"", @@ -77,28 +76,25 @@ "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/core-rest-pipeline": "^1.18.0", + "@azure/core-tracing": "^1.2.0", + "@azure/core-util": "^1.11.0", "fast-json-stable-stringify": "^2.1.0", "jsbi": "^4.3.0", "priorityqueuejs": "^2.0.0", "semaphore": "^1.1.0", - "tslib": "^2.6.2" + "tslib": "^2.8.1" }, "devDependencies": { "@azure-tools/test-utils-vitest": "^1.0.0", "@azure/dev-tool": "^1.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0", - "@azure/identity": "^4.0.1", + "@azure/identity": "^4.5.0", "@azure/logger": "^1.0.0", - "@sinonjs/fake-timers": "^11.0.0", "@types/debug": "^4.1.4", "@types/node": "^18.0.0", - "@types/priorityqueuejs": "^1.0.1", - "@types/semaphore": "^1.1.0", - "@types/sinonjs__fake-timers": "~8.1.2", - "@types/underscore": "^1.8.8", + "@types/priorityqueuejs": "^1.0.4", + "@types/semaphore": "^1.1.4", "@vitest/browser": "^2.1.8", "@vitest/coverage-istanbul": "^2.1.8", "dotenv": "^16.0.0", @@ -106,7 +102,6 @@ "execa": "^5.0.0", "nock": "^13.5.4", "playwright": "^1.49.0", - "requirejs": "^2.3.5", "typescript": "~5.6.2", "vitest": "^2.1.8" }, diff --git a/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts b/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts index 4bc4da53ffc4..0fdb57c58321 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/AlterQueryThroughput.ts @@ -5,18 +5,18 @@ * @summary Updates a container offer to change query throughput. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { finish, handleError, logStep, logSampleHeader } from "./Shared/handleError.js"; -import { - CosmosClient, +import type { OfferDefinition, Resource, ContainerDefinition, DatabaseDefinition, FeedResponse, } from "@azure/cosmos"; +import { CosmosClient } from "@azure/cosmos"; + const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const databaseId = process.env.COSMOS_DATABASE || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts b/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts index 19a8e4bdafee..b9984dd77468 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/Bulk.ts @@ -5,17 +5,11 @@ * @summary Shows a simple bulk call with each BulkOperation type. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { handleError, finish, logStep } from "./Shared/handleError.js"; -import { - BulkOperationType, - CosmosClient, - OperationInput, - PatchOperation, - PatchOperationType, -} from "@azure/cosmos"; +import type { OperationInput } from "@azure/cosmos"; +import { BulkOperationType, CosmosClient, PatchOperationType } from "@azure/cosmos"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore const key = process.env.COSMOS_KEY || ""; @@ -28,7 +22,7 @@ function getEntropy(): string { return `${Math.floor(Math.random() * 10000)}`; } -async function run() { +async function run(): Promise { const containerId = "bulkContainerV2"; const client = new CosmosClient({ key: key, diff --git a/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts b/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts index b012fb269812..40b0572181c8 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/BulkUpdateWithSproc.ts @@ -5,8 +5,7 @@ * @summary Bulk Updates documents with a Stored Procedure. Prefer `container.items().bulk()` to this behavior. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError.js"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts index e136d54c0b67..ddd3bdffea86 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeed.ts @@ -5,8 +5,7 @@ * @summary Demonstrates using a ChangeFeed. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { finish, handleError, logSampleHeader } from "./Shared/handleError.js"; import { CosmosClient } from "@azure/cosmos"; diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts index 29c5e06b4d56..d4a11acec13b 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedHierarchicalPartitionKey.ts @@ -5,8 +5,7 @@ * @summary Demonstrates using a ChangeFeed for a partition key */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { finish, handleError, logSampleHeader } from "../Shared/handleError.js"; import { diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts index c355520d5c95..c9823f8f30c7 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorAllVersionsAndDeletes.ts @@ -5,8 +5,7 @@ * @summary Demonstrates using a ChangeFeed in AllVersionsAndDeletes mode for entire container, a partition key, and an epk range */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { finish, handleError, logSampleHeader, logStep } from "../Shared/handleError.js"; import { diff --git a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts index 38ec46603fd6..073ec6c1d9fd 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ChangeFeedIterator/ChangeFeedIteratorLatestVersion.ts @@ -5,8 +5,7 @@ * @summary Demonstrates using a ChangeFeed in LatestVersion mode for entire container, a partition key, and an epk range */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { finish, handleError, logSampleHeader, logStep } from "../Shared/handleError.js"; import { diff --git a/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts index bda9b9bab69f..3950b285eb4e 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts @@ -5,19 +5,17 @@ * @summary Demonstrates container create, read, delete and reading all containers belonging to a database. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { finish, handleError, logStep, logSampleHeader } from "./Shared/handleError.js"; +import type { ContainerDefinition, IndexingPolicy, SpatialIndex } from "@azure/cosmos"; import { - ContainerDefinition, CosmosClient, - IndexingPolicy, - SpatialIndex, VectorEmbeddingDataType, VectorEmbeddingDistanceFunction, VectorIndexType, } from "@azure/cosmos"; + const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const databaseId = process.env.COSMOS_DATABASE || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts index aa6a1ddd7e4c..e3281e12ee6b 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/DatabaseManagement.ts @@ -5,8 +5,7 @@ * @summary Demonstrates database create, read, delete and reading all databases. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { handleError, logStep, logSampleHeader, finish } from "./Shared/handleError.js"; import { CosmosClient } from "@azure/cosmos"; diff --git a/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts b/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts index 975d13c7e1cd..5f96b043fe1f 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/Diagnostics.ts @@ -5,18 +5,11 @@ * @summary Demonstrates usage of CosmosDiagnostic Object. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { handleError, logSampleHeader, finish } from "./Shared/handleError.js"; -import { - CosmosClient, - BulkOperationType, - OperationInput, - Container, - PatchOperationType, - GatewayStatistics, -} from "@azure/cosmos"; +import type { OperationInput, Container, GatewayStatistics } from "@azure/cosmos"; +import { CosmosClient, BulkOperationType, PatchOperationType } from "@azure/cosmos"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts b/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts index 73356e58efef..a3bb10b03a36 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/EntraAuth.ts @@ -5,12 +5,9 @@ * @summary Uses AAD credentials to authenticate with the CosmosClient. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { UsernamePasswordCredential } from "@azure/identity"; -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore import { CosmosClient } from "@azure/cosmos"; import { handleError, finish, logStep } from "./Shared/handleError.js"; @@ -18,7 +15,7 @@ const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const existingContainerId = process.env.COSMOS_CONTAINER || ""; -async function run() { +async function run(): Promise { logStep("Create credential object from @azure/identity"); const credentials = new UsernamePasswordCredential( "fake-tenant-id", diff --git a/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts b/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts index 4a96575dbb68..91ad6156a090 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/HierarchicalPartitioning.ts @@ -5,23 +5,21 @@ * @summary Shows various operations on containers with Hierarchical Partitioning. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { handleError, logSampleHeader, finish } from "./Shared/handleError.js"; +import type { PatchOperation, OperationInput } from "@azure/cosmos"; import { CosmosClient, BulkOperationType, - PatchOperation, PartitionKeyKind, PartitionKeyBuilder, - OperationInput, } from "@azure/cosmos"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const databaseId = process.env.COSMOS_DATABASE || ""; -const containerId = process.env.COSMOS_CONTAINER || ""; + logSampleHeader("Demonstrating Usage of Hierarchical Partitioning."); // Establish a new instance of the CosmosClient to be used throughout this demo @@ -137,7 +135,7 @@ async function run(): Promise { const bulkOperations: OperationInput[] = [ { operationType: BulkOperationType.Create, - //Providing partition key is not necessary while create, it can be automatically derived from resourceBody. + // Providing partition key is not necessary while create, it can be automatically derived from resourceBody. resourceBody: { id: "item3", name: "sample", address: { zip: 345 } }, }, { diff --git a/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts index f6d303758409..436823f71dfd 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/IndexManagement.ts @@ -5,17 +5,11 @@ * @summary Shows various ways to manage indexing items or changing container index policies. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError.js"; -import { - CosmosClient, - IndexKind, - DataType, - ContainerDefinition, - IndexingMode, -} from "@azure/cosmos"; +import type { ContainerDefinition } from "@azure/cosmos"; +import { CosmosClient, IndexKind, DataType, IndexingMode } from "@azure/cosmos"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; @@ -98,8 +92,8 @@ async function run(): Promise { { id: "item2", foo: "bar" }, { indexingDirective: "include" }, ); - if (itemDef) { - console.log(`Item with id ${itemDef.id} 'created`); + if (itemDef2) { + console.log(`Item with id ${itemDef2.id} 'created`); } console.log("Querying all items for a given item should find a result as it was indexed"); diff --git a/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts index 95f9996a9e06..108afcd06098 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts @@ -5,13 +5,12 @@ * @summary Demonstrates item creation, read, delete and reading all items belonging to a container. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError.js"; -import { CosmosClient, PatchOperation, PriorityLevel } from "@azure/cosmos"; - -import { Families } from "./Data/Families.json.js"; +import type { PatchOperation } from "@azure/cosmos"; +import { CosmosClient, PriorityLevel } from "@azure/cosmos"; +import Families from "./Data/Families.json" assert { type: "json" }; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; @@ -177,7 +176,7 @@ async function run(): Promise { } } logStep("Patching an item with single patch operation"); - const patchSource = itemDefList.find((t) => t.id == "AndersenFamily"); + const patchSource = itemDefList.find((t) => t.id === "AndersenFamily"); console.log(JSON.stringify(patchSource)); const replaceOperation: PatchOperation[] = [ { @@ -192,8 +191,9 @@ async function run(): Promise { throw new Error("ID for old offer is undefined"); } const { resource: patchSource1 } = await container.item(patchId!).patch(replaceOperation); - if (patchSource1) + if (patchSource1) { console.log(`Patched ${patchSource.lastName} to new ${patchSource1.lastName}.`); + } logStep("Patching an item with multiple patch operations"); const multipleOperations: PatchOperation[] = [ { diff --git a/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts b/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts index 8c807bef0026..68d528ca6c8f 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/Query/FullTextSearch.ts @@ -5,11 +5,11 @@ * @summary Demonstrates full text search queries. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { finish, handleError, logSampleHeader } from "./../Shared/handleError.js"; -import { CosmosClient, IndexingPolicy } from "@azure/cosmos"; +import type { IndexingPolicy } from "@azure/cosmos"; +import { CosmosClient } from "@azure/cosmos"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const databaseId = process.env.COSMOS_DATABASE || ""; diff --git a/sdk/cosmosdb/cosmos/samples-dev/QueryThroughput.ts b/sdk/cosmosdb/cosmos/samples-dev/QueryThroughput.ts index 84314d434b2d..82ef578a11a8 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/QueryThroughput.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/QueryThroughput.ts @@ -5,16 +5,16 @@ * @summary Demonstrates query throughput scenarios. */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; -import { Container, FeedOptions, SqlQuerySpec, CosmosClient } from "@azure/cosmos"; +import type { Container, FeedOptions, SqlQuerySpec } from "@azure/cosmos"; +import { CosmosClient } from "@azure/cosmos"; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const containerId = process.env.COSMOS_CONTAINER || ""; const databaseId = process.env.COSMOS_DATABASE || ""; -async function run() { +async function run(): Promise { const client = new CosmosClient({ endpoint, key, diff --git a/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts b/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts index c63bd12bb862..b02fee3d5c4c 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/SasTokenAuth.ts @@ -5,21 +5,16 @@ * @summary Demonstrates using SasTokens for granting scoped access to Cosmos resources. *Private feature* */ -import * as dotenv from "dotenv"; -dotenv.config(); - -import { - CosmosClient, - SasTokenProperties, - createAuthorizationSasToken, - SasTokenPermissionKind, -} from "@azure/cosmos"; +import "dotenv/config"; + +import type { SasTokenProperties } from "@azure/cosmos"; +import { CosmosClient, createAuthorizationSasToken, SasTokenPermissionKind } from "@azure/cosmos"; import { handleError, finish, logStep } from "./Shared/handleError.js"; const masterKey = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; const sasToken = "your-sas-token"; -async function run() { +async function run(): Promise { logStep("Create a SasToken object"); const sasTokenProperties = { diff --git a/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts b/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts index 42a735761f0b..788397f383f6 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ServerSideScripts.ts @@ -5,11 +5,12 @@ * @summary Demonstrates using stored procedures for server side run functions */ -import * as dotenv from "dotenv"; -dotenv.config(); +import "dotenv/config"; import { logSampleHeader, logStep, finish, handleError } from "./Shared/handleError.js"; -import { CosmosClient, ErrorResponse, FeedOptions, Item, Resource } from "@azure/cosmos"; +import type { ErrorResponse, FeedOptions, Item, Resource } from "@azure/cosmos"; +import { CosmosClient } from "@azure/cosmos"; + logSampleHeader("Server Side Scripts"); const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts index b59b06ac6738..0f49f33bfb44 100644 --- a/sdk/cosmosdb/cosmos/test/internal/session.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/session.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ -import assert from "node:assert"; + import type { ClientContext, Container, PluginConfig } from "../../src/index.js"; import { PluginOn } from "../../src/index.js"; import { OperationType, ResourceType } from "../../src/common/index.js"; @@ -13,10 +12,10 @@ import { masterKey } from "../public/common/_fakeTestSecrets.js"; import { addEntropy, getTestDatabase, removeAllDatabases } from "../public/common/TestHelpers.js"; import type { RequestContext } from "../../src/index.js"; import type { Response } from "../../src/request/Response.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect, beforeEach } from "vitest"; -describe("New session token", function () { - it("preserves tokens", async function () { +describe("New session token", () => { + it("preserves tokens", async () => { let response: Response; let rqContext: RequestContext; const plugins: PluginConfig[] = [ @@ -72,8 +71,8 @@ describe("New session token", function () { }); }); -describe("Integrated Cache Staleness", async function (this: Suite) { - beforeEach(async function () { +describe("Integrated Cache Staleness", async () => { + beforeEach(async () => { await removeAllDatabases(); }); const dbId = addEntropy("maxIntegratedCacheTestDB"); @@ -143,7 +142,7 @@ describe("Integrated Cache Staleness", async function (this: Suite) { id: containerId, }); - it("Should pass with maxIntegratedCacheStalenessInMs and consistency level set.", async function () { + it("Should pass with maxIntegratedCacheStalenessInMs and consistency level set.", async () => { assert.ok(container.items.create({ id: "1" })); container.item("1").read(itemRequestFeedOptions); container.items @@ -163,18 +162,17 @@ describe("Integrated Cache Staleness", async function (this: Suite) { container.items.query(querySpec, itemRequestFeedOptions).fetchAll(); // Should fail: maxIntegratedCacheStalenessInMs cannot be 0 - this.dedicatedGatewayMaxAge = 0; - await container.read(this.dedicatedGatewayMaxAge); + await container.read({ maxIntegratedCacheStalenessInMs: 0 }); }); }); // This test has to be run against sqlx endpoint -describe.skip("Bypass integrated cache", function (this: Suite) { - beforeEach(async function () { +describe.skip("Bypass integrated cache", () => { + beforeEach(async () => { await removeAllDatabases(); }); - it("Should pass with bypass integrated cache set", async function () { + it("Should pass with bypass integrated cache set", async () => { const dbId = addEntropy("bypassIntegratedCacheTestDB"); const containerId = addEntropy("bypassIntegratedCacheTestContainer"); const client = new CosmosClient({ @@ -200,12 +198,12 @@ describe.skip("Bypass integrated cache", function (this: Suite) { }); // For some reason this test does not pass against the emulator. Skipping it for now -describe.skip("Session Token", function (this: Suite) { - beforeEach(async function () { +describe.skip("Session Token", () => { + beforeEach(async () => { await removeAllDatabases(); }); - it("retries session not found successfully", async function () { + it("retries session not found successfully", async () => { const clientA = new CosmosClient({ endpoint, key: masterKey, @@ -259,7 +257,7 @@ describe.skip("Session Token", function (this: Suite) { }); }); -async function createItem(container: Container) { +async function createItem(container: Container): Promise { const { resource: { id }, } = await container.items.create({ diff --git a/sdk/cosmosdb/cosmos/test/mocha.env.ts b/sdk/cosmosdb/cosmos/test/mocha.env.ts deleted file mode 100644 index 65af76a9424a..000000000000 --- a/sdk/cosmosdb/cosmos/test/mocha.env.ts +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/* - * Specify test tsconfig file for Windows - */ -process.env.TS_NODE_PROJECT = "test/tsconfig.json"; diff --git a/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts b/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts index 428942579b6d..764b63a9eee3 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/MockClientContext.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + import { MockedQueryIterator } from "./MockQueryIterator.js"; export class MockedClientContext { constructor(private partitionKeyRanges: unknown) {} diff --git a/sdk/cosmosdb/cosmos/test/public/common/MockQueryIterator.ts b/sdk/cosmosdb/cosmos/test/public/common/MockQueryIterator.ts index d2d3e9eba856..2cc1afbd56c2 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/MockQueryIterator.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/MockQueryIterator.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + export class MockedQueryIterator { constructor(private results: unknown) {} public async fetchAll(): Promise<{ diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestData.ts b/sdk/cosmosdb/cosmos/test/public/common/TestData.ts index 316cec5f4f37..ebdc0da7f62c 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestData.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestData.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + export class TestData { public numberOfDocuments: number; public field: string; diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts index a478cea486a0..41e9c1417ea3 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ -import assert from "node:assert"; + import type { Container, CosmosDiagnostics, @@ -37,7 +36,8 @@ import { import type { ExtractPromise } from "../../../src/utils/diagnostics.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; -import { assert } from "vitest"; +import { assert, expect } from "vitest"; +import { AssertionError } from "node:assert"; const defaultRoutingGatewayPort: string = ":8081"; const defaultComputeGatewayPort: string = ":8903"; @@ -264,7 +264,7 @@ function compareObjects(test: any, target: any, message: string): void { const errorMessage = `${message} Properties [${mismatchedProperties.join( ", ", )}] did not match.`; - throw new AssertionError(errorMessage); + throw new AssertionError({ message: errorMessage }); } } @@ -481,8 +481,8 @@ export async function bulkReplaceItems( documents.map(async (document) => { const partitionKey = extractPartitionKeys(document, partitionKeyDef); const { resource: doc } = await container.item(document.id, partitionKey).replace(document); - const { _etag: _1, _ts: _2, ...expectedModifiedDocument } = document; // eslint-disable-line @typescript-eslint/no-unused-vars - const { _etag: _4, _ts: _3, ...actualModifiedDocument } = doc; // eslint-disable-line @typescript-eslint/no-unused-vars + const { _etag: _1, _ts: _2, ...expectedModifiedDocument } = document; + const { _etag: _4, _ts: _3, ...actualModifiedDocument } = doc; assert.deepStrictEqual(expectedModifiedDocument, actualModifiedDocument); return doc; }), @@ -640,7 +640,7 @@ export async function assertThrowsAsync(test: () => Promise, error?: any): } catch (e: any) { if (!error || e instanceof error) return "everything is fine"; } - throw new assert.AssertionError({ + throw new AssertionError({ message: "Missing rejection" + (error ? " with " + error.name : ""), }); } diff --git a/sdk/cosmosdb/cosmos/test/public/common/setup.ts b/sdk/cosmosdb/cosmos/test/public/common/setup.ts deleted file mode 100644 index 435d4557b6e9..000000000000 --- a/sdk/cosmosdb/cosmos/test/public/common/setup.ts +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -// eslint-disable-next-line @typescript-eslint/no-require-imports -require("source-map-support").install(); -import util from "node:util"; - -process.on("unhandledRejection", (error: any) => { - if (error.body) { - try { - error.body = JSON.parse(error.body); - } catch (err: any) { - /* NO OP */ - } - } - const nestedError = new Error("Unhandled exception found"); - Object.defineProperty(nestedError, "errors", { value: [error] }); - console.error( - util.formatWithOptions({ colors: true, compact: true, depth: 6 }, "%O", nestedError), - ); -}); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts index 492114588059..b9a92209a350 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { IndexingPolicy, VectorEmbeddingPolicy } from "../../../src/documents/index.js"; import { VectorEmbeddingDataType, @@ -10,18 +10,18 @@ import { import { getTestDatabase } from "../common/TestHelpers.js"; import type { Database } from "../../../src/client/Database/Database.js"; import type { Container } from "../../../src/client/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll, afterAll } from "vitest"; // Skipping these tests as they are not supported by public emulator describe("Vector search feature", async () => { describe("VectorEmbeddingPolicy", async () => { let database: Database; - before(async function () { + beforeAll(async () => { // removeAllDatabases(); database = await getTestDatabase("vector embedding database"); }); - it("validate VectorEmbeddingPolicy", async function () { + it("validate VectorEmbeddingPolicy", async () => { const indexingPolicy: IndexingPolicy = { vectorIndexes: [ { path: "/vector1", type: VectorIndexType.Flat }, @@ -67,7 +67,7 @@ describe("Vector search feature", async () => { }); // skipping the test case for now. Will enable it once the changes are live on backend - it.skip("validate VectorEmbeddingPolicy", async function () { + it.skip("validate VectorEmbeddingPolicy", async () => { const indexingPolicy: IndexingPolicy = { vectorIndexes: [ { path: "/vector1", type: VectorIndexType.Flat }, @@ -139,7 +139,7 @@ describe("Vector search feature", async () => { assert(containerdef.indexingPolicy.vectorIndexes[2].vectorIndexShardKey[0] === "/ZipCode"); }); - it("should fail to create vector indexing policy", async function () { + it("should fail to create vector indexing policy", async () => { const vectorEmbeddingPolicy: VectorEmbeddingPolicy = { vectorEmbeddings: [ { @@ -184,7 +184,7 @@ describe("Vector search feature", async () => { } }); - it("should fail to replace vector indexing policy", async function () { + it("should fail to replace vector indexing policy", async () => { const vectorEmbeddingPolicy: VectorEmbeddingPolicy = { vectorEmbeddings: [ { @@ -218,7 +218,7 @@ describe("Vector search feature", async () => { } }); - it.skip("should fail to create vector embedding policy", async function () { + it.skip("should fail to create vector embedding policy", async () => { // Using too many dimensions const vectorEmbeddingPolicy: VectorEmbeddingPolicy = { vectorEmbeddings: [ @@ -263,7 +263,7 @@ describe("Vector search feature", async () => { } }); - after(async function () { + afterAll(async () => { await database.delete(); }); }); @@ -272,7 +272,7 @@ describe("Vector search feature", async () => { let database: Database; let container: Container; - before(async function () { + beforeAll(async () => { database = await getTestDatabase("vector search database"); const indexingPolicy: IndexingPolicy = { vectorIndexes: [{ path: "/vector1", type: VectorIndexType.Flat }], @@ -321,49 +321,49 @@ describe("Vector search feature", async () => { }); }); - it("should execute vector search query", async function () { + it("should execute vector search query", async () => { // create a queryiterator to run vector search query const query = "SELECT TOP 10 c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'}) AS similarityScore from c ORDER BY VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'})"; await executeQueryAndVerifyOrder(container, query, 3, false); }); - it("should execute distinct vector search query", async function () { + it("should execute distinct vector search query", async () => { // create a queryiterator to run vector search query const query = "SELECT distinct TOP 10 c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'}) AS similarityScore from c ORDER BY VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'})"; await executeQueryAndVerifyOrder(container, query, 3, false); }); - it("should execute vector search query with limit in query", async function () { + it("should execute vector search query with limit in query", async () => { // create a queryiterator to run vector search query const query = "SELECT c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector2, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'}) OFFSET 0 LIMIT 2"; await executeQueryAndVerifyOrder(container, query, 2, true); }); - it("should execute distinct vector search query with limit in query", async function () { + it("should execute distinct vector search query with limit in query", async () => { // create a queryiterator to run vector search query const query = "SELECT distinct c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector2, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'}) OFFSET 0 LIMIT 2"; await executeQueryAndVerifyOrder(container, query, 2, true); }); - it("should execute vector search query with top in query", async function () { + it("should execute vector search query with top in query", async () => { // create a queryiterator to run vector search query const query = "SELECT TOP 2 c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector2, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'})"; await executeQueryAndVerifyOrder(container, query, 2, true); }); - it("should execute distinct vector search query with top in query", async function () { + it("should execute distinct vector search query with top in query", async () => { // create a queryiterator to run vector search query const query = "SELECT distinct TOP 2 c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector2, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'})"; await executeQueryAndVerifyOrder(container, query, 2, true); }); - it("should execute vector search query with filter in query", async function () { + it("should execute vector search query with filter in query", async () => { // create a queryiterator to run vector search query const query = "SELECT c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'}) AS similarityScore from c WHERE VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'}) >= 0.0"; @@ -378,7 +378,7 @@ describe("Vector search feature", async () => { } } }); - it("should execute distinct vector search query with filter in query", async function () { + it("should execute distinct vector search query with filter in query", async () => { // create a queryiterator to run vector search query const query = "SELECT distinct c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'}) AS similarityScore from c WHERE VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'euclidean'}) >= 0.0"; @@ -393,7 +393,7 @@ describe("Vector search feature", async () => { } } }); - after(async function () { + afterAll(async () => { await database.delete(); }); }); @@ -402,7 +402,7 @@ describe("Vector search feature", async () => { let database: Database; let container: Container; - before(async function () { + beforeAll(async () => { database = await getTestDatabase("vector search database"); const indexingPolicy: IndexingPolicy = { vectorIndexes: [{ path: "/vector1", type: VectorIndexType.Flat }], @@ -439,35 +439,35 @@ describe("Vector search feature", async () => { } }); - it("should execute vector search query, large data OFFSET 0 LIMIT 1000", async function () { + it("should execute vector search query, large data OFFSET 0 LIMIT 1000", async () => { // create a queryiterator to run vector search query const query = "SELECT c.id AS Id, VectorDistance([0.0001, 0.0001], c.vector1, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.0001, 0.0001], c.vector1, true, {distanceFunction:'dotProduct'}) OFFSET 0 LIMIT 1000"; await executeQueryAndVerifyOrder(container, query, 1000, true); }); - it("should execute distinct vector search query, large data OFFSET 0 LIMIT", async function () { + it("should execute distinct vector search query, large data OFFSET 0 LIMIT", async () => { // create a queryiterator to run vector search query const query = "SELECT DISTINCT c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.0001, 0.0001], c.vector1, true, {distanceFunction:'dotProduct'}) OFFSET 0 LIMIT 1000"; await executeQueryAndVerifyOrder(container, query, 1000, true); }); - it("should execute vector search query with top in query, large data", async function () { + it("should execute vector search query with top in query, large data", async () => { // create a queryiterator to run vector search query const query = "SELECT TOP 1000 c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.0001, 0.0001], c.vector1, true, {distanceFunction:'dotProduct'})"; await executeQueryAndVerifyOrder(container, query, 1000, true); }); - it("should execute distinct vector search query with top in query, large data", async function () { + it("should execute distinct vector search query with top in query, large data", async () => { // create a queryiterator to run vector search query const query = "SELECT DISTINCT TOP 1000 c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.0001, 0.0001], c.vector1, true, {distanceFunction:'dotProduct'})"; await executeQueryAndVerifyOrder(container, query, 1000, true); }); - it.skip("should execute vector search query, large data with offset 1000 and limit 500", async function () { + it.skip("should execute vector search query, large data with offset 1000 and limit 500", async () => { // create a queryiterator to run vector search query const query = "SELECT c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotProduct'}) AS similarityScore from c ORDER BY VectorDistance([0.0001, 0.0001], c.vector1, true, {distanceFunction:'dotProduct'}) OFFSET 1000 LIMIT 500"; @@ -488,7 +488,7 @@ describe("Vector search feature", async () => { assert.equal(id, 500); }); - it.skip("should execute distinct vector search query, large data with offset 1000 and limit 500", async function () { + it.skip("should execute distinct vector search query, large data with offset 1000 and limit 500", async () => { // create a queryiterator to run vector search query const query = "SELECT DISTINCT c.id AS Id, VectorDistance([0.056419, -0.021141], c.vector1, true, {distanceFunction:'dotproduct'}) AS similarityScore from c ORDER BY VectorDistance([0.0001, 0.0001], c.vector1, true, {distanceFunction:'dotProduct'}) OFFSET 1000 LIMIT 500"; @@ -509,7 +509,7 @@ describe("Vector search feature", async () => { assert.equal(id, 500); }); - after(async function () { + afterAll(async () => { await database.delete(); }); }); @@ -547,11 +547,11 @@ async function executeQueryAndVerifyOrder( describe.skip("Full text search feature", async () => { let database: Database; - before(async function () { + beforeAll(async () => { database = await getTestDatabase("full text search database"); }); - after(async function () { + afterAll(async () => { await database.delete(); }); @@ -569,7 +569,7 @@ describe.skip("Full text search feature", async () => { ], }; - it("validate full text search policy", async function () { + it("validate full text search policy", async () => { const containerName = "full text search container policy"; const { resource: containerdef } = await database.containers.createIfNotExists({ id: containerName, @@ -586,7 +586,7 @@ describe.skip("Full text search feature", async () => { assert(containerdef.fullTextPolicy.fullTextPaths[1].path === "/text2"); }); - it("should execute a full text query", async function () { + it("should execute a full text query", async () => { const containerName = "full text search container 1"; const query = "SELECT TOP 10 * FROM c ORDER BY RANK FullTextScore(c.text1, ['swim', 'run'])"; @@ -607,7 +607,7 @@ describe.skip("Full text search feature", async () => { assert(result.length === 2); }); - it("should execute a full text query with RRF score", async function () { + it("should execute a full text query with RRF score", async () => { const containerName = "full text search container 2"; const vectorEmbeddingPolicy: VectorEmbeddingPolicy = { vectorEmbeddings: [ @@ -655,7 +655,7 @@ describe.skip("Full text search feature", async () => { assert(result.length === 2); }); - it("should execute a full text query with fetchAll", async function () { + it("should execute a full text query with fetchAll", async () => { const containerName = "full text search container 3"; const query = "SELECT TOP 10 * FROM c ORDER BY RANK FullTextScore(c.text, ['swim', 'run'])"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts index 115900dd928f..97f5958541d2 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { CosmosClient, PermissionMode } from "../../../src/index.js"; import type { PermissionDefinition } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; @@ -11,16 +11,15 @@ import { getTestDatabase, removeAllDatabases, } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - describe("Validate Authorization", function () { - it("should handle all the key options", async function () { + describe("Validate Authorization", () => { + it("should handle all the key options", async () => { const clientOptionsKey = new CosmosClient({ endpoint, key: masterKey, @@ -264,19 +263,19 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }; - it("Should do authorization successfully name based", async function () { + it("Should do authorization successfully name based", async () => { await authorizationCRUDTest(false); }); - it("Should do authorization successfully name based with upsert", async function () { + it("Should do authorization successfully name based with upsert", async () => { await authorizationCRUDTest(true); }); - it("Should do authorization over multiple partitions successfully name based", async function () { + it("Should do authorization over multiple partitions successfully name based", async () => { await authorizationCRUDOverMultiplePartitionsTest(); }); - it("should allow deletion of a doc with container token", async function () { + it("should allow deletion of a doc with container token", async () => { const container = await getTestContainer("Validate Authorization container"); const { resource: item } = await container.items.create({ diff --git a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts index 4302f2f6f509..4d82df39432b 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { Agent } from "node:http"; import { CosmosClient } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; @@ -15,11 +15,9 @@ import { UsernamePasswordCredential } from "@azure/identity"; import { defaultConnectionPolicy } from "../../../src/documents/index.js"; import { describe, it, assert } from "vitest"; -describe("Client Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 200000); - - describe("Validate client request timeout", function () { - xit("timeout occurs within expected timeframe", async function () { +describe("Client Tests", { timeout: 200000 }, () => { + describe("Validate client request timeout", () => { + it.skip("timeout occurs within expected timeframe", async () => { // making timeout 1 ms to make sure it will throw // (create database request takes 10ms-15ms to finish on emulator) const client = new CosmosClient({ @@ -42,8 +40,8 @@ describe("Client Tests", function (this: Suite) { }); }); - describe("Constructor", function () { - it("Accepts node Agent", function () { + describe("Constructor", () => { + it("Accepts node Agent", () => { const client = new CosmosClient({ endpoint: "https://faaaaaake.com", agent: new Agent(), @@ -51,18 +49,18 @@ describe("Client Tests", function (this: Suite) { }); assert.ok(client !== undefined, "client shouldn't be undefined if it succeeded"); }); - it("Accepts a connection string", function () { + it("Accepts a connection string", () => { const client = new CosmosClient(`AccountEndpoint=${endpoint};AccountKey=${masterKey};`); assert.ok(client !== undefined, "client shouldn't be undefined if it succeeded"); client.dispose(); }); - it("throws on a bad connection string", function () { + it("throws on a bad connection string", () => { assert.throws(() => new CosmosClient(`bad;Connection=string;`)); }); - it("throws on a bad endpoint", function () { + it("throws on a bad endpoint", () => { assert.throws(() => new CosmosClient({ endpoint: "asda=asda;asada;" })); }); - it("fails to read databases with bad AAD authentication", async function () { + it("fails to read databases with bad AAD authentication", async () => { try { const credentials = new UsernamePasswordCredential( "fake-tenant-id", @@ -81,8 +79,8 @@ describe("Client Tests", function (this: Suite) { } }); }); - describe.skip("Validate user passed AbortController.signal", function () { - it("should throw exception if aborted during the request", async function () { + describe.skip("Validate user passed AbortController.signal", () => { + it("should throw exception if aborted during the request", async () => { const client = new CosmosClient({ endpoint, key: masterKey }); try { const controller = new AbortController(); @@ -95,7 +93,7 @@ describe("Client Tests", function (this: Suite) { } client.dispose(); }); - it("should throw exception if passed an already aborted signal", async function () { + it("should throw exception if passed an already aborted signal", async () => { const client = new CosmosClient({ endpoint, key: masterKey }); try { const controller = new AbortController(); @@ -108,7 +106,7 @@ describe("Client Tests", function (this: Suite) { } client.dispose(); }); - it("should abort a query", async function () { + it("should abort a query", async () => { const container = await getTestContainer("abort query"); await bulkInsertItems(container, generateDocuments(20)); try { @@ -124,7 +122,7 @@ describe("Client Tests", function (this: Suite) { assert.equal(err.name, "AbortError", "client should throw exception"); } }); - it("should not abort if abort signal is never called", async function () { + it("should not abort if abort signal is never called", async () => { // Testing the happy path to prevent this bug https://github.com/Azure/azure-sdk-for-js/issues/9510 const client = new CosmosClient({ endpoint, key: masterKey }); try { @@ -137,38 +135,40 @@ describe("Client Tests", function (this: Suite) { client.dispose(); }); }); - describe("Background refresher", async function () { + describe("Background refresher", async () => { // not async to leverage done() callback inside setTimeout - it("should fetch new endpoints", function (done) { - // set refresh rate to 700ms - const client = new CosmosClient({ - endpoint, - key: masterKey, - connectionPolicy: { - ...defaultConnectionPolicy, - endpointRefreshRateInMs: 700, - enableBackgroundEndpointRefreshing: true, - }, - }); + it("should fetch new endpoints", () => + // eslint-disable-next-line promise/param-names + new Promise((done) => { + // set refresh rate to 700ms + const client = new CosmosClient({ + endpoint, + key: masterKey, + connectionPolicy: { + ...defaultConnectionPolicy, + endpointRefreshRateInMs: 700, + enableBackgroundEndpointRefreshing: true, + }, + }); - // then timeout 1.2s so that we first fetch no endpoints, then after it refreshes we see them - client - .getReadEndpoints() - .then((firstEndpoints) => { - assert.equal(firstEndpoints.length, 0); - setTimeout(() => { - client - .getReadEndpoints() - .then((endpoints) => { - assert.notEqual(firstEndpoints, endpoints); - done(); - return; - }) - .catch(console.warn); - }, 1200); - return; - }) - .catch(console.warn); - }); + // then timeout 1.2s so that we first fetch no endpoints, then after it refreshes we see them + client + .getReadEndpoints() + .then((firstEndpoints) => { + assert.equal(firstEndpoints.length, 0); + setTimeout(() => { + client + .getReadEndpoints() + .then((endpoints) => { + assert.notEqual(firstEndpoints, endpoints); + done(); + return; + }) + .catch(console.warn); + }, 1200); + return; + }) + .catch(console.warn); + })); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts index f0dad900d48b..8e28fdba1d27 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/computedProperties.spec.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { ComputedProperty } from "../../../src/documents/ComputedProperty.js"; import type { IndexingPolicy } from "../../../src/documents/IndexingPolicy.js"; import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; import type { Container } from "../../../src/client/Container/Container.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach, beforeAll } from "vitest"; // As of the current emulator release (March 23), computed properties are not supported, // hence, we are temporarily excluding these tests. @@ -23,7 +23,8 @@ describe.skip("Computed Properties test", async () => { let allComputedPropertiesResult: any; let emptyResult: any; let sampleItems: any; - before(async function () { + + beforeAll(async () => { lowerName = { name: "lowerLastName", query: @@ -116,11 +117,11 @@ describe.skip("Computed Properties test", async () => { ]; }); - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); }); - it("empty computed property", async function () { + it("empty computed property", async () => { // create container const container: Container = await createContainer("empty computed property", []); const { resources: results } = await container.items @@ -129,7 +130,7 @@ describe.skip("Computed Properties test", async () => { assert.deepStrictEqual(results, emptyResult); }); - it("all computed properties, no indexing", async function () { + it("all computed properties, no indexing", async () => { const container: Container = await createContainer( "all computed properties", allComputedProperties, @@ -140,7 +141,7 @@ describe.skip("Computed Properties test", async () => { assert.deepStrictEqual(results, allComputedPropertiesResult); }); - it("all computed properties, indexed, exclude /*", async function () { + it("all computed properties, indexed, exclude /*", async () => { const container: Container = await createContainer( "all computed properties, indexed, exclude all", allComputedProperties, @@ -152,7 +153,7 @@ describe.skip("Computed Properties test", async () => { assert.deepStrictEqual(results, allComputedPropertiesResult); }); - it("all computed properties, indexed, include /*", async function () { + it("all computed properties, indexed, include /*", async () => { const container: Container = await createContainer( "all computed properties, indexed, include all", allComputedProperties, @@ -164,7 +165,7 @@ describe.skip("Computed Properties test", async () => { assert.deepStrictEqual(results, allComputedPropertiesResult); }); - it("all computed properties, not indexed, exclude /*", async function () { + it("all computed properties, not indexed, exclude /*", async () => { const container: Container = await createContainer( "all computed properties, not indexed, exclude all", allComputedProperties, @@ -176,7 +177,7 @@ describe.skip("Computed Properties test", async () => { assert.deepStrictEqual(results, allComputedPropertiesResult); }); - it("all computed properties, not indexed, include /*", async function () { + it("all computed properties, not indexed, include /*", async () => { const container: Container = await createContainer( "all computed properties, not indexed, include all", allComputedProperties, @@ -189,7 +190,7 @@ describe.skip("Computed Properties test", async () => { }); // replace test - it("replace computed property for a contianer", async function () { + it("replace computed property for a contianer", async () => { const database = await getTestDatabase("sample database"); // create container const { resource: containerdef } = await database.containers.createIfNotExists({ @@ -227,7 +228,7 @@ describe.skip("Computed Properties test", async () => { assert.deepStrictEqual(results2, output2); }); - it("delete computed property for a contianer", async function () { + it("delete computed property for a contianer", async () => { const database = await getTestDatabase("sample database"); // create container const { resource: containerdef } = await database.containers.createIfNotExists({ @@ -263,7 +264,7 @@ describe.skip("Computed Properties test", async () => { containerName: string, computedProperties: ComputedProperty[], indexingPolicy?: IndexingPolicy, - ) { + ): Promise { const database = await getTestDatabase("sample database"); // create container const { resource: containerdef } = await database.containers.createIfNotExists({ diff --git a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts index 475452f04b79..714a2c7ee869 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts @@ -1,23 +1,22 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { removeAllDatabases, getTestContainer, testForDiagnostics } from "../common/TestHelpers.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; -describe("Conflicts", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { +describe("Conflicts", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - describe("Query conflicts", function () { - it("query conflicts", async function () { + describe("Query conflicts", () => { + it("query conflicts", async () => { const container = await getTestContainer("conflicts"); const { resources } = await container.conflicts.query("SELECT * from C").fetchNext(); assert.equal(resources.length, 0); }); - it("query conflicts with forceQueryPlan", async function () { + it("query conflicts with forceQueryPlan", async () => { // TODO. Remove! This test is to prevent regression on a bug where a query plan was being fetched for non-item resources // Ideally QueryIterator for item gets its own type instead of shared amongst all resources const container = await getTestContainer("conflicts"); @@ -27,7 +26,7 @@ describe("Conflicts", function (this: Suite) { assert.equal(resources.length, 0); }); }); - it("Test diagnostics for conflict", async function () { + it("Test diagnostics for conflict", async () => { const container = await getTestContainer("conflicts"); const timestamp = getCurrentTimestampInMs(); await testForDiagnostics( diff --git a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts index 092456e2540f..cae827256277 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/container.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { ContainerResponse, PartitionKeyDefinition } from "../../../src/index.js"; import { Constants, @@ -23,15 +23,14 @@ import { } from "../common/TestHelpers.js"; import { SpatialType } from "../../../src/index.js"; import { GeospatialType } from "../../../src/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach, beforeAll } from "vitest"; -describe("Containers", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { +describe("Containers", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - describe("Container CRUD", function () { + describe("Container CRUD", () => { const containerCRUDTest = async function ( partitionKey?: PartitionKeyDefinition, opts?: Partial, @@ -218,15 +217,15 @@ describe("Containers", function (this: Suite) { } }; - it("Default partition key", async function () { + it("Default partition key", async () => { await containerCRUDTest(); }); - it("Custom partition key", async function () { + it("Custom partition key", async () => { await containerCRUDTest({ paths: ["/id"] }); }); - it("Hierarchical partition key", async function () { + it("Hierarchical partition key", async () => { await containerCRUDTest({ paths: ["/id", "/id2"], version: 2, @@ -234,8 +233,8 @@ describe("Containers", function (this: Suite) { }); }); - describe("Bad partition key definition", async function () { - it("Has 'paths' property as string", async function () { + describe("Bad partition key definition", async () => { + it("Has 'paths' property as string", async () => { // create database const database = await getTestDatabase("container CRUD bad partition key"); @@ -268,7 +267,7 @@ describe("Containers", function (this: Suite) { assert.equal(err.code, 400); } }); - it("Path contains anything other than AlphaNumeric + '_'", async function () { + it("Path contains anything other than AlphaNumeric + '_'", async () => { // create database const database = await getTestDatabase("container CRUD bad partition key"); @@ -295,7 +294,7 @@ describe("Containers", function (this: Suite) { ); } }); - it("Is missing leading '/'", async function () { + it("Is missing leading '/'", async () => { // create database const database = await getTestDatabase("container CRUD bad partition key"); @@ -317,7 +316,7 @@ describe("Containers", function (this: Suite) { assert.equal(err.message, "Partition key must start with '/'"); } }); - it("Is missing leading '/' - hierarchical partitions", async function () { + it("Is missing leading '/' - hierarchical partitions", async () => { // create database const database = await getTestDatabase("container CRUD bad partition key"); @@ -351,8 +350,8 @@ describe("Containers", function (this: Suite) { }); }); - describe("Indexing policy", function () { - it("Create container with correct indexing policy", async function () { + describe("Indexing policy", () => { + it("Create container with correct indexing policy", async () => { // create database const database = await getTestDatabase("container test database"); @@ -379,7 +378,7 @@ describe("Containers", function (this: Suite) { ); const uniqueKeysContainer = database.container(uniqueKeysContainerDef.id); - assert.equal(uniqueKeysContainerDef.uniqueKeyPolicy.uniqueKeys[0].paths, "/foo"); + assert.equal(uniqueKeysContainerDef.uniqueKeyPolicy.uniqueKeys[0].paths[0], "/foo"); await uniqueKeysContainer.delete(); @@ -465,7 +464,7 @@ describe("Containers", function (this: Suite) { assert(rootIncludedPath); // root path should exist. }; - it("Create container with default indexing policy", async function () { + it("Create container with default indexing policy", async () => { // create database const database = await getTestDatabase("container test database"); @@ -526,7 +525,7 @@ describe("Containers", function (this: Suite) { }); }); - describe("Validate response headers", function () { + describe("Validate response headers", () => { const createThenReadcontainer = async function ( database: Database, definition: ContainerDefinition, @@ -558,27 +557,27 @@ describe("Containers", function (this: Suite) { assert.equal(headers3[Constants.HttpHeaders.LazyIndexingProgress], undefined); }; - it("nativeApi Validate index progress headers name based", async function () { + it("nativeApi Validate index progress headers name based", async () => { await indexProgressHeadersTest(); }); }); }); -describe("createIfNotExists", function () { +describe("createIfNotExists", () => { let database: Database; - before(async function () { + beforeAll(async () => { // create database database = await getTestDatabase("containers.createIfNotExists"); }); - it("create container should work if container does not already exist", async function () { + it("create container should work if container does not already exist", async () => { const def: ContainerDefinition = { id: "does not exist" }; const { container } = await database.containers.createIfNotExists(def); const { resource: readDef } = await container.read(); assert.equal(def.id, readDef.id); }); - it("create container should work if container already exists", async function () { + it("create container should work if container already exists", async () => { const def: ContainerDefinition = { id: "does exist" }; await database.containers.create(def); @@ -587,7 +586,7 @@ describe("createIfNotExists", function () { assert.equal(def.id, readDef.id); }); - it("create container should work if container does not exist - with hierarchical partitions", async function () { + it("create container should work if container does not exist - with hierarchical partitions", async () => { const def: ContainerDefinition = { id: "does not exist hierarchical partitions", partitionKey: { @@ -601,7 +600,7 @@ describe("createIfNotExists", function () { assert.equal(def.id, readDef.id); }); - it("create container should work if container already exists - with hierarchical partitions", async function () { + it("create container should work if container already exists - with hierarchical partitions", async () => { const def: ContainerDefinition = { id: "does exist hierarchical partitions", partitionKey: { @@ -618,7 +617,7 @@ describe("createIfNotExists", function () { }); }); -describe("container.readOffer", function () { +describe("container.readOffer", () => { let containerWithOffer: Container; let containerWithoutOffer: Container; let container2WithOffer: Container; @@ -630,8 +629,10 @@ describe("container.readOffer", function () { const containerRequest: ContainerRequest = { id: "sample-offerless", }; + let offerDatabase: Database; - before(async function () { + + beforeAll(async () => { offerDatabase = await getTestDatabase("has offer"); containerWithOffer = await getTestContainer( "offerContainer", @@ -644,25 +645,25 @@ describe("container.readOffer", function () { container2WithOffer = response1.container; container2WithoutOffer = response2.container; }); - describe("database does not have offer", function () { - it("has offer", async function () { + describe("database does not have offer", () => { + it("has offer", async () => { const offer: any = await containerWithOffer.readOffer(); const { resource: readDef } = await containerWithOffer.read(); assert.equal(offer.resource.offerResourceId, readDef._rid); }); - it("does not have offer so uses default", async function () { + it("does not have offer so uses default", async () => { const offer: any = await containerWithoutOffer.readOffer(); const { resource: readDef } = await containerWithoutOffer.read(); assert.equal(offer.resource.offerResourceId, readDef._rid); }); }); - describe("database has offer", function () { - it("container does not have offer", async function () { + describe("database has offer", () => { + it("container does not have offer", async () => { const offer: any = await container2WithoutOffer.readOffer(); const { resource: readDef } = await container2WithoutOffer.read(); assert.equal(offer.resource.offerResourceId, readDef._rid); }); - it("container has offer", async function () { + it("container has offer", async () => { const offer: any = await container2WithOffer.readOffer(); const { resource: readDef } = await container2WithOffer.read(); assert.equal(offer.resource.offerResourceId, readDef._rid); @@ -670,12 +671,14 @@ describe("container.readOffer", function () { }); }); -describe("container.create", function () { +describe("container.create", () => { let database: Database; - before(async () => { + + beforeAll(async () => { database = await getTestDatabase("autoscale test"); }); - it("uses autoscale", async function () { + + it("uses autoscale", async () => { const maxThroughput = 50000; const containerRequest: ContainerRequest = { id: "sample", @@ -686,7 +689,7 @@ describe("container.create", function () { const settings = offer.content.offerAutopilotSettings; assert.equal(settings.maxThroughput, maxThroughput); }); - it("throws with maxThroughput and throughput", function () { + it("throws with maxThroughput and throughput", () => { const containerRequest: ContainerRequest = { id: "sample", throughput: 400, @@ -696,8 +699,8 @@ describe("container.create", function () { }); }); -describe("Reading items using container", function () { - it("should be able to read item based on partition key value", async function () { +describe("Reading items using container", () => { + it("should be able to read item based on partition key value", async () => { const container = await getTestContainer("container", undefined, { partitionKey: { paths: ["/key1", "/key2"], kind: PartitionKeyKind.MultiHash, version: 2 }, }); @@ -743,13 +746,13 @@ describe("Reading items using container", function () { }); }); -describe("container.deleteAllItemsForPartitionKey", function () { - it("should delete all items for partition key value", async function () { +describe("container.deleteAllItemsForPartitionKey", () => { + it("should delete all items for partition key value", async () => { const container = await getTestContainer("container", undefined, { partitionKey: "/pk" }); await testDeleteAllItemsForPartitionKey(container); }); - it("should delete all items for parition key value in multi partition container", async function () { + it("should delete all items for parition key value in multi partition container", async () => { // multi partition container const container = await getTestContainer("container", undefined, { partitionKey: { @@ -760,7 +763,8 @@ describe("container.deleteAllItemsForPartitionKey", function () { }); await testDeleteAllItemsForPartitionKey(container); }); - async function testDeleteAllItemsForPartitionKey(container: Container) { + + async function testDeleteAllItemsForPartitionKey(container: Container): Promise { const { resource: create1 } = await container.items.create({ id: "1", key: "value", diff --git a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts index d376c9098931..04c1ff054b58 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/database.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { DatabaseDefinition, Database } from "../../../src/index.js"; import { CosmosClient } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; @@ -13,7 +13,7 @@ import { testForDiagnostics, } from "../common/TestHelpers.js"; import type { DatabaseRequest } from "../../../src/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach, beforeAll } from "vitest"; const client = new CosmosClient({ endpoint, @@ -21,13 +21,12 @@ const client = new CosmosClient({ connectionPolicy: { enableBackgroundEndpointRefreshing: false }, }); -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - describe("Validate Database CRUD", async function () { + describe("Validate Database CRUD", async () => { const databaseCRUDTest = async function (): Promise { // read databases @@ -122,19 +121,19 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }; - it("nativeApi Should do database CRUD operations successfully name based", async function () { + it("nativeApi Should do database CRUD operations successfully name based", async () => { await databaseCRUDTest(); }); - describe("databases.createIfNotExists", function () { - it("should handle does not exist", async function () { + describe("databases.createIfNotExists", () => { + it("should handle does not exist", async () => { const def: DatabaseDefinition = { id: addEntropy("does not exist") }; const { database } = await client.databases.createIfNotExists(def); const { resource: readDef } = await database.read(); assert.equal(def.id, readDef.id); }); - it("should handle does exist", async function () { + it("should handle does exist", async () => { const def: DatabaseDefinition = { id: addEntropy("does exist") }; // Set up await client.databases.create(def); @@ -148,8 +147,8 @@ describe("NodeJS CRUD Tests", function (this: Suite) { }); // TODO: These are unit tests, not e2e tests like above, so maybe should seperate these. - describe("Validate Id validation", function () { - it("nativeApi Should fail on ends with a space", async function () { + describe("Validate Id validation", () => { + it("nativeApi Should fail on ends with a space", async () => { // Id shoudn't end with a space. try { await client.databases.create({ id: "id_ends_with_space " }); @@ -159,7 +158,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }); - it("nativeAPI Should fail on contains '/'", async function () { + it("nativeAPI Should fail on contains '/'", async () => { // Id shoudn't contain "/". try { await client.databases.create({ id: "id_with_illegal/_char" }); @@ -169,7 +168,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }); - it("nativeAPI Should fail on contains '\\'", async function () { + it("nativeAPI Should fail on contains '\\'", async () => { // Id shoudn't contain "\\". try { await client.databases.create({ id: "id_with_illegal\\_char" }); @@ -179,7 +178,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }); - it("nativeAPI Should fail on contains '?'", async function () { + it("nativeAPI Should fail on contains '?'", async () => { // Id shoudn't contain "?". try { await client.databases.create({ id: "id_with_illegal?_?char" }); @@ -189,7 +188,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }); - it("nativeAPI should fail on contains '#'", async function () { + it("nativeAPI should fail on contains '#'", async () => { // Id shouldn't contain "#". try { await client.databases.create({ id: "id_with_illegal#_char" }); @@ -201,31 +200,31 @@ describe("NodeJS CRUD Tests", function (this: Suite) { }); }); -describe("database.readOffer", function () { - describe("without offer", async function () { +describe("database.readOffer", () => { + describe("without offer", async () => { let offerlessDatabase: Database; - before(async function () { + beforeAll(async () => { offerlessDatabase = await getTestDatabase("has offer db1"); }); - it("returns undefined resource", async function () { + it("returns undefined resource", async () => { const offer: any = await offerlessDatabase.readOffer(); assert.equal(offer.resource, undefined); }); }); - describe("has offer", function () { + describe("has offer", () => { let offerDatabase: Database; - before(async function () { + beforeAll(async () => { offerDatabase = await getTestDatabase("has offer db2", undefined, { throughput: 500 }); }); - it("returns offer", async function () { + it("returns offer", async () => { const offer: any = await offerDatabase.readOffer(); assert.equal(offer.resource.offerVersion, "V2"); }); }); }); -describe("database.create", function () { - it("uses autoscale", async function () { +describe("database.create", () => { + it("uses autoscale", async () => { const maxThroughput = 50000; const databaseRequest: DatabaseRequest = { maxThroughput, @@ -235,7 +234,7 @@ describe("database.create", function () { const settings = offer.content.offerAutopilotSettings; assert.equal(settings.maxThroughput, maxThroughput); }); - it("throws with maxThroughput and throughput", function () { + it("throws with maxThroughput and throughput", () => { const databaseRequest: DatabaseRequest = { throughput: 400, maxThroughput: 4000, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts index 2960ab1cf441..88d5baf668f4 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/databaseaccount.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { CosmosClient, OperationType } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; @@ -13,12 +13,7 @@ const client = new CosmosClient({ connectionPolicy: { enableBackgroundEndpointRefreshing: false }, }); -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function (ctx) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - }); - +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { describe("validate database account functionality", function () { it("nativeApi Should get database account successfully name based", async function () { const { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts index 227331d0cc97..c92f2912d995 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/globalEndpointManager.spec.ts @@ -4,12 +4,9 @@ import { DatabaseAccount, ResourceResponse } from "../../../src/index.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { GlobalEndpointManager } from "../../../src/index.js"; import { OperationType, ResourceType } from "../../../src/index.js"; -import * as fakeTimers from "@sinonjs/fake-timers"; - -import assert from "node:assert"; import { createDummyDiagnosticNode } from "../common/TestHelpers.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach, beforeAll, afterAll, vi } from "vitest"; const locationUnavailabilityExpiratationTime = 6 * 60 * 1000; const headers = { @@ -44,8 +41,8 @@ const databaseAccountBody: any = { ConsistencyPolicy: "Session", }; -describe("GlobalEndpointManager", function () { - describe("#resolveServiceEndpoint", function () { +describe("GlobalEndpointManager", () => { + describe("#resolveServiceEndpoint", () => { let gem = new GlobalEndpointManager( { endpoint: "https://test.documents.azure.com:443/", @@ -66,7 +63,7 @@ describe("GlobalEndpointManager", function () { }, ); - it("should resolve the correct endpoint", async function () { + it("should resolve the correct endpoint", async () => { // We don't block on init for database account calls assert.equal( await gem.resolveServiceEndpoint( @@ -109,7 +106,7 @@ describe("GlobalEndpointManager", function () { ); }); - it("should allow you to pass a normalized preferred location", async function () { + it("should allow you to pass a normalized preferred location", async () => { gem = new GlobalEndpointManager( { endpoint: "https://test.documents.azure.com:443/", @@ -140,15 +137,14 @@ describe("GlobalEndpointManager", function () { ); }); - describe("should resolve to endpoint when call made after server unavailability time", function () { - let clock: fakeTimers.InstalledClock; - before(async function () { - clock = fakeTimers.install(); + describe("should resolve to endpoint when call made after server unavailability time", () => { + beforeAll(async () => { + vi.useFakeTimers(); }); - after(function () { - clock.uninstall(); + afterAll(() => { + vi.useRealTimers(); }); - it("should resolve to endpoint when call made after server unavailability time", async function () { + it("should resolve to endpoint when call made after server unavailability time", async () => { gem = new GlobalEndpointManager( { endpoint: "https://test.documents.azure.com:443/", @@ -177,18 +173,17 @@ describe("GlobalEndpointManager", function () { await gem.getReadEndpoint(diagnosticNode), "https://test-eastus2.documents.azure.com:443/", ); - clock.tick(locationUnavailabilityExpiratationTime); + vi.advanceTimersByTime(locationUnavailabilityExpiratationTime); await gem.refreshEndpointList(diagnosticNode); assert.equal( await gem.getReadEndpoint(diagnosticNode), "https://test-westus2.documents.azure.com:443/", ); - clock.uninstall(); }); }); }); - describe("#markCurrentLocationUnavailable", function () { + describe("#markCurrentLocationUnavailable", () => { const gem = new GlobalEndpointManager( { endpoint: "https://test.documents.azure.com:443/", @@ -213,7 +208,7 @@ describe("GlobalEndpointManager", function () { await gem.refreshEndpointList(createDummyDiagnosticNode()); }); - it("should mark the current location unavailable for read", async function () { + it("should mark the current location unavailable for read", async () => { // We don't block on init for database account calls await gem.markCurrentLocationUnavailableForRead( createDummyDiagnosticNode(), @@ -227,7 +222,7 @@ describe("GlobalEndpointManager", function () { "https://test-westus2.documents.azure.com:443/", ); }); - it("should mark the current location unavailable for write", async function () { + it("should mark the current location unavailable for write", async () => { // We don't block on init for database account calls await gem.markCurrentLocationUnavailableForWrite( createDummyDiagnosticNode(), diff --git a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts index 5ce52128f291..ab7253d9a40e 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/npcontainer.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ -import assert from "node:assert"; + import type { Container, PluginConfig, @@ -13,7 +12,7 @@ import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { ResourceType, HTTPMethod, StatusCodes } from "../../../src/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect, beforeEach, afterAll } from "vitest"; const plugins: PluginConfig[] = [ { @@ -42,7 +41,7 @@ const client = new CosmosClient({ key: masterKey, }); -describe("Non Partitioned Container", function () { +describe("Non Partitioned Container", () => { let container: Container; beforeEach(async () => { await removeAllDatabases(); @@ -50,7 +49,7 @@ describe("Non Partitioned Container", function () { container = client.database(npContainer.database.id).container(npContainer.id); }); - after(async () => { + afterAll(async () => { client.dispose(); legacyClient.dispose(); }); @@ -148,7 +147,7 @@ describe("Non Partitioned Container", function () { assert.equal(response[5].statusCode, StatusCodes.Ok); }); - it("should handle batch operations", async function () { + it("should handle batch operations", async () => { const operations: OperationInput[] = [ { operationType: "Create", diff --git a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts index 28110b7d866a..faf40a4e7c8f 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/offer.spec.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { Constants, CosmosClient } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; const client = new CosmosClient({ endpoint, @@ -21,16 +21,13 @@ const validateOfferResponseBody = function (offer: any): void { assert(offer._self.indexOf(offer.id) !== -1, "Offer id not contained in offer self link."); }; -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - - beforeEach(async function (ctx) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - describe("Validate Offer CRUD", function () { - it("nativeApi Should do offer read and query operations successfully name based single partition collection", async function () { + describe("Validate Offer CRUD", () => { + it("nativeApi Should do offer read and query operations successfully name based single partition collection", async () => { const mbInBytes = 1024 * 1024; const offerThroughput = 400; const container = await getTestContainer("Validate Offer CRUD"); @@ -96,7 +93,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }); - it("nativeApi Should do offer replace operations successfully name based", async function () { + it("nativeApi Should do offer replace operations successfully name based", async () => { await getTestContainer("Validate Offer CRUD"); const { resources: offers } = await client.offers.readAll().fetchAll(); assert.equal(offers.length, 1); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts index 83de0fbcaa08..b093efebe9d3 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/permission.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { PermissionMode } from "../../../src/index.js"; import type { PermissionDefinition } from "../../../src/index.js"; import { @@ -9,10 +9,9 @@ import { removeAllDatabases, replaceOrUpsertPermission, } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { beforeEach(async function () { await removeAllDatabases(); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts index 80814c97e8cc..d7474e9ce13b 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/plugin.spec.ts @@ -1,15 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ + import type { CosmosClientOptions } from "../../../src/index.js"; import { CosmosClient } from "../../../src/index.js"; import type { RequestContext } from "../../../src/index.js"; import type { Plugin, Next, PluginConfig } from "../../../src/index.js"; - -import * as assert from "node:assert"; import type { DiagnosticNodeInternal } from "../../../src/diagnostics/DiagnosticNodeInternal.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect } from "vitest"; describe("Plugin", function () { it("should handle all requests", async function () { @@ -54,7 +52,7 @@ describe("Plugin", function () { assert.equal(requestCount, FAILCOUNT + 1); // Get Database Account + FAILED GET Database + Get Database assert.notEqual(response, undefined); assert.equal(response.statusCode, successResponse.code); - assert.deepEqual(response.resource, successResponse.result); + assert.deepEqual(response.resource, successResponse.result as any); client.dispose(); }); @@ -97,7 +95,7 @@ describe("Plugin", function () { assert.equal(requestCount, 2); // Get Database Account + Get Database assert.notEqual(response, undefined); assert.equal(response.statusCode, successResponse.code); - assert.deepEqual(response.resource, successResponse.result); + assert.deepEqual(response.resource, successResponse.result as any); client.dispose(); }); @@ -149,7 +147,7 @@ describe("Plugin", function () { assert.equal(innerRequestCount, 2); // Get Database Account + Get Database assert.notEqual(response, undefined); assert.equal(response.statusCode, successResponse.code); - assert.deepEqual(response.resource, successResponse.result); + assert.deepEqual(response.resource, successResponse.result as any); client.dispose(); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts index e782404b0b7d..cab620c9affa 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/query.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { ContainerDefinition } from "../../../src/index.js"; import { CosmosClient } from "../../../src/index.js"; import type { Container } from "../../../src/index.js"; @@ -13,7 +13,7 @@ import { testForDiagnostics, } from "../common/TestHelpers.js"; import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll } from "vitest"; const client = new CosmosClient({ endpoint, @@ -27,14 +27,13 @@ if (!Symbol || !Symbol.asyncIterator) { (Symbol as any).asyncIterator = Symbol.for("Symbol.asyncIterator"); } -describe("Queries", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - before(async function () { +describe("Queries", { timeout: 10000 }, () => { + beforeAll(async () => { await removeAllDatabases(); }); - describe("Query CRUD", function () { - it("nativeApi Should do queries CRUD operations successfully name based", async function () { + describe("Query CRUD", () => { + it("nativeApi Should do queries CRUD operations successfully name based", async () => { // create a database const database = await getTestDatabase("query test database"); // query databases @@ -60,11 +59,10 @@ describe("Queries", function (this: Suite) { }); }); - describe("QueryIterator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); + describe("QueryIterator", { timeout: 30000 }, () => { let resources: { container: Container; doc1: any; doc2: any; doc3: any }; - before(async function () { + beforeAll(async () => { const container = await getTestContainer("Validate QueryIterator Functionality", client); const { resource: doc1 } = await container.items.create({ id: "doc1", prop1: "value1" }); const { resource: doc2 } = await container.items.create({ id: "doc2", prop1: "value2" }); @@ -72,7 +70,7 @@ describe("Queries", function (this: Suite) { resources = { container, doc1, doc2, doc3 }; }); - it("fetchAll", async function () { + it("fetchAll", async () => { const queryIterator = resources.container.items.readAll({ maxItemCount: 2 }); const { resources: docs } = await testForDiagnostics( @@ -95,7 +93,7 @@ describe("Queries", function (this: Suite) { assert.equal(docs[2].id, resources.doc3.id); }); - it("asyncIterator", async function () { + it("asyncIterator", async () => { const queryIterator = resources.container.items.readAll({ maxItemCount: 2 }); let counter = 0; for await (const { resources: docs } of queryIterator.getAsyncIterator()) { @@ -110,7 +108,7 @@ describe("Queries", function (this: Suite) { assert(counter === 2, "iterator should have run 3 times"); }); - it("executeNext", async function () { + it("executeNext", async () => { let queryIterator = resources.container.items.readAll({ maxItemCount: 2, }); @@ -163,7 +161,7 @@ describe("Queries", function (this: Suite) { "second batch element should be doc3", ); }); - it("fails with invalid continuation token", async function () { + it("fails with invalid continuation token", async () => { let queryIterator = resources.container.items.readAll({ maxItemCount: 2, }); @@ -182,10 +180,8 @@ describe("Queries", function (this: Suite) { } }); - describe("SUM query iterator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); - - it("returns undefined sum with null value in aggregator", async function () { + describe("SUM query iterator", { timeout: 30000 }, () => { + it("returns undefined sum with null value in aggregator", async () => { const container = await getTestContainer( "Validate QueryIterator Functionality", undefined, @@ -205,7 +201,7 @@ describe("Queries", function (this: Suite) { const { resources: sum } = await queryIterator.fetchAll(); assert.equal(sum.length, 0); }); - it("returns undefined sum with false value in aggregator", async function () { + it("returns undefined sum with false value in aggregator", async () => { const container = await getTestContainer( "Validate QueryIterator Functionality", undefined, @@ -225,7 +221,7 @@ describe("Queries", function (this: Suite) { const { resources: sum } = await queryIterator.fetchAll(); assert.equal(sum.length, 0); }); - it("returns undefined sum with empty array value in aggregator", async function () { + it("returns undefined sum with empty array value in aggregator", async () => { const container = await getTestContainer( "Validate QueryIterator Functionality", undefined, @@ -245,7 +241,8 @@ describe("Queries", function (this: Suite) { const { resources: sum } = await queryIterator.fetchAll(); assert.equal(sum.length, 0); }); - it("returns a valid sum with undefined value in aggregator", async function () { + + it("returns a valid sum with undefined value in aggregator", async () => { const container = await getTestContainer( "Validate QueryIterator Functionality", undefined, @@ -268,10 +265,8 @@ describe("Queries", function (this: Suite) { }); }); - describe("MakeList query iterator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); - - it("returns all documents for query iterator with makeList", async function () { + describe("MakeList query iterator", { timeout: 30000 }, () => { + it("returns all documents for query iterator with makeList", async () => { const queryIterator = resources.container.items.query( "SELECT VALUE MAKELIST (c.prop1) FROM c", ); @@ -280,7 +275,7 @@ describe("Queries", function (this: Suite) { assert.deepEqual(ages[0], ["value1", "value2", "value3"]); }); - it("returns all documents for query iterator with makeList with multipartitioned container", async function () { + it("returns all documents for query iterator with makeList with multipartitioned container", async () => { const container = await getTestContainer("multipartitioned makelist", client, { throughput: 12100, }); @@ -294,7 +289,7 @@ describe("Queries", function (this: Suite) { assert.deepEqual(ages[0], ["value1", "value2", "value3", "value1"]); }); - it("field of type array", async function () { + it("field of type array", async () => { const container = await getTestContainer("array field", client, { throughput: 12100, }); @@ -309,7 +304,7 @@ describe("Queries", function (this: Suite) { assert.deepEqual(ages[0], [["value1", "value2"], []]); }); - it("field of type string", async function () { + it("field of type string", async () => { const container = await getTestContainer("array field", client, { throughput: 12100, }); @@ -325,10 +320,8 @@ describe("Queries", function (this: Suite) { }); }); - describe("MakeSet query iterator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); - - it("returns all documents for query iterator with makeSet", async function () { + describe("MakeSet query iterator", { timeout: 30000 }, () => { + it("returns all documents for query iterator with makeSet", async () => { await resources.container.items.create({ id: "doc4", prop1: "value1" }); const queryIterator = resources.container.items.query( "SELECT VALUE MAKESET (c.prop1) FROM c", @@ -338,7 +331,7 @@ describe("Queries", function (this: Suite) { assert.deepEqual(ages[0], ["value1", "value2", "value3"]); }); - it("returns all documents for query iterator with makeSet with multipartitioned container", async function () { + it("returns all documents for query iterator with makeSet with multipartitioned container", async () => { const container = await getTestContainer("multipartitioned makeset", client, { throughput: 12100, }); @@ -354,11 +347,10 @@ describe("Queries", function (this: Suite) { }); }); - describe("QueryIterator: Hierarchical partitions", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); + describe("QueryIterator: Hierarchical partitions", { timeout: 30000 }, () => { let resources: { container: Container; doc1: any; doc2: any; doc3: any; doc4: any }; - before(async function () { + beforeAll(async () => { const containerDef: ContainerDefinition = { partitionKey: { paths: ["/prop1", "/prop2"], @@ -379,7 +371,7 @@ describe("Queries", function (this: Suite) { resources = { container, doc1, doc2, doc3, doc4 }; }); - it("fetchAll", async function () { + it("fetchAll", async () => { const queryIterator = resources.container.items.readAll({ maxItemCount: 2 }); const { resources: docs } = await queryIterator.fetchAll(); assert.equal(docs.length, 4, "queryIterator should return all documents using continuation"); @@ -389,7 +381,7 @@ describe("Queries", function (this: Suite) { assert.equal(docs[3].id, resources.doc4.id); }); - it("asyncIterator", async function () { + it("asyncIterator", async () => { const queryIterator = resources.container.items.readAll({ maxItemCount: 2 }); let counter = 0; for await (const { resources: docs } of queryIterator.getAsyncIterator()) { @@ -405,7 +397,7 @@ describe("Queries", function (this: Suite) { assert.strictEqual(counter, 3, "iterator should have run 4 times"); }); - it("asyncIterator - with partitionKey parameter", async function () { + it("asyncIterator - with partitionKey parameter", async () => { const queryIterator = resources.container.items.readAll({ maxItemCount: 2, partitionKey: ["a", 1], @@ -423,7 +415,7 @@ describe("Queries", function (this: Suite) { assert.strictEqual(counter, 2, "iterator should have run 3 times"); }); - it("executeNext", async function () { + it("executeNext", async () => { let queryIterator = resources.container.items.readAll({ maxItemCount: 2, partitionKey: ["a", 1], @@ -465,7 +457,7 @@ describe("Queries", function (this: Suite) { "second batch element should be doc3", ); }); - it("fails with invalid continuation token", async function () { + it("fails with invalid continuation token", async () => { let queryIterator = resources.container.items.readAll({ maxItemCount: 2, partitionKey: ["a", 1], @@ -485,10 +477,8 @@ describe("Queries", function (this: Suite) { } }); - describe("SUM query iterator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); - - it("return sum for given partition key", async function () { + describe("SUM query iterator", { timeout: 30000 }, () => { + it("return sum for given partition key", async () => { const container = await getTestContainer( "Validate QueryIterator Functionality", undefined, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts index f9c6af72935b..ed7974d0c33a 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/queryIterator.spec.ts @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -// Import the required modules -import assert from "node:assert"; import type { Container, FeedOptions } from "../../../src/index.js"; import { CosmosClient, OperationType, ResourceType } from "../../../src/index.js"; import { endpoint } from "../../public/common/_testConfig.js"; @@ -12,10 +10,9 @@ import { isValidV4UUID, removeAllDatabases, } from "../../public/common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll, afterAll } from "vitest"; -describe("Correlated Activity Id", function () { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); +describe("Correlated Activity Id", { timeout: 30000 }, () => { let container: Container; let capturedCorrelatedActivityIds: any[]; const client = new CosmosClient({ @@ -40,7 +37,7 @@ describe("Correlated Activity Id", function () { ], }); - before(async () => { + beforeAll(async () => { container = await getTestContainer("Test", client, { partitionKey: "/name", throughput: 10000, @@ -178,7 +175,6 @@ describe("Correlated Activity Id", function () { assert.ok(capturedCorrelatedActivityIds.every(isValidV4UUID)); const correlatedIdFetchAll = capturedCorrelatedActivityIds[0]; capturedCorrelatedActivityIds = []; - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _ of queryIterator.getAsyncIterator()) { // The loop is intentionally empty } @@ -196,7 +192,6 @@ describe("Correlated Activity Id", function () { assert.ok(capturedCorrelatedActivityIds.every(isValidV4UUID)); const correlatedIdFetchNext = capturedCorrelatedActivityIds[0]; capturedCorrelatedActivityIds = []; - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _ of queryIterator.getAsyncIterator()) { // The loop is intentionally empty } @@ -237,7 +232,6 @@ describe("Correlated Activity Id", function () { capturedCorrelatedActivityIds = []; // getAsyncIterator try { - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _ of queryIterator.getAsyncIterator()) { // The loop is intentionally empty } @@ -250,7 +244,7 @@ describe("Correlated Activity Id", function () { ); } }); - after(async function () { + afterAll(async () => { await removeAllDatabases(); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts index 61627c6155c7..1c228c0bbe45 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/spatial.spec.ts @@ -1,14 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { Database } from "../../../src/index.js"; import { DataType, IndexKind } from "../../../src/index.js"; import { createOrUpsertItem, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; -describe("Spatial Indexes", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { +describe("Spatial Indexes", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); @@ -63,11 +62,11 @@ describe("Spatial Indexes", function (this: Suite) { assert.equal("location1", results[0].id); }; - it("nativeApi Should support spatial index name based", async function () { + it("nativeApi Should support spatial index name based", async () => { await spatialIndexTest(false); }); - it("nativeApi Should support spatial index name based with upsert", async function () { + it("nativeApi Should support spatial index name based with upsert", async () => { await spatialIndexTest(true); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts index 41e4bb428ae1..98f33982aa46 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { Constants } from "../../../src/index.js"; import type { Container, StoredProcedureDefinition } from "../../../src/index.js"; import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; @@ -10,20 +10,19 @@ import { getTestDatabase, removeAllDatabases, } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; // Used for sproc declare let getContext: any; -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { beforeEach(async function () { await removeAllDatabases(); }); describe("Validate sproc CRUD", function () { let container: Container; - beforeEach(async function (ctx) { - container = await getTestContainer(this.test.fullTitle()); + beforeEach(async (ctx) => { + container = await getTestContainer(ctx); }); it("nativeApi Should do sproc CRUD operations successfully with create/replace", async function () { @@ -94,8 +93,8 @@ describe("NodeJS CRUD Tests", function (this: Suite) { describe("Validate stored procedure functionality", function () { let container: Container; - beforeEach(async function (ctx) { - container = await getTestContainer(this.test.fullTitle()); + beforeEach(async (ctx) => { + container = await getTestContainer(ctx); }); it("nativeApi should do stored procedure operations successfully with create/replace", async function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts index 8aefa6f751d0..09b63953b289 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts @@ -1,18 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { TriggerOperation, TriggerType } from "../../../src/index.js"; import type { TriggerDefinition, Container } from "../../../src/index.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; const notFoundErrorCode = 404; // Mock for trigger function bodies declare let getContext: any; -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { let container: Container; beforeEach(async function () { diff --git a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts index f81bb78efa8c..baebc3a6fd41 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { Container, ContainerDefinition, Database } from "../../../src/index.js"; import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; import { StatusCodes } from "../../../src/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; async function sleep(time: number): Promise { return new Promise((resolve) => { @@ -12,8 +12,7 @@ async function sleep(time: number): Promise { }); } -describe("Container TTL", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 600000); +describe("Container TTL", { timeout: 600000 }, () => { beforeEach(async function () { await removeAllDatabases(); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts index aee2d55888ac..1dbae2cc90f1 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/udf.spec.ts @@ -1,34 +1,33 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { UserDefinedFunctionDefinition, Container } from "../../../src/index.js"; import { removeAllDatabases, getTestContainer } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; -describe("User Defined Function", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +describe("User Defined Function", { timeout: 10000 }, () => { let container: Container; - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); // get container container = await getTestContainer("UDFTests"); }); - it("nativeApi Should do UDF CRUD operations successfully", async function () { + it("nativeApi Should do UDF CRUD operations successfully", async () => { const { resources: udfs } = await container.scripts.userDefinedFunctions.readAll().fetchAll(); // create a udf const beforeCreateUdfsCount = udfs.length; const udfDefinition: UserDefinedFunctionDefinition = { id: "sample udf", - body: "function () { const x = 10; }", + body: "() => { const x = 10; }", }; // TODO also handle upsert case const { resource: udf } = await container.scripts.userDefinedFunctions.create(udfDefinition); assert.equal(udf.id, udfDefinition.id); - assert.equal(udf.body, "function () { const x = 10; }"); + assert.equal(udf.body, "() => { const x = 10; }"); // read udfs after creation const { resources: udfsAfterCreate } = await container.scripts.userDefinedFunctions @@ -56,13 +55,13 @@ describe("User Defined Function", function (this: Suite) { assert(results.length > 0, "number of results for the query should be > 0"); // replace udf - udfDefinition.body = "function () { const x = 10; }"; + udfDefinition.body = "() => { const x = 10; }"; const { resource: replacedUdf } = await container.scripts .userDefinedFunction(udfDefinition.id) .replace(udfDefinition); assert.equal(replacedUdf.id, udfDefinition.id); - assert.equal(replacedUdf.body, "function () { const x = 10; }"); + assert.equal(replacedUdf.body, "() => { const x = 10; }"); // read udf const { resource: udfAfterReplace } = await container.scripts diff --git a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts index c5831f49a77b..116c2697852c 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/user.spec.ts @@ -1,16 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { UserDefinition } from "../../../src/index.js"; import { createOrUpsertUser, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - describe("Validate User CRUD", function () { + describe("Validate User CRUD", () => { const userCRUDTest = async function (isUpsertTest: boolean): Promise { // create database const database = await getTestDatabase("Validate user CRUD"); @@ -78,11 +77,11 @@ describe("NodeJS CRUD Tests", function (this: Suite) { } }; - it("nativeApi Should do User CRUD operations successfully name based", async function () { + it("nativeApi Should do User CRUD operations successfully name based", async () => { await userCRUDTest(false); }); - it("nativeApi Should do User CRUD operations successfully name based with upsert", async function () { + it("nativeApi Should do User CRUD operations successfully name based with upsert", async () => { await userCRUDTest(true); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts index b8c930673c3a..d5888c2ac095 100644 --- a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts @@ -1,13 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import { IndexMetricWriter, IndexUtilizationInfo } from "../../src/indexMetrics/index.js"; import { describe, it, assert } from "vitest"; -describe("Test Index Metrics Writer", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 20000); - +describe("Test Index Metrics Writer", { timeout: 20000 }, () => { it("test writeIndexMetrics", async function () { const result: { result: IndexUtilizationInfo } = { result: IndexUtilizationInfo.Empty }; IndexUtilizationInfo.tryCreateFromDelimitedBase64String( @@ -31,7 +28,7 @@ describe("Test Index Metrics Writer", function (this: Suite) { }); }); -describe("Test Index Utilization Info", function (this: Suite) { +describe("Test Index Utilization Info", () => { it("test tryCreateFromDelimitedBase64String", async function () { const delimitedString = "eyJVdGlsaXplZFNpbmdsZUluZGV4ZXMiOlt7IkZpbHRlckV4cHJlc3Npb24iOiIiLCJJbmRleFNwZWMiOiJcL25hbWVcLz8iLCJGaWx0ZXJQcmVjaXNlU2V0Ijp0cnVlLCJJbmRleFByZWNpc2VTZXQiOnRydWUsIkluZGV4SW1wYWN0U2NvcmUiOiJIaWdoIn1dLCJQb3RlbnRpYWxTaW5nbGVJbmRleGVzIjpbXSwiVXRpbGl6ZWRDb21wb3NpdGVJbmRleGVzIjpbXSwiUG90ZW50aWFsQ29tcG9zaXRlSW5kZXhlcyI6W119"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts index 00946ebc2d46..4767d396e19f 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { Container, ContainerDefinition } from "../../../src/index.js"; import { IndexingMode } from "../../../src/index.js"; import { DataType, IndexKind } from "../../../src/index.js"; @@ -9,10 +9,9 @@ import type { SqlQuerySpec } from "../../../src/index.js"; import type { FeedOptions } from "../../../src/index.js"; import { TestData } from "../common/TestData.js"; import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect, beforeAll } from "vitest"; -describe("Aggregate Query", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 20000); +describe("Aggregate Query", { timeout: 20000 }, () => { const partitionKey = "key"; const uniquePartitionKey = "uniquePartitionKey"; const testdata = new TestData(partitionKey, uniquePartitionKey); @@ -49,7 +48,7 @@ describe("Aggregate Query", function (this: Suite) { const containerOptions = { offerThroughput: 10100 }; - before(async function () { + beforeAll(async function () { await removeAllDatabases(); container = await getTestContainer( "Validate Aggregate Document Query", diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts index da41bc9a73d1..92f0e27cba72 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + import type { Container, ContainerDefinition } from "../../../../src/index.js"; import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../../common/TestHelpers.js"; -import assert from "node:assert"; import groupBySnapshot from "./groupBy.snapshot.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach, beforeAll } from "vitest"; const options = { maxItemCount: 100, @@ -544,12 +544,12 @@ describe("Cross partition GROUP BY", () => { assert.deepStrictEqual(actual, groupBySnapshot[`${currentTestTitle} ${snapshotNumber++}`]); }; - beforeEach(function (ctx) { - currentTestTitle = this.currentTest.fullTitle(); + beforeEach((ctx) => { + currentTestTitle = ctx.currentTest.fullTitle(); snapshotNumber = 1; }); - before(async () => { + beforeAll(async () => { await removeAllDatabases(); container = await getTestContainer( "GROUP BY Query", diff --git a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts index 2e65680613bb..dd97b29b40de 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/authorization.spec.ts @@ -1,16 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { Container } from "../../../src/index.js"; import { CosmosClient, PermissionMode } from "../../../src/index.js"; import type { Database } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; - -describe("Authorization", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +import { describe, it, assert, beforeEach, afterEach } from "vitest"; +describe("Authorization", { timeout: 10000 }, () => { // TODO: should have types for all these things let database: Database; let container: Container; @@ -27,7 +25,7 @@ describe("Authorization", function (this: Suite) { }; /** ************ TEST **************/ - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); // create a database & container @@ -67,11 +65,11 @@ describe("Authorization", function (this: Suite) { collAllPermission = allPermission; }); - afterEach(async function () { + afterEach(async () => { await removeAllDatabases(); }); - it("Accessing container by resourceTokens", async function () { + it("Accessing container by resourceTokens", async () => { const rTokens: any = {}; rTokens[container.id] = collReadPermission._token; @@ -88,7 +86,7 @@ describe("Authorization", function (this: Suite) { assert.equal(coll.id, container.id, "invalid container"); }); - it("Accessing container by permissionFeed", async function () { + it("Accessing container by permissionFeed", async () => { const clientReadPermission = new CosmosClient({ endpoint, permissionFeed: [collReadPermission], @@ -103,7 +101,7 @@ describe("Authorization", function (this: Suite) { assert.equal(coll.id, container.id, "invalid container"); }); - it("Accessing container without permission fails", async function () { + it("Accessing container without permission fails", async () => { const clientNoPermission = new CosmosClient({ endpoint }); try { @@ -115,7 +113,7 @@ describe("Authorization", function (this: Suite) { clientNoPermission.dispose(); }); - it("Accessing document by permissionFeed of parent container", async function () { + it("Accessing document by permissionFeed of parent container", async () => { const { resource: createdDoc } = await container.items.create({ id: "document1", }); @@ -134,7 +132,7 @@ describe("Authorization", function (this: Suite) { assert.equal(readDoc.id, createdDoc.id, "invalid document read"); }); - it.skip("Modifying container by resourceTokens", async function () { + it.skip("Modifying container by resourceTokens", async () => { const rTokens: any = {}; rTokens[container.id] = collAllPermission._token; const clientAllPermission = new CosmosClient({ @@ -147,7 +145,7 @@ describe("Authorization", function (this: Suite) { return clientAllPermission.database(database.id).container(container.id).delete(); }); - it.skip("Modifying container by permissionFeed", async function () { + it.skip("Modifying container by permissionFeed", async () => { const clientAllPermission = new CosmosClient({ endpoint, permissionFeed: [collAllPermission], diff --git a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts index f354f3f4ded5..2aa0049ebbd3 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/changeFeed.spec.ts @@ -1,25 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { RequestOptions } from "../../../src/index.js"; import type { Container, ContainerDefinition } from "../../../src/index.js"; import { PartitionKeyDefinitionVersion, PartitionKeyKind } from "../../../src/documents/index.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; - -describe("Change Feed Iterator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 20000); +import { describe, it, assert, beforeAll, afterAll } from "vitest"; +describe("Change Feed Iterator", { timeout: 20000 }, () => { // delete all databases and create sample database - before(async function () { + beforeAll(async () => { await removeAllDatabases(); }); - describe("Newly updated items should be fetched incrementally", function () { + describe("Newly updated items should be fetched incrementally", () => { let container: Container; // create container and two items - before(async function () { + beforeAll(async () => { const containerDef: ContainerDefinition = { partitionKey: { paths: ["/key1", "/key2"], @@ -40,7 +38,7 @@ describe("Change Feed Iterator", function (this: Suite) { await container.items.create({ id: "item2", key1: "1", key2: 1 }); }); - it("should throw if used with no partition key or partition key range id", async function () { + it("should throw if used with no partition key or partition key range id", async () => { const iterator = container.items.changeFeed({ startFromBeginning: true }); try { @@ -55,7 +53,7 @@ describe("Change Feed Iterator", function (this: Suite) { assert.fail("Should have failed"); }); - it("should fetch updated items only", async function () { + it("should fetch updated items only", async () => { const iterator = container.items.changeFeed(["0", 0], { startFromBeginning: true }); const { result: items, headers } = await iterator.fetchNext(); @@ -85,11 +83,11 @@ describe("Change Feed Iterator", function (this: Suite) { }); }); - describe("Newly created items should be fetched incrementally", async function () { + describe("Newly created items should be fetched incrementally", async () => { let container: Container; // create container and one item - before(async function () { + beforeAll(async () => { const containerDef: ContainerDefinition = { partitionKey: { paths: ["/key1", "/key2"], @@ -108,11 +106,11 @@ describe("Change Feed Iterator", function (this: Suite) { await container.items.create({ id: "item1", key1: "1", key2: 1 }); }); - after(async function () { + afterAll(async () => { await container.delete(); }); - it("should fetch new items only", async function () { + it("should fetch new items only", async () => { const iterator = container.items.changeFeed(["0", 0]); const { result: items, headers } = await iterator.fetchNext(); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts index 75411853dc9c..18866dc6394b 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/changeFeedIterator.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { ChangeFeedIteratorOptions, RequestOptions } from "../../../src/index.js"; import { ChangeFeedStartFrom, @@ -21,20 +21,18 @@ import { import { FeedRangeInternal } from "../../../src/client/ChangeFeed/FeedRange.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { StatusCodes } from "../../../src/common/statusCodes.js"; -import { describe, it, assert } from "vitest"; - -describe("Change Feed Iterator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 20000); +import { describe, it, assert, beforeAll, afterAll } from "vitest"; +describe("Change Feed Iterator", { timeout: 20000 }, () => { // delete all databases and create sample database - before(async function () { + beforeAll(async () => { await removeAllDatabases(); }); - describe("test changefeed iterator options", function () { + describe("test changefeed iterator options", () => { let container: Container; - before(async function () { + beforeAll(async () => { const containerDef: ContainerDefinition = { partitionKey: { paths: ["/key1", "/key2"], @@ -58,7 +56,7 @@ describe("Change Feed Iterator", function (this: Suite) { } }); - it("max item count cannot be < 1", async function () { + it("max item count cannot be < 1", async () => { try { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 0, @@ -77,10 +75,10 @@ describe("Change Feed Iterator", function (this: Suite) { }); }); - describe("test changefeed for one partition key", function () { + describe("test changefeed for one partition key", () => { let container: Container; - before(async function () { + beforeAll(async () => { const containerDef: ContainerDefinition = { partitionKey: { paths: ["/key1", "/key2"], @@ -104,7 +102,7 @@ describe("Change Feed Iterator", function (this: Suite) { } }); - it("check if maxItemCount property is being followed", async function () { + it("check if maxItemCount property is being followed", async () => { const maxItemCount = 1; const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: maxItemCount, @@ -122,7 +120,7 @@ describe("Change Feed Iterator", function (this: Suite) { } }); - it("startFromBeginning should fetch all results", async function () { + it("startFromBeginning should fetch all results", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { changeFeedStartFrom: ChangeFeedStartFrom.Beginning(["0", 0]), }; @@ -136,7 +134,7 @@ describe("Change Feed Iterator", function (this: Suite) { } }); - it("Iterator should start from last continuation token and fetch remaining results", async function () { + it("Iterator should start from last continuation token and fetch remaining results", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 1, changeFeedStartFrom: ChangeFeedStartFrom.Beginning(["0", 0]), @@ -163,7 +161,7 @@ describe("Change Feed Iterator", function (this: Suite) { } }); - it("startFromNow should fetch all results from now on", async function () { + it("startFromNow should fetch all results from now on", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 10, changeFeedStartFrom: ChangeFeedStartFrom.Now(["0", 0]), @@ -190,7 +188,7 @@ describe("Change Feed Iterator", function (this: Suite) { } }); // skipping this test for now due to flaky behavior - it.skip("check diagnostic for readNext operation.", async function () { + it.skip("check diagnostic for readNext operation.", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 10, changeFeedStartFrom: ChangeFeedStartFrom.Now(["0", 0]), @@ -213,9 +211,9 @@ describe("Change Feed Iterator", function (this: Suite) { }); }); - describe("test changefeed for entire container", function () { + describe("test changefeed for entire container", () => { let container: Container; - before(async function () { + beforeAll(async () => { const containerDef: ContainerDefinition = { partitionKey: { paths: ["/name"], @@ -239,7 +237,7 @@ describe("Change Feed Iterator", function (this: Suite) { } }); - it("ChangeFeedStartFrom.Beginning should fetch all results of all partitions", async function () { + it("ChangeFeedStartFrom.Beginning should fetch all results of all partitions", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { changeFeedStartFrom: ChangeFeedStartFrom.Beginning(), }; @@ -253,7 +251,7 @@ describe("Change Feed Iterator", function (this: Suite) { assert.equal(counter, 20, "20 items should be fetched"); }); - it("Iterator should start from last continuation token and fetch remaining results", async function () { + it("Iterator should start from last continuation token and fetch remaining results", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 1, changeFeedStartFrom: ChangeFeedStartFrom.Beginning(), @@ -282,7 +280,7 @@ describe("Change Feed Iterator", function (this: Suite) { assert.equal(counter2, 10, "Remaining number of items should be equal to 10"); }); - it("partitions should be iterated breadth first", async function () { + it("partitions should be iterated breadth first", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 1, changeFeedStartFrom: ChangeFeedStartFrom.Beginning(), @@ -305,7 +303,7 @@ describe("Change Feed Iterator", function (this: Suite) { assert.notEqual(partitionKey1, partitionKey2, "Partition keys should be different"); }); - it("ChangeFeedStartFrom.Now() should fetch all results from now on for entire container", async function () { + it("ChangeFeedStartFrom.Now() should fetch all results from now on for entire container", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 10, changeFeedStartFrom: ChangeFeedStartFrom.Now(), @@ -336,9 +334,9 @@ describe("Change Feed Iterator", function (this: Suite) { }); }); -describe("test changefeed for feed range", function () { +describe("test changefeed for feed range", () => { let container: Container; - before(async function () { + beforeAll(async () => { const containerDef: ContainerDefinition = { partitionKey: { paths: ["/name"], @@ -355,7 +353,7 @@ describe("test changefeed for feed range", function () { await container.items.create({ name: "sample4", key: i }); } }); - it("startFromBeginning should fetch all results", async function () { + it("startFromBeginning should fetch all results", async () => { const feedRanges = await container.getFeedRanges(); const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { @@ -370,7 +368,7 @@ describe("test changefeed for feed range", function () { } }); - it("Iterator should start from last continuation token and fetch remaining results", async function () { + it("Iterator should start from last continuation token and fetch remaining results", async () => { const feedRanges = await container.getFeedRanges(); const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 1, @@ -398,7 +396,7 @@ describe("test changefeed for feed range", function () { } }); - it("ChangeFeedStartFrom.Now() should fetch all results from now on", async function () { + it("ChangeFeedStartFrom.Now() should fetch all results from now on", async () => { const feedRanges = await container.getFeedRanges(); const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { @@ -430,7 +428,7 @@ describe("test changefeed for feed range", function () { } }); - it("fetch results for more than one physical partitions", async function () { + it("fetch results for more than one physical partitions", async () => { const epkRange = new FeedRangeInternal("", "05C1DFFFFFFFF8"); const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { changeFeedStartFrom: ChangeFeedStartFrom.Beginning(epkRange), @@ -450,9 +448,9 @@ describe("test changefeed for feed range", function () { }); }); -describe("test changefeed allVersionsAndDeletes mode for entire container", function () { +describe("test changefeed allVersionsAndDeletes mode for entire container", () => { let container: Container; - before(async function () { + beforeAll(async () => { const newTimeStamp = ChangeFeedRetentionTimeSpan.fromMinutes(5); const changeFeedPolicy = new ChangeFeedPolicy(newTimeStamp); const containerDef: ContainerDefinition = { @@ -471,7 +469,7 @@ describe("test changefeed allVersionsAndDeletes mode for entire container", func ); await changeFeedAllVersionsInsertItems(container, 1, 5); }); - it("startFromBeginning is not supported", async function () { + it("startFromBeginning is not supported", async () => { try { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { changeFeedStartFrom: ChangeFeedStartFrom.Beginning(), @@ -493,7 +491,7 @@ describe("test changefeed allVersionsAndDeletes mode for entire container", func } }); - it("validate changefeed results", async function () { + it("validate changefeed results", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 5, changeFeedStartFrom: ChangeFeedStartFrom.Now(), @@ -585,14 +583,14 @@ describe("test changefeed allVersionsAndDeletes mode for entire container", func } assert.strictEqual(counter, 20, "20 results should be fetched"); }); - after(async function () { + afterAll(async () => { await container.delete(); }); }); -describe("test changefeed allVersionsAndDeletes mode for a feed range", function () { +describe("test changefeed allVersionsAndDeletes mode for a feed range", () => { let container: Container; - before(async function () { + beforeAll(async () => { const newTimeStamp = ChangeFeedRetentionTimeSpan.fromMinutes(5); const changeFeedPolicy = new ChangeFeedPolicy(newTimeStamp); const containerDef: ContainerDefinition = { @@ -611,7 +609,7 @@ describe("test changefeed allVersionsAndDeletes mode for a feed range", function ); await changeFeedAllVersionsInsertItems(container, 1, 5); }); - it("startFromBeginning is not supported", async function () { + it("startFromBeginning is not supported", async () => { try { const feedRanges = await container.getFeedRanges(); const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { @@ -634,7 +632,7 @@ describe("test changefeed allVersionsAndDeletes mode for a feed range", function } }); - it("validate changefeed results", async function () { + it("validate changefeed results", async () => { const feedRanges = await container.getFeedRanges(); const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 5, @@ -726,14 +724,14 @@ describe("test changefeed allVersionsAndDeletes mode for a feed range", function } assert.strictEqual(counter, 5, "5 results should be fetched"); }); - after(async function () { + afterAll(async () => { await container.delete(); }); }); -describe("test changefeed allVersionsAndDeletes mode for a partition key", function () { +describe("test changefeed allVersionsAndDeletes mode for a partition key", () => { let container: Container; - before(async function () { + beforeAll(async () => { const newTimeStamp = ChangeFeedRetentionTimeSpan.fromMinutes(5); const changeFeedPolicy = new ChangeFeedPolicy(newTimeStamp); const containerDef: ContainerDefinition = { @@ -752,7 +750,7 @@ describe("test changefeed allVersionsAndDeletes mode for a partition key", funct ); await changeFeedAllVersionsInsertItems(container, 1, 5); }); - it("startFromBeginning is not supported", async function () { + it("startFromBeginning is not supported", async () => { try { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { changeFeedStartFrom: ChangeFeedStartFrom.Beginning("sample1"), @@ -774,7 +772,7 @@ describe("test changefeed allVersionsAndDeletes mode for a partition key", funct } }); - it("validate changefeed results", async function () { + it("validate changefeed results", async () => { const changeFeedIteratorOptions: ChangeFeedIteratorOptions = { maxItemCount: 5, changeFeedStartFrom: ChangeFeedStartFrom.Now("sample1"), @@ -866,7 +864,7 @@ describe("test changefeed allVersionsAndDeletes mode for a partition key", funct } assert.strictEqual(counter, 5, "5 results should be fetched"); }); - after(async function () { + afterAll(async () => { await container.delete(); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts index bcc93a05e4b1..71208288c1e8 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { RequestContext } from "../../../src/index.js"; import { CosmosClient } from "../../../src/index.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; @@ -265,7 +265,14 @@ describe("RetryPolicy", function () { }); }); }); -function getPlugins(responses: any[], lastEndpointCalled: string[]) { + +function getPlugins( + responses: any[], + lastEndpointCalled: string[], +): { + on: PluginOn; + plugin: (context: RequestContext) => Promise; +}[] { let index = 0; let requestIndex = 0; const plugins = [ diff --git a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts index cd4c3812880b..69febfe4f88c 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/crossPartition.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import * as util from "node:util"; import type { Container, ContainerDefinition } from "../../../src/index.js"; import { DataType, IndexKind } from "../../../src/index.js"; @@ -13,7 +13,7 @@ import { generateDocuments, } from "../common/TestHelpers.js"; import type { FeedResponse, FeedOptions } from "../../../src/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll } from "vitest"; function compare(key: string) { return function (a: any, b: any): number { @@ -27,10 +27,8 @@ function compare(key: string) { }; } -describe("Cross Partition", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || "30000"); - - describe("Validate Query", function () { +describe("Cross Partition", { timeout: 30000 }, () => { + describe("Validate Query", () => { const documentDefinitions = generateDocuments(20); const containerDefinition: ContainerDefinition = { @@ -62,9 +60,9 @@ describe("Cross Partition", function (this: Suite) { // - removes all the databases, // - creates a new database, - // - creates a new collecton, + // - creates a new collection, // - bulk inserts documents to the container - before(async function () { + beforeAll(async () => { await removeAllDatabases(); container = await getTestContainer( "Validate 中文 Query", @@ -260,7 +258,7 @@ describe("Cross Partition", function (this: Suite) { await validateAsyncIterator(queryIterator, expectedOrderIds, expectedCount); }; - it("Validate Parallel Query As String With maxDegreeOfParallelism = 0", async function () { + it("Validate Parallel Query As String With maxDegreeOfParallelism = 0", async () => { // simple order by query in string format const query = "SELECT * FROM root r"; const options = { @@ -275,7 +273,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Parallel Query As String With maxDegreeOfParallelism: -1", async function () { + it("Validate Parallel Query As String With maxDegreeOfParallelism: -1", async () => { // simple order by query in string format const query = "SELECT * FROM root r"; const options: FeedOptions = { @@ -292,7 +290,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Parallel Query As String With maxDegreeOfParallelism: 1", async function () { + it("Validate Parallel Query As String With maxDegreeOfParallelism: 1", async () => { // simple order by query in string format const query = "SELECT * FROM root r"; const options = { @@ -307,7 +305,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Parallel Query As String With maxDegreeOfParallelism: 3", async function () { + it("Validate Parallel Query As String With maxDegreeOfParallelism: 3", async () => { // simple order by query in string format const query = "SELECT * FROM root r"; const options: FeedOptions = { @@ -323,7 +321,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = 0", async function () { + it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = 0", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.spam"; const options = { @@ -343,7 +341,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = 1 #nosignoff", async function () { + it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = 1 #nosignoff", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.spam"; const options = { @@ -363,7 +361,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = 3", async function () { + it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = 3", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.spam"; const options = { @@ -383,7 +381,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = -1", async function () { + it("Validate Simple OrderBy Query As String With maxDegreeOfParallelism = -1", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.spam"; const options = { @@ -403,7 +401,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate DISTINCT Query", async function () { + it("Validate DISTINCT Query", async () => { // simple order by query in string format const query = "SELECT DISTINCT VALUE r.spam3 FROM root r"; const options = { @@ -414,7 +412,7 @@ describe("Cross Partition", function (this: Suite) { await executeQueryAndValidateResults({ query, options, expectedCount: 3 }); }); - it("Validate DISTINCT OrderBy Query", async function () { + it("Validate DISTINCT OrderBy Query", async () => { // simple order by query in string format const query = "SELECT DISTINCT VALUE r.spam3 FROM root r order by r.spam3 DESC"; const options = { @@ -431,7 +429,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate parallel DISTINCT Query", async function () { + it("Validate parallel DISTINCT Query", async () => { // simple order by query in string format const query = "SELECT DISTINCT VALUE r.spam3 FROM root r order by r.spam3"; const options = { @@ -450,7 +448,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate DISTINCT Query with maxItemCount = 1", async function () { + it("Validate DISTINCT Query with maxItemCount = 1", async () => { // simple order by query in string format const query = "SELECT DISTINCT VALUE r.spam3 FROM root r order by r.spam3"; const options = { @@ -467,7 +465,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate DISTINCT Query with maxItemCount = 20", async function () { + it("Validate DISTINCT Query with maxItemCount = 20", async () => { // simple order by query in string format const query = "SELECT DISTINCT VALUE r.spam3 FROM root r order by r.spam3"; const options = { @@ -484,7 +482,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Simple OrderBy Query As String", async function () { + it("Validate Simple OrderBy Query As String", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.spam"; const options = { @@ -503,7 +501,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Simple OrderBy Query", async function () { + it("Validate Simple OrderBy Query", async () => { // simple order by query const querySpec = { query: "SELECT * FROM root r order by r.spam", @@ -524,7 +522,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy Query With ASC", async function () { + it("Validate OrderBy Query With ASC", async () => { // an order by query with explicit ascending ordering const querySpec = { query: "SELECT * FROM root r order by r.spam ASC", @@ -545,7 +543,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy Query With DESC", async function () { + it("Validate OrderBy Query With DESC", async () => { // an order by query with explicit descending ordering const querySpec = { query: "SELECT * FROM root r order by r.spam DESC", @@ -569,7 +567,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy with top", async function () { + it("Validate OrderBy with top", async () => { // an order by query with top, total existing docs more than requested top count const topCount = 9; const querySpec = { @@ -593,7 +591,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy with Top Query (less results than top counts)", async function () { + it("Validate OrderBy with Top Query (less results than top counts)", async () => { // an order by query with top, total existing docs less than requested top count const topCount = 30; // sanity check @@ -616,7 +614,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Top Query with maxDegreeOfParallelism = 3", async function () { + it("Validate Top Query with maxDegreeOfParallelism = 3", async () => { // a top query const topCount = 6; // sanity check @@ -645,7 +643,7 @@ describe("Cross Partition", function (this: Suite) { assert.equal(results.length, Object.keys(uniqueIds).length); }); - it("Validate Top Query", async function () { + it("Validate Top Query", async () => { // a top query const topCount = 6; // sanity check @@ -671,7 +669,7 @@ describe("Cross Partition", function (this: Suite) { assert.equal(results.length, Object.keys(uniqueIds).length); }); - it("Validate Top Query (with 0 topCount)", async function () { + it("Validate Top Query (with 0 topCount)", async () => { // a top query const topCount = 0; // sanity check @@ -697,7 +695,7 @@ describe("Cross Partition", function (this: Suite) { assert.equal(results.length, Object.keys(uniqueIds).length); }); - it("Validate Parametrized Top Query", async function () { + it("Validate Parametrized Top Query", async () => { // a top query const topCount = 6; // sanity check @@ -727,7 +725,7 @@ describe("Cross Partition", function (this: Suite) { assert.equal(results.length, Object.keys(uniqueIds).length); }); - it("Validate OrderBy with Parametrized Top Query", async function () { + it("Validate OrderBy with Parametrized Top Query", async () => { // a parametrized top order by query const topCount = 9; // sanity check @@ -756,7 +754,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy with Parametrized Predicate", async function () { + it("Validate OrderBy with Parametrized Predicate", async () => { // an order by query combined with parametrized predicate const querySpec = { query: "SELECT * FROM root r where r.cnt > @cnt order by r.spam", @@ -782,7 +780,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Error Handling - Orderby where types are noncomparable", async function () { + it("Validate Error Handling - Orderby where types are noncomparable", async () => { // test orderby with different order by item type // an order by query const query = { @@ -801,7 +799,7 @@ describe("Cross Partition", function (this: Suite) { } }); - it("Validate OrderBy Integer Query", async function () { + it("Validate OrderBy Integer Query", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.cnt"; const options = { @@ -820,7 +818,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy Floating Point Number Query", async function () { + it("Validate OrderBy Floating Point Number Query", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.number"; const options = { @@ -839,7 +837,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy Boolean Query", async function () { + it("Validate OrderBy Boolean Query", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.boolVar"; const options = { @@ -866,7 +864,7 @@ describe("Cross Partition", function (this: Suite) { } }); - it("Validate simple LIMIT OFFSET", async function () { + it("Validate simple LIMIT OFFSET", async () => { const limit = 1; const offset = 7; @@ -886,7 +884,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate filtered LIMIT OFFSET", async function () { + it("Validate filtered LIMIT OFFSET", async () => { const limit = 1; const offset = 2; @@ -908,7 +906,7 @@ describe("Cross Partition", function (this: Suite) { // TODO Add test for OFFSET LIMT filtered on partition - it("Validate OrderBy Query With ASC and LIMIT 2 and OFFSET 10", async function () { + it("Validate OrderBy Query With ASC and LIMIT 2 and OFFSET 10", async () => { const limit = 2; const offset = 10; @@ -935,7 +933,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate OrderBy Query With ASC and LIMIT 0 and OFFSET 5", async function () { + it("Validate OrderBy Query With ASC and LIMIT 0 and OFFSET 5", async () => { const limit = 5; const offset = 0; @@ -962,7 +960,7 @@ describe("Cross Partition", function (this: Suite) { }); }); - it("Validate Failure", async function () { + it("Validate Failure", async () => { // simple order by query in string format const query = "SELECT * FROM root r order by r.spam"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts index 3f8976954fd2..e2c112410bf5 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/encoding.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { IndexingMode } from "../../../src/index.js"; import { getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach, afterEach } from "vitest"; const testDoc = { id: "ABC", @@ -11,20 +11,18 @@ const testDoc = { "€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€", }; -describe("Create And Read Validation", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - +describe("Create And Read Validation", { timeout: 10000 }, () => { const dateTime = new Date(); const databaseId = "encodingTestDB"; - afterEach(async function () { + afterEach(async () => { await removeAllDatabases(); }); - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); }); - it("check if the document from db matches the actual document", async function () { + it("check if the document from db matches the actual document", async () => { // Create Database const database = await getTestDatabase(databaseId); const containerBody = { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts index 4dad20aa38cb..695d9c869880 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts index c64b43290d86..7b547bdb4b7e 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/failover.spec.ts @@ -1,12 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ + import type { CosmosClientOptions, PluginConfig } from "../../../src/index.js"; import { CosmosClient, PluginOn } from "../../../src/index.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; -import assert from "node:assert"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect } from "vitest"; const endpoint = "https://failovertest.documents.azure.com/"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts index 2687c4b38f12..a0a5dd7b17eb 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/fullTextSearch.spec.ts @@ -1,14 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; -import { ContainerDefinition, Container } from "../../../src/index.js"; + +import type { ContainerDefinition, Container } from "../../../src/index.js"; import items from "./text-3properties-1536dimensions-100documents.js"; import { getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; - -describe.skip("Validate full text search queries", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 20000); +import { describe, it, assert, beforeAll } from "vitest"; +describe.skip("Validate full text search queries", { timeout: 20000 }, () => { const partitionKey = "id"; let container: Container; const containerDefinition: ContainerDefinition = { @@ -243,7 +241,7 @@ describe.skip("Validate full text search queries", function (this: Suite) { const containerOptions = { offerThroughput: 25000 }; - before(async function () { + beforeAll(async () => { await removeAllDatabases(); container = await getTestContainer( "Validate FTS Query", @@ -256,7 +254,7 @@ describe.skip("Validate full text search queries", function (this: Suite) { } }); - it("FetchNext: should return correct expected values for all the queries", async function () { + it("FetchNext: should return correct expected values for all the queries", async () => { for (const [query, { expected1, expected2 }] of queriesMap) { const queryOptions = { allowUnboundedNonStreamingQueries: true, forceQueryPlan: true }; const queryIterator = container.items.query(query, queryOptions); @@ -278,7 +276,7 @@ describe.skip("Validate full text search queries", function (this: Suite) { } }); - it("FetchAll: should return correct expected values for all the queries", async function () { + it("FetchAll: should return correct expected values for all the queries", async () => { for (const [query, { expected1, expected2 }] of queriesMap) { const queryOptions = { allowUnboundedNonStreamingQueries: true }; const queryIterator = container.items.query(query, queryOptions); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts index 4ad90c525867..1312e03b0177 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/multiregion.spec.ts @@ -1,13 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ -import assert from "node:assert"; + import { CosmosClient } from "../../../src/index.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import type { PluginConfig, CosmosClientOptions } from "../../../src/index.js"; import { PluginOn } from "../../../src/index.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect } from "vitest"; const endpoint = "https://failovertest.documents.azure.com/"; @@ -112,10 +111,8 @@ const collectionResponse = { diagnostics: getEmptyCosmosDiagnostics(), }; -describe("Multi-region tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || "30000"); - - it("Preferred locations should be honored for readEndpoint", async function () { +describe("Multi-region tests", { timeout: 30000 }, () => { + it("Preferred locations should be honored for readEndpoint", async () => { let requestIndex = 0; let lastEndpointCalled = ""; const responses = [ @@ -159,7 +156,7 @@ describe("Multi-region tests", function (this: Suite) { client.dispose(); }); - it("Preferred locations should be honored for writeEndpoint", async function () { + it("Preferred locations should be honored for writeEndpoint", async () => { let requestIndex = 0; let lastEndpointCalled = ""; const responses = [ diff --git a/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts index fc1c0894bec8..93471464a215 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/proxy.spec.ts @@ -1,7 +1,6 @@ -import { describe, it, assert } from "vitest"; - -// Copyright (c) Microsoft Corporation. +// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + // import * as http from "http"; // import { Context } from "mocha"; // import * as net from "net"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts index db2296d9bfcd..9ece61a24482 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/query.spec.ts @@ -1,21 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { Container, FeedOptions } from "../../../src/index.js"; import { getTestContainer, getTestDatabase, removeAllDatabases } from "../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; const doc = { id: "myId", pk: "pk" }; -describe("ResourceLink Trimming of leading and trailing slashes", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +describe("ResourceLink Trimming of leading and trailing slashes", { timeout: 10000 }, () => { const containerId = "testcontainer"; - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); }); - it("validate correct execution of query using named container link with leading and trailing slashes", async function () { + it("validate correct execution of query using named container link with leading and trailing slashes", async () => { const containerDefinition = { id: containerId, partitionKey: { @@ -40,15 +39,14 @@ describe("ResourceLink Trimming of leading and trailing slashes", function (this }); }); -describe("Test Query Metrics", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 20000); +describe("Test Query Metrics", { timeout: 20000 }, () => { const collectionId = "testCollection3"; - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); }); - it("validate that query metrics are correct for a single partition query", async function () { + it("validate that query metrics are correct for a single partition query", async () => { const database = await getTestDatabase("query metrics test db"); const collectionDefinition = { @@ -91,14 +89,12 @@ describe("Test Query Metrics", function (this: Suite) { }); }); -describe("Partition key in FeedOptions", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - - beforeEach(async function () { +describe("Partition key in FeedOptions", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - it("passing partition key in FeedOptions", async function () { + it("passing partition key in FeedOptions", async () => { const containerDefinition = { id: "testcontainer", partitionKey: { @@ -125,9 +121,7 @@ describe("Partition key in FeedOptions", function (this: Suite) { }); }); -describe("aggregate query over null value", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - +describe("aggregate query over null value", { timeout: 10000 }, () => { const aggregateQueryOverNullValue = async function ( testName: string, containerName: string, @@ -174,27 +168,25 @@ describe("aggregate query over null value", function (this: Suite) { assert.strictEqual(resources[0].source, null); }; - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); }); - it("should execute successfully for container with single partition", async function () { + it("should execute successfully for container with single partition", async () => { await aggregateQueryOverNullValue("SinglePartition", "SinglePartition", 400); }); - it("should execute successfully for container with multiple partitions", async function () { + it("should execute successfully for container with multiple partitions", async () => { await aggregateQueryOverNullValue("MultiplePartitons", "MultiplePartitons", 10100); }); }); -describe("Test Index metrics", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 20000); - - beforeEach(async function () { +describe("Test Index metrics", { timeout: 20000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - it("validate that index metrics are correct", async function () { + it("validate that index metrics are correct", async () => { const collectionId = "testCollection3"; const createdContainerSinglePartition = await setupContainer( "index metrics test db", @@ -211,7 +203,7 @@ describe("Test Index metrics", function (this: Suite) { await validateIndexMetrics(createdContainerMultiPartition, collectionId); }); - async function validateIndexMetrics(container: Container, collectionId: string) { + async function validateIndexMetrics(container: Container, collectionId: string): Promise { const doc1 = { id: "myId1", pk: "pk1", name: "test1" }; const doc2 = { id: "myId2", pk: "pk2", name: "test2" }; const doc3 = { id: "myId3", pk: "pk2", name: "test2" }; @@ -239,7 +231,11 @@ describe("Test Index metrics", function (this: Suite) { } } } - async function setupContainer(datbaseName: string, collectionId: string, throughput?: number) { + async function setupContainer( + datbaseName: string, + collectionId: string, + throughput?: number, + ): Promise { const database = await getTestDatabase(datbaseName); const collectionDefinition = { diff --git a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts index c4df8e01141f..c72916217304 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { ClientSideMetrics, QueryMetrics, diff --git a/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts index 438f529550a1..b56ea5852bc3 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts @@ -1,7 +1,7 @@ -import { describe, it, assert } from "vitest"; - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + +import { describe, it } from "vitest"; // import assert from "assert"; // import { ConnectionPolicy, Constants, CosmosClient, RetryOptions } from "../../src"; // import * as request from "../../src/request"; @@ -41,7 +41,7 @@ describe("retry policy tests", function () { // } // TODO: need to fix this, the stubbing doesn't work with the new way we work - xit("throttle retry policy test default retryAfter", async function () { + it.skip("throttle retry policy test default retryAfter", async function () { // connectionPolicy.RetryOptions = new RetryOptions(5); // const client = new CosmosClient({endpoint, key: masterKey, connectionPolicy}); // const { result: db } = await client.createDatabase({ id: "sample database" }); @@ -65,7 +65,7 @@ describe("retry policy tests", function () { // client.getDatabaseAccount = originalGetDatabaseAccount; }); - xit("throttle retry policy test fixed retryAfter", async function () { + it.skip("throttle retry policy test fixed retryAfter", async function () { // connectionPolicy.RetryOptions = new RetryOptions(5, 2000); // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); @@ -90,7 +90,7 @@ describe("retry policy tests", function () { // client.getDatabaseAccount = originalGetDatabaseAccount; }); - xit("throttle retry policy test max wait time", async function () { + it.skip("throttle retry policy test max wait time", async function () { // connectionPolicy.RetryOptions = new RetryOptions(5, 2000, 3); // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); @@ -111,7 +111,7 @@ describe("retry policy tests", function () { // client.getDatabaseAccount = originalGetDatabaseAccount; }); - xit("default retry policy validate create failure", async function () { + it.skip("default retry policy validate create failure", async function () { // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); // const { result: collection } = await client.createCollection(db._self, collectionDefinition); @@ -127,7 +127,7 @@ describe("retry policy tests", function () { // request._createRequestObjectStub = global.originalFunc; }); - xit("default retry policy validate read success", async function () { + it.skip("default retry policy validate read success", async function () { // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); // const { result: collection } = await client.createCollection(db._self, collectionDefinition); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts index 356c2bea8e09..0f2c357ed767 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/split.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ + import type { Container } from "../../../src/index.js"; import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../common/TestHelpers.js"; import type { CosmosClientOptions, PluginConfig } from "../../../src/index.js"; @@ -8,8 +8,7 @@ import { Constants, CosmosClient, PluginOn } from "../../../src/index.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; import { SubStatusCodes } from "../../../src/common/index.js"; -import assert from "node:assert"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect, beforeAll } from "vitest"; const splitError = new Error("Fake Partition Split") as any; splitError.code = 410; @@ -30,7 +29,7 @@ const documentDefinitions = generateDocuments(20); describe("Partition Splits", () => { let container: Container; - before(async function () { + beforeAll(async () => { await removeAllDatabases(); container = await getTestContainer( "Partition Splits", diff --git a/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts index 6ac7068b4dea..c973d8d010a9 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/sslVerification.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { CosmosClient } from "../../../src/index.js"; import { getTestDatabase } from "../common/TestHelpers.js"; import https from "node:https"; @@ -10,8 +10,8 @@ const endpoint = "https://localhost:8081"; const masterKey = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="; -describe("Validate SSL verification check for emulator #nosignoff", function () { - it("should throw exception", async function () { +describe("Validate SSL verification check for emulator #nosignoff", () => { + it("should throw exception", async () => { try { const client = new CosmosClient({ endpoint, @@ -26,7 +26,7 @@ describe("Validate SSL verification check for emulator #nosignoff", function () } }); - it("disable ssl check via agent", async function () { + it("disable ssl check via agent", async () => { const client = new CosmosClient({ endpoint, key: masterKey, diff --git a/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts index ffadf9271a7b..98151899d4a3 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/timeout.spec.ts @@ -1,20 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -/* eslint-disable no-unused-expressions */ -import assert from "node:assert"; + import type { Container } from "../../../src/index.js"; import { CosmosClient } from "../../../src/index.js"; import { addEntropy, removeAllDatabases } from "../common/TestHelpers.js"; import { endpoint } from "../common/_testConfig.js"; import { masterKey } from "../common/_fakeTestSecrets.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect, beforeEach } from "vitest"; -describe("Timeout", function () { - beforeEach(async function () { +describe("Timeout", () => { + beforeEach(async () => { await removeAllDatabases(); }); - it("successfully exits queries after a timeout duration", async function () { + it("successfully exits queries after a timeout duration", async () => { const clientA = new CosmosClient({ endpoint, key: masterKey, @@ -65,7 +64,7 @@ describe("Timeout", function () { }); }); -async function createItem(container: Container) { +async function createItem(container: Container): Promise { const { resource: { id }, } = await container.items.create({ diff --git a/sdk/cosmosdb/cosmos/test/tsconfig.json b/sdk/cosmosdb/cosmos/test/tsconfig.json deleted file mode 100644 index 237919c4352c..000000000000 --- a/sdk/cosmosdb/cosmos/test/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "declaration": true, - "module": "commonjs", - "moduleResolution": "node", - "importHelpers": true, - "noImplicitAny": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "preserveConstEnums": true, - "removeComments": false, - "target": "es6", - "lib": ["es2019"], - "sourceMap": true, - "newLine": "LF", - "composite": true, - "noUnusedLocals": true - } -} diff --git a/sdk/cosmosdb/cosmos/tsconfig.json b/sdk/cosmosdb/cosmos/tsconfig.json index 133e19ad75b0..494466b2b107 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.json +++ b/sdk/cosmosdb/cosmos/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../../tsconfig", "compilerOptions": { + "outDir": "dist-esm", "module": "NodeNext", "strict": false, "noImplicitAny": true, From 7fc7c52b5bcd829af522a6a1f2e6d97a6b0e67df Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 19:55:12 -0500 Subject: [PATCH 13/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- ...ngOrderByDistinctEndpointComponent.spec.ts | 2 +- ...nStreamingOrderByEndpointComponent.spec.ts | 2 +- .../public/functional/item/batch.item.spec.ts | 28 +- .../public/functional/item/bulk.item.spec.ts | 90 +- .../test/public/functional/item/item.spec.ts | 830 +++++++++--------- .../functional/item/itemIdEncoding.spec.ts | 13 +- .../test/public/functional/sproc.spec.ts | 7 +- .../test/public/functional/trigger.spec.ts | 20 +- .../cosmos/test/public/functional/ttl.spec.ts | 12 +- .../cosmos/test/public/indexMetrics.spec.ts | 14 +- .../public/integration/aggregateQuery.spec.ts | 36 +- .../integration/aggregates/groupBy.spec.ts | 3 +- .../public/integration/client.retry.spec.ts | 12 +- .../integration/extractPartitionKey.spec.ts | 18 +- .../public/integration/queryMetrics.spec.ts | 10 +- .../test/public/integration/retry.spec.ts | 12 +- sdk/test-utils/test-utils-vitest/src/index.ts | 1 + sdk/test-utils/test-utils-vitest/src/utils.ts | 20 + 18 files changed, 579 insertions(+), 551 deletions(-) create mode 100644 sdk/test-utils/test-utils-vitest/src/utils.ts diff --git a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts index 60ba73c5283f..9a1a549d8dea 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { ExecutionContext } from "../../../../src/queryExecutionContext/index.js"; import { NonStreamingOrderByDistinctEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.js"; import type { QueryInfo } from "../../../../src/request/ErrorResponse.js"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts index 49c11f9ee373..b12e10903714 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { ExecutionContext } from "../../../../src/queryExecutionContext/index.js"; import { NonStreamingOrderByEndpointComponent } from "../../../../src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts index 4093c4527e43..ecf1d811a89c 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/batch.item.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import type { Container, OperationResponse } from "../../../../src/index.js"; import { CosmosClient, @@ -16,10 +15,10 @@ import { PartitionKeyKind } from "../../../../src/documents/index.js"; import { endpoint } from "../../common/_testConfig.js"; import { masterKey } from "../../common/_fakeTestSecrets.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll } from "vitest"; -describe("test batch operations", function () { - describe("v2 multi partition container", async function () { +describe("test batch operations", () => { + describe("v2 multi partition container", async () => { let container: Container; let createItemId: string; let otherItemId: string; @@ -27,7 +26,8 @@ describe("test batch operations", function () { let replaceItemId: string; let deleteItemId: string; let patchItemId: string; - before(async function () { + + beforeAll(async () => { const client = new CosmosClient({ key: masterKey, endpoint }); const db = await client.databases.createIfNotExists({ id: "patchDb" }); const contResponse = await db.database.containers.createIfNotExists({ @@ -61,7 +61,8 @@ describe("test batch operations", function () { class: "2010", }); }); - it("can batch all operation types", async function () { + + it("can batch all operation types", async () => { const operations: OperationInput[] = [ { operationType: BulkOperationType.Create, @@ -98,7 +99,8 @@ describe("test batch operations", function () { assert.strictEqual(response.result[3].statusCode, 204); assert.strictEqual(response.result[4].statusCode, 200); }); - it("rolls back prior operations when one fails", async function () { + + it("rolls back prior operations when one fails", async () => { const operations: OperationInput[] = [ { operationType: BulkOperationType.Upsert, @@ -117,7 +119,8 @@ describe("test batch operations", function () { assert.strictEqual(readItem, undefined); assert(isOperationResponse(deleteResponse.result[0])); }); - it("test diagnostics for batch api", async function () { + + it("test diagnostics for batch api", async () => { const operations: OperationInput[] = [ { operationType: BulkOperationType.Create, @@ -176,7 +179,7 @@ describe("test batch operations", function () { ); } }); - describe("v2 multi partition container - hierarchical partitions", async function () { + describe("v2 multi partition container - hierarchical partitions", async () => { let container: Container; let createItemId: string; let otherItemId: string; @@ -184,7 +187,7 @@ describe("test batch operations", function () { let replaceItemId: string; let deleteItemId: string; let patchItemId: string; - before(async function () { + beforeAll(async () => { const client = new CosmosClient({ key: masterKey, endpoint }); const db = await client.databases.createIfNotExists({ id: "patchDb" }); const contResponse = await db.database.containers.createIfNotExists({ @@ -222,7 +225,7 @@ describe("test batch operations", function () { class: "2010", }); }); - it("can batch all operation types", async function () { + it("can batch all operation types", async () => { const operations: OperationInput[] = [ { operationType: BulkOperationType.Create, @@ -259,7 +262,8 @@ describe("test batch operations", function () { assert.strictEqual(response.result[3].statusCode, 204); assert.strictEqual(response.result[4].statusCode, 200); }); - it("rolls back prior operations when one fails", async function () { + + it("rolls back prior operations when one fails", async () => { const operations: OperationInput[] = [ { operationType: BulkOperationType.Upsert, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts index ea71cc15e5b4..4c473ebf1d3a 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/bulk.item.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import type { BulkOptions, Container, @@ -31,12 +30,12 @@ import { endpoint } from "../../common/_testConfig.js"; import { masterKey } from "../../common/_fakeTestSecrets.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; import { SubStatusCodes } from "../../../../src/common/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll, afterAll } from "vitest"; -describe("test bulk operations", async function () { - describe("Check size based splitting of batches", function () { +describe("test bulk operations", async () => { + describe("Check size based splitting of batches", () => { let container: Container; - before(async function () { + beforeAll(async () => { container = await getTestContainer("bulk container", undefined, { partitionKey: { paths: ["/key"], @@ -45,10 +44,10 @@ describe("test bulk operations", async function () { throughput: 5000, }); }); - after(async () => { + afterAll(async () => { await container.database.delete(); }); - it("Check case when cumulative size of all operations is less than threshold", async function () { + it("Check case when cumulative size of all operations is less than threshold", async () => { const operations: OperationInput[] = [...Array(10).keys()].map( () => ({ @@ -61,7 +60,7 @@ describe("test bulk operations", async function () { assert.strictEqual(res.statusCode, 201, `Status should be 201 for operation ${index}`), ); }); - it("Check case when cumulative size of all operations is greater than threshold - payload size is 5x threshold", async function () { + it("Check case when cumulative size of all operations is greater than threshold - payload size is 5x threshold", async () => { const operations: OperationInput[] = [...Array(10).keys()].map( () => ({ @@ -77,7 +76,7 @@ describe("test bulk operations", async function () { assert.strictEqual(res.statusCode, 201, `Status should be 201 for operation ${index}`), ); }); - it("Check case when cumulative size of all operations is greater than threshold - payload size is 25x threshold", async function () { + it("Check case when cumulative size of all operations is greater than threshold - payload size is 25x threshold", async () => { const operations: OperationInput[] = [...Array(50).keys()].map( () => ({ @@ -95,13 +94,13 @@ describe("test bulk operations", async function () { ); }); }); - describe("v1 container", async function () { - describe("multi partition container", async function () { + describe("v1 container", async () => { + describe("multi partition container", async () => { let container: Container; let readItemId: string; let replaceItemId: string; let deleteItemId: string; - before(async function () { + beforeAll(async () => { container = await getTestContainer("bulk container", undefined, { partitionKey: { paths: ["/key"], @@ -128,10 +127,10 @@ describe("test bulk operations", async function () { class: "2010", }); }); - after(async () => { + afterAll(async () => { await container.database.delete(); }); - it("multi partition container handles create, upsert, replace, delete", async function () { + it("multi partition container handles create, upsert, replace, delete", async () => { const operations = [ { operationType: BulkOperationType.Create, @@ -175,7 +174,7 @@ describe("test bulk operations", async function () { assert.equal(response[4].resourceBody.name, "nice"); assert.equal(response[4].statusCode, 200); }); - it("Check case when cumulative size of all operations is less than threshold", async function () { + it("Check case when cumulative size of all operations is less than threshold", async () => { const operations: OperationInput[] = [...Array(10).keys()].map( () => ({ @@ -188,7 +187,7 @@ describe("test bulk operations", async function () { assert.strictEqual(res.statusCode, 201, `Status should be 201 for operation ${index}`), ); }); - it("Check case when cumulative size of all operations is greater than threshold", async function () { + it("Check case when cumulative size of all operations is greater than threshold", async () => { const operations: OperationInput[] = [...Array(10).keys()].map( () => ({ @@ -204,7 +203,7 @@ describe("test bulk operations", async function () { assert.strictEqual(res.statusCode, 201, `Status should be 201 for operation ${index}`), ); }); - it("Check case when cumulative size of all operations is greater than threshold", async function () { + it("Check case when cumulative size of all operations is greater than threshold", async () => { const operations: OperationInput[] = [...Array(50).keys()].map( () => ({ @@ -222,12 +221,12 @@ describe("test bulk operations", async function () { ); }); }); - describe("single partition container", async function () { + describe("single partition container", async () => { let container: Container; let deleteItemId: string; let readItemId: string; let replaceItemId: string; - before(async function () { + beforeAll(async () => { container = await getTestContainer("bulk container"); deleteItemId = addEntropy("item2"); readItemId = addEntropy("item2"); @@ -243,7 +242,7 @@ describe("test bulk operations", async function () { class: "2010", }); }); - it("deletes operation with default partition", async function () { + it("deletes operation with default partition", async () => { const operation: OperationInput = { operationType: BulkOperationType.Delete, id: deleteItemId, @@ -252,7 +251,7 @@ describe("test bulk operations", async function () { const deleteResponse = await container.items.bulk([operation]); assert.equal(deleteResponse[0].statusCode, 204); }); - it("read operation with default partition", async function () { + it("read operation with default partition", async () => { const operation: OperationInput = { operationType: BulkOperationType.Read, id: readItemId, @@ -266,7 +265,7 @@ describe("test bulk operations", async function () { "Read Items id should match", ); }); - it("create operation with default partition", async function () { + it("create operation with default partition", async () => { const id = "testId"; const createOp: OperationInput = { operationType: BulkOperationType.Create, @@ -287,7 +286,7 @@ describe("test bulk operations", async function () { assert.strictEqual(readResponse[1].statusCode, 200); assert.strictEqual(readResponse[1].resourceBody.id, id, "Read item's id should match"); }); - it("read operation with partition split", async function () { + it("read operation with partition split", async () => { // using plugins generate split response from backend const splitContainer = await getSplitContainer(); await splitContainer.items.create({ @@ -313,7 +312,7 @@ describe("test bulk operations", async function () { await splitContainer.database.delete(); }); - it("container handles Create, Read, Upsert, Delete opertion with partition split", async function () { + it("container handles Create, Read, Upsert, Delete opertion with partition split", async () => { const operations = [ { operationType: BulkOperationType.Create, @@ -403,8 +402,8 @@ describe("test bulk operations", async function () { } }); }); - describe("v2 container", function () { - describe("multi partition container", async function () { + describe("v2 container", () => { + describe("multi partition container", async () => { let readItemId: string; let replaceItemId: string; let patchItemId: string; @@ -448,7 +447,8 @@ describe("test bulk operations", async function () { documentToCreate: [], operations: [], }; - async function runBulkTestDataSet(dataset: BulkTestDataSet) { + + async function runBulkTestDataSet(dataset: BulkTestDataSet): Promise { const client = new CosmosClient({ key: masterKey, endpoint, @@ -515,8 +515,8 @@ describe("test bulk operations", async function () { propertysToMatch, }; } - describe("handles create, upsert, patch, replace, delete", async function () { - it("Hierarchical Partitions with two keys", async function () { + describe("handles create, upsert, patch, replace, delete", async () => { + it("Hierarchical Partitions with two keys", async () => { readItemId = addEntropy("item1"); const createItemWithBooleanPartitionKeyId = addEntropy( "createItemWithBooleanPartitionKeyId", @@ -710,7 +710,7 @@ describe("test bulk operations", async function () { }; await runBulkTestDataSet(dataset); }); - it("Hierarchical Partitions with three keys", async function () { + it("Hierarchical Partitions with three keys", async () => { readItemId = addEntropy("item1"); const createItemWithBooleanPartitionKeyId = addEntropy( "createItemWithBooleanPartitionKeyId", @@ -908,7 +908,7 @@ describe("test bulk operations", async function () { await runBulkTestDataSet(dataset); }); }); - it("respects order", async function () { + it("respects order", async () => { readItemId = addEntropy("item1"); const dataset: BulkTestDataSet = { ...defaultBulkTestDataSet, @@ -939,7 +939,7 @@ describe("test bulk operations", async function () { }; await runBulkTestDataSet(dataset); }); - it("424 errors for operations after an error when continueOnError is set to false", async function () { + it("424 errors for operations after an error when continueOnError is set to false", async () => { const dataset: BulkTestDataSet = { ...defaultBulkTestDataSet, dbName: addEntropy("424 errors"), @@ -966,7 +966,7 @@ describe("test bulk operations", async function () { }; await runBulkTestDataSet(dataset); }); - it("Continues after errors with default value of continueOnError true", async function () { + it("Continues after errors with default value of continueOnError true", async () => { const dataset: BulkTestDataSet = { ...defaultBulkTestDataSet, dbName: addEntropy("continueOnError"), @@ -991,7 +991,7 @@ describe("test bulk operations", async function () { }; await runBulkTestDataSet(dataset); }); - it("autogenerates IDs for Create operations", async function () { + it("autogenerates IDs for Create operations", async () => { const dataset: BulkTestDataSet = { ...defaultBulkTestDataSet, dbName: addEntropy("autogenerateIDs"), @@ -1009,7 +1009,7 @@ describe("test bulk operations", async function () { }; await runBulkTestDataSet(dataset); }); - it("handles operations with null, undefined, and 0 partition keys", async function () { + it("handles operations with null, undefined, and 0 partition keys", async () => { const item1Id = addEntropy("item1"); const item2Id = addEntropy("item2"); const item3Id = addEntropy("item2"); @@ -1057,11 +1057,11 @@ describe("test bulk operations", async function () { await runBulkTestDataSet(dataset); }); }); - describe("multi partition container - nested partition key", async function () { + describe("multi partition container - nested partition key", async () => { let container: Container; let createItemId: string; let upsertItemId: string; - before(async function () { + beforeAll(async () => { container = await getTestContainer("bulk container", undefined, { partitionKey: { paths: ["/nested/key"], @@ -1072,7 +1072,7 @@ describe("test bulk operations", async function () { createItemId = addEntropy("createItem"); upsertItemId = addEntropy("upsertItem"); }); - it("creates an item with nested object partition key", async function () { + it("creates an item with nested object partition key", async () => { const operations: OperationInput[] = [ { operationType: BulkOperationType.Create, @@ -1098,9 +1098,9 @@ describe("test bulk operations", async function () { assert.equal(createResponse[0].statusCode, 201); }); }); - describe("multi partitioned container with many items handle partition split", async function () { + describe("multi partitioned container with many items handle partition split", async () => { let container: Container; - before(async function () { + beforeAll(async () => { let responseIndex = 0; // On every 50th request, return a 410 error const plugins: PluginConfig[] = [ @@ -1142,7 +1142,7 @@ describe("test bulk operations", async function () { } }); - it("check multiple partition splits during bulk", async function () { + it("check multiple partition splits during bulk", async () => { const operations: OperationInput[] = []; for (let i = 0; i < 300; i++) { operations.push({ @@ -1163,12 +1163,12 @@ describe("test bulk operations", async function () { }); }); }); - describe("test diagnostics for bulk", async function () { + describe("test diagnostics for bulk", async () => { let container: Container; let readItemId: string; let replaceItemId: string; let deleteItemId: string; - before(async function () { + beforeAll(async () => { container = await getTestContainer("bulk container for diagnostics", undefined, { partitionKey: { paths: ["/key"], @@ -1195,10 +1195,10 @@ describe("test bulk operations", async function () { class: "2010", }); }); - after(async () => { + afterAll(async () => { await container.database.delete(); }); - it("test diagnostics for bulk", async function () { + it("test diagnostics for bulk", async () => { const operations = [ { operationType: BulkOperationType.Create, diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts index aaf402d1de92..c85f0261bdde 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/item.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { Container, ContainerDefinition, @@ -33,7 +33,7 @@ import { } from "../../../../src/documents/index.js"; import { PriorityLevel } from "../../../../src/documents/PriorityLevel.js"; import { getCurrentTimestampInMs } from "../../../../src/utils/time.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach, beforeAll } from "vitest"; /** * Tests Item api. @@ -76,7 +76,7 @@ type CRUDTestDataSet = { propertyToCheck?: string[]; }; -function extractNestedPropertyFromObject(obj: any, paths: string[] = []) { +function extractNestedPropertyFromObject(obj: any, paths: string[] = []): void { paths.reduce((ob: any, path: string) => { if (ob !== null && ob !== undefined && typeof ob === "object") { return ob[path]; @@ -192,11 +192,11 @@ async function CRUDTestRunner(dataset: CRUDTestDataSet, isUpsertTest: boolean): // update document } -describe("Item CRUD hierarchical partition", function (this: Suite) { - beforeEach(async function () { +describe("Item CRUD hierarchical partition", () => { + beforeEach(async () => { await removeAllDatabases(); }); - it("hierarchycal partitions", async function () { + it("hierarchycal partitions", async () => { const dbName = "hierarchical partition db"; const database = await getTestDatabase(dbName); const containerDef = { @@ -241,440 +241,443 @@ describe("Item CRUD hierarchical partition", function (this: Suite) { }); }); -describe("Create, Upsert, Read, Update, Replace, Delete Operations on Item", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { - await removeAllDatabases(); - }); +describe( + "Create, Upsert, Read, Update, Replace, Delete Operations on Item", + { timeout: 10000 }, + () => { + beforeEach(async () => { + await removeAllDatabases(); + }); - async function multipelPartitionCRUDTest(dataset: MultiCRUDTestDataSet): Promise { - const database = await getTestDatabase(dataset.dbName); - const { resource: containerdef } = await database.containers.create( - { ...dataset.containerDef, partitionKey: dataset.partitinKeyDef }, - dataset.containerRequestOps, - ); - const container = database.container(containerdef.id); - let returnedDocuments = await bulkInsertItems(container, dataset.documents); + async function multiplePartitionCRUDTest(dataset: MultiCRUDTestDataSet): Promise { + const database = await getTestDatabase(dataset.dbName); + const { resource: containerdef } = await database.containers.create( + { ...dataset.containerDef, partitionKey: dataset.partitinKeyDef }, + dataset.containerRequestOps, + ); + const container = database.container(containerdef.id); + let returnedDocuments = await bulkInsertItems(container, dataset.documents); - assert.equal(returnedDocuments.length, dataset.documents.length); - returnedDocuments.sort(function (doc1, doc2) { - return doc1.id.localeCompare(doc2.id); - }); - await bulkReadItems(container, returnedDocuments, dataset.partitinKeyDef); - const { resources: successDocuments } = await container.items.readAll().fetchAll(); - assert(successDocuments !== undefined, "error reading documents"); - assert.equal( - successDocuments.length, - returnedDocuments.length, - "Expected " + returnedDocuments.length + " documents to be succesfully read", - ); - successDocuments.sort(function (doc1, doc2) { - return doc1.id.localeCompare(doc2.id); - }); - assert.equal( - JSON.stringify(successDocuments), - JSON.stringify(returnedDocuments), - "Unexpected documents are returned", - ); - returnedDocuments.forEach(function (document) { - document.prop ? ++document.prop : null; // eslint-disable-line no-unused-expressions - }); - const newReturnedDocuments = await bulkReplaceItems( - container, - returnedDocuments, - dataset.partitinKeyDef, - ); - returnedDocuments = newReturnedDocuments; - await bulkQueryItemsWithPartitionKey( - container, - returnedDocuments, - dataset.singleDocFetchQuery, - dataset.parameterGenerator, - ); - const querySpec = { - query: "SELECT * FROM Root", - }; - const { resources: results } = await container.items - .query(querySpec, { enableScanInQuery: true }) - .fetchAll(); - assert(results !== undefined, "error querying documents"); - results.sort(function (doc1, doc2) { - return doc1.id.localeCompare(doc2.id); - }); - assert.equal( - results.length, - returnedDocuments.length, - "Expected " + returnedDocuments.length + " documents to be succesfully queried", - ); - assert.equal( - JSON.stringify(results), - JSON.stringify(returnedDocuments), - "Unexpected query results", - ); + assert.equal(returnedDocuments.length, dataset.documents.length); + returnedDocuments.sort(function (doc1, doc2) { + return doc1.id.localeCompare(doc2.id); + }); + await bulkReadItems(container, returnedDocuments, dataset.partitinKeyDef); + const { resources: successDocuments } = await container.items.readAll().fetchAll(); + assert(successDocuments !== undefined, "error reading documents"); + assert.equal( + successDocuments.length, + returnedDocuments.length, + "Expected " + returnedDocuments.length + " documents to be successfully read", + ); + successDocuments.sort(function (doc1, doc2) { + return doc1.id.localeCompare(doc2.id); + }); + assert.equal( + JSON.stringify(successDocuments), + JSON.stringify(returnedDocuments), + "Unexpected documents are returned", + ); + returnedDocuments.forEach(function (document) { + document.prop ? ++document.prop : null; + }); + const newReturnedDocuments = await bulkReplaceItems( + container, + returnedDocuments, + dataset.partitinKeyDef, + ); + returnedDocuments = newReturnedDocuments; + await bulkQueryItemsWithPartitionKey( + container, + returnedDocuments, + dataset.singleDocFetchQuery, + dataset.parameterGenerator, + ); + const querySpec = { + query: "SELECT * FROM Root", + }; + const { resources: results } = await container.items + .query(querySpec, { enableScanInQuery: true }) + .fetchAll(); + assert(results !== undefined, "error querying documents"); + results.sort(function (doc1, doc2) { + return doc1.id.localeCompare(doc2.id); + }); + assert.equal( + results.length, + returnedDocuments.length, + "Expected " + returnedDocuments.length + " documents to be succesfully queried", + ); + assert.equal( + JSON.stringify(results), + JSON.stringify(returnedDocuments), + "Unexpected query results", + ); - await bulkDeleteItems(container, returnedDocuments, dataset.partitinKeyDef); - } + await bulkDeleteItems(container, returnedDocuments, dataset.partitinKeyDef); + } - const dataSetForDefaultSinglePhysicalPartition: CRUDTestDataSet = { - containerDef: { id: "default container with single physical partition" }, - itemDef: { - name: "sample document", - foo: "bar", - key: "value", - replace: "new property", - }, - replaceItemDef: { - name: "replaced document", - foo: "not bar", - key: "value", - replace: "new property", - }, - originalItemPartitionKey: undefined, - replacedItemPartitionKey: undefined, - propertyToCheck: ["name"], - }; + const dataSetForDefaultSinglePhysicalPartition: CRUDTestDataSet = { + containerDef: { id: "default container with single physical partition" }, + itemDef: { + name: "sample document", + foo: "bar", + key: "value", + replace: "new property", + }, + replaceItemDef: { + name: "replaced document", + foo: "not bar", + key: "value", + replace: "new property", + }, + originalItemPartitionKey: undefined, + replacedItemPartitionKey: undefined, + propertyToCheck: ["name"], + }; - const dataSetForDefaultMultiplePhysicalPartition1: CRUDTestDataSet = { - ...dataSetForDefaultSinglePhysicalPartition, - itemDef: { - _partitionKey: "aswww", // For second physical partition - name: "sample document", - foo: "bar", - key: "value", - replace: "new property", - }, - replaceItemDef: { - _partitionKey: "aswww", // For second physical partition - name: "replaced document", - foo: "not bar", - key: "value", - replace: "new property", - }, - containerDef: { - id: "default container with multiple physical partition", - throughput: 12000, - }, - originalItemPartitionKey: "aswww", - replacedItemPartitionKey: "aswww", - }; + const dataSetForDefaultMultiplePhysicalPartition1: CRUDTestDataSet = { + ...dataSetForDefaultSinglePhysicalPartition, + itemDef: { + _partitionKey: "aswww", // For second physical partition + name: "sample document", + foo: "bar", + key: "value", + replace: "new property", + }, + replaceItemDef: { + _partitionKey: "aswww", // For second physical partition + name: "replaced document", + foo: "not bar", + key: "value", + replace: "new property", + }, + containerDef: { + id: "default container with multiple physical partition", + throughput: 12000, + }, + originalItemPartitionKey: "aswww", + replacedItemPartitionKey: "aswww", + }; - const dataSetForDefaultMultiplePhysicalPartition2: CRUDTestDataSet = { - ...dataSetForDefaultSinglePhysicalPartition, - itemDef: { - _partitionKey: "asdfadsf", // For second physical partition - name: "sample document", - foo: "bar", - key: "value", - replace: "new property", - }, - replaceItemDef: { - _partitionKey: "asdfadsf", // For second physical partition - name: "replaced document", - foo: "not bar", - key: "value", - replace: "new property", - }, - containerDef: { - id: "default container with multiple physical partition", - throughput: 12000, - }, - originalItemPartitionKey: "asdfadsf", - replacedItemPartitionKey: "asdfadsf", - }; + const dataSetForDefaultMultiplePhysicalPartition2: CRUDTestDataSet = { + ...dataSetForDefaultSinglePhysicalPartition, + itemDef: { + _partitionKey: "asdfadsf", // For second physical partition + name: "sample document", + foo: "bar", + key: "value", + replace: "new property", + }, + replaceItemDef: { + _partitionKey: "asdfadsf", // For second physical partition + name: "replaced document", + foo: "not bar", + key: "value", + replace: "new property", + }, + containerDef: { + id: "default container with multiple physical partition", + throughput: 12000, + }, + originalItemPartitionKey: "asdfadsf", + replacedItemPartitionKey: "asdfadsf", + }; - const dataSetForHierarchicalPartitionKey: CRUDTestDataSet = { - containerDef: { - id: "sample container", - partitionKey: { + const dataSetForHierarchicalPartitionKey: CRUDTestDataSet = { + containerDef: { + id: "sample container", + partitionKey: { + paths: ["/key", "/key2"], + version: PartitionKeyDefinitionVersion.V2, + kind: PartitionKeyKind.MultiHash, + }, + }, + itemDef: { + name: "sample document", + foo: "bar", + key2: "value2", + key: "value", + replace: "new property", + }, + replaceItemDef: { + name: "replaced document", + foo: "not bar", + key2: "value2", + key: "value", + replace: "new property", + }, + originalItemPartitionKey: ["value", "value2"], + replacedItemPartitionKey: ["value", "value2"], + }; + const multiCrudDataset1: MultiCRUDTestDataSet = { + dbName: "db1", + partitinKeyDef: { + paths: ["/key"], + }, + containerDef: { + id: "col1", + }, + documents: [ + { id: "document1" }, + { id: "document2", key: null, key2: null, prop: 1 }, + { id: "document3", key: false, key2: false, prop: 1 }, + { id: "document4", key: true, key2: true, prop: 1 }, + { id: "document5", key: 1, key2: 1, prop: 1 }, + { id: "document6", key: "A", key2: "A", prop: 1 }, + { id: "document7", key: "", key2: "", prop: 1 }, + ], + containerRequestOps: { + offerThroughput: 12000, + }, + singleDocFetchQuery: "SELECT * FROM root r WHERE r.key=@key", + parameterGenerator: (doc: any) => { + return [ + { + name: "@key", + value: doc["key"], + }, + ]; + }, + }; + const multiCrudDatasetWithHierarchicalPartition: MultiCRUDTestDataSet = { + dbName: "db1", + partitinKeyDef: { paths: ["/key", "/key2"], version: PartitionKeyDefinitionVersion.V2, kind: PartitionKeyKind.MultiHash, }, - }, - itemDef: { - name: "sample document", - foo: "bar", - key2: "value2", - key: "value", - replace: "new property", - }, - replaceItemDef: { - name: "replaced document", - foo: "not bar", - key2: "value2", - key: "value", - replace: "new property", - }, - originalItemPartitionKey: ["value", "value2"], - replacedItemPartitionKey: ["value", "value2"], - }; - const multiCrudDataset1: MultiCRUDTestDataSet = { - dbName: "db1", - partitinKeyDef: { - paths: ["/key"], - }, - containerDef: { - id: "col1", - }, - documents: [ - { id: "document1" }, - { id: "document2", key: null, key2: null, prop: 1 }, - { id: "document3", key: false, key2: false, prop: 1 }, - { id: "document4", key: true, key2: true, prop: 1 }, - { id: "document5", key: 1, key2: 1, prop: 1 }, - { id: "document6", key: "A", key2: "A", prop: 1 }, - { id: "document7", key: "", key2: "", prop: 1 }, - ], - containerRequestOps: { - offerThroughput: 12000, - }, - singleDocFetchQuery: "SELECT * FROM root r WHERE r.key=@key", - parameterGenerator: (doc: any) => { - return [ - { - name: "@key", - value: doc["key"], - }, - ]; - }, - }; - const multiCrudDatasetWithHierarchicalPartition: MultiCRUDTestDataSet = { - dbName: "db1", - partitinKeyDef: { - paths: ["/key", "/key2"], - version: PartitionKeyDefinitionVersion.V2, - kind: PartitionKeyKind.MultiHash, - }, - containerDef: { - id: "col1", - }, - documents: [ - { id: "document1" }, - { id: "document2", key: null, key2: null, prop: 1 }, - { id: "document3", key: false, key2: false, prop: 1 }, - { id: "document4", key: true, key2: true, prop: 1 }, - { id: "document5", key: 1, key2: 1, prop: 1 }, - { id: "document6", key: "A", key2: "A", prop: 1 }, - { id: "document7", key: "", key2: "", prop: 1 }, - ], - containerRequestOps: { - offerThroughput: 12000, - }, - singleDocFetchQuery: "SELECT * FROM root r WHERE r.key=@key and r.key2=@key2", - parameterGenerator: (doc: any) => { - return [ - { - name: "@key", - value: doc["key"], - }, - { - name: "@key2", - value: doc["key2"], - }, - ]; - }, - }; + containerDef: { + id: "col1", + }, + documents: [ + { id: "document1" }, + { id: "document2", key: null, key2: null, prop: 1 }, + { id: "document3", key: false, key2: false, prop: 1 }, + { id: "document4", key: true, key2: true, prop: 1 }, + { id: "document5", key: 1, key2: 1, prop: 1 }, + { id: "document6", key: "A", key2: "A", prop: 1 }, + { id: "document7", key: "", key2: "", prop: 1 }, + ], + containerRequestOps: { + offerThroughput: 12000, + }, + singleDocFetchQuery: "SELECT * FROM root r WHERE r.key=@key and r.key2=@key2", + parameterGenerator: (doc: any) => { + return [ + { + name: "@key", + value: doc["key"], + }, + { + name: "@key2", + value: doc["key2"], + }, + ]; + }, + }; - describe("V1 Container", async () => { - describe("Single Partition Container", async () => { - it("Should do document CRUD operations successfully : container with default partition key", async function () { - await CRUDTestRunner(dataSetForDefaultSinglePhysicalPartition, false); - }); + describe("V1 Container", async () => { + describe("Single Partition Container", async () => { + it("Should do document CRUD operations successfully : container with default partition key", async () => { + await CRUDTestRunner(dataSetForDefaultSinglePhysicalPartition, false); + }); - it("Should do document CRUD operations successfully with upsert : container with default partition key", async function () { - await CRUDTestRunner(dataSetForDefaultSinglePhysicalPartition, true); - }); + it("Should do document CRUD operations successfully with upsert : container with default partition key", async () => { + await CRUDTestRunner(dataSetForDefaultSinglePhysicalPartition, true); + }); - it("Should do document CRUD operations successfully : container with default partition key, multiple physical partitions", async function () { - await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition1, false); - await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition2, false); - }); + it("Should do document CRUD operations successfully : container with default partition key, multiple physical partitions", async () => { + await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition1, false); + await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition2, false); + }); - it("Should do document CRUD operations successfully with upsert: container with default partition key, multiple physical partitions", async function () { - await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition1, true); - await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition2, true); + it("Should do document CRUD operations successfully with upsert: container with default partition key, multiple physical partitions", async () => { + await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition1, true); + await CRUDTestRunner(dataSetForDefaultMultiplePhysicalPartition2, true); + }); }); }); - }); - describe("V2 Container", async () => { - describe("Multi Partition Container", async () => { - it("Should do document CRUD operations successfully : container with hierarchical partition key", async function () { - await CRUDTestRunner(dataSetForHierarchicalPartitionKey, false); - }); - it("Should do document CRUD operations successfully with upsert : container with hierarchical partition key", async function () { - await CRUDTestRunner(dataSetForHierarchicalPartitionKey, true); + describe("V2 Container", async () => { + describe("Multi Partition Container", async () => { + it("Should do document CRUD operations successfully : container with hierarchical partition key", async () => { + await CRUDTestRunner(dataSetForHierarchicalPartitionKey, false); + }); + it("Should do document CRUD operations successfully with upsert : container with hierarchical partition key", async () => { + await CRUDTestRunner(dataSetForHierarchicalPartitionKey, true); + }); }); }); - }); - it("Document CRUD over multiple partition: Single partition key", async function () { - await multipelPartitionCRUDTest(multiCrudDataset1); - }); - - it("Document CRUD over multiple partition : Hierarchical partitions", async function () { - await multipelPartitionCRUDTest(multiCrudDatasetWithHierarchicalPartition); - }); + it("Document CRUD over multiple partition: Single partition key", async () => { + await multiplePartitionCRUDTest(multiCrudDataset1); + }); - it("Should auto generate an id for a collection partitioned on id", async function () { - // https://github.com/Azure/azure-sdk-for-js/issues/9734 - const container = await getTestContainer("db1", undefined, { partitionKey: "/id" }); - const { resource } = await container.items.create({}); - assert.ok(resource.id); - }); + it("Document CRUD over multiple partition : Hierarchical partitions", async () => { + await multiplePartitionCRUDTest(multiCrudDatasetWithHierarchicalPartition); + }); - describe("Upsert when collection partitioned on id", async () => { - // https://github.com/Azure/azure-sdk-for-js/issues/21383 - it("should create a new resource if /id is not passed", async function () { + it("Should auto generate an id for a collection partitioned on id", async () => { + // https://github.com/Azure/azure-sdk-for-js/issues/9734 const container = await getTestContainer("db1", undefined, { partitionKey: "/id" }); - const { resource: resource } = await container.items.upsert({ key1: 0, key2: 0 }); + const { resource } = await container.items.create({}); assert.ok(resource.id); }); - it("should create a new resource if /id is passed and resource doesn't exist", async function () { - const container = await getTestContainer("db1", undefined, { partitionKey: "/id" }); - const { resource: resource } = await container.items.upsert({ - id: "1ee929e0-40aa-4143-978c-8415914056d4", - key1: 0, - key2: 0, + describe("Upsert when collection partitioned on id", async () => { + // https://github.com/Azure/azure-sdk-for-js/issues/21383 + it("should create a new resource if /id is not passed", async () => { + const container = await getTestContainer("db1", undefined, { partitionKey: "/id" }); + const { resource: resource } = await container.items.upsert({ key1: 0, key2: 0 }); + assert.ok(resource.id); }); - assert.ok(resource.id); - }); - it("should update a resource if /id is passed and exists in container", async function () { - const container = await getTestContainer("db1", undefined, { partitionKey: "/id" }); - const { resource: resource1 } = await container.items.upsert({ key1: 0, key2: 1 }); - assert.ok(resource1.id); - const { resource: resource2 } = await container.items.upsert({ - id: resource1.id, - key1: 0, - key2: 2, + it("should create a new resource if /id is passed and resource doesn't exist", async () => { + const container = await getTestContainer("db1", undefined, { partitionKey: "/id" }); + const { resource: resource } = await container.items.upsert({ + id: "1ee929e0-40aa-4143-978c-8415914056d4", + key1: 0, + key2: 0, + }); + assert.ok(resource.id); }); - assert.strictEqual(resource1.id, resource2.id); - }); - }); + it("should update a resource if /id is passed and exists in container", async () => { + const container = await getTestContainer("db1", undefined, { partitionKey: "/id" }); + const { resource: resource1 } = await container.items.upsert({ key1: 0, key2: 1 }); + assert.ok(resource1.id); - describe("Test diagnostics for item CRUD", async function () { - const container = await getTestContainer("db1", undefined, { - throughput: 20000, - partitionKey: "/id", - }); - // Test diagnostic for item create - const itemId = "2"; - it("Test diagnostics for item.create", async function () { - const startTimestamp = getCurrentTimestampInMs(); - await testForDiagnostics( - async () => { - return container.items.create({ id: itemId }); - }, - { - requestStartTimeUTCInMsLowerLimit: startTimestamp, - requestDurationInMsUpperLimit: getCurrentTimestampInMs(), - retryCount: 0, - // metadataCallCount: 5, - locationEndpointsContacted: 1, - }, - ); + const { resource: resource2 } = await container.items.upsert({ + id: resource1.id, + key1: 0, + key2: 2, + }); + assert.strictEqual(resource1.id, resource2.id); + }); }); - // Test diagnostic for item read - it("Test diagnostics for item.read", async function () { - const readTimestamp = getCurrentTimestampInMs(); - await testForDiagnostics( - async () => { - return container.item(itemId, itemId).read(); - }, - { - requestStartTimeUTCInMsLowerLimit: readTimestamp, - requestDurationInMsUpperLimit: getCurrentTimestampInMs(), - retryCount: 0, - // metadataCallCount: 2, // 2 calls for database account - locationEndpointsContacted: 1, - }, - ); - }); + describe("Test diagnostics for item CRUD", async () => { + const container = await getTestContainer("db1", undefined, { + throughput: 20000, + partitionKey: "/id", + }); + // Test diagnostic for item create + const itemId = "2"; + it("Test diagnostics for item.create", async () => { + const startTimestamp = getCurrentTimestampInMs(); + await testForDiagnostics( + async () => { + return container.items.create({ id: itemId }); + }, + { + requestStartTimeUTCInMsLowerLimit: startTimestamp, + requestDurationInMsUpperLimit: getCurrentTimestampInMs(), + retryCount: 0, + // metadataCallCount: 5, + locationEndpointsContacted: 1, + }, + ); + }); - // Test diagnostic for item update - it("Test diagnostics for item.upsert", async function () { - const upsertTimestamp = getCurrentTimestampInMs(); - await testForDiagnostics( - async () => { - return container.items.upsert({ - id: itemId, - value: "3", - }); - }, - { - requestStartTimeUTCInMsLowerLimit: upsertTimestamp, - requestDurationInMsUpperLimit: getCurrentTimestampInMs(), - retryCount: 0, - // metadataCallCount: 2, // 2 call for database account. - locationEndpointsContacted: 1, - }, - ); - }); + // Test diagnostic for item read + it("Test diagnostics for item.read", async () => { + const readTimestamp = getCurrentTimestampInMs(); + await testForDiagnostics( + async () => { + return container.item(itemId, itemId).read(); + }, + { + requestStartTimeUTCInMsLowerLimit: readTimestamp, + requestDurationInMsUpperLimit: getCurrentTimestampInMs(), + retryCount: 0, + // metadataCallCount: 2, // 2 calls for database account + locationEndpointsContacted: 1, + }, + ); + }); - // Test diagnostic for item replace - it("Test diagnostics for item.replace", async function () { - const replaceTimestamp = getCurrentTimestampInMs(); - await testForDiagnostics( - async () => { - return container.item(itemId, itemId).replace({ - id: itemId, - value: "4", - }); - }, - { - requestStartTimeUTCInMsLowerLimit: replaceTimestamp, - requestDurationInMsUpperLimit: getCurrentTimestampInMs(), - retryCount: 0, - // metadataCallCount: 2, // 2 call for database account. - locationEndpointsContacted: 1, - }, - ); - }); + // Test diagnostic for item update + it("Test diagnostics for item.upsert", async () => { + const upsertTimestamp = getCurrentTimestampInMs(); + await testForDiagnostics( + async () => { + return container.items.upsert({ + id: itemId, + value: "3", + }); + }, + { + requestStartTimeUTCInMsLowerLimit: upsertTimestamp, + requestDurationInMsUpperLimit: getCurrentTimestampInMs(), + retryCount: 0, + // metadataCallCount: 2, // 2 call for database account. + locationEndpointsContacted: 1, + }, + ); + }); - // Test diagnostic for item query fetchAll - it("Test diagnostics for items.query fetchAll", async function () { - const fetchAllTimestamp = getCurrentTimestampInMs(); - await testForDiagnostics( - async () => { - return container.items.query("select * from c ").fetchAll(); - }, - { - requestStartTimeUTCInMsLowerLimit: fetchAllTimestamp, - requestDurationInMsUpperLimit: getCurrentTimestampInMs(), - retryCount: 0, - // metadataCallCount: 11, - locationEndpointsContacted: 1, - }, - true, - ); - }); + // Test diagnostic for item replace + it("Test diagnostics for item.replace", async () => { + const replaceTimestamp = getCurrentTimestampInMs(); + await testForDiagnostics( + async () => { + return container.item(itemId, itemId).replace({ + id: itemId, + value: "4", + }); + }, + { + requestStartTimeUTCInMsLowerLimit: replaceTimestamp, + requestDurationInMsUpperLimit: getCurrentTimestampInMs(), + retryCount: 0, + // metadataCallCount: 2, // 2 call for database account. + locationEndpointsContacted: 1, + }, + ); + }); - // Test diagnostic for item query fetchAll - it("Test diagnostics for item.query fetchNext", async function () { - const fetchNextTimestamp = getCurrentTimestampInMs(); - await testForDiagnostics( - async () => { - return container.items.query("select * from c ").fetchNext(); - }, - { - requestStartTimeUTCInMsLowerLimit: fetchNextTimestamp, - requestDurationInMsUpperLimit: getCurrentTimestampInMs(), - retryCount: 0, - // metadataCallCount: 5, - locationEndpointsContacted: 1, - }, - true, - ); + // Test diagnostic for item query fetchAll + it("Test diagnostics for items.query fetchAll", async () => { + const fetchAllTimestamp = getCurrentTimestampInMs(); + await testForDiagnostics( + async () => { + return container.items.query("select * from c ").fetchAll(); + }, + { + requestStartTimeUTCInMsLowerLimit: fetchAllTimestamp, + requestDurationInMsUpperLimit: getCurrentTimestampInMs(), + retryCount: 0, + // metadataCallCount: 11, + locationEndpointsContacted: 1, + }, + true, + ); + }); + + // Test diagnostic for item query fetchAll + it("Test diagnostics for item.query fetchNext", async () => { + const fetchNextTimestamp = getCurrentTimestampInMs(); + await testForDiagnostics( + async () => { + return container.items.query("select * from c ").fetchNext(); + }, + { + requestStartTimeUTCInMsLowerLimit: fetchNextTimestamp, + requestDurationInMsUpperLimit: getCurrentTimestampInMs(), + retryCount: 0, + // metadataCallCount: 5, + locationEndpointsContacted: 1, + }, + true, + ); + }); }); - }); -}); + }, +); // TODO: Non-deterministic test. We can't guarantee we see any response with a 429 status code since the retries happen within the response -describe("item read retries", async function () { - it("retries on 429", async function () { +describe("item read retries", async () => { + it("retries on 429", async () => { const client = new CosmosClient({ key: masterKey, endpoint }); const { resource: db } = await client.databases.create({ id: `small db ${Math.random() * 1000}`, @@ -694,12 +697,12 @@ describe("item read retries", async function () { }); }); -describe("patch operations", function () { - describe("various mixed operations", function () { +describe("patch operations", () => { + describe("various mixed operations", () => { let container: Container; let addItemId: string; let conditionItemId: string; - before(async function () { + beforeAll(async () => { addItemId = addEntropy("addItemId"); conditionItemId = addEntropy("conditionItemId"); const client = new CosmosClient({ key: masterKey, endpoint }); @@ -734,7 +737,7 @@ describe("patch operations", function () { num: 0, }); }); - it("handles add, remove, replace, set, incr", async function () { + it("handles add, remove, replace, set, incr", async () => { const operations: PatchOperation[] = [ { op: "add", @@ -768,7 +771,7 @@ describe("patch operations", function () { assert.strictEqual(addItem.last, "b"); assert.strictEqual(addItem.removable, undefined); }); - it("conditionally patches", async function () { + it("conditionally patches", async () => { const operations: PatchOperation[] = [ { op: "add", @@ -783,13 +786,13 @@ describe("patch operations", function () { assert.strictEqual(conditionItem.newImproved, "it works"); }); }); - describe("various mixed operations - hierarchical partitions", function () { + describe("various mixed operations - hierarchical partitions", () => { let container: Container; let addItemId: string; let addItemWithOnePartitionKeyId: string; let addItemWithNoPartitionKeyId: string; let conditionItemId: string; - before(async function () { + beforeAll(async () => { addItemId = addEntropy("addItemId"); addItemWithOnePartitionKeyId = addEntropy("addItemWithOnePartitionKeyId"); addItemWithNoPartitionKeyId = addEntropy("addItemWithNoPartitionKeyId"); @@ -857,7 +860,7 @@ describe("patch operations", function () { num: 0, }); }); - it("handles add, remove, replace, set, incr - hierarchical partitions", async function () { + it("handles add, remove, replace, set, incr - hierarchical partitions", async () => { const operations: PatchOperation[] = [ { op: "add", @@ -911,7 +914,7 @@ describe("patch operations", function () { assert.strictEqual(addItemWithNoPartitionKey.last, "b"); assert.strictEqual(addItemWithNoPartitionKey.removable, undefined); }); - it("conditionally patches", async function () { + it("conditionally patches", async () => { const operations: PatchOperation[] = [ { op: "add", @@ -928,9 +931,8 @@ describe("patch operations", function () { }); }); -describe("Item CRUD with priority", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - beforeEach(async function () { +describe("Item CRUD with priority", { timeout: 10000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); const documentCRUDTest = async function (isUpsertTest: boolean): Promise { @@ -1026,11 +1028,11 @@ describe("Item CRUD with priority", function (this: Suite) { assert.equal(response.resource, undefined); }; - it("Should do document CRUD operations successfully", async function () { + it("Should do document CRUD operations successfully", async () => { await documentCRUDTest(false); }); - it("Should do document CRUD operations successfully with upsert", async function () { + it("Should do document CRUD operations successfully with upsert", async () => { await documentCRUDTest(true); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts index e5486e0d49d8..3f351c01d1c1 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { Container, CosmosClient } from "../../../../src/index.js"; import { getTestContainer, @@ -8,7 +8,7 @@ import { defaultClient, defaultComputeGatewayClient, } from "../../common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; interface ItemPayload { id?: string; @@ -32,10 +32,10 @@ const createPayload = function (id: string): ItemPayload { }; }; -const executeTestCase = async function ( +const executeTestCase = async ( scenario: TestScenario, useComputeGateway: boolean = false, -) { +): Promise => { const client: CosmosClient = useComputeGateway ? defaultComputeGatewayClient : defaultClient; const container: Container = await getTestContainer(scenario.name, client, { partitionKey: { @@ -113,12 +113,11 @@ const executeTestCase = async function ( } }; -const executeTestCaseOnComputeGateway = async function (scenario: TestScenario) { +const executeTestCaseOnComputeGateway = async (scenario: TestScenario): Promise => { return executeTestCase(scenario, true); }; -describe("Id encoding", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +describe("Id encoding", { timeout: 10000 }, () => { beforeEach(async function () { await removeAllDatabases(); }); diff --git a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts index 98f33982aa46..9a8834fa0667 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/sproc.spec.ts @@ -11,6 +11,7 @@ import { removeAllDatabases, } from "../common/TestHelpers.js"; import { describe, it, assert, beforeEach } from "vitest"; +import { getTaskFullTitle } from "@azure-tools/test-utils-vitest"; // Used for sproc declare let getContext: any; @@ -22,7 +23,7 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { describe("Validate sproc CRUD", function () { let container: Container; beforeEach(async (ctx) => { - container = await getTestContainer(ctx); + container = await getTestContainer(getTaskFullTitle(ctx)); }); it("nativeApi Should do sproc CRUD operations successfully with create/replace", async function () { @@ -94,7 +95,7 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { describe("Validate stored procedure functionality", function () { let container: Container; beforeEach(async (ctx) => { - container = await getTestContainer(ctx); + container = await getTestContainer(getTaskFullTitle(ctx)); }); it("nativeApi should do stored procedure operations successfully with create/replace", async function () { @@ -160,7 +161,7 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { const { resource: containerResult } = await database.containers.create(containerDefinition, { offerThroughput: 12000, }); - const container = await database.container(containerResult.id); + const container = database.container(containerResult.id); const querySproc = { id: "querySproc", diff --git a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts index 09b63953b289..07db5a3f6374 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/trigger.spec.ts @@ -14,13 +14,13 @@ declare let getContext: any; describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { let container: Container; - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); container = await getTestContainer("trigger container"); }); - describe("Validate Trigger CRUD", function () { - it("nativeApi Should do trigger CRUD operations successfully name based", async function () { + describe("Validate Trigger CRUD", () => { + it("nativeApi Should do trigger CRUD operations successfully name based", async () => { // read triggers const { resources: triggers } = await container.scripts.triggers.readAll().fetchAll(); assert.equal(Array.isArray(triggers), true); @@ -64,13 +64,13 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { // replace trigger // prettier-ignore - trigger.body = function () { const x = 20; console.log(x); }; + trigger.body = () => { const x = 20; console.log(x); }; const { resource: replacedTrigger } = await container.scripts .trigger(trigger.id) .replace(trigger); assert.equal(replacedTrigger.id, trigger.id); - assert.equal(replacedTrigger.body, "function () { const x = 20; console.log(x); }"); + assert.equal(replacedTrigger.body, "() => { const x = 20; console.log(x); }"); // read trigger const { resource: triggerAfterReplace } = await container.scripts @@ -91,11 +91,11 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { }); }); - describe("validate trigger functionality", function () { + describe("validate trigger functionality", () => { const triggers: TriggerDefinition[] = [ { id: "t1", - body: function () { + body: () => { const item = getContext().getRequest().getBody(); item.id = item.id.toUpperCase() + "t1"; getContext().getRequest().setBody(item); @@ -111,7 +111,7 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { }, { id: "t3", - body: function () { + body: () => { const item = getContext().getRequest().getBody(); item.id = item.id.toLowerCase() + "t3"; getContext().getRequest().setBody(item); @@ -121,7 +121,7 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { }, { id: "response1", - body: function () { + body: () => { const prebody = getContext().getRequest().getBody(); if (prebody.id !== "TESTING POST TRIGGERt1") throw "name mismatch"; const postbody = getContext().getResponse().getBody(); @@ -138,7 +138,7 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { }, ]; - it("should do trigger operations successfully with create", async function () { + it("should do trigger operations successfully with create", async () => { for (const trigger of triggers) { await container.scripts.triggers.create(trigger); } diff --git a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts index baebc3a6fd41..70c08a7a940c 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/ttl.spec.ts @@ -13,7 +13,7 @@ async function sleep(time: number): Promise { } describe("Container TTL", { timeout: 600000 }, () => { - beforeEach(async function () { + beforeEach(async () => { await removeAllDatabases(); }); async function createcontainerWithInvalidDefaultTtl( @@ -58,7 +58,7 @@ describe("Container TTL", { timeout: 600000 }, () => { } } - it("Validate container and Item TTL values.", async function () { + it("Validate container and Item TTL values.", async () => { const database = await getTestDatabase("ttl test1 database"); const containerDefinition = { @@ -165,7 +165,7 @@ describe("Container TTL", { timeout: 600000 }, () => { await positiveDefaultTtlStep2(container, doc, itemDefinition); } - it("Validate Item TTL with positive defaultTtl.", async function () { + it("Validate Item TTL with positive defaultTtl.", async () => { const database = await getTestDatabase("ttl test2 database"); const containerDefinition = { @@ -205,7 +205,7 @@ describe("Container TTL", { timeout: 600000 }, () => { assert.equal(readItem2.id, createdItem2.id); } - it("Validate Item TTL with -1 defaultTtl.", async function () { + it("Validate Item TTL with -1 defaultTtl.", async () => { const database = await getTestDatabase("ttl test2 database"); const containerDefinition = { @@ -240,7 +240,7 @@ describe("Container TTL", { timeout: 600000 }, () => { await minusOneDefaultTtlStep1(container, createdItem1, createdItem2, createdItem3); }); - it("Validate Item TTL with no defaultTtl.", async function () { + it("Validate Item TTL with no defaultTtl.", async () => { const database = await getTestDatabase("ttl test3 database"); const containerDefinition = { id: "sample container" }; @@ -263,7 +263,7 @@ describe("Container TTL", { timeout: 600000 }, () => { await checkItemExists(container, createdItem); }); - it("Validate Item TTL Misc cases.", async function () { + it("Validate Item TTL Misc cases.", async () => { const database = await getTestDatabase("ttl test4 database"); const containerDefinition = { diff --git a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts index d5888c2ac095..c3e513679e69 100644 --- a/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/indexMetrics.spec.ts @@ -5,7 +5,7 @@ import { IndexMetricWriter, IndexUtilizationInfo } from "../../src/indexMetrics/ import { describe, it, assert } from "vitest"; describe("Test Index Metrics Writer", { timeout: 20000 }, () => { - it("test writeIndexMetrics", async function () { + it("test writeIndexMetrics", async () => { const result: { result: IndexUtilizationInfo } = { result: IndexUtilizationInfo.Empty }; IndexUtilizationInfo.tryCreateFromDelimitedBase64String( "eyJVdGlsaXplZFNpbmdsZUluZGV4ZXMiOlt7IkZpbHRlckV4cHJlc3Npb24iOiIiLCJJbmRleFNwZWMiOiJcL25hbWVcLz8iLCJGaWx0ZXJQcmVjaXNlU2V0Ijp0cnVlLCJJbmRleFByZWNpc2VTZXQiOnRydWUsIkluZGV4SW1wYWN0U2NvcmUiOiJIaWdoIn1dLCJQb3RlbnRpYWxTaW5nbGVJbmRleGVzIjpbXSwiVXRpbGl6ZWRDb21wb3NpdGVJbmRleGVzIjpbXSwiUG90ZW50aWFsQ29tcG9zaXRlSW5kZXhlcyI6W119", @@ -29,7 +29,7 @@ describe("Test Index Metrics Writer", { timeout: 20000 }, () => { }); describe("Test Index Utilization Info", () => { - it("test tryCreateFromDelimitedBase64String", async function () { + it("test tryCreateFromDelimitedBase64String", async () => { const delimitedString = "eyJVdGlsaXplZFNpbmdsZUluZGV4ZXMiOlt7IkZpbHRlckV4cHJlc3Npb24iOiIiLCJJbmRleFNwZWMiOiJcL25hbWVcLz8iLCJGaWx0ZXJQcmVjaXNlU2V0Ijp0cnVlLCJJbmRleFByZWNpc2VTZXQiOnRydWUsIkluZGV4SW1wYWN0U2NvcmUiOiJIaWdoIn1dLCJQb3RlbnRpYWxTaW5nbGVJbmRleGVzIjpbXSwiVXRpbGl6ZWRDb21wb3NpdGVJbmRleGVzIjpbXSwiUG90ZW50aWFsQ29tcG9zaXRlSW5kZXhlcyI6W119"; const result: { result: IndexUtilizationInfo } = { result: IndexUtilizationInfo.Empty }; @@ -45,7 +45,7 @@ describe("Test Index Utilization Info", () => { assert.equal(result.result?.UtilizedSingleIndexes[0].IndexImpactScore, "High"); }); - it("test tryCreateFromDelimitedBase64String with invalid string", async function () { + it("test tryCreateFromDelimitedBase64String with invalid string", async () => { const delimitedString = "invalid"; const result: { result: IndexUtilizationInfo } = { result: IndexUtilizationInfo.Empty }; @@ -58,7 +58,7 @@ describe("Test Index Utilization Info", () => { assert.equal(result.result, IndexUtilizationInfo.Empty); }); - it("test tryCreateFromDelimitedBase64String with empty string", async function () { + it("test tryCreateFromDelimitedBase64String with empty string", async () => { const delimitedString = ""; const result: { result: IndexUtilizationInfo } = { result: IndexUtilizationInfo.Empty }; @@ -71,14 +71,14 @@ describe("Test Index Utilization Info", () => { assert.equal(result.result, IndexUtilizationInfo.Empty); }); - it("test createFromString with empty string", async function () { + it("test createFromString with empty string", async () => { const delimitedString = ""; const result = IndexUtilizationInfo.createFromString(delimitedString, true); assert.equal(result, IndexUtilizationInfo.Empty); }); - it("test createFromString with invalid string", async function () { + it("test createFromString with invalid string", async () => { const delimitedString = "invalid"; const result = IndexUtilizationInfo.createFromString(delimitedString, true); @@ -86,7 +86,7 @@ describe("Test Index Utilization Info", () => { assert.equal(result, IndexUtilizationInfo.Empty); }); - it("test createFromString with valid string", async function () { + it("test createFromString with valid string", async () => { const delimitedString = "eyJVdGlsaXplZFNpbmdsZUluZGV4ZXMiOlt7IkZpbHRlckV4cHJlc3Npb24iOiIiLCJJbmRleFNwZWMiOiJcL25hbWVcLz8iLCJGaWx0ZXJQcmVjaXNlU2V0Ijp0cnVlLCJJbmRleFByZWNpc2VTZXQiOnRydWUsIkluZGV4SW1wYWN0U2NvcmUiOiJIaWdoIn1dLCJQb3RlbnRpYWxTaW5nbGVJbmRleGVzIjpbXSwiVXRpbGl6ZWRDb21wb3NpdGVJbmRleGVzIjpbXSwiUG90ZW50aWFsQ29tcG9zaXRlSW5kZXhlcyI6W119"; diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts index 4767d396e19f..54a8d03cbf46 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregateQuery.spec.ts @@ -48,7 +48,7 @@ describe("Aggregate Query", { timeout: 20000 }, () => { const containerOptions = { offerThroughput: 10100 }; - beforeAll(async function () { + beforeAll(async () => { await removeAllDatabases(); container = await getTestContainer( "Validate Aggregate Document Query", @@ -171,102 +171,102 @@ describe("Aggregate Query", { timeout: 20000 }, () => { await ValidateAsyncIterator(queryIterator, expectedResults); }; - it("SELECT VALUE AVG", async function () { + it("SELECT VALUE AVG", async () => { await executeQueryAndValidateResults("SELECT VALUE AVG(r.key) FROM r WHERE IS_NUMBER(r.key)", [ average, ]); }); - it("SELECT VALUE AVG with ORDER BY", async function () { + it("SELECT VALUE AVG with ORDER BY", async () => { await executeQueryAndValidateResults( "SELECT VALUE AVG(r.key) FROM r WHERE IS_NUMBER(r.key) ORDER BY r.key, r.field", [average], ); }); - it("SELECT VALUE COUNT", async function () { + it("SELECT VALUE COUNT", async () => { await executeQueryAndValidateResults("SELECT VALUE COUNT(r.key) FROM r", [ testdata.numberOfDocuments, ]); }); - it("SELECT VALUE COUNT with ORDER BY", async function () { + it("SELECT VALUE COUNT with ORDER BY", async () => { await executeQueryAndValidateResults("SELECT VALUE COUNT(r.key) FROM r ORDER BY r.key", [ testdata.numberOfDocuments, ]); }); - it("SELECT VALUE MAX", async function () { + it("SELECT VALUE MAX", async () => { await executeQueryAndValidateResults("SELECT VALUE MAX(r.key) FROM r", ["xyz"]); }); - it("SELECT VALUE MAX with ORDER BY", async function () { + it("SELECT VALUE MAX with ORDER BY", async () => { await executeQueryAndValidateResults("SELECT VALUE MAX(r.key) FROM r ORDER BY r.key", ["xyz"]); }); - it("SELECT VALUE MIN", async function () { + it("SELECT VALUE MIN", async () => { await executeQueryAndValidateResults("SELECT VALUE MIN(r.key) FROM r", [null]); }); - it("SELECT VALUE MIN with ORDER BY", async function () { + it("SELECT VALUE MIN with ORDER BY", async () => { await executeQueryAndValidateResults("SELECT VALUE MIN(r.key) FROM r ORDER BY r.key", [null]); }); - it("SELECT VALUE SUM", async function () { + it("SELECT VALUE SUM", async () => { await executeQueryAndValidateResults("SELECT VALUE SUM(r.key) FROM r WHERE IS_NUMBER(r.key)", [ testdata.sum, ]); }); - it("SELECT VALUE SUM with ORDER BY", async function () { + it("SELECT VALUE SUM with ORDER BY", async () => { await executeQueryAndValidateResults( "SELECT VALUE SUM(r.key) FROM r WHERE IS_NUMBER(r.key) ORDER BY r.key", [testdata.sum], ); }); - it("SELECT VALUE AVG for single partiton", async function () { + it("SELECT VALUE AVG for single partiton", async () => { await executeQueryAndValidateResults( "SELECT VALUE AVG(r.field) FROM r WHERE r.key = 'uniquePartitionKey'", [samePartitionSum / testdata.numberOfDocsWithSamePartitionKey], ); }); - it("SELECT VALUE COUNT for single partiton", async function () { + it("SELECT VALUE COUNT for single partiton", async () => { await executeQueryAndValidateResults( "SELECT VALUE COUNT(r.field) FROM r WHERE r.key = 'uniquePartitionKey'", [testdata.numberOfDocsWithSamePartitionKey], ); }); - it("SELECT VALUE MAX for single partiton", async function () { + it("SELECT VALUE MAX for single partiton", async () => { await executeQueryAndValidateResults( "SELECT VALUE MAX(r.field) FROM r WHERE r.key = 'uniquePartitionKey'", [testdata.numberOfDocsWithSamePartitionKey], ); }); - it("SELECT VALUE MIN for single partiton", async function () { + it("SELECT VALUE MIN for single partiton", async () => { await executeQueryAndValidateResults( "SELECT VALUE MIN(r.field) FROM r WHERE r.key = 'uniquePartitionKey'", [1], ); }); - it("SELECT VALUE SUM for single partiton", async function () { + it("SELECT VALUE SUM for single partiton", async () => { await executeQueryAndValidateResults( "SELECT VALUE SUM(r.field) FROM r WHERE r.key = 'uniquePartitionKey'", [samePartitionSum], ); }); - it("Non VALUE aggregate", async function () { + it("Non VALUE aggregate", async () => { await executeQueryAndValidateResults("SELECT AVG(r.key) FROM r WHERE IS_NUMBER(r.key)", [ { $1: average }, ]); }); - it("Multiple Aggregates", async function () { + it("Multiple Aggregates", async () => { await executeQueryAndValidateResults("SELECT COUNT(1), MAX(r.key) FROM r", [ { $1: testdata.numberOfDocuments, $2: "xyz" }, ]); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts index 92f0e27cba72..cc9333380fa9 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/aggregates/groupBy.spec.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +import { getTaskFullTitle } from "@azure-tools/test-utils-vitest"; import type { Container, ContainerDefinition } from "../../../../src/index.js"; import { bulkInsertItems, getTestContainer, removeAllDatabases } from "../../common/TestHelpers.js"; import groupBySnapshot from "./groupBy.snapshot.js"; @@ -545,7 +546,7 @@ describe("Cross partition GROUP BY", () => { }; beforeEach((ctx) => { - currentTestTitle = ctx.currentTest.fullTitle(); + currentTestTitle = getTaskFullTitle(ctx); snapshotNumber = 1; }); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts index 71208288c1e8..9ce8f00640e5 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/client.retry.spec.ts @@ -11,8 +11,8 @@ import { describe, it, assert } from "vitest"; const endpoint = "https://failovertest.documents.azure.com/"; -describe("RetryPolicy", function () { - describe("Timeout Failover retry policy", function () { +describe("RetryPolicy", () => { + describe("Timeout Failover retry policy", () => { const databaseAccountResponse = { headers: { "content-location": "https://failovertest.documents.azure.com/", @@ -112,7 +112,7 @@ describe("RetryPolicy", function () { code: 200, diagnostics: getEmptyCosmosDiagnostics(), }; - it("when 1st region endpoint becomes unseriviceable", async function () { + it("when 1st region endpoint becomes unseriviceable", async () => { const lastEndpointCalled: string[] = []; const responses = [ databaseAccountResponse, @@ -139,7 +139,7 @@ describe("RetryPolicy", function () { client.dispose(); }); - it("when both region endpoint becomes unseriviceable", async function () { + it("when both region endpoint becomes unseriviceable", async () => { const lastEndpointCalled: string[] = []; const responses = [ databaseAccountResponse, @@ -161,7 +161,7 @@ describe("RetryPolicy", function () { client.dispose(); }); - it("when both regions Timeout with retrial window", async function () { + it("when both regions Timeout with retrial window", async () => { const responses = [ databaseAccountResponse, collectionResponse, @@ -229,7 +229,7 @@ describe("RetryPolicy", function () { client.dispose(); }); - it("timeout error thrown when retry count exceeds 120", async function () { + it("timeout error thrown when retry count exceeds 120", async () => { const lastEndpointCalled: string[] = []; const responses = [ databaseAccountResponse, diff --git a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts index 695d9c869880..009db88eaaf1 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/extractPartitionKey.spec.ts @@ -4,44 +4,44 @@ import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; import { describe, it, assert } from "vitest"; -describe("extractPartitionKey", function () { - describe("With undefined partitionKeyDefinition", function () { - it("should return undefined", function () { +describe("extractPartitionKey", () => { + describe("With undefined partitionKeyDefinition", () => { + it("should return undefined", () => { const document: any = {}; const result = extractPartitionKeys(document, undefined); assert.equal(result, undefined); }); }); - describe("With a defined partitionKeyDefinition", function () { + describe("With a defined partitionKeyDefinition", () => { const partitionKeyDefinition = { paths: ["/a/b"] }; const migratedPartitionKeyDefinition = { paths: ["/_partitionKey"], isSystemKey: true }; - it("should return [{}] when document has no partition key value", function () { + it("should return [{}] when document has no partition key value", () => { const document = {}; const result = extractPartitionKeys(document, partitionKeyDefinition); assert.deepEqual(result, [{}]); }); - it("should return [] when container is migrated from non-partitioned and document has no partition key value", function () { + it("should return [] when container is migrated from non-partitioned and document has no partition key value", () => { const document = {}; const result = extractPartitionKeys(document, migratedPartitionKeyDefinition); assert.deepEqual(result, [{}]); }); - it("should return [null] when document has a null partition key value", function () { + it("should return [null] when document has a null partition key value", () => { const document: any = { a: { b: null } }; const result = extractPartitionKeys(document, partitionKeyDefinition); assert.deepEqual(result, [null]); }); - it("should return [{}] when document has a partially defined partition key value", function () { + it("should return [{}] when document has a partially defined partition key value", () => { const document = { a: "some value" }; const result = extractPartitionKeys(document, partitionKeyDefinition); assert.deepEqual(result, [{}]); }); - it("should return [value] when document has a valid partition key value", function () { + it("should return [value] when document has a valid partition key value", () => { const document = { a: { b: "some value" } }; const result = extractPartitionKeys(document, partitionKeyDefinition); assert.deepEqual(result, ["some value"]); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts index c72916217304..b4b02db34563 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/queryMetrics.spec.ts @@ -10,7 +10,7 @@ import { } from "../../../src/index.js"; import { describe, it, assert } from "vitest"; -describe("QueryMetrics", function () { +describe("QueryMetrics", () => { // Properties const totalQueryExecutionTime = TimeSpan.fromMilliseconds(33.67); const queryCompilationTime = TimeSpan.fromMilliseconds(0.06); @@ -117,7 +117,7 @@ describe("QueryMetrics", function () { ); }; - it("Can Be Cloned", function () { + it("Can Be Cloned", () => { const queryMetrics2 = new QueryMetrics( queryMetrics.retrievedDocumentCount, queryMetrics.retrievedDocumentSize, @@ -137,7 +137,7 @@ describe("QueryMetrics", function () { assertQueryMetricsEquality(queryMetrics, queryMetrics2); }); - it("Should Add Two Query Metrics", function () { + it("Should Add Two Query Metrics", () => { const doubleQueryMetrics = queryMetrics.add([queryMetrics]); const doubleRetrievedDocumentCount = retrievedDocumentCount * 2; @@ -215,7 +215,7 @@ describe("QueryMetrics", function () { assertQueryMetricsEquality(queryMetricsFromCreateArray, expectedQueryMetrics); }); - it("Can Be Create From Delimited String", function () { + it("Can Be Create From Delimited String", () => { const queryMetricsFromDelimitedString = QueryMetrics.createFromDelimitedString( delimitedString, new ClientSideMetrics(requestCharge), @@ -224,7 +224,7 @@ describe("QueryMetrics", function () { assertQueryMetricsEquality(queryMetricsFromDelimitedString, queryMetrics); }); - it("Can Be Converted To A Delimited String", function () { + it("Can Be Converted To A Delimited String", () => { const delimitedStringFromMetrics = queryMetrics.toDelimitedString(); const queryMetricsFromDelimitedString = QueryMetrics.createFromDelimitedString( delimitedStringFromMetrics, diff --git a/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts index b56ea5852bc3..df4435780bd7 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/retry.spec.ts @@ -6,7 +6,7 @@ import { describe, it } from "vitest"; // import { ConnectionPolicy, Constants, CosmosClient, RetryOptions } from "../../src"; // import * as request from "../../src/request"; -describe("retry policy tests", function () { +describe("retry policy tests", () => { // this.timeout(300000); // const collectionDefinition = { // id: "sample collection" @@ -41,7 +41,7 @@ describe("retry policy tests", function () { // } // TODO: need to fix this, the stubbing doesn't work with the new way we work - it.skip("throttle retry policy test default retryAfter", async function () { + it.skip("throttle retry policy test default retryAfter", async () => { // connectionPolicy.RetryOptions = new RetryOptions(5); // const client = new CosmosClient({endpoint, key: masterKey, connectionPolicy}); // const { result: db } = await client.createDatabase({ id: "sample database" }); @@ -65,7 +65,7 @@ describe("retry policy tests", function () { // client.getDatabaseAccount = originalGetDatabaseAccount; }); - it.skip("throttle retry policy test fixed retryAfter", async function () { + it.skip("throttle retry policy test fixed retryAfter", async () => { // connectionPolicy.RetryOptions = new RetryOptions(5, 2000); // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); @@ -90,7 +90,7 @@ describe("retry policy tests", function () { // client.getDatabaseAccount = originalGetDatabaseAccount; }); - it.skip("throttle retry policy test max wait time", async function () { + it.skip("throttle retry policy test max wait time", async () => { // connectionPolicy.RetryOptions = new RetryOptions(5, 2000, 3); // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); @@ -111,7 +111,7 @@ describe("retry policy tests", function () { // client.getDatabaseAccount = originalGetDatabaseAccount; }); - it.skip("default retry policy validate create failure", async function () { + it.skip("default retry policy validate create failure", async () => { // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); // const { result: collection } = await client.createCollection(db._self, collectionDefinition); @@ -127,7 +127,7 @@ describe("retry policy tests", function () { // request._createRequestObjectStub = global.originalFunc; }); - it.skip("default retry policy validate read success", async function () { + it.skip("default retry policy validate read success", async () => { // const client = new CosmosClient(endpoint, { masterKey }, connectionPolicy); // const { result: db } = await client.createDatabase({ id: "sample database" }); // const { result: collection } = await client.createCollection(db._self, collectionDefinition); diff --git a/sdk/test-utils/test-utils-vitest/src/index.ts b/sdk/test-utils/test-utils-vitest/src/index.ts index 1bc58cc42dc6..3848b53e6950 100644 --- a/sdk/test-utils/test-utils-vitest/src/index.ts +++ b/sdk/test-utils/test-utils-vitest/src/index.ts @@ -13,3 +13,4 @@ export * from "./tracing/testTracerProvider.js"; export * from "./tracing/spanGraphModel.js"; export * from "./fakeTestSecrets.js"; export { createMockTracingContext } from "./tracing/mockContext.js"; +export * from "./utils.js"; diff --git a/sdk/test-utils/test-utils-vitest/src/utils.ts b/sdk/test-utils/test-utils-vitest/src/utils.ts new file mode 100644 index 000000000000..6f073ad3d403 --- /dev/null +++ b/sdk/test-utils/test-utils-vitest/src/utils.ts @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { TaskContext, RunnerTestSuite } from "vitest"; + +/** + * Gets the full title of a task to mimic the behavior of Mocha's full title. + * @param ctx - The task context. + * @returns The full title that includes the suite and task name. + */ +export function getTaskFullTitle(ctx: TaskContext): string { + function getTitlePath(suite: RunnerTestSuite | undefined): string[] { + if (suite) { + return [...getTitlePath(suite.suite), suite.name]; + } + return []; + } + + return [...getTitlePath(ctx.task.suite), ctx.task.name].join(" "); +} From 0746e9b3eafdec1ae48469db9cbd689cb499c510 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 5 Dec 2024 20:13:31 -0500 Subject: [PATCH 14/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/package.json | 29 +++++++++++--- .../src/utils/hashing/encoding/number.ts | 38 ++++++++----------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 841cbcb6ea41..6d2a4c5d7521 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -15,8 +15,8 @@ "azure" ], "author": "Microsoft Corporation", - "main": "./dist/index.js", - "module": "./dist-esm/src/index.js", + "main": "./dist/commonjs/index.js", + "module": "./dist/esm/index.js", "browser": "./dist/browser/index.js", "files": [ "dist/", @@ -33,7 +33,7 @@ } ] }, - "types": "./dist/types/latest/cosmos.d.ts", + "types": "./dist/commonjs/index.d.ts", "engines": { "node": ">=18.0.0" }, @@ -80,7 +80,6 @@ "@azure/core-tracing": "^1.2.0", "@azure/core-util": "^1.11.0", "fast-json-stable-stringify": "^2.1.0", - "jsbi": "^4.3.0", "priorityqueuejs": "^2.0.0", "semaphore": "^1.1.0", "tslib": "^2.8.1" @@ -99,7 +98,6 @@ "@vitest/coverage-istanbul": "^2.1.8", "dotenv": "^16.0.0", "eslint": "^9.9.0", - "execa": "^5.0.0", "nock": "^13.5.4", "playwright": "^1.49.0", "typescript": "~5.6.2", @@ -156,5 +154,26 @@ "react-native" ], "selfLink": false + }, + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } } } diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts index c6ade43b95f0..c2750dd737ab 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts @@ -1,20 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import JSBI from "jsbi"; import { BytePrefix } from "./prefix.js"; export function writeNumberForBinaryEncodingJSBI(hash: number): Buffer { let payload = encodeNumberAsUInt64JSBI(hash); let outputStream = Buffer.from(BytePrefix.Number, "hex"); - const firstChunk = JSBI.asUintN(64, JSBI.signedRightShift(payload, JSBI.BigInt(56))); + const firstChunk = BigInt.asUintN(64, payload >> BigInt(56)); outputStream = Buffer.concat([outputStream, Buffer.from(firstChunk.toString(16), "hex")]); - payload = JSBI.asUintN(64, JSBI.leftShift(JSBI.BigInt(payload), JSBI.BigInt(0x8))); + payload = BigInt.asUintN(64, BigInt(payload << BigInt(0x8))); - let byteToWrite = JSBI.BigInt(0); + let byteToWrite = BigInt(0); let firstIteration = false; - let shifted: JSBI; + let shifted: bigint; let padded: string; do { @@ -30,12 +29,12 @@ export function writeNumberForBinaryEncodingJSBI(hash: number): Buffer { 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))); + shifted = BigInt.asUintN(64, payload >> BigInt(56)); + byteToWrite = BigInt.asUintN(64, shifted | BigInt(0x01)); + payload = BigInt.asUintN(64, payload << BigInt(7)); + } while (payload !== BigInt(0)); - const lastChunk = JSBI.asUintN(64, JSBI.bitwiseAnd(byteToWrite, JSBI.BigInt(0xfe))); + const lastChunk = BigInt.asUintN(64, byteToWrite & 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 @@ -47,12 +46,10 @@ export function writeNumberForBinaryEncodingJSBI(hash: number): Buffer { return outputStream; } -function encodeNumberAsUInt64JSBI(value: number): JSBI { +function encodeNumberAsUInt64JSBI(value: number): bigint { const rawValueBits = getRawBitsJSBI(value); - const mask = JSBI.BigInt(0x8000000000000000); - const returned = JSBI.greaterThan(mask, rawValueBits) - ? JSBI.bitwiseXor(rawValueBits, mask) - : JSBI.add(JSBI.bitwiseNot(rawValueBits), JSBI.BigInt(1)); + const mask = BigInt(0x8000000000000000); + const returned = mask > rawValueBits ? rawValueBits ^ mask : ~rawValueBits + BigInt(1); return returned; } @@ -60,20 +57,15 @@ export function doubleToByteArrayJSBI(double: number): Buffer { const output: Buffer = 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), - ), - ); + output[i] = Number((lng >> (BigInt(i) * BigInt(8))) & BigInt(0xff)); } return output; } -function getRawBitsJSBI(value: number): JSBI { +function getRawBitsJSBI(value: number): bigint { const view = new DataView(new ArrayBuffer(8)); view.setFloat64(0, value); - return JSBI.BigInt(`0x${buf2hex(view.buffer)}`); + return BigInt(`0x${buf2hex(view.buffer)}`); } function buf2hex(buffer: ArrayBuffer): string { From 94c7802210772617678b95063bf5b29e4be09b83 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 6 Dec 2024 10:22:57 -0500 Subject: [PATCH 15/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/browser-test.js | 3 - sdk/cosmosdb/cosmos/bundle-types.js | 17 --- sdk/cosmosdb/cosmos/consumer-test.js | 34 ----- sdk/cosmosdb/cosmos/package.json | 4 +- sdk/cosmosdb/cosmos/prep-samples.js | 4 - .../cosmos/test/internal/unit/auth.spec.ts | 9 +- .../changeFeedRetentionTimeSpan.spec.ts | 1 - .../unit/changeFeed/changeFeedUtils.spec.ts | 1 - .../unit/changeFeed/feedRangeQueue.spec.ts | 1 - .../cosmos/test/internal/unit/client.spec.ts | 143 +++++++----------- .../unit/defaultQueryExecutionContext.spec.ts | 2 +- .../test/internal/unit/diagnostics.spec.ts | 68 +++++---- .../test/internal/unit/getHeader.spec.ts | 12 +- .../unit/globalStatisticsAggregator.spec.ts | 20 ++- .../test/internal/unit/hashing/v1.spec.ts | 1 - .../test/internal/unit/hashing/v2.spec.ts | 1 - .../cosmos/test/internal/unit/helper.spec.ts | 10 +- .../unit/inMemoryCollectionRoutingMap.spec.ts | 30 ++-- .../test/internal/unit/platform.spec.ts | 18 ++- .../test/internal/unit/sasToken.spec.ts | 8 +- .../internal/unit/sessionContainer.spec.ts | 6 +- .../unit/smartRoutingMapProvider.spec.ts | 42 ++--- .../unit/timeoutFailoverRetryPolicy.spec.ts | 22 +-- .../test/internal/unit/utils/batch.spec.ts | 1 - .../test/internal/unit/utils/checkURL.spec.ts | 2 +- .../unit/utils/nonStreamingOrderByMap.spec.ts | 2 +- .../nonStreamingOrderByPriorityQueue.spec.ts | 2 +- .../test/internal/unit/utils/offer.spec.ts | 2 +- .../supportedQueryFeaturesBuilder.spec.ts | 2 +- .../public/functional/authorization.spec.ts | 2 +- .../nonStreamingDistinctOrderBy.spec.ts | 10 +- .../nonStreamingOrderBy.spec.ts | 10 +- sdk/cosmosdb/cosmos/tsconfig.json | 3 +- sdk/cosmosdb/cosmos/vitest.browser.config.ts | 5 +- sdk/cosmosdb/cosmos/vitest.config.ts | 3 +- 35 files changed, 202 insertions(+), 299 deletions(-) delete mode 100644 sdk/cosmosdb/cosmos/browser-test.js delete mode 100644 sdk/cosmosdb/cosmos/bundle-types.js delete mode 100644 sdk/cosmosdb/cosmos/consumer-test.js delete mode 100644 sdk/cosmosdb/cosmos/prep-samples.js diff --git a/sdk/cosmosdb/cosmos/browser-test.js b/sdk/cosmosdb/cosmos/browser-test.js deleted file mode 100644 index d656d0a42d8e..000000000000 --- a/sdk/cosmosdb/cosmos/browser-test.js +++ /dev/null @@ -1,3 +0,0 @@ -const tests = require.context("./lib/", true, /\.spec\.js$/); - -tests.keys().forEach(tests); diff --git a/sdk/cosmosdb/cosmos/bundle-types.js b/sdk/cosmosdb/cosmos/bundle-types.js deleted file mode 100644 index 21981d0886b6..000000000000 --- a/sdk/cosmosdb/cosmos/bundle-types.js +++ /dev/null @@ -1,17 +0,0 @@ -// TODO. The api-extractor CLI command forces us into their docs generation and will error. -// By invoking the node API we avoid this. -// But we also swallow errors. -// See https://github.com/Microsoft/web-build-tools/issues/920 -const ApiExtractor = require("@microsoft/api-extractor"); -const NodeCoreLib = require("@microsoft/node-core-library"); -const config = NodeCoreLib.JsonFile.loadAndValidate( - "api-extractor.json", - ApiExtractor.Extractor.jsonSchema, -); - -// This interface provides additional runtime state that is NOT part of the config file -const options = { - localBuild: process.argv.indexOf("--ship") < 0, -}; -const extractor = new ApiExtractor.Extractor(config, options); -extractor.processProject(); diff --git a/sdk/cosmosdb/cosmos/consumer-test.js b/sdk/cosmosdb/cosmos/consumer-test.js deleted file mode 100644 index cb0ab3041e3c..000000000000 --- a/sdk/cosmosdb/cosmos/consumer-test.js +++ /dev/null @@ -1,34 +0,0 @@ -const execa = require("execa"); -let tsVersionsToCheckCompatibility = ["4.2"]; - -if (!process.env.SKIP_LATEST) { - tsVersionsToCheckCompatibility.push("latest"); -} - -async function exec(cmd) { - const command = execa(cmd, { cwd: "./consumer-test", shell: true }); - command.stderr.pipe(process.stderr); - command.stdout.pipe(process.stdout); - return command; -} - -(async () => { - try { - console.log("Running typescript consumer test against", tsVersionsToCheckCompatibility); - for (const version of tsVersionsToCheckCompatibility) { - console.log(`Compiling with typescript@${version} - Basic`); - await exec( - `npx -p typescript@${version} tsc ./test.ts --allowSyntheticDefaultImports true --target ES5`, - ); - console.log(`Compiling with typescript@${version} - Custom lib`); - await exec( - `npx -p typescript@${version} tsc ./test.ts --allowSyntheticDefaultImports true --lib es2018`, - ); - } - process.exit(0); - } catch (error) { - console.log("Typescript consumer test failed!"); - console.log(error); - process.exit(1); - } -})(); diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 6d2a4c5d7521..1cbfa8aed1f9 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -62,7 +62,7 @@ "test:signoff": "npm run integration-test:node -- --fgrep \"nosignoff\" --invert", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser", - "unit-test:node": "dev-tool run test:vitest", + "unit-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' dev-tool run test:vitest", "update-snippets": "echo skipped" }, "repository": "github:Azure/azure-sdk-for-js", @@ -98,7 +98,7 @@ "@vitest/coverage-istanbul": "^2.1.8", "dotenv": "^16.0.0", "eslint": "^9.9.0", - "nock": "^13.5.4", + "nock": "^13.5.6", "playwright": "^1.49.0", "typescript": "~5.6.2", "vitest": "^2.1.8" diff --git a/sdk/cosmosdb/cosmos/prep-samples.js b/sdk/cosmosdb/cosmos/prep-samples.js deleted file mode 100644 index 7f41580c426f..000000000000 --- a/sdk/cosmosdb/cosmos/prep-samples.js +++ /dev/null @@ -1,4 +0,0 @@ -const fs = require("fs"); - -// work around TS not being able to find the typings when not importing from a package reference. -fs.copyFileSync("./dist/types/latest/cosmos.d.ts", "./dist/index.d.ts"); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts index 73d300e12e9d..bd725b1e6333 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/auth.spec.ts @@ -2,13 +2,10 @@ // Licensed under the MIT License. import { getAuthorizationTokenUsingResourceTokens } from "../../../src/auth.js"; -import assert from "node:assert"; import { describe, it, assert } from "vitest"; -describe("NodeJS CRUD Tests", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); - - it("should find exact match", async function () { +describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { + it("should find exact match", async () => { const token = getAuthorizationTokenUsingResourceTokens( { foo: "bar", @@ -19,7 +16,7 @@ describe("NodeJS CRUD Tests", function (this: Suite) { assert.strictEqual(token, "bar"); }); - it("should only allow container tokens", async function () { + it("should only allow container tokens", async () => { const token = getAuthorizationTokenUsingResourceTokens( { "dbs/ValidateAuthorization containe8734/colls/ValidateAuthorization containe5344": "token", diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts index ac50f90de152..329e0efe2b42 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedRetentionTimeSpan.spec.ts @@ -2,7 +2,6 @@ // Licensed under the MIT License. import { ChangeFeedRetentionTimeSpan } from "../../../../src/client/ChangeFeed/ChangeFeedRetentionTimeSpan.js"; -import assert from "node:assert"; import { describe, it, assert } from "vitest"; describe("test ChangeFeedRetentionTimeSpan", function () { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts index 24f3466ce060..3e0825e2e1f5 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/changeFeedUtils.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import { extractOverlappingRanges, isNullOrEmpty, diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts index 619b7606042a..b458566d1ce9 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/changeFeed/feedRangeQueue.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import { FeedRangeQueue } from "../../../../src/client/ChangeFeed/FeedRangeQueue.js"; import { ChangeFeedRange } from "../../../../src/client/ChangeFeed/ChangeFeedRange.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts index c0bcad1aa0ad..c4c5f8a77b79 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts @@ -1,16 +1,16 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Container, RequestContext } from "../../../src/index.js"; +import nock from "nock"; +import type { Container } from "../../../src/index.js"; import { CosmosClient, PatchOperationType, ResourceType } from "../../../src/index.js"; -import assert from "node:assert"; import { getTestContainer } from "../../public/common/TestHelpers.js"; import type { AccessToken, TokenCredential } from "@azure/identity"; -import nock from "nock"; import { RequestHandler } from "../../../src/request/RequestHandler.js"; import { masterKey } from "../../public/common/_fakeTestSecrets.js"; import { endpoint } from "../../public/common/_testConfig.js"; -import { describe, it, assert, expect, vi, beforeEach, afterEach } from "vitest"; +import type { MockInstance } from "vitest"; +import { describe, it, assert, vi, beforeEach, afterEach } from "vitest"; class MockCredential implements TokenCredential { constructor(public returnPromise: Promise) {} @@ -66,25 +66,23 @@ const testDataset = { }, }; -describe("Testing Credentials integration for Client", function (this: Suite) { +describe("Testing Credentials integration for Client", () => { // endpoint for mock server, which doesn't conflict with emulator's endpoints. - const mockedEndpoint = "https://localhost:8082"; + const mockedEndpoint = "https://localhost:6969"; const aadToken = "aadToken"; - let sandbox: SinonSandbox; - let spy: SinonSpy; - beforeEach(function () { - sandbox = Sinon.createSandbox(); - }); - function setupSpyOnRequestHandler() { - spy = sandbox.spy(RequestHandler, "request"); + let spy: MockInstance; + + function setupSpyOnRequestHandler(): void { + spy = vi.spyOn(RequestHandler, "request"); } - afterEach(function () { + afterEach(() => { vi.restoreAllMocks(); }); - describe("Client Test With AAD Credentials", function () { + describe("Client Test With AAD Credentials", () => { let client: CosmosClient; - beforeEach(function () { + + beforeEach(() => { client = new CosmosClient({ endpoint: mockedEndpoint, aadCredentials: new MockCredential( @@ -92,109 +90,89 @@ describe("Testing Credentials integration for Client", function (this: Suite) { ), }); }); - afterEach(function () { + + afterEach(() => { nock.restore(); nock.cleanAll(); nock.enableNetConnect(); }); - it("Test pipeline setup for items.create for aadCredentials", async function () { + + it("Test pipeline setup for items.create for aadCredentials", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); await container.items.create(item1Definition); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - return !!arg?.pipeline; - }), - ), - ); + + const spyCall = spy.mock.calls[0][0]; + assert.isDefined(spyCall.pipeline); }); - it("Test pipeline setup for items.read for aadCredentials", async function () { + + it("Test pipeline setup for items.read for aadCredentials", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); await container.items.create(item1Definition); setupSpyOnRequestHandler(); + await container.item(item1Definition.id, "dummy_partition_key").read(); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - return !!arg?.pipeline; - }), - ), - ); + + const spyCall = spy.mock.calls[0][0]; + assert.isDefined(spyCall.pipeline); }); - it("Test pipeline setup for items.patch", async function () { + + it("Test pipeline setup for items.patch", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); await container.items.create(item1Definition); setupSpyOnRequestHandler(); + await container.item(item1Definition.id).patch([item1patchRequest]); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - return !!arg?.pipeline; - }), - ), - ); + + const spyCall = spy.mock.calls[0][0]; + assert.isDefined(spyCall.pipeline); }); - it("Test pipeline setup for items.replace", async function () { + + it("Test pipeline setup for items.replace", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); await container .item(item1Definition.id, "dummy_partition_key") .replace(testDataset.itemGetResponse); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - return !!arg?.pipeline; - }), - ), - ); + + const spyCall = spy.mock.calls[0][0]; + assert.isDefined(spyCall.pipeline); }); - it("Test pipeline setup for items.upsert", async function () { + it("Test pipeline setup for items.upsert", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); await container.items.upsert(testDataset.itemGetResponse); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - return !!arg?.pipeline; - }), - ), - ); + + const spyCall = spy.mock.calls[0][0]; + assert.isDefined(spyCall.pipeline); }); - it("Test pipeline setup for items.delete", async function () { + it("Test pipeline setup for items.delete", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); await container.items.create(item1Definition); setupSpyOnRequestHandler(); + await container.item(item1Definition.id, "dummy_partition_key").delete(); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - return !!arg?.pipeline; - }), - ), - ); + const spyCall = spy.mock.calls[0][0]; + assert.isDefined(spyCall.pipeline); }); - it("Test pipeline setup for items.batch", async function () { + it("Test pipeline setup for items.batch", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); + await container.items.batch([]); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - return !!arg?.pipeline; - }), - ), - ); + + const spyCall = spy.mock.calls[0][0]; + assert.isDefined(spyCall.pipeline); }); - function setupMockResponse() { + function setupMockResponse(): void { if (!nock.isActive()) { nock.activate(); } @@ -230,8 +208,9 @@ describe("Testing Credentials integration for Client", function (this: Suite) { .reply(200, testDataset.itemGetResponse); } }); - describe("Client Test With key", function () { - it("Test items.create for tokens", async function () { + + describe("Client Test With key", { skip: true }, () => { + it("Test items.create for tokens", async () => { const client = new CosmosClient({ endpoint: endpoint, key: masterKey, @@ -239,15 +218,9 @@ describe("Testing Credentials integration for Client", function (this: Suite) { const container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); await container.items.create(item1Definition); - assert( - spy.calledWithMatch( - Sinon.match(function (arg: RequestContext) { - const AUTH_PREFIX = `type%3Dmaster%26ver%3D1`; - const authHeader: string = arg?.headers["authorization"]?.toString() || ""; - return authHeader.includes(AUTH_PREFIX); - }), - ), - ); + + const spyCall = spy.mock.calls[0][0]; + assert.isTrue(spyCall.headers.authorization.includes("type%3Dmaster%26ver%3D1")); }); }); }); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts index 62e3d501da06..85786912a936 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/defaultQueryExecutionContext.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. + import type { FetchFunctionCallback } from "../../../src/queryExecutionContext/index.js"; import { DefaultQueryExecutionContext } from "../../../src/queryExecutionContext/index.js"; import type { FeedOptions } from "../../../src/index.js"; -import assert from "node:assert"; import { sleep } from "../../../src/common/index.js"; import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts index 78bcfce5a475..5f3b3489e898 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/diagnostics.spec.ts @@ -32,21 +32,22 @@ import { getDiagnosticLevelFromEnvironment, setDiagnosticLevel, } from "../../../src/diagnostics/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, expect, beforeEach, afterEach } from "vitest"; -describe("Diagnostic Unit Tests", function (this: Suite) { - describe("Test withDiagnostics utility function", function () { +describe("Diagnostic Unit Tests", () => { + describe("Test withDiagnostics utility function", () => { const clientContext = createTestClientContext({}, undefined); - it("Test wrapped function's returned type is returned properly", async function () { + it("Test wrapped function's returned type is returned properly", async () => { const testValue = "testValue"; const testResponse = await withDiagnostics(async (node: DiagnosticNodeInternal) => { - expect(node).to.exist; // eslint-disable-line no-unused-expressions + expect(node).to.exist; return testValue; }, clientContext); expect(testResponse).to.eql(testValue); }); - it("Test CosmosDiagnostic getting injected for supported Response Types.", async function () { + + it("Test CosmosDiagnostic getting injected for supported Response Types.", async () => { const itemResource: Resource = { id: "item1", _rid: "item1`", @@ -57,7 +58,7 @@ describe("Diagnostic Unit Tests", function (this: Suite) { const emptyDiagnostics = getEmptyCosmosDiagnostics(); const testValue = new ItemResponse(itemResource, {}, 200, 0, {} as any, emptyDiagnostics); const testResponse = await withDiagnostics(async (node: DiagnosticNodeInternal) => { - expect(node).to.exist; // eslint-disable-line no-unused-expressions + expect(node).to.exist; return testValue; }, clientContext); expect(testResponse).to.eql(testValue); @@ -65,8 +66,8 @@ describe("Diagnostic Unit Tests", function (this: Suite) { }); }); - describe("Test addDignosticChild utility function", async function () { - it("Test in case of exception, exception Diagnostic Node is marked failed and exception is rethrown.", async function () { + describe("Test addDignosticChild utility function", async () => { + it("Test in case of exception, exception Diagnostic Node is marked failed and exception is rethrown.", async () => { const diagnosticNode = new DiagnosticNodeInternal( CosmosDbDiagnosticLevel.debug, DiagnosticNodeType.CLIENT_REQUEST_NODE, @@ -74,10 +75,10 @@ describe("Diagnostic Unit Tests", function (this: Suite) { ); const childNodeType = DiagnosticNodeType.METADATA_REQUEST_NODE; // Ensure that addDignosticChild throws an exception by wrapping it in a function - const wrapperFunction = async () => { + const wrapperFunction = async (): Promise => { await addDignosticChild( async (childNode) => { - expect(childNode).to.exist; // eslint-disable-line no-unused-expressions + expect(childNode).to.exist; throw new ErrorResponse("Testing error handling in diagnostic child."); }, diagnosticNode, @@ -93,7 +94,8 @@ describe("Diagnostic Unit Tests", function (this: Suite) { expect(error.message).to.equal("Testing error handling in diagnostic child."); } }); - it("Test in case debug and debug-unsafe diagnostic level child diagnostic nodes are added.", async function () { + + it("Test in case debug and debug-unsafe diagnostic level child diagnostic nodes are added.", async () => { const testValue = "testValue"; // Ensure that addDignosticChild throws an exception by wrapping it in a function await Promise.all( @@ -107,7 +109,7 @@ describe("Diagnostic Unit Tests", function (this: Suite) { const childNodeType = DiagnosticNodeType.METADATA_REQUEST_NODE; const testResponse = await addDignosticChild( async (childNode) => { - expect(childNode).to.exist; // eslint-disable-line no-unused-expressions + expect(childNode).to.exist; return testValue; }, diagnosticNode, @@ -124,7 +126,7 @@ describe("Diagnostic Unit Tests", function (this: Suite) { ), ); }); - it("Test in info diagnostic level child diagnostic nodes are not added.", async function () { + it("Test in info diagnostic level child diagnostic nodes are not added.", async () => { const diagnosticNode = new DiagnosticNodeInternal( CosmosDbDiagnosticLevel.info, DiagnosticNodeType.CLIENT_REQUEST_NODE, @@ -134,7 +136,7 @@ describe("Diagnostic Unit Tests", function (this: Suite) { // Ensure that addDignosticChild throws an exception by wrapping it in a function await addDignosticChild( async (childNode) => { - expect(childNode).to.exist; // eslint-disable-line no-unused-expressions + expect(childNode).to.exist; }, diagnosticNode, childNodeType, @@ -145,15 +147,15 @@ describe("Diagnostic Unit Tests", function (this: Suite) { }); }); - describe("Test ClientConfigDiagnostic initialization", function () { + describe("Test ClientConfigDiagnostic initialization", () => { let savedDiagnosticLevel: CosmosDbDiagnosticLevel | undefined; - beforeEach(async function () { + beforeEach(async () => { savedDiagnosticLevel = getDiagnosticLevelFromEnvironment(); }); - afterEach(function () { + afterEach(() => { setDiagnosticLevel(savedDiagnosticLevel); }); - it("Check for endpoint", async function () { + it("Check for endpoint", async () => { setDiagnosticLevel(CosmosDbDiagnosticLevel.debug); const testEndpoint = "AccountEndpoint=https://localhost:8081/;AccountKey=key"; const client = new CosmosClient(testEndpoint); @@ -163,7 +165,7 @@ describe("Diagnostic Unit Tests", function (this: Suite) { expect(clientConfigDiagnostic.endpoint).to.eq("https://localhost:8081/"); expect(clientContext.diagnosticLevel).to.eq(CosmosDbDiagnosticLevel.debug); }); - it("Check initilization of diagnostic level", async function () { + it("Check initilization of diagnostic level", async () => { const possibleDiagnosticLevels = [ CosmosDbDiagnosticLevel.info, CosmosDbDiagnosticLevel.debug, @@ -183,7 +185,7 @@ describe("Diagnostic Unit Tests", function (this: Suite) { expect(determineDiagnosticLevel(level, undefined)).to.eql(level); }); }); - it("Check setting of diagnostic level", async function () { + it("Check setting of diagnostic level", async () => { // Testing scope of diagnostic level is limited to an instance of CosmosDB client. const clientInfo = new CosmosClient({ endpoint: "https://localhost", @@ -210,28 +212,28 @@ describe("Diagnostic Unit Tests", function (this: Suite) { }); }); - it("Test Ordering of Diagnostic Level", function () { + it("Test Ordering of Diagnostic Level", () => { const info = CosmosDbDiagnosticLevel.info; const debug = CosmosDbDiagnosticLevel.debug; const debugUnsafe = CosmosDbDiagnosticLevel.debugUnsafe; - expect(allowTracing(info, info)).to.be.true; // eslint-disable-line no-unused-expressions - expect(allowTracing(debug, info)).to.be.false; // eslint-disable-line no-unused-expressions - expect(allowTracing(debugUnsafe, info)).to.be.false; // eslint-disable-line no-unused-expressions + expect(allowTracing(info, info)).to.be.true; + expect(allowTracing(debug, info)).to.be.false; + expect(allowTracing(debugUnsafe, info)).to.be.false; - expect(allowTracing(info, debug)).to.be.true; // eslint-disable-line no-unused-expressions - expect(allowTracing(debug, debug)).to.be.true; // eslint-disable-line no-unused-expressions - expect(allowTracing(debugUnsafe, debug)).to.be.false; // eslint-disable-line no-unused-expressions + expect(allowTracing(info, debug)).to.be.true; + expect(allowTracing(debug, debug)).to.be.true; + expect(allowTracing(debugUnsafe, debug)).to.be.false; - expect(allowTracing(info, debugUnsafe)).to.be.true; // eslint-disable-line no-unused-expressions - expect(allowTracing(debug, debugUnsafe)).to.be.true; // eslint-disable-line no-unused-expressions - expect(allowTracing(debugUnsafe, debugUnsafe)).to.be.true; // eslint-disable-line no-unused-expressions + expect(allowTracing(info, debugUnsafe)).to.be.true; + expect(allowTracing(debug, debugUnsafe)).to.be.true; + expect(allowTracing(debugUnsafe, debugUnsafe)).to.be.true; }); }); function createTestClientContext( options: Partial, diagnosticLevel: CosmosDbDiagnosticLevel, -) { +): ClientContext { const clientOps: CosmosClientOptions = { endpoint: "", connectionPolicy: { @@ -243,7 +245,7 @@ function createTestClientContext( const globalEndpointManager = new GlobalEndpointManager( clientOps, async (diagnosticNode: DiagnosticNodeInternal, opts: RequestOptions) => { - expect(opts).to.exist; // eslint-disable-line no-unused-expressions + expect(opts).to.exist; const dummyAccount: any = diagnosticNode; return dummyAccount; }, diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts index ec155d35ff34..694b2d8819ca 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/getHeader.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { Constants } from "../../../src/common/constants.js"; import { getHeaders } from "../../../src/request/request.js"; -import { CosmosHeaders, FeedOptions } from "../../../src/index.js"; +import type { CosmosHeaders, FeedOptions } from "../../../src/index.js"; import { describe, it, assert } from "vitest"; -describe("Test x-ms-documentdb-query-parallelizecrosspartitionquery header value", function () { +describe("Test x-ms-documentdb-query-parallelizecrosspartitionquery header value", () => { const mockedEndpoint = "https://localhost:8081"; function getHeadersFunc(feedOptions: FeedOptions): Promise { return getHeaders({ @@ -22,7 +22,8 @@ describe("Test x-ms-documentdb-query-parallelizecrosspartitionquery header value partitionKey: null, }); } - it("If maxDegreeOfParallelism > 1 then x-ms-documentdb-query-parallelizecrosspartitionquery header should be true", async function () { + + it("If maxDegreeOfParallelism > 1 then x-ms-documentdb-query-parallelizecrosspartitionquery header should be true", async () => { const headers = await getHeadersFunc({ maxDegreeOfParallelism: 2 }); assert.equal( headers[Constants.HttpHeaders.ParallelizeCrossPartitionQuery], @@ -30,7 +31,8 @@ describe("Test x-ms-documentdb-query-parallelizecrosspartitionquery header value "incorrect header value", ); }); - it("If maxDegreeOfParallelism == 0 then x-ms-documentdb-query-parallelizecrosspartitionquery header should be null", async function () { + + it("If maxDegreeOfParallelism == 0 then x-ms-documentdb-query-parallelizecrosspartitionquery header should be null", async () => { const headers = await getHeadersFunc({ maxDegreeOfParallelism: 0 }); assert.equal( headers[Constants.HttpHeaders.ParallelizeCrossPartitionQuery], diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts index 4544480f54c1..640bd1e82aee 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/globalStatisticsAggregator.spec.ts @@ -1,20 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; -import { GlobalStatisticsAggregator } from "../../../src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js"; -import { GlobalStatistics } from "../../../src/request/globalStatistics.js"; -import { describe, it, assert } from "vitest"; -describe("global statistics aggregator", function (this: Suite) { - this.timeout(process.env.MOCHA_TIMEOUT || 10000); +import { GlobalStatisticsAggregator } from "../../../src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.js"; +import type { GlobalStatistics } from "../../../src/request/globalStatistics.js"; +import { describe, it, assert, beforeEach } from "vitest"; +describe("global statistics aggregator", { timeout: 10000 }, () => { let aggregator: GlobalStatisticsAggregator; - beforeEach(function () { + beforeEach(() => { aggregator = new GlobalStatisticsAggregator(); }); - it("should aggregate document count and full text statistics", async function () { + it("should aggregate document count and full text statistics", async () => { const stats1: GlobalStatistics = { documentCount: 2, fullTextStatistics: [ @@ -44,7 +42,7 @@ describe("global statistics aggregator", function (this: Suite) { assert.deepStrictEqual(result.fullTextStatistics[1].hitCounts, [6, 7, 8]); }); - it("should handle empty full text statistics correctly", async function () { + it("should handle empty full text statistics correctly", async () => { const stats: GlobalStatistics = { documentCount: 1, fullTextStatistics: [], @@ -57,7 +55,7 @@ describe("global statistics aggregator", function (this: Suite) { assert.deepStrictEqual(result.fullTextStatistics, []); }); - it("should handle one Global Statistics correctly", async function () { + it("should handle one Global Statistics correctly", async () => { const stats1: GlobalStatistics = { documentCount: 2, fullTextStatistics: [ @@ -77,7 +75,7 @@ describe("global statistics aggregator", function (this: Suite) { assert.deepStrictEqual(result.fullTextStatistics[1].hitCounts, [4, 5, 6, 7]); }); - it("should handle null and undefined Global Statistics correctly", async function () { + it("should handle null and undefined Global Statistics correctly", async () => { const stats1: GlobalStatistics = { documentCount: 2, fullTextStatistics: [ diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts index cb9ce730344c..94383b231cda 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v1.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import { hashV1PartitionKey } from "../../../../src/utils/hashing/v1.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts index 508fdf74b22c..8255b924be4a 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hashing/v2.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import { hashV2PartitionKey } from "../../../../src/utils/hashing/v2.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts index 93c12aa8373e..d7f79d6e26d3 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/helper.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { parseConnectionString } from "../../../src/common/index.js"; import { describe, it, assert } from "vitest"; -describe("Helper methods", function () { - describe("parseConnectionString", function () { - it("parses a valid connection string", function () { +describe("Helper methods", () => { + describe("parseConnectionString", () => { + it("parses a valid connection string", () => { const connectionString = "AccountEndpoint=https://test-account.documents.azure.com:443/;AccountKey=c213asdasdefgdfgrtweaYPpgoeCsHbpRTHhxuMsTaw==;"; // [SuppressMessage("Microsoft.Security", "CS001:SecretInline", Justification="Not a real key")] const connectionObject = parseConnectionString(connectionString); @@ -14,7 +14,7 @@ describe("Helper methods", function () { assert.equal(connectionObject.endpoint, "https://test-account.documents.azure.com:443/"); assert.equal(connectionObject.key, "c213asdasdefgdfgrtweaYPpgoeCsHbpRTHhxuMsTaw=="); // [SuppressMessage("Microsoft.Security", "CS001:SecretInline", Justification="Not a real key")] }); - it("throws on invalid connection string", function () { + it("throws on invalid connection string", () => { const connectionString = "asdqweqsdfd==;==sfd;asdqwe;asdqwe"; assert.throws(() => parseConnectionString(connectionString)); }); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts index 3d11684ed805..5281ac2b141c 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/inMemoryCollectionRoutingMap.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { QueryRange } from "../../../src/routing/index.js"; import { createCompleteRoutingMap } from "../../../src/routing/CollectionRoutingMapFactory.js"; import { describe, it, assert } from "vitest"; -describe("InMemoryCollectionRoutingMap Tests", function () { - describe("getOverlappingRanges", function () { +describe("InMemoryCollectionRoutingMap Tests", () => { + describe("getOverlappingRanges", () => { const partitionKeyRanges = [ { id: "0", minInclusive: "", maxExclusive: "05C1C9CD673398" }, { @@ -29,7 +29,7 @@ describe("InMemoryCollectionRoutingMap Tests", function () { const partitionRangeWithInfo = partitionKeyRanges.map((r) => [r, true]); const collectionRoutingMap = createCompleteRoutingMap(partitionRangeWithInfo); - it("queryCompleteRange", function () { + it("queryCompleteRange", () => { const completeRange = new QueryRange("", "FF", true, false); const overlappingPartitionKeyRanges = collectionRoutingMap.getOverlappingRanges(completeRange); @@ -38,14 +38,14 @@ describe("InMemoryCollectionRoutingMap Tests", function () { assert.deepEqual(overlappingPartitionKeyRanges, partitionKeyRanges); }); - it("queryEmptyRange", function () { + it("queryEmptyRange", () => { const emtpyRange = new QueryRange("05C1C9CD673396", "05C1C9CD673396", true, false); const overlappingPartitionKeyRanges = collectionRoutingMap.getOverlappingRanges(emtpyRange); assert.equal(overlappingPartitionKeyRanges.length, 0); }); - it("queryPoint", function () { + it("queryPoint", () => { const pointRange = new QueryRange("05C1D9CD673397", "05C1D9CD673397", true, true); const overlappingPartitionKeyRanges = collectionRoutingMap.getOverlappingRanges(pointRange); @@ -54,7 +54,7 @@ describe("InMemoryCollectionRoutingMap Tests", function () { assert(overlappingPartitionKeyRanges[0].maxExclusive > pointRange.max); }); - it("boundaryPointQuery", function () { + it("boundaryPointQuery", () => { const pointRange = new QueryRange("05C1C9CD673398", "05C1C9CD673398", true, true); const overlappingPartitionKeyRanges = collectionRoutingMap.getOverlappingRanges(pointRange); @@ -65,7 +65,7 @@ describe("InMemoryCollectionRoutingMap Tests", function () { }); }); - describe("All methods", function () { + describe("All methods", () => { const partitionRangeWithInfo = [ [ { @@ -103,7 +103,7 @@ describe("InMemoryCollectionRoutingMap Tests", function () { const collectionRoutingMap = createCompleteRoutingMap(partitionRangeWithInfo); - it("validate _orderedPartitionKeyRanges", function () { + it("validate _orderedPartitionKeyRanges", () => { assert.equal("0", collectionRoutingMap.getOrderedParitionKeyRanges()[0].id); assert.equal("1", collectionRoutingMap.getOrderedParitionKeyRanges()[1].id); assert.equal("2", collectionRoutingMap.getOrderedParitionKeyRanges()[2].id); @@ -111,14 +111,14 @@ describe("InMemoryCollectionRoutingMap Tests", function () { }); // TODO: bad practice to test implementation details - it("validate _orderedPartitionInfo", function () { + it("validate _orderedPartitionInfo", () => { assert.equal(0, (collectionRoutingMap.orderedPartitionInfo as number[])[0]); assert.equal(1, (collectionRoutingMap.orderedPartitionInfo as number[])[1]); assert.equal(2, (collectionRoutingMap.orderedPartitionInfo as number[])[2]); assert.equal(3, (collectionRoutingMap.orderedPartitionInfo as number[])[3]); }); - it("validate getOverlappingRanges", function () { + it("validate getOverlappingRanges", () => { const completeRange = new QueryRange("", "FF", true, false); const compareId = function (a: any, b: any): number { @@ -161,9 +161,9 @@ describe("InMemoryCollectionRoutingMap Tests", function () { }); }); - describe("Error Handling", function () { - describe("Incorrect instantiation", function () { - it("Invalid Routing Map", function () { + describe("Error Handling", () => { + describe("Incorrect instantiation", () => { + it("Invalid Routing Map", () => { const partitionRangeWithInfo = [ [ { @@ -191,7 +191,7 @@ describe("InMemoryCollectionRoutingMap Tests", function () { }); // TODO: test does two things (code smell) - it("Incomplete Routing Map", function () { + it("Incomplete Routing Map", () => { let partitionRangeWithInfo = [ [ { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts index a36566dc336f..9063223fec37 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts @@ -1,22 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { Constants } from "../../../src/common/constants.js"; import { getUserAgent } from "../../../src/common/platform.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, expect } from "vitest"; +import process from "node:process"; +import packageJson from "../../../package.json" assert { type: "json" }; -// eslint-disable-next-line @typescript-eslint/no-require-imports -const packageJson = require("../../../package.json"); const packageVersion = packageJson["version"]; const constantVersion = Constants.SDKVersion; -describe("getUserAgent", function () { +describe("getUserAgent", () => { it("should contain the current SDK version", () => { + console.log(getUserAgent()); assert(getUserAgent().includes(packageVersion)); }); it("should contain the current node version", () => { - assert(getUserAgent().includes(process.version.replace("v", ""))); + const majorVersion = process.versions.node.split(".")[0]; + expect(getUserAgent()).toContain(majorVersion); }); it("should allow a custom suffix", () => { @@ -25,8 +27,8 @@ describe("getUserAgent", function () { }); }); -describe("Version", function () { - it("should have matching constant version & package version", function () { +describe("Version", () => { + it("should have matching constant version & package version", () => { assert.equal( constantVersion, packageVersion, diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts index 985bbdf0be01..234d5723175a 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/sasToken.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { CosmosClient } from "../../../src/index.js"; import { endpoint } from "../../public/common/_testConfig.js"; import { masterKey, userSasTokenKey } from "../../public/common/_fakeTestSecrets.js"; @@ -9,7 +9,7 @@ import { createAuthorizationSasToken } from "../../../src/utils/SasToken.js"; import type { SasTokenProperties } from "../../../src/client/SasToken/SasTokenProperties.js"; import { describe, it, assert } from "vitest"; -describe.skip("SAS Token Authorization", function () { +describe.skip("SAS Token Authorization", () => { const sasTokenProperties = { user: "user1", userTag: "", @@ -26,7 +26,7 @@ describe.skip("SAS Token Authorization", function () { dataPlaneWriterScope: 0, }; - it("should connect with sas token properties set", async function () { + it("should connect with sas token properties set", async () => { const key = await createAuthorizationSasToken(masterKey, sasTokenProperties); // If connecting to the Cosmos DB Emulator, disable TLS verification for your node process: @@ -54,7 +54,7 @@ describe.skip("SAS Token Authorization", function () { assert(undefined !== dbs, "Should be able to fetch list of databases"); }); - it("should connect when a user set sas token", async function () { + it("should connect when a user set sas token", async () => { const sasTokenClient = new CosmosClient({ endpoint, key: userSasTokenKey, diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts index 138870dcf55e..2341099802ce 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/sessionContainer.spec.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { Constants, OperationType, ResourceType } from "../../../src/common/index.js"; import type { CosmosHeaders } from "../../../src/queryExecutionContext/CosmosHeaders.js"; import { SessionContainer } from "../../../src/session/sessionContainer.js"; import type { SessionContext } from "../../../src/session/SessionContext.js"; import { describe, it, assert } from "vitest"; -describe("SessionContainer", function () { +describe("SessionContainer", () => { const collectionLink = "dbs/testDatabase/colls/testCollection"; const collectionRid = "-EdBAKsiRLM="; - it("set/get/delete", function () { + it("set/get/delete", () => { const sc = new SessionContainer(); const tokenString = "1:1#100#1=20#2=5#3=30"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts index 317af09d10db..e158b2fd7372 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/smartRoutingMapProvider.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import type { ClientContext } from "../../../src/ClientContext.js"; import { PartitionKeyRangeCache, @@ -11,7 +11,7 @@ import { MockedClientContext } from "../../public/common/MockClientContext.js"; import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; import { describe, it, assert } from "vitest"; -describe("Smart Routing Map Provider OverlappingRanges", function () { +describe("Smart Routing Map Provider OverlappingRanges", () => { const containerLink = "dbs/7JZZAA==/colls/7JZZAOS-JQA=/"; const partitionKeyRanges = [ @@ -196,63 +196,63 @@ describe("Smart Routing Map Provider OverlappingRanges", function () { await assertBothProvidersResultsEqual(queryRanges1); }; - describe("Test Full Range", function () { - it('query ranges: ["", ""FF)', function () { + describe("Test Full Range", () => { + it('query ranges: ["", ""FF)', () => { // query range is the whole partition key range const pkRange = new QueryRange("", "FF", true, false); return validateOverlappingRanges([pkRange], partitionKeyRanges); }); - it('query ranges: ("", ""FF)', function () { + it('query ranges: ("", ""FF)', () => { // query range is the whole partition key range const pkRange = new QueryRange("", "FF", false, false); return validateOverlappingRanges([pkRange], partitionKeyRanges); }); }); - describe("Test Empty Range", function () { - it("empty query range list", async function () { + describe("Test Empty Range", () => { + it("empty query range list", async () => { // query range list is empty await validateOverlappingRanges([], []); }); - it('query ranges: ("", ""]', async function () { + it('query ranges: ("", ""]', async () => { // validate the overlaping partition key ranges results for empty ranges is empty await validateOverlappingRanges([new QueryRange("", "", false, true)], []); }); - it('query ranges: ("", "")', async function () { + it('query ranges: ("", "")', async () => { // validate the overlaping partition key ranges results for empty ranges is empty await validateOverlappingRanges([new QueryRange("", "", false, false)], []); }); - it('query ranges: ["", "")', async function () { + it('query ranges: ["", "")', async () => { // validate the overlaping partition key ranges results for empty ranges is empty await validateOverlappingRanges([new QueryRange("", "", true, false)], []); }); }); - describe("Error Handling: Bad Overlapping Query Range", function () { - it("overlapping query ranges (in a point)", async function () { + describe("Error Handling: Bad Overlapping Query Range", () => { + it("overlapping query ranges (in a point)", async () => { const r1 = new QueryRange("", "AA", true, true); const r2 = new QueryRange("AA", "FF", true, false); await validateSmartOverlappingRanges([r1, r2], undefined, true); }); - it("overlapping query ranges (in a range)", async function () { + it("overlapping query ranges (in a range)", async () => { const r1 = new QueryRange("", "AB", true, false); const r2 = new QueryRange("AA", "FA", true, false); await validateSmartOverlappingRanges([r1, r2], undefined, true); }); - it("not sorted query ranges", async function () { + it("not sorted query ranges", async () => { const r1 = new QueryRange("AB", "AC", true, false); const r2 = new QueryRange("AA", "AB", true, false); await validateSmartOverlappingRanges([r1, r2], undefined, true); }); }); - it("Empty Ranges are thrown away", async function () { + it("Empty Ranges are thrown away", async () => { const e1 = new QueryRange("", "", true, false); const r1 = new QueryRange("", "AB", true, false); const e2 = new QueryRange("AB", "AB", true, false); @@ -262,12 +262,12 @@ describe("Smart Routing Map Provider OverlappingRanges", function () { await assertOverlappingRangesAreEqual([e1, r1, e2, r2, e3, e4], [r1, r2]); }); - it("Single Query Range", async function () { + it("Single Query Range", async () => { const r = new QueryRange("AB", "AC", true, false); await assertBothProvidersResultsEqual([r]); }); - it("Multiple Query Ranges", async function () { + it("Multiple Query Ranges", async () => { const ranges = [ new QueryRange("0000000040", "0000000045", true, false), new QueryRange("0000000045", "0000000046", true, false), @@ -276,12 +276,12 @@ describe("Smart Routing Map Provider OverlappingRanges", function () { await assertBothProvidersResultsEqual(ranges); }); - it("Single Boundary Case Query Range", async function () { + it("Single Boundary Case Query Range", async () => { const ranges = [new QueryRange("05C1C9CD673398", "05C1D9CD673398", true, false)]; await validateOverlappingRanges(ranges, partitionKeyRanges.slice(1, 2)); }); - it("Two Adjacent Boundary Case Query Ranges", async function () { + it("Two Adjacent Boundary Case Query Ranges", async () => { const ranges = [ // partitionKeyRanges[1] new QueryRange("05C1C9CD673398", "05C1D9CD673398", true, false), @@ -291,7 +291,7 @@ describe("Smart Routing Map Provider OverlappingRanges", function () { await validateOverlappingRanges(ranges, partitionKeyRanges.slice(1, 3)); }); - it("Two Ranges in one partition key range", async function () { + it("Two Ranges in one partition key range", async () => { const ranges = [ // two ranges fall in the same partition key range new QueryRange("05C1C9CD673400", "05C1C9CD673401", true, false), @@ -300,7 +300,7 @@ describe("Smart Routing Map Provider OverlappingRanges", function () { await validateOverlappingRanges(ranges, partitionKeyRanges.slice(1, 2)); }); - it("Complex", async function () { + it("Complex", async () => { const ranges = [ // all are covered by partitionKeyRanges[1] new QueryRange("05C1C9CD673398", "05C1D9CD673391", true, false), diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts index cf58149b4f06..614dd7111554 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/timeoutFailoverRetryPolicy.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { TimeoutFailoverRetryPolicy } from "../../../src/retry/timeoutFailoverRetryPolicy.js"; import { GlobalEndpointManager } from "../../../src/globalEndpointManager.js"; import { HTTPMethod, OperationType, ResourceType } from "../../../src/common/constants.js"; @@ -12,9 +12,9 @@ import { StatusCodes } from "../../../src/common/statusCodes.js"; import { TimeoutError } from "../../../src/request/TimeoutError.js"; import { getEmptyCosmosDiagnostics } from "../../../src/utils/diagnostics.js"; import { createDummyDiagnosticNode } from "../../public/common/TestHelpers.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeEach } from "vitest"; -describe("TimeoutFailoverRetryPolicy", function () { +describe("TimeoutFailoverRetryPolicy", () => { const databaseAccountBody: any = { writableLocations: [ { @@ -65,7 +65,7 @@ describe("TimeoutFailoverRetryPolicy", function () { let timeoutErr: TimeoutError; let locEndpoint: string; - beforeEach(async function () { + beforeEach(async () => { retryPolicy = new TimeoutFailoverRetryPolicy( gem, headers, @@ -79,7 +79,7 @@ describe("TimeoutFailoverRetryPolicy", function () { locEndpoint = "endpoint"; }); - it("should determine if retry should occur correctly", async function () { + it("should determine if retry should occur correctly", async () => { const err: ErrorResponse = timeoutErr; const retryContext: RetryContext | undefined = undefined; const locationEndpoint: string | undefined = undefined; @@ -105,7 +105,7 @@ describe("TimeoutFailoverRetryPolicy", function () { false, ); }); - it("should not retry when timeout error but the request is not valid for timeout error", async function () { + it("should not retry when timeout error but the request is not valid for timeout error", async () => { const retryPolicy_post = new TimeoutFailoverRetryPolicy( gem, headers, @@ -124,7 +124,7 @@ describe("TimeoutFailoverRetryPolicy", function () { false, ); }); - it("should not retry when Endpoint discovery is disabled", async function () { + it("should not retry when Endpoint discovery is disabled", async () => { const retryPolicy_endpointDiscoveryDisabled = new TimeoutFailoverRetryPolicy( gem, headers, @@ -143,7 +143,7 @@ describe("TimeoutFailoverRetryPolicy", function () { false, ); }); - it("should not retry when maxServiceUnavailableRetryCount exceeded", async function () { + it("should not retry when maxServiceUnavailableRetryCount exceeded", async () => { const serviceUnavailableErr: ErrorResponse = { code: StatusCodes.ServiceUnavailable, name: "service unavailable", @@ -179,7 +179,7 @@ describe("TimeoutFailoverRetryPolicy", function () { false, ); }); - it("should not retry when Maximum retry attempt count exceeded", async function () { + it("should not retry when Maximum retry attempt count exceeded", async () => { const retryPolicy_maxRetryAttemptCount = new TimeoutFailoverRetryPolicy( gem, headers, @@ -210,7 +210,7 @@ describe("TimeoutFailoverRetryPolicy", function () { false, ); }); - it("should not retry when multiple write locations are not allowed", async function () { + it("should not retry when multiple write locations are not allowed", async () => { const gem_test = new GlobalEndpointManager( { endpoint: "https://test.documents.azure.com:443/", @@ -250,7 +250,7 @@ describe("TimeoutFailoverRetryPolicy", function () { false, ); }); - it("should retry when prefered locations are not defined and failover count exceeds the number of read", async function () { + it("should retry when prefered locations are not defined and failover count exceeds the number of read", async () => { const gem_test2 = new GlobalEndpointManager( { endpoint: "https://test.documents.azure.com:443/", diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts index 1878e26e0779..dfaf0c6e8f71 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/batch.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import { Constants } from "../../../../src/index.js"; import type { Batch, Operation } from "../../../../src/utils/batch.js"; import { diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts index c49a20c8be82..0476aab7858b 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/checkURL.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { sanitizeEndpoint } from "../../../../src/utils/checkURL.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts index f723cea28b4c..3e388d7e022d 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByMap.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { NonStreamingOrderByMap } from "../../../../src/utils/nonStreamingOrderByMap.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts index b2342839326a..4250ed64cae9 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { FixedSizePriorityQueue } from "../../../../src/utils/fixedSizePriorityQueue.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts index 6d945b85ac26..ea365c2213d4 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/offer.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { validateOffer } from "../../../../src/utils/offers.js"; import type { ContainerRequest } from "../../../../src/index.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts index 82dfe5e69b5f..d318877edef4 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; + import { supportedQueryFeaturesBuilder } from "../../../../src/utils/supportedQueryFeaturesBuilder.js"; import type { FeedOptions } from "../../../../src/request/FeedOptions.js"; import { describe, it, assert } from "vitest"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts index 97f5958541d2..dabc6f6ea226 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/authorization.spec.ts @@ -52,7 +52,7 @@ describe("NodeJS CRUD Tests", { timeout: 10000 }, () => { }); // eslint-disable-next-line @typescript-eslint/explicit-function-return-type - const setupEntities = async function (isUpsertTest: boolean) { + const setupEntities = async (isUpsertTest: boolean) => { // create database const database = await getTestDatabase("Validate Authorization database"); // create container1 diff --git a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts index cbdc8d886eef..84a4e9e34c84 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import type { Container } from "../../../../src/index.js"; import { CosmosClient } from "../../../../src/index.js"; import { endpoint } from "../../common/_testConfig.js"; @@ -13,17 +12,16 @@ import { VectorEmbeddingDistanceFunction, VectorIndexType, } from "../../../../src/documents/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll, afterAll } from "vitest"; -describe("Test nonStreaming Queries", function () { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); +describe("Test nonStreaming Queries", { timeout: 30000 }, () => { let container: Container; const client = new CosmosClient({ endpoint, key: masterKey, }); - before(async () => { + beforeAll(async () => { const vectorEmbeddingPolicy: VectorEmbeddingPolicy = { vectorEmbeddings: [ { @@ -609,7 +607,7 @@ describe("Test nonStreaming Queries", function () { } }); - after(async function () { + afterAll(async () => { await removeAllDatabases(); }); }); diff --git a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts index 794f666119c8..3818d03df0f3 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import assert from "node:assert"; import type { Container } from "../../../../src/index.js"; import { CosmosClient } from "../../../../src/index.js"; import { endpoint } from "../../common/_testConfig.js"; @@ -13,17 +12,16 @@ import { VectorEmbeddingDistanceFunction, VectorIndexType, } from "../../../../src/documents/index.js"; -import { describe, it, assert } from "vitest"; +import { describe, it, assert, beforeAll, afterAll } from "vitest"; -describe("Test nonStreaming Queries", function () { - this.timeout(process.env.MOCHA_TIMEOUT || 30000); +describe("Test nonStreaming Queries", { timeout: 30000 }, () => { let container: Container; const client = new CosmosClient({ endpoint, key: masterKey, }); - before(async () => { + beforeAll(async () => { const vectorEmbeddingPolicy: VectorEmbeddingPolicy = { vectorEmbeddings: [ { @@ -629,7 +627,7 @@ describe("Test nonStreaming Queries", function () { } }); - after(async function () { + afterAll(async () => { await removeAllDatabases(); }); }); diff --git a/sdk/cosmosdb/cosmos/tsconfig.json b/sdk/cosmosdb/cosmos/tsconfig.json index 494466b2b107..4baddcbc491e 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.json +++ b/sdk/cosmosdb/cosmos/tsconfig.json @@ -28,6 +28,7 @@ "samples-dev/**/*.ts", "test/**/*.ts", "test/**/*.mts", - "test/**/*.cts" + "test/**/*.cts", + "package.json" ] } diff --git a/sdk/cosmosdb/cosmos/vitest.browser.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.config.ts index b48c61b2ef46..607c63035791 100644 --- a/sdk/cosmosdb/cosmos/vitest.browser.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.browser.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -9,9 +8,7 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: [ - "dist-test/browser/test/**/*.spec.js", - ], + include: ["dist-test/browser/test/internal/unit/**/*.spec.js"], }, }), ); diff --git a/sdk/cosmosdb/cosmos/vitest.config.ts b/sdk/cosmosdb/cosmos/vitest.config.ts index 39267dd2f56f..5927363e4c2c 100644 --- a/sdk/cosmosdb/cosmos/vitest.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -9,7 +8,7 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: ["test/**/*.spec.ts"], + include: ["test/internal/unit/**/*.spec.ts"], }, }), ); From 10c4cae2c25c6a4b541b77425fd90dd096574a44 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 6 Dec 2024 12:01:55 -0500 Subject: [PATCH 16/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 25 ++++++- .../unit/hybridExecutionContext.spec.ts | 65 +++++++++---------- .../cosmos/test/public/common/TestHelpers.ts | 4 +- 3 files changed, 53 insertions(+), 41 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index beae7aa5a70c..48a83fd43a93 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -19823,7 +19823,7 @@ packages: dev: false file:projects/cosmos.tgz: - resolution: {integrity: sha512-l5rV9Yu/fjvbShmu02iwVLOdLChhvsru7Ke7u8yG6uoPVQJK8Ruto5Y6gWeWaNiJ57yHruwQ+8iOiJj+fHuGuQ==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-kjUP3LdwwmEe/PuiN0fZs3x13sZXM25Bpw5K1CNpmFcutdX/IrIggs3fkKVtDpEwBTge/vuSAn3i76n6TfKcPw==, tarball: file:projects/cosmos.tgz} name: '@rush-temp/cosmos' version: 0.0.0 dependencies: @@ -19837,6 +19837,8 @@ packages: '@types/sinon': 17.0.3 '@types/sinonjs__fake-timers': 8.1.5 '@types/underscore': 1.13.0 + '@vitest/browser': 2.1.8(@types/node@18.19.67)(playwright@1.49.0)(typescript@5.6.3)(vitest@2.1.8) + '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) chai: 4.3.10 dotenv: 16.4.5 eslint: 9.16.0 @@ -19845,6 +19847,7 @@ packages: jsbi: 4.3.0 mocha: 10.8.2 nock: 13.5.6 + playwright: 1.49.0 priorityqueuejs: 2.0.0 requirejs: 2.3.7 semaphore: 1.1.0 @@ -19853,11 +19856,27 @@ packages: ts-node: 10.9.2(@types/node@18.19.67)(typescript@5.6.3) tslib: 2.8.1 typescript: 5.6.3 + vitest: 2.1.8(@types/node@18.19.67)(@vitest/browser@2.1.8) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - utf-8-validate + - vite + - webdriverio dev: false file:projects/create-microsoft-playwright-testing.tgz: diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts index cc4e06813a05..53e5f5d960dd 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts @@ -1,23 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +import type { ClientContext, FeedOptions, QueryInfo } from "../../../src/index.js"; import { - ClientContext, CosmosDbDiagnosticLevel, DiagnosticNodeInternal, - FeedOptions, - QueryInfo, DiagnosticNodeType, -} from "../../../src"; +} from "../../../src/index.js"; import { HybridQueryExecutionContext, HybridQueryExecutionContextBaseStates, -} from "../../../src/queryExecutionContext/hybridQueryExecutionContext"; -import { HybridSearchQueryInfo } from "../../../src/request/ErrorResponse"; -import { GlobalStatistics } from "../../../src/request/globalStatistics"; -import assert from "assert"; -import { HybridSearchQueryResult } from "../../../src/request/hybridSearchQueryResult"; -import sinon from "sinon"; -import { MockedClientContext } from "../../public/common/MockClientContext"; +} from "../../../src/queryExecutionContext/hybridQueryExecutionContext.js"; +import type { HybridSearchQueryInfo } from "../../../src/request/ErrorResponse.js"; +import type { GlobalStatistics } from "../../../src/request/globalStatistics.js"; +import type { HybridSearchQueryResult } from "../../../src/request/hybridSearchQueryResult.js"; +import { MockedClientContext } from "../../public/common/MockClientContext.js"; +import { describe, it, assert, expect, vi } from "vitest"; const collectionLink = "/dbs/testDb/colls/testCollection"; // Sample collection link const options: FeedOptions = { maxItemCount: 2, maxDegreeOfParallelism: 1 }; @@ -66,7 +63,7 @@ const partitionedQueryExecutionInfo = { const correlatedActivityId = "sample-activity-id"; // Example correlated activity ID const diagnosticLevel = CosmosDbDiagnosticLevel.info; -describe("hybridQueryExecutionContext", function () { +describe("hybridQueryExecutionContext", () => { const clientContext: ClientContext = new MockedClientContext( partitionedQueryExecutionInfo.queryRanges, ) as any; @@ -82,16 +79,12 @@ describe("hybridQueryExecutionContext", function () { ); context["options"] = options; - describe("initialize Method", async function () { - it("initialize Method should get executed correctly", async function () { - sinon - .stub(context["globalStatisticsExecutionContext"], "hasMoreResults") - .onCall(0) - .returns(true) // First call returns true - .onCall(1) - .returns(false); // Second call returns false - - sinon.stub(context["globalStatisticsExecutionContext"], "nextItem").resolves({ + describe("initialize Method", async () => { + it("initialize Method should get executed correctly", async () => { + vi.mocked(context["globalStatisticsExecutionContext"].hasMoreResults) + .mockReturnValueOnce(true) + .mockReturnValueOnce(false); + vi.mocked(context["globalStatisticsExecutionContext"].nextItem).mockResolvedValueOnce({ result: { documentCount: 2, fullTextStatistics: [{ totalWordCount: 100, hitCounts: [1, 2, 3] }], @@ -112,24 +105,24 @@ describe("hybridQueryExecutionContext", function () { }; // Stub the processComponentQueries and replacePlaceholders methods to assert that they are called - const processComponentQueriesSpy = sinon.spy(context as any, "processComponentQueries"); - const replacePlaceholdersSpy = sinon.spy(context as any, "replacePlaceholdersWorkaroud"); + const processComponentQueriesSpy = vi.spyOn(context as any, "processComponentQueries"); + const replacePlaceholdersSpy = vi.spyOn(context as any, "replacePlaceholdersWorkaroud"); // Call the initialize method await context["initialize"](diagnosticNode, sampleHeader); assert.strictEqual(context["componentsExecutionContext"].length, 1); assert.strictEqual(context["state"], HybridQueryExecutionContextBaseStates.initialized); - assert(processComponentQueriesSpy.calledOnce); - assert(replacePlaceholdersSpy.calledTwice); + expect(processComponentQueriesSpy).toHaveBeenCalledTimes(1); + expect(replacePlaceholdersSpy).toHaveBeenCalledTimes(2); - processComponentQueriesSpy.restore(); - replacePlaceholdersSpy.restore(); + processComponentQueriesSpy.mockRestore(); + replacePlaceholdersSpy.mockRestore(); }); }); - describe("ReplacePlaceholders Method", function () { - it("replacePlaceholders method should replace placeholders in all queries correctly", async function () { + describe("ReplacePlaceholders Method", () => { + it("replacePlaceholders method should replace placeholders in all queries correctly", async () => { // Array of query test cases const queryTestCases = [ { @@ -197,14 +190,14 @@ describe("hybridQueryExecutionContext", function () { const result = context["replacePlaceholdersWorkaroud"](queryToTest, stats1, 2); // Normalize both actual and expected queries by removing all whitespace - const normalize = (str: string) => str.replace(/\s+/g, " ").trim(); + const normalize = (str: string): string => str.replace(/\s+/g, " ").trim(); assert.equal(normalize(result), normalize(expectedQuery)); }); }); }); - describe("SortHybridSearchResultByRRFScore Method", function () { - it("sortHybridSearchResultByRRFScore method should sort hybrid search results correctly based on RRF score", async function () { + describe("SortHybridSearchResultByRRFScore Method", () => { + it("sortHybridSearchResultByRRFScore method should sort hybrid search results correctly based on RRF score", async () => { const input: HybridSearchQueryResult[] = [ { rid: "1", componentScores: [10, 20], data: {}, score: 0, ranks: [] }, { rid: "2", componentScores: [30, 10], data: {}, score: 0, ranks: [] }, @@ -218,7 +211,7 @@ describe("hybridQueryExecutionContext", function () { assert.deepStrictEqual(resultRids, expectedSortedRids); }); - it("sortHybridSearchResultByRRFScore method should sort hybrid search results with single component score", async function () { + it("sortHybridSearchResultByRRFScore method should sort hybrid search results with single component score", async () => { const input: HybridSearchQueryResult[] = [ { rid: "1", componentScores: [30], data: {}, score: 0, ranks: [] }, { rid: "2", componentScores: [20], data: {}, score: 0, ranks: [] }, @@ -232,7 +225,7 @@ describe("hybridQueryExecutionContext", function () { assert.deepStrictEqual(resultRids, expectedSortedRids); }); - it("sortHybridSearchResultByRRFScore method should handle one HybridSearchQueryResult", async function () { + it("sortHybridSearchResultByRRFScore method should handle one HybridSearchQueryResult", async () => { const input: HybridSearchQueryResult[] = [ { rid: "1", componentScores: [10, 20, 30], data: {}, score: 0, ranks: [] }, ]; @@ -244,7 +237,7 @@ describe("hybridQueryExecutionContext", function () { assert.deepStrictEqual(resultRids, expectedSortedRids); }); - it("sortHybridSearchResultByRRFScore method should handle empty HybridSearchQueryResult array", async function () { + it("sortHybridSearchResultByRRFScore method should handle empty HybridSearchQueryResult array", async () => { const input: HybridSearchQueryResult[] = []; const result = context["sortHybridSearchResultByRRFScore"](input); assert.deepStrictEqual(input, result); diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts index bd78c1becbd7..98e87e86e8c9 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts @@ -38,8 +38,8 @@ import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; import { assert, expect } from "vitest"; import { AssertionError } from "node:assert"; -import fs from "fs"; -import path from "path"; +import fs from "node:fs"; +import path from "node:path"; const defaultRoutingGatewayPort: string = ":8081"; const defaultComputeGatewayPort: string = ":8903"; From 2e5d7a74188c11019bae1f7e3bd15378fec13544 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 6 Dec 2024 14:00:00 -0500 Subject: [PATCH 17/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- .../cosmos/src/utils/atob-browser.mts | 48 +----------------- .../cosmos/src/utils/atob-react-native.mts | 50 +++++++++++++++++++ .../cosmos/src/utils/digest-browser.mts | 4 +- ...ative.ts => globalCrypto-react-native.mts} | 4 +- sdk/cosmosdb/cosmos/src/utils/globalCrypto.ts | 10 +--- .../cosmos/src/utils/hmac-browser.mts | 18 +++---- .../cosmos/src/utils/hmac-react-native.mts | 18 +++++++ .../unit/hybridExecutionContext.spec.ts | 4 +- 8 files changed, 87 insertions(+), 69 deletions(-) create mode 100644 sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts rename sdk/cosmosdb/cosmos/src/utils/{globalCrypto.native.ts => globalCrypto-react-native.mts} (72%) create mode 100644 sdk/cosmosdb/cosmos/src/utils/hmac-react-native.mts diff --git a/sdk/cosmosdb/cosmos/src/utils/atob-browser.mts b/sdk/cosmosdb/cosmos/src/utils/atob-browser.mts index 438fd1da11c3..09c88528911e 100644 --- a/sdk/cosmosdb/cosmos/src/utils/atob-browser.mts +++ b/sdk/cosmosdb/cosmos/src/utils/atob-browser.mts @@ -1,50 +1,4 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -let safeatob: any; - -// 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: string): string => { - // 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; +export default globalThis.atob; diff --git a/sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts b/sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts new file mode 100644 index 000000000000..438fd1da11c3 --- /dev/null +++ b/sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +let safeatob: any; + +// 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: string): string => { + // 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; diff --git a/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts b/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts index 5277438c2739..ff8748c54082 100644 --- a/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts +++ b/sdk/cosmosdb/cosmos/src/utils/digest-browser.mts @@ -11,7 +11,7 @@ export async function digest(str: string): Promise { } function bufferToHex(buffer: ArrayBuffer): string { - return Array.prototype.map - .call(new Uint8Array(buffer), (item: number) => ("00" + item.toString(16)).slice(-2)) + return Array.from(new Uint8Array(buffer)) + .map((item) => item.toString(16).padStart(2, "0")) .join(""); } diff --git a/sdk/cosmosdb/cosmos/src/utils/globalCrypto.native.ts b/sdk/cosmosdb/cosmos/src/utils/globalCrypto-react-native.mts similarity index 72% rename from sdk/cosmosdb/cosmos/src/utils/globalCrypto.native.ts rename to sdk/cosmosdb/cosmos/src/utils/globalCrypto-react-native.mts index 0922aa72db12..2ce34802a3b4 100644 --- a/sdk/cosmosdb/cosmos/src/utils/globalCrypto.native.ts +++ b/sdk/cosmosdb/cosmos/src/utils/globalCrypto-react-native.mts @@ -4,5 +4,7 @@ // 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 @typescript-eslint/no-require-imports +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +import globalCrypto from "isomorphic-webcrypto"; export { globalCrypto }; diff --git a/sdk/cosmosdb/cosmos/src/utils/globalCrypto.ts b/sdk/cosmosdb/cosmos/src/utils/globalCrypto.ts index 5eda1f9d94f8..4715cf6bf641 100644 --- a/sdk/cosmosdb/cosmos/src/utils/globalCrypto.ts +++ b/sdk/cosmosdb/cosmos/src/utils/globalCrypto.ts @@ -1,14 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -// eslint-disable-next-line @azure/azure-sdk/ts-no-window -const globalRef: any = typeof self === "undefined" ? window : self; - -if (!globalRef) { - throw new Error("Could not find global"); -} - -const globalCrypto: Crypto = globalRef.crypto || globalRef.msCrypto; +// eslint-disable-next-line n/no-unsupported-features/node-builtins +const globalCrypto: Crypto = globalThis.crypto; if (!globalCrypto || !globalCrypto.subtle) { throw new Error("Browser does not support cryptography functions"); diff --git a/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts b/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts index 9ecc786cfaab..5594fe9f0e52 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts +++ b/sdk/cosmosdb/cosmos/src/utils/hmac-browser.mts @@ -2,19 +2,19 @@ // Licensed under the MIT License. import { encodeUTF8, encodeBase64 } from "./encode.js"; -import atob from "./atob.js"; -import { globalCrypto } from "./globalCrypto.js"; export async function hmac(key: string, message: string): Promise { const importParams: HmacImportParams = { name: "HMAC", hash: { name: "SHA-256" } }; - const encodedMessage = new Uint8Array( - [...unescape(encodeURIComponent(message))].map((c) => c.charCodeAt(0)), + const encodedMessage = new TextEncoder().encode(message); + const encodedKey = encodeUTF8(globalThis.atob(key)); + const cryptoKey = await globalThis.crypto.subtle.importKey( + "raw", + encodedKey, + importParams, + false, + ["sign"], ); - 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); + const signature = await globalThis.crypto.subtle.sign(importParams, cryptoKey, encodedMessage); return encodeBase64(signature); } diff --git a/sdk/cosmosdb/cosmos/src/utils/hmac-react-native.mts b/sdk/cosmosdb/cosmos/src/utils/hmac-react-native.mts new file mode 100644 index 000000000000..c757c2f5772c --- /dev/null +++ b/sdk/cosmosdb/cosmos/src/utils/hmac-react-native.mts @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { encodeUTF8, encodeBase64 } from "./encode.js"; +import atob from "./atob.js"; +import { globalCrypto } from "./globalCrypto.js"; + +export async function hmac(key: string, message: string): Promise { + const importParams: HmacImportParams = { name: "HMAC", hash: { name: "SHA-256" } }; + const encodedMessage = new TextEncoder().encode(message); + 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); +} diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts index 53e5f5d960dd..e9d7a89878e7 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/hybridExecutionContext.spec.ts @@ -81,10 +81,10 @@ describe("hybridQueryExecutionContext", () => { describe("initialize Method", async () => { it("initialize Method should get executed correctly", async () => { - vi.mocked(context["globalStatisticsExecutionContext"].hasMoreResults) + vi.spyOn(context["globalStatisticsExecutionContext"], "hasMoreResults") .mockReturnValueOnce(true) .mockReturnValueOnce(false); - vi.mocked(context["globalStatisticsExecutionContext"].nextItem).mockResolvedValueOnce({ + vi.spyOn(context["globalStatisticsExecutionContext"], "nextItem").mockResolvedValueOnce({ result: { documentCount: 2, fullTextStatistics: [{ totalWordCount: 100, hitCounts: [1, 2, 3] }], From 6b4dfeb5c1ae14c17c96aab22a6fe4f659d57e73 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 6 Dec 2024 14:23:44 -0500 Subject: [PATCH 18/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 3 ++- sdk/cosmosdb/cosmos/package.json | 5 +++-- .../cosmos/src/indexMetrics/IndexUtilizationInfo.ts | 1 + sdk/cosmosdb/cosmos/src/request/RequestHandler.ts | 6 ++++++ sdk/cosmosdb/cosmos/src/request/request.ts | 3 +++ sdk/cosmosdb/cosmos/src/utils/atob.ts | 2 ++ .../cosmos/src/utils/hashing/encoding/number.ts | 1 + .../cosmos/src/utils/hashing/encoding/string.ts | 1 + sdk/cosmosdb/cosmos/src/utils/hashing/murmurHash.ts | 2 ++ sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts | 1 + sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts | 1 + .../cosmos/test/internal/unit/platform.spec.ts | 5 +++-- .../cosmos/test/public/common/TestHelpers.ts | 3 +-- sdk/cosmosdb/cosmos/tsconfig.browser.config.json | 13 +++++++++++-- sdk/cosmosdb/cosmos/vitest.browser.config.ts | 2 +- 15 files changed, 39 insertions(+), 10 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 48a83fd43a93..04b4959e39ac 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -19823,7 +19823,7 @@ packages: dev: false file:projects/cosmos.tgz: - resolution: {integrity: sha512-kjUP3LdwwmEe/PuiN0fZs3x13sZXM25Bpw5K1CNpmFcutdX/IrIggs3fkKVtDpEwBTge/vuSAn3i76n6TfKcPw==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-8d9pUlsrqnMMWz0E4QoFwVxL3sRQMbBuu8Uu6d3FuLydP3R3dBkpy9qrvK66eePFAAa//qQz917Rd2EYjsY6Ig==, tarball: file:projects/cosmos.tgz} name: '@rush-temp/cosmos' version: 0.0.0 dependencies: @@ -19839,6 +19839,7 @@ packages: '@types/underscore': 1.13.0 '@vitest/browser': 2.1.8(@types/node@18.19.67)(playwright@1.49.0)(typescript@5.6.3)(vitest@2.1.8) '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) + buffer: 6.0.3 chai: 4.3.10 dotenv: 16.4.5 eslint: 9.16.0 diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 1cbfa8aed1f9..47d7bfa0d328 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -61,8 +61,8 @@ "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", "test:signoff": "npm run integration-test:node -- --fgrep \"nosignoff\" --invert", "unit-test": "npm run unit-test:node && npm run unit-test:browser", - "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser", - "unit-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' dev-tool run test:vitest", + "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser --no-test-proxy", + "unit-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' dev-tool run test:vitest --no-test-proxy", "update-snippets": "echo skipped" }, "repository": "github:Azure/azure-sdk-for-js", @@ -79,6 +79,7 @@ "@azure/core-rest-pipeline": "^1.18.0", "@azure/core-tracing": "^1.2.0", "@azure/core-util": "^1.11.0", + "buffer": "^6.0.3", "fast-json-stable-stringify": "^2.1.0", "priorityqueuejs": "^2.0.0", "semaphore": "^1.1.0", diff --git a/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts b/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts index a55c9b5d26a2..f319f251e3e1 100644 --- a/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts +++ b/sdk/cosmosdb/cosmos/src/indexMetrics/IndexUtilizationInfo.ts @@ -3,6 +3,7 @@ import type { SingleIndexUtilizationEntity } from "./SingleIndexUtilizationEntity.js"; import type { CompositeIndexUtilizationEntity } from "./CompositeIndexUtilizationEntity.js"; +import { Buffer } from "buffer"; export class IndexUtilizationInfo { public static readonly Empty = new IndexUtilizationInfo([], [], [], []); diff --git a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts index e12e0f30e292..87c276ae66d2 100644 --- a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts +++ b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts @@ -24,7 +24,9 @@ import { getCurrentTimestampInMs } from "../utils/time.js"; const logger: AzureLogger = createClientLogger("RequestHandler"); async function executeRequest( + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters diagnosticNode: DiagnosticNodeInternal, + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters requestContext: RequestContext, ): Promise> { return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request); @@ -34,7 +36,9 @@ async function executeRequest( * @hidden */ async function httpRequest( + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters requestContext: RequestContext, + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters diagnosticNode: DiagnosticNodeInternal, ): Promise<{ headers: any; @@ -176,7 +180,9 @@ async function httpRequest( * @hidden */ async function request( + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters requestContext: RequestContext, + // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters diagnosticNode: DiagnosticNodeInternal, ): Promise> { if (requestContext.body) { diff --git a/sdk/cosmosdb/cosmos/src/request/request.ts b/sdk/cosmosdb/cosmos/src/request/request.ts index 191aae33d6b1..0de128c9d4a8 100644 --- a/sdk/cosmosdb/cosmos/src/request/request.ts +++ b/sdk/cosmosdb/cosmos/src/request/request.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. import { setAuthorizationHeader } from "../auth.js"; + import { Constants, HTTPMethod, @@ -13,6 +14,8 @@ import type { CosmosHeaders } from "../queryExecutionContext/index.js"; import type { FeedOptions, RequestOptions } from "./index.js"; import { defaultLogger } from "../common/logger.js"; import { ChangeFeedMode } from "../client/ChangeFeed/index.js"; +import type { Buffer } from "buffer"; + // ---------------------------------------------------------------------------- // Utility methods // diff --git a/sdk/cosmosdb/cosmos/src/utils/atob.ts b/sdk/cosmosdb/cosmos/src/utils/atob.ts index 73832ff6e5b4..7f3d82d7bf13 100644 --- a/sdk/cosmosdb/cosmos/src/utils/atob.ts +++ b/sdk/cosmosdb/cosmos/src/utils/atob.ts @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +import { Buffer } from "buffer"; + export default function atob(str: string): string { return Buffer.from(str, "base64").toString("binary"); } diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts index c2750dd737ab..fa787aa99f54 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/number.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import { BytePrefix } from "./prefix.js"; +import { Buffer } from "buffer"; export function writeNumberForBinaryEncodingJSBI(hash: number): Buffer { let payload = encodeNumberAsUInt64JSBI(hash); diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts index 181c70ca2a02..ab7f1b9b1c07 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/encoding/string.ts @@ -2,6 +2,7 @@ // Licensed under the MIT License. import { BytePrefix } from "./prefix.js"; +import { Buffer } from "buffer"; export function writeStringForBinaryEncoding(payload: string): Buffer { let outputStream = Buffer.from(BytePrefix.String, "hex"); diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/murmurHash.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/murmurHash.ts index 54a24e3b7835..cc7d103b39fb 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/murmurHash.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/murmurHash.ts @@ -10,6 +10,8 @@ // PRIVATE FUNCTIONS // ----------------- +import { Buffer } from "buffer"; + function _x86Multiply(m: number, n: number) { // // Given two 32bit ints, returns the two multiplied together as a diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts index c07f7affc18b..210488a05feb 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/v1.ts @@ -6,6 +6,7 @@ import { writeStringForBinaryEncoding } from "./encoding/string.js"; import { BytePrefix } from "./encoding/prefix.js"; import MurmurHash from "./murmurHash.js"; import type { PrimitivePartitionKeyValue } from "../../documents/index.js"; +import { Buffer } from "buffer"; const MAX_STRING_CHARS = 100; diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts index c8f73ae821bb..dde0de5c894a 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/v2.ts @@ -5,6 +5,7 @@ import type { PrimitivePartitionKeyValue } from "../../documents/index.js"; import { doubleToByteArrayJSBI } from "./encoding/number.js"; import { BytePrefix } from "./encoding/prefix.js"; import MurmurHash from "./murmurHash.js"; +import { Buffer } from "buffer"; export function hashV2PartitionKey(partitionKey: PrimitivePartitionKeyValue[]): string { const toHash: Buffer = Buffer.concat(partitionKey.map(prefixKeyByType)); diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts index 9063223fec37..ed0c64dee602 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/platform.spec.ts @@ -6,11 +6,12 @@ import { getUserAgent } from "../../../src/common/platform.js"; import { describe, it, assert, expect } from "vitest"; import process from "node:process"; import packageJson from "../../../package.json" assert { type: "json" }; +import { isNodeLike } from "@azure/core-util"; const packageVersion = packageJson["version"]; const constantVersion = Constants.SDKVersion; -describe("getUserAgent", () => { +describe("getUserAgent", { skip: !isNodeLike }, () => { it("should contain the current SDK version", () => { console.log(getUserAgent()); assert(getUserAgent().includes(packageVersion)); @@ -27,7 +28,7 @@ describe("getUserAgent", () => { }); }); -describe("Version", () => { +describe("Version", { skip: !isNodeLike }, () => { it("should have matching constant version & package version", () => { assert.equal( constantVersion, diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts index 98e87e86e8c9..00d656f13b24 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts @@ -80,9 +80,8 @@ export async function removeAllDatabases(client: CosmosClient = defaultClient): ), ); } catch (err: any) { - console.log("An error occured", err); + console.log("An error occurred", err); assert.fail(err); - throw err; } } diff --git a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json index f772e6eb3b76..1e1d9e77bb7a 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json +++ b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json @@ -1,8 +1,17 @@ { "extends": "./.tshy/build.json", - "include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"], - "exclude": ["./test/**/node/**/*.ts"], + "include": [ + "./src/**/*.ts", + "./src/**/*.mts", + "./test/**/*.ts", + "./test/**/*.mts", + "package.json" + ], + "exclude": [ + "./test/**/node/**/*.ts" + ], "compilerOptions": { + "allowJs": true, "outDir": "./dist-test/browser", "rootDir": ".", "skipLibCheck": true diff --git a/sdk/cosmosdb/cosmos/vitest.browser.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.config.ts index 607c63035791..2b79ca094ff8 100644 --- a/sdk/cosmosdb/cosmos/vitest.browser.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.browser.config.ts @@ -2,7 +2,7 @@ // Licensed under the MIT License. import { defineConfig, mergeConfig } from "vitest/config"; -import viteConfig from "../../../vitest.browser.shared.config.ts"; +import viteConfig from "../../../vitest.browser.base.config.ts"; export default mergeConfig( viteConfig, From cf94011af37ec5a48fa48b5256a833b4b66319d3 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 10 Dec 2024 17:41:16 -0500 Subject: [PATCH 19/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 46 ++++++++++++++++++------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 1903043cd1e6..f323ecc7cc02 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -11812,7 +11812,7 @@ packages: dev: false file:projects/agrifood-farming.tgz: - resolution: {integrity: sha512-QO5oynBAKz7qpL0WPKrhzMRp/WpsKLZSSRwPKM+LT/4YC3gbyv69hebqORLGVEBAhkZUnlpLutSb4kjtIT08cQ==, tarball: file:projects/agrifood-farming.tgz} + resolution: {integrity: sha512-HR7zBN9+74lxas2r6nppdjRfRev03CshOxdxcIerWCQEgcIQn/38oqQ+RoRL2zixLCeC1HsHorxEeTTOMUwNGA==, tarball: file:projects/agrifood-farming.tgz} name: '@rush-temp/agrifood-farming' version: 0.0.0 dependencies: @@ -11849,25 +11849,13 @@ packages: typescript: 5.6.3 vitest: 2.1.8(@types/node@18.19.67)(@vitest/browser@2.1.8) transitivePeerDependencies: - - '@edge-runtime/vm' - - '@vitest/ui' + - '@swc/core' + - '@swc/wasm' - bufferutil - - happy-dom + - debug - jiti - - jsdom - - less - - lightningcss - - msw - - safaridriver - - sass - - sass-embedded - - stylus - - sugarss - supports-color - - terser - utf-8-validate - - vite - - webdriverio dev: false file:projects/ai-anomaly-detector.tgz: @@ -20034,7 +20022,7 @@ packages: dev: false file:projects/cosmos.tgz: - resolution: {integrity: sha512-8xMmkXxJCocWUM/b58gByW//I5fGgVoYD3EZpEwsM9J5aa3RhCEpJU8guu6m31frsXFPRwqyQdxmqVDN4QUezw==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-8d9pUlsrqnMMWz0E4QoFwVxL3sRQMbBuu8Uu6d3FuLydP3R3dBkpy9qrvK66eePFAAa//qQz917Rd2EYjsY6Ig==, tarball: file:projects/cosmos.tgz} name: '@rush-temp/cosmos' version: 0.0.0 dependencies: @@ -20048,6 +20036,9 @@ packages: '@types/sinon': 17.0.3 '@types/sinonjs__fake-timers': 8.1.5 '@types/underscore': 1.13.0 + '@vitest/browser': 2.1.8(@types/node@18.19.67)(playwright@1.49.0)(typescript@5.6.3)(vitest@2.1.8) + '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) + buffer: 6.0.3 chai: 4.3.10 dotenv: 16.4.7 eslint: 9.16.0 @@ -20056,6 +20047,7 @@ packages: jsbi: 4.3.0 mocha: 11.0.2 nock: 13.5.6 + playwright: 1.49.0 priorityqueuejs: 2.0.0 requirejs: 2.3.7 semaphore: 1.1.0 @@ -20064,11 +20056,27 @@ packages: ts-node: 10.9.2(@types/node@18.19.67)(typescript@5.6.3) tslib: 2.8.1 typescript: 5.6.3 + vitest: 2.1.8(@types/node@18.19.67)(@vitest/browser@2.1.8) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - utf-8-validate + - vite + - webdriverio dev: false file:projects/create-microsoft-playwright-testing.tgz: From bbb9e097428e458890c5cc90caf200eeb2138dc4 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 10 Dec 2024 17:58:34 -0500 Subject: [PATCH 20/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/package.json | 8 ++------ sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts | 3 ++- sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts | 8 +++----- sdk/cosmosdb/cosmos/vitest.browser.config.ts | 1 + 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 47d7bfa0d328..cbfd88ee6e42 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -40,23 +40,19 @@ "scripts": { "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", "build:samples": "echo Obsolete.", - "build:test": "echo", - "bundle": "dev-tool run bundle", - "bundle-types": "node bundle-types.js", + "build:test": "echo Obsolete.", "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"samples-dev/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", - "check:src:strict": "tsc --pretty --project tsconfig.strict.json", "clean": "dev-tool run vendored rimraf --glob 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 && dev-tool run extract-api", "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"samples-dev/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test:browser": "echo skipped", - "integration-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' mocha -r test/mocha.env.ts -r ts-node/register -r dotenv/config -r ./test/public/common/setup.ts --reporter ../../../common/tools/mocha-multi-reporter.js --reporter-option output=test-results.xml \"./test/internal/**/*.spec.ts\" \"./test/public/**/*.spec.ts\" --timeout 100000", + "integration-test:node": "echo skipped", "lint": "eslint package.json api-extractor.json src test", "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", "pack": "npm pack 2>&1", "test": "npm run unit-test && npm run integration-test", - "test-consumer": "dev-tool run vendored rimraf consumer-test/node_modules consumer-test/package-lock.json && node consumer-test.js 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:signoff": "npm run integration-test:node -- --fgrep \"nosignoff\" --invert", diff --git a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts index c4c5f8a77b79..b5643152b383 100644 --- a/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/internal/unit/client.spec.ts @@ -11,6 +11,7 @@ import { masterKey } from "../../public/common/_fakeTestSecrets.js"; import { endpoint } from "../../public/common/_testConfig.js"; import type { MockInstance } from "vitest"; import { describe, it, assert, vi, beforeEach, afterEach } from "vitest"; +import { isNodeLike } from "@azure/core-util"; class MockCredential implements TokenCredential { constructor(public returnPromise: Promise) {} @@ -66,7 +67,7 @@ const testDataset = { }, }; -describe("Testing Credentials integration for Client", () => { +describe("Testing Credentials integration for Client", { skip: !isNodeLike }, async () => { // endpoint for mock server, which doesn't conflict with emulator's endpoints. const mockedEndpoint = "https://localhost:6969"; const aadToken = "aadToken"; diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts index 00d656f13b24..8a13c76735a9 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts @@ -37,7 +37,7 @@ import type { ExtractPromise } from "../../../src/utils/diagnostics.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; import { assert, expect } from "vitest"; -import { AssertionError } from "node:assert"; +import { AssertionError } from "chai"; import fs from "node:fs"; import path from "node:path"; @@ -265,7 +265,7 @@ function compareObjects(test: any, target: any, message: string): void { const errorMessage = `${message} Properties [${mismatchedProperties.join( ", ", )}] did not match.`; - throw new AssertionError({ message: errorMessage }); + throw new AssertionError(errorMessage); } } @@ -641,9 +641,7 @@ export async function assertThrowsAsync(test: () => Promise, error?: any): } catch (e: any) { if (!error || e instanceof error) return "everything is fine"; } - throw new AssertionError({ - message: "Missing rejection" + (error ? " with " + error.name : ""), - }); + throw new AssertionError("Missing rejection" + (error ? " with " + error.name : "")); } // helper functions for testing change feed allVersionsAndDeletes mode diff --git a/sdk/cosmosdb/cosmos/vitest.browser.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.config.ts index 2b79ca094ff8..d97889ad0f8e 100644 --- a/sdk/cosmosdb/cosmos/vitest.browser.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.browser.config.ts @@ -9,6 +9,7 @@ export default mergeConfig( defineConfig({ test: { include: ["dist-test/browser/test/internal/unit/**/*.spec.js"], + exclude: ["dist-test/browser/test/internal/unit/client.spec.js"], }, }), ); From 1ab6eac022dc81a23ab3912c9b3d53adb4d387cf Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 20 Dec 2024 10:39:50 -0500 Subject: [PATCH 21/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 115 +++++++----------------------- 1 file changed, 27 insertions(+), 88 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 09387f856d63..0d61e9d61a6d 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -918,7 +918,7 @@ importers: version: file:projects/core-xml.tgz(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/cosmos': specifier: file:./projects/cosmos.tgz - version: file:projects/cosmos.tgz + version: file:projects/cosmos.tgz(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/create-microsoft-playwright-testing': specifier: file:./projects/create-microsoft-playwright-testing.tgz version: file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2)) @@ -3591,7 +3591,7 @@ packages: version: 0.0.0 '@rush-temp/confidential-ledger@file:projects/confidential-ledger.tgz': - resolution: {integrity: sha512-Gh04SARYLYKqfJcMhnzqQ4aoQcWNw+tokGGhULmwQhutUaYCVjx69T3fzYTkEeXjWx/289eFK3zBD8TMA3p7+g==, tarball: file:projects/confidential-ledger.tgz} + resolution: {integrity: sha512-SJzc0t6IU+ncIo/2rsSt6PQzH5KpCAMYcFLxYBb4OripIcE4U5gKmotJfB7koFj1/r0T/9eZqpeD+1OTT0dJQQ==, tarball: file:projects/confidential-ledger.tgz} version: 0.0.0 '@rush-temp/container-registry@file:projects/container-registry.tgz': @@ -3647,7 +3647,7 @@ packages: version: 0.0.0 '@rush-temp/cosmos@file:projects/cosmos.tgz': - resolution: {integrity: sha512-v9YVLjFKbVmx5EWiE7LsPWU04QvgDtvIkB2cGhQhm+sbNsCmXtdvkuRLCU7KqB/fWUMjAmnE14leCv/9cKYr8Q==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-8d9pUlsrqnMMWz0E4QoFwVxL3sRQMbBuu8Uu6d3FuLydP3R3dBkpy9qrvK66eePFAAa//qQz917Rd2EYjsY6Ig==, tarball: file:projects/cosmos.tgz} version: 0.0.0 '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz': @@ -4365,9 +4365,6 @@ packages: '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} - '@types/underscore@1.13.0': - resolution: {integrity: sha512-L6LBgy1f0EFQZ+7uSA57+n2g/s4Qs5r06Vwrwn0/nuK1de+adz00NWaztRQ30aEqw5qOaWbPI8u2cGQ52lj6VA==} - '@types/unist@2.0.11': resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} @@ -4840,10 +4837,6 @@ packages: peerDependencies: chai: '>= 5' - chai@4.3.10: - resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==} - engines: {node: '>=4'} - chai@4.5.0: resolution: {integrity: sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==} engines: {node: '>=4'} @@ -5500,10 +5493,6 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} - execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} - execa@6.1.0: resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -5861,10 +5850,6 @@ packages: resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} engines: {node: '>= 14'} - human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - human-signals@3.0.1: resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} engines: {node: '>=12.20.0'} @@ -6135,9 +6120,6 @@ packages: js2xmlparser@4.0.2: resolution: {integrity: sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==} - jsbi@4.3.0: - resolution: {integrity: sha512-SnZNcinB4RIcnEyZqFPdGPVgrg2AcnykiBy0sHVJQKHYeaLUvi3Exj+iaPpLnFVkDPZIV4U0yvgC9/R4uEAZ9g==} - jsbn@1.1.0: resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==} @@ -6718,10 +6700,6 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} - npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} - npm-run-path@5.3.0: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -7184,11 +7162,6 @@ packages: require-main-filename@2.0.0: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} - requirejs@2.3.7: - resolution: {integrity: sha512-DouTG8T1WanGok6Qjg2SXuCMzszOo0eHeH9hDZ5Y4x8Je+9JB38HdTLT4/VA8OaUhBa0JPVHJ0pyBkM1z+pDsw==} - engines: {node: '>=0.4.0'} - hasBin: true - requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} @@ -7533,10 +7506,6 @@ packages: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} - strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} @@ -16641,39 +16610,45 @@ snapshots: - vite - webdriverio - '@rush-temp/cosmos@file:projects/cosmos.tgz': + '@rush-temp/cosmos@file:projects/cosmos.tgz(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9))': dependencies: - '@sinonjs/fake-timers': 11.3.1 - '@types/chai': 4.3.20 '@types/debug': 4.1.12 - '@types/mocha': 10.0.10 '@types/node': 18.19.68 '@types/priorityqueuejs': 1.0.4 '@types/semaphore': 1.1.4 - '@types/sinon': 17.0.3 - '@types/sinonjs__fake-timers': 8.1.5 - '@types/underscore': 1.13.0 - chai: 4.3.10 + '@vitest/browser': 2.1.8(@types/node@18.19.68)(playwright@1.49.1)(typescript@5.6.3)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) + '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) + buffer: 6.0.3 dotenv: 16.4.7 eslint: 9.17.0 - execa: 5.1.1 fast-json-stable-stringify: 2.1.0 - jsbi: 4.3.0 - mocha: 11.0.2 nock: 13.5.6 + playwright: 1.49.1 priorityqueuejs: 2.0.0 - requirejs: 2.3.7 semaphore: 1.1.0 - sinon: 17.0.1 - source-map-support: 0.5.21 - ts-node: 10.9.2(@types/node@18.19.68)(typescript@5.7.2) tslib: 2.8.1 - typescript: 5.7.2 + typescript: 5.6.3 + vitest: 2.1.8(@types/node@18.19.68)(@vitest/browser@2.1.8)(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2)) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - utf-8-validate + - vite + - webdriverio '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.6.8(@types/node@22.7.9)(typescript@5.7.2))': dependencies: @@ -20227,8 +20202,6 @@ snapshots: '@types/trusted-types@2.0.7': {} - '@types/underscore@1.13.0': {} - '@types/unist@2.0.11': {} '@types/unzipper@0.10.10': @@ -20887,16 +20860,6 @@ snapshots: chai: 5.1.2 fclone: 1.0.11 - chai@4.3.10: - dependencies: - assertion-error: 1.1.0 - check-error: 1.0.3 - deep-eql: 4.1.4 - get-func-name: 2.0.2 - loupe: 2.3.7 - pathval: 1.1.1 - type-detect: 4.1.0 - chai@4.5.0: dependencies: assertion-error: 1.1.0 @@ -21621,18 +21584,6 @@ snapshots: events@3.3.0: {} - execa@5.1.1: - dependencies: - cross-spawn: 7.0.6 - get-stream: 6.0.1 - human-signals: 2.1.0 - is-stream: 2.0.1 - merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 - execa@6.1.0: dependencies: cross-spawn: 7.0.6 @@ -22050,8 +22001,6 @@ snapshots: transitivePeerDependencies: - supports-color - human-signals@2.1.0: {} - human-signals@3.0.1: {} humanize-ms@1.2.1: @@ -22308,8 +22257,6 @@ snapshots: dependencies: xmlcreate: 2.0.4 - jsbi@4.3.0: {} - jsbn@1.1.0: {} jsdoc@4.0.4: @@ -23049,10 +22996,6 @@ snapshots: normalize-path@3.0.0: {} - npm-run-path@4.0.1: - dependencies: - path-key: 3.1.1 - npm-run-path@5.3.0: dependencies: path-key: 4.0.0 @@ -23594,8 +23537,6 @@ snapshots: require-main-filename@2.0.0: {} - requirejs@2.3.7: {} - requires-port@1.0.0: {} requizzle@0.2.4: @@ -24008,8 +23949,6 @@ snapshots: strip-bom@4.0.0: {} - strip-final-newline@2.0.0: {} - strip-final-newline@3.0.0: {} strip-indent@4.0.0: From 1126b4c5d44307513bcbdca900b8eed2274ef398 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 20 Dec 2024 19:19:08 -0500 Subject: [PATCH 22/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/eslint.config.mjs | 1 + sdk/cosmosdb/cosmos/package.json | 2 +- sdk/cosmosdb/cosmos/review/cosmos.api.md | 22 +- .../cosmos/src/utils/atob-react-native.mts | 2 +- sdk/cosmosdb/cosmos/src/utils/atob.ts | 2 +- .../cosmos/tsconfig.browser.config.json | 4 +- sdk/cosmosdb/cosmos/tsconfig.json | 39 +-- sdk/cosmosdb/cosmos/tsconfig.samples.json | 10 + sdk/cosmosdb/cosmos/tsconfig.src.json | 15 ++ sdk/cosmosdb/cosmos/tsconfig.strict.json | 239 ------------------ sdk/cosmosdb/cosmos/tsconfig.test.json | 3 + sdk/cosmosdb/cosmos/vitest.esm.config.ts | 11 + 12 files changed, 66 insertions(+), 284 deletions(-) create mode 100644 sdk/cosmosdb/cosmos/tsconfig.samples.json create mode 100644 sdk/cosmosdb/cosmos/tsconfig.src.json delete mode 100644 sdk/cosmosdb/cosmos/tsconfig.strict.json create mode 100644 sdk/cosmosdb/cosmos/tsconfig.test.json create mode 100644 sdk/cosmosdb/cosmos/vitest.esm.config.ts diff --git a/sdk/cosmosdb/cosmos/eslint.config.mjs b/sdk/cosmosdb/cosmos/eslint.config.mjs index 441f491bbaa7..17a3a625ee56 100644 --- a/sdk/cosmosdb/cosmos/eslint.config.mjs +++ b/sdk/cosmosdb/cosmos/eslint.config.mjs @@ -27,6 +27,7 @@ export default azsdkEslint.config([ // left to the cosmos team make this rule error again "@azure/azure-sdk/ts-package-json-module": "warn", "@azure/azure-sdk/ts-doc-internal": "warn", + "@azure/azure-sdk/ts-use-interface-parameters": "off", }, }, { diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index cbfd88ee6e42..8a1a2be0f1b5 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -55,7 +55,6 @@ "test": "npm run unit-test && npm run integration-test", "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:signoff": "npm run integration-test:node -- --fgrep \"nosignoff\" --invert", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser --no-test-proxy", "unit-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' dev-tool run test:vitest --no-test-proxy", @@ -138,6 +137,7 @@ }, "type": "module", "tshy": { + "project": "./tsconfig.src.json", "exports": { "./package.json": "./package.json", ".": "./src/index.ts" diff --git a/sdk/cosmosdb/cosmos/review/cosmos.api.md b/sdk/cosmosdb/cosmos/review/cosmos.api.md index 454f36a290fc..326481edd00c 100644 --- a/sdk/cosmosdb/cosmos/review/cosmos.api.md +++ b/sdk/cosmosdb/cosmos/review/cosmos.api.md @@ -813,8 +813,8 @@ export class DatabaseAccount { // @deprecated get MediaLink(): string; readonly mediaLink: string; - readonly readableLocations: Location[]; - readonly writableLocations: Location[]; + readonly readableLocations: Location_2[]; + readonly writableLocations: Location_2[]; } // @public (undocumented) @@ -1305,7 +1305,7 @@ export interface JSONObject { export type JSONValue = boolean | number | string | null | JSONArray | JSONObject; // @public -export interface Location { +interface Location_2 { // (undocumented) databaseAccountEndpoint: string; // (undocumented) @@ -1315,6 +1315,7 @@ export interface Location { // (undocumented) unavailable?: boolean; } +export { Location_2 as Location } // @public export interface MetadataLookUpDiagnostic { @@ -1634,7 +1635,7 @@ export class PermissionResponse extends ResourceResponse; query(query: SqlQuerySpec, options?: FeedOptions): QueryIterator; @@ -1644,14 +1645,16 @@ export class Permissions { // (undocumented) readonly user: User; } +export { Permissions_2 as Permissions } // @public -export type Plugin = (context: RequestContext, diagnosticNode: DiagnosticNodeInternal, next: Next) => Promise>; +type Plugin_2 = (context: RequestContext, diagnosticNode: DiagnosticNodeInternal, next: Next) => Promise>; +export { Plugin_2 as Plugin } // @public export interface PluginConfig { on: keyof typeof PluginOn; - plugin: Plugin; + plugin: Plugin_2; } // @public @@ -1911,7 +1914,7 @@ export interface RequestContext { } // @public (undocumented) -export interface RequestInfo { +interface RequestInfo_2 { // (undocumented) headers: CosmosHeaders; // (undocumented) @@ -1923,6 +1926,7 @@ export interface RequestInfo { // (undocumented) verb: HTTPMethod; } +export { RequestInfo_2 as RequestInfo } // @public export interface RequestOptions extends SharedOptions { @@ -2403,7 +2407,7 @@ export class TimeSpan { } // @public (undocumented) -export type TokenProvider = (requestInfo: RequestInfo) => Promise; +export type TokenProvider = (requestInfo: RequestInfo_2) => Promise; // @public export class Trigger { @@ -2498,7 +2502,7 @@ export class User { // (undocumented) readonly id: string; permission(id: string): Permission; - readonly permissions: Permissions; + readonly permissions: Permissions_2; read(options?: RequestOptions): Promise; replace(body: UserDefinition, options?: RequestOptions): Promise; get url(): string; diff --git a/sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts b/sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts index 438fd1da11c3..5fd3a773f175 100644 --- a/sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts +++ b/sdk/cosmosdb/cosmos/src/utils/atob-react-native.mts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -let safeatob: any; +let safeatob: (data: string) => string; // base64 character set, plus padding character (=) const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; diff --git a/sdk/cosmosdb/cosmos/src/utils/atob.ts b/sdk/cosmosdb/cosmos/src/utils/atob.ts index 7f3d82d7bf13..bd086a17a97f 100644 --- a/sdk/cosmosdb/cosmos/src/utils/atob.ts +++ b/sdk/cosmosdb/cosmos/src/utils/atob.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { Buffer } from "buffer"; +import { Buffer } from "node:buffer"; export default function atob(str: string): string { return Buffer.from(str, "base64").toString("binary"); diff --git a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json index 1e1d9e77bb7a..c24ed56d14c5 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json +++ b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json @@ -7,9 +7,7 @@ "./test/**/*.mts", "package.json" ], - "exclude": [ - "./test/**/node/**/*.ts" - ], + "exclude": ["./test/**/node/**/*.ts"], "compilerOptions": { "allowJs": true, "outDir": "./dist-test/browser", diff --git a/sdk/cosmosdb/cosmos/tsconfig.json b/sdk/cosmosdb/cosmos/tsconfig.json index 4baddcbc491e..19ceb382b521 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.json +++ b/sdk/cosmosdb/cosmos/tsconfig.json @@ -1,34 +1,13 @@ { - "extends": "../../../tsconfig", - "compilerOptions": { - "outDir": "dist-esm", - "module": "NodeNext", - "strict": false, - "noImplicitAny": true, - "noImplicitReturns": false, - "noFallthroughCasesInSwitch": false, - "preserveConstEnums": true, - "removeComments": false, - "target": "ES2017", - "newLine": "LF", - "resolveJsonModule": true, - "lib": ["es2019"], - "moduleResolution": "NodeNext", - "composite": true, - "stripInternal": true, - "paths": { - "@azure/cosmos": ["./src/index"] + "references": [ + { + "path": "./tsconfig.src.json" }, - "rootDir": "." - }, - "include": [ - "src/**/*.ts", - "src/**/*.mts", - "src/**/*.cts", - "samples-dev/**/*.ts", - "test/**/*.ts", - "test/**/*.mts", - "test/**/*.cts", - "package.json" + { + "path": "./tsconfig.samples.json" + }, + { + "path": "./tsconfig.test.json" + } ] } diff --git a/sdk/cosmosdb/cosmos/tsconfig.samples.json b/sdk/cosmosdb/cosmos/tsconfig.samples.json new file mode 100644 index 000000000000..a7c0ce1573c9 --- /dev/null +++ b/sdk/cosmosdb/cosmos/tsconfig.samples.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.samples.base.json", + "compilerOptions": { + "paths": { + "@azure/cosmos": [ + "./dist/esm" + ] + } + } +} diff --git a/sdk/cosmosdb/cosmos/tsconfig.src.json b/sdk/cosmosdb/cosmos/tsconfig.src.json new file mode 100644 index 000000000000..af5edce5995c --- /dev/null +++ b/sdk/cosmosdb/cosmos/tsconfig.src.json @@ -0,0 +1,15 @@ +{ + "extends": "../../../tsconfig.lib.json", + "compilerOptions": { + "composite": true, + "stripInternal": true, + "preserveConstEnums": true, + "removeComments": false, + "strict": false, + "noImplicitAny": true, + "noImplicitReturns": false, + "noFallthroughCasesInSwitch": false, + "newLine": "LF", + "resolveJsonModule": true + } +} diff --git a/sdk/cosmosdb/cosmos/tsconfig.strict.json b/sdk/cosmosdb/cosmos/tsconfig.strict.json deleted file mode 100644 index 2f36c9c1d9dd..000000000000 --- a/sdk/cosmosdb/cosmos/tsconfig.strict.json +++ /dev/null @@ -1,239 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "composite": false, - "noEmit": true, - // THIS HAS TO ALWAYS BE ENABLED - "strict": true - }, - "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.(ts|json)"], - // ADDITION TO THIS LIST IS NOT ALLOWED - "exclude": [ - "src/documents/DatabaseAccount.ts", - "src/documents/IndexingPolicy.ts", - "src/plugins/Plugin.ts", - "src/common/helper.ts", - "src/common/uriFactory.ts", - "src/client/Conflict/Conflict.ts", - "src/client/Conflict/ConflictDefinition.ts", - "src/client/Conflict/ConflictResponse.ts", - "src/client/Conflict/Conflicts.ts", - "src/client/Container/Container.ts", - "src/client/Container/ContainerDefinition.ts", - "src/client/Container/ContainerRequest.ts", - "src/client/Container/ContainerResponse.ts", - "src/client/Container/Containers.ts", - "src/client/Database/Database.ts", - "src/client/Database/DatabaseResponse.ts", - "src/client/Database/Databases.ts", - "src/client/Item/Item.ts", - "src/client/Item/ItemResponse.ts", - "src/client/Item/Items.ts", - "src/client/Offer/Offer.ts", - "src/client/Offer/OfferResponse.ts", - "src/client/Offer/Offers.ts", - "src/client/Permission/Permission.ts", - "src/client/Permission/PermissionDefinition.ts", - "src/client/Permission/PermissionResponse.ts", - "src/client/Permission/Permissions.ts", - "src/client/Script/Scripts.ts", - "src/client/StoredProcedure/StoredProcedure.ts", - "src/client/StoredProcedure/StoredProcedureResponse.ts", - "src/client/StoredProcedure/StoredProcedures.ts", - "src/client/Trigger/Trigger.ts", - "src/client/Trigger/TriggerDefinition.ts", - "src/client/Trigger/TriggerResponse.ts", - "src/client/Trigger/Triggers.ts", - "src/client/User/User.ts", - "src/client/User/UserResponse.ts", - "src/client/User/Users.ts", - "src/client/UserDefinedFunction/UserDefinedFunction.ts", - "src/client/UserDefinedFunction/UserDefinedFunctionResponse.ts", - "src/client/UserDefinedFunction/UserDefinedFunctions.ts", - "src/diagnostics/CosmosDiagnosticsContext.ts", - "src/diagnostics/DiagnosticFormatter.ts", - "src/diagnostics/DiagnosticNodeInternal.ts", - "src/diagnostics/DiagnosticWriter.ts", - "src/diagnostics/index.ts", - "src/diagnostics/diagnosticLevelComparator.ts", - "src/diagnostics/CosmosDbDiagnosticLevel.ts", - "src/queryExecutionContext/Aggregators/AverageAggregator.ts", - "src/queryExecutionContext/Aggregators/MaxAggregator.ts", - "src/queryExecutionContext/Aggregators/MinAggregator.ts", - "src/queryExecutionContext/Aggregators/SumAggregator.ts", - "src/queryExecutionContext/EndpointComponent/GroupByEndpointComponent.ts", - "src/queryExecutionContext/EndpointComponent/GroupByValueEndpointComponent.ts", - "src/queryExecutionContext/EndpointComponent/OffsetLimitEndpointComponent.ts", - "src/queryExecutionContext/EndpointComponent/OrderByEndpointComponent.ts", - "src/queryExecutionContext/EndpointComponent/OrderedDistinctEndpointComponent.ts", - "src/queryExecutionContext/EndpointComponent/UnorderedDistinctEndpointComponent.ts", - "src/queryExecutionContext/defaultQueryExecutionContext.ts", - "src/queryExecutionContext/documentProducer.ts", - "src/queryExecutionContext/ExecutionContext.ts", - "src/queryExecutionContext/headerUtils.ts", - "src/queryExecutionContext/orderByDocumentProducerComparator.ts", - "src/queryExecutionContext/orderByQueryExecutionContext.ts", - "src/queryExecutionContext/parallelQueryExecutionContext.ts", - "src/queryExecutionContext/parallelQueryExecutionContextBase.ts", - "src/queryExecutionContext/pipelinedQueryExecutionContext.ts", - "src/CosmosDiagnostics.ts", - "src/request/ErrorResponse.ts", - "src/request/FeedOptions.ts", - "src/request/FeedResponse.ts", - "src/request/request.ts", - "src/request/RequestContext.ts", - "src/request/RequestHandler.ts", - "src/request/RequestOptions.ts", - "src/request/ResourceResponse.ts", - "src/request/Response.ts", - "src/request/SharedOptions.ts", - "src/retry/defaultRetryPolicy.ts", - "src/retry/endpointDiscoveryRetryPolicy.ts", - "src/retry/resourceThrottleRetryPolicy.ts", - "src/retry/RetryPolicy.ts", - "src/retry/retryUtility.ts", - "src/retry/sessionRetryPolicy.ts", - "src/retry/timeoutFailoverRetryPolicy.ts", - "src/retry/RetryContext.ts", - "src/routing/CollectionRoutingMapFactory.ts", - "src/routing/inMemoryCollectionRoutingMap.ts", - "src/routing/partitionKeyRangeCache.ts", - "src/routing/QueryRange.ts", - "src/routing/smartRoutingMapProvider.ts", - "src/session/sessionContainer.ts", - "src/session/SessionContext.ts", - "src/utils/batch.ts", - "src/utils/diagnostics.ts", - "src/utils/headers.ts", - "src/utils/offers.ts", - "src/utils/strings.ts", - "src/utils/typeChecks.ts", - "src/utils/nonStreamingOrderByMap.ts", - "src/auth.ts", - "src/ChangeFeedIterator.ts", - "src/ChangeFeedResponse.ts", - "src/ClientContext.ts", - "src/CosmosClient.ts", - "src/CosmosClientOptions.ts", - "src/extractPartitionKey.ts", - "src/globalEndpointManager.ts", - "src/queryIterator.ts", - "src/client/ChangeFeed/*.ts", - "src/client/User/index.ts", - "src/client/Item/index.ts", - "src/client/StoredProcedure/index.ts", - "src/client/Trigger/index.ts", - "src/client/Offer/index.ts", - "src/client/Permission/index.ts", - "src/client/index.ts", - "src/client/UserDefinedFunction/index.ts", - "src/client/Conflict/index.ts", - "src/client/Container/index.ts", - "src/client/Database/index.ts", - "src/client/ClientUtils.ts", - "src/documents/index.ts", - "src/request/index.ts", - "src/index.ts", - "src/retry/index.ts", - "src/queryExecutionContext/Aggregators/index.ts", - "src/queryExecutionContext/index.ts", - "src/common/index.ts", - "src/routing/index.ts", - "src/utils/SasToken.ts", - "src/utils/tracing.ts", - "src/utils/hashing", - "src/client/SasToken/SasTokenProperties.ts", - "src/client/SasToken/PermissionScopeValues.ts", - "src/documents/VectorEmbeddingPolicy.ts", - "src/queryExecutionContext/EndpointComponent/NonStreamingOrderByDistinctEndpointComponent.ts", - "src/queryExecutionContext/EndpointComponent/NonStreamingOrderByEndpointComponent.ts", - "src/queryExecutionContext/nonStreamingOrderByResponse.ts", - "src/queryExecutionContext/nonStreamingOrderByResult.ts", - "src/queryExecutionContext/orderByComparator.ts", - "src/utils/fixedSizePriorityQueue.ts", - "src/utils/supportedQueryFeaturesBuilder.ts", - "src/documents/FullTextPolicy.ts", - "src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts", - "src/queryExecutionContext/hybridQueryExecutionContext.ts", - "src/request/globalStatistics.ts", - "src/request/hybridSearchQueryResult.ts", - "test/public/common/TestHelpers.ts", - "test/internal/session.spec.ts", - "test/internal/unit/auth.spec.ts", - "test/internal/unit/defaultQueryExecutionContext.spec.ts", - "test/internal/unit/helper.spec.ts", - "test/internal/unit/inMemoryCollectionRoutingMap.spec.ts", - "test/internal/unit/platform.spec.ts", - "test/internal/unit/sasToken.spec.ts", - "test/internal/unit/hybridExecutionContext.spec.ts", - "test/internal/unit/sessionContainer.spec.ts", - "test/internal/unit/changeFeed/*.spec.ts", - "test/public/common/MockQueryIterator.ts", - "test/public/common/MockClientContext.ts", - "test/internal/unit/smartRoutingMapProvider.spec.ts", - "test/internal/unit/diagnostics.spec.ts", - "test/internal/unit/hashing/v1.spec.ts", - "test/internal/unit/hashing/v2.spec.ts", - "test/internal/unit/utils/batch.spec.ts", - "test/internal/unit/utils/checkURL.spec.ts", - "test/internal/unit/utils/offer.spec.ts", - "test/internal/unit/client.spec.ts", - "test/internal/unit/timeoutFailoverRetryPolicy.spec.ts", - "test/internal/unit/nonStreamingOrderByMap.spec.ts", - "test/internal/unit/utils/supportedQueryFeaturesBuilder.spec.ts", - "test/internal/unit/getHeader.spec.ts", - "test/public/common/BaselineTest.PathParser.ts", - "test/public/common/TestData.ts", - "test/public/common/setup.ts", - "test/public/functional/authorization.spec.ts", - "test/public/functional/client.spec.ts", - "test/public/functional/conflict.spec.ts", - "test/public/functional/container.spec.ts", - "test/public/functional/database.spec.ts", - "test/public/functional/databaseaccount.spec.ts", - "test/public/functional/globalEndpointManager.spec.ts", - "test/public/functional/item/item.spec.ts", - "test/public/functional/item/bulk.item.spec.ts", - "test/public/functional/item/batch.item.spec.ts", - "test/public/functional/item/itemIdEncoding.spec.ts", - "test/public/functional/endpointComponent/NonStreamingOrderByEndpointComponent.spec.ts", - "test/public/functional/endpointComponent/NonStreamingOrderByDistinctEndpointComponent.spec.ts", - "test/public/functional/npcontainer.spec.ts", - "test/public/functional/offer.spec.ts", - "test/public/functional/permission.spec.ts", - "test/public/functional/plugin.spec.ts", - "test/public/functional/query.spec.ts", - "test/public/functional/spatial.spec.ts", - "test/public/functional/sproc.spec.ts", - "test/public/functional/trigger.spec.ts", - "test/public/functional/ttl.spec.ts", - "test/public/functional/udf.spec.ts", - "test/public/functional/user.spec.ts", - "test/public/functional/queryIterator.spec.ts", - "test/public/integration/aggregateQuery.spec.ts", - "test/public/integration/authorization.spec.ts", - "test/public/integration/changeFeed.spec.ts", - "test/public/integration/changeFeedIterator.spec.ts", - "test/public/integration/crossPartition.spec.ts", - "test/public/integration/encoding.spec.ts", - "test/public/integration/extractPartitionKey.spec.ts", - "test/public/integration/failover.spec.ts", - "test/public/integration/multiregion.spec.ts", - "test/public/integration/proxy.spec.ts", - "test/public/integration/query.spec.ts", - "test/public/integration/queryMetrics.spec.ts", - "test/public/integration/retry.spec.ts", - "test/public/integration/split.spec.ts", - "test/public/integration/sslVerification.spec.ts", - "test/public/integration/timeout.spec.ts", - "test/public/integration/aggregates/groupBy.spec.ts", - "test/public/integration/nonStreamingOrderBy/nonStreamingOrderBy.spec.ts", - "test/public/integration/nonStreamingOrderBy/nonStreamingDistinctOrderBy.spec.ts", - "test/public/integration/client.retry.spec.ts", - "test/public/integration/fullTextSearch.spec.ts", - "test/public/functional/NonStreamingQueryPolicy.spec.ts", - "test/public/functional/computedProperties.spec.ts", - "test/internal/unit/utils/nonStreamingOrderByPriorityQueue.spec.ts", - "test/internal/unit/globalStatisticsAggregator.spec.ts" - ] -} diff --git a/sdk/cosmosdb/cosmos/tsconfig.test.json b/sdk/cosmosdb/cosmos/tsconfig.test.json new file mode 100644 index 000000000000..290ca214aebc --- /dev/null +++ b/sdk/cosmosdb/cosmos/tsconfig.test.json @@ -0,0 +1,3 @@ +{ + "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] +} diff --git a/sdk/cosmosdb/cosmos/vitest.esm.config.ts b/sdk/cosmosdb/cosmos/vitest.esm.config.ts new file mode 100644 index 000000000000..2f6e757a54f7 --- /dev/null +++ b/sdk/cosmosdb/cosmos/vitest.esm.config.ts @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig( + vitestConfig, + vitestEsmConfig +); From a5511e308f24de38d74405fc64aa317ad07fea94 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 30 Dec 2024 15:29:27 -0500 Subject: [PATCH 23/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 113 +++++++----------------------- 1 file changed, 26 insertions(+), 87 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index eb3c3216bc0f..760c7c902cc2 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -918,7 +918,7 @@ importers: version: file:projects/core-xml.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/cosmos': specifier: file:./projects/cosmos.tgz - version: file:projects/cosmos.tgz + version: file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/create-microsoft-playwright-testing': specifier: file:./projects/create-microsoft-playwright-testing.tgz version: file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) @@ -3671,7 +3671,7 @@ packages: version: 0.0.0 '@rush-temp/cosmos@file:projects/cosmos.tgz': - resolution: {integrity: sha512-v9YVLjFKbVmx5EWiE7LsPWU04QvgDtvIkB2cGhQhm+sbNsCmXtdvkuRLCU7KqB/fWUMjAmnE14leCv/9cKYr8Q==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-8d9pUlsrqnMMWz0E4QoFwVxL3sRQMbBuu8Uu6d3FuLydP3R3dBkpy9qrvK66eePFAAa//qQz917Rd2EYjsY6Ig==, tarball: file:projects/cosmos.tgz} version: 0.0.0 '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz': @@ -4389,9 +4389,6 @@ packages: '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} - '@types/underscore@1.13.0': - resolution: {integrity: sha512-L6LBgy1f0EFQZ+7uSA57+n2g/s4Qs5r06Vwrwn0/nuK1de+adz00NWaztRQ30aEqw5qOaWbPI8u2cGQ52lj6VA==} - '@types/unist@2.0.11': resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} @@ -4864,10 +4861,6 @@ packages: peerDependencies: chai: '>= 5' - chai@4.3.10: - resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==} - engines: {node: '>=4'} - chai@4.5.0: resolution: {integrity: sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==} engines: {node: '>=4'} @@ -5524,10 +5517,6 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} - execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} - execa@6.1.0: resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -5885,10 +5874,6 @@ packages: resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} engines: {node: '>= 14'} - human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - human-signals@3.0.1: resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} engines: {node: '>=12.20.0'} @@ -6163,9 +6148,6 @@ packages: js2xmlparser@4.0.2: resolution: {integrity: sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==} - jsbi@4.3.0: - resolution: {integrity: sha512-SnZNcinB4RIcnEyZqFPdGPVgrg2AcnykiBy0sHVJQKHYeaLUvi3Exj+iaPpLnFVkDPZIV4U0yvgC9/R4uEAZ9g==} - jsbn@1.1.0: resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==} @@ -6746,10 +6728,6 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} - npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} - npm-run-path@5.3.0: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -7212,11 +7190,6 @@ packages: require-main-filename@2.0.0: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} - requirejs@2.3.7: - resolution: {integrity: sha512-DouTG8T1WanGok6Qjg2SXuCMzszOo0eHeH9hDZ5Y4x8Je+9JB38HdTLT4/VA8OaUhBa0JPVHJ0pyBkM1z+pDsw==} - engines: {node: '>=0.4.0'} - hasBin: true - requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} @@ -7569,10 +7542,6 @@ packages: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} - strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} @@ -16716,39 +16685,45 @@ snapshots: - vite - webdriverio - '@rush-temp/cosmos@file:projects/cosmos.tgz': + '@rush-temp/cosmos@file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9))': dependencies: - '@sinonjs/fake-timers': 11.3.1 - '@types/chai': 4.3.20 '@types/debug': 4.1.12 - '@types/mocha': 10.0.10 '@types/node': 18.19.68 '@types/priorityqueuejs': 1.0.4 '@types/semaphore': 1.1.4 - '@types/sinon': 17.0.3 - '@types/sinonjs__fake-timers': 8.1.5 - '@types/underscore': 1.13.0 - chai: 4.3.10 + '@vitest/browser': 2.1.8(@types/node@18.19.68)(playwright@1.49.1)(typescript@5.6.3)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) + '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) + buffer: 6.0.3 dotenv: 16.4.7 eslint: 9.17.0 - execa: 5.1.1 fast-json-stable-stringify: 2.1.0 - jsbi: 4.3.0 - mocha: 11.0.2 nock: 13.5.6 + playwright: 1.49.1 priorityqueuejs: 2.0.0 - requirejs: 2.3.7 semaphore: 1.1.0 - sinon: 17.0.1 - source-map-support: 0.5.21 - ts-node: 10.9.2(@types/node@18.19.68)(typescript@5.7.2) tslib: 2.8.1 - typescript: 5.7.2 + typescript: 5.6.3 + vitest: 2.1.8(@types/node@18.19.68)(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - utf-8-validate + - vite + - webdriverio '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))': dependencies: @@ -20303,8 +20278,6 @@ snapshots: '@types/trusted-types@2.0.7': {} - '@types/underscore@1.13.0': {} - '@types/unist@2.0.11': {} '@types/unzipper@0.10.10': @@ -20963,16 +20936,6 @@ snapshots: chai: 5.1.2 fclone: 1.0.11 - chai@4.3.10: - dependencies: - assertion-error: 1.1.0 - check-error: 1.0.3 - deep-eql: 4.1.4 - get-func-name: 2.0.2 - loupe: 2.3.7 - pathval: 1.1.1 - type-detect: 4.1.0 - chai@4.5.0: dependencies: assertion-error: 1.1.0 @@ -21699,18 +21662,6 @@ snapshots: events@3.3.0: {} - execa@5.1.1: - dependencies: - cross-spawn: 7.0.6 - get-stream: 6.0.1 - human-signals: 2.1.0 - is-stream: 2.0.1 - merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 - execa@6.1.0: dependencies: cross-spawn: 7.0.6 @@ -22128,8 +22079,6 @@ snapshots: transitivePeerDependencies: - supports-color - human-signals@2.1.0: {} - human-signals@3.0.1: {} humanize-ms@1.2.1: @@ -22393,8 +22342,6 @@ snapshots: dependencies: xmlcreate: 2.0.4 - jsbi@4.3.0: {} - jsbn@1.1.0: {} jsdoc@4.0.4: @@ -23134,10 +23081,6 @@ snapshots: normalize-path@3.0.0: {} - npm-run-path@4.0.1: - dependencies: - path-key: 3.1.1 - npm-run-path@5.3.0: dependencies: path-key: 4.0.0 @@ -23679,8 +23622,6 @@ snapshots: require-main-filename@2.0.0: {} - requirejs@2.3.7: {} - requires-port@1.0.0: {} requizzle@0.2.4: @@ -24099,8 +24040,6 @@ snapshots: strip-bom@4.0.0: {} - strip-final-newline@2.0.0: {} - strip-final-newline@3.0.0: {} strip-indent@4.0.0: From a621f25b9a0e9c16c8d55722296e044fc7a4dade Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 30 Dec 2024 16:12:32 -0500 Subject: [PATCH 24/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/review/cosmos.api.md | 76 +++++++++++++++++++ .../Aggregators/GlobalStatisticsAggregator.ts | 4 +- .../cosmos/src/utils/hashing/multiHash.ts | 1 + .../cosmos/test/public/common/TestHelpers.ts | 5 +- .../test/public/functional/client.spec.ts | 8 ++ .../test/public/functional/conflict.spec.ts | 1 + sdk/cosmosdb/cosmos/tsconfig.src.json | 1 - sdk/cosmosdb/cosmos/vitest.browser.config.ts | 6 +- sdk/cosmosdb/cosmos/vitest.config.ts | 1 + 9 files changed, 97 insertions(+), 6 deletions(-) diff --git a/sdk/cosmosdb/cosmos/review/cosmos.api.md b/sdk/cosmosdb/cosmos/review/cosmos.api.md index 326481edd00c..fe1c03dd86c9 100644 --- a/sdk/cosmosdb/cosmos/review/cosmos.api.md +++ b/sdk/cosmosdb/cosmos/review/cosmos.api.md @@ -7,6 +7,7 @@ import { AbortError } from '@azure/abort-controller'; import type { HttpClient } from '@azure/core-rest-pipeline'; import type { Pipeline } from '@azure/core-rest-pipeline'; +import type { PipelineResponse } from '@azure/core-rest-pipeline'; import { RestError } from '@azure/core-rest-pipeline'; import type { TokenCredential } from '@azure/core-auth'; @@ -58,6 +59,8 @@ export type BulkPatchOperation = OperationBase & { // @public export class ChangeFeedIterator { + // @internal + constructor(clientContext: ClientContext, resourceId: string, resourceLink: string, partitionKey: PartitionKey, changeFeedOptions: ChangeFeedOptions); fetchNext(): Promise>>; getAsyncIterator(): AsyncIterable>>; get hasMoreResults(): boolean; @@ -73,6 +76,14 @@ export interface ChangeFeedIteratorOptions { // @public export class ChangeFeedIteratorResponse { + // @internal + constructor( + result: T, + count: number, + statusCode: number, + headers: CosmosHeaders, + diagnostics: CosmosDiagnostics, + subStatusCode?: number); get activityId(): string; get continuationToken(): string; readonly count: number; @@ -118,6 +129,11 @@ export interface ChangeFeedPullModelIterator { // @public export class ChangeFeedResponse { + // @internal + constructor( + result: T, + count: number, + statusCode: number, headers: CosmosHeaders, diagnostics: CosmosDiagnostics); get activityId(): string; get continuation(): string; readonly count: number; @@ -133,7 +149,11 @@ export class ChangeFeedResponse { // @public (undocumented) export class ChangeFeedRetentionTimeSpan { + // @internal + constructor(minutes: number); static fromMinutes(minutes: number): ChangeFeedRetentionTimeSpan; + // @internal (undocumented) + getRetentionInMinutes(): number; } // @public @@ -717,6 +737,8 @@ export interface CosmosClientOptions { httpClient?: HttpClient; key?: string; permissionFeed?: PermissionDefinition[]; + // @internal (undocumented) + plugins?: PluginConfig[]; resourceTokens?: { [resourcePath: string]: string; }; @@ -736,6 +758,8 @@ export enum CosmosDbDiagnosticLevel { // @public export class CosmosDiagnostics { + // @internal + constructor(clientSideRequestStatistics: ClientSideRequestStatistics, diagnosticNode?: DiagnosticNode, clientConfig?: ClientConfigDiagnostic); // (undocumented) readonly clientConfig?: ClientConfigDiagnostic; // (undocumented) @@ -938,6 +962,14 @@ export interface DiagnosticNode { // @public export class DiagnosticNodeInternal implements DiagnosticNode { + // Warning: (ae-forgotten-export) The symbol "CosmosDiagnosticContext" needs to be exported by the entry point index.d.ts + // + // @internal + constructor(diagnosticLevel: CosmosDbDiagnosticLevel, type: DiagnosticNodeType, parent: DiagnosticNodeInternal, data?: Partial, startTimeUTCInMs?: number, ctx?: CosmosDiagnosticContext); + // @internal + addChildNode(child: DiagnosticNodeInternal, level: CosmosDbDiagnosticLevel, metadataType?: MetadataLookUpType): DiagnosticNodeInternal; + // @internal (undocumented) + addData(data: Partial, msg?: string, level?: CosmosDbDiagnosticLevel): void; // (undocumented) children: DiagnosticNodeInternal[]; // (undocumented) @@ -948,12 +980,28 @@ export class DiagnosticNodeInternal implements DiagnosticNode { durationInMs: number; // (undocumented) id: string; + // @internal (undocumented) + initializeChildNode(type: DiagnosticNodeType, level: CosmosDbDiagnosticLevel, data?: Partial): DiagnosticNodeInternal; // (undocumented) nodeType: DiagnosticNodeType; // (undocumented) parent: DiagnosticNodeInternal; + // @internal (undocumented) + recordEndpointResolution(location: string): void; + // @internal (undocumented) + recordFailedNetworkCall(startTimeUTCInMs: number, requestContext: RequestContext, retryAttemptNumber: number, statusCode: number, substatusCode: number, responseHeaders: CosmosHeaders_2): void; + // @internal (undocumented) + recordQueryResult(resources: unknown, level: CosmosDbDiagnosticLevel): void; + // @internal (undocumented) + recordSuccessfulNetworkCall(startTimeUTCInMs: number, requestContext: RequestContext, pipelineResponse: PipelineResponse, substatus: number, url: string): void; // (undocumented) startTimeUTCInMs: number; + // @internal + toDiagnostic(clientConfigDiagnostic: ClientConfigDiagnostic): CosmosDiagnostics; + // @internal + toDiagnosticNode(): DiagnosticNode; + // @internal + updateTimestamp(endTimeUTCInMs?: number): void; } // @public (undocumented) @@ -1061,12 +1109,18 @@ export interface FeedOptions extends SharedOptions { partitionKey?: PartitionKey; populateIndexMetrics?: boolean; populateQueryMetrics?: boolean; + // @internal + useAllVersionsAndDeletesFeed?: boolean; useIncrementalFeed?: boolean; + // @internal + useLatestVersionFeed?: boolean; vectorSearchBufferSize?: number; } // @public export abstract class FeedRange { + // @internal + protected constructor(minInclusive: string, maxExclusive: string); readonly maxExclusive: string; readonly minInclusive: string; } @@ -1113,6 +1167,16 @@ export interface FullTextPolicy { fullTextPaths: FullTextPath[]; } +// Warning: (ae-internal-missing-underscore) The name "FullTextStatistics" should be prefixed with an underscore because the declaration is marked as @internal +// +// @internal +export interface FullTextStatistics { + // (undocumented) + hitCounts: number[]; + // (undocumented) + totalWordCount: number; +} + // @public (undocumented) export type GatewayStatistics = { activityId?: string; @@ -1136,6 +1200,8 @@ export enum GeospatialType { // @public export class GlobalEndpointManager { + // @internal + constructor(options: CosmosClientOptions, readDatabaseAccount: (diagnosticNode: DiagnosticNodeInternal, opts: RequestOptions) => Promise>); // (undocumented) canUseMultipleWriteLocations(resourceType?: ResourceType, operationType?: OperationType): boolean; enableEndpointDiscovery: boolean; @@ -1156,6 +1222,16 @@ export class GlobalEndpointManager { resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number): Promise; } +// Warning: (ae-internal-missing-underscore) The name "GlobalStatistics" should be prefixed with an underscore because the declaration is marked as @internal +// +// @internal +export interface GlobalStatistics { + // (undocumented) + documentCount: number; + // (undocumented) + fullTextStatistics: FullTextStatistics[]; +} + // @public (undocumented) export interface GroupByAliasToAggregateType { // (undocumented) diff --git a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts index ebfa016dd111..d157837d6a52 100644 --- a/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts +++ b/sdk/cosmosdb/cosmos/src/queryExecutionContext/Aggregators/GlobalStatisticsAggregator.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { GlobalStatistics } from "../../request/globalStatistics.js"; -import { Aggregator } from "./Aggregator.js"; +import type { GlobalStatistics } from "../../request/globalStatistics.js"; +import type { Aggregator } from "./Aggregator.js"; export class GlobalStatisticsAggregator implements Aggregator { private globalStatistics: GlobalStatistics; diff --git a/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts b/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts index 3e3e6756c59f..d7098ec1b0b0 100644 --- a/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts +++ b/sdk/cosmosdb/cosmos/src/utils/hashing/multiHash.ts @@ -5,6 +5,7 @@ import { hashV2PartitionKey } from "./v2.js"; /** * Generate Hash for a `Multi Hash` type partition. + * @internal * @param partitionKey - to be hashed. * @returns */ diff --git a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts index 8a13c76735a9..27b8dafb245e 100644 --- a/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts +++ b/sdk/cosmosdb/cosmos/test/public/common/TestHelpers.ts @@ -36,11 +36,12 @@ import { import type { ExtractPromise } from "../../../src/utils/diagnostics.js"; import { getCurrentTimestampInMs } from "../../../src/utils/time.js"; import { extractPartitionKeys } from "../../../src/extractPartitionKey.js"; -import { assert, expect } from "vitest"; -import { AssertionError } from "chai"; +import { assert, expect, chai } from "vitest"; import fs from "node:fs"; import path from "node:path"; +const AssertionError = chai.AssertionError; + const defaultRoutingGatewayPort: string = ":8081"; const defaultComputeGatewayPort: string = ":8903"; diff --git a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts index 4d82df39432b..dd13fa3571d2 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/client.spec.ts @@ -49,17 +49,21 @@ describe("Client Tests", { timeout: 200000 }, () => { }); assert.ok(client !== undefined, "client shouldn't be undefined if it succeeded"); }); + it("Accepts a connection string", () => { const client = new CosmosClient(`AccountEndpoint=${endpoint};AccountKey=${masterKey};`); assert.ok(client !== undefined, "client shouldn't be undefined if it succeeded"); client.dispose(); }); + it("throws on a bad connection string", () => { assert.throws(() => new CosmosClient(`bad;Connection=string;`)); }); + it("throws on a bad endpoint", () => { assert.throws(() => new CosmosClient({ endpoint: "asda=asda;asada;" })); }); + it("fails to read databases with bad AAD authentication", async () => { try { const credentials = new UsernamePasswordCredential( @@ -93,6 +97,7 @@ describe("Client Tests", { timeout: 200000 }, () => { } client.dispose(); }); + it("should throw exception if passed an already aborted signal", async () => { const client = new CosmosClient({ endpoint, key: masterKey }); try { @@ -106,6 +111,7 @@ describe("Client Tests", { timeout: 200000 }, () => { } client.dispose(); }); + it("should abort a query", async () => { const container = await getTestContainer("abort query"); await bulkInsertItems(container, generateDocuments(20)); @@ -122,6 +128,7 @@ describe("Client Tests", { timeout: 200000 }, () => { assert.equal(err.name, "AbortError", "client should throw exception"); } }); + it("should not abort if abort signal is never called", async () => { // Testing the happy path to prevent this bug https://github.com/Azure/azure-sdk-for-js/issues/9510 const client = new CosmosClient({ endpoint, key: masterKey }); @@ -135,6 +142,7 @@ describe("Client Tests", { timeout: 200000 }, () => { client.dispose(); }); }); + describe("Background refresher", async () => { // not async to leverage done() callback inside setTimeout it("should fetch new endpoints", () => diff --git a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts index 714a2c7ee869..8483595ed2ef 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/conflict.spec.ts @@ -26,6 +26,7 @@ describe("Conflicts", { timeout: 10000 }, () => { assert.equal(resources.length, 0); }); }); + it("Test diagnostics for conflict", async () => { const container = await getTestContainer("conflicts"); const timestamp = getCurrentTimestampInMs(); diff --git a/sdk/cosmosdb/cosmos/tsconfig.src.json b/sdk/cosmosdb/cosmos/tsconfig.src.json index af5edce5995c..8a50e17d4c42 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.src.json +++ b/sdk/cosmosdb/cosmos/tsconfig.src.json @@ -2,7 +2,6 @@ "extends": "../../../tsconfig.lib.json", "compilerOptions": { "composite": true, - "stripInternal": true, "preserveConstEnums": true, "removeComments": false, "strict": false, diff --git a/sdk/cosmosdb/cosmos/vitest.browser.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.config.ts index d97889ad0f8e..2ab6dcb3eefc 100644 --- a/sdk/cosmosdb/cosmos/vitest.browser.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.browser.config.ts @@ -9,7 +9,11 @@ export default mergeConfig( defineConfig({ test: { include: ["dist-test/browser/test/internal/unit/**/*.spec.js"], - exclude: ["dist-test/browser/test/internal/unit/client.spec.js"], + exclude: [ + "dist-test/browser/test/public/**/*.spec.js", + "dist-test/browser/test/internal/session.spec.js", + "dist-test/browser/test/internal/unit/client.spec.js", + ], }, }), ); diff --git a/sdk/cosmosdb/cosmos/vitest.config.ts b/sdk/cosmosdb/cosmos/vitest.config.ts index 5927363e4c2c..d628e8a08e9b 100644 --- a/sdk/cosmosdb/cosmos/vitest.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.config.ts @@ -9,6 +9,7 @@ export default mergeConfig( defineConfig({ test: { include: ["test/internal/unit/**/*.spec.ts"], + exclude: ["test/internal/session.spec.ts", "test/public/**/*.spec.ts"], }, }), ); From fdbb42b2ca015053f08ffa9d26ef7cf5157112ed Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 30 Dec 2024 17:27:32 -0500 Subject: [PATCH 25/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/package.json | 4 ++-- sdk/cosmosdb/cosmos/tsconfig.samples.json | 4 +--- .../cosmos/vitest.browser.int.config.ts | 17 +++++++++++++++++ sdk/cosmosdb/cosmos/vitest.int.config.ts | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 sdk/cosmosdb/cosmos/vitest.browser.int.config.ts create mode 100644 sdk/cosmosdb/cosmos/vitest.int.config.ts diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 8a1a2be0f1b5..62cef3c48650 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -47,8 +47,8 @@ "extract-api": "npm run check:src:strict && npm run build:src && dev-tool run extract-api", "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"samples-dev/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:browser": "echo skipped", - "integration-test:node": "echo skipped", + "integration-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser --no-test-proxy -- -c vitest.browser.int.config.ts", + "integration-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' dev-tool run test:vitest --no-test-proxy -- -c vitest.int.config.ts", "lint": "eslint package.json api-extractor.json src test", "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", "pack": "npm pack 2>&1", diff --git a/sdk/cosmosdb/cosmos/tsconfig.samples.json b/sdk/cosmosdb/cosmos/tsconfig.samples.json index a7c0ce1573c9..fcfb9cce093c 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.samples.json +++ b/sdk/cosmosdb/cosmos/tsconfig.samples.json @@ -2,9 +2,7 @@ "extends": "../../../tsconfig.samples.base.json", "compilerOptions": { "paths": { - "@azure/cosmos": [ - "./dist/esm" - ] + "@azure/cosmos": ["./dist/esm"] } } } diff --git a/sdk/cosmosdb/cosmos/vitest.browser.int.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.int.config.ts new file mode 100644 index 000000000000..6217ad55ac03 --- /dev/null +++ b/sdk/cosmosdb/cosmos/vitest.browser.int.config.ts @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.browser.base.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: [ + "dist-test/browser/test/internal/unit/**/*.spec.js", + "dist-test/browser/test/public/**/*.spec.js", + ], + }, + }), +); diff --git a/sdk/cosmosdb/cosmos/vitest.int.config.ts b/sdk/cosmosdb/cosmos/vitest.int.config.ts new file mode 100644 index 000000000000..189815140647 --- /dev/null +++ b/sdk/cosmosdb/cosmos/vitest.int.config.ts @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ["test/internal/unit/**/*.spec.ts", "test/public/**/*.spec.ts"], + }, + }), +); From abcc3cfa83d711d5e5184f0dd5fe0b6703692341 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 2 Jan 2025 17:03:03 -0500 Subject: [PATCH 26/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 113 ++++-------------- sdk/cosmosdb/cosmos/PoliCheckExclusions.txt | 1 - sdk/cosmosdb/cosmos/package.json | 2 +- .../functional/item/itemIdEncoding.spec.ts | 8 +- .../test/public/integration/session.spec.ts | 44 ++++--- .../cosmos/tsconfig.browser.config.json | 17 --- sdk/cosmosdb/cosmos/vitest.browser.config.ts | 19 --- .../cosmos/vitest.browser.int.config.ts | 17 --- sdk/cosmosdb/cosmos/vitest.config.ts | 2 +- sdk/cosmosdb/cosmos/vitest.int.config.ts | 2 +- 10 files changed, 64 insertions(+), 161 deletions(-) delete mode 100644 sdk/cosmosdb/cosmos/PoliCheckExclusions.txt delete mode 100644 sdk/cosmosdb/cosmos/tsconfig.browser.config.json delete mode 100644 sdk/cosmosdb/cosmos/vitest.browser.config.ts delete mode 100644 sdk/cosmosdb/cosmos/vitest.browser.int.config.ts diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 7f91a657e58b..693f82c78d01 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -918,7 +918,7 @@ importers: version: file:projects/core-xml.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/cosmos': specifier: file:./projects/cosmos.tgz - version: file:projects/cosmos.tgz + version: file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/create-microsoft-playwright-testing': specifier: file:./projects/create-microsoft-playwright-testing.tgz version: file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) @@ -3671,7 +3671,7 @@ packages: version: 0.0.0 '@rush-temp/cosmos@file:projects/cosmos.tgz': - resolution: {integrity: sha512-v9YVLjFKbVmx5EWiE7LsPWU04QvgDtvIkB2cGhQhm+sbNsCmXtdvkuRLCU7KqB/fWUMjAmnE14leCv/9cKYr8Q==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-8d9pUlsrqnMMWz0E4QoFwVxL3sRQMbBuu8Uu6d3FuLydP3R3dBkpy9qrvK66eePFAAa//qQz917Rd2EYjsY6Ig==, tarball: file:projects/cosmos.tgz} version: 0.0.0 '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz': @@ -4389,9 +4389,6 @@ packages: '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} - '@types/underscore@1.13.0': - resolution: {integrity: sha512-L6LBgy1f0EFQZ+7uSA57+n2g/s4Qs5r06Vwrwn0/nuK1de+adz00NWaztRQ30aEqw5qOaWbPI8u2cGQ52lj6VA==} - '@types/unist@2.0.11': resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} @@ -4864,10 +4861,6 @@ packages: peerDependencies: chai: '>= 5' - chai@4.3.10: - resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==} - engines: {node: '>=4'} - chai@4.5.0: resolution: {integrity: sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==} engines: {node: '>=4'} @@ -5524,10 +5517,6 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} - execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} - execa@6.1.0: resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -5877,10 +5866,6 @@ packages: resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} engines: {node: '>= 14'} - human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - human-signals@3.0.1: resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} engines: {node: '>=12.20.0'} @@ -6155,9 +6140,6 @@ packages: js2xmlparser@4.0.2: resolution: {integrity: sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==} - jsbi@4.3.0: - resolution: {integrity: sha512-SnZNcinB4RIcnEyZqFPdGPVgrg2AcnykiBy0sHVJQKHYeaLUvi3Exj+iaPpLnFVkDPZIV4U0yvgC9/R4uEAZ9g==} - jsbn@1.1.0: resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==} @@ -6738,10 +6720,6 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} - npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} - npm-run-path@5.3.0: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -7204,11 +7182,6 @@ packages: require-main-filename@2.0.0: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} - requirejs@2.3.7: - resolution: {integrity: sha512-DouTG8T1WanGok6Qjg2SXuCMzszOo0eHeH9hDZ5Y4x8Je+9JB38HdTLT4/VA8OaUhBa0JPVHJ0pyBkM1z+pDsw==} - engines: {node: '>=0.4.0'} - hasBin: true - requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} @@ -7561,10 +7534,6 @@ packages: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} - strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} @@ -16892,39 +16861,45 @@ snapshots: - vite - webdriverio - '@rush-temp/cosmos@file:projects/cosmos.tgz': + '@rush-temp/cosmos@file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9))': dependencies: - '@sinonjs/fake-timers': 11.3.1 - '@types/chai': 4.3.20 '@types/debug': 4.1.12 - '@types/mocha': 10.0.10 '@types/node': 18.19.68 '@types/priorityqueuejs': 1.0.4 '@types/semaphore': 1.1.4 - '@types/sinon': 17.0.3 - '@types/sinonjs__fake-timers': 8.1.5 - '@types/underscore': 1.13.0 - chai: 4.3.10 + '@vitest/browser': 2.1.8(@types/node@18.19.68)(playwright@1.49.1)(typescript@5.6.3)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) + '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) + buffer: 6.0.3 dotenv: 16.4.7 eslint: 9.17.0 - execa: 5.1.1 fast-json-stable-stringify: 2.1.0 - jsbi: 4.3.0 - mocha: 11.0.2 nock: 13.5.6 + playwright: 1.49.1 priorityqueuejs: 2.0.0 - requirejs: 2.3.7 semaphore: 1.1.0 - sinon: 17.0.1 - source-map-support: 0.5.21 - ts-node: 10.9.2(@types/node@18.19.68)(typescript@5.7.2) tslib: 2.8.1 - typescript: 5.7.2 + typescript: 5.6.3 + vitest: 2.1.8(@types/node@18.19.68)(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - utf-8-validate + - vite + - webdriverio '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))': dependencies: @@ -20479,8 +20454,6 @@ snapshots: '@types/trusted-types@2.0.7': {} - '@types/underscore@1.13.0': {} - '@types/unist@2.0.11': {} '@types/unzipper@0.10.10': @@ -21069,16 +21042,6 @@ snapshots: chai: 5.1.2 fclone: 1.0.11 - chai@4.3.10: - dependencies: - assertion-error: 1.1.0 - check-error: 1.0.3 - deep-eql: 4.1.4 - get-func-name: 2.0.2 - loupe: 2.3.7 - pathval: 1.1.1 - type-detect: 4.1.0 - chai@4.5.0: dependencies: assertion-error: 1.1.0 @@ -21805,18 +21768,6 @@ snapshots: events@3.3.0: {} - execa@5.1.1: - dependencies: - cross-spawn: 7.0.6 - get-stream: 6.0.1 - human-signals: 2.1.0 - is-stream: 2.0.1 - merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 - execa@6.1.0: dependencies: cross-spawn: 7.0.6 @@ -22230,8 +22181,6 @@ snapshots: transitivePeerDependencies: - supports-color - human-signals@2.1.0: {} - human-signals@3.0.1: {} humanize-ms@1.2.1: @@ -22495,8 +22444,6 @@ snapshots: dependencies: xmlcreate: 2.0.4 - jsbi@4.3.0: {} - jsbn@1.1.0: {} jsdoc@4.0.4: @@ -23236,10 +23183,6 @@ snapshots: normalize-path@3.0.0: {} - npm-run-path@4.0.1: - dependencies: - path-key: 3.1.1 - npm-run-path@5.3.0: dependencies: path-key: 4.0.0 @@ -23781,8 +23724,6 @@ snapshots: require-main-filename@2.0.0: {} - requirejs@2.3.7: {} - requires-port@1.0.0: {} requizzle@0.2.4: @@ -24201,8 +24142,6 @@ snapshots: strip-bom@4.0.0: {} - strip-final-newline@2.0.0: {} - strip-final-newline@3.0.0: {} strip-indent@4.0.0: diff --git a/sdk/cosmosdb/cosmos/PoliCheckExclusions.txt b/sdk/cosmosdb/cosmos/PoliCheckExclusions.txt deleted file mode 100644 index 483a9c42c3c2..000000000000 --- a/sdk/cosmosdb/cosmos/PoliCheckExclusions.txt +++ /dev/null @@ -1 +0,0 @@ -package-lock.json \ No newline at end of file diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index cbf9420d25b0..98eec0e651af 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -47,7 +47,7 @@ "extract-api": "npm run check:src:strict && npm run build:src && dev-tool run extract-api", "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"samples-dev/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser --no-test-proxy -- -c vitest.browser.int.config.ts", + "integration-test:browser": "echo skipped", "integration-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' dev-tool run test:vitest --no-test-proxy -- -c vitest.int.config.ts", "lint": "eslint package.json api-extractor.json src test", "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts index d86220fbb1d2..59b962db8e4c 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts @@ -5,8 +5,8 @@ import type { Container, CosmosClient } from "../../../../src/index.js"; import { getTestContainer, removeAllDatabases, - defaultClient, - defaultComputeGatewayClient, + getDefaultClient, + getDefaultComputeGatewayClient, } from "../../common/TestHelpers.js"; import { describe, it, assert, beforeEach } from "vitest"; @@ -36,7 +36,9 @@ const executeTestCase = async ( scenario: TestScenario, useComputeGateway: boolean = false, ): Promise => { - const client: CosmosClient = useComputeGateway ? defaultComputeGatewayClient() : defaultClient(); + const client: CosmosClient = useComputeGateway + ? getDefaultComputeGatewayClient() + : getDefaultClient(); const container: Container = await getTestContainer(scenario.name, client, { partitionKey: { paths: ["/pk"], diff --git a/sdk/cosmosdb/cosmos/test/public/integration/session.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/session.spec.ts index 0f49f33bfb44..7c843a38f560 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/session.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/session.spec.ts @@ -1,17 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { ClientContext, Container, PluginConfig } from "../../src/index.js"; -import { PluginOn } from "../../src/index.js"; -import { OperationType, ResourceType } from "../../src/common/index.js"; -import { ConsistencyLevel } from "../../src/index.js"; -import { CosmosClient } from "../../src/index.js"; -import type { SessionContainer } from "../../src/session/sessionContainer.js"; -import { endpoint } from "../public/common/_testConfig.js"; -import { masterKey } from "../public/common/_fakeTestSecrets.js"; -import { addEntropy, getTestDatabase, removeAllDatabases } from "../public/common/TestHelpers.js"; -import type { RequestContext } from "../../src/index.js"; -import type { Response } from "../../src/request/Response.js"; +import type { ClientContext, Container, PluginConfig } from "../../../src/index.js"; +import { PluginOn } from "../../../src/index.js"; +import { OperationType, ResourceType } from "../../../src/common/index.js"; +import { ConsistencyLevel } from "../../../src/index.js"; +import { CosmosClient } from "../../../src/index.js"; +import type { SessionContainer } from "../../../src/session/sessionContainer.js"; +import { endpoint } from "../../public/common/_testConfig.js"; +import { masterKey } from "../../public/common/_fakeTestSecrets.js"; +import { + addEntropy, + getTestDatabase, + removeAllDatabases, +} from "../../public/common/TestHelpers.js"; +import type { RequestContext } from "../../../src/index.js"; +import type { Response } from "../../../src/request/Response.js"; import { describe, it, assert, expect, beforeEach } from "vitest"; describe("New session token", () => { @@ -21,7 +25,11 @@ describe("New session token", () => { const plugins: PluginConfig[] = [ { on: PluginOn.request, - plugin: async (context, diagNode, next) => { + plugin: async ( + context: RequestContext, + diagNode: any, + next: (context: RequestContext) => Promise>, + ) => { expect(diagNode, "DiagnosticsNode should not be undefined or null").to.exist; rqContext = context; response = await next(context); @@ -85,7 +93,11 @@ describe("Integrated Cache Staleness", async () => { plugins: [ { on: "request", - plugin: async (context, diagNode, next) => { + plugin: async ( + context: RequestContext, + diagNode: any, + next: (context: RequestContext) => Promise>, + ) => { expect(diagNode, "DiagnosticsNode should not be undefined or null").to.exist; if ( context.resourceType === ResourceType.item && @@ -219,7 +231,11 @@ describe.skip("Session Token", () => { plugins: [ { on: "request", - plugin: async (context, diagNode, next) => { + plugin: async ( + context: RequestContext, + diagNode: any, + next: (context: RequestContext) => Promise>, + ) => { expect(diagNode, "DiagnosticsNode should not be undefined or null").to.exist; // Simulate a "Session Not Found" error by manually making the client session token *way* ahead of any available session on the server // This is just a way to simulate the error. Getting this to happen in practice is difficult and only usually occurs cross region where there is significant replication lag diff --git a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json b/sdk/cosmosdb/cosmos/tsconfig.browser.config.json deleted file mode 100644 index c24ed56d14c5..000000000000 --- a/sdk/cosmosdb/cosmos/tsconfig.browser.config.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "./.tshy/build.json", - "include": [ - "./src/**/*.ts", - "./src/**/*.mts", - "./test/**/*.ts", - "./test/**/*.mts", - "package.json" - ], - "exclude": ["./test/**/node/**/*.ts"], - "compilerOptions": { - "allowJs": true, - "outDir": "./dist-test/browser", - "rootDir": ".", - "skipLibCheck": true - } -} diff --git a/sdk/cosmosdb/cosmos/vitest.browser.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.config.ts deleted file mode 100644 index 2ab6dcb3eefc..000000000000 --- a/sdk/cosmosdb/cosmos/vitest.browser.config.ts +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { defineConfig, mergeConfig } from "vitest/config"; -import viteConfig from "../../../vitest.browser.base.config.ts"; - -export default mergeConfig( - viteConfig, - defineConfig({ - test: { - include: ["dist-test/browser/test/internal/unit/**/*.spec.js"], - exclude: [ - "dist-test/browser/test/public/**/*.spec.js", - "dist-test/browser/test/internal/session.spec.js", - "dist-test/browser/test/internal/unit/client.spec.js", - ], - }, - }), -); diff --git a/sdk/cosmosdb/cosmos/vitest.browser.int.config.ts b/sdk/cosmosdb/cosmos/vitest.browser.int.config.ts deleted file mode 100644 index 6217ad55ac03..000000000000 --- a/sdk/cosmosdb/cosmos/vitest.browser.int.config.ts +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { defineConfig, mergeConfig } from "vitest/config"; -import viteConfig from "../../../vitest.browser.base.config.ts"; - -export default mergeConfig( - viteConfig, - defineConfig({ - test: { - include: [ - "dist-test/browser/test/internal/unit/**/*.spec.js", - "dist-test/browser/test/public/**/*.spec.js", - ], - }, - }), -); diff --git a/sdk/cosmosdb/cosmos/vitest.config.ts b/sdk/cosmosdb/cosmos/vitest.config.ts index d628e8a08e9b..a4334dd9bed1 100644 --- a/sdk/cosmosdb/cosmos/vitest.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.config.ts @@ -9,7 +9,7 @@ export default mergeConfig( defineConfig({ test: { include: ["test/internal/unit/**/*.spec.ts"], - exclude: ["test/internal/session.spec.ts", "test/public/**/*.spec.ts"], + exclude: ["test/public/**/*.spec.ts"], }, }), ); diff --git a/sdk/cosmosdb/cosmos/vitest.int.config.ts b/sdk/cosmosdb/cosmos/vitest.int.config.ts index 189815140647..b60f0effa527 100644 --- a/sdk/cosmosdb/cosmos/vitest.int.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.int.config.ts @@ -8,7 +8,7 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: ["test/internal/unit/**/*.spec.ts", "test/public/**/*.spec.ts"], + include: ["test/internal/**/*.spec.ts", "test/public/**/*.spec.ts"], }, }), ); From 42df788a5faa54f241bd7f9f3a7cf4b60e574393 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 2 Jan 2025 17:28:10 -0500 Subject: [PATCH 27/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/.gitignore | 4 ++++ sdk/cosmosdb/cosmos/package.json | 1 + sdk/cosmosdb/cosmos/vitest.int.config.ts | 3 +++ 3 files changed, 8 insertions(+) diff --git a/sdk/cosmosdb/cosmos/.gitignore b/sdk/cosmosdb/cosmos/.gitignore index 53c30a3a6293..20543c0cc45a 100644 --- a/sdk/cosmosdb/cosmos/.gitignore +++ b/sdk/cosmosdb/cosmos/.gitignore @@ -61,3 +61,7 @@ test/**/*.js.map test/**/*.d.ts tsconfig.tsbuildinfo .env + +# Testing +test-results.xml +test-results-int.xml diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 98eec0e651af..a637cbebb684 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -96,6 +96,7 @@ "eslint": "^9.9.0", "nock": "^13.5.6", "playwright": "^1.49.0", + "source-map-support": "^0.5.21", "typescript": "~5.6.2", "vitest": "^2.1.8" }, diff --git a/sdk/cosmosdb/cosmos/vitest.int.config.ts b/sdk/cosmosdb/cosmos/vitest.int.config.ts index b60f0effa527..936cf7cec358 100644 --- a/sdk/cosmosdb/cosmos/vitest.int.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.int.config.ts @@ -8,6 +8,9 @@ export default mergeConfig( viteConfig, defineConfig({ test: { + outputFile: { + junit: "test-results-int.xml", + }, include: ["test/internal/**/*.spec.ts", "test/public/**/*.spec.ts"], }, }), From 9186bcb7bfefc0eb38dd8b6426648aebf325294d Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 2 Jan 2025 17:38:31 -0500 Subject: [PATCH 28/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 3 ++- sdk/cosmosdb/cosmos/package.json | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 693f82c78d01..6f617b58f2c0 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3671,7 +3671,7 @@ packages: version: 0.0.0 '@rush-temp/cosmos@file:projects/cosmos.tgz': - resolution: {integrity: sha512-8d9pUlsrqnMMWz0E4QoFwVxL3sRQMbBuu8Uu6d3FuLydP3R3dBkpy9qrvK66eePFAAa//qQz917Rd2EYjsY6Ig==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-J2IVP21UPSmueIGvagyCzq/6p0HoPHi50K4NhhG8BONUT78YgqeK4mjZFjLUqQwXI9FG6dfEYxtB6Q++c8yspw==, tarball: file:projects/cosmos.tgz} version: 0.0.0 '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz': @@ -16877,6 +16877,7 @@ snapshots: playwright: 1.49.1 priorityqueuejs: 2.0.0 semaphore: 1.1.0 + source-map-support: 0.5.21 tslib: 2.8.1 typescript: 5.6.3 vitest: 2.1.8(@types/node@18.19.68)(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index a637cbebb684..98eec0e651af 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -96,7 +96,6 @@ "eslint": "^9.9.0", "nock": "^13.5.6", "playwright": "^1.49.0", - "source-map-support": "^0.5.21", "typescript": "~5.6.2", "vitest": "^2.1.8" }, From 8bb031d54e12e969839890a93e3ed84d616c8eeb Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 2 Jan 2025 22:11:31 -0500 Subject: [PATCH 29/45] Update sdk/cosmosdb/cosmos/package.json Co-authored-by: Deyaaeldeen Almahallawi --- sdk/cosmosdb/cosmos/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 98eec0e651af..e00878e5b780 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -96,7 +96,7 @@ "eslint": "^9.9.0", "nock": "^13.5.6", "playwright": "^1.49.0", - "typescript": "~5.6.2", + "typescript": "~5.7.2", "vitest": "^2.1.8" }, "//sampleConfiguration": { From 82657129bc4596b2a75411eb0b83c74763c239b3 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 2 Jan 2025 22:11:54 -0500 Subject: [PATCH 30/45] Update sdk/cosmosdb/cosmos/vitest.int.config.ts Co-authored-by: Deyaaeldeen Almahallawi --- sdk/cosmosdb/cosmos/vitest.int.config.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/cosmosdb/cosmos/vitest.int.config.ts b/sdk/cosmosdb/cosmos/vitest.int.config.ts index 936cf7cec358..c0db70d85fab 100644 --- a/sdk/cosmosdb/cosmos/vitest.int.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.int.config.ts @@ -11,7 +11,6 @@ export default mergeConfig( outputFile: { junit: "test-results-int.xml", }, - include: ["test/internal/**/*.spec.ts", "test/public/**/*.spec.ts"], }, }), ); From 0304724fb41bcbcf2429297521d01c3ea1e24d8f Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 3 Jan 2025 09:45:35 -0500 Subject: [PATCH 31/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 7 +- sdk/cosmosdb/cosmos/review/cosmos.api.md | 76 ------------------- .../cosmos/samples-dev/ItemManagement.ts | 2 +- sdk/cosmosdb/cosmos/tsconfig.samples.json | 7 +- sdk/cosmosdb/cosmos/tsconfig.src.json | 3 +- 5 files changed, 11 insertions(+), 84 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 6f617b58f2c0..18fd4774c13f 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3671,7 +3671,7 @@ packages: version: 0.0.0 '@rush-temp/cosmos@file:projects/cosmos.tgz': - resolution: {integrity: sha512-J2IVP21UPSmueIGvagyCzq/6p0HoPHi50K4NhhG8BONUT78YgqeK4mjZFjLUqQwXI9FG6dfEYxtB6Q++c8yspw==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-IzgO/rrDUd7B2ldyw/1N7sJ0DbLe5Wsd56Fsu3wpDJbDeYcSAmjODoqvmqRpGg3C5Ikz9fk4LFeUO2r9scylpg==, tarball: file:projects/cosmos.tgz} version: 0.0.0 '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz': @@ -16867,7 +16867,7 @@ snapshots: '@types/node': 18.19.68 '@types/priorityqueuejs': 1.0.4 '@types/semaphore': 1.1.4 - '@vitest/browser': 2.1.8(@types/node@18.19.68)(playwright@1.49.1)(typescript@5.6.3)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) + '@vitest/browser': 2.1.8(@types/node@18.19.68)(playwright@1.49.1)(typescript@5.7.2)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) buffer: 6.0.3 dotenv: 16.4.7 @@ -16877,9 +16877,8 @@ snapshots: playwright: 1.49.1 priorityqueuejs: 2.0.0 semaphore: 1.1.0 - source-map-support: 0.5.21 tslib: 2.8.1 - typescript: 5.6.3 + typescript: 5.7.2 vitest: 2.1.8(@types/node@18.19.68)(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) transitivePeerDependencies: - '@edge-runtime/vm' diff --git a/sdk/cosmosdb/cosmos/review/cosmos.api.md b/sdk/cosmosdb/cosmos/review/cosmos.api.md index fe1c03dd86c9..326481edd00c 100644 --- a/sdk/cosmosdb/cosmos/review/cosmos.api.md +++ b/sdk/cosmosdb/cosmos/review/cosmos.api.md @@ -7,7 +7,6 @@ import { AbortError } from '@azure/abort-controller'; import type { HttpClient } from '@azure/core-rest-pipeline'; import type { Pipeline } from '@azure/core-rest-pipeline'; -import type { PipelineResponse } from '@azure/core-rest-pipeline'; import { RestError } from '@azure/core-rest-pipeline'; import type { TokenCredential } from '@azure/core-auth'; @@ -59,8 +58,6 @@ export type BulkPatchOperation = OperationBase & { // @public export class ChangeFeedIterator { - // @internal - constructor(clientContext: ClientContext, resourceId: string, resourceLink: string, partitionKey: PartitionKey, changeFeedOptions: ChangeFeedOptions); fetchNext(): Promise>>; getAsyncIterator(): AsyncIterable>>; get hasMoreResults(): boolean; @@ -76,14 +73,6 @@ export interface ChangeFeedIteratorOptions { // @public export class ChangeFeedIteratorResponse { - // @internal - constructor( - result: T, - count: number, - statusCode: number, - headers: CosmosHeaders, - diagnostics: CosmosDiagnostics, - subStatusCode?: number); get activityId(): string; get continuationToken(): string; readonly count: number; @@ -129,11 +118,6 @@ export interface ChangeFeedPullModelIterator { // @public export class ChangeFeedResponse { - // @internal - constructor( - result: T, - count: number, - statusCode: number, headers: CosmosHeaders, diagnostics: CosmosDiagnostics); get activityId(): string; get continuation(): string; readonly count: number; @@ -149,11 +133,7 @@ export class ChangeFeedResponse { // @public (undocumented) export class ChangeFeedRetentionTimeSpan { - // @internal - constructor(minutes: number); static fromMinutes(minutes: number): ChangeFeedRetentionTimeSpan; - // @internal (undocumented) - getRetentionInMinutes(): number; } // @public @@ -737,8 +717,6 @@ export interface CosmosClientOptions { httpClient?: HttpClient; key?: string; permissionFeed?: PermissionDefinition[]; - // @internal (undocumented) - plugins?: PluginConfig[]; resourceTokens?: { [resourcePath: string]: string; }; @@ -758,8 +736,6 @@ export enum CosmosDbDiagnosticLevel { // @public export class CosmosDiagnostics { - // @internal - constructor(clientSideRequestStatistics: ClientSideRequestStatistics, diagnosticNode?: DiagnosticNode, clientConfig?: ClientConfigDiagnostic); // (undocumented) readonly clientConfig?: ClientConfigDiagnostic; // (undocumented) @@ -962,14 +938,6 @@ export interface DiagnosticNode { // @public export class DiagnosticNodeInternal implements DiagnosticNode { - // Warning: (ae-forgotten-export) The symbol "CosmosDiagnosticContext" needs to be exported by the entry point index.d.ts - // - // @internal - constructor(diagnosticLevel: CosmosDbDiagnosticLevel, type: DiagnosticNodeType, parent: DiagnosticNodeInternal, data?: Partial, startTimeUTCInMs?: number, ctx?: CosmosDiagnosticContext); - // @internal - addChildNode(child: DiagnosticNodeInternal, level: CosmosDbDiagnosticLevel, metadataType?: MetadataLookUpType): DiagnosticNodeInternal; - // @internal (undocumented) - addData(data: Partial, msg?: string, level?: CosmosDbDiagnosticLevel): void; // (undocumented) children: DiagnosticNodeInternal[]; // (undocumented) @@ -980,28 +948,12 @@ export class DiagnosticNodeInternal implements DiagnosticNode { durationInMs: number; // (undocumented) id: string; - // @internal (undocumented) - initializeChildNode(type: DiagnosticNodeType, level: CosmosDbDiagnosticLevel, data?: Partial): DiagnosticNodeInternal; // (undocumented) nodeType: DiagnosticNodeType; // (undocumented) parent: DiagnosticNodeInternal; - // @internal (undocumented) - recordEndpointResolution(location: string): void; - // @internal (undocumented) - recordFailedNetworkCall(startTimeUTCInMs: number, requestContext: RequestContext, retryAttemptNumber: number, statusCode: number, substatusCode: number, responseHeaders: CosmosHeaders_2): void; - // @internal (undocumented) - recordQueryResult(resources: unknown, level: CosmosDbDiagnosticLevel): void; - // @internal (undocumented) - recordSuccessfulNetworkCall(startTimeUTCInMs: number, requestContext: RequestContext, pipelineResponse: PipelineResponse, substatus: number, url: string): void; // (undocumented) startTimeUTCInMs: number; - // @internal - toDiagnostic(clientConfigDiagnostic: ClientConfigDiagnostic): CosmosDiagnostics; - // @internal - toDiagnosticNode(): DiagnosticNode; - // @internal - updateTimestamp(endTimeUTCInMs?: number): void; } // @public (undocumented) @@ -1109,18 +1061,12 @@ export interface FeedOptions extends SharedOptions { partitionKey?: PartitionKey; populateIndexMetrics?: boolean; populateQueryMetrics?: boolean; - // @internal - useAllVersionsAndDeletesFeed?: boolean; useIncrementalFeed?: boolean; - // @internal - useLatestVersionFeed?: boolean; vectorSearchBufferSize?: number; } // @public export abstract class FeedRange { - // @internal - protected constructor(minInclusive: string, maxExclusive: string); readonly maxExclusive: string; readonly minInclusive: string; } @@ -1167,16 +1113,6 @@ export interface FullTextPolicy { fullTextPaths: FullTextPath[]; } -// Warning: (ae-internal-missing-underscore) The name "FullTextStatistics" should be prefixed with an underscore because the declaration is marked as @internal -// -// @internal -export interface FullTextStatistics { - // (undocumented) - hitCounts: number[]; - // (undocumented) - totalWordCount: number; -} - // @public (undocumented) export type GatewayStatistics = { activityId?: string; @@ -1200,8 +1136,6 @@ export enum GeospatialType { // @public export class GlobalEndpointManager { - // @internal - constructor(options: CosmosClientOptions, readDatabaseAccount: (diagnosticNode: DiagnosticNodeInternal, opts: RequestOptions) => Promise>); // (undocumented) canUseMultipleWriteLocations(resourceType?: ResourceType, operationType?: OperationType): boolean; enableEndpointDiscovery: boolean; @@ -1222,16 +1156,6 @@ export class GlobalEndpointManager { resolveServiceEndpoint(diagnosticNode: DiagnosticNodeInternal, resourceType: ResourceType, operationType: OperationType, startServiceEndpointIndex?: number): Promise; } -// Warning: (ae-internal-missing-underscore) The name "GlobalStatistics" should be prefixed with an underscore because the declaration is marked as @internal -// -// @internal -export interface GlobalStatistics { - // (undocumented) - documentCount: number; - // (undocumented) - fullTextStatistics: FullTextStatistics[]; -} - // @public (undocumented) export interface GroupByAliasToAggregateType { // (undocumented) diff --git a/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts b/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts index 108afcd06098..d282dfd0af1d 100644 --- a/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts +++ b/sdk/cosmosdb/cosmos/samples-dev/ItemManagement.ts @@ -10,7 +10,7 @@ import "dotenv/config"; import { logSampleHeader, handleError, finish, logStep } from "./Shared/handleError.js"; import type { PatchOperation } from "@azure/cosmos"; import { CosmosClient, PriorityLevel } from "@azure/cosmos"; -import Families from "./Data/Families.json" assert { type: "json" }; +import Families from "./Data/Families.json" with { type: "json" }; const key = process.env.COSMOS_KEY || ""; const endpoint = process.env.COSMOS_ENDPOINT || ""; diff --git a/sdk/cosmosdb/cosmos/tsconfig.samples.json b/sdk/cosmosdb/cosmos/tsconfig.samples.json index fcfb9cce093c..00fa7493d0c0 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.samples.json +++ b/sdk/cosmosdb/cosmos/tsconfig.samples.json @@ -2,7 +2,10 @@ "extends": "../../../tsconfig.samples.base.json", "compilerOptions": { "paths": { - "@azure/cosmos": ["./dist/esm"] - } + "@azure/cosmos": [ + "./dist/esm" + ] + }, + "resolveJsonModule": true } } diff --git a/sdk/cosmosdb/cosmos/tsconfig.src.json b/sdk/cosmosdb/cosmos/tsconfig.src.json index 8a50e17d4c42..1c1ec3a9ef16 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.src.json +++ b/sdk/cosmosdb/cosmos/tsconfig.src.json @@ -9,6 +9,7 @@ "noImplicitReturns": false, "noFallthroughCasesInSwitch": false, "newLine": "LF", - "resolveJsonModule": true + "resolveJsonModule": true, + "stripInternal": true } } From f0e5aac7a4fac925349d0a3692478202dc7922e4 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Fri, 3 Jan 2025 09:51:59 -0500 Subject: [PATCH 32/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/eslint.config.mjs | 1 - sdk/cosmosdb/cosmos/src/request/RequestHandler.ts | 6 ------ 2 files changed, 7 deletions(-) diff --git a/sdk/cosmosdb/cosmos/eslint.config.mjs b/sdk/cosmosdb/cosmos/eslint.config.mjs index 17a3a625ee56..441f491bbaa7 100644 --- a/sdk/cosmosdb/cosmos/eslint.config.mjs +++ b/sdk/cosmosdb/cosmos/eslint.config.mjs @@ -27,7 +27,6 @@ export default azsdkEslint.config([ // left to the cosmos team make this rule error again "@azure/azure-sdk/ts-package-json-module": "warn", "@azure/azure-sdk/ts-doc-internal": "warn", - "@azure/azure-sdk/ts-use-interface-parameters": "off", }, }, { diff --git a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts index 87c276ae66d2..e12e0f30e292 100644 --- a/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts +++ b/sdk/cosmosdb/cosmos/src/request/RequestHandler.ts @@ -24,9 +24,7 @@ import { getCurrentTimestampInMs } from "../utils/time.js"; const logger: AzureLogger = createClientLogger("RequestHandler"); async function executeRequest( - // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters diagnosticNode: DiagnosticNodeInternal, - // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters requestContext: RequestContext, ): Promise> { return executePlugins(diagnosticNode, requestContext, httpRequest, PluginOn.request); @@ -36,9 +34,7 @@ async function executeRequest( * @hidden */ async function httpRequest( - // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters requestContext: RequestContext, - // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters diagnosticNode: DiagnosticNodeInternal, ): Promise<{ headers: any; @@ -180,9 +176,7 @@ async function httpRequest( * @hidden */ async function request( - // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters requestContext: RequestContext, - // eslint-disable-next-line @azure/azure-sdk/ts-use-interface-parameters diagnosticNode: DiagnosticNodeInternal, ): Promise> { if (requestContext.body) { From 86d81c022613db4bbd2c96f8eaaaa636b4188b0b Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 6 Jan 2025 18:53:32 -0500 Subject: [PATCH 33/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 111 +++++++----------------------- 1 file changed, 25 insertions(+), 86 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 1dd33371d6a6..b5f91aa80c97 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -918,7 +918,7 @@ importers: version: file:projects/core-xml.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/cosmos': specifier: file:./projects/cosmos.tgz - version: file:projects/cosmos.tgz + version: file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/create-microsoft-playwright-testing': specifier: file:./projects/create-microsoft-playwright-testing.tgz version: file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) @@ -3671,7 +3671,7 @@ packages: version: 0.0.0 '@rush-temp/cosmos@file:projects/cosmos.tgz': - resolution: {integrity: sha512-v9YVLjFKbVmx5EWiE7LsPWU04QvgDtvIkB2cGhQhm+sbNsCmXtdvkuRLCU7KqB/fWUMjAmnE14leCv/9cKYr8Q==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-IzgO/rrDUd7B2ldyw/1N7sJ0DbLe5Wsd56Fsu3wpDJbDeYcSAmjODoqvmqRpGg3C5Ikz9fk4LFeUO2r9scylpg==, tarball: file:projects/cosmos.tgz} version: 0.0.0 '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz': @@ -4389,9 +4389,6 @@ packages: '@types/trusted-types@2.0.7': resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==} - '@types/underscore@1.13.0': - resolution: {integrity: sha512-L6LBgy1f0EFQZ+7uSA57+n2g/s4Qs5r06Vwrwn0/nuK1de+adz00NWaztRQ30aEqw5qOaWbPI8u2cGQ52lj6VA==} - '@types/unist@2.0.11': resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} @@ -4864,10 +4861,6 @@ packages: peerDependencies: chai: '>= 5' - chai@4.3.10: - resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==} - engines: {node: '>=4'} - chai@4.5.0: resolution: {integrity: sha512-RITGBfijLkBddZvnn8jdqoTypxvqbOLYQkGGxXzeFjVHvudaPw0HNFD9x928/eUwYWd2dPCugVqspGALTZZQKw==} engines: {node: '>=4'} @@ -5524,10 +5517,6 @@ packages: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} - execa@5.1.1: - resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} - engines: {node: '>=10'} - execa@6.1.0: resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -5881,10 +5870,6 @@ packages: resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} engines: {node: '>= 14'} - human-signals@2.1.0: - resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} - engines: {node: '>=10.17.0'} - human-signals@3.0.1: resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} engines: {node: '>=12.20.0'} @@ -6159,9 +6144,6 @@ packages: js2xmlparser@4.0.2: resolution: {integrity: sha512-6n4D8gLlLf1n5mNLQPRfViYzu9RATblzPEtm1SthMX1Pjao0r9YI9nw7ZIfRxQMERS87mcswrg+r/OYrPRX6jA==} - jsbi@4.3.0: - resolution: {integrity: sha512-SnZNcinB4RIcnEyZqFPdGPVgrg2AcnykiBy0sHVJQKHYeaLUvi3Exj+iaPpLnFVkDPZIV4U0yvgC9/R4uEAZ9g==} - jsbn@1.1.0: resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==} @@ -6742,10 +6724,6 @@ packages: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} - npm-run-path@4.0.1: - resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} - engines: {node: '>=8'} - npm-run-path@5.3.0: resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -7208,11 +7186,6 @@ packages: require-main-filename@2.0.0: resolution: {integrity: sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==} - requirejs@2.3.7: - resolution: {integrity: sha512-DouTG8T1WanGok6Qjg2SXuCMzszOo0eHeH9hDZ5Y4x8Je+9JB38HdTLT4/VA8OaUhBa0JPVHJ0pyBkM1z+pDsw==} - engines: {node: '>=0.4.0'} - hasBin: true - requires-port@1.0.0: resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} @@ -7565,10 +7538,6 @@ packages: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} - strip-final-newline@2.0.0: - resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} - engines: {node: '>=6'} - strip-final-newline@3.0.0: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} @@ -17059,39 +17028,45 @@ snapshots: - vite - webdriverio - '@rush-temp/cosmos@file:projects/cosmos.tgz': + '@rush-temp/cosmos@file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9))': dependencies: - '@sinonjs/fake-timers': 11.3.1 - '@types/chai': 4.3.20 '@types/debug': 4.1.12 - '@types/mocha': 10.0.10 '@types/node': 18.19.70 '@types/priorityqueuejs': 1.0.4 '@types/semaphore': 1.1.4 - '@types/sinon': 17.0.3 - '@types/sinonjs__fake-timers': 8.1.5 - '@types/underscore': 1.13.0 - chai: 4.3.10 + '@vitest/browser': 2.1.8(@types/node@18.19.70)(playwright@1.49.1)(typescript@5.7.2)(vite@5.4.11(@types/node@22.7.9))(vitest@2.1.8) + '@vitest/coverage-istanbul': 2.1.8(vitest@2.1.8) + buffer: 6.0.3 dotenv: 16.4.7 eslint: 9.17.0 - execa: 5.1.1 fast-json-stable-stringify: 2.1.0 - jsbi: 4.3.0 - mocha: 11.1.0 nock: 13.5.6 + playwright: 1.49.1 priorityqueuejs: 2.0.0 - requirejs: 2.3.7 semaphore: 1.1.0 - sinon: 17.0.1 - source-map-support: 0.5.21 - ts-node: 10.9.2(@types/node@18.19.70)(typescript@5.7.2) tslib: 2.8.1 typescript: 5.7.2 + vitest: 2.1.8(@types/node@18.19.70)(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) transitivePeerDependencies: - - '@swc/core' - - '@swc/wasm' + - '@edge-runtime/vm' + - '@vitest/ui' + - bufferutil + - happy-dom - jiti + - jsdom + - less + - lightningcss + - msw + - safaridriver + - sass + - sass-embedded + - stylus + - sugarss - supports-color + - terser + - utf-8-validate + - vite + - webdriverio '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))': dependencies: @@ -20646,8 +20621,6 @@ snapshots: '@types/trusted-types@2.0.7': {} - '@types/underscore@1.13.0': {} - '@types/unist@2.0.11': {} '@types/unzipper@0.10.10': @@ -21236,16 +21209,6 @@ snapshots: chai: 5.1.2 fclone: 1.0.11 - chai@4.3.10: - dependencies: - assertion-error: 1.1.0 - check-error: 1.0.3 - deep-eql: 4.1.4 - get-func-name: 2.0.2 - loupe: 2.3.7 - pathval: 1.1.1 - type-detect: 4.1.0 - chai@4.5.0: dependencies: assertion-error: 1.1.0 @@ -21972,18 +21935,6 @@ snapshots: events@3.3.0: {} - execa@5.1.1: - dependencies: - cross-spawn: 7.0.6 - get-stream: 6.0.1 - human-signals: 2.1.0 - is-stream: 2.0.1 - merge-stream: 2.0.0 - npm-run-path: 4.0.1 - onetime: 5.1.2 - signal-exit: 3.0.7 - strip-final-newline: 2.0.0 - execa@6.1.0: dependencies: cross-spawn: 7.0.6 @@ -22402,8 +22353,6 @@ snapshots: transitivePeerDependencies: - supports-color - human-signals@2.1.0: {} - human-signals@3.0.1: {} humanize-ms@1.2.1: @@ -22670,8 +22619,6 @@ snapshots: dependencies: xmlcreate: 2.0.4 - jsbi@4.3.0: {} - jsbn@1.1.0: {} jsdoc@4.0.4: @@ -23411,10 +23358,6 @@ snapshots: normalize-path@3.0.0: {} - npm-run-path@4.0.1: - dependencies: - path-key: 3.1.1 - npm-run-path@5.3.0: dependencies: path-key: 4.0.0 @@ -23956,8 +23899,6 @@ snapshots: require-main-filename@2.0.0: {} - requirejs@2.3.7: {} - requires-port@1.0.0: {} requizzle@0.2.4: @@ -24376,8 +24317,6 @@ snapshots: strip-bom@4.0.0: {} - strip-final-newline@2.0.0: {} - strip-final-newline@3.0.0: {} strip-indent@4.0.0: From 713c486deabeee865efa835d548e3ad21364708e Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 6 Jan 2025 19:29:48 -0500 Subject: [PATCH 34/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/tsconfig.samples.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/cosmosdb/cosmos/tsconfig.samples.json b/sdk/cosmosdb/cosmos/tsconfig.samples.json index 00fa7493d0c0..3fa38993ec45 100644 --- a/sdk/cosmosdb/cosmos/tsconfig.samples.json +++ b/sdk/cosmosdb/cosmos/tsconfig.samples.json @@ -2,9 +2,7 @@ "extends": "../../../tsconfig.samples.base.json", "compilerOptions": { "paths": { - "@azure/cosmos": [ - "./dist/esm" - ] + "@azure/cosmos": ["./dist/esm"] }, "resolveJsonModule": true } From d191019c7fc2b86d69e58f8f1ca870eaa8ed7698 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Mon, 6 Jan 2025 17:07:03 -0800 Subject: [PATCH 35/45] [eslint-plugin] workaround undefined `exported` --- .../eslint-plugin-azure-sdk/src/rules/ts-doc-internal.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-doc-internal.ts b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-doc-internal.ts index d2546ab439d2..bc6bc2e7bf8e 100644 --- a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-doc-internal.ts +++ b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-doc-internal.ts @@ -82,7 +82,9 @@ export default createRule({ const tsNode = converter.get(node as TSESTree.Node) as any; const symbol = typeChecker.getTypeAtLocation(tsNode).getSymbol(); const exported = context.settings.exported as Array; - + if (!exported) { + return; + } // if type is internal and has a TSDoc if (!exported.includes(symbol) && tsNode.jsDoc !== undefined) { // fetch all tags From a3858adf4cc140743328cd5a611ef5f3fa6d5fa0 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Mon, 6 Jan 2025 22:57:06 -0500 Subject: [PATCH 36/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/vitest.config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/cosmosdb/cosmos/vitest.config.ts b/sdk/cosmosdb/cosmos/vitest.config.ts index a4334dd9bed1..3ef95f8a878b 100644 --- a/sdk/cosmosdb/cosmos/vitest.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.config.ts @@ -10,6 +10,8 @@ export default mergeConfig( test: { include: ["test/internal/unit/**/*.spec.ts"], exclude: ["test/public/**/*.spec.ts"], + hookTimeout: 500000, + testTimeout: 500000, }, }), ); From cb18825da1bffeb8a25ac7c1a29e1b1ae06b6ae8 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 11:02:37 -0500 Subject: [PATCH 37/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index e00878e5b780..f5cb16d08090 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -54,6 +54,7 @@ "pack": "npm pack 2>&1", "test": "npm run unit-test && npm run integration-test", "test:browser": "npm run unit-test:browser && npm run integration-test:browser", + "test-consumer": "echo skipped", "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "echo skipped", From d68f75e58b4a474c051320be84aaf8d83c40a670 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 11:08:11 -0500 Subject: [PATCH 38/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts index b5643152b383..685956a400c0 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts @@ -69,7 +69,7 @@ const testDataset = { describe("Testing Credentials integration for Client", { skip: !isNodeLike }, async () => { // endpoint for mock server, which doesn't conflict with emulator's endpoints. - const mockedEndpoint = "https://localhost:6969"; + const mockedEndpoint = "https://localhost:8082"; const aadToken = "aadToken"; let spy: MockInstance; From 8ab98e14e693ba594e2c40afc4a42a1ffb89a072 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 11:13:47 -0500 Subject: [PATCH 39/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts index 685956a400c0..0b8899c6b66a 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts @@ -143,6 +143,7 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as const spyCall = spy.mock.calls[0][0]; assert.isDefined(spyCall.pipeline); }); + it("Test pipeline setup for items.upsert", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); @@ -152,6 +153,7 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as const spyCall = spy.mock.calls[0][0]; assert.isDefined(spyCall.pipeline); }); + it("Test pipeline setup for items.delete", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); @@ -162,6 +164,7 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as const spyCall = spy.mock.calls[0][0]; assert.isDefined(spyCall.pipeline); }); + it("Test pipeline setup for items.batch", async () => { setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); From 47f77e3d5c94b8dfb1d9ee3dde63ac59e92df5ff Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 11:16:45 -0500 Subject: [PATCH 40/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index f5cb16d08090..6ab6ffcf6f36 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -56,6 +56,7 @@ "test:browser": "npm run unit-test:browser && npm run integration-test:browser", "test-consumer": "echo skipped", "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", + "test:signoff": "echo skipped", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "echo skipped", "unit-test:node": "dev-tool run test:vitest", From af64274d4b3ba55bfd7b163a7f13f7e9393a61b7 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 11:20:14 -0500 Subject: [PATCH 41/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/cosmosdb/cosmos/package.json b/sdk/cosmosdb/cosmos/package.json index 6ab6ffcf6f36..5c2dc0787e1e 100644 --- a/sdk/cosmosdb/cosmos/package.json +++ b/sdk/cosmosdb/cosmos/package.json @@ -38,19 +38,19 @@ "node": ">=18.0.0" }, "scripts": { - "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "build": "npm run clean && dev-tool run build-package && npm run extract-api", "build:samples": "echo Obsolete.", "build:test": "echo Obsolete.", "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": "dev-tool run vendored rimraf --glob 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 && dev-tool run extract-api", + "extract-api": "dev-tool run vendored mkdirp ./review && dev-tool run extract-api", "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"samples-dev/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test:browser": "echo skipped", "integration-test:node": "dev-tool run vendored cross-env NODE_OPTIONS='--dns-result-order=ipv4first' dev-tool run test:vitest --no-test-proxy -- -c vitest.int.config.ts", - "lint": "eslint package.json api-extractor.json src test", - "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", + "lint": "dev-tool run vendored eslint package.json api-extractor.json src test", + "lint:fix": "dev-tool run vendored eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", "pack": "npm pack 2>&1", "test": "npm run unit-test && npm run integration-test", "test:browser": "npm run unit-test:browser && npm run integration-test:browser", From 672d8345eb60afc122f4a7ddcf95db176762d699 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 11:55:15 -0500 Subject: [PATCH 42/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 8 ++++---- sdk/cosmosdb/cosmos/vitest.config.ts | 1 + sdk/cosmosdb/cosmos/vitest.int.config.ts | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index b5f91aa80c97..96c3767708cb 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -918,7 +918,7 @@ importers: version: file:projects/core-xml.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) '@rush-temp/cosmos': specifier: file:./projects/cosmos.tgz - version: file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9)) + version: file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) '@rush-temp/create-microsoft-playwright-testing': specifier: file:./projects/create-microsoft-playwright-testing.tgz version: file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) @@ -3671,7 +3671,7 @@ packages: version: 0.0.0 '@rush-temp/cosmos@file:projects/cosmos.tgz': - resolution: {integrity: sha512-IzgO/rrDUd7B2ldyw/1N7sJ0DbLe5Wsd56Fsu3wpDJbDeYcSAmjODoqvmqRpGg3C5Ikz9fk4LFeUO2r9scylpg==, tarball: file:projects/cosmos.tgz} + resolution: {integrity: sha512-MkmfDa9tUWqnwR8aF4MMXLk//KaT7JemvzRRhaoOSKQ/bkZR9B9UG/cGMh7XFQxUC7mVxBKaV9QycA/HYilGLg==, tarball: file:projects/cosmos.tgz} version: 0.0.0 '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz': @@ -17028,7 +17028,7 @@ snapshots: - vite - webdriverio - '@rush-temp/cosmos@file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))(vite@5.4.11(@types/node@22.7.9))': + '@rush-temp/cosmos@file:projects/cosmos.tgz(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))': dependencies: '@types/debug': 4.1.12 '@types/node': 18.19.70 @@ -17046,6 +17046,7 @@ snapshots: semaphore: 1.1.0 tslib: 2.8.1 typescript: 5.7.2 + vite: 5.4.11(@types/node@18.19.70) vitest: 2.1.8(@types/node@18.19.70)(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2)) transitivePeerDependencies: - '@edge-runtime/vm' @@ -17065,7 +17066,6 @@ snapshots: - supports-color - terser - utf-8-validate - - vite - webdriverio '@rush-temp/create-microsoft-playwright-testing@file:projects/create-microsoft-playwright-testing.tgz(@vitest/browser@2.1.8)(msw@2.7.0(@types/node@22.7.9)(typescript@5.7.2))': diff --git a/sdk/cosmosdb/cosmos/vitest.config.ts b/sdk/cosmosdb/cosmos/vitest.config.ts index 3ef95f8a878b..ba1e1633420c 100644 --- a/sdk/cosmosdb/cosmos/vitest.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.config.ts @@ -3,6 +3,7 @@ import { defineConfig, mergeConfig } from "vitest/config"; import viteConfig from "../../../vitest.shared.config.ts"; +import "dotenv/config"; export default mergeConfig( viteConfig, diff --git a/sdk/cosmosdb/cosmos/vitest.int.config.ts b/sdk/cosmosdb/cosmos/vitest.int.config.ts index c0db70d85fab..bcd01c21c31d 100644 --- a/sdk/cosmosdb/cosmos/vitest.int.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.int.config.ts @@ -3,6 +3,7 @@ import { defineConfig, mergeConfig } from "vitest/config"; import viteConfig from "../../../vitest.shared.config.ts"; +import "dotenv/config"; export default mergeConfig( viteConfig, From 47001841e5708496fd74db9d4d65330240adf6e5 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 12:10:33 -0500 Subject: [PATCH 43/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- sdk/cosmosdb/cosmos/vitest.int.config.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/cosmosdb/cosmos/vitest.int.config.ts b/sdk/cosmosdb/cosmos/vitest.int.config.ts index bcd01c21c31d..2fccec0c42f8 100644 --- a/sdk/cosmosdb/cosmos/vitest.int.config.ts +++ b/sdk/cosmosdb/cosmos/vitest.int.config.ts @@ -12,6 +12,8 @@ export default mergeConfig( outputFile: { junit: "test-results-int.xml", }, + hookTimeout: 500000, + testTimeout: 500000, }, }), ); From fa72ca4f844314f6d99dfa2be5b13033b9a135e6 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 12:31:24 -0500 Subject: [PATCH 44/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- .../functional/item/itemIdEncoding.spec.ts | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts index 59b962db8e4c..6f7a2354e184 100644 --- a/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/functional/item/itemIdEncoding.spec.ts @@ -119,12 +119,12 @@ const executeTestCaseOnComputeGateway = async (scenario: TestScenario): Promise< return executeTestCase(scenario, true); }; -describe("Id encoding", { timeout: 10000 }, () => { - beforeEach(async function () { +describe("Id encoding", { timeout: 100000 }, () => { + beforeEach(async () => { await removeAllDatabases(); }); - it("RGW_plainVanillaId", async function () { + it("RGW_plainVanillaId", async () => { const scenario: TestScenario = { name: "RGW_PlainVanillaId", id: "Test", @@ -137,7 +137,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_plainVanillaId", async function () { + it("CGW_plainVanillaId", async () => { const scenario: TestScenario = { name: "CGW_PlainVanillaId", id: "Test", @@ -150,7 +150,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_ContainerIdWithUnicode鱀", async function () { + it("RGW_ContainerIdWithUnicode鱀", async () => { const scenario: TestScenario = { name: "RGW_ContainerIdWithUnicode鱀", id: "Test", @@ -163,7 +163,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_ContainerIdWithUnicode鱀", async function () { + it("CGW_ContainerIdWithUnicode鱀", async () => { const scenario: TestScenario = { name: "CGW_ContainerIdWithUnicode鱀", id: "Test", @@ -176,7 +176,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithWhitespaces", async function () { + it("RGW_idWithWhitespaces", async () => { const scenario: TestScenario = { name: "RGW_IdWithWhitespaces", id: "This is a test", @@ -189,7 +189,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithWhitespaces", async function () { + it("CGW_idWithWhitespaces", async () => { const scenario: TestScenario = { name: "CGW_IdWithWhitespaces", id: "This is a test", @@ -202,7 +202,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idStartingWithWhitespace", async function () { + it("RGW_idStartingWithWhitespace", async () => { const scenario: TestScenario = { name: "RGW_IdStartingWithWhitespace", id: " Test", @@ -215,7 +215,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idStartingWithWhitespace", async function () { + it("CGW_idStartingWithWhitespace", async () => { const scenario: TestScenario = { name: "CGW_IdStartingWithWhitespace", id: " Test", @@ -228,7 +228,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idStartingWithWhitespaces", async function () { + it("RGW_idStartingWithWhitespaces", async () => { const scenario: TestScenario = { name: "RGW_IdStartingWithWhitespaces", id: " Test", @@ -241,7 +241,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idStartingWithWhitespaces", async function () { + it("CGW_idStartingWithWhitespaces", async () => { const scenario: TestScenario = { name: "CGW_IdStartingWithWhitespaces", id: " Test", @@ -254,7 +254,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idEndingWithWhitespace", async function () { + it("RGW_idEndingWithWhitespace", async () => { const scenario: TestScenario = { name: "RGW_IdEndingWithWhitespace", id: "Test ", @@ -267,7 +267,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idEndingWithWhitespace", async function () { + it("CGW_idEndingWithWhitespace", async () => { const scenario: TestScenario = { name: "CGW_IdEndingWithWhitespace", id: "Test ", @@ -280,7 +280,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idEndingWithWhitespaces", async function () { + it("RGW_idEndingWithWhitespaces", async () => { const scenario: TestScenario = { name: "RGW_IdEndingWithWhitespaces", id: "Test ", @@ -293,7 +293,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idEndingWithWhitespaces", async function () { + it("CGW_idEndingWithWhitespaces", async () => { const scenario: TestScenario = { name: "CGW_IdEndingWithWhitespaces", id: "Test ", @@ -306,7 +306,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithUnicodeCharacters", async function () { + it("RGW_idWithUnicodeCharacters", async () => { const scenario: TestScenario = { name: "RGW_IdWithUnicodeCharacters", id: "WithUnicode鱀", @@ -319,7 +319,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithUnicodeCharacters", async function () { + it("CGW_idWithUnicodeCharacters", async () => { const scenario: TestScenario = { name: "CGW_IdWithUnicodeCharacters", id: "WithUnicode鱀", @@ -332,7 +332,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithAllowedSpecialCharacters", async function () { + it("RGW_idWithAllowedSpecialCharacters", async () => { const scenario: TestScenario = { name: "RGW_IdWithAllowedSpecialCharacters", id: "WithAllowedSpecial,=.:~+-@()^${}[]!_Chars", @@ -345,7 +345,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithAllowedSpecialCharacters", async function () { + it("CGW_idWithAllowedSpecialCharacters", async () => { const scenario: TestScenario = { name: "CGW_IdWithAllowedSpecialCharacters", id: "WithAllowedSpecial,=.:~+-@()^${}[]!_Chars", @@ -358,7 +358,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithBase64EncodedIdCharacters", async function () { + it("RGW_idWithBase64EncodedIdCharacters", async () => { const base64EncodedId = "BQE1D3PdG4N4bzU9TKaCIM3qc0TVcZ2/Y3jnsRfwdHC1ombkX3F1dot/SG0/UTq9AbgdX3" + "kOWoP6qL6lJqWeKgV3zwWWPZO/t5X0ehJzv9LGkWld07LID2rhWhGT6huBM6Q="; @@ -376,7 +376,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithBase64EncodedIdCharacters", async function () { + it("CGW_idWithBase64EncodedIdCharacters", async () => { const base64EncodedId = "BQE1D3PdG4N4bzU9TKaCIM3qc0TVcZ2/Y3jnsRfwdHC1ombkX3F1dot/SG0/UTq9AbgdX3" + "kOWoP6qL6lJqWeKgV3zwWWPZO/t5X0ehJzv9LGkWld07LID2rhWhGT6huBM6Q="; @@ -394,7 +394,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idEndingWithPercentEncodedWhitespace", async function () { + it("RGW_idEndingWithPercentEncodedWhitespace", async () => { const scenario: TestScenario = { name: "RGW_IdEndingWithPercentEncodedWhitespace", id: "IdEndingWithPercentEncodedWhitespace%20", @@ -407,7 +407,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idEndingWithPercentEncodedWhitespace", async function () { + it("CGW_idEndingWithPercentEncodedWhitespace", async () => { const scenario: TestScenario = { name: "CGW_IdEndingWithPercentEncodedWhitespace", id: "IdEndingWithPercentEncodedWhitespace%20", @@ -420,7 +420,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithPercentEncodedSpecialChar", async function () { + it("RGW_idWithPercentEncodedSpecialChar", async () => { const scenario: TestScenario = { name: "RGW_IdWithPercentEncodedSpecialChar", id: "WithPercentEncodedSpecialChar%E9%B1%80", @@ -433,7 +433,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithPercentEncodedSpecialChar", async function () { + it("CGW_idWithPercentEncodedSpecialChar", async () => { const scenario: TestScenario = { name: "CGW_IdWithPercentEncodedSpecialChar", id: "WithPercentEncodedSpecialChar%E9%B1%80", @@ -446,7 +446,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithDisallowedCharQuestionMark", async function () { + it("RGW_idWithDisallowedCharQuestionMark", async () => { const scenario: TestScenario = { name: "RGW_IdWithDisallowedCharQuestionMark", id: "Disallowed?Chars", @@ -459,7 +459,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithDisallowedCharQuestionMark", async function () { + it("CGW_idWithDisallowedCharQuestionMark", async () => { const scenario: TestScenario = { name: "CGW_IdWithDisallowedCharQuestionMark", id: "Disallowed?Chars", @@ -472,7 +472,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithDisallowedCharForwardSlash", async function () { + it("RGW_idWithDisallowedCharForwardSlash", async () => { const scenario: TestScenario = { name: "RGW_IdWithDisallowedCharForwardSlash", id: "Disallowed/Chars", @@ -483,7 +483,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithDisallowedCharForwardSlash", async function () { + it("CGW_idWithDisallowedCharForwardSlash", async () => { const scenario: TestScenario = { name: "CGW_IdWithDisallowedCharForwardSlash", id: "Disallowed/Chars", @@ -494,7 +494,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithDisallowedCharBackSlash", async function () { + it("RGW_idWithDisallowedCharBackSlash", async () => { const scenario: TestScenario = { name: "RGW_IdWithDisallowedCharBackSlash", id: "Disallowed\\Chars", @@ -505,7 +505,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithDisallowedCharBackSlash", async function () { + it("CGW_idWithDisallowedCharBackSlash", async () => { const scenario: TestScenario = { name: "CGW_IdWithDisallowedCharBackSlash", id: "Disallowed\\Chars", @@ -516,7 +516,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithDisallowedCharPoundSign", async function () { + it("RGW_idWithDisallowedCharPoundSign", async () => { const scenario: TestScenario = { name: "RGW_IdWithDisallowedCharPoundSign", id: "Disallowed#Chars", @@ -527,7 +527,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithDisallowedCharPoundSign", async function () { + it("CGW_idWithDisallowedCharPoundSign", async () => { const scenario: TestScenario = { name: "CGW_IdWithDisallowedCharPoundSign", id: "Disallowed#Chars", @@ -538,7 +538,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithCarriageReturn", async function () { + it("RGW_idWithCarriageReturn", async () => { const scenario: TestScenario = { name: "RGW_IdWithCarriageReturn", id: "With\rCarriageReturn", @@ -551,7 +551,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithCarriageReturn", async function () { + it("CGW_idWithCarriageReturn", async () => { const scenario: TestScenario = { name: "CGW_IdWithCarriageReturn", id: "With\rCarriageReturn", @@ -564,7 +564,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithTab", async function () { + it("RGW_idWithTab", async () => { const scenario: TestScenario = { name: "RGW_IdWithTab", id: "With\tTab", @@ -577,7 +577,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithTab", async function () { + it("CGW_idWithTab", async () => { const scenario: TestScenario = { name: "CGW_IdWithTab", id: "With\tTab", @@ -590,7 +590,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCaseOnComputeGateway(scenario); }); - it("RGW_idWithLineFeed", async function () { + it("RGW_idWithLineFeed", async () => { const scenario: TestScenario = { name: "RGW_IdWithLineFeed", id: "With\nLineFeed", @@ -603,7 +603,7 @@ describe("Id encoding", { timeout: 10000 }, () => { await executeTestCase(scenario); }); - it("CGW_idWithLineFeed", async function () { + it("CGW_idWithLineFeed", async () => { const scenario: TestScenario = { name: "CGW_IdWithLineFeed", id: "With\nLineFeed", From 4a46ca5c1f48f95c156c7c494ced9299827497c5 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Tue, 7 Jan 2025 12:41:22 -0500 Subject: [PATCH 45/45] [cosmos] Migrate @azure/cosmos to ESM/vitest --- .../cosmos/test/public/integration/client.spec.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts b/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts index 0b8899c6b66a..9d0e8e422c29 100644 --- a/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts +++ b/sdk/cosmosdb/cosmos/test/public/integration/client.spec.ts @@ -80,10 +80,12 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as afterEach(() => { vi.restoreAllMocks(); }); + describe("Client Test With AAD Credentials", () => { let client: CosmosClient; beforeEach(() => { + setupMockResponse(); client = new CosmosClient({ endpoint: mockedEndpoint, aadCredentials: new MockCredential( @@ -99,7 +101,6 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as }); it("Test pipeline setup for items.create for aadCredentials", async () => { - setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); await container.items.create(item1Definition); @@ -109,7 +110,6 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as }); it("Test pipeline setup for items.read for aadCredentials", async () => { - setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); await container.items.create(item1Definition); setupSpyOnRequestHandler(); @@ -121,7 +121,6 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as }); it("Test pipeline setup for items.patch", async () => { - setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); await container.items.create(item1Definition); setupSpyOnRequestHandler(); @@ -133,7 +132,6 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as }); it("Test pipeline setup for items.replace", async () => { - setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); await container @@ -145,7 +143,6 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as }); it("Test pipeline setup for items.upsert", async () => { - setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler(); await container.items.upsert(testDataset.itemGetResponse); @@ -155,7 +152,6 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as }); it("Test pipeline setup for items.delete", async () => { - setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); await container.items.create(item1Definition); setupSpyOnRequestHandler(); @@ -166,7 +162,6 @@ describe("Testing Credentials integration for Client", { skip: !isNodeLike }, as }); it("Test pipeline setup for items.batch", async () => { - setupMockResponse(); const container: Container = await getTestContainer("Test Container", client); setupSpyOnRequestHandler();