@azure-tools/typespec-ts 0.54.0 → 0.54.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (522) hide show
  1. package/CHANGELOG.md +25 -10
  2. package/README.md +0 -4
  3. package/dist/src/contextManager.d.ts +5 -5
  4. package/dist/src/contextManager.d.ts.map +1 -1
  5. package/dist/src/contextManager.js +3 -3
  6. package/dist/src/contextManager.js.map +1 -1
  7. package/dist/src/framework/declaration.d.ts +1 -1
  8. package/dist/src/framework/declaration.d.ts.map +1 -1
  9. package/dist/src/framework/declaration.js +2 -4
  10. package/dist/src/framework/declaration.js.map +1 -1
  11. package/dist/src/framework/dependency.d.ts.map +1 -1
  12. package/dist/src/framework/hooks/binder.d.ts +1 -1
  13. package/dist/src/framework/hooks/binder.d.ts.map +1 -1
  14. package/dist/src/framework/hooks/binder.js +31 -40
  15. package/dist/src/framework/hooks/binder.js.map +1 -1
  16. package/dist/src/framework/hooks/sdkTypes.d.ts +1 -1
  17. package/dist/src/framework/hooks/sdkTypes.d.ts.map +1 -1
  18. package/dist/src/framework/hooks/sdkTypes.js +8 -12
  19. package/dist/src/framework/hooks/sdkTypes.js.map +1 -1
  20. package/dist/src/framework/hooks/useDependencies.d.ts.map +1 -1
  21. package/dist/src/framework/hooks/useDependencies.js +1 -1
  22. package/dist/src/framework/hooks/useDependencies.js.map +1 -1
  23. package/dist/src/framework/load-static-helpers.d.ts +1 -1
  24. package/dist/src/framework/load-static-helpers.d.ts.map +1 -1
  25. package/dist/src/framework/load-static-helpers.js +17 -31
  26. package/dist/src/framework/load-static-helpers.js.map +1 -1
  27. package/dist/src/framework/reference.d.ts.map +1 -1
  28. package/dist/src/framework/reference.js +2 -2
  29. package/dist/src/framework/reference.js.map +1 -1
  30. package/dist/src/framework/sample.js +8 -8
  31. package/dist/src/framework/sample.js.map +1 -1
  32. package/dist/src/index.d.ts +1 -1
  33. package/dist/src/index.d.ts.map +1 -1
  34. package/dist/src/index.js +103 -92
  35. package/dist/src/index.js.map +1 -1
  36. package/dist/src/lib.d.ts +1 -1
  37. package/dist/src/lib.d.ts.map +1 -1
  38. package/dist/src/lib.js +140 -140
  39. package/dist/src/lib.js.map +1 -1
  40. package/dist/src/metaTree.d.ts +1 -1
  41. package/dist/src/metaTree.d.ts.map +1 -1
  42. package/dist/src/modular/buildClassicalClient.d.ts +1 -1
  43. package/dist/src/modular/buildClassicalClient.d.ts.map +1 -1
  44. package/dist/src/modular/buildClassicalClient.js +60 -74
  45. package/dist/src/modular/buildClassicalClient.js.map +1 -1
  46. package/dist/src/modular/buildClassicalOperationGroups.d.ts +2 -2
  47. package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +1 -1
  48. package/dist/src/modular/buildClassicalOperationGroups.js +8 -10
  49. package/dist/src/modular/buildClassicalOperationGroups.js.map +1 -1
  50. package/dist/src/modular/buildClientContext.d.ts +2 -2
  51. package/dist/src/modular/buildClientContext.d.ts.map +1 -1
  52. package/dist/src/modular/buildClientContext.js +31 -38
  53. package/dist/src/modular/buildClientContext.js.map +1 -1
  54. package/dist/src/modular/buildModularOptions.d.ts +1 -1
  55. package/dist/src/modular/buildModularOptions.d.ts.map +1 -1
  56. package/dist/src/modular/buildModularOptions.js +5 -6
  57. package/dist/src/modular/buildModularOptions.js.map +1 -1
  58. package/dist/src/modular/buildOperations.d.ts +3 -3
  59. package/dist/src/modular/buildOperations.d.ts.map +1 -1
  60. package/dist/src/modular/buildOperations.js +23 -25
  61. package/dist/src/modular/buildOperations.js.map +1 -1
  62. package/dist/src/modular/buildProjectFiles.d.ts +1 -1
  63. package/dist/src/modular/buildProjectFiles.d.ts.map +1 -1
  64. package/dist/src/modular/buildProjectFiles.js +8 -11
  65. package/dist/src/modular/buildProjectFiles.js.map +1 -1
  66. package/dist/src/modular/buildRestorePoller.d.ts +1 -1
  67. package/dist/src/modular/buildRestorePoller.d.ts.map +1 -1
  68. package/dist/src/modular/buildRestorePoller.js +12 -13
  69. package/dist/src/modular/buildRestorePoller.js.map +1 -1
  70. package/dist/src/modular/buildRootIndex.d.ts +2 -2
  71. package/dist/src/modular/buildRootIndex.d.ts.map +1 -1
  72. package/dist/src/modular/buildRootIndex.js +36 -50
  73. package/dist/src/modular/buildRootIndex.js.map +1 -1
  74. package/dist/src/modular/buildSubpathIndex.d.ts.map +1 -1
  75. package/dist/src/modular/buildSubpathIndex.js +9 -18
  76. package/dist/src/modular/buildSubpathIndex.js.map +1 -1
  77. package/dist/src/modular/emitLoggerFile.d.ts.map +1 -1
  78. package/dist/src/modular/emitLoggerFile.js +4 -4
  79. package/dist/src/modular/emitLoggerFile.js.map +1 -1
  80. package/dist/src/modular/emitModels.d.ts +1 -1
  81. package/dist/src/modular/emitModels.d.ts.map +1 -1
  82. package/dist/src/modular/emitModels.js +81 -113
  83. package/dist/src/modular/emitModels.js.map +1 -1
  84. package/dist/src/modular/emitModelsOptions.d.ts +1 -1
  85. package/dist/src/modular/emitModelsOptions.d.ts.map +1 -1
  86. package/dist/src/modular/emitModelsOptions.js +7 -8
  87. package/dist/src/modular/emitModelsOptions.js.map +1 -1
  88. package/dist/src/modular/emitSamples.d.ts.map +1 -1
  89. package/dist/src/modular/emitSamples.js +69 -77
  90. package/dist/src/modular/emitSamples.js.map +1 -1
  91. package/dist/src/modular/emitTests.d.ts.map +1 -1
  92. package/dist/src/modular/emitTests.js +13 -18
  93. package/dist/src/modular/emitTests.js.map +1 -1
  94. package/dist/src/modular/external-dependencies.js +54 -54
  95. package/dist/src/modular/helpers/classicalOperationHelpers.d.ts +1 -1
  96. package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +1 -1
  97. package/dist/src/modular/helpers/classicalOperationHelpers.js +59 -68
  98. package/dist/src/modular/helpers/classicalOperationHelpers.js.map +1 -1
  99. package/dist/src/modular/helpers/clientHelpers.d.ts +2 -2
  100. package/dist/src/modular/helpers/clientHelpers.d.ts.map +1 -1
  101. package/dist/src/modular/helpers/clientHelpers.js +31 -54
  102. package/dist/src/modular/helpers/clientHelpers.js.map +1 -1
  103. package/dist/src/modular/helpers/clientOptionHelpers.d.ts.map +1 -1
  104. package/dist/src/modular/helpers/clientOptionHelpers.js +1 -1
  105. package/dist/src/modular/helpers/clientOptionHelpers.js.map +1 -1
  106. package/dist/src/modular/helpers/exampleValueHelpers.d.ts +2 -2
  107. package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +1 -1
  108. package/dist/src/modular/helpers/exampleValueHelpers.js +72 -84
  109. package/dist/src/modular/helpers/exampleValueHelpers.js.map +1 -1
  110. package/dist/src/modular/helpers/namingHelpers.d.ts +1 -1
  111. package/dist/src/modular/helpers/namingHelpers.d.ts.map +1 -1
  112. package/dist/src/modular/helpers/namingHelpers.js +7 -10
  113. package/dist/src/modular/helpers/namingHelpers.js.map +1 -1
  114. package/dist/src/modular/helpers/operationHelpers.d.ts +2 -2
  115. package/dist/src/modular/helpers/operationHelpers.d.ts.map +1 -1
  116. package/dist/src/modular/helpers/operationHelpers.js +204 -288
  117. package/dist/src/modular/helpers/operationHelpers.js.map +1 -1
  118. package/dist/src/modular/helpers/typeHelpers.d.ts +1 -1
  119. package/dist/src/modular/helpers/typeHelpers.d.ts.map +1 -1
  120. package/dist/src/modular/helpers/typeHelpers.js +4 -6
  121. package/dist/src/modular/helpers/typeHelpers.js.map +1 -1
  122. package/dist/src/modular/serialization/buildDeserializerFunction.d.ts +1 -1
  123. package/dist/src/modular/serialization/buildDeserializerFunction.d.ts.map +1 -1
  124. package/dist/src/modular/serialization/buildDeserializerFunction.js +58 -67
  125. package/dist/src/modular/serialization/buildDeserializerFunction.js.map +1 -1
  126. package/dist/src/modular/serialization/buildSerializerFunction.d.ts +1 -1
  127. package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +1 -1
  128. package/dist/src/modular/serialization/buildSerializerFunction.js +65 -75
  129. package/dist/src/modular/serialization/buildSerializerFunction.js.map +1 -1
  130. package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts +1 -1
  131. package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts.map +1 -1
  132. package/dist/src/modular/serialization/buildXmlSerializerFunction.js +73 -90
  133. package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +1 -1
  134. package/dist/src/modular/serialization/serializeUtils.d.ts.map +1 -1
  135. package/dist/src/modular/serialization/serializeUtils.js +25 -33
  136. package/dist/src/modular/serialization/serializeUtils.js.map +1 -1
  137. package/dist/src/modular/static-helpers-metadata.js +60 -60
  138. package/dist/src/modular/type-expressions/get-credential-expression.js +1 -1
  139. package/dist/src/modular/type-expressions/get-credential-expression.js.map +1 -1
  140. package/dist/src/modular/type-expressions/get-enum-expression.d.ts +1 -1
  141. package/dist/src/modular/type-expressions/get-enum-expression.d.ts.map +1 -1
  142. package/dist/src/modular/type-expressions/get-enum-expression.js +1 -2
  143. package/dist/src/modular/type-expressions/get-enum-expression.js.map +1 -1
  144. package/dist/src/modular/type-expressions/get-model-expression.d.ts.map +1 -1
  145. package/dist/src/modular/type-expressions/get-model-expression.js +10 -13
  146. package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
  147. package/dist/src/modular/type-expressions/get-nullable-expression.d.ts +1 -1
  148. package/dist/src/modular/type-expressions/get-nullable-expression.d.ts.map +1 -1
  149. package/dist/src/modular/type-expressions/get-nullable-expression.js +2 -3
  150. package/dist/src/modular/type-expressions/get-nullable-expression.js.map +1 -1
  151. package/dist/src/modular/type-expressions/get-type-expression.d.ts.map +1 -1
  152. package/dist/src/modular/type-expressions/get-type-expression.js +5 -11
  153. package/dist/src/modular/type-expressions/get-type-expression.js.map +1 -1
  154. package/dist/src/modular/type-expressions/get-union-expression.d.ts +1 -1
  155. package/dist/src/modular/type-expressions/get-union-expression.d.ts.map +1 -1
  156. package/dist/src/modular/type-expressions/get-union-expression.js.map +1 -1
  157. package/dist/src/rlc-common/buildClient.d.ts +1 -1
  158. package/dist/src/rlc-common/buildClient.d.ts.map +1 -1
  159. package/dist/src/rlc-common/buildClient.js +67 -89
  160. package/dist/src/rlc-common/buildClient.js.map +1 -1
  161. package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +1 -1
  162. package/dist/src/rlc-common/buildClientDefinitions.js +28 -45
  163. package/dist/src/rlc-common/buildClientDefinitions.js.map +1 -1
  164. package/dist/src/rlc-common/buildIndexFile.d.ts.map +1 -1
  165. package/dist/src/rlc-common/buildIndexFile.js +59 -60
  166. package/dist/src/rlc-common/buildIndexFile.js.map +1 -1
  167. package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +1 -1
  168. package/dist/src/rlc-common/buildIsUnexpectedHelper.js +37 -38
  169. package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +1 -1
  170. package/dist/src/rlc-common/buildLogger.d.ts.map +1 -1
  171. package/dist/src/rlc-common/buildLogger.js +4 -5
  172. package/dist/src/rlc-common/buildLogger.js.map +1 -1
  173. package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +1 -1
  174. package/dist/src/rlc-common/buildMethodShortcuts.js +4 -4
  175. package/dist/src/rlc-common/buildMethodShortcuts.js.map +1 -1
  176. package/dist/src/rlc-common/buildObjectTypes.d.ts.map +1 -1
  177. package/dist/src/rlc-common/buildObjectTypes.js +57 -96
  178. package/dist/src/rlc-common/buildObjectTypes.js.map +1 -1
  179. package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +1 -1
  180. package/dist/src/rlc-common/buildPaginateHelper.js +2 -2
  181. package/dist/src/rlc-common/buildPaginateHelper.js.map +1 -1
  182. package/dist/src/rlc-common/buildParameterTypes.d.ts.map +1 -1
  183. package/dist/src/rlc-common/buildParameterTypes.js +71 -61
  184. package/dist/src/rlc-common/buildParameterTypes.js.map +1 -1
  185. package/dist/src/rlc-common/buildPollingHelper.d.ts.map +1 -1
  186. package/dist/src/rlc-common/buildPollingHelper.js +9 -10
  187. package/dist/src/rlc-common/buildPollingHelper.js.map +1 -1
  188. package/dist/src/rlc-common/buildResponseTypes.d.ts.map +1 -1
  189. package/dist/src/rlc-common/buildResponseTypes.js +23 -27
  190. package/dist/src/rlc-common/buildResponseTypes.js.map +1 -1
  191. package/dist/src/rlc-common/buildSamples.d.ts +1 -1
  192. package/dist/src/rlc-common/buildSamples.d.ts.map +1 -1
  193. package/dist/src/rlc-common/buildSamples.js +2 -2
  194. package/dist/src/rlc-common/buildSchemaType.d.ts.map +1 -1
  195. package/dist/src/rlc-common/buildSchemaType.js +31 -13
  196. package/dist/src/rlc-common/buildSchemaType.js.map +1 -1
  197. package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +1 -1
  198. package/dist/src/rlc-common/buildSerializeHelper.js +4 -4
  199. package/dist/src/rlc-common/buildSerializeHelper.js.map +1 -1
  200. package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +1 -1
  201. package/dist/src/rlc-common/buildTopLevelIndexFile.js +9 -13
  202. package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +1 -1
  203. package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +1 -1
  204. package/dist/src/rlc-common/helpers/apiVersionUtil.js +6 -8
  205. package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +1 -1
  206. package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +1 -1
  207. package/dist/src/rlc-common/helpers/importsUtil.js +32 -37
  208. package/dist/src/rlc-common/helpers/importsUtil.js.map +1 -1
  209. package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +1 -1
  210. package/dist/src/rlc-common/helpers/nameConstructors.js +2 -4
  211. package/dist/src/rlc-common/helpers/nameConstructors.js.map +1 -1
  212. package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +1 -1
  213. package/dist/src/rlc-common/helpers/nameUtils.js +17 -23
  214. package/dist/src/rlc-common/helpers/nameUtils.js.map +1 -1
  215. package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +1 -1
  216. package/dist/src/rlc-common/helpers/operationHelpers.js +16 -31
  217. package/dist/src/rlc-common/helpers/operationHelpers.js.map +1 -1
  218. package/dist/src/rlc-common/helpers/packageUtil.js +3 -6
  219. package/dist/src/rlc-common/helpers/packageUtil.js.map +1 -1
  220. package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +1 -1
  221. package/dist/src/rlc-common/helpers/pathUtils.js +1 -3
  222. package/dist/src/rlc-common/helpers/pathUtils.js.map +1 -1
  223. package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +1 -1
  224. package/dist/src/rlc-common/helpers/schemaHelpers.js +3 -7
  225. package/dist/src/rlc-common/helpers/schemaHelpers.js.map +1 -1
  226. package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +1 -1
  227. package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +1 -1
  228. package/dist/src/rlc-common/helpers/shortcutMethods.js +2 -2
  229. package/dist/src/rlc-common/helpers/shortcutMethods.js.map +1 -1
  230. package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +1 -1
  231. package/dist/src/rlc-common/helpers/typeUtil.js +4 -9
  232. package/dist/src/rlc-common/helpers/typeUtil.js.map +1 -1
  233. package/dist/src/rlc-common/helpers/valueGenerationUtil.js +7 -11
  234. package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +1 -1
  235. package/dist/src/rlc-common/index.d.ts +28 -28
  236. package/dist/src/rlc-common/index.d.ts.map +1 -1
  237. package/dist/src/rlc-common/index.js +28 -28
  238. package/dist/src/rlc-common/index.js.map +1 -1
  239. package/dist/src/rlc-common/interfaces.d.ts.map +1 -1
  240. package/dist/src/rlc-common/interfaces.js.map +1 -1
  241. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +1 -1
  242. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +14 -15
  243. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +1 -1
  244. package/dist/src/rlc-common/metadata/buildChangelogFile.js +2 -3
  245. package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +1 -1
  246. package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +1 -1
  247. package/dist/src/rlc-common/metadata/buildESLintConfig.js +5 -8
  248. package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +1 -1
  249. package/dist/src/rlc-common/metadata/buildLicenseFile.js +1 -1
  250. package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +1 -1
  251. package/dist/src/rlc-common/metadata/buildPackageFile.js +33 -37
  252. package/dist/src/rlc-common/metadata/buildPackageFile.js.map +1 -1
  253. package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +1 -1
  254. package/dist/src/rlc-common/metadata/buildReadmeFile.js +31 -39
  255. package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +1 -1
  256. package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +1 -1
  257. package/dist/src/rlc-common/metadata/buildRollupConfig.js +4 -6
  258. package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +1 -1
  259. package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +1 -1
  260. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +3 -5
  261. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +1 -1
  262. package/dist/src/rlc-common/metadata/buildTestConfig.js +11 -12
  263. package/dist/src/rlc-common/metadata/buildTestConfig.js.map +1 -1
  264. package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +1 -1
  265. package/dist/src/rlc-common/metadata/buildTsConfig.js +28 -28
  266. package/dist/src/rlc-common/metadata/buildTsConfig.js.map +1 -1
  267. package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +1 -1
  268. package/dist/src/rlc-common/metadata/buildVitestConfig.js +3 -5
  269. package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +1 -1
  270. package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +1 -1
  271. package/dist/src/rlc-common/metadata/buildWarpConfig.js +4 -5
  272. package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +1 -1
  273. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +1 -1
  274. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +1 -1
  275. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +14 -14
  276. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +1 -1
  277. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +1 -1
  278. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +24 -29
  279. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +1 -1
  280. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +1 -1
  281. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +15 -16
  282. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +1 -1
  283. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +8 -8
  284. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +1 -1
  285. package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +1 -1
  286. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +28 -31
  287. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +1 -1
  288. package/dist/src/rlc-common/metadata/utils.js +1 -2
  289. package/dist/src/rlc-common/metadata/utils.js.map +1 -1
  290. package/dist/src/rlc-common/test/buildKarmaConfig.js +1 -1
  291. package/dist/src/rlc-common/test/buildRecordedClient.js +4 -5
  292. package/dist/src/rlc-common/test/buildRecordedClient.js.map +1 -1
  293. package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +1 -1
  294. package/dist/src/rlc-common/test/buildSampleTest.js +3 -4
  295. package/dist/src/rlc-common/test/buildSampleTest.js.map +1 -1
  296. package/dist/src/rlc-common/test/buildSnippets.d.ts.map +1 -1
  297. package/dist/src/rlc-common/test/buildSnippets.js +7 -10
  298. package/dist/src/rlc-common/test/buildSnippets.js.map +1 -1
  299. package/dist/src/rlc-common/transformSampleGroups.d.ts.map +1 -1
  300. package/dist/src/rlc-common/transformSampleGroups.js +41 -45
  301. package/dist/src/rlc-common/transformSampleGroups.js.map +1 -1
  302. package/dist/src/testing/index.d.ts.map +1 -1
  303. package/dist/src/testing/index.js +1 -1
  304. package/dist/src/testing/index.js.map +1 -1
  305. package/dist/src/transform/transform.d.ts +1 -1
  306. package/dist/src/transform/transform.d.ts.map +1 -1
  307. package/dist/src/transform/transform.js +28 -27
  308. package/dist/src/transform/transform.js.map +1 -1
  309. package/dist/src/transform/transformApiVersionInfo.d.ts +1 -1
  310. package/dist/src/transform/transformApiVersionInfo.d.ts.map +1 -1
  311. package/dist/src/transform/transformApiVersionInfo.js +12 -14
  312. package/dist/src/transform/transformApiVersionInfo.js.map +1 -1
  313. package/dist/src/transform/transformHelperFunctionDetails.d.ts +1 -1
  314. package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +1 -1
  315. package/dist/src/transform/transformHelperFunctionDetails.js +11 -14
  316. package/dist/src/transform/transformHelperFunctionDetails.js.map +1 -1
  317. package/dist/src/transform/transformParameters.d.ts +2 -2
  318. package/dist/src/transform/transformParameters.d.ts.map +1 -1
  319. package/dist/src/transform/transformParameters.js +32 -45
  320. package/dist/src/transform/transformParameters.js.map +1 -1
  321. package/dist/src/transform/transformPaths.d.ts +1 -1
  322. package/dist/src/transform/transformPaths.d.ts.map +1 -1
  323. package/dist/src/transform/transformPaths.js +19 -23
  324. package/dist/src/transform/transformPaths.js.map +1 -1
  325. package/dist/src/transform/transformResponses.d.ts +1 -1
  326. package/dist/src/transform/transformResponses.d.ts.map +1 -1
  327. package/dist/src/transform/transformResponses.js +21 -25
  328. package/dist/src/transform/transformResponses.js.map +1 -1
  329. package/dist/src/transform/transformSchemas.d.ts.map +1 -1
  330. package/dist/src/transform/transformSchemas.js +21 -32
  331. package/dist/src/transform/transformSchemas.js.map +1 -1
  332. package/dist/src/transform/transformTelemetryInfo.d.ts +1 -1
  333. package/dist/src/transform/transformTelemetryInfo.d.ts.map +1 -1
  334. package/dist/src/transform/transformTelemetryInfo.js +3 -3
  335. package/dist/src/transform/transformTelemetryInfo.js.map +1 -1
  336. package/dist/src/transform/transfromRLCOptions.d.ts +1 -1
  337. package/dist/src/transform/transfromRLCOptions.d.ts.map +1 -1
  338. package/dist/src/transform/transfromRLCOptions.js +28 -39
  339. package/dist/src/transform/transfromRLCOptions.js.map +1 -1
  340. package/dist/src/utils/clientUtils.d.ts +1 -1
  341. package/dist/src/utils/clientUtils.d.ts.map +1 -1
  342. package/dist/src/utils/clientUtils.js +15 -23
  343. package/dist/src/utils/clientUtils.js.map +1 -1
  344. package/dist/src/utils/credentialUtils.d.ts +1 -1
  345. package/dist/src/utils/credentialUtils.d.ts.map +1 -1
  346. package/dist/src/utils/credentialUtils.js +4 -5
  347. package/dist/src/utils/credentialUtils.js.map +1 -1
  348. package/dist/src/utils/crossLanguageDef.d.ts.map +1 -1
  349. package/dist/src/utils/crossLanguageDef.js +11 -15
  350. package/dist/src/utils/crossLanguageDef.js.map +1 -1
  351. package/dist/src/utils/emitUtil.d.ts +1 -1
  352. package/dist/src/utils/emitUtil.d.ts.map +1 -1
  353. package/dist/src/utils/emitUtil.js +5 -7
  354. package/dist/src/utils/emitUtil.js.map +1 -1
  355. package/dist/src/utils/fileSystemUtils.d.ts +2 -0
  356. package/dist/src/utils/fileSystemUtils.d.ts.map +1 -1
  357. package/dist/src/utils/fileSystemUtils.js +26 -7
  358. package/dist/src/utils/fileSystemUtils.js.map +1 -1
  359. package/dist/src/utils/importHelper.d.ts.map +1 -1
  360. package/dist/src/utils/importHelper.js +3 -6
  361. package/dist/src/utils/importHelper.js.map +1 -1
  362. package/dist/src/utils/interfaces.d.ts +1 -1
  363. package/dist/src/utils/interfaces.d.ts.map +1 -1
  364. package/dist/src/utils/mediaTypes.d.ts.map +1 -1
  365. package/dist/src/utils/mediaTypes.js +7 -19
  366. package/dist/src/utils/mediaTypes.js.map +1 -1
  367. package/dist/src/utils/modelUtils.d.ts +5 -5
  368. package/dist/src/utils/modelUtils.d.ts.map +1 -1
  369. package/dist/src/utils/modelUtils.js +168 -257
  370. package/dist/src/utils/modelUtils.js.map +1 -1
  371. package/dist/src/utils/namespaceUtils.d.ts.map +1 -1
  372. package/dist/src/utils/namespaceUtils.js +6 -7
  373. package/dist/src/utils/namespaceUtils.js.map +1 -1
  374. package/dist/src/utils/operationUtil.d.ts +1 -1
  375. package/dist/src/utils/operationUtil.d.ts.map +1 -1
  376. package/dist/src/utils/operationUtil.js +60 -81
  377. package/dist/src/utils/operationUtil.js.map +1 -1
  378. package/dist/src/utils/parameterUtils.d.ts +1 -1
  379. package/dist/src/utils/parameterUtils.d.ts.map +1 -1
  380. package/dist/src/utils/parameterUtils.js +26 -33
  381. package/dist/src/utils/parameterUtils.js.map +1 -1
  382. package/dist/src/utils/resolve-project-root.js +2 -2
  383. package/dist/src/utils/resolve-project-root.js.map +1 -1
  384. package/dist/tsconfig.tsbuildinfo +1 -1
  385. package/package.json +36 -43
  386. package/src/contextManager.ts +6 -9
  387. package/src/framework/declaration.ts +18 -28
  388. package/src/framework/dependency.ts +1 -2
  389. package/src/framework/hooks/binder.ts +47 -120
  390. package/src/framework/hooks/sdkTypes.ts +27 -54
  391. package/src/framework/hooks/useDependencies.ts +2 -4
  392. package/src/framework/load-static-helpers.ts +28 -51
  393. package/src/framework/reference.ts +2 -5
  394. package/src/framework/sample.ts +9 -9
  395. package/src/index.ts +145 -185
  396. package/src/lib.ts +143 -158
  397. package/src/metaTree.ts +1 -1
  398. package/src/modular/buildClassicalClient.ts +83 -160
  399. package/src/modular/buildClassicalOperationGroups.ts +14 -39
  400. package/src/modular/buildClientContext.ts +54 -83
  401. package/src/modular/buildModularOptions.ts +4 -5
  402. package/src/modular/buildOperations.ts +46 -73
  403. package/src/modular/buildProjectFiles.ts +18 -47
  404. package/src/modular/buildRestorePoller.ts +27 -46
  405. package/src/modular/buildRootIndex.ts +86 -160
  406. package/src/modular/buildSubpathIndex.ts +35 -58
  407. package/src/modular/emitLoggerFile.ts +4 -9
  408. package/src/modular/emitModels.ts +136 -266
  409. package/src/modular/emitModelsOptions.ts +10 -16
  410. package/src/modular/emitSamples.ts +92 -180
  411. package/src/modular/emitTests.ts +28 -61
  412. package/src/modular/external-dependencies.ts +54 -54
  413. package/src/modular/helpers/classicalOperationHelpers.ts +73 -126
  414. package/src/modular/helpers/clientHelpers.ts +41 -88
  415. package/src/modular/helpers/clientOptionHelpers.ts +4 -11
  416. package/src/modular/helpers/exampleValueHelpers.ts +99 -215
  417. package/src/modular/helpers/namingHelpers.ts +12 -28
  418. package/src/modular/helpers/operationHelpers.ts +430 -757
  419. package/src/modular/helpers/typeHelpers.ts +11 -22
  420. package/src/modular/serialization/buildDeserializerFunction.ts +88 -122
  421. package/src/modular/serialization/buildSerializerFunction.ts +91 -129
  422. package/src/modular/serialization/buildXmlSerializerFunction.ts +104 -183
  423. package/src/modular/serialization/serializeUtils.ts +12 -22
  424. package/src/modular/static/rollup.test.config.js +11 -14
  425. package/src/modular/static/scripts/renameOutput.mjs +2 -2
  426. package/src/modular/static-helpers-metadata.ts +60 -60
  427. package/src/modular/type-expressions/get-credential-expression.ts +1 -1
  428. package/src/modular/type-expressions/get-enum-expression.ts +5 -10
  429. package/src/modular/type-expressions/get-model-expression.ts +13 -17
  430. package/src/modular/type-expressions/get-nullable-expression.ts +4 -5
  431. package/src/modular/type-expressions/get-type-expression.ts +8 -12
  432. package/src/modular/type-expressions/get-union-expression.ts +4 -4
  433. package/src/modular/type-expressions/utils.ts +1 -1
  434. package/src/rlc-common/buildClient.ts +70 -141
  435. package/src/rlc-common/buildClientDefinitions.ts +44 -87
  436. package/src/rlc-common/buildIndexFile.ts +78 -78
  437. package/src/rlc-common/buildIsUnexpectedHelper.ts +34 -41
  438. package/src/rlc-common/buildLogger.ts +7 -7
  439. package/src/rlc-common/buildMethodShortcuts.ts +9 -21
  440. package/src/rlc-common/buildObjectTypes.ts +79 -156
  441. package/src/rlc-common/buildPaginateHelper.ts +9 -12
  442. package/src/rlc-common/buildParameterTypes.ts +116 -137
  443. package/src/rlc-common/buildPollingHelper.ts +7 -7
  444. package/src/rlc-common/buildResponseTypes.ts +34 -57
  445. package/src/rlc-common/buildSamples.ts +3 -3
  446. package/src/rlc-common/buildSchemaType.ts +37 -29
  447. package/src/rlc-common/buildSerializeHelper.ts +5 -5
  448. package/src/rlc-common/buildTopLevelIndexFile.ts +12 -19
  449. package/src/rlc-common/helpers/apiVersionUtil.ts +5 -10
  450. package/src/rlc-common/helpers/importsUtil.ts +27 -30
  451. package/src/rlc-common/helpers/nameConstructors.ts +16 -50
  452. package/src/rlc-common/helpers/nameUtils.ts +19 -42
  453. package/src/rlc-common/helpers/operationHelpers.ts +14 -31
  454. package/src/rlc-common/helpers/pathUtils.ts +2 -7
  455. package/src/rlc-common/helpers/schemaHelpers.ts +4 -15
  456. package/src/rlc-common/helpers/shortcutMethods.ts +6 -15
  457. package/src/rlc-common/helpers/typeUtil.ts +4 -11
  458. package/src/rlc-common/helpers/valueGenerationUtil.ts +16 -39
  459. package/src/rlc-common/index.ts +28 -28
  460. package/src/rlc-common/interfaces.ts +3 -11
  461. package/src/rlc-common/metadata/buildApiExtractorConfig.ts +17 -24
  462. package/src/rlc-common/metadata/buildChangelogFile.ts +1 -1
  463. package/src/rlc-common/metadata/buildESLintConfig.ts +3 -5
  464. package/src/rlc-common/metadata/buildLicenseFile.ts +1 -1
  465. package/src/rlc-common/metadata/buildPackageFile.ts +27 -35
  466. package/src/rlc-common/metadata/buildReadmeFile.ts +16 -29
  467. package/src/rlc-common/metadata/buildRollupConfig.ts +5 -8
  468. package/src/rlc-common/metadata/buildSampleEnvFile.ts +2 -3
  469. package/src/rlc-common/metadata/buildTestConfig.ts +10 -10
  470. package/src/rlc-common/metadata/buildTsConfig.ts +32 -35
  471. package/src/rlc-common/metadata/buildVitestConfig.ts +4 -10
  472. package/src/rlc-common/metadata/buildWarpConfig.ts +3 -6
  473. package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +16 -25
  474. package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +29 -50
  475. package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +20 -31
  476. package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +11 -13
  477. package/src/rlc-common/metadata/packageJson/packageCommon.ts +32 -52
  478. package/src/rlc-common/test/buildKarmaConfig.ts +1 -1
  479. package/src/rlc-common/test/buildRecordedClient.ts +3 -3
  480. package/src/rlc-common/test/buildSampleTest.ts +3 -3
  481. package/src/rlc-common/test/buildSnippets.ts +6 -12
  482. package/src/rlc-common/transformSampleGroups.ts +54 -105
  483. package/src/testing/index.ts +2 -5
  484. package/src/transform/transform.ts +22 -34
  485. package/src/transform/transformApiVersionInfo.ts +17 -30
  486. package/src/transform/transformHelperFunctionDetails.ts +14 -26
  487. package/src/transform/transformParameters.ts +55 -105
  488. package/src/transform/transformPaths.ts +26 -43
  489. package/src/transform/transformResponses.ts +26 -33
  490. package/src/transform/transformSchemas.ts +15 -33
  491. package/src/transform/transformTelemetryInfo.ts +8 -14
  492. package/src/transform/transfromRLCOptions.ts +53 -116
  493. package/src/utils/clientUtils.ts +22 -41
  494. package/src/utils/credentialUtils.ts +8 -19
  495. package/src/utils/crossLanguageDef.ts +15 -34
  496. package/src/utils/emitUtil.ts +11 -17
  497. package/src/utils/fileSystemUtils.ts +30 -8
  498. package/src/utils/importHelper.ts +5 -10
  499. package/src/utils/interfaces.ts +1 -1
  500. package/src/utils/mediaTypes.ts +13 -34
  501. package/src/utils/modelUtils.ts +175 -384
  502. package/src/utils/namespaceUtils.ts +8 -24
  503. package/src/utils/operationUtil.ts +98 -190
  504. package/src/utils/parameterUtils.ts +31 -54
  505. package/src/utils/resolve-project-root.ts +3 -3
  506. package/static/static-helpers/cloudSettingHelpers.ts +4 -6
  507. package/static/static-helpers/multipartHelpers.ts +3 -3
  508. package/static/static-helpers/pagingHelpers.ts +28 -63
  509. package/static/static-helpers/pollingHelpers.ts +16 -29
  510. package/static/static-helpers/serialization/build-multi-collection.ts +1 -4
  511. package/static/static-helpers/serialization/check-prop-undefined.ts +1 -4
  512. package/static/static-helpers/serialization/get-binary-response-browser.mts +3 -1
  513. package/static/static-helpers/serialization/get-binary-response.ts +2 -2
  514. package/static/static-helpers/serialization/get-binary-stream-response-browser.mts +1 -3
  515. package/static/static-helpers/serialization/get-binary-stream-response.ts +2 -4
  516. package/static/static-helpers/serialization/serialize-record.ts +1 -1
  517. package/static/static-helpers/serialization/serializers.ts +4 -7
  518. package/static/static-helpers/serialization/xml-helpers.ts +42 -90
  519. package/static/static-helpers/simplePollerHelpers.ts +10 -19
  520. package/static/static-helpers/storageCompatResponse.ts +10 -27
  521. package/static/static-helpers/urlTemplate.ts +4 -7
  522. package/static/test-helpers/recordedClient.ts +5 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure-tools/typespec-ts",
