ts-openapi-codegen 2.0.0 → 2.1.0-beta.2
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 +95 -2
- package/README.rus.md +95 -2
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.js +365 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.js +142 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.js +137 -0
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts +17 -0
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/analyzeDiff.js +105 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts +17 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.js +54 -0
- package/dist/cli/analyzeDiff/ciSummary.d.ts +6 -0
- package/dist/cli/analyzeDiff/ciSummary.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ciSummary.js +20 -0
- package/dist/cli/analyzeDiff/diffEngine.d.ts +54 -0
- package/dist/cli/analyzeDiff/diffEngine.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/diffEngine.js +209 -0
- package/dist/cli/analyzeDiff/ignoreRules.d.ts +33 -0
- package/dist/cli/analyzeDiff/ignoreRules.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ignoreRules.js +93 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.d.ts +10 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.js +84 -0
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts +6 -0
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/logLegacyReport.js +29 -0
- package/dist/cli/analyzeDiff/miracles.d.ts +89 -0
- package/dist/cli/analyzeDiff/miracles.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/miracles.js +325 -0
- package/dist/cli/analyzeDiff/pluginPaths.d.ts +5 -0
- package/dist/cli/analyzeDiff/pluginPaths.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/pluginPaths.js +13 -0
- package/dist/cli/analyzeDiff/report.d.ts +3 -0
- package/dist/cli/analyzeDiff/report.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/report.js +7 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.d.ts +6 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.js +16 -0
- package/dist/cli/analyzeDiff/specParser.d.ts +22 -0
- package/dist/cli/analyzeDiff/specParser.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/specParser.js +80 -0
- package/dist/cli/analyzeDiff/types.d.ts +61 -0
- package/dist/cli/analyzeDiff/types.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/types.js +2 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts +6 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.js +21 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +13 -8
- package/dist/cli/checkAndUpdateConfig/constants.d.ts +0 -9
- package/dist/cli/checkAndUpdateConfig/constants.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/constants.js +1 -10
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +11 -7
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.js +6 -3
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.js +3 -2
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.js +2 -2
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.d.ts +2 -0
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.d.ts.map +1 -0
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.js +152 -0
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts +6 -2
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +54 -18
- package/dist/cli/index.js +57 -2
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.js +19 -6
- package/dist/cli/initOpenApiConfig/initConfig.d.ts +1 -0
- package/dist/cli/initOpenApiConfig/initConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initConfig.js +47 -24
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts +8 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.js +40 -8
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/buildConfig.js +60 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.js +2 -1
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.js +2 -1
- package/dist/cli/interactive/confirmDialog.d.ts.map +1 -1
- package/dist/cli/interactive/confirmDialog.js +3 -2
- package/dist/cli/interactive/constants.d.ts +2 -2
- package/dist/cli/interactive/constants.js +8 -8
- package/dist/cli/interactive/selectDialog.d.ts.map +1 -1
- package/dist/cli/interactive/selectDialog.js +11 -6
- package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
- package/dist/cli/previewChanges/previewChanges.js +45 -17
- package/dist/cli/schemas/analyzeDiff.d.ts +14 -0
- package/dist/cli/schemas/analyzeDiff.d.ts.map +1 -0
- package/dist/cli/schemas/analyzeDiff.js +28 -0
- package/dist/cli/schemas/generate.d.ts +9 -0
- package/dist/cli/schemas/generate.d.ts.map +1 -1
- package/dist/cli/schemas/generate.js +9 -0
- package/dist/cli/schemas/index.d.ts +3 -1
- package/dist/cli/schemas/index.d.ts.map +1 -1
- package/dist/cli/schemas/index.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 +15 -1
- package/dist/common/Logger.d.ts +20 -1
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +70 -9
- package/dist/common/LoggerMessages.d.ts +135 -33
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +118 -45
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +7 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts +4 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +35 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +4 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts +79 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.js +19 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +171 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +2 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +40 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +34 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +23 -3
- package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +2 -2
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +2 -1
- package/dist/common/__tests__/Logger.test.d.ts +2 -0
- package/dist/common/__tests__/Logger.test.d.ts.map +1 -0
- package/dist/common/__tests__/Logger.test.js +100 -0
- package/dist/common/utils/__tests__/convertArrayToObject.test.js +3 -0
- package/dist/common/utils/__tests__/eslintFix.test.d.ts +2 -0
- package/dist/common/utils/__tests__/eslintFix.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/eslintFix.test.js +134 -0
- package/dist/common/utils/__tests__/format.test.d.ts +2 -0
- package/dist/common/utils/__tests__/format.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/format.test.js +90 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +3 -0
- package/dist/common/utils/eslintFix.d.ts +7 -0
- package/dist/common/utils/eslintFix.d.ts.map +1 -0
- package/dist/common/utils/eslintFix.js +78 -0
- 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 +39 -15
- package/dist/common/utils/jsonPath.d.ts +5 -0
- package/dist/common/utils/jsonPath.d.ts.map +1 -0
- package/dist/common/utils/jsonPath.js +27 -0
- package/dist/common/utils/normalizeObject.d.ts +2 -0
- package/dist/common/utils/normalizeObject.d.ts.map +1 -0
- package/dist/common/utils/normalizeObject.js +63 -0
- package/dist/core/Context.d.ts +8 -1
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +23 -4
- package/dist/core/OpenApiClient.d.ts +2 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +116 -6
- package/dist/core/WriteClient.d.ts +4 -0
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +38 -4
- package/dist/core/__tests__/WriteClient.test.js +4 -1
- package/dist/core/api/v2/parser/__tests__/getModel.test.d.ts +2 -0
- package/dist/core/api/v2/parser/__tests__/getModel.test.d.ts.map +1 -0
- package/dist/core/api/v2/parser/__tests__/getModel.test.js +34 -0
- package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModel.js +6 -1
- package/dist/core/api/v2/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperation.js +2 -0
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +9 -1
- package/dist/core/api/v2/types/OpenApiSchema.model.d.ts +2 -0
- package/dist/core/api/v2/types/OpenApiSchema.model.d.ts.map +1 -1
- package/dist/core/api/v3/parser/__tests__/getContent.test.d.ts +2 -0
- package/dist/core/api/v3/parser/__tests__/getContent.test.d.ts.map +1 -0
- package/dist/core/api/v3/parser/__tests__/getContent.test.js +65 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.d.ts +2 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.d.ts.map +1 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.js +34 -0
- package/dist/core/api/v3/parser/getContent.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getContent.js +21 -11
- package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModel.js +6 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperation.js +2 -0
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +9 -1
- package/dist/core/api/v3/types/OpenApiSchema.model.d.ts +2 -0
- package/dist/core/api/v3/types/OpenApiSchema.model.d.ts.map +1 -1
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.d.ts +2 -0
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.d.ts.map +1 -0
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.js +100 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.d.ts +2 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.d.ts.map +1 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.js +71 -0
- package/dist/core/governance/evaluateGovernanceRules.d.ts +42 -0
- package/dist/core/governance/evaluateGovernanceRules.d.ts.map +1 -0
- package/dist/core/governance/evaluateGovernanceRules.js +134 -0
- package/dist/core/governance/governanceConfigSchema.d.ts +4 -0
- package/dist/core/governance/governanceConfigSchema.d.ts.map +1 -0
- package/dist/core/governance/governanceConfigSchema.js +39 -0
- package/dist/core/governance/loadGovernanceConfig.d.ts +7 -0
- package/dist/core/governance/loadGovernanceConfig.d.ts.map +1 -0
- package/dist/core/governance/loadGovernanceConfig.js +60 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -2
- package/dist/core/plugins/GeneratorPlugin.model.d.ts +42 -0
- package/dist/core/plugins/GeneratorPlugin.model.d.ts.map +1 -0
- package/dist/core/plugins/GeneratorPlugin.model.js +2 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.d.ts +2 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.d.ts.map +1 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.js +115 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.d.ts +2 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.d.ts.map +1 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.js +62 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts +28 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts.map +1 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.js +160 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.d.ts +6 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.d.ts.map +1 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.js +13 -0
- package/dist/core/plugins/getBuiltinPlugins.d.ts +6 -0
- package/dist/core/plugins/getBuiltinPlugins.d.ts.map +1 -0
- package/dist/core/plugins/getBuiltinPlugins.js +10 -0
- package/dist/core/plugins/index.d.ts +4 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +5 -0
- package/dist/core/plugins/loadGeneratorPlugins.d.ts +6 -0
- package/dist/core/plugins/loadGeneratorPlugins.d.ts.map +1 -0
- package/dist/core/plugins/loadGeneratorPlugins.js +94 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.d.ts +2 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.d.ts.map +1 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.js +537 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.d.ts +2 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.d.ts.map +1 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.js +66 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts +45 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts.map +1 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.js +640 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts +11 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts.map +1 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.js +132 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.d.ts +2 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.d.ts.map +1 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.js +156 -0
- package/dist/core/strict/validateOpenApiStrict.d.ts +43 -0
- package/dist/core/strict/validateOpenApiStrict.d.ts.map +1 -0
- package/dist/core/strict/validateOpenApiStrict.js +253 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts +2 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/Templates.model.d.ts +3 -0
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/types/enums/ModelsMode.enum.d.ts +5 -0
- package/dist/core/types/enums/ModelsMode.enum.d.ts.map +1 -0
- package/dist/core/types/enums/ModelsMode.enum.js +8 -0
- package/dist/core/types/shared/Client.model.d.ts +2 -0
- package/dist/core/types/shared/Client.model.d.ts.map +1 -1
- package/dist/core/types/shared/DiffInfo.model.d.ts +13 -0
- package/dist/core/types/shared/DiffInfo.model.d.ts.map +1 -0
- package/dist/core/types/shared/DiffInfo.model.js +2 -0
- package/dist/core/types/shared/Miracle.model.d.ts +13 -0
- package/dist/core/types/shared/Miracle.model.d.ts.map +1 -0
- package/dist/core/types/shared/Miracle.model.js +2 -0
- package/dist/core/types/shared/Model.model.d.ts +23 -0
- package/dist/core/types/shared/Model.model.d.ts.map +1 -1
- package/dist/core/types/shared/Operation.model.d.ts +5 -0
- package/dist/core/types/shared/Operation.model.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.js +9 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.d.ts +2 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.js +108 -0
- package/dist/core/utils/__tests__/getMappedType.test.js +2 -0
- package/dist/core/utils/__tests__/getOperationResponseCode.test.js +7 -2
- package/dist/core/utils/__tests__/getOperationResults.test.d.ts +2 -0
- package/dist/core/utils/__tests__/getOperationResults.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/getOperationResults.test.js +43 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.d.ts +2 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.js +116 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +1 -0
- package/dist/core/utils/__tests__/writeClientModels.test.js +50 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts +14 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts.map +1 -0
- package/dist/core/utils/applyDiffReportToClient.js +367 -0
- package/dist/core/utils/getMappedType.d.ts.map +1 -1
- package/dist/core/utils/getMappedType.js +2 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +1 -14
- package/dist/core/utils/getOperationResponseCode.d.ts.map +1 -1
- package/dist/core/utils/getOperationResponseCode.js +10 -8
- package/dist/core/utils/loadDiffReport.d.ts +39 -0
- package/dist/core/utils/loadDiffReport.d.ts.map +1 -0
- package/dist/core/utils/loadDiffReport.js +51 -0
- package/dist/core/utils/prepareDtoModels.d.ts +3 -0
- package/dist/core/utils/prepareDtoModels.d.ts.map +1 -0
- package/dist/core/utils/prepareDtoModels.js +189 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +4 -1
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +6 -0
- package/dist/core/utils/validateRawOptions.d.ts +1 -1
- package/dist/core/utils/validateRawOptions.d.ts.map +1 -1
- package/dist/core/utils/validateRawOptions.js +4 -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 +6 -1
- package/dist/core/utils/writeClientCoreIndex.d.ts +1 -0
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +2 -2
- package/dist/core/utils/writeClientExecutor.d.ts +2 -0
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +6 -2
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientFullIndex.js +3 -1
- package/dist/core/utils/writeClientModels.d.ts +6 -0
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +24 -3
- package/dist/core/utils/writeClientModelsIndex.d.ts +2 -0
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.js +2 -2
- package/dist/core/utils/writeClientSchemas.d.ts +2 -0
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +6 -2
- package/dist/core/utils/writeClientServices.d.ts +2 -0
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +6 -2
- package/dist/templatesCompiled/cli/openApiConfig.d.ts +4 -1
- package/dist/templatesCompiled/cli/openApiConfig.d.ts.map +1 -1
- package/dist/templatesCompiled/cli/openApiConfig.js +88 -37
- package/dist/templatesCompiled/client/core/ApiRequestOptions.js +1 -1
- package/dist/templatesCompiled/client/core/BaseDto.d.ts +8 -0
- package/dist/templatesCompiled/client/core/BaseDto.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/BaseDto.js +18 -0
- package/dist/templatesCompiled/client/core/axios/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/axios/request.js +2 -2
- package/dist/templatesCompiled/client/core/axios/sendRequest.js +4 -4
- package/dist/templatesCompiled/client/core/dtoUtils.d.ts +8 -0
- package/dist/templatesCompiled/client/core/dtoUtils.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/dtoUtils.js +18 -0
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +2 -2
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +1 -1
- package/dist/templatesCompiled/client/core/fetch/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/fetch/request.js +2 -2
- package/dist/templatesCompiled/client/core/functions/isBinary.js +1 -1
- package/dist/templatesCompiled/client/core/node/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/node/request.js +2 -2
- package/dist/templatesCompiled/client/core/xhr/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/xhr/request.js +2 -2
- package/dist/templatesCompiled/client/core/xhr/sendRequest.js +4 -4
- package/dist/templatesCompiled/client/exportModels.d.ts +34 -0
- package/dist/templatesCompiled/client/exportModels.d.ts.map +1 -0
- package/dist/templatesCompiled/client/exportModels.js +280 -0
- package/dist/templatesCompiled/client/exportService.d.ts +7 -4
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +52 -33
- package/dist/templatesCompiled/client/indexCore.d.ts +3 -1
- package/dist/templatesCompiled/client/indexCore.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexCore.js +13 -2
- package/dist/templatesCompiled/client/indexFull.d.ts +9 -7
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +52 -34
- package/dist/templatesCompiled/client/indexModels.d.ts +7 -5
- package/dist/templatesCompiled/client/indexModels.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexModels.js +27 -18
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts +27 -19
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.js +144 -63
- package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts +1 -0
- package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts.map +1 -1
- package/dist/templatesCompiled/client/jsonschema/exportSchema.js +17 -13
- package/dist/templatesCompiled/client/partials/exportInterface.d.ts +13 -5
- package/dist/templatesCompiled/client/partials/exportInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/exportInterface.js +91 -21
- package/dist/templatesCompiled/client/partials/result.d.ts +6 -4
- package/dist/templatesCompiled/client/partials/result.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/result.js +16 -6
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts +1 -0
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/serviceOption.js +11 -4
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts +22 -16
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.js +72 -60
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts +27 -19
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.js +77 -61
- package/package.json +7 -5
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OptionValues } from 'commander';
|
|
2
|
+
export type AnalyzeDiffResult = {
|
|
3
|
+
success: boolean;
|
|
4
|
+
skipped?: boolean;
|
|
5
|
+
reportPath?: string;
|
|
6
|
+
ignored?: number;
|
|
7
|
+
error?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Maps analyze-diff result to a process exit code. Does not call `process.exit`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function toAnalyzeDiffExitCode(result: AnalyzeDiffResult): number;
|
|
13
|
+
/**
|
|
14
|
+
* Runs semantic diff analysis between two OpenAPI specs and writes JSON report.
|
|
15
|
+
*/
|
|
16
|
+
export declare function analyzeDiff(options: OptionValues): Promise<AnalyzeDiffResult>;
|
|
17
|
+
//# sourceMappingURL=analyzeDiff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeDiff.d.ts","sourceRoot":"","sources":["../../../src/cli/analyzeDiff/analyzeDiff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAoBzC,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,CAEvE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuFnF"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toAnalyzeDiffExitCode = toAnalyzeDiffExitCode;
|
|
4
|
+
exports.analyzeDiff = analyzeDiff;
|
|
5
|
+
const Consts_1 = require("../../common/Consts");
|
|
6
|
+
const LoggerMessages_1 = require("../../common/LoggerMessages");
|
|
7
|
+
const validateZodOptions_1 = require("../../common/Validation/validateZodOptions");
|
|
8
|
+
const evaluateGovernanceRules_1 = require("../../core/governance/evaluateGovernanceRules");
|
|
9
|
+
const loadGovernanceConfig_1 = require("../../core/governance/loadGovernanceConfig");
|
|
10
|
+
const applySemanticDiffPluginHooks_1 = require("../../core/plugins/applySemanticDiffPluginHooks");
|
|
11
|
+
const loadGeneratorPlugins_1 = require("../../core/plugins/loadGeneratorPlugins");
|
|
12
|
+
const analyzeOpenApiDiff_1 = require("../../core/semanticDiff/analyzeOpenApiDiff");
|
|
13
|
+
const getOpenApiSpec_1 = require("../../core/utils/getOpenApiSpec");
|
|
14
|
+
const schemas_1 = require("../schemas");
|
|
15
|
+
const ciSummary_1 = require("./ciSummary");
|
|
16
|
+
const ignoreRules_1 = require("./ignoreRules");
|
|
17
|
+
const ignoreSemanticChanges_1 = require("./ignoreSemanticChanges");
|
|
18
|
+
const pluginPaths_1 = require("./pluginPaths");
|
|
19
|
+
const semanticDiffContext_1 = require("./semanticDiffContext");
|
|
20
|
+
const specParser_1 = require("./specParser");
|
|
21
|
+
/**
|
|
22
|
+
* Maps analyze-diff result to a process exit code. Does not call `process.exit`.
|
|
23
|
+
*/
|
|
24
|
+
function toAnalyzeDiffExitCode(result) {
|
|
25
|
+
return result.success ? 0 : 1;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Runs semantic diff analysis between two OpenAPI specs and writes JSON report.
|
|
29
|
+
*/
|
|
30
|
+
async function analyzeDiff(options) {
|
|
31
|
+
const validationResult = (0, validateZodOptions_1.validateZodOptions)(schemas_1.analyzeDiffOptionsSchema, options);
|
|
32
|
+
if (!validationResult.success) {
|
|
33
|
+
const message = validationResult.errors.join('\n');
|
|
34
|
+
Consts_1.APP_LOGGER.error(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.VALIDATION_ERROR(message));
|
|
35
|
+
return { success: false, error: message };
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const validatedOptions = validationResult.data;
|
|
39
|
+
const reportPathInput = validatedOptions.outputReport ?? Consts_1.DEFAULT_ANALYZE_DIFF_REPORT_PATH;
|
|
40
|
+
const newSpecInput = validatedOptions.input;
|
|
41
|
+
const oldSpecInput = validatedOptions.compareWith;
|
|
42
|
+
const gitRef = validatedOptions.git;
|
|
43
|
+
if (!oldSpecInput && !gitRef) {
|
|
44
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.SKIPPED_NO_BASE);
|
|
45
|
+
return { success: true, skipped: true };
|
|
46
|
+
}
|
|
47
|
+
const baseSourceLabel = oldSpecInput ? `compare-with:${oldSpecInput}` : `git:${gitRef}`;
|
|
48
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.STARTED(newSpecInput, baseSourceLabel));
|
|
49
|
+
const newContext = (0, semanticDiffContext_1.createSemanticDiffContext)(newSpecInput);
|
|
50
|
+
const newSpec = await (0, getOpenApiSpec_1.getOpenApiSpec)(newContext, newSpecInput);
|
|
51
|
+
const oldSpec = oldSpecInput
|
|
52
|
+
? await (0, getOpenApiSpec_1.getOpenApiSpec)((0, semanticDiffContext_1.createSemanticDiffContext)(oldSpecInput), oldSpecInput)
|
|
53
|
+
: (await (0, specParser_1.readSpecFromGit)(gitRef, newSpecInput));
|
|
54
|
+
if (oldSpecInput && validatedOptions.git) {
|
|
55
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.COMPARE_WITH_OVERRIDES_GIT(validatedOptions.git));
|
|
56
|
+
}
|
|
57
|
+
const governancePolicy = await (0, loadGovernanceConfig_1.loadGovernanceConfig)(validatedOptions.governanceConfig);
|
|
58
|
+
const ignoreRules = (0, ignoreRules_1.loadIgnoreRules)(validatedOptions.openapiConfig);
|
|
59
|
+
const plugins = await (0, loadGeneratorPlugins_1.loadGeneratorPlugins)((0, pluginPaths_1.resolvePluginPaths)(validatedOptions.openapiConfig));
|
|
60
|
+
const baseReport = (0, analyzeOpenApiDiff_1.analyzeOpenApiDiff)(oldSpec, newSpec, {
|
|
61
|
+
allowBreaking: validatedOptions.allowBreaking ?? false,
|
|
62
|
+
governanceConfig: governancePolicy,
|
|
63
|
+
});
|
|
64
|
+
const pluginHooksResult = await (0, applySemanticDiffPluginHooks_1.applySemanticDiffPluginHooks)({
|
|
65
|
+
report: baseReport,
|
|
66
|
+
reportPath: reportPathInput,
|
|
67
|
+
plugins,
|
|
68
|
+
allowBreaking: validatedOptions.allowBreaking ?? false,
|
|
69
|
+
strictPluginMode: validatedOptions.strictPluginMode ?? false,
|
|
70
|
+
onDiagnostic: diagnostic => {
|
|
71
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.PLUGIN_DIAGNOSTIC(diagnostic));
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const { report: reportAfterIgnore, ignored } = (0, ignoreSemanticChanges_1.filterSemanticChangesByIgnoreRules)(pluginHooksResult.report, ignoreRules);
|
|
75
|
+
const report = {
|
|
76
|
+
...reportAfterIgnore,
|
|
77
|
+
governance: (0, evaluateGovernanceRules_1.evaluateGovernanceRules)({
|
|
78
|
+
openApi: newSpec,
|
|
79
|
+
breakingChangesCount: reportAfterIgnore.summary.breaking,
|
|
80
|
+
allowBreaking: validatedOptions.allowBreaking ?? false,
|
|
81
|
+
governanceConfig: governancePolicy,
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
const reportPath = await (0, analyzeOpenApiDiff_1.writeSemanticDiffReport)(report, pluginHooksResult.reportPath);
|
|
85
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.REPORT_CREATED(reportPath));
|
|
86
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.SUMMARY(report, reportPath));
|
|
87
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.RECOMMENDATION(report));
|
|
88
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.GOVERNANCE(report));
|
|
89
|
+
if (ignored > 0) {
|
|
90
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.IGNORED_CHANGES(ignored));
|
|
91
|
+
}
|
|
92
|
+
if (validatedOptions.ci) {
|
|
93
|
+
Consts_1.APP_LOGGER.info(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.CI_MARKDOWN_SUMMARY((0, ciSummary_1.formatCiMarkdownSummary)(report, reportPath)));
|
|
94
|
+
}
|
|
95
|
+
if (validatedOptions.ci && report.governance.summary.errors > 0) {
|
|
96
|
+
return { success: false, reportPath, error: LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.CI_FAILURE };
|
|
97
|
+
}
|
|
98
|
+
return { success: true, reportPath, ignored };
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
102
|
+
Consts_1.APP_LOGGER.error(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.EXECUTION_ERROR(message));
|
|
103
|
+
return { success: false, error: message };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DiffReport, IgnoreRule, JsonValue } from './types';
|
|
2
|
+
type BuildLegacyReportParams = {
|
|
3
|
+
baseLabel: string;
|
|
4
|
+
targetLabel: string;
|
|
5
|
+
oldSpec: JsonValue;
|
|
6
|
+
newSpec: JsonValue;
|
|
7
|
+
ignoreRules: IgnoreRule[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Собирает legacy diff-отчет по сравнению двух спецификаций.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildLegacyReport(params: BuildLegacyReportParams): {
|
|
13
|
+
report: DiffReport;
|
|
14
|
+
ignored: number;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=buildLegacyReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildLegacyReport.d.ts","sourceRoot":"","sources":["../../../src/cli/analyzeDiff/buildLegacyReport.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAa,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE5E,KAAK,uBAAuB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,EAAE,SAAS,CAAC;IACnB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,uBAAuB,GAAG;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CA6C1G"}
|
|
@@ -0,0 +1,54 @@
|
|
|
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.buildLegacyReport = buildLegacyReport;
|
|
7
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
+
const diffEngine_1 = require("./diffEngine");
|
|
9
|
+
const ignoreRules_1 = require("./ignoreRules");
|
|
10
|
+
const miracles_1 = require("./miracles");
|
|
11
|
+
/**
|
|
12
|
+
* Собирает legacy diff-отчет по сравнению двух спецификаций.
|
|
13
|
+
*/
|
|
14
|
+
function buildLegacyReport(params) {
|
|
15
|
+
const { baseLabel, targetLabel, oldSpec, newSpec, ignoreRules } = params;
|
|
16
|
+
const normalizedOld = (0, diffEngine_1.normalizeForDiff)(oldSpec);
|
|
17
|
+
const normalizedNew = (0, diffEngine_1.normalizeForDiff)(newSpec);
|
|
18
|
+
const baseHash = crypto_1.default.createHash('sha256').update(JSON.stringify(normalizedOld)).digest('hex');
|
|
19
|
+
const targetHash = crypto_1.default.createHash('sha256').update(JSON.stringify(normalizedNew)).digest('hex');
|
|
20
|
+
const entries = (0, diffEngine_1.withDiffType)((0, diffEngine_1.collectDiffEntries)(normalizedOld, normalizedNew));
|
|
21
|
+
const { filtered, ignored } = (0, ignoreRules_1.applyIgnoreRules)(entries, ignoreRules);
|
|
22
|
+
const breakingCount = filtered.filter(entry => entry.severity === 'breaking').length;
|
|
23
|
+
const stabilityScore = filtered.length === 0 ? 100 : Math.round(((filtered.length - breakingCount) / filtered.length) * 100);
|
|
24
|
+
const stats = {
|
|
25
|
+
totalChanges: filtered.length,
|
|
26
|
+
added: filtered.filter(entry => entry.action === 'added').length,
|
|
27
|
+
removed: filtered.filter(entry => entry.action === 'removed').length,
|
|
28
|
+
changed: filtered.filter(entry => entry.action === 'changed').length,
|
|
29
|
+
ignored: ignored || undefined,
|
|
30
|
+
stabilityScore,
|
|
31
|
+
};
|
|
32
|
+
const breaking = filtered.filter(entry => entry.severity === 'breaking');
|
|
33
|
+
const warnings = filtered.filter(entry => entry.severity === 'warning');
|
|
34
|
+
const info = filtered.filter(entry => entry.severity === 'info');
|
|
35
|
+
const report = {
|
|
36
|
+
version: '1.0.0',
|
|
37
|
+
timestamp: new Date().toISOString(),
|
|
38
|
+
metadata: {
|
|
39
|
+
base: baseLabel,
|
|
40
|
+
target: targetLabel,
|
|
41
|
+
baseHash,
|
|
42
|
+
targetHash,
|
|
43
|
+
},
|
|
44
|
+
stats,
|
|
45
|
+
diff: {
|
|
46
|
+
breaking,
|
|
47
|
+
warnings,
|
|
48
|
+
info,
|
|
49
|
+
all: filtered,
|
|
50
|
+
},
|
|
51
|
+
miracles: (0, miracles_1.buildMiracles)(entries, normalizedOld, normalizedNew),
|
|
52
|
+
};
|
|
53
|
+
return { report, ignored };
|
|
54
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SemanticDiffReport } from '../../core/semanticDiff/analyzeOpenApiDiff';
|
|
2
|
+
/**
|
|
3
|
+
* Builds markdown summary for CI logs.
|
|
4
|
+
*/
|
|
5
|
+
export declare function formatCiMarkdownSummary(report: SemanticDiffReport, reportPath: string): string;
|
|
6
|
+
//# sourceMappingURL=ciSummary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ciSummary.d.ts","sourceRoot":"","sources":["../../../src/cli/analyzeDiff/ciSummary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAEhF;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAc9F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatCiMarkdownSummary = formatCiMarkdownSummary;
|
|
4
|
+
/**
|
|
5
|
+
* Builds markdown summary for CI logs.
|
|
6
|
+
*/
|
|
7
|
+
function formatCiMarkdownSummary(report, reportPath) {
|
|
8
|
+
const reasons = report.recommendation.reasons.map(reason => `- \`${reason}\``).join('\n');
|
|
9
|
+
return [
|
|
10
|
+
'### OpenAPI Semantic Diff',
|
|
11
|
+
`- Report: \`${reportPath}\``,
|
|
12
|
+
`- Schema Version: \`${report.schemaVersion}\``,
|
|
13
|
+
`- Recommendation: \`${report.recommendation.semver}\` (confidence: \`${report.recommendation.confidence}\`)`,
|
|
14
|
+
`- Reason: ${report.recommendation.reason}`,
|
|
15
|
+
'- Reason Codes:',
|
|
16
|
+
reasons,
|
|
17
|
+
`- Summary: breaking=\`${report.summary.breaking}\`, nonBreaking=\`${report.summary.nonBreaking}\`, informational=\`${report.summary.informational}\``,
|
|
18
|
+
`- Governance: errors=\`${report.governance.summary.errors}\`, warnings=\`${report.governance.summary.warnings}\`, info=\`${report.governance.summary.info}\``,
|
|
19
|
+
].join('\n');
|
|
20
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Diff } from 'deep-diff';
|
|
2
|
+
import type { DiffAction, DiffEntry, JsonValue } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Проверяет, содержит ли путь сегменты, указывающие на полиморфную схему (oneOf/anyOf).
|
|
5
|
+
* @param segments сегменты json-path
|
|
6
|
+
* @returns true если встречены полиморфные сегменты
|
|
7
|
+
*/
|
|
8
|
+
export declare const hasPolymorphicSegment: (segments: (string | number)[]) => boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Классифицирует серьёзность изменения по действию (added/removed/changed).
|
|
11
|
+
* @param action действие изменения
|
|
12
|
+
* @returns уровень серьёзности
|
|
13
|
+
*/
|
|
14
|
+
export declare const classifySeverity: (action: DiffAction) => "info" | "warning" | "breaking";
|
|
15
|
+
/**
|
|
16
|
+
* Строит единичную запись отличия из набора сегментов пути и значений.
|
|
17
|
+
* Добавляет заметку при полиморфных изменениях.
|
|
18
|
+
* @param action действие изменения
|
|
19
|
+
* @param segments сегменты пути
|
|
20
|
+
* @param from предыдущее значение
|
|
21
|
+
* @param to новое значение
|
|
22
|
+
* @returns готовая запись DiffEntry
|
|
23
|
+
*/
|
|
24
|
+
export declare const buildDiffEntry: (action: DiffAction, segments: (string | number)[], from?: JsonValue, to?: JsonValue) => DiffEntry;
|
|
25
|
+
/**
|
|
26
|
+
* Пытается классифицировать тип изменения по структуре json-path и самой записи.
|
|
27
|
+
* Возвращает семантические коды типа изменения (METHOD_REMOVED, PROPERTY_ADDED и т.д.).
|
|
28
|
+
* @param entry запись diff
|
|
29
|
+
* @returns код типа изменения или undefined
|
|
30
|
+
*/
|
|
31
|
+
export declare const classifyDiffType: (entry: DiffEntry) => string | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Добавляет поле type к каждой записи diff, вычисленное через classifyDiffType, если отсутствует.
|
|
34
|
+
* @param entries массив записей diff
|
|
35
|
+
* @returns массив записей с полем type
|
|
36
|
+
*/
|
|
37
|
+
export declare const withDiffType: (entries: DiffEntry[]) => DiffEntry[];
|
|
38
|
+
/**
|
|
39
|
+
* Преобразует единичный объект отличия из deep-diff в один или несколько DiffEntry.
|
|
40
|
+
* Обрабатывает массивные/индексные отличия (kind 'A') рекурсивно.
|
|
41
|
+
* @param difference объект отличия от deep-diff
|
|
42
|
+
* @returns массив DiffEntry
|
|
43
|
+
*/
|
|
44
|
+
export declare const diffToEntries: (difference: Diff<unknown, unknown>) => DiffEntry[];
|
|
45
|
+
/**
|
|
46
|
+
* Собирает все записи отличий между двумя JSON-структурами: старой и новой.
|
|
47
|
+
* Выполняет глубокое сравнение и маппинг на DiffEntry.
|
|
48
|
+
* @param oldValue старая версия спецификации
|
|
49
|
+
* @param newValue новая версия спецификации
|
|
50
|
+
* @returns массив DiffEntry
|
|
51
|
+
*/
|
|
52
|
+
export declare const collectDiffEntries: (oldValue: JsonValue, newValue: JsonValue) => DiffEntry[];
|
|
53
|
+
export declare const normalizeForDiff: (value: JsonValue) => JsonValue;
|
|
54
|
+
//# sourceMappingURL=diffEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diffEngine.d.ts","sourceRoot":"","sources":["../../../src/cli/analyzeDiff/diffEngine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAoB,MAAM,WAAW,CAAC;AAMnD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,KAAG,OAErE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,UAAU,oCAUlD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,UAAU,EAAE,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAAE,OAAO,SAAS,EAAE,KAAK,SAAS,KAAG,SAoBpH,CAAC;AA0BF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,OAAO,SAAS,KAAG,MAAM,GAAG,SAwC5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,SAAS,SAAS,EAAE,KAAG,SAAS,EAK5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,YAAY,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,KAAG,SAAS,EA8B3E,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,SAAS,EAAE,UAAU,SAAS,KAAG,SAAS,EAMtF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,SAAS,KAAG,SAGnD,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
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.normalizeForDiff = exports.collectDiffEntries = exports.diffToEntries = exports.withDiffType = exports.classifyDiffType = exports.buildDiffEntry = exports.classifySeverity = exports.hasPolymorphicSegment = void 0;
|
|
7
|
+
const deep_diff_1 = require("deep-diff");
|
|
8
|
+
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
9
|
+
const jsonPath_1 = require("../../common/utils/jsonPath");
|
|
10
|
+
const normalizeObject_1 = require("../../common/utils/normalizeObject");
|
|
11
|
+
const miracles_1 = require("./miracles");
|
|
12
|
+
/**
|
|
13
|
+
* Проверяет, содержит ли путь сегменты, указывающие на полиморфную схему (oneOf/anyOf).
|
|
14
|
+
* @param segments сегменты json-path
|
|
15
|
+
* @returns true если встречены полиморфные сегменты
|
|
16
|
+
*/
|
|
17
|
+
const hasPolymorphicSegment = (segments) => {
|
|
18
|
+
return segments.includes('oneOf') || segments.includes('anyOf');
|
|
19
|
+
};
|
|
20
|
+
exports.hasPolymorphicSegment = hasPolymorphicSegment;
|
|
21
|
+
/**
|
|
22
|
+
* Классифицирует серьёзность изменения по действию (added/removed/changed).
|
|
23
|
+
* @param action действие изменения
|
|
24
|
+
* @returns уровень серьёзности
|
|
25
|
+
*/
|
|
26
|
+
const classifySeverity = (action) => {
|
|
27
|
+
if (action === 'removed') {
|
|
28
|
+
return 'breaking';
|
|
29
|
+
}
|
|
30
|
+
if (action === 'changed') {
|
|
31
|
+
return 'warning';
|
|
32
|
+
}
|
|
33
|
+
return 'info';
|
|
34
|
+
};
|
|
35
|
+
exports.classifySeverity = classifySeverity;
|
|
36
|
+
/**
|
|
37
|
+
* Строит единичную запись отличия из набора сегментов пути и значений.
|
|
38
|
+
* Добавляет заметку при полиморфных изменениях.
|
|
39
|
+
* @param action действие изменения
|
|
40
|
+
* @param segments сегменты пути
|
|
41
|
+
* @param from предыдущее значение
|
|
42
|
+
* @param to новое значение
|
|
43
|
+
* @returns готовая запись DiffEntry
|
|
44
|
+
*/
|
|
45
|
+
const buildDiffEntry = (action, segments, from, to) => {
|
|
46
|
+
const path = (0, jsonPath_1.toJsonPath)(segments);
|
|
47
|
+
if ((0, exports.hasPolymorphicSegment)(segments)) {
|
|
48
|
+
return {
|
|
49
|
+
action: 'changed',
|
|
50
|
+
path,
|
|
51
|
+
from,
|
|
52
|
+
to,
|
|
53
|
+
severity: 'warning',
|
|
54
|
+
note: 'Manual review required: polymorphic schema change',
|
|
55
|
+
type: 'POLYMORPHIC_CHANGE',
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
action,
|
|
60
|
+
path,
|
|
61
|
+
from,
|
|
62
|
+
to,
|
|
63
|
+
severity: (0, exports.classifySeverity)(action),
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
exports.buildDiffEntry = buildDiffEntry;
|
|
67
|
+
/**
|
|
68
|
+
* Возвращает имя корневой схемы из сегментов пути, если путь указывает на components.schemas или definitions.
|
|
69
|
+
* @param segments сегменты json-path
|
|
70
|
+
* @returns имя схемы или null
|
|
71
|
+
*/
|
|
72
|
+
const getSchemaRootName = (segments) => {
|
|
73
|
+
const s = segments.map(String);
|
|
74
|
+
if (s[0] === 'components' && s[1] === 'schemas')
|
|
75
|
+
return s[2] ?? null;
|
|
76
|
+
if (s[0] === 'definitions')
|
|
77
|
+
return s[1] ?? null;
|
|
78
|
+
return null;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Извлекает имя свойства из сегментов пути (ищет 'properties' и следующий сегмент).
|
|
82
|
+
* @param segments сегменты json-path
|
|
83
|
+
* @returns имя свойства или null
|
|
84
|
+
*/
|
|
85
|
+
const getPropertyNameFromSegments = (segments) => {
|
|
86
|
+
const s = segments.map(String);
|
|
87
|
+
const propsIndex = s.indexOf('properties');
|
|
88
|
+
if (propsIndex === -1)
|
|
89
|
+
return null;
|
|
90
|
+
return s[propsIndex + 1] ?? null;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Пытается классифицировать тип изменения по структуре json-path и самой записи.
|
|
94
|
+
* Возвращает семантические коды типа изменения (METHOD_REMOVED, PROPERTY_ADDED и т.д.).
|
|
95
|
+
* @param entry запись diff
|
|
96
|
+
* @returns код типа изменения или undefined
|
|
97
|
+
*/
|
|
98
|
+
const classifyDiffType = (entry) => {
|
|
99
|
+
const segments = (0, jsonPath_1.parseJsonPath)(entry.path);
|
|
100
|
+
const s = segments.map(String);
|
|
101
|
+
if (s[0] === 'paths') {
|
|
102
|
+
const hasMethod = s.length >= 3;
|
|
103
|
+
const isMethodRoot = s.length === 3;
|
|
104
|
+
if (hasMethod && isMethodRoot) {
|
|
105
|
+
if (entry.action === 'removed')
|
|
106
|
+
return 'METHOD_REMOVED';
|
|
107
|
+
if (entry.action === 'added')
|
|
108
|
+
return 'METHOD_ADDED';
|
|
109
|
+
return 'METHOD_CHANGED';
|
|
110
|
+
}
|
|
111
|
+
return 'PATH_CHANGED';
|
|
112
|
+
}
|
|
113
|
+
const schemaName = getSchemaRootName(s);
|
|
114
|
+
if (schemaName) {
|
|
115
|
+
const isSchemaRoot = s.length <= 3;
|
|
116
|
+
if (isSchemaRoot) {
|
|
117
|
+
if (entry.action === 'removed')
|
|
118
|
+
return 'SCHEMA_REMOVED';
|
|
119
|
+
if (entry.action === 'added')
|
|
120
|
+
return 'SCHEMA_ADDED';
|
|
121
|
+
return 'SCHEMA_CHANGED';
|
|
122
|
+
}
|
|
123
|
+
const propertyName = getPropertyNameFromSegments(s);
|
|
124
|
+
if (propertyName) {
|
|
125
|
+
const fromType = (0, miracles_1.getTypeSignature)((entry.from ?? {}));
|
|
126
|
+
const toType = (0, miracles_1.getTypeSignature)((entry.to ?? {}));
|
|
127
|
+
if (entry.action === 'changed' && fromType && toType && fromType !== toType) {
|
|
128
|
+
return 'TYPE_CHANGED';
|
|
129
|
+
}
|
|
130
|
+
if (entry.action === 'removed')
|
|
131
|
+
return 'PROPERTY_REMOVED';
|
|
132
|
+
if (entry.action === 'added')
|
|
133
|
+
return 'PROPERTY_ADDED';
|
|
134
|
+
return 'PROPERTY_CHANGED';
|
|
135
|
+
}
|
|
136
|
+
return 'SCHEMA_CHANGED';
|
|
137
|
+
}
|
|
138
|
+
return undefined;
|
|
139
|
+
};
|
|
140
|
+
exports.classifyDiffType = classifyDiffType;
|
|
141
|
+
/**
|
|
142
|
+
* Добавляет поле type к каждой записи diff, вычисленное через classifyDiffType, если отсутствует.
|
|
143
|
+
* @param entries массив записей diff
|
|
144
|
+
* @returns массив записей с полем type
|
|
145
|
+
*/
|
|
146
|
+
const withDiffType = (entries) => {
|
|
147
|
+
return entries.map(entry => ({
|
|
148
|
+
...entry,
|
|
149
|
+
type: entry.type ?? (0, exports.classifyDiffType)(entry),
|
|
150
|
+
}));
|
|
151
|
+
};
|
|
152
|
+
exports.withDiffType = withDiffType;
|
|
153
|
+
/**
|
|
154
|
+
* Преобразует единичный объект отличия из deep-diff в один или несколько DiffEntry.
|
|
155
|
+
* Обрабатывает массивные/индексные отличия (kind 'A') рекурсивно.
|
|
156
|
+
* @param difference объект отличия от deep-diff
|
|
157
|
+
* @returns массив DiffEntry
|
|
158
|
+
*/
|
|
159
|
+
const diffToEntries = (difference) => {
|
|
160
|
+
if (difference.kind === 'A') {
|
|
161
|
+
const segments = [...(difference.path ?? []), difference.index];
|
|
162
|
+
const item = difference.item;
|
|
163
|
+
if (item.kind === 'A') {
|
|
164
|
+
return (0, exports.diffToEntries)({ ...item, path: segments });
|
|
165
|
+
}
|
|
166
|
+
if (item.kind === 'N') {
|
|
167
|
+
return [(0, exports.buildDiffEntry)('added', segments, undefined, item.rhs)];
|
|
168
|
+
}
|
|
169
|
+
if (item.kind === 'D') {
|
|
170
|
+
return [(0, exports.buildDiffEntry)('removed', segments, item.lhs, undefined)];
|
|
171
|
+
}
|
|
172
|
+
if (item.kind === 'E') {
|
|
173
|
+
return [(0, exports.buildDiffEntry)('changed', segments, item.lhs, item.rhs)];
|
|
174
|
+
}
|
|
175
|
+
return [];
|
|
176
|
+
}
|
|
177
|
+
const segments = difference.path ?? [];
|
|
178
|
+
if (difference.kind === 'N') {
|
|
179
|
+
return [(0, exports.buildDiffEntry)('added', segments, undefined, difference.rhs)];
|
|
180
|
+
}
|
|
181
|
+
if (difference.kind === 'D') {
|
|
182
|
+
return [(0, exports.buildDiffEntry)('removed', segments, difference.lhs, undefined)];
|
|
183
|
+
}
|
|
184
|
+
if (difference.kind === 'E') {
|
|
185
|
+
return [(0, exports.buildDiffEntry)('changed', segments, difference.lhs, difference.rhs)];
|
|
186
|
+
}
|
|
187
|
+
return [];
|
|
188
|
+
};
|
|
189
|
+
exports.diffToEntries = diffToEntries;
|
|
190
|
+
/**
|
|
191
|
+
* Собирает все записи отличий между двумя JSON-структурами: старой и новой.
|
|
192
|
+
* Выполняет глубокое сравнение и маппинг на DiffEntry.
|
|
193
|
+
* @param oldValue старая версия спецификации
|
|
194
|
+
* @param newValue новая версия спецификации
|
|
195
|
+
* @returns массив DiffEntry
|
|
196
|
+
*/
|
|
197
|
+
const collectDiffEntries = (oldValue, newValue) => {
|
|
198
|
+
if ((0, fast_deep_equal_1.default)(oldValue, newValue)) {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
const differences = (0, deep_diff_1.diff)(oldValue, newValue) ?? [];
|
|
202
|
+
return differences.flatMap(exports.diffToEntries);
|
|
203
|
+
};
|
|
204
|
+
exports.collectDiffEntries = collectDiffEntries;
|
|
205
|
+
const normalizeForDiff = (value) => {
|
|
206
|
+
// обёртка вокруг normalizeObject, если нужно
|
|
207
|
+
return (0, normalizeObject_1.normalizeObject)(value);
|
|
208
|
+
};
|
|
209
|
+
exports.normalizeForDiff = normalizeForDiff;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DiffEntry, IgnoreRule } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Проверяет, активно ли правило игнорирования по полю `until`.
|
|
4
|
+
* @param rule правило игнорирования
|
|
5
|
+
* @returns true если правило активно или не содержит валидной даты
|
|
6
|
+
*/
|
|
7
|
+
export declare const isRuleActive: (rule: IgnoreRule) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Проверяет, соответствует ли запись diff правилу игнорирования.
|
|
10
|
+
* Совмещает полное совпадение пути, префикс и регулярные выражения.
|
|
11
|
+
* @param entry запись отличия
|
|
12
|
+
* @param rule правило игнорирования
|
|
13
|
+
* @returns true если правило применимо к записи
|
|
14
|
+
*/
|
|
15
|
+
export declare const matchesIgnoreRule: (entry: DiffEntry, rule: IgnoreRule) => boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Применяет набор правил игнорирования к массиву записей и возвращает отфильтрованные записи и число игнорированных.
|
|
18
|
+
* @param entries список записей diff
|
|
19
|
+
* @param rules список правил игнорирования
|
|
20
|
+
* @returns объект с полем filtered и числом ignored
|
|
21
|
+
*/
|
|
22
|
+
export declare const applyIgnoreRules: (entries: DiffEntry[], rules: IgnoreRule[]) => {
|
|
23
|
+
filtered: DiffEntry[];
|
|
24
|
+
ignored: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Извлекает правила игнорирования из загруженной конфигурации openapi.
|
|
28
|
+
* @param configData загруженные данные конфигурации
|
|
29
|
+
* @returns список правил ignore
|
|
30
|
+
*/
|
|
31
|
+
export declare const getIgnoreRulesFromConfig: (configData: Record<string, any> | Record<string, any>[] | null) => IgnoreRule[];
|
|
32
|
+
export declare const loadIgnoreRules: (openapiConfigPath?: string) => IgnoreRule[];
|
|
33
|
+
//# sourceMappingURL=ignoreRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignoreRules.d.ts","sourceRoot":"","sources":["../../../src/cli/analyzeDiff/ignoreRules.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,UAAU,KAAG,OAK/C,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,SAAS,EAAE,MAAM,UAAU,KAAG,OAkBtE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,SAAS,EAAE,EAAE,OAAO,UAAU,EAAE,KAAG;IAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAapH,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACjC,YAAY,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,KAC/D,UAAU,EAOZ,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,oBAAoB,MAAM,KAAG,UAAU,EAGtE,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadIgnoreRules = exports.getIgnoreRulesFromConfig = exports.applyIgnoreRules = exports.matchesIgnoreRule = exports.isRuleActive = void 0;
|
|
4
|
+
const Consts_1 = require("../../common/Consts");
|
|
5
|
+
const LoggerMessages_1 = require("../../common/LoggerMessages");
|
|
6
|
+
const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
|
|
7
|
+
/**
|
|
8
|
+
* Проверяет, активно ли правило игнорирования по полю `until`.
|
|
9
|
+
* @param rule правило игнорирования
|
|
10
|
+
* @returns true если правило активно или не содержит валидной даты
|
|
11
|
+
*/
|
|
12
|
+
const isRuleActive = (rule) => {
|
|
13
|
+
if (!rule.until)
|
|
14
|
+
return true;
|
|
15
|
+
const timestamp = Date.parse(rule.until);
|
|
16
|
+
if (Number.isNaN(timestamp))
|
|
17
|
+
return true;
|
|
18
|
+
return Date.now() <= timestamp;
|
|
19
|
+
};
|
|
20
|
+
exports.isRuleActive = isRuleActive;
|
|
21
|
+
/**
|
|
22
|
+
* Проверяет, соответствует ли запись diff правилу игнорирования.
|
|
23
|
+
* Совмещает полное совпадение пути, префикс и регулярные выражения.
|
|
24
|
+
* @param entry запись отличия
|
|
25
|
+
* @param rule правило игнорирования
|
|
26
|
+
* @returns true если правило применимо к записи
|
|
27
|
+
*/
|
|
28
|
+
const matchesIgnoreRule = (entry, rule) => {
|
|
29
|
+
if (!(0, exports.isRuleActive)(rule))
|
|
30
|
+
return false;
|
|
31
|
+
if (rule.path) {
|
|
32
|
+
if (entry.path === rule.path)
|
|
33
|
+
return true;
|
|
34
|
+
if (entry.path.startsWith(`${rule.path}.`))
|
|
35
|
+
return true;
|
|
36
|
+
if (entry.path.startsWith(`${rule.path}[`))
|
|
37
|
+
return true;
|
|
38
|
+
if (entry.path.startsWith(`${rule.path}/`))
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (rule.pattern) {
|
|
42
|
+
try {
|
|
43
|
+
const regex = new RegExp(rule.pattern);
|
|
44
|
+
return regex.test(entry.path);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
Consts_1.APP_LOGGER.warn(LoggerMessages_1.LOGGER_MESSAGES.ANALYZE_DIFF.INVALID_IGNORE_PATTERN(rule.pattern, String(err)));
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
exports.matchesIgnoreRule = matchesIgnoreRule;
|
|
54
|
+
/**
|
|
55
|
+
* Применяет набор правил игнорирования к массиву записей и возвращает отфильтрованные записи и число игнорированных.
|
|
56
|
+
* @param entries список записей diff
|
|
57
|
+
* @param rules список правил игнорирования
|
|
58
|
+
* @returns объект с полем filtered и числом ignored
|
|
59
|
+
*/
|
|
60
|
+
const applyIgnoreRules = (entries, rules) => {
|
|
61
|
+
if (!rules.length) {
|
|
62
|
+
return { filtered: entries, ignored: 0 };
|
|
63
|
+
}
|
|
64
|
+
let ignored = 0;
|
|
65
|
+
const filtered = entries.filter(entry => {
|
|
66
|
+
const shouldIgnore = rules.some(rule => (0, exports.matchesIgnoreRule)(entry, rule));
|
|
67
|
+
if (shouldIgnore)
|
|
68
|
+
ignored += 1;
|
|
69
|
+
return !shouldIgnore;
|
|
70
|
+
});
|
|
71
|
+
return { filtered, ignored };
|
|
72
|
+
};
|
|
73
|
+
exports.applyIgnoreRules = applyIgnoreRules;
|
|
74
|
+
/**
|
|
75
|
+
* Извлекает правила игнорирования из загруженной конфигурации openapi.
|
|
76
|
+
* @param configData загруженные данные конфигурации
|
|
77
|
+
* @returns список правил ignore
|
|
78
|
+
*/
|
|
79
|
+
const getIgnoreRulesFromConfig = (configData) => {
|
|
80
|
+
if (!configData)
|
|
81
|
+
return [];
|
|
82
|
+
if (Array.isArray(configData)) {
|
|
83
|
+
const withAnalyze = configData.find(item => item?.analyze?.ignore);
|
|
84
|
+
return withAnalyze?.analyze?.ignore ?? [];
|
|
85
|
+
}
|
|
86
|
+
return configData.analyze?.ignore ?? [];
|
|
87
|
+
};
|
|
88
|
+
exports.getIgnoreRulesFromConfig = getIgnoreRulesFromConfig;
|
|
89
|
+
const loadIgnoreRules = (openapiConfigPath) => {
|
|
90
|
+
const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(openapiConfigPath);
|
|
91
|
+
return (0, exports.getIgnoreRulesFromConfig)(configData);
|
|
92
|
+
};
|
|
93
|
+
exports.loadIgnoreRules = loadIgnoreRules;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SemanticDiffReport } from '../../core/semanticDiff/analyzeOpenApiDiff';
|
|
2
|
+
import { IgnoreRule } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Applies legacy analyze.ignore rules to semantic changes and returns ignored count.
|
|
5
|
+
*/
|
|
6
|
+
export declare function filterSemanticChangesByIgnoreRules(report: SemanticDiffReport, ignoreRules: IgnoreRule[]): {
|
|
7
|
+
report: SemanticDiffReport;
|
|
8
|
+
ignored: number;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=ignoreSemanticChanges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignoreSemanticChanges.d.ts","sourceRoot":"","sources":["../../../src/cli/analyzeDiff/ignoreSemanticChanges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAEhF,OAAO,EAAa,UAAU,EAAE,MAAM,SAAS,CAAC;AAqDhD;;GAEG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,kBAAkB,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG;IAAE,MAAM,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAmCzJ"}
|