@autorest/typescript 6.0.0-beta.7 → 6.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -5
- package/dist/{src/generators/static/README.md.hbs → hlcREADME.md.hbs} +41 -5
- package/dist/hlcSamples.ts.hbs +49 -0
- package/dist/karma.conf.js.hbs +126 -0
- package/dist/paginateHelper.ts.hbs +208 -0
- package/dist/pollingHelper.ts.hbs +72 -0
- package/dist/rlcEnv.ts.hbs +3 -0
- package/dist/rlcREADME.md.hbs +71 -0
- package/dist/rlcRecordedClient.ts.hbs +26 -0
- package/dist/rlcSampleTest.spec.ts.hbs +20 -0
- package/dist/rlcSamples.ts.hbs +28 -0
- package/dist/sampleEnv.hbs +4 -0
- package/dist/sampleTest.ts.hbs +32 -0
- package/dist/samples.ts.hbs +0 -0
- package/dist/src/autorestSession.d.ts +18 -6
- package/dist/src/autorestSession.d.ts.map +1 -1
- package/dist/src/autorestSession.js +3 -9
- package/dist/src/autorestSession.js.map +1 -1
- package/dist/src/conflictResolver.d.ts +3 -0
- package/dist/src/conflictResolver.d.ts.map +1 -0
- package/dist/src/conflictResolver.js +43 -0
- package/dist/src/conflictResolver.js.map +1 -0
- package/dist/src/generators/LROGenerator.d.ts.map +1 -1
- package/dist/src/generators/LROGenerator.js +5 -13
- package/dist/src/generators/LROGenerator.js.map +1 -1
- package/dist/src/generators/clientFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/clientFileGenerator.js +303 -61
- package/dist/src/generators/clientFileGenerator.js.map +1 -1
- package/dist/src/generators/indexGenerator.d.ts +1 -1
- package/dist/src/generators/indexGenerator.d.ts.map +1 -1
- package/dist/src/generators/indexGenerator.js +143 -11
- package/dist/src/generators/indexGenerator.js.map +1 -1
- package/dist/src/generators/mappersGenerator.d.ts.map +1 -1
- package/dist/src/generators/mappersGenerator.js +93 -19
- package/dist/src/generators/mappersGenerator.js.map +1 -1
- package/dist/src/generators/modelsGenerator.d.ts.map +1 -1
- package/dist/src/generators/modelsGenerator.js +81 -82
- package/dist/src/generators/modelsGenerator.js.map +1 -1
- package/dist/src/generators/operationGenerator.d.ts.map +1 -1
- package/dist/src/generators/operationGenerator.js +92 -125
- package/dist/src/generators/operationGenerator.js.map +1 -1
- package/dist/src/generators/operationInterfaceGenerator.js +20 -20
- package/dist/src/generators/operationInterfaceGenerator.js.map +1 -1
- package/dist/src/generators/parametersGenerator.d.ts.map +1 -1
- package/dist/src/generators/parametersGenerator.js +7 -8
- package/dist/src/generators/parametersGenerator.js.map +1 -1
- package/dist/src/generators/samples/hlcSampleGenerator.d.ts +13 -0
- package/dist/src/generators/samples/hlcSampleGenerator.d.ts.map +1 -0
- package/dist/src/generators/samples/hlcSampleGenerator.js +43 -0
- package/dist/src/generators/samples/hlcSampleGenerator.js.map +1 -0
- package/dist/src/generators/samples/hlcSamples.ts.hbs +49 -0
- package/dist/src/generators/samples/rlcSampleGenerator.d.ts +4 -0
- package/dist/src/generators/samples/rlcSampleGenerator.d.ts.map +1 -0
- package/dist/src/generators/samples/rlcSampleGenerator.js +64 -0
- package/dist/src/generators/samples/rlcSampleGenerator.js.map +1 -0
- package/dist/src/generators/samples/rlcSamples.ts.hbs +28 -0
- package/dist/src/generators/samples/sampleEnv.hbs +4 -0
- package/dist/src/generators/samples/sampleEnvGenerator.d.ts +3 -0
- package/dist/src/generators/samples/sampleEnvGenerator.d.ts.map +1 -0
- package/dist/src/generators/samples/sampleEnvGenerator.js +17 -0
- package/dist/src/generators/samples/sampleEnvGenerator.js.map +1 -0
- package/dist/src/generators/static/apiExtractorConfig.js +3 -3
- package/dist/src/generators/static/apiExtractorConfig.js.map +1 -1
- package/dist/src/generators/static/esLintConfigGenerator.d.ts +3 -0
- package/dist/src/generators/static/esLintConfigGenerator.d.ts.map +1 -0
- package/dist/src/generators/static/esLintConfigGenerator.js +26 -0
- package/dist/src/generators/static/esLintConfigGenerator.js.map +1 -0
- package/{src/generators/static/README.md.hbs → dist/src/generators/static/hlcREADME.md.hbs} +41 -5
- package/dist/src/generators/static/karma.conf.js.hbs +126 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.d.ts +3 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.js +23 -0
- package/dist/src/generators/static/karmaConfigFileGenerator.js.map +1 -0
- package/dist/src/generators/static/licenseFileGenerator.js +1 -1
- package/dist/src/generators/static/licenseFileGenerator.js.map +1 -1
- package/dist/src/generators/static/packageFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/packageFileGenerator.js +267 -79
- package/dist/src/generators/static/packageFileGenerator.js.map +1 -1
- package/dist/src/generators/static/readmeFileGenerator.d.ts +2 -2
- package/dist/src/generators/static/readmeFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/readmeFileGenerator.js +54 -26
- package/dist/src/generators/static/readmeFileGenerator.js.map +1 -1
- package/dist/src/generators/static/rlcREADME.md.hbs +71 -0
- package/dist/src/generators/static/rollupConfigFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/rollupConfigFileGenerator.js +12 -71
- package/dist/src/generators/static/rollupConfigFileGenerator.js.map +1 -1
- package/dist/src/generators/static/tsConfigFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/static/tsConfigFileGenerator.js +47 -20
- package/dist/src/generators/static/tsConfigFileGenerator.js.map +1 -1
- package/dist/src/generators/test/envBrowserFileGenerator.d.ts +3 -0
- package/dist/src/generators/test/envBrowserFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/test/envBrowserFileGenerator.js +15 -0
- package/dist/src/generators/test/envBrowserFileGenerator.js.map +1 -0
- package/dist/src/generators/test/envFileGenerator.d.ts +3 -0
- package/dist/src/generators/test/envFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/test/envFileGenerator.js +23 -0
- package/dist/src/generators/test/envFileGenerator.js.map +1 -0
- package/dist/src/generators/test/recordedClientFileGenerator.d.ts +3 -0
- package/dist/src/generators/test/recordedClientFileGenerator.d.ts.map +1 -0
- package/dist/src/generators/test/recordedClientFileGenerator.js +23 -0
- package/dist/src/generators/test/recordedClientFileGenerator.js.map +1 -0
- package/dist/src/generators/test/rlcEnv.ts.hbs +3 -0
- package/dist/src/generators/test/rlcRecordedClient.ts.hbs +26 -0
- package/dist/src/generators/test/rlcSampleTest.spec.ts.hbs +20 -0
- package/dist/src/generators/test/sampleTest.ts.hbs +32 -0
- package/dist/src/generators/test/sampleTestGenerator.d.ts +3 -0
- package/dist/src/generators/test/sampleTestGenerator.d.ts.map +1 -0
- package/dist/src/generators/test/sampleTestGenerator.js +34 -0
- package/dist/src/generators/test/sampleTestGenerator.js.map +1 -0
- package/dist/src/generators/tracingFileGenerator.d.ts.map +1 -1
- package/dist/src/generators/tracingFileGenerator.js +7 -21
- package/dist/src/generators/tracingFileGenerator.js.map +1 -1
- package/dist/src/generators/utils/docsUtils.js +2 -2
- package/dist/src/generators/utils/docsUtils.js.map +1 -1
- package/dist/src/generators/utils/operationsUtils.js +1 -1
- package/dist/src/generators/utils/operationsUtils.js.map +1 -1
- package/dist/src/generators/utils/pagingOperations.d.ts +5 -0
- package/dist/src/generators/utils/pagingOperations.d.ts.map +1 -1
- package/dist/src/generators/utils/pagingOperations.js +15 -15
- package/dist/src/generators/utils/pagingOperations.js.map +1 -1
- package/dist/src/generators/utils/parameterUtils.js +9 -9
- package/dist/src/generators/utils/parameterUtils.js.map +1 -1
- package/dist/src/generators/utils/responseTypeUtils.js +2 -2
- package/dist/src/generators/utils/responseTypeUtils.js.map +1 -1
- package/dist/src/generators/utils/tracingUtils.d.ts.map +1 -1
- package/dist/src/generators/utils/tracingUtils.js +2 -6
- package/dist/src/generators/utils/tracingUtils.js.map +1 -1
- package/dist/src/lroImpl.d.ts +16 -0
- package/dist/src/lroImpl.d.ts.map +1 -0
- package/dist/src/lroImpl.js +45 -0
- package/dist/src/lroImpl.js.map +1 -0
- package/dist/src/main.d.ts +2 -2
- package/dist/src/main.d.ts.map +1 -1
- package/dist/src/main.js +8 -8
- package/dist/src/main.js.map +1 -1
- package/dist/src/models/clientDetails.d.ts +10 -1
- package/dist/src/models/clientDetails.d.ts.map +1 -1
- package/dist/src/models/modelDetails.d.ts +2 -2
- package/dist/src/models/modelDetails.d.ts.map +1 -1
- package/dist/src/models/operationDetails.d.ts +1 -0
- package/dist/src/models/operationDetails.d.ts.map +1 -1
- package/dist/src/models/sampleDetails.d.ts +22 -0
- package/dist/src/models/sampleDetails.d.ts.map +1 -0
- package/dist/src/models/sampleDetails.js +3 -0
- package/dist/src/models/sampleDetails.js.map +1 -0
- package/dist/src/restLevelClient/generateClient.d.ts +1 -1
- package/dist/src/restLevelClient/generateClient.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateClient.js +108 -167
- package/dist/src/restLevelClient/generateClient.js.map +1 -1
- package/dist/src/restLevelClient/generateClientDefinition.d.ts +6 -0
- package/dist/src/restLevelClient/generateClientDefinition.d.ts.map +1 -0
- package/dist/src/restLevelClient/generateClientDefinition.js +261 -0
- package/dist/src/restLevelClient/generateClientDefinition.js.map +1 -0
- package/dist/src/restLevelClient/generateIsUnexpectedHelper.d.ts +8 -0
- package/dist/src/restLevelClient/generateIsUnexpectedHelper.d.ts.map +1 -0
- package/dist/src/restLevelClient/generateIsUnexpectedHelper.js +204 -0
- package/dist/src/restLevelClient/generateIsUnexpectedHelper.js.map +1 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.d.ts +8 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.d.ts.map +1 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.js +70 -0
- package/dist/src/restLevelClient/generateMethodShortcuts.js.map +1 -0
- package/dist/src/restLevelClient/generateObjectTypes.d.ts +3 -3
- package/dist/src/restLevelClient/generateObjectTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateObjectTypes.js +43 -31
- package/dist/src/restLevelClient/generateObjectTypes.js.map +1 -1
- package/dist/src/restLevelClient/generatePagingHelper.d.ts +3 -0
- package/dist/src/restLevelClient/generatePagingHelper.d.ts.map +1 -0
- package/dist/src/restLevelClient/generatePagingHelper.js +54 -0
- package/dist/src/restLevelClient/generatePagingHelper.js.map +1 -0
- package/dist/src/restLevelClient/generateParameterTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateParameterTypes.js +247 -43
- package/dist/src/restLevelClient/generateParameterTypes.js.map +1 -1
- package/dist/src/restLevelClient/generatePollingHelper.d.ts +3 -0
- package/dist/src/restLevelClient/generatePollingHelper.d.ts.map +1 -0
- package/dist/src/restLevelClient/generatePollingHelper.js +20 -0
- package/dist/src/restLevelClient/generatePollingHelper.js.map +1 -0
- package/dist/src/restLevelClient/generateResponseTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateResponseTypes.js +45 -29
- package/dist/src/restLevelClient/generateResponseTypes.js.map +1 -1
- package/dist/src/restLevelClient/generateRestLevel.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateRestLevel.js +64 -15
- package/dist/src/restLevelClient/generateRestLevel.js.map +1 -1
- package/dist/src/restLevelClient/generateSchemaTypes.d.ts.map +1 -1
- package/dist/src/restLevelClient/generateSchemaTypes.js +29 -7
- package/dist/src/restLevelClient/generateSchemaTypes.js.map +1 -1
- package/dist/src/restLevelClient/generateTopLevelIndexFile.d.ts +4 -0
- package/dist/src/restLevelClient/generateTopLevelIndexFile.d.ts.map +1 -0
- package/dist/src/restLevelClient/generateTopLevelIndexFile.js +37 -0
- package/dist/src/restLevelClient/generateTopLevelIndexFile.js.map +1 -0
- package/dist/src/restLevelClient/getPropertySignature.d.ts +3 -2
- package/dist/src/restLevelClient/getPropertySignature.d.ts.map +1 -1
- package/dist/src/restLevelClient/getPropertySignature.js +23 -7
- package/dist/src/restLevelClient/getPropertySignature.js.map +1 -1
- package/dist/src/restLevelClient/helpers/hasPollingOperations.d.ts +4 -0
- package/dist/src/restLevelClient/helpers/hasPollingOperations.d.ts.map +1 -0
- package/dist/src/restLevelClient/helpers/hasPollingOperations.js +12 -0
- package/dist/src/restLevelClient/helpers/hasPollingOperations.js.map +1 -0
- package/dist/src/restLevelClient/helpers/modelHelpers.d.ts +4 -0
- package/dist/src/restLevelClient/helpers/modelHelpers.d.ts.map +1 -0
- package/dist/src/restLevelClient/helpers/modelHelpers.js +19 -0
- package/dist/src/restLevelClient/helpers/modelHelpers.js.map +1 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.d.ts +10 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.d.ts.map +1 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.js +64 -0
- package/dist/src/restLevelClient/helpers/operationHelpers.js.map +1 -0
- package/dist/src/restLevelClient/interfaces.d.ts +33 -0
- package/dist/src/restLevelClient/interfaces.d.ts.map +1 -0
- package/dist/src/restLevelClient/interfaces.js +3 -0
- package/dist/src/restLevelClient/interfaces.js.map +1 -0
- package/dist/src/restLevelClient/mutateCodeModel.js +2 -2
- package/dist/src/restLevelClient/mutateCodeModel.js.map +1 -1
- package/dist/src/restLevelClient/operationHelpers.d.ts +4 -0
- package/dist/src/restLevelClient/operationHelpers.d.ts.map +1 -1
- package/dist/src/restLevelClient/operationHelpers.js +21 -10
- package/dist/src/restLevelClient/operationHelpers.js.map +1 -1
- package/dist/src/restLevelClient/paginateHelper.ts.hbs +208 -0
- package/dist/src/restLevelClient/pollingHelper.ts.hbs +72 -0
- package/dist/src/restLevelClient/samples/generateSamples.d.ts +23 -0
- package/dist/src/restLevelClient/samples/generateSamples.d.ts.map +1 -0
- package/dist/src/restLevelClient/samples/generateSamples.js +3 -0
- package/dist/src/restLevelClient/samples/generateSamples.js.map +1 -0
- package/dist/src/restLevelClient/samples/samples.ts.hbs +0 -0
- package/dist/src/restLevelClient/schemaHelpers.d.ts +12 -2
- package/dist/src/restLevelClient/schemaHelpers.d.ts.map +1 -1
- package/dist/src/restLevelClient/schemaHelpers.js +48 -14
- package/dist/src/restLevelClient/schemaHelpers.js.map +1 -1
- package/dist/src/transforms/extensions.js +10 -10
- package/dist/src/transforms/extensions.js.map +1 -1
- package/dist/src/transforms/groupTransforms.js +2 -2
- package/dist/src/transforms/groupTransforms.js.map +1 -1
- package/dist/src/transforms/mapperTransforms.d.ts +1 -1
- package/dist/src/transforms/mapperTransforms.d.ts.map +1 -1
- package/dist/src/transforms/mapperTransforms.js +30 -27
- package/dist/src/transforms/mapperTransforms.js.map +1 -1
- package/dist/src/transforms/objectTransforms.d.ts.map +1 -1
- package/dist/src/transforms/objectTransforms.js +42 -26
- package/dist/src/transforms/objectTransforms.js.map +1 -1
- package/dist/src/transforms/operationTransforms.d.ts.map +1 -1
- package/dist/src/transforms/operationTransforms.js +29 -26
- package/dist/src/transforms/operationTransforms.js.map +1 -1
- package/dist/src/transforms/optionsTransforms.js +1 -1
- package/dist/src/transforms/optionsTransforms.js.map +1 -1
- package/dist/src/transforms/parameterTransforms.d.ts.map +1 -1
- package/dist/src/transforms/parameterTransforms.js +43 -27
- package/dist/src/transforms/parameterTransforms.js.map +1 -1
- package/dist/src/transforms/samplesTransforms.d.ts +7 -0
- package/dist/src/transforms/samplesTransforms.d.ts.map +1 -0
- package/dist/src/transforms/samplesTransforms.js +293 -0
- package/dist/src/transforms/samplesTransforms.js.map +1 -0
- package/dist/src/transforms/transforms.d.ts +1 -2
- package/dist/src/transforms/transforms.d.ts.map +1 -1
- package/dist/src/transforms/transforms.js +26 -24
- package/dist/src/transforms/transforms.js.map +1 -1
- package/dist/src/transforms/urlTransforms.js +3 -3
- package/dist/src/transforms/urlTransforms.js.map +1 -1
- package/dist/src/typescriptGenerator.d.ts +2 -2
- package/dist/src/typescriptGenerator.d.ts.map +1 -1
- package/dist/src/typescriptGenerator.js +46 -40
- package/dist/src/typescriptGenerator.js.map +1 -1
- package/dist/src/utils/autorestOptions.d.ts +2 -2
- package/dist/src/utils/autorestOptions.d.ts.map +1 -1
- package/dist/src/utils/autorestOptions.js +148 -61
- package/dist/src/utils/autorestOptions.js.map +1 -1
- package/dist/src/utils/cloneOperation.js +2 -2
- package/dist/src/utils/cloneOperation.js.map +1 -1
- package/dist/src/utils/copyFiles.d.ts +2 -0
- package/dist/src/utils/copyFiles.d.ts.map +1 -0
- package/dist/src/utils/copyFiles.js +33 -0
- package/dist/src/utils/copyFiles.js.map +1 -0
- package/dist/src/utils/extractHeaders.js +4 -4
- package/dist/src/utils/extractHeaders.js.map +1 -1
- package/dist/src/utils/extractPaginationDetails.d.ts +5 -1
- package/dist/src/utils/extractPaginationDetails.d.ts.map +1 -1
- package/dist/src/utils/extractPaginationDetails.js +23 -10
- package/dist/src/utils/extractPaginationDetails.js.map +1 -1
- package/dist/src/utils/headersToSchema.js +1 -1
- package/dist/src/utils/headersToSchema.js.map +1 -1
- package/dist/src/utils/logger.js +1 -1
- package/dist/src/utils/logger.js.map +1 -1
- package/dist/src/utils/nameUtils.d.ts +6 -2
- package/dist/src/utils/nameUtils.d.ts.map +1 -1
- package/dist/src/utils/nameUtils.js +13 -8
- package/dist/src/utils/nameUtils.js.map +1 -1
- package/dist/src/utils/schemaHelpers.d.ts +6 -1
- package/dist/src/utils/schemaHelpers.d.ts.map +1 -1
- package/dist/src/utils/schemaHelpers.js +50 -7
- package/dist/src/utils/schemaHelpers.js.map +1 -1
- package/dist/src/utils/sortObjectSchemasHierarchically.js +1 -1
- package/dist/src/utils/sortObjectSchemasHierarchically.js.map +1 -1
- package/dist/src/utils/valueHelpers.d.ts.map +1 -1
- package/dist/src/utils/valueHelpers.js +2 -1
- package/dist/src/utils/valueHelpers.js.map +1 -1
- package/package.json +59 -39
- package/src/autorestSession.ts +26 -18
- package/src/conflictResolver.ts +61 -0
- package/src/generators/LROGenerator.ts +2 -16
- package/src/generators/clientFileGenerator.ts +400 -50
- package/src/generators/indexGenerator.ts +166 -14
- package/src/generators/mappersGenerator.ts +108 -8
- package/src/generators/modelsGenerator.ts +101 -98
- package/src/generators/operationGenerator.ts +63 -122
- package/src/generators/parametersGenerator.ts +2 -3
- package/src/generators/samples/hlcSampleGenerator.ts +50 -0
- package/src/generators/samples/hlcSamples.ts.hbs +49 -0
- package/src/generators/samples/rlcSampleGenerator.ts +72 -0
- package/src/generators/samples/rlcSamples.ts.hbs +28 -0
- package/src/generators/samples/sampleEnv.hbs +4 -0
- package/src/generators/samples/sampleEnvGenerator.ts +14 -0
- package/src/generators/static/apiExtractorConfig.ts +3 -3
- package/src/generators/static/esLintConfigGenerator.ts +24 -0
- package/src/generators/static/hlcREADME.md.hbs +144 -0
- package/src/generators/static/karma.conf.js.hbs +126 -0
- package/src/generators/static/karmaConfigFileGenerator.ts +20 -0
- package/src/generators/static/packageFileGenerator.ts +305 -82
- package/src/generators/static/readmeFileGenerator.ts +85 -42
- package/src/generators/static/rlcREADME.md.hbs +71 -0
- package/src/generators/static/rollupConfigFileGenerator.ts +13 -71
- package/src/generators/static/tsConfigFileGenerator.ts +55 -21
- package/src/generators/test/envBrowserFileGenerator.ts +14 -0
- package/src/generators/test/envFileGenerator.ts +22 -0
- package/src/generators/test/recordedClientFileGenerator.ts +22 -0
- package/src/generators/test/rlcEnv.ts.hbs +3 -0
- package/src/generators/test/rlcRecordedClient.ts.hbs +26 -0
- package/src/generators/test/rlcSampleTest.spec.ts.hbs +20 -0
- package/src/generators/test/sampleTest.ts.hbs +32 -0
- package/src/generators/test/sampleTestGenerator.ts +32 -0
- package/src/generators/tracingFileGenerator.ts +6 -24
- package/src/generators/utils/pagingOperations.ts +1 -2
- package/src/generators/utils/tracingUtils.ts +1 -5
- package/src/lroImpl.ts +26 -0
- package/src/main.ts +8 -5
- package/src/models/clientDetails.ts +11 -1
- package/src/models/modelDetails.ts +2 -2
- package/src/models/operationDetails.ts +1 -0
- package/src/models/sampleDetails.ts +22 -0
- package/src/restLevelClient/generateClient.ts +134 -244
- package/src/restLevelClient/generateClientDefinition.ts +386 -0
- package/src/restLevelClient/generateIsUnexpectedHelper.ts +224 -0
- package/src/restLevelClient/generateMethodShortcuts.ts +121 -0
- package/src/restLevelClient/generateObjectTypes.ts +62 -21
- package/src/restLevelClient/generatePagingHelper.ts +69 -0
- package/src/restLevelClient/generateParameterTypes.ts +377 -55
- package/src/restLevelClient/generatePollingHelper.ts +19 -0
- package/src/restLevelClient/generateResponseTypes.ts +53 -22
- package/src/restLevelClient/generateRestLevel.ts +65 -8
- package/src/restLevelClient/generateSchemaTypes.ts +43 -8
- package/src/restLevelClient/generateTopLevelIndexFile.ts +37 -0
- package/src/restLevelClient/getPropertySignature.ts +31 -6
- package/src/restLevelClient/helpers/hasPollingOperations.ts +15 -0
- package/src/restLevelClient/helpers/modelHelpers.ts +15 -0
- package/src/restLevelClient/helpers/operationHelpers.ts +93 -0
- package/src/restLevelClient/interfaces.ts +39 -0
- package/src/restLevelClient/operationHelpers.ts +23 -9
- package/src/restLevelClient/paginateHelper.ts.hbs +208 -0
- package/src/restLevelClient/pollingHelper.ts.hbs +72 -0
- package/src/restLevelClient/samples/generateSamples.ts +23 -0
- package/src/restLevelClient/samples/samples.ts.hbs +0 -0
- package/src/restLevelClient/schemaHelpers.ts +51 -9
- package/src/transforms/mapperTransforms.ts +12 -6
- package/src/transforms/objectTransforms.ts +26 -6
- package/src/transforms/operationTransforms.ts +6 -1
- package/src/transforms/parameterTransforms.ts +26 -7
- package/src/transforms/samplesTransforms.ts +349 -0
- package/src/transforms/transforms.ts +14 -9
- package/src/typescriptGenerator.ts +41 -45
- package/src/utils/autorestOptions.ts +203 -86
- package/src/utils/copyFiles.ts +36 -0
- package/src/utils/extractPaginationDetails.ts +19 -1
- package/src/utils/nameUtils.ts +18 -9
- package/src/utils/schemaHelpers.ts +51 -4
- package/src/utils/valueHelpers.ts +1 -0
- package/CHANGELOG.md +0 -44
- package/dist/src/coreClientLro.d.ts +0 -26
- package/dist/src/coreClientLro.d.ts.map +0 -1
- package/dist/src/coreClientLro.js +0 -207
- package/dist/src/coreClientLro.js.map +0 -1
- package/dist/src/coreHttpLro.d.ts +0 -26
- package/dist/src/coreHttpLro.d.ts.map +0 -1
- package/dist/src/coreHttpLro.js +0 -186
- package/dist/src/coreHttpLro.js.map +0 -1
- package/dist/src/generators/clientContextFileGenerator.d.ts +0 -5
- package/dist/src/generators/clientContextFileGenerator.d.ts.map +0 -1
- package/dist/src/generators/clientContextFileGenerator.js +0 -263
- package/dist/src/generators/clientContextFileGenerator.js.map +0 -1
- package/dist/src/lro/azureAsyncPolling.d.ts +0 -3
- package/dist/src/lro/azureAsyncPolling.d.ts.map +0 -1
- package/dist/src/lro/azureAsyncPolling.js +0 -71
- package/dist/src/lro/azureAsyncPolling.js.map +0 -1
- package/dist/src/lro/bodyPolling.d.ts +0 -8
- package/dist/src/lro/bodyPolling.d.ts.map +0 -1
- package/dist/src/lro/bodyPolling.js +0 -34
- package/dist/src/lro/bodyPolling.js.map +0 -1
- package/dist/src/lro/index.d.ts +0 -4
- package/dist/src/lro/index.d.ts.map +0 -1
- package/dist/src/lro/index.js +0 -10
- package/dist/src/lro/index.js.map +0 -1
- package/dist/src/lro/locationPolling.d.ts +0 -3
- package/dist/src/lro/locationPolling.d.ts.map +0 -1
- package/dist/src/lro/locationPolling.js +0 -18
- package/dist/src/lro/locationPolling.js.map +0 -1
- package/dist/src/lro/lroEngine.d.ts +0 -14
- package/dist/src/lro/lroEngine.d.ts.map +0 -1
- package/dist/src/lro/lroEngine.js +0 -38
- package/dist/src/lro/lroEngine.js.map +0 -1
- package/dist/src/lro/models.d.ts +0 -138
- package/dist/src/lro/models.d.ts.map +0 -1
- package/dist/src/lro/models.js +0 -12
- package/dist/src/lro/models.js.map +0 -1
- package/dist/src/lro/operation.d.ts +0 -36
- package/dist/src/lro/operation.d.ts.map +0 -1
- package/dist/src/lro/operation.js +0 -89
- package/dist/src/lro/operation.js.map +0 -1
- package/dist/src/lro/passthrough.d.ts +0 -3
- package/dist/src/lro/passthrough.d.ts.map +0 -1
- package/dist/src/lro/passthrough.js +0 -14
- package/dist/src/lro/passthrough.js.map +0 -1
- package/dist/src/lro/requestUtils.d.ts +0 -16
- package/dist/src/lro/requestUtils.d.ts.map +0 -1
- package/dist/src/lro/requestUtils.js +0 -76
- package/dist/src/lro/requestUtils.js.map +0 -1
- package/dist/src/lro/stateMachine.d.ts +0 -18
- package/dist/src/lro/stateMachine.d.ts.map +0 -1
- package/dist/src/lro/stateMachine.js +0 -90
- package/dist/src/lro/stateMachine.js.map +0 -1
- package/src/coreClientLro.ts +0 -315
- package/src/coreHttpLro.ts +0 -268
- package/src/generators/clientContextFileGenerator.ts +0 -405
- package/src/lro/azureAsyncPolling.ts +0 -82
- package/src/lro/bodyPolling.ts +0 -34
- package/src/lro/index.ts +0 -18
- package/src/lro/locationPolling.ts +0 -20
- package/src/lro/lroEngine.ts +0 -53
- package/src/lro/models.ts +0 -165
- package/src/lro/operation.ts +0 -112
- package/src/lro/passthrough.ts +0 -15
- package/src/lro/requestUtils.ts +0 -94
- package/src/lro/stateMachine.ts +0 -108
|
@@ -1,31 +1,183 @@
|
|
|
1
|
-
import { Project } from "ts-morph";
|
|
1
|
+
import { Project, SourceFile } from "ts-morph";
|
|
2
2
|
import { ClientDetails } from "../models/clientDetails";
|
|
3
|
-
import { getAutorestOptions } from "../autorestSession";
|
|
4
|
-
|
|
3
|
+
import { getAutorestOptions, getSession } from "../autorestSession";
|
|
4
|
+
import { NameType, normalizeName } from "../utils/nameUtils";
|
|
5
|
+
import { hasPagingOperations } from "../utils/extractPaginationDetails";
|
|
6
|
+
import { hasPollingOperations } from "../restLevelClient/helpers/hasPollingOperations";
|
|
7
|
+
import {
|
|
8
|
+
hasInputModels,
|
|
9
|
+
hasOutputModels
|
|
10
|
+
} from "../restLevelClient/helpers/modelHelpers";
|
|
5
11
|
export function generateIndexFile(
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
project: Project,
|
|
13
|
+
clientDetails?: ClientDetails
|
|
8
14
|
) {
|
|
9
|
-
const { srcPath,
|
|
15
|
+
const { restLevelClient, srcPath, multiClient, batch } = getAutorestOptions();
|
|
10
16
|
const indexFile = project.createSourceFile(`${srcPath}/index.ts`, undefined, {
|
|
11
17
|
overwrite: true
|
|
12
18
|
});
|
|
13
19
|
|
|
20
|
+
if (!restLevelClient) {
|
|
21
|
+
if (!clientDetails) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
"ClientDetails are required when generating High Level Clients"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
generateHLCIndex(clientDetails, indexFile);
|
|
27
|
+
} else if (!multiClient || !batch || batch?.length === 1) {
|
|
28
|
+
// if we are generate single client package for RLC
|
|
29
|
+
generateRLCIndex(indexFile);
|
|
30
|
+
} else {
|
|
31
|
+
generateRLCIndexForMultiClient(indexFile);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// to generate a index.ts for each single module inside the multi client RLC package
|
|
36
|
+
function generateRLCIndexForMultiClient(file: SourceFile) {
|
|
37
|
+
const { model } = getSession();
|
|
38
|
+
const clientName = model.language.default.name;
|
|
39
|
+
const createClientFuncName = `createClient`;
|
|
40
|
+
const moduleName = normalizeName(clientName, NameType.File);
|
|
41
|
+
|
|
42
|
+
file.addImportDeclaration({
|
|
43
|
+
namespaceImport: "Parameters",
|
|
44
|
+
moduleSpecifier: "./parameters"
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
file.addImportDeclaration({
|
|
48
|
+
namespaceImport: "Responses",
|
|
49
|
+
moduleSpecifier: "./responses"
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
file.addImportDeclaration({
|
|
53
|
+
namespaceImport: "Client",
|
|
54
|
+
moduleSpecifier: "./clientDefinitions"
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const exports = ["Parameters", "Responses", "Client"];
|
|
58
|
+
if (hasInputModels(model)) {
|
|
59
|
+
file.addImportDeclaration({
|
|
60
|
+
namespaceImport: "Models",
|
|
61
|
+
moduleSpecifier: "./models"
|
|
62
|
+
});
|
|
63
|
+
exports.push("Models");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (hasOutputModels(model)) {
|
|
67
|
+
file.addImportDeclaration({
|
|
68
|
+
namespaceImport: "OutputModels",
|
|
69
|
+
moduleSpecifier: "./outputModels"
|
|
70
|
+
});
|
|
71
|
+
exports.push("OutputModels");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (hasPagingOperations(model)) {
|
|
75
|
+
file.addImportDeclaration({
|
|
76
|
+
namespaceImport: "PaginateHelper",
|
|
77
|
+
moduleSpecifier: "./paginateHelper"
|
|
78
|
+
});
|
|
79
|
+
exports.push("PaginateHelper");
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (hasPollingOperations(model)) {
|
|
83
|
+
file.addImportDeclaration({
|
|
84
|
+
namespaceImport: "PollingHelper",
|
|
85
|
+
moduleSpecifier: "./pollingHelper"
|
|
86
|
+
});
|
|
87
|
+
exports.push("PollingHelper");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
file.addExportDeclarations([
|
|
91
|
+
{
|
|
92
|
+
moduleSpecifier: `./${moduleName}`,
|
|
93
|
+
namedExports: [`${createClientFuncName}`]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
namedExports: [...exports]
|
|
97
|
+
}
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function generateRLCIndex(file: SourceFile) {
|
|
102
|
+
const { model } = getSession();
|
|
103
|
+
const clientName = model.language.default.name;
|
|
104
|
+
const createClientFuncName = `${clientName}`;
|
|
105
|
+
const moduleName = normalizeName(clientName, NameType.File);
|
|
106
|
+
|
|
107
|
+
file.addImportDeclaration({
|
|
108
|
+
moduleSpecifier: `./${moduleName}`,
|
|
109
|
+
defaultImport: createClientFuncName
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
file.addExportDeclarations([
|
|
113
|
+
{
|
|
114
|
+
moduleSpecifier: `./${moduleName}`
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
moduleSpecifier: "./parameters"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
moduleSpecifier: "./responses"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
moduleSpecifier: "./clientDefinitions"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
moduleSpecifier: "./isUnexpected"
|
|
127
|
+
}
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
if (hasInputModels(model)) {
|
|
131
|
+
file.addExportDeclarations([
|
|
132
|
+
{
|
|
133
|
+
moduleSpecifier: "./models"
|
|
134
|
+
}
|
|
135
|
+
]);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (hasOutputModels(model)) {
|
|
139
|
+
file.addExportDeclarations([
|
|
140
|
+
{
|
|
141
|
+
moduleSpecifier: "./outputModels"
|
|
142
|
+
}
|
|
143
|
+
]);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (hasPagingOperations(model)) {
|
|
147
|
+
file.addExportDeclarations([
|
|
148
|
+
{
|
|
149
|
+
moduleSpecifier: "./paginateHelper"
|
|
150
|
+
}
|
|
151
|
+
]);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (hasPollingOperations(model)) {
|
|
155
|
+
file.addExportDeclarations([
|
|
156
|
+
{
|
|
157
|
+
moduleSpecifier: "./pollingHelper"
|
|
158
|
+
}
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
file.addExportAssignment({
|
|
163
|
+
expression: createClientFuncName,
|
|
164
|
+
isExportEquals: false
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function generateHLCIndex(clientDetails: ClientDetails, file: SourceFile) {
|
|
169
|
+
const { disablePagingAsyncIterators } = getAutorestOptions();
|
|
14
170
|
if (clientDetails.options.hasPaging && !disablePagingAsyncIterators) {
|
|
15
|
-
|
|
171
|
+
file.addStatements([`/// <reference lib="esnext.asynciterable" />`]);
|
|
16
172
|
}
|
|
17
173
|
|
|
18
|
-
|
|
174
|
+
file.addExportDeclarations([
|
|
19
175
|
{
|
|
20
176
|
moduleSpecifier: "./models"
|
|
21
177
|
},
|
|
22
178
|
{
|
|
23
179
|
moduleSpecifier: `./${clientDetails.sourceFileName}`,
|
|
24
180
|
namedExports: [clientDetails.className]
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
moduleSpecifier: `./${clientDetails.sourceFileName}Context`,
|
|
28
|
-
namedExports: [`${clientDetails.className}Context`]
|
|
29
181
|
}
|
|
30
182
|
]);
|
|
31
183
|
|
|
@@ -34,12 +186,12 @@ export function generateIndexFile(
|
|
|
34
186
|
);
|
|
35
187
|
|
|
36
188
|
if (operationGroups.length) {
|
|
37
|
-
|
|
189
|
+
file.addExportDeclarations([
|
|
38
190
|
{
|
|
39
191
|
moduleSpecifier: "./operationsInterfaces"
|
|
40
192
|
}
|
|
41
193
|
]);
|
|
42
194
|
}
|
|
43
195
|
|
|
44
|
-
|
|
196
|
+
file.fixUnusedIdentifiers();
|
|
45
197
|
}
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
MapperConstraints
|
|
20
20
|
} from "@azure/core-http";
|
|
21
21
|
import { ModelProperties } from "../transforms/mapperTransforms";
|
|
22
|
-
import { keys, isEmpty, isString, isNil, isEqual } from "lodash";
|
|
22
|
+
import { keys, isEmpty, isString, isNil, isEqual, List } from "lodash";
|
|
23
23
|
import { getStringForValue, MapperTypes } from "../utils/valueHelpers";
|
|
24
24
|
import { PolymorphicObjectDetails, ObjectKind } from "../models/modelDetails";
|
|
25
25
|
import { logger } from "../utils/logger";
|
|
@@ -57,14 +57,89 @@ export function generateMappers(
|
|
|
57
57
|
mappersFile.fixUnusedIdentifiers();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
function getParents(
|
|
61
|
+
mapperParentMap: Map<string, Array<string>>,
|
|
62
|
+
parent: string
|
|
63
|
+
) {
|
|
64
|
+
const list: Array<string> = new Array<string>();
|
|
65
|
+
const parents = mapperParentMap.get(parent);
|
|
66
|
+
|
|
67
|
+
if (!parents) {
|
|
68
|
+
parents!.forEach(pnt => {
|
|
69
|
+
if (!list.includes(pnt)) {
|
|
70
|
+
getParents(mapperParentMap, pnt).forEach(str => list.push(str));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (!list.includes(parent)) {
|
|
76
|
+
list.push(parent);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return list;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function traverse(mapperParentMap: Map<string, Array<string>>) {
|
|
83
|
+
const list: Array<string> = new Array<string>();
|
|
84
|
+
mapperParentMap.forEach((value: string[], key: string) => {
|
|
85
|
+
value.forEach(parent => {
|
|
86
|
+
if (!list.includes(parent)) {
|
|
87
|
+
getParents(mapperParentMap, parent).forEach(str => list.push(str));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
if (!list.includes(key)) {
|
|
91
|
+
list.push(key);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
return list;
|
|
95
|
+
}
|
|
96
|
+
|
|
60
97
|
/**
|
|
61
98
|
* This function writes to the mappers.ts file all the mappers to be used by @azure/core-http for serialization
|
|
62
99
|
*/
|
|
63
100
|
function writeMappers(sourceFile: SourceFile, { mappers }: ClientDetails) {
|
|
101
|
+
const mapperParentMap: Map<string, Array<string>> = new Map<
|
|
102
|
+
string,
|
|
103
|
+
Array<string>
|
|
104
|
+
>();
|
|
105
|
+
const mapperPositionMap: Map<string, number> = new Map<string, number>();
|
|
106
|
+
let position = 0;
|
|
107
|
+
mappers.forEach(mapper => {
|
|
108
|
+
const compositeMapper = mapper as CompositeMapper;
|
|
109
|
+
const mapperClassName = compositeMapper.type.className;
|
|
110
|
+
if (!mapperClassName) return;
|
|
111
|
+
mapperPositionMap.set(mapperClassName, position);
|
|
112
|
+
position += 1;
|
|
113
|
+
let listOfParents = mapperParentMap.get(mapperClassName);
|
|
114
|
+
if (!listOfParents) {
|
|
115
|
+
listOfParents = new Array<string>();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (
|
|
119
|
+
compositeMapper.type.modelProperties &&
|
|
120
|
+
compositeMapper.type.modelProperties.parentsRefs
|
|
121
|
+
) {
|
|
122
|
+
const { parentsRefs } = (compositeMapper.type.modelProperties ||
|
|
123
|
+
{}) as ModelProperties;
|
|
124
|
+
|
|
125
|
+
if (parentsRefs) {
|
|
126
|
+
(parentsRefs as string[]).forEach(parentsRef => {
|
|
127
|
+
listOfParents!.push(parentsRef);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
mapperParentMap.set(mapperClassName, listOfParents);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const modifiedList = traverse(mapperParentMap);
|
|
64
136
|
const { useCoreV2 } = getAutorestOptions();
|
|
65
137
|
const generatedMappers: Map<string, Mapper> = new Map<string, Mapper>();
|
|
66
138
|
|
|
67
|
-
|
|
139
|
+
modifiedList.forEach(name => {
|
|
140
|
+
const arrayIndex = mapperPositionMap.get(name) || 0;
|
|
141
|
+
const mapper = mappers[arrayIndex];
|
|
142
|
+
|
|
68
143
|
const mapperClassName = (mapper as CompositeMapper).type.className;
|
|
69
144
|
if (!mapperClassName) {
|
|
70
145
|
logger.warning(`Expected a mapper with a className, skipping generation`);
|
|
@@ -103,6 +178,19 @@ function writeMappers(sourceFile: SourceFile, { mappers }: ClientDetails) {
|
|
|
103
178
|
leadingTrivia: writer => writer.blankLine()
|
|
104
179
|
});
|
|
105
180
|
|
|
181
|
+
const { polymorphicDiscriminator } = mapper.type as CompositeMapperType;
|
|
182
|
+
|
|
183
|
+
if (polymorphicDiscriminator) {
|
|
184
|
+
if (
|
|
185
|
+
isString(polymorphicDiscriminator) &&
|
|
186
|
+
`${polymorphicDiscriminator}`.startsWith(mapper.serializedName!)
|
|
187
|
+
) {
|
|
188
|
+
sourceFile.addStatements(
|
|
189
|
+
`${polymorphicDiscriminator}=${polymorphicDiscriminator};`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
106
194
|
// Keep track of the mapper we just generated
|
|
107
195
|
generatedMappers.set(mapperClassName, mapper);
|
|
108
196
|
});
|
|
@@ -178,7 +266,7 @@ export function writeMapper(writer: CodeBlockWriter, mapper: Mapper) {
|
|
|
178
266
|
.write("type:")
|
|
179
267
|
.block(() => {
|
|
180
268
|
// Write tipe properties for the current mapper
|
|
181
|
-
writeMapperType(writer, mapper
|
|
269
|
+
writeMapperType(writer, mapper, parents);
|
|
182
270
|
});
|
|
183
271
|
});
|
|
184
272
|
}
|
|
@@ -189,14 +277,16 @@ export function writeMapper(writer: CodeBlockWriter, mapper: Mapper) {
|
|
|
189
277
|
*/
|
|
190
278
|
function writeMapperType(
|
|
191
279
|
writer: CodeBlockWriter,
|
|
192
|
-
|
|
280
|
+
mapper: Mapper,
|
|
193
281
|
parents: string[]
|
|
194
282
|
) {
|
|
283
|
+
const mapperType = mapper.type;
|
|
284
|
+
|
|
195
285
|
if (isSequenceMapperType(mapperType)) {
|
|
196
286
|
return writeSequenceMapperType(writer, mapperType);
|
|
197
287
|
}
|
|
198
288
|
|
|
199
|
-
return writeCompositeMapperType(writer,
|
|
289
|
+
return writeCompositeMapperType(writer, mapper, parents);
|
|
200
290
|
}
|
|
201
291
|
|
|
202
292
|
/**
|
|
@@ -213,9 +303,10 @@ function isSequenceMapperType(
|
|
|
213
303
|
*/
|
|
214
304
|
function writeCompositeMapperType(
|
|
215
305
|
writer: CodeBlockWriter,
|
|
216
|
-
|
|
306
|
+
mapper: Mapper,
|
|
217
307
|
parents: string[]
|
|
218
308
|
) {
|
|
309
|
+
const mapperType = mapper.type;
|
|
219
310
|
const {
|
|
220
311
|
modelProperties,
|
|
221
312
|
polymorphicDiscriminator,
|
|
@@ -223,7 +314,14 @@ function writeCompositeMapperType(
|
|
|
223
314
|
} = mapperType as CompositeMapperType;
|
|
224
315
|
writeObjectProps(restType, writer);
|
|
225
316
|
// Write type properties that need special handling
|
|
226
|
-
|
|
317
|
+
if (polymorphicDiscriminator) {
|
|
318
|
+
if (
|
|
319
|
+
!isString(polymorphicDiscriminator) ||
|
|
320
|
+
!`${polymorphicDiscriminator}`.startsWith(mapper.serializedName!)
|
|
321
|
+
) {
|
|
322
|
+
writePolymorphicDiscriminator(writer, polymorphicDiscriminator);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
227
325
|
writeModelProperties(writer, parents, modelProperties);
|
|
228
326
|
}
|
|
229
327
|
|
|
@@ -258,7 +356,9 @@ function writeMapperContraints(
|
|
|
258
356
|
.block(() => {
|
|
259
357
|
if (Pattern) {
|
|
260
358
|
writer.write(
|
|
261
|
-
`Pattern: new RegExp("${Pattern.source
|
|
359
|
+
`Pattern: new RegExp("${Pattern.source
|
|
360
|
+
.replace(/\\/g, "\\\\")
|
|
361
|
+
.replace(/"/g, '\\"')}"), `
|
|
262
362
|
);
|
|
263
363
|
}
|
|
264
364
|
|
|
@@ -27,7 +27,6 @@ import { filterOperationParameters } from "./utils/parameterUtils";
|
|
|
27
27
|
import {
|
|
28
28
|
OperationDetails,
|
|
29
29
|
OperationResponseDetails,
|
|
30
|
-
OperationGroupDetails
|
|
31
30
|
} from "../models/operationDetails";
|
|
32
31
|
import { ParameterDetails } from "../models/parameterDetails";
|
|
33
32
|
import {
|
|
@@ -69,6 +68,10 @@ export function generateModels(clientDetails: ClientDetails, project: Project) {
|
|
|
69
68
|
namespaceImport: "coreRestPipeline",
|
|
70
69
|
moduleSpecifier: "@azure/core-rest-pipeline"
|
|
71
70
|
});
|
|
71
|
+
modelsIndexFile.addImportDeclaration({
|
|
72
|
+
namespaceImport: "coreHttpCompat",
|
|
73
|
+
moduleSpecifier: "@azure/core-http-compat"
|
|
74
|
+
});
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
writeUniontypes(clientDetails, modelsIndexFile);
|
|
@@ -77,13 +80,21 @@ export function generateModels(clientDetails: ClientDetails, project: Project) {
|
|
|
77
80
|
writeOperationModels(clientDetails, modelsIndexFile);
|
|
78
81
|
writeClientModels(clientDetails, modelsIndexFile);
|
|
79
82
|
modelsIndexFile.fixUnusedIdentifiers();
|
|
83
|
+
const allTypes = modelsIndexFile.getTypeAliases();
|
|
84
|
+
clientDetails.allTypes = allTypes
|
|
85
|
+
.filter(item => {
|
|
86
|
+
return item.isExported();
|
|
87
|
+
})
|
|
88
|
+
.map(item => {
|
|
89
|
+
return item.getName();
|
|
90
|
+
});
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
const writeClientModels = (
|
|
83
94
|
clientDetails: ClientDetails,
|
|
84
95
|
modelsIndexFile: SourceFile
|
|
85
96
|
) => {
|
|
86
|
-
const { useCoreV2 } = getAutorestOptions();
|
|
97
|
+
const { useCoreV2, coreHttpCompatMode } = getAutorestOptions();
|
|
87
98
|
let clientOptionalParams = clientDetails.parameters.filter(
|
|
88
99
|
p =>
|
|
89
100
|
(!p.required || p.defaultValue) &&
|
|
@@ -97,7 +108,9 @@ const writeClientModels = (
|
|
|
97
108
|
{
|
|
98
109
|
baseClass: !useCoreV2
|
|
99
110
|
? "coreHttp.ServiceClientOptions"
|
|
100
|
-
:
|
|
111
|
+
: coreHttpCompatMode
|
|
112
|
+
? "coreHttpCompat.ExtendedServiceClientOptions"
|
|
113
|
+
: "coreClient.ServiceClientOptions"
|
|
101
114
|
}
|
|
102
115
|
);
|
|
103
116
|
};
|
|
@@ -391,11 +404,11 @@ function buildResponseType(
|
|
|
391
404
|
docs: ["The underlying HTTP response."],
|
|
392
405
|
type: innerResponseProperties.length
|
|
393
406
|
? Writers.intersectionType(
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
407
|
+
"coreHttp.HttpResponse",
|
|
408
|
+
Writers.objectType({
|
|
409
|
+
properties: innerResponseProperties
|
|
410
|
+
})
|
|
411
|
+
)
|
|
399
412
|
: "coreHttp.HttpResponse",
|
|
400
413
|
leadingTrivia: writer => writer.blankLine()
|
|
401
414
|
}
|
|
@@ -435,13 +448,13 @@ function buildResponseType(
|
|
|
435
448
|
if (!useCoreV2) {
|
|
436
449
|
return intersectionTypes.length > 1
|
|
437
450
|
? // Using apply instead of calling the method directly to be able to conditionally pass
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
451
|
+
// parameters, this way we don't have to have a nested if/else tree to decide which parameters
|
|
452
|
+
// to pass, we will pass any intersectionTypes availabe plus the innerType. When there are no intersection types
|
|
453
|
+
// we just return innerType
|
|
454
|
+
Writers.intersectionType.apply(
|
|
455
|
+
Writers,
|
|
456
|
+
intersectionTypes as IntersectionTypeParameters
|
|
457
|
+
)
|
|
445
458
|
: (innerTypeWriter as WriterFunction);
|
|
446
459
|
} else {
|
|
447
460
|
if (intersectionTypes.length > 1) {
|
|
@@ -491,7 +504,7 @@ const writeExtensibleChoice = (
|
|
|
491
504
|
members: choice.properties.map(p => ({
|
|
492
505
|
name: p.name,
|
|
493
506
|
value: p.value,
|
|
494
|
-
docs: p.description ?
|
|
507
|
+
docs: [p.description ? p.description : p.name]
|
|
495
508
|
}))
|
|
496
509
|
});
|
|
497
510
|
}
|
|
@@ -537,7 +550,9 @@ const writeSealedChoice = (
|
|
|
537
550
|
modelsIndexFile: SourceFile
|
|
538
551
|
) => {
|
|
539
552
|
const values = choice.properties
|
|
540
|
-
.map(p =>
|
|
553
|
+
.map(p =>
|
|
554
|
+
choice.itemType === SchemaType.String ? `"${p.value}"` : p.value
|
|
555
|
+
)
|
|
541
556
|
.join(" | ");
|
|
542
557
|
|
|
543
558
|
modelsIndexFile.addTypeAlias({
|
|
@@ -557,29 +572,14 @@ const writeObjects = (
|
|
|
557
572
|
const writeObjectSignature = (modelsIndexFile: SourceFile) => (
|
|
558
573
|
model: ObjectDetails
|
|
559
574
|
) => {
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
type: Writers.intersectionType(
|
|
569
|
-
parents,
|
|
570
|
-
Writers.objectType({ properties })
|
|
571
|
-
),
|
|
572
|
-
leadingTrivia: writer => writer.blankLine()
|
|
573
|
-
});
|
|
574
|
-
} else {
|
|
575
|
-
modelsIndexFile.addInterface({
|
|
576
|
-
name: model.name,
|
|
577
|
-
docs: model.description ? [model.description] : [],
|
|
578
|
-
isExported: true,
|
|
579
|
-
properties,
|
|
580
|
-
leadingTrivia: writer => writer.blankLine()
|
|
581
|
-
});
|
|
582
|
-
}
|
|
575
|
+
modelsIndexFile.addInterface({
|
|
576
|
+
name: model.name,
|
|
577
|
+
docs: model.description ? [model.description] : [],
|
|
578
|
+
isExported: true,
|
|
579
|
+
extends: model.parents.map(p => p.name),
|
|
580
|
+
properties: getPropertiesSignatures(model),
|
|
581
|
+
leadingTrivia: writer => writer.blankLine()
|
|
582
|
+
});
|
|
583
583
|
};
|
|
584
584
|
|
|
585
585
|
/**
|
|
@@ -600,7 +600,6 @@ function writeUniontypes({ objects }: ClientDetails, modelsFile: SourceFile) {
|
|
|
600
600
|
: c.name;
|
|
601
601
|
})
|
|
602
602
|
];
|
|
603
|
-
|
|
604
603
|
modelsFile.addTypeAlias({
|
|
605
604
|
name: `${obj.name}Union`,
|
|
606
605
|
isExported: true,
|
|
@@ -610,20 +609,6 @@ function writeUniontypes({ objects }: ClientDetails, modelsFile: SourceFile) {
|
|
|
610
609
|
});
|
|
611
610
|
}
|
|
612
611
|
|
|
613
|
-
/**
|
|
614
|
-
* Checks if a polymorphic parent needs to be included in the Union type to represent its polymorphism
|
|
615
|
-
* A parent needs to be in the union only if its name is in the list of allowed discriminator values
|
|
616
|
-
* otherwise the parent should be excluded.
|
|
617
|
-
* @param parent Plymorphic parent to check
|
|
618
|
-
*/
|
|
619
|
-
function isPolymorphicParentInUnion(parent: PolymorphicObjectDetails): boolean {
|
|
620
|
-
return Object.keys(parent.discriminatorValues).some(property =>
|
|
621
|
-
parent.discriminatorValues[property].some(
|
|
622
|
-
discriminatorValue => discriminatorValue === parent.name
|
|
623
|
-
)
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
|
|
627
612
|
interface WriteOptionalParametersOptions {
|
|
628
613
|
baseClass?: string;
|
|
629
614
|
mediaTypes?: Set<KnownMediaType>;
|
|
@@ -687,7 +672,7 @@ function writeOptionalParameters(
|
|
|
687
672
|
function buildParamDetails(p: ParameterDetails): PropertySignatureStructure {
|
|
688
673
|
const description = getParameterDescription(p, operationFullName);
|
|
689
674
|
return {
|
|
690
|
-
name: p.name,
|
|
675
|
+
name: normalizeName(p.name, NameType.Parameter, true),
|
|
691
676
|
hasQuestionToken: true,
|
|
692
677
|
type: p.typeDetails.typeName,
|
|
693
678
|
docs: description ? [description] : undefined,
|
|
@@ -705,9 +690,9 @@ function writeOptionalParameters(
|
|
|
705
690
|
isExported: true,
|
|
706
691
|
extends: [
|
|
707
692
|
baseClass ||
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
693
|
+
(!useCoreV2
|
|
694
|
+
? "coreHttp.OperationOptions"
|
|
695
|
+
: "coreClient.OperationOptions")
|
|
711
696
|
],
|
|
712
697
|
properties: properties
|
|
713
698
|
};
|
|
@@ -762,48 +747,50 @@ function writeOptionalParameters(
|
|
|
762
747
|
});
|
|
763
748
|
}
|
|
764
749
|
|
|
750
|
+
// Get the type name to generate given a property
|
|
751
|
+
function getPropertyTypeName(
|
|
752
|
+
property: PropertyDetails,
|
|
753
|
+
objectDetails: ObjectDetails,
|
|
754
|
+
ignoreNullableOnOptional: boolean
|
|
755
|
+
) {
|
|
756
|
+
if (property.isConstant) {
|
|
757
|
+
if (
|
|
758
|
+
property.type === SchemaType.Number ||
|
|
759
|
+
property.type === SchemaType.Boolean
|
|
760
|
+
) {
|
|
761
|
+
return `${property.defaultValue}`;
|
|
762
|
+
}
|
|
763
|
+
return `"${getStringForValue(
|
|
764
|
+
property.defaultValue,
|
|
765
|
+
property.type,
|
|
766
|
+
false //quoted
|
|
767
|
+
)}"`;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
const typeName =
|
|
771
|
+
property.name === "siblings"
|
|
772
|
+
? `${(objectDetails as PolymorphicObjectDetails).unionName}[]`
|
|
773
|
+
: property.type;
|
|
774
|
+
|
|
775
|
+
if (ignoreNullableOnOptional) {
|
|
776
|
+
return property.nullable && property.required
|
|
777
|
+
? `${typeName} | null`
|
|
778
|
+
: typeName;
|
|
779
|
+
} else {
|
|
780
|
+
return property.nullable ? `${typeName} | null` : typeName;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
765
784
|
/**
|
|
766
|
-
*
|
|
785
|
+
* Get a list of properties from an object which aren't marked as discriminators
|
|
767
786
|
* @param objectDetails Object description
|
|
768
787
|
*/
|
|
769
|
-
function
|
|
788
|
+
function getNonDiscriminatorProperties(
|
|
770
789
|
objectDetails: ObjectDetails
|
|
771
|
-
):
|
|
772
|
-
const { ignoreNullableOnOptional } = getAutorestOptions();
|
|
790
|
+
): PropertyDetails[] {
|
|
773
791
|
const { properties } = objectDetails;
|
|
774
|
-
const getTypename = (property: PropertyDetails) => {
|
|
775
|
-
if (property.isConstant) {
|
|
776
|
-
return `"${getStringForValue(
|
|
777
|
-
property.defaultValue,
|
|
778
|
-
property.type,
|
|
779
|
-
false //quoted
|
|
780
|
-
)}"`;
|
|
781
|
-
}
|
|
782
792
|
|
|
783
|
-
|
|
784
|
-
property.name === "siblings"
|
|
785
|
-
? `${(objectDetails as PolymorphicObjectDetails).unionName}[]`
|
|
786
|
-
: property.type;
|
|
787
|
-
|
|
788
|
-
if (ignoreNullableOnOptional) {
|
|
789
|
-
return property.nullable && property.required
|
|
790
|
-
? `${typeName} | null`
|
|
791
|
-
: typeName;
|
|
792
|
-
} else {
|
|
793
|
-
return property.nullable ? `${typeName} | null` : typeName;
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
|
|
797
|
-
return properties
|
|
798
|
-
.filter(property => !property.isDiscriminator)
|
|
799
|
-
.map<PropertySignatureStructure>(property => ({
|
|
800
|
-
name: `"${property.name}"`,
|
|
801
|
-
hasQuestionToken: !property.required,
|
|
802
|
-
isReadonly: property.readOnly,
|
|
803
|
-
type: getTypename(property),
|
|
804
|
-
docs: getPropertyDescription(property),
|
|
805
|
-
kind: StructureKind.PropertySignature
|
|
806
|
-
}));
|
|
793
|
+
return properties.filter(property => !property.isDiscriminator);
|
|
807
794
|
}
|
|
808
795
|
|
|
809
796
|
function getPropertyDescription({ description, readOnly }: PropertyDetails) {
|
|
@@ -884,8 +871,24 @@ function withAdditionalProperties(
|
|
|
884
871
|
* Gets an enhanced list of Properties to construct an Object signature
|
|
885
872
|
* @param objectDetails Object description
|
|
886
873
|
*/
|
|
887
|
-
const getPropertiesSignatures = (objectDetails: ObjectDetails) =>
|
|
888
|
-
|
|
874
|
+
const getPropertiesSignatures = (objectDetails: ObjectDetails) => {
|
|
875
|
+
const { ignoreNullableOnOptional = false } = getAutorestOptions();
|
|
876
|
+
const properties = getNonDiscriminatorProperties(objectDetails).map<
|
|
877
|
+
PropertySignatureStructure
|
|
878
|
+
>(property => ({
|
|
879
|
+
name: `"${property.name}"`,
|
|
880
|
+
hasQuestionToken: !property.required,
|
|
881
|
+
isReadonly: property.readOnly,
|
|
882
|
+
type: getPropertyTypeName(
|
|
883
|
+
property,
|
|
884
|
+
objectDetails,
|
|
885
|
+
ignoreNullableOnOptional
|
|
886
|
+
),
|
|
887
|
+
docs: getPropertyDescription(property),
|
|
888
|
+
kind: StructureKind.PropertySignature
|
|
889
|
+
}));
|
|
890
|
+
return withDiscriminator(
|
|
889
891
|
objectDetails,
|
|
890
|
-
withAdditionalProperties(objectDetails,
|
|
892
|
+
withAdditionalProperties(objectDetails, properties)
|
|
891
893
|
);
|
|
894
|
+
};
|