ts-openapi-codegen 2.1.0-beta.7 → 2.1.0-beta.9
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 +7 -0
- package/README.rus.md +7 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.js +31 -24
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.js +47 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.js +8 -7
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.js +8 -7
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts +14 -2
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/analyzeDiff.js +56 -13
- package/dist/cli/analyzeDiff/ciSummary.d.ts +6 -3
- package/dist/cli/analyzeDiff/ciSummary.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/ciSummary.js +10 -6
- package/dist/cli/analyzeDiff/ignoreRules.d.ts +0 -6
- package/dist/cli/analyzeDiff/ignoreRules.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/ignoreRules.js +2 -3
- package/dist/cli/analyzeDiff/report.d.ts +0 -1
- package/dist/cli/analyzeDiff/report.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/report.js +1 -3
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts +2 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/writeLegacyReport.js +2 -0
- package/dist/cli/analyzeUsage/analyzeUsage.d.ts +2 -2
- package/dist/cli/analyzeUsage/analyzeUsage.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/analyzeUsage.js +10 -12
- package/dist/cli/analyzeUsage/core/ProjectContext.d.ts +1 -1
- package/dist/cli/analyzeUsage/core/ProjectContext.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/core/ProjectContext.js +5 -10
- package/dist/cli/analyzeUsage/core/Scanner.d.ts +8 -0
- package/dist/cli/analyzeUsage/core/Scanner.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/core/Scanner.js +10 -0
- package/dist/cli/analyzeUsage/rules/ClientRule.d.ts +10 -2
- package/dist/cli/analyzeUsage/rules/ClientRule.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/rules/ClientRule.js +29 -21
- package/dist/cli/analyzeUsage/rules/CoverageRule.d.ts +2 -2
- package/dist/cli/analyzeUsage/rules/CoverageRule.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/rules/CoverageRule.js +16 -24
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.js +4 -1
- package/dist/cli/analyzeUsage/rules/ImportRule.d.ts +2 -2
- package/dist/cli/analyzeUsage/rules/ImportRule.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/rules/ImportRule.js +9 -11
- package/dist/cli/analyzeUsage/rules/ModelRule.d.ts +2 -2
- package/dist/cli/analyzeUsage/rules/ModelRule.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/rules/ModelRule.js +4 -8
- package/dist/cli/analyzeUsage/rules/SchemaRule.d.ts +2 -2
- package/dist/cli/analyzeUsage/rules/SchemaRule.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/rules/SchemaRule.js +8 -10
- package/dist/cli/analyzeUsage/rules/ServiceRule.d.ts +10 -2
- package/dist/cli/analyzeUsage/rules/ServiceRule.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/rules/ServiceRule.js +27 -23
- package/dist/cli/analyzeUsage/types.d.ts +4 -4
- package/dist/cli/analyzeUsage/types.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/utils/fuzzy.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/utils/report.d.ts +1 -1
- package/dist/cli/analyzeUsage/utils/report.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/utils/report.js +8 -8
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.js +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +9 -1
- package/dist/cli/index.js +3 -2
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.js +2 -8
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/cli/interactive/constants.d.ts +0 -4
- package/dist/cli/interactive/constants.d.ts.map +1 -1
- package/dist/cli/interactive/constants.js +1 -5
- package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/formatDiff.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.js +5 -12
- package/dist/cli/schemas/analyzeUsage.d.ts.map +1 -1
- package/dist/cli/schemas/analyzeUsage.js +4 -1
- package/dist/cli/schemas/generate.d.ts +3 -2
- package/dist/cli/schemas/generate.d.ts.map +1 -1
- package/dist/cli/schemas/generate.js +3 -2
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +1 -2
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +1 -1
- package/dist/common/LoggerMessages.d.ts +15 -3
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +18 -7
- package/dist/common/TEslintFixOptions.d.ts +20 -0
- package/dist/common/TEslintFixOptions.d.ts.map +1 -0
- package/dist/common/TEslintFixOptions.js +15 -0
- package/dist/common/TRawOptions.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +2 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.js +1 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts +3 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.js +10 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +4 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +7 -1
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +4 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +2 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +2 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.js +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +3 -2
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +4 -16
- package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.js +1 -1
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.js +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +1 -3
- package/dist/common/VersionedSchema/Utils/getLatestVersionFromMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +1 -3
- package/dist/common/VersionedSchema/Utils/replaceInvalidKeysWithMappedNames.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/replaceInvalidKeysWithMappedNames.js +1 -1
- package/dist/common/VersionedSchema/Utils/validateAndSuggestKeyCorrections.d.ts.map +1 -1
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts +1 -1
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts.map +1 -1
- package/dist/common/utils/__tests__/eslintFix.test.js +25 -67
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.d.ts +2 -0
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.js +28 -0
- package/dist/common/utils/__tests__/format.test.js +26 -17
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.d.ts +2 -0
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.js +78 -0
- package/dist/common/utils/codegenTempDir.d.ts +20 -0
- package/dist/common/utils/codegenTempDir.d.ts.map +1 -0
- package/dist/common/utils/codegenTempDir.js +42 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +3 -8
- package/dist/common/utils/eslintFix.d.ts +48 -4
- package/dist/common/utils/eslintFix.d.ts.map +1 -1
- package/dist/common/utils/eslintFix.js +121 -15
- package/dist/common/utils/format.d.ts +1 -1
- package/dist/common/utils/format.d.ts.map +1 -1
- package/dist/common/utils/format.js +23 -11
- package/dist/common/utils/jsonPath.d.ts.map +1 -1
- package/dist/common/utils/prepareTempEslintConfig.d.ts +18 -0
- package/dist/common/utils/prepareTempEslintConfig.d.ts.map +1 -0
- package/dist/common/utils/prepareTempEslintConfig.js +55 -0
- package/dist/common/utils/prepareTempTsConfig.d.ts +23 -0
- package/dist/common/utils/prepareTempTsConfig.d.ts.map +1 -0
- package/dist/common/utils/prepareTempTsConfig.js +105 -0
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +2 -6
- package/dist/core/OpenApiClient.d.ts +15 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +68 -10
- package/dist/core/WriteClient.d.ts +73 -17
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +72 -18
- package/dist/core/__tests__/WriteClient.test.js +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +1 -3
- package/dist/core/api/v2/parser/getServiceName.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameters.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +1 -3
- package/dist/core/api/v3/parser/getServiceName.d.ts +1 -1
- package/dist/core/governance/evaluateGovernanceRules.d.ts.map +1 -1
- package/dist/core/governance/evaluateGovernanceRules.js +1 -3
- package/dist/core/governance/loadGovernanceConfig.d.ts.map +1 -1
- package/dist/core/governance/loadGovernanceConfig.js +2 -4
- package/dist/core/plugins/GeneratorPlugin.model.d.ts.map +1 -1
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts.map +1 -1
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.js +79 -21
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.js +20 -1
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts +58 -6
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts.map +1 -1
- package/dist/core/semanticDiff/analyzeOpenApiDiff.js +47 -19
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts +9 -1
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts.map +1 -1
- package/dist/core/semanticDiff/semanticDiffReportSchema.js +137 -53
- package/dist/core/strict/validateOpenApiStrict.d.ts.map +1 -1
- package/dist/core/types/Consts.js +1 -1
- package/dist/core/types/DiffReport.model.d.ts +101 -0
- package/dist/core/types/DiffReport.model.d.ts.map +1 -0
- package/dist/core/types/DiffReport.model.js +5 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts +3 -3
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/ExportedModel.model.d.ts +1 -1
- package/dist/core/types/base/ExportedModel.model.d.ts.map +1 -1
- package/dist/core/types/base/ExportedService.model.d.ts.map +1 -1
- package/dist/core/types/base/OutputPaths.model.d.ts.map +1 -1
- package/dist/core/types/base/PrefixArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/PropertyGroup.model.d.ts +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/shared/Model.model.d.ts +36 -0
- package/dist/core/types/shared/Model.model.d.ts.map +1 -1
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.js +182 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.d.ts +2 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.js +77 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.d.ts +2 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.js +159 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.js +131 -0
- package/dist/core/utils/__tests__/modelHelpers.test.js +27 -9
- package/dist/core/utils/__tests__/postProcessModelImports.test.js +1 -4
- package/dist/core/utils/__tests__/postProcessServiceImports.test.js +1 -4
- package/dist/core/utils/__tests__/prepareDtoModels.test.js +74 -2
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +27 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.js +111 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.d.ts +2 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.js +68 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +10 -11
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +10 -27
- package/dist/core/utils/__tests__/templateRendering.test.js +71 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.d.ts +2 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.d.ts.map +1 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.js +63 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.d.ts +10 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.d.ts.map +1 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.js +13 -0
- package/dist/core/utils/adapters/index.d.ts +4 -0
- package/dist/core/utils/adapters/index.d.ts.map +1 -0
- package/dist/core/utils/adapters/index.js +8 -0
- package/dist/core/utils/adapters/semanticToStructural.d.ts +12 -0
- package/dist/core/utils/adapters/semanticToStructural.d.ts.map +1 -0
- package/dist/core/utils/adapters/semanticToStructural.js +36 -0
- package/dist/core/utils/appendUniqueLinesToFile.js +1 -1
- package/dist/core/utils/applyDiffReportToClient.d.ts +13 -1
- package/dist/core/utils/applyDiffReportToClient.d.ts.map +1 -1
- package/dist/core/utils/applyDiffReportToClient.js +189 -109
- package/dist/core/utils/areEqual.d.ts +1 -1
- package/dist/core/utils/buildMiraclesFromSemanticChanges.d.ts +25 -0
- package/dist/core/utils/buildMiraclesFromSemanticChanges.d.ts.map +1 -0
- package/dist/core/utils/buildMiraclesFromSemanticChanges.js +146 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.d.ts +23 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.d.ts.map +1 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.js +163 -0
- package/dist/core/utils/getOpenApiSpec.d.ts +18 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +35 -0
- package/dist/core/utils/getOperationErrors.d.ts +2 -2
- package/dist/core/utils/getOperationErrors.d.ts.map +1 -1
- package/dist/core/utils/getOperationResults.d.ts +1 -1
- package/dist/core/utils/getPropertyGroupSimple.d.ts.map +1 -1
- package/dist/core/utils/getPropertyGroupSimple.js +1 -3
- package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
- package/dist/core/utils/loadDiffReport.d.ts +11 -30
- package/dist/core/utils/loadDiffReport.d.ts.map +1 -1
- package/dist/core/utils/loadDiffReport.js +69 -3
- package/dist/core/utils/loadSemanticOpenApiSpec.d.ts +15 -0
- package/dist/core/utils/loadSemanticOpenApiSpec.d.ts.map +1 -0
- package/dist/core/utils/loadSemanticOpenApiSpec.js +61 -0
- package/dist/core/utils/modelHelpers.d.ts +13 -5
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +28 -23
- package/dist/core/utils/normalizeString.d.ts.map +1 -1
- package/dist/core/utils/normalizeString.js +1 -5
- package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessServiceImports.js +1 -3
- package/dist/core/utils/precompileTemplates.js +1 -0
- package/dist/core/utils/prepareAlias.d.ts +1 -1
- package/dist/core/utils/prepareDtoModels.d.ts +5 -0
- package/dist/core/utils/prepareDtoModels.d.ts.map +1 -1
- package/dist/core/utils/prepareDtoModels.js +56 -13
- package/dist/core/utils/registerHandlebarHelpers.d.ts +1 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +3 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts +1 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/resolveClassesModeTypes.d.ts +8 -0
- package/dist/core/utils/resolveClassesModeTypes.d.ts.map +1 -0
- package/dist/core/utils/resolveClassesModeTypes.js +77 -0
- package/dist/core/utils/semanticChangesToDiffEntries.d.ts +37 -0
- package/dist/core/utils/semanticChangesToDiffEntries.d.ts.map +1 -0
- package/dist/core/utils/semanticChangesToDiffEntries.js +99 -0
- package/dist/core/utils/semanticPointerToJsonPath.d.ts +7 -0
- package/dist/core/utils/semanticPointerToJsonPath.d.ts.map +1 -0
- package/dist/core/utils/semanticPointerToJsonPath.js +67 -0
- package/dist/core/utils/serviceHelpers.d.ts +6 -7
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
- package/dist/core/utils/serviceHelpers.js +8 -25
- package/dist/core/utils/sortModelByName.d.ts +1 -1
- package/dist/core/utils/writeClientExecutor.d.ts +1 -2
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +2 -6
- package/dist/core/utils/writeClientModels.d.ts +1 -2
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +4 -6
- package/dist/core/utils/writeClientSchemas.d.ts +1 -3
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +2 -7
- package/dist/core/utils/writeClientServices.d.ts +15 -16
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +6 -13
- package/dist/templatesCompiled/client/exportModels.d.ts +17 -11
- package/dist/templatesCompiled/client/exportModels.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportModels.js +96 -49
- package/dist/templatesCompiled/client/exportService.d.ts +13 -10
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +95 -67
- package/dist/templatesCompiled/client/partials/header.d.ts +1 -0
- package/dist/templatesCompiled/client/partials/header.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/header.js +11 -2
- package/package.json +130 -136
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts +0 -17
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/buildLegacyReport.js +0 -54
- package/dist/cli/analyzeDiff/diffEngine.d.ts +0 -54
- package/dist/cli/analyzeDiff/diffEngine.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/diffEngine.js +0 -209
|
@@ -0,0 +1,61 @@
|
|
|
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.loadSemanticOpenApiSpec = loadSemanticOpenApiSpec;
|
|
7
|
+
exports.loadSemanticOpenApiObject = loadSemanticOpenApiObject;
|
|
8
|
+
const swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
9
|
+
const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
|
|
10
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
11
|
+
const expandOpenApiRefsForSemanticDiff_1 = require("./expandOpenApiRefsForSemanticDiff");
|
|
12
|
+
function createSwaggerRefsResolver(refs) {
|
|
13
|
+
return {
|
|
14
|
+
exists: ref => refs.exists(ref),
|
|
15
|
+
get: ref => refs.get(ref),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function assertOpenApiObject(spec, source) {
|
|
19
|
+
if (!spec || typeof spec !== 'object' || Array.isArray(spec)) {
|
|
20
|
+
throw new Error(`Invalid OpenAPI schema at ${source}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Загружает OpenAPI-файл для семантического diff без полного dereference.
|
|
25
|
+
* @param input путь к файлу спецификации
|
|
26
|
+
* @returns спецификация с развёрнутыми refs для семантического сравнения
|
|
27
|
+
*/
|
|
28
|
+
async function loadSemanticOpenApiSpec(input) {
|
|
29
|
+
const absoluteInput = (0, pathHelpers_1.resolveHelper)(process.cwd(), input);
|
|
30
|
+
if (!input) {
|
|
31
|
+
throw new Error(`OpenAPI spec path is empty`);
|
|
32
|
+
}
|
|
33
|
+
const exists = await fileSystemHelpers_1.fileSystemHelpers.exists(absoluteInput);
|
|
34
|
+
if (!exists) {
|
|
35
|
+
throw new Error(`OpenAPI spec not found: ${absoluteInput}`);
|
|
36
|
+
}
|
|
37
|
+
const parser = new swagger_parser_1.default();
|
|
38
|
+
const resolved = (await parser.resolve(absoluteInput));
|
|
39
|
+
const raw = resolved.get(absoluteInput);
|
|
40
|
+
assertOpenApiObject(raw, absoluteInput);
|
|
41
|
+
return (0, expandOpenApiRefsForSemanticDiff_1.expandOpenApiRefsForSemanticDiff)(raw, {
|
|
42
|
+
refs: createSwaggerRefsResolver(resolved),
|
|
43
|
+
sourceFile: absoluteInput,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Разворачивает уже загруженный OpenAPI-объект для семантического diff.
|
|
48
|
+
* @param spec загруженная спецификация
|
|
49
|
+
* @param [sourceFile] исходный путь к файлу для резолва внешних refs
|
|
50
|
+
* @returns спецификация с развёрнутыми refs для семантического сравнения
|
|
51
|
+
*/
|
|
52
|
+
async function loadSemanticOpenApiObject(spec, sourceFile) {
|
|
53
|
+
assertOpenApiObject(spec, sourceFile ?? 'in-memory OpenAPI object');
|
|
54
|
+
const parser = new swagger_parser_1.default();
|
|
55
|
+
const resolved = (await parser.resolve(spec));
|
|
56
|
+
const absoluteSourceFile = sourceFile ? (0, pathHelpers_1.resolveHelper)(process.cwd(), sourceFile) : undefined;
|
|
57
|
+
return (0, expandOpenApiRefsForSemanticDiff_1.expandOpenApiRefsForSemanticDiff)(spec, {
|
|
58
|
+
refs: createSwaggerRefsResolver(resolved),
|
|
59
|
+
sourceFile: absoluteSourceFile,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type { Model } from '../types/shared/Model.model';
|
|
2
|
+
type AliasAssignable = {
|
|
3
|
+
name: string;
|
|
4
|
+
alias: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Назначает различающие алиасы, когда несколько элементов имеют одно имя.
|
|
8
|
+
* Первое вхождение сохраняет имя без алиаса; следующие получают $2, $3 и т.д.
|
|
9
|
+
* @param items массив элементов с полями name и alias
|
|
10
|
+
* @returns тот же массив с обновлёнными алиасами
|
|
11
|
+
*/
|
|
12
|
+
export declare const assignDuplicateAliases: <T extends AliasAssignable>(items: T[]) => T[];
|
|
2
13
|
/**
|
|
3
14
|
* Assigns alias to models with the same name.
|
|
4
|
-
* Modifies objects
|
|
5
|
-
*
|
|
6
|
-
* Example: if there are two models with name="Pet", the following will be assigned:
|
|
7
|
-
* - first: alias="Pet$1"
|
|
8
|
-
* - second: alias="Pet$2"
|
|
15
|
+
* Modifies objects in-place and returns the same array.
|
|
9
16
|
*
|
|
10
17
|
* @param models - an array of models sorted by name
|
|
11
18
|
* @returns the same array of models (modified)
|
|
@@ -25,4 +32,5 @@ export declare function setDuplicateModelAliases(models: Model[]): Model[];
|
|
|
25
32
|
* @returns the same array of models (modified)
|
|
26
33
|
*/
|
|
27
34
|
export declare function resolveModelImports(models: Model[], outputModelsDir: string): Model[];
|
|
35
|
+
export {};
|
|
28
36
|
//# sourceMappingURL=modelHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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,KAAK,eAAe,GAAG;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,CAAC,SAAS,eAAe,EAAE,OAAO,CAAC,EAAE,KAAG,CAAC,EAoB/E,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAEjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,KAAK,EAAE,CAyErF"}
|
|
@@ -3,40 +3,45 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.assignDuplicateAliases = void 0;
|
|
6
7
|
exports.setDuplicateModelAliases = setDuplicateModelAliases;
|
|
7
8
|
exports.resolveModelImports = resolveModelImports;
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
11
|
+
/**
|
|
12
|
+
* Назначает различающие алиасы, когда несколько элементов имеют одно имя.
|
|
13
|
+
* Первое вхождение сохраняет имя без алиаса; следующие получают $2, $3 и т.д.
|
|
14
|
+
* @param items массив элементов с полями name и alias
|
|
15
|
+
* @returns тот же массив с обновлёнными алиасами
|
|
16
|
+
*/
|
|
17
|
+
const assignDuplicateAliases = (items) => {
|
|
18
|
+
const nameCounts = new Map();
|
|
19
|
+
items.forEach(item => {
|
|
20
|
+
nameCounts.set(item.name, (nameCounts.get(item.name) ?? 0) + 1);
|
|
21
|
+
});
|
|
22
|
+
const nameIndex = new Map();
|
|
23
|
+
items.forEach(item => {
|
|
24
|
+
const count = nameCounts.get(item.name) ?? 1;
|
|
25
|
+
if (count <= 1) {
|
|
26
|
+
item.alias = '';
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const index = (nameIndex.get(item.name) ?? 0) + 1;
|
|
30
|
+
nameIndex.set(item.name, index);
|
|
31
|
+
item.alias = index === 1 ? '' : `${item.name}$${index}`;
|
|
32
|
+
});
|
|
33
|
+
return items;
|
|
34
|
+
};
|
|
35
|
+
exports.assignDuplicateAliases = assignDuplicateAliases;
|
|
10
36
|
/**
|
|
11
37
|
* Assigns alias to models with the same name.
|
|
12
|
-
* Modifies objects
|
|
13
|
-
*
|
|
14
|
-
* Example: if there are two models with name="Pet", the following will be assigned:
|
|
15
|
-
* - first: alias="Pet$1"
|
|
16
|
-
* - second: alias="Pet$2"
|
|
38
|
+
* Modifies objects in-place and returns the same array.
|
|
17
39
|
*
|
|
18
40
|
* @param models - an array of models sorted by name
|
|
19
41
|
* @returns the same array of models (modified)
|
|
20
42
|
*/
|
|
21
43
|
function setDuplicateModelAliases(models) {
|
|
22
|
-
|
|
23
|
-
let index = 1;
|
|
24
|
-
models.forEach(model => {
|
|
25
|
-
if (previous && previous.name === model.name) {
|
|
26
|
-
if (index === 1) {
|
|
27
|
-
previous.alias = `${model.name}$${index}`;
|
|
28
|
-
index++;
|
|
29
|
-
}
|
|
30
|
-
model.alias = `${model.name}$${index}`;
|
|
31
|
-
index++;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
model.alias = '';
|
|
35
|
-
index = 1;
|
|
36
|
-
}
|
|
37
|
-
previous = model;
|
|
38
|
-
});
|
|
39
|
-
return models;
|
|
44
|
+
return (0, exports.assignDuplicateAliases)(models);
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
47
|
* Adjusts the imports fields of the models to relative paths and correct aliases,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeString.d.ts","sourceRoot":"","sources":["../../../src/core/utils/normalizeString.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"normalizeString.d.ts","sourceRoot":"","sources":["../../../src/core/utils/normalizeString.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAMzE"}
|
|
@@ -6,9 +6,5 @@ function normalizeString(value) {
|
|
|
6
6
|
if (!value) {
|
|
7
7
|
return value;
|
|
8
8
|
}
|
|
9
|
-
return value
|
|
10
|
-
.replace(Consts_1.REGEX_BACKSLASH, '/')
|
|
11
|
-
.replace(Consts_1.REGEX_MULTIPLE_SLASHES, '/')
|
|
12
|
-
.replace(Consts_1.REGEX_DOT_SLASH, '/')
|
|
13
|
-
.replace(Consts_1.REGEX_LEADING_DOT_SLASH, './');
|
|
9
|
+
return value.replace(Consts_1.REGEX_BACKSLASH, '/').replace(Consts_1.REGEX_MULTIPLE_SLASHES, '/').replace(Consts_1.REGEX_DOT_SLASH, '/').replace(Consts_1.REGEX_LEADING_DOT_SLASH, './');
|
|
14
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postProcessServiceImports.d.ts","sourceRoot":"","sources":["../../../src/core/utils/postProcessServiceImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAI7D;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"postProcessServiceImports.d.ts","sourceRoot":"","sources":["../../../src/core/utils/postProcessServiceImports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAI7D;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,EAAE,CAEpE"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { Client } from '../types/shared/Client.model';
|
|
2
|
+
/**
|
|
3
|
+
* Подготавливает raw/DTO-модели и геттеры для режима classes.
|
|
4
|
+
* @param client сгенерированный клиент
|
|
5
|
+
* @returns клиент с заполненными DTO-полями моделей
|
|
6
|
+
*/
|
|
2
7
|
export declare const prepareDtoModels: (client: Client) => Client;
|
|
3
8
|
//# sourceMappingURL=prepareDtoModels.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareDtoModels.d.ts","sourceRoot":"","sources":["../../../src/core/utils/prepareDtoModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"prepareDtoModels.d.ts","sourceRoot":"","sources":["../../../src/core/utils/prepareDtoModels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAgO3D;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAuCjD,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.prepareDtoModels = void 0;
|
|
4
4
|
const escapeName_1 = require("./escapeName");
|
|
5
5
|
const unique_1 = require("./unique");
|
|
6
|
+
const getBaseName = (model) => model.alias || model.name;
|
|
6
7
|
const buildPropertyTarget = (name, prefix) => {
|
|
7
8
|
if (name.startsWith("'") && name.endsWith("'")) {
|
|
8
9
|
return `${prefix}[${name}]`;
|
|
@@ -52,7 +53,7 @@ const resolveTypeFactory = (nameMap, kind) => {
|
|
|
52
53
|
return types.length > 1 ? `(${intersection})` : intersection || 'any';
|
|
53
54
|
}
|
|
54
55
|
if (model.export === 'enum' && model.enum?.length) {
|
|
55
|
-
return joinUnique(model.enum.map(en => en.value), ' | ') || model.type;
|
|
56
|
+
return (joinUnique(model.enum.map(en => en.value), ' | ') || model.type);
|
|
56
57
|
}
|
|
57
58
|
if (model.export === 'interface') {
|
|
58
59
|
return buildInlineInterfaceType(model, resolveType);
|
|
@@ -61,16 +62,49 @@ const resolveTypeFactory = (nameMap, kind) => {
|
|
|
61
62
|
};
|
|
62
63
|
return resolveType;
|
|
63
64
|
};
|
|
65
|
+
const finalizeDtoType = (property, dtoType) => {
|
|
66
|
+
if (!property.isRequired && !property.default && !property.isNullable) {
|
|
67
|
+
return `${dtoType} | undefined`;
|
|
68
|
+
}
|
|
69
|
+
return dtoType;
|
|
70
|
+
};
|
|
71
|
+
const applyCoercion = (expr, property, accessor) => {
|
|
72
|
+
if (!property.needsCoercion || !property.coercionTo) {
|
|
73
|
+
return expr;
|
|
74
|
+
}
|
|
75
|
+
switch (property.coercionTo) {
|
|
76
|
+
case 'number':
|
|
77
|
+
return `typeof ${accessor} === 'string' ? Number(${accessor}) : (${expr})`;
|
|
78
|
+
case 'boolean':
|
|
79
|
+
return `typeof ${accessor} === 'string' ? ${accessor} === 'true' : (${expr})`;
|
|
80
|
+
default:
|
|
81
|
+
return expr;
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const buildOptionalSuffix = (property) => {
|
|
85
|
+
if (property.default) {
|
|
86
|
+
return '';
|
|
87
|
+
}
|
|
88
|
+
if (!property.isRequired) {
|
|
89
|
+
return property.isNullable ? ' ?? null' : ' ?? undefined';
|
|
90
|
+
}
|
|
91
|
+
if (property.isNullable) {
|
|
92
|
+
return ' ?? null';
|
|
93
|
+
}
|
|
94
|
+
return '';
|
|
95
|
+
};
|
|
64
96
|
const buildDtoInit = (property, nameMap) => {
|
|
65
97
|
const accessor = buildPropertyTarget(property.name, 'data');
|
|
66
|
-
const
|
|
98
|
+
const optionalSuffix = buildOptionalSuffix(property);
|
|
99
|
+
const defaultSuffix = property.default ? ` ?? ${property.default}` : optionalSuffix;
|
|
67
100
|
const isReference = property.export === 'reference' && nameMap.has(property.type);
|
|
68
101
|
if (isReference) {
|
|
69
102
|
const dtoName = nameMap.get(property.type).dtoName;
|
|
70
103
|
if (property.isRequired) {
|
|
71
|
-
return `new ${dtoName}(${accessor})
|
|
104
|
+
return applyCoercion(`new ${dtoName}(${accessor})`, property, accessor);
|
|
72
105
|
}
|
|
73
|
-
|
|
106
|
+
const expr = `${accessor} ? new ${dtoName}(${accessor}) : undefined`;
|
|
107
|
+
return applyCoercion(expr, property, accessor);
|
|
74
108
|
}
|
|
75
109
|
if (property.export === 'array') {
|
|
76
110
|
const itemModel = property.link ?? { ...property, export: 'reference', link: null };
|
|
@@ -78,13 +112,14 @@ const buildDtoInit = (property, nameMap) => {
|
|
|
78
112
|
if (itemIsRef) {
|
|
79
113
|
const dtoName = nameMap.get(itemModel.type).dtoName;
|
|
80
114
|
if (property.isRequired) {
|
|
81
|
-
return `fromArray(${dtoName}, ${accessor})
|
|
115
|
+
return applyCoercion(`fromArray(${dtoName}, ${accessor})`, property, accessor);
|
|
82
116
|
}
|
|
83
|
-
|
|
117
|
+
const expr = `${accessor} ? fromArray(${dtoName}, ${accessor}) : undefined`;
|
|
118
|
+
return applyCoercion(expr, property, accessor);
|
|
84
119
|
}
|
|
85
|
-
return `${accessor}${defaultSuffix}
|
|
120
|
+
return applyCoercion(`${accessor}${defaultSuffix}`, property, accessor);
|
|
86
121
|
}
|
|
87
|
-
return `${accessor}${defaultSuffix}
|
|
122
|
+
return applyCoercion(`${accessor}${defaultSuffix}`, property, accessor);
|
|
88
123
|
};
|
|
89
124
|
const buildDtoToJson = (property, nameMap) => {
|
|
90
125
|
const accessor = buildPropertyTarget(property.name, 'this');
|
|
@@ -122,7 +157,8 @@ const attachDtoGetters = (client) => {
|
|
|
122
157
|
client.models.forEach(model => {
|
|
123
158
|
if (!model.isDefinition || model.export !== 'interface')
|
|
124
159
|
return;
|
|
125
|
-
const
|
|
160
|
+
const modelKey = getBaseName(model);
|
|
161
|
+
const entries = miraclesByModel.get(modelKey) ?? miraclesByModel.get(model.name);
|
|
126
162
|
if (!entries || entries.length === 0)
|
|
127
163
|
return;
|
|
128
164
|
const getters = entries
|
|
@@ -148,15 +184,22 @@ const attachDtoGetters = (client) => {
|
|
|
148
184
|
}
|
|
149
185
|
});
|
|
150
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* Подготавливает raw/DTO-модели и геттеры для режима classes.
|
|
189
|
+
* @param client сгенерированный клиент
|
|
190
|
+
* @returns клиент с заполненными DTO-полями моделей
|
|
191
|
+
*/
|
|
151
192
|
const prepareDtoModels = (client) => {
|
|
152
193
|
const nameMap = new Map();
|
|
153
194
|
client.models.forEach(model => {
|
|
154
|
-
const
|
|
155
|
-
const
|
|
195
|
+
const baseName = getBaseName(model);
|
|
196
|
+
const rawName = `${baseName}Raw`;
|
|
197
|
+
const dtoName = `${baseName}Dto`;
|
|
156
198
|
model.rawName = rawName;
|
|
157
199
|
model.dtoName = dtoName;
|
|
200
|
+
model.exportName = baseName;
|
|
158
201
|
model.dtoKind = model.export === 'interface' ? 'class' : 'alias';
|
|
159
|
-
nameMap.set(
|
|
202
|
+
nameMap.set(baseName, { rawName, dtoName });
|
|
160
203
|
});
|
|
161
204
|
const resolveRaw = resolveTypeFactory(nameMap, 'raw');
|
|
162
205
|
const resolveDto = resolveTypeFactory(nameMap, 'dto');
|
|
@@ -171,7 +214,7 @@ const prepareDtoModels = (client) => {
|
|
|
171
214
|
}
|
|
172
215
|
model.properties.forEach(property => {
|
|
173
216
|
property.rawType = resolveRaw(property);
|
|
174
|
-
property.dtoType = resolveDto(property);
|
|
217
|
+
property.dtoType = finalizeDtoType(property, resolveDto(property));
|
|
175
218
|
property.dtoInit = buildDtoInit(property, nameMap);
|
|
176
219
|
property.dtoToJSON = buildDtoToJson(property, nameMap);
|
|
177
220
|
property.dtoTarget = buildPropertyTarget(property.name, '');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"registerHandlebarHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAK5D,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,aAAa,EAAE,OAAO,CAAC;IAAC,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,CAuMzJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AAiGA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AAiGA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AA0C1E,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC7C,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B,GAAG,SAAS,CAwKZ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Client } from '../types/shared/Client.model';
|
|
2
|
+
/**
|
|
3
|
+
* Заменяет импорты и типы моделей на exportName в режиме classes.
|
|
4
|
+
* @param client сгенерированный клиент
|
|
5
|
+
* @returns клиент с обновлёнными импортами и типами
|
|
6
|
+
*/
|
|
7
|
+
export declare const resolveClassesModeTypes: (client: Client) => Client;
|
|
8
|
+
//# sourceMappingURL=resolveClassesModeTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveClassesModeTypes.d.ts","sourceRoot":"","sources":["../../../src/core/utils/resolveClassesModeTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAsD3D;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAAI,QAAQ,MAAM,KAAG,MA8BxD,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveClassesModeTypes = void 0;
|
|
4
|
+
const normalizeImportPath = (value) => (value.startsWith('./') ? value.slice(2) : value);
|
|
5
|
+
const resolveExportName = (model, pathToExportName) => {
|
|
6
|
+
const modelPath = normalizeImportPath(model.path);
|
|
7
|
+
if (modelPath) {
|
|
8
|
+
const exportName = pathToExportName.get(modelPath);
|
|
9
|
+
if (exportName) {
|
|
10
|
+
return exportName;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
for (const imprt of model.imports ?? []) {
|
|
14
|
+
const importPath = normalizeImportPath(imprt.path);
|
|
15
|
+
const exportName = pathToExportName.get(importPath);
|
|
16
|
+
if (exportName && (imprt.name === model.base || imprt.name === model.type)) {
|
|
17
|
+
return exportName;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
};
|
|
22
|
+
const applyExportNameToModel = (model, pathToExportName) => {
|
|
23
|
+
const exportName = resolveExportName(model, pathToExportName);
|
|
24
|
+
if (exportName) {
|
|
25
|
+
model.base = exportName;
|
|
26
|
+
model.type = exportName;
|
|
27
|
+
}
|
|
28
|
+
if (model.link) {
|
|
29
|
+
applyExportNameToModel(model.link, pathToExportName);
|
|
30
|
+
}
|
|
31
|
+
model.properties?.forEach(child => applyExportNameToModel(child, pathToExportName));
|
|
32
|
+
};
|
|
33
|
+
const resolveImportForClassesMode = (imprt, pathToExportName) => {
|
|
34
|
+
const importPath = normalizeImportPath(imprt.path);
|
|
35
|
+
const exportName = pathToExportName.get(importPath);
|
|
36
|
+
if (!exportName || exportName === imprt.name) {
|
|
37
|
+
return imprt;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
...imprt,
|
|
41
|
+
name: exportName,
|
|
42
|
+
alias: '',
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Заменяет импорты и типы моделей на exportName в режиме classes.
|
|
47
|
+
* @param client сгенерированный клиент
|
|
48
|
+
* @returns клиент с обновлёнными импортами и типами
|
|
49
|
+
*/
|
|
50
|
+
const resolveClassesModeTypes = (client) => {
|
|
51
|
+
const pathToExportName = new Map();
|
|
52
|
+
client.models.forEach(model => {
|
|
53
|
+
if (!model.isDefinition) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const exportName = model.exportName || model.alias || model.name;
|
|
57
|
+
pathToExportName.set(normalizeImportPath(model.path), exportName);
|
|
58
|
+
});
|
|
59
|
+
client.services.forEach(service => {
|
|
60
|
+
service.imports = service.imports.map(imprt => resolveImportForClassesMode(imprt, pathToExportName));
|
|
61
|
+
service.operations.forEach(operation => {
|
|
62
|
+
operation.imports = operation.imports.map(imprt => resolveImportForClassesMode(imprt, pathToExportName));
|
|
63
|
+
operation.results.forEach(result => applyExportNameToModel(result, pathToExportName));
|
|
64
|
+
operation.parameters.forEach(parameter => applyExportNameToModel(parameter, pathToExportName));
|
|
65
|
+
operation.parametersPath.forEach(parameter => applyExportNameToModel(parameter, pathToExportName));
|
|
66
|
+
operation.parametersQuery.forEach(parameter => applyExportNameToModel(parameter, pathToExportName));
|
|
67
|
+
operation.parametersForm.forEach(parameter => applyExportNameToModel(parameter, pathToExportName));
|
|
68
|
+
operation.parametersHeader.forEach(parameter => applyExportNameToModel(parameter, pathToExportName));
|
|
69
|
+
operation.parametersCookie.forEach(parameter => applyExportNameToModel(parameter, pathToExportName));
|
|
70
|
+
if (operation.parametersBody) {
|
|
71
|
+
applyExportNameToModel(operation.parametersBody, pathToExportName);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
return client;
|
|
76
|
+
};
|
|
77
|
+
exports.resolveClassesModeTypes = resolveClassesModeTypes;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SemanticDiffChange } from '../semanticDiff/analyzeOpenApiDiff';
|
|
2
|
+
import type { DiffReportEntry } from '../types/DiffReport.model';
|
|
3
|
+
import type { DiffAction, DiffSeverity } from '../types/shared/DiffInfo.model';
|
|
4
|
+
/**
|
|
5
|
+
* Преобразует тип семантического изменения в legacy diff action.
|
|
6
|
+
* @param changeType тип семантического изменения
|
|
7
|
+
* @returns действие legacy diff
|
|
8
|
+
*/
|
|
9
|
+
export declare function semanticChangeTypeToAction(changeType: string): DiffAction;
|
|
10
|
+
/**
|
|
11
|
+
* Преобразует серьёзность семантического изменения в legacy diff severity.
|
|
12
|
+
* @param severity серьёзность семантического изменения
|
|
13
|
+
* @returns уровень серьёзности legacy diff
|
|
14
|
+
*/
|
|
15
|
+
export declare function semanticSeverityToDiffSeverity(severity: SemanticDiffChange['severity']): DiffSeverity;
|
|
16
|
+
/**
|
|
17
|
+
* Строит legacy JSONPath для семантического изменения, включая суффикс `.type`.
|
|
18
|
+
* @param change семантическое изменение
|
|
19
|
+
* @returns JSONPath для legacy diff
|
|
20
|
+
*/
|
|
21
|
+
export declare function semanticChangeToJsonPath(change: SemanticDiffChange): string;
|
|
22
|
+
/**
|
|
23
|
+
* Извлекает значения from/to для legacy diff-записи.
|
|
24
|
+
* @param change семантическое изменение
|
|
25
|
+
* @returns значения до и после изменения
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveSemanticChangeValues(change: SemanticDiffChange): {
|
|
28
|
+
from?: unknown;
|
|
29
|
+
to?: unknown;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Преобразует семантические изменения в legacy DiffReportEntry.
|
|
33
|
+
* @param changes список семантических изменений
|
|
34
|
+
* @returns список legacy diff-записей
|
|
35
|
+
*/
|
|
36
|
+
export declare function semanticChangesToDiffEntries(changes: SemanticDiffChange[]): DiffReportEntry[];
|
|
37
|
+
//# sourceMappingURL=semanticChangesToDiffEntries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticChangesToDiffEntries.d.ts","sourceRoot":"","sources":["../../../src/core/utils/semanticChangesToDiffEntries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAgB/E;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAczE;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,kBAAkB,CAAC,UAAU,CAAC,GAAG,YAAY,CAUrG;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAQ3E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,kBAAkB,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,EAAE,CAAC,EAAE,OAAO,CAAA;CAAE,CAgBxG;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,eAAe,EAAE,CAa7F"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.semanticChangeTypeToAction = semanticChangeTypeToAction;
|
|
4
|
+
exports.semanticSeverityToDiffSeverity = semanticSeverityToDiffSeverity;
|
|
5
|
+
exports.semanticChangeToJsonPath = semanticChangeToJsonPath;
|
|
6
|
+
exports.resolveSemanticChangeValues = resolveSemanticChangeValues;
|
|
7
|
+
exports.semanticChangesToDiffEntries = semanticChangesToDiffEntries;
|
|
8
|
+
const semanticPointerToJsonPath_1 = require("./semanticPointerToJsonPath");
|
|
9
|
+
const REMOVED_CHANGE_TYPES = new Set(['model.removed', 'model.property.removed', 'model.enum.value.removed', 'operation.removed', 'operation.parameter.removed', 'operation.response.success.removed']);
|
|
10
|
+
const ADDED_CHANGE_TYPES = new Set(['model.added', 'model.property.added', 'model.enum.value.added', 'operation.added', 'operation.parameter.added', 'operation.response.success.added']);
|
|
11
|
+
const CHANGED_CHANGE_TYPES = new Set([
|
|
12
|
+
'model.property.type.changed',
|
|
13
|
+
'model.property.required.changed',
|
|
14
|
+
'operation.parameter.required.changed',
|
|
15
|
+
'operation.parameter.type.changed',
|
|
16
|
+
'operation.requestBody.required.changed',
|
|
17
|
+
'operation.response.success.type.changed',
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Преобразует тип семантического изменения в legacy diff action.
|
|
21
|
+
* @param changeType тип семантического изменения
|
|
22
|
+
* @returns действие legacy diff
|
|
23
|
+
*/
|
|
24
|
+
function semanticChangeTypeToAction(changeType) {
|
|
25
|
+
if (REMOVED_CHANGE_TYPES.has(changeType) || changeType.endsWith('.removed')) {
|
|
26
|
+
return 'removed';
|
|
27
|
+
}
|
|
28
|
+
if (ADDED_CHANGE_TYPES.has(changeType) || changeType.endsWith('.added')) {
|
|
29
|
+
return 'added';
|
|
30
|
+
}
|
|
31
|
+
if (CHANGED_CHANGE_TYPES.has(changeType) || changeType.endsWith('.changed')) {
|
|
32
|
+
return 'changed';
|
|
33
|
+
}
|
|
34
|
+
return 'changed';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Преобразует серьёзность семантического изменения в legacy diff severity.
|
|
38
|
+
* @param severity серьёзность семантического изменения
|
|
39
|
+
* @returns уровень серьёзности legacy diff
|
|
40
|
+
*/
|
|
41
|
+
function semanticSeverityToDiffSeverity(severity) {
|
|
42
|
+
if (severity === 'breaking') {
|
|
43
|
+
return 'breaking';
|
|
44
|
+
}
|
|
45
|
+
if (severity === 'non-breaking') {
|
|
46
|
+
return 'warning';
|
|
47
|
+
}
|
|
48
|
+
return 'info';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Строит legacy JSONPath для семантического изменения, включая суффикс `.type`.
|
|
52
|
+
* @param change семантическое изменение
|
|
53
|
+
* @returns JSONPath для legacy diff
|
|
54
|
+
*/
|
|
55
|
+
function semanticChangeToJsonPath(change) {
|
|
56
|
+
const basePath = (0, semanticPointerToJsonPath_1.semanticPointerToJsonPath)(change.path);
|
|
57
|
+
if (change.type === 'model.property.type.changed' || change.type === 'operation.parameter.type.changed') {
|
|
58
|
+
return `${basePath}.type`;
|
|
59
|
+
}
|
|
60
|
+
return basePath;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Извлекает значения from/to для legacy diff-записи.
|
|
64
|
+
* @param change семантическое изменение
|
|
65
|
+
* @returns значения до и после изменения
|
|
66
|
+
*/
|
|
67
|
+
function resolveSemanticChangeValues(change) {
|
|
68
|
+
if (change.type === 'model.property.required.changed' || change.type === 'operation.parameter.required.changed') {
|
|
69
|
+
return {
|
|
70
|
+
from: change.fromRequired,
|
|
71
|
+
to: change.toRequired,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (change.from !== undefined || change.to !== undefined) {
|
|
75
|
+
return {
|
|
76
|
+
from: change.from,
|
|
77
|
+
to: change.to,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return {};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Преобразует семантические изменения в legacy DiffReportEntry.
|
|
84
|
+
* @param changes список семантических изменений
|
|
85
|
+
* @returns список legacy diff-записей
|
|
86
|
+
*/
|
|
87
|
+
function semanticChangesToDiffEntries(changes) {
|
|
88
|
+
return changes.map(change => {
|
|
89
|
+
const { from, to } = resolveSemanticChangeValues(change);
|
|
90
|
+
return {
|
|
91
|
+
action: semanticChangeTypeToAction(change.type),
|
|
92
|
+
path: semanticChangeToJsonPath(change),
|
|
93
|
+
severity: semanticSeverityToDiffSeverity(change.severity),
|
|
94
|
+
from,
|
|
95
|
+
to,
|
|
96
|
+
note: change.message,
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Преобразует семантический JSON Pointer в legacy JSONPath, используемый генератором.
|
|
3
|
+
* @param pointer JSON Pointer или уже готовый JSONPath
|
|
4
|
+
* @returns legacy JSONPath
|
|
5
|
+
*/
|
|
6
|
+
export declare function semanticPointerToJsonPath(pointer: string): string;
|
|
7
|
+
//# sourceMappingURL=semanticPointerToJsonPath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semanticPointerToJsonPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/semanticPointerToJsonPath.ts"],"names":[],"mappings":"AAgDA;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAuBjE"}
|