@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
|
@@ -146,18 +146,10 @@ export function writeGetOperationOptions(
|
|
|
146
146
|
statements: !useCoreV2
|
|
147
147
|
? `
|
|
148
148
|
const operationOptions: coreHttp.OperationOptions = options || {};
|
|
149
|
-
operationOptions.requestOptions = {
|
|
150
|
-
...operationOptions.requestOptions,
|
|
151
|
-
shouldDeserialize: shouldDeserializeLro(lroResourceLocationConfig),
|
|
152
|
-
};
|
|
153
149
|
return coreHttp.operationOptionsToRequestOptionsBase(operationOptions);
|
|
154
150
|
`
|
|
155
151
|
: `
|
|
156
152
|
const operationOptions: coreClient.OperationOptions = options || {};
|
|
157
|
-
operationOptions.requestOptions = {
|
|
158
|
-
...operationOptions.requestOptions,
|
|
159
|
-
shouldDeserialize: shouldDeserializeLro(lroResourceLocationConfig),
|
|
160
|
-
};
|
|
161
153
|
return operationOptions;`
|
|
162
154
|
});
|
|
163
155
|
}
|
|
@@ -433,9 +425,14 @@ function buildMapper(
|
|
|
433
425
|
return "";
|
|
434
426
|
}
|
|
435
427
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
428
|
+
let mapperString = "";
|
|
429
|
+
if (typeof mapper === "string") {
|
|
430
|
+
// When mapper is a reference (string) we don't need to stringify the object
|
|
431
|
+
mapperString = mapper;
|
|
432
|
+
} else {
|
|
433
|
+
const { constraints, ...restMapper } = mapper;
|
|
434
|
+
mapperString = JSON.stringify(restMapper);
|
|
435
|
+
}
|
|
439
436
|
|
|
440
437
|
return `${mapperName}: ${mapperString},`;
|
|
441
438
|
}
|
|
@@ -475,7 +472,7 @@ function addClass(
|
|
|
475
472
|
);
|
|
476
473
|
const operationGroupClass = operationGroupFile.addClass({
|
|
477
474
|
name: `${className}Impl`,
|
|
478
|
-
docs: [`Class
|
|
475
|
+
docs: [`Class containing ${className} operations.`],
|
|
479
476
|
isExported: true,
|
|
480
477
|
implements: [`${className}`]
|
|
481
478
|
});
|
|
@@ -483,7 +480,7 @@ function addClass(
|
|
|
483
480
|
name: "client",
|
|
484
481
|
isReadonly: true,
|
|
485
482
|
scope: Scope.Private,
|
|
486
|
-
type: `${clientDetails.className}
|
|
483
|
+
type: `${clientDetails.className}`
|
|
487
484
|
});
|
|
488
485
|
const constructorDefinition = operationGroupClass.addConstructor({
|
|
489
486
|
docs: [
|
|
@@ -495,7 +492,7 @@ function addClass(
|
|
|
495
492
|
{
|
|
496
493
|
name: "client",
|
|
497
494
|
hasQuestionToken: false,
|
|
498
|
-
type: `${clientDetails.className}
|
|
495
|
+
type: `${clientDetails.className}`
|
|
499
496
|
}
|
|
500
497
|
]
|
|
501
498
|
});
|
|
@@ -776,30 +773,12 @@ function writeNoOverloadsOperationBody(
|
|
|
776
773
|
const vanillaOptionsName = "options";
|
|
777
774
|
let options = vanillaOptionsName;
|
|
778
775
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
clientDetails,
|
|
786
|
-
operationName,
|
|
787
|
-
`${options} || {}`
|
|
788
|
-
);
|
|
789
|
-
operationMethod.addStatements([tracingStatement]);
|
|
790
|
-
// Options from createSpan should be used as operation options, updating
|
|
791
|
-
options = compileOperationOptionsToRequestOptionsBase(
|
|
792
|
-
updatedOptionsName,
|
|
793
|
-
operation.isLro,
|
|
794
|
-
lroResourceLocationConfig
|
|
795
|
-
);
|
|
796
|
-
} else {
|
|
797
|
-
options = compileOperationOptionsToRequestOptionsBase(
|
|
798
|
-
vanillaOptionsName,
|
|
799
|
-
operation.isLro,
|
|
800
|
-
lroResourceLocationConfig
|
|
801
|
-
);
|
|
802
|
-
}
|
|
776
|
+
// Options from createSpan should be used as operation options, updating
|
|
777
|
+
options = compileOperationOptionsToRequestOptionsBase(
|
|
778
|
+
vanillaOptionsName,
|
|
779
|
+
operation.isLro,
|
|
780
|
+
lroResourceLocationConfig
|
|
781
|
+
);
|
|
803
782
|
|
|
804
783
|
const sendParams = parameterDeclarations
|
|
805
784
|
.map(p =>
|
|
@@ -821,6 +800,7 @@ function writeNoOverloadsOperationBody(
|
|
|
821
800
|
if (operation.isLro) {
|
|
822
801
|
if (!useCoreV2) {
|
|
823
802
|
writeLroOperationBody(
|
|
803
|
+
clientDetails,
|
|
824
804
|
"operationArguments",
|
|
825
805
|
responseName,
|
|
826
806
|
operationSpecName,
|
|
@@ -831,6 +811,7 @@ function writeNoOverloadsOperationBody(
|
|
|
831
811
|
);
|
|
832
812
|
} else {
|
|
833
813
|
writeLroOperationBody(
|
|
814
|
+
clientDetails,
|
|
834
815
|
`{${sendParams}}`,
|
|
835
816
|
responseName,
|
|
836
817
|
operationSpecName,
|
|
@@ -858,18 +839,6 @@ interface OptionsStatement {
|
|
|
858
839
|
outputOptionsVarName: string;
|
|
859
840
|
}
|
|
860
841
|
|
|
861
|
-
function getTracingSpanStatement(
|
|
862
|
-
clientDetails: ClientDetails,
|
|
863
|
-
operationName: string,
|
|
864
|
-
options: string
|
|
865
|
-
): OptionsStatement {
|
|
866
|
-
const outputOptionsVarName = "updatedOptions";
|
|
867
|
-
return {
|
|
868
|
-
statement: `const { span, ${outputOptionsVarName} } = createSpan("${clientDetails.className}-${operationName}", ${options});`,
|
|
869
|
-
outputOptionsVarName: outputOptionsVarName
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
|
|
873
842
|
function writeSendOperationRequest(
|
|
874
843
|
responseName: string,
|
|
875
844
|
operationMethod: MethodDeclaration,
|
|
@@ -879,6 +848,7 @@ function writeSendOperationRequest(
|
|
|
879
848
|
sendParams: string
|
|
880
849
|
) {
|
|
881
850
|
const { useCoreV2, tracingInfo } = getAutorestOptions();
|
|
851
|
+
const operationName = operationMethod.getName();
|
|
882
852
|
const client = isInline ? "" : ".client";
|
|
883
853
|
const sendRequestStatement = !useCoreV2
|
|
884
854
|
? `this${client}.sendOperationRequest(operationArguments, ${operationSpecName})`
|
|
@@ -887,10 +857,11 @@ function writeSendOperationRequest(
|
|
|
887
857
|
// When tracing is enabled we want to report success and failures through OpenTelemetry
|
|
888
858
|
// so we create a span and mark it as succeeded or failed
|
|
889
859
|
operationMethod.addStatements(
|
|
890
|
-
|
|
860
|
+
getTracingClientWithSpanStatement(
|
|
891
861
|
sendRequestStatement,
|
|
892
862
|
responseName,
|
|
893
|
-
!!tracingInfo
|
|
863
|
+
!!tracingInfo,
|
|
864
|
+
`${clientDetails.className}.${operationName}`
|
|
894
865
|
)
|
|
895
866
|
);
|
|
896
867
|
}
|
|
@@ -899,25 +870,18 @@ function getSpanStatusCode() {
|
|
|
899
870
|
return "coreTracing.SpanStatusCode.UNSET";
|
|
900
871
|
}
|
|
901
872
|
|
|
902
|
-
function
|
|
873
|
+
function getTracingClientWithSpanStatement(
|
|
903
874
|
sendRequestStatement: string,
|
|
904
875
|
responseName: string,
|
|
905
|
-
isTracingEnabled: boolean
|
|
876
|
+
isTracingEnabled: boolean,
|
|
877
|
+
spanName: string
|
|
906
878
|
) {
|
|
907
879
|
const { useCoreV2 } = getAutorestOptions();
|
|
908
880
|
if (isTracingEnabled) {
|
|
909
|
-
return `
|
|
910
|
-
|
|
911
|
-
return
|
|
912
|
-
}
|
|
913
|
-
span.setStatus({
|
|
914
|
-
code: ${getSpanStatusCode()},
|
|
915
|
-
message: error.message
|
|
916
|
-
});
|
|
917
|
-
throw error;
|
|
918
|
-
} finally {
|
|
919
|
-
span.end();
|
|
920
|
-
}`;
|
|
881
|
+
return `
|
|
882
|
+
return tracingClient.withSpan("${spanName}", options ?? {}, async options => {
|
|
883
|
+
return ${sendRequestStatement} as Promise<${responseName}>;
|
|
884
|
+
});`;
|
|
921
885
|
} else {
|
|
922
886
|
return !useCoreV2
|
|
923
887
|
? `return ${sendRequestStatement} as Promise<${responseName}>`
|
|
@@ -926,6 +890,7 @@ function getTracingTryCatchStatement(
|
|
|
926
890
|
}
|
|
927
891
|
|
|
928
892
|
function writeLroOperationBody(
|
|
893
|
+
clientDetails: ClientDetails,
|
|
929
894
|
operationParamsName: string,
|
|
930
895
|
responseName: string,
|
|
931
896
|
operationSpecName: string,
|
|
@@ -935,18 +900,16 @@ function writeLroOperationBody(
|
|
|
935
900
|
isTracingEnabled = false
|
|
936
901
|
) {
|
|
937
902
|
const { useCoreV2 } = getAutorestOptions();
|
|
903
|
+
const spanName = `${clientDetails.className}.${methodDeclaration.getName()}`;
|
|
938
904
|
const client = isInline ? "" : ".client";
|
|
939
905
|
const sendRequestStatement = `this${client}.sendOperationRequest(args, spec)`;
|
|
940
|
-
|
|
941
|
-
const finalStateStr = lroResourceLocationConfig
|
|
942
|
-
? `"${lroResourceLocationConfig.toLowerCase()}"`
|
|
943
|
-
: "";
|
|
944
906
|
const sendOperationStatement = !useCoreV2
|
|
945
907
|
? `const directSendOperation = async (args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec): Promise<${responseName}> => {
|
|
946
|
-
${
|
|
908
|
+
${getTracingClientWithSpanStatement(
|
|
947
909
|
sendRequestStatement,
|
|
948
910
|
responseName,
|
|
949
|
-
isTracingEnabled
|
|
911
|
+
isTracingEnabled,
|
|
912
|
+
spanName
|
|
950
913
|
)}
|
|
951
914
|
};
|
|
952
915
|
const sendOperation = async (args: coreHttp.OperationArguments, spec: coreHttp.OperationSpec) => {
|
|
@@ -958,10 +921,11 @@ function writeLroOperationBody(
|
|
|
958
921
|
}};
|
|
959
922
|
}`
|
|
960
923
|
: `const directSendOperation = async (args: coreClient.OperationArguments, spec: coreClient.OperationSpec): Promise<${responseName}> => {
|
|
961
|
-
${
|
|
924
|
+
${getTracingClientWithSpanStatement(
|
|
962
925
|
sendRequestStatement,
|
|
963
926
|
responseName,
|
|
964
|
-
isTracingEnabled
|
|
927
|
+
isTracingEnabled,
|
|
928
|
+
spanName
|
|
965
929
|
)}
|
|
966
930
|
};
|
|
967
931
|
const sendOperation = async (args: coreClient.OperationArguments, spec: coreClient.OperationSpec) => {
|
|
@@ -987,12 +951,17 @@ function writeLroOperationBody(
|
|
|
987
951
|
headers: currentRawResponse!.headers.toJSON()
|
|
988
952
|
}};
|
|
989
953
|
}`;
|
|
990
|
-
const LroClassName = useCoreV2 ? "CoreClientLro" : "CoreHttpLro";
|
|
991
954
|
methodDeclaration.addStatements([
|
|
992
955
|
sendOperationStatement,
|
|
993
|
-
`const lro = new
|
|
994
|
-
${operationSpecName}
|
|
995
|
-
`
|
|
956
|
+
`const lro = new LroImpl(sendOperation,${operationParamsName},
|
|
957
|
+
${operationSpecName})`,
|
|
958
|
+
`const poller = new LroEngine(lro,{ resumeFrom: options?.resumeFrom, intervalInMs: options?.updateIntervalInMs${
|
|
959
|
+
lroResourceLocationConfig
|
|
960
|
+
? `, lroResourceLocationConfig: "${lroResourceLocationConfig.toLowerCase()}"`
|
|
961
|
+
: ""
|
|
962
|
+
} });`,
|
|
963
|
+
"await poller.poll();",
|
|
964
|
+
"return poller;"
|
|
996
965
|
]);
|
|
997
966
|
|
|
998
967
|
methodDeclaration.setReturnType(
|
|
@@ -1015,6 +984,7 @@ function writeMultiMediaTypeOperationBody(
|
|
|
1015
984
|
): void {
|
|
1016
985
|
const { useCoreV2, tracingInfo } = getAutorestOptions();
|
|
1017
986
|
const coreImport = !useCoreV2 ? "coreHttp" : "coreClient";
|
|
987
|
+
|
|
1018
988
|
operationMethod.addStatements([
|
|
1019
989
|
`let operationSpec: ${coreImport}.OperationSpec;`,
|
|
1020
990
|
`let operationArguments: ${coreImport}.OperationArguments;`
|
|
@@ -1096,29 +1066,13 @@ function writeMultiMediaTypeOperationBody(
|
|
|
1096
1066
|
const lroResourceLocationConfig =
|
|
1097
1067
|
operation.lroOptions && operation.lroOptions["final-state-via"];
|
|
1098
1068
|
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
tracingStatement,
|
|
1107
|
-
`operationArguments.options = ${compileOperationOptionsToRequestOptionsBase(
|
|
1108
|
-
outputOptionsVarName,
|
|
1109
|
-
operation.isLro,
|
|
1110
|
-
lroResourceLocationConfig
|
|
1111
|
-
)};`
|
|
1112
|
-
]);
|
|
1113
|
-
} else {
|
|
1114
|
-
operationMethod.addStatements([
|
|
1115
|
-
`operationArguments.options = ${compileOperationOptionsToRequestOptionsBase(
|
|
1116
|
-
optionsVarName,
|
|
1117
|
-
operation.isLro,
|
|
1118
|
-
lroResourceLocationConfig
|
|
1119
|
-
)};`
|
|
1120
|
-
]);
|
|
1121
|
-
}
|
|
1069
|
+
operationMethod.addStatements([
|
|
1070
|
+
`operationArguments.options = ${compileOperationOptionsToRequestOptionsBase(
|
|
1071
|
+
optionsVarName,
|
|
1072
|
+
operation.isLro,
|
|
1073
|
+
lroResourceLocationConfig
|
|
1074
|
+
)};`
|
|
1075
|
+
]);
|
|
1122
1076
|
|
|
1123
1077
|
if (!operation.isLro) {
|
|
1124
1078
|
writeSendOperationRequest(
|
|
@@ -1131,6 +1085,7 @@ function writeMultiMediaTypeOperationBody(
|
|
|
1131
1085
|
);
|
|
1132
1086
|
} else {
|
|
1133
1087
|
writeLroOperationBody(
|
|
1088
|
+
clientDetails,
|
|
1134
1089
|
"operationArguments",
|
|
1135
1090
|
responseName,
|
|
1136
1091
|
"operationSpec",
|
|
@@ -1328,38 +1283,24 @@ function addImports(
|
|
|
1328
1283
|
});
|
|
1329
1284
|
}
|
|
1330
1285
|
|
|
1331
|
-
const
|
|
1286
|
+
const clientClassName = `${className}`;
|
|
1332
1287
|
|
|
1333
|
-
const
|
|
1334
|
-
clientContextClassName,
|
|
1335
|
-
NameType.File
|
|
1336
|
-
);
|
|
1288
|
+
const clientFileName = normalizeName(clientClassName, NameType.File);
|
|
1337
1289
|
|
|
1338
1290
|
operationGroupFile.addImportDeclaration({
|
|
1339
|
-
namedImports: [`${
|
|
1340
|
-
moduleSpecifier: `../${
|
|
1291
|
+
namedImports: [`${clientClassName}`],
|
|
1292
|
+
moduleSpecifier: `../${clientFileName}`
|
|
1341
1293
|
});
|
|
1342
1294
|
|
|
1343
1295
|
if (hasLroOperation(operationGroupDetails)) {
|
|
1344
1296
|
operationGroupFile.addImportDeclaration({
|
|
1345
|
-
namedImports: ["PollerLike", "PollOperationState"],
|
|
1297
|
+
namedImports: ["PollerLike", "PollOperationState", "LroEngine"],
|
|
1346
1298
|
moduleSpecifier: "@azure/core-lro"
|
|
1347
1299
|
});
|
|
1348
1300
|
operationGroupFile.addImportDeclaration({
|
|
1349
|
-
namedImports: ["
|
|
1350
|
-
moduleSpecifier: `../
|
|
1301
|
+
namedImports: ["LroImpl"],
|
|
1302
|
+
moduleSpecifier: `../lroImpl`
|
|
1351
1303
|
});
|
|
1352
|
-
if (useCoreV2) {
|
|
1353
|
-
operationGroupFile.addImportDeclaration({
|
|
1354
|
-
namedImports: ["CoreClientLro", "shouldDeserializeLro"],
|
|
1355
|
-
moduleSpecifier: `../coreClientLro`
|
|
1356
|
-
});
|
|
1357
|
-
} else {
|
|
1358
|
-
operationGroupFile.addImportDeclaration({
|
|
1359
|
-
namedImports: ["CoreHttpLro", "shouldDeserializeLro"],
|
|
1360
|
-
moduleSpecifier: `../coreHttpLro`
|
|
1361
|
-
});
|
|
1362
|
-
}
|
|
1363
1304
|
}
|
|
1364
1305
|
}
|
|
1365
1306
|
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from "ts-morph";
|
|
12
12
|
import { ClientDetails } from "../models/clientDetails";
|
|
13
13
|
import { ParameterDetails } from "../models/parameterDetails";
|
|
14
|
-
import { isString } from "util";
|
|
15
14
|
import { writeMapper } from "./mappersGenerator";
|
|
16
15
|
import { shouldImportParameters } from "./utils/importUtils";
|
|
17
16
|
import { logger } from "../utils/logger";
|
|
@@ -143,7 +142,7 @@ function writeParameterMapper(
|
|
|
143
142
|
{ mapper }: ParameterDetails
|
|
144
143
|
) {
|
|
145
144
|
writer.write("mapper: ");
|
|
146
|
-
if (
|
|
145
|
+
if (typeof mapper === "string") {
|
|
147
146
|
writer.write(`${mapper}Mapper`);
|
|
148
147
|
} else {
|
|
149
148
|
writeMapper(writer, mapper);
|
|
@@ -184,7 +183,7 @@ function getCoreHttpImports(clientDetails: ClientDetails) {
|
|
|
184
183
|
|
|
185
184
|
function getImportedMappers(clientDetails: ClientDetails) {
|
|
186
185
|
const mappers = clientDetails.parameters
|
|
187
|
-
.filter(p => !p.isSynthetic &&
|
|
186
|
+
.filter(p => !p.isSynthetic && typeof p.mapper === "string")
|
|
188
187
|
.map(p => `${p.mapper} as ${p.mapper}Mapper`);
|
|
189
188
|
|
|
190
189
|
return [...new Set<string>(mappers)];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Project,
|
|
6
|
+
SourceFile
|
|
7
|
+
} from "ts-morph";
|
|
8
|
+
import * as fs from 'fs';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import * as hbs from "handlebars";
|
|
11
|
+
import { getAutorestOptions, getSession } from "../../autorestSession";
|
|
12
|
+
import { ClientDetails } from "../../models/clientDetails";
|
|
13
|
+
import { SampleGroup } from "../../models/sampleDetails";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Function that writes the code for all the operations.
|
|
17
|
+
* It will generate one file per operation group and each file contains:
|
|
18
|
+
* - A class definition for the operation group
|
|
19
|
+
* - Methods and overrides for each operation
|
|
20
|
+
* - OperationSpecs for each operation
|
|
21
|
+
* @param clientDetails client details
|
|
22
|
+
* @param project project for code generation
|
|
23
|
+
*/
|
|
24
|
+
export function generateHLCSamples(
|
|
25
|
+
clientDetails: ClientDetails,
|
|
26
|
+
project: Project
|
|
27
|
+
): void {
|
|
28
|
+
// Toplevel operations are inlined in the client
|
|
29
|
+
const sampleGroups = clientDetails.samples;
|
|
30
|
+
const session = getSession();
|
|
31
|
+
if (!sampleGroups) {
|
|
32
|
+
session.error("No samples are found! ", []);
|
|
33
|
+
}
|
|
34
|
+
for (const sampleGroup of sampleGroups as SampleGroup[]) {
|
|
35
|
+
try {
|
|
36
|
+
const file = fs.readFileSync(path.join(__dirname, "hlcSamples.ts.hbs"), {
|
|
37
|
+
encoding: "utf-8"
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const sampleGroupFileContents = hbs.compile(file, { noEscape: true });
|
|
41
|
+
project.createSourceFile(`samples-dev/${sampleGroup.sampleFileName}.ts`, sampleGroupFileContents(sampleGroup), {
|
|
42
|
+
overwrite: true
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
session.error("An error was encountered while handling sample generation", [sampleGroup.sampleFileName]);
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
import {
|
|
5
|
+
{{#if importedTypes.length }}
|
|
6
|
+
{{#each importedTypes}}
|
|
7
|
+
{{this}},
|
|
8
|
+
{{/each}}
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{clientClassName}},
|
|
11
|
+
} from "{{clientPackageName}}";
|
|
12
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
13
|
+
|
|
14
|
+
{{#each samples}}
|
|
15
|
+
/**
|
|
16
|
+
* This sample demonstrates how to {{this.operationDescription}}
|
|
17
|
+
*
|
|
18
|
+
* @summary {{this.operationDescription}}
|
|
19
|
+
* x-ms-original-file: {{this.originalFileLocation}}
|
|
20
|
+
*/
|
|
21
|
+
async function {{this.sampleFunctionName}}() {
|
|
22
|
+
{{#each this.clientParamAssignments}}
|
|
23
|
+
{{this}}
|
|
24
|
+
{{/each}}
|
|
25
|
+
{{#each this.methodParamAssignments}}
|
|
26
|
+
{{this}}
|
|
27
|
+
{{/each}}
|
|
28
|
+
const credential = new DefaultAzureCredential();
|
|
29
|
+
const client = new {{this.clientClassName}}({{this.clientParameterNames}});
|
|
30
|
+
{{#if this.isPaging}}
|
|
31
|
+
const resArray = new Array();
|
|
32
|
+
for await (let item of client{{#unless this.isTopLevel}}.{{this.operationGroupName}}{{/unless}}.{{this.operationName}}({{this.methodParameterNames}})){
|
|
33
|
+
resArray.push(item);
|
|
34
|
+
}
|
|
35
|
+
console.log(resArray);
|
|
36
|
+
{{else}}
|
|
37
|
+
const result = await client
|
|
38
|
+
{{#unless this.isTopLevel}}
|
|
39
|
+
.{{this.operationGroupName}}
|
|
40
|
+
{{/unless}}
|
|
41
|
+
.{{this.operationName}}({{this.methodParameterNames}});
|
|
42
|
+
console.log(result);
|
|
43
|
+
|
|
44
|
+
{{/if}}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
{{this.sampleFunctionName}}().catch(console.error);
|
|
48
|
+
|
|
49
|
+
{{/each}}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { TestCodeModel } from "@autorest/testmodeler/dist/src/core/model";
|
|
2
|
+
import { Project } from "ts-morph";
|
|
3
|
+
import { getAutorestOptions, getSession } from "../../autorestSession";
|
|
4
|
+
import * as fs from 'fs';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import * as hbs from "handlebars";
|
|
7
|
+
import { NameType, normalizeName } from "../../utils/nameUtils";
|
|
8
|
+
import { getLanguageMetadata } from "../../utils/languageHelpers";
|
|
9
|
+
import { transformBaseUrl } from "../../transforms/urlTransforms";
|
|
10
|
+
|
|
11
|
+
export function generateRLCSamples(model: TestCodeModel, project: Project) {
|
|
12
|
+
const {
|
|
13
|
+
generateSample,
|
|
14
|
+
multiClient
|
|
15
|
+
} = getAutorestOptions();
|
|
16
|
+
const session = getSession();
|
|
17
|
+
if (!generateSample || !model?.testModel?.mockTest?.exampleGroups) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// Not supported to generate code for multi-client
|
|
21
|
+
if (multiClient) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const file = fs.readFileSync(path.join(__dirname, "rlcSamples.ts.hbs"), {
|
|
26
|
+
encoding: "utf-8"
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const sampleFileContents = hbs.compile(file, { noEscape: true });
|
|
30
|
+
const sampleData = createSampleData(model);
|
|
31
|
+
project.createSourceFile(`samples-dev/${sampleData.filename}.ts`, sampleFileContents(sampleData), {
|
|
32
|
+
overwrite: true
|
|
33
|
+
});
|
|
34
|
+
} catch (error) {
|
|
35
|
+
session.error("An error was encountered while handling sample generation", []);
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function createSampleData(model: TestCodeModel) {
|
|
41
|
+
const {
|
|
42
|
+
addCredentials,
|
|
43
|
+
packageDetails
|
|
44
|
+
} = getAutorestOptions();
|
|
45
|
+
const clientFileName = normalizeName(
|
|
46
|
+
getLanguageMetadata(model.language).name,
|
|
47
|
+
NameType.File
|
|
48
|
+
);
|
|
49
|
+
const clientName = getLanguageMetadata(model.language).name;
|
|
50
|
+
const clientInterfaceName = clientName.endsWith("Client") ? `${clientName}` : `${clientName}Client`;
|
|
51
|
+
const { parameterName } = transformBaseUrl(model);
|
|
52
|
+
const hasUriParameter = !!parameterName, hasCredentials = addCredentials;
|
|
53
|
+
const clientParameters = [];
|
|
54
|
+
const clientParamAssignments = [];
|
|
55
|
+
if (hasUriParameter) {
|
|
56
|
+
clientParamAssignments.push(`const ${parameterName} = process.env["ENDPOINT"] || "<${parameterName}>"`);
|
|
57
|
+
clientParameters.push(`${parameterName}`);
|
|
58
|
+
}
|
|
59
|
+
if (hasCredentials) {
|
|
60
|
+
clientParamAssignments.push("const credential = new DefaultAzureCredential();");
|
|
61
|
+
clientParameters.push("credential");
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
filename: `${clientFileName}Sample`,
|
|
65
|
+
clientParamAssignments,
|
|
66
|
+
clientClassName: clientInterfaceName,
|
|
67
|
+
clientPackageName: `${packageDetails.name}`,
|
|
68
|
+
clientParameterNames: clientParameters.join(","),
|
|
69
|
+
hasCredentials
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import createClient, {
|
|
4
|
+
{{clientClassName}},
|
|
5
|
+
} from "{{clientPackageName}}";
|
|
6
|
+
{{#if hasCredentials }}
|
|
7
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
8
|
+
{{/if}}
|
|
9
|
+
import * as dotenv from "dotenv";
|
|
10
|
+
|
|
11
|
+
dotenv.config();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* This is a simple sample on how to create client and please add your own code below
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
async function main() {
|
|
18
|
+
{{#each this.clientParamAssignments}}
|
|
19
|
+
{{this}}
|
|
20
|
+
{{/each}}
|
|
21
|
+
const client: {{clientClassName}} = createClient({{this.clientParameterNames}});
|
|
22
|
+
const result = !!client ? "Success" : "Fail";
|
|
23
|
+
console.log(result," to create client.");
|
|
24
|
+
// Add your own code here
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
main().catch(console.error);
|
|
28
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as hbs from 'handlebars';
|
|
4
|
+
import { Project } from 'ts-morph';
|
|
5
|
+
|
|
6
|
+
export function generateSampleEnv(project: Project) {
|
|
7
|
+
const file = fs.readFileSync(path.join(__dirname, "sampleEnv.hbs"), {
|
|
8
|
+
encoding: "utf-8"
|
|
9
|
+
});
|
|
10
|
+
const readmeFileContents = hbs.compile(file, { noEscape: true });
|
|
11
|
+
project.createSourceFile("sample.env", readmeFileContents({}), {
|
|
12
|
+
overwrite: true
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -5,7 +5,7 @@ import { Project } from "ts-morph";
|
|
|
5
5
|
import { getAutorestOptions } from "../../autorestSession";
|
|
6
6
|
|
|
7
7
|
export function generateApiExtractorConfig(project: Project) {
|
|
8
|
-
const { generateMetadata } = getAutorestOptions();
|
|
8
|
+
const { generateMetadata, packageDetails, generateTest, restLevelClient } = getAutorestOptions();
|
|
9
9
|
|
|
10
10
|
if (!generateMetadata) {
|
|
11
11
|
return;
|
|
@@ -14,7 +14,7 @@ export function generateApiExtractorConfig(project: Project) {
|
|
|
14
14
|
const config = {
|
|
15
15
|
$schema:
|
|
16
16
|
"https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
17
|
-
mainEntryPointFilePath:
|
|
17
|
+
mainEntryPointFilePath: `${restLevelClient ? "./types" : "./dist-esm"}${generateTest ? "/src" : ""}/index.d.ts`,
|
|
18
18
|
docModel: {
|
|
19
19
|
enabled: true
|
|
20
20
|
},
|
|
@@ -25,7 +25,7 @@ export function generateApiExtractorConfig(project: Project) {
|
|
|
25
25
|
dtsRollup: {
|
|
26
26
|
enabled: true,
|
|
27
27
|
untrimmedFilePath: "",
|
|
28
|
-
publicTrimmedFilePath: `./
|
|
28
|
+
publicTrimmedFilePath: `./types/${packageDetails.nameWithoutScope}.d.ts`
|
|
29
29
|
},
|
|
30
30
|
messages: {
|
|
31
31
|
tsdocMessageReporting: {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Project } from "ts-morph";
|
|
2
|
+
import { getAutorestOptions } from "../../autorestSession";
|
|
3
|
+
|
|
4
|
+
const esLintConfig = {
|
|
5
|
+
plugins: ["@azure/azure-sdk"],
|
|
6
|
+
extends: ["plugin:@azure/azure-sdk/azure-sdk-base"],
|
|
7
|
+
rules: {
|
|
8
|
+
"@azure/azure-sdk/ts-modules-only-named": "warn",
|
|
9
|
+
"@azure/azure-sdk/ts-apiextractor-json-types": "warn",
|
|
10
|
+
"@azure/azure-sdk/ts-package-json-types": "warn",
|
|
11
|
+
"@azure/azure-sdk/ts-package-json-engine-is-present": "warn",
|
|
12
|
+
"tsdoc/syntax": "warn"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function generateEsLintConfig(project: Project) {
|
|
17
|
+
const { generateMetadata } = getAutorestOptions();
|
|
18
|
+
if (!generateMetadata) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
project.createSourceFile(".eslintrc.json", JSON.stringify(esLintConfig), {
|
|
22
|
+
overwrite: true
|
|
23
|
+
});
|
|
24
|
+
}
|