@azure-tools/typespec-ts 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (353) hide show
  1. package/.eslintrc.json +23 -0
  2. package/.prettierignore +1 -0
  3. package/.prettierrc +7 -0
  4. package/.rush/temp/package-deps_build.json +303 -0
  5. package/.rush/temp/shrinkwrap-deps.json +469 -0
  6. package/CHANGELOG.md +65 -0
  7. package/CONTRIBUTING.md +134 -0
  8. package/README.md +150 -0
  9. package/dist/src/emitUtil.d.ts +6 -0
  10. package/dist/src/emitUtil.d.ts.map +1 -0
  11. package/dist/src/emitUtil.js +45 -0
  12. package/dist/src/emitUtil.js.map +1 -0
  13. package/dist/src/index.d.ts +3 -0
  14. package/dist/src/index.d.ts.map +1 -0
  15. package/dist/src/index.js +59 -0
  16. package/dist/src/index.js.map +1 -0
  17. package/dist/src/lib.d.ts +159 -0
  18. package/dist/src/lib.d.ts.map +1 -0
  19. package/dist/src/lib.js +189 -0
  20. package/dist/src/lib.js.map +1 -0
  21. package/dist/src/modelUtils.d.ts +12 -0
  22. package/dist/src/modelUtils.d.ts.map +1 -0
  23. package/dist/src/modelUtils.js +812 -0
  24. package/dist/src/modelUtils.js.map +1 -0
  25. package/dist/src/operationUtil.d.ts +16 -0
  26. package/dist/src/operationUtil.d.ts.map +1 -0
  27. package/dist/src/operationUtil.js +142 -0
  28. package/dist/src/operationUtil.js.map +1 -0
  29. package/dist/src/transform/transform.d.ts +8 -0
  30. package/dist/src/transform/transform.d.ts.map +1 -0
  31. package/dist/src/transform/transform.js +131 -0
  32. package/dist/src/transform/transform.js.map +1 -0
  33. package/dist/src/transform/transformAnnotationDetails.d.ts +6 -0
  34. package/dist/src/transform/transformAnnotationDetails.d.ts.map +1 -0
  35. package/dist/src/transform/transformAnnotationDetails.js +188 -0
  36. package/dist/src/transform/transformAnnotationDetails.js.map +1 -0
  37. package/dist/src/transform/transformApiVersionParam.d.ts +5 -0
  38. package/dist/src/transform/transformApiVersionParam.d.ts.map +1 -0
  39. package/dist/src/transform/transformApiVersionParam.js +76 -0
  40. package/dist/src/transform/transformApiVersionParam.js.map +1 -0
  41. package/dist/src/transform/transformParameters.d.ts +14 -0
  42. package/dist/src/transform/transformParameters.d.ts.map +1 -0
  43. package/dist/src/transform/transformParameters.js +315 -0
  44. package/dist/src/transform/transformParameters.js.map +1 -0
  45. package/dist/src/transform/transformPaths.d.ts +10 -0
  46. package/dist/src/transform/transformPaths.d.ts.map +1 -0
  47. package/dist/src/transform/transformPaths.js +124 -0
  48. package/dist/src/transform/transformPaths.js.map +1 -0
  49. package/dist/src/transform/transformResponses.d.ts +5 -0
  50. package/dist/src/transform/transformResponses.d.ts.map +1 -0
  51. package/dist/src/transform/transformResponses.js +136 -0
  52. package/dist/src/transform/transformResponses.js.map +1 -0
  53. package/dist/src/transform/transformSchemas.d.ts +4 -0
  54. package/dist/src/transform/transformSchemas.d.ts.map +1 -0
  55. package/dist/src/transform/transformSchemas.js +175 -0
  56. package/dist/src/transform/transformSchemas.js.map +1 -0
  57. package/dist/src/transform/transfromRLCOptions.d.ts +10 -0
  58. package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -0
  59. package/dist/src/transform/transfromRLCOptions.js +156 -0
  60. package/dist/src/transform/transfromRLCOptions.js.map +1 -0
  61. package/dist/tsconfig.tsbuildinfo +1 -0
  62. package/package.json +73 -0
  63. package/src/emitUtil.ts +63 -0
  64. package/src/index.ts +106 -0
  65. package/src/lib.ts +207 -0
  66. package/src/modelUtils.ts +961 -0
  67. package/src/operationUtil.ts +203 -0
  68. package/src/transform/transform.ts +224 -0
  69. package/src/transform/transformAnnotationDetails.ts +231 -0
  70. package/src/transform/transformApiVersionParam.ts +104 -0
  71. package/src/transform/transformParameters.ts +480 -0
  72. package/src/transform/transformPaths.ts +187 -0
  73. package/src/transform/transformResponses.ts +190 -0
  74. package/src/transform/transformSchemas.ts +209 -0
  75. package/src/transform/transfromRLCOptions.ts +202 -0
  76. package/test/commands/cadl-ranch-list.ts +83 -0
  77. package/test/commands/check-clean-tree.ts +55 -0
  78. package/test/commands/childProcessOnExit.ts +16 -0
  79. package/test/commands/gen-cadl-ranch.ts +21 -0
  80. package/test/commands/run.ts +41 -0
  81. package/test/integration/arrayItemTypes.spec.ts +93 -0
  82. package/test/integration/authApiKey.spec.ts +38 -0
  83. package/test/integration/authOauth2.spec.ts +65 -0
  84. package/test/integration/authUnion.spec.ts +72 -0
  85. package/test/integration/dictionary.spec.ts +102 -0
  86. package/test/integration/extensibleEnums.spec.ts +61 -0
  87. package/test/integration/fixedEnums.spec.ts +52 -0
  88. package/test/integration/generated/arrays/itemTypes/src/arrayItemTypesClient.ts +31 -0
  89. package/test/integration/generated/arrays/itemTypes/src/clientDefinitions.ts +150 -0
  90. package/test/integration/generated/arrays/itemTypes/src/index.ts +13 -0
  91. package/test/integration/generated/arrays/itemTypes/src/models.ts +9 -0
  92. package/test/integration/generated/arrays/itemTypes/src/outputModels.ts +9 -0
  93. package/test/integration/generated/arrays/itemTypes/src/parameters.ts +78 -0
  94. package/test/integration/generated/arrays/itemTypes/src/responses.ts +104 -0
  95. package/test/integration/generated/arrays/itemTypes/tspconfig.yaml +12 -0
  96. package/test/integration/generated/authentication/apiKey/.eslintrc.json +11 -0
  97. package/test/integration/generated/authentication/apiKey/README.md +56 -0
  98. package/test/integration/generated/authentication/apiKey/api-extractor.json +18 -0
  99. package/test/integration/generated/authentication/apiKey/karma.conf.js +133 -0
  100. package/test/integration/generated/authentication/apiKey/package.json +103 -0
  101. package/test/integration/generated/authentication/apiKey/rollup.config.js +118 -0
  102. package/test/integration/generated/authentication/apiKey/src/authApiKeyClient.ts +41 -0
  103. package/test/integration/generated/authentication/apiKey/src/clientDefinitions.ts +33 -0
  104. package/test/integration/generated/authentication/apiKey/src/index.ts +12 -0
  105. package/test/integration/generated/authentication/apiKey/src/outputModels.ts +6 -0
  106. package/test/integration/generated/authentication/apiKey/src/parameters.ts +7 -0
  107. package/test/integration/generated/authentication/apiKey/src/responses.ts +21 -0
  108. package/test/integration/generated/authentication/apiKey/test/public/sampleTest.spec.ts +23 -0
  109. package/test/integration/generated/authentication/apiKey/test/public/utils/env.browser.ts +2 -0
  110. package/test/integration/generated/authentication/apiKey/test/public/utils/env.ts +6 -0
  111. package/test/integration/generated/authentication/apiKey/test/public/utils/recordedClient.ts +29 -0
  112. package/test/integration/generated/authentication/apiKey/tsconfig.json +25 -0
  113. package/test/integration/generated/authentication/apiKey/tspconfig.yaml +10 -0
  114. package/test/integration/generated/authentication/oauth2/karma.conf.js +133 -0
  115. package/test/integration/generated/authentication/oauth2/src/authOauth2Client.ts +41 -0
  116. package/test/integration/generated/authentication/oauth2/src/clientDefinitions.ts +33 -0
  117. package/test/integration/generated/authentication/oauth2/src/index.ts +12 -0
  118. package/test/integration/generated/authentication/oauth2/src/outputModels.ts +6 -0
  119. package/test/integration/generated/authentication/oauth2/src/parameters.ts +7 -0
  120. package/test/integration/generated/authentication/oauth2/src/responses.ts +21 -0
  121. package/test/integration/generated/authentication/oauth2/test/public/sampleTest.spec.ts +23 -0
  122. package/test/integration/generated/authentication/oauth2/test/public/utils/env.browser.ts +2 -0
  123. package/test/integration/generated/authentication/oauth2/test/public/utils/env.ts +6 -0
  124. package/test/integration/generated/authentication/oauth2/test/public/utils/recordedClient.ts +29 -0
  125. package/test/integration/generated/authentication/oauth2/tspconfig.yaml +12 -0
  126. package/test/integration/generated/authentication/union/karma.conf.js +133 -0
  127. package/test/integration/generated/authentication/union/src/authUnionClient.ts +42 -0
  128. package/test/integration/generated/authentication/union/src/clientDefinitions.ts +27 -0
  129. package/test/integration/generated/authentication/union/src/index.ts +11 -0
  130. package/test/integration/generated/authentication/union/src/parameters.ts +7 -0
  131. package/test/integration/generated/authentication/union/src/responses.ts +14 -0
  132. package/test/integration/generated/authentication/union/test/public/sampleTest.spec.ts +23 -0
  133. package/test/integration/generated/authentication/union/test/public/utils/env.browser.ts +2 -0
  134. package/test/integration/generated/authentication/union/test/public/utils/env.ts +6 -0
  135. package/test/integration/generated/authentication/union/test/public/utils/recordedClient.ts +29 -0
  136. package/test/integration/generated/authentication/union/tspconfig.yaml +12 -0
  137. package/test/integration/generated/dictionary/.eslintrc.json +11 -0
  138. package/test/integration/generated/dictionary/README.md +56 -0
  139. package/test/integration/generated/dictionary/api-extractor.json +18 -0
  140. package/test/integration/generated/dictionary/package.json +80 -0
  141. package/test/integration/generated/dictionary/rollup.config.js +118 -0
  142. package/test/integration/generated/dictionary/src/clientDefinitions.ts +165 -0
  143. package/test/integration/generated/dictionary/src/dictClient.ts +29 -0
  144. package/test/integration/generated/dictionary/src/index.ts +13 -0
  145. package/test/integration/generated/dictionary/src/models.ts +9 -0
  146. package/test/integration/generated/dictionary/src/outputModels.ts +9 -0
  147. package/test/integration/generated/dictionary/src/parameters.ts +86 -0
  148. package/test/integration/generated/dictionary/src/responses.ts +115 -0
  149. package/test/integration/generated/dictionary/tsconfig.json +25 -0
  150. package/test/integration/generated/dictionary/tspconfig.yaml +12 -0
  151. package/test/integration/generated/enums/extensible/.eslintrc.json +11 -0
  152. package/test/integration/generated/enums/extensible/README.md +56 -0
  153. package/test/integration/generated/enums/extensible/api-extractor.json +18 -0
  154. package/test/integration/generated/enums/extensible/package.json +80 -0
  155. package/test/integration/generated/enums/extensible/rollup.config.js +118 -0
  156. package/test/integration/generated/enums/extensible/src/clientDefinitions.ts +45 -0
  157. package/test/integration/generated/enums/extensible/src/enumsExtensible.ts +31 -0
  158. package/test/integration/generated/enums/extensible/src/index.ts +11 -0
  159. package/test/integration/generated/enums/extensible/src/parameters.ts +23 -0
  160. package/test/integration/generated/enums/extensible/src/responses.ts +26 -0
  161. package/test/integration/generated/enums/extensible/tsconfig.json +25 -0
  162. package/test/integration/generated/enums/extensible/tspconfig.yaml +11 -0
  163. package/test/integration/generated/enums/fixed/.eslintrc.json +11 -0
  164. package/test/integration/generated/enums/fixed/README.md +56 -0
  165. package/test/integration/generated/enums/fixed/api-extractor.json +18 -0
  166. package/test/integration/generated/enums/fixed/package.json +80 -0
  167. package/test/integration/generated/enums/fixed/rollup.config.js +118 -0
  168. package/test/integration/generated/enums/fixed/src/clientDefinitions.ts +43 -0
  169. package/test/integration/generated/enums/fixed/src/enumsFixed.ts +31 -0
  170. package/test/integration/generated/enums/fixed/src/index.ts +11 -0
  171. package/test/integration/generated/enums/fixed/src/parameters.ts +36 -0
  172. package/test/integration/generated/enums/fixed/src/responses.ts +27 -0
  173. package/test/integration/generated/enums/fixed/tsconfig.json +25 -0
  174. package/test/integration/generated/enums/fixed/tspconfig.yaml +11 -0
  175. package/test/integration/generated/hello/.eslintrc.json +11 -0
  176. package/test/integration/generated/hello/README.md +56 -0
  177. package/test/integration/generated/hello/api-extractor.json +18 -0
  178. package/test/integration/generated/hello/package.json +80 -0
  179. package/test/integration/generated/hello/rollup.config.js +118 -0
  180. package/test/integration/generated/hello/src/clientDefinitions.ts +19 -0
  181. package/test/integration/generated/hello/src/hello.ts +29 -0
  182. package/test/integration/generated/hello/src/index.ts +11 -0
  183. package/test/integration/generated/hello/src/parameters.ts +6 -0
  184. package/test/integration/generated/hello/src/responses.ts +10 -0
  185. package/test/integration/generated/hello/tsconfig.json +25 -0
  186. package/test/integration/generated/hello/tspconfig.yaml +11 -0
  187. package/test/integration/generated/lro/lroBasic/.eslintrc.json +11 -0
  188. package/test/integration/generated/lro/lroBasic/README.md +56 -0
  189. package/test/integration/generated/lro/lroBasic/api-extractor.json +18 -0
  190. package/test/integration/generated/lro/lroBasic/package.json +82 -0
  191. package/test/integration/generated/lro/lroBasic/rollup.config.js +118 -0
  192. package/test/integration/generated/lro/lroBasic/src/azureLro.ts +31 -0
  193. package/test/integration/generated/lro/lroBasic/src/clientDefinitions.ts +37 -0
  194. package/test/integration/generated/lro/lroBasic/src/index.ts +12 -0
  195. package/test/integration/generated/lro/lroBasic/src/parameters.ts +8 -0
  196. package/test/integration/generated/lro/lroBasic/src/pollingHelper.ts +75 -0
  197. package/test/integration/generated/lro/lroBasic/src/responses.ts +22 -0
  198. package/test/integration/generated/lro/lroBasic/tsconfig.json +25 -0
  199. package/test/integration/generated/lro/lroBasic/tspconfig.yaml +11 -0
  200. package/test/integration/generated/models/inheritance/.eslintrc.json +11 -0
  201. package/test/integration/generated/models/inheritance/README.md +56 -0
  202. package/test/integration/generated/models/inheritance/api-extractor.json +18 -0
  203. package/test/integration/generated/models/inheritance/package.json +80 -0
  204. package/test/integration/generated/models/inheritance/rollup.config.js +118 -0
  205. package/test/integration/generated/models/inheritance/src/clientDefinitions.ts +79 -0
  206. package/test/integration/generated/models/inheritance/src/index.ts +13 -0
  207. package/test/integration/generated/models/inheritance/src/models.ts +52 -0
  208. package/test/integration/generated/models/inheritance/src/modelsInheritance.ts +31 -0
  209. package/test/integration/generated/models/inheritance/src/outputModels.ts +52 -0
  210. package/test/integration/generated/models/inheritance/src/parameters.ts +35 -0
  211. package/test/integration/generated/models/inheritance/src/responses.ts +56 -0
  212. package/test/integration/generated/models/inheritance/tsconfig.json +25 -0
  213. package/test/integration/generated/models/inheritance/tspconfig.yaml +11 -0
  214. package/test/integration/generated/models/propertyOptional/.eslintrc.json +11 -0
  215. package/test/integration/generated/models/propertyOptional/README.md +56 -0
  216. package/test/integration/generated/models/propertyOptional/api-extractor.json +18 -0
  217. package/test/integration/generated/models/propertyOptional/package.json +80 -0
  218. package/test/integration/generated/models/propertyOptional/rollup.config.js +118 -0
  219. package/test/integration/generated/models/propertyOptional/src/clientDefinitions.ts +263 -0
  220. package/test/integration/generated/models/propertyOptional/src/index.ts +13 -0
  221. package/test/integration/generated/models/propertyOptional/src/models.ts +46 -0
  222. package/test/integration/generated/models/propertyOptional/src/modelsPropertyOptional.ts +31 -0
  223. package/test/integration/generated/models/propertyOptional/src/outputModels.ts +46 -0
  224. package/test/integration/generated/models/propertyOptional/src/parameters.ts +124 -0
  225. package/test/integration/generated/models/propertyOptional/src/responses.ts +169 -0
  226. package/test/integration/generated/models/propertyOptional/tsconfig.json +25 -0
  227. package/test/integration/generated/models/propertyOptional/tspconfig.yaml +11 -0
  228. package/test/integration/generated/models/propertyTypes/.eslintrc.json +11 -0
  229. package/test/integration/generated/models/propertyTypes/README.md +56 -0
  230. package/test/integration/generated/models/propertyTypes/api-extractor.json +18 -0
  231. package/test/integration/generated/models/propertyTypes/package.json +80 -0
  232. package/test/integration/generated/models/propertyTypes/rollup.config.js +118 -0
  233. package/test/integration/generated/models/propertyTypes/src/clientDefinitions.ts +234 -0
  234. package/test/integration/generated/models/propertyTypes/src/index.ts +13 -0
  235. package/test/integration/generated/models/propertyTypes/src/models.ts +99 -0
  236. package/test/integration/generated/models/propertyTypes/src/modelsPropertyTypes.ts +31 -0
  237. package/test/integration/generated/models/propertyTypes/src/outputModels.ts +99 -0
  238. package/test/integration/generated/models/propertyTypes/src/parameters.ts +147 -0
  239. package/test/integration/generated/models/propertyTypes/src/responses.ts +186 -0
  240. package/test/integration/generated/models/propertyTypes/tsconfig.json +25 -0
  241. package/test/integration/generated/models/propertyTypes/tspconfig.yaml +11 -0
  242. package/test/integration/generated/models/usage/.eslintrc.json +11 -0
  243. package/test/integration/generated/models/usage/README.md +56 -0
  244. package/test/integration/generated/models/usage/api-extractor.json +18 -0
  245. package/test/integration/generated/models/usage/package.json +80 -0
  246. package/test/integration/generated/models/usage/rollup.config.js +118 -0
  247. package/test/integration/generated/models/usage/src/clientDefinitions.ts +41 -0
  248. package/test/integration/generated/models/usage/src/index.ts +13 -0
  249. package/test/integration/generated/models/usage/src/models.ts +12 -0
  250. package/test/integration/generated/models/usage/src/modelsUsage.ts +31 -0
  251. package/test/integration/generated/models/usage/src/outputModels.ts +12 -0
  252. package/test/integration/generated/models/usage/src/parameters.ts +19 -0
  253. package/test/integration/generated/models/usage/src/responses.ts +22 -0
  254. package/test/integration/generated/models/usage/tsconfig.json +25 -0
  255. package/test/integration/generated/models/usage/tspconfig.yaml +11 -0
  256. package/test/integration/generated/models/visibility/.eslintrc.json +11 -0
  257. package/test/integration/generated/models/visibility/README.md +56 -0
  258. package/test/integration/generated/models/visibility/api-extractor.json +18 -0
  259. package/test/integration/generated/models/visibility/package.json +80 -0
  260. package/test/integration/generated/models/visibility/rollup.config.js +118 -0
  261. package/test/integration/generated/models/visibility/src/clientDefinitions.ts +40 -0
  262. package/test/integration/generated/models/visibility/src/index.ts +13 -0
  263. package/test/integration/generated/models/visibility/src/models.ts +14 -0
  264. package/test/integration/generated/models/visibility/src/modelsVisibilityAutomatic.ts +31 -0
  265. package/test/integration/generated/models/visibility/src/outputModels.ts +16 -0
  266. package/test/integration/generated/models/visibility/src/parameters.ts +41 -0
  267. package/test/integration/generated/models/visibility/src/responses.ts +36 -0
  268. package/test/integration/generated/models/visibility/tsconfig.json +25 -0
  269. package/test/integration/generated/models/visibility/tspconfig.yaml +11 -0
  270. package/test/integration/generated/resiliency/devDriven/.eslintrc.json +11 -0
  271. package/test/integration/generated/resiliency/devDriven/README.md +56 -0
  272. package/test/integration/generated/resiliency/devDriven/api-extractor.json +18 -0
  273. package/test/integration/generated/resiliency/devDriven/package.json +81 -0
  274. package/test/integration/generated/resiliency/devDriven/rollup.config.js +118 -0
  275. package/test/integration/generated/resiliency/devDriven/src/clientDefinitions.ts +75 -0
  276. package/test/integration/generated/resiliency/devDriven/src/index.ts +15 -0
  277. package/test/integration/generated/resiliency/devDriven/src/isUnexpected.ts +117 -0
  278. package/test/integration/generated/resiliency/devDriven/src/models.ts +8 -0
  279. package/test/integration/generated/resiliency/devDriven/src/outputModels.ts +25 -0
  280. package/test/integration/generated/resiliency/devDriven/src/paginateHelper.ts +154 -0
  281. package/test/integration/generated/resiliency/devDriven/src/parameters.ts +17 -0
  282. package/test/integration/generated/resiliency/devDriven/src/resiliencyDevDriven.ts +31 -0
  283. package/test/integration/generated/resiliency/devDriven/src/responses.ts +62 -0
  284. package/test/integration/generated/resiliency/devDriven/tsconfig.json +25 -0
  285. package/test/integration/generated/resiliency/devDriven/tspconfig.yaml +11 -0
  286. package/test/integration/generated/resiliency/srvDriven1/.eslintrc.json +11 -0
  287. package/test/integration/generated/resiliency/srvDriven1/README.md +56 -0
  288. package/test/integration/generated/resiliency/srvDriven1/api-extractor.json +18 -0
  289. package/test/integration/generated/resiliency/srvDriven1/package.json +80 -0
  290. package/test/integration/generated/resiliency/srvDriven1/rollup.config.js +118 -0
  291. package/test/integration/generated/resiliency/srvDriven1/src/clientDefinitions.ts +70 -0
  292. package/test/integration/generated/resiliency/srvDriven1/src/index.ts +13 -0
  293. package/test/integration/generated/resiliency/srvDriven1/src/models.ts +6 -0
  294. package/test/integration/generated/resiliency/srvDriven1/src/outputModels.ts +6 -0
  295. package/test/integration/generated/resiliency/srvDriven1/src/parameters.ts +51 -0
  296. package/test/integration/generated/resiliency/srvDriven1/src/resiliencyServiceDriven1.ts +31 -0
  297. package/test/integration/generated/resiliency/srvDriven1/src/responses.ts +34 -0
  298. package/test/integration/generated/resiliency/srvDriven1/tsconfig.json +25 -0
  299. package/test/integration/generated/resiliency/srvDriven1/tspconfig.yaml +11 -0
  300. package/test/integration/generated/resiliency/srvDriven2/.eslintrc.json +11 -0
  301. package/test/integration/generated/resiliency/srvDriven2/README.md +56 -0
  302. package/test/integration/generated/resiliency/srvDriven2/api-extractor.json +18 -0
  303. package/test/integration/generated/resiliency/srvDriven2/package.json +80 -0
  304. package/test/integration/generated/resiliency/srvDriven2/rollup.config.js +118 -0
  305. package/test/integration/generated/resiliency/srvDriven2/src/clientDefinitions.ts +93 -0
  306. package/test/integration/generated/resiliency/srvDriven2/src/index.ts +13 -0
  307. package/test/integration/generated/resiliency/srvDriven2/src/models.ts +6 -0
  308. package/test/integration/generated/resiliency/srvDriven2/src/outputModels.ts +6 -0
  309. package/test/integration/generated/resiliency/srvDriven2/src/parameters.ts +68 -0
  310. package/test/integration/generated/resiliency/srvDriven2/src/resiliencyServiceDriven2.ts +31 -0
  311. package/test/integration/generated/resiliency/srvDriven2/src/responses.ts +45 -0
  312. package/test/integration/generated/resiliency/srvDriven2/tsconfig.json +25 -0
  313. package/test/integration/generated/resiliency/srvDriven2/tspconfig.yaml +11 -0
  314. package/test/integration/generated/specialWords/src/clientDefinitions.ts +61 -0
  315. package/test/integration/generated/specialWords/src/index.ts +13 -0
  316. package/test/integration/generated/specialWords/src/models.ts +17 -0
  317. package/test/integration/generated/specialWords/src/outputModels.ts +17 -0
  318. package/test/integration/generated/specialWords/src/parameters.ts +37 -0
  319. package/test/integration/generated/specialWords/src/responses.ts +31 -0
  320. package/test/integration/generated/specialWords/src/specialWordsClient.ts +31 -0
  321. package/test/integration/generated/specialWords/tspconfig.yaml +11 -0
  322. package/test/integration/generated/unions/src/clientDefinitions.ts +53 -0
  323. package/test/integration/generated/unions/src/index.ts +12 -0
  324. package/test/integration/generated/unions/src/models.ts +27 -0
  325. package/test/integration/generated/unions/src/parameters.ts +34 -0
  326. package/test/integration/generated/unions/src/responses.ts +24 -0
  327. package/test/integration/generated/unions/src/unionsClient.ts +31 -0
  328. package/test/integration/generated/unions/tspconfig.yaml +11 -0
  329. package/test/integration/helloWorld.spec.ts +20 -0
  330. package/test/integration/lroBasic.spec.ts +25 -0
  331. package/test/integration/modelInheritance.spec.ts +192 -0
  332. package/test/integration/modelPropertyOptional.spec.ts +362 -0
  333. package/test/integration/modelPropertyType.spec.ts +119 -0
  334. package/test/integration/modelUsage.spec.ts +47 -0
  335. package/test/integration/resiliencyDpgCustomization.spec.ts +52 -0
  336. package/test/integration/specialWords.spec.ts +73 -0
  337. package/test/integration/unions.spec.ts +69 -0
  338. package/test/tsconfig.json +4 -0
  339. package/test/unit/azureCoreOperationsGenerator.spec.ts +71 -0
  340. package/test/unit/clientDefinitionGenerator.spec.ts +73 -0
  341. package/test/unit/clientFactoryGenerator.spec.ts +507 -0
  342. package/test/unit/docsGenerator.spec.ts +201 -0
  343. package/test/unit/modelsGenerator.spec.ts +1319 -0
  344. package/test/unit/parametersGenerator.spec.ts +561 -0
  345. package/test/unit/responsesGenerator.spec.ts +462 -0
  346. package/test/unit/spreadAndAlias.spec.ts +200 -0
  347. package/test/unit/util/emitUtil.ts +156 -0
  348. package/test/unit/util/testUtil.ts +83 -0
  349. package/test/util/customBearerTokenTestingPolicy.ts +78 -0
  350. package/test/util/matrix.ts +48 -0
  351. package/tsconfig.json +36 -0
  352. package/tsconfig.test.json +7 -0
  353. package/typespec-ts.build.log +2 -0