3
- "version": "0.54.0",
3
+ "version": "0.54.1",
4
4
  "description": "An experimental TypeSpec emitter for TypeScript RLC",
5
5
  "main": "dist/src/index.js",
6
6
  "type": "module",
@@ -18,15 +18,6 @@
18
18
  "license": "MIT",
19
19
  "devDependencies": {
20
20
  "@azure-rest/core-client": "^2.3.1",
21
- "@typespec/http-specs": "0.1.0-alpha.37-dev.6",
22
- "@typespec/spector": "0.1.0-dev.4",
23
- "@typespec/spec-api": "0.1.0-dev.3",
24
- "@typespec/tspd": "0.74.2",
25
- "@azure-tools/azure-http-specs": "0.1.0-alpha.41-dev.2",
26
- "@azure-tools/typespec-autorest": "^0.68.0",
27
- "@azure-tools/typespec-azure-core": "^0.68.0",
28
- "@azure-tools/typespec-azure-resource-manager": "^0.68.0",
29
- "@azure-tools/typespec-client-generator-core": "^0.68.3",
30
21
  "@azure/abort-controller": "^2.1.2",
31
22
  "@azure/core-auth": "^1.6.0",
32
23
  "@azure/core-lro": "^3.1.0",
@@ -34,50 +25,49 @@
34
25
  "@azure/core-rest-pipeline": "^1.14.0",
35
26
  "@azure/core-util": "^1.4.0",
36
27
  "@azure/logger": "^1.0.4",
37
- "@types/chai": "^4.3.1",
38
- "@types/fs-extra": "^9.0.13",
39
- "@types/lodash": "^4.17.4",
40
28
  "@typescript-eslint/eslint-plugin": "^8.28.0",
41
- "@typescript-eslint/parser": "^8.28.0",
29
+ "@typescript-eslint/parser": "^8.58.1",
30
+ "@typespec/ts-http-runtime": "0.3.5",
31
+ "cross-env": "^10.1.0",
32
+ "eslint-plugin-require-extensions": "0.1.3",
33
+ "mkdirp": "^3.0.1",
34
+ "npm-run-all": "~4.1.5",
35
+ "prettier": "^3.8.1",
36
+ "vitest": "^4.1.3",
37
+ "vite": "^8.0.8",
38
+ "@vitest/coverage-v8": "^4.1.3",
39
+ "@microsoft/api-extractor": "^7.58.1",
40
+ "tsx": "^4.21.0",
41
+ "yaml": "^2.8.3",
42
+ "@typespec/http-specs": "^0.1.0-alpha.37",
43
+ "@typespec/spector": "^0.1.0-alpha.25",
44
+ "@typespec/spec-api": "^0.1.0-alpha.14",
45
+ "@azure-tools/typespec-autorest": "^0.68.0",
46
+ "@azure-tools/azure-http-specs": "^0.1.0-alpha.40",
47
+ "@typespec/tspd": "^0.74.2",
48
+ "@azure-tools/typespec-azure-core": "^0.68.0",
49
+ "@azure-tools/typespec-azure-resource-manager": "^0.68.0",
50
+ "@azure-tools/typespec-client-generator-core": "^0.68.4",
42
51
  "@typespec/compiler": "^1.12.0",
43
52
  "@typespec/http": "^1.12.0",
44
53
  "@typespec/openapi": "^1.12.0",
45
54
  "@typespec/rest": "^0.82.0",
46
- "@typespec/ts-http-runtime": "^0.1.0",
47
- "@typespec/versioning": "^0.82.0",
48
55
  "@typespec/xml": "^0.82.0",
49
- "chai": "^4.3.6",
50
- "chalk": "^4.0.0",
51
- "cross-env": "^7.0.3",
52
- "eslint-plugin-require-extensions": "0.1.3",
53
- "mkdirp": "^3.0.1",
54
- "npm-run-all": "~4.1.5",
55
- "prettier": "^3.3.3",
56
- "ts-node": "~10.9.1",
57
- "vitest": "^4.1.0",
58
- "vite": "^6.0.0",
59
- "@vitest/coverage-v8": "^4.1.0",
60
- "@vitest/coverage-istanbul": "^4.1.0",
61
- "@microsoft/api-extractor": "^7.47.5",
62
- "tsx": "^4.16.5",
63
- "@types/js-yaml": "^4.0.9",
64
- "js-yaml": "^4.1.0"
56
+ "@typespec/versioning": "^0.82.0"
65
57
  },
