ts-openapi-codegen 2.1.0-beta.1 → 2.1.0-beta.10
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/README.md +27 -934
- package/README.rus.md +27 -934
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.js +40 -24
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.js +47 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.js +17 -7
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.js +17 -7
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts +14 -2
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/analyzeDiff.js +58 -15
- package/dist/cli/analyzeDiff/ciSummary.d.ts +6 -3
- package/dist/cli/analyzeDiff/ciSummary.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/ciSummary.js +10 -6
- package/dist/cli/analyzeDiff/ignoreRules.d.ts +0 -22
- package/dist/cli/analyzeDiff/ignoreRules.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/ignoreRules.js +3 -25
- package/dist/cli/analyzeDiff/miracles.d.ts +0 -54
- package/dist/cli/analyzeDiff/miracles.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/miracles.js +1 -219
- package/dist/cli/analyzeDiff/specParser.d.ts +0 -13
- package/dist/cli/analyzeDiff/specParser.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/specParser.js +2 -23
- package/dist/cli/analyzeDiff/types.d.ts +0 -42
- package/dist/cli/analyzeDiff/types.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/analyzeUsage.d.ts +4 -0
- package/dist/cli/analyzeUsage/analyzeUsage.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/analyzeUsage.js +60 -0
- package/dist/cli/analyzeUsage/core/Analyzer.d.ts +9 -0
- package/dist/cli/analyzeUsage/core/Analyzer.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/core/Analyzer.js +29 -0
- package/dist/cli/analyzeUsage/core/ProjectContext.d.ts +10 -0
- package/dist/cli/analyzeUsage/core/ProjectContext.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/core/ProjectContext.js +58 -0
- package/dist/cli/analyzeUsage/core/Scanner.d.ts +23 -0
- package/dist/cli/analyzeUsage/core/Scanner.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/core/Scanner.js +125 -0
- package/dist/cli/analyzeUsage/rules/ClientRule.d.ts +14 -0
- package/dist/cli/analyzeUsage/rules/ClientRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ClientRule.js +86 -0
- package/dist/cli/analyzeUsage/rules/CoverageRule.d.ts +7 -0
- package/dist/cli/analyzeUsage/rules/CoverageRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/CoverageRule.js +55 -0
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.js +63 -0
- package/dist/cli/analyzeUsage/rules/ImportRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/ImportRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ImportRule.js +50 -0
- package/dist/cli/analyzeUsage/rules/ModelRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/ModelRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ModelRule.js +34 -0
- package/dist/cli/analyzeUsage/rules/SchemaRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/SchemaRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/SchemaRule.js +46 -0
- package/dist/cli/analyzeUsage/rules/ServiceRule.d.ts +15 -0
- package/dist/cli/analyzeUsage/rules/ServiceRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ServiceRule.js +96 -0
- package/dist/cli/analyzeUsage/types.d.ts +52 -0
- package/dist/cli/analyzeUsage/types.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/types.js +2 -0
- package/dist/cli/analyzeUsage/utils/fuzzy.d.ts +5 -0
- package/dist/cli/analyzeUsage/utils/fuzzy.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/utils/fuzzy.js +38 -0
- package/dist/cli/analyzeUsage/utils/report.d.ts +16 -0
- package/dist/cli/analyzeUsage/utils/report.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/utils/report.js +85 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.js +53 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.js +52 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +2 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +15 -6
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +2 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +8 -5
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.js +20 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.js +35 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.js +59 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +19 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateExecutorSetup.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateExecutorSetup.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateExecutorSetup.js +55 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.js +1 -1
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.js +18 -9
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts +2 -5
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +24 -20
- package/dist/cli/index.js +45 -9
- package/dist/cli/initOpenApiConfig/Types.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/Types.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/__tests__/init.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/__tests__/init.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/__tests__/init.test.js +20 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.js +49 -0
- package/dist/cli/initOpenApiConfig/init.d.ts +2 -1
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.js +52 -20
- package/dist/cli/initOpenApiConfig/initConfig.d.ts +5 -0
- package/dist/cli/initOpenApiConfig/initConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initConfig.js +8 -4
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts +3 -2
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.js +36 -10
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.js +93 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.js +45 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.js +61 -0
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts +6 -12
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/buildConfig.js +24 -19
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.js +2 -0
- package/dist/cli/interactive/constants.d.ts +0 -4
- package/dist/cli/interactive/constants.d.ts.map +1 -1
- package/dist/cli/interactive/constants.js +1 -5
- package/dist/cli/previewChanges/previewChanges.d.ts +2 -1
- package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
- package/dist/cli/previewChanges/previewChanges.js +8 -8
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.js +52 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.js +43 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.js +32 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.js +68 -0
- package/dist/cli/previewChanges/utils/formatDiff.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.js +5 -12
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.js +36 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.js +59 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.js +43 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.js +31 -0
- package/dist/cli/schemas/analyzeUsage.d.ts +13 -0
- package/dist/cli/schemas/analyzeUsage.d.ts.map +1 -0
- package/dist/cli/schemas/analyzeUsage.js +41 -0
- package/dist/cli/schemas/generate.d.ts +10 -2
- package/dist/cli/schemas/generate.d.ts.map +1 -1
- package/dist/cli/schemas/generate.js +7 -2
- package/dist/cli/schemas/index.d.ts +2 -2
- package/dist/cli/schemas/index.d.ts.map +1 -1
- package/dist/cli/schemas/index.js +1 -1
- package/dist/cli/schemas/init.d.ts +10 -0
- package/dist/cli/schemas/init.d.ts.map +1 -1
- package/dist/cli/schemas/init.js +3 -1
- package/dist/cli/types.d.ts +6 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/common/Consts.d.ts +1 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +7 -3
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +3 -3
- package/dist/common/LoggerMessages.d.ts +71 -12
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +76 -18
- package/dist/common/TEslintFixOptions.d.ts +20 -0
- package/dist/common/TEslintFixOptions.d.ts.map +1 -0
- package/dist/common/TEslintFixOptions.js +15 -0
- package/dist/common/TRawOptions.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +2 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.js +1 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.js +15 -5
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +18 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +7 -1
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +4 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +2 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +2 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.js +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +7 -1
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +4 -16
- package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.js +1 -1
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.js +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +4 -6
- package/dist/common/VersionedSchema/Utils/getLatestVersionFromMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +6 -8
- package/dist/common/VersionedSchema/Utils/replaceInvalidKeysWithMappedNames.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/replaceInvalidKeysWithMappedNames.js +1 -1
- package/dist/common/VersionedSchema/Utils/validateAndSuggestKeyCorrections.d.ts.map +1 -1
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts +1 -1
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts.map +1 -1
- package/dist/common/utils/__tests__/eslintFix.test.js +25 -67
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.d.ts +2 -0
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.js +28 -0
- package/dist/common/utils/__tests__/format.test.js +26 -17
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.d.ts +2 -0
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.js +78 -0
- package/dist/common/utils/codegenTempDir.d.ts +20 -0
- package/dist/common/utils/codegenTempDir.d.ts.map +1 -0
- package/dist/common/utils/codegenTempDir.js +42 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +3 -8
- package/dist/common/utils/eslintFix.d.ts +48 -4
- package/dist/common/utils/eslintFix.d.ts.map +1 -1
- package/dist/common/utils/eslintFix.js +121 -15
- package/dist/common/utils/format.d.ts +1 -1
- package/dist/common/utils/format.d.ts.map +1 -1
- package/dist/common/utils/format.js +23 -11
- package/dist/common/utils/jsonPath.d.ts.map +1 -1
- package/dist/common/utils/prepareTempEslintConfig.d.ts +18 -0
- package/dist/common/utils/prepareTempEslintConfig.d.ts.map +1 -0
- package/dist/common/utils/prepareTempEslintConfig.js +55 -0
- package/dist/common/utils/prepareTempTsConfig.d.ts +23 -0
- package/dist/common/utils/prepareTempTsConfig.d.ts.map +1 -0
- package/dist/common/utils/prepareTempTsConfig.js +105 -0
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +2 -6
- package/dist/core/OpenApiClient.d.ts +27 -1
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +259 -19
- package/dist/core/WriteClient.d.ts +84 -17
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +96 -22
- package/dist/core/__tests__/WriteClient.test.js +2 -1
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +1 -3
- package/dist/core/api/v2/parser/getServiceName.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameters.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +1 -3
- package/dist/core/api/v3/parser/getServiceName.d.ts +1 -1
- package/dist/core/governance/evaluateGovernanceRules.d.ts.map +1 -1
- package/dist/core/governance/evaluateGovernanceRules.js +1 -3
- package/dist/core/governance/loadGovernanceConfig.d.ts.map +1 -1
- package/dist/core/governance/loadGovernanceConfig.js +2 -4
- package/dist/core/plugins/GeneratorPlugin.model.d.ts.map +1 -1
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts.map +1 -1
- package/dist/core/plugins/getBuiltinPlugins.d.ts.map +1 -1
- package/dist/core/plugins/loadGeneratorPlugins.d.ts.map +1 -1
- package/dist/core/plugins/loadGeneratorPlugins.js +1 -1
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.js +79 -21
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.js +20 -1
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts +58 -6
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts.map +1 -1
- package/dist/core/semanticDiff/analyzeOpenApiDiff.js +47 -19
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts +8 -3
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts.map +1 -1
- package/dist/core/semanticDiff/semanticDiffReportSchema.js +139 -56
- package/dist/core/strict/validateOpenApiStrict.d.ts.map +1 -1
- package/dist/core/types/Consts.js +1 -1
- package/dist/core/types/DiffReport.model.d.ts +101 -0
- package/dist/core/types/DiffReport.model.d.ts.map +1 -0
- package/dist/core/types/DiffReport.model.js +5 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts +3 -3
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/ExportedModel.model.d.ts +1 -1
- package/dist/core/types/base/ExportedModel.model.d.ts.map +1 -1
- package/dist/core/types/base/ExportedService.model.d.ts.map +1 -1
- package/dist/core/types/base/OutputPaths.model.d.ts.map +1 -1
- package/dist/core/types/base/PrefixArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/PropertyGroup.model.d.ts +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/Templates.model.d.ts +1 -0
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/types/shared/Client.model.d.ts +1 -1
- package/dist/core/types/shared/Client.model.d.ts.map +1 -1
- package/dist/core/types/shared/Model.model.d.ts +37 -1
- package/dist/core/types/shared/Model.model.d.ts.map +1 -1
- package/dist/core/utils/GenerationCache.d.ts +18 -0
- package/dist/core/utils/GenerationCache.d.ts.map +1 -0
- package/dist/core/utils/GenerationCache.js +41 -0
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.js +1 -0
- package/dist/core/utils/__tests__/GenerationCache.test.d.ts +2 -0
- package/dist/core/utils/__tests__/GenerationCache.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/GenerationCache.test.js +37 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.js +182 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.d.ts +2 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.js +77 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.d.ts +2 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.js +159 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.d.ts +2 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.js +246 -0
- package/dist/core/utils/__tests__/modelHelpers.test.js +27 -9
- package/dist/core/utils/__tests__/postProcessModelImports.test.js +1 -4
- package/dist/core/utils/__tests__/postProcessServiceImports.test.js +1 -4
- package/dist/core/utils/__tests__/prepareDtoModels.test.js +168 -1
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +27 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.js +111 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.d.ts +2 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.js +68 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +10 -11
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +10 -27
- package/dist/core/utils/__tests__/templateRendering.test.d.ts +2 -0
- package/dist/core/utils/__tests__/templateRendering.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/templateRendering.test.js +190 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.js +30 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.d.ts +2 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.d.ts.map +1 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.js +63 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.d.ts +10 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.d.ts.map +1 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.js +13 -0
- package/dist/core/utils/adapters/index.d.ts +3 -0
- package/dist/core/utils/adapters/index.d.ts.map +1 -0
- package/dist/core/utils/adapters/index.js +6 -0
- package/dist/core/utils/adapters/semanticToStructural.d.ts +12 -0
- package/dist/core/utils/adapters/semanticToStructural.d.ts.map +1 -0
- package/dist/core/utils/adapters/semanticToStructural.js +36 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts +13 -1
- package/dist/core/utils/applyDiffReportToClient.d.ts.map +1 -1
- package/dist/core/utils/applyDiffReportToClient.js +189 -109
- package/dist/core/utils/areEqual.d.ts +1 -1
- package/dist/core/utils/buildMiraclesFromSemanticChanges.d.ts +25 -0
- package/dist/core/utils/buildMiraclesFromSemanticChanges.d.ts.map +1 -0
- package/dist/core/utils/buildMiraclesFromSemanticChanges.js +146 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.d.ts +23 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.d.ts.map +1 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.js +163 -0
- package/dist/core/utils/getOpenApiSpec.d.ts +6 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +6 -0
- package/dist/core/utils/getOperationErrors.d.ts +2 -2
- package/dist/core/utils/getOperationErrors.d.ts.map +1 -1
- package/dist/core/utils/getOperationResults.d.ts +1 -1
- package/dist/core/utils/getPropertyGroupSimple.d.ts.map +1 -1
- package/dist/core/utils/getPropertyGroupSimple.js +1 -3
- package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
- package/dist/core/utils/loadDiffReport.d.ts +11 -30
- package/dist/core/utils/loadDiffReport.d.ts.map +1 -1
- package/dist/core/utils/loadDiffReport.js +75 -9
- package/dist/core/utils/loadSemanticOpenApiSpec.d.ts +15 -0
- package/dist/core/utils/loadSemanticOpenApiSpec.d.ts.map +1 -0
- package/dist/core/utils/loadSemanticOpenApiSpec.js +61 -0
- package/dist/core/utils/modelHelpers.d.ts +13 -5
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +28 -23
- package/dist/core/utils/normalizeString.d.ts.map +1 -1
- package/dist/core/utils/normalizeString.js +1 -5
- package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessServiceImports.js +1 -3
- package/dist/core/utils/precompileTemplates.js +4 -2
- package/dist/core/utils/prepareAlias.d.ts +1 -1
- package/dist/core/utils/prepareDtoModels.d.ts +5 -0
- package/dist/core/utils/prepareDtoModels.d.ts.map +1 -1
- package/dist/core/utils/prepareDtoModels.js +57 -20
- package/dist/core/utils/registerHandlebarHelpers.d.ts +1 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +3 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts +1 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +2 -0
- package/dist/core/utils/resolveClassesModeTypes.d.ts +8 -0
- package/dist/core/utils/resolveClassesModeTypes.d.ts.map +1 -0
- package/dist/core/utils/resolveClassesModeTypes.js +77 -0
- package/dist/core/utils/semanticChangesToDiffEntries.d.ts +28 -0
- package/dist/core/utils/semanticChangesToDiffEntries.d.ts.map +1 -0
- package/dist/core/utils/semanticChangesToDiffEntries.js +98 -0
- package/dist/core/utils/semanticPointerToJsonPath.d.ts +7 -0
- package/dist/core/utils/semanticPointerToJsonPath.d.ts.map +1 -0
- package/dist/core/utils/semanticPointerToJsonPath.js +67 -0
- package/dist/core/utils/serviceHelpers.d.ts +6 -7
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
- package/dist/core/utils/serviceHelpers.js +8 -25
- package/dist/core/utils/sortModelByName.d.ts +1 -1
- package/dist/core/utils/validateRawOptions.js +2 -2
- package/dist/core/utils/writeClientCore.d.ts +2 -0
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +43 -21
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +14 -4
- package/dist/core/utils/writeClientExecutor.d.ts +1 -3
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +6 -11
- package/dist/core/utils/writeClientFullIndex.js +4 -4
- package/dist/core/utils/writeClientModels.d.ts +1 -2
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +14 -16
- package/dist/core/utils/writeClientModelsIndex.d.ts +1 -1
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.js +14 -4
- package/dist/core/utils/writeClientSchemas.d.ts +1 -3
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +9 -14
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemasIndex.js +14 -4
- package/dist/core/utils/writeClientServices.d.ts +15 -16
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +12 -19
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientServicesIndex.js +14 -4
- package/dist/core/utils/writeClientSimpleIndex.js +4 -4
- package/dist/core/utils/writeFileIfChanged.d.ts +3 -0
- package/dist/core/utils/writeFileIfChanged.d.ts.map +1 -0
- package/dist/core/utils/writeFileIfChanged.js +22 -0
- package/dist/templatesCompiled/cli/customCreateExecutorAdapter.d.ts +8 -0
- package/dist/templatesCompiled/cli/customCreateExecutorAdapter.d.ts.map +1 -0
- package/dist/templatesCompiled/cli/customCreateExecutorAdapter.js +18 -0
- package/dist/templatesCompiled/cli/customRequest.js +7 -7
- package/dist/templatesCompiled/cli/customRequestExecutor.js +7 -7
- package/dist/templatesCompiled/client/core/ApiError.js +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts +0 -6
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +3 -22
- package/dist/templatesCompiled/client/core/executor/legacyRequestAdapter.d.ts +11 -0
- package/dist/templatesCompiled/client/core/executor/legacyRequestAdapter.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/executor/legacyRequestAdapter.js +28 -0
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts +2 -0
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +8 -2
- package/dist/templatesCompiled/client/core/functions/catchErrors.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/interceptors.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +1 -1
- package/dist/templatesCompiled/client/exportClient.d.ts +0 -4
- package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportClient.js +9 -45
- package/dist/templatesCompiled/client/exportModels.d.ts +17 -11
- package/dist/templatesCompiled/client/exportModels.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportModels.js +96 -49
- package/dist/templatesCompiled/client/exportService.d.ts +13 -10
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +95 -67
- package/dist/templatesCompiled/client/indexCore.js +4 -4
- package/dist/templatesCompiled/client/indexFull.js +8 -8
- package/dist/templatesCompiled/client/indexSimple.js +2 -2
- package/dist/templatesCompiled/client/partials/header.d.ts +1 -0
- package/dist/templatesCompiled/client/partials/header.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/header.js +11 -2
- package/dist/test/helpers/silenceLoggers.d.ts +11 -0
- package/dist/test/helpers/silenceLoggers.d.ts.map +1 -0
- package/dist/test/helpers/silenceLoggers.js +88 -0
- package/package.json +132 -136
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts +0 -17
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/buildLegacyReport.js +0 -54
- package/dist/cli/analyzeDiff/diffEngine.d.ts +0 -54
- package/dist/cli/analyzeDiff/diffEngine.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/diffEngine.js +0 -209
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts +0 -6
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/logLegacyReport.js +0 -29
- package/dist/cli/analyzeDiff/report.d.ts +0 -3
- package/dist/cli/analyzeDiff/report.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/report.js +0 -7
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts +0 -6
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/writeLegacyReport.js +0 -21
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts +0 -4
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts.map +0 -1
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.js +0 -21
- package/dist/common/utils/normalizeObject.d.ts +0 -2
- package/dist/common/utils/normalizeObject.d.ts.map +0 -1
- package/dist/common/utils/normalizeObject.js +0 -63
- package/dist/core/utils/appendUniqueLinesToFile.d.ts +0 -2
- package/dist/core/utils/appendUniqueLinesToFile.d.ts.map +0 -1
- package/dist/core/utils/appendUniqueLinesToFile.js +0 -24
|
@@ -9,6 +9,7 @@ const getComment_1 = require("./getComment");
|
|
|
9
9
|
const getModelNameWithPrefix_1 = require("./getModelNameWithPrefix");
|
|
10
10
|
const getOpenApiVersion_1 = require("./getOpenApiVersion");
|
|
11
11
|
const getOperationName_1 = require("./getOperationName");
|
|
12
|
+
const getOperationParameterName_1 = require("./getOperationParameterName");
|
|
12
13
|
const getOperationPath_1 = require("./getOperationPath");
|
|
13
14
|
const getServiceClassName_1 = require("./getServiceClassName");
|
|
14
15
|
const serviceHelpers_1 = require("./serviceHelpers");
|
|
@@ -21,21 +22,37 @@ const getSchemaDefinitions = (openApi, version) => {
|
|
|
21
22
|
const definitions = openApi?.definitions;
|
|
22
23
|
return definitions ?? {};
|
|
23
24
|
};
|
|
24
|
-
const
|
|
25
|
+
const buildLocalSchemaRef = (schemaName, version) => (version === getOpenApiVersion_1.OpenApiVersion.V3 ? `#/components/schemas/${schemaName}` : `#/definitions/${schemaName}`);
|
|
26
|
+
const resolveSchemaDefinition = (schemaName, schemaDef, version, context) => {
|
|
27
|
+
if (context) {
|
|
28
|
+
try {
|
|
29
|
+
const resolved = context.get(buildLocalSchemaRef(schemaName, version));
|
|
30
|
+
if (resolved && typeof resolved === 'object') {
|
|
31
|
+
return resolved;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// fallback to raw schemaDef
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return schemaDef;
|
|
39
|
+
};
|
|
40
|
+
const buildSchemaNameMap = (openApi, version, prefix, context) => {
|
|
25
41
|
const definitions = getSchemaDefinitions(openApi, version);
|
|
26
42
|
const map = new Map();
|
|
27
43
|
Object.entries(definitions).forEach(([schemaName, schemaDef]) => {
|
|
44
|
+
const resolvedDef = resolveSchemaDefinition(schemaName, schemaDef, version, context);
|
|
28
45
|
const encodedName = (0, encode_1.encode)(schemaName);
|
|
29
|
-
const modelName = (0, getModelNameWithPrefix_1.getModelNameWithPrefix)(encodedName,
|
|
46
|
+
const modelName = (0, getModelNameWithPrefix_1.getModelNameWithPrefix)(encodedName, resolvedDef, prefix);
|
|
30
47
|
map.set(schemaName, modelName);
|
|
31
48
|
});
|
|
32
49
|
return map;
|
|
33
50
|
};
|
|
34
51
|
const getSchemaNameFromSegments = (segments, version) => {
|
|
35
52
|
if (version === getOpenApiVersion_1.OpenApiVersion.V3) {
|
|
36
|
-
return segments[0] === 'components' && segments[1] === 'schemas' ? segments[2] ?? null : null;
|
|
53
|
+
return segments[0] === 'components' && segments[1] === 'schemas' ? (segments[2] ?? null) : null;
|
|
37
54
|
}
|
|
38
|
-
return segments[0] === 'definitions' ? segments[1] ?? null : null;
|
|
55
|
+
return segments[0] === 'definitions' ? (segments[1] ?? null) : null;
|
|
39
56
|
};
|
|
40
57
|
const describeSchemaType = (value) => {
|
|
41
58
|
if (typeof value === 'string') {
|
|
@@ -96,7 +113,43 @@ const mergeOperationDiff = (existing, entry) => {
|
|
|
96
113
|
severity,
|
|
97
114
|
};
|
|
98
115
|
};
|
|
99
|
-
const
|
|
116
|
+
const normalizeOperationPathForKey = (path) => path.replace(/\$\{([^}]+)\}/g, '{$1}').replace(/\{([^}]+)\}/g, (substring, name) => (substring === '{api-version}' ? substring : `{${name}}`));
|
|
117
|
+
const buildOperationKey = (method, path) => `${method.toUpperCase()} ${normalizeOperationPathForKey(path)}`;
|
|
118
|
+
const createGhostPathParameters = (path) => {
|
|
119
|
+
const parameters = [];
|
|
120
|
+
const pattern = /\{([^}]+)\}/g;
|
|
121
|
+
let match;
|
|
122
|
+
while ((match = pattern.exec(path)) !== null) {
|
|
123
|
+
const prop = match[1];
|
|
124
|
+
if (prop === 'api-version') {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const name = (0, getOperationParameterName_1.getOperationParameterName)(prop);
|
|
128
|
+
parameters.push({
|
|
129
|
+
in: 'path',
|
|
130
|
+
prop,
|
|
131
|
+
name,
|
|
132
|
+
alias: '',
|
|
133
|
+
path: '',
|
|
134
|
+
export: 'generic',
|
|
135
|
+
type: 'string',
|
|
136
|
+
base: 'string',
|
|
137
|
+
template: null,
|
|
138
|
+
link: null,
|
|
139
|
+
description: null,
|
|
140
|
+
isDefinition: false,
|
|
141
|
+
isReadOnly: false,
|
|
142
|
+
isRequired: true,
|
|
143
|
+
isNullable: false,
|
|
144
|
+
imports: [],
|
|
145
|
+
enum: [],
|
|
146
|
+
enums: [],
|
|
147
|
+
properties: [],
|
|
148
|
+
mediaType: null,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
return parameters;
|
|
152
|
+
};
|
|
100
153
|
const findOperationMatches = (entries) => {
|
|
101
154
|
const operationDiffs = new Map();
|
|
102
155
|
const removedOperations = [];
|
|
@@ -128,6 +181,7 @@ const createGhostOperation = (match, serviceName) => {
|
|
|
128
181
|
const description = typeof from.description === 'string' ? from.description : '';
|
|
129
182
|
const operationNameFallback = `${match.method}${serviceName}`;
|
|
130
183
|
const operationName = (0, getOperationName_1.getOperationName)(operationId || operationNameFallback);
|
|
184
|
+
const pathParameters = createGhostPathParameters(match.path);
|
|
131
185
|
return {
|
|
132
186
|
service: serviceName,
|
|
133
187
|
name: operationName,
|
|
@@ -136,8 +190,8 @@ const createGhostOperation = (match, serviceName) => {
|
|
|
136
190
|
deprecated: true,
|
|
137
191
|
method: match.method.toUpperCase(),
|
|
138
192
|
path: (0, getOperationPath_1.getOperationPath)(match.path),
|
|
139
|
-
parameters:
|
|
140
|
-
parametersPath:
|
|
193
|
+
parameters: pathParameters,
|
|
194
|
+
parametersPath: pathParameters,
|
|
141
195
|
parametersQuery: [],
|
|
142
196
|
parametersForm: [],
|
|
143
197
|
parametersHeader: [],
|
|
@@ -196,20 +250,32 @@ const applyOperationDiffs = (client, entries) => {
|
|
|
196
250
|
}
|
|
197
251
|
client.services = Array.from(servicesMap.values());
|
|
198
252
|
};
|
|
199
|
-
const
|
|
200
|
-
const
|
|
201
|
-
|
|
253
|
+
const buildModelsByName = (models) => {
|
|
254
|
+
const modelsByName = new Map();
|
|
255
|
+
models.forEach(model => {
|
|
256
|
+
const list = modelsByName.get(model.name) ?? [];
|
|
257
|
+
list.push(model);
|
|
258
|
+
modelsByName.set(model.name, list);
|
|
259
|
+
});
|
|
260
|
+
return modelsByName;
|
|
261
|
+
};
|
|
262
|
+
const getModelsForSchema = (schemaName, schemaNameMap, modelsByName) => {
|
|
263
|
+
const modelName = schemaNameMap.get(schemaName);
|
|
264
|
+
if (!modelName)
|
|
265
|
+
return [];
|
|
266
|
+
return modelsByName.get(modelName) ?? [];
|
|
267
|
+
};
|
|
268
|
+
const applyModelDiffs = (client, entries, openApi, openApiVersion, prefix, context) => {
|
|
269
|
+
const schemaNameMap = buildSchemaNameMap(openApi, openApiVersion, prefix, context);
|
|
270
|
+
const modelsByName = buildModelsByName(client.models);
|
|
202
271
|
const ghostPropertyKeys = new Set();
|
|
203
272
|
entries.forEach(entry => {
|
|
204
273
|
const segments = (0, jsonPath_1.parseJsonPath)(entry.path);
|
|
205
274
|
const schemaName = getSchemaNameFromSegments(segments, openApiVersion);
|
|
206
275
|
if (!schemaName)
|
|
207
276
|
return;
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
-
return;
|
|
211
|
-
const model = modelsByName.get(modelName);
|
|
212
|
-
if (!model)
|
|
277
|
+
const models = getModelsForSchema(schemaName, schemaNameMap, modelsByName);
|
|
278
|
+
if (models.length === 0)
|
|
213
279
|
return;
|
|
214
280
|
const propertiesIndex = segments.indexOf('properties');
|
|
215
281
|
if (propertiesIndex === -1 || propertiesIndex + 1 >= segments.length) {
|
|
@@ -217,68 +283,70 @@ const applyModelDiffs = (client, entries, openApi, openApiVersion, prefix) => {
|
|
|
217
283
|
}
|
|
218
284
|
const rawPropertyName = segments[propertiesIndex + 1];
|
|
219
285
|
const propertyName = (0, escapeName_1.escapeName)(rawPropertyName);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
model.ghostProperties
|
|
286
|
+
for (const model of models) {
|
|
287
|
+
if (entry.action === 'removed' && propertiesIndex + 1 === segments.length - 1) {
|
|
288
|
+
const key = `${model.name}:${model.alias}:${propertyName}`;
|
|
289
|
+
if (ghostPropertyKeys.has(key))
|
|
290
|
+
continue;
|
|
291
|
+
const exists = model.properties.some(prop => prop.name === propertyName);
|
|
292
|
+
if (!exists) {
|
|
293
|
+
const ghost = {
|
|
294
|
+
name: propertyName,
|
|
295
|
+
alias: '',
|
|
296
|
+
path: model.path,
|
|
297
|
+
export: 'generic',
|
|
298
|
+
type: 'unknown',
|
|
299
|
+
base: 'unknown',
|
|
300
|
+
template: null,
|
|
301
|
+
link: null,
|
|
302
|
+
description: null,
|
|
303
|
+
isDefinition: false,
|
|
304
|
+
isReadOnly: false,
|
|
305
|
+
isRequired: false,
|
|
306
|
+
isNullable: false,
|
|
307
|
+
imports: [],
|
|
308
|
+
enum: [],
|
|
309
|
+
enums: [],
|
|
310
|
+
properties: [],
|
|
311
|
+
diff: {
|
|
312
|
+
action: 'removed',
|
|
313
|
+
path: entry.path,
|
|
314
|
+
severity: entry.severity,
|
|
315
|
+
from: entry.from,
|
|
316
|
+
to: entry.to,
|
|
317
|
+
},
|
|
318
|
+
isGhost: true,
|
|
319
|
+
};
|
|
320
|
+
if (!model.ghostProperties) {
|
|
321
|
+
model.ghostProperties = [];
|
|
322
|
+
}
|
|
323
|
+
model.ghostProperties.push(ghost);
|
|
324
|
+
ghostPropertyKeys.add(key);
|
|
255
325
|
}
|
|
256
|
-
|
|
257
|
-
ghostPropertyKeys.add(key);
|
|
326
|
+
continue;
|
|
258
327
|
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
model.hasCoercion = true;
|
|
328
|
+
if (entry.action === 'changed' && segments[segments.length - 1] === 'type') {
|
|
329
|
+
const property = model.properties.find(prop => prop.name === propertyName);
|
|
330
|
+
if (!property)
|
|
331
|
+
continue;
|
|
332
|
+
const previousType = describeSchemaType(entry.from);
|
|
333
|
+
const currentTypeRaw = typeof entry.to === 'string' ? entry.to : describeSchemaType(entry.to);
|
|
334
|
+
const currentType = normalizeScalarType(currentTypeRaw);
|
|
335
|
+
const previousScalar = normalizeScalarType(previousType);
|
|
336
|
+
property.diff = {
|
|
337
|
+
action: entry.action,
|
|
338
|
+
path: entry.path,
|
|
339
|
+
severity: entry.severity,
|
|
340
|
+
from: entry.from,
|
|
341
|
+
to: entry.to,
|
|
342
|
+
previousType,
|
|
343
|
+
};
|
|
344
|
+
if (previousScalar && currentType && previousScalar !== currentType) {
|
|
345
|
+
property.needsCoercion = true;
|
|
346
|
+
property.coercionFrom = previousScalar;
|
|
347
|
+
property.coercionTo = currentType;
|
|
348
|
+
model.hasCoercion = true;
|
|
349
|
+
}
|
|
282
350
|
}
|
|
283
351
|
}
|
|
284
352
|
});
|
|
@@ -286,53 +354,65 @@ const applyModelDiffs = (client, entries, openApi, openApiVersion, prefix) => {
|
|
|
286
354
|
const applyMiracleTypeCoercions = (client, confirmedMiracles, entries) => {
|
|
287
355
|
if (!confirmedMiracles.length)
|
|
288
356
|
return;
|
|
289
|
-
const modelsByName =
|
|
357
|
+
const modelsByName = buildModelsByName(client.models);
|
|
290
358
|
for (const miracle of confirmedMiracles) {
|
|
291
359
|
if (miracle.type !== 'TYPE_COERCION')
|
|
292
360
|
continue;
|
|
293
361
|
if (!miracle.modelName)
|
|
294
362
|
continue;
|
|
295
|
-
const
|
|
296
|
-
if (
|
|
363
|
+
const models = modelsByName.get(miracle.modelName) ?? [];
|
|
364
|
+
if (models.length === 0)
|
|
297
365
|
continue;
|
|
298
366
|
const rawProperty = miracle.newProperty ?? miracle.oldProperty;
|
|
299
367
|
if (!rawProperty)
|
|
300
368
|
continue;
|
|
301
369
|
const propertyName = (0, escapeName_1.escapeName)(rawProperty);
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
property.diff
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
370
|
+
for (const model of models) {
|
|
371
|
+
const property = model.properties.find(prop => prop.name === propertyName);
|
|
372
|
+
if (!property)
|
|
373
|
+
continue;
|
|
374
|
+
property.needsCoercion = true;
|
|
375
|
+
model.hasCoercion = true;
|
|
376
|
+
if (!miracle.newPath)
|
|
377
|
+
continue;
|
|
378
|
+
const typePath = `${miracle.newPath}.type`;
|
|
379
|
+
const typeEntry = entries.find(entry => entry.action === 'changed' && entry.path === typePath);
|
|
380
|
+
if (!typeEntry)
|
|
381
|
+
continue;
|
|
382
|
+
const previousType = describeSchemaType(typeEntry.from);
|
|
383
|
+
const currentTypeRaw = typeof typeEntry.to === 'string' ? typeEntry.to : describeSchemaType(typeEntry.to);
|
|
384
|
+
const currentType = normalizeScalarType(currentTypeRaw);
|
|
385
|
+
const previousScalar = normalizeScalarType(previousType);
|
|
386
|
+
if (previousScalar && currentType && previousScalar !== currentType) {
|
|
387
|
+
property.coercionFrom = previousScalar;
|
|
388
|
+
property.coercionTo = currentType;
|
|
389
|
+
if (!property.diff) {
|
|
390
|
+
property.diff = {
|
|
391
|
+
action: typeEntry.action,
|
|
392
|
+
path: typeEntry.path,
|
|
393
|
+
severity: typeEntry.severity,
|
|
394
|
+
from: typeEntry.from,
|
|
395
|
+
to: typeEntry.to,
|
|
396
|
+
previousType,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
329
399
|
}
|
|
330
400
|
}
|
|
331
401
|
}
|
|
332
402
|
};
|
|
333
|
-
|
|
403
|
+
/**
|
|
404
|
+
* Применяет структурный diff-отчёт к сгенерированному клиенту: помечает изменения, miracles и ghost-свойства.
|
|
405
|
+
* @param client сгенерированный клиент
|
|
406
|
+
* @param openApi исходная OpenAPI-спецификация
|
|
407
|
+
* @param openApiVersion версия OpenAPI
|
|
408
|
+
* @param diffReport загруженный diff-отчёт или null
|
|
409
|
+
* @param prefix артефакты префиксов имён
|
|
410
|
+
* @param [context] контекст генерации для разрешения имён схем
|
|
411
|
+
* @returns клиент с аннотациями diff
|
|
412
|
+
*/
|
|
413
|
+
const applyDiffReportToClient = ({ client, openApi, openApiVersion, diffReport, prefix, context }) => {
|
|
334
414
|
const entries = diffReport?.diff?.all ?? [];
|
|
335
|
-
const schemaNameMap = buildSchemaNameMap(openApi, openApiVersion, prefix);
|
|
415
|
+
const schemaNameMap = buildSchemaNameMap(openApi, openApiVersion, prefix, context);
|
|
336
416
|
const confirmedMiracles = (diffReport?.miracles ?? [])
|
|
337
417
|
.filter(miracle => miracle.status === 'confirmed' || miracle.confidence === 1)
|
|
338
418
|
.map(miracle => {
|
|
@@ -341,7 +421,7 @@ const applyDiffReportToClient = ({ client, openApi, openApiVersion, diffReport,
|
|
|
341
421
|
const oldSchema = getSchemaNameFromSegments(oldSegments, openApiVersion);
|
|
342
422
|
const newSchema = getSchemaNameFromSegments(newSegments, openApiVersion);
|
|
343
423
|
const schemaName = oldSchema || newSchema;
|
|
344
|
-
const modelName = schemaName ? schemaNameMap.get(schemaName) : undefined;
|
|
424
|
+
const modelName = (schemaName ? schemaNameMap.get(schemaName) : undefined) ?? miracle.modelName;
|
|
345
425
|
const oldPropIndex = oldSegments.indexOf('properties');
|
|
346
426
|
const newPropIndex = newSegments.indexOf('properties');
|
|
347
427
|
const oldProperty = oldPropIndex !== -1 ? oldSegments[oldPropIndex + 1] : undefined;
|
|
@@ -360,7 +440,7 @@ const applyDiffReportToClient = ({ client, openApi, openApiVersion, diffReport,
|
|
|
360
440
|
if (entries.length === 0) {
|
|
361
441
|
return client;
|
|
362
442
|
}
|
|
363
|
-
applyModelDiffs(client, entries, openApi, openApiVersion, prefix);
|
|
443
|
+
applyModelDiffs(client, entries, openApi, openApiVersion, prefix, context);
|
|
364
444
|
applyOperationDiffs(client, entries);
|
|
365
445
|
return client;
|
|
366
446
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SemanticDiffChange } from '../semanticDiff/analyzeOpenApiDiff';
|
|
2
|
+
import type { MiracleEntry } from '../types/shared/Miracle.model';
|
|
3
|
+
type SemanticPropertyChange = {
|
|
4
|
+
schemaPath: string;
|
|
5
|
+
schemaName: string;
|
|
6
|
+
propertyName: string;
|
|
7
|
+
jsonPath: string;
|
|
8
|
+
payload: Record<string, unknown>;
|
|
9
|
+
typeSignature?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Разбирает JSON Pointer свойства схемы в метаданные изменения.
|
|
14
|
+
* @param path JSON Pointer путь к свойству
|
|
15
|
+
* @returns метаданные изменения или null, если путь не относится к свойству схемы
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseSchemaPropertyPointer(path: string): Omit<SemanticPropertyChange, 'payload' | 'typeSignature' | 'description'> | null;
|
|
18
|
+
/**
|
|
19
|
+
* Строит miracles типов RENAME и TYPE_COERCION из семантических изменений.
|
|
20
|
+
* @param changes список семантических изменений
|
|
21
|
+
* @returns список miracles
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildMiraclesFromSemanticChanges(changes: SemanticDiffChange[]): MiracleEntry[];
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=buildMiraclesFromSemanticChanges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildMiraclesFromSemanticChanges.d.ts","sourceRoot":"","sources":["../../../src/core/utils/buildMiraclesFromSemanticChanges.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGlE,KAAK,sBAAsB,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAIF;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,eAAe,GAAG,aAAa,CAAC,GAAG,IAAI,CAezI;AA0CD;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,YAAY,EAAE,CA6F9F"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseSchemaPropertyPointer = parseSchemaPropertyPointer;
|
|
7
|
+
exports.buildMiraclesFromSemanticChanges = buildMiraclesFromSemanticChanges;
|
|
8
|
+
const leven_1 = __importDefault(require("leven"));
|
|
9
|
+
const miracles_1 = require("../../cli/analyzeDiff/miracles");
|
|
10
|
+
const semanticPointerToJsonPath_1 = require("./semanticPointerToJsonPath");
|
|
11
|
+
const SCHEMA_PROPERTY_POINTER_REGEX = /^#\/components\/schemas\/([^/]+)\/properties\/([^/]+)$/;
|
|
12
|
+
/**
|
|
13
|
+
* Разбирает JSON Pointer свойства схемы в метаданные изменения.
|
|
14
|
+
* @param path JSON Pointer путь к свойству
|
|
15
|
+
* @returns метаданные изменения или null, если путь не относится к свойству схемы
|
|
16
|
+
*/
|
|
17
|
+
function parseSchemaPropertyPointer(path) {
|
|
18
|
+
const match = path.match(SCHEMA_PROPERTY_POINTER_REGEX);
|
|
19
|
+
if (!match) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const schemaName = match[1];
|
|
23
|
+
const propertyName = match[2];
|
|
24
|
+
return {
|
|
25
|
+
schemaPath: `components.schemas.${schemaName}`,
|
|
26
|
+
schemaName,
|
|
27
|
+
propertyName,
|
|
28
|
+
jsonPath: (0, semanticPointerToJsonPath_1.semanticPointerToJsonPath)(path),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const toPayload = (value) => {
|
|
32
|
+
if (value && typeof value === 'object') {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
if (typeof value === 'string') {
|
|
36
|
+
return { type: value };
|
|
37
|
+
}
|
|
38
|
+
return {};
|
|
39
|
+
};
|
|
40
|
+
const extractSemanticPropertyChange = (change, action) => {
|
|
41
|
+
const parsed = parseSchemaPropertyPointer(change.path);
|
|
42
|
+
if (!parsed) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const payload = toPayload(action === 'removed' ? change.from : change.to);
|
|
46
|
+
const typeSignature = (0, miracles_1.getTypeSignature)(payload) ?? (typeof change.from === 'string' ? change.from : typeof change.to === 'string' ? change.to : undefined);
|
|
47
|
+
return {
|
|
48
|
+
...parsed,
|
|
49
|
+
payload,
|
|
50
|
+
typeSignature,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const isSimilarityCandidate = (removed, added) => {
|
|
54
|
+
if (removed.schemaPath !== added.schemaPath) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
if (removed.typeSignature && added.typeSignature) {
|
|
58
|
+
return removed.typeSignature === added.typeSignature;
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Строит miracles типов RENAME и TYPE_COERCION из семантических изменений.
|
|
64
|
+
* @param changes список семантических изменений
|
|
65
|
+
* @returns список miracles
|
|
66
|
+
*/
|
|
67
|
+
function buildMiraclesFromSemanticChanges(changes) {
|
|
68
|
+
const removedProps = [];
|
|
69
|
+
const addedProps = [];
|
|
70
|
+
const miracles = [];
|
|
71
|
+
for (const change of changes) {
|
|
72
|
+
if (change.type === 'model.property.removed') {
|
|
73
|
+
const removed = extractSemanticPropertyChange(change, 'removed');
|
|
74
|
+
if (removed) {
|
|
75
|
+
removedProps.push(removed);
|
|
76
|
+
}
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (change.type === 'model.property.added') {
|
|
80
|
+
const added = extractSemanticPropertyChange(change, 'added');
|
|
81
|
+
if (added) {
|
|
82
|
+
addedProps.push(added);
|
|
83
|
+
}
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (change.type !== 'model.property.type.changed') {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const parsed = parseSchemaPropertyPointer(change.path);
|
|
90
|
+
if (!parsed) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
const fromType = (0, miracles_1.normalizeScalarType)(typeof change.from === 'string' ? change.from : undefined);
|
|
94
|
+
const toType = (0, miracles_1.normalizeScalarType)(typeof change.to === 'string' ? change.to : undefined);
|
|
95
|
+
if (!fromType || !toType || fromType === toType) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
miracles.push({
|
|
99
|
+
oldPath: parsed.jsonPath,
|
|
100
|
+
newPath: parsed.jsonPath,
|
|
101
|
+
type: 'TYPE_COERCION',
|
|
102
|
+
confidence: 1,
|
|
103
|
+
status: 'auto-generated',
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
for (const removed of removedProps) {
|
|
107
|
+
const candidates = addedProps.filter(added => isSimilarityCandidate(removed, added));
|
|
108
|
+
if (candidates.length === 0) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const removedName = (0, miracles_1.normalizeName)(removed.propertyName);
|
|
112
|
+
if (!removedName) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
let best = null;
|
|
116
|
+
for (const candidate of candidates) {
|
|
117
|
+
const addedName = (0, miracles_1.normalizeName)(candidate.propertyName);
|
|
118
|
+
if (!addedName) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const distance = (0, leven_1.default)(removedName, addedName);
|
|
122
|
+
const ratio = distance / Math.max(removedName.length, addedName.length);
|
|
123
|
+
if (!best || ratio < best.ratio) {
|
|
124
|
+
best = { candidate, ratio };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (!best || best.ratio > 0.2) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
const sameType = !!removed.typeSignature && !!best.candidate.typeSignature && removed.typeSignature === best.candidate.typeSignature;
|
|
131
|
+
const onlyCandidate = candidates.length === 1;
|
|
132
|
+
const descBonus = (0, miracles_1.descriptionSimilarityBonus)(removed.description, best.candidate.description);
|
|
133
|
+
const confidence = (0, miracles_1.computeConfidence)(best.ratio, sameType, onlyCandidate, descBonus);
|
|
134
|
+
miracles.push({
|
|
135
|
+
oldPath: removed.jsonPath,
|
|
136
|
+
newPath: best.candidate.jsonPath,
|
|
137
|
+
type: 'RENAME',
|
|
138
|
+
confidence,
|
|
139
|
+
status: 'auto-generated',
|
|
140
|
+
modelName: removed.schemaName,
|
|
141
|
+
oldProperty: removed.propertyName,
|
|
142
|
+
newProperty: best.candidate.propertyName,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
return miracles;
|
|
146
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Резолвер ссылок для семантического diff.
|
|
3
|
+
* @property [exists] проверка существования ссылки
|
|
4
|
+
* @property get получение значения по ссылке
|
|
5
|
+
*/
|
|
6
|
+
export type SemanticRefResolver = {
|
|
7
|
+
exists?: (ref: string) => boolean;
|
|
8
|
+
get: (ref: string) => unknown;
|
|
9
|
+
};
|
|
10
|
+
type ExpandOptions = {
|
|
11
|
+
refs?: SemanticRefResolver;
|
|
12
|
+
sourceFile?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Строит клон спецификации с развёрнутыми refs для семантического сравнения.
|
|
16
|
+
* Циклы и неразрешённые refs остаются стабильными `$ref`-объектами.
|
|
17
|
+
* @param root корневой узел OpenAPI-документа
|
|
18
|
+
* @param [options] опции резолва ссылок
|
|
19
|
+
* @returns клон с развёрнутыми refs
|
|
20
|
+
*/
|
|
21
|
+
export declare function expandOpenApiRefsForSemanticDiff<T = unknown>(root: T, options?: ExpandOptions): T;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=expandOpenApiRefsForSemanticDiff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expandOpenApiRefsForSemanticDiff.d.ts","sourceRoot":"","sources":["../../../src/core/utils/expandOpenApiRefsForSemanticDiff.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;IAClC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;CACjC,CAAC;AAaF,KAAK,aAAa,GAAG;IACjB,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAmLF;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,GAAE,aAAkB,GAAG,CAAC,CAGrG"}
|