diff --git a/sdk/openai/openai/README.md b/sdk/openai/openai/README.md index 05cfd6a129a2..f4ad85580401 100644 --- a/sdk/openai/openai/README.md +++ b/sdk/openai/openai/README.md @@ -46,7 +46,7 @@ There are several ways to authenticate with the Azure OpenAI service and the rec 2. Create a token provider by calling the `getBearerTokenProvider` with the desired credential type. For example, [DefaultAzureCredential][azure_identity_dac]: - ```js + ```ts import { DefaultAzureCredential, getBearerTokenProvider } from "@azure/identity"; const credential = new DefaultAzureCredential(); @@ -56,7 +56,7 @@ There are several ways to authenticate with the Azure OpenAI service and the rec 3. Create the client by passing in the token provider: - ```js + ```ts import { AzureOpenAI } from "openai"; const deployment = "Your deployment name"; diff --git a/sdk/openai/openai/api-extractor.json b/sdk/openai/openai/api-extractor.json index cbf75608dfdc..f978f622f751 100644 --- a/sdk/openai/openai/api-extractor.json +++ b/sdk/openai/openai/api-extractor.json @@ -9,9 +9,7 @@ "reportFolder": "./review" }, "dtsRollup": { - "enabled": true, - "untrimmedFilePath": "", - "publicTrimmedFilePath": "dist/openai.d.ts" + "enabled": false }, "messages": { "tsdocMessageReporting": { diff --git a/sdk/openai/openai/eslint.config.mjs b/sdk/openai/openai/eslint.config.mjs index 79f0d75d9796..ac709bfe034d 100644 --- a/sdk/openai/openai/eslint.config.mjs +++ b/sdk/openai/openai/eslint.config.mjs @@ -3,13 +3,19 @@ import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; export default [ ...azsdkEslint.configs.recommended, { - rules: { - "@azure/azure-sdk/ts-package-json-engine-is-present": "warn", - "@azure/azure-sdk/ts-package-json-module": "off", - "@azure/azure-sdk/ts-package-json-main-is-cjs": "off", - "@azure/azure-sdk/ts-package-json-types": "off", - "@azure/azure-sdk/ts-package-json-files-required": "off", - "no-restricted-imports": "warn", + files: ["**/*.ts", "**/*.cts", "**/*.mts"], + languageOptions: { + parserOptions: { + project: ["./tsconfig.src.json", "./tsconfig.tests.json"], + }, + }, + }, + { + files: ["*.md/*.ts"], + languageOptions: { + parserOptions: { + project: null, + }, }, }, ]; diff --git a/sdk/openai/openai/package.json b/sdk/openai/openai/package.json index c33ee8c18634..007dd161b373 100644 --- a/sdk/openai/openai/package.json +++ b/sdk/openai/openai/package.json @@ -43,6 +43,7 @@ "LICENSE" ], "tshy": { + "project": "./tsconfig.src.json", "exports": { "./package.json": "./package.json", ".": "./src/index.ts", @@ -69,8 +70,8 @@ "integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test:browser": "dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --no-test-proxy --browser", "integration-test:node": "dev-tool run test:vitest --no-test-proxy", - "lint": "eslint README.md package.json api-extractor.json src", - "lint:fix": "eslint README.md package.json api-extractor.json src --fix --fix-type [problem,suggestion]", + "lint": "eslint README.md package.json api-extractor.json src test", + "lint:fix": "eslint README.md package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", "pack": "npm pack 2>&1", "test": "npm run clean && dev-tool run build-package && npm run unit-test:node && dev-tool run build-test && npm run unit-test:browser && npm run integration-test", "test:browser": "npm run clean && npm run build:test && npm run integration-test:browser", diff --git a/sdk/openai/openai/test/public/completions.spec.ts b/sdk/openai/openai/test/public/completions.spec.ts index 32d001ea55a9..111de744a5eb 100644 --- a/sdk/openai/openai/test/public/completions.spec.ts +++ b/sdk/openai/openai/test/public/completions.spec.ts @@ -22,7 +22,7 @@ import { } from "./utils/utils.js"; import { type ChatCompletionMessageParam } from "openai/resources/chat/completions.mjs"; import { completionsModelsToSkip, functionCallModelsToSkip } from "./utils/models.js"; -import "../../src/types/index.js"; +import "@azure/openai/types"; describe("Completions", function () { let deployments: DeploymentInfo[] = []; diff --git a/sdk/openai/openai/test/public/utils/asserts.ts b/sdk/openai/openai/test/public/utils/asserts.ts index 8d9debc5aa99..3ad1533bd645 100644 --- a/sdk/openai/openai/test/public/utils/asserts.ts +++ b/sdk/openai/openai/test/public/utils/asserts.ts @@ -13,7 +13,7 @@ import type { ContentFilterResultDetailsForPromptOutput, ContentFilterResultsForChoiceOutput, ContentFilterResultsForPromptOutput, -} from "../../../src/types/index.js"; +} from "@azure/openai/types"; import type { Assistant, AssistantCreateParams } from "openai/resources/beta/assistants.mjs"; import type { Batch, diff --git a/sdk/openai/openai/test/public/utils/utils.ts b/sdk/openai/openai/test/public/utils/utils.ts index 13191546ea20..f06bcb9cd3a0 100644 --- a/sdk/openai/openai/test/public/utils/utils.ts +++ b/sdk/openai/openai/test/public/utils/utils.ts @@ -23,7 +23,7 @@ import { } from "./envVars.js"; import type { Run } from "openai/resources/beta/threads/runs/runs.mjs"; import { createClientLogger } from "@azure/logger"; -import type { AzureChatExtensionConfiguration } from "../../../src/types/models.js"; +import type { AzureChatExtensionConfiguration } from "@azure/openai/types"; const logger = createClientLogger("openai"); diff --git a/sdk/openai/openai/tsconfig.browser.config.json b/sdk/openai/openai/tsconfig.browser.config.json index acc82a24cd33..7eafd57faa8c 100644 --- a/sdk/openai/openai/tsconfig.browser.config.json +++ b/sdk/openai/openai/tsconfig.browser.config.json @@ -1,11 +1,9 @@ { - "extends": "./.tshy/build.json", + "extends": ["./.tshy/build.json", "./tsconfig.tests.json"], "include": ["./src/**/*.ts", "./src/**/*.mts", "./test/**/*.ts", "./test/**/*.mts"], "exclude": ["./test/**/node/**/*.ts"], "compilerOptions": { "outDir": "./dist-test/browser", - "lib": ["DOM"], - "rootDir": ".", - "skipLibCheck": true + "composite": true } } diff --git a/sdk/openai/openai/tsconfig.json b/sdk/openai/openai/tsconfig.json index 193393509e82..dc1db702a3b7 100644 --- a/sdk/openai/openai/tsconfig.json +++ b/sdk/openai/openai/tsconfig.json @@ -1,20 +1,9 @@ { "extends": "../../../tsconfig", - "compilerOptions": { - "paths": { - "@azure/openai": ["./src/index.js"] - }, - "module": "NodeNext", - "moduleResolution": "NodeNext", - "rootDir": "." - }, - "exclude": ["./samples/**/*.ts"], - "include": [ - "./src/**/*.ts", - "./src/**/*.mts", - "./src/**/*.cts", - "./samples-dev/**/*.ts", - "./test/**/*.ts", - "./test/**/*.mts" - ] + "references": [ + { "path": "./tsconfig.src.json" }, + { "path": "./tsconfig.samples.json" }, + { "path": "./tsconfig.tests.json" } + ], + "files": [] } diff --git a/sdk/openai/openai/tsconfig.samples.json b/sdk/openai/openai/tsconfig.samples.json new file mode 100644 index 000000000000..95150971070e --- /dev/null +++ b/sdk/openai/openai/tsconfig.samples.json @@ -0,0 +1,14 @@ +{ + "extends": "../../../tsconfig", + "compilerOptions": { + "target": "ES2023", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "paths": { + "@azure/openai": ["./dist/esm/index.js"] + }, + "noEmit": true, + "composite": true + }, + "include": ["./samples-dev"] +} diff --git a/sdk/openai/openai/tsconfig.src.json b/sdk/openai/openai/tsconfig.src.json new file mode 100644 index 000000000000..0413c4ab838c --- /dev/null +++ b/sdk/openai/openai/tsconfig.src.json @@ -0,0 +1,9 @@ +{ + "extends": "../../../tsconfig", + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "composite": true + }, + "include": ["./src"] +} diff --git a/sdk/openai/openai/tsconfig.tests.json b/sdk/openai/openai/tsconfig.tests.json new file mode 100644 index 000000000000..034bf4ba832a --- /dev/null +++ b/sdk/openai/openai/tsconfig.tests.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../tsconfig", + "compilerOptions": { + "target": "ES2023", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "lib": ["DOM"], + "skipLibCheck": true, + "noEmit": true, + "composite": true + }, + "include": ["./test"] +} diff --git a/sdk/openai/openai/vitest.config.ts b/sdk/openai/openai/vitest.config.ts index 7fe92764c4f6..fcef344cc8f6 100644 --- a/sdk/openai/openai/vitest.config.ts +++ b/sdk/openai/openai/vitest.config.ts @@ -13,6 +13,11 @@ export default mergeConfig( hookTimeout: 25000, fileParallelism: false, include: ["test/public/**/*.spec.ts"], + typecheck: { + enabled: true, + tsconfig: "tsconfig.tests.json", + include: ["test/**/*.ts", "test/**/*.mts", "test/**/*.cts"] + } }, }), );