66
58
  "peerDependencies": {
67
59
  "@azure-tools/typespec-azure-core": "^0.68.0",
68
- "@azure-tools/typespec-client-generator-core": "^0.68.3",
69
- "@typespec/compiler": "^1.12.0",
60
+ "@azure-tools/typespec-client-generator-core": "^0.68.4",
70
61
  "@typespec/http": "^1.12.0",
71
62
  "@typespec/rest": "^0.82.0",
72
63
  "@typespec/versioning": "^0.82.0",
64
+ "@typespec/compiler": "^1.12.0",
73
65
  "@typespec/xml": "^0.82.0"
74
66
  },
75
67
  "dependencies": {
76
- "fast-xml-parser": "^4.5.0",
77
- "fs-extra": "^11.1.0",
68
+ "fast-xml-parser": "^5.7.0",
78
69
  "handlebars": "^4.7.7",
79
- "lodash": "^4.17.21",
80
- "prettier": "^3.3.3",
70
+ "prettier": "^3.8.1",
81
71
  "ts-morph": "^23.0.0",
82
72
  "tslib": "^2.3.1"
83
73
  },
@@ -89,10 +79,14 @@
89
79
  "LICENSE",
90
80
  "static/**"
91
81
  ],
82
+ "repository": {
83
+ "type": "git",
84
+ "url": "git+https://github.com/Azure/typespec-azure.git"
85
+ },
92
86
  "bugs": {
93
- "url": "https://github.com/Azure/autorest.typescript/issues"
87
+ "url": "https://github.com/Azure/typespec-azure/issues"
94
88
  },
