ts-openapi-codegen 1.0.0-beta.8 → 1.0.0
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 +221 -123
- package/README.rus.md +725 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +12 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +66 -0
- package/dist/cli/checkAndUpdateConfig/constants.d.ts +13 -0
- package/dist/cli/checkAndUpdateConfig/constants.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/constants.js +29 -0
- package/dist/cli/checkAndUpdateConfig/types.d.ts +20 -0
- package/dist/cli/checkAndUpdateConfig/types.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/types.js +12 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +12 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +56 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.js +11 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts +14 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.js +30 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts +17 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.js +29 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.js +11 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts +29 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.js +49 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.js +22 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts +17 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +53 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts +34 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.js +41 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.js +18 -0
- package/dist/cli/generate/runGenerateOpenApi.d.ts +2 -2
- package/dist/cli/generate/runGenerateOpenApi.d.ts.map +1 -1
- package/dist/cli/generate/runGenerateOpenApi.js +12 -14
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +56 -30
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.js +11 -18
- package/dist/cli/interactive/confirmDialog.d.ts +17 -0
- package/dist/cli/interactive/confirmDialog.d.ts.map +1 -0
- package/dist/cli/interactive/confirmDialog.js +36 -0
- package/dist/cli/interactive/constants.d.ts +7 -0
- package/dist/cli/interactive/constants.d.ts.map +1 -0
- package/dist/cli/interactive/constants.js +25 -0
- package/dist/cli/interactive/selectDialog.d.ts +17 -0
- package/dist/cli/interactive/selectDialog.d.ts.map +1 -0
- package/dist/cli/interactive/selectDialog.js +43 -0
- package/dist/cli/interactive/types.d.ts +40 -0
- package/dist/cli/interactive/types.d.ts.map +1 -0
- package/dist/cli/interactive/types.js +12 -0
- package/dist/common/Consts.d.ts +23 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +28 -1
- package/dist/common/Enums.d.ts +4 -0
- package/dist/common/Enums.d.ts.map +1 -1
- package/dist/common/Enums.js +6 -1
- package/dist/common/Logger.d.ts +1 -1
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +5 -38
- package/dist/common/UpdateNotifier.d.ts +36 -2
- package/dist/common/UpdateNotifier.d.ts.map +1 -1
- package/dist/common/UpdateNotifier.js +150 -57
- package/dist/common/VersionedSchema/Types.d.ts +5 -0
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +1 -7
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +3 -0
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +14 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.js +11 -0
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +5 -2
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +22 -15
- package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +1 -0
- package/dist/common/utils/__tests__/convertArrayToObject.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.js +14 -14
- package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.js +5 -5
- package/dist/common/utils/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.js +4 -4
- package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.js +4 -4
- package/dist/common/utils/__tests__/getUniqueObjectKeys.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.js +5 -5
- package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.js +5 -5
- package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.js +21 -15
- package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.js +13 -9
- package/dist/common/utils/__tests__/pathHelpers.test.d.ts.map +1 -0
- package/dist/{core → common}/utils/__tests__/pathHelpers.test.js +8 -8
- package/dist/common/utils/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.js +5 -5
- package/dist/common/utils/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.js +5 -5
- package/dist/common/utils/convertArrayToObject.d.ts +2 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -0
- package/dist/common/{Utils.js → utils/convertArrayToObject.js} +0 -20
- package/dist/{core/utils/fileSystem.d.ts → common/utils/fileSystemHelpers.d.ts} +8 -5
- package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -0
- package/dist/common/utils/fileSystemHelpers.js +85 -0
- package/dist/common/utils/format.d.ts +3 -0
- package/dist/common/utils/format.d.ts.map +1 -0
- package/dist/{core → common}/utils/format.js +2 -2
- package/dist/common/utils/loadConfigIfExists.d.ts +2 -0
- package/dist/common/utils/loadConfigIfExists.d.ts.map +1 -0
- package/dist/common/utils/loadConfigIfExists.js +22 -0
- package/dist/common/utils/pathHelpers.d.ts +6 -0
- package/dist/common/utils/pathHelpers.d.ts.map +1 -0
- package/dist/{core → common}/utils/pathHelpers.js +16 -20
- package/dist/common/utils/safeHasOwn.d.ts +2 -0
- package/dist/common/utils/safeHasOwn.d.ts.map +1 -0
- package/dist/common/utils/safeHasOwn.js +9 -0
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +3 -3
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +18 -18
- package/dist/core/__tests__/WriteClient.test.js +61 -60
- package/dist/core/api/v2/Parser.d.ts.map +1 -1
- package/dist/core/api/v2/Parser.js +2 -9
- package/dist/core/api/v2/parser/__tests__/getServer.test.js +2 -2
- package/dist/core/api/v2/parser/__tests__/getType.test.js +3 -3
- package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModelProperties.js +2 -5
- package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModels.js +2 -1
- package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.js +2 -1
- package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponse.js +2 -5
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +2 -5
- package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getServices.js +2 -5
- package/dist/core/api/v2/parser/getType.js +4 -4
- package/dist/core/api/v3/Parser.d.ts +1 -1
- package/dist/core/api/v3/Parser.d.ts.map +1 -1
- package/dist/core/api/v3/Parser.js +2 -9
- package/dist/core/api/v3/parser/__tests__/getServer.test.js +3 -3
- package/dist/core/api/v3/parser/__tests__/getType.test.js +3 -3
- package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModelProperties.js +2 -5
- package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModels.js +2 -1
- package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponse.js +2 -5
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +2 -5
- package/dist/core/api/v3/parser/getServer.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServer.js +2 -5
- package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServices.js +2 -5
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +5 -13
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +34 -27
- package/dist/core/types/Consts.d.ts +5 -1
- package/dist/core/types/Consts.d.ts.map +1 -1
- package/dist/core/types/Consts.js +6 -2
- package/dist/core/types/base/Root.model.d.ts +1 -0
- package/dist/core/types/base/Root.model.d.ts.map +1 -1
- package/dist/core/utils/__tests__/escapeDescription.test.js +3 -3
- package/dist/core/utils/__tests__/escapeName.test.js +2 -2
- package/dist/core/utils/__tests__/flatMap.test.js +2 -2
- package/dist/core/utils/__tests__/getAbsolutePath.test.js +6 -6
- package/dist/core/utils/__tests__/getClassName.test.js +2 -2
- package/dist/core/utils/__tests__/getComment.test.js +2 -2
- package/dist/core/utils/__tests__/getEnumFromDescription.test.js +2 -2
- package/dist/core/utils/__tests__/getFileName.test.js +2 -2
- package/dist/core/utils/__tests__/getGatheringRefs.test.js +2 -2
- package/dist/core/utils/__tests__/getMappedType.test.js +2 -2
- package/dist/core/utils/__tests__/getModelNames.test.js +2 -2
- package/dist/core/utils/__tests__/getOpenApiVersion.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationName.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationParameterName.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationPath.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationResponseCode.test.js +2 -2
- package/dist/core/utils/__tests__/getPattern.test.js +2 -2
- package/dist/core/utils/__tests__/getRefFromSchema.test.js +2 -2
- package/dist/core/utils/__tests__/getRefs.test.js +2 -2
- package/dist/core/utils/__tests__/getRelativeModelPath.test.js +3 -3
- package/dist/core/utils/__tests__/getServiceClassName.test.js +2 -2
- package/dist/core/utils/__tests__/getServiceNames.test.js +2 -2
- package/dist/core/utils/__tests__/getServiceVersion.test.js +2 -2
- package/dist/core/utils/__tests__/isString.test.js +2 -2
- package/dist/core/utils/__tests__/isSubdirectory.test.js +10 -10
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
- package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +2 -2
- package/dist/core/utils/__tests__/replaceString.test.js +2 -2
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +360 -51
- package/dist/core/utils/__tests__/sort.test.js +2 -2
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +11 -11
- package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +11 -11
- package/dist/core/utils/__tests__/sortModelsByName.test.js +2 -2
- package/dist/core/utils/__tests__/sortServicesByName.test.js +2 -2
- package/dist/core/utils/__tests__/stripNamespace.test.js +2 -2
- package/dist/core/utils/__tests__/unique.test.js +2 -2
- package/dist/core/utils/__tests__/writeClientCore.test.js +52 -50
- package/dist/core/utils/__tests__/writeClientFullIndex.test.js +39 -37
- package/dist/core/utils/__tests__/writeClientModels.test.js +65 -63
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +65 -63
- package/dist/core/utils/__tests__/writeClientServices.test.js +60 -58
- package/dist/core/utils/appendUniqueLinesToFile.js +4 -4
- package/dist/core/utils/createNormalizedRef.js +2 -2
- package/dist/core/utils/getAbsolutePath.js +3 -3
- package/dist/core/utils/getModelNameWithPrefix.d.ts +3 -0
- package/dist/core/utils/getModelNameWithPrefix.d.ts.map +1 -0
- package/dist/core/utils/getModelNameWithPrefix.js +15 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +4 -4
- package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
- package/dist/core/utils/getOutputPaths.js +6 -6
- package/dist/core/utils/getPattern.d.ts.map +1 -1
- package/dist/core/utils/getPattern.js +2 -1
- package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
- package/dist/core/utils/getRelativeModelPath.js +2 -6
- package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
- package/dist/core/utils/isSubdirectory.js +4 -3
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -1
- package/dist/core/utils/mapPathToTargetDirSafe.js +11 -12
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +18 -6
- package/dist/core/utils/normalizeString.d.ts +2 -0
- package/dist/core/utils/normalizeString.d.ts.map +1 -0
- package/dist/core/utils/normalizeString.js +14 -0
- package/dist/core/utils/normalizedAbsolutePath.js +3 -3
- package/dist/core/utils/parseRef.d.ts.map +1 -1
- package/dist/core/utils/parseRef.js +7 -10
- package/dist/core/utils/precompileTemplates.js +14 -10
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +24 -0
- package/dist/core/utils/replaceString.d.ts.map +1 -1
- package/dist/core/utils/replaceString.js +2 -1
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefPath.js +3 -3
- package/dist/core/utils/resolveRefToImportPath.d.ts +8 -2
- package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefToImportPath.js +91 -31
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
- package/dist/core/utils/serviceHelpers.js +2 -1
- package/dist/core/utils/stripNamespace.js +5 -5
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +12 -12
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +2 -2
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientFullIndex.js +4 -4
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +7 -7
- 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.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +7 -7
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemasIndex.js +2 -2
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +5 -5
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientServicesIndex.js +2 -2
- package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSimpleIndex.js +4 -4
- package/dist/templatesCompiled/client/exportModel.js +4 -4
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +12 -13
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +35 -29
- package/dist/templatesCompiled/client/partials/parameters.d.ts +3 -2
- package/dist/templatesCompiled/client/partials/parameters.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/parameters.js +25 -20
- package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts +4 -2
- package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/parametersDefinition.js +31 -10
- package/package.json +15 -13
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts +0 -5
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +0 -1
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +0 -45
- package/dist/common/Utils.d.ts +0 -3
- package/dist/common/Utils.d.ts.map +0 -1
- package/dist/common/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
- package/dist/common/__tests__/convertArrayToObject.test.d.ts.map +0 -1
- package/dist/common/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
- package/dist/common/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +0 -1
- package/dist/common/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
- package/dist/common/__tests__/getUniqueObjectKeys.test.d.ts.map +0 -1
- package/dist/common/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
- package/dist/common/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
- package/dist/common/__tests__/migrationForOptions.test.d.ts.map +0 -1
- package/dist/common/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +0 -1
- package/dist/common/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts +0 -2
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.js +0 -82
- package/dist/core/utils/__tests__/pathHelpers.test.d.ts.map +0 -1
- package/dist/core/utils/fileSystem.d.ts.map +0 -1
- package/dist/core/utils/fileSystem.js +0 -26
- package/dist/core/utils/format.d.ts +0 -2
- package/dist/core/utils/format.d.ts.map +0 -1
- package/dist/core/utils/getRelativeModelImportPath.d.ts +0 -9
- package/dist/core/utils/getRelativeModelImportPath.d.ts.map +0 -1
- package/dist/core/utils/getRelativeModelImportPath.js +0 -45
- package/dist/core/utils/isDirectory.d.ts +0 -2
- package/dist/core/utils/isDirectory.d.ts.map +0 -1
- package/dist/core/utils/isDirectory.js +0 -13
- package/dist/core/utils/pathHelpers.d.ts +0 -7
- package/dist/core/utils/pathHelpers.d.ts.map +0 -1
- /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.js +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.d.ts +0 -0
- /package/dist/{core → common}/utils/__tests__/pathHelpers.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.d.ts +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeConfigFile = writeConfigFile;
|
|
4
|
+
const prepareConfigData_1 = require("./prepareConfigData");
|
|
5
|
+
const updateExistingConfigFile_1 = require("./updateExistingConfigFile");
|
|
6
|
+
const writeExampleConfigFile_1 = require("./writeExampleConfigFile");
|
|
7
|
+
/**
|
|
8
|
+
* Записывает или обновляет файл конфигурации.
|
|
9
|
+
* Поддерживает как обновление существующего файла, так и создание примера.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Опции записи файла
|
|
12
|
+
* @throws {Error} Если путь не найден или ошибка при записи
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Обновить существующий конфиг
|
|
16
|
+
* await writeConfigFile({
|
|
17
|
+
* data: migratedData,
|
|
18
|
+
* configPath: './openapi-config.json',
|
|
19
|
+
* isUpdating: true,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Создать файл с примером
|
|
24
|
+
* await writeConfigFile({
|
|
25
|
+
* data: migratedData,
|
|
26
|
+
* configPath: './openapi-config.json',
|
|
27
|
+
* isUpdating: false,
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
async function writeConfigFile({ data, configPath, isUpdating, }) {
|
|
31
|
+
const preparedData = await (0, prepareConfigData_1.prepareConfigData)(data);
|
|
32
|
+
if (!preparedData) {
|
|
33
|
+
throw new Error('Failed to prepare configuration data for writing');
|
|
34
|
+
}
|
|
35
|
+
if (isUpdating) {
|
|
36
|
+
await (0, updateExistingConfigFile_1.updateExistingConfigFile)(configPath, preparedData);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
await (0, writeExampleConfigFile_1.writeExampleConfigFile)(configPath, preparedData);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeExampleConfigFile.d.ts","sourceRoot":"","sources":["../../../../src/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAW5F"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.writeExampleConfigFile = writeExampleConfigFile;
|
|
4
|
+
const Consts_1 = require("../../../common/Consts");
|
|
5
|
+
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
6
|
+
/**
|
|
7
|
+
* Создает файл с примером конфигурации
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
async function writeExampleConfigFile(configPath, data) {
|
|
11
|
+
const pathParts = configPath.split('/');
|
|
12
|
+
const fileName = pathParts.pop();
|
|
13
|
+
const exampleFileName = `example-config-${fileName}`;
|
|
14
|
+
const examplePath = [...pathParts, exampleFileName].join('/');
|
|
15
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile(examplePath, data);
|
|
16
|
+
Consts_1.APP_LOGGER.forceInfo(`Example configuration generated and written to: ${examplePath}\n` +
|
|
17
|
+
`You can use it as a template for your actual configuration.`);
|
|
18
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { OptionValues } from 'commander';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Запускает генерацию OpenAPI клиента
|
|
4
|
+
* Поддерживает как конфиг-файл, так и параметры из CLI
|
|
5
5
|
*/
|
|
6
6
|
export declare function runGenerateOpenApi(options: OptionValues): Promise<void>;
|
|
7
7
|
//# sourceMappingURL=runGenerateOpenApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runGenerateOpenApi.d.ts","sourceRoot":"","sources":["../../../src/cli/generate/runGenerateOpenApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"runGenerateOpenApi.d.ts","sourceRoot":"","sources":["../../../src/cli/generate/runGenerateOpenApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAgBzC;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoD7E"}
|
|
@@ -34,10 +34,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.runGenerateOpenApi = runGenerateOpenApi;
|
|
37
|
+
const Consts_1 = require("../../common/Consts");
|
|
37
38
|
const defaultOptions_1 = require("../../common/defaultOptions");
|
|
38
39
|
const Enums_1 = require("../../common/Enums");
|
|
39
|
-
const
|
|
40
|
-
const
|
|
40
|
+
const convertArrayToObject_1 = require("../../common/utils/convertArrayToObject");
|
|
41
|
+
const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
|
|
41
42
|
const MultiOptionsMigrationPlan_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan");
|
|
42
43
|
const MultiOptionsVersionedSchemas_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas");
|
|
43
44
|
const OptionsMigrationPlans_1 = require("../../common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans");
|
|
@@ -46,16 +47,11 @@ const migrateDataToLatestSchemaVersion_1 = require("../../common/VersionedSchema
|
|
|
46
47
|
const OpenAPI = __importStar(require("../../core"));
|
|
47
48
|
const isInstanceOfMultiOptions_1 = require("../../core/utils/isInstanceOfMultiOptions");
|
|
48
49
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
50
|
+
* Запускает генерацию OpenAPI клиента
|
|
51
|
+
* Поддерживает как конфиг-файл, так и параметры из CLI
|
|
51
52
|
*/
|
|
52
53
|
async function runGenerateOpenApi(options) {
|
|
53
54
|
const { openapiConfig, ...clientOptions } = options;
|
|
54
|
-
const logger = new Logger_1.Logger({
|
|
55
|
-
level: Enums_1.ELogLevel.INFO,
|
|
56
|
-
instanceId: 'openapi-cli',
|
|
57
|
-
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
58
|
-
});
|
|
59
55
|
try {
|
|
60
56
|
const hasMinimumRequiredOptions = !!clientOptions.input && !!clientOptions.output;
|
|
61
57
|
if (hasMinimumRequiredOptions) {
|
|
@@ -65,25 +61,27 @@ async function runGenerateOpenApi(options) {
|
|
|
65
61
|
process.exit(0);
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
|
-
const configData = (0,
|
|
64
|
+
const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(openapiConfig);
|
|
69
65
|
if (!configData) {
|
|
70
|
-
|
|
66
|
+
Consts_1.APP_LOGGER.error('The configuration file is missing');
|
|
71
67
|
}
|
|
72
|
-
const preparedOptions = (0,
|
|
68
|
+
const preparedOptions = (0, convertArrayToObject_1.convertArrayToObject)(configData);
|
|
73
69
|
const isMultiOptions = (0, isInstanceOfMultiOptions_1.isInstanceOfMultioptions)(preparedOptions);
|
|
74
70
|
const migratedOptions = isMultiOptions
|
|
75
71
|
? (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
|
|
76
72
|
rawInput: preparedOptions,
|
|
77
73
|
migrationPlans: MultiOptionsMigrationPlan_1.multiOptionsMigrationPlan,
|
|
78
74
|
versionedSchemas: MultiOptionsVersionedSchemas_1.multiOptionsVersionedSchema,
|
|
75
|
+
migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
|
|
79
76
|
})
|
|
80
77
|
: (0, migrateDataToLatestSchemaVersion_1.migrateDataToLatestSchemaVersion)({
|
|
81
78
|
rawInput: preparedOptions,
|
|
82
79
|
migrationPlans: OptionsMigrationPlans_1.optionsMigrationPlans,
|
|
83
80
|
versionedSchemas: OptionsVersionedSchemas_1.optionsVersionedSchemas,
|
|
81
|
+
migrationMode: Enums_1.EMigrationMode.GENERATE_OPENAPI,
|
|
84
82
|
});
|
|
85
83
|
if (!migratedOptions) {
|
|
86
|
-
|
|
84
|
+
Consts_1.APP_LOGGER.error("Couldn't convert the set of options to the current version");
|
|
87
85
|
}
|
|
88
86
|
else {
|
|
89
87
|
const { value } = migratedOptions;
|
|
@@ -97,6 +95,6 @@ async function runGenerateOpenApi(options) {
|
|
|
97
95
|
process.exit(0);
|
|
98
96
|
}
|
|
99
97
|
catch (error) {
|
|
100
|
-
|
|
98
|
+
Consts_1.APP_LOGGER.error(error.message);
|
|
101
99
|
}
|
|
102
100
|
}
|
package/dist/cli/index.d.ts
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
"use strict";
|
|
2
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
5
|
};
|
|
5
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
7
|
const commander_1 = require("commander");
|
|
7
|
-
const Consts_1 = require("common/Consts");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const
|
|
9
|
+
const Consts_1 = require("../common/Consts");
|
|
10
10
|
const Enums_1 = require("../common/Enums");
|
|
11
|
-
const Logger_1 = require("../common/Logger");
|
|
12
11
|
const UpdateNotifier_1 = require("../common/UpdateNotifier");
|
|
12
|
+
const pathHelpers_1 = require("../common/utils/pathHelpers");
|
|
13
13
|
const HttpClient_enum_1 = require("../core/types/enums/HttpClient.enum");
|
|
14
|
-
const
|
|
14
|
+
const checkConfig_1 = require("./checkAndUpdateConfig/checkConfig");
|
|
15
|
+
const updateConfig_1 = require("./checkAndUpdateConfig/updateConfig");
|
|
15
16
|
const runGenerateOpenApi_1 = require("./generate/runGenerateOpenApi");
|
|
16
17
|
const Enums_2 = require("./initOpenApiConfig/Enums");
|
|
17
18
|
const runInitOpenapiConfig_1 = require("./initOpenApiConfig/runInitOpenapiConfig");
|
|
18
19
|
const utils_1 = require("./utils");
|
|
19
|
-
const packageDetails = JSON.parse(fs_1.default.readFileSync(
|
|
20
|
+
const packageDetails = JSON.parse(fs_1.default.readFileSync((0, pathHelpers_1.joinHelper)(__dirname, '../../package.json'), 'utf-8'));
|
|
20
21
|
const APP_NAME = packageDetails.name || 'ts-openapi-codegen-cli';
|
|
21
22
|
const APP_VERSION = packageDetails.version || '1.0.0';
|
|
22
23
|
const APP_DESCRIPTION = packageDetails.description || 'Description';
|
|
23
|
-
const updateNotifier = new UpdateNotifier_1.UpdateNotifier(
|
|
24
|
+
const updateNotifier = new UpdateNotifier_1.UpdateNotifier({
|
|
25
|
+
packageName: APP_NAME,
|
|
26
|
+
packageVersion: APP_VERSION,
|
|
27
|
+
});
|
|
24
28
|
const program = new commander_1.Command();
|
|
25
29
|
program.version(APP_VERSION).name(APP_NAME).description(APP_DESCRIPTION).addHelpText('before', (0, utils_1.getCLIName)(APP_NAME));
|
|
30
|
+
/**
|
|
31
|
+
* generate - Команда для генерации кода на основе OpenAPI спецификации
|
|
32
|
+
*/
|
|
26
33
|
program
|
|
27
34
|
.command('generate')
|
|
28
|
-
.description('Starts code generation based on the provided
|
|
35
|
+
.description('Starts code generation based on the provided openapi specifications')
|
|
29
36
|
.addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
|
|
30
37
|
.usage('[options]')
|
|
31
38
|
.option('-ocn, --openapi-config <value>', 'The path to the configuration file, listing the options', Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME)
|
|
@@ -41,43 +48,67 @@ program
|
|
|
41
48
|
.option('--excludeCoreServiceFiles', 'The generation of the core and services is excluded (default: false)')
|
|
42
49
|
.option('--includeSchemasFiles', 'The generation of model validation schemes is enabled (default: false)')
|
|
43
50
|
.option('--request <value>', 'Path to custom request file')
|
|
44
|
-
.option('--interfacePrefix <value>', 'Prefix for interface model(default: "I")',
|
|
45
|
-
.option('--enumPrefix <value>', 'Prefix for enum model(default: "E")',
|
|
46
|
-
.option('--typePrefix <value>', 'Prefix for type model(default: "T")',
|
|
51
|
+
.option('--interfacePrefix <value>', 'Prefix for interface model(default: "I")', 'I')
|
|
52
|
+
.option('--enumPrefix <value>', 'Prefix for enum model(default: "E")', 'E')
|
|
53
|
+
.option('--typePrefix <value>', 'Prefix for type model(default: "T")', 'T')
|
|
47
54
|
.option('--useCancelableRequest', 'Use cancelled promise as returned data type in request (default: false)')
|
|
48
55
|
.addOption(new commander_1.Option('-l, --logLevel <level>', 'Logging level').choices([...Object.values(Enums_1.ELogLevel)]).default(Enums_1.ELogLevel.ERROR))
|
|
49
56
|
.addOption(new commander_1.Option('-t, --logTarget <target>', 'Target of logging').choices([...Object.values(Enums_1.ELogOutput)]).default(Enums_1.ELogOutput.CONSOLE))
|
|
50
57
|
.option('-s, --sortByRequired', 'Property sorting strategy: simplified or extended')
|
|
51
58
|
.option('--useSeparatedIndexes', 'Use separate index files for the core, models, schemas, and services.')
|
|
52
|
-
.hook('preAction', () => {
|
|
53
|
-
updateNotifier.checkAndNotify();
|
|
59
|
+
.hook('preAction', async () => {
|
|
60
|
+
await updateNotifier.checkAndNotify();
|
|
54
61
|
})
|
|
55
62
|
.action(async (options) => {
|
|
56
63
|
await (0, runGenerateOpenApi_1.runGenerateOpenApi)(options);
|
|
57
64
|
});
|
|
65
|
+
/**
|
|
66
|
+
* check - Команда для проверки конфигурационного файла
|
|
67
|
+
*/
|
|
58
68
|
program
|
|
59
|
-
.command('check-
|
|
60
|
-
.description('
|
|
69
|
+
.command('check-config')
|
|
70
|
+
.description('Checks if the configuration file data is filled in correctly')
|
|
61
71
|
.addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
|
|
62
72
|
.option('-ocn, --openapi-config <value>', 'The path to the configuration file, listing the options', Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME)
|
|
63
|
-
.hook('preAction', () => {
|
|
64
|
-
updateNotifier.checkAndNotify();
|
|
73
|
+
.hook('preAction', async () => {
|
|
74
|
+
await updateNotifier.checkAndNotify();
|
|
65
75
|
})
|
|
66
|
-
.action((options) => {
|
|
67
|
-
(0,
|
|
76
|
+
.action(async (options) => {
|
|
77
|
+
await (0, checkConfig_1.checkConfig)(options.openapiConfig);
|
|
68
78
|
});
|
|
79
|
+
/**
|
|
80
|
+
* update - Команда для обновления конфигурационного файла
|
|
81
|
+
*/
|
|
69
82
|
program
|
|
70
|
-
.command('
|
|
71
|
-
.description('
|
|
83
|
+
.command('update-config')
|
|
84
|
+
.description('Updates the configuration file to the latest version')
|
|
85
|
+
.addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
|
|
86
|
+
.option('-ocn, --openapi-config <value>', 'The path to the configuration file, listing the options', Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME)
|
|
87
|
+
.hook('preAction', async () => {
|
|
88
|
+
await updateNotifier.checkAndNotify();
|
|
89
|
+
})
|
|
90
|
+
.action(async (options) => {
|
|
91
|
+
await (0, updateConfig_1.updateConfig)(options.openapiConfig);
|
|
92
|
+
});
|
|
93
|
+
/**
|
|
94
|
+
* init - Команда для инициализации конфигурационного файла
|
|
95
|
+
*/
|
|
96
|
+
program
|
|
97
|
+
.command('init')
|
|
98
|
+
.description('Generates a configuration file template for a set of single or multiple options')
|
|
72
99
|
.addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
|
|
73
100
|
.option('-ocn, --openapi-config <value>', 'The path to the configuration file, listing the options', Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME)
|
|
74
101
|
.addOption(new commander_1.Option('-t, --type <type>', 'A variant of the set of options for running the client generator (default: "OPTION")').choices([...Object.values(Enums_2.EOptionType)]).default(Enums_2.EOptionType.OPTION))
|
|
75
|
-
.hook('preAction', () => {
|
|
76
|
-
updateNotifier.checkAndNotify();
|
|
102
|
+
.hook('preAction', async () => {
|
|
103
|
+
await updateNotifier.checkAndNotify();
|
|
77
104
|
})
|
|
78
|
-
.action((options) => {
|
|
79
|
-
(0, runInitOpenapiConfig_1.runInitOpenapiConfig)(options);
|
|
105
|
+
.action(async (options) => {
|
|
106
|
+
await (0, runInitOpenapiConfig_1.runInitOpenapiConfig)(options);
|
|
80
107
|
});
|
|
108
|
+
program.exitOverride();
|
|
109
|
+
// TODO: Включить позже!
|
|
110
|
+
// program.showSuggestionAfterError(false);
|
|
111
|
+
// Парсирование аргументов с обработкой ошибок
|
|
81
112
|
try {
|
|
82
113
|
program.parse(process.argv);
|
|
83
114
|
}
|
|
@@ -85,12 +116,7 @@ catch (error) {
|
|
|
85
116
|
if (error.code === 'commander.unknownOption') {
|
|
86
117
|
const errorMessage = error?.message ?? '';
|
|
87
118
|
if (errorMessage) {
|
|
88
|
-
|
|
89
|
-
level: Enums_1.ELogLevel.INFO,
|
|
90
|
-
instanceId: 'check-openapi-config',
|
|
91
|
-
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
92
|
-
});
|
|
93
|
-
logger.error(errorMessage);
|
|
119
|
+
Consts_1.APP_LOGGER.error(errorMessage);
|
|
94
120
|
}
|
|
95
121
|
}
|
|
96
122
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runInitOpenapiConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/initOpenApiConfig/runInitOpenapiConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"runInitOpenapiConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/initOpenApiConfig/runInitOpenapiConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAazC,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,YAAY,iBAoB9D"}
|
|
@@ -40,38 +40,31 @@ exports.runInitOpenapiConfig = runInitOpenapiConfig;
|
|
|
40
40
|
const Handlebars = __importStar(require("handlebars/runtime"));
|
|
41
41
|
const prettier_1 = require("prettier");
|
|
42
42
|
const Consts_1 = require("../../common/Consts");
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const fileSystem_1 = require("../../core/utils/fileSystem");
|
|
43
|
+
const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
|
|
44
|
+
const loadConfigIfExists_1 = require("../../common/utils/loadConfigIfExists");
|
|
45
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
47
46
|
const getFileName_1 = require("../../core/utils/getFileName");
|
|
48
|
-
const pathHelpers_1 = require("../../core/utils/pathHelpers");
|
|
49
47
|
const openApiConfig_1 = __importDefault(require("../../templatesCompiled/cli/openApiConfig"));
|
|
50
|
-
const
|
|
48
|
+
const Enums_1 = require("./Enums");
|
|
51
49
|
async function runInitOpenapiConfig(params) {
|
|
52
50
|
const { openapiConfig, type: optionType } = params;
|
|
53
|
-
const logger = new Logger_1.Logger({
|
|
54
|
-
level: Enums_1.ELogLevel.INFO,
|
|
55
|
-
instanceId: 'init-openapi-config',
|
|
56
|
-
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
57
|
-
});
|
|
58
51
|
try {
|
|
59
|
-
const configData = (0,
|
|
52
|
+
const configData = (0, loadConfigIfExists_1.loadConfigIfExists)(openapiConfig);
|
|
60
53
|
if (!configData) {
|
|
61
54
|
const configFilePath = openapiConfig ?? Consts_1.DEFAULT_OPENAPI_CONFIG_FILENAME;
|
|
62
|
-
const file = (0, pathHelpers_1.
|
|
55
|
+
const file = (0, pathHelpers_1.resolveHelper)(process.cwd(), configFilePath);
|
|
63
56
|
const configTemplate = Handlebars.template(openApiConfig_1.default);
|
|
64
|
-
const templateResult = configTemplate({ useMultyOptions: optionType ===
|
|
57
|
+
const templateResult = configTemplate({ useMultyOptions: optionType === Enums_1.EOptionType.MULTIOPTION });
|
|
65
58
|
const formattedValue = await (0, prettier_1.format)(templateResult, { parser: 'json' });
|
|
66
|
-
await
|
|
67
|
-
|
|
59
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile(file, formattedValue);
|
|
60
|
+
Consts_1.APP_LOGGER.info(`File recording completed: ${file}`);
|
|
68
61
|
}
|
|
69
62
|
else {
|
|
70
63
|
const fileName = (0, getFileName_1.getFileName)(openapiConfig);
|
|
71
|
-
|
|
64
|
+
Consts_1.APP_LOGGER.info(`The configuration file already exists: ${fileName}`);
|
|
72
65
|
}
|
|
73
66
|
}
|
|
74
67
|
catch (error) {
|
|
75
|
-
|
|
68
|
+
Consts_1.APP_LOGGER.error(error.message);
|
|
76
69
|
}
|
|
77
70
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EnquirerConfirmOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Отображает диалог подтверждения для пользователя.
|
|
4
|
+
* Используется для критичных действий (удаление, публикация и т.д.)
|
|
5
|
+
*
|
|
6
|
+
* @param options - Опции диалога
|
|
7
|
+
* @returns Результат выбора пользователя (true/false)
|
|
8
|
+
* @throws Процесс завершится при прерывании пользователем (Ctrl+C)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const confirmed = await confirmDialog({
|
|
12
|
+
* message: 'Вы уверены?',
|
|
13
|
+
* initial: false,
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export declare function confirmDialog(options: EnquirerConfirmOptions): Promise<boolean>;
|
|
17
|
+
//# sourceMappingURL=confirmDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"confirmDialog.d.ts","sourceRoot":"","sources":["../../../src/cli/interactive/confirmDialog.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAerF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.confirmDialog = confirmDialog;
|
|
4
|
+
const enquirer_1 = require("enquirer");
|
|
5
|
+
const Consts_1 = require("../../common/Consts");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
/**
|
|
8
|
+
* Отображает диалог подтверждения для пользователя.
|
|
9
|
+
* Используется для критичных действий (удаление, публикация и т.д.)
|
|
10
|
+
*
|
|
11
|
+
* @param options - Опции диалога
|
|
12
|
+
* @returns Результат выбора пользователя (true/false)
|
|
13
|
+
* @throws Процесс завершится при прерывании пользователем (Ctrl+C)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const confirmed = await confirmDialog({
|
|
17
|
+
* message: 'Вы уверены?',
|
|
18
|
+
* initial: false,
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
async function confirmDialog(options) {
|
|
22
|
+
try {
|
|
23
|
+
const response = await (0, enquirer_1.prompt)({
|
|
24
|
+
type: 'confirm',
|
|
25
|
+
name: 'answer',
|
|
26
|
+
message: options.message,
|
|
27
|
+
initial: options.initial ?? true,
|
|
28
|
+
});
|
|
29
|
+
return response.answer;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Пользователь прервал процесс (Ctrl+C)
|
|
33
|
+
Consts_1.APP_LOGGER.error(`\n${constants_1.DIALOG_MESSAGES.OPERATION_CANCELLED}`);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EConfigType, EnquirerSelectChoice } from './types';
|
|
2
|
+
export declare const OPEN_API_CONFIG_SELECT_OPTIONS: EnquirerSelectChoice<EConfigType>[];
|
|
3
|
+
export declare const DIALOG_MESSAGES: {
|
|
4
|
+
readonly OPERATION_CANCELLED: "Операция отменена пользователем.";
|
|
5
|
+
readonly SELECTION_CANCELLED: "Выбор отменён.";
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/cli/interactive/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAC,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE3D,eAAO,MAAM,8BAA8B,EAAE,oBAAoB,CAAC,WAAW,CAAC,EAgB7E,CAAC;AAEF,eAAO,MAAM,eAAe;;;CAGlB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DIALOG_MESSAGES = exports.OPEN_API_CONFIG_SELECT_OPTIONS = void 0;
|
|
4
|
+
const types_1 = require("./types");
|
|
5
|
+
exports.OPEN_API_CONFIG_SELECT_OPTIONS = [
|
|
6
|
+
{
|
|
7
|
+
name: 'Набор опций',
|
|
8
|
+
value: types_1.EConfigType.FLAT,
|
|
9
|
+
hint: 'Набор параметров для генерации по одной спецификации.',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: 'Множественные опции',
|
|
13
|
+
value: types_1.EConfigType.MULTI,
|
|
14
|
+
hint: 'Набор параметров для генерации по нескольким файлам спецификаций.',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'Не генерировать',
|
|
18
|
+
value: types_1.EConfigType.NONE,
|
|
19
|
+
hint: 'Не создавать файл конфигурации',
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
exports.DIALOG_MESSAGES = {
|
|
23
|
+
OPERATION_CANCELLED: 'Операция отменена пользователем.',
|
|
24
|
+
SELECTION_CANCELLED: 'Выбор отменён.',
|
|
25
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { EnquirerSelectOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Отображает диалог выбора одного варианта из списка.
|
|
4
|
+
*
|
|
5
|
+
* @param options - Опции диалога выбора
|
|
6
|
+
* @returns Выбранное значение (тип из choices.value)
|
|
7
|
+
* @throws Процесс завершится при прерывании пользователем (Ctrl+C)
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const selected = await selectDialog<MyEnum>({
|
|
11
|
+
* message: 'Выберите вариант',
|
|
12
|
+
* initial: 0,
|
|
13
|
+
* choices: myChoices,
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export declare function selectDialog<T = string>(options: EnquirerSelectOptions<T>): Promise<T>;
|
|
17
|
+
//# sourceMappingURL=selectDialog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectDialog.d.ts","sourceRoot":"","sources":["../../../src/cli/interactive/selectDialog.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAsB5F"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectDialog = selectDialog;
|
|
4
|
+
const enquirer_1 = require("enquirer");
|
|
5
|
+
const Consts_1 = require("../../common/Consts");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
/**
|
|
8
|
+
* Отображает диалог выбора одного варианта из списка.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Опции диалога выбора
|
|
11
|
+
* @returns Выбранное значение (тип из choices.value)
|
|
12
|
+
* @throws Процесс завершится при прерывании пользователем (Ctrl+C)
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* const selected = await selectDialog<MyEnum>({
|
|
16
|
+
* message: 'Выберите вариант',
|
|
17
|
+
* initial: 0,
|
|
18
|
+
* choices: myChoices,
|
|
19
|
+
* });
|
|
20
|
+
*/
|
|
21
|
+
async function selectDialog(options) {
|
|
22
|
+
try {
|
|
23
|
+
const response = await (0, enquirer_1.prompt)({
|
|
24
|
+
type: 'select',
|
|
25
|
+
name: 'choice',
|
|
26
|
+
message: options.message,
|
|
27
|
+
choices: options.choices.map(choice => ({
|
|
28
|
+
name: choice.name,
|
|
29
|
+
value: choice.value,
|
|
30
|
+
hint: choice.hint,
|
|
31
|
+
})),
|
|
32
|
+
initial: options.initial,
|
|
33
|
+
result(value) {
|
|
34
|
+
return value.value;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return response.choice;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
Consts_1.APP_LOGGER.error(`\n${constants_1.DIALOG_MESSAGES.SELECTION_CANCELLED}`);
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Тип конфигурации для инициализации
|
|
3
|
+
*/
|
|
4
|
+
export declare enum EConfigType {
|
|
5
|
+
NONE = "NONE",
|
|
6
|
+
FLAT = "FLAT",
|
|
7
|
+
MULTI = "MULTI"
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Интерфейс для вариантов выбора в диалоге
|
|
11
|
+
*/
|
|
12
|
+
export interface EnquirerSelectChoice<T = string> {
|
|
13
|
+
/** Текст, отображаемый пользователю */
|
|
14
|
+
name: string;
|
|
15
|
+
/** Возвращаемое значение при выборе */
|
|
16
|
+
value: T;
|
|
17
|
+
/** Подсказка/описание варианта */
|
|
18
|
+
hint?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Опции для диалога подтверждения
|
|
22
|
+
*/
|
|
23
|
+
export interface EnquirerConfirmOptions {
|
|
24
|
+
/** Вопрос для пользователя */
|
|
25
|
+
message: string;
|
|
26
|
+
/** Значение по умолчанию */
|
|
27
|
+
initial?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Опции для диалога выбора
|
|
31
|
+
*/
|
|
32
|
+
export interface EnquirerSelectOptions<T = string> {
|
|
33
|
+
/** Вопрос/сообщение */
|
|
34
|
+
message: string;
|
|
35
|
+
/** Варианты для выбора */
|
|
36
|
+
choices: EnquirerSelectChoice<T>[];
|
|
37
|
+
/** Индекс выбранного по умолчанию */
|
|
38
|
+
initial?: number;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/cli/interactive/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,WAAW;IACnB,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB,CAAC,CAAC,GAAG,MAAM;IAC5C,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,KAAK,EAAE,CAAC,CAAC;IACT,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,MAAM;IAC7C,uBAAuB;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,0BAA0B;IAC1B,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;IACnC,qCAAqC;IACrC,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EConfigType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Тип конфигурации для инициализации
|
|
6
|
+
*/
|
|
7
|
+
var EConfigType;
|
|
8
|
+
(function (EConfigType) {
|
|
9
|
+
EConfigType["NONE"] = "NONE";
|
|
10
|
+
EConfigType["FLAT"] = "FLAT";
|
|
11
|
+
EConfigType["MULTI"] = "MULTI";
|
|
12
|
+
})(EConfigType || (exports.EConfigType = EConfigType = {}));
|
package/dist/common/Consts.d.ts
CHANGED
|
@@ -1,2 +1,25 @@
|
|
|
1
|
+
import { HttpClient } from '../core';
|
|
2
|
+
import { ELogLevel, ELogOutput } from './Enums';
|
|
3
|
+
import { Logger } from './Logger';
|
|
1
4
|
export declare const DEFAULT_OPENAPI_CONFIG_FILENAME = "openapi.config.json";
|
|
5
|
+
export declare const COMMON_DEFAULT_OPTIONS_VALUES: {
|
|
6
|
+
outputCore: string;
|
|
7
|
+
outputServices: string;
|
|
8
|
+
outputModels: string;
|
|
9
|
+
outputSchemas: string;
|
|
10
|
+
httpClient: HttpClient;
|
|
11
|
+
useOptions: boolean;
|
|
12
|
+
useUnionTypes: boolean;
|
|
13
|
+
excludeCoreServiceFiles: boolean;
|
|
14
|
+
includeSchemasFiles: boolean;
|
|
15
|
+
interfacePrefix: string;
|
|
16
|
+
enumPrefix: string;
|
|
17
|
+
typePrefix: string;
|
|
18
|
+
useCancelableRequest: boolean;
|
|
19
|
+
logLevel: ELogLevel;
|
|
20
|
+
logTarget: ELogOutput;
|
|
21
|
+
sortByRequired: boolean;
|
|
22
|
+
useSeparatedIndexes: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare const APP_LOGGER: Logger;
|
|
2
25
|
//# sourceMappingURL=Consts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../src/common/Consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,+BAA+B,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Consts.d.ts","sourceRoot":"","sources":["../../src/common/Consts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AAErE,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;CAkBzC,CAAC;AAEF,eAAO,MAAM,UAAU,QAIrB,CAAC"}
|