ts-openapi-codegen 1.0.0-beta.6 → 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.js +2 -2
- package/dist/cli/generate/runGenerateOpenApi.js +4 -4
- package/dist/cli/index.js +11 -13
- package/dist/cli/utils.d.ts +0 -17
- package/dist/cli/utils.d.ts.map +1 -1
- package/dist/cli/utils.js +0 -20
- package/dist/common/Options.d.ts +4 -6
- package/dist/common/Options.d.ts.map +1 -1
- 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 +43 -45
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +156 -81
- package/dist/core/__tests__/WriteClient.test.js +12 -8
- 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 +19 -20
- 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 +2 -6
- package/dist/core/utils/prepareAlias.d.ts.map +1 -1
- package/dist/core/utils/prepareAlias.js +0 -4
- 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 +14 -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 +2 -2
- package/dist/core/utils/sortModelByName.d.ts.map +1 -1
- 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/package.json +7 -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__/writeClientIndex.test.d.ts +0 -2
- package/dist/core/utils/__tests__/writeClientIndex.test.d.ts.map +0 -1
- 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/dist/core/Context.d.ts
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { JSONSchema4Type, JSONSchema6Type, JSONSchema7Type } from 'json-schema';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { OutputPaths } from './types/base/OutputPaths.model';
|
|
3
|
+
import { PrefixArtifacts } from './types/base/PrefixArtifacts.model';
|
|
4
|
+
import { $Root } from './types/base/Root.model';
|
|
4
5
|
type TContextProps = {
|
|
5
6
|
input: string | Record<string, any>;
|
|
6
|
-
output:
|
|
7
|
-
prefix?:
|
|
7
|
+
output: OutputPaths;
|
|
8
|
+
prefix?: PrefixArtifacts;
|
|
8
9
|
sortByRequired?: boolean;
|
|
9
10
|
};
|
|
11
|
+
type RefsLike = {
|
|
12
|
+
values: (...args: any[]) => Record<string, any>;
|
|
13
|
+
get: (...args: any[]) => JSONSchema4Type | JSONSchema6Type | JSONSchema7Type;
|
|
14
|
+
paths: (...args: any[]) => string[];
|
|
15
|
+
exists: (...args: any[]) => boolean;
|
|
16
|
+
};
|
|
10
17
|
/**
|
|
11
18
|
* A Context wich can share a data between methods
|
|
12
19
|
*/
|
|
@@ -14,17 +21,18 @@ export declare class Context {
|
|
|
14
21
|
private _refs;
|
|
15
22
|
private _root;
|
|
16
23
|
private _output;
|
|
17
|
-
prefix:
|
|
24
|
+
prefix: PrefixArtifacts;
|
|
18
25
|
private _sortByRequired;
|
|
19
26
|
constructor({ input, output, prefix, sortByRequired }: TContextProps);
|
|
20
|
-
addRefs(refs:
|
|
27
|
+
addRefs(refs: RefsLike): Context;
|
|
21
28
|
values(...types: string[]): Record<string, any>;
|
|
22
29
|
get($ref: string): JSONSchema4Type | JSONSchema6Type | JSONSchema7Type;
|
|
23
30
|
paths(...types: string[]): string[];
|
|
24
31
|
exists($ref: string): boolean;
|
|
25
32
|
fileName(): string;
|
|
26
|
-
get output():
|
|
33
|
+
get output(): OutputPaths;
|
|
27
34
|
get sortByRequired(): boolean;
|
|
35
|
+
get root(): $Root | undefined;
|
|
28
36
|
}
|
|
29
37
|
export {};
|
|
30
38
|
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/core/Context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../src/core/Context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,KAAK,EAAC,MAAM,yBAAyB,CAAC;AAK/C,KAAK,aAAa,GAAG;IACjB,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAA;AAED,KAAK,QAAQ,GAAG;IACZ,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChD,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,eAAe,GAAG,eAAe,GAAG,eAAe,CAAC;IAC7E,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,qBAAa,OAAO;IAChB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,OAAO,CAAc;IACtB,MAAM,EAAE,eAAe,CAI5B;IAEF,OAAO,CAAC,eAAe,CAAkB;gBAE7B,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,aAAa;IAmB7D,OAAO,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO;IAKhC,MAAM,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAO/C,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,GAAG,eAAe;IAOtE,KAAK,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAOnC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAO7B,QAAQ,IAAI,MAAM;IAOzB,IAAW,MAAM,gBAKhB;IAED,IAAW,cAAc,YAExB;IAED,IAAW,IAAI,IAAI,KAAK,GAAG,SAAS,CAEnC;CACJ"}
|
package/dist/core/Context.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { Logger } from '../common/Logger';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { OutputPaths } from './types/base/OutputPaths.model';
|
|
3
|
+
import { HttpClient } from './types/enums/HttpClient.enum';
|
|
4
4
|
import type { Client } from './types/shared/Client.model';
|
|
5
5
|
import { Templates } from './utils/registerHandlebarTemplates';
|
|
6
|
+
import { writeClientCore } from './utils/writeClientCore';
|
|
7
|
+
import { writeClientCoreIndex } from './utils/writeClientCoreIndex';
|
|
8
|
+
import { writeClientFullIndex } from './utils/writeClientFullIndex';
|
|
9
|
+
import { writeClientModels } from './utils/writeClientModels';
|
|
10
|
+
import { writeClientModelsIndex } from './utils/writeClientModelsIndex';
|
|
11
|
+
import { writeClientSchemas } from './utils/writeClientSchemas';
|
|
12
|
+
import { writeClientSchemasIndex } from './utils/writeClientSchemasIndex';
|
|
13
|
+
import { writeClientServices } from './utils/writeClientServices';
|
|
14
|
+
import { writeClientServicesIndex } from './utils/writeClientServicesIndex';
|
|
15
|
+
import { writeClientSimpleIndex } from './utils/writeClientSimpleIndex';
|
|
6
16
|
/**
|
|
7
17
|
* @param client Client object with all the models, services, etc.
|
|
8
18
|
* @param templates Templates wrapper with all loaded Handlebars templates
|
|
@@ -10,54 +20,31 @@ import { Templates } from './utils/registerHandlebarTemplates';
|
|
|
10
20
|
* @param httpClient The selected httpClient (fetch, xhr or node)
|
|
11
21
|
* @param useOptions Use options or arguments functions
|
|
12
22
|
* @param useUnionTypes Use union types instead of enums
|
|
13
|
-
* @param
|
|
14
|
-
* @param
|
|
15
|
-
* @param exportModels: Generate models
|
|
16
|
-
* @param exportSchemas: Generate schemas
|
|
17
|
-
* @param clean: Clean a directory before generation
|
|
23
|
+
* @param excludeCoreServiceFiles The generation of the core and services is excluded
|
|
24
|
+
* @param includeSchemasFiles The generation of model validation schemes is enabled
|
|
18
25
|
* @param request: Path to custom request file
|
|
19
26
|
* @param useCancelableRequest Use cancelable request type.
|
|
27
|
+
* @param useSeparatedIndexes Use separate index files for the core, models, schemas, and services
|
|
20
28
|
*/
|
|
21
|
-
|
|
29
|
+
type TWriteClientProps = {
|
|
22
30
|
client: Client;
|
|
23
31
|
templates: Templates;
|
|
24
|
-
outputPaths:
|
|
32
|
+
outputPaths: OutputPaths;
|
|
25
33
|
httpClient: HttpClient;
|
|
26
34
|
useOptions: boolean;
|
|
27
35
|
useUnionTypes: boolean;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
exportModels: boolean;
|
|
31
|
-
exportSchemas: boolean;
|
|
32
|
-
clean: boolean;
|
|
36
|
+
excludeCoreServiceFiles: boolean;
|
|
37
|
+
includeSchemasFiles: boolean;
|
|
33
38
|
request?: string;
|
|
34
39
|
useCancelableRequest?: boolean;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @param templates The loaded handlebar templates
|
|
39
|
-
* @param outputPaths Directory to write the generated files to
|
|
40
|
-
* @param useUnionTypes Use union types instead of enums
|
|
41
|
-
* @param exportCore: Generate core
|
|
42
|
-
* @param exportServices: Generate services
|
|
43
|
-
* @param exportModels: Generate models
|
|
44
|
-
* @param exportSchemas: Generate schemas
|
|
45
|
-
*/
|
|
46
|
-
export interface IWriteClientIndex {
|
|
47
|
-
client: Client;
|
|
48
|
-
templates: Templates;
|
|
49
|
-
outputPaths: IOutput;
|
|
50
|
-
useUnionTypes: boolean;
|
|
51
|
-
exportCore: boolean;
|
|
52
|
-
exportServices: boolean;
|
|
53
|
-
exportModels: boolean;
|
|
54
|
-
exportSchemas: boolean;
|
|
55
|
-
}
|
|
40
|
+
useSeparatedIndexes?: boolean;
|
|
41
|
+
};
|
|
42
|
+
type TAPIClientGeneratorConfig = Omit<TWriteClientProps, 'httpClient' | 'useOptions' | 'request' | 'useCancelableRequest' | 'useSeparatedIndexes'>;
|
|
56
43
|
/**
|
|
57
44
|
* The client which is writing all items and keep the parameters to write index file
|
|
58
45
|
*/
|
|
59
46
|
export declare class WriteClient {
|
|
60
|
-
private
|
|
47
|
+
private config;
|
|
61
48
|
private _logger;
|
|
62
49
|
constructor();
|
|
63
50
|
/**
|
|
@@ -68,29 +55,40 @@ export declare class WriteClient {
|
|
|
68
55
|
* @param httpClient The selected httpClient (fetch, xhr or node)
|
|
69
56
|
* @param useOptions Use options or arguments functions
|
|
70
57
|
* @param useUnionTypes Use union types instead of enums
|
|
71
|
-
* @param
|
|
72
|
-
* @param
|
|
73
|
-
* @param exportModels: Generate models
|
|
74
|
-
* @param exportSchemas: Generate schemas
|
|
75
|
-
* @param clean: Clean a directory before generation
|
|
58
|
+
* @param excludeCoreServiceFiles:
|
|
59
|
+
* @param includeSchemasFiles:
|
|
76
60
|
* @param request: Path to custom request file
|
|
77
61
|
* @param useCancelableRequest Use cancelable request type.
|
|
78
62
|
*/
|
|
79
|
-
writeClient(options:
|
|
63
|
+
writeClient(options: TWriteClientProps): Promise<void>;
|
|
80
64
|
/**
|
|
81
65
|
* Method keeps all options that is need to create index file
|
|
82
|
-
* @param
|
|
66
|
+
* @param config
|
|
83
67
|
*/
|
|
84
|
-
|
|
68
|
+
buildClientGeneratorConfigMap(config: TAPIClientGeneratorConfig): void;
|
|
85
69
|
combineAndWrite(): Promise<void>;
|
|
70
|
+
combineAndWrightSimple(): Promise<void>;
|
|
86
71
|
get logger(): Logger;
|
|
72
|
+
private buildSimpleClientIndexMap;
|
|
87
73
|
private buildClientIndexMap;
|
|
88
|
-
private
|
|
74
|
+
private finalizeAndWrite;
|
|
75
|
+
private simpledFinalizeAndWrite;
|
|
89
76
|
private getOutputPath;
|
|
90
77
|
private ensureClientIndex;
|
|
78
|
+
private ensureSimpleClientIndex;
|
|
91
79
|
private isSameModel;
|
|
92
80
|
private isSameShema;
|
|
93
81
|
private isSomeService;
|
|
82
|
+
writeClientCore: typeof writeClientCore;
|
|
83
|
+
writeClientCoreIndex: typeof writeClientCoreIndex;
|
|
84
|
+
writeClientFullIndex: typeof writeClientFullIndex;
|
|
85
|
+
writeClientModels: typeof writeClientModels;
|
|
86
|
+
writeClientModelsIndex: typeof writeClientModelsIndex;
|
|
87
|
+
writeClientSchemas: typeof writeClientSchemas;
|
|
88
|
+
writeClientSchemasIndex: typeof writeClientSchemasIndex;
|
|
89
|
+
writeClientServices: typeof writeClientServices;
|
|
90
|
+
writeClientServicesIndex: typeof writeClientServicesIndex;
|
|
91
|
+
writeClientSimpleIndex: typeof writeClientSimpleIndex;
|
|
94
92
|
}
|
|
95
93
|
export {};
|
|
96
94
|
//# sourceMappingURL=WriteClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"WriteClient.d.ts","sourceRoot":"","sources":["../../src/core/WriteClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI1C,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAI1D,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAG/D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE;;;;;;;;;;;;GAYG;AACH,KAAK,iBAAiB,GAAG;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,uBAAuB,EAAE,OAAO,CAAC;IACjC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,KAAK,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,YAAY,GAAG,SAAS,GAAG,sBAAsB,GAAG,qBAAqB,CAAC,CAAC;AAEnJ;;GAEG;AACH,qBAAa,WAAW;IACpB,OAAO,CAAC,MAAM,CAAuD;IACrE,OAAO,CAAC,OAAO,CAAS;;IAUxB;;;;;;;;;;;;OAYG;IACG,WAAW,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IA2F5D;;;OAGG;IACH,6BAA6B,CAAC,MAAM,EAAE,yBAAyB;IAUzD,eAAe;IAKf,sBAAsB;IAK5B,IAAW,MAAM,WAEhB;IAED,OAAO,CAAC,yBAAyB;IAyCjC,OAAO,CAAC,mBAAmB;YA4Db,gBAAgB;YAUhB,uBAAuB;IAMrC,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAezB,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,aAAa;IAId,eAAe,yBAAmB;IAClC,oBAAoB,8BAAwB;IAC5C,oBAAoB,8BAAwB;IAC5C,iBAAiB,2BAAqB;IACtC,sBAAsB,gCAA0B;IAChD,kBAAkB,4BAAsB;IACxC,uBAAuB,iCAA2B;IAClD,mBAAmB,6BAAuB;IAC1C,wBAAwB,kCAA4B;IACpD,sBAAsB,gCAA0B;CAC1D"}
|
package/dist/core/WriteClient.js
CHANGED
|
@@ -9,15 +9,20 @@ const prepareAlias_1 = require("./utils/prepareAlias");
|
|
|
9
9
|
const sortModelByName_1 = require("./utils/sortModelByName");
|
|
10
10
|
const unique_1 = require("./utils/unique");
|
|
11
11
|
const writeClientCore_1 = require("./utils/writeClientCore");
|
|
12
|
-
const
|
|
12
|
+
const writeClientCoreIndex_1 = require("./utils/writeClientCoreIndex");
|
|
13
|
+
const writeClientFullIndex_1 = require("./utils/writeClientFullIndex");
|
|
13
14
|
const writeClientModels_1 = require("./utils/writeClientModels");
|
|
15
|
+
const writeClientModelsIndex_1 = require("./utils/writeClientModelsIndex");
|
|
14
16
|
const writeClientSchemas_1 = require("./utils/writeClientSchemas");
|
|
17
|
+
const writeClientSchemasIndex_1 = require("./utils/writeClientSchemasIndex");
|
|
15
18
|
const writeClientServices_1 = require("./utils/writeClientServices");
|
|
19
|
+
const writeClientServicesIndex_1 = require("./utils/writeClientServicesIndex");
|
|
20
|
+
const writeClientSimpleIndex_1 = require("./utils/writeClientSimpleIndex");
|
|
16
21
|
/**
|
|
17
22
|
* The client which is writing all items and keep the parameters to write index file
|
|
18
23
|
*/
|
|
19
24
|
class WriteClient {
|
|
20
|
-
|
|
25
|
+
config = new Map();
|
|
21
26
|
_logger;
|
|
22
27
|
constructor() {
|
|
23
28
|
this._logger = new Logger_1.Logger({
|
|
@@ -34,133 +39,158 @@ class WriteClient {
|
|
|
34
39
|
* @param httpClient The selected httpClient (fetch, xhr or node)
|
|
35
40
|
* @param useOptions Use options or arguments functions
|
|
36
41
|
* @param useUnionTypes Use union types instead of enums
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param exportModels: Generate models
|
|
40
|
-
* @param exportSchemas: Generate schemas
|
|
41
|
-
* @param clean: Clean a directory before generation
|
|
42
|
+
* @param excludeCoreServiceFiles:
|
|
43
|
+
* @param includeSchemasFiles:
|
|
42
44
|
* @param request: Path to custom request file
|
|
43
45
|
* @param useCancelableRequest Use cancelable request type.
|
|
44
46
|
*/
|
|
45
47
|
async writeClient(options) {
|
|
46
|
-
const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes,
|
|
47
|
-
if (
|
|
48
|
+
const { client, templates, outputPaths, httpClient, useOptions, useUnionTypes, excludeCoreServiceFiles = false, includeSchemasFiles = false, request, useCancelableRequest = false, useSeparatedIndexes = false, } = options;
|
|
49
|
+
if (!excludeCoreServiceFiles) {
|
|
48
50
|
await fileSystem_1.fileSystem.mkdir(outputPaths.outputCore);
|
|
49
|
-
await
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
await this.writeClientCore({ client, templates, outputCorePath: outputPaths.outputCore, httpClient, request, useCancelableRequest });
|
|
52
|
+
await this.writeClientCoreIndex({
|
|
53
|
+
templates,
|
|
54
|
+
outputCorePath: outputPaths.outputCore,
|
|
55
|
+
useCancelableRequest,
|
|
56
|
+
useSeparatedIndexes,
|
|
57
|
+
});
|
|
52
58
|
const { outputCore, outputServices, outputModels } = outputPaths;
|
|
53
59
|
await fileSystem_1.fileSystem.mkdir(outputPaths.outputServices);
|
|
54
|
-
await
|
|
60
|
+
await this.writeClientServices({
|
|
55
61
|
services: client.services,
|
|
56
62
|
templates,
|
|
57
63
|
outputPaths: {
|
|
58
64
|
outputServices,
|
|
59
|
-
outputCore:
|
|
60
|
-
outputModels:
|
|
65
|
+
outputCore: `${(0, pathHelpers_1.relative)(outputServices, outputCore)}`,
|
|
66
|
+
outputModels: `${(0, pathHelpers_1.relative)(outputServices, outputModels)}`,
|
|
61
67
|
},
|
|
62
68
|
httpClient,
|
|
63
69
|
useUnionTypes,
|
|
64
70
|
useOptions,
|
|
65
71
|
useCancelableRequest,
|
|
66
72
|
});
|
|
73
|
+
await this.writeClientServicesIndex({
|
|
74
|
+
services: client.services,
|
|
75
|
+
templates,
|
|
76
|
+
outputServices,
|
|
77
|
+
useSeparatedIndexes,
|
|
78
|
+
});
|
|
67
79
|
}
|
|
68
|
-
if (
|
|
80
|
+
if (includeSchemasFiles) {
|
|
69
81
|
await fileSystem_1.fileSystem.mkdir(outputPaths.outputSchemas);
|
|
70
|
-
await
|
|
82
|
+
await this.writeClientSchemas({
|
|
71
83
|
models: client.models,
|
|
72
84
|
templates,
|
|
73
85
|
outputSchemasPath: outputPaths.outputSchemas,
|
|
74
86
|
httpClient,
|
|
75
87
|
useUnionTypes,
|
|
76
88
|
});
|
|
77
|
-
|
|
78
|
-
if (exportModels) {
|
|
79
|
-
await fileSystem_1.fileSystem.mkdir(outputPaths.outputModels);
|
|
80
|
-
await (0, writeClientModels_1.writeClientModels)({
|
|
89
|
+
await this.writeClientSchemasIndex({
|
|
81
90
|
models: client.models,
|
|
82
91
|
templates,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
useUnionTypes,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (exportCore || exportServices || exportSchemas || exportModels) {
|
|
89
|
-
await fileSystem_1.fileSystem.mkdir(outputPaths.output);
|
|
90
|
-
await this.writeClientIndex({
|
|
91
|
-
client,
|
|
92
|
-
templates,
|
|
93
|
-
outputPaths,
|
|
94
|
-
useUnionTypes,
|
|
95
|
-
exportCore,
|
|
96
|
-
exportServices,
|
|
97
|
-
exportModels,
|
|
98
|
-
exportSchemas,
|
|
92
|
+
outputSchemasPath: outputPaths.outputSchemas,
|
|
93
|
+
useSeparatedIndexes,
|
|
99
94
|
});
|
|
100
95
|
}
|
|
96
|
+
await fileSystem_1.fileSystem.mkdir(outputPaths.outputModels);
|
|
97
|
+
await this.writeClientModels({
|
|
98
|
+
models: client.models,
|
|
99
|
+
templates,
|
|
100
|
+
outputModelsPath: outputPaths.outputModels,
|
|
101
|
+
httpClient,
|
|
102
|
+
useUnionTypes,
|
|
103
|
+
});
|
|
104
|
+
await this.writeClientModelsIndex({
|
|
105
|
+
models: client.models,
|
|
106
|
+
templates,
|
|
107
|
+
outputModelsPath: outputPaths.outputModels,
|
|
108
|
+
useSeparatedIndexes,
|
|
109
|
+
});
|
|
110
|
+
await fileSystem_1.fileSystem.mkdir(outputPaths.output);
|
|
111
|
+
this.buildClientGeneratorConfigMap({
|
|
112
|
+
client,
|
|
113
|
+
templates,
|
|
114
|
+
outputPaths,
|
|
115
|
+
useUnionTypes,
|
|
116
|
+
excludeCoreServiceFiles,
|
|
117
|
+
includeSchemasFiles,
|
|
118
|
+
});
|
|
101
119
|
}
|
|
102
120
|
/**
|
|
103
121
|
* Method keeps all options that is need to create index file
|
|
104
|
-
* @param
|
|
122
|
+
* @param config
|
|
105
123
|
*/
|
|
106
|
-
|
|
107
|
-
const { outputPaths } =
|
|
108
|
-
const values = this.
|
|
124
|
+
buildClientGeneratorConfigMap(config) {
|
|
125
|
+
const { outputPaths } = config;
|
|
126
|
+
const values = this.config.get(outputPaths.output);
|
|
109
127
|
if (values) {
|
|
110
|
-
values.push(
|
|
128
|
+
values.push(config);
|
|
111
129
|
}
|
|
112
130
|
else {
|
|
113
|
-
this.
|
|
131
|
+
this.config.set(outputPaths.output, Array.of(config));
|
|
114
132
|
}
|
|
115
133
|
}
|
|
116
134
|
async combineAndWrite() {
|
|
117
135
|
const result = this.buildClientIndexMap();
|
|
118
|
-
await this.
|
|
136
|
+
await this.finalizeAndWrite(result);
|
|
137
|
+
}
|
|
138
|
+
async combineAndWrightSimple() {
|
|
139
|
+
const result = this.buildSimpleClientIndexMap();
|
|
140
|
+
await this.simpledFinalizeAndWrite(result);
|
|
119
141
|
}
|
|
120
142
|
get logger() {
|
|
121
143
|
return this._logger;
|
|
122
144
|
}
|
|
145
|
+
buildSimpleClientIndexMap() {
|
|
146
|
+
const result = new Map();
|
|
147
|
+
for (const [key, value] of this.config.entries()) {
|
|
148
|
+
for (const item of value) {
|
|
149
|
+
const { outputPaths, templates, excludeCoreServiceFiles, includeSchemasFiles } = item;
|
|
150
|
+
const outputCore = this.getOutputPath(outputPaths?.outputCore, key, 'core');
|
|
151
|
+
const outputModels = this.getOutputPath(outputPaths?.outputModels, key, 'models');
|
|
152
|
+
const outputSchemas = this.getOutputPath(outputPaths?.outputSchemas, key, 'schemas');
|
|
153
|
+
const outputServices = this.getOutputPath(outputPaths?.outputServices, key, 'services');
|
|
154
|
+
const clientIndex = this.ensureSimpleClientIndex(result, key, templates);
|
|
155
|
+
if (!excludeCoreServiceFiles) {
|
|
156
|
+
const relativePathCore = (0, pathHelpers_1.relative)(key, outputCore);
|
|
157
|
+
if (!clientIndex.core.includes(relativePathCore)) {
|
|
158
|
+
clientIndex.core.push(relativePathCore);
|
|
159
|
+
}
|
|
160
|
+
const relativeService = (0, pathHelpers_1.relative)(key, outputServices);
|
|
161
|
+
if (!clientIndex.services.includes(relativeService)) {
|
|
162
|
+
clientIndex.services.push(relativeService);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const relativePathModel = (0, pathHelpers_1.relative)(key, outputModels);
|
|
166
|
+
if (!clientIndex.models.includes(relativePathModel)) {
|
|
167
|
+
clientIndex.models.push(relativePathModel);
|
|
168
|
+
}
|
|
169
|
+
if (includeSchemasFiles) {
|
|
170
|
+
const relativePathSchema = (0, pathHelpers_1.relative)(key, outputSchemas);
|
|
171
|
+
if (!clientIndex.schemas.includes(relativePathSchema)) {
|
|
172
|
+
clientIndex.schemas.push(relativePathSchema);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
123
179
|
buildClientIndexMap() {
|
|
124
180
|
const result = new Map();
|
|
125
|
-
for (const [key, value] of this.
|
|
181
|
+
for (const [key, value] of this.config.entries()) {
|
|
126
182
|
for (const item of value) {
|
|
127
|
-
const {
|
|
183
|
+
const { outputPaths, client, templates, useUnionTypes, excludeCoreServiceFiles, includeSchemasFiles } = item;
|
|
128
184
|
const outputCore = this.getOutputPath(outputPaths?.outputCore, key, 'core');
|
|
129
185
|
const outputModels = this.getOutputPath(outputPaths?.outputModels, key, 'models');
|
|
130
186
|
const outputSchemas = this.getOutputPath(outputPaths?.outputSchemas, key, 'schemas');
|
|
131
187
|
const outputServices = this.getOutputPath(outputPaths?.outputServices, key, 'services');
|
|
132
188
|
const clientIndex = this.ensureClientIndex(result, key, templates);
|
|
133
|
-
if (
|
|
189
|
+
if (!excludeCoreServiceFiles) {
|
|
134
190
|
const rel = (0, pathHelpers_1.relative)(key, outputCore);
|
|
135
191
|
if (!clientIndex.core.includes(rel)) {
|
|
136
192
|
clientIndex.core.push(rel);
|
|
137
193
|
}
|
|
138
|
-
}
|
|
139
|
-
if (exportModels || exportSchemas) {
|
|
140
|
-
const relativePathModel = `${(0, pathHelpers_1.relative)(key, outputModels)}`;
|
|
141
|
-
const relativePathSchema = `${(0, pathHelpers_1.relative)(key, outputSchemas)}`;
|
|
142
|
-
for (const model of client.models) {
|
|
143
|
-
const modelFinal = {
|
|
144
|
-
name: model.name,
|
|
145
|
-
alias: '',
|
|
146
|
-
path: model.path,
|
|
147
|
-
package: relativePathModel,
|
|
148
|
-
enum: model.enum && model.enum.length > 0,
|
|
149
|
-
useUnionTypes,
|
|
150
|
-
enums: model.enums && model.enums.length > 0,
|
|
151
|
-
};
|
|
152
|
-
if (exportModels && clientIndex.models.some(m => this.isSameModel(m, modelFinal))) {
|
|
153
|
-
clientIndex.models.push(modelFinal);
|
|
154
|
-
}
|
|
155
|
-
if (exportSchemas) {
|
|
156
|
-
const schema = { ...modelFinal, package: relativePathSchema };
|
|
157
|
-
if (!clientIndex.schemas.some(s => this.isSameShema(s, schema))) {
|
|
158
|
-
clientIndex.schemas.push(schema);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (exportServices) {
|
|
164
194
|
const relativeService = `${(0, pathHelpers_1.relative)(key, outputServices)}`;
|
|
165
195
|
for (const service of client.services) {
|
|
166
196
|
if (!clientIndex.services.some(s => this.isSomeService(s, service.name, relativeService))) {
|
|
@@ -171,17 +201,44 @@ class WriteClient {
|
|
|
171
201
|
}
|
|
172
202
|
}
|
|
173
203
|
}
|
|
204
|
+
const relativePathModel = `${(0, pathHelpers_1.relative)(key, outputModels)}`;
|
|
205
|
+
const relativePathSchema = `${(0, pathHelpers_1.relative)(key, outputSchemas)}`;
|
|
206
|
+
for (const model of client.models) {
|
|
207
|
+
const modelFinal = {
|
|
208
|
+
name: model.name,
|
|
209
|
+
alias: '',
|
|
210
|
+
path: model.path,
|
|
211
|
+
package: relativePathModel,
|
|
212
|
+
enum: model.enum && model.enum.length > 0,
|
|
213
|
+
useUnionTypes,
|
|
214
|
+
enums: model.enums && model.enums.length > 0,
|
|
215
|
+
};
|
|
216
|
+
if (!clientIndex.models.some(m => this.isSameModel(m, modelFinal))) {
|
|
217
|
+
clientIndex.models.push(modelFinal);
|
|
218
|
+
}
|
|
219
|
+
if (includeSchemasFiles) {
|
|
220
|
+
const schema = { ...modelFinal, package: relativePathSchema };
|
|
221
|
+
if (!clientIndex.schemas.some(s => this.isSameShema(s, schema))) {
|
|
222
|
+
clientIndex.schemas.push(schema);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
174
226
|
}
|
|
175
227
|
}
|
|
176
228
|
return result;
|
|
177
229
|
}
|
|
178
|
-
async
|
|
230
|
+
async finalizeAndWrite(result) {
|
|
179
231
|
for (const value of result.values()) {
|
|
180
232
|
value.models = value.models.filter(unique_1.unique).sort(sortModelByName_1.sortModelByName);
|
|
181
233
|
(0, prepareAlias_1.prepareAlias)(value.models);
|
|
182
234
|
value.schemas = value.schemas.filter(unique_1.unique).sort(sortModelByName_1.sortModelByName);
|
|
183
235
|
(0, prepareAlias_1.prepareAlias)(value.schemas);
|
|
184
|
-
await
|
|
236
|
+
await this.writeClientFullIndex(value);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async simpledFinalizeAndWrite(result) {
|
|
240
|
+
for (const value of result.values()) {
|
|
241
|
+
await this.writeClientSimpleIndex(value);
|
|
185
242
|
}
|
|
186
243
|
}
|
|
187
244
|
getOutputPath(output, key, fallback) {
|
|
@@ -200,13 +257,21 @@ class WriteClient {
|
|
|
200
257
|
}
|
|
201
258
|
return map.get(key);
|
|
202
259
|
}
|
|
260
|
+
ensureSimpleClientIndex(map, key, templates) {
|
|
261
|
+
if (!map.has(key)) {
|
|
262
|
+
map.set(key, {
|
|
263
|
+
templates,
|
|
264
|
+
outputPath: key,
|
|
265
|
+
core: [],
|
|
266
|
+
models: [],
|
|
267
|
+
schemas: [],
|
|
268
|
+
services: [],
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return map.get(key);
|
|
272
|
+
}
|
|
203
273
|
isSameModel(a, b) {
|
|
204
|
-
return
|
|
205
|
-
a.path === b.path &&
|
|
206
|
-
a.package === b.package &&
|
|
207
|
-
a.enum === b.enum &&
|
|
208
|
-
a.enums === b.enums &&
|
|
209
|
-
a.useUnionTypes === b.useUnionTypes);
|
|
274
|
+
return a.name === b.name && a.path === b.path && a.package === b.package && a.enum === b.enum && a.enums === b.enums && a.useUnionTypes === b.useUnionTypes;
|
|
210
275
|
}
|
|
211
276
|
isSameShema(a, b) {
|
|
212
277
|
return a.name === b.name && a.path === b.path && a.package === b.package;
|
|
@@ -214,5 +279,15 @@ class WriteClient {
|
|
|
214
279
|
isSomeService(a, name, pkg) {
|
|
215
280
|
return a.name === name && a.package === pkg;
|
|
216
281
|
}
|
|
282
|
+
writeClientCore = writeClientCore_1.writeClientCore;
|
|
283
|
+
writeClientCoreIndex = writeClientCoreIndex_1.writeClientCoreIndex;
|
|
284
|
+
writeClientFullIndex = writeClientFullIndex_1.writeClientFullIndex;
|
|
285
|
+
writeClientModels = writeClientModels_1.writeClientModels;
|
|
286
|
+
writeClientModelsIndex = writeClientModelsIndex_1.writeClientModelsIndex;
|
|
287
|
+
writeClientSchemas = writeClientSchemas_1.writeClientSchemas;
|
|
288
|
+
writeClientSchemasIndex = writeClientSchemasIndex_1.writeClientSchemasIndex;
|
|
289
|
+
writeClientServices = writeClientServices_1.writeClientServices;
|
|
290
|
+
writeClientServicesIndex = writeClientServicesIndex_1.writeClientServicesIndex;
|
|
291
|
+
writeClientSimpleIndex = writeClientSimpleIndex_1.writeClientSimpleIndex;
|
|
217
292
|
}
|
|
218
293
|
exports.WriteClient = WriteClient;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const strict_1 = __importDefault(require("node:assert/strict"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
-
const
|
|
8
|
+
const HttpClient_enum_1 = require("../types/enums/HttpClient.enum");
|
|
9
9
|
const fileSystem_1 = require("../utils/fileSystem");
|
|
10
10
|
const getOutputPaths_1 = require("../utils/getOutputPaths");
|
|
11
11
|
const WriteClient_1 = require("../WriteClient");
|
|
@@ -30,7 +30,14 @@ const WriteClient_1 = require("../WriteClient");
|
|
|
30
30
|
services: [],
|
|
31
31
|
};
|
|
32
32
|
const templates = {
|
|
33
|
-
|
|
33
|
+
indexes: {
|
|
34
|
+
full: () => 'fullIndex',
|
|
35
|
+
simple: () => 'simpleIndex',
|
|
36
|
+
core: () => 'coreIndex',
|
|
37
|
+
models: () => 'modelsIndex',
|
|
38
|
+
schemas: () => 'schemasIndex',
|
|
39
|
+
services: () => 'servicesIndex',
|
|
40
|
+
},
|
|
34
41
|
exports: {
|
|
35
42
|
model: () => 'model',
|
|
36
43
|
schema: () => 'schema',
|
|
@@ -51,14 +58,11 @@ const WriteClient_1 = require("../WriteClient");
|
|
|
51
58
|
client,
|
|
52
59
|
templates,
|
|
53
60
|
outputPaths,
|
|
54
|
-
httpClient:
|
|
61
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
55
62
|
useOptions: false,
|
|
56
63
|
useUnionTypes: false,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
exportModels: true,
|
|
60
|
-
exportSchemas: true,
|
|
61
|
-
clean: true,
|
|
64
|
+
excludeCoreServiceFiles: false,
|
|
65
|
+
includeSchemasFiles: false,
|
|
62
66
|
});
|
|
63
67
|
strict_1.default.ok(mkdirCalls.length > 0, 'mkdir should be called at least once');
|
|
64
68
|
strict_1.default.ok(writeFileCalls.length > 0, 'writeFile should be called at least once');
|