diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 30ef27a5568b..6c14cf78e569 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -20553,7 +20553,7 @@ packages: dev: false file:projects/health-insights-cancerprofiling.tgz: - resolution: {integrity: sha512-fAdFqmdr0LMhpG7oC5nnvnll+JoRDQo2yfqWDwz/1CCo+jYW6TkCHUD5xBL573SCSwgHuiwnTBy8XrzkZPHRcw==, tarball: file:projects/health-insights-cancerprofiling.tgz} + resolution: {integrity: sha512-VbNwjG9FeYaNHVZ5ccHivYA5aMTBQaj9e/3S1qhujNHdW79W4w9R989l0SMtitK7WXcC7OfQunMVVA/v5BKPeA==, tarball: file:projects/health-insights-cancerprofiling.tgz} name: '@rush-temp/health-insights-cancerprofiling' version: 0.0.0 dependencies: @@ -21362,7 +21362,7 @@ packages: dev: false file:projects/maps-search.tgz: - resolution: {integrity: sha512-X/aBErvhTJe1CqpWhvb7NuzkbSSNzua6ZCpZj7zq43E9KiyvZPm47NcdNTZUXs0UCP+NnH2k+RXzU8ihSCSQqQ==, tarball: file:projects/maps-search.tgz} + resolution: {integrity: sha512-3L9N9SrTi+SdvxB/8TQWgZDIuBtS6ODj8qc+QNqdc5XyToQop38/Hh6GV+xVt+W28umT3ZufBQbz9dA5McL/6w==, tarball: file:projects/maps-search.tgz} name: '@rush-temp/maps-search' version: 0.0.0 dependencies: @@ -21374,6 +21374,8 @@ packages: '@types/chai': 4.3.20 '@types/mocha': 10.0.10 '@types/node': 18.19.65 + '@vitest/browser': 2.1.5(@types/node@18.19.65)(playwright@1.49.0)(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 @@ -21390,18 +21392,32 @@ packages: karma-sourcemap-loader: 0.3.8 mocha: 10.8.2 nyc: 17.1.0 + playwright: 1.49.0 source-map-support: 0.5.21 ts-node: 10.9.2(@types/node@18.19.65)(typescript@5.6.3) tslib: 2.8.1 typescript: 5.6.3 + vitest: 2.1.5(@types/node@18.19.65)(@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/microsoft-playwright-testing.tgz: diff --git a/sdk/maps/maps-search-rest/api-extractor.json b/sdk/maps/maps-search-rest/api-extractor.json index 3b45c10dca04..9a6ebf0a0ba0 100644 --- a/sdk/maps/maps-search-rest/api-extractor.json +++ b/sdk/maps/maps-search-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/maps-search-rest.d.ts" + "publicTrimmedFilePath": "dist/maps-search-rest.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/maps/maps-search-rest/generated/index.ts b/sdk/maps/maps-search-rest/generated/index.ts deleted file mode 100644 index 488446420b82..000000000000 --- a/sdk/maps/maps-search-rest/generated/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import MapsSearchClient from "./mapsSearchClient"; - -export * from "./mapsSearchClient"; -export * from "./parameters"; -export * from "./responses"; -export * from "./clientDefinitions"; -export * from "./isUnexpected"; -export * from "./models"; -export * from "./outputModels"; - -export default MapsSearchClient; diff --git a/sdk/maps/maps-search-rest/karma.conf.js b/sdk/maps/maps-search-rest/karma.conf.js deleted file mode 100644 index 8793e336491d..000000000000 --- a/sdk/maps/maps-search-rest/karma.conf.js +++ /dev/null @@ -1,125 +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", "MAPS_RESOURCE_CLIENT_ID", "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", - }, - }, - }); -}; diff --git a/sdk/maps/maps-search-rest/package.json b/sdk/maps/maps-search-rest/package.json index c03f6c9db2fb..ef9a8e541e84 100644 --- a/sdk/maps/maps-search-rest/package.json +++ b/sdk/maps/maps-search-rest/package.json @@ -13,31 +13,28 @@ "isomorphic" ], "license": "MIT", - "main": "dist/index.js", - "module": "./dist-esm/src/index.js", - "types": "./types/maps-search-rest.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" }, "files": [ "dist/", - "dist-esm/src/", - "types/maps-search-rest.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 bundle", - "build:debug": "tsc -p . && dev-tool run bundle && dev-tool run extract-api", - "build:node": "tsc -p . && dev-tool run bundle --browser-test false", + "build": "npm run clean && dev-tool run build-package && dev-tool run extract-api", + "build:browser": "dev-tool run build-package && dev-tool run bundle", + "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 bundle --browser-test false", "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-browser dist-esm test-dist temp types *.tgz *.log", "execute:samples": "dev-tool samples run samples-dev", @@ -45,8 +42,8 @@ "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", "generate:client": "autorest --typescript swagger/README.md && npm run format", "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 5000000 '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 src test", "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", "pack": "npm pack 2>&1", @@ -54,51 +51,38 @@ "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, "autoPublish": false, "dependencies": { - "@azure-rest/core-client": "^1.0.0", - "@azure/core-auth": "^1.3.0", - "@azure/core-lro": "^2.2.0", - "@azure/core-rest-pipeline": "^1.8.0", - "@azure/logger": "^1.0.4", + "@azure-rest/core-client": "^2.3.1", + "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^2.7.2", + "@azure/core-rest-pipeline": "^1.18.0", + "@azure/logger": "^1.1.4", "@azure/maps-common": "1.0.0-beta.2", - "tslib": "^2.2.0" + "tslib": "^2.8.1" }, "devDependencies": { - "@azure-tools/test-credential": "^1.0.0", - "@azure-tools/test-recorder": "^3.0.0", - "@azure-tools/test-utils": "~1.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/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.2.8", - "@types/mocha": "^10.0.0", + "@azure/identity": "^4.5.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": "^1.1.0", - "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.3.8", - "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.49.0", + "typescript": "~5.6.2", + "vitest": "^2.1.5" }, "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/maps/maps-search-rest/README.md", "//metadata": { @@ -109,9 +93,7 @@ } ] }, - "browser": { - "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" - }, + "browser": "./dist/browser/index.js", "//sampleConfiguration": { "productName": "MapsSearchClient", "productSlugs": [ @@ -123,5 +105,42 @@ }, "apiRefLink": "https://docs.microsoft.com/javascript/api/@azure-rest/maps-search", "disableDocsMs": true + }, + "type": "module", + "tshy": { + "exports": { + "./package.json": "./package.json", + ".": "./src/index.ts" + }, + "dialects": [ + "esm", + "commonjs" + ], + "esmDialects": [ + "browser", + "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/maps/maps-search-rest/samples-dev/geocoding.ts b/sdk/maps/maps-search-rest/samples-dev/geocoding.ts index 5c1d99272c10..16f1ddb4dc42 100644 --- a/sdk/maps/maps-search-rest/samples-dev/geocoding.ts +++ b/sdk/maps/maps-search-rest/samples-dev/geocoding.ts @@ -3,9 +3,7 @@ import MapsSearch, { isUnexpected } from "@azure-rest/maps-search"; import { DefaultAzureCredential } from "@azure/identity"; -import * as dotenv from "dotenv"; - -dotenv.config(); +import "dotenv/config"; /** * @summary Demonstrate how to search the coordinates of an address (a.k.a. Geocoding). diff --git a/sdk/maps/maps-search-rest/samples-dev/geocodingBatch.ts b/sdk/maps/maps-search-rest/samples-dev/geocodingBatch.ts index c634bc0b6430..0c9bbf275953 100644 --- a/sdk/maps/maps-search-rest/samples-dev/geocodingBatch.ts +++ b/sdk/maps/maps-search-rest/samples-dev/geocodingBatch.ts @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import MapsSearch, { GeocodingBatchResponseOutput, isUnexpected } from "@azure-rest/maps-search"; +import type { GeocodingBatchResponseOutput } from "@azure-rest/maps-search"; +import MapsSearch, { isUnexpected } from "@azure-rest/maps-search"; import { DefaultAzureCredential } from "@azure/identity"; -import * as dotenv from "dotenv"; - -dotenv.config(); +import "dotenv/config"; /** * @summary This sample demonstrates how to make a batched search address request. diff --git a/sdk/maps/maps-search-rest/samples-dev/reverseGeocoding.ts b/sdk/maps/maps-search-rest/samples-dev/reverseGeocoding.ts index 03aeccfee5c9..fe93fc8f9abe 100644 --- a/sdk/maps/maps-search-rest/samples-dev/reverseGeocoding.ts +++ b/sdk/maps/maps-search-rest/samples-dev/reverseGeocoding.ts @@ -3,9 +3,7 @@ import MapsSearch, { isUnexpected } from "@azure-rest/maps-search"; import { DefaultAzureCredential } from "@azure/identity"; -import * as dotenv from "dotenv"; - -dotenv.config(); +import "dotenv/config"; /** * @summary This sample demonstrates how to reverse a geocode to an address. diff --git a/sdk/maps/maps-search-rest/samples-dev/reverseGeocodingBatch.ts b/sdk/maps/maps-search-rest/samples-dev/reverseGeocodingBatch.ts index 1f44c417a146..cc6664ab62e4 100644 --- a/sdk/maps/maps-search-rest/samples-dev/reverseGeocodingBatch.ts +++ b/sdk/maps/maps-search-rest/samples-dev/reverseGeocodingBatch.ts @@ -1,11 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import MapsSearch, { GeocodingBatchResponseOutput, isUnexpected } from "@azure-rest/maps-search"; +import type { GeocodingBatchResponseOutput } from "@azure-rest/maps-search"; +import MapsSearch, { isUnexpected } from "@azure-rest/maps-search"; import { DefaultAzureCredential } from "@azure/identity"; -import * as dotenv from "dotenv"; - -dotenv.config(); +import "dotenv/config"; /** * @summary Demonstrate how to request a batch of reverse geocoding. diff --git a/sdk/maps/maps-search-rest/samples-dev/searchPolygons.ts b/sdk/maps/maps-search-rest/samples-dev/searchPolygons.ts index 4ea4947c408d..b0d1cd7d4ffe 100644 --- a/sdk/maps/maps-search-rest/samples-dev/searchPolygons.ts +++ b/sdk/maps/maps-search-rest/samples-dev/searchPolygons.ts @@ -3,9 +3,7 @@ import MapsSearch, { isUnexpected } from "@azure-rest/maps-search"; import { DefaultAzureCredential } from "@azure/identity"; -import * as dotenv from "dotenv"; - -dotenv.config(); +import "dotenv/config"; /** * @summary Demonstrate how to request the geometry data such as a city or country outline for a set of entities, previously retrieved from an Online Search request in GeoJSON format. diff --git a/sdk/maps/maps-search-rest/src/MapsSearch.ts b/sdk/maps/maps-search-rest/src/MapsSearch.ts index 1dc9301f8cce..61c7a44d417b 100644 --- a/sdk/maps/maps-search-rest/src/MapsSearch.ts +++ b/sdk/maps/maps-search-rest/src/MapsSearch.ts @@ -5,8 +5,8 @@ import type { ClientOptions } from "@azure-rest/core-client"; import type { AzureKeyCredential, AzureSASCredential, TokenCredential } from "@azure/core-auth"; import { isSASCredential, isTokenCredential } from "@azure/core-auth"; import { createMapsClientIdPolicy } from "@azure/maps-common"; -import type { MapsSearchClient } from "../generated"; -import createClient from "../generated"; +import type { MapsSearchClient } from "./generated/index.js"; +import createClient from "./generated/index.js"; import { bearerTokenAuthenticationPolicy } from "@azure/core-rest-pipeline"; /** diff --git a/sdk/maps/maps-search-rest/generated/clientDefinitions.ts b/sdk/maps/maps-search-rest/src/generated/clientDefinitions.ts similarity index 99% rename from sdk/maps/maps-search-rest/generated/clientDefinitions.ts rename to sdk/maps/maps-search-rest/src/generated/clientDefinitions.ts index 324d124601d9..c0934494090f 100644 --- a/sdk/maps/maps-search-rest/generated/clientDefinitions.ts +++ b/sdk/maps/maps-search-rest/src/generated/clientDefinitions.ts @@ -7,7 +7,7 @@ import { SearchGetPolygonParameters, SearchGetReverseGeocodingParameters, SearchGetReverseGeocodingBatchParameters, -} from "./parameters"; +} from "./parameters.js"; import { SearchGetGeocoding200Response, SearchGetGeocodingDefaultResponse, @@ -19,7 +19,7 @@ import { SearchGetReverseGeocodingDefaultResponse, SearchGetReverseGeocodingBatch200Response, SearchGetReverseGeocodingBatchDefaultResponse, -} from "./responses"; +} from "./responses.js"; import { Client, StreamableMethod } from "@azure-rest/core-client"; export interface GetGeocoding { diff --git a/sdk/maps/maps-search-rest/src/generated/index.ts b/sdk/maps/maps-search-rest/src/generated/index.ts new file mode 100644 index 000000000000..062ad78d87e8 --- /dev/null +++ b/sdk/maps/maps-search-rest/src/generated/index.ts @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import MapsSearchClient from "./mapsSearchClient.js"; + +export * from "./mapsSearchClient.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 default MapsSearchClient; diff --git a/sdk/maps/maps-search-rest/generated/isUnexpected.ts b/sdk/maps/maps-search-rest/src/generated/isUnexpected.ts similarity index 99% rename from sdk/maps/maps-search-rest/generated/isUnexpected.ts rename to sdk/maps/maps-search-rest/src/generated/isUnexpected.ts index 06ec16983749..97eb0d9c9a27 100644 --- a/sdk/maps/maps-search-rest/generated/isUnexpected.ts +++ b/sdk/maps/maps-search-rest/src/generated/isUnexpected.ts @@ -12,7 +12,7 @@ import { SearchGetReverseGeocodingDefaultResponse, SearchGetReverseGeocodingBatch200Response, SearchGetReverseGeocodingBatchDefaultResponse, -} from "./responses"; +} from "./responses.js"; const responseMap: Record = { "GET /geocode": ["200"], diff --git a/sdk/maps/maps-search-rest/generated/logger.ts b/sdk/maps/maps-search-rest/src/generated/logger.ts similarity index 100% rename from sdk/maps/maps-search-rest/generated/logger.ts rename to sdk/maps/maps-search-rest/src/generated/logger.ts diff --git a/sdk/maps/maps-search-rest/generated/mapsSearchClient.ts b/sdk/maps/maps-search-rest/src/generated/mapsSearchClient.ts similarity index 95% rename from sdk/maps/maps-search-rest/generated/mapsSearchClient.ts rename to sdk/maps/maps-search-rest/src/generated/mapsSearchClient.ts index 6581f5e89847..f9b43b8faaae 100644 --- a/sdk/maps/maps-search-rest/generated/mapsSearchClient.ts +++ b/sdk/maps/maps-search-rest/src/generated/mapsSearchClient.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 { KeyCredential } from "@azure/core-auth"; -import { MapsSearchClient } from "./clientDefinitions"; +import { MapsSearchClient } from "./clientDefinitions.js"; /** The optional parameters for the client */ export interface MapsSearchClientOptions extends ClientOptions { diff --git a/sdk/maps/maps-search-rest/generated/models.ts b/sdk/maps/maps-search-rest/src/generated/models.ts similarity index 100% rename from sdk/maps/maps-search-rest/generated/models.ts rename to sdk/maps/maps-search-rest/src/generated/models.ts diff --git a/sdk/maps/maps-search-rest/generated/outputModels.ts b/sdk/maps/maps-search-rest/src/generated/outputModels.ts similarity index 100% rename from sdk/maps/maps-search-rest/generated/outputModels.ts rename to sdk/maps/maps-search-rest/src/generated/outputModels.ts diff --git a/sdk/maps/maps-search-rest/generated/parameters.ts b/sdk/maps/maps-search-rest/src/generated/parameters.ts similarity index 99% rename from sdk/maps/maps-search-rest/generated/parameters.ts rename to sdk/maps/maps-search-rest/src/generated/parameters.ts index 3a3040443689..9a3cd5b4b32a 100644 --- a/sdk/maps/maps-search-rest/generated/parameters.ts +++ b/sdk/maps/maps-search-rest/src/generated/parameters.ts @@ -5,7 +5,7 @@ import { RequestParameters } from "@azure-rest/core-client"; import { GeocodingBatchRequestBody, ReverseGeocodingBatchRequestBody, -} from "./models"; +} from "./models.js"; export interface SearchGetGeocodingQueryParamProperties { /** Maximum number of responses that will be returned. Default: 5, minimum: 1 and maximum: 20. */ diff --git a/sdk/maps/maps-search-rest/generated/responses.ts b/sdk/maps/maps-search-rest/src/generated/responses.ts similarity index 99% rename from sdk/maps/maps-search-rest/generated/responses.ts rename to sdk/maps/maps-search-rest/src/generated/responses.ts index 16de475d489a..e9dfee856731 100644 --- a/sdk/maps/maps-search-rest/generated/responses.ts +++ b/sdk/maps/maps-search-rest/src/generated/responses.ts @@ -8,7 +8,7 @@ import { ErrorResponseOutput, GeocodingBatchResponseOutput, BoundaryOutput, -} from "./outputModels"; +} from "./outputModels.js"; export interface SearchGetGeocoding200Headers { /** request id. */ diff --git a/sdk/maps/maps-search-rest/src/index.ts b/sdk/maps/maps-search-rest/src/index.ts index 9a0c5844337b..9d691b4503b4 100644 --- a/sdk/maps/maps-search-rest/src/index.ts +++ b/sdk/maps/maps-search-rest/src/index.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import MapsSearch from "./MapsSearch"; -export * from "../generated"; +import MapsSearch from "./MapsSearch.js"; + +export * from "./generated/index.js"; export default MapsSearch; diff --git a/sdk/maps/maps-search-rest/swagger/README.md b/sdk/maps/maps-search-rest/swagger/README.md index f102ba07afa0..1e3674affcc2 100644 --- a/sdk/maps/maps-search-rest/swagger/README.md +++ b/sdk/maps/maps-search-rest/swagger/README.md @@ -25,7 +25,7 @@ generate-test: false generate-sample: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ -source-code-folder-path: ./generated +source-code-folder-path: ./src/generated input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/main/specification/maps/data-plane/Search/stable/2023-06-01/search.json package-version: 2.0.0-beta.2 rest-level-client: true diff --git a/sdk/maps/maps-search-rest/test/public/MapsSearch.spec.ts b/sdk/maps/maps-search-rest/test/public/MapsSearch.spec.ts index 986dd8142357..144bedffbfe9 100644 --- a/sdk/maps/maps-search-rest/test/public/MapsSearch.spec.ts +++ b/sdk/maps/maps-search-rest/test/public/MapsSearch.spec.ts @@ -1,33 +1,31 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Context } from "mocha"; import type { Recorder } from "@azure-tools/test-recorder"; import { env } from "@azure-tools/test-recorder"; import { isNodeLike } from "@azure/core-util"; import { createTestCredential } from "@azure-tools/test-credential"; -import { assert } from "chai"; -import { createClient, createRecorder } from "./utils/recordedClient"; -import type { MapsSearchClient } from "../../src"; -import MapsSearch, { isUnexpected } from "../../src"; +import { createClient, createRecorder } from "./utils/recordedClient.js"; +import type { MapsSearchClient } from "../../src/index.js"; +import MapsSearch, { isUnexpected } from "../../src/index.js"; +import { describe, it, assert, beforeEach, afterEach } from "vitest"; -describe("Authentication", function () { +describe("Authentication", () => { let recorder: Recorder; - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); + beforeEach(async (ctx) => { + recorder = await createRecorder(ctx); }); - afterEach(async function () { + afterEach(async () => { await recorder.stop(); }); - it("should work with Microsoft Entra ID authentication", async function () { - /** - * Skip this test in browser because we have to use InteractiveBrowserCredential in the browser. - * But it requires user's interaction, which is not testable in karma. - * */ - if (!isNodeLike) this.skip(); + /** + * Skip this test in browser because we have to use InteractiveBrowserCredential in the browser. + * But it requires user's interaction, which is not testable in karma. + * */ + it("should work with Microsoft Entra ID authentication", { skip: !isNodeLike }, async () => { /** * Use createTestCredential() instead of new DefaultAzureCredential(), else the playback mode won't work * Reference: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/test-quickstart.md#azuread-oauth2-authentication @@ -44,24 +42,24 @@ describe("Authentication", function () { }); }); -describe("Endpoint can be overwritten", function () { +describe("Endpoint can be overwritten", () => { let recorder: Recorder; - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); + beforeEach(async (ctx) => { + recorder = await createRecorder(ctx); }); - afterEach(async function () { + afterEach(async () => { await recorder.stop(); }); - it("should be executed without specifying baseUrl", async function () { + it("should be executed without specifying baseUrl", async () => { const client = createClient(recorder.configureClientOptions({})); const response = await client.path("/geocode").get({ queryParameters: { query: "Starbucks" } }); assert.isOk(!isUnexpected(response)); }); - it("should be executed with different baseUrl", async function () { + it("should be executed with different baseUrl", async () => { const client = createClient( recorder.configureClientOptions({ baseUrl: "https://us.atlas.microsoft.com/" }), ); @@ -70,20 +68,20 @@ describe("Endpoint can be overwritten", function () { }); }); -describe("Get Search Polygon", function () { +describe("Get Search Polygon", () => { let recorder: Recorder; let client: MapsSearchClient; - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); + beforeEach(async (ctx) => { + recorder = await createRecorder(ctx); client = createClient(recorder.configureClientOptions({})); }); - afterEach(async function () { + afterEach(async () => { await recorder.stop(); }); - it("should accept coordinates and other options and return geometry data", async function () { + it("should accept coordinates and other options and return geometry data", async () => { const response = await client.path("/search/polygon").get({ queryParameters: { coordinates: [-122.204141, 47.61256], @@ -98,20 +96,20 @@ describe("Get Search Polygon", function () { }); }); -describe("/geocode", function () { +describe("/geocode", () => { let recorder: Recorder; let client: MapsSearchClient; - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); + beforeEach(async (ctx) => { + recorder = await createRecorder(ctx); client = createClient(recorder.configureClientOptions({})); }); - afterEach(async function () { + afterEach(async () => { await recorder.stop(); }); - it("should return non-empty results", async function () { + it("should return non-empty results", async () => { const response = await client .path("/geocode") .get({ queryParameters: { query: "1 Microsoft Way, Redmond, WA 98052" } }); @@ -122,20 +120,20 @@ describe("/geocode", function () { }); }); -describe("/geocode:batch", function () { +describe("/geocode:batch", () => { let recorder: Recorder; let client: MapsSearchClient; - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); + beforeEach(async (ctx) => { + recorder = await createRecorder(ctx); client = createClient(recorder.configureClientOptions({})); }); - afterEach(async function () { + afterEach(async () => { await recorder.stop(); }); - it("should return non-empty results", async function () { + it("should return non-empty results", async () => { const response = await client.path("/geocode:batch").post({ body: { batchItems: [ @@ -151,7 +149,7 @@ describe("/geocode:batch", function () { assert.isNotEmpty(response.body); }); - it("should be expected even one of the batch items failed", async function () { + it("should be expected even one of the batch items failed", async () => { const response = await client.path("/geocode:batch").post({ body: { batchItems: [ @@ -167,20 +165,20 @@ describe("/geocode:batch", function () { }); }); -describe("/reverseGeocode", function () { +describe("/reverseGeocode", () => { let recorder: Recorder; let client: MapsSearchClient; - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); + beforeEach(async (ctx) => { + recorder = await createRecorder(ctx); client = createClient(recorder.configureClientOptions({})); }); - afterEach(async function () { + afterEach(async () => { await recorder.stop(); }); - it("should throw error if query is invalid", async function () { + it("should throw error if query is invalid", async () => { // "The provided coordinates in query are invalid, out of range, or not in the expected format" assert.isTrue( isUnexpected( @@ -194,7 +192,7 @@ describe("/reverseGeocode", function () { ); }); - it("should return non-empty results", async function () { + it("should return non-empty results", async () => { const response = await client .path("/reverseGeocode") .get({ queryParameters: { coordinates: [121, 25] } }); @@ -205,20 +203,20 @@ describe("/reverseGeocode", function () { }); }); -describe("/reverseGeocode:batch", function () { +describe("/reverseGeocode:batch", () => { let recorder: Recorder; let client: MapsSearchClient; - beforeEach(async function (this: Context) { - recorder = await createRecorder(this); + beforeEach(async (ctx) => { + recorder = await createRecorder(ctx); client = createClient(recorder.configureClientOptions({})); }); - afterEach(async function () { + afterEach(async () => { await recorder.stop(); }); - it("should return non-empty results", async function () { + it("should return non-empty results", async () => { const response = await client.path("/reverseGeocode:batch").post({ body: { batchItems: [ @@ -233,7 +231,7 @@ describe("/reverseGeocode:batch", function () { assert.isNotEmpty(response.body); }); - it("should be expected even one of the batch items failed", async function () { + it("should be expected even one of the batch items failed", async () => { const response = await client.path("/reverseGeocode:batch").post({ body: { batchItems: [ diff --git a/sdk/maps/maps-search-rest/test/public/utils/env.browser.ts b/sdk/maps/maps-search-rest/test/public/utils/env-browser.mts similarity index 100% rename from sdk/maps/maps-search-rest/test/public/utils/env.browser.ts rename to sdk/maps/maps-search-rest/test/public/utils/env-browser.mts diff --git a/sdk/maps/maps-search-rest/test/public/utils/recordedClient.ts b/sdk/maps/maps-search-rest/test/public/utils/recordedClient.ts index 27531b789f46..147b6e646f21 100644 --- a/sdk/maps/maps-search-rest/test/public/utils/recordedClient.ts +++ b/sdk/maps/maps-search-rest/test/public/utils/recordedClient.ts @@ -1,13 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import type { Context } from "mocha"; -import type { RecorderStartOptions } from "@azure-tools/test-recorder"; +import type { RecorderStartOptions, TestInfo } from "@azure-tools/test-recorder"; import { env, Recorder } from "@azure-tools/test-recorder"; -import "./env"; +import "./env.js"; import type { ClientOptions } from "@azure-rest/core-client"; -import type { MapsSearchClient } from "../../../src/"; -import MapsSearch from "../../../src/"; +import type { MapsSearchClient } from "../../../src/index.js"; +import MapsSearch from "../../../src/index.js"; import { createTestCredential } from "@azure-tools/test-credential"; const envSetupForPlayback: Record = { @@ -23,8 +22,8 @@ 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: Context): Promise { - const recorder = new Recorder(context.currentTest); +export async function createRecorder(context: TestInfo): Promise { + const recorder = new Recorder(context); await recorder.start(recorderEnvSetup); return recorder; } diff --git a/sdk/maps/maps-search-rest/tsconfig.browser.config.json b/sdk/maps/maps-search-rest/tsconfig.browser.config.json new file mode 100644 index 000000000000..f772e6eb3b76 --- /dev/null +++ b/sdk/maps/maps-search-rest/tsconfig.browser.config.json @@ -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 + } +} diff --git a/sdk/maps/maps-search-rest/tsconfig.json b/sdk/maps/maps-search-rest/tsconfig.json index 9e810cffd80b..2c08b3b98722 100644 --- a/sdk/maps/maps-search-rest/tsconfig.json +++ b/sdk/maps/maps-search-rest/tsconfig.json @@ -1,9 +1,20 @@ { "extends": "../../../tsconfig", "compilerOptions": { - "outDir": "./dist-esm", - "declarationDir": "./types", - "paths": { "@azure-rest/maps-search": ["./src/index"] } + "paths": { + "@azure-rest/maps-search": ["./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", + "test/**/*.mts", + "test/**/*.cts" + ] } diff --git a/sdk/maps/maps-search-rest/vitest.browser.config.ts b/sdk/maps/maps-search-rest/vitest.browser.config.ts new file mode 100644 index 000000000000..50ec2d5489b0 --- /dev/null +++ b/sdk/maps/maps-search-rest/vitest.browser.config.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: 5000000, + testTimeout: 5000000, + }, + }), +); diff --git a/sdk/maps/maps-search-rest/vitest.config.ts b/sdk/maps/maps-search-rest/vitest.config.ts new file mode 100644 index 000000000000..d01fdec8ac69 --- /dev/null +++ b/sdk/maps/maps-search-rest/vitest.config.ts @@ -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: 5000000, + testTimeout: 5000000, + }, + }), +);