@azure-tools/typespec-ts 0.11.0-alpha.20230413.3
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 +392 -0
- package/.rush/temp/shrinkwrap-deps.json +472 -0
- package/CHANGELOG.md +65 -0
- package/CONTRIBUTING.md +137 -0
- package/README.md +150 -0
- package/dist/src/casingUtils.d.ts +4 -0
- package/dist/src/casingUtils.d.ts.map +1 -0
- package/dist/src/casingUtils.js +39 -0
- package/dist/src/casingUtils.js.map +1 -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 +90 -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 +190 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/modelUtils.d.ts +33 -0
- package/dist/src/modelUtils.d.ts.map +1 -0
- package/dist/src/modelUtils.js +900 -0
- package/dist/src/modelUtils.js.map +1 -0
- package/dist/src/modular/buildApiIndex.d.ts +3 -0
- package/dist/src/modular/buildApiIndex.d.ts.map +1 -0
- package/dist/src/modular/buildApiIndex.js +12 -0
- package/dist/src/modular/buildApiIndex.js.map +1 -0
- package/dist/src/modular/buildClassicalClient.d.ts +4 -0
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -0
- package/dist/src/modular/buildClassicalClient.js +116 -0
- package/dist/src/modular/buildClassicalClient.js.map +1 -0
- package/dist/src/modular/buildClientContext.d.ts +7 -0
- package/dist/src/modular/buildClientContext.d.ts.map +1 -0
- package/dist/src/modular/buildClientContext.js +65 -0
- package/dist/src/modular/buildClientContext.js.map +1 -0
- package/dist/src/modular/buildCodeModel.d.ts +14 -0
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -0
- package/dist/src/modular/buildCodeModel.js +1106 -0
- package/dist/src/modular/buildCodeModel.js.map +1 -0
- package/dist/src/modular/buildOperations.d.ts +13 -0
- package/dist/src/modular/buildOperations.d.ts.map +1 -0
- package/dist/src/modular/buildOperations.js +68 -0
- package/dist/src/modular/buildOperations.js.map +1 -0
- package/dist/src/modular/buildProjectFiles.d.ts +5 -0
- package/dist/src/modular/buildProjectFiles.d.ts.map +1 -0
- package/dist/src/modular/buildProjectFiles.js +188 -0
- package/dist/src/modular/buildProjectFiles.js.map +1 -0
- package/dist/src/modular/buildRootIndex.d.ts +4 -0
- package/dist/src/modular/buildRootIndex.d.ts.map +1 -0
- package/dist/src/modular/buildRootIndex.js +49 -0
- package/dist/src/modular/buildRootIndex.js.map +1 -0
- package/dist/src/modular/buildSharedTypes.d.ts +6 -0
- package/dist/src/modular/buildSharedTypes.d.ts.map +1 -0
- package/dist/src/modular/buildSharedTypes.js +33 -0
- package/dist/src/modular/buildSharedTypes.js.map +1 -0
- package/dist/src/modular/emitModels.d.ts +7 -0
- package/dist/src/modular/emitModels.d.ts.map +1 -0
- package/dist/src/modular/emitModels.js +63 -0
- package/dist/src/modular/emitModels.js.map +1 -0
- package/dist/src/modular/helpers/clientHelpers.d.ts +4 -0
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/clientHelpers.js +31 -0
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -0
- package/dist/src/modular/helpers/credentialHelpers.d.ts +7 -0
- package/dist/src/modular/helpers/credentialHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/credentialHelpers.js +22 -0
- package/dist/src/modular/helpers/credentialHelpers.js.map +1 -0
- package/dist/src/modular/helpers/namingHelpers.d.ts +3 -0
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/namingHelpers.js +4 -0
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -0
- package/dist/src/modular/helpers/operationHelpers.d.ts +8 -0
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/operationHelpers.js +191 -0
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -0
- package/dist/src/modular/helpers/parameterHelpers.d.ts +3 -0
- package/dist/src/modular/helpers/parameterHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/parameterHelpers.js +11 -0
- package/dist/src/modular/helpers/parameterHelpers.js.map +1 -0
- package/dist/src/modular/helpers/typeHelpers.d.ts +16 -0
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/typeHelpers.js +71 -0
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -0
- package/dist/src/modular/interfaces.d.ts +10 -0
- package/dist/src/modular/interfaces.d.ts.map +1 -0
- package/dist/src/modular/interfaces.js +2 -0
- package/dist/src/modular/interfaces.js.map +1 -0
- package/dist/src/modular/modularCodeModel.d.ts +120 -0
- package/dist/src/modular/modularCodeModel.d.ts.map +1 -0
- package/dist/src/modular/modularCodeModel.js +2 -0
- package/dist/src/modular/modularCodeModel.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 +6 -0
- package/dist/src/transform/transform.d.ts.map +1 -0
- package/dist/src/transform/transform.js +87 -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/transformApiVersionInfo.d.ts +5 -0
- package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -0
- package/dist/src/transform/transformApiVersionInfo.js +64 -0
- package/dist/src/transform/transformApiVersionInfo.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 +314 -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 +161 -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 +80 -0
- package/src/casingUtils.ts +48 -0
- package/src/emitUtil.ts +63 -0
- package/src/index.ts +148 -0
- package/src/lib.ts +208 -0
- package/src/modelUtils.ts +1080 -0
- package/src/modular/buildApiIndex.ts +13 -0
- package/src/modular/buildClassicalClient.ts +154 -0
- package/src/modular/buildClientContext.ts +96 -0
- package/src/modular/buildCodeModel.ts +1444 -0
- package/src/modular/buildOperations.ts +93 -0
- package/src/modular/buildProjectFiles.ts +217 -0
- package/src/modular/buildRootIndex.ts +75 -0
- package/src/modular/buildSharedTypes.ts +40 -0
- package/src/modular/emitModels.ts +72 -0
- package/src/modular/helpers/clientHelpers.ts +38 -0
- package/src/modular/helpers/credentialHelpers.ts +29 -0
- package/src/modular/helpers/namingHelpers.ts +5 -0
- package/src/modular/helpers/operationHelpers.ts +289 -0
- package/src/modular/helpers/parameterHelpers.ts +12 -0
- package/src/modular/helpers/typeHelpers.ts +84 -0
- package/src/modular/interfaces.ts +10 -0
- package/src/modular/modularCodeModel.ts +148 -0
- package/src/operationUtil.ts +203 -0
- package/src/transform/transform.ts +154 -0
- package/src/transform/transformAnnotationDetails.ts +231 -0
- package/src/transform/transformApiVersionInfo.ts +108 -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 +197 -0
- package/src/transform/transfromRLCOptions.ts +202 -0
- package/test/commands/cadl-ranch-list.ts +111 -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 +31 -0
- package/test/integration/arrayItemTypes.spec.ts +96 -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/collectionFormat.spec.ts +74 -0
- package/test/integration/dictionary.spec.ts +106 -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 +165 -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 +86 -0
- package/test/integration/generated/arrays/itemTypes/src/responses.ts +115 -0
- package/test/integration/generated/arrays/itemTypes/tspconfig.yaml +15 -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 +13 -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 +15 -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 +15 -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 +180 -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 +94 -0
- package/test/integration/generated/dictionary/src/responses.ts +126 -0
- package/test/integration/generated/dictionary/tsconfig.json +25 -0
- package/test/integration/generated/dictionary/tspconfig.yaml +15 -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 +14 -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 +14 -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 +14 -0
- package/test/integration/generated/internal/src/clientDefinitions.ts +27 -0
- package/test/integration/generated/internal/src/index.ts +13 -0
- package/test/integration/generated/internal/src/internalClient.ts +31 -0
- package/test/integration/generated/internal/src/models.ts +8 -0
- package/test/integration/generated/internal/src/outputModels.ts +13 -0
- package/test/integration/generated/internal/src/parameters.ts +21 -0
- package/test/integration/generated/internal/src/responses.ts +20 -0
- package/test/integration/generated/internal/tspconfig.yaml +14 -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 +13 -0
- package/test/integration/generated/lro/lroBasic/src/outputModels.ts +8 -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 +23 -0
- package/test/integration/generated/lro/lroBasic/tsconfig.json +25 -0
- package/test/integration/generated/lro/lroBasic/tspconfig.yaml +14 -0
- package/test/integration/generated/lro/lroCore/.eslintrc.json +11 -0
- package/test/integration/generated/lro/lroCore/README.md +56 -0
- package/test/integration/generated/lro/lroCore/api-extractor.json +18 -0
- package/test/integration/generated/lro/lroCore/package.json +82 -0
- package/test/integration/generated/lro/lroCore/rollup.config.js +118 -0
- package/test/integration/generated/lro/lroCore/src/azureLroCore.ts +31 -0
- package/test/integration/generated/lro/lroCore/src/clientDefinitions.ts +51 -0
- package/test/integration/generated/lro/lroCore/src/index.ts +15 -0
- package/test/integration/generated/lro/lroCore/src/isUnexpected.ts +128 -0
- package/test/integration/generated/lro/lroCore/src/models.ts +8 -0
- package/test/integration/generated/lro/lroCore/src/outputModels.ts +53 -0
- package/test/integration/generated/lro/lroCore/src/parameters.ts +25 -0
- package/test/integration/generated/lro/lroCore/src/pollingHelper.ts +75 -0
- package/test/integration/generated/lro/lroCore/src/responses.ts +91 -0
- package/test/integration/generated/lro/lroCore/tsconfig.json +25 -0
- package/test/integration/generated/lro/lroCore/tspconfig.yaml +14 -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 +14 -0
- package/test/integration/generated/models/propertyNullable/.eslintrc.json +11 -0
- package/test/integration/generated/models/propertyNullable/README.md +56 -0
- package/test/integration/generated/models/propertyNullable/api-extractor.json +18 -0
- package/test/integration/generated/models/propertyNullable/package.json +80 -0
- package/test/integration/generated/models/propertyNullable/rollup.config.js +118 -0
- package/test/integration/generated/models/propertyNullable/src/clientDefinitions.ts +227 -0
- package/test/integration/generated/models/propertyNullable/src/index.ts +13 -0
- package/test/integration/generated/models/propertyNullable/src/models.ts +56 -0
- package/test/integration/generated/models/propertyNullable/src/modelsPropertyNullable.ts +31 -0
- package/test/integration/generated/models/propertyNullable/src/outputModels.ts +56 -0
- package/test/integration/generated/models/propertyNullable/src/parameters.ts +195 -0
- package/test/integration/generated/models/propertyNullable/src/responses.ts +144 -0
- package/test/integration/generated/models/propertyNullable/tsconfig.json +25 -0
- package/test/integration/generated/models/propertyNullable/tspconfig.yaml +14 -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 +14 -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 +14 -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 +14 -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 +14 -0
- package/test/integration/generated/parameters/collection-format/src/clientDefinitions.ts +39 -0
- package/test/integration/generated/parameters/collection-format/src/collectionFormatClient.ts +31 -0
- package/test/integration/generated/parameters/collection-format/src/index.ts +12 -0
- package/test/integration/generated/parameters/collection-format/src/parameters.ts +38 -0
- package/test/integration/generated/parameters/collection-format/src/responses.ts +19 -0
- package/test/integration/generated/parameters/collection-format/src/serializeHelper.ts +16 -0
- package/test/integration/generated/parameters/collection-format/tspconfig.yaml +14 -0
- package/test/integration/generated/projection/src/clientDefinitions.ts +45 -0
- package/test/integration/generated/projection/src/index.ts +12 -0
- package/test/integration/generated/projection/src/models.ts +11 -0
- package/test/integration/generated/projection/src/parameters.ts +26 -0
- package/test/integration/generated/projection/src/projectionClient.ts +31 -0
- package/test/integration/generated/projection/src/responses.ts +19 -0
- package/test/integration/generated/projection/tspconfig.yaml +14 -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 +14 -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 +14 -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 +14 -0
- package/test/integration/generated/server/path/multiple/src/clientDefinitions.ts +35 -0
- package/test/integration/generated/server/path/multiple/src/index.ts +11 -0
- package/test/integration/generated/server/path/multiple/src/multipleParamInServerPathClient.ts +39 -0
- package/test/integration/generated/server/path/multiple/src/parameters.ts +7 -0
- package/test/integration/generated/server/path/multiple/src/responses.ts +14 -0
- package/test/integration/generated/server/path/multiple/tspconfig.yaml +14 -0
- package/test/integration/generated/server/path/single/src/clientDefinitions.ts +19 -0
- package/test/integration/generated/server/path/single/src/index.ts +11 -0
- package/test/integration/generated/server/path/single/src/parameters.ts +6 -0
- package/test/integration/generated/server/path/single/src/responses.ts +9 -0
- package/test/integration/generated/server/path/single/src/singleParamInServerPathClient.ts +34 -0
- package/test/integration/generated/server/path/single/tspconfig.yaml +14 -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 +14 -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 +14 -0
- package/test/integration/helloWorld.spec.ts +20 -0
- package/test/integration/internal.spec.ts +43 -0
- package/test/integration/lroBasic.spec.ts +25 -0
- package/test/integration/modelInheritance.spec.ts +192 -0
- package/test/integration/modelPropertyNullable.spec.ts +115 -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/projection.spec.ts +55 -0
- package/test/integration/resiliencyDpgCustomization.spec.ts +52 -0
- package/test/integration/server.spec.ts +59 -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/apiVersion.spec.ts +388 -0
- package/test/unit/azureCoreOperationsGenerator.spec.ts +71 -0
- package/test/unit/clientDefinitionGenerator.spec.ts +73 -0
- package/test/unit/clientFactoryGenerator.spec.ts +376 -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 +157 -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,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,31 @@
|
|
|
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
|
+
`./temp/http/${sourceTypespec}`
|
|
18
|
+
);
|
|
19
|
+
const outputPath = joinPath(
|
|
20
|
+
`${__dirname}`,
|
|
21
|
+
"..",
|
|
22
|
+
`./integration/generated/${targetFolder}`
|
|
23
|
+
);
|
|
24
|
+
const typespecCommand = `cd ${outputPath} && npx tsp`;
|
|
25
|
+
const commandArguments: string[] = ["compile", `${typespecPath}`];
|
|
26
|
+
const command = `${typespecCommand} ${commandArguments.join(" ")}`;
|
|
27
|
+
console.log(command);
|
|
28
|
+
const result = execSync(command);
|
|
29
|
+
console.log(`=== End ${targetFolder} ===`);
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
type: "nullable-float",
|
|
52
|
+
defaultValue: [1.2, null, 3.0]
|
|
53
|
+
}
|
|
54
|
+
];
|
|
55
|
+
describe("Array Item-Types Client", () => {
|
|
56
|
+
let client: ArrayItemTypesClient;
|
|
57
|
+
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
client = ArrayItemTypesClientFactory({
|
|
60
|
+
allowInsecureConnection: true
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
matrix([testedTypes], async (params: TypeDetail) => {
|
|
65
|
+
it(`should get a ${params.type} value`, async () => {
|
|
66
|
+
try {
|
|
67
|
+
const result = await client
|
|
68
|
+
.path(`/arrays/item-types/${params.type}` as any)
|
|
69
|
+
.get();
|
|
70
|
+
assert.strictEqual(result.status, "200");
|
|
71
|
+
assert.deepEqual(result.body, params.defaultValue);
|
|
72
|
+
} catch (err) {
|
|
73
|
+
assert.fail(err as string);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it(`should put a ${params.type} value`, async () => {
|
|
78
|
+
try {
|
|
79
|
+
let property;
|
|
80
|
+
if (params.convertedToFn) {
|
|
81
|
+
property = params.convertedToFn(params.defaultValue);
|
|
82
|
+
} else {
|
|
83
|
+
property = params.defaultValue;
|
|
84
|
+
}
|
|
85
|
+
const result = await client
|
|
86
|
+
.path(`/arrays/item-types/${params.type}` as any)
|
|
87
|
+
.put({
|
|
88
|
+
body: property
|
|
89
|
+
});
|
|
90
|
+
assert.strictEqual(result.status, "204");
|
|
91
|
+
} catch (err) {
|
|
92
|
+
assert.fail(err as string);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import CollectionFormatClientFactory, {
|
|
3
|
+
buildMultiCollection,
|
|
4
|
+
CollectionFormatClient
|
|
5
|
+
} from "./generated/parameters/collection-format/src/index.js";
|
|
6
|
+
describe("Collection Format Rest Client", () => {
|
|
7
|
+
let client: CollectionFormatClient;
|
|
8
|
+
const colors = ["blue", "red", "green"];
|
|
9
|
+
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
client = CollectionFormatClientFactory({
|
|
12
|
+
allowInsecureConnection: true,
|
|
13
|
+
retryOptions: {
|
|
14
|
+
maxRetries: 0
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should serialize multi format query array parameter", async () => {
|
|
20
|
+
try {
|
|
21
|
+
const result = await client.path("/parameters/collection-format/query/multi").get({
|
|
22
|
+
queryParameters: {
|
|
23
|
+
colors: buildMultiCollection(colors, "colors")
|
|
24
|
+
},
|
|
25
|
+
skipUrlEncoding: true
|
|
26
|
+
});
|
|
27
|
+
assert.strictEqual(result.status, "204");
|
|
28
|
+
} catch (err) {
|
|
29
|
+
assert.fail(err as string);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("should serialize csv format query array parameter", async () => {
|
|
34
|
+
try {
|
|
35
|
+
const result = await client.path("/parameters/collection-format/query/csv").get({
|
|
36
|
+
queryParameters: {
|
|
37
|
+
colors: colors
|
|
38
|
+
},
|
|
39
|
+
skipUrlEncoding: true
|
|
40
|
+
});
|
|
41
|
+
assert.strictEqual(result.status, "204");
|
|
42
|
+
} catch (err) {
|
|
43
|
+
assert.fail(err as string);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should serialize csv format header array parameter", async () => {
|
|
48
|
+
try {
|
|
49
|
+
const result = await client.path("/parameters/collection-format/header/csv").get({
|
|
50
|
+
headers: {
|
|
51
|
+
colors: colors as any
|
|
52
|
+
},
|
|
53
|
+
skipUrlEncoding: true
|
|
54
|
+
});
|
|
55
|
+
assert.strictEqual(result.status, "204");
|
|
56
|
+
} catch (err) {
|
|
57
|
+
assert.fail(err as string);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// it.skip("should serialize default format query array parameter", async () => {
|
|
62
|
+
// try {
|
|
63
|
+
// const result = await client.path("/collectionFormat/default").get({
|
|
64
|
+
// queryParameters: {
|
|
65
|
+
// colors: buildMultiCollection(colors, 'colors')
|
|
66
|
+
// },
|
|
67
|
+
// skipUrlEncoding: true
|
|
68
|
+
// });
|
|
69
|
+
// assert.strictEqual(result.status, "200");
|
|
70
|
+
// } catch (err) {
|
|
71
|
+
// assert.fail(err as string);
|
|
72
|
+
// }
|
|
73
|
+
// });
|
|
74
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import { matrix } from "../util/matrix.js";
|
|
3
|
+
import DictClientFactory, {
|
|
4
|
+
DictClient
|
|
5
|
+
} from "./generated/dictionary/src/index.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: { k1: 1, k2: 2 }
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: "int64",
|
|
20
|
+
defaultValue: { k1: Number.MAX_SAFE_INTEGER, k2: Number.MIN_SAFE_INTEGER }
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: "boolean",
|
|
24
|
+
defaultValue: { k1: true, k2: false }
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: "string",
|
|
28
|
+
defaultValue: { k1: "hello", k2: "" }
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: "float32",
|
|
32
|
+
defaultValue: { k1: 42.42 }
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: "datetime",
|
|
36
|
+
defaultValue: { k1: "2022-08-26T18:38:00Z" }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "duration",
|
|
40
|
+
defaultValue: { k1: "P123DT22H14M12.011S" }
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "unknown",
|
|
44
|
+
defaultValue: { k1: 1, k2: "hello", k3: null }
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: "model",
|
|
48
|
+
defaultValue: { k1: { property: "hello" }, k2: { property: "world" } }
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "model/recursive",
|
|
52
|
+
defaultValue: {
|
|
53
|
+
k1: { property: "hello", children: {} },
|
|
54
|
+
k2: {
|
|
55
|
+
property: "world",
|
|
56
|
+
children: { "k2.1": { property: "inner world" } }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type: "nullable-float",
|
|
62
|
+
defaultValue: { k1: 1.2, k2: 0.5, k3: null }
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
describe("Dictionary Client", () => {
|
|
66
|
+
let client: DictClient;
|
|
67
|
+
|
|
68
|
+
beforeEach(() => {
|
|
69
|
+
client = DictClientFactory({
|
|
70
|
+
allowInsecureConnection: true
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
matrix([testedTypes], async (params: TypeDetail) => {
|
|
75
|
+
it(`should get a ${params.type} value`, async () => {
|
|
76
|
+
try {
|
|
77
|
+
const result = await client
|
|
78
|
+
.path(`/dictionary/${params.type}` as any)
|
|
79
|
+
.get();
|
|
80
|
+
assert.strictEqual(result.status, "200");
|
|
81
|
+
assert.deepEqual(result.body, params.defaultValue);
|
|
82
|
+
} catch (err) {
|
|
83
|
+
assert.fail(err as string);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it(`should put a ${params.type} value`, async () => {
|
|
88
|
+
try {
|
|
89
|
+
let property;
|
|
90
|
+
if (params.convertedToFn) {
|
|
91
|
+
property = params.convertedToFn(params.defaultValue);
|
|
92
|
+
} else {
|
|
93
|
+
property = params.defaultValue;
|
|
94
|
+
}
|
|
95
|
+
const result = await client
|
|
96
|
+
.path(`/dictionary/${params.type}` as any)
|
|
97
|
+
.put({
|
|
98
|
+
body: property
|
|
99
|
+
});
|
|
100
|
+
assert.strictEqual(result.status, "204");
|
|
101
|
+
} catch (err) {
|
|
102
|
+
assert.fail(err as string);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import EnumsExtensibleClientFactory, {
|
|
2
|
+
EnumsExtensibleClient
|
|
3
|
+
} from "./generated/enums/extensible/src/index.js";
|
|
4
|
+
import { assert } from "chai";
|
|
5
|
+
describe("ExtensibleEnums Rest Client", () => {
|
|
6
|
+
let client: EnumsExtensibleClient;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
client = EnumsExtensibleClientFactory({ allowInsecureConnection: true });
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("should get known value", async () => {
|
|
13
|
+
try {
|
|
14
|
+
const result = await client
|
|
15
|
+
.path("/enums/extensible/string/known-value")
|
|
16
|
+
.get();
|
|
17
|
+
assert.strictEqual(result.status, "200");
|
|
18
|
+
assert.strictEqual(result.body, "Monday");
|
|
19
|
+
} catch (err) {
|
|
20
|
+
assert.fail(err as string);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should put known value", async () => {
|
|
25
|
+
try {
|
|
26
|
+
const result = await client
|
|
27
|
+
.path("/enums/extensible/string/known-value")
|
|
28
|
+
.put({
|
|
29
|
+
body: JSON.stringify("Monday")
|
|
30
|
+
});
|
|
31
|
+
assert.strictEqual(result.status, "204");
|
|
32
|
+
} catch (err) {
|
|
33
|
+
assert.fail(err as string);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should get unknown value", async () => {
|
|
38
|
+
try {
|
|
39
|
+
const result = await client
|
|
40
|
+
.path("/enums/extensible/string/unknown-value")
|
|
41
|
+
.get();
|
|
42
|
+
assert.strictEqual(result.status, "200");
|
|
43
|
+
assert.strictEqual(result.body, "Weekend");
|
|
44
|
+
} catch (err) {
|
|
45
|
+
assert.fail(err as string);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("should put unknown value", async () => {
|
|
50
|
+
try {
|
|
51
|
+
const result = await client
|
|
52
|
+
.path("/enums/extensible/string/unknown-value")
|
|
53
|
+
.put({
|
|
54
|
+
body: JSON.stringify("Weekend")
|
|
55
|
+
});
|
|
56
|
+
assert.strictEqual(result.status, "204");
|
|
57
|
+
} catch (err) {
|
|
58
|
+
assert.fail(err as string);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { assert } from "chai";
|
|
2
|
+
import EnumsFixedClientFactory, {
|
|
3
|
+
EnumsFixedClient
|
|
4
|
+
} from "./generated/enums/fixed/src/index.js";
|
|
5
|
+
describe("FixedEnums Rest Client", () => {
|
|
6
|
+
let client: EnumsFixedClient;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
client = EnumsFixedClientFactory({
|
|
10
|
+
allowInsecureConnection: true,
|
|
11
|
+
retryOptions: {
|
|
12
|
+
maxRetries: 0
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("should get known value", async () => {
|
|
18
|
+
try {
|
|
19
|
+
const result = await client.path("/enums/fixed/string/known-value").get();
|
|
20
|
+
assert.strictEqual(result.status, "200");
|
|
21
|
+
assert.strictEqual(result.body, "Monday");
|
|
22
|
+
} catch (err) {
|
|
23
|
+
assert.fail(err as string);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("should put known value", async () => {
|
|
28
|
+
try {
|
|
29
|
+
const result = await client.path("/enums/fixed/string/known-value").put({
|
|
30
|
+
body: "Monday",
|
|
31
|
+
contentType: "application/json"
|
|
32
|
+
});
|
|
33
|
+
assert.strictEqual(result.status, "204");
|
|
34
|
+
} catch (err) {
|
|
35
|
+
assert.fail(err as string);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("should put unknown value and receives 500", async () => {
|
|
40
|
+
try {
|
|
41
|
+
const result = await client
|
|
42
|
+
.path("/enums/fixed/string/unknown-value")
|
|
43
|
+
.put({
|
|
44
|
+
body: "Weekend" as any,
|
|
45
|
+
contentType: "application/json"
|
|
46
|
+
});
|
|
47
|
+
assert.strictEqual(result.status, "500");
|
|
48
|
+
} catch (err) {
|
|
49
|
+
assert.fail(err as string);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|