From dcdca3175c9929027937691596858c27e3b151a0 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:04 -0500 Subject: [PATCH 01/13] Migration: Update package.json, tsconfig.json, and api-extractor.json --- .../api-extractor.json | 27 ++++++-- .../communication-messages-rest/package.json | 66 +++++++++---------- .../communication-messages-rest/tsconfig.json | 19 ++++-- 3 files changed, 67 insertions(+), 45 deletions(-) diff --git a/sdk/communication/communication-messages-rest/api-extractor.json b/sdk/communication/communication-messages-rest/api-extractor.json index e4a0816f672e..b5983fcc4f78 100644 --- a/sdk/communication/communication-messages-rest/api-extractor.json +++ b/sdk/communication/communication-messages-rest/api-extractor.json @@ -1,18 +1,31 @@ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "mainEntryPointFilePath": "./types/src/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, + "mainEntryPointFilePath": "dist/esm/index.d.ts", + "docModel": { + "enabled": true + }, + "apiReport": { + "enabled": true, + "reportFolder": "./review" + }, "dtsRollup": { "enabled": true, "untrimmedFilePath": "", - "publicTrimmedFilePath": "./types/communication-messages.d.ts" + "publicTrimmedFilePath": "dist/communication-messages.d.ts" }, "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } } } } diff --git a/sdk/communication/communication-messages-rest/package.json b/sdk/communication/communication-messages-rest/package.json index ea0c3727d42c..6dd7be2427b2 100644 --- a/sdk/communication/communication-messages-rest/package.json +++ b/sdk/communication/communication-messages-rest/package.json @@ -22,22 +22,19 @@ }, "files": [ "dist/", - "dist-esm/src/", - "types/communication-messages.d.ts", "README.md", - "LICENSE", - "review/*" + "LICENSE" ], "engines": { "node": ">=18.0.0" }, "scripts": { - "build": "npm run clean && tsc -p . && dev-tool run bundle && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", - "build:browser": "tsc -p . && dev-tool run vendored cross-env ONLY_BROWSER=true rollup -c 2>&1", - "build:debug": "tsc -p . && dev-tool run bundle && dev-tool run extract-api", - "build:node": "tsc -p . && dev-tool run vendored cross-env ONLY_NODE=true rollup -c 2>&1", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "build:browser": "dev-tool run build-package && dev-tool run vendored cross-env ONLY_BROWSER=true rollup -c 2>&1", + "build:debug": "dev-tool run build-package && dev-tool run bundle && dev-tool run extract-api", + "build:node": "dev-tool run build-package && dev-tool run vendored cross-env ONLY_NODE=true rollup -c 2>&1", "build:samples": "echo skipped.", - "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\" \"*.{js,json}\" \"test/**/*.ts\"", "clean": "dev-tool run vendored rimraf --glob dist dist-browser dist-esm test-dist temp types *.tgz *.log", "execute:samples": "echo skipped", @@ -54,8 +51,8 @@ "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", "test:node": "npm run clean && npm run build:test && npm run unit-test:node", "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" }, "sideEffects": false, @@ -71,33 +68,22 @@ "tslib": "^2.2.0" }, "devDependencies": { - "@azure-tools/test-credential": "^1.0.0", - "@azure-tools/test-recorder": "^3.0.0", + "@azure-tools/test-credential": "^2.0.0", + "@azure-tools/test-recorder": "^4.1.0", + "@azure-tools/test-utils-vitest": "^1.0.0", "@azure/dev-tool": "^1.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0", "@azure/identity": "^4.2.1", - "@types/chai": "^4.2.8", - "@types/mocha": "^10.0.0", "@types/node": "^18.0.0", + "@vitest/browser": "^2.1.5", + "@vitest/coverage-istanbul": "^2.1.5", "autorest": "latest", - "chai": "^4.2.0", "dotenv": "^16.0.0", "eslint": "^9.9.0", - "karma": "^6.2.0", - "karma-chrome-launcher": "^3.0.0", - "karma-coverage": "^2.0.0", - "karma-env-preprocessor": "^0.1.1", - "karma-firefox-launcher": "^2.1.2", - "karma-junit-reporter": "^2.0.1", - "karma-mocha": "^2.0.1", - "karma-mocha-reporter": "^2.2.5", "karma-source-map-support": "~1.4.0", - "karma-sourcemap-loader": "^0.4.0", - "mocha": "^10.0.0", - "nyc": "^17.0.0", - "source-map-support": "^0.5.9", - "ts-node": "^10.0.0", - "typescript": "~5.6.2" + "playwright": "^1.48.2", + "typescript": "~5.6.2", + "vitest": "^2.1.5" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest-rest/README.md", "//metadata": { @@ -108,9 +94,7 @@ } ] }, - "browser": { - "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" - }, + "browser": "./dist/browser/index.js", "//sampleConfiguration": { "productName": "Azure client library for Azure Communication Messages Services", "productSlugs": [ @@ -118,5 +102,21 @@ "azure-communication-services" ], "apiRefLink": "https://learn.microsoft.com/javascript/api/overview/azure/communication-messages-rest-readme?view=azure-node-latest" + }, + "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "react-native" + ], + "selfLink": false } } diff --git a/sdk/communication/communication-messages-rest/tsconfig.json b/sdk/communication/communication-messages-rest/tsconfig.json index 7a24ea1fe5d3..d9234afa7716 100644 --- a/sdk/communication/communication-messages-rest/tsconfig.json +++ b/sdk/communication/communication-messages-rest/tsconfig.json @@ -1,11 +1,20 @@ { "extends": "../../../tsconfig", "compilerOptions": { - "outDir": "./dist-esm", - "declarationDir": "./types", "paths": { - "@azure-rest/communication-messages": ["./src/index"] - } + "@azure-rest/communication-messages": [ + "./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" + ] } From 8293e08d8d371cfe0675e7e5cf23506f707ff43c Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:05 -0500 Subject: [PATCH 02/13] Migration: Update test config --- .../tsconfig.browser.config.json | 17 +++++++++++++++++ .../vitest.browser.config.ts | 17 +++++++++++++++++ .../vitest.config.ts | 15 +++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 sdk/communication/communication-messages-rest/tsconfig.browser.config.json create mode 100644 sdk/communication/communication-messages-rest/vitest.browser.config.ts create mode 100644 sdk/communication/communication-messages-rest/vitest.config.ts diff --git a/sdk/communication/communication-messages-rest/tsconfig.browser.config.json b/sdk/communication/communication-messages-rest/tsconfig.browser.config.json new file mode 100644 index 000000000000..b6586181d006 --- /dev/null +++ b/sdk/communication/communication-messages-rest/tsconfig.browser.config.json @@ -0,0 +1,17 @@ +{ + "extends": "./.tshy/build.json", + "include": [ + "./src/**/*.ts", + "./src/**/*.mts", + "./test/**/*.spec.ts", + "./test/**/*.mts" + ], + "exclude": [ + "./test/**/node/**/*.ts" + ], + "compilerOptions": { + "outDir": "./dist-test/browser", + "rootDir": ".", + "skipLibCheck": true + } +} diff --git a/sdk/communication/communication-messages-rest/vitest.browser.config.ts b/sdk/communication/communication-messages-rest/vitest.browser.config.ts new file mode 100644 index 000000000000..b48c61b2ef46 --- /dev/null +++ b/sdk/communication/communication-messages-rest/vitest.browser.config.ts @@ -0,0 +1,17 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.browser.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: [ + "dist-test/browser/test/**/*.spec.js", + ], + }, + }), +); diff --git a/sdk/communication/communication-messages-rest/vitest.config.ts b/sdk/communication/communication-messages-rest/vitest.config.ts new file mode 100644 index 000000000000..39267dd2f56f --- /dev/null +++ b/sdk/communication/communication-messages-rest/vitest.config.ts @@ -0,0 +1,15 @@ + +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { defineConfig, mergeConfig } from "vitest/config"; +import viteConfig from "../../../vitest.shared.config.ts"; + +export default mergeConfig( + viteConfig, + defineConfig({ + test: { + include: ["test/**/*.spec.ts"], + }, + }), +); From 71c0e21c2c559b2956c010a9cad35e58263b939f Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:05 -0500 Subject: [PATCH 03/13] Migration: Clean up files --- .../communication-messages-rest/karma.conf.js | 134 ------------------ 1 file changed, 134 deletions(-) delete mode 100644 sdk/communication/communication-messages-rest/karma.conf.js diff --git a/sdk/communication/communication-messages-rest/karma.conf.js b/sdk/communication/communication-messages-rest/karma.conf.js deleted file mode 100644 index e9819f9fe275..000000000000 --- a/sdk/communication/communication-messages-rest/karma.conf.js +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -// 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: ["source-map-support", "mocha"], - - plugins: [ - "karma-mocha", - "karma-mocha-reporter", - "karma-chrome-launcher", - "karma-firefox-launcher", - "karma-env-preprocessor", - "karma-coverage", - "karma-sourcemap-loader", - "karma-junit-reporter", - "karma-source-map-support", - ], - - // list of files / patterns to load in the browser - files: [ - "dist-test/index.browser.js", - { - pattern: "dist-test/index.browser.js.map", - type: "html", - included: false, - served: true, - }, - ], - - // 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.js": ["coverage"] - }, - - envPreprocessor: [ - "TEST_MODE", - "AZURE_CLIENT_SECRET", - "AZURE_CLIENT_ID", - "AZURE_TENANT_ID", - "CHANNEL_ID", - "RECIPIENT_PHONE_NUMBER", - "COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING", - "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 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, - - // --no-sandbox allows our tests to run in Linux without having to change the system. - // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex. - browsers: ["ChromeHeadlessNoSandbox"], - customLaunchers: { - ChromeHeadlessNoSandbox: { - base: "ChromeHeadless", - flags: ["--no-sandbox", "--disable-web-security"], - }, - }, - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: 1, - - browserNoActivityTimeout: 60000000, - browserDisconnectTimeout: 10000, - browserDisconnectTolerance: 3, - - client: { - mocha: { - // change Karma's debug.html to the mocha web reporter - reporter: "html", - timeout: "600000", - }, - }, - }); -}; From a5088cf442ccfb235d14c06e536d65b9bb487631 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:06 -0500 Subject: [PATCH 04/13] Migration: Apply codemod: "fixSourceFile" --- .../samples-dev/DownloadMedia.ts | 2 +- .../src/generated/src/clientDefinitions.ts | 4 ++-- .../src/generated/src/index.ts | 18 +++++++++--------- .../src/generated/src/isUnexpected.ts | 2 +- .../src/generated/src/messagesServiceClient.ts | 4 ++-- .../src/generated/src/parameters.ts | 2 +- .../src/generated/src/responses.ts | 2 +- .../communication-messages-rest/src/index.ts | 18 +++++++++--------- .../src/messagesServiceClient.ts | 4 ++-- .../test/public/messageTest.spec.ts | 12 ++++++------ .../test/public/utils/recordedClient.ts | 4 ++-- 11 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sdk/communication/communication-messages-rest/samples-dev/DownloadMedia.ts b/sdk/communication/communication-messages-rest/samples-dev/DownloadMedia.ts index 0d37d9255385..d2e4454bdd2b 100644 --- a/sdk/communication/communication-messages-rest/samples-dev/DownloadMedia.ts +++ b/sdk/communication/communication-messages-rest/samples-dev/DownloadMedia.ts @@ -7,7 +7,7 @@ import NotificationClient from "@azure-rest/communication-messages"; import { AzureKeyCredential } from "@azure/core-auth"; -import * as fs from "fs"; +import * as fs from "node:fs"; // Load the .env file if it exists import * as dotenv from "dotenv"; diff --git a/sdk/communication/communication-messages-rest/src/generated/src/clientDefinitions.ts b/sdk/communication/communication-messages-rest/src/generated/src/clientDefinitions.ts index 26e53c5baca3..30b588cbdff9 100644 --- a/sdk/communication/communication-messages-rest/src/generated/src/clientDefinitions.ts +++ b/sdk/communication/communication-messages-rest/src/generated/src/clientDefinitions.ts @@ -5,7 +5,7 @@ import { GetMediaParameters, SendParameters, ListTemplatesParameters, -} from "./parameters"; +} from "./parameters.js"; import { GetMedia200Response, GetMediaDefaultResponse, @@ -13,7 +13,7 @@ import { SendDefaultResponse, ListTemplates200Response, ListTemplatesDefaultResponse, -} from "./responses"; +} from "./responses.js"; import { Client, StreamableMethod } from "@azure-rest/core-client"; export interface GetMedia { diff --git a/sdk/communication/communication-messages-rest/src/generated/src/index.ts b/sdk/communication/communication-messages-rest/src/generated/src/index.ts index f2046b303f34..56dbb282687a 100644 --- a/sdk/communication/communication-messages-rest/src/generated/src/index.ts +++ b/sdk/communication/communication-messages-rest/src/generated/src/index.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import MessagesServiceClient from "./messagesServiceClient"; +import MessagesServiceClient from "./messagesServiceClient.js"; -export * from "./messagesServiceClient"; -export * from "./parameters"; -export * from "./responses"; -export * from "./clientDefinitions"; -export * from "./isUnexpected"; -export * from "./models"; -export * from "./outputModels"; -export * from "./paginateHelper"; +export * from "./messagesServiceClient.js"; +export * from "./parameters.js"; +export * from "./responses.js"; +export * from "./clientDefinitions.js"; +export * from "./isUnexpected.js"; +export * from "./models.js"; +export * from "./outputModels.js"; +export * from "./paginateHelper.js"; export default MessagesServiceClient; diff --git a/sdk/communication/communication-messages-rest/src/generated/src/isUnexpected.ts b/sdk/communication/communication-messages-rest/src/generated/src/isUnexpected.ts index 8d5724f47831..4ba236a0785a 100644 --- a/sdk/communication/communication-messages-rest/src/generated/src/isUnexpected.ts +++ b/sdk/communication/communication-messages-rest/src/generated/src/isUnexpected.ts @@ -8,7 +8,7 @@ import { SendDefaultResponse, ListTemplates200Response, ListTemplatesDefaultResponse, -} from "./responses"; +} from "./responses.js"; const responseMap: Record = { "GET /messages/streams/{id}": ["200"], diff --git a/sdk/communication/communication-messages-rest/src/generated/src/messagesServiceClient.ts b/sdk/communication/communication-messages-rest/src/generated/src/messagesServiceClient.ts index 81c04ef3a03d..2ccd514458b1 100644 --- a/sdk/communication/communication-messages-rest/src/generated/src/messagesServiceClient.ts +++ b/sdk/communication/communication-messages-rest/src/generated/src/messagesServiceClient.ts @@ -2,9 +2,9 @@ // Licensed under the MIT License. import { getClient, ClientOptions } from "@azure-rest/core-client"; -import { logger } from "./logger"; +import { logger } from "./logger.js"; import { TokenCredential, KeyCredential } from "@azure/core-auth"; -import { MessagesServiceClient } from "./clientDefinitions"; +import { MessagesServiceClient } from "./clientDefinitions.js"; /** The optional parameters for the client */ export interface MessagesServiceClientOptions extends ClientOptions { diff --git a/sdk/communication/communication-messages-rest/src/generated/src/parameters.ts b/sdk/communication/communication-messages-rest/src/generated/src/parameters.ts index a168bd0214c8..f46c2e46e766 100644 --- a/sdk/communication/communication-messages-rest/src/generated/src/parameters.ts +++ b/sdk/communication/communication-messages-rest/src/generated/src/parameters.ts @@ -3,7 +3,7 @@ import { RawHttpHeadersInput } from "@azure/core-rest-pipeline"; import { RequestParameters } from "@azure-rest/core-client"; -import { NotificationContent } from "./models"; +import { NotificationContent } from "./models.js"; export interface GetMediaHeaders { /** An opaque, globally-unique, client-generated string identifier for the request. */ diff --git a/sdk/communication/communication-messages-rest/src/generated/src/responses.ts b/sdk/communication/communication-messages-rest/src/generated/src/responses.ts index 0c622f0ec8d3..188eefd8dfeb 100644 --- a/sdk/communication/communication-messages-rest/src/generated/src/responses.ts +++ b/sdk/communication/communication-messages-rest/src/generated/src/responses.ts @@ -7,7 +7,7 @@ import { RepeatabilityResultOutput, SendMessageResultOutput, PagedMessageTemplateItemOutput, -} from "./outputModels"; +} from "./outputModels.js"; export interface GetMedia200Headers { /** An opaque, globally-unique, client-generated string identifier for the request. */ diff --git a/sdk/communication/communication-messages-rest/src/index.ts b/sdk/communication/communication-messages-rest/src/index.ts index 258a5af85f13..e69027f27809 100644 --- a/sdk/communication/communication-messages-rest/src/index.ts +++ b/sdk/communication/communication-messages-rest/src/index.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import MessagesServiceClient from "./messagesServiceClient"; -export * from "./generated/src/messagesServiceClient"; -export * from "./generated/src/parameters"; -export * from "./generated/src/responses"; -export * from "./generated/src/clientDefinitions"; -export * from "./generated/src/isUnexpected"; -export * from "./generated/src/models"; -export * from "./generated/src/outputModels"; -export * from "./generated/src/paginateHelper"; +import MessagesServiceClient from "./messagesServiceClient.js"; +export * from "./generated/src/messagesServiceClient.js"; +export * from "./generated/src/parameters.js"; +export * from "./generated/src/responses.js"; +export * from "./generated/src/clientDefinitions.js"; +export * from "./generated/src/isUnexpected.js"; +export * from "./generated/src/models.js"; +export * from "./generated/src/outputModels.js"; +export * from "./generated/src/paginateHelper.js"; export default MessagesServiceClient; diff --git a/sdk/communication/communication-messages-rest/src/messagesServiceClient.ts b/sdk/communication/communication-messages-rest/src/messagesServiceClient.ts index bf96056bd9b4..0732b0ca6794 100644 --- a/sdk/communication/communication-messages-rest/src/messagesServiceClient.ts +++ b/sdk/communication/communication-messages-rest/src/messagesServiceClient.ts @@ -5,8 +5,8 @@ import type { TokenCredential, KeyCredential } from "@azure/core-auth"; import { isTokenCredential, isKeyCredential } from "@azure/core-auth"; import type { ClientOptions } from "@azure-rest/core-client"; import { parseClientArguments, createCommunicationAuthPolicy } from "@azure/communication-common"; -import type { MessagesServiceClient } from "./generated/src/clientDefinitions"; -import GeneratedAzureCommunicationMessageServiceClient from "./generated/src/messagesServiceClient"; +import type { MessagesServiceClient } from "./generated/src/clientDefinitions.js"; +import GeneratedAzureCommunicationMessageServiceClient from "./generated/src/messagesServiceClient.js"; /** * Initialize a new instance of `MessagesServiceClient` diff --git a/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts b/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts index 455e125b579d..20a491aca379 100644 --- a/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts +++ b/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts @@ -4,7 +4,7 @@ import type { Recorder } from "@azure-tools/test-recorder"; import { env } from "@azure-tools/test-recorder"; import { assert } from "chai"; -import { createRecorderWithConnectionString } from "./utils/recordedClient"; +import { createRecorderWithConnectionString } from "./utils/recordedClient.js"; import type { Context } from "mocha"; import type { MessagesServiceClient, @@ -17,18 +17,18 @@ import type { AudioNotificationContent, VideoNotificationContent, DocumentNotificationContent, -} from "../../src/generated/src"; +} from "../../src/generated/src/index.js"; describe("Notification Messages Test", () => { let recorder: Recorder; let client: MessagesServiceClient; - beforeEach(async function (this: Context) { + beforeEach(async function (ctx) { ({ client, recorder } = await createRecorderWithConnectionString(this)); }); afterEach(async function () { - if (!this.currentTest?.isPending()) { + if (!ctx.task.pending) { await recorder.stop(); } }); @@ -399,12 +399,12 @@ describe("Message Template Read Test", () => { let recorder: Recorder; let client: MessagesServiceClient; - beforeEach(async function (this: Context) { + beforeEach(async function (ctx) { ({ client, recorder } = await createRecorderWithConnectionString(this)); }); afterEach(async function () { - if (!this.currentTest?.isPending()) { + if (!ctx.task.pending) { await recorder.stop(); } }); diff --git a/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts b/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts index 4adaeff1146f..def0ec82a999 100644 --- a/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts +++ b/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts @@ -4,8 +4,8 @@ import type { Context, Test } from "mocha"; import type { RecorderStartOptions, SanitizerOptions } from "@azure-tools/test-recorder"; import { Recorder, env } from "@azure-tools/test-recorder"; -import type { MessagesServiceClient } from "../../../src"; -import MessageClient from "../../../src"; +import type { MessagesServiceClient } from "../../../src/index.js"; +import MessageClient from "../../../src/index.js"; import { parseConnectionString } from "@azure/communication-common"; import type { TokenCredential } from "@azure/core-auth"; import { createTestCredential } from "@azure-tools/test-credential"; From 74330d1e12850c752472fa869659a5bf844483f3 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:06 -0500 Subject: [PATCH 05/13] Migration: Apply codemod: "fixTestingImports" --- .../test/public/messageTest.spec.ts | 3 +-- .../test/public/utils/recordedClient.ts | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts b/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts index 20a491aca379..5705bebb4b86 100644 --- a/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts +++ b/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts @@ -3,9 +3,7 @@ import type { Recorder } from "@azure-tools/test-recorder"; import { env } from "@azure-tools/test-recorder"; -import { assert } from "chai"; import { createRecorderWithConnectionString } from "./utils/recordedClient.js"; -import type { Context } from "mocha"; import type { MessagesServiceClient, Send202Response, @@ -18,6 +16,7 @@ import type { VideoNotificationContent, DocumentNotificationContent, } from "../../src/generated/src/index.js"; +import { describe, it, assert, expect, vi, beforeEach, afterEach } from "vitest"; describe("Notification Messages Test", () => { let recorder: Recorder; diff --git a/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts b/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts index def0ec82a999..7370dbcce8d5 100644 --- a/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts +++ b/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts @@ -1,7 +1,5 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. - -import type { Context, Test } from "mocha"; import type { RecorderStartOptions, SanitizerOptions } from "@azure-tools/test-recorder"; import { Recorder, env } from "@azure-tools/test-recorder"; import type { MessagesServiceClient } from "../../../src/index.js"; From 62532a8a40036edd1b72ae00d5866b8bd9edbcb2 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:06 -0500 Subject: [PATCH 06/13] Migration: Apply codemod: "replaceAssertIsRejected" From 4052e03d1657d0d502fd0dc67b9881a8f44b2cdd Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:06 -0500 Subject: [PATCH 07/13] Migration: Apply codemod: "replaceSinonStub" From b71b312b9bec738d0101f66800c29fec098a1285 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:07 -0500 Subject: [PATCH 08/13] Migration: Apply codemod: "addViHelper" From efc01157278e94a02bb10069b9df29b4f594fd03 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:07 -0500 Subject: [PATCH 09/13] Migration: Apply codemod: "replaceSupportTracing" From 5e5ec64186c6ba1b6b49d31f54bc23f68de27cb7 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:07 -0500 Subject: [PATCH 10/13] Migration: Apply codemod: "replaceTestUtils" From 97f3991c20974931adddc7f1e575ac487105a2de Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 14:47:08 -0500 Subject: [PATCH 11/13] Migration: rushx format --- .../tsconfig.browser.config.json | 11 ++--------- .../communication-messages-rest/tsconfig.json | 12 ++---------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/sdk/communication/communication-messages-rest/tsconfig.browser.config.json b/sdk/communication/communication-messages-rest/tsconfig.browser.config.json index b6586181d006..f772e6eb3b76 100644 --- a/sdk/communication/communication-messages-rest/tsconfig.browser.config.json +++ b/sdk/communication/communication-messages-rest/tsconfig.browser.config.json @@ -1,14 +1,7 @@ { "extends": "./.tshy/build.json", - "include": [ - "./src/**/*.ts", - "./src/**/*.mts", - "./test/**/*.spec.ts", - "./test/**/*.mts" - ], - "exclude": [ - "./test/**/node/**/*.ts" - ], + "include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.spec.ts", "./test/**/*.mts"], + "exclude": ["./test/**/node/**/*.ts"], "compilerOptions": { "outDir": "./dist-test/browser", "rootDir": ".", diff --git a/sdk/communication/communication-messages-rest/tsconfig.json b/sdk/communication/communication-messages-rest/tsconfig.json index d9234afa7716..4234309cdbaf 100644 --- a/sdk/communication/communication-messages-rest/tsconfig.json +++ b/sdk/communication/communication-messages-rest/tsconfig.json @@ -2,19 +2,11 @@ "extends": "../../../tsconfig", "compilerOptions": { "paths": { - "@azure-rest/communication-messages": [ - "./src/index" - ] + "@azure-rest/communication-messages": ["./src/index"] }, "module": "NodeNext", "moduleResolution": "NodeNext", "rootDir": "." }, - "include": [ - "src/**/*.ts", - "src/**/*.mts", - "src/**/*.cts", - "samples-dev/**/*.ts", - "test/**/*.ts" - ] + "include": ["src/**/*.ts", "src/**/*.mts", "src/**/*.cts", "samples-dev/**/*.ts", "test/**/*.ts"] } From 777db70f28474d42a5271f6cb3a7725efe86a89b Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 15:13:16 -0500 Subject: [PATCH 12/13] [communication] Update @azure-rest/communication-messages to ESM/vitest --- common/config/rush/pnpm-lock.yaml | 285 +++++++++++++++++- .../communication-messages-rest/package.json | 31 +- .../test/public/messageTest.spec.ts | 36 +-- .../utils/{env.browser.ts => env-browser.mts} | 0 .../test/public/utils/recordedClient.ts | 12 +- .../vitest.browser.config.ts | 7 +- .../vitest.config.ts | 3 +- 7 files changed, 336 insertions(+), 38 deletions(-) rename sdk/communication/communication-messages-rest/test/public/utils/{env.browser.ts => env-browser.mts} (100%) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index cbc5d727c77b..279b31f82e72 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1962,6 +1962,12 @@ packages: cookie: 0.5.0 dev: false + /@bundled-es-modules/cookie@2.0.1: + resolution: {integrity: sha512-8o+5fRPLNbjbdGRRmJj3h6Hh1AQJf2dk3qQ/5ZFb+PXkRNiSoMGGUKlsgLfrxneb72axVJyIYji64E2+nNfYyw==} + dependencies: + cookie: 0.7.2 + dev: false + /@bundled-es-modules/statuses@1.0.1: resolution: {integrity: sha512-yn7BklA5acgcBr+7w064fGV+SGIFySjCKpqjcWgBAIfrAkY+4GQTJJHQMeT3V/sgz23VTEVV8TtOmkvJAhFVfg==} dependencies: @@ -4514,6 +4520,40 @@ packages: - vite dev: false + /@vitest/browser@2.1.5(@types/node@18.19.64)(playwright@1.48.2)(typescript@5.6.3)(vitest@2.1.5): + resolution: {integrity: sha512-JrpnxvkrjlBrF7oXbK/YytWVYfJIzWYeDKppANlUaisBKwDso+yXlWocAJrANx8gUxyirF355Yx80S+SKQqayg==} + peerDependencies: + playwright: '*' + safaridriver: '*' + vitest: 2.1.5 + webdriverio: '*' + peerDependenciesMeta: + playwright: + optional: true + safaridriver: + optional: true + webdriverio: + optional: true + dependencies: + '@testing-library/dom': 10.4.0 + '@testing-library/user-event': 14.5.2(@testing-library/dom@10.4.0) + '@vitest/mocker': 2.1.5(msw@2.6.4) + '@vitest/utils': 2.1.5 + magic-string: 0.30.12 + msw: 2.6.4(@types/node@18.19.64)(typescript@5.6.3) + playwright: 1.48.2 + sirv: 3.0.0 + tinyrainbow: 1.2.0 + vitest: 2.1.5(@types/node@18.19.64)(@vitest/browser@2.1.5) + ws: 8.18.0 + transitivePeerDependencies: + - '@types/node' + - bufferutil + - typescript + - utf-8-validate + - vite + dev: false + /@vitest/coverage-istanbul@1.6.0(vitest@1.6.0): resolution: {integrity: sha512-h/BwpXehkkS0qsNCS00QxiupAqVkNi0WT19BR0dQvlge5oHghoSVLx63fABYFoKxVb7Ue7+k6V2KokmQ1zdMpg==} peerDependencies: @@ -4553,6 +4593,26 @@ packages: - supports-color dev: false + /@vitest/coverage-istanbul@2.1.5(vitest@2.1.5): + resolution: {integrity: sha512-jJsS5jeHncmSvzMNE03F1pk8F9etmjzGmGyQnGMkdHdVek/bxK/3vo8Qr3e9XmVuDM3UZKOy1ObeQHgC2OxvHg==} + peerDependencies: + vitest: 2.1.5 + dependencies: + '@istanbuljs/schema': 0.1.3 + debug: 4.3.7(supports-color@8.1.1) + istanbul-lib-coverage: 3.2.2 + istanbul-lib-instrument: 6.0.3 + istanbul-lib-report: 3.0.1 + istanbul-lib-source-maps: 5.0.6 + istanbul-reports: 3.1.7 + magicast: 0.3.5 + test-exclude: 7.0.1 + tinyrainbow: 1.2.0 + vitest: 2.1.5(@types/node@18.19.64)(@vitest/browser@2.1.5) + transitivePeerDependencies: + - supports-color + dev: false + /@vitest/expect@1.6.0: resolution: {integrity: sha512-ixEvFVQjycy/oNgHjqsL6AZCDduC+tflRluaHIzKIsdbzkLn2U/iBnVeJwB6HsIjQBdfMR8Z0tRxKUsvFJEeWQ==} dependencies: @@ -4570,6 +4630,15 @@ packages: tinyrainbow: 1.2.0 dev: false + /@vitest/expect@2.1.5: + resolution: {integrity: sha512-nZSBTW1XIdpZvEJyoP/Sy8fUg0b8od7ZpGDkTUcfJ7wz/VoZAFzFfLyxVxGFhUjJzhYqSbIpfMtl/+k/dpWa3Q==} + dependencies: + '@vitest/spy': 2.1.5 + '@vitest/utils': 2.1.5 + chai: 5.1.2 + tinyrainbow: 1.2.0 + dev: false + /@vitest/mocker@2.1.4(msw@2.6.0): resolution: {integrity: sha512-Ky/O1Lc0QBbutJdW0rqLeFNbuLEyS+mIPiNdlVlp2/yhJ0SbyYqObS5IHdhferJud8MbbwMnexg4jordE5cCoQ==} peerDependencies: @@ -4604,12 +4673,52 @@ packages: vite: 5.4.10(@types/node@18.19.64) dev: false + /@vitest/mocker@2.1.5(msw@2.6.4): + resolution: {integrity: sha512-XYW6l3UuBmitWqSUXTNXcVBUCRytDogBsWuNXQijc00dtnU/9OqpXWp4OJroVrad/gLIomAq9aW8yWDBtMthhQ==} + peerDependencies: + msw: ^2.4.9 + vite: ^5.0.0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + dependencies: + '@vitest/spy': 2.1.5 + estree-walker: 3.0.3 + magic-string: 0.30.12 + msw: 2.6.4(@types/node@18.19.64)(typescript@5.6.3) + dev: false + + /@vitest/mocker@2.1.5(vite@5.4.10): + resolution: {integrity: sha512-XYW6l3UuBmitWqSUXTNXcVBUCRytDogBsWuNXQijc00dtnU/9OqpXWp4OJroVrad/gLIomAq9aW8yWDBtMthhQ==} + peerDependencies: + msw: ^2.4.9 + vite: ^5.0.0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + dependencies: + '@vitest/spy': 2.1.5 + estree-walker: 3.0.3 + magic-string: 0.30.12 + vite: 5.4.10(@types/node@18.19.64) + dev: false + /@vitest/pretty-format@2.1.4: resolution: {integrity: sha512-L95zIAkEuTDbUX1IsjRl+vyBSLh3PwLLgKpghl37aCK9Jvw0iP+wKwIFhfjdUtA2myLgjrG6VU6JCFLv8q/3Ww==} dependencies: tinyrainbow: 1.2.0 dev: false + /@vitest/pretty-format@2.1.5: + resolution: {integrity: sha512-4ZOwtk2bqG5Y6xRGHcveZVr+6txkH7M2e+nPFd6guSoN638v/1XQ0K06eOpi0ptVU/2tW/pIU4IoPotY/GZ9fw==} + dependencies: + tinyrainbow: 1.2.0 + dev: false + /@vitest/runner@1.6.0: resolution: {integrity: sha512-P4xgwPjwesuBiHisAVz/LSSZtDjOTPYZVmNAnpHHSR6ONrf8eCJOFRvUwdHn30F5M1fxhqtl7QZQUk2dprIXAg==} dependencies: @@ -4625,6 +4734,13 @@ packages: pathe: 1.1.2 dev: false + /@vitest/runner@2.1.5: + resolution: {integrity: sha512-pKHKy3uaUdh7X6p1pxOkgkVAFW7r2I818vHDthYLvUyjRfkKOU6P45PztOch4DZarWQne+VOaIMwA/erSSpB9g==} + dependencies: + '@vitest/utils': 2.1.5 + pathe: 1.1.2 + dev: false + /@vitest/snapshot@1.6.0: resolution: {integrity: sha512-+Hx43f8Chus+DCmygqqfetcAZrDJwvTj0ymqjQq4CvmpKFSTVteEOBzCusu1x2tt4OJcvBflyHUE0DZSLgEMtQ==} dependencies: @@ -4641,6 +4757,14 @@ packages: pathe: 1.1.2 dev: false + /@vitest/snapshot@2.1.5: + resolution: {integrity: sha512-zmYw47mhfdfnYbuhkQvkkzYroXUumrwWDGlMjpdUr4jBd3HZiV2w7CQHj+z7AAS4VOtWxI4Zt4bWt4/sKcoIjg==} + dependencies: + '@vitest/pretty-format': 2.1.5 + magic-string: 0.30.12 + pathe: 1.1.2 + dev: false + /@vitest/spy@1.6.0: resolution: {integrity: sha512-leUTap6B/cqi/bQkXUu6bQV5TZPx7pmMBKBQiI0rJA8c3pB56ZsaTbREnF7CJfmvAS4V2cXIBAh/3rVwrrCYgw==} dependencies: @@ -4653,6 +4777,12 @@ packages: tinyspy: 3.0.2 dev: false + /@vitest/spy@2.1.5: + resolution: {integrity: sha512-aWZF3P0r3w6DiYTVskOYuhBc7EMc3jvn1TkBg8ttylFFRqNN2XGD7V5a4aQdk6QiUzZQ4klNBSpCLJgWNdIiNw==} + dependencies: + tinyspy: 3.0.2 + dev: false + /@vitest/utils@1.6.0: resolution: {integrity: sha512-21cPiuGMoMZwiOHa2i4LXkMkMkCGzA+MVFV70jRwHo95dL4x/ts5GZhML1QWuy7yfp3WzK3lRvZi3JnXTYqrBw==} dependencies: @@ -4670,6 +4800,14 @@ packages: tinyrainbow: 1.2.0 dev: false + /@vitest/utils@2.1.5: + resolution: {integrity: sha512-yfj6Yrp0Vesw2cwJbP+cl04OC+IHFsuQsrsJBL9pyGeQXE56v1UAOQco+SR55Vf1nQzfV0QJg1Qum7AaWUwwYg==} + dependencies: + '@vitest/pretty-format': 2.1.5 + loupe: 3.1.2 + tinyrainbow: 1.2.0 + dev: false + /abort-controller@3.0.0: resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} engines: {node: '>=6.5'} @@ -6037,6 +6175,10 @@ packages: engines: {node: '>= 0.4'} dev: false + /es-module-lexer@1.5.4: + resolution: {integrity: sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==} + dev: false + /es6-error@4.1.1: resolution: {integrity: sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==} dev: false @@ -8569,6 +8711,40 @@ packages: - '@types/node' dev: false + /msw@2.6.4(@types/node@18.19.64)(typescript@5.6.3): + resolution: {integrity: sha512-Pm4LmWQeytDsNCR+A7gt39XAdtH6zQb6jnIKRig0FlvYOn8eksn3s1nXxUfz5KYUjbckof7Z4p2ewzgffPoCbg==} + engines: {node: '>=18'} + hasBin: true + requiresBuild: true + peerDependencies: + typescript: '>= 4.8.x' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@bundled-es-modules/cookie': 2.0.1 + '@bundled-es-modules/statuses': 1.0.1 + '@bundled-es-modules/tough-cookie': 0.1.6 + '@inquirer/confirm': 5.0.1(@types/node@18.19.64) + '@mswjs/interceptors': 0.36.9 + '@open-draft/deferred-promise': 2.2.0 + '@open-draft/until': 2.1.0 + '@types/cookie': 0.6.0 + '@types/statuses': 2.0.5 + chalk: 4.1.2 + graphql: 16.9.0 + headers-polyfill: 4.0.3 + is-node-process: 1.2.0 + outvariant: 1.4.3 + path-to-regexp: 6.3.0 + strict-event-emitter: 0.5.1 + type-fest: 4.26.1 + typescript: 5.6.3 + yargs: 17.7.2 + transitivePeerDependencies: + - '@types/node' + dev: false + /mustache@4.2.0: resolution: {integrity: sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==} hasBin: true @@ -10185,6 +10361,10 @@ packages: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} dev: false + /std-env@3.8.0: + resolution: {integrity: sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==} + dev: false + /stoppable@1.1.0: resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} engines: {node: '>=4', npm: '>=6'} @@ -11134,6 +11314,28 @@ packages: - terser dev: false + /vite-node@2.1.5(@types/node@18.19.64): + resolution: {integrity: sha512-rd0QIgx74q4S1Rd56XIiL2cYEdyWn13cunYBIuqh9mpmQr7gGS0IxXoP8R6OaZtNQQLyXSWbd4rXKYUbhFpK5w==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + dependencies: + cac: 6.7.14 + debug: 4.3.7(supports-color@8.1.1) + es-module-lexer: 1.5.4 + pathe: 1.1.2 + vite: 5.4.10(@types/node@18.19.64) + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + dev: false + /vite@5.4.10(@types/node@18.19.64): resolution: {integrity: sha512-1hvaPshuPUtxeQ0hsVH3Mud0ZanOLwVTneA1EgbAM5LhaZEqyPWGRQ7BtaMvUrTDeEaC8pxtj6a6jku3x4z6SQ==} engines: {node: ^18.0.0 || >=20.0.0} @@ -11387,6 +11589,65 @@ packages: - terser dev: false + /vitest@2.1.5(@types/node@18.19.64)(@vitest/browser@2.1.5): + resolution: {integrity: sha512-P4ljsdpuzRTPI/kbND2sDZ4VmieerR2c9szEZpjc+98Z9ebvnXmM5+0tHEKqYZumXqlvnmfWsjeFOjXVriDG7A==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@edge-runtime/vm': '*' + '@types/node': ^18.0.0 || >=20.0.0 + '@vitest/browser': 2.1.5 + '@vitest/ui': 2.1.5 + happy-dom: '*' + jsdom: '*' + peerDependenciesMeta: + '@edge-runtime/vm': + optional: true + '@types/node': + optional: true + '@vitest/browser': + optional: true + '@vitest/ui': + optional: true + happy-dom: + optional: true + jsdom: + optional: true + dependencies: + '@types/node': 18.19.64 + '@vitest/browser': 2.1.5(@types/node@18.19.64)(playwright@1.48.2)(typescript@5.6.3)(vitest@2.1.5) + '@vitest/expect': 2.1.5 + '@vitest/mocker': 2.1.5(vite@5.4.10) + '@vitest/pretty-format': 2.1.5 + '@vitest/runner': 2.1.5 + '@vitest/snapshot': 2.1.5 + '@vitest/spy': 2.1.5 + '@vitest/utils': 2.1.5 + chai: 5.1.2 + debug: 4.3.7(supports-color@8.1.1) + expect-type: 1.1.0 + magic-string: 0.30.12 + pathe: 1.1.2 + std-env: 3.8.0 + tinybench: 2.9.0 + tinyexec: 0.3.1 + tinypool: 1.0.1 + tinyrainbow: 1.2.0 + vite: 5.4.10(@types/node@18.19.64) + vite-node: 2.1.5(@types/node@18.19.64) + why-is-node-running: 2.3.0 + transitivePeerDependencies: + - less + - lightningcss + - msw + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + dev: false + /void-elements@2.0.1: resolution: {integrity: sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung==} engines: {node: '>=0.10.0'} @@ -18971,7 +19232,7 @@ packages: dev: false file:projects/communication-messages.tgz: - resolution: {integrity: sha512-oEFJuO+RzX3gA86WxlnTcUnnFTSzQPzasiwupB6/pl+KjI80ZX9UAOKDb2qRW1v1Pu3Ch/YeFAprVg21znmOAQ==, tarball: file:projects/communication-messages.tgz} + resolution: {integrity: sha512-IcDGaDqJ1GhWIIajWNiyS4FUnZB3JEvDYXG7mopGzk4wgpUfOhVoVrJuz07pg3unKTn48Oqlm4EOWFmAm0wbag==, tarball: file:projects/communication-messages.tgz} name: '@rush-temp/communication-messages' version: 0.0.0 dependencies: @@ -18981,6 +19242,8 @@ packages: '@types/chai': 4.3.20 '@types/mocha': 10.0.9 '@types/node': 18.19.64 + '@vitest/browser': 2.1.5(@types/node@18.19.64)(playwright@1.48.2)(typescript@5.6.3)(vitest@2.1.5) + '@vitest/coverage-istanbul': 2.1.5(vitest@2.1.5) autorest: 3.7.1 chai: 4.3.10 dotenv: 16.4.5 @@ -18997,18 +19260,32 @@ packages: karma-sourcemap-loader: 0.4.0 mocha: 10.8.2 nyc: 17.1.0 + playwright: 1.48.2 source-map-support: 0.5.21 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.5(@types/node@18.19.64)(@vitest/browser@2.1.5) 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-phone-numbers.tgz: diff --git a/sdk/communication/communication-messages-rest/package.json b/sdk/communication/communication-messages-rest/package.json index 6dd7be2427b2..c5b4527f238b 100644 --- a/sdk/communication/communication-messages-rest/package.json +++ b/sdk/communication/communication-messages-rest/package.json @@ -13,9 +13,9 @@ "isomorphic" ], "license": "MIT", - "main": "dist/index.js", - "module": "./dist-esm/src/index.js", - "types": "./types/communication-messages.d.ts", + "main": "./dist/commonjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/commonjs/index.d.ts", "repository": "github:Azure/azure-sdk-for-js", "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" @@ -58,8 +58,8 @@ "sideEffects": false, "autoPublish": false, "dependencies": { - "@azure-rest/core-client": "^1.4.0", - "@azure/communication-common": "^2.2.0", + "@azure-rest/core-client": "^2.3.1", + "@azure/communication-common": "^2.3.1", "@azure/core-auth": "^1.6.0", "@azure/core-paging": "^1.5.0", "@azure/core-rest-pipeline": "^1.12.0", @@ -118,5 +118,26 @@ "react-native" ], "selfLink": false + }, + "exports": { + "./package.json": "./package.json", + ".": { + "browser": { + "types": "./dist/browser/index.d.ts", + "default": "./dist/browser/index.js" + }, + "react-native": { + "types": "./dist/react-native/index.d.ts", + "default": "./dist/react-native/index.js" + }, + "import": { + "types": "./dist/esm/index.d.ts", + "default": "./dist/esm/index.js" + }, + "require": { + "types": "./dist/commonjs/index.d.ts", + "default": "./dist/commonjs/index.js" + } + } } } diff --git a/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts b/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts index 5705bebb4b86..2ce8b5eed45f 100644 --- a/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts +++ b/sdk/communication/communication-messages-rest/test/public/messageTest.spec.ts @@ -16,23 +16,23 @@ import type { VideoNotificationContent, DocumentNotificationContent, } from "../../src/generated/src/index.js"; -import { describe, it, assert, expect, vi, beforeEach, afterEach } from "vitest"; +import { describe, it, assert, beforeEach, afterEach } from "vitest"; describe("Notification Messages Test", () => { let recorder: Recorder; let client: MessagesServiceClient; - beforeEach(async function (ctx) { - ({ client, recorder } = await createRecorderWithConnectionString(this)); + beforeEach(async (ctx) => { + ({ client, recorder } = await createRecorderWithConnectionString(ctx)); }); - afterEach(async function () { + afterEach(async (ctx) => { if (!ctx.task.pending) { await recorder.stop(); } }); - it("send simple text message test", async function () { + it("send simple text message test", async () => { const result = await client.path("/messages/notifications:send").post({ contentType: "application/json", body: { @@ -48,7 +48,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send document message test", async function () { + it("send document message test", async () => { const documentMessage: DocumentNotificationContent = { kind: "document", mediaUri: "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", @@ -66,7 +66,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send video message test", async function () { + it("send video message test", async () => { const videoMessage: VideoNotificationContent = { kind: "video", mediaUri: "https://sample-videos.com/video321/mp4/480/big_buck_bunny_480p_1mb.mp4", @@ -84,7 +84,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send audio message test", async function () { + it("send audio message test", async () => { const audioMessage: AudioNotificationContent = { kind: "audio", mediaUri: "https://sample-videos.com/audio/mp3/wave.mp3", @@ -102,7 +102,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send image message test", async function () { + it("send image message test", async () => { const imageMessage: ImageNotificationContent = { kind: "image", mediaUri: "https://www.w3schools.com/w3css/img_lights.jpg", @@ -121,7 +121,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send simple text template message test", async function () { + it("send simple text template message test", async () => { const DaysTemplateValue: MessageTemplateValue = { kind: "text", name: "Days", @@ -159,7 +159,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send template message with video test", async function () { + it("send template message with video test", async () => { const HeaderVideo: MessageTemplateValue = { kind: "video", name: "HappyHourVideo", @@ -217,7 +217,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send template message with image test", async function () { + it("send template message with image test", async () => { const HeaderImage: MessageTemplateValue = { kind: "image", name: "CompanyPhoto", @@ -266,7 +266,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send template message with document test", async function () { + it("send template message with document test", async () => { const HeaderDoc: MessageTemplateValue = { kind: "document", name: "BoardingPass", @@ -333,7 +333,7 @@ describe("Notification Messages Test", () => { assert.isDefined(response.body.receipts[0].messageId); }); - it("send template message with quick reply buttons test", async function () { + it("send template message with quick reply buttons test", async () => { const NameTemplateValue: MessageTemplateValue = { kind: "text", name: "NameValue", @@ -398,17 +398,17 @@ describe("Message Template Read Test", () => { let recorder: Recorder; let client: MessagesServiceClient; - beforeEach(async function (ctx) { - ({ client, recorder } = await createRecorderWithConnectionString(this)); + beforeEach(async (ctx) => { + ({ client, recorder } = await createRecorderWithConnectionString(ctx)); }); - afterEach(async function () { + afterEach(async (ctx) => { if (!ctx.task.pending) { await recorder.stop(); } }); - it("get template test", async function () { + it("get template test", async () => { const result = await client .path("/messages/channels/{channelId}/templates", env.CHANNEL_ID || "") .get(); diff --git a/sdk/communication/communication-messages-rest/test/public/utils/env.browser.ts b/sdk/communication/communication-messages-rest/test/public/utils/env-browser.mts similarity index 100% rename from sdk/communication/communication-messages-rest/test/public/utils/env.browser.ts rename to sdk/communication/communication-messages-rest/test/public/utils/env-browser.mts diff --git a/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts b/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts index 7370dbcce8d5..434976aa17c6 100644 --- a/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts +++ b/sdk/communication/communication-messages-rest/test/public/utils/recordedClient.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { RecorderStartOptions, SanitizerOptions } from "@azure-tools/test-recorder"; +import type { RecorderStartOptions, SanitizerOptions, TestInfo } from "@azure-tools/test-recorder"; import { Recorder, env } from "@azure-tools/test-recorder"; import type { MessagesServiceClient } from "../../../src/index.js"; import MessageClient from "../../../src/index.js"; @@ -55,7 +55,7 @@ const recorderEnvSetup: RecorderStartOptions = { * Should be called first in the test suite to make sure environment variables are * read before they are being used. */ -export async function createRecorder(context: Test | undefined): Promise { +export async function createRecorder(context: TestInfo | undefined): Promise { const recorder = new Recorder(context); await recorder.start(recorderEnvSetup); await recorder.setMatcher("CustomDefaultMatcher", { @@ -69,8 +69,8 @@ export async function createRecorder(context: Test | undefined): Promise { - const recorder = await createRecorder(context.currentTest); +export async function createRecorderWithToken(context: TestInfo): Promise { + const recorder = await createRecorder(context); const credential: TokenCredential = createTestCredential(); const endpoint = parseConnectionString( @@ -84,9 +84,9 @@ export async function createRecorderWithToken(context: Context): Promise { - const recorder = await createRecorder(context.currentTest); + const recorder = await createRecorder(context); const client = MessageClient( env.COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING ?? "", diff --git a/sdk/communication/communication-messages-rest/vitest.browser.config.ts b/sdk/communication/communication-messages-rest/vitest.browser.config.ts index b48c61b2ef46..50ec2d5489b0 100644 --- a/sdk/communication/communication-messages-rest/vitest.browser.config.ts +++ b/sdk/communication/communication-messages-rest/vitest.browser.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -9,9 +8,9 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: [ - "dist-test/browser/test/**/*.spec.js", - ], + include: ["dist-test/browser/test/**/*.spec.js"], + hookTimeout: 5000000, + testTimeout: 5000000, }, }), ); diff --git a/sdk/communication/communication-messages-rest/vitest.config.ts b/sdk/communication/communication-messages-rest/vitest.config.ts index 39267dd2f56f..d01fdec8ac69 100644 --- a/sdk/communication/communication-messages-rest/vitest.config.ts +++ b/sdk/communication/communication-messages-rest/vitest.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -10,6 +9,8 @@ export default mergeConfig( defineConfig({ test: { include: ["test/**/*.spec.ts"], + hookTimeout: 5000000, + testTimeout: 5000000, }, }), ); From af73fe3a621279463409ce1110830e8f991af0a9 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Thu, 14 Nov 2024 15:45:43 -0500 Subject: [PATCH 13/13] [communication] Update @azure-rest/communication-messages to ESM/vitest --- .../communication-messages-rest/tsconfig.json | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sdk/communication/communication-messages-rest/tsconfig.json b/sdk/communication/communication-messages-rest/tsconfig.json index 4234309cdbaf..e803d4d78e1a 100644 --- a/sdk/communication/communication-messages-rest/tsconfig.json +++ b/sdk/communication/communication-messages-rest/tsconfig.json @@ -8,5 +8,13 @@ "moduleResolution": "NodeNext", "rootDir": "." }, - "include": ["src/**/*.ts", "src/**/*.mts", "src/**/*.cts", "samples-dev/**/*.ts", "test/**/*.ts"] + "include": [ + "src/**/*.ts", + "src/**/*.mts", + "src/**/*.cts", + "samples-dev/**/*.ts", + "test/**/*.ts", + "test/**/*.mts", + "test/**/*.cts" + ] }