ts-openapi-codegen 1.0.0-beta.5 → 1.0.0-beta.7
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 +43 -58
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts +5 -0
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +1 -0
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +40 -0
- package/dist/cli/generate/runGenerateOpenApi.js +4 -4
- package/dist/cli/index.js +57 -18
- package/dist/cli/utils.d.ts +4 -16
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js +22 -20
- package/dist/common/Options.d.ts +4 -6
- package/dist/common/Options.d.ts.map +1 -1
- package/dist/common/UpdateNotifier.d.ts +24 -0
- package/dist/common/UpdateNotifier.d.ts.map +1 -0
- package/dist/common/UpdateNotifier.js +120 -0
- package/dist/common/Utils.d.ts.map +1 -1
- package/dist/common/Utils.js +8 -9
- package/dist/common/VersionedSchema/CommonSchemas.d.ts +12 -0
- package/dist/common/VersionedSchema/CommonSchemas.d.ts.map +1 -1
- package/dist/common/VersionedSchema/CommonSchemas.js +27 -1
- package/dist/common/VersionedSchema/{MultiOptionsMigrationPlan.d.ts → MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts} +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsMigrationPlan.js → MultiOptionsVersioned/MultiOptionsMigrationPlan.js} +18 -7
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV1.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV1.js → MultiOptionsVersioned/MultiOptionsSchemaV1.js} +4 -4
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV2.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV2.js → MultiOptionsVersioned/MultiOptionsSchemaV2.js} +4 -4
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts +5 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV3.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV3.js → MultiOptionsVersioned/MultiOptionsSchemaV3.js} +3 -3
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV4.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsSchemaV4.js → MultiOptionsVersioned/MultiOptionsSchemaV4.js} +4 -4
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts +6 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.d.ts.map +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsSchemaV5.js +22 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts +3 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{MultiOptionsVersionedSchemas.js → MultiOptionsVersioned/MultiOptionsVersionedSchemas.js} +10 -5
- package/dist/common/VersionedSchema/{OptionsMigrationPlans.d.ts → OptionsVersioned/OptionsMigrationPlans.d.ts} +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +23 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts +6 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV1.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsSchemaV1.js → OptionsVersioned/OptionsSchemaV1.js} +4 -4
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts +6 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV2.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsSchemaV2.js → OptionsVersioned/OptionsSchemaV2.js} +4 -4
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts +5 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV3.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsSchemaV3.js → OptionsVersioned/OptionsSchemaV3.js} +3 -3
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts +6 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.d.ts.map +1 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsSchemaV4.js +17 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts +3 -0
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/{OptionsVersionedSchemas.js → OptionsVersioned/OptionsVersionedSchemas.js} +9 -4
- package/dist/common/VersionedSchema/Types.d.ts +0 -4
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/__tests__/convertArrayToObject.test.js +62 -59
- package/dist/common/__tests__/mergeObjectSchemas.test.js +1 -1
- package/dist/common/__tests__/migrationForMultiOptions.test.js +9 -5
- package/dist/common/__tests__/migrationForOptions.test.js +17 -8
- package/dist/common/defaultOptions.d.ts.map +1 -1
- package/dist/common/defaultOptions.js +5 -7
- package/dist/core/Context.d.ts +15 -7
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +3 -0
- package/dist/core/WriteClient.d.ts +94 -0
- package/dist/core/WriteClient.d.ts.map +1 -0
- package/dist/core/WriteClient.js +293 -0
- package/dist/core/__tests__/WriteClient.test.d.ts +2 -0
- package/dist/core/__tests__/WriteClient.test.d.ts.map +1 -0
- package/dist/core/{utils/__tests__/writeClient.test.js → __tests__/WriteClient.test.js} +16 -12
- package/dist/core/api/v2/parser/__tests__/getType.test.js +7 -25
- package/dist/core/api/v2/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModel.js +5 -2
- package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModelProperties.js +3 -1
- package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModels.js +3 -29
- package/dist/core/api/v2/parser/getOperation.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperation.js +3 -3
- package/dist/core/api/v2/parser/getOperationParameter.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.js +4 -2
- package/dist/core/api/v2/parser/getOperationParameters.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperationParameters.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameters.js +2 -2
- package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponse.js +3 -1
- package/dist/core/api/v2/parser/getOperationResponses.d.ts +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +2 -2
- package/dist/core/api/v2/parser/getServiceName.d.ts +3 -0
- package/dist/core/api/v2/parser/getServiceName.d.ts.map +1 -0
- package/dist/core/api/v2/parser/getServiceName.js +8 -0
- package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getServices.js +21 -32
- package/dist/core/api/v2/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getType.js +13 -9
- package/dist/core/api/v3/parser/__tests__/getType.test.js +6 -24
- package/dist/core/api/v3/parser/getModel.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModel.js +5 -2
- package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModelProperties.js +3 -1
- package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModels.js +3 -29
- package/dist/core/api/v3/parser/getOperation.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperation.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperation.js +4 -4
- package/dist/core/api/v3/parser/getOperationParameter.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameter.js +6 -3
- package/dist/core/api/v3/parser/getOperationParameters.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperationParameters.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationParameters.js +2 -2
- package/dist/core/api/v3/parser/getOperationRequestBody.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationRequestBody.js +3 -1
- package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponse.js +3 -1
- package/dist/core/api/v3/parser/getOperationResponses.d.ts +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +2 -2
- package/dist/core/api/v3/parser/getServiceName.d.ts +3 -0
- package/dist/core/api/v3/parser/getServiceName.d.ts.map +1 -0
- package/dist/core/api/v3/parser/getServiceName.js +8 -0
- package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServices.js +18 -84
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +22 -10
- package/dist/core/api/v3/types/OpenApiPath.model.d.ts +2 -1
- package/dist/core/api/v3/types/OpenApiPath.model.d.ts.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +21 -22
- package/dist/core/types/base/ClientArtifacts.model.d.ts +12 -0
- package/dist/core/types/base/ClientArtifacts.model.d.ts.map +1 -0
- package/dist/core/types/base/ExportedModel.model.d.ts +17 -0
- package/dist/core/types/base/ExportedModel.model.d.ts.map +1 -0
- package/dist/core/types/base/ExportedService.model.d.ts +9 -0
- package/dist/core/types/base/ExportedService.model.d.ts.map +1 -0
- package/dist/core/types/base/ExportedService.model.js +2 -0
- package/dist/core/types/base/OutputPaths.model.d.ts +15 -0
- package/dist/core/types/base/OutputPaths.model.d.ts.map +1 -0
- package/dist/core/types/base/OutputPaths.model.js +2 -0
- package/dist/core/types/base/PrefixArtifacts.model.d.ts +6 -0
- package/dist/core/types/base/PrefixArtifacts.model.d.ts.map +1 -0
- package/dist/core/types/base/PrefixArtifacts.model.js +2 -0
- package/dist/core/types/base/PropertyGroup.model.d.ts +4 -0
- package/dist/core/types/base/PropertyGroup.model.d.ts.map +1 -0
- package/dist/core/types/base/PropertyGroup.model.js +2 -0
- package/dist/core/types/base/RefWithtype.model.d.ts +11 -0
- package/dist/core/types/base/RefWithtype.model.d.ts.map +1 -0
- package/dist/core/types/base/RefWithtype.model.js +2 -0
- package/dist/core/types/base/Root.model.d.ts +5 -0
- package/dist/core/types/base/Root.model.d.ts.map +1 -0
- package/dist/core/types/base/Root.model.js +2 -0
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts +10 -0
- package/dist/core/types/base/SimpleClientArtifacts.model.d.ts.map +1 -0
- package/dist/core/types/base/SimpleClientArtifacts.model.js +2 -0
- package/dist/core/types/enums/HttpClient.enum.d.ts +7 -0
- package/dist/core/types/enums/HttpClient.enum.d.ts.map +1 -0
- package/dist/core/types/{Enums.js → enums/HttpClient.enum.js} +1 -9
- package/dist/core/types/enums/TypeRef.enum.d.ts +8 -0
- package/dist/core/types/enums/TypeRef.enum.d.ts.map +1 -0
- package/dist/core/types/enums/TypeRef.enum.js +11 -0
- package/dist/core/utils/__tests__/getAbsolutePath.test.js +1 -1
- package/dist/core/utils/__tests__/getGatheringRefs.test.js +3 -6
- package/dist/core/utils/__tests__/getRefFromSchema.test.js +1 -1
- package/dist/core/utils/__tests__/pathHelpers.test.js +4 -4
- package/dist/core/utils/__tests__/refResolver.test.d.ts +2 -0
- package/dist/core/utils/__tests__/refResolver.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/refResolver.test.js +55 -0
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
- package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +7 -3
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts +2 -0
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +67 -0
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +24 -24
- package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +13 -13
- package/dist/core/utils/__tests__/writeClientCore.test.js +14 -6
- package/dist/core/utils/__tests__/writeClientFullIndex.test.d.ts +2 -0
- package/dist/core/utils/__tests__/writeClientFullIndex.test.d.ts.map +1 -0
- package/dist/core/utils/__tests__/{writeClientIndex.test.js → writeClientFullIndex.test.js} +15 -7
- package/dist/core/utils/__tests__/writeClientModels.test.js +15 -7
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +15 -7
- package/dist/core/utils/__tests__/writeClientServices.test.js +15 -7
- package/dist/core/utils/advancedDeduplicatePath.d.ts +5 -0
- package/dist/core/utils/advancedDeduplicatePath.d.ts.map +1 -0
- package/dist/core/utils/advancedDeduplicatePath.js +29 -0
- package/dist/core/utils/appendUniqueLinesToFile.d.ts +2 -0
- package/dist/core/utils/appendUniqueLinesToFile.d.ts.map +1 -0
- package/dist/core/utils/appendUniqueLinesToFile.js +24 -0
- package/dist/core/utils/createNormalizedRef.d.ts +7 -0
- package/dist/core/utils/createNormalizedRef.d.ts.map +1 -0
- package/dist/core/utils/createNormalizedRef.js +24 -0
- package/dist/core/utils/findCommonParent.d.ts +7 -0
- package/dist/core/utils/findCommonParent.d.ts.map +1 -0
- package/dist/core/utils/findCommonParent.js +20 -0
- package/dist/core/utils/getAbsolutePath.d.ts.map +1 -1
- package/dist/core/utils/getAbsolutePath.js +16 -5
- package/dist/core/utils/getGatheringRefs.d.ts +2 -2
- package/dist/core/utils/getGatheringRefs.d.ts.map +1 -1
- package/dist/core/utils/getGatheringRefs.js +26 -17
- package/dist/core/utils/getMappedType.d.ts +0 -1
- package/dist/core/utils/getMappedType.d.ts.map +1 -1
- package/dist/core/utils/getMappedType.js +3 -4
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +9 -32
- package/dist/core/utils/getOutputPaths.d.ts +2 -2
- package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
- package/dist/core/utils/getPropertyGroupExtended.d.ts +2 -2
- package/dist/core/utils/getPropertyGroupExtended.d.ts.map +1 -1
- package/dist/core/utils/getPropertyGroupSimple.d.ts +2 -2
- package/dist/core/utils/getPropertyGroupSimple.d.ts.map +1 -1
- package/dist/core/utils/getRefFromSchema.js +2 -2
- package/dist/core/utils/getRelativeModelImportPath.js +1 -1
- package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
- package/dist/core/utils/getRelativeModelPath.js +5 -0
- package/dist/core/utils/isDirectory.d.ts +2 -0
- package/dist/core/utils/isDirectory.d.ts.map +1 -0
- package/dist/core/utils/isDirectory.js +13 -0
- package/dist/core/utils/isFileName.d.ts +7 -0
- package/dist/core/utils/isFileName.d.ts.map +1 -0
- package/dist/core/utils/isFileName.js +30 -0
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts +10 -0
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -0
- package/dist/core/utils/mapPathToTargetDirSafe.js +49 -0
- package/dist/core/utils/modelHelpers.d.ts +28 -0
- package/dist/core/utils/modelHelpers.d.ts.map +1 -0
- package/dist/core/utils/modelHelpers.js +73 -0
- package/dist/core/utils/normalizeAllRefs.d.ts +6 -0
- package/dist/core/utils/normalizeAllRefs.d.ts.map +1 -0
- package/dist/core/utils/normalizeAllRefs.js +35 -0
- package/dist/core/utils/normalizePath.d.ts +5 -0
- package/dist/core/utils/normalizePath.d.ts.map +1 -0
- package/dist/core/utils/normalizePath.js +19 -0
- package/dist/core/utils/normalizeRef.d.ts +5 -0
- package/dist/core/utils/normalizeRef.d.ts.map +1 -0
- package/dist/core/utils/normalizeRef.js +17 -0
- package/dist/core/utils/parseRef.d.ts +18 -0
- package/dist/core/utils/parseRef.d.ts.map +1 -0
- package/dist/core/utils/parseRef.js +64 -0
- package/dist/core/utils/pathHelpers.d.ts +1 -0
- package/dist/core/utils/pathHelpers.d.ts.map +1 -1
- package/dist/core/utils/pathHelpers.js +23 -3
- package/dist/core/utils/prepareAlias.d.ts +3 -0
- package/dist/core/utils/prepareAlias.d.ts.map +1 -0
- package/dist/core/utils/prepareAlias.js +20 -0
- package/dist/core/utils/prepareOptions.d.ts.map +1 -1
- package/dist/core/utils/prepareOptions.js +5 -7
- package/dist/core/utils/registerHandlebarHelpers.d.ts +1 -1
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.d.ts +9 -2
- package/dist/core/utils/registerHandlebarTemplates.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarTemplates.js +16 -2
- package/dist/core/utils/resolveRefPath.d.ts +7 -0
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -0
- package/dist/core/utils/resolveRefPath.js +34 -0
- package/dist/core/utils/resolveRefToImportPath.d.ts +7 -0
- package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -0
- package/dist/core/utils/resolveRefToImportPath.js +45 -0
- package/dist/core/utils/serviceHelpers.d.ts +41 -0
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -0
- package/dist/core/utils/serviceHelpers.js +115 -0
- package/dist/core/utils/sortModelByName.d.ts +3 -0
- package/dist/core/utils/sortModelByName.d.ts.map +1 -0
- package/dist/core/utils/sortModelByName.js +12 -0
- package/dist/core/utils/writeClientCore.d.ts +4 -2
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +4 -1
- package/dist/core/utils/writeClientCoreIndex.d.ts +11 -0
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientCoreIndex.js +16 -0
- package/dist/core/utils/writeClientFullIndex.d.ts +9 -0
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientFullIndex.js +22 -0
- package/dist/core/utils/writeClientModels.d.ts +3 -2
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +5 -0
- package/dist/core/utils/writeClientModelsIndex.d.ts +12 -0
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientModelsIndex.js +16 -0
- package/dist/core/utils/writeClientSchemas.d.ts +3 -2
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +5 -0
- package/dist/core/utils/writeClientSchemasIndex.d.ts +12 -0
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientSchemasIndex.js +16 -0
- package/dist/core/utils/writeClientServices.d.ts +5 -4
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +4 -0
- package/dist/core/utils/writeClientServicesIndex.d.ts +12 -0
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientServicesIndex.js +16 -0
- package/dist/core/utils/writeClientSimpleIndex.d.ts +9 -0
- package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -0
- package/dist/core/utils/writeClientSimpleIndex.js +22 -0
- package/dist/templatesCompiled/exportModel.js +2 -2
- package/dist/templatesCompiled/indexCore.d.ts +9 -0
- package/dist/templatesCompiled/indexCore.d.ts.map +1 -0
- package/dist/templatesCompiled/indexCore.js +22 -0
- package/dist/templatesCompiled/{index.d.ts → indexFull.d.ts} +1 -1
- package/dist/templatesCompiled/indexFull.d.ts.map +1 -0
- package/dist/templatesCompiled/indexModels.d.ts +15 -0
- package/dist/templatesCompiled/indexModels.d.ts.map +1 -0
- package/dist/templatesCompiled/indexModels.js +82 -0
- package/dist/templatesCompiled/indexServices.d.ts +10 -0
- package/dist/templatesCompiled/indexServices.d.ts.map +1 -0
- package/dist/templatesCompiled/indexServices.js +35 -0
- package/dist/templatesCompiled/indexShemas.d.ts +11 -0
- package/dist/templatesCompiled/indexShemas.d.ts.map +1 -0
- package/dist/templatesCompiled/indexShemas.js +47 -0
- package/dist/templatesCompiled/indexSimple.d.ts +21 -0
- package/dist/templatesCompiled/indexSimple.d.ts.map +1 -0
- package/dist/templatesCompiled/indexSimple.js +121 -0
- package/dist/templatesCompiled/partials/isReadOnly.d.ts +1 -1
- package/dist/templatesCompiled/partials/isReadOnly.d.ts.map +1 -1
- package/dist/templatesCompiled/partials/isReadOnly.js +1 -2
- package/dist/templatesCompiled/partials/isRequiredDefinition.d.ts +9 -0
- package/dist/templatesCompiled/partials/isRequiredDefinition.d.ts.map +1 -0
- package/dist/templatesCompiled/partials/isRequiredDefinition.js +27 -0
- package/dist/templatesCompiled/partials/parametersDefinition.js +1 -1
- package/package.json +15 -4
- package/dist/common/VersionedSchema/MultiOptionsMigrationPlan.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV1.d.ts +0 -6
- package/dist/common/VersionedSchema/MultiOptionsSchemaV1.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV2.d.ts +0 -6
- package/dist/common/VersionedSchema/MultiOptionsSchemaV2.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV3.d.ts +0 -5
- package/dist/common/VersionedSchema/MultiOptionsSchemaV3.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsSchemaV4.d.ts +0 -6
- package/dist/common/VersionedSchema/MultiOptionsSchemaV4.d.ts.map +0 -1
- package/dist/common/VersionedSchema/MultiOptionsVersionedSchemas.d.ts +0 -3
- package/dist/common/VersionedSchema/MultiOptionsVersionedSchemas.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsMigrationPlans.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsMigrationPlans.js +0 -15
- package/dist/common/VersionedSchema/OptionsSchemaV1.d.ts +0 -6
- package/dist/common/VersionedSchema/OptionsSchemaV1.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsSchemaV2.d.ts +0 -6
- package/dist/common/VersionedSchema/OptionsSchemaV2.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsSchemaV3.d.ts +0 -5
- package/dist/common/VersionedSchema/OptionsSchemaV3.d.ts.map +0 -1
- package/dist/common/VersionedSchema/OptionsVersionedSchemas.d.ts +0 -3
- package/dist/common/VersionedSchema/OptionsVersionedSchemas.d.ts.map +0 -1
- package/dist/core/types/Enums.d.ts +0 -14
- package/dist/core/types/Enums.d.ts.map +0 -1
- package/dist/core/types/Models.d.ts +0 -37
- package/dist/core/types/Models.d.ts.map +0 -1
- package/dist/core/types/shared/ConverterData.model.d.ts +0 -7
- package/dist/core/types/shared/ConverterData.model.d.ts.map +0 -1
- package/dist/core/utils/__tests__/writeClient.test.d.ts +0 -2
- package/dist/core/utils/__tests__/writeClient.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/writeClientIndex.test.d.ts +0 -2
- package/dist/core/utils/__tests__/writeClientIndex.test.d.ts.map +0 -1
- package/dist/core/utils/writeClient.d.ts +0 -89
- package/dist/core/utils/writeClient.d.ts.map +0 -1
- package/dist/core/utils/writeClient.js +0 -227
- package/dist/core/utils/writeClientIndex.d.ts +0 -59
- package/dist/core/utils/writeClientIndex.d.ts.map +0 -1
- package/dist/core/utils/writeClientIndex.js +0 -27
- package/dist/templatesCompiled/index.d.ts.map +0 -1
- /package/dist/core/types/{Models.js → base/ClientArtifacts.model.js} +0 -0
- /package/dist/core/types/{shared/ConverterData.model.js → base/ExportedModel.model.js} +0 -0
- /package/dist/templatesCompiled/{index.js → indexFull.js} +0 -0
package/README.md
CHANGED
|
@@ -60,11 +60,8 @@ $ openapi --help
|
|
|
60
60
|
-c, --httpClient <value> HTTP client to generate [fetch, xhr, node] (default: "fetch")
|
|
61
61
|
--useOptions <value> Use options instead of arguments (default: false)
|
|
62
62
|
--useUnionTypes <value> Use union types instead of enums (default: false)
|
|
63
|
-
--
|
|
64
|
-
--
|
|
65
|
-
--exportModels <value> Write models to disk (default: true)
|
|
66
|
-
--exportSchemas <value> Write schemas to disk (default: false)
|
|
67
|
-
--clean <value> Clean a directory before generation (default: true)
|
|
63
|
+
--excludeCoreServiceFiles (default: false)
|
|
64
|
+
--includeSchemasFiles (default: false)
|
|
68
65
|
--interfacePrefix <value> Prefix for interface model(default: "I")
|
|
69
66
|
--enumPrefix <value> Prefix for enum model(default: "E")
|
|
70
67
|
--typePrefix <value> Prefix for type model(default: "T")
|
|
@@ -87,18 +84,14 @@ You should create a file in the root of a project with the name '[openapi.config
|
|
|
87
84
|
"input": "./first.yml",
|
|
88
85
|
"output": "./dist",
|
|
89
86
|
"client": "xhr",
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"exportModels": true,
|
|
93
|
-
"exportSchemas": true
|
|
87
|
+
"excludeCoreServiceFiles": true,
|
|
88
|
+
"includeSchemasFiles": true,
|
|
94
89
|
},{
|
|
95
90
|
"input": "./second.yml",
|
|
96
91
|
"output": "./dist",
|
|
97
92
|
"client": "xhr",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"exportModels": true,
|
|
101
|
-
"exportSchemas": true
|
|
93
|
+
"excludeCoreServiceFiles": true,
|
|
94
|
+
"includeSchemasFiles": true,
|
|
102
95
|
}]
|
|
103
96
|
```
|
|
104
97
|
or with common block
|
|
@@ -106,10 +99,8 @@ or with common block
|
|
|
106
99
|
{
|
|
107
100
|
"output": "./dist",
|
|
108
101
|
"client": "xhr",
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"exportModels": true,
|
|
112
|
-
"exportSchemas": true,
|
|
102
|
+
"excludeCoreServiceFiles": true,
|
|
103
|
+
"includeSchemasFiles": true,
|
|
113
104
|
"items": [{
|
|
114
105
|
"input": "./first.yml"
|
|
115
106
|
},{
|
|
@@ -118,47 +109,41 @@ or with common block
|
|
|
118
109
|
}
|
|
119
110
|
```
|
|
120
111
|
|
|
121
|
-
| Name
|
|
122
|
-
|
|
123
|
-
| output
|
|
124
|
-
| outputCore
|
|
125
|
-
| outputServices
|
|
126
|
-
| outputModels
|
|
127
|
-
| outputSchemas
|
|
128
|
-
| client
|
|
129
|
-
| useOptions
|
|
130
|
-
| useUnionTypes
|
|
131
|
-
|
|
|
132
|
-
|
|
|
133
|
-
|
|
|
134
|
-
|
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
|
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
|
|
|
143
|
-
|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
| | request | string | |Path to custom request file |
|
|
157
|
-
| | write | boolean |true |Write the files to disk (true or false) |
|
|
158
|
-
| | interfacePrefix | string | |Prefix for interface model(I) |
|
|
159
|
-
| | enumPrefix | string | |Prefix for enum model(E) |
|
|
160
|
-
| | typePrefix | string | |Prefix for type model(T) |
|
|
161
|
-
| | useCancelableRequest | boolean |false |Use cancelled promise as returned data type in request |
|
|
112
|
+
| Name | Item | type | Default | Description |
|
|
113
|
+
|-------------------------|-------------------------|-------------|----------|-----------------------------------------------------------|
|
|
114
|
+
| output | | string | |The relative location of the output directory |
|
|
115
|
+
| outputCore | | string | {output} |The relative location of the output directory for core |
|
|
116
|
+
| outputServices | | string | {output} |The relative location of the output directory for services |
|
|
117
|
+
| outputModels | | string | {output} |The relative location of the output directory for models |
|
|
118
|
+
| outputSchemas | | string | {output} |The relative location of the output directory for schemas |
|
|
119
|
+
| client | | string | 'fetch' |The selected httpClient (fetch or XHR) |
|
|
120
|
+
| useOptions | | boolean | false |Use options or arguments functions |
|
|
121
|
+
| useUnionTypes | | boolean | false |Use union types instead of enums |
|
|
122
|
+
| excludeCoreServiceFiles | | boolean | true | |
|
|
123
|
+
| includeSchemasFiles | | boolean | true | |
|
|
124
|
+
| request | | string | |Path to custom request file |
|
|
125
|
+
| interfacePrefix | | string | 'I' |Prefix for interface model |
|
|
126
|
+
| enumPrefix | | string | 'E' |Prefix for enum model |
|
|
127
|
+
| typePrefix | | string | 'T' |Prefix for type model |
|
|
128
|
+
| useCancelableRequest | | boolean | false |Use cancelled promise as returned data type in request |
|
|
129
|
+
| items | | array | | |
|
|
130
|
+
| | input | string | |The relative location of the OpenAPI spec |
|
|
131
|
+
| | output | string | | |
|
|
132
|
+
| | outputCore | string | | |
|
|
133
|
+
| | outputServices | string | | |
|
|
134
|
+
| | outputModels | string | | |
|
|
135
|
+
| | outputSchemas | string | | |
|
|
136
|
+
| | client | string |'fetch' |The selected httpClient (fetch or XHR) |
|
|
137
|
+
| | useOptions | boolean |false |Use options or arguments functions |
|
|
138
|
+
| | useUnionTypes | boolean |false |Use union types instead of enums |
|
|
139
|
+
| | excludeCoreServiceFiles | boolean |true | |
|
|
140
|
+
| | includeSchemasFiles | boolean |true | |
|
|
141
|
+
| | request | string | |Path to custom request file |
|
|
142
|
+
| | write | boolean |true |Write the files to disk (true or false) |
|
|
143
|
+
| | interfacePrefix | string | |Prefix for interface model(I) |
|
|
144
|
+
| | enumPrefix | string | |Prefix for enum model(E) |
|
|
145
|
+
| | typePrefix | string | |Prefix for type model(T) |
|
|
146
|
+
| | useCancelableRequest | boolean |false |Use cancelled promise as returned data type in request |
|
|
162
147
|
|
|
163
148
|
## Example
|
|
164
149
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chekOpenApiConfig.d.ts","sourceRoot":"","sources":["../../../src/cli/chekOpenApiConfig/chekOpenApiConfig.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,wBAAgB,iBAAiB,SA4BhC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chekOpenApiConfig = chekOpenApiConfig;
|
|
4
|
+
const Enums_1 = require("../../common/Enums");
|
|
5
|
+
const Logger_1 = require("../../common/Logger");
|
|
6
|
+
const Utils_1 = require("../../common/Utils");
|
|
7
|
+
const MultiOptionsVersionedSchemas_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas");
|
|
8
|
+
const OptionsVersionedSchemas_1 = require("../../common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas");
|
|
9
|
+
const getErrorFieldsFromValidation_1 = require("../../common/VersionedSchema/Utils/getErrorFieldsFromValidation");
|
|
10
|
+
const isInstanceOfMultiOptions_1 = require("../../core/utils/isInstanceOfMultiOptions");
|
|
11
|
+
/**
|
|
12
|
+
* The function checks whether the configuration file data is filled in correctly
|
|
13
|
+
*/
|
|
14
|
+
function chekOpenApiConfig() {
|
|
15
|
+
const logger = new Logger_1.Logger({
|
|
16
|
+
level: Enums_1.ELogLevel.INFO,
|
|
17
|
+
instanceId: 'check-openapi-config',
|
|
18
|
+
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
19
|
+
});
|
|
20
|
+
try {
|
|
21
|
+
const configData = (0, Utils_1.loadConfigIfExists)();
|
|
22
|
+
if (!configData) {
|
|
23
|
+
logger.error('The configuration file is missing');
|
|
24
|
+
}
|
|
25
|
+
const preparedOptions = (0, Utils_1.convertArrayToObject)(configData);
|
|
26
|
+
const isMultiOptions = (0, isInstanceOfMultiOptions_1.isInstanceOfMultioptions)(preparedOptions);
|
|
27
|
+
const currentMigrationPlan = isMultiOptions ? MultiOptionsVersionedSchemas_1.multiOptionsVersionedSchema : OptionsVersionedSchemas_1.optionsVersionedSchemas;
|
|
28
|
+
const currentSchema = currentMigrationPlan
|
|
29
|
+
.map((sch, idx) => ({ ...sch, index: idx + 1 }))
|
|
30
|
+
.reduce((prev, curr) => (curr.index > prev.index ? curr : prev));
|
|
31
|
+
const { error } = currentSchema.schema.validate(preparedOptions);
|
|
32
|
+
if (error) {
|
|
33
|
+
const details = (0, getErrorFieldsFromValidation_1.getErrorFieldsFromValidation)(error).map((e) => `${e.path}: ${e.type}`).join(',');
|
|
34
|
+
logger.error(`The configuration file data is specified incorrectly: ${details}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger.error(error.message);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -38,10 +38,10 @@ const defaultOptions_1 = require("../../common/defaultOptions");
|
|
|
38
38
|
const Enums_1 = require("../../common/Enums");
|
|
39
39
|
const Logger_1 = require("../../common/Logger");
|
|
40
40
|
const Utils_1 = require("../../common/Utils");
|
|
41
|
-
const MultiOptionsMigrationPlan_1 = require("../../common/VersionedSchema/MultiOptionsMigrationPlan");
|
|
42
|
-
const MultiOptionsVersionedSchemas_1 = require("../../common/VersionedSchema/MultiOptionsVersionedSchemas");
|
|
43
|
-
const OptionsMigrationPlans_1 = require("../../common/VersionedSchema/OptionsMigrationPlans");
|
|
44
|
-
const OptionsVersionedSchemas_1 = require("../../common/VersionedSchema/OptionsVersionedSchemas");
|
|
41
|
+
const MultiOptionsMigrationPlan_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan");
|
|
42
|
+
const MultiOptionsVersionedSchemas_1 = require("../../common/VersionedSchema/MultiOptionsVersioned/MultiOptionsVersionedSchemas");
|
|
43
|
+
const OptionsMigrationPlans_1 = require("../../common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans");
|
|
44
|
+
const OptionsVersionedSchemas_1 = require("../../common/VersionedSchema/OptionsVersioned/OptionsVersionedSchemas");
|
|
45
45
|
const migrateDataToLatestSchemaVersion_1 = require("../../common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion");
|
|
46
46
|
const OpenAPI = __importStar(require("../../core"));
|
|
47
47
|
const isInstanceOfMultiOptions_1 = require("../../core/utils/isInstanceOfMultiOptions");
|
package/dist/cli/index.js
CHANGED
|
@@ -1,40 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
const commander_1 = require("commander");
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
4
9
|
const Enums_1 = require("../common/Enums");
|
|
5
|
-
const
|
|
10
|
+
const Logger_1 = require("../common/Logger");
|
|
11
|
+
const UpdateNotifier_1 = require("../common/UpdateNotifier");
|
|
12
|
+
const HttpClient_enum_1 = require("../core/types/enums/HttpClient.enum");
|
|
13
|
+
const chekOpenApiConfig_1 = require("./chekOpenApiConfig/chekOpenApiConfig");
|
|
6
14
|
const runGenerateOpenApi_1 = require("./generate/runGenerateOpenApi");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
const packageDetails = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '../../package.json'), 'utf-8'));
|
|
17
|
+
const APP_NAME = packageDetails.name || 'ts-openapi-codegen-cli';
|
|
18
|
+
const APP_VERSION = packageDetails.version || '1.0.0';
|
|
19
|
+
const APP_DESCRIPTION = packageDetails.description || 'Description';
|
|
20
|
+
const updateNotifier = new UpdateNotifier_1.UpdateNotifier(APP_NAME, APP_VERSION);
|
|
9
21
|
const program = new commander_1.Command();
|
|
10
|
-
program.version(APP_VERSION).name(APP_NAME).description(
|
|
22
|
+
program.version(APP_VERSION).name(APP_NAME).description(APP_DESCRIPTION).addHelpText('before', (0, utils_1.getCLIName)(APP_NAME));
|
|
11
23
|
program
|
|
12
24
|
.command('generate')
|
|
25
|
+
.description('Starts code generation based on the provided opeanpi specifications')
|
|
26
|
+
.addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
|
|
13
27
|
.usage('[options]')
|
|
14
|
-
.version(APP_VERSION)
|
|
15
28
|
.option('-i, --input <value>', 'OpenAPI specification, can be a path, url or string content (required)', '')
|
|
16
29
|
.option('-o, --output <value>', 'Output directory (required)', '')
|
|
17
30
|
.option('-oc, --outputCore <value>', 'Output directory for core files')
|
|
18
31
|
.option('-os, --outputServices <value>', 'Output directory for services')
|
|
19
32
|
.option('-om, --outputModels <value>', 'Output directory for models')
|
|
20
33
|
.option('-osm, --outputSchemas <value>', 'Output directory for schemas')
|
|
21
|
-
.addOption(new commander_1.Option('-c, --httpClient <value>', 'HTTP client to generate').choices([...Object.values(
|
|
22
|
-
.option('--useOptions
|
|
23
|
-
.option('--useUnionTypes
|
|
24
|
-
.option('--
|
|
25
|
-
.option('--
|
|
26
|
-
.option('--exportModels <value>', 'Write models to disk', true)
|
|
27
|
-
.option('--exportSchemas <value>', 'Write schemas to disk', false)
|
|
28
|
-
.option('--clean <value>', 'Clean a directory before generation', true)
|
|
34
|
+
.addOption(new commander_1.Option('-c, --httpClient <value>', 'HTTP client to generate').choices([...Object.values(HttpClient_enum_1.HttpClient)]).default(HttpClient_enum_1.HttpClient.FETCH))
|
|
35
|
+
.option('--useOptions', 'Use options instead of arguments (default: false)')
|
|
36
|
+
.option('--useUnionTypes', 'Use union types instead of enums (default: false)')
|
|
37
|
+
.option('--excludeCoreServiceFiles', 'The generation of the core and services is excluded (default: false)')
|
|
38
|
+
.option('--includeSchemasFiles', 'The generation of model validation schemes is enabled (default: false)')
|
|
29
39
|
.option('--request <value>', 'Path to custom request file')
|
|
30
|
-
.option('--interfacePrefix <value>', 'Prefix for interface model(default: "I")')
|
|
31
|
-
.option('--enumPrefix <value>', 'Prefix for enum model(default: "E")')
|
|
32
|
-
.option('--typePrefix <value>', 'Prefix for type model(default: "T")')
|
|
33
|
-
.option('--useCancelableRequest
|
|
40
|
+
.option('--interfacePrefix <value>', 'Prefix for interface model(default: "I")', "I")
|
|
41
|
+
.option('--enumPrefix <value>', 'Prefix for enum model(default: "E")', "E")
|
|
42
|
+
.option('--typePrefix <value>', 'Prefix for type model(default: "T")', "T")
|
|
43
|
+
.option('--useCancelableRequest', 'Use cancelled promise as returned data type in request (default: false)')
|
|
34
44
|
.addOption(new commander_1.Option('-l, --logLevel <level>', 'Logging level').choices([...Object.values(Enums_1.ELogLevel)]).default(Enums_1.ELogLevel.ERROR))
|
|
35
45
|
.addOption(new commander_1.Option('-t, --logTarget <target>', 'Target of logging').choices([...Object.values(Enums_1.ELogOutput)]).default(Enums_1.ELogOutput.CONSOLE))
|
|
36
46
|
.option('-s, --sortByRequired', 'Property sorting strategy: simplified or extended')
|
|
47
|
+
.option('--useSeparatedIndexes', 'Use separate index files for the core, models, schemas, and services.')
|
|
48
|
+
.hook('preAction', () => {
|
|
49
|
+
updateNotifier.checkAndNotify();
|
|
50
|
+
})
|
|
37
51
|
.action(async (options) => {
|
|
38
52
|
await (0, runGenerateOpenApi_1.runGenerateOpenApi)(options);
|
|
39
53
|
});
|
|
40
|
-
program
|
|
54
|
+
program
|
|
55
|
+
.command('check-openapi-config')
|
|
56
|
+
.description('Starts checking whether the configuration file data is filled in correctly.')
|
|
57
|
+
.addHelpText('before', (0, utils_1.getCLIName)(APP_NAME))
|
|
58
|
+
.hook('preAction', () => {
|
|
59
|
+
updateNotifier.checkAndNotify();
|
|
60
|
+
})
|
|
61
|
+
.action(() => {
|
|
62
|
+
(0, chekOpenApiConfig_1.chekOpenApiConfig)();
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
program.parse(process.argv);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error.code === 'commander.unknownOption') {
|
|
69
|
+
const errorMessage = error?.message ?? '';
|
|
70
|
+
if (errorMessage) {
|
|
71
|
+
const logger = new Logger_1.Logger({
|
|
72
|
+
level: Enums_1.ELogLevel.INFO,
|
|
73
|
+
instanceId: 'check-openapi-config',
|
|
74
|
+
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
75
|
+
});
|
|
76
|
+
logger.error(errorMessage);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
package/dist/cli/utils.d.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
+
export declare function isValidJson(value: any): boolean;
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @param {*} value The value to check.
|
|
5
|
-
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
|
|
6
|
-
* @example
|
|
7
|
-
*
|
|
8
|
-
* isNil(null)
|
|
9
|
-
* // => true
|
|
10
|
-
*
|
|
11
|
-
* isNil(void 0)
|
|
12
|
-
* // => true
|
|
13
|
-
*
|
|
14
|
-
* isNil(NaN)
|
|
15
|
-
* // => false
|
|
3
|
+
* Returns the stylized package name to display in the terminal
|
|
4
|
+
* @param appName Package name
|
|
16
5
|
*/
|
|
17
|
-
export declare function
|
|
18
|
-
export declare function isValidJson(value: any): boolean;
|
|
6
|
+
export declare function getCLIName(appName: string): string;
|
|
19
7
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/cli/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/cli/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,WAOrC;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,UAazC"}
|
package/dist/cli/utils.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isNil = isNil;
|
|
4
6
|
exports.isValidJson = isValidJson;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* @param {*} value The value to check.
|
|
9
|
-
* @returns {boolean} Returns `true` if `value` is nullish, else `false`.
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* isNil(null)
|
|
13
|
-
* // => true
|
|
14
|
-
*
|
|
15
|
-
* isNil(void 0)
|
|
16
|
-
* // => true
|
|
17
|
-
*
|
|
18
|
-
* isNil(NaN)
|
|
19
|
-
* // => false
|
|
20
|
-
*/
|
|
21
|
-
function isNil(value) {
|
|
22
|
-
return value == null;
|
|
23
|
-
}
|
|
7
|
+
exports.getCLIName = getCLIName;
|
|
8
|
+
const figlet_1 = __importDefault(require("figlet"));
|
|
24
9
|
function isValidJson(value) {
|
|
25
10
|
try {
|
|
26
11
|
JSON.parse(value);
|
|
@@ -30,3 +15,20 @@ function isValidJson(value) {
|
|
|
30
15
|
return false;
|
|
31
16
|
}
|
|
32
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the stylized package name to display in the terminal
|
|
20
|
+
* @param appName Package name
|
|
21
|
+
*/
|
|
22
|
+
function getCLIName(appName) {
|
|
23
|
+
const name = figlet_1.default.textSync(appName, {
|
|
24
|
+
horizontalLayout: 'default',
|
|
25
|
+
verticalLayout: 'default',
|
|
26
|
+
width: 75,
|
|
27
|
+
whitespaceBreak: true,
|
|
28
|
+
});
|
|
29
|
+
return `
|
|
30
|
+
|
|
31
|
+
${name}
|
|
32
|
+
|
|
33
|
+
`;
|
|
34
|
+
}
|
package/dist/common/Options.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpClient } from
|
|
1
|
+
import { HttpClient } from '../core';
|
|
2
2
|
export type TOptions = {
|
|
3
3
|
input: string | Record<string, any>;
|
|
4
4
|
output: string;
|
|
@@ -9,11 +9,8 @@ export type TOptions = {
|
|
|
9
9
|
httpClient?: HttpClient;
|
|
10
10
|
useOptions?: boolean;
|
|
11
11
|
useUnionTypes?: boolean;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exportModels?: boolean;
|
|
15
|
-
exportSchemas?: boolean;
|
|
16
|
-
clean?: boolean;
|
|
12
|
+
excludeCoreServiceFiles?: boolean;
|
|
13
|
+
includeSchemasFiles?: boolean;
|
|
17
14
|
request?: string;
|
|
18
15
|
write?: boolean;
|
|
19
16
|
interfacePrefix?: string;
|
|
@@ -21,6 +18,7 @@ export type TOptions = {
|
|
|
21
18
|
typePrefix?: string;
|
|
22
19
|
useCancelableRequest?: boolean;
|
|
23
20
|
sortByRequired?: boolean;
|
|
21
|
+
useSeparatedIndexes?: boolean;
|
|
24
22
|
};
|
|
25
23
|
export type TMultiOptions = {
|
|
26
24
|
items: TOptions[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Options.d.ts","sourceRoot":"","sources":["../../src/common/Options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Options.d.ts","sourceRoot":"","sources":["../../src/common/Options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,QAAQ,GAAG;IACnB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IACxB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACrB,GAAG,IAAI,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class for tracking the release of a newer version of the generator
|
|
3
|
+
*/
|
|
4
|
+
export declare class UpdateNotifier {
|
|
5
|
+
private _packageName;
|
|
6
|
+
private _packageVersion;
|
|
7
|
+
private _configStore;
|
|
8
|
+
private _packageStoreInfo;
|
|
9
|
+
private _logger;
|
|
10
|
+
constructor(packageName: string, packageVersion: string);
|
|
11
|
+
/**
|
|
12
|
+
* Requests the latest version of the generator via npm
|
|
13
|
+
*/
|
|
14
|
+
private fetchNpmPackageInfo;
|
|
15
|
+
/**
|
|
16
|
+
* Checks for updates and writes useful information to the cache
|
|
17
|
+
*/
|
|
18
|
+
private checkUpdate;
|
|
19
|
+
/**
|
|
20
|
+
* Checks for updates and notifies about the possibility to install a new version.
|
|
21
|
+
*/
|
|
22
|
+
checkAndNotify(): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=UpdateNotifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UpdateNotifier.d.ts","sourceRoot":"","sources":["../../src/common/UpdateNotifier.ts"],"names":[],"mappings":"AAqBA;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,OAAO,CAAS;gBAEZ,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM;IA0BvD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkB3B;;OAEG;IACH,OAAO,CAAC,WAAW;IAwBnB;;OAEG;IACH,cAAc;CAmCjB"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.UpdateNotifier = void 0;
|
|
7
|
+
const boxen_1 = __importDefault(require("boxen"));
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const configstore_1 = __importDefault(require("configstore"));
|
|
11
|
+
const semver_1 = __importDefault(require("semver"));
|
|
12
|
+
const Enums_1 = require("./Enums");
|
|
13
|
+
const Logger_1 = require("./Logger");
|
|
14
|
+
// one week
|
|
15
|
+
const UPDATE_CHECK_INTERVAL = 1000 * 60 * 60 * 24 * 7;
|
|
16
|
+
const INCLUDED_RELEASE_TYPES = ['major', 'minor'];
|
|
17
|
+
/**
|
|
18
|
+
* A class for tracking the release of a newer version of the generator
|
|
19
|
+
*/
|
|
20
|
+
class UpdateNotifier {
|
|
21
|
+
_packageName;
|
|
22
|
+
_packageVersion;
|
|
23
|
+
_configStore = null;
|
|
24
|
+
_packageStoreInfo = null;
|
|
25
|
+
_logger;
|
|
26
|
+
constructor(packageName, packageVersion) {
|
|
27
|
+
this._logger = new Logger_1.Logger({
|
|
28
|
+
instanceId: '',
|
|
29
|
+
level: Enums_1.ELogLevel.INFO,
|
|
30
|
+
logOutput: Enums_1.ELogOutput.CONSOLE,
|
|
31
|
+
});
|
|
32
|
+
if (!packageName || !packageVersion) {
|
|
33
|
+
this._logger.warn(`
|
|
34
|
+
The necessary parameters for checking the version are not specified.
|
|
35
|
+
Current values packageName: ${packageName}, packageVersion: ${packageVersion}
|
|
36
|
+
`);
|
|
37
|
+
}
|
|
38
|
+
this._packageName = packageName;
|
|
39
|
+
this._packageVersion = packageVersion;
|
|
40
|
+
try {
|
|
41
|
+
this._configStore = new configstore_1.default(`-${this._packageName}`, {
|
|
42
|
+
lastUpdateCheck: Date.now(),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
this._logger.warn('The settings store has not been created. The package update will be checked more often than once every 1 week!');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Requests the latest version of the generator via npm
|
|
51
|
+
*/
|
|
52
|
+
fetchNpmPackageInfo() {
|
|
53
|
+
try {
|
|
54
|
+
const latestVersion = (0, child_process_1.execSync)(`npm view ${this._packageName} version`).toString().trim();
|
|
55
|
+
const releaseType = semver_1.default.diff(this._packageVersion, latestVersion);
|
|
56
|
+
return {
|
|
57
|
+
currentVersion: this._packageVersion,
|
|
58
|
+
differenceType: releaseType,
|
|
59
|
+
latestVersion,
|
|
60
|
+
packageName: this._packageName,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
this._logger.warn("Couldn't get information about the latest current version");
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Checks for updates and writes useful information to the cache
|
|
70
|
+
*/
|
|
71
|
+
checkUpdate() {
|
|
72
|
+
if (!this._configStore) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this._packageStoreInfo = this._configStore.get('package_store_info');
|
|
76
|
+
if (this._packageStoreInfo) {
|
|
77
|
+
this._packageStoreInfo.currentVersion = this._packageVersion;
|
|
78
|
+
// clean cache
|
|
79
|
+
this._configStore.delete('package_store_info');
|
|
80
|
+
}
|
|
81
|
+
if (Date.now() - this._configStore.get('lastUpdateCheck') < UPDATE_CHECK_INTERVAL) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const fetchInfo = this.fetchNpmPackageInfo();
|
|
85
|
+
this._configStore.set('lastUpdateCheck', Date.now());
|
|
86
|
+
if (fetchInfo?.differenceType && INCLUDED_RELEASE_TYPES.includes(fetchInfo.differenceType)) {
|
|
87
|
+
this._configStore.set('package_store_info', fetchInfo);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Checks for updates and notifies about the possibility to install a new version.
|
|
92
|
+
*/
|
|
93
|
+
checkAndNotify() {
|
|
94
|
+
if (!this._configStore) {
|
|
95
|
+
this._logger.warn("Couldn't get information about the latest current version");
|
|
96
|
+
this._logger.shutdownLogger();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.checkUpdate();
|
|
100
|
+
if (!this._packageStoreInfo || !semver_1.default.gt(this._packageStoreInfo.latestVersion, this._packageStoreInfo.currentVersion)) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const { packageName, currentVersion, latestVersion } = this._packageStoreInfo;
|
|
104
|
+
const scriptText = chalk_1.default.yellowBright(`npm i -D ${packageName}@${latestVersion}`);
|
|
105
|
+
const message = `
|
|
106
|
+
An update is available: ${chalk_1.default.gray(currentVersion)} -> ${chalk_1.default.greenBright(latestVersion)}}
|
|
107
|
+
Run ${scriptText} to update
|
|
108
|
+
`;
|
|
109
|
+
console.log((0, boxen_1.default)(message, {
|
|
110
|
+
borderColor: 'cyanBright',
|
|
111
|
+
margin: 1,
|
|
112
|
+
padding: 1,
|
|
113
|
+
title: 'Pay attention',
|
|
114
|
+
titleAlignment: 'center',
|
|
115
|
+
textAlignment: 'center',
|
|
116
|
+
}));
|
|
117
|
+
this._logger.shutdownLogger();
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.UpdateNotifier = UpdateNotifier;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/common/Utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,uDAYjC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/common/Utils.ts"],"names":[],"mappings":"AAOA,wBAAgB,kBAAkB,uDAYjC;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA4DxH"}
|
package/dist/common/Utils.js
CHANGED
|
@@ -24,10 +24,8 @@ function loadConfigIfExists() {
|
|
|
24
24
|
function convertArrayToObject(optionsArr) {
|
|
25
25
|
const emptyResult = {
|
|
26
26
|
items: [],
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
exportModels: undefined,
|
|
30
|
-
exportSchemas: undefined,
|
|
27
|
+
excludeCoreServiceFiles: undefined,
|
|
28
|
+
includeSchemasFiles: undefined,
|
|
31
29
|
request: undefined,
|
|
32
30
|
useOptions: undefined,
|
|
33
31
|
useCancelableRequest: undefined,
|
|
@@ -52,16 +50,17 @@ function convertArrayToObject(optionsArr) {
|
|
|
52
50
|
'httpClient',
|
|
53
51
|
'useOptions',
|
|
54
52
|
'useUnionTypes',
|
|
55
|
-
'
|
|
56
|
-
'
|
|
57
|
-
'exportModels',
|
|
58
|
-
'exportSchemas',
|
|
59
|
-
'clean',
|
|
53
|
+
'excludeCoreServiceFiles',
|
|
54
|
+
'includeSchemasFiles',
|
|
60
55
|
'request',
|
|
61
56
|
'interfacePrefix',
|
|
62
57
|
'enumPrefix',
|
|
63
58
|
'typePrefix',
|
|
64
59
|
'useCancelableRequest',
|
|
60
|
+
'logLevel',
|
|
61
|
+
'logTarget',
|
|
62
|
+
'sortByRequired',
|
|
63
|
+
'useSeparatedIndexes',
|
|
65
64
|
];
|
|
66
65
|
const extractedFields = fieldsToExtract.reduce((acc, field) => ({
|
|
67
66
|
...acc,
|