mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-29 06:34:10 +00:00
dependabot part 1
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import crypto from "crypto";
|
||||
|
||||
import { CosmosDBManagementClient } from "@azure/arm-cosmosdb";
|
||||
import { BulkOperationType, Container, CosmosClient, CosmosClientOptions, Database, JSONObject } from "@azure/cosmos";
|
||||
import { AzureIdentityCredentialAdapter } from "@azure/ms-rest-js";
|
||||
|
||||
import { Buffer } from "node:buffer";
|
||||
import { webcrypto } from "node:crypto";
|
||||
import {
|
||||
generateUniqueName,
|
||||
getAccountName,
|
||||
@@ -12,6 +10,7 @@ import {
|
||||
subscriptionId,
|
||||
TestAccount,
|
||||
} from "./fx";
|
||||
globalThis.crypto = webcrypto as Crypto;
|
||||
|
||||
export interface TestItem {
|
||||
id: string;
|
||||
@@ -60,8 +59,9 @@ function createTestItems(): TestItem[] {
|
||||
|
||||
// Document IDs cannot contain '/', '\', or '#'
|
||||
function createSafeRandomString(byteLength: number): string {
|
||||
return crypto
|
||||
.randomBytes(byteLength)
|
||||
const bytes = new Uint8Array(byteLength);
|
||||
crypto.getRandomValues(bytes);
|
||||
return Buffer.from(bytes)
|
||||
.toString("base64")
|
||||
.replace(/[/\\#]/g, "_");
|
||||
}
|
||||
@@ -104,8 +104,7 @@ async function createCosmosClientForSQLAccount(
|
||||
accountType: TestAccount.SQL | TestAccount.SQLContainerCopyOnly = TestAccount.SQL,
|
||||
): Promise<{ armClient: CosmosDBManagementClient; client: CosmosClient }> {
|
||||
const credentials = getAzureCLICredentials();
|
||||
const adaptedCredentials = new AzureIdentityCredentialAdapter(credentials);
|
||||
const armClient = new CosmosDBManagementClient(adaptedCredentials, subscriptionId);
|
||||
const armClient = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||
const accountName = getAccountName(accountType);
|
||||
const account = await armClient.databaseAccounts.get(resourceGroupName, accountName);
|
||||
|
||||
@@ -232,7 +231,7 @@ export async function createTestSQLContainer({
|
||||
}
|
||||
|
||||
export const setPartitionKeys = (partitionKeys: PartitionKey[]) => {
|
||||
const result = {};
|
||||
const result: Record<string, unknown> = {};
|
||||
|
||||
partitionKeys.forEach((partitionKey) => {
|
||||
const { key: keyPath, value: keyValue } = partitionKey;
|
||||
@@ -245,7 +244,7 @@ export const setPartitionKeys = (partitionKeys: PartitionKey[]) => {
|
||||
current[key] = keyValue;
|
||||
} else {
|
||||
current[key] = current[key] || {};
|
||||
current = current[key];
|
||||
current = current[key] as Record<string, unknown>;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user