95
- "homepage": "https://github.com/Azure/autorest.typescript/tree/main/packages/typespec-ts/",
89
+ "homepage": "https://github.com/Azure/typespec-azure/tree/main/packages/typespec-ts/",
96
90
  "scripts": {
97
91
  "test-next": "vitest run --project test-next",
98
92
  "test-next:coverage": "vitest run --project test-next --coverage",
@@ -103,10 +97,9 @@
103
97
  "test:standard": "npm run test-next && npm run copy:typespec && npm run unit-test&& npm run integration-test-ci:rlc && npm run integration-test-ci:modular",
104
98
  "lint": "eslint src --ext .ts --max-warnings=0",
105
99
  "lint:fix": "eslint src --fix --ext .ts",
106
- "format": "npm run -s prettier -- --write",
107
- "check-format": "npm run prettier -- --check",
100
+ "check:tree": "tsx ./test/commands/check-clean-tree.ts",
101
+ "test:ts:e2e": "npm run copy:typespec && npm run integration-test-ci:azure-rlc && npm run integration-test-ci:azure-modular",
108
102
  "prettier": "prettier --config ./.prettierrc \"{src,test,static}/**/*.ts\" \"!test/**/generated/**/*.ts\"",
109
- "check:tree": "node --loader ts-node/esm ./test/commands/check-clean-tree.ts",
110
103
  "integration-test-ci": "npm-run-all copy:typespec integration-test-ci:rlc integration-test-ci:azure-rlc integration-test-ci:modular integration-test-ci:azure-modular",
111
104
  "integration-test-ci:sequential": "npm-run-all --serial copy:typespec integration-test-ci:modular && npm run integration-test-ci:modular",
112
105
  "integration-test-ci:rlc": "npm-run-all --silent -p start-test-server:rlc --race generate-and-run:rlc",
@@ -1,10 +1,10 @@
1
- import { Project, SourceFile } from "ts-morph";
2
- import { RlcMetaTree } from "./metaTree.js";
3
- import { EmitContext } from "@typespec/compiler";
4
1
  import { SdkContext } from "@azure-tools/typespec-client-generator-core";
5
- import { SdkTypeContext } from "./framework/hooks/sdkTypes.js";
6
- import { Binder } from "./framework/hooks/binder.js";
2
+ import { EmitContext } from "@typespec/compiler";
3
+ import { Project, SourceFile } from "ts-morph";
7
4
  import { ExternalDependencies } from "./framework/dependency.js";
5
+ import { Binder } from "./framework/hooks/binder.js";
6
+ import { SdkTypeContext } from "./framework/hooks/sdkTypes.js";
7
+ import { RlcMetaTree } from "./metaTree.js";
8
8
 
9
9
  /**
10
10
  * Contexts Object Guidelines
@@ -96,9 +96,6 @@ export function useContext<K extends ContextKey>(key: K): Contexts[K] {
96
96
  * @param {ContextKey} key - The key of the context to provide.
97
97
  * @param {Contexts[K]} value - The value to set for the specified context.
98
98
  */
99
- export function provideContext<K extends ContextKey>(
100
- key: K,
101
- value: Contexts[K]
102
- ): void {
99
+ export function provideContext<K extends ContextKey>(key: K, value: Contexts[K]): void {
103
100
  contextManager.setContext(key, value);
104
101
  }
@@ -1,16 +1,16 @@
1
1
  import {
2
- SourceFile,
2
+ ClassDeclaration,
3
3
  ClassDeclarationStructure,
4
+ EnumDeclaration,
4
5
  EnumDeclarationStructure,
6
+ FunctionDeclaration,
5
7
  FunctionDeclarationStructure,
8
+ InterfaceDeclaration,
6
9
  InterfaceDeclarationStructure,
7
- TypeAliasDeclarationStructure,
10
+ SourceFile,
8
11
  StructureKind,
9
- ClassDeclaration,
10
- EnumDeclaration,
11
- FunctionDeclaration,
12
- InterfaceDeclaration,
13
- TypeAliasDeclaration
12
+ TypeAliasDeclaration,
13
+ TypeAliasDeclarationStructure,
14
14
  } from "ts-morph";
15
15
  import { useBinder } from "./hooks/binder.js";
16
16
  import { refkey as getRefKey } from "./refkey.js";
@@ -31,58 +31,50 @@ export type Declarations =
31
31
  export function addDeclaration(
32
32
  sourceFile: SourceFile,
33
33
  declaration: ClassDeclarationStructure,
34
- refkey: unknown
34
+ refkey: unknown,
35
35
  ): void;
36
36
 
37
37
  export function addDeclaration(
38
38
  sourceFile: SourceFile,
39
39
  declaration: EnumDeclarationStructure,
40
- refkey: unknown
40
+ refkey: unknown,
41
41
  ): void;
42
42
 
43
43
  export function addDeclaration(
44
44
  sourceFile: SourceFile,
45
45
  declaration: FunctionDeclarationStructure,
46
- refkey: unknown
46
+ refkey: unknown,
47
47
  ): void;
48
48
 
49
49
  export function addDeclaration(
50
50
  sourceFile: SourceFile,
51
51
  declaration: InterfaceDeclarationStructure,
52
- refkey: unknown
52
+ refkey: unknown,
53
53
  ): void;
54
54
 
55
55
  export function addDeclaration(
56
56
  sourceFile: SourceFile,
57
57
  declaration: TypeAliasDeclarationStructure,
58
- refkey: unknown
59
- ): void;
60
- export function addDeclaration(
61
- sourceFile: SourceFile,
62
- declaration: string,
63
- refkey: unknown
58
+ refkey: unknown,
64
59
  ): void;
60
+ export function addDeclaration(sourceFile: SourceFile, declaration: string, refkey: unknown): void;
65
61
  export function addDeclaration(
66
62
  sourceFile: SourceFile,
67
63
  input: DeclarationStructures | string,
68
- refkey: unknown
64
+ refkey: unknown,
69
65
  ): void {
70
66
  const binder = useBinder();
71
67
  const declaration: DeclarationStructures =
72
- typeof input === "string"
73
- ? ({ name: input, kind: StructureKind.TypeAlias } as any)
74
- : input;
68
+ typeof input === "string" ? ({ name: input, kind: StructureKind.TypeAlias } as any) : input;
75
69
  if (!declaration.name) {
76
- throw new Error(
77
- `Declaration must have a name ${JSON.stringify(declaration)}`
78
- );
70
+ throw new Error(`Declaration must have a name ${JSON.stringify(declaration)}`);
79
71
  }
80
72
 
81
73
  const stringRefkey = typeof refkey === "string" ? refkey : getRefKey(refkey);
82
74
  const trackedDeclarationName = binder.trackDeclaration(
83
75
  stringRefkey,
84
76
  declaration.name,
85
- sourceFile
77
+ sourceFile,
86
78
  );
87
79
 
88
80
  // Update the declaration name to be unique
@@ -107,8 +99,6 @@ export function addDeclaration(
107
99
  }
108
100
  break;
109
101
  default:
110
- throw new Error(
111
- `Unsupported declaration kind ${(trackedDeclaration as any).kind}`
112
- );
102
+ throw new Error(`Unsupported declaration kind ${(trackedDeclaration as any).kind}`);
113
103
  }
114
104
  }
@@ -5,8 +5,7 @@ export interface ReferenceableSymbol {
5
5
  visibility?: "internal" | "public";
6
6
  }
7
7
 
8
- export type ExternalDependencies = CoreDependencies &
9
- Record<string, ReferenceableSymbol>;
8
+ export type ExternalDependencies = CoreDependencies & Record<string, ReferenceableSymbol>;
10
9
 
11
10
  /**
12
11
  * This interface defines the well known Core dependencies that plugins can use to override and provide their own implementations if needed
@@ -1,21 +1,18 @@
1
+ import { normalizePath } from "@typespec/compiler";
2
+ import path from "path/posix";
1
3
  import {
2
- SourceFile,
3
4
  ImportDeclarationStructure,
4
- StructureKind,
5
5
  ImportSpecifierStructure,
6
- Project
6
+ Project,
7
+ SourceFile,
8
+ StructureKind,
7
9
  } from "ts-morph";
8
10
  import { provideContext, useContext } from "../../contextManager.js";
11
+ import { generateLocallyUniqueName } from "../../modular/helpers/namingHelpers.js";
9
12
  import { ReferenceableSymbol } from "../dependency.js";
10
- import { provideDependencies, useDependencies } from "./useDependencies.js";
13
+ import { SourceFileSymbol, StaticHelperMetadata } from "../load-static-helpers.js";
11
14
  import { refkey } from "../refkey.js";
12
- import {
13
- SourceFileSymbol,
14
- StaticHelperMetadata
15
- } from "../load-static-helpers.js";
16
- import path from "path/posix";
17
- import { normalizePath } from "@typespec/compiler";
18
- import { generateLocallyUniqueName } from "../../modular/helpers/namingHelpers.js";
15
+ import { provideDependencies, useDependencies } from "./useDependencies.js";
19
16
 
20
17
  export interface DeclarationInfo {
21
18
  name: string;
@@ -39,11 +36,7 @@ export interface Binder {
39
36
  * @param sourceFile - The source file where the declaration is made.
40
37
  * @returns The tracked declaration name.
41
38
  */
42
- trackDeclaration(
43
- refkey: unknown,
44
- name: string,
45
- sourceFile: SourceFile
46
- ): string;
39
+ trackDeclaration(refkey: unknown, name: string, sourceFile: SourceFile): string;
47
40
  resolveReference(refkey: unknown): string;
48
41
  resolveAllReferences(sourceRoot: string, testRoot?: string): void;
49
42
  }
