[communication] Migrate @azure-tools/communication-tiering to ESM/vitest (#31719)

### Packages impacted by this PR

- @azure-tools/communication-tiering

### Issues associated with this PR

- https://github.com/Azure/azure-sdk-for-js/issues/31338

### Describe the problem that is addressed by this PR

Moves the package to ESM/vitest

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
This commit is contained in:
Matthew Podwysocki 2024-11-12 12:11:15 -05:00 коммит произвёл GitHub
Родитель 53189ded1c
Коммит e316d19cac
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
25 изменённых файлов: 192 добавлений и 253 удалений

Просмотреть файл

@ -19100,7 +19100,7 @@ packages:
dev: false dev: false
file:projects/communication-tiering.tgz: file:projects/communication-tiering.tgz:
resolution: {integrity: sha512-nDoqnFBea7fbl3xKZpetYRo4tdp0rw5rDRLrhjprDsgSrCOBoKrioCzzIWQ8Jr9VJ8bRHvhvc7m56jihYGDe7g==, tarball: file:projects/communication-tiering.tgz} resolution: {integrity: sha512-rz1BR/nFh76ye4xr8Y7ma9rk7L5MdY/OvQzCHdccWUqJtna7thL+3dBEzfugUV3+3x25rHJ6QTwpj6VFz8P6Pg==, tarball: file:projects/communication-tiering.tgz}
name: '@rush-temp/communication-tiering' name: '@rush-temp/communication-tiering'
version: 0.0.0 version: 0.0.0
dependencies: dependencies:
@ -19111,6 +19111,8 @@ packages:
'@types/node': 18.19.64 '@types/node': 18.19.64
'@types/sinon': 17.0.3 '@types/sinon': 17.0.3
'@types/uuid': 8.3.4 '@types/uuid': 8.3.4
'@vitest/browser': 2.1.4(@types/node@18.19.64)(playwright@1.48.2)(typescript@5.6.3)(vitest@2.1.4)
'@vitest/coverage-istanbul': 2.1.4(vitest@2.1.4)
chai: 4.3.10 chai: 4.3.10
dotenv: 16.4.5 dotenv: 16.4.5
eslint: 9.14.0 eslint: 9.14.0
@ -19127,19 +19129,33 @@ packages:
karma-sourcemap-loader: 0.3.8 karma-sourcemap-loader: 0.3.8
mocha: 10.8.2 mocha: 10.8.2
nyc: 17.1.0 nyc: 17.1.0
playwright: 1.48.2
sinon: 17.0.1 sinon: 17.0.1
ts-node: 10.9.2(@types/node@18.19.64)(typescript@5.6.3) ts-node: 10.9.2(@types/node@18.19.64)(typescript@5.6.3)
tslib: 2.8.1 tslib: 2.8.1
typescript: 5.6.3 typescript: 5.6.3
uuid: 8.3.2 uuid: 8.3.2
vitest: 2.1.4(@types/node@18.19.64)(@vitest/browser@2.1.4)
transitivePeerDependencies: transitivePeerDependencies:
- '@swc/core' - '@edge-runtime/vm'
- '@swc/wasm' - '@vitest/ui'
- bufferutil - bufferutil
- debug - happy-dom
- jiti - jiti
- jsdom
- less
- lightningcss
- msw
- safaridriver
- sass
- sass-embedded
- stylus
- sugarss
- supports-color - supports-color
- terser
- utf-8-validate - utf-8-validate
- vite
- webdriverio
dev: false dev: false
file:projects/communication-toll-free-verification.tgz: file:projects/communication-toll-free-verification.tgz:

Просмотреть файл

@ -1,10 +0,0 @@
{
"include": ["dist-esm/src/**/*.js"],
"exclude": ["**/*.d.ts", "dist-esm/src/generated/*"],
"reporter": ["text-summary", "html", "cobertura"],
"exclude-after-remap": false,
"sourceMap": true,
"produce-source-map": true,
"instrument": true,
"all": true
}

Просмотреть файл

@ -1,6 +1,6 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts", "mainEntryPointFilePath": "dist/esm/index.d.ts",
"docModel": { "docModel": {
"enabled": true "enabled": true
}, },
@ -11,7 +11,7 @@
"dtsRollup": { "dtsRollup": {
"enabled": true, "enabled": true,
"untrimmedFilePath": "", "untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/communication-tiering.d.ts" "publicTrimmedFilePath": "dist/communication-tiering.d.ts"
}, },
"messages": { "messages": {
"tsdocMessageReporting": { "tsdocMessageReporting": {

Просмотреть файл

@ -1,129 +0,0 @@
// https://github.com/karma-runner/karma-chrome-launcher
process.env.CHROME_BIN = require("puppeteer").executablePath();
require("dotenv").config();
const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: "./",
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ["mocha"],
plugins: [
"karma-mocha",
"karma-mocha-reporter",
"karma-chrome-launcher",
"karma-firefox-launcher",
"karma-env-preprocessor",
"karma-coverage",
"karma-sourcemap-loader",
"karma-junit-reporter",
],
// list of files / patterns to load in the browser
files: ["dist-test/index.browser.js"],
// list of files / patterns to exclude
exclude: [],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"**/*.js": ["sourcemap", "env"],
// IMPORTANT: COMMENT following line if you want to debug in your browsers!!
// Preprocess source file to calculate code coverage, however this will make source file unreadable
//"dist-test/index.browser.js": ["coverage"]
},
// inject following environment values into browser testing with window.__env__
// environment values MUST be exported or set with same console running "karma start"
// https://www.npmjs.com/package/karma-env-preprocessor
envPreprocessor: [
"TEST_MODE",
"COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING",
"INCLUDE_PHONENUMBER_LIVE_TESTS",
"AZURE_PHONE_NUMBER",
"COMMUNICATION_ENDPOINT",
"AZURE_CLIENT_ID",
"AZURE_CLIENT_SECRET",
"AZURE_TENANT_ID",
"COMMUNICATION_SKIP_INT_PHONENUMBERS_TESTS",
"RECORDINGS_RELATIVE_PATH",
],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ["mocha", "coverage", "junit"],
coverageReporter: {
// specify a common output directory
dir: "coverage-browser/",
reporters: [
{ type: "json", subdir: ".", file: "coverage.json" },
{ type: "lcovonly", subdir: ".", file: "lcov.info" },
{ type: "html", subdir: "html" },
{ type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
],
},
junitReporter: {
outputDir: "", // results will be saved as $outputDir/$browserName.xml
outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
suite: "", // suite will become the package name attribute in xml testsuite element
useBrowserName: false, // add browser name to report and classes names
nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
properties: {}, // key value pair of properties to add to the <properties> section of the report
},
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
// 'ChromeHeadless', 'Chrome', 'Firefox', 'Edge', 'IE'
browsers: ["HeadlessChrome"],
customLaunchers: {
HeadlessChrome: {
base: "ChromeHeadless",
flags: ["--no-sandbox", "--disable-web-security"],
},
},
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: true,
// Concurrency level
// how many browser should be started simultaneous
concurrency: 1,
browserNoActivityTimeout: 600000,
browserDisconnectTimeout: 10000,
browserDisconnectTolerance: 3,
client: {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: "html",
timeout: "600000",
},
},
});
};

Просмотреть файл

@ -3,25 +3,25 @@
"version": "1.0.0-beta.1", "version": "1.0.0-beta.1",
"description": "Test", "description": "Test",
"sdk-type": "client", "sdk-type": "client",
"main": "dist/index.js", "main": "./dist/commonjs/index.js",
"module": "dist-esm/src/index.js", "module": "./dist/esm/index.js",
"types": "types/communication-tiering.d.ts", "types": "./dist/commonjs/index.d.ts",
"scripts": { "scripts": {
"build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run extract-api", "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
"build:autorest": "autorest --typescript ./swagger/README.md && rushx format", "build:autorest": "autorest --typescript ./swagger/README.md && rushx format",
"build:browser": "tsc -p . && dev-tool run bundle", "build:browser": "dev-tool run build-package && dev-tool run bundle",
"build:clean": "rush update --recheck && rush rebuild && npm run build", "build:clean": "rush update --recheck && rush rebuild && npm run build",
"build:node": "tsc -p . && dev-tool run bundle", "build:node": "dev-tool run build-package && dev-tool run bundle",
"build:samples": "dev-tool samples publish --force", "build:samples": "dev-tool samples publish --force",
"build:test": "tsc -p . && dev-tool run bundle", "build:test": "dev-tool run build-package && dev-tool run bundle",
"check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"clean": "dev-tool run vendored rimraf --glob dist dist-* types *.tgz *.log", "clean": "dev-tool run vendored rimraf --glob dist dist-* types *.tgz *.log",
"execute:samples": "dev-tool samples run samples-dev", "execute:samples": "dev-tool samples run samples-dev",
"extract-api": "tsc -p . && dev-tool run extract-api", "extract-api": "dev-tool run build-package && dev-tool run extract-api",
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test": "npm run integration-test:node && npm run integration-test:browser",
"integration-test:browser": "dev-tool run test:browser", "integration-test:browser": "dev-tool run test:browser",
"integration-test:node": "dev-tool run test:node-js-input -- --timeout 300000 'dist-esm/test/public/*.spec.js'", "integration-test:node": "dev-tool run test:vitest",
"lint": "eslint package.json api-extractor.json README.md src test", "lint": "eslint package.json api-extractor.json README.md src test",
"lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]", "lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]",
"pack": "npm pack 2>&1", "pack": "npm pack 2>&1",
@ -30,14 +30,12 @@
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node", "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
"test:watch": "npm run test -- --watch --reporter min", "test:watch": "npm run test -- --watch --reporter min",
"unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test": "npm run unit-test:node && npm run unit-test:browser",
"unit-test:browser": "dev-tool run 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:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'", "unit-test:node": "dev-tool run test:vitest",
"update-snippets": "echo skipped" "update-snippets": "echo skipped"
}, },
"files": [ "files": [
"dist/", "dist/",
"dist-esm/src/",
"types/communication-tiering.d.ts",
"README.md", "README.md",
"LICENSE" "LICENSE"
], ],
@ -73,35 +71,22 @@
"uuid": "^8.3.2" "uuid": "^8.3.2"
}, },
"devDependencies": { "devDependencies": {
"@azure-tools/test-recorder": "^3.0.0", "@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils": "^1.0.1", "@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/core-util": "^1.9.0", "@azure/core-util": "^1.9.0",
"@azure/dev-tool": "^1.0.0", "@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/identity": "^4.0.1", "@azure/identity": "^4.0.1",
"@types/chai": "^4.1.6",
"@types/mocha": "^10.0.0",
"@types/node": "^18.0.0", "@types/node": "^18.0.0",
"@types/sinon": "^17.0.0",
"@types/uuid": "^8.3.2", "@types/uuid": "^8.3.2",
"chai": "^4.2.0", "@vitest/browser": "^2.1.4",
"@vitest/coverage-istanbul": "^2.1.4",
"dotenv": "^16.0.0", "dotenv": "^16.0.0",
"eslint": "^9.9.0", "eslint": "^9.9.0",
"inherits": "^2.0.3", "inherits": "^2.0.3",
"karma": "^6.2.0", "playwright": "^1.48.2",
"karma-chrome-launcher": "^3.0.0", "typescript": "~5.6.2",
"karma-coverage": "^2.0.0", "vitest": "^2.1.4"
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^10.0.0",
"nyc": "^17.0.0",
"sinon": "^17.0.0",
"ts-node": "^10.0.0",
"typescript": "~5.6.2"
}, },
"//metadata": { "//metadata": {
"constantPaths": [ "constantPaths": [
@ -132,5 +117,43 @@
"requiredResources": { "requiredResources": {
"Azure Communication Services account": "https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource" "Azure Communication Services account": "https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource"
} }
},
"type": "module",
"tshy": {
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
},
"dialects": [
"esm",
"commonjs"
],
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
},
"browser": "./dist/browser/index.js",
"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"
}
}
} }
} }

