@azure-tools/typespec-ts 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +23 -0
- package/.prettierignore +1 -0
- package/.prettierrc +7 -0
- package/.rush/temp/package-deps_build.json +303 -0
- package/.rush/temp/shrinkwrap-deps.json +469 -0
- package/CHANGELOG.md +65 -0
- package/CONTRIBUTING.md +134 -0
- package/README.md +150 -0
- package/dist/src/emitUtil.d.ts +6 -0
- package/dist/src/emitUtil.d.ts.map +1 -0
- package/dist/src/emitUtil.js +45 -0
- package/dist/src/emitUtil.js.map +1 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +59 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +159 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +189 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/modelUtils.d.ts +12 -0
- package/dist/src/modelUtils.d.ts.map +1 -0
- package/dist/src/modelUtils.js +812 -0
- package/dist/src/modelUtils.js.map +1 -0
- package/dist/src/operationUtil.d.ts +16 -0
- package/dist/src/operationUtil.d.ts.map +1 -0
- package/dist/src/operationUtil.js +142 -0
- package/dist/src/operationUtil.js.map +1 -0
- package/dist/src/transform/transform.d.ts +8 -0
- package/dist/src/transform/transform.d.ts.map +1 -0
- package/dist/src/transform/transform.js +131 -0
- package/dist/src/transform/transform.js.map +1 -0
- package/dist/src/transform/transformAnnotationDetails.d.ts +6 -0
- package/dist/src/transform/transformAnnotationDetails.d.ts.map +1 -0
- package/dist/src/transform/transformAnnotationDetails.js +188 -0
- package/dist/src/transform/transformAnnotationDetails.js.map +1 -0
- package/dist/src/transform/transformApiVersionParam.d.ts +5 -0
- package/dist/src/transform/transformApiVersionParam.d.ts.map +1 -0
- package/dist/src/transform/transformApiVersionParam.js +76 -0
- package/dist/src/transform/transformApiVersionParam.js.map +1 -0
- package/dist/src/transform/transformParameters.d.ts +14 -0
- package/dist/src/transform/transformParameters.d.ts.map +1 -0
- package/dist/src/transform/transformParameters.js +315 -0
- package/dist/src/transform/transformParameters.js.map +1 -0
- package/dist/src/transform/transformPaths.d.ts +10 -0
- package/dist/src/transform/transformPaths.d.ts.map +1 -0
- package/dist/src/transform/transformPaths.js +124 -0
- package/dist/src/transform/transformPaths.js.map +1 -0
- package/dist/src/transform/transformResponses.d.ts +5 -0
- package/dist/src/transform/transformResponses.d.ts.map +1 -0
- package/dist/src/transform/transformResponses.js +136 -0
- package/dist/src/transform/transformResponses.js.map +1 -0
- package/dist/src/transform/transformSchemas.d.ts +4 -0
- package/dist/src/transform/transformSchemas.d.ts.map +1 -0
- package/dist/src/transform/transformSchemas.js +175 -0
- package/dist/src/transform/transformSchemas.js.map +1 -0
- package/dist/src/transform/transfromRLCOptions.d.ts +10 -0
- package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -0
- package/dist/src/transform/transfromRLCOptions.js +156 -0
- package/dist/src/transform/transfromRLCOptions.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +73 -0
- package/src/emitUtil.ts +63 -0
- package/src/index.ts +106 -0
- package/src/lib.ts +207 -0
- package/src/modelUtils.ts +961 -0
- package/src/operationUtil.ts +203 -0
- package/src/transform/transform.ts +224 -0
- package/src/transform/transformAnnotationDetails.ts +231 -0
- package/src/transform/transformApiVersionParam.ts +104 -0
- package/src/transform/transformParameters.ts +480 -0
- package/src/transform/transformPaths.ts +187 -0
- package/src/transform/transformResponses.ts +190 -0
- package/src/transform/transformSchemas.ts +209 -0
- package/src/transform/transfromRLCOptions.ts +202 -0
- package/test/commands/cadl-ranch-list.ts +83 -0
- package/test/commands/check-clean-tree.ts +55 -0
- package/test/commands/childProcessOnExit.ts +16 -0
- package/test/commands/gen-cadl-ranch.ts +21 -0
- package/test/commands/run.ts +41 -0
- package/test/integration/arrayItemTypes.spec.ts +93 -0
- package/test/integration/authApiKey.spec.ts +38 -0
- package/test/integration/authOauth2.spec.ts +65 -0
- package/test/integration/authUnion.spec.ts +72 -0
- package/test/integration/dictionary.spec.ts +102 -0
- package/test/integration/extensibleEnums.spec.ts +61 -0
- package/test/integration/fixedEnums.spec.ts +52 -0
- package/test/integration/generated/arrays/itemTypes/src/arrayItemTypesClient.ts +31 -0
- package/test/integration/generated/arrays/itemTypes/src/clientDefinitions.ts +150 -0
- package/test/integration/generated/arrays/itemTypes/src/index.ts +13 -0
- package/test/integration/generated/arrays/itemTypes/src/models.ts +9 -0
- package/test/integration/generated/arrays/itemTypes/src/outputModels.ts +9 -0
- package/test/integration/generated/arrays/itemTypes/src/parameters.ts +78 -0
- package/test/integration/generated/arrays/itemTypes/src/responses.ts +104 -0
- package/test/integration/generated/arrays/itemTypes/tspconfig.yaml +12 -0
- package/test/integration/generated/authentication/apiKey/.eslintrc.json +11 -0
- package/test/integration/generated/authentication/apiKey/README.md +56 -0
- package/test/integration/generated/authentication/apiKey/api-extractor.json +18 -0
- package/test/integration/generated/authentication/apiKey/karma.conf.js +133 -0
- package/test/integration/generated/authentication/apiKey/package.json +103 -0
- package/test/integration/generated/authentication/apiKey/rollup.config.js +118 -0
- package/test/integration/generated/authentication/apiKey/src/authApiKeyClient.ts +41 -0
- package/test/integration/generated/authentication/apiKey/src/clientDefinitions.ts +33 -0
- package/test/integration/generated/authentication/apiKey/src/index.ts +12 -0
- package/test/integration/generated/authentication/apiKey/src/outputModels.ts +6 -0
- package/test/integration/generated/authentication/apiKey/src/parameters.ts +7 -0
- package/test/integration/generated/authentication/apiKey/src/responses.ts +21 -0
- package/test/integration/generated/authentication/apiKey/test/public/sampleTest.spec.ts +23 -0
- package/test/integration/generated/authentication/apiKey/test/public/utils/env.browser.ts +2 -0
- package/test/integration/generated/authentication/apiKey/test/public/utils/env.ts +6 -0
- package/test/integration/generated/authentication/apiKey/test/public/utils/recordedClient.ts +29 -0
- package/test/integration/generated/authentication/apiKey/tsconfig.json +25 -0
- package/test/integration/generated/authentication/apiKey/tspconfig.yaml +10 -0
- package/test/integration/generated/authentication/oauth2/karma.conf.js +133 -0
- package/test/integration/generated/authentication/oauth2/src/authOauth2Client.ts +41 -0
- package/test/integration/generated/authentication/oauth2/src/clientDefinitions.ts +33 -0
- package/test/integration/generated/authentication/oauth2/src/index.ts +12 -0
- package/test/integration/generated/authentication/oauth2/src/outputModels.ts +6 -0
- package/test/integration/generated/authentication/oauth2/src/parameters.ts +7 -0
- package/test/integration/generated/authentication/oauth2/src/responses.ts +21 -0
- package/test/integration/generated/authentication/oauth2/test/public/sampleTest.spec.ts +23 -0
- package/test/integration/generated/authentication/oauth2/test/public/utils/env.browser.ts +2 -0
- package/test/integration/generated/authentication/oauth2/test/public/utils/env.ts +6 -0
- package/test/integration/generated/authentication/oauth2/test/public/utils/recordedClient.ts +29 -0
- package/test/integration/generated/authentication/oauth2/tspconfig.yaml +12 -0
- package/test/integration/generated/authentication/union/karma.conf.js +133 -0
- package/test/integration/generated/authentication/union/src/authUnionClient.ts +42 -0
- package/test/integration/generated/authentication/union/src/clientDefinitions.ts +27 -0
- package/test/integration/generated/authentication/union/src/index.ts +11 -0
- package/test/integration/generated/authentication/union/src/parameters.ts +7 -0
- package/test/integration/generated/authentication/union/src/responses.ts +14 -0
- package/test/integration/generated/authentication/union/test/public/sampleTest.spec.ts +23 -0
- package/test/integration/generated/authentication/union/test/public/utils/env.browser.ts +2 -0
- package/test/integration/generated/authentication/union/test/public/utils/env.ts +6 -0
- package/test/integration/generated/authentication/union/test/public/utils/recordedClient.ts +29 -0
- package/test/integration/generated/authentication/union/tspconfig.yaml +12 -0
- package/test/integration/generated/dictionary/.eslintrc.json +11 -0
- package/test/integration/generated/dictionary/README.md +56 -0
- package/test/integration/generated/dictionary/api-extractor.json +18 -0
- package/test/integration/generated/dictionary/package.json +80 -0
- package/test/integration/generated/dictionary/rollup.config.js +118 -0
- package/test/integration/generated/dictionary/src/clientDefinitions.ts +165 -0
- package/test/integration/generated/dictionary/src/dictClient.ts +29 -0
- package/test/integration/generated/dictionary/src/index.ts +13 -0
- package/test/integration/generated/dictionary/src/models.ts +9 -0
- package/test/integration/generated/dictionary/src/outputModels.ts +9 -0
- package/test/integration/generated/dictionary/src/parameters.ts +86 -0
- package/test/integration/generated/dictionary/src/responses.ts +115 -0
- package/test/integration/generated/dictionary/tsconfig.json +25 -0
- package/test/integration/generated/dictionary/tspconfig.yaml +12 -0
- package/test/integration/generated/enums/extensible/.eslintrc.json +11 -0
- package/test/integration/generated/enums/extensible/README.md +56 -0
- package/test/integration/generated/enums/extensible/api-extractor.json +18 -0
- package/test/integration/generated/enums/extensible/package.json +80 -0
- package/test/integration/generated/enums/extensible/rollup.config.js +118 -0
- package/test/integration/generated/enums/extensible/src/clientDefinitions.ts +45 -0
- package/test/integration/generated/enums/extensible/src/enumsExtensible.ts +31 -0
- package/test/integration/generated/enums/extensible/src/index.ts +11 -0
- package/test/integration/generated/enums/extensible/src/parameters.ts +23 -0
- package/test/integration/generated/enums/extensible/src/responses.ts +26 -0
- package/test/integration/generated/enums/extensible/tsconfig.json +25 -0
- package/test/integration/generated/enums/extensible/tspconfig.yaml +11 -0
- package/test/integration/generated/enums/fixed/.eslintrc.json +11 -0
- package/test/integration/generated/enums/fixed/README.md +56 -0
- package/test/integration/generated/enums/fixed/api-extractor.json +18 -0
- package/test/integration/generated/enums/fixed/package.json +80 -0
- package/test/integration/generated/enums/fixed/rollup.config.js +118 -0
- package/test/integration/generated/enums/fixed/src/clientDefinitions.ts +43 -0
- package/test/integration/generated/enums/fixed/src/enumsFixed.ts +31 -0
- package/test/integration/generated/enums/fixed/src/index.ts +11 -0
- package/test/integration/generated/enums/fixed/src/parameters.ts +36 -0
- package/test/integration/generated/enums/fixed/src/responses.ts +27 -0
- package/test/integration/generated/enums/fixed/tsconfig.json +25 -0
- package/test/integration/generated/enums/fixed/tspconfig.yaml +11 -0
- package/test/integration/generated/hello/.eslintrc.json +11 -0
- package/test/integration/generated/hello/README.md +56 -0
- package/test/integration/generated/hello/api-extractor.json +18 -0
- package/test/integration/generated/hello/package.json +80 -0
- package/test/integration/generated/hello/rollup.config.js +118 -0
- package/test/integration/generated/hello/src/clientDefinitions.ts +19 -0
- package/test/integration/generated/hello/src/hello.ts +29 -0
- package/test/integration/generated/hello/src/index.ts +11 -0
- package/test/integration/generated/hello/src/parameters.ts +6 -0
- package/test/integration/generated/hello/src/responses.ts +10 -0
- package/test/integration/generated/hello/tsconfig.json +25 -0
- package/test/integration/generated/hello/tspconfig.yaml +11 -0
- package/test/integration/generated/lro/lroBasic/.eslintrc.json +11 -0
- package/test/integration/generated/lro/lroBasic/README.md +56 -0
- package/test/integration/generated/lro/lroBasic/api-extractor.json +18 -0
- package/test/integration/generated/lro/lroBasic/package.json +82 -0
- package/test/integration/generated/lro/lroBasic/rollup.config.js +118 -0
- package/test/integration/generated/lro/lroBasic/src/azureLro.ts +31 -0
- package/test/integration/generated/lro/lroBasic/src/clientDefinitions.ts +37 -0
- package/test/integration/generated/lro/lroBasic/src/index.ts +12 -0
- package/test/integration/generated/lro/lroBasic/src/parameters.ts +8 -0
- package/test/integration/generated/lro/lroBasic/src/pollingHelper.ts +75 -0
- package/test/integration/generated/lro/lroBasic/src/responses.ts +22 -0
- package/test/integration/generated/lro/lroBasic/tsconfig.json +25 -0
- package/test/integration/generated/lro/lroBasic/tspconfig.yaml +11 -0
- package/test/integration/generated/models/inheritance/.eslintrc.json +11 -0
- package/test/integration/generated/models/inheritance/README.md +56 -0
- package/test/integration/generated/models/inheritance/api-extractor.json +18 -0
- package/test/integration/generated/models/inheritance/package.json +80 -0
- package/test/integration/generated/models/inheritance/rollup.config.js +118 -0
- package/test/integration/generated/models/inheritance/src/clientDefinitions.ts +79 -0
- package/test/integration/generated/models/inheritance/src/index.ts +13 -0
- package/test/integration/generated/models/inheritance/src/models.ts +52 -0
- package/test/integration/generated/models/inheritance/src/modelsInheritance.ts +31 -0
- package/test/integration/generated/models/inheritance/src/outputModels.ts +52 -0
- package/test/integration/generated/models/inheritance/src/parameters.ts +35 -0
- package/test/integration/generated/models/inheritance/src/responses.ts +56 -0
- package/test/integration/generated/models/inheritance/tsconfig.json +25 -0
- package/test/integration/generated/models/inheritance/tspconfig.yaml +11 -0
- package/test/integration/generated/models/propertyOptional/.eslintrc.json +11 -0
- package/test/integration/generated/models/propertyOptional/README.md +56 -0
- package/test/integration/generated/models/propertyOptional/api-extractor.json +18 -0
- package/test/integration/generated/models/propertyOptional/package.json +80 -0
- package/test/integration/generated/models/propertyOptional/rollup.config.js +118 -0
- package/test/integration/generated/models/propertyOptional/src/clientDefinitions.ts +263 -0
- package/test/integration/generated/models/propertyOptional/src/index.ts +13 -0
- package/test/integration/generated/models/propertyOptional/src/models.ts +46 -0
- package/test/integration/generated/models/propertyOptional/src/modelsPropertyOptional.ts +31 -0
- package/test/integration/generated/models/propertyOptional/src/outputModels.ts +46 -0
- package/test/integration/generated/models/propertyOptional/src/parameters.ts +124 -0
- package/test/integration/generated/models/propertyOptional/src/responses.ts +169 -0
- package/test/integration/generated/models/propertyOptional/tsconfig.json +25 -0
- package/test/integration/generated/models/propertyOptional/tspconfig.yaml +11 -0
- package/test/integration/generated/models/propertyTypes/.eslintrc.json +11 -0
- package/test/integration/generated/models/propertyTypes/README.md +56 -0
- package/test/integration/generated/models/propertyTypes/api-extractor.json +18 -0
- package/test/integration/generated/models/propertyTypes/package.json +80 -0
- package/test/integration/generated/models/propertyTypes/rollup.config.js +118 -0
- package/test/integration/generated/models/propertyTypes/src/clientDefinitions.ts +234 -0
- package/test/integration/generated/models/propertyTypes/src/index.ts +13 -0
- package/test/integration/generated/models/propertyTypes/src/models.ts +99 -0
- package/test/integration/generated/models/propertyTypes/src/modelsPropertyTypes.ts +31 -0
- package/test/integration/generated/models/propertyTypes/src/outputModels.ts +99 -0
- package/test/integration/generated/models/propertyTypes/src/parameters.ts +147 -0
- package/test/integration/generated/models/propertyTypes/src/responses.ts +186 -0
- package/test/integration/generated/models/propertyTypes/tsconfig.json +25 -0
- package/test/integration/generated/models/propertyTypes/tspconfig.yaml +11 -0
- package/test/integration/generated/models/usage/.eslintrc.json +11 -0
- package/test/integration/generated/models/usage/README.md +56 -0
- package/test/integration/generated/models/usage/api-extractor.json +18 -0
- package/test/integration/generated/models/usage/package.json +80 -0
- package/test/integration/generated/models/usage/rollup.config.js +118 -0
- package/test/integration/generated/models/usage/src/clientDefinitions.ts +41 -0
- package/test/integration/generated/models/usage/src/index.ts +13 -0
- package/test/integration/generated/models/usage/src/models.ts +12 -0
- package/test/integration/generated/models/usage/src/modelsUsage.ts +31 -0
- package/test/integration/generated/models/usage/src/outputModels.ts +12 -0
- package/test/integration/generated/models/usage/src/parameters.ts +19 -0
- package/test/integration/generated/models/usage/src/responses.ts +22 -0
- package/test/integration/generated/models/usage/tsconfig.json +25 -0
- package/test/integration/generated/models/usage/tspconfig.yaml +11 -0
- package/test/integration/generated/models/visibility/.eslintrc.json +11 -0
- package/test/integration/generated/models/visibility/README.md +56 -0
- package/test/integration/generated/models/visibility/api-extractor.json +18 -0
- package/test/integration/generated/models/visibility/package.json +80 -0
- package/test/integration/generated/models/visibility/rollup.config.js +118 -0
- package/test/integration/generated/models/visibility/src/clientDefinitions.ts +40 -0
- package/test/integration/generated/models/visibility/src/index.ts +13 -0
- package/test/integration/generated/models/visibility/src/models.ts +14 -0
- package/test/integration/generated/models/visibility/src/modelsVisibilityAutomatic.ts +31 -0
- package/test/integration/generated/models/visibility/src/outputModels.ts +16 -0
- package/test/integration/generated/models/visibility/src/parameters.ts +41 -0
- package/test/integration/generated/models/visibility/src/responses.ts +36 -0
- package/test/integration/generated/models/visibility/tsconfig.json +25 -0
- package/test/integration/generated/models/visibility/tspconfig.yaml +11 -0
- package/test/integration/generated/resiliency/devDriven/.eslintrc.json +11 -0
- package/test/integration/generated/resiliency/devDriven/README.md +56 -0
- package/test/integration/generated/resiliency/devDriven/api-extractor.json +18 -0
- package/test/integration/generated/resiliency/devDriven/package.json +81 -0
- package/test/integration/generated/resiliency/devDriven/rollup.config.js +118 -0
- package/test/integration/generated/resiliency/devDriven/src/clientDefinitions.ts +75 -0
- package/test/integration/generated/resiliency/devDriven/src/index.ts +15 -0
- package/test/integration/generated/resiliency/devDriven/src/isUnexpected.ts +117 -0
- package/test/integration/generated/resiliency/devDriven/src/models.ts +8 -0
- package/test/integration/generated/resiliency/devDriven/src/outputModels.ts +25 -0
- package/test/integration/generated/resiliency/devDriven/src/paginateHelper.ts +154 -0
- package/test/integration/generated/resiliency/devDriven/src/parameters.ts +17 -0
- package/test/integration/generated/resiliency/devDriven/src/resiliencyDevDriven.ts +31 -0
- package/test/integration/generated/resiliency/devDriven/src/responses.ts +62 -0
- package/test/integration/generated/resiliency/devDriven/tsconfig.json +25 -0
- package/test/integration/generated/resiliency/devDriven/tspconfig.yaml +11 -0
- package/test/integration/generated/resiliency/srvDriven1/.eslintrc.json +11 -0
- package/test/integration/generated/resiliency/srvDriven1/README.md +56 -0
- package/test/integration/generated/resiliency/srvDriven1/api-extractor.json +18 -0
- package/test/integration/generated/resiliency/srvDriven1/package.json +80 -0
- package/test/integration/generated/resiliency/srvDriven1/rollup.config.js +118 -0
- package/test/integration/generated/resiliency/srvDriven1/src/clientDefinitions.ts +70 -0
- package/test/integration/generated/resiliency/srvDriven1/src/index.ts +13 -0
- package/test/integration/generated/resiliency/srvDriven1/src/models.ts +6 -0
- package/test/integration/generated/resiliency/srvDriven1/src/outputModels.ts +6 -0
- package/test/integration/generated/resiliency/srvDriven1/src/parameters.ts +51 -0
- package/test/integration/generated/resiliency/srvDriven1/src/resiliencyServiceDriven1.ts +31 -0
- package/test/integration/generated/resiliency/srvDriven1/src/responses.ts +34 -0
- package/test/integration/generated/resiliency/srvDriven1/tsconfig.json +25 -0
- package/test/integration/generated/resiliency/srvDriven1/tspconfig.yaml +11 -0
- package/test/integration/generated/resiliency/srvDriven2/.eslintrc.json +11 -0
- package/test/integration/generated/resiliency/srvDriven2/README.md +56 -0
- package/test/integration/generated/resiliency/srvDriven2/api-extractor.json +18 -0
- package/test/integration/generated/resiliency/srvDriven2/package.json +80 -0
- package/test/integration/generated/resiliency/srvDriven2/rollup.config.js +118 -0
- package/test/integration/generated/resiliency/srvDriven2/src/clientDefinitions.ts +93 -0
- package/test/integration/generated/resiliency/srvDriven2/src/index.ts +13 -0
- package/test/integration/generated/resiliency/srvDriven2/src/models.ts +6 -0
- package/test/integration/generated/resiliency/srvDriven2/src/outputModels.ts +6 -0
- package/test/integration/generated/resiliency/srvDriven2/src/parameters.ts +68 -0
- package/test/integration/generated/resiliency/srvDriven2/src/resiliencyServiceDriven2.ts +31 -0
- package/test/integration/generated/resiliency/srvDriven2/src/responses.ts +45 -0
- package/test/integration/generated/resiliency/srvDriven2/tsconfig.json +25 -0
- package/test/integration/generated/resiliency/srvDriven2/tspconfig.yaml +11 -0
- package/test/integration/generated/specialWords/src/clientDefinitions.ts +61 -0
- package/test/integration/generated/specialWords/src/index.ts +13 -0
- package/test/integration/generated/specialWords/src/models.ts +17 -0
- package/test/integration/generated/specialWords/src/outputModels.ts +17 -0
- package/test/integration/generated/specialWords/src/parameters.ts +37 -0
- package/test/integration/generated/specialWords/src/responses.ts +31 -0
- package/test/integration/generated/specialWords/src/specialWordsClient.ts +31 -0
- package/test/integration/generated/specialWords/tspconfig.yaml +11 -0
- package/test/integration/generated/unions/src/clientDefinitions.ts +53 -0
- package/test/integration/generated/unions/src/index.ts +12 -0
- package/test/integration/generated/unions/src/models.ts +27 -0
- package/test/integration/generated/unions/src/parameters.ts +34 -0
- package/test/integration/generated/unions/src/responses.ts +24 -0
- package/test/integration/generated/unions/src/unionsClient.ts +31 -0
- package/test/integration/generated/unions/tspconfig.yaml +11 -0
- package/test/integration/helloWorld.spec.ts +20 -0
- package/test/integration/lroBasic.spec.ts +25 -0
- package/test/integration/modelInheritance.spec.ts +192 -0
- package/test/integration/modelPropertyOptional.spec.ts +362 -0
- package/test/integration/modelPropertyType.spec.ts +119 -0
- package/test/integration/modelUsage.spec.ts +47 -0
- package/test/integration/resiliencyDpgCustomization.spec.ts +52 -0
- package/test/integration/specialWords.spec.ts +73 -0
- package/test/integration/unions.spec.ts +69 -0
- package/test/tsconfig.json +4 -0
- package/test/unit/azureCoreOperationsGenerator.spec.ts +71 -0
- package/test/unit/clientDefinitionGenerator.spec.ts +73 -0
- package/test/unit/clientFactoryGenerator.spec.ts +507 -0
- package/test/unit/docsGenerator.spec.ts +201 -0
- package/test/unit/modelsGenerator.spec.ts +1319 -0
- package/test/unit/parametersGenerator.spec.ts +561 -0
- package/test/unit/responsesGenerator.spec.ts +462 -0
- package/test/unit/spreadAndAlias.spec.ts +200 -0
- package/test/unit/util/emitUtil.ts +156 -0
- package/test/unit/util/testUtil.ts +83 -0
- package/test/util/customBearerTokenTestingPolicy.ts +78 -0
- package/test/util/matrix.ts +48 -0
- package/tsconfig.json +36 -0
- package/tsconfig.test.json +7 -0
- package/typespec-ts.build.log +2 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# How to Contribute
|
|
2
|
+
|
|
3
|
+
## Prerequisite
|
|
4
|
+
|
|
5
|
+
Please follow the **[Prerequisite](../../CONTRIBUTING.md#prerequisites)** part to install the dependencies.
|
|
6
|
+
|
|
7
|
+
## Steps to clone, build & test
|
|
8
|
+
|
|
9
|
+
1. Use the following command to clone the Typescript/Javascript SDK generator repository:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
git clone https://github.com/Azure/autorest.typescript.git
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. Use the following commands to build the SDK generator:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
rush update
|
|
19
|
+
rush rebuild
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
3. There are also 3 test-suites in the RLC generator:
|
|
23
|
+
|
|
24
|
+
1. Unit tests (which could be found at `test/unit/*`)
|
|
25
|
+
2. Integration tests (which could be found at `test/integration/*`)
|
|
26
|
+
3. Smoke tests (which could be found at `../../packages/typespec-test`)
|
|
27
|
+
|
|
28
|
+
1. You can run the Unit tests & Integration tests using the following command:
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
npm run test
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Running the command above will do the following things:
|
|
35
|
+
|
|
36
|
+
- Start TestServer
|
|
37
|
+
- Build Cadl Typescript
|
|
38
|
+
- Generate all scenarios in parallel (i.e. Dictionary, Extensible Enums, Models, Resiliency)
|
|
39
|
+
- Run all the tests under test/integration
|
|
40
|
+
- Stop TestServer
|
|
41
|
+
|
|
42
|
+
**_Note_**: If your development environment is Windows, then run the command `npm run start-test-server`(in a seperate window) before running `npm run test` and run the command `npm run stop-test-server` after. (In non windows machines, we could run the test-server in the background automatically. But, in Windows machines, it has to be done manually.)
|
|
43
|
+
|
|
44
|
+
5. You can run the Smoke tests using the following command:
|
|
45
|
+
|
|
46
|
+
```shell
|
|
47
|
+
cd ../../packages/typespec-test
|
|
48
|
+
npm run smoke-test
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## How to add an integration test case
|
|
52
|
+
|
|
53
|
+
Whenever you work on adding a feature/fixing a bug, this would probably be your first step. You create a test case and then run it through the generator, see the result, modify the generator, run it again and so on, until you get the desired output.
|
|
54
|
+
|
|
55
|
+
1. Pick up a cadl as your test input in cadl-ranch. Below are some examples
|
|
56
|
+
|
|
57
|
+
Let us say your test input is `authentication/api-key/main.cadl` in @azure-tools/cadl-ranch-specs.
|
|
58
|
+
|
|
59
|
+
1. Now add an entry to the CadlRanchConfig to the file [`cadl-ranch-list.ts`](./test/commands/cadl-ranch-list.ts). In the file, add the following to the array.
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
{
|
|
63
|
+
outputPath: "authentication/apiKey",
|
|
64
|
+
inputPath: "authentication/api-key"
|
|
65
|
+
},
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
1. Create a tspconfig.yaml in `./test/integration/generated/authentication/apiKey` folder and put the following content in it.
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
emitters:
|
|
72
|
+
"../../../../../../../../../../../packages/typespec-ts/dist/src/index.js":
|
|
73
|
+
generateMetadata: true
|
|
74
|
+
generateTest: true
|
|
75
|
+
includeShortcuts: true
|
|
76
|
+
azureSdkForJs: false
|
|
77
|
+
addCredentials: false
|
|
78
|
+
isCadlTest: true
|
|
79
|
+
title: AuthApiKeyClient
|
|
80
|
+
packageDetails:
|
|
81
|
+
name: "@msinternal/auth-apikey"
|
|
82
|
+
description: "Auth api key Test Service"
|
|
83
|
+
version: "1.0.0"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
1. Now, You can generate the RLC for your test case with the following command: (Initially, during your development, you do not want to run all the cases during every step of your development, you can comment out other test cases. But, once your code changes are complete for your case, then you need to run the entire suite to ensure that your changes did not cause any unwanted changes.)
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
npm run generate-cadl-only
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
1. Once you are satisfied with the generated code, you can add a spec file such as `testUserCaseRest.spec.ts` file [here](./test/integration). You can find several examples in the same place.
|
|
93
|
+
|
|
94
|
+
## How to debug
|
|
95
|
+
|
|
96
|
+
### `generate-cadl-only` step
|
|
97
|
+
|
|
98
|
+
If you would like to debug the `generate-cadl-only` step for our test input, Open the repository in VS Code -> Select `Generate code for CadlEmitter` section -> Click `Attach`.
|
|
99
|
+
|
|
100
|
+
### Spec file
|
|
101
|
+
|
|
102
|
+
If you would like to debug the `testUserCase.spec.ts` file (after the SDK is generated), Open the repository in VS Code -> Open the `testUserCase.spec.ts` file -> Select `Run and Debug` section -> Click `IntegrationTests - Current File`.
|
|
103
|
+
|
|
104
|
+
### How to debug an unit test case
|
|
105
|
+
|
|
106
|
+
- In VS Code, We have created a Debugging profile for UnitTests to start debugging:
|
|
107
|
+
|
|
108
|
+
1. Go to the debugger tab
|
|
109
|
+
2. Select the "[CADL] - Unit Test" Profile
|
|
110
|
+
3. Click the "Play" button
|
|
111
|
+
|
|
112
|
+
- Your breakpoints will start hitting, you can set breakpoints in either Test or Generator code
|
|
113
|
+
|
|
114
|
+
### Integration Tests
|
|
115
|
+
|
|
116
|
+
- In order to debug integration tests you need to start the test server, by running:
|
|
117
|
+
|
|
118
|
+
npm run start-test-server:v1
|
|
119
|
+
|
|
120
|
+
- Once the Test Server is running
|
|
121
|
+
|
|
122
|
+
1. In VSCode go to the debugger tab
|
|
123
|
+
2. Select the "[CADL] - Integration Test" profile from the drop down
|
|
124
|
+
3. Click the "Play" button
|
|
125
|
+
|
|
126
|
+
- **\*\***IMPORTANT**\*\***: Running Integration Tests for debugging, does not re-generate the test clients so make sure that after each change you do:
|
|
127
|
+
|
|
128
|
+
- Re-generate all the test swaggers
|
|
129
|
+
|
|
130
|
+
npm run generate-cadl-only -- --build
|
|
131
|
+
|
|
132
|
+
- Re-generate a specific swagger
|
|
133
|
+
|
|
134
|
+
npm run generate-cadl-only -- -i bodyComplexRest -b
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
This library is the TypeSpec typescript emitter for Rest Level Client. It take [TypeSpec](https://github.com/microsoft/typespec) as input, transform it into RLCModel, then call rlc-common library to generate the RLC code.
|
|
4
|
+
|
|
5
|
+
On a high level, the entire Rest Level Client generation process would be:
|
|
6
|
+
|
|
7
|
+
TypeSpec Input -> TypeSpec Compiler -> TypeSpec Program -> Transform RLCModel -> TypeSpec RLC Common library to Generate Code
|
|
8
|
+
|
|
9
|
+
Within the Transform RLCModel, it has the following stages:
|
|
10
|
+
|
|
11
|
+
TypeSpec Program + User Options -> Transform RLCModel Paths -> Transform RLCModel Options -> Transform RLCModel Schemas -> Transform RLCModel Response and Parameter Types -> TypeSpec RLCCommon libraries to generate the code.
|
|
12
|
+
|
|
13
|
+
# How to use
|
|
14
|
+
|
|
15
|
+
## Prerequisite
|
|
16
|
+
|
|
17
|
+
Install [Node.js](https://nodejs.org/en/download/) 16 or above. (Verify by `node --version`)
|
|
18
|
+
|
|
19
|
+
Install [TypeSpec](https://github.com/microsoft/typespec) latest.
|
|
20
|
+
|
|
21
|
+
## Initialize TypeSpec Project
|
|
22
|
+
|
|
23
|
+
Follow [TypeSpec Getting Started](hhttps://github.com/microsoft/typespec#getting-started) to initialize your TypeSpec project.
|
|
24
|
+
|
|
25
|
+
Make sure `npx tsp compile .` runs correctly.
|
|
26
|
+
|
|
27
|
+
## Add typespec-ts
|
|
28
|
+
|
|
29
|
+
Make sure the version of [typespec-ts release](https://www.npmjs.com/package/@azure-tools/typespec-ts) depends on the same version of "@typespec/compiler" as in your TypeSpec project.
|
|
30
|
+
|
|
31
|
+
Modify `package.json`, add one line under `dependencies`:
|
|
32
|
+
|
|
33
|
+
```diff
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@typespec/compiler": "latest",
|
|
36
|
+
"@typespec/rest": "latest",
|
|
37
|
+
"@azure-tools/typespec-azure-core": "latest",
|
|
38
|
+
+ "@azure-tools/typespec-ts": "latest"
|
|
39
|
+
},
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Run `npm install` again to install `@azure-tools/typespec-ts`.
|
|
43
|
+
|
|
44
|
+
Modify (or create) `tspconfig.yaml`, add one line under `emit`:
|
|
45
|
+
|
|
46
|
+
```diff
|
|
47
|
+
emit:
|
|
48
|
+
+ - "@azure-tools/typespec-ts"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Modify tspconfig.yaml
|
|
52
|
+
|
|
53
|
+
One can further configure the SDK generated, using the emitter options on `@azure-tools/typespec-ts`.
|
|
54
|
+
|
|
55
|
+
```yaml
|
|
56
|
+
options:
|
|
57
|
+
"@azure-tools/typespec-ts":
|
|
58
|
+
packageDetails:
|
|
59
|
+
name: "@azure-rest/confidential-ledger"
|
|
60
|
+
description: "Confidential Ledger Service"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Generate Typescript
|
|
64
|
+
|
|
65
|
+
Same `npx tsp compile .` or `npx tsp compile . --outputPath=<target-folder>`.
|
|
66
|
+
|
|
67
|
+
If `outputPath` option is not provided, generated code will be under `cadl-output` folder.
|
|
68
|
+
|
|
69
|
+
## Emitter Options
|
|
70
|
+
|
|
71
|
+
### packageDetails
|
|
72
|
+
|
|
73
|
+
Provide the metadata for `package.json`, `README.md` and user-agent information. And it's highly recommanded to set up this detail for your package.
|
|
74
|
+
|
|
75
|
+
| Property | Description |
|
|
76
|
+
| ----------- | ------------------------------------------------------------------------------------------------ |
|
|
77
|
+
| name | the name of package.json file, usually start with `@azure-rest` if this is data-plane RLC client |
|
|
78
|
+
| description | description used in package.json file |
|
|
79
|
+
| version | detailed version for your released package, the default vaule is `1.0.0-beta.1` |
|
|
80
|
+
|
|
81
|
+
### title
|
|
82
|
+
|
|
83
|
+
Generally the codegen will leverage the title defined in `@service` decorator in TypeSpec to name our client. But if you'd like to override it you could config the `title` info.
|
|
84
|
+
|
|
85
|
+
```yaml
|
|
86
|
+
title: AnomalyDetectorRest
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### generateMetadata
|
|
90
|
+
|
|
91
|
+
To indicate if the codegen needs to generate metadata files which includes `package.json`, `README.md` and `tsconfig.json` etc.
|
|
92
|
+
|
|
93
|
+
By default we'll enable the option but if you'd like to disable this feature you could set it as `false`.
|
|
94
|
+
|
|
95
|
+
```yaml
|
|
96
|
+
generateMetadata: false
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### generateTest
|
|
100
|
+
|
|
101
|
+
To allow the codegen generating test sample files and updating testing configuration. And the default value is `true` and you could also turn it off as `false`.
|
|
102
|
+
|
|
103
|
+
### includeShortcuts
|
|
104
|
+
|
|
105
|
+
To allow the codegen generating shortcut methods in client definition. This is an experimental feature so we disable it by default. If you want to try it just turn it on.
|
|
106
|
+
|
|
107
|
+
```yaml
|
|
108
|
+
includeShortcuts: true
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### azureSdkForJs
|
|
112
|
+
|
|
113
|
+
This is used to indicate your project is generated in [azure-sdk-for-js](https://github.com/Azure/azure-sdk-for-js) repo or not. If your package is located in that repo we'll leverage `dev-tool` to accelerate our building and testing, however if not we'll remove the dependency for that tool.
|
|
114
|
+
|
|
115
|
+
Usually the released JS sdk will be put into azure-sdk-for-js so we enable this option by default.
|
|
116
|
+
|
|
117
|
+
### addCredentials
|
|
118
|
+
|
|
119
|
+
We support two types of authentication: Azure Key Credential(AzureKey) and Token credential(AADToken), any other will need to be handled manually.
|
|
120
|
+
|
|
121
|
+
There are two ways to set up our credential details
|
|
122
|
+
|
|
123
|
+
- To use `@useAuth` decorator in TypeSpec
|
|
124
|
+
- To config in yaml file
|
|
125
|
+
|
|
126
|
+
Please notice defining in TypeSpec is recommanded and also has higher priority than second one.
|
|
127
|
+
|
|
128
|
+
To enable credential in `tspconfig.yaml` and we need to provide more details to let codegen know types.
|
|
129
|
+
|
|
130
|
+
### credentialScopes
|
|
131
|
+
|
|
132
|
+
If we enable the option `addCredentials` and specify `credentialScopes` the details we would enable the AADToken authentication.
|
|
133
|
+
|
|
134
|
+
```yaml
|
|
135
|
+
addCredentials: true
|
|
136
|
+
credentialScopes: https://yourendpoint.azure.com/.default
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### credentialKeyHeaderName
|
|
140
|
+
|
|
141
|
+
If we enable the option `addCredentials` and specify `credentialKeyHeaderName` the details we would enable the AzureKey authentication.
|
|
142
|
+
|
|
143
|
+
```yaml
|
|
144
|
+
addCredentials: true
|
|
145
|
+
credentialKeyHeaderName: Your-Subscription-Key
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
# Contributing
|
|
149
|
+
|
|
150
|
+
If you want to contribute on this project read the [contrubuting document](./CONTRIBUTING.md) for more details.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContentBuilder } from "@azure-tools/rlc-common";
|
|
2
|
+
import { RLCModel } from "@azure-tools/rlc-common";
|
|
3
|
+
import { Program } from "@typespec/compiler";
|
|
4
|
+
export declare function emitModels(rlcModels: RLCModel, program: Program): Promise<void>;
|
|
5
|
+
export declare function emitContentByBuilder(program: Program, builderFnOrList: ContentBuilder | ContentBuilder[], rlcModels: RLCModel, emitterOutputDir?: string): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=emitUtil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitUtil.d.ts","sourceRoot":"","sources":["../../src/emitUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAQ,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAgB,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK3D,wBAAsB,UAAU,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,iBAWrE;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,eAAe,EAAE,cAAc,GAAG,cAAc,EAAE,EAClD,SAAS,EAAE,QAAQ,EACnB,gBAAgB,CAAC,EAAE,MAAM,iBAW1B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { buildSchemaTypes } from "@azure-tools/rlc-common";
|
|
2
|
+
import { dirname, join } from "path";
|
|
3
|
+
import { format } from "prettier";
|
|
4
|
+
import { prettierJSONOptions, prettierTypeScriptOptions } from "./lib.js";
|
|
5
|
+
export async function emitModels(rlcModels, program) {
|
|
6
|
+
const schemaOutput = buildSchemaTypes(rlcModels);
|
|
7
|
+
if (schemaOutput) {
|
|
8
|
+
const { inputModelFile, outputModelFile } = schemaOutput;
|
|
9
|
+
if (inputModelFile) {
|
|
10
|
+
await emitFile(inputModelFile, program);
|
|
11
|
+
}
|
|
12
|
+
if (outputModelFile) {
|
|
13
|
+
await emitFile(outputModelFile, program);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function emitContentByBuilder(program, builderFnOrList, rlcModels, emitterOutputDir) {
|
|
18
|
+
if (!Array.isArray(builderFnOrList)) {
|
|
19
|
+
builderFnOrList = [builderFnOrList];
|
|
20
|
+
}
|
|
21
|
+
for (const builderFn of builderFnOrList) {
|
|
22
|
+
const contentFile = builderFn(rlcModels);
|
|
23
|
+
if (contentFile) {
|
|
24
|
+
await emitFile(contentFile, program, emitterOutputDir);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function emitFile(file, program, emitterOutputDir) {
|
|
29
|
+
const host = program.host;
|
|
30
|
+
const filePath = join(emitterOutputDir !== null && emitterOutputDir !== void 0 ? emitterOutputDir : "", file.path);
|
|
31
|
+
const isJson = /\.json$/gi.test(filePath);
|
|
32
|
+
const isSourceCode = /\.(ts|js)$/gi.test(filePath);
|
|
33
|
+
const licenseHeader = `// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n`;
|
|
34
|
+
let prettierFileContent = file.content;
|
|
35
|
+
if (isSourceCode) {
|
|
36
|
+
prettierFileContent = `${licenseHeader.trimStart()}\n${prettierFileContent}`;
|
|
37
|
+
}
|
|
38
|
+
// Format the contents if necessary
|
|
39
|
+
if (isJson || isSourceCode) {
|
|
40
|
+
prettierFileContent = format(prettierFileContent, isJson ? prettierJSONOptions : prettierTypeScriptOptions);
|
|
41
|
+
}
|
|
42
|
+
await host.mkdirp(dirname(filePath));
|
|
43
|
+
await host.writeFile(filePath, prettierFileContent);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=emitUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitUtil.js","sourceRoot":"","sources":["../../src/emitUtil.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAE1E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,SAAmB,EAAE,OAAgB;IACpE,MAAM,YAAY,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;IACjD,IAAI,YAAY,EAAE;QAChB,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,YAAY,CAAC;QACzD,IAAI,cAAc,EAAE;YAClB,MAAM,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;SACzC;QACD,IAAI,eAAe,EAAE;YACnB,MAAM,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;SAC1C;KACF;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAAgB,EAChB,eAAkD,EAClD,SAAmB,EACnB,gBAAyB;IAEzB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE;QACnC,eAAe,GAAG,CAAC,eAAe,CAAC,CAAC;KACrC;IACD,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE;QACvC,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,WAAW,EAAE;YACf,MAAM,QAAQ,CAAC,WAAW,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;SACxD;KACF;AACH,CAAC;AAED,KAAK,UAAU,QAAQ,CACrB,IAAU,EACV,OAAgB,EAChB,gBAAyB;IAEzB,MAAM,IAAI,GAAiB,OAAO,CAAC,IAAI,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnD,MAAM,aAAa,GAAG,+EAA+E,CAAC;IACtG,IAAI,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC;IAEvC,IAAI,YAAY,EAAE;QAChB,mBAAmB,GAAG,GAAG,aAAa,CAAC,SAAS,EAAE,KAAK,mBAAmB,EAAE,CAAC;KAC9E;IACD,mCAAmC;IACnC,IAAI,MAAM,IAAI,YAAY,EAAE;QAC1B,mBAAmB,GAAG,MAAM,CAC1B,mBAAmB,EACnB,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,yBAAyB,CACzD,CAAC;KACH;IACD,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmC1D,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,iBAwDjD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import * as fsextra from "fs-extra";
|
|
4
|
+
import { buildClientDefinitions, buildResponseTypes, buildParameterTypes, buildIsUnexpectedHelper, buildClient, buildIndexFile, buildTopLevelIndex, buildRollupConfig, buildTsConfig, buildApiExtractorConfig, buildPackageFile, buildPollingHelper, buildPaginateHelper, buildEsLintConfig, buildKarmaConfigFile, buildEnvFile, buildEnvBrowserFile, buildRecordedClientFile, buildSampleTest, buildReadmeFile, buildSerializeHelper } from "@azure-tools/rlc-common";
|
|
5
|
+
import { transformRLCModel } from "./transform/transform.js";
|
|
6
|
+
import { emitContentByBuilder, emitModels } from "./emitUtil.js";
|
|
7
|
+
import { listClients, createDpgContext } from "@azure-tools/typespec-client-generator-core";
|
|
8
|
+
import * as path from "path";
|
|
9
|
+
export async function $onEmit(context) {
|
|
10
|
+
const program = context.program;
|
|
11
|
+
const options = context.options;
|
|
12
|
+
const dpgContext = createDpgContext(context);
|
|
13
|
+
const clients = listClients(dpgContext);
|
|
14
|
+
let count = -1;
|
|
15
|
+
for (const client of clients) {
|
|
16
|
+
count++;
|
|
17
|
+
const rlcModels = await transformRLCModel(program, options, client, context.emitterOutputDir, dpgContext);
|
|
18
|
+
clearSrcFolder(rlcModels, count);
|
|
19
|
+
await emitModels(rlcModels, program);
|
|
20
|
+
await emitContentByBuilder(program, buildClientDefinitions, rlcModels);
|
|
21
|
+
await emitContentByBuilder(program, buildResponseTypes, rlcModels);
|
|
22
|
+
await emitContentByBuilder(program, buildClient, rlcModels);
|
|
23
|
+
await emitContentByBuilder(program, buildParameterTypes, rlcModels);
|
|
24
|
+
await emitContentByBuilder(program, buildIsUnexpectedHelper, rlcModels);
|
|
25
|
+
await emitContentByBuilder(program, buildIndexFile, rlcModels);
|
|
26
|
+
await emitContentByBuilder(program, buildTopLevelIndex, rlcModels);
|
|
27
|
+
await emitContentByBuilder(program, buildPaginateHelper, rlcModels);
|
|
28
|
+
await emitContentByBuilder(program, buildPollingHelper, rlcModels);
|
|
29
|
+
// buildSerializeHelper
|
|
30
|
+
await emitContentByBuilder(program, buildSerializeHelper, rlcModels);
|
|
31
|
+
// build metadata relevant files
|
|
32
|
+
await emitContentByBuilder(program, [
|
|
33
|
+
buildEsLintConfig,
|
|
34
|
+
buildRollupConfig,
|
|
35
|
+
buildTsConfig,
|
|
36
|
+
buildApiExtractorConfig,
|
|
37
|
+
buildPackageFile,
|
|
38
|
+
buildReadmeFile
|
|
39
|
+
], rlcModels, context.emitterOutputDir);
|
|
40
|
+
// build test relevant files
|
|
41
|
+
await emitContentByBuilder(program, [
|
|
42
|
+
buildKarmaConfigFile,
|
|
43
|
+
buildEnvFile,
|
|
44
|
+
buildEnvBrowserFile,
|
|
45
|
+
buildRecordedClientFile,
|
|
46
|
+
buildSampleTest
|
|
47
|
+
], rlcModels, context.emitterOutputDir);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function clearSrcFolder(model, count) {
|
|
51
|
+
var _a;
|
|
52
|
+
const srcPath = model.srcPath;
|
|
53
|
+
fsextra.emptyDirSync(srcPath);
|
|
54
|
+
if (((_a = model === null || model === void 0 ? void 0 : model.options) === null || _a === void 0 ? void 0 : _a.multiClient) && count === 0) {
|
|
55
|
+
const folderPath = path.join(srcPath.substring(0, srcPath.indexOf(path.sep + "src") + 4));
|
|
56
|
+
fsextra.emptyDirSync(folderPath);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { JSONSchemaType } from "@typespec/compiler";
|
|
2
|
+
import { RLCOptions } from "@azure-tools/rlc-common";
|
|
3
|
+
import { Options } from "prettier";
|
|
4
|
+
export declare const RLCOptionsSchema: JSONSchemaType<RLCOptions>;
|
|
5
|
+
export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
6
|
+
"security-service-namespace": {
|
|
7
|
+
readonly default: "Cannot add security details to a namespace other than the service namespace.";
|
|
8
|
+
};
|
|
9
|
+
"more-than-one-service": {
|
|
10
|
+
readonly default: "Only support one service and more than one services are not allowed.";
|
|
11
|
+
};
|
|
12
|
+
"no-service-defined": {
|
|
13
|
+
readonly default: "No service defined and must have one and only one service defined.";
|
|
14
|
+
};
|
|
15
|
+
"resource-namespace": {
|
|
16
|
+
readonly default: "Resource goes on namespace";
|
|
17
|
+
};
|
|
18
|
+
"missing-path-param": {
|
|
19
|
+
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
20
|
+
};
|
|
21
|
+
"duplicate-body-types": {
|
|
22
|
+
readonly default: "Request has multiple body types";
|
|
23
|
+
};
|
|
24
|
+
"duplicate-header": {
|
|
25
|
+
readonly default: import("@typespec/compiler").CallableMessage<["header"]>;
|
|
26
|
+
};
|
|
27
|
+
"duplicate-example": {
|
|
28
|
+
readonly default: "Duplicate @example declarations on operation";
|
|
29
|
+
};
|
|
30
|
+
"invalid-schema": {
|
|
31
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
32
|
+
};
|
|
33
|
+
"union-null": {
|
|
34
|
+
readonly default: "Cannot have a union containing only null types.";
|
|
35
|
+
};
|
|
36
|
+
"union-unsupported": {
|
|
37
|
+
readonly default: "Unions cannot be emitted to OpenAPI v2 unless all options are literals of the same type.";
|
|
38
|
+
readonly null: "Unions containing multiple model types cannot be emitted to OpenAPI v2 unless the union is between one model type and 'null'.";
|
|
39
|
+
};
|
|
40
|
+
discriminator: {
|
|
41
|
+
readonly duplicate: import("@typespec/compiler").CallableMessage<["val", "model1", "model2"]>;
|
|
42
|
+
readonly missing: "The discriminator property is not defined in a variant of a discriminated union.";
|
|
43
|
+
readonly required: "the discriminator property must be a required property.";
|
|
44
|
+
readonly type: "the discriminator property must be type 'string'.";
|
|
45
|
+
};
|
|
46
|
+
"discriminator-value": {
|
|
47
|
+
readonly literal: "Each variant of a discriminated union should define the discriminator property with a string literal value.";
|
|
48
|
+
};
|
|
49
|
+
"invalid-default": {
|
|
50
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
51
|
+
};
|
|
52
|
+
"no-credential-scopes": {
|
|
53
|
+
readonly default: "Please provide credential scopes to ensure the token credential signature can be generated.";
|
|
54
|
+
};
|
|
55
|
+
}, RLCOptions>;
|
|
56
|
+
export declare const reportDiagnostic: <C extends "security-service-namespace" | "more-than-one-service" | "no-service-defined" | "resource-namespace" | "missing-path-param" | "duplicate-body-types" | "duplicate-header" | "duplicate-example" | "invalid-schema" | "union-null" | "union-unsupported" | "discriminator" | "discriminator-value" | "invalid-default" | "no-credential-scopes", M extends keyof {
|
|
57
|
+
"security-service-namespace": {
|
|
58
|
+
readonly default: "Cannot add security details to a namespace other than the service namespace.";
|
|
59
|
+
};
|
|
60
|
+
"more-than-one-service": {
|
|
61
|
+
readonly default: "Only support one service and more than one services are not allowed.";
|
|
62
|
+
};
|
|
63
|
+
"no-service-defined": {
|
|
64
|
+
readonly default: "No service defined and must have one and only one service defined.";
|
|
65
|
+
};
|
|
66
|
+
"resource-namespace": {
|
|
67
|
+
readonly default: "Resource goes on namespace";
|
|
68
|
+
};
|
|
69
|
+
"missing-path-param": {
|
|
70
|
+
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
71
|
+
};
|
|
72
|
+
"duplicate-body-types": {
|
|
73
|
+
readonly default: "Request has multiple body types";
|
|
74
|
+
};
|
|
75
|
+
"duplicate-header": {
|
|
76
|
+
readonly default: import("@typespec/compiler").CallableMessage<["header"]>;
|
|
77
|
+
};
|
|
78
|
+
"duplicate-example": {
|
|
79
|
+
readonly default: "Duplicate @example declarations on operation";
|
|
80
|
+
};
|
|
81
|
+
"invalid-schema": {
|
|
82
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
83
|
+
};
|
|
84
|
+
"union-null": {
|
|
85
|
+
readonly default: "Cannot have a union containing only null types.";
|
|
86
|
+
};
|
|
87
|
+
"union-unsupported": {
|
|
88
|
+
readonly default: "Unions cannot be emitted to OpenAPI v2 unless all options are literals of the same type.";
|
|
89
|
+
readonly null: "Unions containing multiple model types cannot be emitted to OpenAPI v2 unless the union is between one model type and 'null'.";
|
|
90
|
+
};
|
|
91
|
+
discriminator: {
|
|
92
|
+
readonly duplicate: import("@typespec/compiler").CallableMessage<["val", "model1", "model2"]>;
|
|
93
|
+
readonly missing: "The discriminator property is not defined in a variant of a discriminated union.";
|
|
94
|
+
readonly required: "the discriminator property must be a required property.";
|
|
95
|
+
readonly type: "the discriminator property must be type 'string'.";
|
|
96
|
+
};
|
|
97
|
+
"discriminator-value": {
|
|
98
|
+
readonly literal: "Each variant of a discriminated union should define the discriminator property with a string literal value.";
|
|
99
|
+
};
|
|
100
|
+
"invalid-default": {
|
|
101
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
102
|
+
};
|
|
103
|
+
"no-credential-scopes": {
|
|
104
|
+
readonly default: "Please provide credential scopes to ensure the token credential signature can be generated.";
|
|
105
|
+
};
|
|
106
|
+
}[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
|
|
107
|
+
"security-service-namespace": {
|
|
108
|
+
readonly default: "Cannot add security details to a namespace other than the service namespace.";
|
|
109
|
+
};
|
|
110
|
+
"more-than-one-service": {
|
|
111
|
+
readonly default: "Only support one service and more than one services are not allowed.";
|
|
112
|
+
};
|
|
113
|
+
"no-service-defined": {
|
|
114
|
+
readonly default: "No service defined and must have one and only one service defined.";
|
|
115
|
+
};
|
|
116
|
+
"resource-namespace": {
|
|
117
|
+
readonly default: "Resource goes on namespace";
|
|
118
|
+
};
|
|
119
|
+
"missing-path-param": {
|
|
120
|
+
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
121
|
+
};
|
|
122
|
+
"duplicate-body-types": {
|
|
123
|
+
readonly default: "Request has multiple body types";
|
|
124
|
+
};
|
|
125
|
+
"duplicate-header": {
|
|
126
|
+
readonly default: import("@typespec/compiler").CallableMessage<["header"]>;
|
|
127
|
+
};
|
|
128
|
+
"duplicate-example": {
|
|
129
|
+
readonly default: "Duplicate @example declarations on operation";
|
|
130
|
+
};
|
|
131
|
+
"invalid-schema": {
|
|
132
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
133
|
+
};
|
|
134
|
+
"union-null": {
|
|
135
|
+
readonly default: "Cannot have a union containing only null types.";
|
|
136
|
+
};
|
|
137
|
+
"union-unsupported": {
|
|
138
|
+
readonly default: "Unions cannot be emitted to OpenAPI v2 unless all options are literals of the same type.";
|
|
139
|
+
readonly null: "Unions containing multiple model types cannot be emitted to OpenAPI v2 unless the union is between one model type and 'null'.";
|
|
140
|
+
};
|
|
141
|
+
discriminator: {
|
|
142
|
+
readonly duplicate: import("@typespec/compiler").CallableMessage<["val", "model1", "model2"]>;
|
|
143
|
+
readonly missing: "The discriminator property is not defined in a variant of a discriminated union.";
|
|
144
|
+
readonly required: "the discriminator property must be a required property.";
|
|
145
|
+
readonly type: "the discriminator property must be type 'string'.";
|
|
146
|
+
};
|
|
147
|
+
"discriminator-value": {
|
|
148
|
+
readonly literal: "Each variant of a discriminated union should define the discriminator property with a string literal value.";
|
|
149
|
+
};
|
|
150
|
+
"invalid-default": {
|
|
151
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
152
|
+
};
|
|
153
|
+
"no-credential-scopes": {
|
|
154
|
+
readonly default: "Please provide credential scopes to ensure the token credential signature can be generated.";
|
|
155
|
+
};
|
|
156
|
+
}, C, M>) => void;
|
|
157
|
+
export declare const prettierTypeScriptOptions: Options;
|
|
158
|
+
export declare const prettierJSONOptions: Options;
|
|
159
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,cAAc,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,UAAU,CAgEvD,CAAC;AAgHF,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA4B,CAAC;AAC9C,eAAO,MAAQ,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAS,CAAC;AAEzC,eAAO,MAAM,yBAAyB,EAAE,OASvC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,OAKjC,CAAC"}
|