ts-openapi-codegen 2.0.0-beta.9 → 2.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +177 -18
- package/README.rus.md +177 -21
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiff.cli.test.js +365 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffRenameAndInvalidRegex.test.js +142 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.d.ts +2 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/__tests__/analyzeDiffTypeCoercion.test.js +137 -0
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts +17 -0
- package/dist/cli/analyzeDiff/analyzeDiff.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/analyzeDiff.js +105 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts +17 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/buildLegacyReport.js +54 -0
- package/dist/cli/analyzeDiff/ciSummary.d.ts +6 -0
- package/dist/cli/analyzeDiff/ciSummary.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ciSummary.js +20 -0
- package/dist/cli/analyzeDiff/diffEngine.d.ts +54 -0
- package/dist/cli/analyzeDiff/diffEngine.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/diffEngine.js +209 -0
- package/dist/cli/analyzeDiff/ignoreRules.d.ts +33 -0
- package/dist/cli/analyzeDiff/ignoreRules.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ignoreRules.js +93 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.d.ts +10 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/ignoreSemanticChanges.js +84 -0
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts +6 -0
- package/dist/cli/analyzeDiff/logLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/logLegacyReport.js +29 -0
- package/dist/cli/analyzeDiff/miracles.d.ts +89 -0
- package/dist/cli/analyzeDiff/miracles.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/miracles.js +325 -0
- package/dist/cli/analyzeDiff/pluginPaths.d.ts +5 -0
- package/dist/cli/analyzeDiff/pluginPaths.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/pluginPaths.js +13 -0
- package/dist/cli/analyzeDiff/report.d.ts +3 -0
- package/dist/cli/analyzeDiff/report.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/report.js +7 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.d.ts +6 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/semanticDiffContext.js +16 -0
- package/dist/cli/analyzeDiff/specParser.d.ts +22 -0
- package/dist/cli/analyzeDiff/specParser.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/specParser.js +80 -0
- package/dist/cli/analyzeDiff/types.d.ts +61 -0
- package/dist/cli/analyzeDiff/types.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/types.js +2 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts +6 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.d.ts.map +1 -0
- package/dist/cli/analyzeDiff/writeLegacyReport.js +21 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +13 -8
- package/dist/cli/checkAndUpdateConfig/constants.d.ts +0 -9
- package/dist/cli/checkAndUpdateConfig/constants.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/constants.js +1 -10
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +11 -7
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.js +6 -3
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.js +3 -2
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +5 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts.map +1 -1
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.js +2 -2
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.d.ts +2 -0
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.d.ts.map +1 -0
- package/dist/cli/generateOpenApiClient/__tests__/generateOpenApiClient.strict.test.js +152 -0
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts +6 -2
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.d.ts.map +1 -1
- package/dist/cli/generateOpenApiClient/generateOpenApiClient.js +70 -22
- package/dist/cli/index.js +62 -5
- package/dist/cli/initOpenApiConfig/init.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/init.js +19 -6
- package/dist/cli/initOpenApiConfig/initConfig.d.ts +1 -0
- package/dist/cli/initOpenApiConfig/initConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initConfig.js +47 -24
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts +8 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/initCustomRequest.js +40 -8
- package/dist/cli/initOpenApiConfig/utils/buildConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/buildConfig.js +60 -0
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/validateSpecFile.js +2 -1
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/utils/writeConfigFile.js +2 -1
- package/dist/cli/interactive/confirmDialog.d.ts.map +1 -1
- package/dist/cli/interactive/confirmDialog.js +3 -2
- package/dist/cli/interactive/constants.d.ts +2 -2
- package/dist/cli/interactive/constants.js +8 -8
- package/dist/cli/interactive/selectDialog.d.ts.map +1 -1
- package/dist/cli/interactive/selectDialog.js +11 -6
- package/dist/cli/previewChanges/previewChanges.d.ts.map +1 -1
- package/dist/cli/previewChanges/previewChanges.js +151 -39
- package/dist/cli/previewChanges/utils/updateOutputPaths.d.ts.map +1 -1
- package/dist/cli/previewChanges/utils/updateOutputPaths.js +6 -0
- package/dist/cli/schemas/analyzeDiff.d.ts +14 -0
- package/dist/cli/schemas/analyzeDiff.d.ts.map +1 -0
- package/dist/cli/schemas/analyzeDiff.js +28 -0
- package/dist/cli/schemas/generate.d.ts +9 -0
- package/dist/cli/schemas/generate.d.ts.map +1 -1
- package/dist/cli/schemas/generate.js +9 -0
- package/dist/cli/schemas/index.d.ts +3 -1
- package/dist/cli/schemas/index.d.ts.map +1 -1
- package/dist/cli/schemas/index.js +2 -0
- package/dist/common/Consts.d.ts +1 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +19 -2
- package/dist/common/Logger.d.ts +20 -1
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +70 -9
- package/dist/common/LoggerMessages.d.ts +136 -33
- package/dist/common/LoggerMessages.d.ts.map +1 -1
- package/dist/common/LoggerMessages.js +119 -45
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +20 -4
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts +4 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedBase.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts +10 -2
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts +77 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV4.js +41 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts +79 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedOptionsSchemaV5.js +19 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts +326 -28
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/AllVersionedSchemas/UnifiedVersionedSchemas.js +15 -17
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +52 -4
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +48 -7
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +6 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +4 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +6 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +6 -2
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +6 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +4 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +6 -2
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/__mocks__/compatibilityCases.js +40 -1
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/__tests__/allUtils.test.js +185 -0
- package/dist/common/VersionedSchema/Utils/__tests__/compareShapes.test.js +20 -3
- package/dist/common/VersionedSchema/Utils/__tests__/migrateDataToLatestSchemaVersion.test.js +19 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +4 -0
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.js +68 -23
- package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.d.ts +1 -1
- package/dist/common/VersionedSchema/Utils/getUniqueKeysFromSchemas.js +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +10 -0
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +34 -15
- package/dist/common/__tests__/Logger.test.d.ts +2 -0
- package/dist/common/__tests__/Logger.test.d.ts.map +1 -0
- package/dist/common/__tests__/Logger.test.js +100 -0
- package/dist/common/utils/__tests__/convertArrayToObject.test.js +67 -169
- package/dist/common/utils/__tests__/eslintFix.test.d.ts +2 -0
- package/dist/common/utils/__tests__/eslintFix.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/eslintFix.test.js +134 -0
- package/dist/common/utils/__tests__/format.test.d.ts +2 -0
- package/dist/common/utils/__tests__/format.test.d.ts.map +1 -0
- package/dist/common/utils/__tests__/format.test.js +90 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -1
- package/dist/common/utils/convertArrayToObject.js +54 -14
- package/dist/common/utils/eslintFix.d.ts +7 -0
- package/dist/common/utils/eslintFix.d.ts.map +1 -0
- package/dist/common/utils/eslintFix.js +78 -0
- package/dist/common/utils/format.d.ts +1 -1
- package/dist/common/utils/format.d.ts.map +1 -1
- package/dist/common/utils/format.js +39 -15
- package/dist/common/utils/jsonPath.d.ts +5 -0
- package/dist/common/utils/jsonPath.d.ts.map +1 -0
- package/dist/common/utils/jsonPath.js +27 -0
- package/dist/common/utils/normalizeObject.d.ts +2 -0
- package/dist/common/utils/normalizeObject.d.ts.map +1 -0
- package/dist/common/utils/normalizeObject.js +63 -0
- package/dist/core/Context.d.ts +8 -1
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +23 -4
- package/dist/core/OpenApiClient.d.ts +2 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -1
- package/dist/core/OpenApiClient.js +127 -6
- package/dist/core/WriteClient.d.ts +12 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +83 -8
- package/dist/core/__tests__/WriteClient.test.js +6 -1
- package/dist/core/api/v2/parser/__tests__/getModel.test.d.ts +2 -0
- package/dist/core/api/v2/parser/__tests__/getModel.test.d.ts.map +1 -0
- package/dist/core/api/v2/parser/__tests__/getModel.test.js +34 -0
- package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModel.js +6 -1
- package/dist/core/api/v2/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperation.js +2 -0
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +9 -1
- package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getType.js +2 -1
- package/dist/core/api/v2/types/OpenApiSchema.model.d.ts +2 -0
- package/dist/core/api/v2/types/OpenApiSchema.model.d.ts.map +1 -1
- package/dist/core/api/v3/parser/__tests__/getContent.test.d.ts +2 -0
- package/dist/core/api/v3/parser/__tests__/getContent.test.d.ts.map +1 -0
- package/dist/core/api/v3/parser/__tests__/getContent.test.js +65 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.d.ts +2 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.d.ts.map +1 -0
- package/dist/core/api/v3/parser/__tests__/getModel.test.js +34 -0
- package/dist/core/api/v3/parser/getContent.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getContent.js +21 -11
- package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModel.js +6 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperation.js +2 -0
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +9 -1
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +2 -1
- package/dist/core/api/v3/types/OpenApiSchema.model.d.ts +2 -0
- package/dist/core/api/v3/types/OpenApiSchema.model.d.ts.map +1 -1
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.d.ts +2 -0
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.d.ts.map +1 -0
- package/dist/core/governance/__tests__/evaluateGovernanceRules.test.js +100 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.d.ts +2 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.d.ts.map +1 -0
- package/dist/core/governance/__tests__/loadGovernanceConfig.test.js +71 -0
- package/dist/core/governance/evaluateGovernanceRules.d.ts +42 -0
- package/dist/core/governance/evaluateGovernanceRules.d.ts.map +1 -0
- package/dist/core/governance/evaluateGovernanceRules.js +134 -0
- package/dist/core/governance/governanceConfigSchema.d.ts +4 -0
- package/dist/core/governance/governanceConfigSchema.d.ts.map +1 -0
- package/dist/core/governance/governanceConfigSchema.js +39 -0
- package/dist/core/governance/loadGovernanceConfig.d.ts +7 -0
- package/dist/core/governance/loadGovernanceConfig.d.ts.map +1 -0
- package/dist/core/governance/loadGovernanceConfig.js +60 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +4 -2
- package/dist/core/plugins/GeneratorPlugin.model.d.ts +42 -0
- package/dist/core/plugins/GeneratorPlugin.model.d.ts.map +1 -0
- package/dist/core/plugins/GeneratorPlugin.model.js +2 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.d.ts +2 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.d.ts.map +1 -0
- package/dist/core/plugins/__tests__/applySemanticDiffPluginHooks.test.js +115 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.d.ts +2 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.d.ts.map +1 -0
- package/dist/core/plugins/__tests__/loadGeneratorPlugins.test.js +62 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts +28 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.d.ts.map +1 -0
- package/dist/core/plugins/applySemanticDiffPluginHooks.js +160 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.d.ts +6 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.d.ts.map +1 -0
- package/dist/core/plugins/builtins/xTypescriptTypePlugin.js +13 -0
- package/dist/core/plugins/getBuiltinPlugins.d.ts +6 -0
- package/dist/core/plugins/getBuiltinPlugins.d.ts.map +1 -0
- package/dist/core/plugins/getBuiltinPlugins.js +10 -0
- package/dist/core/plugins/index.d.ts +4 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/index.js +5 -0
- package/dist/core/plugins/loadGeneratorPlugins.d.ts +6 -0
- package/dist/core/plugins/loadGeneratorPlugins.d.ts.map +1 -0
- package/dist/core/plugins/loadGeneratorPlugins.js +94 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.d.ts +2 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.d.ts.map +1 -0
- package/dist/core/semanticDiff/__tests__/analyzeOpenApiDiff.test.js +537 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.d.ts +2 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.d.ts.map +1 -0
- package/dist/core/semanticDiff/__tests__/semanticDiffReportSchema.test.js +66 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts +45 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.d.ts.map +1 -0
- package/dist/core/semanticDiff/analyzeOpenApiDiff.js +640 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts +11 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.d.ts.map +1 -0
- package/dist/core/semanticDiff/semanticDiffReportSchema.js +132 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.d.ts +2 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.d.ts.map +1 -0
- package/dist/core/strict/__tests__/validateOpenApiStrict.test.js +156 -0
- package/dist/core/strict/validateOpenApiStrict.d.ts +43 -0
- package/dist/core/strict/validateOpenApiStrict.d.ts.map +1 -0
- package/dist/core/strict/validateOpenApiStrict.js +253 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts +2 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -1
- package/dist/core/types/base/Templates.model.d.ts +4 -1
- package/dist/core/types/base/Templates.model.d.ts.map +1 -1
- package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts +6 -0
- package/dist/core/types/enums/EmptySchemaStrategy.enum.d.ts.map +1 -0
- package/dist/core/types/enums/EmptySchemaStrategy.enum.js +9 -0
- package/dist/core/types/enums/ModelsMode.enum.d.ts +5 -0
- package/dist/core/types/enums/ModelsMode.enum.d.ts.map +1 -0
- package/dist/core/types/enums/ModelsMode.enum.js +8 -0
- package/dist/core/types/shared/Client.model.d.ts +2 -0
- package/dist/core/types/shared/Client.model.d.ts.map +1 -1
- package/dist/core/types/shared/DiffInfo.model.d.ts +13 -0
- package/dist/core/types/shared/DiffInfo.model.d.ts.map +1 -0
- package/dist/core/types/shared/DiffInfo.model.js +2 -0
- package/dist/core/types/shared/Miracle.model.d.ts +13 -0
- package/dist/core/types/shared/Miracle.model.d.ts.map +1 -0
- package/dist/core/types/shared/Miracle.model.js +2 -0
- package/dist/core/types/shared/Model.model.d.ts +23 -0
- package/dist/core/types/shared/Model.model.d.ts.map +1 -1
- package/dist/core/types/shared/Operation.model.d.ts +5 -0
- package/dist/core/types/shared/Operation.model.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.d.ts.map +1 -1
- package/dist/core/utils/__mocks__/templates.js +9 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.d.ts +2 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/applyDiffReportToClient.test.js +108 -0
- package/dist/core/utils/__tests__/getMappedType.test.js +2 -0
- package/dist/core/utils/__tests__/getOperationResponseCode.test.js +7 -2
- package/dist/core/utils/__tests__/getOperationResults.test.d.ts +2 -0
- package/dist/core/utils/__tests__/getOperationResults.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/getOperationResults.test.js +43 -0
- package/dist/core/utils/__tests__/getRelativeModelPath.test.d.ts +2 -0
- package/dist/core/utils/__tests__/getRelativeModelPath.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/getRelativeModelPath.test.js +27 -0
- package/dist/core/utils/__tests__/modelHelpers.test.d.ts +2 -0
- package/dist/core/utils/__tests__/modelHelpers.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/modelHelpers.test.js +151 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts +2 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/postProcessModelImports.test.js +67 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts +2 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/postProcessServiceImports.test.js +26 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.d.ts +2 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/prepareDtoModels.test.js +116 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveRefPath.test.js +22 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.d.ts +2 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/serviceHelpers.test.js +122 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/writeClientExecutor.test.js +20 -0
- package/dist/core/utils/__tests__/writeClientModels.test.js +50 -0
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +2 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts +14 -0
- package/dist/core/utils/applyDiffReportToClient.d.ts.map +1 -0
- package/dist/core/utils/applyDiffReportToClient.js +367 -0
- package/dist/core/utils/getMappedType.d.ts.map +1 -1
- package/dist/core/utils/getMappedType.js +2 -0
- package/dist/core/utils/getOperationResponseCode.d.ts.map +1 -1
- package/dist/core/utils/getOperationResponseCode.js +10 -8
- package/dist/core/utils/getRelativeModelPath.d.ts +9 -0
- package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -0
- package/dist/core/utils/getRelativeModelPath.js +37 -0
- package/dist/core/utils/loadDiffReport.d.ts +39 -0
- package/dist/core/utils/loadDiffReport.d.ts.map +1 -0
- package/dist/core/utils/loadDiffReport.js +51 -0
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +37 -3
- package/dist/core/utils/postProcessModelImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessModelImports.js +14 -1
- package/dist/core/utils/postProcessServiceImports.d.ts.map +1 -1
- package/dist/core/utils/postProcessServiceImports.js +1 -2
- package/dist/core/utils/precompileTemplates.js +1 -0
- package/dist/core/utils/prepareDtoModels.d.ts +3 -0
- package/dist/core/utils/prepareDtoModels.d.ts.map +1 -0
- package/dist/core/utils/prepareDtoModels.js +189 -0
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +29 -1
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +48 -41
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefPath.js +1 -4
- package/dist/core/utils/validateRawOptions.d.ts +1 -1
- package/dist/core/utils/validateRawOptions.d.ts.map +1 -1
- package/dist/core/utils/validateRawOptions.js +4 -2
- package/dist/core/utils/writeClientCore.d.ts +2 -0
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +6 -1
- package/dist/core/utils/writeClientCoreIndex.d.ts +1 -0
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +2 -2
- package/dist/core/utils/writeClientExecutor.d.ts +6 -1
- package/dist/core/utils/writeClientExecutor.d.ts.map +1 -1
- package/dist/core/utils/writeClientExecutor.js +22 -3
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientFullIndex.js +3 -1
- package/dist/core/utils/writeClientModels.d.ts +6 -0
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +24 -3
- package/dist/core/utils/writeClientModelsIndex.d.ts +2 -0
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.js +2 -2
- package/dist/core/utils/writeClientSchemas.d.ts +6 -1
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +16 -3
- package/dist/core/utils/writeClientServices.d.ts +2 -0
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +6 -2
- package/dist/templatesCompiled/cli/openApiConfig.d.ts +4 -1
- package/dist/templatesCompiled/cli/openApiConfig.d.ts.map +1 -1
- package/dist/templatesCompiled/cli/openApiConfig.js +88 -37
- package/dist/templatesCompiled/client/core/ApiError.js +1 -1
- package/dist/templatesCompiled/client/core/ApiRequestOptions.js +1 -1
- package/dist/templatesCompiled/client/core/ApiResult.js +1 -1
- package/dist/templatesCompiled/client/core/BaseDto.d.ts +8 -0
- package/dist/templatesCompiled/client/core/BaseDto.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/BaseDto.js +18 -0
- package/dist/templatesCompiled/client/core/axios/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/axios/request.js +3 -3
- package/dist/templatesCompiled/client/core/axios/sendRequest.js +4 -4
- package/dist/templatesCompiled/client/core/dtoUtils.d.ts +8 -0
- package/dist/templatesCompiled/client/core/dtoUtils.d.ts.map +1 -0
- package/dist/templatesCompiled/client/core/dtoUtils.js +18 -0
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts +2 -0
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.d.ts.map +1 -1
- package/dist/templatesCompiled/client/core/executor/createExecutorAdapter.js +13 -8
- package/dist/templatesCompiled/client/core/executor/requestExecutor.js +1 -1
- package/dist/templatesCompiled/client/core/fetch/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/fetch/request.js +3 -3
- package/dist/templatesCompiled/client/core/functions/catchErrors.js +1 -1
- package/dist/templatesCompiled/client/core/functions/isBinary.js +1 -1
- package/dist/templatesCompiled/client/core/interceptors/withInterceptors.js +1 -1
- package/dist/templatesCompiled/client/core/node/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/node/request.js +3 -3
- package/dist/templatesCompiled/client/core/xhr/getResponseBody.js +1 -1
- package/dist/templatesCompiled/client/core/xhr/request.js +3 -3
- package/dist/templatesCompiled/client/core/xhr/sendRequest.js +4 -4
- package/dist/templatesCompiled/client/exportClient.d.ts +4 -0
- package/dist/templatesCompiled/client/exportClient.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportClient.js +51 -13
- package/dist/templatesCompiled/client/exportModels.d.ts +34 -0
- package/dist/templatesCompiled/client/exportModels.d.ts.map +1 -0
- package/dist/templatesCompiled/client/exportModels.js +280 -0
- package/dist/templatesCompiled/client/exportSchema.d.ts +5 -1
- package/dist/templatesCompiled/client/exportSchema.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportSchema.js +37 -7
- package/dist/templatesCompiled/client/exportService.d.ts +9 -4
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +96 -37
- package/dist/templatesCompiled/client/indexCore.d.ts +3 -1
- package/dist/templatesCompiled/client/indexCore.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexCore.js +13 -2
- package/dist/templatesCompiled/client/indexFull.d.ts +10 -7
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +54 -33
- package/dist/templatesCompiled/client/indexModels.d.ts +7 -5
- package/dist/templatesCompiled/client/indexModels.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexModels.js +27 -18
- package/dist/templatesCompiled/client/indexSimple.d.ts +1 -0
- package/dist/templatesCompiled/client/indexSimple.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexSimple.js +4 -1
- package/dist/templatesCompiled/client/joi/exportSchema.js +5 -5
- package/dist/templatesCompiled/client/joi/partials/joiSchema.js +7 -7
- package/dist/templatesCompiled/client/joi/partials/joiSchemaComposition.js +4 -4
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts +27 -19
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/joi/partials/joiSchemaGeneric.js +144 -63
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts +5 -3
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/joi/partials/joiSchemaInterface.js +39 -12
- package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts +1 -0
- package/dist/templatesCompiled/client/jsonschema/exportSchema.d.ts.map +1 -1
- package/dist/templatesCompiled/client/jsonschema/exportSchema.js +21 -17
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchema.js +7 -7
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaArray.js +5 -5
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaComposition.js +2 -2
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaDictionary.js +5 -5
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts +3 -1
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/jsonschema/partials/jsonschemaSchemaInterface.js +45 -15
- package/dist/templatesCompiled/client/partials/exportInterface.d.ts +13 -5
- package/dist/templatesCompiled/client/partials/exportInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/exportInterface.js +91 -21
- package/dist/templatesCompiled/client/partials/result.d.ts +6 -4
- package/dist/templatesCompiled/client/partials/result.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/result.js +16 -6
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts +1 -0
- package/dist/templatesCompiled/client/partials/serviceOption.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/serviceOption.js +11 -4
- package/dist/templatesCompiled/client/yup/exportSchema.js +3 -3
- package/dist/templatesCompiled/client/yup/partials/yupSchema.js +7 -7
- package/dist/templatesCompiled/client/yup/partials/yupSchemaComposition.js +4 -4
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts +22 -16
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/yup/partials/yupSchemaGeneric.js +72 -60
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts +5 -3
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/yup/partials/yupSchemaInterface.js +39 -12
- package/dist/templatesCompiled/client/zod/exportSchema.js +3 -3
- package/dist/templatesCompiled/client/zod/partials/zodSchema.js +7 -7
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts +5 -6
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaArray.js +14 -28
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts +3 -0
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaComposition.js +32 -8
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts +3 -4
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaDictionary.js +9 -23
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts +27 -19
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaGeneric.js +77 -61
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts +4 -2
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.d.ts.map +1 -1
- package/dist/templatesCompiled/client/zod/partials/zodSchemaInterface.js +18 -7
- package/package.json +8 -6
- package/dist/common/defaultOptions.d.ts +0 -3
- package/dist/common/defaultOptions.d.ts.map +0 -1
- package/dist/common/defaultOptions.js +0 -28
- package/dist/core/utils/advancedDeduplicatePath.d.ts +0 -5
- package/dist/core/utils/advancedDeduplicatePath.d.ts.map +0 -1
- package/dist/core/utils/advancedDeduplicatePath.js +0 -29
|
@@ -4,38 +4,83 @@ exports.determineBestMatchingSchemaVersion = determineBestMatchingSchemaVersion;
|
|
|
4
4
|
const validateZodOptions_1 = require("../../Validation/validateZodOptions");
|
|
5
5
|
const getUniqueKeysFromSchemas_1 = require("./getUniqueKeysFromSchemas");
|
|
6
6
|
const getUniqueObjectKeys_1 = require("./getUniqueObjectKeys");
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Counts unknown keys using a strict schema variant.
|
|
9
|
+
* The strict check is used only for ranking candidates, not for final validation.
|
|
10
|
+
*/
|
|
11
|
+
function getStrictUnrecognizedKeyCount(schema, inputData) {
|
|
12
|
+
const strictResult = (0, validateZodOptions_1.validateZodOptionsRaw)(schema.strict(), inputData);
|
|
13
|
+
if (strictResult.success) {
|
|
14
|
+
return 0;
|
|
15
|
+
}
|
|
16
|
+
return strictResult.error.issues.reduce((count, issue) => {
|
|
17
|
+
if (issue.code !== 'unrecognized_keys' || !('keys' in issue)) {
|
|
18
|
+
return count;
|
|
19
|
+
}
|
|
20
|
+
return count + issue.keys.length;
|
|
21
|
+
}, 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Compares two schema candidates and returns the better one.
|
|
25
|
+
* Priority:
|
|
26
|
+
* 1) fewer structural errors;
|
|
27
|
+
* 2) fewer strict-mode unknown keys;
|
|
28
|
+
* 3) more matching keys;
|
|
29
|
+
* 4) newer version inside the same schema family;
|
|
30
|
+
* 5) lower index when schema families differ.
|
|
31
|
+
*/
|
|
32
|
+
function compareCandidates(best, current) {
|
|
33
|
+
if (current.structuralErrorCount !== best.structuralErrorCount) {
|
|
34
|
+
return current.structuralErrorCount < best.structuralErrorCount ? current : best;
|
|
35
|
+
}
|
|
36
|
+
if (current.strictUnrecognizedKeyCount !== best.strictUnrecognizedKeyCount) {
|
|
37
|
+
return current.strictUnrecognizedKeyCount < best.strictUnrecognizedKeyCount ? current : best;
|
|
38
|
+
}
|
|
39
|
+
if (current.matchingKeysCount !== best.matchingKeysCount) {
|
|
40
|
+
return current.matchingKeysCount > best.matchingKeysCount ? current : best;
|
|
41
|
+
}
|
|
42
|
+
if (current.type === best.type) {
|
|
43
|
+
return current.index > best.index ? current : best;
|
|
44
|
+
}
|
|
45
|
+
return current.index < best.index ? current : best;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Determines the best matching schema version for input data.
|
|
49
|
+
* `invalid_value` issues are intentionally ignored to allow migration from older enum/value variants.
|
|
50
|
+
*/
|
|
8
51
|
function determineBestMatchingSchemaVersion(inputData, versionedSchemas) {
|
|
9
52
|
if (!versionedSchemas.length) {
|
|
10
53
|
throw new Error('The list of schemes cannot be empty');
|
|
11
54
|
}
|
|
12
55
|
const inputKeys = (0, getUniqueObjectKeys_1.getUniqueObjectKeys)(inputData);
|
|
13
|
-
const
|
|
14
|
-
|
|
56
|
+
const schemaMatches = versionedSchemas.map(({ schema, baseSchema, version, type }, idx) => {
|
|
57
|
+
const schemaKeys = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([schema]);
|
|
58
|
+
const matchingKeysCount = inputKeys.filter(key => schemaKeys.has(key)).length;
|
|
59
|
+
const strictUnrecognizedKeyCount = getStrictUnrecognizedKeyCount(baseSchema, inputData);
|
|
15
60
|
const validationResult = (0, validateZodOptions_1.validateZodOptionsRaw)(schema, inputData);
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
.filter((match) => match !== null);
|
|
20
|
-
if (matchingSchemas.length > 0) {
|
|
21
|
-
const latestMatch = matchingSchemas.reduce((prev, curr) => (curr.index > prev.index ? curr : prev));
|
|
61
|
+
const structuralErrorCount = !validationResult.success
|
|
62
|
+
? validationResult.error.issues.filter(issue => issue.code !== 'invalid_value').length
|
|
63
|
+
: 0;
|
|
22
64
|
return {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
65
|
+
index: idx,
|
|
66
|
+
version,
|
|
67
|
+
type,
|
|
68
|
+
structuralErrorCount,
|
|
69
|
+
strictUnrecognizedKeyCount,
|
|
70
|
+
matchingKeysCount,
|
|
26
71
|
};
|
|
27
|
-
}
|
|
28
|
-
const schemaMatches = versionedSchemas.map(({ schema, version }, idx) => {
|
|
29
|
-
const schemaKeys = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([schema]);
|
|
30
|
-
const validationResult = (0, validateZodOptions_1.validateZodOptionsRaw)(schema, inputData);
|
|
31
|
-
const errorFields = !validationResult.success ? validationResult.error.issues.filter(err => err.code !== 'invalid_value') : [];
|
|
32
|
-
const matchingKeys = inputKeys.filter(key => schemaKeys.has(key));
|
|
33
|
-
return { index: idx, version, errorFields, matchingKeys };
|
|
34
72
|
});
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
73
|
+
const structurallyValidMatches = schemaMatches.filter(match => match.structuralErrorCount === 0);
|
|
74
|
+
if (structurallyValidMatches.length > 0) {
|
|
75
|
+
const bestStructurallyValidMatch = structurallyValidMatches.reduce(compareCandidates);
|
|
76
|
+
const firstVersion = structurallyValidMatches.reduce((earliest, current) => (current.index < earliest.index ? current : earliest)).version;
|
|
77
|
+
return {
|
|
78
|
+
lastVersionIndex: bestStructurallyValidMatch.index,
|
|
79
|
+
latestVersion: bestStructurallyValidMatch.version,
|
|
80
|
+
firstVersion,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const bestMatch = schemaMatches.reduce(compareCandidates);
|
|
39
84
|
return {
|
|
40
85
|
lastVersionIndex: bestMatch.index,
|
|
41
86
|
latestVersion: bestMatch.version,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
/**
|
|
3
3
|
* Get all the unique parameter keys of all Joi schemes in the array
|
|
4
|
-
* @param schemas array of
|
|
4
|
+
* @param schemas array of zod schemes
|
|
5
5
|
* @returns All the unique parameter keys of all Joi schemes in the array
|
|
6
6
|
*/
|
|
7
7
|
export declare function getUniqueKeysFromSchemas(schemas: z.ZodTypeAny[]): Set<string>;
|
|
@@ -18,7 +18,7 @@ function collectKeys(schema, result) {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Get all the unique parameter keys of all Joi schemes in the array
|
|
21
|
-
* @param schemas array of
|
|
21
|
+
* @param schemas array of zod schemes
|
|
22
22
|
* @returns All the unique parameter keys of all Joi schemes in the array
|
|
23
23
|
*/
|
|
24
24
|
function getUniqueKeysFromSchemas(schemas) {
|
|
@@ -2,18 +2,28 @@ import { z } from 'zod';
|
|
|
2
2
|
import { EMigrationMode } from '../../Enums';
|
|
3
3
|
import { EVersionedSchemaType } from '../Enums';
|
|
4
4
|
import { SchemaMigrationPlan, VersionedSchema, VersionMatchResult } from '../Types';
|
|
5
|
+
/**
|
|
6
|
+
* Input arguments for migrating arbitrary config data to the latest schema version.
|
|
7
|
+
*/
|
|
5
8
|
type MigrateToLatestProps = {
|
|
6
9
|
rawInput: Record<string, any>;
|
|
7
10
|
migrationPlans: SchemaMigrationPlan<Record<string, any>, Record<string, any>>[];
|
|
8
11
|
versionedSchemas: VersionedSchema<z.ZodTypeAny>[];
|
|
9
12
|
migrationMode: EMigrationMode;
|
|
10
13
|
};
|
|
14
|
+
/**
|
|
15
|
+
* Result of successful migration to the latest schema.
|
|
16
|
+
*/
|
|
11
17
|
type MigrateToLatestResult = {
|
|
12
18
|
value: Record<string, any>;
|
|
13
19
|
guessedVersion: VersionMatchResult;
|
|
14
20
|
schemaVersion: string;
|
|
15
21
|
schemaType: EVersionedSchemaType;
|
|
16
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* Migrates raw input through the migration graph to the latest schema version.
|
|
25
|
+
* Migration path is resolved by `fromVersion -> toVersion` links from `migrationPlans`.
|
|
26
|
+
*/
|
|
17
27
|
export declare function migrateDataToLatestSchemaVersion({ rawInput, migrationPlans, versionedSchemas, migrationMode }: MigrateToLatestProps): MigrateToLatestResult | null;
|
|
18
28
|
export {};
|
|
19
29
|
//# sourceMappingURL=migrateDataToLatestSchemaVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrateDataToLatestSchemaVersion.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"migrateDataToLatestSchemaVersion.d.ts","sourceRoot":"","sources":["../../../../src/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AASpF;;GAEG;AACH,KAAK,oBAAoB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,cAAc,EAAE,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC;IAChF,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;IAClD,aAAa,EAAE,cAAc,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,KAAK,qBAAqB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,cAAc,EAAE,kBAAkB,CAAC;IACnC,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,oBAAoB,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,qBAAqB,GAAG,IAAI,CAkFlK"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateDataToLatestSchemaVersion = migrateDataToLatestSchemaVersion;
|
|
4
|
+
const Consts_1 = require("../../Consts");
|
|
5
|
+
const LoggerMessages_1 = require("../../LoggerMessages");
|
|
4
6
|
const Enums_1 = require("../../Enums");
|
|
5
7
|
const validateZodOptions_1 = require("../../Validation/validateZodOptions");
|
|
6
8
|
const determineBestMatchingSchemaVersion_1 = require("./determineBestMatchingSchemaVersion");
|
|
@@ -10,6 +12,10 @@ const getUniqueKeysFromSchemas_1 = require("./getUniqueKeysFromSchemas");
|
|
|
10
12
|
const getUniqueObjectKeys_1 = require("./getUniqueObjectKeys");
|
|
11
13
|
const replaceInvalidKeysWithMappedNames_1 = require("./replaceInvalidKeysWithMappedNames");
|
|
12
14
|
const validateAndSuggestKeyCorrections_1 = require("./validateAndSuggestKeyCorrections");
|
|
15
|
+
/**
|
|
16
|
+
* Migrates raw input through the migration graph to the latest schema version.
|
|
17
|
+
* Migration path is resolved by `fromVersion -> toVersion` links from `migrationPlans`.
|
|
18
|
+
*/
|
|
13
19
|
function migrateDataToLatestSchemaVersion({ rawInput, migrationPlans, versionedSchemas, migrationMode }) {
|
|
14
20
|
const schemas = versionedSchemas.map(el => el.schema);
|
|
15
21
|
const allUniqueKeysFromSchemas = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)(schemas);
|
|
@@ -20,34 +26,47 @@ function migrateDataToLatestSchemaVersion({ rawInput, migrationPlans, versionedS
|
|
|
20
26
|
const schemaPossibleKeys = (0, getUniqueKeysFromSchemas_1.getUniqueKeysFromSchemas)([guessedValidationSchema]);
|
|
21
27
|
const replacingKeysMap = (0, generateKeyMappingForInvalidKeys_1.generateKeyMappingForInvalidKeys)(allUniqueKeysFromRawInput, schemaPossibleKeys);
|
|
22
28
|
let currentData = replacingKeysMap.size ? (0, replaceInvalidKeysWithMappedNames_1.replaceInvalidKeysWithMappedNames)(rawInput, replacingKeysMap) : rawInput;
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
const actualSchema = versionedSchemas[versionedSchemas.length - 1];
|
|
30
|
+
const schemasByVersion = new Map(versionedSchemas.map(schemaInfo => [schemaInfo.version, schemaInfo.schema]));
|
|
31
|
+
const migrationPlanByFromVersion = new Map(migrationPlans.map(plan => [plan.fromVersion, plan]));
|
|
32
|
+
let currentVersion = guessedVersion.latestVersion;
|
|
33
|
+
const visitedVersions = new Set([currentVersion]);
|
|
34
|
+
while (currentVersion !== actualSchema.version) {
|
|
35
|
+
const currentVersionSchema = schemasByVersion.get(currentVersion);
|
|
36
|
+
if (!currentVersionSchema) {
|
|
37
|
+
throw new Error(`No schema found for version ${currentVersion}.`);
|
|
38
|
+
}
|
|
39
|
+
const firstValidationResult = (0, validateZodOptions_1.validateZodOptionsRaw)(currentVersionSchema, currentData);
|
|
28
40
|
if (!firstValidationResult.success) {
|
|
29
41
|
(0, getCurrentErrorMessage_1.getCurrentErrorMessage)(firstValidationResult.error, replacingKeysMap);
|
|
30
42
|
}
|
|
31
|
-
const
|
|
32
|
-
const migrationPlan = migrationPlans.find(p => p.fromVersion === fromVersion);
|
|
43
|
+
const migrationPlan = migrationPlanByFromVersion.get(currentVersion);
|
|
33
44
|
if (!migrationPlan) {
|
|
34
|
-
const availableVersions =
|
|
35
|
-
throw new Error(`No migration plan from ${
|
|
45
|
+
const availableVersions = Array.from(migrationPlanByFromVersion.keys()).join(', ');
|
|
46
|
+
throw new Error(`No migration plan from ${currentVersion}. ` +
|
|
36
47
|
`Available migration plans: ${availableVersions}. ` +
|
|
37
48
|
`This usually means the migration chain is incomplete.`);
|
|
38
49
|
}
|
|
39
|
-
const
|
|
50
|
+
const nextVersion = migrationPlan.toVersion;
|
|
51
|
+
const nextSchema = schemasByVersion.get(nextVersion);
|
|
52
|
+
if (!nextSchema) {
|
|
53
|
+
throw new Error(`Migration plan from ${migrationPlan.fromVersion} points to unknown schema version ${nextVersion}.`);
|
|
54
|
+
}
|
|
40
55
|
const migratedRaw = migrationPlan.migrate(currentData);
|
|
41
|
-
const validationResult = (0, validateZodOptions_1.validateZodOptions)(
|
|
56
|
+
const validationResult = (0, validateZodOptions_1.validateZodOptions)(nextSchema, migratedRaw);
|
|
42
57
|
if (!validationResult.success) {
|
|
43
|
-
throw new Error(`Migration from ${
|
|
58
|
+
throw new Error(`Migration from ${currentVersion} to ${nextVersion} failed validation. ` +
|
|
44
59
|
`Error: ${validationResult.errors.join('\n')}. ` +
|
|
45
60
|
`Migration description: ${migrationPlan.description || 'No description provided'}.`);
|
|
46
61
|
}
|
|
47
62
|
currentData = { ...migratedRaw };
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
63
|
+
currentVersion = nextVersion;
|
|
64
|
+
if (visitedVersions.has(currentVersion)) {
|
|
65
|
+
throw new Error(`Migration loop detected at version ${currentVersion}.`);
|
|
66
|
+
}
|
|
67
|
+
visitedVersions.add(currentVersion);
|
|
68
|
+
if (currentVersion === actualSchema.version && migrationMode === Enums_1.EMigrationMode.GENERATE_OPENAPI) {
|
|
69
|
+
Consts_1.APP_LOGGER.warn(LoggerMessages_1.LOGGER_MESSAGES.MIGRATION.OPENAPI_SCHEMA_MIGRATED);
|
|
51
70
|
}
|
|
52
71
|
}
|
|
53
72
|
const validationResult = (0, validateZodOptions_1.validateZodOptionsRaw)(actualSchema.schema, currentData);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logger.test.d.ts","sourceRoot":"","sources":["../../../src/common/__tests__/Logger.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
|
+
const node_test_1 = require("node:test");
|
|
8
|
+
const Enums_1 = require("../Enums");
|
|
9
|
+
const Logger_1 = require("../Logger");
|
|
10
|
+
const LoggerMessages_1 = require("../LoggerMessages");
|
|
11
|
+
(0, node_test_1.describe)('@unit: Logger', () => {
|
|
12
|
+
(0, node_test_1.test)('errorWithHint should log error with recommendation for known code', () => {
|
|
13
|
+
const logger = new Logger_1.Logger({
|
|
14
|
+
instanceId: 'test',
|
|
15
|
+
level: Enums_1.ELogLevel.ERROR,
|
|
16
|
+
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
17
|
+
disableColors: true,
|
|
18
|
+
});
|
|
19
|
+
const loggerErrorMock = node_test_1.mock.fn();
|
|
20
|
+
const loggerInfoMock = node_test_1.mock.fn();
|
|
21
|
+
const loggerWarnMock = node_test_1.mock.fn();
|
|
22
|
+
logger._logger = {
|
|
23
|
+
error: loggerErrorMock,
|
|
24
|
+
info: loggerInfoMock,
|
|
25
|
+
warn: loggerWarnMock,
|
|
26
|
+
level: 'error',
|
|
27
|
+
log: node_test_1.mock.fn(),
|
|
28
|
+
};
|
|
29
|
+
const code = LoggerMessages_1.LOGGER_ERROR_CODES.CONFIG_FILE_MISSING;
|
|
30
|
+
const recommendation = LoggerMessages_1.LOGGER_ERROR_RECOMMENDATIONS[code];
|
|
31
|
+
const exitMock = node_test_1.mock.method(process, 'exit', () => {
|
|
32
|
+
// nothing
|
|
33
|
+
});
|
|
34
|
+
logger.errorWithHint({ code });
|
|
35
|
+
node_assert_1.default.strictEqual(loggerErrorMock.mock.callCount(), 1);
|
|
36
|
+
node_assert_1.default.ok(String(loggerErrorMock.mock.calls[0].arguments[0]).includes('Error:'), 'error message should contain "Error:" prefix');
|
|
37
|
+
node_assert_1.default.ok(loggerInfoMock.mock.callCount() >= 2);
|
|
38
|
+
const infoMessages = loggerInfoMock.mock.calls.map(call => String(call.arguments[0]));
|
|
39
|
+
node_assert_1.default.ok(infoMessages.some(msg => msg.includes('What you can do next')), 'info should contain recommendation title');
|
|
40
|
+
node_assert_1.default.ok(infoMessages.some(msg => msg.includes(recommendation)), 'info should contain concrete recommendation text');
|
|
41
|
+
// Logger no longer calls process.exit; caller is responsible for flush and exit
|
|
42
|
+
node_assert_1.default.strictEqual(exitMock.mock.callCount(), 0);
|
|
43
|
+
});
|
|
44
|
+
(0, node_test_1.test)('success should delegate to internal logger with success level', () => {
|
|
45
|
+
const logger = new Logger_1.Logger({
|
|
46
|
+
instanceId: 'test',
|
|
47
|
+
level: Enums_1.ELogLevel.INFO,
|
|
48
|
+
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
49
|
+
disableColors: true,
|
|
50
|
+
});
|
|
51
|
+
const logMock = node_test_1.mock.fn();
|
|
52
|
+
logger._logger = {
|
|
53
|
+
log: logMock,
|
|
54
|
+
level: 'info',
|
|
55
|
+
};
|
|
56
|
+
logger.success('Done');
|
|
57
|
+
node_assert_1.default.strictEqual(logMock.mock.callCount(), 1);
|
|
58
|
+
const [level, message] = logMock.mock.calls[0].arguments;
|
|
59
|
+
node_assert_1.default.strictEqual(level, 'success');
|
|
60
|
+
node_assert_1.default.strictEqual(message, 'Done');
|
|
61
|
+
});
|
|
62
|
+
(0, node_test_1.test)('error should not call process.exit', () => {
|
|
63
|
+
const logger = new Logger_1.Logger({
|
|
64
|
+
instanceId: 'test',
|
|
65
|
+
level: Enums_1.ELogLevel.ERROR,
|
|
66
|
+
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
67
|
+
disableColors: true,
|
|
68
|
+
});
|
|
69
|
+
const loggerErrorMock = node_test_1.mock.fn();
|
|
70
|
+
logger._logger = { error: loggerErrorMock, level: 'error' };
|
|
71
|
+
const exitMock = node_test_1.mock.method(process, 'exit', () => {
|
|
72
|
+
throw new Error('process.exit should not be called by Logger.error');
|
|
73
|
+
});
|
|
74
|
+
logger.error('Something failed');
|
|
75
|
+
node_assert_1.default.strictEqual(loggerErrorMock.mock.callCount(), 1);
|
|
76
|
+
node_assert_1.default.strictEqual(exitMock.mock.callCount(), 0);
|
|
77
|
+
});
|
|
78
|
+
(0, node_test_1.test)('shutdownLoggerAsync should resolve and close transports', async () => {
|
|
79
|
+
const logger = new Logger_1.Logger({
|
|
80
|
+
instanceId: 'test',
|
|
81
|
+
level: Enums_1.ELogLevel.INFO,
|
|
82
|
+
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
83
|
+
disableColors: true,
|
|
84
|
+
});
|
|
85
|
+
let closeCalled = false;
|
|
86
|
+
const mockTransport = {
|
|
87
|
+
close(cb) {
|
|
88
|
+
closeCalled = true;
|
|
89
|
+
if (typeof cb === 'function')
|
|
90
|
+
cb();
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
logger._logger = {
|
|
94
|
+
transports: [mockTransport],
|
|
95
|
+
close: node_test_1.mock.fn(),
|
|
96
|
+
};
|
|
97
|
+
await logger.shutdownLoggerAsync();
|
|
98
|
+
node_assert_1.default.strictEqual(closeCalled, true);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -7,67 +7,74 @@ const node_assert_1 = __importDefault(require("node:assert"));
|
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
8
|
const convertArrayToObject_1 = require("../convertArrayToObject");
|
|
9
9
|
(0, node_test_1.describe)('@unit: convertArrayToObject', () => {
|
|
10
|
-
(0, node_test_1.test)('
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const expected = {
|
|
10
|
+
(0, node_test_1.test)('returns default shape for null', () => {
|
|
11
|
+
const result = (0, convertArrayToObject_1.convertArrayToObject)(null);
|
|
12
|
+
node_assert_1.default.deepStrictEqual(result, {
|
|
14
13
|
items: [],
|
|
15
14
|
excludeCoreServiceFiles: undefined,
|
|
16
15
|
request: undefined,
|
|
16
|
+
customExecutorPath: undefined,
|
|
17
17
|
useOptions: undefined,
|
|
18
18
|
useCancelableRequest: undefined,
|
|
19
|
-
};
|
|
20
|
-
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
(0, node_test_1.test)('returns default shape for empty array', () => {
|
|
22
|
+
const result = (0, convertArrayToObject_1.convertArrayToObject)([]);
|
|
23
|
+
node_assert_1.default.deepStrictEqual(result, {
|
|
24
|
+
items: [],
|
|
25
|
+
excludeCoreServiceFiles: undefined,
|
|
26
|
+
request: undefined,
|
|
27
|
+
customExecutorPath: undefined,
|
|
28
|
+
useOptions: undefined,
|
|
29
|
+
useCancelableRequest: undefined,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
(0, node_test_1.test)('passes through object config unchanged', () => {
|
|
33
|
+
const input = { input: './spec.json', output: './generated', httpClient: 'axios' };
|
|
34
|
+
const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
|
|
35
|
+
node_assert_1.default.strictEqual(result, input);
|
|
21
36
|
});
|
|
22
|
-
(0, node_test_1.test)('
|
|
37
|
+
(0, node_test_1.test)('converts legacy array and keeps per-item request/customExecutorPath', () => {
|
|
23
38
|
const input = [
|
|
24
39
|
{
|
|
25
40
|
input: 'url1',
|
|
26
41
|
output: 'res1',
|
|
27
|
-
exportCore: true,
|
|
28
42
|
request: 'req1',
|
|
43
|
+
customExecutorPath: 'exec-1',
|
|
44
|
+
httpClient: 'axios',
|
|
45
|
+
useOptions: true,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
input: 'url2',
|
|
49
|
+
output: 'res2',
|
|
50
|
+
request: 'req2',
|
|
51
|
+
customExecutorPath: 'exec-2',
|
|
52
|
+
httpClient: 'axios',
|
|
29
53
|
useOptions: true,
|
|
30
54
|
},
|
|
31
55
|
];
|
|
32
|
-
const
|
|
33
|
-
|
|
56
|
+
const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
|
|
57
|
+
node_assert_1.default.deepStrictEqual(result, {
|
|
58
|
+
httpClient: 'axios',
|
|
59
|
+
useOptions: true,
|
|
60
|
+
useUnionTypes: undefined,
|
|
34
61
|
excludeCoreServiceFiles: undefined,
|
|
35
|
-
|
|
62
|
+
includeSchemasFiles: undefined,
|
|
36
63
|
interfacePrefix: undefined,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
output: 'res1',
|
|
41
|
-
outputCore: undefined,
|
|
42
|
-
outputServices: undefined,
|
|
43
|
-
outputModels: undefined,
|
|
44
|
-
outputSchemas: undefined,
|
|
45
|
-
},
|
|
46
|
-
],
|
|
64
|
+
enumPrefix: undefined,
|
|
65
|
+
typePrefix: undefined,
|
|
66
|
+
useCancelableRequest: undefined,
|
|
47
67
|
logLevel: undefined,
|
|
48
68
|
logTarget: undefined,
|
|
49
|
-
request: 'req1',
|
|
50
69
|
sortByRequired: undefined,
|
|
51
|
-
typePrefix: undefined,
|
|
52
|
-
useCancelableRequest: undefined,
|
|
53
|
-
useOptions: true,
|
|
54
70
|
useSeparatedIndexes: undefined,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const input = [
|
|
63
|
-
{ input: 'url1', output: 'res1', exportCore: true, request: 'req1', useOptions: true },
|
|
64
|
-
{ input: 'url2', output: 'res2', exportCore: true, request: 'req1', useOptions: true },
|
|
65
|
-
];
|
|
66
|
-
const expected = {
|
|
67
|
-
enumPrefix: undefined,
|
|
68
|
-
excludeCoreServiceFiles: undefined,
|
|
69
|
-
httpClient: undefined,
|
|
70
|
-
interfacePrefix: undefined,
|
|
71
|
+
validationLibrary: undefined,
|
|
72
|
+
emptySchemaStrategy: undefined,
|
|
73
|
+
modelsMode: undefined,
|
|
74
|
+
useHistory: undefined,
|
|
75
|
+
diffReport: undefined,
|
|
76
|
+
request: undefined,
|
|
77
|
+
customExecutorPath: undefined,
|
|
71
78
|
items: [
|
|
72
79
|
{
|
|
73
80
|
input: 'url1',
|
|
@@ -76,6 +83,8 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
|
|
|
76
83
|
outputServices: undefined,
|
|
77
84
|
outputModels: undefined,
|
|
78
85
|
outputSchemas: undefined,
|
|
86
|
+
request: 'req1',
|
|
87
|
+
customExecutorPath: 'exec-1',
|
|
79
88
|
},
|
|
80
89
|
{
|
|
81
90
|
input: 'url2',
|
|
@@ -84,146 +93,35 @@ const convertArrayToObject_1 = require("../convertArrayToObject");
|
|
|
84
93
|
outputServices: undefined,
|
|
85
94
|
outputModels: undefined,
|
|
86
95
|
outputSchemas: undefined,
|
|
96
|
+
request: 'req2',
|
|
97
|
+
customExecutorPath: 'exec-2',
|
|
87
98
|
},
|
|
88
99
|
],
|
|
89
|
-
|
|
90
|
-
logTarget: undefined,
|
|
91
|
-
request: 'req1',
|
|
92
|
-
sortByRequired: undefined,
|
|
93
|
-
typePrefix: undefined,
|
|
94
|
-
useCancelableRequest: undefined,
|
|
95
|
-
useOptions: true,
|
|
96
|
-
useSeparatedIndexes: undefined,
|
|
97
|
-
useUnionTypes: undefined,
|
|
98
|
-
validationLibrary: undefined
|
|
99
|
-
};
|
|
100
|
-
const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
|
|
101
|
-
node_assert_1.default.deepStrictEqual(result, expected);
|
|
100
|
+
});
|
|
102
101
|
});
|
|
103
|
-
(0, node_test_1.test)('
|
|
102
|
+
(0, node_test_1.test)('promotes request/customExecutorPath to root when they are equal for all items', () => {
|
|
104
103
|
const input = [
|
|
105
|
-
{ input: 'url1', output: 'res1',
|
|
106
|
-
{ input: 'url2', output: 'res2',
|
|
104
|
+
{ input: 'url1', output: 'res1', request: 'req', customExecutorPath: 'exec' },
|
|
105
|
+
{ input: 'url2', output: 'res2', request: 'req', customExecutorPath: 'exec' },
|
|
107
106
|
];
|
|
108
|
-
const expected = {
|
|
109
|
-
enumPrefix: undefined,
|
|
110
|
-
excludeCoreServiceFiles: undefined,
|
|
111
|
-
httpClient: undefined,
|
|
112
|
-
interfacePrefix: undefined,
|
|
113
|
-
items: [
|
|
114
|
-
{
|
|
115
|
-
input: 'url1',
|
|
116
|
-
output: 'res1',
|
|
117
|
-
outputCore: undefined,
|
|
118
|
-
outputServices: undefined,
|
|
119
|
-
outputModels: undefined,
|
|
120
|
-
outputSchemas: undefined,
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
input: 'url2',
|
|
124
|
-
output: 'res2',
|
|
125
|
-
outputCore: undefined,
|
|
126
|
-
outputServices: undefined,
|
|
127
|
-
outputModels: undefined,
|
|
128
|
-
outputSchemas: undefined,
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
logLevel: undefined,
|
|
132
|
-
logTarget: undefined,
|
|
133
|
-
request: 'req1',
|
|
134
|
-
sortByRequired: undefined,
|
|
135
|
-
typePrefix: undefined,
|
|
136
|
-
useCancelableRequest: undefined,
|
|
137
|
-
useOptions: true,
|
|
138
|
-
useSeparatedIndexes: undefined,
|
|
139
|
-
useUnionTypes: undefined,
|
|
140
|
-
validationLibrary: undefined
|
|
141
|
-
};
|
|
142
107
|
const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
|
|
143
|
-
node_assert_1.default.
|
|
108
|
+
node_assert_1.default.strictEqual(result.request, 'req');
|
|
109
|
+
node_assert_1.default.strictEqual(result.customExecutorPath, 'exec');
|
|
144
110
|
});
|
|
145
|
-
(0, node_test_1.test)('
|
|
111
|
+
(0, node_test_1.test)('supports legacy "client" alias by normalizing it to httpClient', () => {
|
|
146
112
|
const input = [
|
|
147
|
-
{ input: 'url1', output: 'res1' },
|
|
148
|
-
{ input: 'url2', output: 'res2' },
|
|
113
|
+
{ input: 'url1', output: 'res1', client: 'axios', useOptions: true },
|
|
114
|
+
{ input: 'url2', output: 'res2', client: 'axios', useOptions: true },
|
|
149
115
|
];
|
|
150
|
-
const expected = {
|
|
151
|
-
enumPrefix: undefined,
|
|
152
|
-
excludeCoreServiceFiles: undefined,
|
|
153
|
-
httpClient: undefined,
|
|
154
|
-
interfacePrefix: undefined,
|
|
155
|
-
items: [
|
|
156
|
-
{
|
|
157
|
-
input: 'url1',
|
|
158
|
-
output: 'res1',
|
|
159
|
-
outputCore: undefined,
|
|
160
|
-
outputServices: undefined,
|
|
161
|
-
outputModels: undefined,
|
|
162
|
-
outputSchemas: undefined,
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
input: 'url2',
|
|
166
|
-
output: 'res2',
|
|
167
|
-
outputCore: undefined,
|
|
168
|
-
outputServices: undefined,
|
|
169
|
-
outputModels: undefined,
|
|
170
|
-
outputSchemas: undefined,
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
logLevel: undefined,
|
|
174
|
-
logTarget: undefined,
|
|
175
|
-
request: undefined,
|
|
176
|
-
sortByRequired: undefined,
|
|
177
|
-
typePrefix: undefined,
|
|
178
|
-
useCancelableRequest: undefined,
|
|
179
|
-
useOptions: undefined,
|
|
180
|
-
useSeparatedIndexes: undefined,
|
|
181
|
-
useUnionTypes: undefined,
|
|
182
|
-
validationLibrary: undefined
|
|
183
|
-
};
|
|
184
116
|
const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
|
|
185
|
-
node_assert_1.default.
|
|
117
|
+
node_assert_1.default.strictEqual(result.httpClient, 'axios');
|
|
118
|
+
node_assert_1.default.strictEqual(result.useOptions, true);
|
|
186
119
|
});
|
|
187
|
-
(0, node_test_1.test)('
|
|
120
|
+
(0, node_test_1.test)('throws on conflicting root-driven fields', () => {
|
|
188
121
|
const input = [
|
|
189
|
-
{ input: 'url1', output: 'res1',
|
|
190
|
-
{ input: 'url2', output: 'res2',
|
|
122
|
+
{ input: 'url1', output: 'res1', useOptions: true },
|
|
123
|
+
{ input: 'url2', output: 'res2', useOptions: false },
|
|
191
124
|
];
|
|
192
|
-
|
|
193
|
-
enumPrefix: undefined,
|
|
194
|
-
excludeCoreServiceFiles: undefined,
|
|
195
|
-
httpClient: undefined,
|
|
196
|
-
interfacePrefix: undefined,
|
|
197
|
-
items: [
|
|
198
|
-
{
|
|
199
|
-
input: 'url1',
|
|
200
|
-
output: 'res1',
|
|
201
|
-
outputCore: undefined,
|
|
202
|
-
outputServices: undefined,
|
|
203
|
-
outputModels: undefined,
|
|
204
|
-
outputSchemas: undefined,
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
input: 'url2',
|
|
208
|
-
output: 'res2',
|
|
209
|
-
outputCore: undefined,
|
|
210
|
-
outputServices: undefined,
|
|
211
|
-
outputModels: undefined,
|
|
212
|
-
outputSchemas: undefined,
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
logLevel: undefined,
|
|
216
|
-
logTarget: undefined,
|
|
217
|
-
request: undefined,
|
|
218
|
-
sortByRequired: undefined,
|
|
219
|
-
typePrefix: undefined,
|
|
220
|
-
useCancelableRequest: undefined,
|
|
221
|
-
useOptions: undefined,
|
|
222
|
-
useSeparatedIndexes: undefined,
|
|
223
|
-
useUnionTypes: undefined,
|
|
224
|
-
validationLibrary: undefined
|
|
225
|
-
};
|
|
226
|
-
const result = (0, convertArrayToObject_1.convertArrayToObject)(input);
|
|
227
|
-
node_assert_1.default.deepStrictEqual(result, expected);
|
|
125
|
+
node_assert_1.default.throws(() => (0, convertArrayToObject_1.convertArrayToObject)(input), /conflicting "useOptions" values/);
|
|
228
126
|
});
|
|
229
127
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslintFix.test.d.ts","sourceRoot":"","sources":["../../../../src/common/utils/__tests__/eslintFix.test.ts"],"names":[],"mappings":""}
|