@azure-tools/typespec-ts 0.53.3 → 0.54.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 (446) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/src/framework/hooks/binder.d.ts.map +1 -1
  3. package/dist/src/framework/hooks/binder.js +102 -44
  4. package/dist/src/framework/hooks/binder.js.map +1 -1
  5. package/dist/src/framework/hooks/sdkTypes.js +1 -1
  6. package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
  7. package/dist/src/framework/load-static-helpers.js +1 -1
  8. package/dist/src/framework/load-static-helpers.js.map +1 -1
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js +4 -1
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/lib.d.ts +1 -10
  13. package/dist/src/lib.d.ts.map +1 -1
  14. package/dist/src/lib.js +0 -5
  15. package/dist/src/lib.js.map +1 -1
  16. package/dist/src/metaTree.d.ts +1 -1
  17. package/dist/src/metaTree.d.ts.map +1 -1
  18. package/dist/src/modular/buildClassicalClient.js +1 -1
  19. package/dist/src/modular/buildClassicalClient.js.map +1 -1
  20. package/dist/src/modular/buildClassicalOperationGroups.js +1 -1
  21. package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
  22. package/dist/src/modular/buildClientContext.js +1 -1
  23. package/dist/src/modular/buildClientContext.js.map +1 -1
  24. package/dist/src/modular/buildOperations.js +1 -1
  25. package/dist/src/modular/buildOperations.js.map +1 -1
  26. package/dist/src/modular/buildProjectFiles.js +1 -1
  27. package/dist/src/modular/buildProjectFiles.js.map +1 -1
  28. package/dist/src/modular/buildRestorePoller.js +1 -1
  29. package/dist/src/modular/buildRestorePoller.js.map +1 -1
  30. package/dist/src/modular/buildRootIndex.js +1 -1
  31. package/dist/src/modular/buildRootIndex.js.map +1 -1
  32. package/dist/src/modular/emitModels.d.ts +1 -1
  33. package/dist/src/modular/emitModels.d.ts.map +1 -1
  34. package/dist/src/modular/emitModels.js +1 -1
  35. package/dist/src/modular/emitModels.js.map +1 -1
  36. package/dist/src/modular/emitModelsOptions.js +1 -1
  37. package/dist/src/modular/emitModelsOptions.js.map +1 -1
  38. package/dist/src/modular/emitSamples.js +1 -1
  39. package/dist/src/modular/emitSamples.js.map +1 -1
  40. package/dist/src/modular/emitTests.js +1 -1
  41. package/dist/src/modular/emitTests.js.map +1 -1
  42. package/dist/src/modular/helpers/classicalOperationHelpers.js +1 -1
  43. package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
  44. package/dist/src/modular/helpers/clientHelpers.js +1 -1
  45. package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
  46. package/dist/src/modular/helpers/exampleValueHelpers.js +1 -1
  47. package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
  48. package/dist/src/modular/helpers/namingHelpers.d.ts +1 -1
  49. package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
  50. package/dist/src/modular/helpers/namingHelpers.js +1 -1
  51. package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
  52. package/dist/src/modular/helpers/operationHelpers.d.ts +1 -1
  53. package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
  54. package/dist/src/modular/helpers/operationHelpers.js +53 -34
  55. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  56. package/dist/src/modular/helpers/typeHelpers.js +1 -1
  57. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  58. package/dist/src/modular/interfaces.d.ts +1 -1
  59. package/dist/src/modular/interfaces.d.ts.map +1 -1
  60. package/dist/src/modular/serialization/buildDeserializerFunction.js +1 -1
  61. package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
  62. package/dist/src/modular/serialization/buildSerializerFunction.js +1 -1
  63. package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
  64. package/dist/src/modular/serialization/buildXmlSerializerFunction.js +1 -1
  65. package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
  66. package/dist/src/modular/type-expressions/get-type-expression.js +1 -1
  67. package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
  68. package/dist/src/rlc-common/buildClient.d.ts +9 -0
  69. package/dist/src/rlc-common/buildClient.d.ts.map +1 -0
  70. package/dist/src/rlc-common/buildClient.js +413 -0
  71. package/dist/src/rlc-common/buildClient.js.map +1 -0
  72. package/dist/src/rlc-common/buildClientDefinitions.d.ts +6 -0
  73. package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +1 -0
  74. package/dist/src/rlc-common/buildClientDefinitions.js +174 -0
  75. package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -0
  76. package/dist/src/rlc-common/buildIndexFile.d.ts +6 -0
  77. package/dist/src/rlc-common/buildIndexFile.d.ts.map +1 -0
  78. package/dist/src/rlc-common/buildIndexFile.js +242 -0
  79. package/dist/src/rlc-common/buildIndexFile.js.map +1 -0
  80. package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts +6 -0
  81. package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +1 -0
  82. package/dist/src/rlc-common/buildIsUnexpectedHelper.js +224 -0
  83. package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -0
  84. package/dist/src/rlc-common/buildLogger.d.ts +6 -0
  85. package/dist/src/rlc-common/buildLogger.d.ts.map +1 -0
  86. package/dist/src/rlc-common/buildLogger.js +32 -0
  87. package/dist/src/rlc-common/buildLogger.js.map +1 -0
  88. package/dist/src/rlc-common/buildMethodShortcuts.d.ts +5 -0
  89. package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +1 -0
  90. package/dist/src/rlc-common/buildMethodShortcuts.js +54 -0
  91. package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -0
  92. package/dist/src/rlc-common/buildObjectTypes.d.ts +29 -0
  93. package/dist/src/rlc-common/buildObjectTypes.d.ts.map +1 -0
  94. package/dist/src/rlc-common/buildObjectTypes.js +451 -0
  95. package/dist/src/rlc-common/buildObjectTypes.js.map +1 -0
  96. package/dist/src/rlc-common/buildPaginateHelper.d.ts +6 -0
  97. package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +1 -0
  98. package/dist/src/rlc-common/buildPaginateHelper.js +27 -0
  99. package/dist/src/rlc-common/buildPaginateHelper.js.map +1 -0
  100. package/dist/src/rlc-common/buildParameterTypes.d.ts +14 -0
  101. package/dist/src/rlc-common/buildParameterTypes.d.ts.map +1 -0
  102. package/dist/src/rlc-common/buildParameterTypes.js +381 -0
  103. package/dist/src/rlc-common/buildParameterTypes.js.map +1 -0
  104. package/dist/src/rlc-common/buildPollingHelper.d.ts +6 -0
  105. package/dist/src/rlc-common/buildPollingHelper.d.ts.map +1 -0
  106. package/dist/src/rlc-common/buildPollingHelper.js +62 -0
  107. package/dist/src/rlc-common/buildPollingHelper.js.map +1 -0
  108. package/dist/src/rlc-common/buildResponseTypes.d.ts +6 -0
  109. package/dist/src/rlc-common/buildResponseTypes.d.ts.map +1 -0
  110. package/dist/src/rlc-common/buildResponseTypes.js +147 -0
  111. package/dist/src/rlc-common/buildResponseTypes.js.map +1 -0
  112. package/dist/src/rlc-common/buildSamples.d.ts +3 -0
  113. package/dist/src/rlc-common/buildSamples.d.ts.map +1 -0
  114. package/dist/src/rlc-common/buildSamples.js +30 -0
  115. package/dist/src/rlc-common/buildSamples.js.map +1 -0
  116. package/dist/src/rlc-common/buildSchemaType.d.ts +20 -0
  117. package/dist/src/rlc-common/buildSchemaType.d.ts.map +1 -0
  118. package/dist/src/rlc-common/buildSchemaType.js +53 -0
  119. package/dist/src/rlc-common/buildSchemaType.js.map +1 -0
  120. package/dist/src/rlc-common/buildSerializeHelper.d.ts +6 -0
  121. package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +1 -0
  122. package/dist/src/rlc-common/buildSerializeHelper.js +36 -0
  123. package/dist/src/rlc-common/buildSerializeHelper.js.map +1 -0
  124. package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts +6 -0
  125. package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +1 -0
  126. package/dist/src/rlc-common/buildTopLevelIndexFile.js +52 -0
  127. package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +1 -0
  128. package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts +17 -0
  129. package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +1 -0
  130. package/dist/src/rlc-common/helpers/apiVersionUtil.js +45 -0
  131. package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -0
  132. package/dist/src/rlc-common/helpers/importsUtil.d.ts +18 -0
  133. package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +1 -0
  134. package/dist/src/rlc-common/helpers/importsUtil.js +169 -0
  135. package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -0
  136. package/dist/src/rlc-common/helpers/nameConstructors.d.ts +42 -0
  137. package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +1 -0
  138. package/dist/src/rlc-common/helpers/nameConstructors.js +63 -0
  139. package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -0
  140. package/dist/src/rlc-common/helpers/nameUtils.d.ts +37 -0
  141. package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +1 -0
  142. package/dist/src/rlc-common/helpers/nameUtils.js +246 -0
  143. package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -0
  144. package/dist/src/rlc-common/helpers/operationHelpers.d.ts +16 -0
  145. package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +1 -0
  146. package/dist/src/rlc-common/helpers/operationHelpers.js +119 -0
  147. package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -0
  148. package/dist/src/rlc-common/helpers/packageUtil.d.ts +7 -0
  149. package/dist/src/rlc-common/helpers/packageUtil.d.ts.map +1 -0
  150. package/dist/src/rlc-common/helpers/packageUtil.js +13 -0
  151. package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -0
  152. package/dist/src/rlc-common/helpers/pathUtils.d.ts +2 -0
  153. package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +1 -0
  154. package/dist/src/rlc-common/helpers/pathUtils.js +12 -0
  155. package/dist/src/rlc-common/helpers/pathUtils.js.map +1 -0
  156. package/dist/src/rlc-common/helpers/schemaHelpers.d.ts +10 -0
  157. package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +1 -0
  158. package/dist/src/rlc-common/helpers/schemaHelpers.js +41 -0
  159. package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -0
  160. package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +4 -0
  161. package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +1 -0
  162. package/dist/src/rlc-common/helpers/shortcutMethods.js +49 -0
  163. package/dist/src/rlc-common/helpers/shortcutMethods.js.map +1 -0
  164. package/dist/src/rlc-common/helpers/typeUtil.d.ts +32 -0
  165. package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +1 -0
  166. package/dist/src/rlc-common/helpers/typeUtil.js +167 -0
  167. package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -0
  168. package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts +12 -0
  169. package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts.map +1 -0
  170. package/dist/src/rlc-common/helpers/valueGenerationUtil.js +165 -0
  171. package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -0
  172. package/dist/src/rlc-common/index.d.ts +41 -0
  173. package/dist/src/rlc-common/index.d.ts.map +1 -0
  174. package/dist/src/rlc-common/index.js +43 -0
  175. package/dist/src/rlc-common/index.js.map +1 -0
  176. package/dist/src/rlc-common/interfaces.d.ts +369 -0
  177. package/dist/src/rlc-common/interfaces.d.ts.map +1 -0
  178. package/dist/src/rlc-common/interfaces.js +11 -0
  179. package/dist/src/rlc-common/interfaces.js.map +1 -0
  180. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts +6 -0
  181. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +1 -0
  182. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +56 -0
  183. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -0
  184. package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts +6 -0
  185. package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts.map +1 -0
  186. package/dist/src/rlc-common/metadata/buildChangelogFile.js +26 -0
  187. package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -0
  188. package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts +6 -0
  189. package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -0
  190. package/dist/src/rlc-common/metadata/buildESLintConfig.js +82 -0
  191. package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -0
  192. package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts +5 -0
  193. package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts.map +1 -0
  194. package/dist/src/rlc-common/metadata/buildLicenseFile.js +32 -0
  195. package/dist/src/rlc-common/metadata/buildLicenseFile.js.map +1 -0
  196. package/dist/src/rlc-common/metadata/buildPackageFile.d.ts +25 -0
  197. package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +1 -0
  198. package/dist/src/rlc-common/metadata/buildPackageFile.js +201 -0
  199. package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -0
  200. package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts +11 -0
  201. package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +1 -0
  202. package/dist/src/rlc-common/metadata/buildReadmeFile.js +426 -0
  203. package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -0
  204. package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts +6 -0
  205. package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +1 -0
  206. package/dist/src/rlc-common/metadata/buildRollupConfig.js +142 -0
  207. package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -0
  208. package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts +6 -0
  209. package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +1 -0
  210. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +17 -0
  211. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -0
  212. package/dist/src/rlc-common/metadata/buildTestConfig.d.ts +16 -0
  213. package/dist/src/rlc-common/metadata/buildTestConfig.d.ts.map +1 -0
  214. package/dist/src/rlc-common/metadata/buildTestConfig.js +55 -0
  215. package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -0
  216. package/dist/src/rlc-common/metadata/buildTsConfig.d.ts +61 -0
  217. package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -0
  218. package/dist/src/rlc-common/metadata/buildTsConfig.js +170 -0
  219. package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -0
  220. package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts +6 -0
  221. package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +1 -0
  222. package/dist/src/rlc-common/metadata/buildVitestConfig.js +28 -0
  223. package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -0
  224. package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts +20 -0
  225. package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +1 -0
  226. package/dist/src/rlc-common/metadata/buildWarpConfig.js +77 -0
  227. package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -0
  228. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +51 -0
  229. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +1 -0
  230. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +121 -0
  231. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -0
  232. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts +242 -0
  233. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +1 -0
  234. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +176 -0
  235. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -0
  236. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts +8 -0
  237. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +1 -0
  238. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +102 -0
  239. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +1 -0
  240. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts +57 -0
  241. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts.map +1 -0
  242. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +53 -0
  243. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +1 -0
  244. package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts +64 -0
  245. package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +1 -0
  246. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +183 -0
  247. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -0
  248. package/dist/src/rlc-common/metadata/utils.d.ts +3 -0
  249. package/dist/src/rlc-common/metadata/utils.d.ts.map +1 -0
  250. package/dist/src/rlc-common/metadata/utils.js +7 -0
  251. package/dist/src/rlc-common/metadata/utils.js.map +1 -0
  252. package/dist/src/rlc-common/static/paginateContent.d.ts +2 -0
  253. package/dist/src/rlc-common/static/paginateContent.d.ts.map +1 -0
  254. package/dist/src/rlc-common/static/paginateContent.js +345 -0
  255. package/dist/src/rlc-common/static/paginateContent.js.map +1 -0
  256. package/dist/src/rlc-common/static/pollingContent.d.ts +2 -0
  257. package/dist/src/rlc-common/static/pollingContent.d.ts.map +1 -0
  258. package/dist/src/rlc-common/static/pollingContent.js +225 -0
  259. package/dist/src/rlc-common/static/pollingContent.js.map +1 -0
  260. package/dist/src/rlc-common/static/sampleTemplate.d.ts +2 -0
  261. package/dist/src/rlc-common/static/sampleTemplate.d.ts.map +1 -0
  262. package/dist/src/rlc-common/static/sampleTemplate.js +56 -0
  263. package/dist/src/rlc-common/static/sampleTemplate.js.map +1 -0
  264. package/dist/src/rlc-common/static/serializeHelper.d.ts +6 -0
  265. package/dist/src/rlc-common/static/serializeHelper.d.ts.map +1 -0
  266. package/dist/src/rlc-common/static/serializeHelper.js +31 -0
  267. package/dist/src/rlc-common/static/serializeHelper.js.map +1 -0
  268. package/dist/src/rlc-common/test/buildKarmaConfig.d.ts +6 -0
  269. package/dist/src/rlc-common/test/buildKarmaConfig.d.ts.map +1 -0
  270. package/dist/src/rlc-common/test/buildKarmaConfig.js +11 -0
  271. package/dist/src/rlc-common/test/buildKarmaConfig.js.map +1 -0
  272. package/dist/src/rlc-common/test/buildRecordedClient.d.ts +6 -0
  273. package/dist/src/rlc-common/test/buildRecordedClient.d.ts.map +1 -0
  274. package/dist/src/rlc-common/test/buildRecordedClient.js +18 -0
  275. package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -0
  276. package/dist/src/rlc-common/test/buildSampleTest.d.ts +6 -0
  277. package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -0
  278. package/dist/src/rlc-common/test/buildSampleTest.js +15 -0
  279. package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -0
  280. package/dist/src/rlc-common/test/buildSnippets.d.ts +6 -0
  281. package/dist/src/rlc-common/test/buildSnippets.d.ts.map +1 -0
  282. package/dist/src/rlc-common/test/buildSnippets.js +29 -0
  283. package/dist/src/rlc-common/test/buildSnippets.js.map +1 -0
  284. package/dist/src/rlc-common/test/template.d.ts +5 -0
  285. package/dist/src/rlc-common/test/template.d.ts.map +1 -0
  286. package/dist/src/rlc-common/test/template.js +261 -0
  287. package/dist/src/rlc-common/test/template.js.map +1 -0
  288. package/dist/src/rlc-common/transformSampleGroups.d.ts +9 -0
  289. package/dist/src/rlc-common/transformSampleGroups.d.ts.map +1 -0
  290. package/dist/src/rlc-common/transformSampleGroups.js +317 -0
  291. package/dist/src/rlc-common/transformSampleGroups.js.map +1 -0
  292. package/dist/src/transform/transform.d.ts +1 -1
  293. package/dist/src/transform/transform.d.ts.map +1 -1
  294. package/dist/src/transform/transform.js +1 -1
  295. package/dist/src/transform/transform.js.map +1 -1
  296. package/dist/src/transform/transformApiVersionInfo.d.ts +1 -1
  297. package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
  298. package/dist/src/transform/transformApiVersionInfo.js +1 -1
  299. package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
  300. package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
  301. package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
  302. package/dist/src/transform/transformParameters.d.ts +1 -1
  303. package/dist/src/transform/transformParameters.d.ts.map +1 -1
  304. package/dist/src/transform/transformParameters.js +1 -1
  305. package/dist/src/transform/transformParameters.js.map +1 -1
  306. package/dist/src/transform/transformPaths.d.ts +1 -1
  307. package/dist/src/transform/transformPaths.d.ts.map +1 -1
  308. package/dist/src/transform/transformPaths.js +1 -1
  309. package/dist/src/transform/transformPaths.js.map +1 -1
  310. package/dist/src/transform/transformResponses.d.ts +1 -1
  311. package/dist/src/transform/transformResponses.d.ts.map +1 -1
  312. package/dist/src/transform/transformResponses.js +1 -1
  313. package/dist/src/transform/transformResponses.js.map +1 -1
  314. package/dist/src/transform/transformSchemas.js +1 -1
  315. package/dist/src/transform/transformSchemas.js.map +1 -1
  316. package/dist/src/transform/transformTelemetryInfo.d.ts +1 -1
  317. package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
  318. package/dist/src/transform/transfromRLCOptions.d.ts +1 -1
  319. package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
  320. package/dist/src/transform/transfromRLCOptions.js +1 -3
  321. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  322. package/dist/src/utils/clientUtils.js +1 -1
  323. package/dist/src/utils/clientUtils.js.map +1 -1
  324. package/dist/src/utils/crossLanguageDef.js +1 -1
  325. package/dist/src/utils/crossLanguageDef.js.map +1 -1
  326. package/dist/src/utils/emitUtil.d.ts +1 -1
  327. package/dist/src/utils/emitUtil.d.ts.map +1 -1
  328. package/dist/src/utils/emitUtil.js +1 -1
  329. package/dist/src/utils/emitUtil.js.map +1 -1
  330. package/dist/src/utils/interfaces.d.ts +1 -1
  331. package/dist/src/utils/interfaces.d.ts.map +1 -1
  332. package/dist/src/utils/modelUtils.d.ts +1 -1
  333. package/dist/src/utils/modelUtils.d.ts.map +1 -1
  334. package/dist/src/utils/modelUtils.js +1 -1
  335. package/dist/src/utils/modelUtils.js.map +1 -1
  336. package/dist/src/utils/operationUtil.d.ts +1 -1
  337. package/dist/src/utils/operationUtil.d.ts.map +1 -1
  338. package/dist/src/utils/operationUtil.js +1 -1
  339. package/dist/src/utils/operationUtil.js.map +1 -1
  340. package/dist/src/utils/parameterUtils.d.ts +1 -1
  341. package/dist/src/utils/parameterUtils.d.ts.map +1 -1
  342. package/dist/src/utils/parameterUtils.js +1 -1
  343. package/dist/src/utils/parameterUtils.js.map +1 -1
  344. package/dist/tsconfig.tsbuildinfo +1 -1
  345. package/package.json +9 -9
  346. package/src/framework/hooks/binder.ts +142 -51
  347. package/src/framework/hooks/sdkTypes.ts +1 -1
  348. package/src/framework/load-static-helpers.ts +1 -1
  349. package/src/index.ts +5 -1
  350. package/src/lib.ts +1 -16
  351. package/src/metaTree.ts +1 -1
  352. package/src/modular/buildClassicalClient.ts +1 -1
  353. package/src/modular/buildClassicalOperationGroups.ts +1 -1
  354. package/src/modular/buildClientContext.ts +1 -1
  355. package/src/modular/buildOperations.ts +1 -1
  356. package/src/modular/buildProjectFiles.ts +1 -1
  357. package/src/modular/buildRestorePoller.ts +1 -1
  358. package/src/modular/buildRootIndex.ts +1 -1
  359. package/src/modular/emitModels.ts +1 -1
  360. package/src/modular/emitModelsOptions.ts +1 -1
  361. package/src/modular/emitSamples.ts +1 -1
  362. package/src/modular/emitTests.ts +1 -1
  363. package/src/modular/helpers/classicalOperationHelpers.ts +1 -1
  364. package/src/modular/helpers/clientHelpers.ts +1 -1
  365. package/src/modular/helpers/exampleValueHelpers.ts +1 -1
  366. package/src/modular/helpers/namingHelpers.ts +1 -1
  367. package/src/modular/helpers/operationHelpers.ts +65 -42
  368. package/src/modular/helpers/typeHelpers.ts +1 -1
  369. package/src/modular/interfaces.ts +1 -1
  370. package/src/modular/serialization/buildDeserializerFunction.ts +1 -1
  371. package/src/modular/serialization/buildSerializerFunction.ts +1 -1
  372. package/src/modular/serialization/buildXmlSerializerFunction.ts +1 -1
  373. package/src/modular/type-expressions/get-type-expression.ts +1 -1
  374. package/src/rlc-common/buildClient.ts +561 -0
  375. package/src/rlc-common/buildClientDefinitions.ts +278 -0
  376. package/src/rlc-common/buildIndexFile.ts +344 -0
  377. package/src/rlc-common/buildIsUnexpectedHelper.ts +255 -0
  378. package/src/rlc-common/buildLogger.ts +43 -0
  379. package/src/rlc-common/buildMethodShortcuts.ts +83 -0
  380. package/src/rlc-common/buildObjectTypes.ts +680 -0
  381. package/src/rlc-common/buildPaginateHelper.ts +34 -0
  382. package/src/rlc-common/buildParameterTypes.ts +575 -0
  383. package/src/rlc-common/buildPollingHelper.ts +83 -0
  384. package/src/rlc-common/buildResponseTypes.ts +203 -0
  385. package/src/rlc-common/buildSamples.ts +32 -0
  386. package/src/rlc-common/buildSchemaType.ts +81 -0
  387. package/src/rlc-common/buildSerializeHelper.ts +49 -0
  388. package/src/rlc-common/buildTopLevelIndexFile.ts +65 -0
  389. package/src/rlc-common/helpers/apiVersionUtil.ts +53 -0
  390. package/src/rlc-common/helpers/importsUtil.ts +187 -0
  391. package/src/rlc-common/helpers/nameConstructors.ts +144 -0
  392. package/src/rlc-common/helpers/nameUtils.ts +319 -0
  393. package/src/rlc-common/helpers/operationHelpers.ts +155 -0
  394. package/src/rlc-common/helpers/packageUtil.ts +13 -0
  395. package/src/rlc-common/helpers/pathUtils.ts +15 -0
  396. package/src/rlc-common/helpers/schemaHelpers.ts +61 -0
  397. package/src/rlc-common/helpers/shortcutMethods.ts +67 -0
  398. package/src/rlc-common/helpers/typeUtil.ts +173 -0
  399. package/src/rlc-common/helpers/valueGenerationUtil.ts +257 -0
  400. package/src/rlc-common/index.ts +43 -0
  401. package/src/rlc-common/interfaces.ts +441 -0
  402. package/src/rlc-common/metadata/buildApiExtractorConfig.ts +71 -0
  403. package/src/rlc-common/metadata/buildChangelogFile.ts +29 -0
  404. package/src/rlc-common/metadata/buildESLintConfig.ts +86 -0
  405. package/src/rlc-common/metadata/buildLicenseFile.ts +33 -0
  406. package/src/rlc-common/metadata/buildPackageFile.ts +250 -0
  407. package/src/rlc-common/metadata/buildReadmeFile.ts +528 -0
  408. package/src/rlc-common/metadata/buildRollupConfig.ts +150 -0
  409. package/src/rlc-common/metadata/buildSampleEnvFile.ts +22 -0
  410. package/src/rlc-common/metadata/buildTestConfig.ts +72 -0
  411. package/src/rlc-common/metadata/buildTsConfig.ts +222 -0
  412. package/src/rlc-common/metadata/buildVitestConfig.ts +36 -0
  413. package/src/rlc-common/metadata/buildWarpConfig.ts +94 -0
  414. package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +161 -0
  415. package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +220 -0
  416. package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +134 -0
  417. package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +70 -0
  418. package/src/rlc-common/metadata/packageJson/packageCommon.ts +255 -0
  419. package/src/rlc-common/metadata/utils.ts +8 -0
  420. package/src/rlc-common/static/paginateContent.ts +345 -0
  421. package/src/rlc-common/static/pollingContent.ts +225 -0
  422. package/src/rlc-common/static/sampleTemplate.ts +56 -0
  423. package/src/rlc-common/static/serializeHelper.ts +34 -0
  424. package/src/rlc-common/test/buildKarmaConfig.ts +12 -0
  425. package/src/rlc-common/test/buildRecordedClient.ts +18 -0
  426. package/src/rlc-common/test/buildSampleTest.ts +15 -0
  427. package/src/rlc-common/test/buildSnippets.ts +35 -0
  428. package/src/rlc-common/test/template.ts +263 -0
  429. package/src/rlc-common/transformSampleGroups.ts +458 -0
  430. package/src/transform/transform.ts +1 -1
  431. package/src/transform/transformApiVersionInfo.ts +1 -1
  432. package/src/transform/transformHelperFunctionDetails.ts +1 -1
  433. package/src/transform/transformParameters.ts +1 -1
  434. package/src/transform/transformPaths.ts +1 -1
  435. package/src/transform/transformResponses.ts +1 -1
  436. package/src/transform/transformSchemas.ts +1 -1
  437. package/src/transform/transformTelemetryInfo.ts +1 -1
  438. package/src/transform/transfromRLCOptions.ts +1 -3
  439. package/src/utils/clientUtils.ts +1 -1
  440. package/src/utils/crossLanguageDef.ts +1 -1
  441. package/src/utils/emitUtil.ts +1 -1
  442. package/src/utils/interfaces.ts +1 -1
  443. package/src/utils/modelUtils.ts +1 -1
  444. package/src/utils/operationUtil.ts +1 -1
  445. package/src/utils/parameterUtils.ts +1 -1
  446. package/LICENSE +0 -21
