@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
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DpgContext,
|
|
3
|
+
listClients
|
|
4
|
+
} from "@azure-tools/typespec-client-generator-core";
|
|
5
|
+
import {
|
|
6
|
+
NameType,
|
|
7
|
+
normalizeName,
|
|
8
|
+
PackageDetails,
|
|
9
|
+
RLCOptions,
|
|
10
|
+
ServiceInfo
|
|
11
|
+
} from "@azure-tools/rlc-common";
|
|
12
|
+
import { getDoc, NoTarget, Program } from "@typespec/compiler";
|
|
13
|
+
import { getAuthentication } from "@typespec/http";
|
|
14
|
+
import { getDefaultService } from "./transform.js";
|
|
15
|
+
import { reportDiagnostic } from "../lib.js";
|
|
16
|
+
|
|
17
|
+
export function transformRLCOptions(
|
|
18
|
+
program: Program,
|
|
19
|
+
emitterOptions: RLCOptions,
|
|
20
|
+
emitterOutputDir: string,
|
|
21
|
+
dpgContext: DpgContext
|
|
22
|
+
): RLCOptions {
|
|
23
|
+
// Extract the options from emitter option
|
|
24
|
+
const options = extractRLCOptions(program, emitterOptions, emitterOutputDir);
|
|
25
|
+
const batch = listClients(dpgContext);
|
|
26
|
+
options.batch = batch;
|
|
27
|
+
return options;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function extractRLCOptions(
|
|
31
|
+
program: Program,
|
|
32
|
+
emitterOptions: RLCOptions,
|
|
33
|
+
emitterOutputDir: string
|
|
34
|
+
): RLCOptions {
|
|
35
|
+
const includeShortcuts = getIncludeShortcuts(emitterOptions);
|
|
36
|
+
const packageDetails = getPackageDetails(program, emitterOptions);
|
|
37
|
+
const serviceInfo = getServiceInfo(program);
|
|
38
|
+
const azureSdkForJs = getAzureSdkForJs(emitterOptions);
|
|
39
|
+
const generateMetadata = getGenerateMetadata(emitterOptions);
|
|
40
|
+
const generateTest = getGenerateTest(emitterOptions);
|
|
41
|
+
const credentialInfo = getCredentialInfo(program, emitterOptions);
|
|
42
|
+
const azureOutputDirectory = getAzureOutputDirectory(emitterOutputDir);
|
|
43
|
+
return {
|
|
44
|
+
...emitterOptions,
|
|
45
|
+
...credentialInfo,
|
|
46
|
+
includeShortcuts,
|
|
47
|
+
packageDetails,
|
|
48
|
+
generateMetadata,
|
|
49
|
+
generateTest,
|
|
50
|
+
azureSdkForJs,
|
|
51
|
+
serviceInfo,
|
|
52
|
+
azureOutputDirectory,
|
|
53
|
+
sourceFrom: "Cadl"
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function processAuth(program: Program) {
|
|
58
|
+
const serviceNs = getDefaultService(program)?.type;
|
|
59
|
+
if (!serviceNs) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
const authorization = getAuthentication(program, serviceNs);
|
|
63
|
+
if (!authorization || !authorization.options) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const securityInfo: RLCOptions = {};
|
|
67
|
+
for (const option of authorization.options) {
|
|
68
|
+
for (const auth of option.schemes) {
|
|
69
|
+
switch (auth.type) {
|
|
70
|
+
case "http":
|
|
71
|
+
break;
|
|
72
|
+
case "apiKey":
|
|
73
|
+
if (auth.in === "cookie") {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
securityInfo.addCredentials = true;
|
|
77
|
+
securityInfo.credentialKeyHeaderName = auth.name;
|
|
78
|
+
break;
|
|
79
|
+
case "oauth2": {
|
|
80
|
+
const flow = auth.flows[0];
|
|
81
|
+
if (flow === undefined || !flow.scopes) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
securityInfo.addCredentials = true;
|
|
85
|
+
if (!securityInfo.credentialScopes) {
|
|
86
|
+
securityInfo.credentialScopes = [];
|
|
87
|
+
}
|
|
88
|
+
if (flow.scopes.length === 0) {
|
|
89
|
+
reportDiagnostic(program, {
|
|
90
|
+
code: "no-credential-scopes",
|
|
91
|
+
target: NoTarget
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
securityInfo.credentialScopes.push(
|
|
95
|
+
...flow.scopes.map((item) => {
|
|
96
|
+
return item.value;
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
default:
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return securityInfo;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function getIncludeShortcuts(emitterOptions: RLCOptions) {
|
|
110
|
+
return Boolean(emitterOptions.includeShortcuts);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function getPackageDetails(
|
|
114
|
+
program: Program,
|
|
115
|
+
emitterOptions: RLCOptions
|
|
116
|
+
): PackageDetails {
|
|
117
|
+
const packageDetails: PackageDetails = {
|
|
118
|
+
...emitterOptions.packageDetails,
|
|
119
|
+
name:
|
|
120
|
+
emitterOptions.packageDetails?.name ??
|
|
121
|
+
normalizeName(
|
|
122
|
+
emitterOptions?.title ?? getDefaultService(program)?.title ?? "",
|
|
123
|
+
NameType.Class
|
|
124
|
+
),
|
|
125
|
+
version: emitterOptions.packageDetails?.version ?? "1.0.0-beta.1"
|
|
126
|
+
};
|
|
127
|
+
if (emitterOptions.packageDetails?.name) {
|
|
128
|
+
const nameParts = emitterOptions.packageDetails?.name.split("/");
|
|
129
|
+
if (nameParts.length === 2) {
|
|
130
|
+
packageDetails.nameWithoutScope = nameParts[1];
|
|
131
|
+
packageDetails.scopeName = nameParts[0]?.replace("@", "");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return packageDetails;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function getServiceInfo(program: Program): ServiceInfo {
|
|
138
|
+
const defaultService = getDefaultService(program);
|
|
139
|
+
return {
|
|
140
|
+
title: defaultService?.title,
|
|
141
|
+
description: defaultService && getDoc(program, defaultService.type)
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function getAzureSdkForJs(emitterOptions: RLCOptions) {
|
|
146
|
+
return emitterOptions.azureSdkForJs === undefined ||
|
|
147
|
+
emitterOptions.azureSdkForJs === null
|
|
148
|
+
? true
|
|
149
|
+
: Boolean(emitterOptions.azureSdkForJs);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function getGenerateMetadata(emitterOptions: RLCOptions) {
|
|
153
|
+
return emitterOptions.generateMetadata === undefined ||
|
|
154
|
+
emitterOptions.generateMetadata === null
|
|
155
|
+
? true
|
|
156
|
+
: Boolean(emitterOptions.generateMetadata);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function getGenerateTest(emitterOptions: RLCOptions) {
|
|
160
|
+
return emitterOptions.generateTest === undefined ||
|
|
161
|
+
emitterOptions.generateTest === null
|
|
162
|
+
? true
|
|
163
|
+
: Boolean(emitterOptions.generateTest);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function getCredentialInfo(
|
|
167
|
+
program: Program,
|
|
168
|
+
emitterOptions: RLCOptions
|
|
169
|
+
) {
|
|
170
|
+
const securityInfo = processAuth(program);
|
|
171
|
+
const addCredentials =
|
|
172
|
+
!securityInfo && emitterOptions.addCredentials === false
|
|
173
|
+
? false
|
|
174
|
+
: securityInfo
|
|
175
|
+
? securityInfo.addCredentials
|
|
176
|
+
: emitterOptions.addCredentials;
|
|
177
|
+
const credentialScopes =
|
|
178
|
+
securityInfo && securityInfo.credentialScopes
|
|
179
|
+
? securityInfo.credentialScopes
|
|
180
|
+
: emitterOptions.credentialScopes;
|
|
181
|
+
const credentialKeyHeaderName =
|
|
182
|
+
securityInfo && securityInfo.credentialKeyHeaderName
|
|
183
|
+
? securityInfo.credentialKeyHeaderName
|
|
184
|
+
: emitterOptions.credentialKeyHeaderName;
|
|
185
|
+
return {
|
|
186
|
+
addCredentials,
|
|
187
|
+
credentialScopes,
|
|
188
|
+
credentialKeyHeaderName
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function getAzureOutputDirectory(emitterOutputDir: string): string | undefined {
|
|
193
|
+
const sdkFolder = emitterOutputDir;
|
|
194
|
+
const sdkReletivePath = sdkFolder
|
|
195
|
+
?.replace(/\/$/, "")
|
|
196
|
+
.split("/")
|
|
197
|
+
.slice(-3)
|
|
198
|
+
.join("/");
|
|
199
|
+
return sdkReletivePath?.substring(0, 3) === "sdk"
|
|
200
|
+
? sdkReletivePath
|
|
201
|
+
: undefined;
|
|
202
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface CadlRanchConfig {
|
|
2
|
+
outputPath: string;
|
|
3
|
+
inputPath: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const cadls: CadlRanchConfig[] = [
|
|
7
|
+
{
|
|
8
|
+
outputPath: "arrays/itemTypes",
|
|
9
|
+
inputPath: "arrays/item-types"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
outputPath: "authentication/apiKey",
|
|
13
|
+
inputPath: "authentication/api-key"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
outputPath: "authentication/oauth2",
|
|
17
|
+
inputPath: "authentication/oauth2"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
outputPath: "authentication/union",
|
|
21
|
+
inputPath: "authentication/union"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
outputPath: "dictionary",
|
|
25
|
+
inputPath: "dictionary"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
outputPath: "enums/extensible",
|
|
29
|
+
inputPath: "enums/extensible"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
outputPath: "enums/fixed",
|
|
33
|
+
inputPath: "enums/fixed"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
outputPath: "hello",
|
|
37
|
+
inputPath: "hello"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
outputPath: "lro/lroBasic",
|
|
41
|
+
inputPath: "lro/lro-basic"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
outputPath: "models/inheritance",
|
|
45
|
+
inputPath: "models/inheritance"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
outputPath: "models/propertyOptional",
|
|
49
|
+
inputPath: "models/property-optional"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
outputPath: "models/propertyTypes",
|
|
53
|
+
inputPath: "models/property-types"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
outputPath: "models/visibility",
|
|
57
|
+
inputPath: "models/visibility"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
outputPath: "models/usage",
|
|
61
|
+
inputPath: "models/usage"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
outputPath: "resiliency/devDriven",
|
|
65
|
+
inputPath: "resiliency/dev-driven"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
outputPath: "resiliency/srvDriven1",
|
|
69
|
+
inputPath: "resiliency/srv-driven-1"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
outputPath: "resiliency/srvDriven2",
|
|
73
|
+
inputPath: "resiliency/srv-driven-2"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
outputPath: "specialWords",
|
|
77
|
+
inputPath: "special-words"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
outputPath: "unions",
|
|
81
|
+
inputPath: "unions"
|
|
82
|
+
}
|
|
83
|
+
];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { spawn, ChildProcess } from "child_process";
|
|
2
|
+
|
|
3
|
+
const onExit = (childProcess: ChildProcess): Promise<string[]> => {
|
|
4
|
+
let messages: string[] = [];
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
if (childProcess.stdout) {
|
|
7
|
+
childProcess.stdout.on("data", (message) => messages.push(message));
|
|
8
|
+
}
|
|
9
|
+
childProcess.once("exit", (code: number) => {
|
|
10
|
+
if (code === 0) {
|
|
11
|
+
resolve(messages);
|
|
12
|
+
}
|
|
13
|
+
reject(new Error(`Exit with code: ${code}`));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
childProcess.once("error", (error: Error) => {
|
|
17
|
+
reject(error);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
async function check_tree() {
|
|
23
|
+
await onExit(
|
|
24
|
+
spawn("git", ["add", "-A"], {
|
|
25
|
+
stdio: [process.stdin, process.stdout, process.stderr]
|
|
26
|
+
})
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// If there is any output from this command it means that
|
|
30
|
+
// there are non committed changes so we need to handle
|
|
31
|
+
// stout
|
|
32
|
+
const messages = await onExit(
|
|
33
|
+
spawn("git", ["diff", "--staged", "--compact-summary"])
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (messages.length !== 0) {
|
|
37
|
+
// Once we have verified that there are non committed changes
|
|
38
|
+
// run git diff again, this time forwarding the stout to present
|
|
39
|
+
// a readable hint to the user
|
|
40
|
+
await onExit(
|
|
41
|
+
spawn("git", ["diff", "--staged", "--compact-summary"], {
|
|
42
|
+
stdio: [process.stdin, process.stdout, process.stderr]
|
|
43
|
+
})
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
throw new Error(
|
|
47
|
+
"Git tree is dirty, regenerate all test cadl files and make sure that there are no un-intended changes"
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
check_tree().catch((error) => {
|
|
53
|
+
console.error(error);
|
|
54
|
+
process.exit(-1);
|
|
55
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChildProcess } from "child_process";
|
|
2
|
+
|
|
3
|
+
export const onExit = (childProcess: ChildProcess) => {
|
|
4
|
+
return new Promise<void>((resolve, reject) => {
|
|
5
|
+
childProcess.once("exit", (code: number) => {
|
|
6
|
+
if (code === 0) {
|
|
7
|
+
resolve();
|
|
8
|
+
}
|
|
9
|
+
reject(new Error(`Exit with code: ${code}`));
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
childProcess.once("error", (error: Error) => {
|
|
13
|
+
reject(error);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { cadls } from "./cadl-ranch-list.js";
|
|
2
|
+
import { runTypespec } from "./run.js";
|
|
3
|
+
import pkg from "chalk";
|
|
4
|
+
const { bold } = pkg;
|
|
5
|
+
const logError = (str: string) => console.error(bold.red(str));
|
|
6
|
+
|
|
7
|
+
async function generateCadls() {
|
|
8
|
+
const list = cadls;
|
|
9
|
+
for (const cadl of list) {
|
|
10
|
+
await runTypespec(cadl);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async function main() {
|
|
15
|
+
await generateCadls();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main().catch((error) => {
|
|
19
|
+
logError(error);
|
|
20
|
+
process.exit(-1);
|
|
21
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { execSync } from "child_process";
|
|
2
|
+
import { dirname, join as joinPath } from "path";
|
|
3
|
+
import { fileURLToPath } from "url";
|
|
4
|
+
import { CadlRanchConfig } from "./cadl-ranch-list.js";
|
|
5
|
+
|
|
6
|
+
export async function runTypespec(config: CadlRanchConfig) {
|
|
7
|
+
const targetFolder = config.outputPath,
|
|
8
|
+
sourceTypespec = config.inputPath;
|
|
9
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
10
|
+
const __dirname = dirname(__filename);
|
|
11
|
+
console.log(`=== Start ${targetFolder} ===`);
|
|
12
|
+
|
|
13
|
+
const typespecPath = joinPath(
|
|
14
|
+
`${__dirname}`,
|
|
15
|
+
"..",
|
|
16
|
+
"..",
|
|
17
|
+
`./node_modules/@azure-tools/cadl-ranch-specs/http/${sourceTypespec}`
|
|
18
|
+
);
|
|
19
|
+
// const emitterPath = joinPath(
|
|
20
|
+
// `${__dirname}`,
|
|
21
|
+
// "..",
|
|
22
|
+
// "..",
|
|
23
|
+
// "./dist/src/index.js"
|
|
24
|
+
// );
|
|
25
|
+
const outputPath = joinPath(
|
|
26
|
+
`${__dirname}`,
|
|
27
|
+
"..",
|
|
28
|
+
`./integration/generated/${targetFolder}`
|
|
29
|
+
);
|
|
30
|
+
const typespecCommand = `cd ${outputPath} && tsp`;
|
|
31
|
+
const commandArguments: string[] = [
|
|
32
|
+
"compile",
|
|
33
|
+
`${typespecPath}`,
|
|
34
|
+
`--output-path=.`
|
|
35
|
+
];
|
|
36
|
+
const command = `${typespecCommand} ${commandArguments.join(" ")}`;
|
|
37
|
+
console.log(command);
|
|
38
|
+
const result = execSync(command);
|
|
39
|
+
console.log(`=== End ${targetFolder} ===`);
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import ArrayItemTypesClientFactory, {
|
|
2
|
+
ArrayItemTypesClient
|
|
3
|
+
} from "./generated/arrays/itemTypes/src/index.js";
|
|
4
|
+
import { assert } from "chai";
|
|
5
|
+
import { matrix } from "../util/matrix.js";
|
|
6
|
+
|
|
7
|
+
interface TypeDetail {
|
|
8
|
+
type: string;
|
|
9
|
+
defaultValue: any;
|
|
10
|
+
convertedToFn?: (_: any) => any;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const testedTypes: TypeDetail[] = [
|
|
14
|
+
{
|
|
15
|
+
type: "int32",
|
|
16
|
+
defaultValue: [1, 2]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "int64",
|
|
20
|
+
defaultValue: [Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER]
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "boolean",
|
|
24
|
+
defaultValue: [true, false]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "string",
|
|
28
|
+
defaultValue: ["hello", ""]
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "float32",
|
|
32
|
+
defaultValue: [42.42]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "datetime",
|
|
36
|
+
defaultValue: ["2022-08-26T18:38:00Z"]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "duration",
|
|
40
|
+
defaultValue: ["P123DT22H14M12.011S"]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "unknown",
|
|
44
|
+
defaultValue: [1, "hello", null]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "model",
|
|
48
|
+
defaultValue: [{ property: "hello" }, { property: "world" }]
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
describe("Array Item-Types Client", () => {
|
|
52
|
+
let client: ArrayItemTypesClient;
|
|
53
|
+
|
|
54
|
+
beforeEach(() => {
|
|
55
|
+
client = ArrayItemTypesClientFactory({
|
|
56
|
+
allowInsecureConnection: true
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
matrix([testedTypes], async (params: TypeDetail) => {
|
|
61
|
+
it(`should get a ${params.type} value`, async () => {
|
|
62
|
+
try {
|
|
63
|
+
const result = await client
|
|
64
|
+
.path(`/arrays/item-types/${params.type}` as any)
|
|
65
|
+
.get();
|
|
66
|
+
assert.strictEqual(result.status, "200");
|
|
67
|
+
console.log("debug", result.body, params.defaultValue);
|
|
68
|
+
assert.deepEqual(result.body, params.defaultValue);
|
|
69
|
+
} catch (err) {
|
|
70
|
+
assert.fail(err as string);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it(`should put a ${params.type} value`, async () => {
|
|
75
|
+
try {
|
|
76
|
+
let property;
|
|
77
|
+
if (params.convertedToFn) {
|
|
78
|
+
property = params.convertedToFn(params.defaultValue);
|
|
79
|
+
} else {
|
|
80
|
+
property = params.defaultValue;
|
|
81
|
+
}
|
|
82
|
+
const result = await client
|
|
83
|
+
.path(`/arrays/item-types/${params.type}` as any)
|
|
84
|
+
.put({
|
|
85
|
+
body: property
|
|
86
|
+
});
|
|
87
|
+
assert.strictEqual(result.status, "204");
|
|
88
|
+
} catch (err) {
|
|
89
|
+
assert.fail(err as string);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import ApiKeyClientFactory, {
|
|
2
|
+
AuthApiKeyClient
|
|
3
|
+
} from "./generated/authentication/apiKey/src/index.js";
|
|
4
|
+
import { assert } from "chai";
|
|
5
|
+
describe("AuthApiKeyClient Rest Client", () => {
|
|
6
|
+
let client: AuthApiKeyClient;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
client = ApiKeyClientFactory(
|
|
10
|
+
{
|
|
11
|
+
key: "valid-key"
|
|
12
|
+
},
|
|
13
|
+
{ allowInsecureConnection: true }
|
|
14
|
+
);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should return 204 when the apiKey is valid", async () => {
|
|
18
|
+
try {
|
|
19
|
+
const result = await client.path("/authentication/api-key/valid").get();
|
|
20
|
+
assert.strictEqual(result.status, "204");
|
|
21
|
+
} catch (err) {
|
|
22
|
+
console.log(err);
|
|
23
|
+
assert.fail(err as string);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should return 403 when the apiKey is invalid", async () => {
|
|
28
|
+
try {
|
|
29
|
+
const result = await client.path("/authentication/api-key/invalid").get();
|
|
30
|
+
assert.strictEqual(result.status, "403");
|
|
31
|
+
if (result.status === "403") {
|
|
32
|
+
assert.strictEqual(result.body.error, "invalid-api-key");
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
assert.fail(err as string);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Outh2ClientFactory, {
|
|
2
|
+
AuthOauth2Client
|
|
3
|
+
} from "./generated/authentication/oauth2/src/index.js";
|
|
4
|
+
import { assert } from "chai";
|
|
5
|
+
import {
|
|
6
|
+
bearerTokenAuthenticationPolicyName,
|
|
7
|
+
PipelinePolicy
|
|
8
|
+
} from "@azure/core-rest-pipeline";
|
|
9
|
+
import { customBearerTokenAuthenticationPolicy } from "../util/customBearerTokenTestingPolicy.js";
|
|
10
|
+
|
|
11
|
+
describe("AuthOauth2Client Rest Client", () => {
|
|
12
|
+
let client: AuthOauth2Client;
|
|
13
|
+
let policy: PipelinePolicy;
|
|
14
|
+
const defaultScope = "https://security.microsoft.com/.default";
|
|
15
|
+
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
client = Outh2ClientFactory(
|
|
18
|
+
{
|
|
19
|
+
getToken: async () => Promise.resolve(null)
|
|
20
|
+
},
|
|
21
|
+
{ allowInsecureConnection: true }
|
|
22
|
+
);
|
|
23
|
+
policy = customBearerTokenAuthenticationPolicy({
|
|
24
|
+
scopes: defaultScope,
|
|
25
|
+
credential: {
|
|
26
|
+
getToken: async () => {
|
|
27
|
+
return {
|
|
28
|
+
token: defaultScope,
|
|
29
|
+
expiresOnTimestamp: Date.now()
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
client.pipeline.removePolicy({
|
|
35
|
+
name: bearerTokenAuthenticationPolicyName
|
|
36
|
+
});
|
|
37
|
+
client.pipeline.addPolicy(policy);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("should return 204 when the token is valid", async () => {
|
|
41
|
+
try {
|
|
42
|
+
const result = await client.path("/authentication/oauth2/valid").get();
|
|
43
|
+
assert.strictEqual(result.status, "204");
|
|
44
|
+
} catch (err) {
|
|
45
|
+
console.log(err);
|
|
46
|
+
assert.fail(err as string);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("should return 403 when the token is invalid", async () => {
|
|
51
|
+
try {
|
|
52
|
+
client.pipeline.removePolicy({
|
|
53
|
+
name: bearerTokenAuthenticationPolicyName
|
|
54
|
+
});
|
|
55
|
+
const result = await client.path("/authentication/oauth2/invalid").get();
|
|
56
|
+
assert.strictEqual(result.status, "403");
|
|
57
|
+
if (result.status === "403") {
|
|
58
|
+
assert.strictEqual(result.body.error, "invalid-grant");
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.log(err);
|
|
62
|
+
assert.fail(err as string);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import {
|
|
3
|
+
bearerTokenAuthenticationPolicyName,
|
|
4
|
+
PipelinePolicy
|
|
5
|
+
} from "@azure/core-rest-pipeline";
|
|
6
|
+
import { customBearerTokenAuthenticationPolicy } from "../util/customBearerTokenTestingPolicy.js";
|
|
7
|
+
import AuthUnionClientFactory, {
|
|
8
|
+
AuthUnionClient
|
|
9
|
+
} from "./generated/authentication/union/src/index.js";
|
|
10
|
+
|
|
11
|
+
describe("AuthUnionClient Rest Client", () => {
|
|
12
|
+
let client: AuthUnionClient;
|
|
13
|
+
let policy: PipelinePolicy;
|
|
14
|
+
const defaultScope = "https://security.microsoft.com/.default";
|
|
15
|
+
|
|
16
|
+
function prepareToken() {
|
|
17
|
+
client = AuthUnionClientFactory(
|
|
18
|
+
{
|
|
19
|
+
getToken: async () => Promise.resolve(null)
|
|
20
|
+
},
|
|
21
|
+
{ allowInsecureConnection: true }
|
|
22
|
+
);
|
|
23
|
+
policy = customBearerTokenAuthenticationPolicy({
|
|
24
|
+
scopes: defaultScope,
|
|
25
|
+
credential: {
|
|
26
|
+
getToken: async () => {
|
|
27
|
+
return {
|
|
28
|
+
token: defaultScope,
|
|
29
|
+
expiresOnTimestamp: Date.now()
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
client.pipeline.removePolicy({
|
|
35
|
+
name: bearerTokenAuthenticationPolicyName
|
|
36
|
+
});
|
|
37
|
+
client.pipeline.addPolicy(policy);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function prepareKey() {
|
|
41
|
+
client = AuthUnionClientFactory(
|
|
42
|
+
{
|
|
43
|
+
key: "valid-key"
|
|
44
|
+
},
|
|
45
|
+
{ allowInsecureConnection: true }
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
it("should return 204 when the token is valid", async () => {
|
|
50
|
+
prepareToken();
|
|
51
|
+
try {
|
|
52
|
+
const result = await client
|
|
53
|
+
.path("/authentication/union/validtoken")
|
|
54
|
+
.get();
|
|
55
|
+
assert.strictEqual(result.status, "204");
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.log(err);
|
|
58
|
+
assert.fail(err as string);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should return 204 when the key is valid", async () => {
|
|
63
|
+
prepareKey();
|
|
64
|
+
try {
|
|
65
|
+
const result = await client.path("/authentication/union/validkey").get();
|
|
66
|
+
assert.strictEqual(result.status, "204");
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.log(err);
|
|
69
|
+
assert.fail(err as string);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|