ts-openapi-codegen 2.1.0-beta.1 → 2.1.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -934
- package/README.rus.md +27 -934
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.js +40 -24
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffLomMiracles.test.js +47 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.js +17 -7
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.js +17 -7
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts +14 -2
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/analyzeDiff.js +58 -15
- package/dist/cli/analyzeDiff/ciSummary.d.ts +6 -3
- package/dist/cli/analyzeDiff/ciSummary.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/ciSummary.js +10 -6
- package/dist/cli/analyzeDiff/ignoreRules.d.ts +0 -22
- package/dist/cli/analyzeDiff/ignoreRules.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/ignoreRules.js +3 -25
- package/dist/cli/analyzeDiff/miracles.d.ts +0 -54
- package/dist/cli/analyzeDiff/miracles.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/miracles.js +1 -219
- package/dist/cli/analyzeDiff/specParser.d.ts +0 -13
- package/dist/cli/analyzeDiff/specParser.d.ts.map +1 -1
- package/dist/cli/analyzeDiff/specParser.js +2 -23
- package/dist/cli/analyzeDiff/types.d.ts +0 -42
- package/dist/cli/analyzeDiff/types.d.ts.map +1 -1
- package/dist/cli/analyzeUsage/analyzeUsage.d.ts +4 -0
- package/dist/cli/analyzeUsage/analyzeUsage.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/analyzeUsage.js +60 -0
- package/dist/cli/analyzeUsage/core/Analyzer.d.ts +9 -0
- package/dist/cli/analyzeUsage/core/Analyzer.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/core/Analyzer.js +29 -0
- package/dist/cli/analyzeUsage/core/ProjectContext.d.ts +10 -0
- package/dist/cli/analyzeUsage/core/ProjectContext.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/core/ProjectContext.js +58 -0
- package/dist/cli/analyzeUsage/core/Scanner.d.ts +23 -0
- package/dist/cli/analyzeUsage/core/Scanner.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/core/Scanner.js +125 -0
- package/dist/cli/analyzeUsage/rules/ClientRule.d.ts +14 -0
- package/dist/cli/analyzeUsage/rules/ClientRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ClientRule.js +86 -0
- package/dist/cli/analyzeUsage/rules/CoverageRule.d.ts +7 -0
- package/dist/cli/analyzeUsage/rules/CoverageRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/CoverageRule.js +55 -0
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/DiagnosticsRule.js +63 -0
- package/dist/cli/analyzeUsage/rules/ImportRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/ImportRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ImportRule.js +50 -0
- package/dist/cli/analyzeUsage/rules/ModelRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/ModelRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ModelRule.js +34 -0
- package/dist/cli/analyzeUsage/rules/SchemaRule.d.ts +6 -0
- package/dist/cli/analyzeUsage/rules/SchemaRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/SchemaRule.js +46 -0
- package/dist/cli/analyzeUsage/rules/ServiceRule.d.ts +15 -0
- package/dist/cli/analyzeUsage/rules/ServiceRule.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/rules/ServiceRule.js +96 -0
- package/dist/cli/analyzeUsage/types.d.ts +52 -0
- package/dist/cli/analyzeUsage/types.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/types.js +2 -0
- package/dist/cli/analyzeUsage/utils/fuzzy.d.ts +5 -0
- package/dist/cli/analyzeUsage/utils/fuzzy.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/utils/fuzzy.js +38 -0
- package/dist/cli/analyzeUsage/utils/report.d.ts +16 -0
- package/dist/cli/analyzeUsage/utils/report.d.ts.map +1 -0
- package/dist/cli/analyzeUsage/utils/report.js +85 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/checkConfig.test.js +53 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/__tests__/updateConfig.test.js +52 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +2 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +15 -6
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +2 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +8 -5
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/prepareConfigData.test.js +20 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/removeDefaultConfigValues.test.js +35 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/__tests__/validateAndMigrateConfigData.test.js +59 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +19 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateExecutorSetup.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateExecutorSetup.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateExecutorSetup.js +55 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.js +1 -1
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.js +18 -9
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts +2 -5
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +24 -20
- package/dist/cli/index.js +45 -9
- package/dist/cli/initOpenApiConfig/Types.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/Types.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/__tests__/init.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/__tests__/init.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/__tests__/init.test.js +20 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/__tests__/initConfig.test.js +49 -0
- package/dist/cli/initOpenApiConfig/init.d.ts +2 -1
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.js +52 -20
- package/dist/cli/initOpenApiConfig/initConfig.d.ts +5 -0
- package/dist/cli/initOpenApiConfig/initConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initConfig.js +8 -4
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts +3 -2
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.js +36 -10
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/buildConfig.test.js +93 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/findSpecFiles.test.js +45 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.d.ts +2 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.d.ts.map +1 -0
- package/dist/cli/initOpenApiConfig/utils/__tests__/validateSpecFiles.test.js +61 -0
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts +6 -12
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/buildConfig.js +24 -19
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/registerHandlebarTemplates.js +2 -0
- package/dist/cli/interactive/constants.d.ts +0 -4
- package/dist/cli/interactive/constants.d.ts.map +1 -1
- package/dist/cli/interactive/constants.js +1 -5
- package/dist/cli/previewChanges/previewChanges.d.ts +2 -1
- package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
- package/dist/cli/previewChanges/previewChanges.js +8 -8
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/compareFiles.test.js +52 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/isDirectoryEmpty.test.js +43 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/readDirectoryRecursive.test.js +32 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.d.ts +2 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.d.ts.map +1 -0
- package/dist/cli/previewChanges/utils/__tests__/updateOutputPaths.test.js +68 -0
- package/dist/cli/previewChanges/utils/formatDiff.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.js +5 -12
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/checkConfigAndUpdate.test.js +36 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/generateOptionsSchema.test.js +59 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/initOptionsSchema.test.js +43 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.d.ts +2 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.d.ts.map +1 -0
- package/dist/cli/schemas/__tests__/previewChangesSchema.test.js +31 -0
- package/dist/cli/schemas/analyzeUsage.d.ts +13 -0
- package/dist/cli/schemas/analyzeUsage.d.ts.map +1 -0
- package/dist/cli/schemas/analyzeUsage.js +41 -0
- package/dist/cli/schemas/generate.d.ts +10 -2
- package/dist/cli/schemas/generate.d.ts.map +1 -1
- package/dist/cli/schemas/generate.js +7 -2
- package/dist/cli/schemas/index.d.ts +2 -2
- package/dist/cli/schemas/index.d.ts.map +1 -1
- package/dist/cli/schemas/index.js +1 -1
- package/dist/cli/schemas/init.d.ts +10 -0
- package/dist/cli/schemas/init.d.ts.map +1 -1
- package/dist/cli/schemas/init.js +3 -1
- package/dist/cli/types.d.ts +6 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +2 -0
- package/dist/common/Consts.d.ts +1 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +7 -3
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +3 -3
- package/dist/common/LoggerMessages.d.ts +71 -12
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +76 -18
- package/dist/common/TEslintFixOptions.d.ts +20 -0
- package/dist/common/TEslintFixOptions.d.ts.map +1 -0
- package/dist/common/TEslintFixOptions.js +15 -0
- package/dist/common/TRawOptions.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +2 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.js +1 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.js +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.js +15 -5
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +18 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +7 -1
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +4 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.js +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +2 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +2 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.js +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +7 -1
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +4 -16
- package/dist/common/VersionedSchema/Utils/buildVersionedSchema.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.js +1 -1
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.js +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +4 -6
- package/dist/common/VersionedSchema/Utils/getLatestVersionFromMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +6 -8
- package/dist/common/VersionedSchema/Utils/replaceInvalidKeysWithMappedNames.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/replaceInvalidKeysWithMappedNames.js +1 -1
- package/dist/common/VersionedSchema/Utils/validateAndSuggestKeyCorrections.d.ts.map +1 -1
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts +1 -1
- package/dist/common/VersionedSchema/refinements/dependentOptionsRefinement.d.ts.map +1 -1
- package/dist/common/utils/__tests__/eslintFix.test.js +25 -67
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.d.ts +2 -0
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/extractEslintFixOptions.test.js +28 -0
- package/dist/common/utils/__tests__/format.test.js +26 -17
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.d.ts +2 -0
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/prepareTempTsConfig.test.js +78 -0
- package/dist/common/utils/codegenTempDir.d.ts +20 -0
- package/dist/common/utils/codegenTempDir.d.ts.map +1 -0
- package/dist/common/utils/codegenTempDir.js +42 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +3 -8
- package/dist/common/utils/eslintFix.d.ts +48 -4
- package/dist/common/utils/eslintFix.d.ts.map +1 -1
- package/dist/common/utils/eslintFix.js +121 -15
- package/dist/common/utils/format.d.ts +1 -1
- package/dist/common/utils/format.d.ts.map +1 -1
- package/dist/common/utils/format.js +23 -11
- package/dist/common/utils/jsonPath.d.ts.map +1 -1
- package/dist/common/utils/prepareTempEslintConfig.d.ts +18 -0
- package/dist/common/utils/prepareTempEslintConfig.d.ts.map +1 -0
- package/dist/common/utils/prepareTempEslintConfig.js +55 -0
- package/dist/common/utils/prepareTempTsConfig.d.ts +23 -0
- package/dist/common/utils/prepareTempTsConfig.d.ts.map +1 -0
- package/dist/common/utils/prepareTempTsConfig.js +105 -0
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +2 -6
- package/dist/core/OpenApiClient.d.ts +27 -1
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +259 -19
- package/dist/core/WriteClient.d.ts +84 -17
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +96 -22
- package/dist/core/__tests__/WriteClient.test.js +2 -1
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +1 -3
- package/dist/core/api/v2/parser/getServiceName.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameters.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +1 -3
- package/dist/core/api/v3/parser/getServiceName.d.ts +1 -1
- package/dist/core/governance/evaluateGovernanceRules.d.ts.map +1 -1
- package/dist/core/governance/evaluateGovernanceRules.js +1 -3
- package/dist/core/governance/loadGovernanceConfig.d.ts.map +1 -1
- package/dist/core/governance/loadGovernanceConfig.js +2 -4
- package/dist/core/plugins/GeneratorPlugin.model.d.ts.map +1 -1
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts.map +1 -1
- package/dist/core/plugins/getBuiltinPlugins.d.ts.map +1 -1
- package/dist/core/plugins/loadGeneratorPlugins.d.ts.map +1 -1
- package/dist/core/plugins/loadGeneratorPlugins.js +1 -1
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.js +79 -21
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.js +20 -1
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts +58 -6
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts.map +1 -1
- package/dist/core/semanticDiff/analyzeOpenApiDiff.js +47 -19
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts +8 -3
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts.map +1 -1
- package/dist/core/semanticDiff/semanticDiffReportSchema.js +139 -56
- package/dist/core/strict/validateOpenApiStrict.d.ts.map +1 -1
- package/dist/core/types/Consts.js +1 -1
- package/dist/core/types/DiffReport.model.d.ts +101 -0
- package/dist/core/types/DiffReport.model.d.ts.map +1 -0
- package/dist/core/types/DiffReport.model.js +5 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts +3 -3
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/ExportedModel.model.d.ts +1 -1
- package/dist/core/types/base/ExportedModel.model.d.ts.map +1 -1
- package/dist/core/types/base/ExportedService.model.d.ts.map +1 -1
- package/dist/core/types/base/OutputPaths.model.d.ts.map +1 -1
- package/dist/core/types/base/PrefixArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/PropertyGroup.model.d.ts +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +1 -1
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/Templates.model.d.ts +1 -0
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/types/shared/Client.model.d.ts +1 -1
- package/dist/core/types/shared/Client.model.d.ts.map +1 -1
- package/dist/core/types/shared/Model.model.d.ts +37 -1
- package/dist/core/types/shared/Model.model.d.ts.map +1 -1
- package/dist/core/utils/GenerationCache.d.ts +18 -0
- package/dist/core/utils/GenerationCache.d.ts.map +1 -0
- package/dist/core/utils/GenerationCache.js +41 -0
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.js +1 -0
- package/dist/core/utils/__tests__/GenerationCache.test.d.ts +2 -0
- package/dist/core/utils/__tests__/GenerationCache.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/GenerationCache.test.js +37 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.js +182 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.d.ts +2 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/buildMiraclesFromSemanticChanges.test.js +77 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.d.ts +2 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/expandOpenApiRefsForSemanticDiff.test.js +159 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.d.ts +2 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/loadDiffReport.test.js +246 -0
- package/dist/core/utils/__tests__/modelHelpers.test.js +27 -9
- package/dist/core/utils/__tests__/postProcessModelImports.test.js +1 -4
- package/dist/core/utils/__tests__/postProcessServiceImports.test.js +1 -4
- package/dist/core/utils/__tests__/prepareDtoModels.test.js +168 -1
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +27 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveClassesModeTypes.test.js +111 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.d.ts +2 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/semanticChangesToDiffEntries.test.js +68 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +10 -11
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +10 -27
- package/dist/core/utils/__tests__/templateRendering.test.d.ts +2 -0
- package/dist/core/utils/__tests__/templateRendering.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/templateRendering.test.js +190 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/writeFileIfChanged.test.js +30 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.d.ts +2 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.d.ts.map +1 -0
- package/dist/core/utils/adapters/__tests__/semanticToStructural.test.js +63 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.d.ts +10 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.d.ts.map +1 -0
- package/dist/core/utils/adapters/extractMiraclesFromSemantic.js +13 -0
- package/dist/core/utils/adapters/index.d.ts +3 -0
- package/dist/core/utils/adapters/index.d.ts.map +1 -0
- package/dist/core/utils/adapters/index.js +6 -0
- package/dist/core/utils/adapters/semanticToStructural.d.ts +12 -0
- package/dist/core/utils/adapters/semanticToStructural.d.ts.map +1 -0
- package/dist/core/utils/adapters/semanticToStructural.js +36 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts +13 -1
- package/dist/core/utils/applyDiffReportToClient.d.ts.map +1 -1
- package/dist/core/utils/applyDiffReportToClient.js +189 -109
- package/dist/core/utils/areEqual.d.ts +1 -1
- package/dist/core/utils/buildMiraclesFromSemanticChanges.d.ts +25 -0
- package/dist/core/utils/buildMiraclesFromSemanticChanges.d.ts.map +1 -0
- package/dist/core/utils/buildMiraclesFromSemanticChanges.js +146 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.d.ts +23 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.d.ts.map +1 -0
- package/dist/core/utils/expandOpenApiRefsForSemanticDiff.js +163 -0
- package/dist/core/utils/getOpenApiSpec.d.ts +6 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +6 -0
- package/dist/core/utils/getOperationErrors.d.ts +2 -2
- package/dist/core/utils/getOperationErrors.d.ts.map +1 -1
- package/dist/core/utils/getOperationResults.d.ts +1 -1
- package/dist/core/utils/getPropertyGroupSimple.d.ts.map +1 -1
- package/dist/core/utils/getPropertyGroupSimple.js +1 -3
- package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
- package/dist/core/utils/loadDiffReport.d.ts +11 -30
- package/dist/core/utils/loadDiffReport.d.ts.map +1 -1
- package/dist/core/utils/loadDiffReport.js +75 -9
- package/dist/core/utils/loadSemanticOpenApiSpec.d.ts +15 -0
- package/dist/core/utils/loadSemanticOpenApiSpec.d.ts.map +1 -0
- package/dist/core/utils/loadSemanticOpenApiSpec.js +61 -0
- package/dist/core/utils/modelHelpers.d.ts +13 -5
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +28 -23
- package/dist/core/utils/normalizeString.d.ts.map +1 -1
- package/dist/core/utils/normalizeString.js +1 -5
- package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessServiceImports.js +1 -3
- package/dist/core/utils/precompileTemplates.js +4 -2
- package/dist/core/utils/prepareAlias.d.ts +1 -1
- package/dist/core/utils/prepareDtoModels.d.ts +5 -0
- package/dist/core/utils/prepareDtoModels.d.ts.map +1 -1
- package/dist/core/utils/prepareDtoModels.js +57 -20
- package/dist/core/utils/registerHandlebarHelpers.d.ts +1 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +3 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts +1 -0
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +2 -0
- package/dist/core/utils/resolveClassesModeTypes.d.ts +8 -0
- package/dist/core/utils/resolveClassesModeTypes.d.ts.map +1 -0
- package/dist/core/utils/resolveClassesModeTypes.js +77 -0
- package/dist/core/utils/semanticChangesToDiffEntries.d.ts +28 -0
- package/dist/core/utils/semanticChangesToDiffEntries.d.ts.map +1 -0
- package/dist/core/utils/semanticChangesToDiffEntries.js +98 -0
- package/dist/core/utils/semanticPointerToJsonPath.d.ts +7 -0
- package/dist/core/utils/semanticPointerToJsonPath.d.ts.map +1 -0
- package/dist/core/utils/semanticPointerToJsonPath.js +67 -0
- package/dist/core/utils/serviceHelpers.d.ts +6 -7
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
- package/dist/core/utils/serviceHelpers.js +8 -25
- package/dist/core/utils/sortModelByName.d.ts +1 -1
- package/dist/core/utils/validateRawOptions.js +2 -2
- package/dist/core/utils/writeClientCore.d.ts +2 -0
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +43 -21
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +14 -4
- package/dist/core/utils/writeClientExecutor.d.ts +1 -3
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +6 -11
- package/dist/core/utils/writeClientFullIndex.js +4 -4
- package/dist/core/utils/writeClientModels.d.ts +1 -2
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +14 -16
- package/dist/core/utils/writeClientModelsIndex.d.ts +1 -1
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.js +14 -4
- package/dist/core/utils/writeClientSchemas.d.ts +1 -3
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +9 -14
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemasIndex.js +14 -4
- package/dist/core/utils/writeClientServices.d.ts +15 -16
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +12 -19
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientServicesIndex.js +14 -4
- package/dist/core/utils/writeClientSimpleIndex.js +4 -4
- package/dist/core/utils/writeFileIfChanged.d.ts +3 -0
- package/dist/core/utils/writeFileIfChanged.d.ts.map +1 -0
- package/dist/core/utils/writeFileIfChanged.js +22 -0
- package/dist/templatesCompiled/cli/customCreateExecutorAdapter.d.ts +8 -0
- package/dist/templatesCompiled/cli/customCreateExecutorAdapter.d.ts.map +1 -0
- package/dist/templatesCompiled/cli/customCreateExecutorAdapter.js +18 -0
- package/dist/templatesCompiled/cli/customRequest.js +7 -7
- package/dist/templatesCompiled/cli/customRequestExecutor.js +7 -7
- package/dist/templatesCompiled/client/core/ApiError.js +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts +0 -6
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +3 -22
- package/dist/templatesCompiled/client/core/executor/legacyRequestAdapter.d.ts +11 -0
- package/dist/templatesCompiled/client/core/executor/legacyRequestAdapter.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/executor/legacyRequestAdapter.js +28 -0
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts +2 -0
- package/dist/templatesCompiled/client/core/executor/requestExecutor.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +8 -2
- package/dist/templatesCompiled/client/core/functions/catchErrors.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/apiErrorInterceptor.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/interceptors.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +1 -1
- package/dist/templatesCompiled/client/exportClient.d.ts +0 -4
- package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportClient.js +9 -45
- package/dist/templatesCompiled/client/exportModels.d.ts +17 -11
- package/dist/templatesCompiled/client/exportModels.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportModels.js +96 -49
- package/dist/templatesCompiled/client/exportService.d.ts +13 -10
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +95 -67
- package/dist/templatesCompiled/client/indexCore.js +4 -4
- package/dist/templatesCompiled/client/indexFull.js +8 -8
- package/dist/templatesCompiled/client/indexSimple.js +2 -2
- package/dist/templatesCompiled/client/partials/header.d.ts +1 -0
- package/dist/templatesCompiled/client/partials/header.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/header.js +11 -2
- package/dist/test/helpers/silenceLoggers.d.ts +11 -0
- package/dist/test/helpers/silenceLoggers.d.ts.map +1 -0
- package/dist/test/helpers/silenceLoggers.js +88 -0
- package/package.json +132 -136
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts +0 -17
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/buildLegacyReport.js +0 -54
- package/dist/cli/analyzeDiff/diffEngine.d.ts +0 -54
- package/dist/cli/analyzeDiff/diffEngine.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/diffEngine.js +0 -209
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts +0 -6
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/logLegacyReport.js +0 -29
- package/dist/cli/analyzeDiff/report.d.ts +0 -3
- package/dist/cli/analyzeDiff/report.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/report.js +0 -7
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts +0 -6
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts.map +0 -1
- package/dist/cli/analyzeDiff/writeLegacyReport.js +0 -21
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts +0 -4
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.d.ts.map +0 -1
- package/dist/common/VersionedSchema/refinements/singleOrMultiRefinement.js +0 -21
- package/dist/common/utils/normalizeObject.d.ts +0 -2
- package/dist/common/utils/normalizeObject.d.ts.map +0 -1
- package/dist/common/utils/normalizeObject.js +0 -63
- package/dist/core/utils/appendUniqueLinesToFile.d.ts +0 -2
- package/dist/core/utils/appendUniqueLinesToFile.d.ts.map +0 -1
- package/dist/core/utils/appendUniqueLinesToFile.js +0 -24
|
@@ -8,6 +8,7 @@ const handlebars_1 = __importDefault(require("handlebars"));
|
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const Enums_1 = require("../../common/Enums");
|
|
10
10
|
const Logger_1 = require("../../common/Logger");
|
|
11
|
+
const LoggerMessages_1 = require("../../common/LoggerMessages");
|
|
11
12
|
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
12
13
|
const Consts_1 = require("../../core/types/Consts");
|
|
13
14
|
const templatesDir = (0, pathHelpers_1.resolveHelper)(__dirname, '../../templates');
|
|
@@ -70,6 +71,7 @@ const precompileTemplates = () => {
|
|
|
70
71
|
getRequiredFields: true,
|
|
71
72
|
getEnumType: true,
|
|
72
73
|
camelCase: true,
|
|
74
|
+
useBatchEslintFix: true,
|
|
73
75
|
},
|
|
74
76
|
});
|
|
75
77
|
const tsContent = header + precompiled;
|
|
@@ -83,10 +85,10 @@ const precompileTemplates = () => {
|
|
|
83
85
|
});
|
|
84
86
|
};
|
|
85
87
|
walk(templatesDir);
|
|
86
|
-
logger.info(
|
|
88
|
+
logger.info(LoggerMessages_1.LOGGER_MESSAGES.TEMPLATES.PRECOMPILE_SUCCESS);
|
|
87
89
|
}
|
|
88
90
|
catch (error) {
|
|
89
|
-
logger.error(
|
|
91
|
+
logger.error(LoggerMessages_1.LOGGER_MESSAGES.TEMPLATES.PRECOMPILE_ERROR(error.message));
|
|
90
92
|
}
|
|
91
93
|
};
|
|
92
94
|
precompileTemplates();
|
|
@@ -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"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareDtoModels = void 0;
|
|
4
|
-
const unique_1 = require("./unique");
|
|
5
4
|
const escapeName_1 = require("./escapeName");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
return name.slice(1, -1);
|
|
9
|
-
}
|
|
10
|
-
return name;
|
|
11
|
-
};
|
|
5
|
+
const unique_1 = require("./unique");
|
|
6
|
+
const getBaseName = (model) => model.alias || model.name;
|
|
12
7
|
const buildPropertyTarget = (name, prefix) => {
|
|
13
8
|
if (name.startsWith("'") && name.endsWith("'")) {
|
|
14
9
|
return `${prefix}[${name}]`;
|
|
@@ -58,7 +53,7 @@ const resolveTypeFactory = (nameMap, kind) => {
|
|
|
58
53
|
return types.length > 1 ? `(${intersection})` : intersection || 'any';
|
|
59
54
|
}
|
|
60
55
|
if (model.export === 'enum' && model.enum?.length) {
|
|
61
|
-
return joinUnique(model.enum.map(en => en.value), ' | ') || model.type;
|
|
56
|
+
return (joinUnique(model.enum.map(en => en.value), ' | ') || model.type);
|
|
62
57
|
}
|
|
63
58
|
if (model.export === 'interface') {
|
|
64
59
|
return buildInlineInterfaceType(model, resolveType);
|
|
@@ -67,16 +62,49 @@ const resolveTypeFactory = (nameMap, kind) => {
|
|
|
67
62
|
};
|
|
68
63
|
return resolveType;
|
|
69
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
|
+
};
|
|
70
96
|
const buildDtoInit = (property, nameMap) => {
|
|
71
97
|
const accessor = buildPropertyTarget(property.name, 'data');
|
|
72
|
-
const
|
|
98
|
+
const optionalSuffix = buildOptionalSuffix(property);
|
|
99
|
+
const defaultSuffix = property.default ? ` ?? ${property.default}` : optionalSuffix;
|
|
73
100
|
const isReference = property.export === 'reference' && nameMap.has(property.type);
|
|
74
101
|
if (isReference) {
|
|
75
102
|
const dtoName = nameMap.get(property.type).dtoName;
|
|
76
103
|
if (property.isRequired) {
|
|
77
|
-
return `new ${dtoName}(${accessor})
|
|
104
|
+
return applyCoercion(`new ${dtoName}(${accessor})`, property, accessor);
|
|
78
105
|
}
|
|
79
|
-
|
|
106
|
+
const expr = `${accessor} ? new ${dtoName}(${accessor}) : undefined`;
|
|
107
|
+
return applyCoercion(expr, property, accessor);
|
|
80
108
|
}
|
|
81
109
|
if (property.export === 'array') {
|
|
82
110
|
const itemModel = property.link ?? { ...property, export: 'reference', link: null };
|
|
@@ -84,13 +112,14 @@ const buildDtoInit = (property, nameMap) => {
|
|
|
84
112
|
if (itemIsRef) {
|
|
85
113
|
const dtoName = nameMap.get(itemModel.type).dtoName;
|
|
86
114
|
if (property.isRequired) {
|
|
87
|
-
return `fromArray(${dtoName}, ${accessor})
|
|
115
|
+
return applyCoercion(`fromArray(${dtoName}, ${accessor})`, property, accessor);
|
|
88
116
|
}
|
|
89
|
-
|
|
117
|
+
const expr = `${accessor} ? fromArray(${dtoName}, ${accessor}) : undefined`;
|
|
118
|
+
return applyCoercion(expr, property, accessor);
|
|
90
119
|
}
|
|
91
|
-
return `${accessor}${defaultSuffix}
|
|
120
|
+
return applyCoercion(`${accessor}${defaultSuffix}`, property, accessor);
|
|
92
121
|
}
|
|
93
|
-
return `${accessor}${defaultSuffix}
|
|
122
|
+
return applyCoercion(`${accessor}${defaultSuffix}`, property, accessor);
|
|
94
123
|
};
|
|
95
124
|
const buildDtoToJson = (property, nameMap) => {
|
|
96
125
|
const accessor = buildPropertyTarget(property.name, 'this');
|
|
@@ -128,7 +157,8 @@ const attachDtoGetters = (client) => {
|
|
|
128
157
|
client.models.forEach(model => {
|
|
129
158
|
if (!model.isDefinition || model.export !== 'interface')
|
|
130
159
|
return;
|
|
131
|
-
const
|
|
160
|
+
const modelKey = getBaseName(model);
|
|
161
|
+
const entries = miraclesByModel.get(modelKey) ?? miraclesByModel.get(model.name);
|
|
132
162
|
if (!entries || entries.length === 0)
|
|
133
163
|
return;
|
|
134
164
|
const getters = entries
|
|
@@ -154,15 +184,22 @@ const attachDtoGetters = (client) => {
|
|
|
154
184
|
}
|
|
155
185
|
});
|
|
156
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* Подготавливает raw/DTO-модели и геттеры для режима classes.
|
|
189
|
+
* @param client сгенерированный клиент
|
|
190
|
+
* @returns клиент с заполненными DTO-полями моделей
|
|
191
|
+
*/
|
|
157
192
|
const prepareDtoModels = (client) => {
|
|
158
193
|
const nameMap = new Map();
|
|
159
194
|
client.models.forEach(model => {
|
|
160
|
-
const
|
|
161
|
-
const
|
|
195
|
+
const baseName = getBaseName(model);
|
|
196
|
+
const rawName = `${baseName}Raw`;
|
|
197
|
+
const dtoName = `${baseName}Dto`;
|
|
162
198
|
model.rawName = rawName;
|
|
163
199
|
model.dtoName = dtoName;
|
|
200
|
+
model.exportName = baseName;
|
|
164
201
|
model.dtoKind = model.export === 'interface' ? 'class' : 'alias';
|
|
165
|
-
nameMap.set(
|
|
202
|
+
nameMap.set(baseName, { rawName, dtoName });
|
|
166
203
|
});
|
|
167
204
|
const resolveRaw = resolveTypeFactory(nameMap, 'raw');
|
|
168
205
|
const resolveDto = resolveTypeFactory(nameMap, 'dto');
|
|
@@ -177,7 +214,7 @@ const prepareDtoModels = (client) => {
|
|
|
177
214
|
}
|
|
178
215
|
model.properties.forEach(property => {
|
|
179
216
|
property.rawType = resolveRaw(property);
|
|
180
|
-
property.dtoType = resolveDto(property);
|
|
217
|
+
property.dtoType = finalizeDtoType(property, resolveDto(property));
|
|
181
218
|
property.dtoInit = buildDtoInit(property, nameMap);
|
|
182
219
|
property.dtoToJSON = buildDtoToJson(property, nameMap);
|
|
183
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":"
|
|
1
|
+
{"version":3,"file":"registerHandlebarTemplates.d.ts","sourceRoot":"","sources":["../../../src/core/utils/registerHandlebarTemplates.ts"],"names":[],"mappings":"AAkGA,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,CAyKZ"}
|
|
@@ -81,6 +81,7 @@ const CancelablePromise_1 = __importDefault(require("../../templatesCompiled/cli
|
|
|
81
81
|
const request_4 = __importDefault(require("../../templatesCompiled/client/core/request"));
|
|
82
82
|
const requestExecutor_1 = __importDefault(require("../../templatesCompiled/client/core/executor/requestExecutor"));
|
|
83
83
|
const createExecutorAdapter_1 = __importDefault(require("../../templatesCompiled/client/core/executor/createExecutorAdapter"));
|
|
84
|
+
const legacyRequestAdapter_1 = __importDefault(require("../../templatesCompiled/client/core/executor/legacyRequestAdapter"));
|
|
84
85
|
const interceptors_1 = __importDefault(require("../../templatesCompiled/client/core/interceptors/interceptors"));
|
|
85
86
|
const apiErrorInterceptor_1 = __importDefault(require("../../templatesCompiled/client/core/interceptors/apiErrorInterceptor"));
|
|
86
87
|
const withInterceptors_1 = __importDefault(require("../../templatesCompiled/client/core/interceptors/withInterceptors"));
|
|
@@ -205,6 +206,7 @@ function registerHandlebarTemplates(root) {
|
|
|
205
206
|
httpStatusCode: Handlebars.template(HttpStatusCode_1.default),
|
|
206
207
|
requestExecutor: Handlebars.template(requestExecutor_1.default),
|
|
207
208
|
createExecutorAdapter: Handlebars.template(createExecutorAdapter_1.default),
|
|
209
|
+
legacyRequestAdapter: Handlebars.template(legacyRequestAdapter_1.default),
|
|
208
210
|
interceptors: Handlebars.template(interceptors_1.default),
|
|
209
211
|
apiErrorInterceptor: Handlebars.template(apiErrorInterceptor_1.default),
|
|
210
212
|
withInterceptors: Handlebars.template(withInterceptors_1.default),
|
|
@@ -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,28 @@
|
|
|
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
|
+
* Преобразует семантические изменения в legacy DiffReportEntry.
|
|
24
|
+
* @param changes список семантических изменений
|
|
25
|
+
* @returns список legacy diff-записей
|
|
26
|
+
*/
|
|
27
|
+
export declare function semanticChangesToDiffEntries(changes: SemanticDiffChange[]): DiffReportEntry[];
|
|
28
|
+
//# 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;AAyBD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,EAAE,GAAG,eAAe,EAAE,CAa7F"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.semanticChangeTypeToAction = semanticChangeTypeToAction;
|
|
4
|
+
exports.semanticSeverityToDiffSeverity = semanticSeverityToDiffSeverity;
|
|
5
|
+
exports.semanticChangeToJsonPath = semanticChangeToJsonPath;
|
|
6
|
+
exports.semanticChangesToDiffEntries = semanticChangesToDiffEntries;
|
|
7
|
+
const semanticPointerToJsonPath_1 = require("./semanticPointerToJsonPath");
|
|
8
|
+
const REMOVED_CHANGE_TYPES = new Set(['model.removed', 'model.property.removed', 'model.enum.value.removed', 'operation.removed', 'operation.parameter.removed', 'operation.response.success.removed']);
|
|
9
|
+
const ADDED_CHANGE_TYPES = new Set(['model.added', 'model.property.added', 'model.enum.value.added', 'operation.added', 'operation.parameter.added', 'operation.response.success.added']);
|
|
10
|
+
const CHANGED_CHANGE_TYPES = new Set([
|
|
11
|
+
'model.property.type.changed',
|
|
12
|
+
'model.property.required.changed',
|
|
13
|
+
'operation.parameter.required.changed',
|
|
14
|
+
'operation.parameter.type.changed',
|
|
15
|
+
'operation.requestBody.required.changed',
|
|
16
|
+
'operation.response.success.type.changed',
|
|
17
|
+
]);
|
|
18
|
+
/**
|
|
19
|
+
* Преобразует тип семантического изменения в legacy diff action.
|
|
20
|
+
* @param changeType тип семантического изменения
|
|
21
|
+
* @returns действие legacy diff
|
|
22
|
+
*/
|
|
23
|
+
function semanticChangeTypeToAction(changeType) {
|
|
24
|
+
if (REMOVED_CHANGE_TYPES.has(changeType) || changeType.endsWith('.removed')) {
|
|
25
|
+
return 'removed';
|
|
26
|
+
}
|
|
27
|
+
if (ADDED_CHANGE_TYPES.has(changeType) || changeType.endsWith('.added')) {
|
|
28
|
+
return 'added';
|
|
29
|
+
}
|
|
30
|
+
if (CHANGED_CHANGE_TYPES.has(changeType) || changeType.endsWith('.changed')) {
|
|
31
|
+
return 'changed';
|
|
32
|
+
}
|
|
33
|
+
return 'changed';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Преобразует серьёзность семантического изменения в legacy diff severity.
|
|
37
|
+
* @param severity серьёзность семантического изменения
|
|
38
|
+
* @returns уровень серьёзности legacy diff
|
|
39
|
+
*/
|
|
40
|
+
function semanticSeverityToDiffSeverity(severity) {
|
|
41
|
+
if (severity === 'breaking') {
|
|
42
|
+
return 'breaking';
|
|
43
|
+
}
|
|
44
|
+
if (severity === 'non-breaking') {
|
|
45
|
+
return 'warning';
|
|
46
|
+
}
|
|
47
|
+
return 'info';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Строит legacy JSONPath для семантического изменения, включая суффикс `.type`.
|
|
51
|
+
* @param change семантическое изменение
|
|
52
|
+
* @returns JSONPath для legacy diff
|
|
53
|
+
*/
|
|
54
|
+
function semanticChangeToJsonPath(change) {
|
|
55
|
+
const basePath = (0, semanticPointerToJsonPath_1.semanticPointerToJsonPath)(change.path);
|
|
56
|
+
if (change.type === 'model.property.type.changed' || change.type === 'operation.parameter.type.changed') {
|
|
57
|
+
return `${basePath}.type`;
|
|
58
|
+
}
|
|
59
|
+
return basePath;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Извлекает значения from/to для legacy diff-записи.
|
|
63
|
+
* @param change семантическое изменение
|
|
64
|
+
* @returns значения до и после изменения
|
|
65
|
+
*/
|
|
66
|
+
function resolveSemanticChangeValues(change) {
|
|
67
|
+
if (change.type === 'model.property.required.changed' || change.type === 'operation.parameter.required.changed') {
|
|
68
|
+
return {
|
|
69
|
+
from: change.fromRequired,
|
|
70
|
+
to: change.toRequired,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (change.from !== undefined || change.to !== undefined) {
|
|
74
|
+
return {
|
|
75
|
+
from: change.from,
|
|
76
|
+
to: change.to,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Преобразует семантические изменения в legacy DiffReportEntry.
|
|
83
|
+
* @param changes список семантических изменений
|
|
84
|
+
* @returns список legacy diff-записей
|
|
85
|
+
*/
|
|
86
|
+
function semanticChangesToDiffEntries(changes) {
|
|
87
|
+
return changes.map(change => {
|
|
88
|
+
const { from, to } = resolveSemanticChangeValues(change);
|
|
89
|
+
return {
|
|
90
|
+
action: semanticChangeTypeToAction(change.type),
|
|
91
|
+
path: semanticChangeToJsonPath(change),
|
|
92
|
+
severity: semanticSeverityToDiffSeverity(change.severity),
|
|
93
|
+
from,
|
|
94
|
+
to,
|
|
95
|
+
note: change.message,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -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"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.semanticPointerToJsonPath = semanticPointerToJsonPath;
|
|
4
|
+
const jsonPath_1 = require("../../common/utils/jsonPath");
|
|
5
|
+
const HTTP_METHODS = new Set(['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'HEAD', 'PATCH', 'TRACE']);
|
|
6
|
+
const OPERATION_SUFFIX_MARKERS = ['parameters', 'requestBody', 'responses'];
|
|
7
|
+
/**
|
|
8
|
+
* Splits semantic operation pointer tail into operation key and nested suffix segments.
|
|
9
|
+
*/
|
|
10
|
+
function splitOperationPointerTail(tail) {
|
|
11
|
+
for (const marker of OPERATION_SUFFIX_MARKERS) {
|
|
12
|
+
const markerIndex = tail.indexOf(`/${marker}`);
|
|
13
|
+
if (markerIndex > 0) {
|
|
14
|
+
return {
|
|
15
|
+
operationKey: tail.slice(0, markerIndex),
|
|
16
|
+
suffix: [
|
|
17
|
+
marker,
|
|
18
|
+
...tail
|
|
19
|
+
.slice(markerIndex + marker.length + 1)
|
|
20
|
+
.split('/')
|
|
21
|
+
.filter(Boolean),
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { operationKey: tail, suffix: [] };
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parses semantic operation key "GET /pets" into HTTP method and route path.
|
|
30
|
+
*/
|
|
31
|
+
function parseOperationKey(operationKey) {
|
|
32
|
+
const match = operationKey.match(/^(GET|PUT|POST|DELETE|OPTIONS|HEAD|PATCH|TRACE)\s+(\S+)$/i);
|
|
33
|
+
if (!match) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const method = match[1].toLowerCase();
|
|
37
|
+
const routePath = match[2];
|
|
38
|
+
if (!HTTP_METHODS.has(match[1].toUpperCase())) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
return { method, routePath };
|
|
42
|
+
}
|
|
43
|
+
const decodePointerSegment = (segment) => segment.replace(/~1/g, '/').replace(/~0/g, '~');
|
|
44
|
+
/**
|
|
45
|
+
* Преобразует семантический JSON Pointer в legacy JSONPath, используемый генератором.
|
|
46
|
+
* @param pointer JSON Pointer или уже готовый JSONPath
|
|
47
|
+
* @returns legacy JSONPath
|
|
48
|
+
*/
|
|
49
|
+
function semanticPointerToJsonPath(pointer) {
|
|
50
|
+
if (pointer.startsWith('$')) {
|
|
51
|
+
return pointer;
|
|
52
|
+
}
|
|
53
|
+
if (!pointer.startsWith('#/')) {
|
|
54
|
+
return pointer;
|
|
55
|
+
}
|
|
56
|
+
const body = pointer.slice(2);
|
|
57
|
+
if (body.startsWith('paths/')) {
|
|
58
|
+
const tail = body.slice('paths/'.length);
|
|
59
|
+
const { operationKey, suffix } = splitOperationPointerTail(tail);
|
|
60
|
+
const parsedOperation = parseOperationKey(operationKey);
|
|
61
|
+
if (parsedOperation) {
|
|
62
|
+
return (0, jsonPath_1.toJsonPath)(['paths', parsedOperation.routePath, parsedOperation.method, ...suffix]);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const rawSegments = body.split('/').map(decodePointerSegment);
|
|
66
|
+
return (0, jsonPath_1.toJsonPath)(rawSegments);
|
|
67
|
+
}
|
|
@@ -7,12 +7,11 @@ import type { Service } from '../types/shared/Service.model';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare function forEachOperationInPath(pathObj: Record<string, any>, cb: (method: string, op: any) => void): void;
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
14
|
-
* @
|
|
15
|
-
* @returns existing or newly created Service
|
|
10
|
+
* Возвращает существующий сервис из map или создаёт новый.
|
|
11
|
+
* @param services map сервисов
|
|
12
|
+
* @param name имя сервиса
|
|
13
|
+
* @param [originName] исходное имя сервиса при создании
|
|
14
|
+
* @returns существующий или новый сервис
|
|
16
15
|
*/
|
|
17
16
|
export declare function ensureService(services: Map<string, Service>, name: string, originName?: string): Service;
|
|
18
17
|
/**
|
|
@@ -29,7 +28,7 @@ export declare function mergeOperationImportsIntoService(service: Service, opera
|
|
|
29
28
|
/**
|
|
30
29
|
* Finalize imports for a service:
|
|
31
30
|
* - Deduplicate and sort imports
|
|
32
|
-
* - Assign aliases for duplicate import names (name, name$
|
|
31
|
+
* - Assign aliases for duplicate import names (first keeps plain name, then name$2, name$3, ...)
|
|
33
32
|
* - Propagate assigned aliases to models referenced in operations (results, parameters)
|
|
34
33
|
*
|
|
35
34
|
* Modifies service in-place and returns it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serviceHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/serviceHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"serviceHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/serviceHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAM7D;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI,CAOhH;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAWxG;AAED;;;;;;;;;GASG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,CAMvF;AA+CD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAiBhE"}
|
|
@@ -5,6 +5,7 @@ exports.ensureService = ensureService;
|
|
|
5
5
|
exports.mergeOperationImportsIntoService = mergeOperationImportsIntoService;
|
|
6
6
|
exports.finalizeServiceImports = finalizeServiceImports;
|
|
7
7
|
const safeHasOwn_1 = require("../../common/utils/safeHasOwn");
|
|
8
|
+
const modelHelpers_1 = require("./modelHelpers");
|
|
8
9
|
const unique_1 = require("./unique");
|
|
9
10
|
const SUPPORTED_METHODS = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch'];
|
|
10
11
|
/**
|
|
@@ -23,12 +24,11 @@ function forEachOperationInPath(pathObj, cb) {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
31
|
-
* @returns existing or newly created Service
|
|
27
|
+
* Возвращает существующий сервис из map или создаёт новый.
|
|
28
|
+
* @param services map сервисов
|
|
29
|
+
* @param name имя сервиса
|
|
30
|
+
* @param [originName] исходное имя сервиса при создании
|
|
31
|
+
* @returns существующий или новый сервис
|
|
32
32
|
*/
|
|
33
33
|
function ensureService(services, name, originName) {
|
|
34
34
|
const existing = services.get(name);
|
|
@@ -100,7 +100,7 @@ function fillModelsByAlias(items = [], value) {
|
|
|
100
100
|
/**
|
|
101
101
|
* Finalize imports for a service:
|
|
102
102
|
* - Deduplicate and sort imports
|
|
103
|
-
* - Assign aliases for duplicate import names (name, name$
|
|
103
|
+
* - Assign aliases for duplicate import names (first keeps plain name, then name$2, name$3, ...)
|
|
104
104
|
* - Propagate assigned aliases to models referenced in operations (results, parameters)
|
|
105
105
|
*
|
|
106
106
|
* Modifies service in-place and returns it.
|
|
@@ -114,24 +114,7 @@ function finalizeServiceImports(service) {
|
|
|
114
114
|
const nameB = b.name.toLowerCase();
|
|
115
115
|
return nameA.localeCompare(nameB, 'en');
|
|
116
116
|
});
|
|
117
|
-
|
|
118
|
-
let index = 1;
|
|
119
|
-
service.imports = service.imports.map(value => {
|
|
120
|
-
if (previous && previous.name === value.name) {
|
|
121
|
-
if (index === 1) {
|
|
122
|
-
previous.alias = `${value.name}$${index}`;
|
|
123
|
-
index++;
|
|
124
|
-
}
|
|
125
|
-
value.alias = `${value.name}$${index}`;
|
|
126
|
-
index++;
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
value.alias = '';
|
|
130
|
-
index = 1;
|
|
131
|
-
}
|
|
132
|
-
previous = value;
|
|
133
|
-
return value;
|
|
134
|
-
});
|
|
117
|
+
(0, modelHelpers_1.assignDuplicateAliases)(service.imports);
|
|
135
118
|
for (const item of service.imports) {
|
|
136
119
|
for (const operation of service.operations) {
|
|
137
120
|
fillModelsByAlias(operation.results, item);
|