@microsoft/teamsfx-core 2.0.4-alpha.8b06251e7.0 → 2.0.4-alpha.8d68ea31a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/common/constants.d.ts +1 -0
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +1 -0
- package/build/common/constants.js.map +1 -1
- package/build/common/deps-checker/internal/dotnetChecker.d.ts.map +1 -1
- package/build/common/deps-checker/internal/dotnetChecker.js +16 -12
- package/build/common/deps-checker/internal/dotnetChecker.js.map +1 -1
- package/build/common/deps-checker/internal/nodeChecker.d.ts.map +1 -1
- package/build/common/deps-checker/internal/nodeChecker.js +1 -1
- package/build/common/deps-checker/internal/nodeChecker.js.map +1 -1
- package/build/common/deps-checker/util/cpUtils.js +2 -2
- package/build/common/deps-checker/util/cpUtils.js.map +1 -1
- package/build/common/local/localCertificateManager.d.ts.map +1 -1
- package/build/common/local/localCertificateManager.js +3 -0
- package/build/common/local/localCertificateManager.js.map +1 -1
- package/build/common/local/packageJsonHelper.d.ts.map +1 -1
- package/build/common/local/packageJsonHelper.js +1 -0
- package/build/common/local/packageJsonHelper.js.map +1 -1
- package/build/common/local/portChecker.js.map +1 -1
- package/build/common/m365/launchHelper.d.ts +1 -1
- package/build/common/m365/launchHelper.d.ts.map +1 -1
- package/build/common/m365/launchHelper.js +12 -3
- package/build/common/m365/launchHelper.js.map +1 -1
- package/build/common/m365/packageService.d.ts.map +1 -1
- package/build/common/m365/packageService.js +14 -13
- package/build/common/m365/packageService.js.map +1 -1
- package/build/common/projectSettingsHelper.d.ts.map +1 -1
- package/build/common/projectSettingsHelper.js +1 -0
- package/build/common/projectSettingsHelper.js.map +1 -1
- package/build/common/samples.d.ts +4 -1
- package/build/common/samples.d.ts.map +1 -1
- package/build/common/samples.js +48 -21
- package/build/common/samples.js.map +1 -1
- package/build/common/spec-parser/adaptiveCardGenerator.d.ts.map +1 -1
- package/build/common/spec-parser/adaptiveCardGenerator.js +3 -2
- package/build/common/spec-parser/adaptiveCardGenerator.js.map +1 -1
- package/build/common/spec-parser/constants.d.ts +4 -0
- package/build/common/spec-parser/constants.d.ts.map +1 -1
- package/build/common/spec-parser/constants.js +27 -0
- package/build/common/spec-parser/constants.js.map +1 -1
- package/build/common/spec-parser/interfaces.d.ts +10 -5
- package/build/common/spec-parser/interfaces.d.ts.map +1 -1
- package/build/common/spec-parser/interfaces.js +3 -1
- package/build/common/spec-parser/interfaces.js.map +1 -1
- package/build/common/spec-parser/manifestUpdater.d.ts +3 -2
- package/build/common/spec-parser/manifestUpdater.d.ts.map +1 -1
- package/build/common/spec-parser/manifestUpdater.js +69 -31
- package/build/common/spec-parser/manifestUpdater.js.map +1 -1
- package/build/common/spec-parser/specFilter.d.ts +1 -1
- package/build/common/spec-parser/specFilter.d.ts.map +1 -1
- package/build/common/spec-parser/specFilter.js +4 -4
- package/build/common/spec-parser/specFilter.js.map +1 -1
- package/build/common/spec-parser/specParser.d.ts +2 -2
- package/build/common/spec-parser/specParser.d.ts.map +1 -1
- package/build/common/spec-parser/specParser.js +32 -25
- package/build/common/spec-parser/specParser.js.map +1 -1
- package/build/common/spec-parser/utils.d.ts +20 -0
- package/build/common/spec-parser/utils.d.ts.map +1 -1
- package/build/common/spec-parser/utils.js +170 -19
- package/build/common/spec-parser/utils.js.map +1 -1
- package/build/component/configManager/interface.d.ts +0 -1
- package/build/component/configManager/interface.d.ts.map +1 -1
- package/build/component/configManager/lifecycle.d.ts +1 -3
- package/build/component/configManager/lifecycle.d.ts.map +1 -1
- package/build/component/configManager/lifecycle.js +12 -47
- package/build/component/configManager/lifecycle.js.map +1 -1
- package/build/component/configManager/parser.js.map +1 -1
- package/build/component/coordinator/index.d.ts.map +1 -1
- package/build/component/coordinator/index.js +16 -7
- package/build/component/coordinator/index.js.map +1 -1
- package/build/component/coordinator/summary.d.ts.map +1 -1
- package/build/component/coordinator/summary.js +2 -1
- package/build/component/coordinator/summary.js.map +1 -1
- package/build/component/driver/aad/utility/aadAppClient.d.ts.map +1 -1
- package/build/component/driver/aad/utility/aadAppClient.js +1 -0
- package/build/component/driver/aad/utility/aadAppClient.js.map +1 -1
- package/build/component/driver/add/addWebPart.d.ts.map +1 -1
- package/build/component/driver/add/addWebPart.js +9 -0
- package/build/component/driver/add/addWebPart.js.map +1 -1
- package/build/component/driver/arm/deploy.d.ts +0 -3
- package/build/component/driver/arm/deploy.d.ts.map +1 -1
- package/build/component/driver/arm/deploy.js +0 -6
- package/build/component/driver/arm/deploy.js.map +1 -1
- package/build/component/driver/arm/util/bicepChecker.js +3 -3
- package/build/component/driver/arm/util/bicepChecker.js.map +1 -1
- package/build/component/driver/arm/util/handleError.js.map +1 -1
- package/build/component/driver/botFramework/createOrUpdateBot.d.ts.map +1 -1
- package/build/component/driver/botFramework/createOrUpdateBot.js +1 -1
- package/build/component/driver/botFramework/createOrUpdateBot.js.map +1 -1
- package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.d.ts +0 -2
- package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.js +0 -10
- package/build/component/driver/deploy/azure/azureAppServiceDeployDriver.js.map +1 -1
- package/build/component/driver/deploy/azure/azureFunctionDeployDriver.d.ts +0 -2
- package/build/component/driver/deploy/azure/azureFunctionDeployDriver.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/azureFunctionDeployDriver.js +0 -10
- package/build/component/driver/deploy/azure/azureFunctionDeployDriver.js.map +1 -1
- package/build/component/driver/deploy/azure/azureStorageDeployDriver.d.ts +0 -2
- package/build/component/driver/deploy/azure/azureStorageDeployDriver.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/azureStorageDeployDriver.js +5 -14
- package/build/component/driver/deploy/azure/azureStorageDeployDriver.js.map +1 -1
- package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.js +7 -2
- package/build/component/driver/deploy/azure/impl/AzureZipDeployImpl.js.map +1 -1
- package/build/component/driver/deploy/azure/impl/azureDeployImpl.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/impl/azureDeployImpl.js +11 -8
- package/build/component/driver/deploy/azure/impl/azureDeployImpl.js.map +1 -1
- package/build/component/driver/deploy/azure/impl/baseDeployImpl.d.ts.map +1 -1
- package/build/component/driver/deploy/azure/impl/baseDeployImpl.js +1 -1
- package/build/component/driver/deploy/azure/impl/baseDeployImpl.js.map +1 -1
- package/build/component/driver/deploy/spfx/deployDriver.d.ts.map +1 -1
- package/build/component/driver/deploy/spfx/deployDriver.js +16 -0
- package/build/component/driver/deploy/spfx/deployDriver.js.map +1 -1
- package/build/component/driver/devTool/installDriver.d.ts.map +1 -1
- package/build/component/driver/devTool/installDriver.js +23 -5
- package/build/component/driver/devTool/installDriver.js.map +1 -1
- package/build/component/driver/file/createOrUpdateEnvironmentFile.d.ts.map +1 -1
- package/build/component/driver/file/createOrUpdateEnvironmentFile.js +7 -7
- package/build/component/driver/file/createOrUpdateEnvironmentFile.js.map +1 -1
- package/build/component/driver/interface/stepDriver.d.ts +1 -7
- package/build/component/driver/interface/stepDriver.d.ts.map +1 -1
- package/build/component/driver/m365/acquire.js +1 -1
- package/build/component/driver/m365/acquire.js.map +1 -1
- package/build/component/driver/script/baseBuildDriver.d.ts.map +1 -1
- package/build/component/driver/script/baseBuildDriver.js +1 -0
- package/build/component/driver/script/baseBuildDriver.js.map +1 -1
- package/build/component/driver/script/baseBuildStepDriver.d.ts +0 -2
- package/build/component/driver/script/baseBuildStepDriver.d.ts.map +1 -1
- package/build/component/driver/script/baseBuildStepDriver.js +0 -4
- package/build/component/driver/script/baseBuildStepDriver.js.map +1 -1
- package/build/component/driver/script/dotnetBuildDriver.d.ts +0 -2
- package/build/component/driver/script/dotnetBuildDriver.d.ts.map +1 -1
- package/build/component/driver/script/dotnetBuildDriver.js +0 -9
- package/build/component/driver/script/dotnetBuildDriver.js.map +1 -1
- package/build/component/driver/script/npmBuildDriver.d.ts +0 -2
- package/build/component/driver/script/npmBuildDriver.d.ts.map +1 -1
- package/build/component/driver/script/npmBuildDriver.js +0 -9
- package/build/component/driver/script/npmBuildDriver.js.map +1 -1
- package/build/component/driver/script/npxBuildDriver.d.ts +0 -2
- package/build/component/driver/script/npxBuildDriver.d.ts.map +1 -1
- package/build/component/driver/script/npxBuildDriver.js +0 -9
- package/build/component/driver/script/npxBuildDriver.js.map +1 -1
- package/build/component/driver/script/scriptDriver.d.ts +10 -1
- package/build/component/driver/script/scriptDriver.d.ts.map +1 -1
- package/build/component/driver/script/scriptDriver.js +29 -22
- package/build/component/driver/script/scriptDriver.js.map +1 -1
- package/build/component/driver/teamsApp/appStudio.js +5 -5
- package/build/component/driver/teamsApp/appStudio.js.map +1 -1
- package/build/component/driver/teamsApp/clients/appStudioClient.d.ts +5 -5
- package/build/component/driver/teamsApp/clients/appStudioClient.d.ts.map +1 -1
- package/build/component/driver/teamsApp/clients/appStudioClient.js +23 -10
- package/build/component/driver/teamsApp/clients/appStudioClient.js.map +1 -1
- package/build/component/driver/teamsApp/clients/authSvcClient.d.ts.map +1 -1
- package/build/component/driver/teamsApp/clients/authSvcClient.js +2 -0
- package/build/component/driver/teamsApp/clients/authSvcClient.js.map +1 -1
- package/build/component/driver/teamsApp/configure.d.ts +0 -1
- package/build/component/driver/teamsApp/configure.d.ts.map +1 -1
- package/build/component/driver/teamsApp/configure.js +1 -6
- package/build/component/driver/teamsApp/configure.js.map +1 -1
- package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts +0 -2
- package/build/component/driver/teamsApp/copyAppPackageToSPFx.d.ts.map +1 -1
- package/build/component/driver/teamsApp/copyAppPackageToSPFx.js +2 -6
- package/build/component/driver/teamsApp/copyAppPackageToSPFx.js.map +1 -1
- package/build/component/driver/teamsApp/create.d.ts +0 -1
- package/build/component/driver/teamsApp/create.d.ts.map +1 -1
- package/build/component/driver/teamsApp/create.js +4 -6
- package/build/component/driver/teamsApp/create.js.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.d.ts +0 -1
- package/build/component/driver/teamsApp/createAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/createAppPackage.js +11 -21
- package/build/component/driver/teamsApp/createAppPackage.js.map +1 -1
- package/build/component/driver/teamsApp/errors.d.ts.map +1 -1
- package/build/component/driver/teamsApp/errors.js +2 -0
- package/build/component/driver/teamsApp/errors.js.map +1 -1
- package/build/component/driver/teamsApp/interfaces/appdefinitions/messagingExtension.d.ts +0 -1
- package/build/component/driver/teamsApp/interfaces/appdefinitions/messagingExtension.d.ts.map +1 -1
- package/build/component/driver/teamsApp/publishAppPackage.d.ts +0 -1
- package/build/component/driver/teamsApp/publishAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/publishAppPackage.js +2 -7
- package/build/component/driver/teamsApp/publishAppPackage.js.map +1 -1
- package/build/component/driver/teamsApp/utils/ManifestUtils.d.ts.map +1 -1
- package/build/component/driver/teamsApp/utils/ManifestUtils.js +2 -0
- package/build/component/driver/teamsApp/utils/ManifestUtils.js.map +1 -1
- package/build/component/driver/teamsApp/validate.d.ts +0 -1
- package/build/component/driver/teamsApp/validate.d.ts.map +1 -1
- package/build/component/driver/teamsApp/validate.js +0 -5
- package/build/component/driver/teamsApp/validate.js.map +1 -1
- package/build/component/driver/teamsApp/validateAppPackage.d.ts +0 -1
- package/build/component/driver/teamsApp/validateAppPackage.d.ts.map +1 -1
- package/build/component/driver/teamsApp/validateAppPackage.js +0 -5
- package/build/component/driver/teamsApp/validateAppPackage.js.map +1 -1
- package/build/component/feature/collaboration.d.ts.map +1 -1
- package/build/component/feature/collaboration.js +3 -3
- package/build/component/feature/collaboration.js.map +1 -1
- package/build/component/generator/copilotPlugin/generator.d.ts +3 -1
- package/build/component/generator/copilotPlugin/generator.d.ts.map +1 -1
- package/build/component/generator/copilotPlugin/generator.js +42 -16
- package/build/component/generator/copilotPlugin/generator.js.map +1 -1
- package/build/component/generator/copilotPlugin/helper.d.ts +1 -1
- package/build/component/generator/copilotPlugin/helper.d.ts.map +1 -1
- package/build/component/generator/copilotPlugin/helper.js +22 -25
- package/build/component/generator/copilotPlugin/helper.js.map +1 -1
- package/build/component/generator/error.d.ts +6 -0
- package/build/component/generator/error.d.ts.map +1 -1
- package/build/component/generator/error.js +13 -1
- package/build/component/generator/error.js.map +1 -1
- package/build/component/generator/generator.d.ts.map +1 -1
- package/build/component/generator/generator.js +18 -10
- package/build/component/generator/generator.js.map +1 -1
- package/build/component/generator/generatorAction.d.ts +2 -1
- package/build/component/generator/generatorAction.d.ts.map +1 -1
- package/build/component/generator/generatorAction.js +8 -2
- package/build/component/generator/generatorAction.js.map +1 -1
- package/build/component/generator/officeAddin/helperMethods.d.ts.map +1 -1
- package/build/component/generator/officeAddin/helperMethods.js +6 -2
- package/build/component/generator/officeAddin/helperMethods.js.map +1 -1
- package/build/component/generator/spfx/depsChecker/generatorChecker.d.ts.map +1 -1
- package/build/component/generator/spfx/depsChecker/generatorChecker.js +2 -0
- package/build/component/generator/spfx/depsChecker/generatorChecker.js.map +1 -1
- package/build/component/generator/spfx/depsChecker/yoChecker.d.ts.map +1 -1
- package/build/component/generator/spfx/depsChecker/yoChecker.js +2 -2
- package/build/component/generator/spfx/depsChecker/yoChecker.js.map +1 -1
- package/build/component/generator/spfx/utils/utils.js +3 -3
- package/build/component/generator/spfx/utils/utils.js.map +1 -1
- package/build/component/generator/utils.d.ts +2 -2
- package/build/component/generator/utils.d.ts.map +1 -1
- package/build/component/generator/utils.js +13 -13
- package/build/component/generator/utils.js.map +1 -1
- package/build/component/messages.d.ts +2 -3
- package/build/component/messages.d.ts.map +1 -1
- package/build/component/messages.js +3 -4
- package/build/component/messages.js.map +1 -1
- package/build/component/middleware/actionExecutionMW.d.ts +2 -2
- package/build/component/middleware/actionExecutionMW.d.ts.map +1 -1
- package/build/component/middleware/envMW.d.ts.map +1 -1
- package/build/component/middleware/envMW.js +1 -1
- package/build/component/middleware/envMW.js.map +1 -1
- package/build/component/provisionUtils.js +6 -6
- package/build/component/provisionUtils.js.map +1 -1
- package/build/component/resource/botService/appStudio/appStudioClient.d.ts.map +1 -1
- package/build/component/resource/botService/appStudio/appStudioClient.js +3 -1
- package/build/component/resource/botService/appStudio/appStudioClient.js.map +1 -1
- package/build/component/resource/botService/botRegistration/botFrameworkRegistration.d.ts +2 -2
- package/build/component/resource/botService/botRegistration/botFrameworkRegistration.d.ts.map +1 -1
- package/build/component/resource/botService/botRegistration/botFrameworkRegistration.js +6 -1
- package/build/component/resource/botService/botRegistration/botFrameworkRegistration.js.map +1 -1
- package/build/component/utils/common.js +1 -1
- package/build/component/utils/common.js.map +1 -1
- package/build/component/utils/depsChecker/cpUtils.d.ts.map +1 -1
- package/build/component/utils/depsChecker/cpUtils.js +8 -4
- package/build/component/utils/depsChecker/cpUtils.js.map +1 -1
- package/build/component/utils/envUtil.js +2 -2
- package/build/component/utils/envUtil.js.map +1 -1
- package/build/core/FxCore.d.ts +3 -2
- package/build/core/FxCore.d.ts.map +1 -1
- package/build/core/FxCore.js +30 -15
- package/build/core/FxCore.js.map +1 -1
- package/build/core/middleware/concurrentLocker.d.ts.map +1 -1
- package/build/core/middleware/concurrentLocker.js +5 -1
- package/build/core/middleware/concurrentLocker.js.map +1 -1
- package/build/core/middleware/projectMigratorV3.d.ts.map +1 -1
- package/build/core/middleware/projectMigratorV3.js.map +1 -1
- package/build/core/middleware/projectVersionChecker.js +5 -5
- package/build/core/middleware/projectVersionChecker.js.map +1 -1
- package/build/core/middleware/utils/debug/taskMigrator.d.ts.map +1 -1
- package/build/core/middleware/utils/debug/taskMigrator.js +3 -0
- package/build/core/middleware/utils/debug/taskMigrator.js.map +1 -1
- package/build/core/middleware/utils/v3MigrationUtils.js +1 -1
- package/build/core/middleware/utils/v3MigrationUtils.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/question/constants.d.ts +2 -2
- package/build/question/constants.d.ts.map +1 -1
- package/build/question/constants.js +2 -2
- package/build/question/constants.js.map +1 -1
- package/build/question/create.d.ts.map +1 -1
- package/build/question/create.js +10 -12
- package/build/question/create.js.map +1 -1
- package/build/question/generator.d.ts.map +1 -1
- package/build/question/generator.js +9 -15
- package/build/question/generator.js.map +1 -1
- package/build/question/inputs/CreateProjectInputs.d.ts +2 -2
- package/build/question/inputs/CreateProjectInputs.d.ts.map +1 -1
- package/build/question/options/CreateProjectOptions.d.ts.map +1 -1
- package/build/question/options/CreateProjectOptions.js +10 -12
- package/build/question/options/CreateProjectOptions.js.map +1 -1
- package/build/question/options/DeployAadManifestOptions.js +1 -1
- package/build/question/options/DeployAadManifestOptions.js.map +1 -1
- package/build/question/options/PermissionGrantOptions.js +2 -2
- package/build/question/options/PermissionGrantOptions.js.map +1 -1
- package/build/question/options/PermissionListOptions.js +2 -2
- package/build/question/options/PermissionListOptions.js.map +1 -1
- package/build/question/options/PreviewTeamsAppOptions.js +2 -2
- package/build/question/options/PreviewTeamsAppOptions.js.map +1 -1
- package/build/question/options/SPFxAddWebpartOptions.d.ts.map +1 -1
- package/build/question/options/SPFxAddWebpartOptions.js +2 -3
- package/build/question/options/SPFxAddWebpartOptions.js.map +1 -1
- package/build/question/options/SelectTeamsManifestOptions.js +1 -1
- package/build/question/options/SelectTeamsManifestOptions.js.map +1 -1
- package/build/question/options/ValidateTeamsAppOptions.js +2 -2
- package/build/question/options/ValidateTeamsAppOptions.js.map +1 -1
- package/build/question/other.d.ts.map +1 -1
- package/build/question/other.js +7 -5
- package/build/question/other.js.map +1 -1
- package/build/question/questionNames.d.ts +1 -1
- package/build/question/questionNames.d.ts.map +1 -1
- package/build/question/questionNames.js +1 -1
- package/build/question/questionNames.js.map +1 -1
- package/build/ui/validationUtils.d.ts +17 -1
- package/build/ui/validationUtils.d.ts.map +1 -1
- package/build/ui/validationUtils.js +206 -4
- package/build/ui/validationUtils.js.map +1 -1
- package/build/ui/visitor.d.ts.map +1 -1
- package/build/ui/visitor.js +16 -15
- package/build/ui/visitor.js.map +1 -1
- package/package.json +11 -8
- package/resource/package.nls.json +9 -8
- package/templates/fallback/common.zip +0 -0
- package/templates/fallback/csharp.zip +0 -0
- package/templates/fallback/js.zip +0 -0
- package/templates/fallback/ts.zip +0 -0
- package/build/common/samples-config-v3.json +0 -446
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
"use strict";
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.generateCommands = exports.updateManifest = void 0;
|
|
5
|
+
exports.generateCommands = exports.generateParametersFromSchema = exports.updateManifest = void 0;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const interfaces_1 = require("./interfaces");
|
|
8
8
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
9
9
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
10
10
|
const utils_1 = require("./utils");
|
|
11
11
|
const specParserError_1 = require("./specParserError");
|
|
12
|
+
const constants_1 = require("./constants");
|
|
12
13
|
async function updateManifest(manifestPath, outputSpecPath, adaptiveCardFolder, spec) {
|
|
13
14
|
var _a;
|
|
14
15
|
try {
|
|
15
16
|
// TODO: manifest interface can be updated when manifest parser library is ready
|
|
16
17
|
const originalManifest = await fs_extra_1.default.readJSON(manifestPath);
|
|
17
|
-
const commands = generateCommands(spec, adaptiveCardFolder, manifestPath);
|
|
18
|
+
const commands = await generateCommands(spec, adaptiveCardFolder, manifestPath);
|
|
18
19
|
const ComposeExtension = {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
composeExtensionType: "apiBased",
|
|
21
|
+
apiSpecificationFile: utils_1.getRelativePath(manifestPath, outputSpecPath),
|
|
21
22
|
commands: commands,
|
|
22
|
-
supportsConversationalAI: true,
|
|
23
23
|
};
|
|
24
24
|
const updatedPart = {
|
|
25
25
|
description: {
|
|
@@ -36,7 +36,30 @@ async function updateManifest(manifestPath, outputSpecPath, adaptiveCardFolder,
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
exports.updateManifest = updateManifest;
|
|
39
|
-
function
|
|
39
|
+
function generateParametersFromSchema(schema, name) {
|
|
40
|
+
var _a;
|
|
41
|
+
const parameters = [];
|
|
42
|
+
if (schema.type === "string" ||
|
|
43
|
+
schema.type === "integer" ||
|
|
44
|
+
schema.type === "boolean" ||
|
|
45
|
+
schema.type === "number") {
|
|
46
|
+
parameters.push({
|
|
47
|
+
name: name,
|
|
48
|
+
title: utils_1.updateFirstLetter(name),
|
|
49
|
+
description: (_a = schema.description) !== null && _a !== void 0 ? _a : "",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else if (schema.type === "object") {
|
|
53
|
+
const { properties } = schema;
|
|
54
|
+
for (const property in properties) {
|
|
55
|
+
const result = generateParametersFromSchema(properties[property], property);
|
|
56
|
+
parameters.push(...result);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return parameters;
|
|
60
|
+
}
|
|
61
|
+
exports.generateParametersFromSchema = generateParametersFromSchema;
|
|
62
|
+
async function generateCommands(spec, adaptiveCardFolder, manifestPath) {
|
|
40
63
|
var _a;
|
|
41
64
|
const paths = spec.paths;
|
|
42
65
|
const commands = [];
|
|
@@ -45,32 +68,47 @@ function generateCommands(spec, adaptiveCardFolder, manifestPath) {
|
|
|
45
68
|
const pathItem = paths[pathUrl];
|
|
46
69
|
if (pathItem) {
|
|
47
70
|
const operations = pathItem;
|
|
48
|
-
// Currently only support GET method
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
// Currently only support GET and POST method
|
|
72
|
+
for (const method in operations) {
|
|
73
|
+
if (method === constants_1.ConstantString.PostMethod || method === constants_1.ConstantString.GetMethod) {
|
|
74
|
+
const operationItem = operations[method];
|
|
75
|
+
if (operationItem) {
|
|
76
|
+
const parameters = [];
|
|
77
|
+
const paramObject = operationItem.parameters;
|
|
78
|
+
if (paramObject) {
|
|
79
|
+
paramObject.forEach((param) => {
|
|
80
|
+
var _a;
|
|
81
|
+
parameters.push({
|
|
82
|
+
name: param.name,
|
|
83
|
+
title: utils_1.updateFirstLetter(param.name),
|
|
84
|
+
description: (_a = param.description) !== null && _a !== void 0 ? _a : "",
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (operationItem.requestBody) {
|
|
89
|
+
const requestJson = operationItem.requestBody
|
|
90
|
+
.content["application/json"];
|
|
91
|
+
if (Object.keys(requestJson).length !== 0) {
|
|
92
|
+
const schema = requestJson.schema;
|
|
93
|
+
const result = generateParametersFromSchema(schema, "requestBody");
|
|
94
|
+
parameters.push(...result);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const operationId = operationItem.operationId;
|
|
98
|
+
const adaptiveCardPath = path_1.default.join(adaptiveCardFolder, operationId + ".json");
|
|
99
|
+
const command = {
|
|
100
|
+
context: ["compose"],
|
|
101
|
+
type: "query",
|
|
102
|
+
title: (_a = operationItem.summary) !== null && _a !== void 0 ? _a : "",
|
|
103
|
+
id: operationId,
|
|
104
|
+
parameters: parameters,
|
|
105
|
+
apiResponseRenderingTemplateFile: (await fs_extra_1.default.pathExists(adaptiveCardPath))
|
|
106
|
+
? utils_1.getRelativePath(manifestPath, adaptiveCardPath)
|
|
107
|
+
: "",
|
|
108
|
+
};
|
|
109
|
+
commands.push(command);
|
|
110
|
+
}
|
|
63
111
|
}
|
|
64
|
-
const adaptiveCardPath = path_1.default.join(adaptiveCardFolder, operationItem.operationId + ".json");
|
|
65
|
-
const command = {
|
|
66
|
-
context: ["compose"],
|
|
67
|
-
type: "query",
|
|
68
|
-
title: (_a = operationItem.summary) !== null && _a !== void 0 ? _a : "",
|
|
69
|
-
id: operationItem.operationId,
|
|
70
|
-
parameters: parameters,
|
|
71
|
-
apiResponseRenderingTemplate: utils_1.getRelativePath(manifestPath, adaptiveCardPath),
|
|
72
|
-
};
|
|
73
|
-
commands.push(command);
|
|
74
112
|
}
|
|
75
113
|
}
|
|
76
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifestUpdater.js","sourceRoot":"","sources":["../../../src/common/spec-parser/manifestUpdater.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAGb,6CAAgG;AAChG,gEAA0B;AAC1B,wDAAwB;AACxB,mCAA6D;AAC7D,uDAAoD;
|
|
1
|
+
{"version":3,"file":"manifestUpdater.js","sourceRoot":"","sources":["../../../src/common/spec-parser/manifestUpdater.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAGb,6CAAgG;AAChG,gEAA0B;AAC1B,wDAAwB;AACxB,mCAA6D;AAC7D,uDAAoD;AACpD,2CAA6C;AAEtC,KAAK,UAAU,cAAc,CAClC,YAAoB,EACpB,cAAsB,EACtB,kBAA0B,EAC1B,IAAwB;;IAExB,IAAI;QACF,gFAAgF;QAChF,MAAM,gBAAgB,GAAoB,MAAM,kBAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;QAE1E,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC;QAChF,MAAM,gBAAgB,GAAqB;YACzC,oBAAoB,EAAE,UAAU;YAChC,oBAAoB,EAAE,uBAAe,CAAC,YAAY,EAAE,cAAc,CAAC;YACnE,QAAQ,EAAE,QAAQ;SACnB,CAAC;QAEF,MAAM,WAAW,GAAoB;YACnC,WAAW,EAAE;gBACX,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;gBACtB,IAAI,EAAE,MAAA,IAAI,CAAC,IAAI,C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MAAM,CAAC,CAAC;iCAC5B;6BACF;4BAED,MAAM,WAAW,GAAG,aAAa,CAAC,WAAY,CAAC;4BAE/C,MAAM,gBAAgB,GAAG,cAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC;4BAE9E,MAAM,OAAO,GAAY;gCACvB,OAAO,EAAE,CAAC,SAAS,CAAC;gCACpB,IAAI,EAAE,OAAO;gCACb,KAAK,EAAE,MAAA,aAAa,CAAC,OAAO,mCAAI,EAAE;gCAClC,EAAE,EAAE,WAAW;gCACf,UAAU,EAAE,UAAU;gCACtB,gCAAgC,EAAE,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;oCACvE,CAAC,CAAC,uBAAe,CAAC,YAAY,EAAE,gBAAgB,CAAC;oCACjD,CAAC,CAAC,EAAE;6BACP,CAAC;4BACF,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;yBACxB;qBACF;iBACF;aACF;SACF;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAhED,4CAgEC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
export declare function specFilter(filter: string[], unResolveSpec: OpenAPIV3.Document): OpenAPIV3.Document;
|
|
2
|
+
export declare function specFilter(filter: string[], unResolveSpec: OpenAPIV3.Document, resolvedSpec: OpenAPIV3.Document): OpenAPIV3.Document;
|
|
3
3
|
//# sourceMappingURL=specFilter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specFilter.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specFilter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"specFilter.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specFilter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAM1C,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EAAE,EAChB,aAAa,EAAE,SAAS,CAAC,QAAQ,EACjC,YAAY,EAAE,SAAS,CAAC,QAAQ,GAC/B,SAAS,CAAC,QAAQ,CAkCpB"}
|
|
@@ -6,20 +6,20 @@ exports.specFilter = void 0;
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
const specParserError_1 = require("./specParserError");
|
|
8
8
|
const interfaces_1 = require("./interfaces");
|
|
9
|
-
const
|
|
10
|
-
function specFilter(filter, unResolveSpec) {
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
function specFilter(filter, unResolveSpec, resolvedSpec) {
|
|
11
11
|
try {
|
|
12
12
|
const newSpec = Object.assign({}, unResolveSpec);
|
|
13
13
|
const newPaths = {};
|
|
14
14
|
for (const filterItem of filter) {
|
|
15
15
|
const [method, path] = filterItem.split(" ");
|
|
16
16
|
const methodName = method.toLowerCase();
|
|
17
|
-
if (!utils_1.isSupportedApi(methodName, path,
|
|
17
|
+
if (!utils_1.isSupportedApi(methodName, path, resolvedSpec)) {
|
|
18
18
|
continue;
|
|
19
19
|
}
|
|
20
20
|
if (!newPaths[path]) {
|
|
21
21
|
newPaths[path] = Object.assign({}, unResolveSpec.paths[path]);
|
|
22
|
-
for (const m of
|
|
22
|
+
for (const m of constants_1.ConstantString.AllOperationMethods) {
|
|
23
23
|
delete newPaths[path][m];
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specFilter.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specFilter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;AAGb,mCAAiE;AACjE,uDAAoD;AACpD,6CAAyC;
|
|
1
|
+
{"version":3,"file":"specFilter.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specFilter.ts"],"names":[],"mappings":"AAAA,u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AO,GAAG,EAAE;QACZ,MAAM,IAAI,iCAAe,CAAE,GAAa,CAAC,QAAQ,EAAE,EAAE,sBAAS,CAAC,gBAAgB,CAAC,CAAC;KAClF;AACH,CAAC;AAtCD,gCAsCC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
2
|
-
import { ValidateResult } from "./interfaces";
|
|
2
|
+
import { GenerateResult, ValidateResult } from "./interfaces";
|
|
3
3
|
/**
|
|
4
4
|
* A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.
|
|
5
5
|
*/
|
|
@@ -38,7 +38,7 @@ export declare class SpecParser {
|
|
|
38
38
|
* @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
|
|
39
39
|
* @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
|
|
40
40
|
*/
|
|
41
|
-
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder: string, signal?: AbortSignal): Promise<
|
|
41
|
+
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
42
42
|
private loadSpec;
|
|
43
43
|
private getAllSupportedApi;
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAGxD,OAAO,EAIL,cAAc,EAIf,MAAM,cAAc,CAAC;AAUtB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,MAAM,EAAE,aAAa,CAAC;IAEtC,OAAO,CAAC,MAAM,CAA0D;IACxE,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,aAAa,CAAiC;IAEtD;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAKxB;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAGxD,OAAO,EAIL,cAAc,EACd,cAAc,EAIf,MAAM,cAAc,CAAC;AAUtB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,MAAM,EAAE,aAAa,CAAC;IAEtC,OAAO,CAAC,MAAM,CAA0D;IACxE,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,aAAa,CAAiC;IAEtD;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAKxB;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IA6FzC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAU/B;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAqBtD;;;;;;OAMG;IACG,QAAQ,CACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,CAAC;YAwEZ,QAAQ;IAQtB,OAAO,CAAC,kBAAkB;CAqB3B"}
|
|
@@ -50,7 +50,7 @@ class SpecParser {
|
|
|
50
50
|
errors,
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
//
|
|
53
|
+
// TODO: we will support swagger 2.0
|
|
54
54
|
if (!this.spec.openapi || this.spec.openapi < "3.0.0") {
|
|
55
55
|
errors.push({
|
|
56
56
|
type: interfaces_1.ErrorType.VersionNotSupported,
|
|
@@ -63,20 +63,9 @@ class SpecParser {
|
|
|
63
63
|
errors,
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
// Server
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
type: interfaces_1.ErrorType.NoServerInformation,
|
|
70
|
-
content: constants_1.ConstantString.NoServerInformation,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
else if (this.spec.servers.length > 1) {
|
|
74
|
-
errors.push({
|
|
75
|
-
type: interfaces_1.ErrorType.MultipleServerInformation,
|
|
76
|
-
content: constants_1.ConstantString.MultipleServerInformation,
|
|
77
|
-
data: this.spec.servers,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
66
|
+
// Server validation
|
|
67
|
+
const serverErrors = utils_1.validateServer(this.spec);
|
|
68
|
+
errors.push(...serverErrors);
|
|
80
69
|
// Remote reference not supported
|
|
81
70
|
const refPaths = this.parser.$refs.paths();
|
|
82
71
|
// refPaths [0] is the current spec file path
|
|
@@ -175,7 +164,10 @@ class SpecParser {
|
|
|
175
164
|
* @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
|
|
176
165
|
*/
|
|
177
166
|
async generate(manifestPath, filter, outputSpecPath, adaptiveCardFolder, signal) {
|
|
178
|
-
|
|
167
|
+
const result = {
|
|
168
|
+
allSuccess: true,
|
|
169
|
+
warnings: [],
|
|
170
|
+
};
|
|
179
171
|
try {
|
|
180
172
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
181
173
|
throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
|
|
@@ -184,7 +176,7 @@ class SpecParser {
|
|
|
184
176
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
185
177
|
throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
|
|
186
178
|
}
|
|
187
|
-
const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec);
|
|
179
|
+
const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec, this.spec);
|
|
188
180
|
let resultStr;
|
|
189
181
|
if (outputSpecPath.endsWith(".yaml") || outputSpecPath.endsWith(".yml")) {
|
|
190
182
|
resultStr = js_yaml_1.default.dump(newUnResolvedSpec);
|
|
@@ -197,17 +189,31 @@ class SpecParser {
|
|
|
197
189
|
throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
|
|
198
190
|
}
|
|
199
191
|
const newSpec = (await this.parser.dereference(newUnResolvedSpec));
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
for (const url in newSpec.paths) {
|
|
193
|
+
for (const method in newSpec.paths[url]) {
|
|
194
|
+
if (method === constants_1.ConstantString.GetMethod || method === constants_1.ConstantString.PostMethod) {
|
|
195
|
+
const operation = newSpec.paths[url][method];
|
|
196
|
+
try {
|
|
197
|
+
const card = adaptiveCardGenerator_1.generateAdaptiveCard(operation);
|
|
198
|
+
const fileName = path_1.default.join(adaptiveCardFolder, `${operation.operationId}.json`);
|
|
199
|
+
await fs_extra_1.default.outputJSON(fileName, card, { spaces: 2 });
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
result.allSuccess = false;
|
|
203
|
+
result.warnings.push({
|
|
204
|
+
type: interfaces_1.WarningType.GenerateCardFailed,
|
|
205
|
+
content: err.toString(),
|
|
206
|
+
data: operation.operationId,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
202
212
|
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
203
213
|
throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
|
|
204
214
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
const card = adaptiveCardGenerator_1.generateAdaptiveCard(getOperation);
|
|
208
|
-
const fileName = path_1.default.join(adaptiveCardFolder, `${getOperation.operationId}.json`);
|
|
209
|
-
await fs_extra_1.default.outputJSON(fileName, card, { spaces: 2 });
|
|
210
|
-
}
|
|
215
|
+
const updatedManifest = await manifestUpdater_1.updateManifest(manifestPath, outputSpecPath, adaptiveCardFolder, newSpec);
|
|
216
|
+
await fs_extra_1.default.outputJSON(manifestPath, updatedManifest, { spaces: 2 });
|
|
211
217
|
}
|
|
212
218
|
catch (err) {
|
|
213
219
|
if (err instanceof specParserError_1.SpecParserError) {
|
|
@@ -215,6 +221,7 @@ class SpecParser {
|
|
|
215
221
|
}
|
|
216
222
|
throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.GenerateFailed);
|
|
217
223
|
}
|
|
224
|
+
return result;
|
|
218
225
|
}
|
|
219
226
|
async loadSpec() {
|
|
220
227
|
if (!this.spec) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specParser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,mDAA6B;AAC7B,yFAAwD;AAExD,uDAAoD;AACpD,
|
|
1
|
+
{"version":3,"file":"specParser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,mDAA6B;AAC7B,yFAAwD;AAExD,uDAAoD;AACpD,6CASsB;AACtB,2CAA6C;AAC7C,8DAA6B;AAC7B,gEAA0B;AAC1B,6CAA0C;AAC1C,mCAAiF;AACjF,uDAAmD;AACnD,mEAA+D;AAC/D,wDAAwB;AAExB;;GAEG;AACH,MAAa,UAAU;IAQrB;;;OAGG;IACH,YAAY,IAAY;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAa,EAAE,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACH,K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zB,MAAM,MAAM,GAAiD,EAAE,CAAC;QAChE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YAC5B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;gBAC5B,uFAAuF;gBACvF,IAAI,sBAAc,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE;oBACtC,MAAM,eAAe,GAAI,OAAe,CAAC,MAAM,CAA8B,CAAC;oBAC9E,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC;iBAC7D;aACF;SACF;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA7QD,gCA6QC"}
|
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import { ErrorResult } from "./interfaces";
|
|
2
3
|
export declare function isYamlSpecFile(specPath: string): Promise<boolean>;
|
|
4
|
+
export declare function checkRequiredParameters(paramObject: OpenAPIV3.ParameterObject[], limit?: number): boolean;
|
|
5
|
+
export declare function isSupportedSchema(schema: OpenAPIV3.SchemaObject): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the given API is supported.
|
|
8
|
+
* @param {string} method - The HTTP method of the API.
|
|
9
|
+
* @param {string} path - The path of the API.
|
|
10
|
+
* @param {OpenAPIV3.Document} spec - The OpenAPI specification document.
|
|
11
|
+
* @returns {boolean} - Returns true if the API is supported, false otherwise.
|
|
12
|
+
* @description The following APIs are supported:
|
|
13
|
+
* 1. only support Get/Post operation without auth property
|
|
14
|
+
* 2. parameter inside query or path only support string, number, boolean and integer
|
|
15
|
+
* 3. parameter inside post body only support string, number, boolean, integer and object
|
|
16
|
+
* 4. request body + required parameters <= 1
|
|
17
|
+
* 5. response body should be “application/json” and not empty, and response code should be 20X
|
|
18
|
+
* 6. only support request body with “application/json” content type
|
|
19
|
+
*/
|
|
3
20
|
export declare function isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document): boolean;
|
|
4
21
|
export declare function updateFirstLetter(str: string): string;
|
|
5
22
|
export declare function getRelativePath(from: string, to: string): string;
|
|
6
23
|
export declare function getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): OpenAPIV3.MediaTypeObject;
|
|
7
24
|
export declare function convertPathToCamelCase(path: string): string;
|
|
25
|
+
export declare function getUrlProtocol(urlString: string): string | undefined;
|
|
26
|
+
export declare function checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
|
|
27
|
+
export declare function validateServer(spec: OpenAPIV3.Document): ErrorResult[];
|
|
8
28
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBvE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,WAAW,EAAa,MAAM,cAAc,CAAC;AAEtD,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiBvE;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,SAAS,CAAC,eAAe,EAAE,EACxC,KAAK,SAAI,GACR,OAAO,CAgCT;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,YAAY,GAAG,OAAO,CA2BzE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,OAAO,CAsC9F;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED,wBAAgB,eAAe,CAC7B,eAAe,EAAE,SAAS,CAAC,eAAe,GAAG,SAAS,GACrD,SAAS,CAAC,eAAe,CAY3B;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAU3D;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAOpE;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,SAAS,CAAC,YAAY,EAAE,GAAG,WAAW,EAAE,CAoB/E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,QAAQ,GAAG,WAAW,EAAE,CA2CtE"}
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
"use strict";
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.convertPathToCamelCase = exports.getResponseJson = exports.getRelativePath = exports.updateFirstLetter = exports.isSupportedApi = exports.isYamlSpecFile = void 0;
|
|
5
|
+
exports.validateServer = exports.checkServerUrl = exports.getUrlProtocol = exports.convertPathToCamelCase = exports.getResponseJson = exports.getRelativePath = exports.updateFirstLetter = exports.isSupportedApi = exports.isSupportedSchema = exports.checkRequiredParameters = exports.isYamlSpecFile = void 0;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
8
8
|
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
9
9
|
const constants_1 = require("./constants");
|
|
10
10
|
const path_1 = tslib_1.__importDefault(require("path"));
|
|
11
|
+
const util = tslib_1.__importStar(require("util"));
|
|
12
|
+
const interfaces_1 = require("./interfaces");
|
|
11
13
|
async function isYamlSpecFile(specPath) {
|
|
12
14
|
if (specPath.endsWith(".yaml") || specPath.endsWith(".yml")) {
|
|
13
15
|
return true;
|
|
@@ -28,30 +30,104 @@ async function isYamlSpecFile(specPath) {
|
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
exports.isYamlSpecFile = isYamlSpecFile;
|
|
33
|
+
function checkRequiredParameters(paramObject, limit = 1) {
|
|
34
|
+
if (limit === 0 && !paramObject) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
let requiredParamCount = 0;
|
|
38
|
+
for (let i = 0; i < paramObject.length; i++) {
|
|
39
|
+
const param = paramObject[i];
|
|
40
|
+
if (param.in === "header" || param.in === "cookie") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const schema = param.schema;
|
|
44
|
+
if (schema.type !== "boolean" &&
|
|
45
|
+
schema.type !== "string" &&
|
|
46
|
+
schema.type !== "number" &&
|
|
47
|
+
schema.type !== "integer") {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (param.required && (param.in === "query" || param.in === "path")) {
|
|
51
|
+
requiredParamCount++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (requiredParamCount <= limit) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
exports.checkRequiredParameters = checkRequiredParameters;
|
|
60
|
+
function isSupportedSchema(schema) {
|
|
61
|
+
// we support schema: {}
|
|
62
|
+
if (Object.keys(schema).length === 0) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (schema.type === "string" ||
|
|
66
|
+
schema.type === "integer" ||
|
|
67
|
+
schema.type === "boolean" ||
|
|
68
|
+
schema.type === "number") {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
else if (schema.type === "array") {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
else if (schema.type === "object") {
|
|
75
|
+
const { properties } = schema;
|
|
76
|
+
for (const property in properties) {
|
|
77
|
+
const result = isSupportedSchema(properties[property]);
|
|
78
|
+
if (!result) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.isSupportedSchema = isSupportedSchema;
|
|
89
|
+
/**
|
|
90
|
+
* Checks if the given API is supported.
|
|
91
|
+
* @param {string} method - The HTTP method of the API.
|
|
92
|
+
* @param {string} path - The path of the API.
|
|
93
|
+
* @param {OpenAPIV3.Document} spec - The OpenAPI specification document.
|
|
94
|
+
* @returns {boolean} - Returns true if the API is supported, false otherwise.
|
|
95
|
+
* @description The following APIs are supported:
|
|
96
|
+
* 1. only support Get/Post operation without auth property
|
|
97
|
+
* 2. parameter inside query or path only support string, number, boolean and integer
|
|
98
|
+
* 3. parameter inside post body only support string, number, boolean, integer and object
|
|
99
|
+
* 4. request body + required parameters <= 1
|
|
100
|
+
* 5. response body should be “application/json” and not empty, and response code should be 20X
|
|
101
|
+
* 6. only support request body with “application/json” content type
|
|
102
|
+
*/
|
|
31
103
|
function isSupportedApi(method, path, spec) {
|
|
32
104
|
var _a;
|
|
33
105
|
const pathObj = spec.paths[path];
|
|
34
106
|
method = method.toLocaleLowerCase();
|
|
35
107
|
if (pathObj) {
|
|
36
|
-
if (method === constants_1.ConstantString.
|
|
108
|
+
if ((method === constants_1.ConstantString.PostMethod || method === constants_1.ConstantString.GetMethod) &&
|
|
109
|
+
pathObj[method] &&
|
|
110
|
+
!((_a = pathObj[method]) === null || _a === void 0 ? void 0 : _a.security)) {
|
|
37
111
|
const operationObject = pathObj[method];
|
|
38
112
|
const paramObject = operationObject.parameters;
|
|
39
|
-
|
|
113
|
+
const requestBody = operationObject.requestBody;
|
|
114
|
+
const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
|
|
115
|
+
const parameterLimit = requestJsonBody ? 0 : 1;
|
|
116
|
+
const responseJson = getResponseJson(operationObject);
|
|
117
|
+
if (Object.keys(responseJson).length === 0) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
if ((!paramObject || paramObject.length === 0) && !requestBody) {
|
|
40
121
|
return true;
|
|
41
122
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
schema.type === "integer" ||
|
|
49
|
-
schema.type === "number" ||
|
|
50
|
-
schema.type === "string") {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
123
|
+
const valid = checkRequiredParameters(paramObject, parameterLimit);
|
|
124
|
+
if (valid) {
|
|
125
|
+
if (requestBody) {
|
|
126
|
+
const schema = requestJsonBody.schema;
|
|
127
|
+
const requestJsonBodySupported = isSupportedSchema(schema);
|
|
128
|
+
return requestJsonBodySupported;
|
|
54
129
|
}
|
|
130
|
+
return true;
|
|
55
131
|
}
|
|
56
132
|
}
|
|
57
133
|
}
|
|
@@ -68,10 +144,14 @@ function getRelativePath(from, to) {
|
|
|
68
144
|
}
|
|
69
145
|
exports.getRelativePath = getRelativePath;
|
|
70
146
|
function getResponseJson(operationObject) {
|
|
71
|
-
var _a, _b
|
|
72
|
-
let json =
|
|
73
|
-
|
|
74
|
-
|
|
147
|
+
var _a, _b;
|
|
148
|
+
let json = {};
|
|
149
|
+
for (const code of constants_1.ConstantString.ResponseCodeFor20X) {
|
|
150
|
+
const responseObject = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a[code];
|
|
151
|
+
if ((_b = responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) === null || _b === void 0 ? void 0 : _b["application/json"]) {
|
|
152
|
+
json = responseObject.content["application/json"];
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
75
155
|
}
|
|
76
156
|
return json;
|
|
77
157
|
}
|
|
@@ -88,4 +168,75 @@ function convertPathToCamelCase(path) {
|
|
|
88
168
|
return camelCasePath;
|
|
89
169
|
}
|
|
90
170
|
exports.convertPathToCamelCase = convertPathToCamelCase;
|
|
171
|
+
function getUrlProtocol(urlString) {
|
|
172
|
+
try {
|
|
173
|
+
const url = new URL(urlString);
|
|
174
|
+
return url.protocol;
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.getUrlProtocol = getUrlProtocol;
|
|
181
|
+
function checkServerUrl(servers) {
|
|
182
|
+
const errors = [];
|
|
183
|
+
const protocol = getUrlProtocol(servers[0].url);
|
|
184
|
+
if (!protocol) {
|
|
185
|
+
// Relative server url is not supported
|
|
186
|
+
errors.push({
|
|
187
|
+
type: interfaces_1.ErrorType.RelativeServerUrlNotSupported,
|
|
188
|
+
content: constants_1.ConstantString.RelativeServerUrlNotSupported,
|
|
189
|
+
data: servers,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
else if (protocol !== "https:") {
|
|
193
|
+
// Http server url is not supported
|
|
194
|
+
errors.push({
|
|
195
|
+
type: interfaces_1.ErrorType.UrlProtocolNotSupported,
|
|
196
|
+
content: util.format(constants_1.ConstantString.UrlProtocolNotSupported, protocol),
|
|
197
|
+
data: servers,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return errors;
|
|
201
|
+
}
|
|
202
|
+
exports.checkServerUrl = checkServerUrl;
|
|
203
|
+
function validateServer(spec) {
|
|
204
|
+
const errors = [];
|
|
205
|
+
let hasTopLevelServers = false;
|
|
206
|
+
let hasPathLevelServers = false;
|
|
207
|
+
let hasOperationLevelServers = false;
|
|
208
|
+
if (spec.servers && spec.servers.length >= 1) {
|
|
209
|
+
hasTopLevelServers = true;
|
|
210
|
+
// for multiple server, we only use the first url
|
|
211
|
+
const serverErrors = checkServerUrl(spec.servers);
|
|
212
|
+
errors.push(...serverErrors);
|
|
213
|
+
}
|
|
214
|
+
const paths = spec.paths;
|
|
215
|
+
for (const path in paths) {
|
|
216
|
+
const methods = paths[path];
|
|
217
|
+
if ((methods === null || methods === void 0 ? void 0 : methods.servers) && methods.servers.length >= 1) {
|
|
218
|
+
hasPathLevelServers = true;
|
|
219
|
+
const serverErrors = checkServerUrl(methods.servers);
|
|
220
|
+
errors.push(...serverErrors);
|
|
221
|
+
}
|
|
222
|
+
for (const method in methods) {
|
|
223
|
+
const operationObject = methods[method];
|
|
224
|
+
if (isSupportedApi(method, path, spec)) {
|
|
225
|
+
if ((operationObject === null || operationObject === void 0 ? void 0 : operationObject.servers) && operationObject.servers.length >= 1) {
|
|
226
|
+
hasOperationLevelServers = true;
|
|
227
|
+
const serverErrors = checkServerUrl(operationObject.servers);
|
|
228
|
+
errors.push(...serverErrors);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (!hasTopLevelServers && !hasPathLevelServers && !hasOperationLevelServers) {
|
|
234
|
+
errors.push({
|
|
235
|
+
type: interfaces_1.ErrorType.NoServerInformation,
|
|
236
|
+
content: constants_1.ConstantString.NoServerInformation,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return errors;
|
|
240
|
+
}
|
|
241
|
+
exports.validateServer = validateServer;
|
|
91
242
|
//# sourceMappingURL=utils.js.map
|