ts-openapi-codegen 1.0.0-beta.8 → 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +221 -123
- package/README.rus.md +725 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts +12 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/checkConfig.js +66 -0
- package/dist/cli/checkAndUpdateConfig/constants.d.ts +13 -0
- package/dist/cli/checkAndUpdateConfig/constants.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/constants.js +29 -0
- package/dist/cli/checkAndUpdateConfig/types.d.ts +20 -0
- package/dist/cli/checkAndUpdateConfig/types.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/types.js +12 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts +12 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/updateConfig.js +56 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/generateConfigExample.js +11 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts +14 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/prepareConfigData.js +30 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts +17 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/removeDefaultConfigValues.js +29 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts +2 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/rewriteConfigFile.js +11 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts +29 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/selectConfigAction.js +49 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/updateExistingConfigFile.js +22 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts +17 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/validateAndMigrateConfigData.js +53 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts +34 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeConfigFile.js +41 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts +6 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.d.ts.map +1 -0
- package/dist/cli/checkAndUpdateConfig/utils/writeExampleConfigFile.js +18 -0
- package/dist/cli/generate/runGenerateOpenApi.d.ts +2 -2
- package/dist/cli/generate/runGenerateOpenApi.d.ts.map +1 -1
- package/dist/cli/generate/runGenerateOpenApi.js +20 -37
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +56 -30
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.d.ts.map +1 -1
- package/dist/cli/initOpenApiConfig/runInitOpenapiConfig.js +11 -18
- package/dist/cli/interactive/confirmDialog.d.ts +17 -0
- package/dist/cli/interactive/confirmDialog.d.ts.map +1 -0
- package/dist/cli/interactive/confirmDialog.js +36 -0
- package/dist/cli/interactive/constants.d.ts +7 -0
- package/dist/cli/interactive/constants.d.ts.map +1 -0
- package/dist/cli/interactive/constants.js +25 -0
- package/dist/cli/interactive/selectDialog.d.ts +17 -0
- package/dist/cli/interactive/selectDialog.d.ts.map +1 -0
- package/dist/cli/interactive/selectDialog.js +43 -0
- package/dist/cli/interactive/types.d.ts +40 -0
- package/dist/cli/interactive/types.d.ts.map +1 -0
- package/dist/cli/interactive/types.js +12 -0
- package/dist/common/Consts.d.ts +4 -0
- package/dist/common/Consts.d.ts.map +1 -1
- package/dist/common/Consts.js +31 -1
- package/dist/common/Enums.d.ts +4 -0
- package/dist/common/Enums.d.ts.map +1 -1
- package/dist/common/Enums.js +6 -1
- package/dist/common/Logger.d.ts +1 -1
- package/dist/common/Logger.d.ts.map +1 -1
- package/dist/common/Logger.js +7 -39
- package/dist/common/LoggerMessages.d.ts +64 -0
- package/dist/common/LoggerMessages.d.ts.map +1 -0
- package/dist/common/LoggerMessages.js +82 -0
- package/dist/common/TRawOptions.d.ts +40 -0
- package/dist/common/TRawOptions.d.ts.map +1 -0
- package/dist/common/UpdateNotifier.d.ts +36 -2
- package/dist/common/UpdateNotifier.d.ts.map +1 -1
- package/dist/common/UpdateNotifier.js +150 -57
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllMigrationPlans.js +31 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts +8 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/AllVersionedSchemas/AllVersionedSchemas.js +33 -0
- package/dist/common/VersionedSchema/Enums.d.ts +2 -1
- package/dist/common/VersionedSchema/Enums.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Enums.js +1 -0
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.d.ts.map +1 -1
- package/dist/common/VersionedSchema/MultiOptionsVersioned/MultiOptionsMigrationPlan.js +10 -19
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.d.ts.map +1 -1
- package/dist/common/VersionedSchema/OptionsVersioned/OptionsMigrationPlans.js +10 -10
- package/dist/common/VersionedSchema/Types.d.ts +10 -0
- package/dist/common/VersionedSchema/Types.d.ts.map +1 -1
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts +3 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsMigrationPlan.js +28 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts +7 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsSchemaV1.js +42 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts +3 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.d.ts.map +1 -0
- package/dist/common/VersionedSchema/UnifiedOptionsVersioned/UnifiedOptionsVersionedSchemas.js +10 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts +11 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/createDefaultFieldsMigration.js +19 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts +7 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/createTrivialMigration.js +15 -0
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts +1 -7
- package/dist/common/VersionedSchema/Utils/determineBestMatchingSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts +3 -0
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/getCurrentErrorMessage.js +14 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts +2 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.d.ts.map +1 -0
- package/dist/common/VersionedSchema/Utils/getKeyByMapValue.js +11 -0
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts +5 -2
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.d.ts.map +1 -1
- package/dist/common/VersionedSchema/Utils/migrateDataToLatestSchemaVersion.js +31 -17
- package/dist/common/utils/__tests__/__mock__/mockJoiSchema.d.ts.map +1 -0
- package/dist/common/utils/__tests__/convertArrayToObject.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.js +14 -14
- package/dist/common/utils/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.js +5 -5
- package/dist/common/utils/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.js +4 -4
- package/dist/common/utils/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.js +4 -4
- package/dist/common/utils/__tests__/getUniqueObjectKeys.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.js +5 -5
- package/dist/common/utils/__tests__/mergeObjectSchemas.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.js +5 -5
- package/dist/common/utils/__tests__/migrationForMultiOptions.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.js +21 -15
- package/dist/common/utils/__tests__/migrationForOptions.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.js +13 -9
- package/dist/common/utils/__tests__/pathHelpers.test.d.ts.map +1 -0
- package/dist/{core → common}/utils/__tests__/pathHelpers.test.js +8 -8
- package/dist/common/utils/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.js +5 -5
- package/dist/common/utils/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +1 -0
- package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.js +5 -5
- package/dist/common/utils/convertArrayToObject.d.ts +2 -0
- package/dist/common/utils/convertArrayToObject.d.ts.map +1 -0
- package/dist/common/{Utils.js → utils/convertArrayToObject.js} +0 -20
- package/dist/{core/utils/fileSystem.d.ts → common/utils/fileSystemHelpers.d.ts} +8 -5
- package/dist/common/utils/fileSystemHelpers.d.ts.map +1 -0
- package/dist/common/utils/fileSystemHelpers.js +85 -0
- package/dist/common/utils/format.d.ts +3 -0
- package/dist/common/utils/format.d.ts.map +1 -0
- package/dist/{core → common}/utils/format.js +2 -2
- package/dist/common/utils/loadConfigIfExists.d.ts +2 -0
- package/dist/common/utils/loadConfigIfExists.d.ts.map +1 -0
- package/dist/common/utils/loadConfigIfExists.js +22 -0
- package/dist/common/utils/pathHelpers.d.ts +6 -0
- package/dist/common/utils/pathHelpers.d.ts.map +1 -0
- package/dist/{core → common}/utils/pathHelpers.js +16 -20
- package/dist/common/utils/safeHasOwn.d.ts +2 -0
- package/dist/common/utils/safeHasOwn.d.ts.map +1 -0
- package/dist/common/utils/safeHasOwn.js +9 -0
- package/dist/core/Context.d.ts.map +1 -1
- package/dist/core/Context.js +3 -3
- package/dist/core/OpenApiClient.d.ts +13 -0
- package/dist/core/OpenApiClient.d.ts.map +1 -0
- package/dist/core/OpenApiClient.js +175 -0
- package/dist/core/WriteClient.d.ts +1 -1
- package/dist/core/WriteClient.d.ts.map +1 -1
- package/dist/core/WriteClient.js +20 -20
- package/dist/core/__tests__/WriteClient.test.js +61 -60
- package/dist/core/api/v2/Parser.d.ts.map +1 -1
- package/dist/core/api/v2/Parser.js +2 -9
- package/dist/core/api/v2/parser/__tests__/getServer.test.js +2 -2
- package/dist/core/api/v2/parser/__tests__/getType.test.js +3 -3
- package/dist/core/api/v2/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModelProperties.js +2 -5
- package/dist/core/api/v2/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getModels.js +2 -1
- package/dist/core/api/v2/parser/getOperationParameter.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationParameter.js +2 -1
- package/dist/core/api/v2/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponse.js +2 -5
- package/dist/core/api/v2/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getOperationResponses.js +2 -5
- package/dist/core/api/v2/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v2/parser/getServices.js +2 -5
- package/dist/core/api/v2/parser/getType.js +4 -4
- package/dist/core/api/v3/Parser.d.ts +1 -1
- package/dist/core/api/v3/Parser.d.ts.map +1 -1
- package/dist/core/api/v3/Parser.js +2 -9
- package/dist/core/api/v3/parser/__tests__/getServer.test.js +3 -3
- package/dist/core/api/v3/parser/__tests__/getType.test.js +3 -3
- package/dist/core/api/v3/parser/getModelProperties.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModelProperties.js +2 -5
- package/dist/core/api/v3/parser/getModels.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getModels.js +2 -1
- package/dist/core/api/v3/parser/getOperationResponse.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponse.js +2 -5
- package/dist/core/api/v3/parser/getOperationResponses.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getOperationResponses.js +2 -5
- package/dist/core/api/v3/parser/getServer.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServer.js +2 -5
- package/dist/core/api/v3/parser/getServices.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getServices.js +2 -5
- package/dist/core/api/v3/parser/getType.d.ts.map +1 -1
- package/dist/core/api/v3/parser/getType.js +5 -13
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -161
- package/dist/core/types/Consts.d.ts +5 -1
- package/dist/core/types/Consts.d.ts.map +1 -1
- package/dist/core/types/Consts.js +6 -2
- package/dist/core/types/base/Root.model.d.ts +1 -0
- package/dist/core/types/base/Root.model.d.ts.map +1 -1
- package/dist/core/utils/__tests__/escapeDescription.test.js +3 -3
- package/dist/core/utils/__tests__/escapeName.test.js +2 -2
- package/dist/core/utils/__tests__/flatMap.test.js +2 -2
- package/dist/core/utils/__tests__/getAbsolutePath.test.js +6 -6
- package/dist/core/utils/__tests__/getClassName.test.js +2 -2
- package/dist/core/utils/__tests__/getComment.test.js +2 -2
- package/dist/core/utils/__tests__/getEnumFromDescription.test.js +2 -2
- package/dist/core/utils/__tests__/getFileName.test.js +2 -2
- package/dist/core/utils/__tests__/getGatheringRefs.test.js +2 -2
- package/dist/core/utils/__tests__/getMappedType.test.js +2 -2
- package/dist/core/utils/__tests__/getModelNames.test.js +2 -2
- package/dist/core/utils/__tests__/getOpenApiVersion.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationName.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationParameterName.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationPath.test.js +2 -2
- package/dist/core/utils/__tests__/getOperationResponseCode.test.js +2 -2
- package/dist/core/utils/__tests__/getPattern.test.js +2 -2
- package/dist/core/utils/__tests__/getRefFromSchema.test.js +2 -2
- package/dist/core/utils/__tests__/getRefs.test.js +2 -2
- package/dist/core/utils/__tests__/getRelativeModelPath.test.js +3 -3
- package/dist/core/utils/__tests__/getServiceClassName.test.js +2 -2
- package/dist/core/utils/__tests__/getServiceNames.test.js +2 -2
- package/dist/core/utils/__tests__/getServiceVersion.test.js +2 -2
- package/dist/core/utils/__tests__/isString.test.js +2 -2
- package/dist/core/utils/__tests__/isSubdirectory.test.js +10 -10
- package/dist/core/utils/__tests__/registerHandlebarHelpers.test.js +2 -2
- package/dist/core/utils/__tests__/registerHandlebarTemplates.test.js +2 -2
- package/dist/core/utils/__tests__/replaceString.test.js +2 -2
- package/dist/core/utils/__tests__/resolveRefToImportPath.test.js +360 -51
- package/dist/core/utils/__tests__/sort.test.js +2 -2
- package/dist/core/utils/__tests__/sortByRequiredExtended.test.js +11 -11
- package/dist/core/utils/__tests__/sortByRequiredSimple.test.js +11 -11
- package/dist/core/utils/__tests__/sortModelsByName.test.js +2 -2
- package/dist/core/utils/__tests__/sortServicesByName.test.js +2 -2
- package/dist/core/utils/__tests__/stripNamespace.test.js +2 -2
- package/dist/core/utils/__tests__/unique.test.js +2 -2
- package/dist/core/utils/__tests__/writeClientCore.test.js +52 -50
- package/dist/core/utils/__tests__/writeClientFullIndex.test.js +39 -37
- package/dist/core/utils/__tests__/writeClientModels.test.js +65 -63
- package/dist/core/utils/__tests__/writeClientSchemas.test.js +65 -63
- package/dist/core/utils/__tests__/writeClientServices.test.js +60 -58
- package/dist/core/utils/appendUniqueLinesToFile.js +4 -4
- package/dist/core/utils/createNormalizedRef.js +2 -2
- package/dist/core/utils/getAbsolutePath.js +3 -3
- package/dist/core/utils/getModelNameWithPrefix.d.ts +3 -0
- package/dist/core/utils/getModelNameWithPrefix.d.ts.map +1 -0
- package/dist/core/utils/getModelNameWithPrefix.js +15 -0
- package/dist/core/utils/getOpenApiSpec.d.ts.map +1 -1
- package/dist/core/utils/getOpenApiSpec.js +4 -4
- package/dist/core/utils/getOutputPaths.d.ts.map +1 -1
- package/dist/core/utils/getOutputPaths.js +6 -6
- package/dist/core/utils/getPattern.d.ts.map +1 -1
- package/dist/core/utils/getPattern.js +2 -1
- package/dist/core/utils/getRelativeModelPath.d.ts.map +1 -1
- package/dist/core/utils/getRelativeModelPath.js +2 -6
- package/dist/core/utils/isSubdirectory.d.ts.map +1 -1
- package/dist/core/utils/isSubdirectory.js +4 -3
- package/dist/core/utils/mapPathToTargetDirSafe.d.ts.map +1 -1
- package/dist/core/utils/mapPathToTargetDirSafe.js +11 -12
- package/dist/core/utils/modelHelpers.d.ts.map +1 -1
- package/dist/core/utils/modelHelpers.js +18 -6
- package/dist/core/utils/normalizeString.d.ts +2 -0
- package/dist/core/utils/normalizeString.d.ts.map +1 -0
- package/dist/core/utils/normalizeString.js +14 -0
- package/dist/core/utils/normalizedAbsolutePath.js +3 -3
- package/dist/core/utils/parseRef.d.ts.map +1 -1
- package/dist/core/utils/parseRef.js +7 -10
- package/dist/core/utils/precompileTemplates.js +14 -10
- package/dist/core/utils/registerHandlebarHelpers.d.ts.map +1 -1
- package/dist/core/utils/registerHandlebarHelpers.js +24 -0
- package/dist/core/utils/replaceString.d.ts.map +1 -1
- package/dist/core/utils/replaceString.js +2 -1
- package/dist/core/utils/resolveRefPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefPath.js +3 -3
- package/dist/core/utils/resolveRefToImportPath.d.ts +8 -2
- package/dist/core/utils/resolveRefToImportPath.d.ts.map +1 -1
- package/dist/core/utils/resolveRefToImportPath.js +91 -31
- package/dist/core/utils/serviceHelpers.d.ts.map +1 -1
- package/dist/core/utils/serviceHelpers.js +2 -1
- package/dist/core/utils/stripNamespace.js +5 -5
- package/dist/core/utils/writeClientCore.d.ts.map +1 -1
- package/dist/core/utils/writeClientCore.js +12 -12
- package/dist/core/utils/writeClientCoreIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientCoreIndex.js +2 -2
- package/dist/core/utils/writeClientFullIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientFullIndex.js +4 -4
- package/dist/core/utils/writeClientModels.d.ts.map +1 -1
- package/dist/core/utils/writeClientModels.js +7 -7
- package/dist/core/utils/writeClientModelsIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientModelsIndex.js +2 -2
- package/dist/core/utils/writeClientSchemas.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemas.js +7 -7
- package/dist/core/utils/writeClientSchemasIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSchemasIndex.js +2 -2
- package/dist/core/utils/writeClientServices.d.ts.map +1 -1
- package/dist/core/utils/writeClientServices.js +5 -5
- package/dist/core/utils/writeClientServicesIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientServicesIndex.js +2 -2
- package/dist/core/utils/writeClientSimpleIndex.d.ts.map +1 -1
- package/dist/core/utils/writeClientSimpleIndex.js +4 -4
- package/dist/templatesCompiled/client/exportModel.js +4 -4
- package/dist/templatesCompiled/client/exportService.d.ts.map +1 -1
- package/dist/templatesCompiled/client/exportService.js +12 -13
- package/dist/templatesCompiled/client/indexFull.d.ts.map +1 -1
- package/dist/templatesCompiled/client/indexFull.js +35 -29
- package/dist/templatesCompiled/client/partials/parameters.d.ts +3 -2
- package/dist/templatesCompiled/client/partials/parameters.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/parameters.js +25 -20
- package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts +4 -2
- package/dist/templatesCompiled/client/partials/parametersDefinition.d.ts.map +1 -1
- package/dist/templatesCompiled/client/partials/parametersDefinition.js +31 -10
- package/package.json +15 -13
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts +0 -5
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.d.ts.map +0 -1
- package/dist/cli/chekOpenApiConfig/chekOpenApiConfig.js +0 -45
- package/dist/common/Options.d.ts +0 -26
- package/dist/common/Options.d.ts.map +0 -1
- package/dist/common/Utils.d.ts +0 -3
- package/dist/common/Utils.d.ts.map +0 -1
- package/dist/common/__tests__/__mock__/mockJoiSchema.d.ts.map +0 -1
- package/dist/common/__tests__/convertArrayToObject.test.d.ts.map +0 -1
- package/dist/common/__tests__/determineBestMatchingSchemaVersion.test.d.ts.map +0 -1
- package/dist/common/__tests__/generateKeyMappingForInvalidKeys.test.d.ts.map +0 -1
- package/dist/common/__tests__/getUniqueKeysFromSchemas.test.d.ts.map +0 -1
- package/dist/common/__tests__/getUniqueObjectKeys.test.d.ts.map +0 -1
- package/dist/common/__tests__/mergeObjectSchemas.test.d.ts.map +0 -1
- package/dist/common/__tests__/migrationForMultiOptions.test.d.ts.map +0 -1
- package/dist/common/__tests__/migrationForOptions.test.d.ts.map +0 -1
- package/dist/common/__tests__/replaceInvalidKeysWithMappedNames.test.d.ts.map +0 -1
- package/dist/common/__tests__/validateAndSuggestKeyCorrections.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts +0 -2
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.d.ts.map +0 -1
- package/dist/core/utils/__tests__/getRelativeModelImportPath.test.js +0 -82
- package/dist/core/utils/__tests__/pathHelpers.test.d.ts.map +0 -1
- package/dist/core/utils/fileSystem.d.ts.map +0 -1
- package/dist/core/utils/fileSystem.js +0 -26
- package/dist/core/utils/format.d.ts +0 -2
- package/dist/core/utils/format.d.ts.map +0 -1
- package/dist/core/utils/getRelativeModelImportPath.d.ts +0 -9
- package/dist/core/utils/getRelativeModelImportPath.d.ts.map +0 -1
- package/dist/core/utils/getRelativeModelImportPath.js +0 -45
- package/dist/core/utils/isDirectory.d.ts +0 -2
- package/dist/core/utils/isDirectory.d.ts.map +0 -1
- package/dist/core/utils/isDirectory.js +0 -13
- package/dist/core/utils/pathHelpers.d.ts +0 -7
- package/dist/core/utils/pathHelpers.d.ts.map +0 -1
- package/dist/core/utils/prepareOptions.d.ts +0 -8
- package/dist/core/utils/prepareOptions.d.ts.map +0 -1
- package/dist/core/utils/prepareOptions.js +0 -31
- /package/dist/common/{Options.js → TRawOptions.js} +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/__mock__/mockJoiSchema.js +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/convertArrayToObject.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/determineBestMatchingSchemaVersion.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/generateKeyMappingForInvalidKeys.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/getUniqueKeysFromSchemas.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/getUniqueObjectKeys.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/mergeObjectSchemas.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/migrationForMultiOptions.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/migrationForOptions.test.d.ts +0 -0
- /package/dist/{core → common}/utils/__tests__/pathHelpers.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/replaceInvalidKeysWithMappedNames.test.d.ts +0 -0
- /package/dist/common/{__tests__ → utils/__tests__}/validateAndSuggestKeyCorrections.test.d.ts +0 -0
|
@@ -5,70 +5,72 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
+
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
8
9
|
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
9
10
|
const WriteClient_1 = require("../../WriteClient");
|
|
10
|
-
|
|
11
|
-
(0, node_test_1.test)('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
11
|
+
(0, node_test_1.describe)('@unit: writeClientSchemas', () => {
|
|
12
|
+
(0, node_test_1.test)('writes to filesystem', async () => {
|
|
13
|
+
const writeFileCalls = [];
|
|
14
|
+
// Re-assigning the function manually with a mock
|
|
15
|
+
const originalWriteFile = fileSystemHelpers_1.fileSystemHelpers.writeFile;
|
|
16
|
+
fileSystemHelpers_1.fileSystemHelpers.writeFile = async (path, content) => {
|
|
17
|
+
writeFileCalls.push([path, content]);
|
|
18
|
+
};
|
|
19
|
+
const models = [
|
|
20
|
+
{
|
|
21
|
+
export: 'interface',
|
|
22
|
+
name: 'MyModel',
|
|
23
|
+
alias: '',
|
|
24
|
+
path: 'MyModel',
|
|
25
|
+
type: 'MyModel',
|
|
26
|
+
base: 'MyModel',
|
|
27
|
+
template: null,
|
|
28
|
+
link: null,
|
|
29
|
+
description: null,
|
|
30
|
+
isDefinition: true,
|
|
31
|
+
isReadOnly: false,
|
|
32
|
+
isRequired: false,
|
|
33
|
+
isNullable: false,
|
|
34
|
+
imports: [],
|
|
35
|
+
enum: [],
|
|
36
|
+
enums: [],
|
|
37
|
+
properties: [],
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
const templates = {
|
|
41
|
+
indexes: {
|
|
42
|
+
full: () => 'fullIndex',
|
|
43
|
+
simple: () => 'simpleIndex',
|
|
44
|
+
core: () => 'coreIndex',
|
|
45
|
+
models: () => 'modelsIndex',
|
|
46
|
+
schemas: () => 'schemasIndex',
|
|
47
|
+
services: () => 'servicesIndex',
|
|
48
|
+
},
|
|
49
|
+
exports: {
|
|
50
|
+
model: () => 'model',
|
|
51
|
+
schema: () => 'schema',
|
|
52
|
+
service: () => 'service',
|
|
53
|
+
},
|
|
54
|
+
core: {
|
|
55
|
+
settings: () => 'settings',
|
|
56
|
+
apiError: () => 'apiError',
|
|
57
|
+
apiRequestOptions: () => 'apiRequestOptions',
|
|
58
|
+
apiResult: () => 'apiResult',
|
|
59
|
+
request: () => 'request',
|
|
60
|
+
cancelablePromise: () => 'cancelablePromise',
|
|
61
|
+
httpStatusCode: () => 'httpStatusCode',
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
const writeClient = new WriteClient_1.WriteClient();
|
|
65
|
+
await writeClient.writeClientSchemas({
|
|
66
|
+
models,
|
|
67
|
+
templates,
|
|
68
|
+
outputSchemasPath: '/',
|
|
69
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
70
|
+
useUnionTypes: false,
|
|
71
|
+
});
|
|
72
|
+
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('MyModelSchema.ts') && content.toString().includes('schema')), 'Expected writeFile to be called with schema content for MyModelSchema.ts');
|
|
73
|
+
// Restoring the original function
|
|
74
|
+
fileSystemHelpers_1.fileSystemHelpers.writeFile = originalWriteFile;
|
|
70
75
|
});
|
|
71
|
-
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('MyModelSchema.ts') && content.toString().includes('schema')), 'Expected writeFile to be called with schema content for MyModelSchema.ts');
|
|
72
|
-
// Restoring the original function
|
|
73
|
-
fileSystem_1.fileSystem.writeFile = originalWriteFile;
|
|
74
76
|
});
|
|
@@ -5,65 +5,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_assert_1 = __importDefault(require("node:assert"));
|
|
7
7
|
const node_test_1 = require("node:test");
|
|
8
|
+
const fileSystemHelpers_1 = require("../../../common/utils/fileSystemHelpers");
|
|
8
9
|
const HttpClient_enum_1 = require("../../types/enums/HttpClient.enum");
|
|
9
10
|
const WriteClient_1 = require("../../WriteClient");
|
|
10
|
-
|
|
11
|
-
(0, node_test_1.test)('
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
11
|
+
(0, node_test_1.describe)('@unit: writeClientServices', () => {
|
|
12
|
+
(0, node_test_1.test)('writes to filesystem', async () => {
|
|
13
|
+
const writeFileCalls = [];
|
|
14
|
+
// Re-assigning the function manually with a mock
|
|
15
|
+
const originalWriteFile = fileSystemHelpers_1.fileSystemHelpers.writeFile;
|
|
16
|
+
fileSystemHelpers_1.fileSystemHelpers.writeFile = async (path, content) => {
|
|
17
|
+
writeFileCalls.push([path, content]);
|
|
18
|
+
};
|
|
19
|
+
const services = [
|
|
20
|
+
{
|
|
21
|
+
name: 'MyService',
|
|
22
|
+
originName: 'MyService',
|
|
23
|
+
operations: [],
|
|
24
|
+
imports: [],
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
const templates = {
|
|
28
|
+
indexes: {
|
|
29
|
+
full: () => 'fullIndex',
|
|
30
|
+
simple: () => 'simpleIndex',
|
|
31
|
+
core: () => 'coreIndex',
|
|
32
|
+
models: () => 'modelsIndex',
|
|
33
|
+
schemas: () => 'schemasIndex',
|
|
34
|
+
services: () => 'servicesIndex',
|
|
35
|
+
},
|
|
36
|
+
exports: {
|
|
37
|
+
model: () => 'model',
|
|
38
|
+
schema: () => 'schema',
|
|
39
|
+
service: () => 'service',
|
|
40
|
+
},
|
|
41
|
+
core: {
|
|
42
|
+
settings: () => 'settings',
|
|
43
|
+
apiError: () => 'apiError',
|
|
44
|
+
apiRequestOptions: () => 'apiRequestOptions',
|
|
45
|
+
apiResult: () => 'apiResult',
|
|
46
|
+
request: () => 'request',
|
|
47
|
+
cancelablePromise: () => 'cancelablePromise',
|
|
48
|
+
httpStatusCode: () => 'httpStatusCode',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
const writeClient = new WriteClient_1.WriteClient();
|
|
52
|
+
await writeClient.writeClientServices({
|
|
53
|
+
services,
|
|
54
|
+
templates,
|
|
55
|
+
outputPaths: {
|
|
56
|
+
outputCore: '/',
|
|
57
|
+
outputModels: '/',
|
|
58
|
+
outputServices: '/',
|
|
59
|
+
},
|
|
60
|
+
httpClient: HttpClient_enum_1.HttpClient.FETCH,
|
|
61
|
+
useUnionTypes: false,
|
|
62
|
+
useOptions: false,
|
|
63
|
+
useCancelableRequest: false,
|
|
64
|
+
});
|
|
65
|
+
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('MyService.ts') && content.toString().includes('service')), 'Expected writeFile to be called with service content for MyService.ts');
|
|
66
|
+
// Restoring the original function
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
fileSystemHelpers_1.fileSystemHelpers.writeFile = originalWriteFile;
|
|
63
70
|
});
|
|
64
|
-
node_assert_1.default.ok(writeFileCalls.some(([filePath, content]) => filePath.toString().includes('MyService.ts') && content.toString().includes('service')), 'Expected writeFile to be called with service content for MyService.ts');
|
|
65
|
-
// Restoring the original function
|
|
66
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
fileSystem_1.fileSystem.writeFile = originalWriteFile;
|
|
69
71
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.appendUniqueLinesToFile = appendUniqueLinesToFile;
|
|
4
|
-
const
|
|
4
|
+
const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
|
|
5
5
|
async function appendUniqueLinesToFile(filePath, data) {
|
|
6
6
|
try {
|
|
7
7
|
let existingContent = '';
|
|
8
|
-
const fileExists = await
|
|
8
|
+
const fileExists = await fileSystemHelpers_1.fileSystemHelpers.exists(filePath);
|
|
9
9
|
if (fileExists) {
|
|
10
|
-
existingContent = await
|
|
10
|
+
existingContent = await fileSystemHelpers_1.fileSystemHelpers.readFile(filePath, "utf8");
|
|
11
11
|
}
|
|
12
12
|
const existingLines = existingContent.split(/\r?\n/).filter(Boolean);
|
|
13
13
|
const dataLines = data.split(/\r?\n/).filter(Boolean);
|
|
@@ -16,7 +16,7 @@ async function appendUniqueLinesToFile(filePath, data) {
|
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const updatedContent = existingContent + linesToAdd.join('\n') + '\n';
|
|
19
|
-
await
|
|
19
|
+
await fileSystemHelpers_1.fileSystemHelpers.writeFile(filePath, updatedContent);
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
22
|
throw new Error(`Error when writing to a file: ${error?.message}`);
|
|
@@ -9,11 +9,11 @@ const parseRef_1 = require("./parseRef");
|
|
|
9
9
|
function createNormalizedRef(parsedRef, resolvedPath) {
|
|
10
10
|
switch (parsedRef.type) {
|
|
11
11
|
case parseRef_1.RefType.LOCAL_FRAGMENT:
|
|
12
|
-
return `${resolvedPath}${parsedRef.fragment
|
|
12
|
+
return `${resolvedPath}${parsedRef.fragment}`;
|
|
13
13
|
case parseRef_1.RefType.EXTERNAL_FILE:
|
|
14
14
|
return resolvedPath;
|
|
15
15
|
case parseRef_1.RefType.EXTERNAL_FILE_FRAGMENT:
|
|
16
|
-
return `${resolvedPath}${parsedRef.fragment
|
|
16
|
+
return `${resolvedPath}${parsedRef.fragment}`;
|
|
17
17
|
case parseRef_1.RefType.ABSOLUTE_PATH:
|
|
18
18
|
return parsedRef.fragment ? `${resolvedPath}${parsedRef.fragment}` : resolvedPath;
|
|
19
19
|
case parseRef_1.RefType.HTTP_URL:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAbsolutePath = getAbsolutePath;
|
|
4
|
-
const pathHelpers_1 = require("
|
|
4
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
5
5
|
function getAbsolutePath(definitionRef, parentRef) {
|
|
6
6
|
// If the definition Ref is missing
|
|
7
7
|
if (!definitionRef) {
|
|
@@ -23,9 +23,9 @@ function getAbsolutePath(definitionRef, parentRef) {
|
|
|
23
23
|
// If definitionRef already has its own fragment and/or relative path
|
|
24
24
|
if (definitionRef.includes('#')) {
|
|
25
25
|
const [defPath, defFrag] = definitionRef.split('#');
|
|
26
|
-
const absPath = defPath ? (0, pathHelpers_1.
|
|
26
|
+
const absPath = defPath ? (0, pathHelpers_1.joinHelper)((0, pathHelpers_1.dirNameHelper)(parentBase), defPath) : parentBase;
|
|
27
27
|
return defFrag ? `${absPath}#${defFrag}` : absPath;
|
|
28
28
|
}
|
|
29
29
|
// Plain relative path → resolve against parent base directory
|
|
30
|
-
return (0, pathHelpers_1.
|
|
30
|
+
return (0, pathHelpers_1.joinHelper)((0, pathHelpers_1.dirNameHelper)(parentBase), definitionRef);
|
|
31
31
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getModelNameWithPrefix.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getModelNameWithPrefix.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,QAAQ,EAAE,eAAe,UAUtG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getModelNameWithPrefix = getModelNameWithPrefix;
|
|
4
|
+
function getModelNameWithPrefix(originalName, definition, prefixes) {
|
|
5
|
+
if (definition.enum && definition !== 'boolean') {
|
|
6
|
+
return `${prefixes.enum}${originalName}`;
|
|
7
|
+
}
|
|
8
|
+
else if (definition.oneOf || definition.anyOf || definition.allOf || ['string', 'number', 'integer', 'boolean', 'array'].includes(definition.type)) {
|
|
9
|
+
return `${prefixes.type}${originalName}`;
|
|
10
|
+
}
|
|
11
|
+
else if (definition.type === 'object') {
|
|
12
|
+
return `${prefixes.interface}${originalName}`;
|
|
13
|
+
}
|
|
14
|
+
return originalName;
|
|
15
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOpenApiSpec.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOpenApiSpec.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAIpE;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA6B5F"}
|
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getOpenApiSpec = getOpenApiSpec;
|
|
7
7
|
const swagger_parser_1 = __importDefault(require("@apidevtools/swagger-parser"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const fileSystemHelpers_1 = require("../../common/utils/fileSystemHelpers");
|
|
9
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
10
10
|
const normalizeAllRefs_1 = require("./normalizeAllRefs");
|
|
11
11
|
/**
|
|
12
12
|
* Load and parse te open api spec. If the file extension is ".yml" or ".yaml"
|
|
@@ -15,11 +15,11 @@ const normalizeAllRefs_1 = require("./normalizeAllRefs");
|
|
|
15
15
|
* @param input
|
|
16
16
|
*/
|
|
17
17
|
async function getOpenApiSpec(context, input) {
|
|
18
|
-
const absoluteInput = (0, pathHelpers_1.
|
|
18
|
+
const absoluteInput = (0, pathHelpers_1.resolveHelper)(process.cwd(), input);
|
|
19
19
|
if (!input) {
|
|
20
20
|
throw new Error(`Could not find OpenApi spec: "${absoluteInput}"`);
|
|
21
21
|
}
|
|
22
|
-
const fileExists = await
|
|
22
|
+
const fileExists = await fileSystemHelpers_1.fileSystemHelpers.exists(absoluteInput);
|
|
23
23
|
if (!fileExists) {
|
|
24
24
|
throw new Error(`Could not read OpenApi spec: "${absoluteInput}"`);
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOutputPaths.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOutputPaths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getOutputPaths.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getOutputPaths.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAG9D,eAAO,MAAM,cAAc,GAAI,sEAM5B;IACC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC,KAAG,WA+BH,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOutputPaths = void 0;
|
|
4
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
4
5
|
const isSubdirectory_1 = require("../utils/isSubdirectory");
|
|
5
|
-
const pathHelpers_1 = require("./pathHelpers");
|
|
6
6
|
const getOutputPaths = ({ output, outputCore, outputModels, outputSchemas, outputServices, }) => {
|
|
7
7
|
const rootPath = process.cwd();
|
|
8
8
|
if (!(0, isSubdirectory_1.isSubDirectory)(rootPath, output)) {
|
|
@@ -20,11 +20,11 @@ const getOutputPaths = ({ output, outputCore, outputModels, outputSchemas, outpu
|
|
|
20
20
|
if (outputServices && !(0, isSubdirectory_1.isSubDirectory)(rootPath, outputServices)) {
|
|
21
21
|
throw new Error(`Output folder(services) is not a subdirectory of the current working directory`);
|
|
22
22
|
}
|
|
23
|
-
const outputPath = (0, pathHelpers_1.
|
|
24
|
-
const outputPathCore = outputCore ? (0, pathHelpers_1.
|
|
25
|
-
const outputPathModels = outputModels ? (0, pathHelpers_1.
|
|
26
|
-
const outputPathSchemas = outputSchemas ? (0, pathHelpers_1.
|
|
27
|
-
const outputPathServices = outputServices ? (0, pathHelpers_1.
|
|
23
|
+
const outputPath = (0, pathHelpers_1.resolveHelper)(rootPath, output);
|
|
24
|
+
const outputPathCore = outputCore ? (0, pathHelpers_1.resolveHelper)(rootPath, outputCore) : (0, pathHelpers_1.resolveHelper)(outputPath, 'core');
|
|
25
|
+
const outputPathModels = outputModels ? (0, pathHelpers_1.resolveHelper)(rootPath, outputModels) : (0, pathHelpers_1.resolveHelper)(outputPath, 'models');
|
|
26
|
+
const outputPathSchemas = outputSchemas ? (0, pathHelpers_1.resolveHelper)(rootPath, outputSchemas) : (0, pathHelpers_1.resolveHelper)(outputPath, 'schemas');
|
|
27
|
+
const outputPathServices = outputServices ? (0, pathHelpers_1.resolveHelper)(rootPath, outputServices) : (0, pathHelpers_1.resolveHelper)(outputPath, 'services');
|
|
28
28
|
return {
|
|
29
29
|
output: outputPath,
|
|
30
30
|
outputCore: outputPathCore,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPattern.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getPattern.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPattern.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getPattern.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPattern = getPattern;
|
|
4
|
+
const Consts_1 = require("../types/Consts");
|
|
4
5
|
/**
|
|
5
6
|
* The spec generates a pattern like this '^\d{3}-\d{2}-\d{4}$'
|
|
6
7
|
* However, to use it in HTML or inside new RegExp() we need to
|
|
@@ -9,5 +10,5 @@ exports.getPattern = getPattern;
|
|
|
9
10
|
* @param pattern
|
|
10
11
|
*/
|
|
11
12
|
function getPattern(pattern) {
|
|
12
|
-
return pattern?.replace(
|
|
13
|
+
return pattern?.replace(Consts_1.REGEX_BACKSLASH, '\\\\');
|
|
13
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRelativeModelPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getRelativeModelPath.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getRelativeModelPath.d.ts","sourceRoot":"","sources":["../../../src/core/utils/getRelativeModelPath.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,iBAAiB,EAAE,MAAM,UA2B7F"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRelativeModelPath = getRelativeModelPath;
|
|
4
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
4
5
|
const getTypeName_1 = require("./getTypeName");
|
|
5
6
|
const isInsideDirectory_1 = require("./isInsideDirectory");
|
|
6
|
-
const pathHelpers_1 = require("./pathHelpers");
|
|
7
|
-
const replaceString_1 = require("./replaceString");
|
|
8
|
-
const stripNamespace_1 = require("./stripNamespace");
|
|
9
7
|
/**
|
|
10
8
|
* The function calculates the relative path to the model.
|
|
11
9
|
* Removes the transition to the directory with a level above.
|
|
@@ -31,11 +29,9 @@ function getRelativeModelPath(folderPath, relativeModelPath) {
|
|
|
31
29
|
}
|
|
32
30
|
modelPath = pathArray.join(pathSep);
|
|
33
31
|
}
|
|
34
|
-
const resolvedPath = (0, pathHelpers_1.
|
|
32
|
+
const resolvedPath = (0, pathHelpers_1.resolveHelper)(folderPath, modelPath);
|
|
35
33
|
if ((0, isInsideDirectory_1.isInsideDirectory)(resolvedPath, folderPath)) {
|
|
36
34
|
mappedPaths = modelPath;
|
|
37
35
|
}
|
|
38
|
-
const normalizedValue = (0, replaceString_1.replaceString)(mappedPaths);
|
|
39
|
-
mappedPaths = (0, stripNamespace_1.stripNamespace)(normalizedValue || '');
|
|
40
36
|
return mappedPaths;
|
|
41
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isSubdirectory.d.ts","sourceRoot":"","sources":["../../../src/core/utils/isSubdirectory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"isSubdirectory.d.ts","sourceRoot":"","sources":["../../../src/core/utils/isSubdirectory.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,WAK3D"}
|
|
@@ -5,14 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isSubDirectory = isSubDirectory;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
8
9
|
/**
|
|
9
10
|
* Checks whether `child` is a subdirectory of `parent`
|
|
10
11
|
* @param parent Parent directory (absolute path)
|
|
11
12
|
* @param child Child directory (absolute or relative path)
|
|
12
13
|
*/
|
|
13
14
|
function isSubDirectory(parent, child) {
|
|
14
|
-
const parentNormalized =
|
|
15
|
-
const childNormalized =
|
|
16
|
-
const relative =
|
|
15
|
+
const parentNormalized = (0, pathHelpers_1.resolveHelper)(parent);
|
|
16
|
+
const childNormalized = (0, pathHelpers_1.resolveHelper)(parentNormalized, child);
|
|
17
|
+
const relative = (0, pathHelpers_1.relativeHelper)(parentNormalized, childNormalized);
|
|
17
18
|
return relative !== '' && !relative.startsWith('..') && !path_1.default.isAbsolute(relative);
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapPathToTargetDirSafe.d.ts","sourceRoot":"","sources":["../../../src/core/utils/mapPathToTargetDirSafe.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapPathToTargetDirSafe.d.ts","sourceRoot":"","sources":["../../../src/core/utils/mapPathToTargetDirSafe.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CA0CrG"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapPathToTargetDirSafe = mapPathToTargetDirSafe;
|
|
4
|
-
const
|
|
4
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
5
5
|
const findCommonParent_1 = require("./findCommonParent");
|
|
6
6
|
const getRelativeModelPath_1 = require("./getRelativeModelPath");
|
|
7
|
-
const pathHelpers_1 = require("./pathHelpers");
|
|
8
7
|
/**
|
|
9
8
|
* Safely muppit the path from SourceDir → targetDir
|
|
10
9
|
* Works even if the file is outside SourceDir, but in a common parent
|
|
@@ -15,34 +14,34 @@ const pathHelpers_1 = require("./pathHelpers");
|
|
|
15
14
|
*/
|
|
16
15
|
function mapPathToTargetDirSafe(filePath, sourceDir, targetDir) {
|
|
17
16
|
const pathSep = '/';
|
|
18
|
-
const absFile = (0, pathHelpers_1.
|
|
19
|
-
const absSource = (0, pathHelpers_1.
|
|
20
|
-
const absTarget = (0, pathHelpers_1.
|
|
17
|
+
const absFile = (0, pathHelpers_1.resolveHelper)(filePath);
|
|
18
|
+
const absSource = (0, pathHelpers_1.resolveHelper)(sourceDir);
|
|
19
|
+
const absTarget = (0, pathHelpers_1.resolveHelper)(targetDir);
|
|
21
20
|
const sourceWithSep = absSource.endsWith(pathSep) ? absSource : absSource + pathSep;
|
|
22
21
|
// 1. The file inside SourceDir → mapim as usual
|
|
23
22
|
if (absFile.startsWith(sourceWithSep)) {
|
|
24
|
-
const rel = (0,
|
|
25
|
-
return (0, pathHelpers_1.
|
|
23
|
+
const rel = (0, pathHelpers_1.relativeHelper)(absSource, absFile);
|
|
24
|
+
return (0, pathHelpers_1.resolveHelper)(absTarget, rel);
|
|
26
25
|
}
|
|
27
26
|
// 2. The file is outside SourceDir, but in a common parent
|
|
28
27
|
const commonParent = (0, findCommonParent_1.findCommonParent)(absSource, absFile);
|
|
29
28
|
if (commonParent) {
|
|
30
29
|
// Path from commonParent → file
|
|
31
|
-
const fileRelToCommon = (0,
|
|
30
|
+
const fileRelToCommon = (0, pathHelpers_1.relativeHelper)(commonParent, absFile);
|
|
32
31
|
// Path from targetDir → commonParent
|
|
33
|
-
const targetToCommon = (0,
|
|
32
|
+
const targetToCommon = (0, pathHelpers_1.relativeHelper)(absTarget, commonParent);
|
|
34
33
|
if (targetToCommon.includes('..')) {
|
|
35
34
|
// targetDir is higher than commonParent → we can't map
|
|
36
35
|
if (filePath) {
|
|
37
|
-
const relativePath = (0,
|
|
36
|
+
const relativePath = (0, pathHelpers_1.relativeHelper)(absSource, absFile);
|
|
38
37
|
return (0, getRelativeModelPath_1.getRelativeModelPath)(targetDir, relativePath);
|
|
39
38
|
}
|
|
40
39
|
return filePath;
|
|
41
40
|
}
|
|
42
41
|
// Collecting: targetDir → commonParent → file
|
|
43
|
-
const pathFromTargetToCommon = (0,
|
|
42
|
+
const pathFromTargetToCommon = (0, pathHelpers_1.relativeHelper)(absTarget, commonParent);
|
|
44
43
|
const pathFromCommonToFile = fileRelToCommon;
|
|
45
|
-
return (0, pathHelpers_1.
|
|
44
|
+
return (0, pathHelpers_1.resolveHelper)(absTarget, pathFromTargetToCommon, pathFromCommonToFile);
|
|
46
45
|
}
|
|
47
46
|
// 3. There is no common parent → return as is
|
|
48
47
|
return filePath;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/modelHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"modelHelpers.d.ts","sourceRoot":"","sources":["../../../src/core/utils/modelHelpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAEzD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,CAkBjE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,eAAe,EAAE,MAAM,GAAG,KAAK,EAAE,CA+BrF"}
|
|
@@ -1,8 +1,12 @@
|
|
|
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
|
exports.setDuplicateModelAliases = setDuplicateModelAliases;
|
|
4
7
|
exports.resolveModelImports = resolveModelImports;
|
|
5
|
-
const path_1 = require("path");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const pathHelpers_1 = require("../../common/utils/pathHelpers");
|
|
6
10
|
/**
|
|
7
11
|
* Assigns alias to models with the same name.
|
|
8
12
|
* Modifies objects of in-place models and returns an array.
|
|
@@ -57,11 +61,19 @@ function resolveModelImports(models, outputModelsDir) {
|
|
|
57
61
|
const importAlias = importModel?.alias ?? imprt.alias;
|
|
58
62
|
let importPath = imprt.path;
|
|
59
63
|
if (importModel) {
|
|
60
|
-
const fromDir = (0,
|
|
61
|
-
const toDir = (0,
|
|
62
|
-
const file =
|
|
63
|
-
const relativePath = (0,
|
|
64
|
-
|
|
64
|
+
const fromDir = (0, pathHelpers_1.dirNameHelper)((0, pathHelpers_1.resolveHelper)(outputModelsDir, model.path));
|
|
65
|
+
const toDir = (0, pathHelpers_1.dirNameHelper)((0, pathHelpers_1.resolveHelper)(outputModelsDir, importModel.path));
|
|
66
|
+
const file = path_1.default.basename(importModel.path);
|
|
67
|
+
const relativePath = (0, pathHelpers_1.relativeHelper)(fromDir, toDir);
|
|
68
|
+
if (relativePath === '') {
|
|
69
|
+
importPath = `./${file}`;
|
|
70
|
+
}
|
|
71
|
+
else if (relativePath.startsWith('./')) {
|
|
72
|
+
importPath = `${relativePath}${file}`;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
importPath = `${relativePath}/${file}`;
|
|
76
|
+
}
|
|
65
77
|
}
|
|
66
78
|
return Object.assign(imprt, {
|
|
67
79
|
alias: importAlias,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeString.d.ts","sourceRoot":"","sources":["../../../src/core/utils/normalizeString.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAUzE"}
|