Просмотреть файл

@ -6,6 +6,6 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated. * Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/ */
export * from "./models"; export * from "./models/index.js";
export { TieringClient } from "./tieringClient"; export { TieringClient } from "./tieringClient.js";
export * from "./operationsInterfaces"; export * from "./operationsInterfaces/index.js";

Просмотреть файл

@ -6,5 +6,5 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated. * Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/ */
export * from "./numberAllotment"; export * from "./numberAllotment.js";
export * from "./tiering"; export * from "./tiering.js";

Просмотреть файл

@ -6,16 +6,16 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated. * Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/ */
import { tracingClient } from "../tracing"; import { tracingClient } from "../tracing.js";
import { NumberAllotment } from "../operationsInterfaces"; import { NumberAllotment } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client"; import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers"; import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters"; import * as Parameters from "../models/parameters.js";
import { TieringClient } from "../tieringClient"; import { TieringClient } from "../tieringClient.js";
import { import {
NumberAllotmentGetAcquiredNumberLimitsOptionalParams, NumberAllotmentGetAcquiredNumberLimitsOptionalParams,
NumberAllotmentGetAcquiredNumberLimitsResponse NumberAllotmentGetAcquiredNumberLimitsResponse
} from "../models"; } from "../models/index.js";
/** Class containing NumberAllotment operations. */ /** Class containing NumberAllotment operations. */
export class NumberAllotmentImpl implements NumberAllotment { export class NumberAllotmentImpl implements NumberAllotment {

Просмотреть файл

@ -6,16 +6,16 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated. * Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/ */
import { tracingClient } from "../tracing"; import { tracingClient } from "../tracing.js";
import { Tiering } from "../operationsInterfaces"; import { Tiering } from "../operationsInterfaces/index.js";
import * as coreClient from "@azure/core-client"; import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers"; import * as Mappers from "../models/mappers.js";
import * as Parameters from "../models/parameters"; import * as Parameters from "../models/parameters.js";
import { TieringClient } from "../tieringClient"; import { TieringClient } from "../tieringClient.js";
import { import {
TieringGetByResourceIdOptionalParams, TieringGetByResourceIdOptionalParams,
TieringGetByResourceIdResponse TieringGetByResourceIdResponse
} from "../models"; } from "../models/index.js";
/** Class containing Tiering operations. */ /** Class containing Tiering operations. */
export class TieringImpl implements Tiering { export class TieringImpl implements Tiering {

Просмотреть файл

@ -6,5 +6,5 @@
* Changes may cause incorrect behavior and will be lost if the code is regenerated. * Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/ */
export * from "./numberAllotment"; export * from "./numberAllotment.js";
export * from "./tiering"; export * from "./tiering.js";

Просмотреть файл

@ -9,7 +9,7 @@
import { import {
NumberAllotmentGetAcquiredNumberLimitsOptionalParams, NumberAllotmentGetAcquiredNumberLimitsOptionalParams,
NumberAllotmentGetAcquiredNumberLimitsResponse NumberAllotmentGetAcquiredNumberLimitsResponse
} from "../models"; } from "../models/index.js";
/** Interface representing a NumberAllotment. */ /** Interface representing a NumberAllotment. */
export interface NumberAllotment { export interface NumberAllotment {

Просмотреть файл

@ -9,7 +9,7 @@
import { import {
TieringGetByResourceIdOptionalParams, TieringGetByResourceIdOptionalParams,
TieringGetByResourceIdResponse TieringGetByResourceIdResponse
} from "../models"; } from "../models/index.js";
/** Interface representing a Tiering. */ /** Interface representing a Tiering. */
export interface Tiering { export interface Tiering {

Просмотреть файл

@ -12,9 +12,9 @@ import {
PipelineResponse, PipelineResponse,
SendRequest SendRequest
} from "@azure/core-rest-pipeline"; } from "@azure/core-rest-pipeline";
import { NumberAllotmentImpl, TieringImpl } from "./operations"; import { NumberAllotmentImpl, TieringImpl } from "./operations/index.js";
import { NumberAllotment, Tiering } from "./operationsInterfaces"; import { NumberAllotment, Tiering } from "./operationsInterfaces/index.js";
import { TieringClientOptionalParams } from "./models"; import { TieringClientOptionalParams } from "./models/index.js";
export class TieringClient extends coreClient.ServiceClient { export class TieringClient extends coreClient.ServiceClient {
endpoint: string; endpoint: string;

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
export * from "./models"; export * from "./models.js";
export * from "./tieringClient"; export * from "./tieringClient.js";

Просмотреть файл

@ -25,4 +25,4 @@ export {
TrialPhoneNumberUsageSmsBounds, TrialPhoneNumberUsageSmsBounds,
TrialPhoneNumberUsageCallingBounds, TrialPhoneNumberUsageCallingBounds,
Paths190FnhrAdministrationResourcesResourceidTelephoneNumberSummaryGetResponses200ContentApplicationJsonSchema as AssetDetailsModel, Paths190FnhrAdministrationResourcesResourceidTelephoneNumberSummaryGetResponses200ContentApplicationJsonSchema as AssetDetailsModel,
} from "./generated/src/models"; } from "./generated/src/models/index.js";

Просмотреть файл

@ -7,15 +7,15 @@ import type {
TieringGetByResourceIdOptionalParams, TieringGetByResourceIdOptionalParams,
AcsTier, AcsTier,
AssetDetailsModel, AssetDetailsModel,
} from "./models"; } from "./models.js";
import type { CommonClientOptions, InternalClientPipelineOptions } from "@azure/core-client"; import type { CommonClientOptions, InternalClientPipelineOptions } from "@azure/core-client";
import type { KeyCredential, TokenCredential } from "@azure/core-auth"; import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import { isTokenCredential } from "@azure/core-auth"; import { isTokenCredential } from "@azure/core-auth";
import { createCommunicationAuthPolicy } from "@azure/communication-common"; import { createCommunicationAuthPolicy } from "@azure/communication-common";
import { isKeyCredential, parseClientArguments } from "@azure/communication-common"; import { isKeyCredential, parseClientArguments } from "@azure/communication-common";
import { TieringClient as TieringGeneratedClient } from "./generated/src"; import { TieringClient as TieringGeneratedClient } from "./generated/src/index.js";
import { logger } from "./utils"; import { logger } from "./utils/index.js";
import { tracingClient } from "./generated/src/tracing"; import { tracingClient } from "./generated/src/tracing.js";
/** /**
* Client options used to configure the TieringGeneratedClient API requests. * Client options used to configure the TieringGeneratedClient API requests.

Просмотреть файл

@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
export * from "./logger"; export * from "./logger.js";
export * from "./constants"; export * from "./constants.js";

Просмотреть файл

@ -2,32 +2,31 @@
// Licensed under the MIT License. // Licensed under the MIT License.
import { AzureKeyCredential } from "@azure/core-auth"; import { AzureKeyCredential } from "@azure/core-auth";
import type { Context } from "mocha"; import { TieringClient } from "../../src/index.js";
import { TieringClient } from "../../src"; import { createMockToken } from "./utils/recordedClient.js";
import { assert } from "chai"; import { describe, it, assert } from "vitest";
import { createMockToken } from "./utils/recordedClient";
describe("RecipientVerificationClient - constructor", function () { describe("RecipientVerificationClient - constructor", () => {
const endpoint = "https://contoso.spool.azure.local"; const endpoint = "https://contoso.spool.azure.local";
const accessKey = "banana"; const accessKey = "banana";
it("successfully instantiates with valid connection string", function () { it("successfully instantiates with valid connection string", () => {
const client = new TieringClient(`endpoint=${endpoint};accesskey=${accessKey}`); const client = new TieringClient(`endpoint=${endpoint};accesskey=${accessKey}`);
assert.instanceOf(client, TieringClient); assert.instanceOf(client, TieringClient);
}); });
it("throws with invalid connection string", function () { it("throws with invalid connection string", () => {
assert.throws(() => { assert.throws(() => {
new TieringClient(`endpoints=${endpoint};accesskey=${accessKey}`); new TieringClient(`endpoints=${endpoint};accesskey=${accessKey}`);
}); });
}); });
it("successfully instantiates with with endpoint and access key", function () { it("successfully instantiates with with endpoint and access key", () => {
const client = new TieringClient(endpoint, new AzureKeyCredential(accessKey)); const client = new TieringClient(endpoint, new AzureKeyCredential(accessKey));
assert.instanceOf(client, TieringClient); assert.instanceOf(client, TieringClient);
}); });
it("successfully instantiates with with endpoint and managed identity", function (this: Context) { it("successfully instantiates with with endpoint and managed identity", () => {
const client = new TieringClient(endpoint, createMockToken()); const client = new TieringClient(endpoint, createMockToken());
assert.instanceOf(client, TieringClient); assert.instanceOf(client, TieringClient);
}); });

Просмотреть файл

@ -1,31 +1,30 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import type { Context } from "mocha";
import type { Recorder } from "@azure-tools/test-recorder"; import type { Recorder } from "@azure-tools/test-recorder";
import { env } from "@azure-tools/test-recorder"; import { env } from "@azure-tools/test-recorder";
import type { TieringClient } from "../../src"; import type { TieringClient } from "../../src/index.js";
import { assert } from "chai"; import { createRecordedClient } from "./utils/recordedClient.js";
import { createRecordedClient } from "./utils/recordedClient"; import { describe, it, assert, beforeEach, afterEach } from "vitest";
describe(`TieringClient - Get Acquired Number Limits`, function () { describe(`TieringClient - Get Acquired Number Limits`, () => {
let recorder: Recorder; let recorder: Recorder;
let client: TieringClient; let client: TieringClient;
beforeEach(async function (this: Context) { beforeEach(async function (ctx) {
({ client, recorder } = await createRecordedClient(this)); ({ client, recorder } = await createRecordedClient(ctx));
}); });
afterEach(async function (this: Context) { afterEach(async function (ctx) {
if (!this.currentTest?.isPending()) { if (!ctx.task.pending) {
await recorder.stop(); await recorder.stop();
} }
}); });
it("get acquired number limits", async function () { it("get acquired number limits", { timeout: 30000 }, async () => {
// print all acquire number limits // print all acquire number limits
const resourceId = env.RESOURCE_ID!; const resourceId = env.RESOURCE_ID!;
const acquiredNumberLimits = await client.getAcquiredNumberLimits(resourceId); const acquiredNumberLimits = await client.getAcquiredNumberLimits(resourceId);
assert.isNotNull(acquiredNumberLimits); assert.isNotNull(acquiredNumberLimits);
}).timeout(30000); });
}); });

Просмотреть файл

@ -1,31 +1,30 @@
// Copyright (c) Microsoft Corporation. // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License. // Licensed under the MIT License.
import type { Context } from "mocha";
import type { Recorder } from "@azure-tools/test-recorder"; import type { Recorder } from "@azure-tools/test-recorder";
import { env } from "@azure-tools/test-recorder"; import { env } from "@azure-tools/test-recorder";
import type { TieringClient } from "../../src"; import type { TieringClient } from "../../src/index.js";
import { assert } from "chai"; import { createRecordedClient } from "./utils/recordedClient.js";
import { createRecordedClient } from "./utils/recordedClient"; import { describe, it, assert, beforeEach, afterEach } from "vitest";
describe(`TieringClient - Get Tier Info`, function () { describe(`TieringClient - Get Tier Info`, () => {
let recorder: Recorder; let recorder: Recorder;
let client: TieringClient; let client: TieringClient;
beforeEach(async function (this: Context) { beforeEach(async function (ctx) {
({ client, recorder } = await createRecordedClient(this)); ({ client, recorder } = await createRecordedClient(ctx));
}); });
afterEach(async function (this: Context) { afterEach(async function (ctx) {
if (!this.currentTest?.isPending()) { if (!ctx.task.pending) {
await recorder.stop(); await recorder.stop();
} }
}); });
it("get tier info", async function () { it("get tier info", { timeout: 30000 }, async () => {
// print all tier info // print all tier info
const resourceId = env.RESOURCE_ID!; const resourceId = env.RESOURCE_ID!;
const tierInfo = await client.getTierByResourceId(resourceId); const tierInfo = await client.getTierByResourceId(resourceId);
assert.isNotNull(tierInfo); assert.isNotNull(tierInfo);
}).timeout(30000); });
}); });

Просмотреть файл

@ -4,15 +4,14 @@ import * as dotenv from "dotenv";
import type { TokenCredential } from "@azure/identity"; import type { TokenCredential } from "@azure/identity";
import { ClientSecretCredential, DefaultAzureCredential } from "@azure/identity"; import { ClientSecretCredential, DefaultAzureCredential } from "@azure/identity";
import type { RecorderStartOptions } from "@azure-tools/test-recorder"; import type { RecorderStartOptions, TestInfo } from "@azure-tools/test-recorder";
import { import {
Recorder, Recorder,
assertEnvironmentVariable, assertEnvironmentVariable,
env, env,
isPlaybackMode, isPlaybackMode,
} from "@azure-tools/test-recorder"; } from "@azure-tools/test-recorder";
import type { Context } from "mocha"; import { TieringClient } from "../../../src/index.js";
import { TieringClient } from "../../../src";
import { isNodeLike } from "@azure/core-util"; import { isNodeLike } from "@azure/core-util";
import { parseConnectionString } from "@azure/communication-common"; import { parseConnectionString } from "@azure/communication-common";
@ -53,9 +52,9 @@ export const recorderOptions: RecorderStartOptions = {
}; };
export async function createRecordedClient( export async function createRecordedClient(
context: Context, context: TestInfo,
): Promise<RecordedClient<TieringClient>> { ): Promise<RecordedClient<TieringClient>> {
const recorder = new Recorder(context.currentTest); const recorder = new Recorder(context);
await recorder.start(recorderOptions); await recorder.start(recorderOptions);
await recorder.setMatcher("CustomDefaultMatcher", { await recorder.setMatcher("CustomDefaultMatcher", {
excludedHeaders: [ excludedHeaders: [
@ -85,9 +84,9 @@ export function createMockToken(): {
} }
export async function createRecordedClientWithToken( export async function createRecordedClientWithToken(
context: Context, context: TestInfo,
): Promise<RecordedClient<TieringClient> | undefined> { ): Promise<RecordedClient<TieringClient> | undefined> {
const recorder = new Recorder(context.currentTest); const recorder = new Recorder(context);
await recorder.start(recorderOptions); await recorder.start(recorderOptions);
let credential: TokenCredential; let credential: TokenCredential;

Просмотреть файл

@ -0,0 +1,10 @@
{
"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
}
}

Просмотреть файл

@ -1,11 +1,12 @@
{ {
"extends": "../../../tsconfig", "extends": "../../../tsconfig",
"compilerOptions": { "compilerOptions": {
"outDir": "./dist-esm",
"declarationDir": "./types",
"paths": { "paths": {
"@azure-tools/communication-tiering": ["./src/index"] "@azure-tools/communication-tiering": ["./src/index"]
}
}, },
"include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] "module": "NodeNext",
"moduleResolution": "NodeNext",
"rootDir": "."
},
"include": ["src/**/*.ts", "src/**/*.mts", "src/**/*.cts", "samples-dev/**/*.ts", "test/**/*.ts"]
} }

Просмотреть файл

@ -0,0 +1,16 @@
// 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"],
hookTimeout: 30000,
testTimeout: 30000,
},
}),
);

Просмотреть файл

@ -0,0 +1,16 @@
// 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"],
hookTimeout: 30000,
testTimeout: 30000,
},
}),
);