@azure-tools/typespec-ts 0.56.0-dev.1 → 0.56.0-dev.10

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 (456) hide show
  1. package/README.md +1 -13
  2. package/dist/src/context-manager.d.ts +2 -2
  3. package/dist/src/context-manager.d.ts.map +1 -1
  4. package/dist/src/framework/declaration.d.ts.map +1 -1
  5. package/dist/src/framework/declaration.js +6 -20
  6. package/dist/src/framework/declaration.js.map +1 -1
  7. package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -1
  8. package/dist/src/framework/hooks/sdk-types.js +1 -1
  9. package/dist/src/framework/hooks/sdk-types.js.map +1 -1
  10. package/dist/src/framework/source-file-batch.d.ts +35 -0
  11. package/dist/src/framework/source-file-batch.d.ts.map +1 -0
  12. package/dist/src/framework/source-file-batch.js +128 -0
  13. package/dist/src/framework/source-file-batch.js.map +1 -0
  14. package/dist/src/index.d.ts.map +1 -1
  15. package/dist/src/index.js +63 -60
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/{rlc-common/interfaces.d.ts → interfaces.d.ts} +12 -14
  18. package/dist/src/interfaces.d.ts.map +1 -0
  19. package/dist/src/interfaces.js.map +1 -0
  20. package/dist/src/lib.d.ts +2 -4
  21. package/dist/src/lib.d.ts.map +1 -1
  22. package/dist/src/lib.js +2 -12
  23. package/dist/src/lib.js.map +1 -1
  24. package/dist/src/meta-tree.d.ts +4 -4
  25. package/dist/src/meta-tree.d.ts.map +1 -1
  26. package/dist/src/metadata/build-api-extractor-config.d.ts +6 -0
  27. package/dist/src/metadata/build-api-extractor-config.d.ts.map +1 -0
  28. package/dist/src/metadata/build-api-extractor-config.js.map +1 -0
  29. package/dist/src/metadata/build-changelog-file.d.ts +6 -0
  30. package/dist/src/metadata/build-changelog-file.d.ts.map +1 -0
  31. package/dist/src/metadata/build-changelog-file.js.map +1 -0
  32. package/dist/src/metadata/build-es-lint-config.d.ts +6 -0
  33. package/dist/src/metadata/build-es-lint-config.d.ts.map +1 -0
  34. package/dist/src/metadata/build-es-lint-config.js.map +1 -0
  35. package/dist/src/metadata/build-license-file.d.ts.map +1 -0
  36. package/dist/src/metadata/build-license-file.js.map +1 -0
  37. package/dist/src/{rlc-common/metadata → metadata}/build-package-file.d.ts +3 -3
  38. package/dist/src/metadata/build-package-file.d.ts.map +1 -0
  39. package/dist/src/{rlc-common/metadata → metadata}/build-package-file.js +1 -1
  40. package/dist/src/metadata/build-package-file.js.map +1 -0
  41. package/dist/src/metadata/build-readme-file.d.ts +11 -0
  42. package/dist/src/metadata/build-readme-file.d.ts.map +1 -0
  43. package/dist/src/{rlc-common/metadata → metadata}/build-readme-file.js +16 -69
  44. package/dist/src/metadata/build-readme-file.js.map +1 -0
  45. package/dist/src/metadata/build-sample-env-file.d.ts +6 -0
  46. package/dist/src/metadata/build-sample-env-file.d.ts.map +1 -0
  47. package/dist/src/metadata/build-sample-env-file.js.map +1 -0
  48. package/dist/src/{rlc-common/metadata → metadata}/build-test-config.d.ts +3 -3
  49. package/dist/src/metadata/build-test-config.d.ts.map +1 -0
  50. package/dist/src/metadata/build-test-config.js.map +1 -0
  51. package/dist/src/{rlc-common/metadata → metadata}/build-ts-config.d.ts +3 -3
  52. package/dist/src/metadata/build-ts-config.d.ts.map +1 -0
  53. package/dist/src/metadata/build-ts-config.js.map +1 -0
  54. package/dist/src/metadata/build-vitest-config.d.ts +6 -0
  55. package/dist/src/metadata/build-vitest-config.d.ts.map +1 -0
  56. package/dist/src/metadata/build-vitest-config.js.map +1 -0
  57. package/dist/src/{rlc-common/metadata → metadata}/build-warp-config.d.ts +2 -2
  58. package/dist/src/metadata/build-warp-config.d.ts.map +1 -0
  59. package/dist/src/metadata/build-warp-config.js.map +1 -0
  60. package/dist/src/metadata/package-json/azure-package-common.d.ts.map +1 -0
  61. package/dist/src/metadata/package-json/azure-package-common.js.map +1 -0
  62. package/dist/src/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -0
  63. package/dist/src/metadata/package-json/build-azure-monorepo-package.js.map +1 -0
  64. package/dist/src/metadata/package-json/package-common.d.ts.map +1 -0
  65. package/dist/src/metadata/package-json/package-common.js.map +1 -0
  66. package/dist/src/metadata/render-template.d.ts +24 -0
  67. package/dist/src/metadata/render-template.d.ts.map +1 -0
  68. package/dist/src/metadata/render-template.js +148 -0
  69. package/dist/src/metadata/render-template.js.map +1 -0
  70. package/dist/src/metadata/test/build-recorded-client.d.ts +6 -0
  71. package/dist/src/metadata/test/build-recorded-client.d.ts.map +1 -0
  72. package/dist/src/metadata/test/build-recorded-client.js +8 -0
  73. package/dist/src/metadata/test/build-recorded-client.js.map +1 -0
  74. package/dist/src/metadata/test/build-sample-test.d.ts +6 -0
  75. package/dist/src/metadata/test/build-sample-test.d.ts.map +1 -0
  76. package/dist/src/metadata/test/build-sample-test.js +8 -0
  77. package/dist/src/metadata/test/build-sample-test.js.map +1 -0
  78. package/dist/src/metadata/test/build-snippets.d.ts +6 -0
  79. package/dist/src/metadata/test/build-snippets.d.ts.map +1 -0
  80. package/dist/src/{rlc-common → metadata}/test/build-snippets.js +3 -5
  81. package/dist/src/metadata/test/build-snippets.js.map +1 -0
  82. package/dist/src/metadata/test/template.d.ts +4 -0
  83. package/dist/src/metadata/test/template.d.ts.map +1 -0
  84. package/dist/src/metadata/test/template.js +100 -0
  85. package/dist/src/metadata/test/template.js.map +1 -0
  86. package/dist/src/metadata/utils.d.ts +3 -0
  87. package/dist/src/metadata/utils.d.ts.map +1 -0
  88. package/dist/src/metadata/utils.js.map +1 -0
  89. package/dist/src/modular/build-classical-client.d.ts.map +1 -1
  90. package/dist/src/modular/build-classical-client.js +9 -9
  91. package/dist/src/modular/build-classical-client.js.map +1 -1
  92. package/dist/src/modular/build-classical-operation-groups.d.ts.map +1 -1
  93. package/dist/src/modular/build-classical-operation-groups.js +3 -3
  94. package/dist/src/modular/build-classical-operation-groups.js.map +1 -1
  95. package/dist/src/modular/build-client-context.d.ts.map +1 -1
  96. package/dist/src/modular/build-client-context.js +7 -7
  97. package/dist/src/modular/build-client-context.js.map +1 -1
  98. package/dist/src/modular/build-modular-options.js +3 -3
  99. package/dist/src/modular/build-modular-options.js.map +1 -1
  100. package/dist/src/modular/build-operations.d.ts.map +1 -1
  101. package/dist/src/modular/build-operations.js +6 -6
  102. package/dist/src/modular/build-operations.js.map +1 -1
  103. package/dist/src/modular/build-project-files.d.ts.map +1 -1
  104. package/dist/src/modular/build-project-files.js +4 -4
  105. package/dist/src/modular/build-project-files.js.map +1 -1
  106. package/dist/src/modular/build-restore-poller.d.ts.map +1 -1
  107. package/dist/src/modular/build-restore-poller.js +3 -3
  108. package/dist/src/modular/build-restore-poller.js.map +1 -1
  109. package/dist/src/modular/build-root-index.d.ts.map +1 -1
  110. package/dist/src/modular/build-root-index.js +42 -14
  111. package/dist/src/modular/build-root-index.js.map +1 -1
  112. package/dist/src/modular/build-subpath-index.d.ts.map +1 -1
  113. package/dist/src/modular/build-subpath-index.js +17 -4
  114. package/dist/src/modular/build-subpath-index.js.map +1 -1
  115. package/dist/src/modular/emit-models-options.d.ts.map +1 -1
  116. package/dist/src/modular/emit-models-options.js +3 -3
  117. package/dist/src/modular/emit-models-options.js.map +1 -1
  118. package/dist/src/modular/emit-models.d.ts +1 -1
  119. package/dist/src/modular/emit-models.d.ts.map +1 -1
  120. package/dist/src/modular/emit-models.js +32 -25
  121. package/dist/src/modular/emit-models.js.map +1 -1
  122. package/dist/src/modular/emit-samples.d.ts.map +1 -1
  123. package/dist/src/modular/emit-samples.js +5 -5
  124. package/dist/src/modular/emit-samples.js.map +1 -1
  125. package/dist/src/modular/emit-tests.d.ts.map +1 -1
  126. package/dist/src/modular/emit-tests.js +1 -1
  127. package/dist/src/modular/emit-tests.js.map +1 -1
  128. package/dist/src/modular/helpers/classical-operation-helpers.d.ts.map +1 -1
  129. package/dist/src/modular/helpers/classical-operation-helpers.js +11 -11
  130. package/dist/src/modular/helpers/classical-operation-helpers.js.map +1 -1
  131. package/dist/src/modular/helpers/client-helpers.d.ts.map +1 -1
  132. package/dist/src/modular/helpers/client-helpers.js +3 -3
  133. package/dist/src/modular/helpers/client-helpers.js.map +1 -1
  134. package/dist/src/modular/helpers/example-value-helpers.d.ts.map +1 -1
  135. package/dist/src/modular/helpers/example-value-helpers.js +2 -2
  136. package/dist/src/modular/helpers/example-value-helpers.js.map +1 -1
  137. package/dist/src/modular/helpers/naming-helpers.d.ts +1 -1
  138. package/dist/src/modular/helpers/naming-helpers.d.ts.map +1 -1
  139. package/dist/src/modular/helpers/naming-helpers.js +2 -2
  140. package/dist/src/modular/helpers/naming-helpers.js.map +1 -1
  141. package/dist/src/modular/helpers/operation-helpers.d.ts +4 -4
  142. package/dist/src/modular/helpers/operation-helpers.d.ts.map +1 -1
  143. package/dist/src/modular/helpers/operation-helpers.js +25 -26
  144. package/dist/src/modular/helpers/operation-helpers.js.map +1 -1
  145. package/dist/src/modular/helpers/type-helpers.d.ts.map +1 -1
  146. package/dist/src/modular/helpers/type-helpers.js +1 -1
  147. package/dist/src/modular/helpers/type-helpers.js.map +1 -1
  148. package/dist/src/modular/interfaces.d.ts +4 -4
  149. package/dist/src/modular/interfaces.d.ts.map +1 -1
  150. package/dist/src/modular/serialization/build-deserializer-function.d.ts.map +1 -1
  151. package/dist/src/modular/serialization/build-deserializer-function.js +2 -2
  152. package/dist/src/modular/serialization/build-deserializer-function.js.map +1 -1
  153. package/dist/src/modular/serialization/build-serializer-function.d.ts.map +1 -1
  154. package/dist/src/modular/serialization/build-serializer-function.js +2 -2
  155. package/dist/src/modular/serialization/build-serializer-function.js.map +1 -1
  156. package/dist/src/modular/serialization/build-xml-serializer-function.d.ts.map +1 -1
  157. package/dist/src/modular/serialization/build-xml-serializer-function.js +1 -1
  158. package/dist/src/modular/serialization/build-xml-serializer-function.js.map +1 -1
  159. package/dist/src/modular/type-expressions/get-enum-expression.js +1 -1
  160. package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
  161. package/dist/src/modular/type-expressions/get-nullable-expression.js +1 -1
  162. package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
  163. package/dist/src/modular/type-expressions/get-type-expression.d.ts.map +1 -1
  164. package/dist/src/modular/type-expressions/get-type-expression.js +3 -3
  165. package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
  166. package/dist/src/transform/transform-api-version-info.d.ts +1 -1
  167. package/dist/src/transform/transform-api-version-info.d.ts.map +1 -1
  168. package/dist/src/transform/transform-api-version-info.js +4 -3
  169. package/dist/src/transform/transform-api-version-info.js.map +1 -1
  170. package/dist/src/transform/{transfrom-rlc-options.d.ts → transform-client-options.d.ts} +3 -3
  171. package/dist/src/transform/transform-client-options.d.ts.map +1 -0
  172. package/dist/src/transform/{transfrom-rlc-options.js → transform-client-options.js} +9 -13
  173. package/dist/src/transform/transform-client-options.js.map +1 -0
  174. package/dist/src/transform/transform-helper-function-details.d.ts +1 -1
  175. package/dist/src/transform/transform-helper-function-details.d.ts.map +1 -1
  176. package/dist/src/transform/transform-helper-function-details.js +4 -4
  177. package/dist/src/transform/transform-helper-function-details.js.map +1 -1
  178. package/dist/src/transform/transform-parameters.d.ts +1 -1
  179. package/dist/src/transform/transform-parameters.d.ts.map +1 -1
  180. package/dist/src/transform/transform-parameters.js +11 -11
  181. package/dist/src/transform/transform-parameters.js.map +1 -1
  182. package/dist/src/transform/transform-paths.d.ts +1 -1
  183. package/dist/src/transform/transform-paths.d.ts.map +1 -1
  184. package/dist/src/transform/transform-paths.js +5 -4
  185. package/dist/src/transform/transform-paths.js.map +1 -1
  186. package/dist/src/transform/transform-responses.d.ts +1 -1
  187. package/dist/src/transform/transform-responses.d.ts.map +1 -1
  188. package/dist/src/transform/transform-responses.js +19 -18
  189. package/dist/src/transform/transform-responses.js.map +1 -1
  190. package/dist/src/transform/transform-schemas.js +5 -5
  191. package/dist/src/transform/transform-schemas.js.map +1 -1
  192. package/dist/src/transform/transform-telemetry-info.d.ts +1 -1
  193. package/dist/src/transform/transform-telemetry-info.d.ts.map +1 -1
  194. package/dist/src/transform/transform-telemetry-info.js +2 -2
  195. package/dist/src/transform/transform-telemetry-info.js.map +1 -1
  196. package/dist/src/transform/transform.d.ts +2 -2
  197. package/dist/src/transform/transform.d.ts.map +1 -1
  198. package/dist/src/transform/transform.js +9 -10
  199. package/dist/src/transform/transform.js.map +1 -1
  200. package/dist/src/utils/api-version-util.d.ts.map +1 -0
  201. package/dist/src/utils/api-version-util.js.map +1 -0
  202. package/dist/src/utils/client-utils.d.ts +5 -5
  203. package/dist/src/utils/client-utils.d.ts.map +1 -1
  204. package/dist/src/utils/client-utils.js +10 -10
  205. package/dist/src/utils/client-utils.js.map +1 -1
  206. package/dist/src/utils/cross-language-def.d.ts.map +1 -1
  207. package/dist/src/utils/cross-language-def.js +3 -3
  208. package/dist/src/utils/cross-language-def.js.map +1 -1
  209. package/dist/src/utils/emit-util.d.ts +2 -2
  210. package/dist/src/utils/emit-util.d.ts.map +1 -1
  211. package/dist/src/utils/emit-util.js +2 -2
  212. package/dist/src/utils/emit-util.js.map +1 -1
  213. package/dist/src/utils/imports-util.d.ts.map +1 -0
  214. package/dist/src/{rlc-common/helpers → utils}/imports-util.js +6 -6
  215. package/dist/src/utils/imports-util.js.map +1 -0
  216. package/dist/src/utils/interfaces.d.ts +3 -4
  217. package/dist/src/utils/interfaces.d.ts.map +1 -1
  218. package/dist/src/utils/model-utils.d.ts +1 -1
  219. package/dist/src/utils/model-utils.d.ts.map +1 -1
  220. package/dist/src/utils/model-utils.js +4 -2
  221. package/dist/src/utils/model-utils.js.map +1 -1
  222. package/dist/src/{rlc-common/helpers → utils}/name-constructors.d.ts +2 -2
  223. package/dist/src/utils/name-constructors.d.ts.map +1 -0
  224. package/dist/src/utils/name-constructors.js.map +1 -0
  225. package/dist/src/utils/name-utils.d.ts.map +1 -0
  226. package/dist/src/utils/name-utils.js.map +1 -0
  227. package/dist/src/utils/namespace-utils.js +4 -4
  228. package/dist/src/utils/namespace-utils.js.map +1 -1
  229. package/dist/src/utils/operation-helpers.d.ts +16 -0
  230. package/dist/src/utils/operation-helpers.d.ts.map +1 -0
  231. package/dist/src/utils/operation-helpers.js.map +1 -0
  232. package/dist/src/utils/operation-util.d.ts +2 -2
  233. package/dist/src/utils/operation-util.d.ts.map +1 -1
  234. package/dist/src/utils/operation-util.js +17 -18
  235. package/dist/src/utils/operation-util.js.map +1 -1
  236. package/dist/src/utils/parameter-utils.d.ts +1 -1
  237. package/dist/src/utils/parameter-utils.d.ts.map +1 -1
  238. package/dist/src/utils/parameter-utils.js +2 -4
  239. package/dist/src/utils/parameter-utils.js.map +1 -1
  240. package/dist/src/{rlc-common/helpers → utils}/schema-helpers.d.ts +2 -2
  241. package/dist/src/utils/schema-helpers.d.ts.map +1 -0
  242. package/dist/src/utils/schema-helpers.js.map +1 -0
  243. package/dist/src/utils/type-util.d.ts.map +1 -0
  244. package/dist/src/utils/type-util.js.map +1 -0
  245. package/dist/tsconfig.tsbuildinfo +1 -1
  246. package/package.json +14 -24
  247. package/src/context-manager.ts +2 -2
  248. package/src/framework/declaration.ts +8 -20
  249. package/src/framework/hooks/sdk-types.ts +1 -1
  250. package/src/framework/source-file-batch.ts +140 -0
  251. package/src/index.ts +81 -101
  252. package/src/{rlc-common/interfaces.ts → interfaces.ts} +14 -16
  253. package/src/lib.ts +3 -16
  254. package/src/meta-tree.ts +4 -4
  255. package/src/{rlc-common/metadata → metadata}/build-api-extractor-config.ts +2 -2
  256. package/src/{rlc-common/metadata → metadata}/build-changelog-file.ts +3 -3
  257. package/src/{rlc-common/metadata → metadata}/build-es-lint-config.ts +2 -2
  258. package/src/{rlc-common/metadata → metadata}/build-package-file.ts +6 -6
  259. package/src/{rlc-common/metadata → metadata}/build-readme-file.ts +25 -99
  260. package/src/{rlc-common/metadata → metadata}/build-sample-env-file.ts +2 -2
  261. package/src/{rlc-common/metadata → metadata}/build-test-config.ts +4 -4
  262. package/src/{rlc-common/metadata → metadata}/build-ts-config.ts +3 -3
  263. package/src/{rlc-common/metadata → metadata}/build-vitest-config.ts +2 -2
  264. package/src/{rlc-common/metadata → metadata}/build-warp-config.ts +2 -2
  265. package/src/metadata/render-template.ts +202 -0
  266. package/src/metadata/test/build-recorded-client.ts +9 -0
  267. package/src/metadata/test/build-sample-test.ts +9 -0
  268. package/src/{rlc-common → metadata}/test/build-snippets.ts +5 -7
  269. package/src/metadata/test/template.ts +101 -0
  270. package/src/{rlc-common/metadata → metadata}/utils.ts +2 -2
  271. package/src/modular/build-classical-client.ts +9 -9
  272. package/src/modular/build-classical-operation-groups.ts +3 -3
  273. package/src/modular/build-client-context.ts +7 -7
  274. package/src/modular/build-modular-options.ts +3 -3
  275. package/src/modular/build-operations.ts +6 -6
  276. package/src/modular/build-project-files.ts +4 -5
  277. package/src/modular/build-restore-poller.ts +3 -3
  278. package/src/modular/build-root-index.ts +57 -19
  279. package/src/modular/build-subpath-index.ts +26 -5
  280. package/src/modular/emit-models-options.ts +3 -3
  281. package/src/modular/emit-models.ts +32 -26
  282. package/src/modular/emit-samples.ts +5 -5
  283. package/src/modular/emit-tests.ts +1 -1
  284. package/src/modular/helpers/classical-operation-helpers.ts +11 -11
  285. package/src/modular/helpers/client-helpers.ts +3 -3
  286. package/src/modular/helpers/example-value-helpers.ts +2 -2
  287. package/src/modular/helpers/naming-helpers.ts +2 -2
  288. package/src/modular/helpers/operation-helpers.ts +27 -27
  289. package/src/modular/helpers/type-helpers.ts +1 -1
  290. package/src/modular/interfaces.ts +4 -4
  291. package/src/modular/serialization/build-deserializer-function.ts +2 -2
  292. package/src/modular/serialization/build-serializer-function.ts +2 -2
  293. package/src/modular/serialization/build-xml-serializer-function.ts +1 -1
  294. package/src/modular/type-expressions/get-enum-expression.ts +1 -1
  295. package/src/modular/type-expressions/get-nullable-expression.ts +1 -1
  296. package/src/modular/type-expressions/get-type-expression.ts +3 -3
  297. package/src/transform/transform-api-version-info.ts +4 -10
  298. package/src/transform/{transfrom-rlc-options.ts → transform-client-options.ts} +12 -22
  299. package/src/transform/transform-helper-function-details.ts +5 -5
  300. package/src/transform/transform-parameters.ts +12 -12
  301. package/src/transform/transform-paths.ts +5 -12
  302. package/src/transform/transform-responses.ts +19 -19
  303. package/src/transform/transform-schemas.ts +5 -5
  304. package/src/transform/transform-telemetry-info.ts +3 -3
  305. package/src/transform/transform.ts +13 -18
  306. package/src/utils/client-utils.ts +11 -11
  307. package/src/utils/cross-language-def.ts +3 -3
  308. package/src/utils/emit-util.ts +3 -3
  309. package/src/{rlc-common/helpers → utils}/imports-util.ts +6 -6
  310. package/src/utils/interfaces.ts +3 -4
  311. package/src/utils/model-utils.ts +7 -8
  312. package/src/{rlc-common/helpers → utils}/name-constructors.ts +2 -2
  313. package/src/utils/namespace-utils.ts +4 -4
  314. package/src/{rlc-common/helpers → utils}/operation-helpers.ts +12 -12
  315. package/src/utils/operation-util.ts +19 -33
  316. package/src/utils/parameter-utils.ts +2 -4
  317. package/src/{rlc-common/helpers → utils}/schema-helpers.ts +2 -2
  318. package/dist/src/rlc-common/helpers/api-version-util.d.ts.map +0 -1
  319. package/dist/src/rlc-common/helpers/api-version-util.js.map +0 -1
  320. package/dist/src/rlc-common/helpers/imports-util.d.ts.map +0 -1
  321. package/dist/src/rlc-common/helpers/imports-util.js.map +0 -1
  322. package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +0 -1
  323. package/dist/src/rlc-common/helpers/name-constructors.js.map +0 -1
  324. package/dist/src/rlc-common/helpers/name-utils.d.ts.map +0 -1
  325. package/dist/src/rlc-common/helpers/name-utils.js.map +0 -1
  326. package/dist/src/rlc-common/helpers/operation-helpers.d.ts +0 -16
  327. package/dist/src/rlc-common/helpers/operation-helpers.d.ts.map +0 -1
  328. package/dist/src/rlc-common/helpers/operation-helpers.js.map +0 -1
  329. package/dist/src/rlc-common/helpers/schema-helpers.d.ts.map +0 -1
  330. package/dist/src/rlc-common/helpers/schema-helpers.js.map +0 -1
  331. package/dist/src/rlc-common/helpers/type-util.d.ts.map +0 -1
  332. package/dist/src/rlc-common/helpers/type-util.js.map +0 -1
  333. package/dist/src/rlc-common/index.d.ts +0 -23
  334. package/dist/src/rlc-common/index.d.ts.map +0 -1
  335. package/dist/src/rlc-common/index.js +0 -25
  336. package/dist/src/rlc-common/index.js.map +0 -1
  337. package/dist/src/rlc-common/interfaces.d.ts.map +0 -1
  338. package/dist/src/rlc-common/interfaces.js.map +0 -1
  339. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts +0 -6
  340. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts.map +0 -1
  341. package/dist/src/rlc-common/metadata/build-api-extractor-config.js.map +0 -1
  342. package/dist/src/rlc-common/metadata/build-changelog-file.d.ts +0 -6
  343. package/dist/src/rlc-common/metadata/build-changelog-file.d.ts.map +0 -1
  344. package/dist/src/rlc-common/metadata/build-changelog-file.js.map +0 -1
  345. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts +0 -6
  346. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts.map +0 -1
  347. package/dist/src/rlc-common/metadata/build-es-lint-config.js.map +0 -1
  348. package/dist/src/rlc-common/metadata/build-license-file.d.ts.map +0 -1
  349. package/dist/src/rlc-common/metadata/build-license-file.js.map +0 -1
  350. package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +0 -1
  351. package/dist/src/rlc-common/metadata/build-package-file.js.map +0 -1
  352. package/dist/src/rlc-common/metadata/build-readme-file.d.ts +0 -11
  353. package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +0 -1
  354. package/dist/src/rlc-common/metadata/build-readme-file.js.map +0 -1
  355. package/dist/src/rlc-common/metadata/build-sample-env-file.d.ts +0 -6
  356. package/dist/src/rlc-common/metadata/build-sample-env-file.d.ts.map +0 -1
  357. package/dist/src/rlc-common/metadata/build-sample-env-file.js.map +0 -1
  358. package/dist/src/rlc-common/metadata/build-test-config.d.ts.map +0 -1
  359. package/dist/src/rlc-common/metadata/build-test-config.js.map +0 -1
  360. package/dist/src/rlc-common/metadata/build-ts-config.d.ts.map +0 -1
  361. package/dist/src/rlc-common/metadata/build-ts-config.js.map +0 -1
  362. package/dist/src/rlc-common/metadata/build-vitest-config.d.ts +0 -6
  363. package/dist/src/rlc-common/metadata/build-vitest-config.d.ts.map +0 -1
  364. package/dist/src/rlc-common/metadata/build-vitest-config.js.map +0 -1
  365. package/dist/src/rlc-common/metadata/build-warp-config.d.ts.map +0 -1
  366. package/dist/src/rlc-common/metadata/build-warp-config.js.map +0 -1
  367. package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts.map +0 -1
  368. package/dist/src/rlc-common/metadata/package-json/azure-package-common.js.map +0 -1
  369. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +0 -1
  370. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +0 -1
  371. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +0 -1
  372. package/dist/src/rlc-common/metadata/package-json/package-common.js.map +0 -1
  373. package/dist/src/rlc-common/metadata/utils.d.ts +0 -3
  374. package/dist/src/rlc-common/metadata/utils.d.ts.map +0 -1
  375. package/dist/src/rlc-common/metadata/utils.js.map +0 -1
  376. package/dist/src/rlc-common/static/paginate-content.d.ts +0 -2
  377. package/dist/src/rlc-common/static/paginate-content.d.ts.map +0 -1
  378. package/dist/src/rlc-common/static/paginate-content.js +0 -345
  379. package/dist/src/rlc-common/static/paginate-content.js.map +0 -1
  380. package/dist/src/rlc-common/static/polling-content.d.ts +0 -2
  381. package/dist/src/rlc-common/static/polling-content.d.ts.map +0 -1
  382. package/dist/src/rlc-common/static/polling-content.js +0 -225
  383. package/dist/src/rlc-common/static/polling-content.js.map +0 -1
  384. package/dist/src/rlc-common/static/sample-template.d.ts +0 -2
  385. package/dist/src/rlc-common/static/sample-template.d.ts.map +0 -1
  386. package/dist/src/rlc-common/static/sample-template.js +0 -56
  387. package/dist/src/rlc-common/static/sample-template.js.map +0 -1
  388. package/dist/src/rlc-common/static/serialize-helper.d.ts +0 -6
  389. package/dist/src/rlc-common/static/serialize-helper.d.ts.map +0 -1
  390. package/dist/src/rlc-common/static/serialize-helper.js +0 -31
  391. package/dist/src/rlc-common/static/serialize-helper.js.map +0 -1
  392. package/dist/src/rlc-common/test/build-karma-config.d.ts +0 -6
  393. package/dist/src/rlc-common/test/build-karma-config.d.ts.map +0 -1
  394. package/dist/src/rlc-common/test/build-karma-config.js +0 -11
  395. package/dist/src/rlc-common/test/build-karma-config.js.map +0 -1
  396. package/dist/src/rlc-common/test/build-recorded-client.d.ts +0 -6
  397. package/dist/src/rlc-common/test/build-recorded-client.d.ts.map +0 -1
  398. package/dist/src/rlc-common/test/build-recorded-client.js +0 -14
  399. package/dist/src/rlc-common/test/build-recorded-client.js.map +0 -1
  400. package/dist/src/rlc-common/test/build-sample-test.d.ts +0 -6
  401. package/dist/src/rlc-common/test/build-sample-test.d.ts.map +0 -1
  402. package/dist/src/rlc-common/test/build-sample-test.js +0 -11
  403. package/dist/src/rlc-common/test/build-sample-test.js.map +0 -1
  404. package/dist/src/rlc-common/test/build-snippets.d.ts +0 -6
  405. package/dist/src/rlc-common/test/build-snippets.d.ts.map +0 -1
  406. package/dist/src/rlc-common/test/build-snippets.js.map +0 -1
  407. package/dist/src/rlc-common/test/template.d.ts +0 -5
  408. package/dist/src/rlc-common/test/template.d.ts.map +0 -1
  409. package/dist/src/rlc-common/test/template.js +0 -227
  410. package/dist/src/rlc-common/test/template.js.map +0 -1
  411. package/dist/src/transform/transfrom-rlc-options.d.ts.map +0 -1
  412. package/dist/src/transform/transfrom-rlc-options.js.map +0 -1
  413. package/src/rlc-common/index.ts +0 -25
  414. package/src/rlc-common/static/paginate-content.ts +0 -345
  415. package/src/rlc-common/static/polling-content.ts +0 -225
  416. package/src/rlc-common/static/sample-template.ts +0 -56
  417. package/src/rlc-common/static/serialize-helper.ts +0 -34
  418. package/src/rlc-common/test/build-karma-config.ts +0 -12
  419. package/src/rlc-common/test/build-recorded-client.ts +0 -15
  420. package/src/rlc-common/test/build-sample-test.ts +0 -12
  421. package/src/rlc-common/test/template.ts +0 -229
  422. /package/dist/src/{rlc-common/interfaces.js → interfaces.js} +0 -0
  423. /package/dist/src/{rlc-common/metadata → metadata}/build-api-extractor-config.js +0 -0
  424. /package/dist/src/{rlc-common/metadata → metadata}/build-changelog-file.js +0 -0
  425. /package/dist/src/{rlc-common/metadata → metadata}/build-es-lint-config.js +0 -0
  426. /package/dist/src/{rlc-common/metadata → metadata}/build-license-file.d.ts +0 -0
  427. /package/dist/src/{rlc-common/metadata → metadata}/build-license-file.js +0 -0
  428. /package/dist/src/{rlc-common/metadata → metadata}/build-sample-env-file.js +0 -0
  429. /package/dist/src/{rlc-common/metadata → metadata}/build-test-config.js +0 -0
  430. /package/dist/src/{rlc-common/metadata → metadata}/build-ts-config.js +0 -0
  431. /package/dist/src/{rlc-common/metadata → metadata}/build-vitest-config.js +0 -0
  432. /package/dist/src/{rlc-common/metadata → metadata}/build-warp-config.js +0 -0
  433. /package/dist/src/{rlc-common/metadata → metadata}/package-json/azure-package-common.d.ts +0 -0
  434. /package/dist/src/{rlc-common/metadata → metadata}/package-json/azure-package-common.js +0 -0
  435. /package/dist/src/{rlc-common/metadata → metadata}/package-json/build-azure-monorepo-package.d.ts +0 -0
  436. /package/dist/src/{rlc-common/metadata → metadata}/package-json/build-azure-monorepo-package.js +0 -0
  437. /package/dist/src/{rlc-common/metadata → metadata}/package-json/package-common.d.ts +0 -0
  438. /package/dist/src/{rlc-common/metadata → metadata}/package-json/package-common.js +0 -0
  439. /package/dist/src/{rlc-common/metadata → metadata}/utils.js +0 -0
  440. /package/dist/src/{rlc-common/helpers → utils}/api-version-util.d.ts +0 -0
  441. /package/dist/src/{rlc-common/helpers → utils}/api-version-util.js +0 -0
  442. /package/dist/src/{rlc-common/helpers → utils}/imports-util.d.ts +0 -0
  443. /package/dist/src/{rlc-common/helpers → utils}/name-constructors.js +0 -0
  444. /package/dist/src/{rlc-common/helpers → utils}/name-utils.d.ts +0 -0
  445. /package/dist/src/{rlc-common/helpers → utils}/name-utils.js +0 -0
  446. /package/dist/src/{rlc-common/helpers → utils}/operation-helpers.js +0 -0
  447. /package/dist/src/{rlc-common/helpers → utils}/schema-helpers.js +0 -0
  448. /package/dist/src/{rlc-common/helpers → utils}/type-util.d.ts +0 -0
  449. /package/dist/src/{rlc-common/helpers → utils}/type-util.js +0 -0
  450. /package/src/{rlc-common/metadata → metadata}/build-license-file.ts +0 -0
  451. /package/src/{rlc-common/metadata → metadata}/package-json/azure-package-common.ts +0 -0
  452. /package/src/{rlc-common/metadata → metadata}/package-json/build-azure-monorepo-package.ts +0 -0
  453. /package/src/{rlc-common/metadata → metadata}/package-json/package-common.ts +0 -0
  454. /package/src/{rlc-common/helpers → utils}/api-version-util.ts +0 -0
  455. /package/src/{rlc-common/helpers → utils}/name-utils.ts +0 -0
  456. /package/src/{rlc-common/helpers → utils}/type-util.ts +0 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-ts",
