diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 438363a1e0f6..4e5580a7085c 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3985,7 +3985,7 @@ packages: dependencies: semver: 7.3.7 shelljs: 0.8.5 - typescript: 4.9.0-dev.20221019 + typescript: 4.9.0-dev.20221020 dev: false /downlevel-dts/0.8.0: @@ -8682,6 +8682,37 @@ packages: hasBin: true dev: false + /ts-node/10.9.1_2e59d8135fdd6591b61d13a0c1b74a82: + resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} + hasBin: true + peerDependencies: + '@swc/core': '>=1.2.50' + '@swc/wasm': '>=1.2.50' + '@types/node': '*' + typescript: '>=2.7' + peerDependenciesMeta: + '@swc/core': + optional: true + '@swc/wasm': + optional: true + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.3 + '@types/node': 14.18.32 + acorn: 8.8.0 + acorn-walk: 8.2.0 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 4.7.4 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + dev: false + /ts-node/10.9.1_48997dee7b72e5515dcf80d69938ef61: resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true @@ -9007,14 +9038,20 @@ packages: hasBin: true dev: false + /typescript/4.7.4: + resolution: {integrity: sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==} + engines: {node: '>=4.2.0'} + hasBin: true + dev: false + /typescript/4.8.4: resolution: {integrity: sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==} engines: {node: '>=4.2.0'} hasBin: true dev: false - /typescript/4.9.0-dev.20221019: - resolution: {integrity: sha512-FgRBDKHZQAbayBvRcfFpjtmztLCobGom2k5W5nFqCXDb/XKYn0oG/8s6O9le3lGIt3+1FC7FYMmqvR5qRW50AA==} + /typescript/4.9.0-dev.20221020: + resolution: {integrity: sha512-m2FnohhzIqj1gqqbkPw1pv/294cE9hGaYLZS7Zt3rpUP36Nr3w/C+LZU2eUuId+DAe7ZWVUrMUAfLvmtr165cw==} engines: {node: '>=4.2.0'} hasBin: true dev: false @@ -16422,7 +16459,7 @@ packages: dev: false file:projects/core-rest-pipeline.tgz: - resolution: {integrity: sha512-+tZ66IuRlxRXrvNubj2nIhVcdb67MsKv2n+wvBXsJz6zbWY+EU4g2a5f2tLE3dQwy2cvVuPEzvWiq9cnOnfu+g==, tarball: file:projects/core-rest-pipeline.tgz} + resolution: {integrity: sha512-P+4UEkZWR9T9IFRcnwPbAKI0JMw2iqPbrmEe/4b7vgEmaS6n19K7T+YnSqoU9FA543ixwQBNdB2ojc7m4m6KEg==, tarball: file:projects/core-rest-pipeline.tgz} name: '@rush-temp/core-rest-pipeline' version: 0.0.0 dependencies: @@ -16454,18 +16491,21 @@ packages: karma-mocha: 2.0.1 karma-mocha-reporter: 2.2.5_karma@6.4.1 karma-sourcemap-loader: 0.3.8 - mocha: 7.2.0 - mocha-junit-reporter: 2.1.0_mocha@7.2.0 + mocha: 10.0.0 + mocha-junit-reporter: 2.1.0_mocha@10.0.0 prettier: 2.7.1 puppeteer: 14.4.1 rimraf: 3.0.2 sinon: 9.2.4 source-map-support: 0.5.21 + ts-node: 10.9.1_2e59d8135fdd6591b61d13a0c1b74a82 tslib: 2.4.0 - typescript: 4.6.4 + typescript: 4.7.4 util: 0.12.4 uuid: 8.3.2 transitivePeerDependencies: + - '@swc/core' + - '@swc/wasm' - bufferutil - debug - encoding diff --git a/common/tools/dev-tool/src/commands/run/bundle.ts b/common/tools/dev-tool/src/commands/run/bundle.ts index fb6eae4fc958..fff9277934ce 100644 --- a/common/tools/dev-tool/src/commands/run/bundle.ts +++ b/common/tools/dev-tool/src/commands/run/bundle.ts @@ -70,9 +70,12 @@ export default leafCommand(commandInfo, async (options) => { try { const bundle = await rollup.rollup(baseConfig); - + const cjsFilename = info.packageJson.main; + if (!cjsFilename) { + throw new Error("Expecting valid main entry"); + } await bundle.write({ - file: "dist/index.js", + file: cjsFilename, format: "cjs", sourcemap: true, exports: "named", diff --git a/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts b/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts index ad3e986c9e5b..0cc6c3e3148e 100644 --- a/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts +++ b/common/tools/dev-tool/src/commands/run/testNodeJSInput.ts @@ -12,8 +12,9 @@ export const commandInfo = makeCommandInfo( export default leafCommand(commandInfo, async (options) => { const defaultMochaArgs = "-r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace"; - const updatedArgs = options["--"]?.map(opt => - opt.includes("**") && !opt.startsWith("'") && !opt.startsWith('"') ? `"${opt}"` : opt) + const updatedArgs = options["--"]?.map((opt) => + opt.includes("**") && !opt.startsWith("'") && !opt.startsWith('"') ? `"${opt}"` : opt + ); const mochaArgs = updatedArgs?.length ? updatedArgs?.join(" ") : '--timeout 5000000 "dist-esm/test/{,!(browser)/**/}/*.spec.js"'; diff --git a/common/tools/dev-tool/src/commands/run/testNodeTSInput.ts b/common/tools/dev-tool/src/commands/run/testNodeTSInput.ts index 3e8426b34d80..bd2e35d96add 100644 --- a/common/tools/dev-tool/src/commands/run/testNodeTSInput.ts +++ b/common/tools/dev-tool/src/commands/run/testNodeTSInput.ts @@ -12,8 +12,9 @@ export const commandInfo = makeCommandInfo( export default leafCommand(commandInfo, async (options) => { const defaultMochaArgs = "-r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace"; - const updatedArgs = options["--"]?.map(opt => - opt.includes("**") && !opt.startsWith("'") && !opt.startsWith('"') ? `"${opt}"` : opt) + const updatedArgs = options["--"]?.map((opt) => + opt.includes("**") && !opt.startsWith("'") && !opt.startsWith('"') ? `"${opt}"` : opt + ); const mochaArgs = updatedArgs?.length ? updatedArgs?.join(" ") : '--timeout 1200000 --exclude "test/**/browser/*.spec.ts" "test/**/*.spec.ts"'; diff --git a/common/tools/dev-tool/src/config/rollup.base.config.ts b/common/tools/dev-tool/src/config/rollup.base.config.ts index 59b5c49837fc..6eda27d8902d 100644 --- a/common/tools/dev-tool/src/config/rollup.base.config.ts +++ b/common/tools/dev-tool/src/config/rollup.base.config.ts @@ -55,7 +55,7 @@ export function sourcemapsExtra() { }, }); - return load instanceof Function ? load.call(shim, id): load.handler.call(shim, id); + return load instanceof Function ? load.call(shim, id) : load.handler.call(shim, id); }, }); } diff --git a/common/tools/dev-tool/src/util/samples/generation.ts b/common/tools/dev-tool/src/util/samples/generation.ts index eb87a108f2a0..d7c3de27d3e7 100644 --- a/common/tools/dev-tool/src/util/samples/generation.ts +++ b/common/tools/dev-tool/src/util/samples/generation.ts @@ -321,16 +321,18 @@ export async function makeSamplesFactory( */ function postProcess(moduleText: string | Buffer): string { const content = Buffer.isBuffer(moduleText) ? moduleText.toString("utf8") : moduleText; - return content - .replace(new RegExp(`^\\s*\\*\\s*@${AZSDK_META_TAG_PREFIX}.*\n`, "gm"), "") - // We also need to clean up extra blank lines that might be left behind by - // removing azsdk tags. These regular expressions are extremely frustrating - // because they deal almost exclusively in the literal "/" and "*" characters. - .replace(/(\s+\*)+\//s, "\n */") - // Clean up blank lines at the beginning - .replace(/\/\*\*(\s+\*)*/s, `/**\n *`) - // Finally remove empty doc comments. - .replace(/\s*\/\*\*(\s+\*)*\/\s*/s, "\n\n"); + return ( + content + .replace(new RegExp(`^\\s*\\*\\s*@${AZSDK_META_TAG_PREFIX}.*\n`, "gm"), "") + // We also need to clean up extra blank lines that might be left behind by + // removing azsdk tags. These regular expressions are extremely frustrating + // because they deal almost exclusively in the literal "/" and "*" characters. + .replace(/(\s+\*)+\//s, "\n */") + // Clean up blank lines at the beginning + .replace(/\/\*\*(\s+\*)*/s, `/**\n *`) + // Finally remove empty doc comments. + .replace(/\s*\/\*\*(\s+\*)*\/\s*/s, "\n\n") + ); } // We use a tempdir at the outer layer to avoid creating dirty trees diff --git a/common/tools/dev-tool/src/util/testProxyUtils.ts b/common/tools/dev-tool/src/util/testProxyUtils.ts index a5929abdb7ea..41d0239c59ee 100644 --- a/common/tools/dev-tool/src/util/testProxyUtils.ts +++ b/common/tools/dev-tool/src/util/testProxyUtils.ts @@ -14,7 +14,11 @@ const log = createPrinter("test-proxy"); const CONTAINER_NAME = "js-azsdk-test-proxy"; export async function startProxyTool(): Promise { - log.info(`Attempting to start test proxy at http://localhost:${process.env.TEST_PROXY_HTTP_PORT ?? 5000} & https://localhost:${process.env.TEST_PROXY_HTTPS_PORT ?? 5001}.\n`); + log.info( + `Attempting to start test proxy at http://localhost:${ + process.env.TEST_PROXY_HTTP_PORT ?? 5000 + } & https://localhost:${process.env.TEST_PROXY_HTTPS_PORT ?? 5001}.\n` + ); const subprocess = spawn(await getDockerRunCommand(), [], { shell: true, @@ -59,13 +63,24 @@ async function getDockerRunCommand() { const testProxyRecordingsLocation = "/srv/testproxy"; const allowLocalhostAccess = "--add-host host.docker.internal:host-gateway"; const imageToLoad = `azsdkengsys.azurecr.io/engsys/testproxy-lin:${await getImageTag()}`; - return `docker run --rm --name ${CONTAINER_NAME} -v ${repoRoot}:${testProxyRecordingsLocation} -p ${process.env.TEST_PROXY_HTTPS_PORT ?? 5001}:5001 -p ${process.env.TEST_PROXY_HTTP_PORT ?? 5000}:5000 ${allowLocalhostAccess} ${imageToLoad}`; + return `docker run --rm --name ${CONTAINER_NAME} -v ${repoRoot}:${testProxyRecordingsLocation} -p ${ + process.env.TEST_PROXY_HTTPS_PORT ?? 5001 + }:5001 -p ${ + process.env.TEST_PROXY_HTTP_PORT ?? 5000 + }:5000 ${allowLocalhostAccess} ${imageToLoad}`; } export async function isProxyToolActive(): Promise { try { - await makeRequest(`http://localhost:${process.env.TEST_PROXY_HTTP_PORT ?? 5000}/info/available`, {}); - log.info(`Proxy tool seems to be active at http://localhost:${process.env.TEST_PROXY_HTTP_PORT ?? 5000}\n`); + await makeRequest( + `http://localhost:${process.env.TEST_PROXY_HTTP_PORT ?? 5000}/info/available`, + {} + ); + log.info( + `Proxy tool seems to be active at http://localhost:${ + process.env.TEST_PROXY_HTTP_PORT ?? 5000 + }\n` + ); return true; } catch (error: any) { return false; diff --git a/common/tools/dev-tool/src/util/testUtils.ts b/common/tools/dev-tool/src/util/testUtils.ts index 148a37bdc61e..50517fcca1e2 100644 --- a/common/tools/dev-tool/src/util/testUtils.ts +++ b/common/tools/dev-tool/src/util/testUtils.ts @@ -1,5 +1,9 @@ import { isProxyToolActive } from "./testProxyUtils"; -import concurrently, { Command as ConcurrentlyCommand, ConcurrentlyCommandInput, ConcurrentlyOptions } from "concurrently"; +import concurrently, { + Command as ConcurrentlyCommand, + ConcurrentlyCommandInput, + ConcurrentlyOptions, +} from "concurrently"; import { createPrinter } from "./printer"; const log = createPrinter("preparing-proxy-tool"); @@ -15,7 +19,9 @@ async function shouldRunProxyTool(): Promise { // No need to run a new one if it is already active // Especially, CI uses this path log.info( - `Proxy tool seems to be active, not attempting to start the test proxy at http://localhost:${process.env.TEST_PROXY_HTTP_PORT ?? 5000} & https://localhost:${process.env.TEST_PROXY_HTTPS_PORT ?? 5001}.\n` + `Proxy tool seems to be active, not attempting to start the test proxy at http://localhost:${ + process.env.TEST_PROXY_HTTP_PORT ?? 5000 + } & https://localhost:${process.env.TEST_PROXY_HTTPS_PORT ?? 5001}.\n` ); } return !isActive; diff --git a/common/tools/eslint-plugin-azure-sdk/docs/rules/ts-package-json-main-is-cjs.md b/common/tools/eslint-plugin-azure-sdk/docs/rules/ts-package-json-main-is-cjs.md index 8e88d5856240..2d3bdcc47e96 100644 --- a/common/tools/eslint-plugin-azure-sdk/docs/rules/ts-package-json-main-is-cjs.md +++ b/common/tools/eslint-plugin-azure-sdk/docs/rules/ts-package-json-main-is-cjs.md @@ -1,6 +1,6 @@ # ts-package-json-main-is-cjs -Requires `main` in `package.json` to be point to a CommonJS or UMD module. In this case, its assumed that it points to `"dist/index.js"`. +Requires `main` in `package.json` to be point to a CommonJS or UMD module. In this case, its assumed that it points to `"dist/index.js"` or `"dist/index.cjs"`. This rule is fixable using the `--fix` option. @@ -14,6 +14,14 @@ This rule is fixable using the `--fix` option. } ``` +### Good + +```json +{ + "main": "dist/index.cjs" +} +``` + ### Bad ```json diff --git a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-main-is-cjs.ts b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-main-is-cjs.ts index ece3560b9b95..13c697b39d83 100644 --- a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-main-is-cjs.ts +++ b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-main-is-cjs.ts @@ -45,10 +45,10 @@ export = { const nodeValue = node.value as Literal; const main = nodeValue.value as string; - if (!/^(\.\/)?dist\/index\.js$/.test(main)) { + if (!/^(\.\/)?dist\/index\.(c)?js$/.test(main)) { context.report({ node: nodeValue, - message: `main is set to ${main} when it should be set to dist/index.js`, + message: `main is set to ${main} when it should be set to dist/index.js or dist/index.cjs`, fix: (fixer: Rule.RuleFixer): Rule.Fix => fixer.replaceText(nodeValue, `"dist/index.js"`), }); diff --git a/common/tools/eslint-plugin-azure-sdk/tests/rules/ts-package-json-main-is-cjs.ts b/common/tools/eslint-plugin-azure-sdk/tests/rules/ts-package-json-main-is-cjs.ts index 06aab3827107..2b151088e44e 100644 --- a/common/tools/eslint-plugin-azure-sdk/tests/rules/ts-package-json-main-is-cjs.ts +++ b/common/tools/eslint-plugin-azure-sdk/tests/rules/ts-package-json-main-is-cjs.ts @@ -263,6 +263,16 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { code: '{"main": "./dist/index.js"}', filename: "package.json", }, + { + // correct format #1 + code: '{"main": "dist/index.cjs"}', + filename: "package.json", + }, + { + // correct format #2 + code: '{"main": "./dist/index.cjs"}', + filename: "package.json", + }, { // a full example package.json (taken from https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/event-hubs/package.json with "scripts" removed for testing purposes) code: examplePackageGood, @@ -300,7 +310,8 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { filename: "package.json", errors: [ { - message: "main is set to dist//index.js when it should be set to dist/index.js", + message: + "main is set to dist//index.js when it should be set to dist/index.js or dist/index.cjs", }, ], output: '{"main": "dist/index.js"}', @@ -310,7 +321,8 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { filename: "package.json", errors: [ { - message: "main is set to .dist/index.js when it should be set to dist/index.js", + message: + "main is set to .dist/index.js when it should be set to dist/index.js or dist/index.cjs", }, ], output: '{"main": "dist/index.js"}', @@ -320,7 +332,8 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { filename: "package.json", errors: [ { - message: "main is set to /dist/index.js when it should be set to dist/index.js", + message: + "main is set to /dist/index.js when it should be set to dist/index.js or dist/index.cjs", }, ], output: '{"main": "dist/index.js"}', @@ -331,7 +344,7 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { filename: "package.json", errors: [ { - message: "main is set to dist when it should be set to dist/index.js", + message: "main is set to dist when it should be set to dist/index.js or dist/index.cjs", }, ], output: '{"main": "dist/index.js"}', @@ -341,7 +354,8 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { filename: "package.json", errors: [ { - message: "main is set to index.js when it should be set to dist/index.js", + message: + "main is set to index.js when it should be set to dist/index.js or dist/index.cjs", }, ], output: '{"main": "dist/index.js"}', @@ -351,7 +365,8 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { filename: "package.json", errors: [ { - message: "main is set to dist/src/index.js when it should be set to dist/index.js", + message: + "main is set to dist/src/index.js when it should be set to dist/index.js or dist/index.cjs", }, ], output: '{"main": "dist/index.js"}', @@ -362,7 +377,8 @@ ruleTester.run("ts-package-json-main-is-cjs", rule, { filename: "package.json", errors: [ { - message: "main is set to index.js when it should be set to dist/index.js", + message: + "main is set to index.js when it should be set to dist/index.js or dist/index.cjs", }, ], output: examplePackageGood, diff --git a/sdk/core/core-rest-pipeline/CHANGELOG.md b/sdk/core/core-rest-pipeline/CHANGELOG.md index 74c170d74975..d0dd6a72844d 100644 --- a/sdk/core/core-rest-pipeline/CHANGELOG.md +++ b/sdk/core/core-rest-pipeline/CHANGELOG.md @@ -1,9 +1,11 @@ # Release History -## 1.9.3 (Unreleased) +## 1.10.0 (Unreleased) ### Features Added +- Added conditional exports for CommonJS and ESM. [#22804](https://github.com/Azure/azure-sdk-for-js/pull/22804) + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/core/core-rest-pipeline/core-rest-pipeline.d.cts b/sdk/core/core-rest-pipeline/core-rest-pipeline.d.cts new file mode 100644 index 000000000000..718d5fdc777b --- /dev/null +++ b/sdk/core/core-rest-pipeline/core-rest-pipeline.d.cts @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +declare global { + interface FormData {} + interface Blob {} + interface File {} + interface ReadableStream {} + interface TransformStream {} +} + +export * from "./types/latest/core-rest-pipeline"; diff --git a/sdk/core/core-rest-pipeline/core-rest-pipeline.shims-3_1.d.cts b/sdk/core/core-rest-pipeline/core-rest-pipeline.shims-3_1.d.cts new file mode 100644 index 000000000000..abb8bf35b987 --- /dev/null +++ b/sdk/core/core-rest-pipeline/core-rest-pipeline.shims-3_1.d.cts @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +declare global { + interface FormData {} + interface Blob {} + interface File {} + interface ReadableStream {} + interface TransformStream {} +} + +export * from "./types/3.1/core-rest-pipeline"; diff --git a/sdk/core/core-rest-pipeline/karma.conf.js b/sdk/core/core-rest-pipeline/karma.conf.cjs similarity index 100% rename from sdk/core/core-rest-pipeline/karma.conf.js rename to sdk/core/core-rest-pipeline/karma.conf.cjs diff --git a/sdk/core/core-rest-pipeline/package.json b/sdk/core/core-rest-pipeline/package.json index 65bc72f8d7f0..01bb7aada277 100644 --- a/sdk/core/core-rest-pipeline/package.json +++ b/sdk/core/core-rest-pipeline/package.json @@ -1,10 +1,23 @@ { "name": "@azure/core-rest-pipeline", - "version": "1.9.3", + "version": "1.10.0", "description": "Isomorphic client library for making HTTP requests in node.js and browser.", "sdk-type": "client", - "main": "dist/index.js", + "main": "dist/index.cjs", "module": "dist-esm/src/index.js", + "type": "module", + "export": { + ".": { + "require": { + "types": "core-rest-pipeline.shims.d.ts", + "default": "./dist/index.cjs" + }, + "import": { + "types": "core-rest-pipeline.shims.d.cts", + "default": "./dist-esm/src/index.js" + } + } + }, "browser": { "./dist-esm/src/defaultHttpClient.js": "./dist-esm/src/defaultHttpClient.browser.js", "./dist-esm/src/policies/decompressResponsePolicy.js": "./dist-esm/src/policies/decompressResponsePolicy.browser.js", @@ -14,7 +27,7 @@ "./dist-esm/src/util/userAgentPlatform.js": "./dist-esm/src/util/userAgentPlatform.browser.js" }, "react-native": { - "./dist/index.js": "./dist-esm/src/index.js", + "./dist/index.cjs": "./dist-esm/src/index.js", "./dist-esm/src/defaultHttpClient.js": "./dist-esm/src/defaultHttpClient.native.js", "./dist-esm/src/util/userAgentPlatform.js": "./dist-esm/src/util/userAgentPlatform.native.js" }, @@ -23,6 +36,9 @@ "<3.6": { "core-rest-pipeline.shims.d.ts": [ "core-rest-pipeline.shims-3_1.d.ts" + ], + "core-rest-pipeline.shims.d.cts": [ + "core-rest-pipeline.shims-3_1.d.cts" ] } }, @@ -46,14 +62,16 @@ "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser", "test:node": "npm run clean && tsc -p . && npm run unit-test:node && npm run integration-test:node", "test": "npm run clean && tsc -p . && npm run unit-test:node && dev-tool run bundle && npm run unit-test:browser && npm run integration-test", - "unit-test:browser": "karma start --single-run", - "unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"", + "unit-test:browser": "karma start karma.conf.cjs --single-run", + "unit-test:node": "mocha --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"", "unit-test": "npm run unit-test:node && npm run unit-test:browser" }, "files": [ "dist/", "dist-esm/src/", + "types/3.1/src/", "types/3.1/core-rest-pipeline.d.ts", + "types/latest/src/", "types/latest/core-rest-pipeline.d.ts", "core-rest-pipeline.shims.d.ts", "core-rest-pipeline.shims-3_1.d.ts", @@ -125,15 +143,19 @@ "karma-sourcemap-loader": "^0.3.8", "karma": "^6.3.0", "mocha-junit-reporter": "^2.0.0", - "mocha": "^7.1.1", + "mocha": "^10.0.0", "prettier": "^2.5.1", "puppeteer": "^14.0.0", "rimraf": "^3.0.0", "sinon": "^9.0.2", "source-map-support": "^0.5.9", - "typescript": "~4.6.0", + "ts-node": "^10.0.0", + "typescript": "~4.7.0", "util": "^0.12.1" }, + "mocha": { + "loader": "ts-node/esm" + }, "//sampleConfiguration": { "skipFolder": true, "disableDocsMs": true, diff --git a/sdk/core/core-rest-pipeline/src/constants.ts b/sdk/core/core-rest-pipeline/src/constants.ts index f527fce0deaa..513bb5ba832e 100644 --- a/sdk/core/core-rest-pipeline/src/constants.ts +++ b/sdk/core/core-rest-pipeline/src/constants.ts @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -export const SDK_VERSION: string = "1.9.3"; +export const SDK_VERSION: string = "1.10.0"; export const DEFAULT_RETRY_POLICY_COUNT = 3; diff --git a/sdk/core/core-rest-pipeline/src/createPipelineFromOptions.ts b/sdk/core/core-rest-pipeline/src/createPipelineFromOptions.ts index fad0579f674a..9fd20e99b012 100644 --- a/sdk/core/core-rest-pipeline/src/createPipelineFromOptions.ts +++ b/sdk/core/core-rest-pipeline/src/createPipelineFromOptions.ts @@ -1,21 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { LogPolicyOptions, logPolicy } from "./policies/logPolicy"; -import { Pipeline, createEmptyPipeline } from "./pipeline"; -import { PipelineRetryOptions, TlsSettings } from "./interfaces"; -import { RedirectPolicyOptions, redirectPolicy } from "./policies/redirectPolicy"; -import { UserAgentPolicyOptions, userAgentPolicy } from "./policies/userAgentPolicy"; +import { LogPolicyOptions, logPolicy } from "./policies/logPolicy.js"; +import { Pipeline, createEmptyPipeline } from "./pipeline.js"; +import { PipelineRetryOptions, TlsSettings } from "./interfaces.js"; +import { RedirectPolicyOptions, redirectPolicy } from "./policies/redirectPolicy.js"; +import { UserAgentPolicyOptions, userAgentPolicy } from "./policies/userAgentPolicy.js"; -import { ProxySettings } from "."; -import { decompressResponsePolicy } from "./policies/decompressResponsePolicy"; -import { defaultRetryPolicy } from "./policies/defaultRetryPolicy"; -import { formDataPolicy } from "./policies/formDataPolicy"; +import { ProxySettings } from "./interfaces.js"; +import { decompressResponsePolicy } from "./policies/decompressResponsePolicy.js"; +import { defaultRetryPolicy } from "./policies/defaultRetryPolicy.js"; +import { formDataPolicy } from "./policies/formDataPolicy.js"; import { isNode } from "@azure/core-util"; -import { proxyPolicy } from "./policies/proxyPolicy"; -import { setClientRequestIdPolicy } from "./policies/setClientRequestIdPolicy"; -import { tlsPolicy } from "./policies/tlsPolicy"; -import { tracingPolicy } from "./policies/tracingPolicy"; +import { proxyPolicy } from "./policies/proxyPolicy.js"; +import { setClientRequestIdPolicy } from "./policies/setClientRequestIdPolicy.js"; +import { tlsPolicy } from "./policies/tlsPolicy.js"; +import { tracingPolicy } from "./policies/tracingPolicy.js"; /** * Defines options that are used to configure the HTTP pipeline for diff --git a/sdk/core/core-rest-pipeline/src/defaultHttpClient.browser.ts b/sdk/core/core-rest-pipeline/src/defaultHttpClient.browser.ts index bc90779365aa..4d8ac42e889f 100644 --- a/sdk/core/core-rest-pipeline/src/defaultHttpClient.browser.ts +++ b/sdk/core/core-rest-pipeline/src/defaultHttpClient.browser.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { HttpClient } from "./interfaces"; -import { createFetchHttpClient } from "./fetchHttpClient"; +import { HttpClient } from "./interfaces.js"; +import { createFetchHttpClient } from "./fetchHttpClient.js"; /** * Create the correct HttpClient for the current environment. diff --git a/sdk/core/core-rest-pipeline/src/defaultHttpClient.native.ts b/sdk/core/core-rest-pipeline/src/defaultHttpClient.native.ts index d9708b80da71..d1085c2bf53b 100644 --- a/sdk/core/core-rest-pipeline/src/defaultHttpClient.native.ts +++ b/sdk/core/core-rest-pipeline/src/defaultHttpClient.native.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { HttpClient } from "./interfaces"; -import { createXhrHttpClient } from "./xhrHttpClient"; +import { HttpClient } from "./interfaces.js"; +import { createXhrHttpClient } from "./xhrHttpClient.js"; /** * Create the correct HttpClient for the current environment. diff --git a/sdk/core/core-rest-pipeline/src/defaultHttpClient.ts b/sdk/core/core-rest-pipeline/src/defaultHttpClient.ts index 9b5def081c74..721e3a2aa750 100644 --- a/sdk/core/core-rest-pipeline/src/defaultHttpClient.ts +++ b/sdk/core/core-rest-pipeline/src/defaultHttpClient.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { HttpClient } from "./interfaces"; -import { createNodeHttpClient } from "./nodeHttpClient"; +import { HttpClient } from "./interfaces.js"; +import { createNodeHttpClient } from "./nodeHttpClient.js"; /** * Create the correct HttpClient for the current environment. diff --git a/sdk/core/core-rest-pipeline/src/fetchHttpClient.ts b/sdk/core/core-rest-pipeline/src/fetchHttpClient.ts index 17e90b60e0f9..ee38b9978463 100644 --- a/sdk/core/core-rest-pipeline/src/fetchHttpClient.ts +++ b/sdk/core/core-rest-pipeline/src/fetchHttpClient.ts @@ -8,9 +8,9 @@ import { PipelineRequest, PipelineResponse, TransferProgressEvent, -} from "./interfaces"; -import { RestError } from "./restError"; -import { createHttpHeaders } from "./httpHeaders"; +} from "./interfaces.js"; +import { RestError } from "./restError.js"; +import { createHttpHeaders } from "./httpHeaders.js"; /** * Checks if the body is a NodeReadable stream which is not supported in Browsers diff --git a/sdk/core/core-rest-pipeline/src/httpHeaders.ts b/sdk/core/core-rest-pipeline/src/httpHeaders.ts index f00b99b18886..3f94d16026c1 100644 --- a/sdk/core/core-rest-pipeline/src/httpHeaders.ts +++ b/sdk/core/core-rest-pipeline/src/httpHeaders.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { HttpHeaders, RawHttpHeaders, RawHttpHeadersInput } from "./interfaces"; +import { HttpHeaders, RawHttpHeaders, RawHttpHeadersInput } from "./interfaces.js"; interface HeaderEntry { name: string; diff --git a/sdk/core/core-rest-pipeline/src/index.ts b/sdk/core/core-rest-pipeline/src/index.ts index 516e34327dab..93718a3fde42 100644 --- a/sdk/core/core-rest-pipeline/src/index.ts +++ b/sdk/core/core-rest-pipeline/src/index.ts @@ -20,64 +20,72 @@ export { SendRequest, TlsSettings, TransferProgressEvent, -} from "./interfaces"; +} from "./interfaces.js"; export { AddPolicyOptions as AddPipelineOptions, PipelinePhase, PipelinePolicy, Pipeline, createEmptyPipeline, -} from "./pipeline"; +} from "./pipeline.js"; export { createPipelineFromOptions, InternalPipelineOptions, PipelineOptions, -} from "./createPipelineFromOptions"; -export { createDefaultHttpClient } from "./defaultHttpClient"; -export { createHttpHeaders } from "./httpHeaders"; -export { createPipelineRequest, PipelineRequestOptions } from "./pipelineRequest"; -export { RestError, RestErrorOptions, isRestError } from "./restError"; +} from "./createPipelineFromOptions.js"; +export { createDefaultHttpClient } from "./defaultHttpClient.js"; +export { createHttpHeaders } from "./httpHeaders.js"; +export { createPipelineRequest, PipelineRequestOptions } from "./pipelineRequest.js"; +export { RestError, RestErrorOptions, isRestError } from "./restError.js"; export { decompressResponsePolicy, decompressResponsePolicyName, -} from "./policies/decompressResponsePolicy"; +} from "./policies/decompressResponsePolicy.js"; export { exponentialRetryPolicy, ExponentialRetryPolicyOptions, exponentialRetryPolicyName, -} from "./policies/exponentialRetryPolicy"; +} from "./policies/exponentialRetryPolicy.js"; export { setClientRequestIdPolicy, setClientRequestIdPolicyName, -} from "./policies/setClientRequestIdPolicy"; -export { logPolicy, logPolicyName, LogPolicyOptions } from "./policies/logPolicy"; -export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./policies/proxyPolicy"; +} from "./policies/setClientRequestIdPolicy.js"; +export { logPolicy, logPolicyName, LogPolicyOptions } from "./policies/logPolicy.js"; +export { proxyPolicy, proxyPolicyName, getDefaultProxySettings } from "./policies/proxyPolicy.js"; export { redirectPolicy, redirectPolicyName, RedirectPolicyOptions, -} from "./policies/redirectPolicy"; +} from "./policies/redirectPolicy.js"; export { systemErrorRetryPolicy, SystemErrorRetryPolicyOptions, systemErrorRetryPolicyName, -} from "./policies/systemErrorRetryPolicy"; +} from "./policies/systemErrorRetryPolicy.js"; export { throttlingRetryPolicy, throttlingRetryPolicyName, ThrottlingRetryPolicyOptions, -} from "./policies/throttlingRetryPolicy"; -export { retryPolicy, RetryPolicyOptions } from "./policies/retryPolicy"; -export { RetryStrategy, RetryInformation, RetryModifiers } from "./retryStrategies/retryStrategy"; -export { tracingPolicy, tracingPolicyName, TracingPolicyOptions } from "./policies/tracingPolicy"; -export { defaultRetryPolicy, DefaultRetryPolicyOptions } from "./policies/defaultRetryPolicy"; +} from "./policies/throttlingRetryPolicy.js"; +export { retryPolicy, RetryPolicyOptions } from "./policies/retryPolicy.js"; +export { + RetryStrategy, + RetryInformation, + RetryModifiers, +} from "./retryStrategies/retryStrategy.js"; +export { + tracingPolicy, + tracingPolicyName, + TracingPolicyOptions, +} from "./policies/tracingPolicy.js"; +export { defaultRetryPolicy, DefaultRetryPolicyOptions } from "./policies/defaultRetryPolicy.js"; export { userAgentPolicy, userAgentPolicyName, UserAgentPolicyOptions, -} from "./policies/userAgentPolicy"; -export { tlsPolicy, tlsPolicyName } from "./policies/tlsPolicy"; -export { formDataPolicy, formDataPolicyName } from "./policies/formDataPolicy"; +} from "./policies/userAgentPolicy.js"; +export { tlsPolicy, tlsPolicyName } from "./policies/tlsPolicy.js"; +export { formDataPolicy, formDataPolicyName } from "./policies/formDataPolicy.js"; export { bearerTokenAuthenticationPolicy, BearerTokenAuthenticationPolicyOptions, @@ -85,5 +93,5 @@ export { ChallengeCallbacks, AuthorizeRequestOptions, AuthorizeRequestOnChallengeOptions, -} from "./policies/bearerTokenAuthenticationPolicy"; -export { ndJsonPolicy, ndJsonPolicyName } from "./policies/ndJsonPolicy"; +} from "./policies/bearerTokenAuthenticationPolicy.js"; +export { ndJsonPolicy, ndJsonPolicyName } from "./policies/ndJsonPolicy.js"; diff --git a/sdk/core/core-rest-pipeline/src/nodeHttpClient.ts b/sdk/core/core-rest-pipeline/src/nodeHttpClient.ts index 95361609847d..05d5033c60a5 100644 --- a/sdk/core/core-rest-pipeline/src/nodeHttpClient.ts +++ b/sdk/core/core-rest-pipeline/src/nodeHttpClient.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import * as http from "http"; -import * as https from "https"; -import * as zlib from "zlib"; +import http from "http"; +import https from "https"; +import zlib from "zlib"; import { Transform } from "stream"; import { AbortController, AbortError } from "@azure/abort-controller"; import { @@ -14,11 +14,11 @@ import { RequestBodyType, TlsSettings, TransferProgressEvent, -} from "./interfaces"; -import { createHttpHeaders } from "./httpHeaders"; -import { RestError } from "./restError"; +} from "./interfaces.js"; +import { createHttpHeaders } from "./httpHeaders.js"; +import { RestError } from "./restError.js"; import { IncomingMessage } from "http"; -import { logger } from "./log"; +import { logger } from "./log.js"; const DEFAULT_TLS_SETTINGS = {}; diff --git a/sdk/core/core-rest-pipeline/src/pipeline.ts b/sdk/core/core-rest-pipeline/src/pipeline.ts index 4be129186628..38f3e3a14e8f 100644 --- a/sdk/core/core-rest-pipeline/src/pipeline.ts +++ b/sdk/core/core-rest-pipeline/src/pipeline.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { HttpClient, PipelineRequest, PipelineResponse, SendRequest } from "./interfaces"; +import { HttpClient, PipelineRequest, PipelineResponse, SendRequest } from "./interfaces.js"; /** * Policies are executed in phases. diff --git a/sdk/core/core-rest-pipeline/src/pipelineRequest.ts b/sdk/core/core-rest-pipeline/src/pipelineRequest.ts index 9cdd6062eeb4..5d0709519b83 100644 --- a/sdk/core/core-rest-pipeline/src/pipelineRequest.ts +++ b/sdk/core/core-rest-pipeline/src/pipelineRequest.ts @@ -9,10 +9,10 @@ import { ProxySettings, RequestBodyType, TransferProgressEvent, -} from "./interfaces"; -import { createHttpHeaders } from "./httpHeaders"; +} from "./interfaces.js"; +import { createHttpHeaders } from "./httpHeaders.js"; import { AbortSignalLike } from "@azure/abort-controller"; -import { generateUuid } from "./util/uuid"; +import { generateUuid } from "./util/uuid.js"; import { OperationTracingOptions } from "@azure/core-tracing"; /** diff --git a/sdk/core/core-rest-pipeline/src/policies/bearerTokenAuthenticationPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/bearerTokenAuthenticationPolicy.ts index c8b374a9e801..605bbd79898e 100644 --- a/sdk/core/core-rest-pipeline/src/policies/bearerTokenAuthenticationPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/bearerTokenAuthenticationPolicy.ts @@ -3,10 +3,10 @@ import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth"; import { AzureLogger } from "@azure/logger"; -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; -import { createTokenCycler } from "../util/tokenCycler"; -import { logger as coreLogger } from "../log"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; +import { createTokenCycler } from "../util/tokenCycler.js"; +import { logger as coreLogger } from "../log.js"; /** * The programmatic identifier of the bearerTokenAuthenticationPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/decompressResponsePolicy.ts b/sdk/core/core-rest-pipeline/src/policies/decompressResponsePolicy.ts index f52a2d2fdcb2..53ff3d9a4ea4 100644 --- a/sdk/core/core-rest-pipeline/src/policies/decompressResponsePolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/decompressResponsePolicy.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; /** * The programmatic identifier of the decompressResponsePolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/defaultRetryPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/defaultRetryPolicy.ts index 90fce25ceddb..66c62aada6f6 100644 --- a/sdk/core/core-rest-pipeline/src/policies/defaultRetryPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/defaultRetryPolicy.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRetryOptions } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; -import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy"; -import { throttlingRetryStrategy } from "../retryStrategies/throttlingRetryStrategy"; -import { retryPolicy } from "./retryPolicy"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../constants"; +import { PipelineRetryOptions } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; +import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy.js"; +import { throttlingRetryStrategy } from "../retryStrategies/throttlingRetryStrategy.js"; +import { retryPolicy } from "./retryPolicy.js"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js"; /** * Name of the {@link defaultRetryPolicy} diff --git a/sdk/core/core-rest-pipeline/src/policies/exponentialRetryPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/exponentialRetryPolicy.ts index d1b703865bb4..dd813300b3ef 100644 --- a/sdk/core/core-rest-pipeline/src/policies/exponentialRetryPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/exponentialRetryPolicy.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelinePolicy } from "../pipeline"; -import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy"; -import { retryPolicy } from "./retryPolicy"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../constants"; +import { PipelinePolicy } from "../pipeline.js"; +import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy.js"; +import { retryPolicy } from "./retryPolicy.js"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js"; /** * The programmatic identifier of the exponentialRetryPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.browser.ts b/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.browser.ts index b8920bf9cbf5..099266eb2ab2 100644 --- a/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.browser.ts +++ b/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.browser.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; /** * The programmatic identifier of the formDataPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.ts index 1a039bf28e98..9c222abe9e76 100644 --- a/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/formDataPolicy.ts @@ -2,8 +2,8 @@ // Licensed under the MIT license. import FormData from "form-data"; -import { FormDataMap, PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; +import { FormDataMap, PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; /** * The programmatic identifier of the formDataPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/logPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/logPolicy.ts index 2dacedf0aac5..afef356665f4 100644 --- a/sdk/core/core-rest-pipeline/src/policies/logPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/logPolicy.ts @@ -2,10 +2,10 @@ // Licensed under the MIT license. import { Debugger } from "@azure/logger"; -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; -import { logger as coreLogger } from "../log"; -import { Sanitizer } from "../util/sanitizer"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; +import { logger as coreLogger } from "../log.js"; +import { Sanitizer } from "../util/sanitizer.js"; /** * The programmatic identifier of the logPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/ndJsonPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/ndJsonPolicy.ts index 04d035c93189..79a646c4f12b 100644 --- a/sdk/core/core-rest-pipeline/src/policies/ndJsonPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/ndJsonPolicy.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; /** * The programmatic identifier of the ndJsonPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/proxyPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/proxyPolicy.ts index 956923d89413..de1e98560974 100644 --- a/sdk/core/core-rest-pipeline/src/policies/proxyPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/proxyPolicy.ts @@ -1,13 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import * as http from "http"; -import * as https from "https"; -import { HttpsProxyAgent, HttpsProxyAgentOptions } from "https-proxy-agent"; -import { HttpProxyAgent, HttpProxyAgentOptions } from "http-proxy-agent"; -import { PipelineRequest, PipelineResponse, ProxySettings, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; -import { logger } from "../log"; +import http from "http"; +import https from "https"; +import httpsPA from "https-proxy-agent"; +const { HttpsProxyAgent } = httpsPA; +import httpPA from "http-proxy-agent"; +const { HttpProxyAgent } = httpPA; +import { PipelineRequest, PipelineResponse, ProxySettings, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; +import { logger } from "../log.js"; const HTTPS_PROXY = "HTTPS_PROXY"; const HTTP_PROXY = "HTTP_PROXY"; @@ -132,7 +134,7 @@ export function getDefaultProxySettings(proxyUrl?: string): ProxySettings | unde export function getProxyAgentOptions( proxySettings: ProxySettings, { headers, tlsSettings }: PipelineRequest -): HttpProxyAgentOptions { +): httpPA.HttpProxyAgentOptions { let parsedProxyUrl: URL; try { parsedProxyUrl = new URL(proxySettings.host); @@ -148,7 +150,7 @@ export function getProxyAgentOptions( ); } - const proxyAgentOptions: HttpsProxyAgentOptions = { + const proxyAgentOptions: httpsPA.HttpsProxyAgentOptions = { hostname: parsedProxyUrl.hostname, port: proxySettings.port, protocol: parsedProxyUrl.protocol, diff --git a/sdk/core/core-rest-pipeline/src/policies/redirectPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/redirectPolicy.ts index 36314ee4439e..6933586fd4c9 100644 --- a/sdk/core/core-rest-pipeline/src/policies/redirectPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/redirectPolicy.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; /** * The programmatic identifier of the redirectPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/retryPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/retryPolicy.ts index c04102d44b0c..5ccdac9780aa 100644 --- a/sdk/core/core-rest-pipeline/src/policies/retryPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/retryPolicy.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; -import { delay } from "../util/helpers"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; +import { delay } from "../util/helpers.js"; import { createClientLogger } from "@azure/logger"; -import { RetryStrategy } from "../retryStrategies/retryStrategy"; -import { RestError } from "../restError"; +import { RetryStrategy } from "../retryStrategies/retryStrategy.js"; +import { RestError } from "../restError.js"; import { AbortError } from "@azure/abort-controller"; import { AzureLogger } from "@azure/logger"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../constants"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js"; const retryPolicyLogger = createClientLogger("core-rest-pipeline retryPolicy"); diff --git a/sdk/core/core-rest-pipeline/src/policies/setClientRequestIdPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/setClientRequestIdPolicy.ts index 564634d77e6c..51a4cabe4f2a 100644 --- a/sdk/core/core-rest-pipeline/src/policies/setClientRequestIdPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/setClientRequestIdPolicy.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; /** * The programmatic identifier of the setClientRequestIdPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/systemErrorRetryPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/systemErrorRetryPolicy.ts index bdf4ae2fd65f..280828100b17 100644 --- a/sdk/core/core-rest-pipeline/src/policies/systemErrorRetryPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/systemErrorRetryPolicy.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelinePolicy } from "../pipeline"; -import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy"; -import { retryPolicy } from "./retryPolicy"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../constants"; +import { PipelinePolicy } from "../pipeline.js"; +import { exponentialRetryStrategy } from "../retryStrategies/exponentialRetryStrategy.js"; +import { retryPolicy } from "./retryPolicy.js"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js"; /** * Name of the {@link systemErrorRetryPolicy} diff --git a/sdk/core/core-rest-pipeline/src/policies/throttlingRetryPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/throttlingRetryPolicy.ts index 7cf262331a6d..33a6ccf3adf4 100644 --- a/sdk/core/core-rest-pipeline/src/policies/throttlingRetryPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/throttlingRetryPolicy.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelinePolicy } from "../pipeline"; -import { throttlingRetryStrategy } from "../retryStrategies/throttlingRetryStrategy"; -import { retryPolicy } from "./retryPolicy"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../constants"; +import { PipelinePolicy } from "../pipeline.js"; +import { throttlingRetryStrategy } from "../retryStrategies/throttlingRetryStrategy.js"; +import { retryPolicy } from "./retryPolicy.js"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../constants.js"; /** * Name of the {@link throttlingRetryPolicy} diff --git a/sdk/core/core-rest-pipeline/src/policies/tlsPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/tlsPolicy.ts index efba9098af14..cf85d5c3da40 100644 --- a/sdk/core/core-rest-pipeline/src/policies/tlsPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/tlsPolicy.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelinePolicy } from "../pipeline"; -import { TlsSettings } from "../interfaces"; +import { PipelinePolicy } from "../pipeline.js"; +import { TlsSettings } from "../interfaces.js"; /** * Name of the TLS Policy diff --git a/sdk/core/core-rest-pipeline/src/policies/tracingPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/tracingPolicy.ts index 098bc93c2b9d..33a7c4c76f04 100644 --- a/sdk/core/core-rest-pipeline/src/policies/tracingPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/tracingPolicy.ts @@ -7,13 +7,13 @@ import { TracingSpan, createTracingClient, } from "@azure/core-tracing"; -import { SDK_VERSION } from "../constants"; -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; -import { getUserAgentValue } from "../util/userAgent"; -import { logger } from "../log"; +import { SDK_VERSION } from "../constants.js"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; +import { getUserAgentValue } from "../util/userAgent.js"; +import { logger } from "../log.js"; import { getErrorMessage, isError } from "@azure/core-util"; -import { isRestError } from "../restError"; +import { isRestError } from "../restError.js"; /** * The programmatic identifier of the tracingPolicy. diff --git a/sdk/core/core-rest-pipeline/src/policies/userAgentPolicy.ts b/sdk/core/core-rest-pipeline/src/policies/userAgentPolicy.ts index 0ab8d10e1c55..05871573c1d3 100644 --- a/sdk/core/core-rest-pipeline/src/policies/userAgentPolicy.ts +++ b/sdk/core/core-rest-pipeline/src/policies/userAgentPolicy.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces"; -import { PipelinePolicy } from "../pipeline"; -import { getUserAgentHeaderName, getUserAgentValue } from "../util/userAgent"; +import { PipelineRequest, PipelineResponse, SendRequest } from "../interfaces.js"; +import { PipelinePolicy } from "../pipeline.js"; +import { getUserAgentHeaderName, getUserAgentValue } from "../util/userAgent.js"; const UserAgentHeaderName = getUserAgentHeaderName(); diff --git a/sdk/core/core-rest-pipeline/src/restError.ts b/sdk/core/core-rest-pipeline/src/restError.ts index ff1d26d09f11..f4fb54f68d90 100644 --- a/sdk/core/core-rest-pipeline/src/restError.ts +++ b/sdk/core/core-rest-pipeline/src/restError.ts @@ -2,9 +2,9 @@ // Licensed under the MIT license. import { isError } from "@azure/core-util"; -import { PipelineRequest, PipelineResponse } from "./interfaces"; -import { custom } from "./util/inspect"; -import { Sanitizer } from "./util/sanitizer"; +import { PipelineRequest, PipelineResponse } from "./interfaces.js"; +import { custom } from "./util/inspect.js"; +import { Sanitizer } from "./util/sanitizer.js"; const errorSanitizer = new Sanitizer(); diff --git a/sdk/core/core-rest-pipeline/src/retryStrategies/exponentialRetryStrategy.ts b/sdk/core/core-rest-pipeline/src/retryStrategies/exponentialRetryStrategy.ts index 586e1b0c520d..88a4375c58fa 100644 --- a/sdk/core/core-rest-pipeline/src/retryStrategies/exponentialRetryStrategy.ts +++ b/sdk/core/core-rest-pipeline/src/retryStrategies/exponentialRetryStrategy.ts @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineResponse } from "../interfaces"; -import { RestError } from "../restError"; +import { PipelineResponse } from "../interfaces.js"; +import { RestError } from "../restError.js"; import { getRandomIntegerInclusive } from "@azure/core-util"; -import { RetryStrategy } from "./retryStrategy"; -import { isThrottlingRetryResponse } from "./throttlingRetryStrategy"; +import { RetryStrategy } from "./retryStrategy.js"; +import { isThrottlingRetryResponse } from "./throttlingRetryStrategy.js"; // intervals are in milliseconds const DEFAULT_CLIENT_RETRY_INTERVAL = 1000; diff --git a/sdk/core/core-rest-pipeline/src/retryStrategies/retryStrategy.ts b/sdk/core/core-rest-pipeline/src/retryStrategies/retryStrategy.ts index e870b853bca0..0ea36b59016c 100644 --- a/sdk/core/core-rest-pipeline/src/retryStrategies/retryStrategy.ts +++ b/sdk/core/core-rest-pipeline/src/retryStrategies/retryStrategy.ts @@ -2,8 +2,8 @@ // Licensed under the MIT license. import { AzureLogger } from "@azure/logger"; -import { PipelineResponse } from "../interfaces"; -import { RestError } from "../restError"; +import { PipelineResponse } from "../interfaces.js"; +import { RestError } from "../restError.js"; /** * Information provided to the retry strategy about the current progress of the retry policy. diff --git a/sdk/core/core-rest-pipeline/src/retryStrategies/throttlingRetryStrategy.ts b/sdk/core/core-rest-pipeline/src/retryStrategies/throttlingRetryStrategy.ts index b64a14efdc44..df6b03d2369d 100644 --- a/sdk/core/core-rest-pipeline/src/retryStrategies/throttlingRetryStrategy.ts +++ b/sdk/core/core-rest-pipeline/src/retryStrategies/throttlingRetryStrategy.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { PipelineResponse } from ".."; -import { parseHeaderValueAsNumber } from "../util/helpers"; -import { RetryStrategy } from "./retryStrategy"; +import { PipelineResponse } from "../interfaces.js"; +import { parseHeaderValueAsNumber } from "../util/helpers.js"; +import { RetryStrategy } from "./retryStrategy.js"; /** * The header that comes back from Azure services representing diff --git a/sdk/core/core-rest-pipeline/src/util/helpers.ts b/sdk/core/core-rest-pipeline/src/util/helpers.ts index f4ce9dc64b0b..2f9b2c6cf504 100644 --- a/sdk/core/core-rest-pipeline/src/util/helpers.ts +++ b/sdk/core/core-rest-pipeline/src/util/helpers.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { AbortError, AbortSignalLike } from "@azure/abort-controller"; -import { PipelineResponse } from "../interfaces"; +import { PipelineResponse } from "../interfaces.js"; const StandardAbortMessage = "The operation was aborted."; diff --git a/sdk/core/core-rest-pipeline/src/util/tokenCycler.ts b/sdk/core/core-rest-pipeline/src/util/tokenCycler.ts index 3a7c159ccea7..36f45ab24f9f 100644 --- a/sdk/core/core-rest-pipeline/src/util/tokenCycler.ts +++ b/sdk/core/core-rest-pipeline/src/util/tokenCycler.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth"; -import { delay } from "./helpers"; +import { delay } from "./helpers.js"; /** * A function that gets a promise of an access token and allows providing diff --git a/sdk/core/core-rest-pipeline/src/util/userAgent.ts b/sdk/core/core-rest-pipeline/src/util/userAgent.ts index cffde1885d94..af452de2073d 100644 --- a/sdk/core/core-rest-pipeline/src/util/userAgent.ts +++ b/sdk/core/core-rest-pipeline/src/util/userAgent.ts @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { getHeaderName, setPlatformSpecificData } from "./userAgentPlatform"; -import { SDK_VERSION } from "../constants"; +import { getHeaderName, setPlatformSpecificData } from "./userAgentPlatform.js"; +import { SDK_VERSION } from "../constants.js"; function getUserAgentString(telemetryInfo: Map): string { const parts: string[] = []; diff --git a/sdk/core/core-rest-pipeline/src/util/userAgentPlatform.ts b/sdk/core/core-rest-pipeline/src/util/userAgentPlatform.ts index c1be64874b1c..2388cd2353c6 100644 --- a/sdk/core/core-rest-pipeline/src/util/userAgentPlatform.ts +++ b/sdk/core/core-rest-pipeline/src/util/userAgentPlatform.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import * as os from "os"; +import os from "os"; /** * @internal diff --git a/sdk/core/core-rest-pipeline/src/xhrHttpClient.ts b/sdk/core/core-rest-pipeline/src/xhrHttpClient.ts index 7895e438a478..944d8f54ba18 100644 --- a/sdk/core/core-rest-pipeline/src/xhrHttpClient.ts +++ b/sdk/core/core-rest-pipeline/src/xhrHttpClient.ts @@ -8,9 +8,9 @@ import { PipelineRequest, PipelineResponse, TransferProgressEvent, -} from "./interfaces"; -import { createHttpHeaders } from "./httpHeaders"; -import { RestError } from "./restError"; +} from "./interfaces.js"; +import { createHttpHeaders } from "./httpHeaders.js"; +import { RestError } from "./restError.js"; function isNodeReadableStream(body: any): body is NodeJS.ReadableStream { return body && typeof body.pipe === "function"; diff --git a/sdk/core/core-rest-pipeline/test/bearerTokenAuthenticationPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/bearerTokenAuthenticationPolicy.spec.ts index d49d2a193b92..f82fffd85cc5 100644 --- a/sdk/core/core-rest-pipeline/test/bearerTokenAuthenticationPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/bearerTokenAuthenticationPolicy.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { AccessToken, TokenCredential } from "@azure/core-auth"; import { PipelinePolicy, @@ -11,8 +11,8 @@ import { bearerTokenAuthenticationPolicy, createHttpHeaders, createPipelineRequest, -} from "../src"; -import { DEFAULT_CYCLER_OPTIONS } from "../src/util/tokenCycler"; +} from "../src/index.js"; +import { DEFAULT_CYCLER_OPTIONS } from "../src/util/tokenCycler.js"; const { refreshWindowInMs: defaultRefreshWindow } = DEFAULT_CYCLER_OPTIONS; diff --git a/sdk/core/core-rest-pipeline/test/browser/decompressResponsePolicy.ts b/sdk/core/core-rest-pipeline/test/browser/decompressResponsePolicy.ts index 719f7a2a7817..030251c7fa06 100644 --- a/sdk/core/core-rest-pipeline/test/browser/decompressResponsePolicy.ts +++ b/sdk/core/core-rest-pipeline/test/browser/decompressResponsePolicy.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { decompressResponsePolicy } from "../../src"; +import { decompressResponsePolicy } from "../../src/index.js"; describe("decompressResponsePolicy (browser)", function () { it("Throws on creation", function () { diff --git a/sdk/core/core-rest-pipeline/test/browser/fetchHttpClient.spec.ts b/sdk/core/core-rest-pipeline/test/browser/fetchHttpClient.spec.ts index c97805fcbcd8..bb1ad95ba54b 100644 --- a/sdk/core/core-rest-pipeline/test/browser/fetchHttpClient.spec.ts +++ b/sdk/core/core-rest-pipeline/test/browser/fetchHttpClient.spec.ts @@ -2,13 +2,13 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { createFetchHttpClient } from "../../src/fetchHttpClient"; -import { createPipelineRequest } from "../../src/pipelineRequest"; -import { png } from "./mocks/encodedPng"; +import { createFetchHttpClient } from "../../src/fetchHttpClient.js"; +import { createPipelineRequest } from "../../src/pipelineRequest.js"; +import { png } from "./mocks/encodedPng.js"; import sinon from "sinon"; -import { createHttpHeaders } from "../../src/httpHeaders"; +import { createHttpHeaders } from "../../src/httpHeaders.js"; import { AbortError, AbortSignalLike } from "@azure/abort-controller"; -import { delay } from "../../src/util/helpers"; +import { delay } from "../../src/util/helpers.js"; const streamBody = new ReadableStream({ async start(controller) { diff --git a/sdk/core/core-rest-pipeline/test/browser/formDataPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/browser/formDataPolicy.spec.ts index 7cea8007f46e..c8388048de50 100644 --- a/sdk/core/core-rest-pipeline/test/browser/formDataPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/browser/formDataPolicy.spec.ts @@ -2,14 +2,14 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PipelineResponse, SendRequest, createHttpHeaders, createPipelineRequest, formDataPolicy, -} from "../../src"; +} from "../../src/index.js"; describe("formDataPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/browser/proxyPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/browser/proxyPolicy.spec.ts index 0b47135417cd..8e148ca5132b 100644 --- a/sdk/core/core-rest-pipeline/test/browser/proxyPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/browser/proxyPolicy.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { proxyPolicy } from "../../src"; +import { proxyPolicy } from "../../src/index.js"; describe("proxyPolicy (browser)", function () { it("Throws on creation", function () { diff --git a/sdk/core/core-rest-pipeline/test/defaultLogPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/defaultLogPolicy.spec.ts index 2dcf1bb640b2..065982419ccd 100644 --- a/sdk/core/core-rest-pipeline/test/defaultLogPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/defaultLogPolicy.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants"; -import { PipelinePolicy } from "../src/pipeline"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants.js"; +import { PipelinePolicy } from "../src/pipeline.js"; import { assert } from "chai"; -import { createHttpHeaders } from "../src/httpHeaders"; -import { createPipelineFromOptions } from "../src/createPipelineFromOptions"; -import { createPipelineRequest } from "../src/pipelineRequest"; +import { createHttpHeaders } from "../src/httpHeaders.js"; +import { createPipelineFromOptions } from "../src/createPipelineFromOptions.js"; +import { createPipelineRequest } from "../src/pipelineRequest.js"; import { isNode } from "@azure/core-util"; import sinon from "sinon"; diff --git a/sdk/core/core-rest-pipeline/test/defaultRetryPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/defaultRetryPolicy.spec.ts index d4ef9b8cd759..55e294c3b316 100644 --- a/sdk/core/core-rest-pipeline/test/defaultRetryPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/defaultRetryPolicy.spec.ts @@ -2,9 +2,9 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; -import { RestError, SendRequest, createPipelineRequest, defaultRetryPolicy } from "../src"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants"; +import sinon from "sinon"; +import { RestError, SendRequest, createPipelineRequest, defaultRetryPolicy } from "../src/index.js"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants.js"; describe("defaultRetryPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/exponentialRetryPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/exponentialRetryPolicy.spec.ts index 9a274c47cf59..24fb98f4d600 100644 --- a/sdk/core/core-rest-pipeline/test/exponentialRetryPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/exponentialRetryPolicy.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PipelineResponse, RestError, @@ -10,8 +10,8 @@ import { createHttpHeaders, createPipelineRequest, exponentialRetryPolicy, -} from "../src"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants"; +} from "../src/index.js"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants.js"; describe("exponentialRetryPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/httpHeaders.spec.ts b/sdk/core/core-rest-pipeline/test/httpHeaders.spec.ts index 05dd7f8fa74a..b2ca06711109 100644 --- a/sdk/core/core-rest-pipeline/test/httpHeaders.spec.ts +++ b/sdk/core/core-rest-pipeline/test/httpHeaders.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { createHttpHeaders } from "../src/httpHeaders"; +import { createHttpHeaders } from "../src/httpHeaders.js"; describe("HttpHeaders", () => { it("toJSON() should use normalized header names", () => { diff --git a/sdk/core/core-rest-pipeline/test/ndJsonPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/ndJsonPolicy.spec.ts index de5059561630..7bdb52386b57 100644 --- a/sdk/core/core-rest-pipeline/test/ndJsonPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/ndJsonPolicy.spec.ts @@ -2,14 +2,14 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PipelineResponse, SendRequest, createHttpHeaders, createPipelineRequest, ndJsonPolicy, -} from "../src"; +} from "../src/index.js"; describe("NdJsonPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/node/bearerTokenAuthenticationPolicyChallenge.spec.ts b/sdk/core/core-rest-pipeline/test/node/bearerTokenAuthenticationPolicyChallenge.spec.ts index 0084f8d6ed78..ffeabdc93a28 100644 --- a/sdk/core/core-rest-pipeline/test/node/bearerTokenAuthenticationPolicyChallenge.spec.ts +++ b/sdk/core/core-rest-pipeline/test/node/bearerTokenAuthenticationPolicyChallenge.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { AccessToken, GetTokenOptions, TokenCredential } from "@azure/core-auth"; import { AuthorizeRequestOnChallengeOptions, @@ -12,7 +12,7 @@ import { createEmptyPipeline, createHttpHeaders, createPipelineRequest, -} from "../../src"; +} from "../../src/index.js"; import { TextDecoder } from "util"; export interface TestChallenge { diff --git a/sdk/core/core-rest-pipeline/test/node/decompressResponsePolicy.ts b/sdk/core/core-rest-pipeline/test/node/decompressResponsePolicy.ts index 587bb3203278..f8c4819f81f1 100644 --- a/sdk/core/core-rest-pipeline/test/node/decompressResponsePolicy.ts +++ b/sdk/core/core-rest-pipeline/test/node/decompressResponsePolicy.ts @@ -2,8 +2,8 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; -import { SendRequest, createPipelineRequest, decompressResponsePolicy } from "../../src"; +import sinon from "sinon"; +import { SendRequest, createPipelineRequest, decompressResponsePolicy } from "../../src/index.js"; describe("decompressResponsePolicy (node)", function () { it("Sets the expected flag on the request", function () { diff --git a/sdk/core/core-rest-pipeline/test/node/formDataPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/node/formDataPolicy.spec.ts index 197fc066a81b..9e40b64f004d 100644 --- a/sdk/core/core-rest-pipeline/test/node/formDataPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/node/formDataPolicy.spec.ts @@ -2,14 +2,14 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PipelineResponse, SendRequest, createHttpHeaders, createPipelineRequest, formDataPolicy, -} from "../../src"; +} from "../../src/index.js"; describe("formDataPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/node/getBodyLength.spec.ts b/sdk/core/core-rest-pipeline/test/node/getBodyLength.spec.ts index 97801776f559..5cd1230bd122 100644 --- a/sdk/core/core-rest-pipeline/test/node/getBodyLength.spec.ts +++ b/sdk/core/core-rest-pipeline/test/node/getBodyLength.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { getBodyLength } from "../../src/nodeHttpClient"; +import { getBodyLength } from "../../src/nodeHttpClient.js"; describe("Get Body Length", function () { it("Gets the length of the ASCII string correctly", function () { diff --git a/sdk/core/core-rest-pipeline/test/node/nodeHttpClient.spec.ts b/sdk/core/core-rest-pipeline/test/node/nodeHttpClient.spec.ts index 00606d0fdb37..b6ecf8521999 100644 --- a/sdk/core/core-rest-pipeline/test/node/nodeHttpClient.spec.ts +++ b/sdk/core/core-rest-pipeline/test/node/nodeHttpClient.spec.ts @@ -2,13 +2,13 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PassThrough, Writable } from "stream"; import { ClientRequest, IncomingHttpHeaders, IncomingMessage } from "http"; -import * as https from "https"; -import * as http from "http"; +import https from "https"; +import http from "http"; import { AbortController } from "@azure/abort-controller"; -import { createDefaultHttpClient, createPipelineRequest } from "../../src"; +import { createDefaultHttpClient, createPipelineRequest } from "../../src/index.js"; class FakeResponse extends PassThrough { public statusCode?: number; diff --git a/sdk/core/core-rest-pipeline/test/node/pipeline.spec.ts b/sdk/core/core-rest-pipeline/test/node/pipeline.spec.ts index 4c773f2b4db3..fc67afdeabbf 100644 --- a/sdk/core/core-rest-pipeline/test/node/pipeline.spec.ts +++ b/sdk/core/core-rest-pipeline/test/node/pipeline.spec.ts @@ -1,19 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import * as http from "https"; -import * as https from "https"; +import http from "https"; +import https from "https"; -import { proxyPolicy, proxyPolicyName } from "../../src/policies/proxyPolicy"; -import { tlsPolicy, tlsPolicyName } from "../../src/policies/tlsPolicy"; +import { proxyPolicy, proxyPolicyName } from "../../src/policies/proxyPolicy.js"; +import { tlsPolicy, tlsPolicyName } from "../../src/policies/tlsPolicy.js"; -import { HttpClient } from "../../src/interfaces"; -import { HttpsProxyAgent } from "https-proxy-agent"; +import { HttpClient } from "../../src/interfaces.js"; +import httpsPA from "https-proxy-agent"; +const { HttpsProxyAgent } = httpsPA; import { assert } from "chai"; -import { createEmptyPipeline } from "../../src/pipeline"; -import { createHttpHeaders } from "../../src/httpHeaders"; -import { createNodeHttpClient } from "../../src/nodeHttpClient"; -import { createPipelineFromOptions } from "../../src/createPipelineFromOptions"; +import { createEmptyPipeline } from "../../src/pipeline.js"; +import { createHttpHeaders } from "../../src/httpHeaders.js"; +import { createNodeHttpClient } from "../../src/nodeHttpClient.js"; +import { createPipelineFromOptions } from "../../src/createPipelineFromOptions.js"; import sinon from "sinon"; describe("HttpsPipeline", function () { diff --git a/sdk/core/core-rest-pipeline/test/node/proxyPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/node/proxyPolicy.spec.ts index b795cba8c4ab..44e1171bb03e 100644 --- a/sdk/core/core-rest-pipeline/test/node/proxyPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/node/proxyPolicy.spec.ts @@ -2,19 +2,19 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { ProxySettings, SendRequest, createPipelineRequest, getDefaultProxySettings, proxyPolicy, -} from "../../src"; +} from "../../src/index.js"; import { getProxyAgentOptions, globalNoProxyList, loadNoProxy, -} from "../../src/policies/proxyPolicy"; +} from "../../src/policies/proxyPolicy.js"; describe("proxyPolicy (node)", function () { it("Sets proxy settings on the request", function () { diff --git a/sdk/core/core-rest-pipeline/test/node/restError.spec.ts b/sdk/core/core-rest-pipeline/test/node/restError.spec.ts index f316919ae176..70262cb96d48 100644 --- a/sdk/core/core-rest-pipeline/test/node/restError.spec.ts +++ b/sdk/core/core-rest-pipeline/test/node/restError.spec.ts @@ -2,7 +2,12 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { PipelineResponse, RestError, createHttpHeaders, createPipelineRequest } from "../../src"; +import { + PipelineResponse, + RestError, + createHttpHeaders, + createPipelineRequest, +} from "../../src/index.js"; import { inspect } from "util"; describe("RestError", function () { diff --git a/sdk/core/core-rest-pipeline/test/pipeline.spec.ts b/sdk/core/core-rest-pipeline/test/pipeline.spec.ts index ddcf575bd651..92619bd4edf0 100644 --- a/sdk/core/core-rest-pipeline/test/pipeline.spec.ts +++ b/sdk/core/core-rest-pipeline/test/pipeline.spec.ts @@ -9,7 +9,7 @@ import { createHttpHeaders, createPipelineFromOptions, createPipelineRequest, -} from "../src"; +} from "../src/index.js"; describe("HttpsPipeline", function () { it("Newly created pipeline has no policies", function () { diff --git a/sdk/core/core-rest-pipeline/test/redirectPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/redirectPolicy.spec.ts index 8f608cabec9f..c9632b5aabfe 100644 --- a/sdk/core/core-rest-pipeline/test/redirectPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/redirectPolicy.spec.ts @@ -2,9 +2,14 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { redirectPolicy } from "../src/policies/redirectPolicy"; -import * as sinon from "sinon"; -import { PipelineResponse, SendRequest, createHttpHeaders, createPipelineRequest } from "../src"; +import { redirectPolicy } from "../src/policies/redirectPolicy.js"; +import sinon from "sinon"; +import { + PipelineResponse, + SendRequest, + createHttpHeaders, + createPipelineRequest, +} from "../src/index.js"; describe("RedirectPolicy", () => { it("should not follow redirect if no location header", async () => { diff --git a/sdk/core/core-rest-pipeline/test/retryPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/retryPolicy.spec.ts index be08417de9fe..cc3666d25195 100644 --- a/sdk/core/core-rest-pipeline/test/retryPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/retryPolicy.spec.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import * as sinon from "sinon"; + +import sinon from "sinon"; import { PipelineResponse, RestError, @@ -8,11 +9,11 @@ import { createHttpHeaders, createPipelineRequest, retryPolicy, -} from "../src"; +} from "../src/index.js"; import { AbortController } from "@azure/abort-controller"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants.js"; import { assert } from "chai"; -import { makeTestLogger } from "./util"; +import { makeTestLogger } from "./util.js"; describe("retryPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/sanitizer.spec.ts b/sdk/core/core-rest-pipeline/test/sanitizer.spec.ts index a00d261f1ec9..b085e74655eb 100644 --- a/sdk/core/core-rest-pipeline/test/sanitizer.spec.ts +++ b/sdk/core/core-rest-pipeline/test/sanitizer.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import { Sanitizer } from "../src/util/sanitizer"; +import { Sanitizer } from "../src/util/sanitizer.js"; describe("Sanitizer", function () { it("Redacts query parameters in url properties", function () { diff --git a/sdk/core/core-rest-pipeline/test/systemErrorRetryPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/systemErrorRetryPolicy.spec.ts index f577f26b9ad8..262ddb0d78bb 100644 --- a/sdk/core/core-rest-pipeline/test/systemErrorRetryPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/systemErrorRetryPolicy.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PipelineResponse, RestError, @@ -10,8 +10,8 @@ import { createHttpHeaders, createPipelineRequest, systemErrorRetryPolicy, -} from "../src"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants"; +} from "../src/index.js"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants.js"; describe("systemErrorRetryPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/throttlingRetryPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/throttlingRetryPolicy.spec.ts index c2e88b78192c..bab425e7151a 100644 --- a/sdk/core/core-rest-pipeline/test/throttlingRetryPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/throttlingRetryPolicy.spec.ts @@ -5,16 +5,16 @@ import { assert, use as chaiUse } from "chai"; import chaiPromises from "chai-as-promised"; chaiUse(chaiPromises); import { Context } from "mocha"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PipelineResponse, SendRequest, createHttpHeaders, createPipelineRequest, throttlingRetryPolicy, -} from "../src"; +} from "../src/index.js"; import { AbortController } from "@azure/abort-controller"; -import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants"; +import { DEFAULT_RETRY_POLICY_COUNT } from "../src/constants.js"; describe("throttlingRetryPolicy", function () { afterEach(function () { diff --git a/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts b/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts index 32acd638a67b..2feb04125872 100644 --- a/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts +++ b/sdk/core/core-rest-pipeline/test/tracingPolicy.spec.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { assert } from "chai"; -import * as sinon from "sinon"; +import sinon from "sinon"; import { PipelineRequest, PipelineResponse, @@ -11,7 +11,7 @@ import { createHttpHeaders, createPipelineRequest, tracingPolicy, -} from "../src"; +} from "../src/index.js"; import { Instrumenter, InstrumenterSpanOptions,