@@ -69,15 +62,8 @@ class BinderImp implements Binder {
69
62
  this.useSubpathImports = options.useSubpathImports ?? false;
70
63
  }
71
64
 
72
- trackDeclaration(
73
- refkey: unknown,
74
- name: string,
75
- sourceFile: SourceFile
76
- ): string {
77
- const uniqueName = this.generateLocallyUniqueDeclarationName(
78
- name,
79
- sourceFile
80
- );
65
+ trackDeclaration(refkey: unknown, name: string, sourceFile: SourceFile): string {
66
+ const uniqueName = this.generateLocallyUniqueDeclarationName(name, sourceFile);
81
67
  const declarationInfo: DeclarationInfo = { name: uniqueName, sourceFile };
82
68
  this.declarations.set(refkey, declarationInfo);
83
69
 
@@ -96,12 +82,8 @@ class BinderImp implements Binder {
96
82
  * @param sourceFile - The source file where the declaration is made.
97
83
  * @returns A unique name for the declaration within the file.
98
84
  */
99
- private generateLocallyUniqueDeclarationName(
100
- name: string,
101
- sourceFile: SourceFile
102
- ): string {
103
- const existingNamesInFile =
104
- this.symbolsBySourceFile.get(sourceFile) ?? new Set<string>();
85
+ private generateLocallyUniqueDeclarationName(name: string, sourceFile: SourceFile): string {
86
+ const existingNamesInFile = this.symbolsBySourceFile.get(sourceFile) ?? new Set<string>();
105
87
  return generateLocallyUniqueName(name, existingNamesInFile);
106
88
  }
107
89
 
@@ -111,10 +93,7 @@ class BinderImp implements Binder {
111
93
  * @param sourceFile - The source file where the import is made.
112
94
  * @returns A unique name for the import within the file.
113
95
  */
114
- private generateLocallyUniqueImportName(
115
- name: string,
116
- sourceFile: SourceFile
117
- ): string {
96
+ private generateLocallyUniqueImportName(name: string, sourceFile: SourceFile): string {
118
97
  const existingImports = (this.imports.get(sourceFile) ?? [])
119
98
  .flatMap((i) => i.namedImports as ImportSpecifierStructure[])
120
99
  .map((i) => i.alias ?? i.name);
@@ -123,15 +102,12 @@ class BinderImp implements Binder {
123
102
  const actualImports = sourceFile
124
103
  .getImportDeclarations()
125
104
  .flatMap((imp) => imp.getNamedImports())
126
- .map(
127
- (namedImp) => namedImp.getAliasNode()?.getText() ?? namedImp.getName()
128
- );
105
+ .map((namedImp) => namedImp.getAliasNode()?.getText() ?? namedImp.getName());
129
106
 
130
- const existingDeclarations =
131
- this.symbolsBySourceFile.get(sourceFile) ?? new Set<string>();
107
+ const existingDeclarations = this.symbolsBySourceFile.get(sourceFile) ?? new Set<string>();
132
108
  return generateLocallyUniqueName(
133
109
  name,
134
- new Set([...existingImports, ...actualImports, ...existingDeclarations])
110
+ new Set([...existingImports, ...actualImports, ...existingDeclarations]),
135
111
  );
136
112
  }
137
113
 
@@ -166,12 +142,9 @@ class BinderImp implements Binder {
166
142
  private addImport(
167
143
  fileWhereImportIsAdded: SourceFile,
168
144
  fileWhereImportPointsTo: SourceFile | string,
169
- name: string
145
+ name: string,
170
146
  ): ImportSpecifierStructure {
171
- const importAlias = this.generateLocallyUniqueImportName(
172
- name,
173
- fileWhereImportIsAdded
174
- );
147
+ const importAlias = this.generateLocallyUniqueImportName(name, fileWhereImportIsAdded);
175
148
  let moduleSpecifier = "";
176
149
  if (typeof fileWhereImportPointsTo === "string") {
177
150
  moduleSpecifier = fileWhereImportPointsTo;
@@ -180,35 +153,30 @@ class BinderImp implements Binder {
180
153
  .getRelativePathTo(fileWhereImportPointsTo)
181
154
  .replace(".ts", ".js");
182
155
  moduleSpecifier =
183
- relative.startsWith(".") || relative.startsWith("/")
184
- ? relative
185
- : `./${relative}`;
156
+ relative.startsWith(".") || relative.startsWith("/") ? relative : `./${relative}`;
186
157
  }
187
158
 
188
159
  const importStructures = this.imports.get(fileWhereImportIsAdded) || [];
189
160
 
190
- let importStructure = importStructures.find(
191
- (imp) => imp.moduleSpecifier === moduleSpecifier
192
- );
161
+ let importStructure = importStructures.find((imp) => imp.moduleSpecifier === moduleSpecifier);
193
162
 
194
163
  if (!importStructure) {
195
164
  importStructure = {
196
165
  kind: StructureKind.ImportDeclaration,
197
166
  moduleSpecifier,
198
- namedImports: []
167
+ namedImports: [],
199
168
  };
200
169
  importStructures.push(importStructure);
201
170
  }
202
171
 
203
- const namedImports =
204
- importStructure.namedImports as ImportSpecifierStructure[];
172
+ const namedImports = importStructure.namedImports as ImportSpecifierStructure[];
205
173
  let importSpecifier = namedImports.find((n) => n.name === importAlias);
206
174
 
207
175
  if (!importSpecifier) {
208
176
  importSpecifier = {
209
177
  name: name,
210
178
  alias: name === importAlias ? undefined : importAlias,
211
- kind: StructureKind.ImportSpecifier
179
+ kind: StructureKind.ImportSpecifier,
212
180
  };
213
181
  namedImports.push(importSpecifier);
214
182
  }
@@ -225,21 +193,15 @@ class BinderImp implements Binder {
225
193
  * e.g. "src/static-helpers/serialization/get-binary-response.ts"
226
194
  * -> "#platform/static-helpers/serialization/get-binary-response"
227
195
  */
228
- private getPlatformImportSpecifier(
229
- declarationSourceFile: SourceFile
230
- ): string | undefined {
196
+ private getPlatformImportSpecifier(declarationSourceFile: SourceFile): string | undefined {
231
197
  if (!this.useSubpathImports) return undefined;
232
198
  const filePath = declarationSourceFile.getFilePath();
233
199
  const srcIndex = filePath.indexOf("/src/");
234
200
  if (srcIndex === -1) return undefined;
235
201
  // Check if a -browser.mts or -react-native.mts sibling exists
236
202
  const basePath = filePath.replace(/\.ts$/, "");
237
- const hasBrowserVariant = this.project.getSourceFile(
238
- basePath + "-browser.mts"
239
- );
240
- const hasReactNativeVariant = this.project.getSourceFile(
241
- basePath + "-react-native.mts"
242
- );
203
+ const hasBrowserVariant = this.project.getSourceFile(basePath + "-browser.mts");
204
+ const hasReactNativeVariant = this.project.getSourceFile(basePath + "-react-native.mts");
243
205
  if (!hasBrowserVariant && !hasReactNativeVariant) return undefined;
244
206
  const relativePath = filePath.substring(srcIndex + "/src/".length);
245
207
  return "#platform/" + relativePath.replace(/\.ts$/, "");
@@ -255,23 +217,14 @@ class BinderImp implements Binder {
255
217
  [unknown, DeclarationInfo | StaticHelperMetadata]
256
218
  >();
257
219
  for (const [key, value] of this.declarations) {
258
- declarationByPlaceholder.set(this.serializePlaceholder(key), [
259
- key,
260
- value
261
- ]);
220
+ declarationByPlaceholder.set(this.serializePlaceholder(key), [key, value]);
262
221
  }
263
222
  for (const [key, value] of this.staticHelpers) {
264
- declarationByPlaceholder.set(this.serializePlaceholder(key), [
265
- key,
266
- value
267
- ]);
223
+ declarationByPlaceholder.set(this.serializePlaceholder(key), [key, value]);
268
224
  }
269
225
  const dependencyByPlaceholder = new Map<string, ReferenceableSymbol>();
270
226
  for (const dependency of Object.values(this.dependencies)) {
271
- dependencyByPlaceholder.set(
272
- this.serializePlaceholder(refkey(dependency)),
273
- dependency
274
- );
227
+ dependencyByPlaceholder.set(this.serializePlaceholder(refkey(dependency)), dependency);
275
228
  }
276
229
 
277
230
  this.project.getSourceFiles().map((file) => {
@@ -285,13 +238,13 @@ class BinderImp implements Binder {
285
238
  file,
286
239
  declarationByPlaceholder,
287
240
  presentPlaceholders,
288
- replacementMap
241
+ replacementMap,
289
242
  );
290
243
  this.resolveDependencyReferences(
291
244
  file,
292
245
  dependencyByPlaceholder,
293
246
  presentPlaceholders,
294
- replacementMap
247
+ replacementMap,
295
248
  );
296
249
  if (replacementMap.size > 0) {
297
250
  applyReplacements(file, replacementMap);
@@ -300,9 +253,7 @@ class BinderImp implements Binder {
300
253
  const importStructures = this.imports.get(file);
301
254
  if (importStructures && importStructures.length > 0) {
302
255
  // Sort imports in place by module specifier to ensure consistent ordering
303
- importStructures.sort((a, b) =>
304
- a.moduleSpecifier < b.moduleSpecifier ? -1 : 1
305
- );
256
+ importStructures.sort((a, b) => (a.moduleSpecifier < b.moduleSpecifier ? -1 : 1));
306
257
  file.addImportDeclarations(importStructures);
307
258
  }
308
259
  });
@@ -322,7 +273,7 @@ class BinderImp implements Binder {
322
273
  file: SourceFile,
323
274
  dependencyByPlaceholder: Map<string, ReferenceableSymbol>,
324
275
  presentPlaceholders: Set<string>,
325
- replacementMap: Map<string, string>
276
+ replacementMap: Map<string, string>,
326
277
  ) {
327
278
  for (const [placeholder, dependency] of dependencyByPlaceholder) {
328
279
  if (!presentPlaceholders.has(placeholder)) {
@@ -346,17 +297,11 @@ class BinderImp implements Binder {
346
297
  */
347
298
  private resolveDeclarationReferences(
348
299
  file: SourceFile,
349
- declarationByPlaceholder: Map<
350
- string,
351
- [unknown, DeclarationInfo | StaticHelperMetadata]
352
- >,
300
+ declarationByPlaceholder: Map<string, [unknown, DeclarationInfo | StaticHelperMetadata]>,
353
301
  presentPlaceholders: Set<string>,
354
- replacementMap: Map<string, string>
302
+ replacementMap: Map<string, string>,
355
303
  ) {
356
- for (const [
357
- placeholderKey,
358
- [declarationKey, declaration]
359
- ] of declarationByPlaceholder) {
304
+ for (const [placeholderKey, [declarationKey, declaration]] of declarationByPlaceholder) {
360
305
  if (!presentPlaceholders.has(placeholderKey)) {
361
306
  continue;
362
307
  }
@@ -373,9 +318,7 @@ class BinderImp implements Binder {
373
318
  if (file !== declarationSourceFile) {
374
319
  this.trackReference(declarationKey, file);
375
320
  // Use #platform/ subpath import specifier for static helpers in warp packages
376
- const platformSpecifier = this.getPlatformImportSpecifier(
377
- declarationSourceFile
378
- );
321
+ const platformSpecifier = this.getPlatformImportSpecifier(declarationSourceFile);
379
322
  const importTarget = platformSpecifier ?? declarationSourceFile;
380
323
  const importDec = this.addImport(file, importTarget, name);
381
324
  name = importDec.alias ?? name;
@@ -399,7 +342,7 @@ class BinderImp implements Binder {
399
342
  if (!sourceFile) {
400
343
  // This should be unreachable
401
344
  throw new Error(
402
- `Static helper ${helper.name} does not have a source file. Make sure that loadStaticHelpers has been correctly initialized in index.ts`
345
+ `Static helper ${helper.name} does not have a source file. Make sure that loadStaticHelpers has been correctly initialized in index.ts`,
403
346
  );
404
347
  }
405
348
  const referencedHelper = this.references.get(refkey(helper));
@@ -411,11 +354,9 @@ class BinderImp implements Binder {
411
354
 
412
355
  // Also keep files that are imported by any used helper file
413
356
  const helperFiles = this.project.getSourceFiles(
414
- normalizePath(path.join(sourceRoot, "static-helpers/**/*.*ts"))
415
- );
416
- const usedFiles = helperFiles.filter(
417
- (file) => !isFileUnused(file, usedHelperNames)
357
+ normalizePath(path.join(sourceRoot, "static-helpers/**/*.*ts")),
418
358
  );
359
+ const usedFiles = helperFiles.filter((file) => !isFileUnused(file, usedHelperNames));
419
360
  for (const usedFile of usedFiles) {
420
361
  for (const importDecl of usedFile.getImportDeclarations()) {
421
362
  const resolved = importDecl.getModuleSpecifierSourceFile();
@@ -437,19 +378,14 @@ class BinderImp implements Binder {
437
378
  }
438
379
  this.project
439
380
  //normalizae the final path to adapt to different systems
440
- .getSourceFiles(
441
- normalizePath(path.join(testRoot, "test/generated/util/**/*.*ts"))
442
- )
381
+ .getSourceFiles(normalizePath(path.join(testRoot, "test/generated/util/**/*.*ts")))
443
382
  .filter((file) => isFileUnused(file, usedHelperNames))
444
383
  .forEach((helperFile) => helperFile.delete());
445
384
  }
446
385
  }
447
386
 
448
387
  // Provide the binder context to be used globally
449
- export function provideBinder(
450
- project: Project,
451
- options: BinderOptions = {}
452
- ): Binder {
388
+ export function provideBinder(project: Project, options: BinderOptions = {}): Binder {
453
389
  const binder = new BinderImp(project, options);
454
390
  provideContext("binder", binder);
455
391
  return binder;
@@ -460,7 +396,7 @@ function isFileUnused(file: SourceFile, usedHelperNames: string[]) {
460
396
  // A file is used if it matches a used helper name exactly,
461
397
  // or is a platform-specific variant (e.g. "foo-browser" for helper "foo")
462
398
  return !usedHelperNames.some(
463
- (s) => name === s || name === `${s}-browser` || name === `${s}-react-native`
399
+ (s) => name === s || name === `${s}-browser` || name === `${s}-react-native`,
464
400
  );
465
401
  }
466
402
 
@@ -478,18 +414,12 @@ export function useBinder(): Binder {
478
414
  * @param sourceFile - The source file to mutate.
479
415
  * @param replacementMap - A map from each placeholder string to its replacement value.
480
416
  */
481
- function applyReplacements(
482
- sourceFile: SourceFile,
483
- replacementMap: Map<string, string>
484
- ): void {
417
+ function applyReplacements(sourceFile: SourceFile, replacementMap: Map<string, string>): void {
485
418
  if (replacementMap.size === 0) {
486
419
  return;
487
420
  }
488
421
  const text = sourceFile.getFullText();
489
- const placeholderRegex = new RegExp(
490
- `${escapeRegExp(PLACEHOLDER_PREFIX)}.+?__`,
491
- "g"
492
- );
422
+ const placeholderRegex = new RegExp(`${escapeRegExp(PLACEHOLDER_PREFIX)}.+?__`, "g");
493
423
  let changed = false;
494
424
  const updatedText = text.replace(placeholderRegex, (match) => {
495
425
  const replacement = replacementMap.get(match);
@@ -517,10 +447,7 @@ function collectPlaceholders(sourceFile: SourceFile): Set<string> {
517
447
  return result;
518
448
  }
519
449
  // Refkeys are alphanumeric (see refkey.ts), so `.+?` safely stops at `__`.
520
- const placeholderRegex = new RegExp(
521
- `${escapeRegExp(PLACEHOLDER_PREFIX)}.+?__`,
522
- "g"
523
- );
450
+ const placeholderRegex = new RegExp(`${escapeRegExp(PLACEHOLDER_PREFIX)}.+?__`, "g");
524
451
  let match: RegExpExecArray | null;
525
452
  while ((match = placeholderRegex.exec(text)) !== null) {
526
453
  result.add(match[0]);