@azure-tools/typespec-ts 0.13.0 → 0.13.1-alpha.20230609.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +37 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/modelUtils.d.ts +2 -0
- package/dist/src/modelUtils.d.ts.map +1 -1
- package/dist/src/modelUtils.js +82 -13
- package/dist/src/modelUtils.js.map +1 -1
- package/dist/src/modular/buildApiIndex.d.ts.map +1 -1
- package/dist/src/modular/buildApiIndex.js +1 -1
- package/dist/src/modular/buildApiIndex.js.map +1 -1
- package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
- package/dist/src/modular/buildClassicalClient.js +6 -6
- package/dist/src/modular/buildClassicalClient.js.map +1 -1
- package/dist/src/modular/buildClientContext.d.ts.map +1 -1
- package/dist/src/modular/buildClientContext.js +9 -3
- package/dist/src/modular/buildClientContext.js.map +1 -1
- package/dist/src/modular/buildCodeModel.d.ts.map +1 -1
- package/dist/src/modular/buildCodeModel.js +190 -169
- package/dist/src/modular/buildCodeModel.js.map +1 -1
- package/dist/src/modular/buildOperations.d.ts.map +1 -1
- package/dist/src/modular/buildOperations.js +20 -2
- package/dist/src/modular/buildOperations.js.map +1 -1
- package/dist/src/modular/buildRootIndex.js +2 -2
- package/dist/src/modular/buildRootIndex.js.map +1 -1
- package/dist/src/modular/buildSharedTypes.d.ts.map +1 -1
- package/dist/src/modular/buildSharedTypes.js +8 -10
- package/dist/src/modular/buildSharedTypes.js.map +1 -1
- package/dist/src/modular/emitModels.d.ts.map +1 -1
- package/dist/src/modular/emitModels.js +19 -6
- package/dist/src/modular/emitModels.js.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/clientHelpers.js +2 -11
- package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
- package/dist/src/modular/helpers/credentialHelpers.js +1 -1
- package/dist/src/modular/helpers/credentialHelpers.js.map +1 -1
- package/dist/src/modular/helpers/fixmeHelpers.d.ts +2 -0
- package/dist/src/modular/helpers/fixmeHelpers.d.ts.map +1 -0
- package/dist/src/modular/helpers/fixmeHelpers.js +4 -0
- package/dist/src/modular/helpers/fixmeHelpers.js.map +1 -0
- package/dist/src/modular/helpers/namingHelpers.d.ts +10 -1
- package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/namingHelpers.js +20 -0
- package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.d.ts +2 -0
- package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/operationHelpers.js +117 -35
- package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
- package/dist/src/modular/helpers/parameterHelpers.js +1 -1
- package/dist/src/modular/helpers/parameterHelpers.js.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
- package/dist/src/modular/helpers/typeHelpers.js +31 -12
- package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
- package/dist/src/modular/modularCodeModel.d.ts +2 -1
- package/dist/src/modular/modularCodeModel.d.ts.map +1 -1
- package/dist/src/operationUtil.d.ts +1 -1
- package/dist/src/operationUtil.d.ts.map +1 -1
- package/dist/src/operationUtil.js +21 -3
- package/dist/src/operationUtil.js.map +1 -1
- package/dist/src/transform/transform.d.ts.map +1 -1
- package/dist/src/transform/transform.js +2 -2
- package/dist/src/transform/transform.js.map +1 -1
- package/dist/src/transform/transformApiVersionInfo.js +9 -0
- package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
- package/dist/src/transform/transformHelperFunctionDetails.js +27 -1
- package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
- package/dist/src/transform/transformParameters.d.ts +1 -0
- package/dist/src/transform/transformParameters.d.ts.map +1 -1
- package/dist/src/transform/transformParameters.js +36 -35
- package/dist/src/transform/transformParameters.js.map +1 -1
- package/dist/src/transform/transformPaths.d.ts.map +1 -1
- package/dist/src/transform/transformPaths.js +9 -0
- package/dist/src/transform/transformPaths.js.map +1 -1
- package/dist/src/transform/transformResponses.d.ts.map +1 -1
- package/dist/src/transform/transformResponses.js +10 -1
- package/dist/src/transform/transformResponses.js.map +1 -1
- package/dist/src/transform/transformSchemas.d.ts.map +1 -1
- package/dist/src/transform/transformSchemas.js +9 -0
- package/dist/src/transform/transformSchemas.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +20 -15
- package/src/index.ts +47 -2
- package/src/modelUtils.ts +90 -15
- package/src/modular/buildApiIndex.ts +3 -1
- package/src/modular/buildClassicalClient.ts +8 -6
- package/src/modular/buildClientContext.ts +11 -3
- package/src/modular/buildCodeModel.ts +221 -196
- package/src/modular/buildOperations.ts +23 -1
- package/src/modular/buildRootIndex.ts +2 -2
- package/src/modular/buildSharedTypes.ts +8 -10
- package/src/modular/emitModels.ts +14 -0
- package/src/modular/helpers/clientHelpers.ts +3 -13
- package/src/modular/helpers/credentialHelpers.ts +1 -1
- package/src/modular/helpers/fixmeHelpers.ts +3 -0
- package/src/modular/helpers/namingHelpers.ts +35 -1
- package/src/modular/helpers/operationHelpers.ts +173 -66
- package/src/modular/helpers/parameterHelpers.ts +1 -1
- package/src/modular/helpers/typeHelpers.ts +33 -12
- package/src/modular/modularCodeModel.ts +3 -1
- package/src/operationUtil.ts +24 -3
- package/src/transform/transform.ts +4 -1
- package/src/transform/transformApiVersionInfo.ts +8 -0
- package/src/transform/transformHelperFunctionDetails.ts +25 -1
- package/src/transform/transformParameters.ts +52 -41
- package/src/transform/transformPaths.ts +8 -0
- package/src/transform/transformResponses.ts +9 -1
- package/src/transform/transformSchemas.ts +8 -0
- package/.eslintrc.json +0 -23
- package/.prettierignore +0 -1
- package/.prettierrc +0 -7
- package/.rush/temp/operation/build/all.log +0 -1
- package/.rush/temp/operation/build/state.json +0 -3
- package/.rush/temp/package-deps_build.json +0 -442
- package/.rush/temp/shrinkwrap-deps.json +0 -490
- package/CONTRIBUTING.md +0 -137
- package/test/commands/cadl-ranch-list.ts +0 -116
- package/test/commands/check-clean-tree.ts +0 -55
- package/test/commands/childProcessOnExit.ts +0 -16
- package/test/commands/gen-cadl-ranch.ts +0 -25
- package/test/commands/run.ts +0 -31
- package/test/integration/arrayItemTypes.spec.ts +0 -96
- package/test/integration/authApiKey.spec.ts +0 -38
- package/test/integration/authOauth2.spec.ts +0 -65
- package/test/integration/authUnion.spec.ts +0 -72
- package/test/integration/azurecore.spec.ts +0 -170
- package/test/integration/collectionFormat.spec.ts +0 -118
- package/test/integration/dictionary.spec.ts +0 -106
- package/test/integration/extensibleEnums.spec.ts +0 -61
- package/test/integration/fixedEnums.spec.ts +0 -52
- package/test/integration/generated/arrays/itemTypes/src/arrayItemTypesClient.ts +0 -35
- package/test/integration/generated/arrays/itemTypes/src/clientDefinitions.ts +0 -165
- package/test/integration/generated/arrays/itemTypes/src/index.ts +0 -13
- package/test/integration/generated/arrays/itemTypes/src/logger.ts +0 -5
- package/test/integration/generated/arrays/itemTypes/src/models.ts +0 -9
- package/test/integration/generated/arrays/itemTypes/src/outputModels.ts +0 -9
- package/test/integration/generated/arrays/itemTypes/src/parameters.ts +0 -86
- package/test/integration/generated/arrays/itemTypes/src/responses.ts +0 -115
- package/test/integration/generated/arrays/itemTypes/tspconfig.yaml +0 -15
- package/test/integration/generated/authentication/apiKey/.eslintrc.json +0 -11
- package/test/integration/generated/authentication/apiKey/README.md +0 -56
- package/test/integration/generated/authentication/apiKey/api-extractor.json +0 -18
- package/test/integration/generated/authentication/apiKey/karma.conf.js +0 -133
- package/test/integration/generated/authentication/apiKey/package.json +0 -103
- package/test/integration/generated/authentication/apiKey/rollup.config.js +0 -118
- package/test/integration/generated/authentication/apiKey/src/authApiKeyClient.ts +0 -45
- package/test/integration/generated/authentication/apiKey/src/clientDefinitions.ts +0 -33
- package/test/integration/generated/authentication/apiKey/src/index.ts +0 -12
- package/test/integration/generated/authentication/apiKey/src/logger.ts +0 -5
- package/test/integration/generated/authentication/apiKey/src/outputModels.ts +0 -6
- package/test/integration/generated/authentication/apiKey/src/parameters.ts +0 -7
- package/test/integration/generated/authentication/apiKey/src/responses.ts +0 -21
- package/test/integration/generated/authentication/apiKey/test/public/sampleTest.spec.ts +0 -23
- package/test/integration/generated/authentication/apiKey/test/public/utils/env.browser.ts +0 -2
- package/test/integration/generated/authentication/apiKey/test/public/utils/env.ts +0 -6
- package/test/integration/generated/authentication/apiKey/test/public/utils/recordedClient.ts +0 -29
- package/test/integration/generated/authentication/apiKey/tsconfig.json +0 -25
- package/test/integration/generated/authentication/apiKey/tspconfig.yaml +0 -13
- package/test/integration/generated/authentication/oauth2/karma.conf.js +0 -133
- package/test/integration/generated/authentication/oauth2/src/authOauth2Client.ts +0 -45
- package/test/integration/generated/authentication/oauth2/src/clientDefinitions.ts +0 -33
- package/test/integration/generated/authentication/oauth2/src/index.ts +0 -12
- package/test/integration/generated/authentication/oauth2/src/logger.ts +0 -5
- package/test/integration/generated/authentication/oauth2/src/outputModels.ts +0 -6
- package/test/integration/generated/authentication/oauth2/src/parameters.ts +0 -7
- package/test/integration/generated/authentication/oauth2/src/responses.ts +0 -21
- package/test/integration/generated/authentication/oauth2/test/public/sampleTest.spec.ts +0 -23
- package/test/integration/generated/authentication/oauth2/test/public/utils/env.browser.ts +0 -2
- package/test/integration/generated/authentication/oauth2/test/public/utils/env.ts +0 -6
- package/test/integration/generated/authentication/oauth2/test/public/utils/recordedClient.ts +0 -29
- package/test/integration/generated/authentication/oauth2/tspconfig.yaml +0 -15
- package/test/integration/generated/authentication/union/karma.conf.js +0 -133
- package/test/integration/generated/authentication/union/src/authUnionClient.ts +0 -46
- package/test/integration/generated/authentication/union/src/clientDefinitions.ts +0 -27
- package/test/integration/generated/authentication/union/src/index.ts +0 -11
- package/test/integration/generated/authentication/union/src/logger.ts +0 -5
- package/test/integration/generated/authentication/union/src/parameters.ts +0 -7
- package/test/integration/generated/authentication/union/src/responses.ts +0 -14
- package/test/integration/generated/authentication/union/test/public/sampleTest.spec.ts +0 -23
- package/test/integration/generated/authentication/union/test/public/utils/env.browser.ts +0 -2
- package/test/integration/generated/authentication/union/test/public/utils/env.ts +0 -6
- package/test/integration/generated/authentication/union/test/public/utils/recordedClient.ts +0 -29
- package/test/integration/generated/authentication/union/tspconfig.yaml +0 -15
- package/test/integration/generated/azure/core/.eslintrc.json +0 -11
- package/test/integration/generated/azure/core/README.md +0 -56
- package/test/integration/generated/azure/core/api-extractor.json +0 -18
- package/test/integration/generated/azure/core/package.json +0 -81
- package/test/integration/generated/azure/core/rollup.config.js +0 -118
- package/test/integration/generated/azure/core/src/azureCoreClient.ts +0 -35
- package/test/integration/generated/azure/core/src/clientDefinitions.ts +0 -108
- package/test/integration/generated/azure/core/src/index.ts +0 -16
- package/test/integration/generated/azure/core/src/isUnexpected.ts +0 -178
- package/test/integration/generated/azure/core/src/logger.ts +0 -5
- package/test/integration/generated/azure/core/src/models.ts +0 -18
- package/test/integration/generated/azure/core/src/outputModels.ts +0 -38
- package/test/integration/generated/azure/core/src/paginateHelper.ts +0 -204
- package/test/integration/generated/azure/core/src/parameters.ts +0 -68
- package/test/integration/generated/azure/core/src/responses.ts +0 -158
- package/test/integration/generated/azure/core/src/serializeHelper.ts +0 -16
- package/test/integration/generated/azure/core/tsconfig.json +0 -25
- package/test/integration/generated/azure/core/tspconfig.yaml +0 -15
- package/test/integration/generated/azure/core-traits/.eslintrc.json +0 -11
- package/test/integration/generated/azure/core-traits/README.md +0 -56
- package/test/integration/generated/azure/core-traits/api-extractor.json +0 -18
- package/test/integration/generated/azure/core-traits/package.json +0 -80
- package/test/integration/generated/azure/core-traits/rollup.config.js +0 -118
- package/test/integration/generated/azure/core-traits/src/azureCoreTraitsClient.ts +0 -35
- package/test/integration/generated/azure/core-traits/src/clientDefinitions.ts +0 -22
- package/test/integration/generated/azure/core-traits/src/index.ts +0 -13
- package/test/integration/generated/azure/core-traits/src/isUnexpected.ts +0 -97
- package/test/integration/generated/azure/core-traits/src/logger.ts +0 -5
- package/test/integration/generated/azure/core-traits/src/outputModels.ts +0 -25
- package/test/integration/generated/azure/core-traits/src/parameters.ts +0 -26
- package/test/integration/generated/azure/core-traits/src/responses.ts +0 -32
- package/test/integration/generated/azure/core-traits/tsconfig.json +0 -25
- package/test/integration/generated/azure/core-traits/tspconfig.yaml +0 -15
- package/test/integration/generated/dictionary/.eslintrc.json +0 -11
- package/test/integration/generated/dictionary/README.md +0 -56
- package/test/integration/generated/dictionary/api-extractor.json +0 -18
- package/test/integration/generated/dictionary/package.json +0 -80
- package/test/integration/generated/dictionary/rollup.config.js +0 -118
- package/test/integration/generated/dictionary/src/clientDefinitions.ts +0 -180
- package/test/integration/generated/dictionary/src/dictClient.ts +0 -33
- package/test/integration/generated/dictionary/src/index.ts +0 -13
- package/test/integration/generated/dictionary/src/logger.ts +0 -5
- package/test/integration/generated/dictionary/src/models.ts +0 -9
- package/test/integration/generated/dictionary/src/outputModels.ts +0 -9
- package/test/integration/generated/dictionary/src/parameters.ts +0 -94
- package/test/integration/generated/dictionary/src/responses.ts +0 -126
- package/test/integration/generated/dictionary/tsconfig.json +0 -25
- package/test/integration/generated/dictionary/tspconfig.yaml +0 -15
- package/test/integration/generated/enums/extensible/.eslintrc.json +0 -11
- package/test/integration/generated/enums/extensible/README.md +0 -56
- package/test/integration/generated/enums/extensible/api-extractor.json +0 -18
- package/test/integration/generated/enums/extensible/package.json +0 -80
- package/test/integration/generated/enums/extensible/rollup.config.js +0 -118
- package/test/integration/generated/enums/extensible/src/clientDefinitions.ts +0 -45
- package/test/integration/generated/enums/extensible/src/index.ts +0 -11
- package/test/integration/generated/enums/extensible/src/logger.ts +0 -5
- package/test/integration/generated/enums/extensible/src/parameters.ts +0 -23
- package/test/integration/generated/enums/extensible/src/responses.ts +0 -26
- package/test/integration/generated/enums/extensible/src/typeEnumExtensible.ts +0 -35
- package/test/integration/generated/enums/extensible/tsconfig.json +0 -25
- package/test/integration/generated/enums/extensible/tspconfig.yaml +0 -14
- package/test/integration/generated/enums/fixed/.eslintrc.json +0 -11
- package/test/integration/generated/enums/fixed/README.md +0 -56
- package/test/integration/generated/enums/fixed/api-extractor.json +0 -18
- package/test/integration/generated/enums/fixed/package.json +0 -80
- package/test/integration/generated/enums/fixed/rollup.config.js +0 -118
- package/test/integration/generated/enums/fixed/src/clientDefinitions.ts +0 -43
- package/test/integration/generated/enums/fixed/src/index.ts +0 -11
- package/test/integration/generated/enums/fixed/src/logger.ts +0 -5
- package/test/integration/generated/enums/fixed/src/parameters.ts +0 -36
- package/test/integration/generated/enums/fixed/src/responses.ts +0 -27
- package/test/integration/generated/enums/fixed/src/typeEnumFixed.ts +0 -35
- package/test/integration/generated/enums/fixed/tsconfig.json +0 -25
- package/test/integration/generated/enums/fixed/tspconfig.yaml +0 -14
- package/test/integration/generated/hello/.eslintrc.json +0 -11
- package/test/integration/generated/hello/README.md +0 -56
- package/test/integration/generated/hello/api-extractor.json +0 -18
- package/test/integration/generated/hello/package.json +0 -80
- package/test/integration/generated/hello/rollup.config.js +0 -118
- package/test/integration/generated/hello/src/clientDefinitions.ts +0 -19
- package/test/integration/generated/hello/src/hello.ts +0 -29
- package/test/integration/generated/hello/src/index.ts +0 -11
- package/test/integration/generated/hello/src/parameters.ts +0 -6
- package/test/integration/generated/hello/src/responses.ts +0 -10
- package/test/integration/generated/hello/tsconfig.json +0 -25
- package/test/integration/generated/hello/tspconfig.yaml +0 -14
- package/test/integration/generated/internal/src/clientDefinitions.ts +0 -53
- package/test/integration/generated/internal/src/index.ts +0 -12
- package/test/integration/generated/internal/src/internalClient.ts +0 -35
- package/test/integration/generated/internal/src/logger.ts +0 -5
- package/test/integration/generated/internal/src/outputModels.ts +0 -17
- package/test/integration/generated/internal/src/parameters.ts +0 -45
- package/test/integration/generated/internal/src/responses.ts +0 -33
- package/test/integration/generated/internal/tspconfig.yaml +0 -14
- package/test/integration/generated/lro/lroCore/.eslintrc.json +0 -11
- package/test/integration/generated/lro/lroCore/README.md +0 -56
- package/test/integration/generated/lro/lroCore/api-extractor.json +0 -18
- package/test/integration/generated/lro/lroCore/package.json +0 -82
- package/test/integration/generated/lro/lroCore/rollup.config.js +0 -118
- package/test/integration/generated/lro/lroCore/src/clientDefinitions.ts +0 -54
- package/test/integration/generated/lro/lroCore/src/index.ts +0 -15
- package/test/integration/generated/lro/lroCore/src/isUnexpected.ts +0 -135
- package/test/integration/generated/lro/lroCore/src/logger.ts +0 -5
- package/test/integration/generated/lro/lroCore/src/models.ts +0 -8
- package/test/integration/generated/lro/lroCore/src/outputModels.ts +0 -50
- package/test/integration/generated/lro/lroCore/src/parameters.ts +0 -25
- package/test/integration/generated/lro/lroCore/src/pollingHelper.ts +0 -113
- package/test/integration/generated/lro/lroCore/src/responses.ts +0 -109
- package/test/integration/generated/lro/lroCore/src/specsAzureCoreLroStandard.ts +0 -35
- package/test/integration/generated/lro/lroCore/tsconfig.json +0 -25
- package/test/integration/generated/lro/lroCore/tspconfig.yaml +0 -14
- package/test/integration/generated/lro/lroRPC/.eslintrc.json +0 -11
- package/test/integration/generated/lro/lroRPC/README.md +0 -56
- package/test/integration/generated/lro/lroRPC/api-extractor.json +0 -18
- package/test/integration/generated/lro/lroRPC/package.json +0 -82
- package/test/integration/generated/lro/lroRPC/rollup.config.js +0 -118
- package/test/integration/generated/lro/lroRPC/src/clientDefinitions.ts +0 -79
- package/test/integration/generated/lro/lroRPC/src/index.ts +0 -15
- package/test/integration/generated/lro/lroRPC/src/isUnexpected.ts +0 -153
- package/test/integration/generated/lro/lroRPC/src/logger.ts +0 -5
- package/test/integration/generated/lro/lroRPC/src/models.ts +0 -8
- package/test/integration/generated/lro/lroRPC/src/outputModels.ts +0 -40
- package/test/integration/generated/lro/lroRPC/src/parameters.ts +0 -20
- package/test/integration/generated/lro/lroRPC/src/pollingHelper.ts +0 -127
- package/test/integration/generated/lro/lroRPC/src/responses.ts +0 -124
- package/test/integration/generated/lro/lroRPC/src/specsAzureCoreLroRpc.ts +0 -35
- package/test/integration/generated/lro/lroRPC/tsconfig.json +0 -25
- package/test/integration/generated/lro/lroRPC/tspconfig.yaml +0 -14
- package/test/integration/generated/models/inheritance/.eslintrc.json +0 -11
- package/test/integration/generated/models/inheritance/README.md +0 -56
- package/test/integration/generated/models/inheritance/api-extractor.json +0 -18
- package/test/integration/generated/models/inheritance/package.json +0 -80
- package/test/integration/generated/models/inheritance/rollup.config.js +0 -118
- package/test/integration/generated/models/inheritance/src/clientDefinitions.ts +0 -81
- package/test/integration/generated/models/inheritance/src/index.ts +0 -13
- package/test/integration/generated/models/inheritance/src/logger.ts +0 -5
- package/test/integration/generated/models/inheritance/src/models.ts +0 -52
- package/test/integration/generated/models/inheritance/src/outputModels.ts +0 -52
- package/test/integration/generated/models/inheritance/src/parameters.ts +0 -35
- package/test/integration/generated/models/inheritance/src/responses.ts +0 -56
- package/test/integration/generated/models/inheritance/src/typeModelInheritance.ts +0 -35
- package/test/integration/generated/models/inheritance/tsconfig.json +0 -25
- package/test/integration/generated/models/inheritance/tspconfig.yaml +0 -14
- package/test/integration/generated/models/propertyNullable/.eslintrc.json +0 -11
- package/test/integration/generated/models/propertyNullable/README.md +0 -56
- package/test/integration/generated/models/propertyNullable/api-extractor.json +0 -18
- package/test/integration/generated/models/propertyNullable/package.json +0 -80
- package/test/integration/generated/models/propertyNullable/rollup.config.js +0 -118
- package/test/integration/generated/models/propertyNullable/src/clientDefinitions.ts +0 -227
- package/test/integration/generated/models/propertyNullable/src/index.ts +0 -13
- package/test/integration/generated/models/propertyNullable/src/logger.ts +0 -5
- package/test/integration/generated/models/propertyNullable/src/models.ts +0 -56
- package/test/integration/generated/models/propertyNullable/src/outputModels.ts +0 -56
- package/test/integration/generated/models/propertyNullable/src/parameters.ts +0 -197
- package/test/integration/generated/models/propertyNullable/src/responses.ts +0 -144
- package/test/integration/generated/models/propertyNullable/src/typePropertyNullable.ts +0 -35
- package/test/integration/generated/models/propertyNullable/tsconfig.json +0 -25
- package/test/integration/generated/models/propertyNullable/tspconfig.yaml +0 -14
- package/test/integration/generated/models/propertyOptional/.eslintrc.json +0 -11
- package/test/integration/generated/models/propertyOptional/README.md +0 -56
- package/test/integration/generated/models/propertyOptional/api-extractor.json +0 -18
- package/test/integration/generated/models/propertyOptional/package.json +0 -80
- package/test/integration/generated/models/propertyOptional/rollup.config.js +0 -118
- package/test/integration/generated/models/propertyOptional/src/clientDefinitions.ts +0 -263
- package/test/integration/generated/models/propertyOptional/src/index.ts +0 -13
- package/test/integration/generated/models/propertyOptional/src/logger.ts +0 -5
- package/test/integration/generated/models/propertyOptional/src/models.ts +0 -46
- package/test/integration/generated/models/propertyOptional/src/outputModels.ts +0 -46
- package/test/integration/generated/models/propertyOptional/src/parameters.ts +0 -125
- package/test/integration/generated/models/propertyOptional/src/responses.ts +0 -169
- package/test/integration/generated/models/propertyOptional/src/typePropertyOptional.ts +0 -35
- package/test/integration/generated/models/propertyOptional/tsconfig.json +0 -25
- package/test/integration/generated/models/propertyOptional/tspconfig.yaml +0 -14
- package/test/integration/generated/models/propertyTypes/.eslintrc.json +0 -11
- package/test/integration/generated/models/propertyTypes/README.md +0 -56
- package/test/integration/generated/models/propertyTypes/api-extractor.json +0 -18
- package/test/integration/generated/models/propertyTypes/package.json +0 -80
- package/test/integration/generated/models/propertyTypes/rollup.config.js +0 -118
- package/test/integration/generated/models/propertyTypes/src/clientDefinitions.ts +0 -310
- package/test/integration/generated/models/propertyTypes/src/index.ts +0 -13
- package/test/integration/generated/models/propertyTypes/src/logger.ts +0 -5
- package/test/integration/generated/models/propertyTypes/src/models.ts +0 -123
- package/test/integration/generated/models/propertyTypes/src/outputModels.ts +0 -123
- package/test/integration/generated/models/propertyTypes/src/parameters.ts +0 -189
- package/test/integration/generated/models/propertyTypes/src/responses.ts +0 -234
- package/test/integration/generated/models/propertyTypes/src/typePropertyValueTypes.ts +0 -35
- package/test/integration/generated/models/propertyTypes/tsconfig.json +0 -25
- package/test/integration/generated/models/propertyTypes/tspconfig.yaml +0 -14
- package/test/integration/generated/models/usage/.eslintrc.json +0 -11
- package/test/integration/generated/models/usage/README.md +0 -56
- package/test/integration/generated/models/usage/api-extractor.json +0 -18
- package/test/integration/generated/models/usage/package.json +0 -80
- package/test/integration/generated/models/usage/rollup.config.js +0 -118
- package/test/integration/generated/models/usage/src/clientDefinitions.ts +0 -41
- package/test/integration/generated/models/usage/src/index.ts +0 -13
- package/test/integration/generated/models/usage/src/logger.ts +0 -5
- package/test/integration/generated/models/usage/src/models.ts +0 -12
- package/test/integration/generated/models/usage/src/outputModels.ts +0 -12
- package/test/integration/generated/models/usage/src/parameters.ts +0 -19
- package/test/integration/generated/models/usage/src/responses.ts +0 -22
- package/test/integration/generated/models/usage/src/typeModelUsage.ts +0 -35
- package/test/integration/generated/models/usage/tsconfig.json +0 -25
- package/test/integration/generated/models/usage/tspconfig.yaml +0 -14
- package/test/integration/generated/models/visibility/.eslintrc.json +0 -11
- package/test/integration/generated/models/visibility/README.md +0 -56
- package/test/integration/generated/models/visibility/api-extractor.json +0 -18
- package/test/integration/generated/models/visibility/package.json +0 -80
- package/test/integration/generated/models/visibility/rollup.config.js +0 -118
- package/test/integration/generated/models/visibility/src/clientDefinitions.ts +0 -40
- package/test/integration/generated/models/visibility/src/index.ts +0 -13
- package/test/integration/generated/models/visibility/src/logger.ts +0 -5
- package/test/integration/generated/models/visibility/src/models.ts +0 -14
- package/test/integration/generated/models/visibility/src/outputModels.ts +0 -16
- package/test/integration/generated/models/visibility/src/parameters.ts +0 -41
- package/test/integration/generated/models/visibility/src/responses.ts +0 -36
- package/test/integration/generated/models/visibility/src/typeModelVisibility.ts +0 -35
- package/test/integration/generated/models/visibility/tsconfig.json +0 -25
- package/test/integration/generated/models/visibility/tspconfig.yaml +0 -14
- package/test/integration/generated/parameters/collection-format/src/clientDefinitions.ts +0 -63
- package/test/integration/generated/parameters/collection-format/src/collectionFormatClient.ts +0 -35
- package/test/integration/generated/parameters/collection-format/src/index.ts +0 -12
- package/test/integration/generated/parameters/collection-format/src/logger.ts +0 -5
- package/test/integration/generated/parameters/collection-format/src/parameters.ts +0 -71
- package/test/integration/generated/parameters/collection-format/src/responses.ts +0 -34
- package/test/integration/generated/parameters/collection-format/src/serializeHelper.ts +0 -28
- package/test/integration/generated/parameters/collection-format/tspconfig.yaml +0 -14
- package/test/integration/generated/parameters/spread/src/clientDefinitions.ts +0 -61
- package/test/integration/generated/parameters/spread/src/index.ts +0 -12
- package/test/integration/generated/parameters/spread/src/logger.ts +0 -5
- package/test/integration/generated/parameters/spread/src/models.ts +0 -7
- package/test/integration/generated/parameters/spread/src/parameters.ts +0 -61
- package/test/integration/generated/parameters/spread/src/parametersSpread.ts +0 -35
- package/test/integration/generated/parameters/spread/src/responses.ts +0 -25
- package/test/integration/generated/parameters/spread/tspconfig.yaml +0 -12
- package/test/integration/generated/projection/src/clientDefinitions.ts +0 -71
- package/test/integration/generated/projection/src/index.ts +0 -12
- package/test/integration/generated/projection/src/logger.ts +0 -5
- package/test/integration/generated/projection/src/models.ts +0 -22
- package/test/integration/generated/projection/src/parameters.ts +0 -48
- package/test/integration/generated/projection/src/projectionClient.ts +0 -35
- package/test/integration/generated/projection/src/responses.ts +0 -34
- package/test/integration/generated/projection/tspconfig.yaml +0 -14
- package/test/integration/generated/resiliency/srvDriven1/.eslintrc.json +0 -11
- package/test/integration/generated/resiliency/srvDriven1/README.md +0 -56
- package/test/integration/generated/resiliency/srvDriven1/api-extractor.json +0 -18
- package/test/integration/generated/resiliency/srvDriven1/package.json +0 -80
- package/test/integration/generated/resiliency/srvDriven1/rollup.config.js +0 -118
- package/test/integration/generated/resiliency/srvDriven1/src/clientDefinitions.ts +0 -46
- package/test/integration/generated/resiliency/srvDriven1/src/index.ts +0 -11
- package/test/integration/generated/resiliency/srvDriven1/src/logger.ts +0 -5
- package/test/integration/generated/resiliency/srvDriven1/src/parameters.ts +0 -30
- package/test/integration/generated/resiliency/srvDriven1/src/responses.ts +0 -19
- package/test/integration/generated/resiliency/srvDriven1/src/serviceDrivenOldClient.ts +0 -43
- package/test/integration/generated/resiliency/srvDriven1/tsconfig.json +0 -25
- package/test/integration/generated/resiliency/srvDriven1/tspconfig.yaml +0 -15
- package/test/integration/generated/resiliency/srvDriven2/.eslintrc.json +0 -11
- package/test/integration/generated/resiliency/srvDriven2/README.md +0 -65
- package/test/integration/generated/resiliency/srvDriven2/api-extractor.json +0 -18
- package/test/integration/generated/resiliency/srvDriven2/package.json +0 -80
- package/test/integration/generated/resiliency/srvDriven2/rollup.config.js +0 -118
- package/test/integration/generated/resiliency/srvDriven2/src/clientDefinitions.ts +0 -57
- package/test/integration/generated/resiliency/srvDriven2/src/index.ts +0 -11
- package/test/integration/generated/resiliency/srvDriven2/src/logger.ts +0 -5
- package/test/integration/generated/resiliency/srvDriven2/src/parameters.ts +0 -45
- package/test/integration/generated/resiliency/srvDriven2/src/responses.ts +0 -24
- package/test/integration/generated/resiliency/srvDriven2/src/serviceDrivenNewClient.ts +0 -43
- package/test/integration/generated/resiliency/srvDriven2/tsconfig.json +0 -25
- package/test/integration/generated/resiliency/srvDriven2/tspconfig.yaml +0 -15
- package/test/integration/generated/server/path/multiple/src/clientDefinitions.ts +0 -35
- package/test/integration/generated/server/path/multiple/src/index.ts +0 -11
- package/test/integration/generated/server/path/multiple/src/logger.ts +0 -5
- package/test/integration/generated/server/path/multiple/src/multipleParamInServerPathClient.ts +0 -43
- package/test/integration/generated/server/path/multiple/src/parameters.ts +0 -7
- package/test/integration/generated/server/path/multiple/src/responses.ts +0 -14
- package/test/integration/generated/server/path/multiple/tspconfig.yaml +0 -14
- package/test/integration/generated/server/path/single/src/clientDefinitions.ts +0 -19
- package/test/integration/generated/server/path/single/src/index.ts +0 -11
- package/test/integration/generated/server/path/single/src/logger.ts +0 -5
- package/test/integration/generated/server/path/single/src/parameters.ts +0 -6
- package/test/integration/generated/server/path/single/src/responses.ts +0 -9
- package/test/integration/generated/server/path/single/src/singleParamInServerPathClient.ts +0 -38
- package/test/integration/generated/server/path/single/tspconfig.yaml +0 -14
- package/test/integration/generated/specialWords/src/clientDefinitions.ts +0 -61
- package/test/integration/generated/specialWords/src/index.ts +0 -13
- package/test/integration/generated/specialWords/src/logger.ts +0 -5
- package/test/integration/generated/specialWords/src/models.ts +0 -17
- package/test/integration/generated/specialWords/src/outputModels.ts +0 -17
- package/test/integration/generated/specialWords/src/parameters.ts +0 -37
- package/test/integration/generated/specialWords/src/responses.ts +0 -31
- package/test/integration/generated/specialWords/src/specialWordsClient.ts +0 -35
- package/test/integration/generated/specialWords/tspconfig.yaml +0 -14
- package/test/integration/generated/unions/src/clientDefinitions.ts +0 -53
- package/test/integration/generated/unions/src/index.ts +0 -12
- package/test/integration/generated/unions/src/logger.ts +0 -5
- package/test/integration/generated/unions/src/models.ts +0 -27
- package/test/integration/generated/unions/src/parameters.ts +0 -34
- package/test/integration/generated/unions/src/responses.ts +0 -24
- package/test/integration/generated/unions/src/unionsClient.ts +0 -35
- package/test/integration/generated/unions/tspconfig.yaml +0 -14
- package/test/integration/internal.spec.ts +0 -76
- package/test/integration/lroCore.spec.ts +0 -89
- package/test/integration/modelInheritance.spec.ts +0 -192
- package/test/integration/modelPropertyNullable.spec.ts +0 -115
- package/test/integration/modelPropertyOptional.spec.ts +0 -362
- package/test/integration/modelPropertyType.spec.ts +0 -135
- package/test/integration/modelUsage.spec.ts +0 -47
- package/test/integration/projection.spec.ts +0 -102
- package/test/integration/resiliencyDpgCustomization.spec.ts +0 -147
- package/test/integration/server.spec.ts +0 -59
- package/test/integration/specialWords.spec.ts +0 -73
- package/test/integration/spreadParameters.spec.ts +0 -82
- package/test/integration/unions.spec.ts +0 -69
- package/test/tsconfig.json +0 -4
- package/test/unit/apiVersion.spec.ts +0 -400
- package/test/unit/azureCoreOperationsGenerator.spec.ts +0 -71
- package/test/unit/clientDefinitionGenerator.spec.ts +0 -73
- package/test/unit/clientFactoryGenerator.spec.ts +0 -404
- package/test/unit/docsGenerator.spec.ts +0 -201
- package/test/unit/modelsGenerator.spec.ts +0 -1529
- package/test/unit/parametersGenerator.spec.ts +0 -561
- package/test/unit/responsesGenerator.spec.ts +0 -462
- package/test/unit/spreadAndAlias.spec.ts +0 -200
- package/test/unit/util/emitUtil.ts +0 -166
- package/test/unit/util/testUtil.ts +0 -88
- package/test/util/customBearerTokenTestingPolicy.ts +0 -78
- package/test/util/matrix.ts +0 -48
- package/tsconfig.json +0 -36
- package/tsconfig.test.json +0 -7
- package/typespec-ts.build.log +0 -1
|
@@ -1,404 +0,0 @@
|
|
|
1
|
-
import { assert } from "chai";
|
|
2
|
-
import { emitClientFactoryFromCadl } from "./util/emitUtil.js";
|
|
3
|
-
import { assertEqualContent } from "./util/testUtil.js";
|
|
4
|
-
|
|
5
|
-
describe("Client Factory generation", () => {
|
|
6
|
-
describe("should handle url parameters", () => {
|
|
7
|
-
it("should handle zero parameter", async () => {
|
|
8
|
-
const models = await emitClientFactoryFromCadl(`
|
|
9
|
-
@server(
|
|
10
|
-
"localhost",
|
|
11
|
-
"Language Service"
|
|
12
|
-
)
|
|
13
|
-
@service( {title: "PetStoreClient"})
|
|
14
|
-
namespace PetStore;
|
|
15
|
-
`);
|
|
16
|
-
assert.ok(models);
|
|
17
|
-
assertEqualContent(
|
|
18
|
-
models!.content,
|
|
19
|
-
`
|
|
20
|
-
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
21
|
-
import { logger } from "./logger";
|
|
22
|
-
import { testClient } from "./clientDefinitions";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Initialize a new instance of \`testClient\`
|
|
26
|
-
* @param options - the parameter for all optional parameters
|
|
27
|
-
*/
|
|
28
|
-
export default function createClient(options: ClientOptions = {}): testClient {
|
|
29
|
-
const baseUrl = options.baseUrl ?? \`localhost\`;
|
|
30
|
-
|
|
31
|
-
const userAgentInfo = \`azsdk-js--rest/1.0.0-beta.1\`;
|
|
32
|
-
const userAgentPrefix =
|
|
33
|
-
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
34
|
-
? \`\${options.userAgentOptions.userAgentPrefix} \${userAgentInfo}\`
|
|
35
|
-
: \`\${userAgentInfo}\`;
|
|
36
|
-
options = {
|
|
37
|
-
...options,
|
|
38
|
-
userAgentOptions: {
|
|
39
|
-
userAgentPrefix,
|
|
40
|
-
},
|
|
41
|
-
loggingOptions: {
|
|
42
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const client = getClient(baseUrl, options) as testClient;
|
|
47
|
-
|
|
48
|
-
return client;
|
|
49
|
-
}
|
|
50
|
-
`
|
|
51
|
-
);
|
|
52
|
-
});
|
|
53
|
-
it("should handle one parameter", async () => {
|
|
54
|
-
const models = await emitClientFactoryFromCadl(`
|
|
55
|
-
@server(
|
|
56
|
-
"{Endpoint}/language",
|
|
57
|
-
"Language Service",
|
|
58
|
-
{
|
|
59
|
-
Endpoint: Endpoint,
|
|
60
|
-
}
|
|
61
|
-
)
|
|
62
|
-
@service( {title: "PetStoreClient"})
|
|
63
|
-
namespace PetStore;
|
|
64
|
-
@doc("The endpoint to use.")
|
|
65
|
-
scalar Endpoint extends string;
|
|
66
|
-
`);
|
|
67
|
-
assert.ok(models);
|
|
68
|
-
assertEqualContent(
|
|
69
|
-
models!.content,
|
|
70
|
-
`
|
|
71
|
-
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
72
|
-
import { logger } from "./logger";
|
|
73
|
-
import { testClient } from "./clientDefinitions";
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Initialize a new instance of \`testClient\`
|
|
77
|
-
* @param endpoint - The endpoint to use.
|
|
78
|
-
* @param options - the parameter for all optional parameters
|
|
79
|
-
*/
|
|
80
|
-
export default function createClient(
|
|
81
|
-
endpoint: string,
|
|
82
|
-
options: ClientOptions = {}
|
|
83
|
-
): testClient {
|
|
84
|
-
const baseUrl = options.baseUrl ?? \`\${endpoint}/language\`;
|
|
85
|
-
|
|
86
|
-
const userAgentInfo = \`azsdk-js--rest/1.0.0-beta.1\`;
|
|
87
|
-
const userAgentPrefix =
|
|
88
|
-
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
89
|
-
? \`\${options.userAgentOptions.userAgentPrefix} \${userAgentInfo}\`
|
|
90
|
-
: \`\${userAgentInfo}\`;
|
|
91
|
-
options = {
|
|
92
|
-
...options,
|
|
93
|
-
userAgentOptions: {
|
|
94
|
-
userAgentPrefix,
|
|
95
|
-
},
|
|
96
|
-
loggingOptions: {
|
|
97
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
const client = getClient(baseUrl, options) as testClient;
|
|
102
|
-
|
|
103
|
-
return client;
|
|
104
|
-
}
|
|
105
|
-
`
|
|
106
|
-
);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it("should handle two parameters", async () => {
|
|
110
|
-
const models = await emitClientFactoryFromCadl(
|
|
111
|
-
`
|
|
112
|
-
@server(
|
|
113
|
-
"{Endpoint}/language/{Version}",
|
|
114
|
-
"Language Service",
|
|
115
|
-
{
|
|
116
|
-
Endpoint: Endpoint,
|
|
117
|
-
Version: Version
|
|
118
|
-
}
|
|
119
|
-
)
|
|
120
|
-
@service( {title: "PetStoreClient"})
|
|
121
|
-
namespace PetStore;
|
|
122
|
-
@doc("The endpoint to use.")
|
|
123
|
-
scalar Endpoint extends string;
|
|
124
|
-
|
|
125
|
-
#suppress "@azure-tools/typespec-azure-core/use-extensible-enum" "for test"
|
|
126
|
-
@doc("The version to use")
|
|
127
|
-
@fixed
|
|
128
|
-
enum Version {
|
|
129
|
-
V1,
|
|
130
|
-
V2
|
|
131
|
-
}
|
|
132
|
-
`,
|
|
133
|
-
true
|
|
134
|
-
);
|
|
135
|
-
assert.ok(models);
|
|
136
|
-
assertEqualContent(
|
|
137
|
-
models!.content,
|
|
138
|
-
`
|
|
139
|
-
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
140
|
-
import { logger } from "./logger";
|
|
141
|
-
import { testClient } from "./clientDefinitions";
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Initialize a new instance of \`testClient\`
|
|
145
|
-
* @param endpoint - The endpoint to use.
|
|
146
|
-
* @param version - The version to use
|
|
147
|
-
* @param options - the parameter for all optional parameters
|
|
148
|
-
*/
|
|
149
|
-
export default function createClient(
|
|
150
|
-
endpoint: string,
|
|
151
|
-
version: "V1" | "V2",
|
|
152
|
-
options: ClientOptions = {}
|
|
153
|
-
): testClient {
|
|
154
|
-
const baseUrl = options.baseUrl ?? \`\${endpoint}/language/\${version}\`;
|
|
155
|
-
|
|
156
|
-
const userAgentInfo = \`azsdk-js--rest/1.0.0-beta.1\`;
|
|
157
|
-
const userAgentPrefix =
|
|
158
|
-
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
159
|
-
? \`\${options.userAgentOptions.userAgentPrefix} \${userAgentInfo}\`
|
|
160
|
-
: \`\${userAgentInfo}\`;
|
|
161
|
-
options = {
|
|
162
|
-
...options,
|
|
163
|
-
userAgentOptions: {
|
|
164
|
-
userAgentPrefix,
|
|
165
|
-
},
|
|
166
|
-
loggingOptions: {
|
|
167
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const client = getClient(baseUrl, options) as testClient;
|
|
172
|
-
|
|
173
|
-
return client;
|
|
174
|
-
}
|
|
175
|
-
`
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
it("should handle extensible enums in host parameters", async () => {
|
|
179
|
-
const models = await emitClientFactoryFromCadl(
|
|
180
|
-
`
|
|
181
|
-
@server(
|
|
182
|
-
"{Endpoint}/language/{Version}",
|
|
183
|
-
"Language Service",
|
|
184
|
-
{
|
|
185
|
-
Endpoint: Endpoint,
|
|
186
|
-
Version: Versions
|
|
187
|
-
}
|
|
188
|
-
)
|
|
189
|
-
@service( {title: "PetStoreClient"})
|
|
190
|
-
namespace PetStore;
|
|
191
|
-
@doc("The endpoint to use.")
|
|
192
|
-
scalar Endpoint extends string;
|
|
193
|
-
|
|
194
|
-
@doc("The version to use.")
|
|
195
|
-
enum Versions {
|
|
196
|
-
v1_1: "v1.1",
|
|
197
|
-
}
|
|
198
|
-
`,
|
|
199
|
-
true
|
|
200
|
-
);
|
|
201
|
-
assert.ok(models);
|
|
202
|
-
assertEqualContent(
|
|
203
|
-
models!.content,
|
|
204
|
-
`
|
|
205
|
-
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
206
|
-
import { logger } from "./logger";
|
|
207
|
-
import { testClient } from "./clientDefinitions";
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Initialize a new instance of \`testClient\`
|
|
211
|
-
* @param endpoint - The endpoint to use.
|
|
212
|
-
* @param version - The version to use. Possible values: v1.1
|
|
213
|
-
* @param options - the parameter for all optional parameters
|
|
214
|
-
*/
|
|
215
|
-
export default function createClient(
|
|
216
|
-
endpoint: string,
|
|
217
|
-
version: string,
|
|
218
|
-
options: ClientOptions = {}
|
|
219
|
-
): testClient {
|
|
220
|
-
const baseUrl = options.baseUrl ?? \`\${endpoint}/language/\${version}\`;
|
|
221
|
-
|
|
222
|
-
const userAgentInfo = \`azsdk-js--rest/1.0.0-beta.1\`;
|
|
223
|
-
const userAgentPrefix =
|
|
224
|
-
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
225
|
-
? \`\${options.userAgentOptions.userAgentPrefix} \${userAgentInfo}\`
|
|
226
|
-
: \`\${userAgentInfo}\`;
|
|
227
|
-
options = {
|
|
228
|
-
...options,
|
|
229
|
-
userAgentOptions: {
|
|
230
|
-
userAgentPrefix,
|
|
231
|
-
},
|
|
232
|
-
loggingOptions: {
|
|
233
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
const client = getClient(baseUrl, options) as testClient;
|
|
238
|
-
|
|
239
|
-
return client;
|
|
240
|
-
}
|
|
241
|
-
`
|
|
242
|
-
);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
describe("should handle no @server definition", () => {
|
|
247
|
-
it("should set default endpoint parameter when no @server", async () => {
|
|
248
|
-
const models = await emitClientFactoryFromCadl(`
|
|
249
|
-
@service( {title: "PetStoreClient"})
|
|
250
|
-
namespace PetStore;
|
|
251
|
-
`);
|
|
252
|
-
assert.ok(models);
|
|
253
|
-
assertEqualContent(
|
|
254
|
-
models!.content,
|
|
255
|
-
`
|
|
256
|
-
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
257
|
-
import { logger } from "./logger";
|
|
258
|
-
import { testClient } from "./clientDefinitions";
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Initialize a new instance of \`testClient\`
|
|
262
|
-
* @param endpoint - The parameter endpoint
|
|
263
|
-
* @param options - the parameter for all optional parameters
|
|
264
|
-
*/
|
|
265
|
-
export default function createClient(endpoint: string, options: ClientOptions = {}): testClient {
|
|
266
|
-
const baseUrl = options.baseUrl ?? \`\${endpoint}\`;
|
|
267
|
-
|
|
268
|
-
const userAgentInfo = \`azsdk-js--rest/1.0.0-beta.1\`;
|
|
269
|
-
const userAgentPrefix =
|
|
270
|
-
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
271
|
-
? \`\${options.userAgentOptions.userAgentPrefix} \${userAgentInfo}\`
|
|
272
|
-
: \`\${userAgentInfo}\`;
|
|
273
|
-
options = {
|
|
274
|
-
...options,
|
|
275
|
-
userAgentOptions: {
|
|
276
|
-
userAgentPrefix,
|
|
277
|
-
},
|
|
278
|
-
loggingOptions: {
|
|
279
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
280
|
-
},
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
const client = getClient(baseUrl, options) as testClient;
|
|
284
|
-
|
|
285
|
-
return client;
|
|
286
|
-
}
|
|
287
|
-
`
|
|
288
|
-
);
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
describe("should handle different auth options", () => {
|
|
293
|
-
it("should not generate credential if scope is empty", async () => {
|
|
294
|
-
const models = await emitClientFactoryFromCadl(`
|
|
295
|
-
@useAuth(
|
|
296
|
-
OAuth2Auth<[{
|
|
297
|
-
type: OAuth2FlowType.implicit,
|
|
298
|
-
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
|
299
|
-
scopes: []
|
|
300
|
-
}]>)
|
|
301
|
-
@service( {title: "PetStoreClient"})
|
|
302
|
-
namespace PetStore;
|
|
303
|
-
`);
|
|
304
|
-
assert.ok(models);
|
|
305
|
-
assertEqualContent(
|
|
306
|
-
models!.content,
|
|
307
|
-
`
|
|
308
|
-
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
309
|
-
import { logger } from "./logger";
|
|
310
|
-
import { testClient } from "./clientDefinitions";
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Initialize a new instance of \`testClient\`
|
|
314
|
-
* @param endpoint - The parameter endpoint
|
|
315
|
-
* @param options - the parameter for all optional parameters
|
|
316
|
-
*/
|
|
317
|
-
export default function createClient(endpoint: string, options: ClientOptions = {}): testClient {
|
|
318
|
-
const baseUrl = options.baseUrl ?? \`\${endpoint}\`;
|
|
319
|
-
|
|
320
|
-
const userAgentInfo = \`azsdk-js--rest/1.0.0-beta.1\`;
|
|
321
|
-
const userAgentPrefix =
|
|
322
|
-
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
323
|
-
? \`\${options.userAgentOptions.userAgentPrefix} \${userAgentInfo}\`
|
|
324
|
-
: \`\${userAgentInfo}\`;
|
|
325
|
-
options = {
|
|
326
|
-
...options,
|
|
327
|
-
userAgentOptions: {
|
|
328
|
-
userAgentPrefix,
|
|
329
|
-
},
|
|
330
|
-
loggingOptions: {
|
|
331
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
332
|
-
},
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
const client = getClient(baseUrl, options) as testClient;
|
|
336
|
-
|
|
337
|
-
return client;
|
|
338
|
-
}
|
|
339
|
-
`
|
|
340
|
-
);
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
it("should generate both credentials if both defined", async () => {
|
|
344
|
-
const models = await emitClientFactoryFromCadl(`
|
|
345
|
-
@useAuth(
|
|
346
|
-
ApiKeyAuth<ApiKeyLocation.header, "apiKey"> |
|
|
347
|
-
OAuth2Auth<[{
|
|
348
|
-
type: OAuth2FlowType.implicit,
|
|
349
|
-
authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
|
350
|
-
scopes: ["https://petstor.com/default"]
|
|
351
|
-
}]>)
|
|
352
|
-
@service( {title: "PetStoreClient"})
|
|
353
|
-
namespace PetStore;
|
|
354
|
-
`);
|
|
355
|
-
assert.ok(models);
|
|
356
|
-
assertEqualContent(
|
|
357
|
-
models!.content,
|
|
358
|
-
`
|
|
359
|
-
import { getClient, ClientOptions } from "@azure-rest/core-client";
|
|
360
|
-
import { logger } from "./logger";
|
|
361
|
-
import { TokenCredential, KeyCredential } from "@azure/core-auth";
|
|
362
|
-
import { testClient } from "./clientDefinitions";
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Initialize a new instance of \`testClient\`
|
|
366
|
-
* @param endpoint - The parameter endpoint
|
|
367
|
-
* @param credentials - uniquely identify client credential
|
|
368
|
-
* @param options - the parameter for all optional parameters
|
|
369
|
-
*/
|
|
370
|
-
export default function createClient(endpoint: string, credentials: TokenCredential | KeyCredential, options: ClientOptions = {}): testClient {
|
|
371
|
-
const baseUrl = options.baseUrl ?? \`\${endpoint}\`;
|
|
372
|
-
|
|
373
|
-
options = {
|
|
374
|
-
...options,
|
|
375
|
-
credentials: {
|
|
376
|
-
scopes: ["https://petstor.com/default"],
|
|
377
|
-
apiKeyHeaderName: "apiKey",
|
|
378
|
-
},
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
const userAgentInfo = \`azsdk-js--rest/1.0.0-beta.1\`;
|
|
382
|
-
const userAgentPrefix =
|
|
383
|
-
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
384
|
-
? \`\${options.userAgentOptions.userAgentPrefix} \${userAgentInfo}\`
|
|
385
|
-
: \`\${userAgentInfo}\`;
|
|
386
|
-
options = {
|
|
387
|
-
...options,
|
|
388
|
-
userAgentOptions: {
|
|
389
|
-
userAgentPrefix,
|
|
390
|
-
},
|
|
391
|
-
loggingOptions: {
|
|
392
|
-
logger: options.loggingOptions?.logger ?? logger.info
|
|
393
|
-
},
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
const client = getClient(baseUrl, credentials, options) as testClient;
|
|
397
|
-
|
|
398
|
-
return client;
|
|
399
|
-
}
|
|
400
|
-
`
|
|
401
|
-
);
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
});
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { assert } from "chai";
|
|
2
|
-
import {
|
|
3
|
-
emitClientDefinitionFromCadl,
|
|
4
|
-
emitModelsFromCadl,
|
|
5
|
-
emitParameterFromCadl
|
|
6
|
-
} from "./util/emitUtil.js";
|
|
7
|
-
import { assertEqualContent } from "./util/testUtil.js";
|
|
8
|
-
|
|
9
|
-
describe("Doc generation testing", () => {
|
|
10
|
-
describe("docs in models.ts & outputModels.ts", () => {
|
|
11
|
-
it("should generate model-level and property-level docs in input model", async () => {
|
|
12
|
-
const models = await emitModelsFromCadl(`
|
|
13
|
-
@doc("A simple model with doc")
|
|
14
|
-
model SimpleModel {
|
|
15
|
-
@doc("A test property.")
|
|
16
|
-
prop: string;
|
|
17
|
-
}
|
|
18
|
-
op read(): { @body body: SimpleModel };
|
|
19
|
-
`);
|
|
20
|
-
assert.ok(models);
|
|
21
|
-
assertEqualContent(
|
|
22
|
-
models!.outputModelFile!.content,
|
|
23
|
-
`
|
|
24
|
-
/** A simple model with doc */
|
|
25
|
-
export interface SimpleModelOutput {
|
|
26
|
-
/** A test property. */
|
|
27
|
-
prop: string;
|
|
28
|
-
}
|
|
29
|
-
`
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
describe("docs in parameters.ts", () => {
|
|
35
|
-
it("should generate body description", async () => {
|
|
36
|
-
const parameters = await emitParameterFromCadl(
|
|
37
|
-
`
|
|
38
|
-
model UserDetailsParameter {
|
|
39
|
-
@body
|
|
40
|
-
@doc("Details about username.")
|
|
41
|
-
username: string;
|
|
42
|
-
}
|
|
43
|
-
op createOrUpdateUser(...UserDetailsParameter): OkResponse;
|
|
44
|
-
`
|
|
45
|
-
);
|
|
46
|
-
assert.ok(parameters);
|
|
47
|
-
assertEqualContent(
|
|
48
|
-
parameters?.content!,
|
|
49
|
-
`
|
|
50
|
-
import { RequestParameters } from "@azure-rest/core-client";
|
|
51
|
-
|
|
52
|
-
export interface CreateOrUpdateUserBodyParam {
|
|
53
|
-
/** Details about username. */
|
|
54
|
-
body: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export type CreateOrUpdateUserParameters = CreateOrUpdateUserBodyParam & RequestParameters;
|
|
58
|
-
`
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
it("shouldn't generate type description as body property description", async () => {
|
|
62
|
-
const parameters = await emitParameterFromCadl(
|
|
63
|
-
`
|
|
64
|
-
@doc("Body type details")
|
|
65
|
-
model UserDetailsParameter {
|
|
66
|
-
username: string;
|
|
67
|
-
}
|
|
68
|
-
op createOrUpdateUser(@body username: UserDetailsParameter): OkResponse;
|
|
69
|
-
`
|
|
70
|
-
);
|
|
71
|
-
assert.ok(parameters);
|
|
72
|
-
assertEqualContent(
|
|
73
|
-
parameters?.content!,
|
|
74
|
-
`
|
|
75
|
-
import { RequestParameters } from "@azure-rest/core-client";
|
|
76
|
-
import { UserDetailsParameter } from "./models";
|
|
77
|
-
|
|
78
|
-
export interface CreateOrUpdateUserBodyParam {
|
|
79
|
-
body: UserDetailsParameter;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export type CreateOrUpdateUserParameters = CreateOrUpdateUserBodyParam & RequestParameters;
|
|
83
|
-
`
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
it("should generate query description", async () => {
|
|
87
|
-
const parameters = await emitParameterFromCadl(
|
|
88
|
-
`
|
|
89
|
-
@doc("The filter query parameter.")
|
|
90
|
-
model FilterParameter {
|
|
91
|
-
@query
|
|
92
|
-
@doc("Input your filter condition.")
|
|
93
|
-
filter: string;
|
|
94
|
-
}
|
|
95
|
-
op list(...FilterParameter): OkResponse;
|
|
96
|
-
`
|
|
97
|
-
);
|
|
98
|
-
assert.ok(parameters);
|
|
99
|
-
assertEqualContent(
|
|
100
|
-
parameters?.content!,
|
|
101
|
-
`
|
|
102
|
-
import { RequestParameters } from "@azure-rest/core-client";
|
|
103
|
-
|
|
104
|
-
export interface ListQueryParamProperties {
|
|
105
|
-
/** Input your filter condition. */
|
|
106
|
-
filter: string;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export interface ListQueryParam {
|
|
110
|
-
queryParameters: ListQueryParamProperties;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export type ListParameters = ListQueryParam & RequestParameters;
|
|
114
|
-
`
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
it("should generate header description with custom name", async () => {
|
|
118
|
-
const parameters = await emitParameterFromCadl(
|
|
119
|
-
`
|
|
120
|
-
op test(@doc("test header") @header("x-my-header") MyHeader: string): string;
|
|
121
|
-
`
|
|
122
|
-
);
|
|
123
|
-
assert.ok(parameters);
|
|
124
|
-
assertEqualContent(
|
|
125
|
-
parameters?.content!,
|
|
126
|
-
`
|
|
127
|
-
import { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
|
|
128
|
-
import { RequestParameters } from "@azure-rest/core-client";
|
|
129
|
-
|
|
130
|
-
export interface TestHeaders {
|
|
131
|
-
/** test header */
|
|
132
|
-
"x-my-header": string;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export interface TestHeaderParam {
|
|
136
|
-
headers: RawHttpHeadersInput & TestHeaders;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export type TestParameters = TestHeaderParam & RequestParameters;
|
|
140
|
-
`
|
|
141
|
-
);
|
|
142
|
-
});
|
|
143
|
-
it("should generate contentType description", async () => {
|
|
144
|
-
const parameters = await emitParameterFromCadl(
|
|
145
|
-
`
|
|
146
|
-
#suppress "@typespec/http/content-type-ignored" "for test"
|
|
147
|
-
op test(@doc("content type") @header contentType: "application/octet-stream"): string;
|
|
148
|
-
`
|
|
149
|
-
);
|
|
150
|
-
assert.ok(parameters);
|
|
151
|
-
assertEqualContent(
|
|
152
|
-
parameters?.content!,
|
|
153
|
-
`
|
|
154
|
-
import { RequestParameters } from "@azure-rest/core-client";
|
|
155
|
-
|
|
156
|
-
export interface TestMediaTypesParam {
|
|
157
|
-
/** content type */
|
|
158
|
-
contentType: "application/octet-stream";
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export type TestParameters = TestMediaTypesParam & RequestParameters;
|
|
162
|
-
`
|
|
163
|
-
);
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
describe("docs in clientDefinitions.ts", () => {
|
|
168
|
-
it("should generate operation description", async () => {
|
|
169
|
-
const clientDef = await emitClientDefinitionFromCadl(
|
|
170
|
-
`
|
|
171
|
-
@summary("This is a summary")
|
|
172
|
-
@doc("This is the longer description")
|
|
173
|
-
op read(): {};
|
|
174
|
-
`
|
|
175
|
-
);
|
|
176
|
-
assert.ok(clientDef);
|
|
177
|
-
assertEqualContent(
|
|
178
|
-
clientDef?.content!,
|
|
179
|
-
`
|
|
180
|
-
import { ReadParameters } from "./parameters";
|
|
181
|
-
import { Read200Response } from "./responses";
|
|
182
|
-
import { Client, StreamableMethod } from "@azure-rest/core-client";
|
|
183
|
-
|
|
184
|
-
export interface Read {
|
|
185
|
-
/** This is the longer description */
|
|
186
|
-
get(options?: ReadParameters): StreamableMethod<Read200Response>;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export interface Routes {
|
|
190
|
-
/** Resource for '/' has methods for the following verbs: get */
|
|
191
|
-
(path: "/"): Read;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
export type testClient = Client & {
|
|
195
|
-
path: Routes;
|
|
196
|
-
};
|
|
197
|
-
`
|
|
198
|
-
);
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
});
|