ts-openapi-codegen 2.0.0-beta.9 → 2.1.0-beta.1
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 +177 -18
- package/README.rus.md +177 -21
- 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/validateAndMigrateConfigData.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +5 -0
- 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 +70 -22
- package/dist/cli/index.js +62 -5
- 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 +151 -39
- package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.js +6 -0
- 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 +19 -2
- 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 +136 -33
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +119 -45
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +20 -4
- 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 +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +77 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +41 -0
- 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 +326 -28
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +15 -17
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +52 -4
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +48 -7
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +6 -2
- 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 +6 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +6 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +6 -2
- 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 +6 -2
- 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 +40 -1
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +185 -0
- package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.js +20 -3
- package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +19 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +4 -0
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +68 -23
- package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.js +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +10 -0
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +34 -15
- 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 +67 -169
- 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 +54 -14
- 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 +127 -6
- package/dist/core/WriteClient.d.ts +12 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +83 -8
- package/dist/core/__tests__/WriteClient.test.js +6 -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/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getType.js +2 -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/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +2 -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 +4 -1
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts +6 -0
- package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts.map +1 -0
- package/dist/core/types/enums/EmptySchemaStrategy.enum.js +9 -0
- 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__/getRelativeModelPath.test.d.ts +2 -0
- package/dist/core/utils/__tests__/getRelativeModelPath.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/getRelativeModelPath.test.js +27 -0
- package/dist/core/utils/__tests__/modelHelpers.test.d.ts +2 -0
- package/dist/core/utils/__tests__/modelHelpers.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/modelHelpers.test.js +151 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts +2 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.js +67 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts +2 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.js +26 -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__/resolveRefPath.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.js +22 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.d.ts +2 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +122 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.js +20 -0
- package/dist/core/utils/__tests__/writeClientModels.test.js +50 -0
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -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/getOperationResponseCode.d.ts.map +1 -1
- package/dist/core/utils/getOperationResponseCode.js +10 -8
- package/dist/core/utils/getRelativeModelPath.d.ts +9 -0
- package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -0
- package/dist/core/utils/getRelativeModelPath.js +37 -0
- 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/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +37 -3
- package/dist/core/utils/postProcessModelImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessModelImports.js +14 -1
- package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessServiceImports.js +1 -2
- package/dist/core/utils/precompileTemplates.js +1 -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 +29 -1
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +48 -41
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefPath.js +1 -4
- 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 +6 -1
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +22 -3
- 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 +6 -1
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +16 -3
- 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/ApiError.js +1 -1
- package/dist/templatesCompiled/client/core/ApiRequestOptions.js +1 -1
- package/dist/templatesCompiled/client/core/ApiResult.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 +3 -3
- 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.d.ts +2 -0
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +13 -8
- 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 +3 -3
- package/dist/templatesCompiled/client/core/functions/catchErrors.js +1 -1
- package/dist/templatesCompiled/client/core/functions/isBinary.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +1 -1
- package/dist/templatesCompiled/client/core/node/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/node/request.js +3 -3
- package/dist/templatesCompiled/client/core/xhr/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/xhr/request.js +3 -3
- package/dist/templatesCompiled/client/core/xhr/sendRequest.js +4 -4
- package/dist/templatesCompiled/client/exportClient.d.ts +4 -0
- package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportClient.js +51 -13
- 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/exportSchema.d.ts +5 -1
- package/dist/templatesCompiled/client/exportSchema.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportSchema.js +37 -7
- package/dist/templatesCompiled/client/exportService.d.ts +9 -4
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +96 -37
- 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 +10 -7
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +54 -33
- 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/indexSimple.d.ts +1 -0
- package/dist/templatesCompiled/client/indexSimple.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexSimple.js +4 -1
- package/dist/templatesCompiled/client/joi/exportSchema.js +5 -5
- package/dist/templatesCompiled/client/joi/partials/joiSchema.js +7 -7
- package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +4 -4
- 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/joi/partials/joiSchemaInterface.d.ts +5 -3
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +39 -12
- 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 +21 -17
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +7 -7
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +5 -5
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +2 -2
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +5 -5
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +3 -1
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +45 -15
- 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/exportSchema.js +3 -3
- package/dist/templatesCompiled/client/yup/partials/yupSchema.js +7 -7
- package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +4 -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/yup/partials/yupSchemaInterface.d.ts +5 -3
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +39 -12
- package/dist/templatesCompiled/client/zod/exportSchema.js +3 -3
- package/dist/templatesCompiled/client/zod/partials/zodSchema.js +7 -7
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +5 -6
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +14 -28
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +3 -0
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +32 -8
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +3 -4
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +9 -23
- 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/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +4 -2
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +18 -7
- package/package.json +8 -6
- package/dist/common/defaultOptions.d.ts +0 -3
- package/dist/common/defaultOptions.d.ts.map +0 -1
- package/dist/common/defaultOptions.js +0 -28
- package/dist/core/utils/advancedDeduplicatePath.d.ts +0 -5
- package/dist/core/utils/advancedDeduplicatePath.d.ts.map +0 -1
- package/dist/core/utils/advancedDeduplicatePath.js +0 -29
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyDiffReportToClient = void 0;
|
|
4
|
+
const jsonPath_1 = require("../../common/utils/jsonPath");
|
|
5
|
+
const encode_1 = require("./encode");
|
|
6
|
+
const escapeName_1 = require("./escapeName");
|
|
7
|
+
const getClassName_1 = require("./getClassName");
|
|
8
|
+
const getComment_1 = require("./getComment");
|
|
9
|
+
const getModelNameWithPrefix_1 = require("./getModelNameWithPrefix");
|
|
10
|
+
const getOpenApiVersion_1 = require("./getOpenApiVersion");
|
|
11
|
+
const getOperationName_1 = require("./getOperationName");
|
|
12
|
+
const getOperationPath_1 = require("./getOperationPath");
|
|
13
|
+
const getServiceClassName_1 = require("./getServiceClassName");
|
|
14
|
+
const serviceHelpers_1 = require("./serviceHelpers");
|
|
15
|
+
const getSchemaDefinitions = (openApi, version) => {
|
|
16
|
+
if (version === getOpenApiVersion_1.OpenApiVersion.V3) {
|
|
17
|
+
const components = openApi?.components;
|
|
18
|
+
const schemas = components?.schemas;
|
|
19
|
+
return schemas ?? {};
|
|
20
|
+
}
|
|
21
|
+
const definitions = openApi?.definitions;
|
|
22
|
+
return definitions ?? {};
|
|
23
|
+
};
|
|
24
|
+
const buildSchemaNameMap = (openApi, version, prefix) => {
|
|
25
|
+
const definitions = getSchemaDefinitions(openApi, version);
|
|
26
|
+
const map = new Map();
|
|
27
|
+
Object.entries(definitions).forEach(([schemaName, schemaDef]) => {
|
|
28
|
+
const encodedName = (0, encode_1.encode)(schemaName);
|
|
29
|
+
const modelName = (0, getModelNameWithPrefix_1.getModelNameWithPrefix)(encodedName, schemaDef, prefix);
|
|
30
|
+
map.set(schemaName, modelName);
|
|
31
|
+
});
|
|
32
|
+
return map;
|
|
33
|
+
};
|
|
34
|
+
const getSchemaNameFromSegments = (segments, version) => {
|
|
35
|
+
if (version === getOpenApiVersion_1.OpenApiVersion.V3) {
|
|
36
|
+
return segments[0] === 'components' && segments[1] === 'schemas' ? segments[2] ?? null : null;
|
|
37
|
+
}
|
|
38
|
+
return segments[0] === 'definitions' ? segments[1] ?? null : null;
|
|
39
|
+
};
|
|
40
|
+
const describeSchemaType = (value) => {
|
|
41
|
+
if (typeof value === 'string') {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
if (value && typeof value === 'object') {
|
|
45
|
+
const record = value;
|
|
46
|
+
if (typeof record.$ref === 'string') {
|
|
47
|
+
return `ref:${record.$ref}`;
|
|
48
|
+
}
|
|
49
|
+
if (typeof record.type === 'string') {
|
|
50
|
+
return record.type;
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(record.oneOf)) {
|
|
53
|
+
return 'oneOf';
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(record.anyOf)) {
|
|
56
|
+
return 'anyOf';
|
|
57
|
+
}
|
|
58
|
+
if (Array.isArray(record.allOf)) {
|
|
59
|
+
return 'allOf';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
};
|
|
64
|
+
const normalizeScalarType = (value) => {
|
|
65
|
+
if (!value)
|
|
66
|
+
return undefined;
|
|
67
|
+
const normalized = value.toLowerCase();
|
|
68
|
+
if (normalized === 'int' || normalized === 'integer')
|
|
69
|
+
return 'number';
|
|
70
|
+
if (normalized === 'float' || normalized === 'double')
|
|
71
|
+
return 'number';
|
|
72
|
+
if (normalized === 'string')
|
|
73
|
+
return 'string';
|
|
74
|
+
if (normalized === 'number')
|
|
75
|
+
return 'number';
|
|
76
|
+
if (normalized === 'boolean')
|
|
77
|
+
return 'boolean';
|
|
78
|
+
return undefined;
|
|
79
|
+
};
|
|
80
|
+
const mergeOperationDiff = (existing, entry) => {
|
|
81
|
+
if (!existing) {
|
|
82
|
+
return {
|
|
83
|
+
action: entry.action,
|
|
84
|
+
path: entry.path,
|
|
85
|
+
severity: entry.severity,
|
|
86
|
+
from: entry.from,
|
|
87
|
+
to: entry.to,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const severityOrder = ['info', 'warning', 'breaking'];
|
|
91
|
+
const existingScore = severityOrder.indexOf(existing.severity);
|
|
92
|
+
const incomingScore = severityOrder.indexOf(entry.severity);
|
|
93
|
+
const severity = incomingScore > existingScore ? entry.severity : existing.severity;
|
|
94
|
+
return {
|
|
95
|
+
...existing,
|
|
96
|
+
severity,
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const buildOperationKey = (method, path) => `${method.toUpperCase()} ${(0, getOperationPath_1.getOperationPath)(path)}`;
|
|
100
|
+
const findOperationMatches = (entries) => {
|
|
101
|
+
const operationDiffs = new Map();
|
|
102
|
+
const removedOperations = [];
|
|
103
|
+
entries.forEach(entry => {
|
|
104
|
+
const segments = (0, jsonPath_1.parseJsonPath)(entry.path);
|
|
105
|
+
if (segments[0] !== 'paths' || segments.length < 3) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const rawPath = segments[1];
|
|
109
|
+
const method = segments[2];
|
|
110
|
+
const key = buildOperationKey(method, rawPath);
|
|
111
|
+
if (entry.action === 'removed' && segments.length === 3) {
|
|
112
|
+
removedOperations.push({
|
|
113
|
+
key,
|
|
114
|
+
path: rawPath,
|
|
115
|
+
method,
|
|
116
|
+
entry,
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
operationDiffs.set(key, mergeOperationDiff(operationDiffs.get(key), entry));
|
|
121
|
+
});
|
|
122
|
+
return { operationDiffs, removedOperations };
|
|
123
|
+
};
|
|
124
|
+
const createGhostOperation = (match, serviceName) => {
|
|
125
|
+
const from = (match.entry.from ?? {});
|
|
126
|
+
const operationId = typeof from.operationId === 'string' ? from.operationId : '';
|
|
127
|
+
const summary = typeof from.summary === 'string' ? from.summary : '';
|
|
128
|
+
const description = typeof from.description === 'string' ? from.description : '';
|
|
129
|
+
const operationNameFallback = `${match.method}${serviceName}`;
|
|
130
|
+
const operationName = (0, getOperationName_1.getOperationName)(operationId || operationNameFallback);
|
|
131
|
+
return {
|
|
132
|
+
service: serviceName,
|
|
133
|
+
name: operationName,
|
|
134
|
+
summary: (0, getComment_1.getComment)(summary),
|
|
135
|
+
description: (0, getComment_1.getComment)(description),
|
|
136
|
+
deprecated: true,
|
|
137
|
+
method: match.method.toUpperCase(),
|
|
138
|
+
path: (0, getOperationPath_1.getOperationPath)(match.path),
|
|
139
|
+
parameters: [],
|
|
140
|
+
parametersPath: [],
|
|
141
|
+
parametersQuery: [],
|
|
142
|
+
parametersForm: [],
|
|
143
|
+
parametersHeader: [],
|
|
144
|
+
parametersCookie: [],
|
|
145
|
+
parametersBody: null,
|
|
146
|
+
imports: [],
|
|
147
|
+
errors: [],
|
|
148
|
+
results: [],
|
|
149
|
+
responseHeader: null,
|
|
150
|
+
responseType: null,
|
|
151
|
+
diff: {
|
|
152
|
+
action: 'removed',
|
|
153
|
+
path: match.entry.path,
|
|
154
|
+
severity: match.entry.severity,
|
|
155
|
+
from: match.entry.from,
|
|
156
|
+
to: match.entry.to,
|
|
157
|
+
},
|
|
158
|
+
isGhost: true,
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
const resolveServiceFromMatch = (services, match) => {
|
|
162
|
+
const from = (match.entry.from ?? {});
|
|
163
|
+
const tagsValue = from.tags;
|
|
164
|
+
const tag = Array.isArray(tagsValue) ? String(tagsValue[0] ?? '') : '';
|
|
165
|
+
const preferredName = tag ? (0, getServiceClassName_1.getServiceClassName)(tag) : (0, getServiceClassName_1.getServiceClassName)('Default');
|
|
166
|
+
const preferredOrigin = tag ? (0, getClassName_1.getClassName)(tag) : (0, getClassName_1.getClassName)('Default');
|
|
167
|
+
const existingByName = services.get(preferredName);
|
|
168
|
+
if (existingByName) {
|
|
169
|
+
return existingByName;
|
|
170
|
+
}
|
|
171
|
+
const existingByOrigin = Array.from(services.values()).find(service => service.originName === preferredOrigin);
|
|
172
|
+
if (existingByOrigin) {
|
|
173
|
+
return existingByOrigin;
|
|
174
|
+
}
|
|
175
|
+
return (0, serviceHelpers_1.ensureService)(services, preferredName, preferredOrigin);
|
|
176
|
+
};
|
|
177
|
+
const applyOperationDiffs = (client, entries) => {
|
|
178
|
+
const { operationDiffs, removedOperations } = findOperationMatches(entries);
|
|
179
|
+
const servicesMap = new Map(client.services.map(service => [service.name, service]));
|
|
180
|
+
for (const service of servicesMap.values()) {
|
|
181
|
+
for (const operation of service.operations) {
|
|
182
|
+
const key = buildOperationKey(operation.method, operation.path);
|
|
183
|
+
const diff = operationDiffs.get(key);
|
|
184
|
+
if (diff) {
|
|
185
|
+
operation.diff = diff;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
for (const match of removedOperations) {
|
|
190
|
+
const service = resolveServiceFromMatch(servicesMap, match);
|
|
191
|
+
const ghostOperation = createGhostOperation(match, service.name);
|
|
192
|
+
const existingOperation = service.operations.find(op => buildOperationKey(op.method, op.path) === match.key);
|
|
193
|
+
if (!existingOperation) {
|
|
194
|
+
service.operations.push(ghostOperation);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
client.services = Array.from(servicesMap.values());
|
|
198
|
+
};
|
|
199
|
+
const applyModelDiffs = (client, entries, openApi, openApiVersion, prefix) => {
|
|
200
|
+
const schemaNameMap = buildSchemaNameMap(openApi, openApiVersion, prefix);
|
|
201
|
+
const modelsByName = new Map(client.models.map(model => [model.name, model]));
|
|
202
|
+
const ghostPropertyKeys = new Set();
|
|
203
|
+
entries.forEach(entry => {
|
|
204
|
+
const segments = (0, jsonPath_1.parseJsonPath)(entry.path);
|
|
205
|
+
const schemaName = getSchemaNameFromSegments(segments, openApiVersion);
|
|
206
|
+
if (!schemaName)
|
|
207
|
+
return;
|
|
208
|
+
const modelName = schemaNameMap.get(schemaName);
|
|
209
|
+
if (!modelName)
|
|
210
|
+
return;
|
|
211
|
+
const model = modelsByName.get(modelName);
|
|
212
|
+
if (!model)
|
|
213
|
+
return;
|
|
214
|
+
const propertiesIndex = segments.indexOf('properties');
|
|
215
|
+
if (propertiesIndex === -1 || propertiesIndex + 1 >= segments.length) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const rawPropertyName = segments[propertiesIndex + 1];
|
|
219
|
+
const propertyName = (0, escapeName_1.escapeName)(rawPropertyName);
|
|
220
|
+
if (entry.action === 'removed' && propertiesIndex + 1 === segments.length - 1) {
|
|
221
|
+
const key = `${modelName}:${propertyName}`;
|
|
222
|
+
if (ghostPropertyKeys.has(key))
|
|
223
|
+
return;
|
|
224
|
+
const exists = model.properties.some(prop => prop.name === propertyName);
|
|
225
|
+
if (!exists) {
|
|
226
|
+
const ghost = {
|
|
227
|
+
name: propertyName,
|
|
228
|
+
alias: '',
|
|
229
|
+
path: model.path,
|
|
230
|
+
export: 'generic',
|
|
231
|
+
type: 'unknown',
|
|
232
|
+
base: 'unknown',
|
|
233
|
+
template: null,
|
|
234
|
+
link: null,
|
|
235
|
+
description: null,
|
|
236
|
+
isDefinition: false,
|
|
237
|
+
isReadOnly: false,
|
|
238
|
+
isRequired: false,
|
|
239
|
+
isNullable: false,
|
|
240
|
+
imports: [],
|
|
241
|
+
enum: [],
|
|
242
|
+
enums: [],
|
|
243
|
+
properties: [],
|
|
244
|
+
diff: {
|
|
245
|
+
action: 'removed',
|
|
246
|
+
path: entry.path,
|
|
247
|
+
severity: entry.severity,
|
|
248
|
+
from: entry.from,
|
|
249
|
+
to: entry.to,
|
|
250
|
+
},
|
|
251
|
+
isGhost: true,
|
|
252
|
+
};
|
|
253
|
+
if (!model.ghostProperties) {
|
|
254
|
+
model.ghostProperties = [];
|
|
255
|
+
}
|
|
256
|
+
model.ghostProperties.push(ghost);
|
|
257
|
+
ghostPropertyKeys.add(key);
|
|
258
|
+
}
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (entry.action === 'changed' && segments[segments.length - 1] === 'type') {
|
|
262
|
+
const property = model.properties.find(prop => prop.name === propertyName);
|
|
263
|
+
if (!property)
|
|
264
|
+
return;
|
|
265
|
+
const previousType = describeSchemaType(entry.from);
|
|
266
|
+
const currentTypeRaw = typeof entry.to === 'string' ? entry.to : describeSchemaType(entry.to);
|
|
267
|
+
const currentType = normalizeScalarType(currentTypeRaw);
|
|
268
|
+
const previousScalar = normalizeScalarType(previousType);
|
|
269
|
+
property.diff = {
|
|
270
|
+
action: entry.action,
|
|
271
|
+
path: entry.path,
|
|
272
|
+
severity: entry.severity,
|
|
273
|
+
from: entry.from,
|
|
274
|
+
to: entry.to,
|
|
275
|
+
previousType,
|
|
276
|
+
};
|
|
277
|
+
if (previousScalar && currentType && previousScalar !== currentType) {
|
|
278
|
+
property.needsCoercion = true;
|
|
279
|
+
property.coercionFrom = previousScalar;
|
|
280
|
+
property.coercionTo = currentType;
|
|
281
|
+
model.hasCoercion = true;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
const applyMiracleTypeCoercions = (client, confirmedMiracles, entries) => {
|
|
287
|
+
if (!confirmedMiracles.length)
|
|
288
|
+
return;
|
|
289
|
+
const modelsByName = new Map(client.models.map(model => [model.name, model]));
|
|
290
|
+
for (const miracle of confirmedMiracles) {
|
|
291
|
+
if (miracle.type !== 'TYPE_COERCION')
|
|
292
|
+
continue;
|
|
293
|
+
if (!miracle.modelName)
|
|
294
|
+
continue;
|
|
295
|
+
const model = modelsByName.get(miracle.modelName);
|
|
296
|
+
if (!model)
|
|
297
|
+
continue;
|
|
298
|
+
const rawProperty = miracle.newProperty ?? miracle.oldProperty;
|
|
299
|
+
if (!rawProperty)
|
|
300
|
+
continue;
|
|
301
|
+
const propertyName = (0, escapeName_1.escapeName)(rawProperty);
|
|
302
|
+
const property = model.properties.find(prop => prop.name === propertyName);
|
|
303
|
+
if (!property)
|
|
304
|
+
continue;
|
|
305
|
+
property.needsCoercion = true;
|
|
306
|
+
model.hasCoercion = true;
|
|
307
|
+
if (!miracle.newPath)
|
|
308
|
+
continue;
|
|
309
|
+
const typePath = `${miracle.newPath}.type`;
|
|
310
|
+
const typeEntry = entries.find(entry => entry.action === 'changed' && entry.path === typePath);
|
|
311
|
+
if (!typeEntry)
|
|
312
|
+
continue;
|
|
313
|
+
const previousType = describeSchemaType(typeEntry.from);
|
|
314
|
+
const currentTypeRaw = typeof typeEntry.to === 'string' ? typeEntry.to : describeSchemaType(typeEntry.to);
|
|
315
|
+
const currentType = normalizeScalarType(currentTypeRaw);
|
|
316
|
+
const previousScalar = normalizeScalarType(previousType);
|
|
317
|
+
if (previousScalar && currentType && previousScalar !== currentType) {
|
|
318
|
+
property.coercionFrom = previousScalar;
|
|
319
|
+
property.coercionTo = currentType;
|
|
320
|
+
if (!property.diff) {
|
|
321
|
+
property.diff = {
|
|
322
|
+
action: typeEntry.action,
|
|
323
|
+
path: typeEntry.path,
|
|
324
|
+
severity: typeEntry.severity,
|
|
325
|
+
from: typeEntry.from,
|
|
326
|
+
to: typeEntry.to,
|
|
327
|
+
previousType,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
const applyDiffReportToClient = ({ client, openApi, openApiVersion, diffReport, prefix }) => {
|
|
334
|
+
const entries = diffReport?.diff?.all ?? [];
|
|
335
|
+
const schemaNameMap = buildSchemaNameMap(openApi, openApiVersion, prefix);
|
|
336
|
+
const confirmedMiracles = (diffReport?.miracles ?? [])
|
|
337
|
+
.filter(miracle => miracle.status === 'confirmed' || miracle.confidence === 1)
|
|
338
|
+
.map(miracle => {
|
|
339
|
+
const oldSegments = (0, jsonPath_1.parseJsonPath)(miracle.oldPath);
|
|
340
|
+
const newSegments = (0, jsonPath_1.parseJsonPath)(miracle.newPath);
|
|
341
|
+
const oldSchema = getSchemaNameFromSegments(oldSegments, openApiVersion);
|
|
342
|
+
const newSchema = getSchemaNameFromSegments(newSegments, openApiVersion);
|
|
343
|
+
const schemaName = oldSchema || newSchema;
|
|
344
|
+
const modelName = schemaName ? schemaNameMap.get(schemaName) : undefined;
|
|
345
|
+
const oldPropIndex = oldSegments.indexOf('properties');
|
|
346
|
+
const newPropIndex = newSegments.indexOf('properties');
|
|
347
|
+
const oldProperty = oldPropIndex !== -1 ? oldSegments[oldPropIndex + 1] : undefined;
|
|
348
|
+
const newProperty = newPropIndex !== -1 ? newSegments[newPropIndex + 1] : undefined;
|
|
349
|
+
return {
|
|
350
|
+
...miracle,
|
|
351
|
+
modelName,
|
|
352
|
+
oldProperty,
|
|
353
|
+
newProperty,
|
|
354
|
+
};
|
|
355
|
+
});
|
|
356
|
+
if (confirmedMiracles.length > 0) {
|
|
357
|
+
client.miracles = confirmedMiracles;
|
|
358
|
+
}
|
|
359
|
+
applyMiracleTypeCoercions(client, confirmedMiracles, entries);
|
|
360
|
+
if (entries.length === 0) {
|
|
361
|
+
return client;
|
|
362
|
+
}
|
|
363
|
+
applyModelDiffs(client, entries, openApi, openApiVersion, prefix);
|
|
364
|
+
applyOperationDiffs(client, entries);
|
|
365
|
+
return client;
|
|
366
|
+
};
|
|
367
|
+
exports.applyDiffReportToClient = applyDiffReportToClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMappedType.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getMappedType.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getMappedType.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getMappedType.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getMappedType = getMappedType;
|
|
4
4
|
exports.hasMappedType = hasMappedType;
|
|
5
5
|
const TYPE_MAPPINGS = new Map([
|
|
6
|
+
['Blob', 'Blob'],
|
|
6
7
|
['File', 'File'],
|
|
7
8
|
['file', 'File'],
|
|
9
|
+
['binary', 'Blob'],
|
|
8
10
|
['any', 'any'],
|
|
9
11
|
['object', 'any'],
|
|
10
12
|
['array', 'any[]'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOperationResponseCode.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOperationResponseCode.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"getOperationResponseCode.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOperationResponseCode.ts"],"names":[],"mappings":"AAAA,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAmBjF"}
|
|
@@ -2,16 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOperationResponseCode = getOperationResponseCode;
|
|
4
4
|
function getOperationResponseCode(value) {
|
|
5
|
-
//
|
|
5
|
+
// "default" is not an explicit HTTP status code and should not be coerced.
|
|
6
6
|
if (value === 'default') {
|
|
7
|
-
return
|
|
7
|
+
return null;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const normalizedValue = value.trim();
|
|
10
|
+
// OpenAPI supports exact response codes (e.g. "200")
|
|
11
|
+
if (/^\d{3}$/.test(normalizedValue)) {
|
|
12
|
+
return Number(normalizedValue);
|
|
13
|
+
}
|
|
14
|
+
// OpenAPI supports response code ranges (e.g. "2XX")
|
|
15
|
+
if (/^[1-5]XX$/i.test(normalizedValue)) {
|
|
16
|
+
return Number(normalizedValue[0]) * 100;
|
|
15
17
|
}
|
|
16
18
|
return null;
|
|
17
19
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The function calculates the relative path to the model.
|
|
3
|
+
* Removes the transition to the directory with a level above.
|
|
4
|
+
* @param folderPath Root folder.
|
|
5
|
+
* @param relativeModelPath Relative path to the model.
|
|
6
|
+
* @returns Correct relative model path.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getRelativeModelPath(folderPath: string | undefined, relativeModelPath: string): string;
|
|
9
|
+
//# sourceMappingURL=getRelativeModelPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRelativeModelPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getRelativeModelPath.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,iBAAiB,EAAE,MAAM,UA2B7F"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRelativeModelPath = getRelativeModelPath;
|
|
4
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
5
|
+
const getTypeName_1 = require("./getTypeName");
|
|
6
|
+
const isInsideDirectory_1 = require("./isInsideDirectory");
|
|
7
|
+
/**
|
|
8
|
+
* The function calculates the relative path to the model.
|
|
9
|
+
* Removes the transition to the directory with a level above.
|
|
10
|
+
* @param folderPath Root folder.
|
|
11
|
+
* @param relativeModelPath Relative path to the model.
|
|
12
|
+
* @returns Correct relative model path.
|
|
13
|
+
*/
|
|
14
|
+
function getRelativeModelPath(folderPath, relativeModelPath) {
|
|
15
|
+
if (!folderPath) {
|
|
16
|
+
return relativeModelPath;
|
|
17
|
+
}
|
|
18
|
+
const pathSep = '/';
|
|
19
|
+
let mappedPaths = '';
|
|
20
|
+
let modelPath = relativeModelPath;
|
|
21
|
+
// If absolute path (filesystem or URL-like), collapse to type name only
|
|
22
|
+
if (modelPath.startsWith('/')) {
|
|
23
|
+
return (0, getTypeName_1.getTypeName)(modelPath);
|
|
24
|
+
}
|
|
25
|
+
if (modelPath.startsWith('../')) {
|
|
26
|
+
const pathArray = modelPath.split(pathSep).filter(Boolean);
|
|
27
|
+
while (pathArray[0] === '..') {
|
|
28
|
+
pathArray.shift();
|
|
29
|
+
}
|
|
30
|
+
modelPath = pathArray.join(pathSep);
|
|
31
|
+
}
|
|
32
|
+
const resolvedPath = (0, pathHelpers_1.resolveHelper)(folderPath, modelPath);
|
|
33
|
+
if ((0, isInsideDirectory_1.isInsideDirectory)(resolvedPath, folderPath)) {
|
|
34
|
+
mappedPaths = modelPath;
|
|
35
|
+
}
|
|
36
|
+
return mappedPaths;
|
|
37
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Logger } from '../../common/Logger';
|
|
2
|
+
import type { DiffInfo } from '../types/shared/DiffInfo.model';
|
|
3
|
+
import type { MiracleEntry } from '../types/shared/Miracle.model';
|
|
4
|
+
export interface DiffReportEntry extends DiffInfo {
|
|
5
|
+
action: DiffInfo['action'];
|
|
6
|
+
}
|
|
7
|
+
export interface DiffReport {
|
|
8
|
+
version?: string;
|
|
9
|
+
timestamp?: string;
|
|
10
|
+
metadata?: {
|
|
11
|
+
base?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
baseHash?: string;
|
|
14
|
+
targetHash?: string;
|
|
15
|
+
};
|
|
16
|
+
stats?: {
|
|
17
|
+
totalChanges?: number;
|
|
18
|
+
added?: number;
|
|
19
|
+
removed?: number;
|
|
20
|
+
changed?: number;
|
|
21
|
+
ignored?: number;
|
|
22
|
+
};
|
|
23
|
+
diff?: {
|
|
24
|
+
breaking?: DiffReportEntry[];
|
|
25
|
+
warnings?: DiffReportEntry[];
|
|
26
|
+
info?: DiffReportEntry[];
|
|
27
|
+
all?: DiffReportEntry[];
|
|
28
|
+
};
|
|
29
|
+
miracles?: MiracleEntry[];
|
|
30
|
+
}
|
|
31
|
+
type LoadDiffReportParams = {
|
|
32
|
+
useHistory?: boolean;
|
|
33
|
+
diffReport?: string;
|
|
34
|
+
inputPath?: string;
|
|
35
|
+
logger: Logger;
|
|
36
|
+
};
|
|
37
|
+
export declare const loadDiffReport: ({ useHistory, diffReport, inputPath, logger }: LoadDiffReportParams) => DiffReport | null;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=loadDiffReport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadDiffReport.d.ts","sourceRoot":"","sources":["../../../src/core/utils/loadDiffReport.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC7C,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,KAAK,CAAC,EAAE;QACJ,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,IAAI,CAAC,EAAE;QACH,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;QAC7B,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;QAC7B,IAAI,CAAC,EAAE,eAAe,EAAE,CAAC;QACzB,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC;KAC3B,CAAC;IACF,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC7B;AAED,KAAK,oBAAoB,GAAG;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAClB,CAAC;AAaF,eAAO,MAAM,cAAc,GAAI,+CAA+C,oBAAoB,KAAG,UAAU,GAAG,IA8BjH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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.loadDiffReport = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const Consts_1 = require("../../common/Consts");
|
|
9
|
+
const isFreshEnough = (reportPath, inputPath) => {
|
|
10
|
+
if (!inputPath)
|
|
11
|
+
return true;
|
|
12
|
+
try {
|
|
13
|
+
const reportStat = fs_1.default.statSync(reportPath);
|
|
14
|
+
const inputStat = fs_1.default.statSync(inputPath);
|
|
15
|
+
return reportStat.mtimeMs >= inputStat.mtimeMs;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const loadDiffReport = ({ useHistory, diffReport, inputPath, logger }) => {
|
|
22
|
+
const shouldLoad = useHistory || !!diffReport;
|
|
23
|
+
if (!shouldLoad)
|
|
24
|
+
return null;
|
|
25
|
+
const reportPath = diffReport || Consts_1.DEFAULT_ANALYZE_DIFF_REPORT_PATH;
|
|
26
|
+
if (!fs_1.default.existsSync(reportPath)) {
|
|
27
|
+
logger.info(`[openapi-codegen] Diff report not found at "${reportPath}". Skipping history annotations.`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
if (!isFreshEnough(reportPath, inputPath)) {
|
|
31
|
+
logger.warn(`[openapi-codegen] Diff report "${reportPath}" is older than the input spec. Skipping history annotations.`);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const raw = fs_1.default.readFileSync(reportPath, 'utf-8');
|
|
36
|
+
const parsed = JSON.parse(raw);
|
|
37
|
+
const hasDiffEntries = !!parsed?.diff?.all?.length;
|
|
38
|
+
const hasMiracles = !!parsed?.miracles?.length;
|
|
39
|
+
if (!hasDiffEntries && !hasMiracles) {
|
|
40
|
+
logger.info(`[openapi-codegen] Diff report "${reportPath}" has no entries. Skipping history annotations.`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
+
logger.warn(`[openapi-codegen] Failed to read diff report "${reportPath}": ${message}`);
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.loadDiffReport = loadDiffReport;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/modelHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modelHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/modelHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAkBjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,KAAK,EAAE,CA4ErF"}
|
|
@@ -52,8 +52,36 @@ function setDuplicateModelAliases(models) {
|
|
|
52
52
|
* @returns the same array of models (modified)
|
|
53
53
|
*/
|
|
54
54
|
function resolveModelImports(models, outputModelsDir) {
|
|
55
|
+
const normalizeImportPath = (value) => (value.startsWith('./') ? value.slice(2) : value);
|
|
56
|
+
const applyAliasToModel = (model, imprt) => {
|
|
57
|
+
const modelPath = normalizeImportPath(model.path);
|
|
58
|
+
const importPath = normalizeImportPath(imprt.path);
|
|
59
|
+
if (modelPath === importPath && model.type === imprt.name && imprt.alias) {
|
|
60
|
+
model.alias = imprt.alias;
|
|
61
|
+
model.base = imprt.alias;
|
|
62
|
+
model.type = imprt.alias;
|
|
63
|
+
}
|
|
64
|
+
if (imprt.alias && model.imports?.some(item => normalizeImportPath(item.path) === importPath && item.name === imprt.name)) {
|
|
65
|
+
if (model.base === imprt.name) {
|
|
66
|
+
model.base = imprt.alias;
|
|
67
|
+
}
|
|
68
|
+
if (model.type === imprt.name) {
|
|
69
|
+
model.type = imprt.alias;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (model.link) {
|
|
73
|
+
applyAliasToModel(model.link, imprt);
|
|
74
|
+
}
|
|
75
|
+
if (model.properties?.length) {
|
|
76
|
+
model.properties.forEach(child => applyAliasToModel(child, imprt));
|
|
77
|
+
}
|
|
78
|
+
if (model.enums?.length) {
|
|
79
|
+
model.enums.forEach(child => applyAliasToModel(child, imprt));
|
|
80
|
+
}
|
|
81
|
+
};
|
|
55
82
|
models.forEach(model => {
|
|
56
|
-
|
|
83
|
+
const importsWithSourcePath = model.imports.map(imprt => {
|
|
84
|
+
const sourcePath = imprt.path;
|
|
57
85
|
const importModel = models.find(value => {
|
|
58
86
|
const normalizedPath = !value.path.startsWith('./') ? `./${value.path}` : value.path;
|
|
59
87
|
return normalizedPath === imprt.path && value.name === imprt.name;
|
|
@@ -69,16 +97,22 @@ function resolveModelImports(models, outputModelsDir) {
|
|
|
69
97
|
importPath = `./${file}`;
|
|
70
98
|
}
|
|
71
99
|
else if (relativePath.startsWith('./')) {
|
|
72
|
-
importPath = `${relativePath}
|
|
100
|
+
importPath = `${relativePath}/${file}`;
|
|
73
101
|
}
|
|
74
102
|
else {
|
|
75
103
|
importPath = `${relativePath}/${file}`;
|
|
76
104
|
}
|
|
77
105
|
}
|
|
78
|
-
|
|
106
|
+
const mappedImport = Object.assign(imprt, {
|
|
79
107
|
alias: importAlias,
|
|
80
108
|
path: importPath,
|
|
81
109
|
});
|
|
110
|
+
return { mappedImport, sourcePath };
|
|
111
|
+
});
|
|
112
|
+
model.imports = importsWithSourcePath.map(item => item.mappedImport);
|
|
113
|
+
importsWithSourcePath.forEach(item => {
|
|
114
|
+
applyAliasToModel(model, item.mappedImport);
|
|
115
|
+
applyAliasToModel(model, Object.assign({}, item.mappedImport, { path: item.sourcePath }));
|
|
82
116
|
});
|
|
83
117
|
});
|
|
84
118
|
return models;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postProcessModelImports.d.ts","sourceRoot":"","sources":["../../../src/core/utils/postProcessModelImports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postProcessModelImports.d.ts","sourceRoot":"","sources":["../../../src/core/utils/postProcessModelImports.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAQzD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,CAY9D"}
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.postProcessModelImports = postProcessModelImports;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const sort_1 = require("./sort");
|
|
5
9
|
const unique_1 = require("./unique");
|
|
10
|
+
function normalizePath(value) {
|
|
11
|
+
return value.startsWith('./') ? value.slice(2) : value;
|
|
12
|
+
}
|
|
6
13
|
/**
|
|
7
14
|
* Set unique imports, sorted by name
|
|
8
15
|
* @param model The model that is post-processed
|
|
9
16
|
*/
|
|
10
17
|
function postProcessModelImports(model) {
|
|
18
|
+
const currentModelPath = normalizePath(model.path);
|
|
19
|
+
const currentModelDir = path_1.default.posix.dirname(currentModelPath);
|
|
11
20
|
return model?.imports
|
|
12
21
|
?.filter(unique_1.unique)
|
|
13
22
|
?.sort(sort_1.sort)
|
|
14
|
-
?.filter(item =>
|
|
23
|
+
?.filter(item => {
|
|
24
|
+
const importPath = normalizePath(item.path);
|
|
25
|
+
const resolvedFromCurrentModel = path_1.default.posix.normalize(path_1.default.posix.join(currentModelDir, importPath));
|
|
26
|
+
return resolvedFromCurrentModel !== currentModelPath;
|
|
27
|
+
});
|
|
15
28
|
}
|