3
- "version": "0.56.0-dev.1",
4
- "description": "An experimental TypeSpec emitter for TypeScript",
3
+ "version": "0.56.0-dev.10",
4
+ "description": "A TypeSpec emitter for TypeScript",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
7
7
  "exports": {
@@ -42,9 +42,7 @@
42
42
  "@typespec/xml": "^0.83.0 || >=0.84.0-dev <0.84.0",
43
43
  "@typespec/ts-http-runtime": "0.3.6",
44
44
  "cross-env": "^10.1.0",
45
- "mkdirp": "^3.0.1",
46
- "npm-run-all": "~4.1.5",
47
- "prettier": "^3.8.1",
45
+ "concurrently": "^10.0.0",
48
46
  "vitest": "^4.1.3",
49
47
  "vite": "^8.0.8",
50
48
  "@vitest/coverage-v8": "^4.1.3",
@@ -62,7 +60,6 @@
62
60
  },
63
61
  "dependencies": {
64
62
  "fast-xml-parser": "^5.7.0",
65
- "handlebars": "^4.7.7",
66
63
  "prettier": "^3.8.1",
67
64
  "ts-morph": "^23.0.0",
68
65
  "tslib": "^2.3.1"
@@ -89,28 +86,21 @@
89
86
  "clean": "rimraf ./dist ./typespec-output",
90
87
  "build": "tsc -p .",
91
88
  "test": "npm run test-next && npm run unit-test && npm run integration-test-ci",
92
- "test:azure": "npm run test-next && npm run copy:typespec && npm run integration-test-ci:azure-modular",
93
- "lint": "eslint . --ext .ts --max-warnings=0",
94
- "lint:fix": "eslint . --fix --ext .ts",
89
+ "lint": "oxlint . --deny-warnings",
90
+ "lint:fix": "oxlint . --fix",
95
91
  "check:tree": "node ./test/commands/check-clean-tree.ts",
96
- "test:ts:e2e": "npm run copy:typespec && npm run integration-test-ci:azure-modular",
97
- "integration-test-ci": "npm-run-all copy:typespec integration-test-ci:azure-modular",
98
- "integration-test-ci:sequential": "npm-run-all --serial copy:typespec integration-test-ci:azure-modular",
99
- "integration-test-ci:azure-modular": "npm-run-all --silent -p start-test-server:azure-modular --race generate-and-run:azure-modular",
100
- "start-test-server": "mkdirp -p coverage && npx tsp-spector serve ./node_modules/@typespec/http-specs/specs --coverageFile ./coverage/spector-coverage-typescript.json",
101
- "start-test-server:azure-modular": "mkdirp -p coverage && npx tsp-spector serve ./node_modules/@azure-tools/azure-http-specs/specs ./node_modules/@typespec/http-specs/specs --port 3002 --coverageFile ./coverage/spector-coverage-typescript-modular-azure.json",
92
+ "integration-test-ci": "npm run copy:typespec && npm run spector-test",
93
+ "spector-test": "concurrently --kill-others --success first \"npm:start-test-server\" \"npm:generate-and-run\"",
94
+ "start-test-server": "node ./test/commands/start-test-server.js",
102
95
  "copy:typespec": "node ./test/commands/copy-typespec.ts",
103
- "generate-and-run:azure-modular": "npm run generate-tsp-only:azure-modular:client && npm-run-all -p integration-test:alone:azure-modular generate-tsp-only:azure-modular:declarations && npm run stop-test-server -- -p 3002",
104
- "generate-tsp-only": "npm run generate-tsp-only:azure-modular",
105
- "generate-tsp-only:azure-modular": "node ./test/commands/gen-spector.js",
106
- "generate-tsp-only:azure-modular:client": "node ./test/commands/gen-spector.js --phase=client",
107
- "generate-tsp-only:azure-modular:declarations": "node ./test/commands/gen-spector.js --phase=declarations",
96
+ "generate-and-run": "npm run generate-tsp-only:client && concurrently --kill-others-on-fail \"npm:integration-test:alone\" \"npm:generate-tsp-only:declarations\" && npm run stop-test-server -- -p 3002",
97
+ "generate-tsp-only": "node ./test/commands/gen-spector.js",
98
+ "generate-tsp-only:client": "node ./test/commands/gen-spector.js --phase=client",
99
+ "generate-tsp-only:declarations": "node ./test/commands/gen-spector.js --phase=declarations",
108
100
  "regen-test-baselines": "npm run generate-tsp-only",
109
- "integration-test:alone": "npm run integration-test:alone:azure-modular",
110
- "integration-test:alone:azure-modular": "vitest run --project integration-azure-modular",
101
+ "integration-test:alone": "vitest run --project integration-azure-modular",
111
102
  "stop-test-server": "npx tsp-spector server stop",
112
- "unit-test": "npm run unit-test:modular",
113
- "unit-test:modular": "cross-env NODE_OPTIONS=--max-old-space-size=1024 vitest run --project unit-modular",
103
+ "unit-test": "cross-env NODE_OPTIONS=--max-old-space-size=1024 vitest run --project unit-modular",
114
104
  "gen:scenario-suites": "node ./test/commands/gen-scenario-suites.ts",
115
105
  "regen-docs": "npm run build && tspd doc . --enable-experimental --output-dir ../../website/src/content/docs/docs/emitters/clients/typespec-ts/reference --skip-js"
116
106
  }