@@ -0,0 +1,133 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ // https://github.com/karma-runner/karma-chrome-launcher
5
+ process.env.CHROME_BIN = require("puppeteer").executablePath();
6
+ require("dotenv").config();
7
+ const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
8
+ process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
9
+
10
+ module.exports = function (config) {
11
+ config.set({
12
+ // base path that will be used to resolve all patterns (eg. files, exclude)
13
+ basePath: "./",
14
+
15
+ // frameworks to use
16
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
17
+ frameworks: ["source-map-support", "mocha"],
18
+
19
+ plugins: [
20
+ "karma-mocha",
21
+ "karma-mocha-reporter",
22
+ "karma-chrome-launcher",
23
+ "karma-firefox-launcher",
24
+ "karma-env-preprocessor",
25
+ "karma-coverage",
26
+ "karma-sourcemap-loader",
27
+ "karma-junit-reporter",
28
+ "karma-source-map-support",
29
+ ],
30
+
31
+ // list of files / patterns to load in the browser
32
+ files: [
33
+ "dist-test/index.browser.js",
34
+ {
35
+ pattern: "dist-test/index.browser.js.map",
36
+ type: "html",
37
+ included: false,
38
+ served: true,
39
+ },
40
+ ],
41
+
42
+ // list of files / patterns to exclude
43
+ exclude: [],
44
+
45
+ // preprocess matching files before serving them to the browser
46
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
47
+ preprocessors: {
48
+ "**/*.js": ["sourcemap", "env"],
49
+ // IMPORTANT: COMMENT following line if you want to debug in your browsers!!
50
+ // Preprocess source file to calculate code coverage, however this will make source file unreadable
51
+ // "dist-test/index.js": ["coverage"]
52
+ },
53
+
54
+ envPreprocessor: [
55
+ "TEST_MODE",
56
+ "ENDPOINT",
57
+ "AZURE_CLIENT_SECRET",
58
+ "AZURE_CLIENT_ID",
59
+ "AZURE_TENANT_ID",
60
+ "SUBSCRIPTION_ID",
61
+ "RECORDINGS_RELATIVE_PATH",
62
+ ],
63
+
64
+ // test results reporter to use
65
+ // possible values: 'dots', 'progress'
66
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
67
+ reporters: ["mocha", "coverage", "junit"],
68
+
69
+ coverageReporter: {
70
+ // specify a common output directory
71
+ dir: "coverage-browser/",
72
+ reporters: [
73
+ { type: "json", subdir: ".", file: "coverage.json" },
74
+ { type: "lcovonly", subdir: ".", file: "lcov.info" },
75
+ { type: "html", subdir: "html" },
76
+ { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
77
+ ],
78
+ },
79
+
80
+ junitReporter: {
81
+ outputDir: "", // results will be saved as $outputDir/$browserName.xml
82
+ outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
83
+ suite: "", // suite will become the package name attribute in xml testsuite element
84
+ useBrowserName: false, // add browser name to report and classes names
85
+ nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
86
+ classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
87
+ properties: {}, // key value pair of properties to add to the <properties> section of the report
88
+ },
89
+
90
+ // web server port
91
+ port: 9876,
92
+
93
+ // enable / disable colors in the output (reporters and logs)
94
+ colors: true,
95
+
96
+ // level of logging
97
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
98
+ logLevel: config.LOG_INFO,
99
+
100
+ // enable / disable watching file and executing tests whenever any file changes
101
+ autoWatch: false,
102
+
103
+ // --no-sandbox allows our tests to run in Linux without having to change the system.
104
+ // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
105
+ browsers: ["ChromeHeadlessNoSandbox"],
106
+ customLaunchers: {
107
+ ChromeHeadlessNoSandbox: {
108
+ base: "ChromeHeadless",
109
+ flags: ["--no-sandbox", "--disable-web-security"],
110
+ },
111
+ },
112
+
113
+ // Continuous Integration mode
114
+ // if true, Karma captures browsers, runs the tests and exits
115
+ singleRun: false,
116
+
117
+ // Concurrency level
118
+ // how many browser should be started simultaneous
119
+ concurrency: 1,
120
+
121
+ browserNoActivityTimeout: 60000000,
122
+ browserDisconnectTimeout: 10000,
123
+ browserDisconnectTolerance: 3,
124
+
125
+ client: {
126
+ mocha: {
127
+ // change Karma's debug.html to the mocha web reporter
128
+ reporter: "html",
129
+ timeout: "600000",
130
+ },
131
+ },
132
+ });
133
+ };
@@ -0,0 +1,41 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { getClient, ClientOptions } from "@azure-rest/core-client";
5
+ import { TokenCredential } from "@azure/core-auth";
6
+ import { AuthOauth2Client } from "./clientDefinitions";
7
+
8
+ /**
9
+ * Initialize a new instance of `AuthOauth2Client`
10
+ * @param credentials type: TokenCredential, uniquely identify client credential
11
+ * @param options type: ClientOptions, the parameter for all optional parameters
12
+ */
13
+ export default function createClient(
14
+ credentials: TokenCredential,
15
+ options: ClientOptions = {}
16
+ ): AuthOauth2Client {
17
+ const baseUrl = options.baseUrl ?? `http://localhost:3000`;
18
+ options.apiVersion = options.apiVersion ?? "1.0.0";
19
+ options = {
20
+ ...options,
21
+ credentials: {
22
+ scopes: ["https://security.microsoft.com/.default"],
23
+ },
24
+ };
25
+
26
+ const userAgentInfo = `azsdk-js-auth-oauth2-rest/1.0.0`;
27
+ const userAgentPrefix =
28
+ options.userAgentOptions && options.userAgentOptions.userAgentPrefix
29
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
30
+ : `${userAgentInfo}`;
31
+ options = {
32
+ ...options,
33
+ userAgentOptions: {
34
+ userAgentPrefix,
35
+ },
36
+ };
37
+
38
+ const client = getClient(baseUrl, credentials, options) as AuthOauth2Client;
39
+
40
+ return client;
41
+ }
@@ -0,0 +1,33 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { ValidParameters, InvalidParameters } from "./parameters";
5
+ import {
6
+ Valid204Response,
7
+ Invalid204Response,
8
+ Invalid403Response,
9
+ } from "./responses";
10
+ import { Client, StreamableMethod } from "@azure-rest/core-client";
11
+
12
+ export interface Valid {
13
+ /** Check whether client is authenticated */
14
+ get(options?: ValidParameters): StreamableMethod<Valid204Response>;
15
+ }
16
+
17
+ export interface Invalid {
18
+ /** Check whether client is authenticated. Will return an invalid bearer error. */
19
+ get(
20
+ options?: InvalidParameters
21
+ ): StreamableMethod<Invalid204Response | Invalid403Response>;
22
+ }
23
+
24
+ export interface Routes {
25
+ /** Resource for '/authentication/oauth2/valid' has methods for the following verbs: get */
26
+ (path: "/authentication/oauth2/valid"): Valid;
27
+ /** Resource for '/authentication/oauth2/invalid' has methods for the following verbs: get */
28
+ (path: "/authentication/oauth2/invalid"): Invalid;
29
+ }
30
+
31
+ export type AuthOauth2Client = Client & {
32
+ path: Routes;
33
+ };
@@ -0,0 +1,12 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import AuthOauth2Client from "./authOauth2Client";
5
+
6
+ export * from "./authOauth2Client";
7
+ export * from "./parameters";
8
+ export * from "./responses";
9
+ export * from "./clientDefinitions";
10
+ export * from "./outputModels";
11
+
12
+ export default AuthOauth2Client;
@@ -0,0 +1,6 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ export interface InvalidAuthOutput {
5
+ error: string;
6
+ }
@@ -0,0 +1,7 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { RequestParameters } from "@azure-rest/core-client";
5
+
6
+ export type ValidParameters = RequestParameters;
7
+ export type InvalidParameters = RequestParameters;
@@ -0,0 +1,21 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { HttpResponse } from "@azure-rest/core-client";
5
+ import { InvalidAuthOutput } from "./outputModels";
6
+
7
+ /** There is no content to send for this request, but the headers may be useful. */
8
+ export interface Valid204Response extends HttpResponse {
9
+ status: "204";
10
+ }
11
+
12
+ /** There is no content to send for this request, but the headers may be useful. */
13
+ export interface Invalid204Response extends HttpResponse {
14
+ status: "204";
15
+ }
16
+
17
+ /** Access is forbidden */
18
+ export interface Invalid403Response extends HttpResponse {
19
+ status: "403";
20
+ body: InvalidAuthOutput;
21
+ }
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { Recorder } from "@azure-tools/test-recorder";
5
+ import { assert } from "chai";
6
+ import { createRecorder } from "./utils/recordedClient";
7
+ import { Context } from "mocha";
8
+
9
+ describe("My test", () => {
10
+ let recorder: Recorder;
11
+
12
+ beforeEach(async function (this: Context) {
13
+ recorder = await createRecorder(this);
14
+ });
15
+
16
+ afterEach(async function () {
17
+ await recorder.stop();
18
+ });
19
+
20
+ it("sample test", async function () {
21
+ assert.equal(1, 1);
22
+ });
23
+ });
@@ -0,0 +1,2 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
@@ -0,0 +1,6 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import * as dotenv from "dotenv";
5
+
6
+ dotenv.config();
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { Context } from "mocha";
5
+ import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
6
+ import "./env";
7
+
8
+ const envSetupForPlayback: Record<string, string> = {
9
+ ENDPOINT: "https://endpoint",
10
+ AZURE_CLIENT_ID: "azure_client_id",
11
+ AZURE_CLIENT_SECRET: "azure_client_secret",
12
+ AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
13
+ SUBSCRIPTION_ID: "azure_subscription_id",
14
+ };
15
+
16
+ const recorderEnvSetup: RecorderStartOptions = {
17
+ envSetupForPlayback,
18
+ };
19
+
20
+ /**
21
+ * creates the recorder and reads the environment variables from the `.env` file.
22
+ * Should be called first in the test suite to make sure environment variables are
23
+ * read before they are being used.
24
+ */
25
+ export async function createRecorder(context: Context): Promise<Recorder> {
26
+ const recorder = new Recorder(context.currentTest);
27
+ await recorder.start(recorderEnvSetup);
28
+ return recorder;
29
+ }
@@ -0,0 +1,12 @@
1
+ emitters:
2
+ "../../../../../../../../../../../packages/typespec-ts/dist/src/index.js":
3
+ generateMetadata: false
4
+ generateTest: true
5
+ addCredentials: false
6
+ azureSdkForJs: false
7
+ isCadlTest: true
8
+ title: AuthOauth2Client
9
+ packageDetails:
10
+ name: "@msinternal/auth-oauth2"
11
+ description: "Auth oauth2 Test Service"
12
+ version: "1.0.0"
@@ -0,0 +1,133 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ // https://github.com/karma-runner/karma-chrome-launcher
5
+ process.env.CHROME_BIN = require("puppeteer").executablePath();
6
+ require("dotenv").config();
7
+ const { relativeRecordingsPath } = require("@azure-tools/test-recorder");
8
+ process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath();
9
+
10
+ module.exports = function (config) {
11
+ config.set({
12
+ // base path that will be used to resolve all patterns (eg. files, exclude)
13
+ basePath: "./",
14
+
15
+ // frameworks to use
16
+ // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
17
+ frameworks: ["source-map-support", "mocha"],
18
+
19
+ plugins: [
20
+ "karma-mocha",
21
+ "karma-mocha-reporter",
22
+ "karma-chrome-launcher",
23
+ "karma-firefox-launcher",
24
+ "karma-env-preprocessor",
25
+ "karma-coverage",
26
+ "karma-sourcemap-loader",
27
+ "karma-junit-reporter",
28
+ "karma-source-map-support",
29
+ ],
30
+
31
+ // list of files / patterns to load in the browser
32
+ files: [
33
+ "dist-test/index.browser.js",
34
+ {
35
+ pattern: "dist-test/index.browser.js.map",
36
+ type: "html",
37
+ included: false,
38
+ served: true,
39
+ },
40
+ ],
41
+
42
+ // list of files / patterns to exclude
43
+ exclude: [],
44
+
45
+ // preprocess matching files before serving them to the browser
46
+ // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
47
+ preprocessors: {
48
+ "**/*.js": ["sourcemap", "env"],
49
+ // IMPORTANT: COMMENT following line if you want to debug in your browsers!!
50
+ // Preprocess source file to calculate code coverage, however this will make source file unreadable
51
+ // "dist-test/index.js": ["coverage"]
52
+ },
53
+
54
+ envPreprocessor: [
55
+ "TEST_MODE",
56
+ "ENDPOINT",
57
+ "AZURE_CLIENT_SECRET",
58
+ "AZURE_CLIENT_ID",
59
+ "AZURE_TENANT_ID",
60
+ "SUBSCRIPTION_ID",
61
+ "RECORDINGS_RELATIVE_PATH",
62
+ ],
63
+
64
+ // test results reporter to use
65
+ // possible values: 'dots', 'progress'
66
+ // available reporters: https://npmjs.org/browse/keyword/karma-reporter
67
+ reporters: ["mocha", "coverage", "junit"],
68
+
69
+ coverageReporter: {
70
+ // specify a common output directory
71
+ dir: "coverage-browser/",
72
+ reporters: [
73
+ { type: "json", subdir: ".", file: "coverage.json" },
74
+ { type: "lcovonly", subdir: ".", file: "lcov.info" },
75
+ { type: "html", subdir: "html" },
76
+ { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" },
77
+ ],
78
+ },
79
+
80
+ junitReporter: {
81
+ outputDir: "", // results will be saved as $outputDir/$browserName.xml
82
+ outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile
83
+ suite: "", // suite will become the package name attribute in xml testsuite element
84
+ useBrowserName: false, // add browser name to report and classes names
85
+ nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element
86
+ classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element
87
+ properties: {}, // key value pair of properties to add to the <properties> section of the report
88
+ },
89
+
90
+ // web server port
91
+ port: 9876,
92
+
93
+ // enable / disable colors in the output (reporters and logs)
94
+ colors: true,
95
+
96
+ // level of logging
97
+ // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
98
+ logLevel: config.LOG_INFO,
99
+
100
+ // enable / disable watching file and executing tests whenever any file changes
101
+ autoWatch: false,
102
+
103
+ // --no-sandbox allows our tests to run in Linux without having to change the system.
104
+ // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex.
105
+ browsers: ["ChromeHeadlessNoSandbox"],
106
+ customLaunchers: {
107
+ ChromeHeadlessNoSandbox: {
108
+ base: "ChromeHeadless",
109
+ flags: ["--no-sandbox", "--disable-web-security"],
110
+ },
111
+ },
112
+
113
+ // Continuous Integration mode
114
+ // if true, Karma captures browsers, runs the tests and exits
115
+ singleRun: false,
116
+
117
+ // Concurrency level
118
+ // how many browser should be started simultaneous
119
+ concurrency: 1,
120
+
121
+ browserNoActivityTimeout: 60000000,
122
+ browserDisconnectTimeout: 10000,
123
+ browserDisconnectTolerance: 3,
124
+
125
+ client: {
126
+ mocha: {
127
+ // change Karma's debug.html to the mocha web reporter
128
+ reporter: "html",
129
+ timeout: "600000",
130
+ },
131
+ },
132
+ });
133
+ };
@@ -0,0 +1,42 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { getClient, ClientOptions } from "@azure-rest/core-client";
5
+ import { TokenCredential, KeyCredential } from "@azure/core-auth";
6
+ import { AuthUnionClient } from "./clientDefinitions";
7
+
8
+ /**
9
+ * Initialize a new instance of `AuthUnionClient`
10
+ * @param credentials type: TokenCredential|KeyCredential, uniquely identify client credential
11
+ * @param options type: ClientOptions, the parameter for all optional parameters
12
+ */
13
+ export default function createClient(
14
+ credentials: TokenCredential | KeyCredential,
15
+ options: ClientOptions = {}
16
+ ): AuthUnionClient {
17
+ const baseUrl = options.baseUrl ?? `http://localhost:3000`;
18
+ options.apiVersion = options.apiVersion ?? "1.0.0";
19
+ options = {
20
+ ...options,
21
+ credentials: {
22
+ scopes: ["https://security.microsoft.com/.default"],
23
+ apiKeyHeaderName: "x-ms-api-key",
24
+ },
25
+ };
26
+
27
+ const userAgentInfo = `azsdk-js-auth-union-rest/1.0.0`;
28
+ const userAgentPrefix =
29
+ options.userAgentOptions && options.userAgentOptions.userAgentPrefix
30
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
31
+ : `${userAgentInfo}`;
32
+ options = {
33
+ ...options,
34
+ userAgentOptions: {
35
+ userAgentPrefix,
36
+ },
37
+ };
38
+
39
+ const client = getClient(baseUrl, credentials, options) as AuthUnionClient;
40
+
41
+ return client;
42
+ }
@@ -0,0 +1,27 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { ValidKeyParameters, ValidTokenParameters } from "./parameters";
5
+ import { ValidKey204Response, ValidToken204Response } from "./responses";
6
+ import { Client, StreamableMethod } from "@azure-rest/core-client";
7
+
8
+ export interface ValidKey {
9
+ /** Check whether client is authenticated */
10
+ get(options?: ValidKeyParameters): StreamableMethod<ValidKey204Response>;
11
+ }
12
+
13
+ export interface ValidToken {
14
+ /** Check whether client is authenticated */
15
+ get(options?: ValidTokenParameters): StreamableMethod<ValidToken204Response>;
16
+ }
17
+
18
+ export interface Routes {
19
+ /** Resource for '/authentication/union/validkey' has methods for the following verbs: get */
20
+ (path: "/authentication/union/validkey"): ValidKey;
21
+ /** Resource for '/authentication/union/validtoken' has methods for the following verbs: get */
22
+ (path: "/authentication/union/validtoken"): ValidToken;
23
+ }
24
+
25
+ export type AuthUnionClient = Client & {
26
+ path: Routes;
27
+ };
@@ -0,0 +1,11 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import AuthUnionClient from "./authUnionClient";
5
+
6
+ export * from "./authUnionClient";
7
+ export * from "./parameters";
8
+ export * from "./responses";
9
+ export * from "./clientDefinitions";
10
+
11
+ export default AuthUnionClient;
@@ -0,0 +1,7 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { RequestParameters } from "@azure-rest/core-client";
5
+
6
+ export type ValidKeyParameters = RequestParameters;
7
+ export type ValidTokenParameters = RequestParameters;
@@ -0,0 +1,14 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { HttpResponse } from "@azure-rest/core-client";
5
+
6
+ /** There is no content to send for this request, but the headers may be useful. */
7
+ export interface ValidKey204Response extends HttpResponse {
8
+ status: "204";
9
+ }
10
+
11
+ /** There is no content to send for this request, but the headers may be useful. */
12
+ export interface ValidToken204Response extends HttpResponse {
13
+ status: "204";
14
+ }
@@ -0,0 +1,23 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { Recorder } from "@azure-tools/test-recorder";
5
+ import { assert } from "chai";
6
+ import { createRecorder } from "./utils/recordedClient";
7
+ import { Context } from "mocha";
8
+
9
+ describe("My test", () => {
10
+ let recorder: Recorder;
11
+
12
+ beforeEach(async function (this: Context) {
13
+ recorder = await createRecorder(this);
14
+ });
15
+
16
+ afterEach(async function () {
17
+ await recorder.stop();
18
+ });
19
+
20
+ it("sample test", async function () {
21
+ assert.equal(1, 1);
22
+ });
23
+ });
@@ -0,0 +1,2 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
@@ -0,0 +1,6 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import * as dotenv from "dotenv";
5
+
6
+ dotenv.config();
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+
4
+ import { Context } from "mocha";
5
+ import { Recorder, RecorderStartOptions } from "@azure-tools/test-recorder";
6
+ import "./env";
7
+
8
+ const envSetupForPlayback: Record<string, string> = {
9
+ ENDPOINT: "https://endpoint",
10
+ AZURE_CLIENT_ID: "azure_client_id",
11
+ AZURE_CLIENT_SECRET: "azure_client_secret",
12
+ AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888",
13
+ SUBSCRIPTION_ID: "azure_subscription_id",
14
+ };
15
+
16
+ const recorderEnvSetup: RecorderStartOptions = {
17
+ envSetupForPlayback,
18
+ };
19
+
20
+ /**
21
+ * creates the recorder and reads the environment variables from the `.env` file.
22
+ * Should be called first in the test suite to make sure environment variables are
23
+ * read before they are being used.
24
+ */
25
+ export async function createRecorder(context: Context): Promise<Recorder> {
26
+ const recorder = new Recorder(context.currentTest);
27
+ await recorder.start(recorderEnvSetup);
28
+ return recorder;
29
+ }
@@ -0,0 +1,12 @@
1
+ emitters:
2
+ "../../../../../../../../../../../packages/typespec-ts/dist/src/index.js":
3
+ generateMetadata: false
4
+ generateTest: true
5
+ addCredentials: false
6
+ azureSdkForJs: false
7
+ isCadlTest: true
8
+ title: AuthUnionClient
9
+ packageDetails:
10
+ name: "@msinternal/auth-union"
11
+ description: "Auth Union Test Service"
12
+ version: "1.0.0"