diff --git a/packages/fx-core/src/common/templates-config.json b/packages/fx-core/src/common/templates-config.json index 443e3563e3..942ccb11b9 100644 --- a/packages/fx-core/src/common/templates-config.json +++ b/packages/fx-core/src/common/templates-config.json @@ -1,6 +1,6 @@ { "version": "~4.2", - "localVersion": "4.2.2", + "localVersion": "4.2.3", "tagPrefix": "templates@", "tagListURL": "https://github.com/OfficeDev/TeamsFx/releases/download/template-tag-list/template-tags.txt", "templateDownloadBaseURL": "https://github.com/OfficeDev/TeamsFx/releases/download", diff --git a/packages/fx-core/src/component/generator/apiSpec/helper.ts b/packages/fx-core/src/component/generator/apiSpec/helper.ts index ae14f25caa..2571212703 100644 --- a/packages/fx-core/src/component/generator/apiSpec/helper.ts +++ b/packages/fx-core/src/component/generator/apiSpec/helper.ts @@ -85,7 +85,11 @@ const enum telemetryEvents { failedToGetGenerateWarning = "failed-to-get-generate-warning", } -export function getParserOptions(type: ProjectType, isDeclarativeCopilot?: boolean): ParseOptions { +export function getParserOptions( + type: ProjectType, + isDeclarativeCopilot?: boolean, + platform?: string +): ParseOptions { return type === ProjectType.Copilot ? { isGptPlugin: isDeclarativeCopilot, @@ -113,7 +117,7 @@ export function getParserOptions(type: ProjectType, isDeclarativeCopilot?: boole } : { projectType: type, - allowBearerTokenAuth: true, // Currently, API key auth support is actually bearer token auth + allowBearerTokenAuth: !!platform && platform === Platform.VS ? false : true, // Currently, API key auth support is actually bearer token auth allowMultipleParameters: true, allowOauth2: featureFlagManager.getBooleanValue(FeatureFlags.SMEOAuth), }; @@ -158,7 +162,10 @@ export async function listOperations( : ProjectType.SME; try { - const specParser = new SpecParser(apiSpecUrl as string, getParserOptions(projectType)); + const specParser = new SpecParser( + apiSpecUrl as string, + getParserOptions(projectType, undefined, inputs.platform) + ); const validationRes = await specParser.validate(); validationRes.errors = formatValidationErrors(validationRes.errors, inputs); diff --git a/packages/fx-core/tests/component/generator/apiSpecGenerator.test.ts b/packages/fx-core/tests/component/generator/apiSpecGenerator.test.ts index 1feef321a8..173c71743d 100644 --- a/packages/fx-core/tests/component/generator/apiSpecGenerator.test.ts +++ b/packages/fx-core/tests/component/generator/apiSpecGenerator.test.ts @@ -1359,6 +1359,36 @@ describe("listOperations", async () => { expect(res.error[0].type).to.be.equal(ErrorType.AddedAPINotInOriginalSpec); } }); + + it("should not allow auth for VS project", async () => { + const inputs = { + platform: Platform.VS, + }; + sandbox.stub(CopilotPluginHelper, "formatValidationErrors").resolves([]); + sandbox.stub(CopilotPluginHelper, "logValidationResults").resolves(); + sandbox.stub(SpecParser.prototype, "validate").resolves({ + status: ValidationStatus.Valid, + warnings: [], + errors: [], + specHash: "xxx", + }); + sandbox.stub(SpecParser.prototype, "list").resolves({ + APIs: [ + { + api: "1", + server: "https://test", + operationId: "id1", + isValid: false, + reason: [ErrorType.AuthTypeIsNotSupported], + }, + ], + allAPICount: 1, + validAPICount: 0, + }); + + const res = await CopilotPluginHelper.listOperations(context, "", inputs, true, false, ""); + expect(res.isOk()).to.be.true; + }); }); describe("SpecGenerator", async () => { diff --git a/templates/package.json b/templates/package.json index 1d459eb0d4..f9624d67ed 100644 --- a/templates/package.json +++ b/templates/package.json @@ -1,6 +1,6 @@ { "name": "templates", - "version": "4.3.0-alpha", + "version": "4.2.3", "private": "true", "license": "MIT", "scripts": { diff --git a/templates/ts/ai-assistant-bot/tsconfig.json b/templates/ts/ai-assistant-bot/tsconfig.json index a68afb21f7..e11f855139 100644 --- a/templates/ts/ai-assistant-bot/tsconfig.json +++ b/templates/ts/ai-assistant-bot/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/ai-bot/tsconfig.json b/templates/ts/ai-bot/tsconfig.json index a68afb21f7..e11f855139 100644 --- a/templates/ts/ai-bot/tsconfig.json +++ b/templates/ts/ai-bot/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/command-and-response/tsconfig.json b/templates/ts/command-and-response/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/command-and-response/tsconfig.json +++ b/templates/ts/command-and-response/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/default-bot-message-extension/tsconfig.json b/templates/ts/default-bot-message-extension/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/default-bot-message-extension/tsconfig.json +++ b/templates/ts/default-bot-message-extension/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/default-bot/tsconfig.json b/templates/ts/default-bot/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/default-bot/tsconfig.json +++ b/templates/ts/default-bot/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/link-unfurling/tsconfig.json b/templates/ts/link-unfurling/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/link-unfurling/tsconfig.json +++ b/templates/ts/link-unfurling/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/m365-message-extension/tsconfig.json b/templates/ts/m365-message-extension/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/m365-message-extension/tsconfig.json +++ b/templates/ts/m365-message-extension/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/message-extension-action/tsconfig.json b/templates/ts/message-extension-action/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/message-extension-action/tsconfig.json +++ b/templates/ts/message-extension-action/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/message-extension-copilot/package.json.tpl b/templates/ts/message-extension-copilot/package.json.tpl index e900c8a110..e4883775a8 100644 --- a/templates/ts/message-extension-copilot/package.json.tpl +++ b/templates/ts/message-extension-copilot/package.json.tpl @@ -34,7 +34,7 @@ "@types/node": "^20.8.9", "env-cmd": "^10.1.0", "ts-node": "^10.4.0", - "typescript": "^5.2.2", + "typescript": "^4.4.4", "nodemon": "^3.0.1", "shx": "^0.3.3" } diff --git a/templates/ts/message-extension-copilot/tsconfig.json b/templates/ts/message-extension-copilot/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/message-extension-copilot/tsconfig.json +++ b/templates/ts/message-extension-copilot/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/message-extension/tsconfig.json b/templates/ts/message-extension/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/message-extension/tsconfig.json +++ b/templates/ts/message-extension/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/non-sso-tab-default-bot/bot/tsconfig.json b/templates/ts/non-sso-tab-default-bot/bot/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/non-sso-tab-default-bot/bot/tsconfig.json +++ b/templates/ts/non-sso-tab-default-bot/bot/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/notification-http-timer-trigger/tsconfig.json b/templates/ts/notification-http-timer-trigger/tsconfig.json index 75fd242a30..e5d60497c0 100644 --- a/templates/ts/notification-http-timer-trigger/tsconfig.json +++ b/templates/ts/notification-http-timer-trigger/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./dist", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "resolveJsonModule": true, diff --git a/templates/ts/notification-http-trigger/tsconfig.json b/templates/ts/notification-http-trigger/tsconfig.json index 75fd242a30..e5d60497c0 100644 --- a/templates/ts/notification-http-trigger/tsconfig.json +++ b/templates/ts/notification-http-trigger/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./dist", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "resolveJsonModule": true, diff --git a/templates/ts/notification-restify/tsconfig.json b/templates/ts/notification-restify/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/notification-restify/tsconfig.json +++ b/templates/ts/notification-restify/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo", diff --git a/templates/ts/notification-timer-trigger/tsconfig.json b/templates/ts/notification-timer-trigger/tsconfig.json index 75fd242a30..e5d60497c0 100644 --- a/templates/ts/notification-timer-trigger/tsconfig.json +++ b/templates/ts/notification-timer-trigger/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./dist", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "resolveJsonModule": true, diff --git a/templates/ts/sso-tab-with-obo-flow/api/tsconfig.json b/templates/ts/sso-tab-with-obo-flow/api/tsconfig.json index e1f43305ef..e8f3677ee6 100644 --- a/templates/ts/sso-tab-with-obo-flow/api/tsconfig.json +++ b/templates/ts/sso-tab-with-obo-flow/api/tsconfig.json @@ -2,8 +2,9 @@ "compilerOptions": { "module": "commonjs", "target": "es6", - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "moduleResolution": "nodenext", "outDir": "dist", "rootDir": ".", "sourceMap": true, diff --git a/templates/ts/workflow/tsconfig.json b/templates/ts/workflow/tsconfig.json index 77972584b2..385a05ba67 100644 --- a/templates/ts/workflow/tsconfig.json +++ b/templates/ts/workflow/tsconfig.json @@ -5,6 +5,7 @@ "module": "commonjs", "outDir": "./lib", "rootDir": "./", + "moduleResolution": "nodenext", "sourceMap": true, "incremental": true, "tsBuildInfoFile": "./lib/.tsbuildinfo",