@@ -4,7 +4,7 @@ import { Project, SourceFile } from "ts-morph";
4
4
  import { ExternalDependencies } from "./framework/dependency.js";
5
5
  import { Binder } from "./framework/hooks/binder.js";
6
6
  import { SdkTypeContext } from "./framework/hooks/sdk-types.js";
7
- import { RlcMetaTree } from "./meta-tree.js";
7
+ import { ClientTypeMetaTree } from "./meta-tree.js";
8
8
 
9
9
  /**
10
10
  * Contexts Object Guidelines
@@ -20,7 +20,7 @@ import { RlcMetaTree } from "./meta-tree.js";
20
20
  * Remember, adding too many contexts can lead to complex dependencies and harder-to-maintain code. Always evaluate if the context is truly necessary or if there are better alternatives such as localized state management or passing props for simpler scenarios.
21
21
  */
22
22
  type Contexts = {
23
- rlcMetaTree: RlcMetaTree; // Context for RLC types metadata.
23
+ clientTypeMetaTree: ClientTypeMetaTree; // Context for client type metadata.
24
24
  outputProject: Project; // The TS-Morph root project context for code generation.
25
25
  symbolMap: Map<string, SourceFile>; // Mapping of symbols to their corresponding source files.
26
26
  sdkTypes: SdkTypeContext;
@@ -8,12 +8,14 @@ import {
8
8
  InterfaceDeclaration,
9
9
  InterfaceDeclarationStructure,
10
10
  SourceFile,
11
+ StatementStructures,
11
12
  StructureKind,
12
13
  TypeAliasDeclaration,
13
14
  TypeAliasDeclarationStructure,
14
15
  } from "ts-morph";
15
16
  import { useBinder } from "./hooks/binder.js";
16
17
  import { refkey as getRefKey } from "./refkey.js";
18
+ import { enqueueStatement } from "./source-file-batch.js";
17
19
  export type DeclarationStructures =
18
20
  | ClassDeclarationStructure
19
21
  | EnumDeclarationStructure
@@ -80,25 +82,11 @@ export function addDeclaration(
80
82
  // Update the declaration name to be unique
81
83
  const trackedDeclaration = { ...declaration, name: trackedDeclarationName };
82
84
 
83
- switch (trackedDeclaration.kind) {
84
- case StructureKind.Class:
85
- sourceFile.addClass(trackedDeclaration);
86
- break;
87
- case StructureKind.Enum:
88
- sourceFile.addEnum(trackedDeclaration);
89
- break;
90
- case StructureKind.Function:
91
- sourceFile.addFunction(trackedDeclaration);
92
- break;
93
- case StructureKind.Interface:
94
- sourceFile.addInterface(trackedDeclaration);
95
- break;
96
- case StructureKind.TypeAlias:
97
- if (trackedDeclaration.type) {
98
- sourceFile.addTypeAlias(trackedDeclaration);
99
- }
100
- break;
101
- default:
102
- throw new Error(`Unsupported declaration kind ${(trackedDeclaration as any).kind}`);
85
+ // Skip empty type aliases (they have no body to emit). Done before
86
+ // dispatching so behaviour is identical whether batching or not.
87
+ if (trackedDeclaration.kind === StructureKind.TypeAlias && !trackedDeclaration.type) {
88
+ return;
103
89
  }
90
+
91
+ enqueueStatement(sourceFile, trackedDeclaration as StatementStructures);
104
92
  }
@@ -14,8 +14,8 @@ import { reportDiagnostic } from "../../lib.js";
14
14
  import { visitPackageTypes } from "../../modular/emit-models.js";
15
15
  import { getAllAncestors, getAllProperties } from "../../modular/helpers/operation-helpers.js";
16
16
  import { normalizeModelPropertyName } from "../../modular/type-expressions/get-type-expression.js";
17
- import { NameType, normalizeName } from "../../rlc-common/index.js";
18
17
  import { SdkContext } from "../../utils/interfaces.js";
18
+ import { NameType, normalizeName } from "../../utils/name-utils.js";
19
19
 
20
20
  export const emitQueue: Set<SdkType> = new Set<SdkType>();
21
21
  export const flattenPropertyModelMap: Map<SdkModelPropertyType, SdkModelType> = new Map<
@@ -0,0 +1,140 @@
1
+ import {
2
+ ExportDeclarationStructure,
3
+ SourceFile,
4
+ StatementStructures,
5
+ StructureKind,
6
+ } from "ts-morph";
7
+
8
+ /**
9
+ * Generic per-source-file batch for ts-morph `add*` mutations.
10
+ *
11
+ * Each individual `sourceFile.addInterface/addFunction/addExportDeclaration/...`
12
+ * call re-parses the entire source file in ts-morph. Calling them in a loop
13
+ * therefore grows as O(N × file_size). This module collects structures while
14
+ * a batch is open and, on flush, issues a single `addStatements` call per file,
15
+ * collapsing N re-parses into 1.
16
+ *
17
+ * The batch is reference-counted so nested begin/flush pairs compose safely.
18
+ * Statements flush in insertion order and produce byte-identical output.
19
+ */
20
+
21
+ let batchDepth = 0;
22
+ const pendingByFile = new Map<SourceFile, StatementStructures[]>();
23
+
24
+ /**
25
+ * Opens a batching scope. Subsequent `enqueueStatement` calls queue rather
26
+ * than mutate the AST until the matching `flushSourceFileBatch` is called.
27
+ */
28
+ export function beginSourceFileBatch(): void {
29
+ batchDepth++;
30
+ }
31
+
32
+ /**
33
+ * Closes the most recent batching scope. When the outermost scope closes,
34
+ * all pending structures are written to their source files in bulk.
35
+ */
36
+ export function flushSourceFileBatch(): void {
37
+ if (batchDepth === 0) {
38
+ return;
39
+ }
40
+ batchDepth--;
41
+ if (batchDepth > 0) {
42
+ return;
43
+ }
44
+ try {
45
+ for (const [sourceFile, statements] of pendingByFile) {
46
+ if (statements.length === 0) {
47
+ continue;
48
+ }
49
+ sourceFile.addStatements(statements);
50
+ }
51
+ } finally {
52
+ pendingByFile.clear();
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Queues a statement structure for bulk-add on flush, or writes it
58
+ * immediately when no batch is open.
59
+ * @param sourceFile - Target source file.
60
+ * @param structure - The statement structure to add.
61
+ */
62
+ export function enqueueStatement(sourceFile: SourceFile, structure: StatementStructures): void {
63
+ if (batchDepth > 0) {
64
+ let pending = pendingByFile.get(sourceFile);
65
+ if (!pending) {
66
+ pending = [];
67
+ pendingByFile.set(sourceFile, pending);
68
+ }
69
+ pending.push(structure);
70
+ return;
71
+ }
72
+ sourceFile.addStatements([structure]);
73
+ }
74
+
75
+ /**
76
+ * Returns the set of names exported from `sourceFile` considering both the
77
+ * declarations already present in its AST and any export declarations queued
78
+ * by the current batch. Use this in place of reading `getExportDeclarations`
79
+ * directly when callers dedup against existing exports inside a batch.
80
+ * @param sourceFile - The file to inspect.
81
+ */
82
+ export function getEffectiveExportedNames(sourceFile: SourceFile): Set<string> {
83
+ const names = new Set<string>();
84
+ for (const decl of sourceFile.getExportDeclarations()) {
85
+ for (const named of decl.getNamedExports()) {
86
+ names.add(named.getAliasNode()?.getText() ?? named.getName());
87
+ }
88
+ }
89
+ const pending = pendingByFile.get(sourceFile);
90
+ if (pending) {
91
+ for (const structure of pending) {
92
+ if (structure.kind !== StructureKind.ExportDeclaration) {
93
+ continue;
94
+ }
95
+ collectNamedExportNames(structure.namedExports, names);
96
+ }
97
+ }
98
+ return names;
99
+ }
100
+
101
+ /**
102
+ * Returns the set of named exports queued in the current batch for
103
+ * `sourceFile`. Use this to union with any AST-based view of exports
104
+ * (e.g. `getExportedDeclarations`) when deduplicating against still-pending
105
+ * writes inside a batch.
106
+ * @param sourceFile - The file to inspect.
107
+ */
108
+ export function getQueuedExportNames(sourceFile: SourceFile): Set<string> {
109
+ const names = new Set<string>();
110
+ const pending = pendingByFile.get(sourceFile);
111
+ if (!pending) {
112
+ return names;
113
+ }
114
+ for (const structure of pending) {
115
+ if (structure.kind !== StructureKind.ExportDeclaration) {
116
+ continue;
117
+ }
118
+ collectNamedExportNames(structure.namedExports, names);
119
+ }
120
+ return names;
121
+ }
122
+
123
+ function collectNamedExportNames(
124
+ named: ExportDeclarationStructure["namedExports"],
125
+ into: Set<string>,
126
+ ): void {
127
+ if (!named || typeof named === "function") {
128
+ // WriterFunction form is opaque to us; callers can't dedup by name.
129
+ return;
130
+ }
131
+ for (const item of named) {
132
+ if (typeof item === "string") {
133
+ into.add(item);
134
+ } else if (typeof item === "function") {
135
+ continue;
136
+ } else if (item) {
137
+ into.add(item.alias ?? item.name);
138
+ }
139
+ }
140
+ }
package/src/index.ts CHANGED
@@ -31,37 +31,6 @@ import {
31
31
  UrlTemplateHelpers,
32
32
  XmlHelpers,
33
33
  } from "./modular/static-helpers-metadata.js";
34
- import {
35
- RLCModel,
36
- RLCOptions,
37
- buildApiExtractorConfig,
38
- buildChangelogFile,
39
- buildEsLintConfig,
40
- buildLicenseFile,
41
- buildPackageFile,
42
- buildReadmeFile,
43
- buildRecordedClientFile,
44
- buildSampleEnvFile,
45
- buildSampleTest,
46
- buildSnippets,
47
- buildTestBrowserTsConfig,
48
- buildTestNodeTsConfig,
49
- buildTsConfig,
50
- buildTsLintConfig,
51
- buildTsSampleConfig,
52
- buildTsSnippetsConfig,
53
- buildTsSrcBrowserConfig,
54
- buildTsSrcCjsConfig,
55
- buildTsSrcEsmConfig,
56
- buildTsSrcReactNativeConfig,
57
- buildVitestConfig,
58
- buildWarpConfig,
59
- getClientName,
60
- hasClientNameChanged,
61
- hasUnexpectedHelper,
62
- updatePackageFile,
63
- updateReadmeFile,
64
- } from "./rlc-common/index.js";
65
34
  import { emitContentByBuilder } from "./utils/emit-util.js";
66
35
  import { clearDirectory, emptyDir, pathExists } from "./utils/file-system-utils.js";
67
36
  import { GenerationDirDetail, SdkContext } from "./utils/interfaces.js";
@@ -76,7 +45,35 @@ import { Project } from "ts-morph";
76
45
  import { provideBinder } from "./framework/hooks/binder.js";
77
46
  import { provideSdkTypes } from "./framework/hooks/sdk-types.js";
78
47
  import { loadStaticHelpers } from "./framework/load-static-helpers.js";
48
+ import { ClientModel, ClientOptions } from "./interfaces.js";
79
49
  import { EmitterOptions } from "./lib.js";
50
+ import { buildApiExtractorConfig } from "./metadata/build-api-extractor-config.js";
51
+ import { buildChangelogFile } from "./metadata/build-changelog-file.js";
52
+ import { buildEsLintConfig } from "./metadata/build-es-lint-config.js";
53
+ import { buildLicenseFile } from "./metadata/build-license-file.js";
54
+ import { buildPackageFile, updatePackageFile } from "./metadata/build-package-file.js";
55
+ import {
56
+ buildReadmeFile,
57
+ hasClientNameChanged,
58
+ updateReadmeFile,
59
+ } from "./metadata/build-readme-file.js";
60
+ import { buildSampleEnvFile } from "./metadata/build-sample-env-file.js";
61
+ import { buildTestBrowserTsConfig, buildTestNodeTsConfig } from "./metadata/build-test-config.js";
62
+ import {
63
+ buildTsConfig,
64
+ buildTsLintConfig,
65
+ buildTsSampleConfig,
66
+ buildTsSnippetsConfig,
67
+ buildTsSrcBrowserConfig,
68
+ buildTsSrcCjsConfig,
69
+ buildTsSrcEsmConfig,
70
+ buildTsSrcReactNativeConfig,
71
+ } from "./metadata/build-ts-config.js";
72
+ import { buildVitestConfig } from "./metadata/build-vitest-config.js";
73
+ import { buildWarpConfig } from "./metadata/build-warp-config.js";
74
+ import { buildRecordedClientFile } from "./metadata/test/build-recorded-client.js";
75
+ import { buildSampleTest } from "./metadata/test/build-sample-test.js";
76
+ import { buildSnippets } from "./metadata/test/build-snippets.js";
80
77
  import { buildClassicalClient } from "./modular/build-classical-client.js";
81
78
  import { buildClassicOperationFiles } from "./modular/build-classical-operation-groups.js";
82
79
  import { buildClientContext, getClientContextPath } from "./modular/build-client-context.js";
@@ -93,13 +90,9 @@ import { emitTests } from "./modular/emit-tests.js";
93
90
  import { getClassicalClientName } from "./modular/helpers/naming-helpers.js";
94
91
  import { ModularEmitterOptions } from "./modular/interfaces.js";
95
92
  import { packageUsesXmlSerialization } from "./modular/serialization/build-xml-serializer-function.js";
96
- import { transformRLCModel } from "./transform/transform.js";
97
- import { transformRLCOptions } from "./transform/transfrom-rlc-options.js";
98
- import {
99
- getClientHierarchyMap,
100
- getModularClientOptions,
101
- getRLCClients,
102
- } from "./utils/client-utils.js";
93
+ import { transformClientOptions } from "./transform/transform-client-options.js";
94
+ import { transformClientModel } from "./transform/transform.js";
95
+ import { getClientHierarchyMap, getClientModuleInfo, getClients } from "./utils/client-utils.js";
103
96
  import { generateCrossLanguageDefinitionFile } from "./utils/cross-language-def.js";
104
97
 
105
98
  export * from "./lib.js";
@@ -128,11 +121,9 @@ export async function $onEmit(context: EmitContext) {
128
121
 
129
122
  // Enrich the dpg context with path detail and common options
130
123
  await enrichDpgContext();
131
- const rlcOptions = dpgContext.rlcOptions ?? {};
124
+ const resolvedEmitterOptions = dpgContext.emitterOptions ?? {};
132
125
 
133
- const needUnexpectedHelper: Map<string, boolean> = new Map<string, boolean>();
134
- const serviceNameToRlcModelsMap: Map<string, RLCModel> = new Map<string, RLCModel>();
135
- provideContext("rlcMetaTree", new Map());
126
+ provideContext("clientTypeMetaTree", new Map());
136
127
  provideContext("symbolMap", new Map());
137
128
  provideContext("outputProject", outputProject);
138
129
  provideContext("emitContext", {
@@ -151,13 +142,13 @@ export async function $onEmit(context: EmitContext) {
151
142
  ...PlatformTypeHelpers,
152
143
  ...CloudSettingHelpers,
153
144
  ...XmlHelpers,
154
- ...(rlcOptions.generateTest ? CreateRecorderHelpers : {}),
155
- ...(rlcOptions.enableStorageCompat ? StorageCompatHelpers : {}),
145
+ ...(resolvedEmitterOptions.generateTest ? CreateRecorderHelpers : {}),
146
+ ...(resolvedEmitterOptions.enableStorageCompat ? StorageCompatHelpers : {}),
156
147
  },
157
148
  {
158
- sourcesDir: dpgContext.generationPathDetail?.modularSourcesDir,
149
+ sourcesDir: dpgContext.generationPathDetail?.sourcesDir,
159
150
  rootDir: dpgContext.generationPathDetail?.rootDir,
160
- options: rlcOptions,
151
+ options: resolvedEmitterOptions,
161
152
  program,
162
153
  host,
163
154
  packageRoot: emitterPackageRoot,
@@ -178,20 +169,16 @@ export async function $onEmit(context: EmitContext) {
178
169
  });
179
170
  provideSdkTypes(dpgContext);
180
171
 
181
- const rlcCodeModels: RLCModel[] = [];
182
172
  let modularEmitterOptions: ModularEmitterOptions;
183
173
  // 1. Clear sources folder
184
174
  await clearSrcFolder();
185
- // 2. Generate RLC code model
186
- // TODO: skip this step in modular once modular generator is sufficiently decoupled
187
- await buildRLCCodeModels();
188
- // 3. Clear samples-dev folder if generateSample is true
175
+ // 2. Clear samples-dev folder if generateSample is true
189
176
  await clearSamplesDevFolder();
190
177
 
191
- // 4. Generate sources
192
- await generateModularSources();
178
+ // 3. Generate sources
179
+ await generateSources();
193
180
 
194
- // 5. Generate metadata and test files
181
+ // 4. Generate metadata and test files
195
182
  function getTypespecTsVersion(context: EmitContext): string | undefined {
196
183
  const emitterMetadata = context.program.emitters.find(
197
184
  (emitter) => emitter.metadata.name === "@azure-tools/typespec-ts",
@@ -205,7 +192,7 @@ export async function $onEmit(context: EmitContext) {
205
192
  const generationPathDetail: GenerationDirDetail = await calculateGenerationDir();
206
193
  dpgContext.generationPathDetail = generationPathDetail;
207
194
  dpgContext.allServiceNamespaces = listAllServiceNamespaces(dpgContext);
208
- const options: RLCOptions = transformRLCOptions(emitterOptions, dpgContext);
195
+ const options: ClientOptions = transformClientOptions(emitterOptions, dpgContext);
209
196
  emitterOptions["generate-sample"] = options.generateSample;
210
197
  // clear output folder if needed
211
198
  if (options.clearOutputFolder) {
@@ -219,7 +206,7 @@ export async function $onEmit(context: EmitContext) {
219
206
  options.generateTest =
220
207
  options.generateTest === true ||
221
208
  (options.generateTest === undefined && (!hasTestFolder || options.azureArm));
222
- dpgContext.rlcOptions = options;
209
+ dpgContext.emitterOptions = options;
223
210
  }
224
211
 
225
212
  async function calculateGenerationDir(): Promise<GenerationDirDetail> {
@@ -236,18 +223,12 @@ export async function $onEmit(context: EmitContext) {
236
223
  return {
237
224
  rootDir: projectRoot,
238
225
  metadataDir: projectRoot,
239
- rlcSourcesDir: sourcesRoot,
240
- modularSourcesDir: sourcesRoot,
226
+ sourcesDir: sourcesRoot,
241
227
  };
242
228
  }
243
229
 
244
230
  async function clearSrcFolder() {
245
- await emptyDir(
246
- host,
247
- dpgContext.generationPathDetail?.modularSourcesDir ??
248
- dpgContext.generationPathDetail?.rlcSourcesDir ??
249
- "",
250
- );
231
+ await emptyDir(host, dpgContext.generationPathDetail?.sourcesDir ?? "");
251
232
  }
252
233
 
253
234
  async function clearSamplesDevFolder() {
@@ -262,32 +243,30 @@ export async function $onEmit(context: EmitContext) {
262
243
  }
263
244
  }
264
245
 
265
- async function buildRLCCodeModels() {
266
- const clients = getRLCClients(dpgContext);
246
+ async function buildClientCodeModels(): Promise<ClientModel[]> {
247
+ const models: ClientModel[] = [];
248
+ const clients = getClients(dpgContext);
267
249
  for (const client of clients) {
268
- const rlcModels = await transformRLCModel(client, dpgContext);
269
- rlcCodeModels.push(rlcModels);
270
- const serviceName = client.services[0]?.name ?? "Unknown";
271
- serviceNameToRlcModelsMap.set(serviceName, rlcModels);
272
- needUnexpectedHelper.set(getClientName(rlcModels), hasUnexpectedHelper(rlcModels));
250
+ models.push(await transformClientModel(client, dpgContext));
273
251
  }
252
+ return models;
274
253
  }
275
254
 
276
- async function generateModularSources() {
277
- const modularSourcesRoot = dpgContext.generationPathDetail?.modularSourcesDir ?? "src";
255
+ async function generateSources() {
256
+ const sourcesRoot = dpgContext.generationPathDetail?.sourcesDir ?? "src";
278
257
  const project = useContext("outputProject");
279
- modularEmitterOptions = transformModularEmitterOptions(dpgContext, modularSourcesRoot, {
258
+ modularEmitterOptions = transformModularEmitterOptions(dpgContext, sourcesRoot, {
280
259
  casing: "camel",
281
260
  });
282
261
 
283
- emitLoggerFile(modularEmitterOptions, modularSourcesRoot);
262
+ emitLoggerFile(modularEmitterOptions, sourcesRoot);
284
263
 
285
- const rootIndexFile = project.createSourceFile(`${modularSourcesRoot}/index.ts`, "", {
264
+ const rootIndexFile = project.createSourceFile(`${sourcesRoot}/index.ts`, "", {
286
265
  overwrite: true,
287
266
  });
288
267
 
289
- emitTypes(dpgContext, { sourceRoot: modularSourcesRoot });
290
- emitNonModelResponseTypes(dpgContext, { sourceRoot: modularSourcesRoot });
268
+ emitTypes(dpgContext, { sourceRoot: sourcesRoot });
269
+ emitNonModelResponseTypes(dpgContext, { sourceRoot: sourcesRoot });
291
270
  buildSubpathIndexFile(modularEmitterOptions, "models", undefined, {
292
271
  recursive: true,
293
272
  });
@@ -302,7 +281,7 @@ export async function $onEmit(context: EmitContext) {
302
281
  buildOperationFiles(dpgContext, subClient, modularEmitterOptions);
303
282
  buildClientContext(dpgContext, subClient, modularEmitterOptions);
304
283
  buildRestorePoller(dpgContext, subClient, modularEmitterOptions);
305
- if (dpgContext.rlcOptions?.hierarchyClient) {
284
+ if (dpgContext.emitterOptions?.hierarchyClient) {
306
285
  buildSubpathIndexFile(modularEmitterOptions, "api", subClient, {
307
286
  exportIndex: false,
308
287
  recursive: true,
@@ -320,24 +299,24 @@ export async function $onEmit(context: EmitContext) {
320
299
  exportIndex: true,
321
300
  interfaceOnly: true,
322
301
  });
323
- const { subfolder } = getModularClientOptions(subClient);
302
+ const { subfolder } = getClientModuleInfo(subClient);
324
303
  // Generate index file for clients with subfolders (multi-client scenarios and nested clients)
325
304
  if (subfolder) {
326
305
  buildSubClientIndexFile(dpgContext, subClient, modularEmitterOptions);
327
306
  }
328
307
  buildRootIndex(dpgContext, modularEmitterOptions, rootIndexFile, subClient);
329
308
  }
330
- // Enable modular sample generation when explicitly set to true or MPG
309
+ // Sample generation is enabled only when the modular generator actually emits
310
+ // samples. Reset the baseline here, then re-enable it below if any are emitted.
311
+ dpgContext.emitterOptions!.generateSample = false;
331
312
  if (emitterOptions["generate-sample"] === true) {
332
313
  const samples = emitSamples(dpgContext);
333
- // Refine the rlc sample generation logic
334
- // TODO: remember to remove this out when RLC is splitted from Modular
335
314
  if (samples.length > 0) {
336
- dpgContext.rlcOptions!.generateSample = true;
315
+ dpgContext.emitterOptions!.generateSample = true;
337
316
  }
338
317
  }
339
318
 
340
- binder.resolveAllReferences(modularSourcesRoot, dpgContext.generationPathDetail?.rootDir);
319
+ binder.resolveAllReferences(sourcesRoot, dpgContext.generationPathDetail?.rootDir);
341
320
  if (program.compilerOptions.noEmit || program.hasError()) {
342
321
  return;
343
322
  }
@@ -382,17 +361,18 @@ export async function $onEmit(context: EmitContext) {
382
361
 
383
362
  async function generateMetadataAndTest(context: SdkContext) {
384
363
  const project = useContext("outputProject");
385
- if (rlcCodeModels.length === 0 || !rlcCodeModels[0]) {
364
+ const clientCodeModels = await buildClientCodeModels();
365
+ if (clientCodeModels.length === 0 || !clientCodeModels[0]) {
386
366
  return;
387
367
  }
388
- const rlcClient: RLCModel = rlcCodeModels[0];
389
- const option = dpgContext.rlcOptions!;
368
+ const clientModel: ClientModel = clientCodeModels[0];
369
+ const option = dpgContext.emitterOptions!;
390
370
  // When generateMetadata is explicitly false and the sources are generated
391
371
  // into a path ending with "generated" (e.g. src/generated), this package
392
372
  // has a manual convenience layer. Skip all metadata/test file generation
393
373
  // to avoid unexpected modifications to files like package.json, README.md,
394
374
  // warp.config.yml, and snippets.spec.ts. metadata.json is still updated.
395
- const sourcesDir = dpgContext.generationPathDetail?.modularSourcesDir ?? "";
375
+ const sourcesDir = dpgContext.generationPathDetail?.sourcesDir ?? "";
396
376
  const hasManualConvenienceLayer = getBaseFileName(sourcesDir) === "generated";
397
377
  // Generate metadata
398
378
  const existingPackageFilePath = joinPaths(
@@ -426,7 +406,7 @@ export async function $onEmit(context: EmitContext) {
426
406
 
427
407
  //TODO Need consider multi-client cases
428
408
  for (const subClient of dpgContext.sdkPackage.clients) {
429
- rlcClient.libraryName = subClient.name;
409
+ clientModel.libraryName = subClient.name;
430
410
  }
431
411
 
432
412
  if (shouldGenerateMetadata) {
@@ -496,7 +476,7 @@ export async function $onEmit(context: EmitContext) {
496
476
  await emitContentByBuilder(
497
477
  program,
498
478
  commonBuilders,
499
- rlcClient,
479
+ clientModel,
500
480
  dpgContext.generationPathDetail?.metadataDir,
501
481
  );
502
482
 
@@ -525,8 +505,8 @@ export async function $onEmit(context: EmitContext) {
525
505
  }),
526
506
  };
527
507
 
528
- // Always update package.json (adds #platform/* imports) and, for modular
529
- // packages, exports, clientContextPaths and LRO deps.
508
+ // Always update package.json (adds #platform/* imports) along with
509
+ // exports, clientContextPaths and LRO deps.
530
510
  {
531
511
  // Read package.json content via host and pass parsed object
532
512
  const pkgSourceFile = await host.readFile(existingPackageFilePath);
@@ -536,30 +516,30 @@ export async function $onEmit(context: EmitContext) {
536
516
  } catch {
537
517
  packageInfo = {};
538
518
  }
539
- updateBuilders.push((model: RLCModel) =>
519
+ updateBuilders.push((model: ClientModel) =>
540
520
  updatePackageFile(model, packageInfo, modularPackageInfo),
541
521
  );
542
522
  }
543
523
 
544
524
  // Update warp.config.yml for Azure monorepo packages
545
- updateBuilders.push((model: RLCModel) => buildWarpConfig(model, modularPackageInfo));
525
+ updateBuilders.push((model: ClientModel) => buildWarpConfig(model, modularPackageInfo));
546
526
 
547
527
  // If the client name changed, regenerate the README and snippets completely;
548
528
  // otherwise update only the API reference link in-place.
549
529
  if (hasReadmeFile) {
550
530
  const readmeSourceFile = await host.readFile(existingReadmeFilePath);
551
531
  const existingReadmeContent = readmeSourceFile.text;
552
- const clientNameChanged = hasClientNameChanged(rlcClient, existingReadmeContent);
532
+ const clientNameChanged = hasClientNameChanged(clientModel, existingReadmeContent);
553
533
  updateBuilders.push(
554
534
  clientNameChanged
555
535
  ? buildReadmeFile
556
- : (model: RLCModel) => updateReadmeFile(model, existingReadmeContent),
536
+ : (model: ClientModel) => updateReadmeFile(model, existingReadmeContent),
557
537
  );
558
538
 
559
539
  // Regenerate snippets.spec.ts only when the client name changed
560
540
  if (clientNameChanged) {
561
541
  for (const subClient of dpgContext.sdkPackage.clients) {
562
- updateBuilders.push((model: RLCModel) =>
542
+ updateBuilders.push((model: ClientModel) =>
563
543
  buildSnippets(model, getClassicalClientName(subClient)),
564
544
  );
565
545
  }
@@ -570,14 +550,14 @@ export async function $onEmit(context: EmitContext) {
570
550
  await emitContentByBuilder(
571
551
  program,
572
552
  updateBuilders,
573
- rlcClient,
553
+ clientModel,
574
554
  dpgContext.generationPathDetail?.metadataDir,
575
555
  );
576
556
  }
577
557
  await emitContentByBuilder(
578
558
  program,
579
559
  buildMetadataJson,
580
- rlcClient,
560
+ clientModel,
581
561
  dpgContext.generationPathDetail?.metadataDir,
582
562
  );
583
563
 
@@ -586,7 +566,7 @@ export async function $onEmit(context: EmitContext) {
586
566
  await emitContentByBuilder(
587
567
  program,
588
568
  [buildRecordedClientFile, buildSampleTest],
589
- rlcClient,
569
+ clientModel,
590
570
  dpgContext.generationPathDetail?.metadataDir,
591
571
  );
592
572
  }