[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:
Родитель
53189ded1c
Коммит
e316d19cac
|
@ -19100,7 +19100,7 @@ packages:
|
|||
dev: false
|
||||
|
||||
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'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
@ -19111,6 +19111,8 @@ packages:
|
|||
'@types/node': 18.19.64
|
||||
'@types/sinon': 17.0.3
|
||||
'@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
|
||||
dotenv: 16.4.5
|
||||
eslint: 9.14.0
|
||||
|
@ -19127,19 +19129,33 @@ packages:
|
|||
karma-sourcemap-loader: 0.3.8
|
||||
mocha: 10.8.2
|
||||
nyc: 17.1.0
|
||||
playwright: 1.48.2
|
||||
sinon: 17.0.1
|
||||
ts-node: 10.9.2(@types/node@18.19.64)(typescript@5.6.3)
|
||||
tslib: 2.8.1
|
||||
typescript: 5.6.3
|
||||
uuid: 8.3.2
|
||||
vitest: 2.1.4(@types/node@18.19.64)(@vitest/browser@2.1.4)
|
||||
transitivePeerDependencies:
|
||||
- '@swc/core'
|
||||
- '@swc/wasm'
|
||||
- '@edge-runtime/vm'
|
||||
- '@vitest/ui'
|
||||
- bufferutil
|
||||
- debug
|
||||
- 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/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",
|
||||
"mainEntryPointFilePath": "types/src/index.d.ts",
|
||||
"mainEntryPointFilePath": "dist/esm/index.d.ts",
|
||||
"docModel": {
|
||||
"enabled": true
|
||||
},
|
||||
|
@ -11,7 +11,7 @@
|
|||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"untrimmedFilePath": "",
|
||||
"publicTrimmedFilePath": "./types/communication-tiering.d.ts"
|
||||
"publicTrimmedFilePath": "dist/communication-tiering.d.ts"
|
||||
},
|
||||
"messages": {
|
||||
"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",
|
||||
"description": "Test",
|
||||
"sdk-type": "client",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist-esm/src/index.js",
|
||||
"types": "types/communication-tiering.d.ts",
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"module": "./dist/esm/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"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: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: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: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}\"",
|
||||
"clean": "dev-tool run vendored rimraf --glob dist dist-* types *.tgz *.log",
|
||||
"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}\"",
|
||||
"integration-test": "npm run integration-test:node && npm run integration-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:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]",
|
||||
"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:watch": "npm run test -- --watch --reporter min",
|
||||
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
||||
"unit-test:browser": "dev-tool run test:browser",
|
||||
"unit-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 --exclude 'test/**/browser/*.spec.ts' 'test/**/*.spec.ts'",
|
||||
"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"
|
||||
},
|
||||
"files": [
|
||||
"dist/",
|
||||
"dist-esm/src/",
|
||||
"types/communication-tiering.d.ts",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
|
@ -73,35 +71,22 @@
|
|||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@azure-tools/test-recorder": "^3.0.0",
|
||||
"@azure-tools/test-utils": "^1.0.1",
|
||||
"@azure-tools/test-recorder": "^4.1.0",
|
||||
"@azure-tools/test-utils-vitest": "^1.0.0",
|
||||
"@azure/core-util": "^1.9.0",
|
||||
"@azure/dev-tool": "^1.0.0",
|
||||
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
|
||||
"@azure/identity": "^4.0.1",
|
||||
"@types/chai": "^4.1.6",
|
||||
"@types/mocha": "^10.0.0",
|
||||
"@types/node": "^18.0.0",
|
||||
"@types/sinon": "^17.0.0",
|
||||
"@types/uuid": "^8.3.2",
|
||||
"chai": "^4.2.0",
|
||||
"@vitest/browser": "^2.1.4",
|
||||
"@vitest/coverage-istanbul": "^2.1.4",
|
||||
"dotenv": "^16.0.0",
|
||||
"eslint": "^9.9.0",
|
||||
"inherits": "^2.0.3",
|
||||
"karma": "^6.2.0",
|
||||
"karma-chrome-launcher": "^3.0.0",
|
||||
"karma-coverage": "^2.0.0",
|
||||
"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"
|
||||
"playwright": "^1.48.2",
|
||||
"typescript": "~5.6.2",
|
||||
"vitest": "^2.1.4"
|
||||
},
|
||||
"//metadata": {
|
||||
"constantPaths": [
|
||||
|
@ -132,5 +117,43 @@
|
|||
"requiredResources": {
|
||||
"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.
|
||||
*/
|
||||
|
||||
export * from "./models";
|
||||
export { TieringClient } from "./tieringClient";
|
||||
export * from "./operationsInterfaces";
|
||||
export * from "./models/index.js";
|
||||
export { TieringClient } from "./tieringClient.js";
|
||||
export * from "./operationsInterfaces/index.js";
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./numberAllotment";
|
||||
export * from "./tiering";
|
||||
export * from "./numberAllotment.js";
|
||||
export * from "./tiering.js";
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import { tracingClient } from "../tracing";
|
||||
import { NumberAllotment } from "../operationsInterfaces";
|
||||
import { tracingClient } from "../tracing.js";
|
||||
import { NumberAllotment } from "../operationsInterfaces/index.js";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { TieringClient } from "../tieringClient";
|
||||
import * as Mappers from "../models/mappers.js";
|
||||
import * as Parameters from "../models/parameters.js";
|
||||
import { TieringClient } from "../tieringClient.js";
|
||||
import {
|
||||
NumberAllotmentGetAcquiredNumberLimitsOptionalParams,
|
||||
NumberAllotmentGetAcquiredNumberLimitsResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/** Class containing NumberAllotment operations. */
|
||||
export class NumberAllotmentImpl implements NumberAllotment {
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import { tracingClient } from "../tracing";
|
||||
import { Tiering } from "../operationsInterfaces";
|
||||
import { tracingClient } from "../tracing.js";
|
||||
import { Tiering } from "../operationsInterfaces/index.js";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { TieringClient } from "../tieringClient";
|
||||
import * as Mappers from "../models/mappers.js";
|
||||
import * as Parameters from "../models/parameters.js";
|
||||
import { TieringClient } from "../tieringClient.js";
|
||||
import {
|
||||
TieringGetByResourceIdOptionalParams,
|
||||
TieringGetByResourceIdResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/** Class containing Tiering operations. */
|
||||
export class TieringImpl implements Tiering {
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./numberAllotment";
|
||||
export * from "./tiering";
|
||||
export * from "./numberAllotment.js";
|
||||
export * from "./tiering.js";
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {
|
||||
NumberAllotmentGetAcquiredNumberLimitsOptionalParams,
|
||||
NumberAllotmentGetAcquiredNumberLimitsResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/** Interface representing a NumberAllotment. */
|
||||
export interface NumberAllotment {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {
|
||||
TieringGetByResourceIdOptionalParams,
|
||||
TieringGetByResourceIdResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/** Interface representing a Tiering. */
|
||||
export interface Tiering {
|
||||
|
|
|
@ -12,9 +12,9 @@ import {
|
|||
PipelineResponse,
|
||||
SendRequest
|
||||
} from "@azure/core-rest-pipeline";
|
||||
import { NumberAllotmentImpl, TieringImpl } from "./operations";
|
||||
import { NumberAllotment, Tiering } from "./operationsInterfaces";
|
||||
import { TieringClientOptionalParams } from "./models";
|
||||
import { NumberAllotmentImpl, TieringImpl } from "./operations/index.js";
|
||||
import { NumberAllotment, Tiering } from "./operationsInterfaces/index.js";
|
||||
import { TieringClientOptionalParams } from "./models/index.js";
|
||||
|
||||
export class TieringClient extends coreClient.ServiceClient {
|
||||
endpoint: string;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
export * from "./models";
|
||||
export * from "./tieringClient";
|
||||
export * from "./models.js";
|
||||
export * from "./tieringClient.js";
|
||||
|
|
|
@ -25,4 +25,4 @@ export {
|
|||
TrialPhoneNumberUsageSmsBounds,
|
||||
TrialPhoneNumberUsageCallingBounds,
|
||||
Paths190FnhrAdministrationResourcesResourceidTelephoneNumberSummaryGetResponses200ContentApplicationJsonSchema as AssetDetailsModel,
|
||||
} from "./generated/src/models";
|
||||
} from "./generated/src/models/index.js";
|
||||
|
|
|
@ -7,15 +7,15 @@ import type {
|
|||
TieringGetByResourceIdOptionalParams,
|
||||
AcsTier,
|
||||
AssetDetailsModel,
|
||||
} from "./models";
|
||||
} from "./models.js";
|
||||
import type { CommonClientOptions, InternalClientPipelineOptions } from "@azure/core-client";
|
||||
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
|
||||
import { isTokenCredential } from "@azure/core-auth";
|
||||
import { createCommunicationAuthPolicy } from "@azure/communication-common";
|
||||
import { isKeyCredential, parseClientArguments } from "@azure/communication-common";
|
||||
import { TieringClient as TieringGeneratedClient } from "./generated/src";
|
||||
import { logger } from "./utils";
|
||||
import { tracingClient } from "./generated/src/tracing";
|
||||
import { TieringClient as TieringGeneratedClient } from "./generated/src/index.js";
|
||||
import { logger } from "./utils/index.js";
|
||||
import { tracingClient } from "./generated/src/tracing.js";
|
||||
|
||||
/**
|
||||
* Client options used to configure the TieringGeneratedClient API requests.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
export * from "./logger";
|
||||
export * from "./constants";
|
||||
export * from "./logger.js";
|
||||
export * from "./constants.js";
|
||||
|
|
|
@ -2,32 +2,31 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import type { Context } from "mocha";
|
||||
import { TieringClient } from "../../src";
|
||||
import { assert } from "chai";
|
||||
import { createMockToken } from "./utils/recordedClient";
|
||||
import { TieringClient } from "../../src/index.js";
|
||||
import { createMockToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert } from "vitest";
|
||||
|
||||
describe("RecipientVerificationClient - constructor", function () {
|
||||
describe("RecipientVerificationClient - constructor", () => {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
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}`);
|
||||
assert.instanceOf(client, TieringClient);
|
||||
});
|
||||
|
||||
it("throws with invalid connection string", function () {
|
||||
it("throws with invalid connection string", () => {
|
||||
assert.throws(() => {
|
||||
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));
|
||||
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());
|
||||
assert.instanceOf(client, TieringClient);
|
||||
});
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { Context } from "mocha";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { env } from "@azure-tools/test-recorder";
|
||||
import type { TieringClient } from "../../src";
|
||||
import { assert } from "chai";
|
||||
import { createRecordedClient } from "./utils/recordedClient";
|
||||
import type { TieringClient } from "../../src/index.js";
|
||||
import { createRecordedClient } from "./utils/recordedClient.js";
|
||||
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 client: TieringClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
({ client, recorder } = await createRecordedClient(this));
|
||||
beforeEach(async function (ctx) {
|
||||
({ client, recorder } = await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
afterEach(async function (ctx) {
|
||||
if (!ctx.task.pending) {
|
||||
await recorder.stop();
|
||||
}
|
||||
});
|
||||
|
||||
it("get acquired number limits", async function () {
|
||||
it("get acquired number limits", { timeout: 30000 }, async () => {
|
||||
// print all acquire number limits
|
||||
const resourceId = env.RESOURCE_ID!;
|
||||
const acquiredNumberLimits = await client.getAcquiredNumberLimits(resourceId);
|
||||
assert.isNotNull(acquiredNumberLimits);
|
||||
}).timeout(30000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,31 +1,30 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { Context } from "mocha";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { env } from "@azure-tools/test-recorder";
|
||||
import type { TieringClient } from "../../src";
|
||||
import { assert } from "chai";
|
||||
import { createRecordedClient } from "./utils/recordedClient";
|
||||
import type { TieringClient } from "../../src/index.js";
|
||||
import { createRecordedClient } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
describe(`TieringClient - Get Tier Info`, function () {
|
||||
describe(`TieringClient - Get Tier Info`, () => {
|
||||
let recorder: Recorder;
|
||||
let client: TieringClient;
|
||||
|
||||
beforeEach(async function (this: Context) {
|
||||
({ client, recorder } = await createRecordedClient(this));
|
||||
beforeEach(async function (ctx) {
|
||||
({ client, recorder } = await createRecordedClient(ctx));
|
||||
});
|
||||
|
||||
afterEach(async function (this: Context) {
|
||||
if (!this.currentTest?.isPending()) {
|
||||
afterEach(async function (ctx) {
|
||||
if (!ctx.task.pending) {
|
||||
await recorder.stop();
|
||||
}
|
||||
});
|
||||
|
||||
it("get tier info", async function () {
|
||||
it("get tier info", { timeout: 30000 }, async () => {
|
||||
// print all tier info
|
||||
const resourceId = env.RESOURCE_ID!;
|
||||
const tierInfo = await client.getTierByResourceId(resourceId);
|
||||
assert.isNotNull(tierInfo);
|
||||
}).timeout(30000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,15 +4,14 @@ import * as dotenv from "dotenv";
|
|||
|
||||
import type { TokenCredential } 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 {
|
||||
Recorder,
|
||||
assertEnvironmentVariable,
|
||||
env,
|
||||
isPlaybackMode,
|
||||
} from "@azure-tools/test-recorder";
|
||||
import type { Context } from "mocha";
|
||||
import { TieringClient } from "../../../src";
|
||||
import { TieringClient } from "../../../src/index.js";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import { parseConnectionString } from "@azure/communication-common";
|
||||
|
||||
|
@ -53,9 +52,9 @@ export const recorderOptions: RecorderStartOptions = {
|
|||
};
|
||||
|
||||
export async function createRecordedClient(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<TieringClient>> {
|
||||
const recorder = new Recorder(context.currentTest);
|
||||
const recorder = new Recorder(context);
|
||||
await recorder.start(recorderOptions);
|
||||
await recorder.setMatcher("CustomDefaultMatcher", {
|
||||
excludedHeaders: [
|
||||
|
@ -85,9 +84,9 @@ export function createMockToken(): {
|
|||
}
|
||||
|
||||
export async function createRecordedClientWithToken(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<TieringClient> | undefined> {
|
||||
const recorder = new Recorder(context.currentTest);
|
||||
const recorder = new Recorder(context);
|
||||
await recorder.start(recorderOptions);
|
||||
|
||||
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",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist-esm",
|
||||
"declarationDir": "./types",
|
||||
"paths": {
|
||||
"@azure-tools/communication-tiering": ["./src/index"]
|
||||
}
|
||||
},
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"rootDir": "."
|
||||
},
|
||||
"include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"]
|
||||
"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,
|
||||
},
|
||||
}),
|
||||
);
|
Загрузка…
Ссылка в новой задаче