[communication] Update @azure/communication-alpha-ids to ESM/vitest (#31661)
### Packages impacted by this PR - @azure/communication-alpha-ids ### Issues associated with this PR - https://github.com/Azure/azure-sdk-for-js/issues/31338 ### Describe the problem that is addressed by this PR Migrates @azure/communication-alpha-ids 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:
Родитель
6f0d99bf0b
Коммит
ab06e98a54
|
@ -18501,7 +18501,7 @@ packages:
|
|||
dev: false
|
||||
|
||||
file:projects/communication-alpha-ids.tgz:
|
||||
resolution: {integrity: sha512-/vES/isBSUn6KSc6TIOiY7k8cSBlHGIqJpJzaN8z0AunG3c3TqTGn6IM4CSfnFm+b1WCWvbVdfyad3RVJUSTag==, tarball: file:projects/communication-alpha-ids.tgz}
|
||||
resolution: {integrity: sha512-bUA4Ndtn6P8msf1fAiWimRDZrHvv9BM5sdJf242sV2qbDvNlmDJp6nqyrZtlU1nMzgkhAy9SQ2cHVfKBJUp1OA==, tarball: file:projects/communication-alpha-ids.tgz}
|
||||
name: '@rush-temp/communication-alpha-ids'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
@ -18511,6 +18511,8 @@ packages:
|
|||
'@types/mocha': 10.0.9
|
||||
'@types/node': 18.19.64
|
||||
'@types/sinon': 17.0.3
|
||||
'@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
|
||||
|
@ -18526,18 +18528,32 @@ 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
|
||||
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-call-automation.tgz:
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"include": [
|
||||
"dist-esm/src/**/*.js"
|
||||
],
|
||||
"exclude": [
|
||||
"**/*.d.ts"
|
||||
],
|
||||
"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-alpha-ids.d.ts"
|
||||
"publicTrimmedFilePath": "dist/communication-alpha-ids.d.ts"
|
||||
},
|
||||
"messages": {
|
||||
"tsdocMessageReporting": {
|
||||
|
|
|
@ -1,126 +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",
|
||||
"AZURE_CLIENT_ID",
|
||||
"AZURE_CLIENT_SECRET",
|
||||
"AZURE_TENANT_ID",
|
||||
"RECORDINGS_RELATIVE_PATH",
|
||||
"AZURE_USERAGENT_OVERRIDE",
|
||||
],
|
||||
|
||||
// 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.2",
|
||||
"description": "SDK for Azure Communication Services which facilitates Alpha IDs administration.",
|
||||
"sdk-type": "client",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist-esm/src/index.js",
|
||||
"types": "types/communication-alpha-ids.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 --version=3.0.6267 --v3 ./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/**/*.spec.js'",
|
||||
"integration-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser",
|
||||
"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-alpha-ids.d.ts",
|
||||
"README.md",
|
||||
"LICENSE"
|
||||
],
|
||||
|
@ -59,46 +57,32 @@
|
|||
"sideEffects": false,
|
||||
"prettier": "@azure/eslint-plugin-azure-sdk/prettier.json",
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^2.0.0",
|
||||
"@azure/communication-common": "^2.2.0",
|
||||
"@azure/abort-controller": "^2.1.2",
|
||||
"@azure/communication-common": "^2.3.1",
|
||||
"@azure/core-auth": "^1.3.0",
|
||||
"@azure/core-client": "^1.3.2",
|
||||
"@azure/core-lro": "^2.2.0",
|
||||
"@azure/core-paging": "^1.1.1",
|
||||
"@azure/core-rest-pipeline": "^1.3.2",
|
||||
"@azure/core-tracing": "^1.0.0",
|
||||
"@azure/logger": "^1.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
"@azure/core-paging": "^1.6.2",
|
||||
"@azure/core-rest-pipeline": "^1.17.0",
|
||||
"@azure/core-tracing": "^1.2.0",
|
||||
"@azure/logger": "^1.1.4",
|
||||
"tslib": "^2.7.0"
|
||||
},
|
||||
"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",
|
||||
"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": [
|
||||
|
@ -129,5 +113,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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,17 +10,17 @@ import type {
|
|||
GetPreRegisteredAlphaIdCountriesOptions,
|
||||
AlphaId,
|
||||
SupportedCountries,
|
||||
} from "./models";
|
||||
} from "./models.js";
|
||||
import { isKeyCredential, parseClientArguments } from "@azure/communication-common";
|
||||
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
|
||||
import { isTokenCredential } from "@azure/core-auth";
|
||||
import type { CommonClientOptions, InternalClientPipelineOptions } from "@azure/core-client";
|
||||
import { AlphaIDsClient as AlphaIDsGeneratedClient } from "./generated/src";
|
||||
import { AlphaIDsClient as AlphaIDsGeneratedClient } from "./generated/src/index.js";
|
||||
import { createCommunicationAuthPolicy } from "@azure/communication-common";
|
||||
import { logger } from "./utils";
|
||||
import { tracingClient } from "./generated/src/tracing";
|
||||
import { logger } from "./utils/index.js";
|
||||
import { tracingClient } from "./generated/src/tracing.js";
|
||||
import type { PagedAsyncIterableIterator } from "@azure/core-paging";
|
||||
import { createAlphaIDsPagingPolicy } from "./utils/customPipelinePolicies";
|
||||
import { createAlphaIDsPagingPolicy } from "./utils/customPipelinePolicies.js";
|
||||
|
||||
/**
|
||||
* Client options used to configure the AlphaIdsClient API requests.
|
||||
|
|
|
@ -12,9 +12,9 @@ import {
|
|||
PipelineResponse,
|
||||
SendRequest
|
||||
} from "@azure/core-rest-pipeline";
|
||||
import { AlphaIdsImpl } from "./operations";
|
||||
import { AlphaIds } from "./operationsInterfaces";
|
||||
import { AlphaIDsClientOptionalParams } from "./models";
|
||||
import { AlphaIdsImpl } from "./operations/index.js";
|
||||
import { AlphaIds } from "./operationsInterfaces/index.js";
|
||||
import { AlphaIDsClientOptionalParams } from "./models/index.js";
|
||||
|
||||
export class AlphaIDsClient extends coreClient.ServiceClient {
|
||||
endpoint: string;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
export { getContinuationToken } from "./pagingHelper";
|
||||
export * from "./models";
|
||||
export { AlphaIDsClient } from "./alphaIDsClient";
|
||||
export * from "./operationsInterfaces";
|
||||
export { getContinuationToken } from "./pagingHelper.js";
|
||||
export * from "./models/index.js";
|
||||
export { AlphaIDsClient } from "./alphaIDsClient.js";
|
||||
export * from "./operationsInterfaces/index.js";
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
OperationURLParameter,
|
||||
OperationQueryParameter
|
||||
} from "@azure/core-client";
|
||||
import { DynamicAlphaIdConfiguration as DynamicAlphaIdConfigurationMapper } from "../models/mappers";
|
||||
import { DynamicAlphaIdConfiguration as DynamicAlphaIdConfigurationMapper } from "../models/mappers.js";
|
||||
|
||||
export const accept: OperationParameter = {
|
||||
parameterPath: "accept",
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
import { tracingClient } from "../tracing";
|
||||
import { tracingClient } from "../tracing.js";
|
||||
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
|
||||
import { setContinuationToken } from "../pagingHelper";
|
||||
import { AlphaIds } from "../operationsInterfaces";
|
||||
import { setContinuationToken } from "../pagingHelper.js";
|
||||
import { AlphaIds } from "../operationsInterfaces/index.js";
|
||||
import * as coreClient from "@azure/core-client";
|
||||
import * as Mappers from "../models/mappers";
|
||||
import * as Parameters from "../models/parameters";
|
||||
import { AlphaIDsClient } from "../alphaIDsClient";
|
||||
import * as Mappers from "../models/mappers.js";
|
||||
import * as Parameters from "../models/parameters.js";
|
||||
import { AlphaIDsClient } from "../alphaIDsClient.js";
|
||||
import {
|
||||
AlphaId,
|
||||
AlphaIdsGetAlphaIdsNextOptionalParams,
|
||||
|
@ -28,7 +28,7 @@ import {
|
|||
AlphaIdsGetPreRegisteredAlphaIdCountriesOptionalParams,
|
||||
AlphaIdsGetPreRegisteredAlphaIdCountriesResponse,
|
||||
AlphaIdsGetAlphaIdsNextResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
/** Class containing AlphaIds operations. */
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./alphaIds";
|
||||
export * from "./alphaIds.js";
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
AlphaIdsGetDynamicAlphaIdCountriesResponse,
|
||||
AlphaIdsGetPreRegisteredAlphaIdCountriesOptionalParams,
|
||||
AlphaIdsGetPreRegisteredAlphaIdCountriesResponse
|
||||
} from "../models";
|
||||
} from "../models/index.js";
|
||||
|
||||
/// <reference lib="esnext.asynciterable" />
|
||||
/** Interface representing a AlphaIds. */
|
||||
|
|
|
@ -6,4 +6,4 @@
|
|||
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
||||
*/
|
||||
|
||||
export * from "./alphaIds";
|
||||
export * from "./alphaIds.js";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
export * from "./models";
|
||||
export * from "./alphaIdsClient";
|
||||
export * from "./models.js";
|
||||
export * from "./alphaIdsClient.js";
|
||||
|
|
|
@ -6,7 +6,7 @@ import type {
|
|||
AlphaIdsGetAlphaIdsOptionalParams,
|
||||
AlphaIdsGetDynamicAlphaIdCountriesOptionalParams,
|
||||
AlphaIdsGetPreRegisteredAlphaIdCountriesOptionalParams,
|
||||
} from ".";
|
||||
} from "./index.js";
|
||||
/**
|
||||
* Additional options for the Get Alpha ID Configuration request.
|
||||
*/
|
||||
|
@ -41,4 +41,4 @@ export {
|
|||
AlphaIdsGetDynamicAlphaIdCountriesOptionalParams,
|
||||
AlphaIdsGetPreRegisteredAlphaIdCountriesOptionalParams,
|
||||
SupportedCountries,
|
||||
} from "./generated/src/models/";
|
||||
} from "./generated/src/models/index.js";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
export * from "./constants";
|
||||
export * from "./logger";
|
||||
export * from "./constants.js";
|
||||
export * from "./logger.js";
|
||||
|
|
|
@ -7,14 +7,13 @@ import {
|
|||
createEmptyPipeline,
|
||||
bearerTokenAuthenticationPolicyName,
|
||||
} from "@azure/core-rest-pipeline";
|
||||
import { AlphaIDsClient as AlphaIDsGeneratedClient } from "../../src/generated/src";
|
||||
import { AlphaIDsClient as AlphaIDsGeneratedClient } from "../../src/generated/src/index.js";
|
||||
import type { TokenCredential } from "@azure/identity";
|
||||
import { assert } from "chai";
|
||||
import { createMockToken } from "../public/utils/recordedClient";
|
||||
import { createMockToken } from "../public/utils/recordedClient.js";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import { parseClientArguments } from "@azure/communication-common";
|
||||
import sinon from "sinon";
|
||||
import type { HttpClient, PipelineRequest, PipelineResponse } from "@azure/core-rest-pipeline";
|
||||
import { describe, it, assert, expect, vi } from "vitest";
|
||||
|
||||
export const createMockHttpClient = <T = Record<string, unknown>>(
|
||||
status: number = 200,
|
||||
|
@ -108,8 +107,8 @@ describe("AlphaIdsGeneratedClient - constructor", function () {
|
|||
"pipeline should have CustomApiVersionPolicy",
|
||||
);
|
||||
|
||||
const spy = sinon.spy(mockHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(mockHttpClient, "sendRequest");
|
||||
await client.alphaIds.upsertDynamicAlphaIdConfiguration(true);
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,16 +2,14 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import type { Context } from "mocha";
|
||||
import type { PipelineRequest } from "@azure/core-rest-pipeline";
|
||||
import { SDK_VERSION } from "../../src/utils/constants";
|
||||
import { AlphaIdsClient } from "../../src";
|
||||
import { SDK_VERSION } from "../../src/utils/constants.js";
|
||||
import { AlphaIdsClient } from "../../src/index.js";
|
||||
import type { TokenCredential } from "@azure/identity";
|
||||
import { assert } from "chai";
|
||||
import { createMockToken } from "../public/utils/recordedClient";
|
||||
import { configurationHttpClient } from "../public/utils/mockHttpClients";
|
||||
import { createMockToken } from "../public/utils/recordedClient.js";
|
||||
import { configurationHttpClient } from "../public/utils/mockHttpClients.js";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import sinon from "sinon";
|
||||
import { describe, it, assert, expect, vi, afterEach } from "vitest";
|
||||
|
||||
describe("AlphaIdsClient - headers", function () {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
|
@ -22,20 +20,20 @@ describe("AlphaIdsClient - headers", function () {
|
|||
let request: PipelineRequest;
|
||||
|
||||
afterEach(function () {
|
||||
sinon.restore();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("calls the spy", async function () {
|
||||
const spy = sinon.spy(configurationHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(configurationHttpClient, "sendRequest");
|
||||
await client.getDynamicAlphaIdConfiguration();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
});
|
||||
|
||||
it("[node] sets correct host", function (this: Context) {
|
||||
it("[node] sets correct host", function (ctx) {
|
||||
if (!isNodeLike) {
|
||||
this.skip();
|
||||
ctx.skip();
|
||||
}
|
||||
assert.equal(request.headers.get("host"), "contoso.spool.azure.local");
|
||||
});
|
||||
|
@ -66,11 +64,11 @@ describe("AlphaIdsClient - headers", function () {
|
|||
httpClient: configurationHttpClient,
|
||||
});
|
||||
|
||||
const spy = sinon.spy(configurationHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(configurationHttpClient, "sendRequest");
|
||||
await client.getDynamicAlphaIdConfiguration();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(
|
||||
request.headers.get("authorization") as string,
|
||||
|
@ -78,18 +76,18 @@ describe("AlphaIdsClient - headers", function () {
|
|||
);
|
||||
});
|
||||
|
||||
it("sets bearer authorization header with TokenCredential", async function (this: Context) {
|
||||
it("sets bearer authorization header with TokenCredential", async function () {
|
||||
const credential: TokenCredential = createMockToken();
|
||||
|
||||
client = new AlphaIdsClient(endpoint, credential, {
|
||||
httpClient: configurationHttpClient,
|
||||
});
|
||||
|
||||
const spy = sinon.spy(configurationHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(configurationHttpClient, "sendRequest");
|
||||
await client.getDynamicAlphaIdConfiguration();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
assert.isDefined(request.headers.get("authorization"));
|
||||
assert.match(request.headers.get("authorization") as string, /Bearer ./);
|
||||
});
|
||||
|
@ -102,11 +100,11 @@ describe("AlphaIdsClient - headers", function () {
|
|||
},
|
||||
});
|
||||
|
||||
const spy = sinon.spy(configurationHttpClient, "sendRequest");
|
||||
const spy = vi.spyOn(configurationHttpClient, "sendRequest");
|
||||
await client.getDynamicAlphaIdConfiguration();
|
||||
sinon.assert.calledOnce(spy);
|
||||
expect(spy).toHaveBeenCalledOnce();
|
||||
|
||||
request = spy.getCall(0).args[0];
|
||||
request = spy.mock.calls[0][0];
|
||||
|
||||
const userAgentHeader = isNodeLike ? "user-agent" : "x-ms-useragent";
|
||||
assert.match(
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
import { AzureKeyCredential } from "@azure/core-auth";
|
||||
import type { Context } from "mocha";
|
||||
import { AlphaIdsClient } from "../../src";
|
||||
import { assert } from "chai";
|
||||
import { createMockToken } from "./utils/recordedClient";
|
||||
import { AlphaIdsClient } from "../../src/index.js";
|
||||
import { createMockToken } from "./utils/recordedClient.js";
|
||||
import { describe, it, assert } from "vitest";
|
||||
|
||||
describe("AlphaIdsClient - constructor", function () {
|
||||
const endpoint = "https://contoso.spool.azure.local";
|
||||
|
@ -27,7 +26,7 @@ describe("AlphaIdsClient - constructor", function () {
|
|||
assert.instanceOf(client, AlphaIdsClient);
|
||||
});
|
||||
|
||||
it("successfully instantiates with with endpoint and managed identity", function (this: Context) {
|
||||
it("successfully instantiates with with endpoint and managed identity", function () {
|
||||
const client = new AlphaIdsClient(endpoint, createMockToken());
|
||||
assert.instanceOf(client, AlphaIdsClient);
|
||||
});
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { AlphaIdsClient } from "../../src";
|
||||
import type { Context } from "mocha";
|
||||
import type { AlphaIdsClient } from "../../src/index.js";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import { createRecordedClient } from "./utils/recordedClient";
|
||||
import { assert } from "chai";
|
||||
import { createRecordedClient } from "./utils/recordedClient.js";
|
||||
import type { FullOperationResponse, OperationOptions } from "@azure/core-client";
|
||||
import type { DynamicAlphaIdConfiguration } from "../../src";
|
||||
import type { DynamicAlphaIdConfiguration } from "../../src/index.js";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
describe(`AlphaIdsClient - manage configuration`, function () {
|
||||
let recorder: Recorder;
|
||||
let client: AlphaIdsClient;
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
@ -84,7 +83,7 @@ describe(`AlphaIdsClient - manage configuration`, function () {
|
|||
}
|
||||
};
|
||||
|
||||
it("can manage configuration", async function () {
|
||||
it("can manage configuration", { timeout: 30000 }, async function () {
|
||||
let configuration: DynamicAlphaIdConfiguration;
|
||||
let configurationResponse: FullOperationResponse | undefined;
|
||||
|
||||
|
@ -107,12 +106,12 @@ describe(`AlphaIdsClient - manage configuration`, function () {
|
|||
`The expected configuration: false is different than the received configuration: true
|
||||
CV: ${configurationResponse?.headers.get("MS-CV")}`,
|
||||
);
|
||||
}).timeout(30000);
|
||||
});
|
||||
|
||||
it("can list all dynamic alpha ids countries", async function () {
|
||||
it("can list all dynamic alpha ids countries", { timeout: 20000 }, async function () {
|
||||
const countries = await _getDynamicCountries();
|
||||
countries?.forEach((countryCode) => {
|
||||
assert.isNotNull(countryCode);
|
||||
});
|
||||
}).timeout(20000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,28 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import type { Context } from "mocha";
|
||||
import type { Recorder } from "@azure-tools/test-recorder";
|
||||
import type { AlphaIdsClient } from "../../src";
|
||||
import { assert } from "chai";
|
||||
import { createRecordedClient } from "./utils/recordedClient";
|
||||
import type { AlphaIdsClient } from "../../src/index.js";
|
||||
import { createRecordedClient } from "./utils/recordedClient.js";
|
||||
import type { FullOperationResponse, OperationOptions } from "@azure/core-client";
|
||||
import { describe, it, assert, beforeEach, afterEach } from "vitest";
|
||||
|
||||
describe(`AlphaIdsClient - Preregistered Alpha Ids Operations`, function () {
|
||||
let recorder: Recorder;
|
||||
let client: AlphaIdsClient;
|
||||
|
||||
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("can list all pre-registered alpha ids", async function () {
|
||||
it("can list all pre-registered alpha ids", { timeout: 40000 }, async function () {
|
||||
let configurationResponse: FullOperationResponse | undefined;
|
||||
const getConfigurationRequest: OperationOptions = {
|
||||
onResponse: (response) => {
|
||||
|
@ -67,9 +65,9 @@ describe(`AlphaIdsClient - Preregistered Alpha Ids Operations`, function () {
|
|||
)}, ${JSON.stringify(error)}`,
|
||||
);
|
||||
}
|
||||
}).timeout(40000);
|
||||
});
|
||||
|
||||
it("can list all pre-registered alpha ids countries", async function () {
|
||||
it("can list all pre-registered alpha ids countries", { timeout: 20000 }, async function () {
|
||||
let configurationResponse: FullOperationResponse | undefined;
|
||||
const getConfigurationRequest: OperationOptions = {
|
||||
onResponse: (response) => {
|
||||
|
@ -89,5 +87,5 @@ describe(`AlphaIdsClient - Preregistered Alpha Ids Operations`, function () {
|
|||
)}, ${JSON.stringify(error)}`,
|
||||
);
|
||||
}
|
||||
}).timeout(20000);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,18 +4,17 @@
|
|||
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 { AlphaIdsClient } from "../../../src";
|
||||
import type { Context } from "mocha";
|
||||
import { AlphaIdsClient } from "../../../src/index.js";
|
||||
import { isNodeLike } from "@azure/core-util";
|
||||
import { parseConnectionString } from "@azure/communication-common";
|
||||
import { createMSUserAgentPolicy } from "./msUserAgentPolicy";
|
||||
import { createMSUserAgentPolicy } from "./msUserAgentPolicy.js";
|
||||
|
||||
if (isNodeLike) {
|
||||
dotenv.config();
|
||||
|
@ -54,9 +53,9 @@ export const recorderOptions: RecorderStartOptions = {
|
|||
};
|
||||
|
||||
export async function createRecordedClient(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<AlphaIdsClient>> {
|
||||
const recorder = new Recorder(context.currentTest);
|
||||
const recorder = new Recorder(context);
|
||||
await recorder.start(recorderOptions);
|
||||
|
||||
// casting is a workaround to enable min-max testing
|
||||
|
@ -87,9 +86,9 @@ export function createMockToken(): {
|
|||
}
|
||||
|
||||
export async function createRecordedClientWithToken(
|
||||
context: Context,
|
||||
context: TestInfo,
|
||||
): Promise<RecordedClient<AlphaIdsClient> | 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-alpha-ids": ["./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: 300000,
|
||||
testTimeout: 300000,
|
||||
},
|
||||
}),
|
||||
);
|
|
@ -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: 300000,
|
||||
testTimeout: 300000,
|
||||
},
|
||||
}),
|
||||
);
|
Загрузка…
Ссылка в новой задаче