@@ -0,0 +1,345 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ export const paginateContent = `
5
+ import type { Client, PathUncheckedResponse } from "@azure-rest/core-client";
6
+ import { createRestError } from "@azure-rest/core-client";
7
+
8
+ /**
9
+ * returns an async iterator that iterates over results. It also has a \`byPage\`
10
+ * method that returns pages of items at once.
11
+ *
12
+ * @param pagedResult - an object that specifies how to get pages.
13
+ * @returns a paged async iterator that iterates over results.
14
+ */
15
+ function getPagedAsyncIterator<
16
+ TElement,
17
+ TPage = TElement[],
18
+ TPageSettings = PageSettings,
19
+ TLink = string,
20
+ >(
21
+ pagedResult: PagedResult<TPage, TPageSettings, TLink>,
22
+ ): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {
23
+ const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);
24
+ return {
25
+ next() {
26
+ return iter.next();
27
+ },
28
+ [Symbol.asyncIterator]() {
29
+ return this;
30
+ },
31
+ byPage:
32
+ pagedResult?.byPage ??
33
+ (((settings?: PageSettings) => {
34
+ const { continuationToken } = settings ?? {};
35
+ return getPageAsyncIterator(pagedResult, {
36
+ pageLink: continuationToken as unknown as TLink | undefined,
37
+ });
38
+ }) as unknown as (settings?: TPageSettings) => AsyncIterableIterator<TPage>),
39
+ };
40
+ }
41
+
42
+ async function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(
43
+ pagedResult: PagedResult<TPage, TPageSettings, TLink>,
44
+ ): AsyncIterableIterator<TElement> {
45
+ const pages = getPageAsyncIterator(pagedResult);
46
+ const firstVal = await pages.next();
47
+ // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
48
+ if (!Array.isArray(firstVal.value)) {
49
+ // can extract elements from this page
50
+ const { toElements } = pagedResult;
51
+ if (toElements) {
52
+ yield* toElements(firstVal.value) as TElement[];
53
+ for await (const page of pages) {
54
+ yield* toElements(page) as TElement[];
55
+ }
56
+ } else {
57
+ yield firstVal.value;
58
+ // \`pages\` is of type \`AsyncIterableIterator<TPage>\` but TPage = TElement in this case
59
+ yield* pages as unknown as AsyncIterableIterator<TElement>;
60
+ }
61
+ } else {
62
+ yield* firstVal.value;
63
+ for await (const page of pages) {
64
+ // pages is of type \`AsyncIterableIterator<TPage>\` so \`page\` is of type \`TPage\`. In this branch,
65
+ // it must be the case that \`TPage = TElement[]\`
66
+ yield* page as unknown as TElement[];
67
+ }
68
+ }
69
+ }
70
+
71
+ async function* getPageAsyncIterator<TPage, TLink, TPageSettings>(
72
+ pagedResult: PagedResult<TPage, TPageSettings, TLink>,
73
+ options: {
74
+ pageLink?: TLink;
75
+ } = {},
76
+ ): AsyncIterableIterator<TPage> {
77
+ const { pageLink } = options;
78
+ let response = await pagedResult.getPage(pageLink ?? pagedResult.firstPageLink);
79
+ if (!response) {
80
+ return;
81
+ }
82
+ yield response.page;
83
+ while (response.nextPageLink) {
84
+ response = await pagedResult.getPage(response.nextPageLink);
85
+ if (!response) {
86
+ return;
87
+ }
88
+ yield response.page;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * An interface that tracks the settings for paged iteration
94
+ */
95
+ export interface PageSettings {
96
+ /**
97
+ * The token that keeps track of where to continue the iterator
98
+ */
99
+ continuationToken?: string;
100
+ }
101
+
102
+ /**
103
+ * An interface that allows async iterable iteration both to completion and by page.
104
+ */
105
+ export interface PagedAsyncIterableIterator<
106
+ TElement,
107
+ TPage = TElement[],
108
+ TPageSettings = PageSettings,
109
+ > {
110
+ /**
111
+ * The next method, part of the iteration protocol
112
+ */
113
+ next(): Promise<IteratorResult<TElement>>;
114
+ /**
115
+ * The connection to the async iterator, part of the iteration protocol
116
+ */
117
+ [Symbol.asyncIterator](): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
118
+ /**
119
+ * Return an AsyncIterableIterator that works a page at a time
120
+ */
121
+ byPage: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
122
+ }
123
+
124
+ /**
125
+ * An interface that describes how to communicate with the service.
126
+ */
127
+ interface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {
128
+ /**
129
+ * Link to the first page of results.
130
+ */
131
+ firstPageLink: TLink;
132
+ /**
133
+ * A method that returns a page of results.
134
+ */
135
+ getPage: (
136
+ pageLink: TLink,
137
+ ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>;
138
+ /**
139
+ * a function to implement the \`byPage\` method on the paged async iterator.
140
+ */
141
+ byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
142
+
143
+ /**
144
+ * A function to extract elements from a page.
145
+ */
146
+ toElements?: (page: TPage) => unknown[];
147
+ }
148
+
149
+ /**
150
+ * Helper type to extract the type of an array
151
+ */
152
+ export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;
153
+
154
+ /**
155
+ * The type of a custom function that defines how to get a page and a link to the next one if any.
156
+ */
157
+ export type GetPage<TPage> = (
158
+ pageLink: string,
159
+ ) => Promise<{
160
+ page: TPage;
161
+ nextPageLink?: string;
162
+ }>;
163
+
164
+ /**
165
+ * Options for the paging helper
166
+ */
167
+ export interface PagingOptions<TResponse> {
168
+ /**
169
+ * Custom function to extract pagination details for crating the PagedAsyncIterableIterator
170
+ */
171
+ customGetPage?: GetPage<PaginateReturn<TResponse>[]>
172
+ }
173
+
174
+ /**
175
+ * Helper type to infer the Type of the paged elements from the response type
176
+ * This type is generated based on the swagger information for x-ms-pageable
177
+ * specifically on the itemName property which indicates the property of the response
178
+ * where the page items are found. The default value is \`value\`.
179
+ * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter
180
+ */
181
+ export type PaginateReturn<TResult> = TResult extends {{#each itemNames}}
182
+ {
183
+
184
+ body: { {{this}}?: infer TPage }
185
+
186
+ } {{#if @last }}{{else}} | {{/if}}
187
+ {{/each}}
188
+ ? GetArrayType<TPage>
189
+ : Array<unknown>;
190
+
191
+ /**
192
+ * Helper to paginate results from an initial response that follows the specification of Autorest \`x-ms-pageable\` extension
193
+ * @param client - Client to use for sending the next page requests
194
+ * @param initialResponse - Initial response containing the nextLink and current page of elements
195
+ * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
196
+ * @returns - PagedAsyncIterableIterator to iterate the elements
197
+ */
198
+ export function paginate<TResponse extends PathUncheckedResponse>(
199
+ client: Client,
200
+ initialResponse: TResponse,
201
+ options: PagingOptions<TResponse> = {}
202
+ ): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {
203
+ // Extract element type from initial response
204
+ type TElement = PaginateReturn<TResponse>;
205
+ let firstRun = true;
206
+ {{#if isComplexPaging}}
207
+ // We need to check the response for success before trying to inspect it looking for
208
+ // the properties to use for nextLink and itemName
209
+ checkPagingRequest(initialResponse);
210
+ const { itemName, nextLinkName } = getPaginationProperties(initialResponse);
211
+ {{else}}
212
+ const itemName = {{ quoteWrap itemNames }};
213
+ const nextLinkName = {{quoteWrap nextLinkNames}};
214
+ {{/if}}
215
+ const { customGetPage } = options;
216
+ const pagedResult: PagedResult<TElement[]> = {
217
+ firstPageLink: "",
218
+ getPage:
219
+ typeof customGetPage === "function"
220
+ ? customGetPage
221
+ : async (pageLink: string) => {
222
+ const result = firstRun
223
+ ? initialResponse
224
+ : await client.pathUnchecked(pageLink).get();
225
+ firstRun = false;
226
+ checkPagingRequest(result);
227
+ const nextLink = getNextLink(result.body, nextLinkName);
228
+ const values = getElements<TElement>(result.body, itemName);
229
+ return {
230
+ page: values,
231
+ nextPageLink: nextLink
232
+ };
233
+ }
234
+ };
235
+
236
+ return getPagedAsyncIterator(pagedResult);
237
+ }
238
+
239
+ /**
240
+ * Gets for the value of nextLink in the body
241
+ */
242
+ function getNextLink(body: unknown, nextLinkName?: string): string | undefined {
243
+ if (!nextLinkName) {
244
+ return undefined;
245
+ }
246
+
247
+ const nextLink = (body as Record<string, unknown>)[nextLinkName];
248
+
249
+ if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
250
+ throw new Error(
251
+ \`Body Property \${nextLinkName} should be a string or undefined\`
252
+ );
253
+ }
254
+
255
+ return nextLink;
256
+ }
257
+
258
+ /**
259
+ * Gets the elements of the current request in the body.
260
+ */
261
+ function getElements<T = unknown>(body: unknown, itemName: string): T[] {
262
+ const value = (body as Record<string, unknown>)[itemName] as T[];
263
+
264
+ // value has to be an array according to the x-ms-pageable extension.
265
+ // The fact that this must be an array is used above to calculate the
266
+ // type of elements in the page in PaginateReturn
267
+ if (!Array.isArray(value)) {
268
+ throw new Error(
269
+ \`Couldn't paginate response\\n Body doesn't contain an array property with name: \${itemName}\`
270
+ );
271
+ }
272
+
273
+ return value ?? [];
274
+ }
275
+
276
+ /**
277
+ * Checks if a request failed
278
+ */
279
+ function checkPagingRequest(response: PathUncheckedResponse): void {
280
+ const Http2xxStatusCodes = [
281
+ "200",
282
+ "201",
283
+ "202",
284
+ "203",
285
+ "204",
286
+ "205",
287
+ "206",
288
+ "207",
289
+ "208",
290
+ "226"
291
+ ];
292
+ if (!Http2xxStatusCodes.includes(response.status)) {
293
+ throw createRestError(
294
+ \`Pagination failed with unexpected statusCode \${response.status}\`,
295
+ response
296
+ );
297
+ }
298
+ }
299
+
300
+ {{#if isComplexPaging}}
301
+ /**
302
+ * Extracts the itemName and nextLinkName from the initial response to use them for pagination
303
+ */
304
+ function getPaginationProperties(initialResponse: PathUncheckedResponse) {
305
+ // Build a set with the passed custom nextLinkNames
306
+ const nextLinkNames = new Set([{{ quoteWrap nextLinkNames }}]);
307
+
308
+ // Build a set with the passed custom set of itemNames
309
+ const itemNames = new Set([{{ quoteWrap itemNames }}]);
310
+
311
+ let nextLinkName: string | undefined;
312
+ let itemName: string | undefined;
313
+
314
+ for (const name of nextLinkNames) {
315
+ const nextLink = (initialResponse.body as Record<string, unknown>)[
316
+ name
317
+ ] as string;
318
+ if (nextLink) {
319
+ nextLinkName = name;
320
+ break;
321
+ }
322
+ }
323
+
324
+ for (const name of itemNames) {
325
+ const item = (initialResponse.body as Record<string, unknown>)[
326
+ name
327
+ ] as string;
328
+ if (item) {
329
+ itemName = name;
330
+ break;
331
+ }
332
+ }
333
+
334
+ if (!itemName) {
335
+ throw new Error(
336
+ \`Couldn't paginate response\\n Body doesn't contain an array property with name: \${[
337
+ ...itemNames
338
+ ].join(" OR ")}\`
339
+ );
340
+ }
341
+
342
+ return { itemName, nextLinkName };
343
+ }
344
+ {{/if}}
345
+ `;
@@ -0,0 +1,225 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ export const pollingContent = `
5
+ import type { Client, HttpResponse } from "@azure-rest/core-client";
6
+ import type { AbortSignalLike } from "@azure/abort-controller";
7
+ import type {
8
+ CancelOnProgress,
9
+ CreateHttpPollerOptions,
10
+ RunningOperation,
11
+ OperationResponse,
12
+ OperationState,
13
+ } from "@azure/core-lro";
14
+ import { createHttpPoller } from "@azure/core-lro";
15
+ {{#if clientOverload}}
16
+ import type {
17
+ {{#each importedResponses}}
18
+ {{this}},
19
+ {{/each}}
20
+ } from "./responses{{#if isEsm}}.js{{/if}}";
21
+ {{/if}}
22
+
23
+ /**
24
+ * A simple poller that can be used to poll a long running operation.
25
+ */
26
+ export interface SimplePollerLike<
27
+ TState extends OperationState<TResult>,
28
+ TResult
29
+ > {
30
+ /**
31
+ * Returns true if the poller has finished polling.
32
+ */
33
+ isDone(): boolean;
34
+ /**
35
+ * Returns the state of the operation.
36
+ */
37
+ getOperationState(): TState;
38
+ /**
39
+ * Returns the result value of the operation,
40
+ * regardless of the state of the poller.
41
+ * It can return undefined or an incomplete form of the final TResult value
42
+ * depending on the implementation.
43
+ */
44
+ getResult(): TResult | undefined;
45
+ /**
46
+ * Returns a promise that will resolve once a single polling request finishes.
47
+ * It does this by calling the update method of the Poller's operation.
48
+ */
49
+ poll(options?: { abortSignal?: AbortSignalLike }): Promise<TState>;
50
+ /**
51
+ * Returns a promise that will resolve once the underlying operation is completed.
52
+ */
53
+ pollUntilDone(pollOptions?: {
54
+ abortSignal?: AbortSignalLike;
55
+ }): Promise<TResult>;
56
+ /**
57
+ * Invokes the provided callback after each polling is completed,
58
+ * sending the current state of the poller's operation.
59
+ *
60
+ * It returns a method that can be used to stop receiving updates on the given callback function.
61
+ */
62
+ onProgress(callback: (state: TState) => void): CancelOnProgress;
63
+
64
+ /**
65
+ * Returns a promise that could be used for serialized version of the poller's operation
66
+ * by invoking the operation's serialize method.
67
+ */
68
+ serialize(): Promise<string>;
69
+
70
+ /**
71
+ * Wait the poller to be submitted.
72
+ */
73
+ submitted(): Promise<void>;
74
+
75
+ /**
76
+ * Returns a string representation of the poller's operation. Similar to serialize but returns a string.
77
+ * @deprecated Use serialize() instead.
78
+ */
79
+ toString(): string;
80
+
81
+ /**
82
+ * Stops the poller from continuing to poll. Please note this will only stop the client-side polling
83
+ * @deprecated Use abortSignal to stop polling instead.
84
+ */
85
+ stopPolling(): void;
86
+
87
+ /**
88
+ * Returns true if the poller is stopped.
89
+ * @deprecated Use abortSignal status to track this instead.
90
+ */
91
+ isStopped(): boolean;
92
+ }
93
+
94
+ /**
95
+ * Helper function that builds a Poller object to help polling a long running operation.
96
+ * @param client - Client to use for sending the request to get additional pages.
97
+ * @param initialResponse - The initial response.
98
+ * @param options - Options to set a resume state or custom polling interval.
99
+ * @returns - A poller object to poll for operation state updates and eventually get the final response.
100
+ */
101
+ {{#if clientOverload}}
102
+ {{#each overloadMap}}
103
+ export async function getLongRunningPoller<
104
+ TResult extends {{ this.finalResponses }}
105
+ >(
106
+ client: Client,
107
+ initialResponse: {{ this.initialResponses }},
108
+ options?: CreateHttpPollerOptions<TResult, OperationState<TResult>>
109
+ ): Promise<SimplePollerLike<OperationState<TResult>, TResult>>;
110
+ {{/each}}
111
+ {{/if}}
112
+ export async function getLongRunningPoller<TResult extends HttpResponse>(
113
+ client: Client,
114
+ initialResponse: TResult,
115
+ options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}
116
+ ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {
117
+ const abortController = new AbortController();
118
+ const poller: RunningOperation<TResult> = {
119
+ sendInitialRequest: async () => {
120
+ // In the case of Rest Clients we are building the LRO poller object from a response that's the reason
121
+ // we are not triggering the initial request here, just extracting the information from the
122
+ // response we were provided.
123
+ return getLroResponse(initialResponse);
124
+ },
125
+ sendPollRequest: async (
126
+ path: string,
127
+ pollOptions?: { abortSignal?: AbortSignalLike }
128
+ ) => {
129
+ // This is the callback that is going to be called to poll the service
130
+ // to get the latest status. We use the client provided and the polling path
131
+ // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
132
+ // depending on the lro pattern that the service implements. If non is provided we default to the initial path.
133
+ function abortListener(): void {
134
+ abortController.abort();
135
+ }
136
+ const inputAbortSignal = pollOptions?.abortSignal;
137
+ const abortSignal = abortController.signal;
138
+ if (inputAbortSignal?.aborted) {
139
+ abortController.abort();
140
+ } else if (!abortSignal.aborted) {
141
+ inputAbortSignal?.addEventListener("abort", abortListener, {
142
+ once: true
143
+ });
144
+ }
145
+ let response;
146
+ try {
147
+ response = await client
148
+ .pathUnchecked(path ?? initialResponse.request.url)
149
+ .get({ abortSignal });
150
+ } finally {
151
+ inputAbortSignal?.removeEventListener("abort", abortListener);
152
+ }
153
+ const lroResponse = getLroResponse(response as TResult);
154
+ lroResponse.rawResponse.headers["x-ms-original-url"] =
155
+ initialResponse.request.url;
156
+ return lroResponse;
157
+ }
158
+ };
159
+
160
+ options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;
161
+ const httpPoller = createHttpPoller(poller, options);
162
+ const simplePoller: SimplePollerLike<OperationState<TResult>, TResult> = {
163
+ isDone() {
164
+ return httpPoller.isDone;
165
+ },
166
+ isStopped() {
167
+ return abortController.signal.aborted;
168
+ },
169
+ getOperationState() {
170
+ if (!httpPoller.operationState) {
171
+ throw new Error(
172
+ "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState()."
173
+ );
174
+ }
175
+ return httpPoller.operationState;
176
+ },
177
+ getResult() {
178
+ return httpPoller.result;
179
+ },
180
+ toString() {
181
+ if (!httpPoller.operationState) {
182
+ throw new Error(
183
+ "Operation state is not available. The poller may not have been started and you could await submitted() before calling getOperationState()."
184
+ );
185
+ }
186
+ return JSON.stringify({
187
+ state: httpPoller.operationState
188
+ });
189
+ },
190
+ stopPolling() {
191
+ abortController.abort();
192
+ },
193
+ onProgress: httpPoller.onProgress,
194
+ poll: httpPoller.poll,
195
+ pollUntilDone: httpPoller.pollUntilDone,
196
+ serialize: httpPoller.serialize,
197
+ submitted: httpPoller.submitted
198
+ };
199
+ return simplePoller;
200
+ }
201
+
202
+ /**
203
+ * Converts a Rest Client response to a response that the LRO implementation understands
204
+ * @param response - a rest client http response
205
+ * @returns - An LRO response that the LRO implementation understands
206
+ */
207
+ function getLroResponse<TResult extends HttpResponse>(
208
+ response: TResult
209
+ ): OperationResponse<TResult> {
210
+ if (Number.isNaN(response.status)) {
211
+ throw new TypeError(
212
+ \`Status code of the response is not a number. Value: \${response.status}\`
213
+ );
214
+ }
215
+
216
+ return {
217
+ flatResponse: response,
218
+ rawResponse: {
219
+ ...response,
220
+ statusCode: Number.parseInt(response.status),
221
+ body: response.body
222
+ }
223
+ };
224
+ }
225
+ `;
@@ -0,0 +1,56 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ export const sampleTemplate = `
5
+ {{#each importedTypes}}
6
+ {{this}}
7
+ {{/each}}
8
+ import "dotenv/config";
9
+
10
+ {{#each samples}}
11
+ /**
12
+ * This sample demonstrates how to {{this.description}}
13
+ *
14
+ * @summary {{this.description}}
15
+ {{#if this.originalFileLocation}}
16
+ * x-ms-original-file: {{this.originalFileLocation}}
17
+ {{/if}}
18
+ */
19
+ async function {{name}}(): Promise<void> {
20
+ {{#each this.clientParamAssignments}}
21
+ {{this}}
22
+ {{/each}}
23
+ const client = {{this.defaultFactoryName}}({{this.clientParamNames}});
24
+ {{#each this.pathParamAssignments}}
25
+ {{this}}
26
+ {{/each}}
27
+ {{#each this.methodParamAssignments}}
28
+ {{this}}
29
+ {{/each}}
30
+ {{#if this.isPaging}}
31
+ const initialResponse = await client.path({{this.pathParamNames}}).{{method}}({{methodParamNames}});
32
+ const pageData = paginate(client, initialResponse);
33
+ const result = [];
34
+ for await (const item of pageData) {
35
+ result.push(item);
36
+ }
37
+ {{else if this.isLRO}}
38
+ const initialResponse ={{#unless this.useLegacyLro}} await{{/unless}} client.path({{this.pathParamNames}}).{{method}}({{methodParamNames}});
39
+ const poller = await getLongRunningPoller(client, initialResponse);
40
+ const result = await poller.pollUntilDone();
41
+ {{else}}
42
+ const result = await client.path({{this.pathParamNames}}).{{method}}({{methodParamNames}});
43
+ {{/if}}
44
+ console.log(result);
45
+ }
46
+
47
+ {{/each}}
48
+
49
+ async function main(): Promise<void> {
50
+ {{#each samples}}
51
+ await {{this.name}}();
52
+ {{/each}}
53
+ }
54
+
55
+ main().catch(console.error);
56
+ `;
@@ -0,0 +1,34 @@
1
+ export const buildMultiCollectionContent = `
2
+ export function buildMultiCollection(
3
+ items: string[],
4
+ parameterName: string
5
+ ): string {
6
+ return items
7
+ .map((item, index) => {
8
+ if (index === 0) {
9
+ return item;
10
+ }
11
+ return \`\${parameterName}=\${item}\`;
12
+ })
13
+ .join("&");
14
+ }`;
15
+
16
+ export const buildPipeCollectionContent = `
17
+ export function buildPipeCollection(items: string[] | number[]): string {
18
+ return items.join("|");
19
+ }`;
20
+
21
+ export const buildSsvCollectionContent = `
22
+ export function buildSsvCollection(items: string[] | number[]): string {
23
+ return items.join(" ");
24
+ }`;
25
+
26
+ export const buildTsvCollectionContent = `
27
+ export function buildTsvCollection(items: string[] | number[]): string {
28
+ return items.join("\\t");
29
+ }`;
30
+
31
+ export const buildCsvCollectionContent = `
32
+ export function buildCsvCollection(items: string[] | number[]): string {
33
+ return items.join(",");
34
+ }`;
@@ -0,0 +1,12 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore: to fix the handlebars issue
3
+ import hbs from "handlebars";
4
+ import { RLCModel } from "../interfaces.js";
5
+ import { karmaConfig } from "./template.js";
6
+
7
+ export function buildKarmaConfigFile(_model: RLCModel) {
8
+ return {
9
+ path: "karma.conf.js",
10
+ content: hbs.compile(karmaConfig, { noEscape: true })({})
11
+ };
12
+ }
@@ -0,0 +1,18 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore: to fix the handlebars issue
3
+ import hbs from "handlebars";
4
+ import { RLCModel } from "../interfaces.js";
5
+ import { recordedClientContent } from "./template.js";
6
+
7
+ export function buildRecordedClientFile(model: RLCModel) {
8
+ const recordedClientFileContents = hbs.compile(recordedClientContent, {
9
+ noEscape: true
10
+ });
11
+ return {
12
+ path: "test/public/utils/recordedClient.ts",
13
+ content: recordedClientFileContents({
14
+ isEsm: model.options?.moduleKind === "esm",
15
+ isCjs: model.options?.moduleKind === "cjs"
16
+ })
17
+ };
18
+ }