@azure-tools/typespec-ts 0.55.0-dev.1 → 0.55.0-dev.2

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 (1002) hide show
  1. package/dist/src/context-manager.d.ts +75 -0
  2. package/dist/src/context-manager.d.ts.map +1 -0
  3. package/dist/src/context-manager.js +59 -0
  4. package/dist/src/context-manager.js.map +1 -0
  5. package/dist/src/framework/hooks/binder.js +3 -3
  6. package/dist/src/framework/hooks/binder.js.map +1 -1
  7. package/dist/src/framework/hooks/sdk-types.d.ts +26 -0
  8. package/dist/src/framework/hooks/sdk-types.d.ts.map +1 -0
  9. package/dist/src/framework/hooks/sdk-types.js +157 -0
  10. package/dist/src/framework/hooks/sdk-types.js.map +1 -0
  11. package/dist/src/framework/hooks/use-dependencies.d.ts +4 -0
  12. package/dist/src/framework/hooks/use-dependencies.d.ts.map +1 -0
  13. package/dist/src/framework/hooks/use-dependencies.js +13 -0
  14. package/dist/src/framework/hooks/use-dependencies.js.map +1 -0
  15. package/dist/src/index.js +23 -23
  16. package/dist/src/index.js.map +1 -1
  17. package/dist/src/meta-tree.d.ts +7 -0
  18. package/dist/src/meta-tree.d.ts.map +1 -0
  19. package/dist/src/meta-tree.js +2 -0
  20. package/dist/src/meta-tree.js.map +1 -0
  21. package/dist/src/modular/build-classical-client.d.ts +6 -0
  22. package/dist/src/modular/build-classical-client.d.ts.map +1 -0
  23. package/dist/src/modular/build-classical-client.js +345 -0
  24. package/dist/src/modular/build-classical-client.js.map +1 -0
  25. package/dist/src/modular/build-classical-operation-groups.d.ts +6 -0
  26. package/dist/src/modular/build-classical-operation-groups.d.ts.map +1 -0
  27. package/dist/src/modular/build-classical-operation-groups.js +48 -0
  28. package/dist/src/modular/build-classical-operation-groups.js.map +1 -0
  29. package/dist/src/modular/build-client-context.d.ts +13 -0
  30. package/dist/src/modular/build-client-context.d.ts.map +1 -0
  31. package/dist/src/modular/build-client-context.js +246 -0
  32. package/dist/src/modular/build-client-context.js.map +1 -0
  33. package/dist/src/modular/build-modular-options.d.ts +6 -0
  34. package/dist/src/modular/build-modular-options.d.ts.map +1 -0
  35. package/dist/src/modular/build-modular-options.js +14 -0
  36. package/dist/src/modular/build-modular-options.js.map +1 -0
  37. package/dist/src/modular/build-operations.d.ts +21 -0
  38. package/dist/src/modular/build-operations.d.ts.map +1 -0
  39. package/dist/src/modular/build-operations.js +172 -0
  40. package/dist/src/modular/build-operations.js.map +1 -0
  41. package/dist/src/modular/build-project-files.d.ts +4 -0
  42. package/dist/src/modular/build-project-files.d.ts.map +1 -0
  43. package/dist/src/modular/build-project-files.js +91 -0
  44. package/dist/src/modular/build-project-files.js.map +1 -0
  45. package/dist/src/modular/build-restore-poller.d.ts +5 -0
  46. package/dist/src/modular/build-restore-poller.d.ts.map +1 -0
  47. package/dist/src/modular/build-restore-poller.js +216 -0
  48. package/dist/src/modular/build-restore-poller.js.map +1 -0
  49. package/dist/src/modular/build-root-index.d.ts +13 -0
  50. package/dist/src/modular/build-root-index.d.ts.map +1 -0
  51. package/dist/src/modular/build-root-index.js +279 -0
  52. package/dist/src/modular/build-root-index.js.map +1 -0
  53. package/dist/src/modular/build-subpath-index.d.ts +16 -0
  54. package/dist/src/modular/build-subpath-index.d.ts.map +1 -0
  55. package/dist/src/modular/build-subpath-index.js +119 -0
  56. package/dist/src/modular/build-subpath-index.js.map +1 -0
  57. package/dist/src/modular/emit-logger-file.d.ts +3 -0
  58. package/dist/src/modular/emit-logger-file.d.ts.map +1 -0
  59. package/dist/src/modular/emit-logger-file.js +18 -0
  60. package/dist/src/modular/emit-logger-file.js.map +1 -0
  61. package/dist/src/modular/emit-models-options.d.ts +5 -0
  62. package/dist/src/modular/emit-models-options.d.ts.map +1 -0
  63. package/dist/src/modular/emit-models-options.js +35 -0
  64. package/dist/src/modular/emit-models-options.js.map +1 -0
  65. package/dist/src/modular/emit-models.d.ts +23 -0
  66. package/dist/src/modular/emit-models.d.ts.map +1 -0
  67. package/dist/src/modular/emit-models.js +850 -0
  68. package/dist/src/modular/emit-models.js.map +1 -0
  69. package/dist/src/modular/emit-samples.d.ts +7 -0
  70. package/dist/src/modular/emit-samples.d.ts.map +1 -0
  71. package/dist/src/modular/emit-samples.js +500 -0
  72. package/dist/src/modular/emit-samples.js.map +1 -0
  73. package/dist/src/modular/emit-tests.d.ts +7 -0
  74. package/dist/src/modular/emit-tests.d.ts.map +1 -0
  75. package/dist/src/modular/emit-tests.js +155 -0
  76. package/dist/src/modular/emit-tests.js.map +1 -0
  77. package/dist/src/modular/helpers/classical-operation-helpers.d.ts +7 -0
  78. package/dist/src/modular/helpers/classical-operation-helpers.d.ts.map +1 -0
  79. package/dist/src/modular/helpers/classical-operation-helpers.js +258 -0
  80. package/dist/src/modular/helpers/classical-operation-helpers.js.map +1 -0
  81. package/dist/src/modular/helpers/client-helpers.d.ts +34 -0
  82. package/dist/src/modular/helpers/client-helpers.d.ts.map +1 -0
  83. package/dist/src/modular/helpers/client-helpers.js +259 -0
  84. package/dist/src/modular/helpers/client-helpers.js.map +1 -0
  85. package/dist/src/modular/helpers/client-option-helpers.d.ts +43 -0
  86. package/dist/src/modular/helpers/client-option-helpers.d.ts.map +1 -0
  87. package/dist/src/modular/helpers/client-option-helpers.js +103 -0
  88. package/dist/src/modular/helpers/client-option-helpers.js.map +1 -0
  89. package/dist/src/modular/helpers/docs-helpers.d.ts +3 -0
  90. package/dist/src/modular/helpers/docs-helpers.d.ts.map +1 -0
  91. package/dist/src/modular/helpers/docs-helpers.js +10 -0
  92. package/dist/src/modular/helpers/docs-helpers.js.map +1 -0
  93. package/dist/src/modular/helpers/example-value-helpers.d.ts +83 -0
  94. package/dist/src/modular/helpers/example-value-helpers.d.ts.map +1 -0
  95. package/dist/src/modular/helpers/example-value-helpers.js +639 -0
  96. package/dist/src/modular/helpers/example-value-helpers.js.map +1 -0
  97. package/dist/src/modular/helpers/naming-helpers.d.ts +22 -0
  98. package/dist/src/modular/helpers/naming-helpers.d.ts.map +1 -0
  99. package/dist/src/modular/helpers/naming-helpers.js +59 -0
  100. package/dist/src/modular/helpers/naming-helpers.js.map +1 -0
  101. package/dist/src/modular/helpers/operation-helpers.d.ts +105 -0
  102. package/dist/src/modular/helpers/operation-helpers.d.ts.map +1 -0
  103. package/dist/src/modular/helpers/operation-helpers.js +2328 -0
  104. package/dist/src/modular/helpers/operation-helpers.js.map +1 -0
  105. package/dist/src/modular/helpers/type-helpers.d.ts +22 -0
  106. package/dist/src/modular/helpers/type-helpers.d.ts.map +1 -0
  107. package/dist/src/modular/helpers/type-helpers.js +94 -0
  108. package/dist/src/modular/helpers/type-helpers.js.map +1 -0
  109. package/dist/src/modular/serialization/build-deserializer-function.d.ts +7 -0
  110. package/dist/src/modular/serialization/build-deserializer-function.d.ts.map +1 -0
  111. package/dist/src/modular/serialization/build-deserializer-function.js +401 -0
  112. package/dist/src/modular/serialization/build-deserializer-function.js.map +1 -0
  113. package/dist/src/modular/serialization/build-serializer-function.d.ts +7 -0
  114. package/dist/src/modular/serialization/build-serializer-function.d.ts.map +1 -0
  115. package/dist/src/modular/serialization/build-serializer-function.js +442 -0
  116. package/dist/src/modular/serialization/build-serializer-function.js.map +1 -0
  117. package/dist/src/modular/serialization/build-xml-serializer-function.d.ts +44 -0
  118. package/dist/src/modular/serialization/build-xml-serializer-function.d.ts.map +1 -0
  119. package/dist/src/modular/serialization/build-xml-serializer-function.js +729 -0
  120. package/dist/src/modular/serialization/build-xml-serializer-function.js.map +1 -0
  121. package/dist/src/modular/serialization/serialize-utils.d.ts +37 -0
  122. package/dist/src/modular/serialization/serialize-utils.d.ts.map +1 -0
  123. package/dist/src/modular/serialization/serialize-utils.js +145 -0
  124. package/dist/src/modular/serialization/serialize-utils.js.map +1 -0
  125. package/dist/src/modular/type-expressions/get-credential-expression.js +1 -1
  126. package/dist/src/modular/type-expressions/get-credential-expression.js.map +1 -1
  127. package/dist/src/modular/type-expressions/get-model-expression.js +1 -1
  128. package/dist/src/modular/type-expressions/get-model-expression.js.map +1 -1
  129. package/dist/src/rlc-common/build-client-definitions.d.ts +6 -0
  130. package/dist/src/rlc-common/build-client-definitions.d.ts.map +1 -0
  131. package/dist/src/rlc-common/build-client-definitions.js +157 -0
  132. package/dist/src/rlc-common/build-client-definitions.js.map +1 -0
  133. package/dist/src/rlc-common/build-client.d.ts +9 -0
  134. package/dist/src/rlc-common/build-client.d.ts.map +1 -0
  135. package/dist/src/rlc-common/build-client.js +391 -0
  136. package/dist/src/rlc-common/build-client.js.map +1 -0
  137. package/dist/src/rlc-common/build-index-file.d.ts +6 -0
  138. package/dist/src/rlc-common/build-index-file.d.ts.map +1 -0
  139. package/dist/src/rlc-common/build-index-file.js +241 -0
  140. package/dist/src/rlc-common/build-index-file.js.map +1 -0
  141. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts +6 -0
  142. package/dist/src/rlc-common/build-is-unexpected-helper.d.ts.map +1 -0
  143. package/dist/src/rlc-common/build-is-unexpected-helper.js +223 -0
  144. package/dist/src/rlc-common/build-is-unexpected-helper.js.map +1 -0
  145. package/dist/src/rlc-common/build-logger.d.ts +6 -0
  146. package/dist/src/rlc-common/build-logger.d.ts.map +1 -0
  147. package/dist/src/rlc-common/build-logger.js +31 -0
  148. package/dist/src/rlc-common/build-logger.js.map +1 -0
  149. package/dist/src/rlc-common/build-method-shortcuts.d.ts +5 -0
  150. package/dist/src/rlc-common/build-method-shortcuts.d.ts.map +1 -0
  151. package/dist/src/rlc-common/build-method-shortcuts.js +54 -0
  152. package/dist/src/rlc-common/build-method-shortcuts.js.map +1 -0
  153. package/dist/src/rlc-common/build-object-types.d.ts +29 -0
  154. package/dist/src/rlc-common/build-object-types.d.ts.map +1 -0
  155. package/dist/src/rlc-common/build-object-types.js +412 -0
  156. package/dist/src/rlc-common/build-object-types.js.map +1 -0
  157. package/dist/src/rlc-common/build-paginate-helper.d.ts +6 -0
  158. package/dist/src/rlc-common/build-paginate-helper.d.ts.map +1 -0
  159. package/dist/src/rlc-common/build-paginate-helper.js +27 -0
  160. package/dist/src/rlc-common/build-paginate-helper.js.map +1 -0
  161. package/dist/src/rlc-common/build-parameter-types.d.ts +14 -0
  162. package/dist/src/rlc-common/build-parameter-types.d.ts.map +1 -0
  163. package/dist/src/rlc-common/build-parameter-types.js +391 -0
  164. package/dist/src/rlc-common/build-parameter-types.js.map +1 -0
  165. package/dist/src/rlc-common/build-polling-helper.d.ts +6 -0
  166. package/dist/src/rlc-common/build-polling-helper.d.ts.map +1 -0
  167. package/dist/src/rlc-common/build-polling-helper.js +61 -0
  168. package/dist/src/rlc-common/build-polling-helper.js.map +1 -0
  169. package/dist/src/rlc-common/build-response-types.d.ts +6 -0
  170. package/dist/src/rlc-common/build-response-types.d.ts.map +1 -0
  171. package/dist/src/rlc-common/build-response-types.js +143 -0
  172. package/dist/src/rlc-common/build-response-types.js.map +1 -0
  173. package/dist/src/rlc-common/build-samples.d.ts +3 -0
  174. package/dist/src/rlc-common/build-samples.d.ts.map +1 -0
  175. package/dist/src/rlc-common/build-samples.js +30 -0
  176. package/dist/src/rlc-common/build-samples.js.map +1 -0
  177. package/dist/src/rlc-common/build-schema-type.d.ts +20 -0
  178. package/dist/src/rlc-common/build-schema-type.d.ts.map +1 -0
  179. package/dist/src/rlc-common/build-schema-type.js +71 -0
  180. package/dist/src/rlc-common/build-schema-type.js.map +1 -0
  181. package/dist/src/rlc-common/build-serialize-helper.d.ts +6 -0
  182. package/dist/src/rlc-common/build-serialize-helper.d.ts.map +1 -0
  183. package/dist/src/rlc-common/build-serialize-helper.js +36 -0
  184. package/dist/src/rlc-common/build-serialize-helper.js.map +1 -0
  185. package/dist/src/rlc-common/build-top-level-index-file.d.ts +6 -0
  186. package/dist/src/rlc-common/build-top-level-index-file.d.ts.map +1 -0
  187. package/dist/src/rlc-common/build-top-level-index-file.js +48 -0
  188. package/dist/src/rlc-common/build-top-level-index-file.js.map +1 -0
  189. package/dist/src/rlc-common/helpers/api-version-util.d.ts +17 -0
  190. package/dist/src/rlc-common/helpers/api-version-util.d.ts.map +1 -0
  191. package/dist/src/rlc-common/helpers/api-version-util.js +43 -0
  192. package/dist/src/rlc-common/helpers/api-version-util.js.map +1 -0
  193. package/dist/src/rlc-common/helpers/imports-util.d.ts +18 -0
  194. package/dist/src/rlc-common/helpers/imports-util.d.ts.map +1 -0
  195. package/dist/src/rlc-common/helpers/imports-util.js +164 -0
  196. package/dist/src/rlc-common/helpers/imports-util.js.map +1 -0
  197. package/dist/src/rlc-common/helpers/name-constructors.d.ts +42 -0
  198. package/dist/src/rlc-common/helpers/name-constructors.d.ts.map +1 -0
  199. package/dist/src/rlc-common/helpers/name-constructors.js +61 -0
  200. package/dist/src/rlc-common/helpers/name-constructors.js.map +1 -0
  201. package/dist/src/rlc-common/helpers/name-utils.d.ts +37 -0
  202. package/dist/src/rlc-common/helpers/name-utils.d.ts.map +1 -0
  203. package/dist/src/rlc-common/helpers/name-utils.js +240 -0
  204. package/dist/src/rlc-common/helpers/name-utils.js.map +1 -0
  205. package/dist/src/rlc-common/helpers/operation-helpers.d.ts +16 -0
  206. package/dist/src/rlc-common/helpers/operation-helpers.d.ts.map +1 -0
  207. package/dist/src/rlc-common/helpers/operation-helpers.js +104 -0
  208. package/dist/src/rlc-common/helpers/operation-helpers.js.map +1 -0
  209. package/dist/src/rlc-common/helpers/package-util.d.ts +7 -0
  210. package/dist/src/rlc-common/helpers/package-util.d.ts.map +1 -0
  211. package/dist/src/rlc-common/helpers/package-util.js +10 -0
  212. package/dist/src/rlc-common/helpers/package-util.js.map +1 -0
  213. package/dist/src/rlc-common/helpers/path-utils.d.ts +2 -0
  214. package/dist/src/rlc-common/helpers/path-utils.d.ts.map +1 -0
  215. package/dist/src/rlc-common/helpers/path-utils.js +10 -0
  216. package/dist/src/rlc-common/helpers/path-utils.js.map +1 -0
  217. package/dist/src/rlc-common/helpers/schema-helpers.d.ts +10 -0
  218. package/dist/src/rlc-common/helpers/schema-helpers.d.ts.map +1 -0
  219. package/dist/src/rlc-common/helpers/schema-helpers.js +37 -0
  220. package/dist/src/rlc-common/helpers/schema-helpers.js.map +1 -0
  221. package/dist/src/rlc-common/helpers/shortcut-methods.d.ts +4 -0
  222. package/dist/src/rlc-common/helpers/shortcut-methods.d.ts.map +1 -0
  223. package/dist/src/rlc-common/helpers/shortcut-methods.js +49 -0
  224. package/dist/src/rlc-common/helpers/shortcut-methods.js.map +1 -0
  225. package/dist/src/rlc-common/helpers/type-util.d.ts +32 -0
  226. package/dist/src/rlc-common/helpers/type-util.d.ts.map +1 -0
  227. package/dist/src/rlc-common/helpers/type-util.js +162 -0
  228. package/dist/src/rlc-common/helpers/type-util.js.map +1 -0
  229. package/dist/src/rlc-common/helpers/value-generation-util.d.ts +12 -0
  230. package/dist/src/rlc-common/helpers/value-generation-util.d.ts.map +1 -0
  231. package/dist/src/rlc-common/helpers/value-generation-util.js +161 -0
  232. package/dist/src/rlc-common/helpers/value-generation-util.js.map +1 -0
  233. package/dist/src/rlc-common/index.d.ts +39 -39
  234. package/dist/src/rlc-common/index.d.ts.map +1 -1
  235. package/dist/src/rlc-common/index.js +39 -39
  236. package/dist/src/rlc-common/index.js.map +1 -1
  237. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts +6 -0
  238. package/dist/src/rlc-common/metadata/build-api-extractor-config.d.ts.map +1 -0
  239. package/dist/src/rlc-common/metadata/build-api-extractor-config.js +55 -0
  240. package/dist/src/rlc-common/metadata/build-api-extractor-config.js.map +1 -0
  241. package/dist/src/rlc-common/metadata/build-changelog-file.d.ts +6 -0
  242. package/dist/src/rlc-common/metadata/build-changelog-file.d.ts.map +1 -0
  243. package/dist/src/rlc-common/metadata/build-changelog-file.js +25 -0
  244. package/dist/src/rlc-common/metadata/build-changelog-file.js.map +1 -0
  245. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts +6 -0
  246. package/dist/src/rlc-common/metadata/build-es-lint-config.d.ts.map +1 -0
  247. package/dist/src/rlc-common/metadata/build-es-lint-config.js +79 -0
  248. package/dist/src/rlc-common/metadata/build-es-lint-config.js.map +1 -0
  249. package/dist/src/rlc-common/metadata/build-license-file.d.ts +5 -0
  250. package/dist/src/rlc-common/metadata/build-license-file.d.ts.map +1 -0
  251. package/dist/src/rlc-common/metadata/build-license-file.js +32 -0
  252. package/dist/src/rlc-common/metadata/build-license-file.js.map +1 -0
  253. package/dist/src/rlc-common/metadata/build-package-file.d.ts +25 -0
  254. package/dist/src/rlc-common/metadata/build-package-file.d.ts.map +1 -0
  255. package/dist/src/rlc-common/metadata/build-package-file.js +197 -0
  256. package/dist/src/rlc-common/metadata/build-package-file.js.map +1 -0
  257. package/dist/src/rlc-common/metadata/build-readme-file.d.ts +11 -0
  258. package/dist/src/rlc-common/metadata/build-readme-file.d.ts.map +1 -0
  259. package/dist/src/rlc-common/metadata/build-readme-file.js +418 -0
  260. package/dist/src/rlc-common/metadata/build-readme-file.js.map +1 -0
  261. package/dist/src/rlc-common/metadata/build-rollup-config.d.ts +6 -0
  262. package/dist/src/rlc-common/metadata/build-rollup-config.d.ts.map +1 -0
  263. package/dist/src/rlc-common/metadata/build-rollup-config.js +140 -0
  264. package/dist/src/rlc-common/metadata/build-rollup-config.js.map +1 -0
  265. package/dist/src/rlc-common/metadata/build-sample-env-file.d.ts +6 -0
  266. package/dist/src/rlc-common/metadata/build-sample-env-file.d.ts.map +1 -0
  267. package/dist/src/rlc-common/metadata/build-sample-env-file.js +15 -0
  268. package/dist/src/rlc-common/metadata/build-sample-env-file.js.map +1 -0
  269. package/dist/src/rlc-common/metadata/build-test-config.d.ts +16 -0
  270. package/dist/src/rlc-common/metadata/build-test-config.d.ts.map +1 -0
  271. package/dist/src/rlc-common/metadata/build-test-config.js +54 -0
  272. package/dist/src/rlc-common/metadata/build-test-config.js.map +1 -0
  273. package/dist/src/rlc-common/metadata/build-ts-config.d.ts +61 -0
  274. package/dist/src/rlc-common/metadata/build-ts-config.d.ts.map +1 -0
  275. package/dist/src/rlc-common/metadata/build-ts-config.js +170 -0
  276. package/dist/src/rlc-common/metadata/build-ts-config.js.map +1 -0
  277. package/dist/src/rlc-common/metadata/build-vitest-config.d.ts +6 -0
  278. package/dist/src/rlc-common/metadata/build-vitest-config.d.ts.map +1 -0
  279. package/dist/src/rlc-common/metadata/build-vitest-config.js +26 -0
  280. package/dist/src/rlc-common/metadata/build-vitest-config.js.map +1 -0
  281. package/dist/src/rlc-common/metadata/build-warp-config.d.ts +20 -0
  282. package/dist/src/rlc-common/metadata/build-warp-config.d.ts.map +1 -0
  283. package/dist/src/rlc-common/metadata/build-warp-config.js +76 -0
  284. package/dist/src/rlc-common/metadata/build-warp-config.js.map +1 -0
  285. package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts +51 -0
  286. package/dist/src/rlc-common/metadata/package-json/azure-package-common.d.ts.map +1 -0
  287. package/dist/src/rlc-common/metadata/package-json/azure-package-common.js +121 -0
  288. package/dist/src/rlc-common/metadata/package-json/azure-package-common.js.map +1 -0
  289. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts +242 -0
  290. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.d.ts.map +1 -0
  291. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js +171 -0
  292. package/dist/src/rlc-common/metadata/package-json/build-azure-monorepo-package.js.map +1 -0
  293. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts +8 -0
  294. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.d.ts.map +1 -0
  295. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js +101 -0
  296. package/dist/src/rlc-common/metadata/package-json/build-azure-standalone-package.js.map +1 -0
  297. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.d.ts +57 -0
  298. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.d.ts.map +1 -0
  299. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.js +53 -0
  300. package/dist/src/rlc-common/metadata/package-json/build-flavorless-package.js.map +1 -0
  301. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts +64 -0
  302. package/dist/src/rlc-common/metadata/package-json/package-common.d.ts.map +1 -0
  303. package/dist/src/rlc-common/metadata/package-json/package-common.js +180 -0
  304. package/dist/src/rlc-common/metadata/package-json/package-common.js.map +1 -0
  305. package/dist/src/rlc-common/static/paginate-content.d.ts +2 -0
  306. package/dist/src/rlc-common/static/paginate-content.d.ts.map +1 -0
  307. package/dist/src/rlc-common/static/paginate-content.js +345 -0
  308. package/dist/src/rlc-common/static/paginate-content.js.map +1 -0
  309. package/dist/src/rlc-common/static/polling-content.d.ts +2 -0
  310. package/dist/src/rlc-common/static/polling-content.d.ts.map +1 -0
  311. package/dist/src/rlc-common/static/polling-content.js +225 -0
  312. package/dist/src/rlc-common/static/polling-content.js.map +1 -0
  313. package/dist/src/rlc-common/static/sample-template.d.ts +2 -0
  314. package/dist/src/rlc-common/static/sample-template.d.ts.map +1 -0
  315. package/dist/src/rlc-common/static/sample-template.js +56 -0
  316. package/dist/src/rlc-common/static/sample-template.js.map +1 -0
  317. package/dist/src/rlc-common/static/serialize-helper.d.ts +6 -0
  318. package/dist/src/rlc-common/static/serialize-helper.d.ts.map +1 -0
  319. package/dist/src/rlc-common/static/serialize-helper.js +31 -0
  320. package/dist/src/rlc-common/static/serialize-helper.js.map +1 -0
  321. package/dist/src/rlc-common/test/build-karma-config.d.ts +6 -0
  322. package/dist/src/rlc-common/test/build-karma-config.d.ts.map +1 -0
  323. package/dist/src/rlc-common/test/build-karma-config.js +11 -0
  324. package/dist/src/rlc-common/test/build-karma-config.js.map +1 -0
  325. package/dist/src/rlc-common/test/build-recorded-client.d.ts +6 -0
  326. package/dist/src/rlc-common/test/build-recorded-client.d.ts.map +1 -0
  327. package/dist/src/rlc-common/test/build-recorded-client.js +17 -0
  328. package/dist/src/rlc-common/test/build-recorded-client.js.map +1 -0
  329. package/dist/src/rlc-common/test/build-sample-test.d.ts +6 -0
  330. package/dist/src/rlc-common/test/build-sample-test.d.ts.map +1 -0
  331. package/dist/src/rlc-common/test/build-sample-test.js +14 -0
  332. package/dist/src/rlc-common/test/build-sample-test.js.map +1 -0
  333. package/dist/src/rlc-common/test/build-snippets.d.ts +6 -0
  334. package/dist/src/rlc-common/test/build-snippets.d.ts.map +1 -0
  335. package/dist/src/rlc-common/test/build-snippets.js +26 -0
  336. package/dist/src/rlc-common/test/build-snippets.js.map +1 -0
  337. package/dist/src/rlc-common/transform-sample-groups.d.ts +9 -0
  338. package/dist/src/rlc-common/transform-sample-groups.d.ts.map +1 -0
  339. package/dist/src/rlc-common/transform-sample-groups.js +313 -0
  340. package/dist/src/rlc-common/transform-sample-groups.js.map +1 -0
  341. package/dist/src/transform/transform-api-version-info.d.ts +6 -0
  342. package/dist/src/transform/transform-api-version-info.d.ts.map +1 -0
  343. package/dist/src/transform/transform-api-version-info.js +78 -0
  344. package/dist/src/transform/transform-api-version-info.js.map +1 -0
  345. package/dist/src/transform/transform-helper-function-details.d.ts +5 -0
  346. package/dist/src/transform/transform-helper-function-details.d.ts.map +1 -0
  347. package/dist/src/transform/transform-helper-function-details.js +74 -0
  348. package/dist/src/transform/transform-helper-function-details.js.map +1 -0
  349. package/dist/src/transform/transform-parameters.d.ts +14 -0
  350. package/dist/src/transform/transform-parameters.d.ts.map +1 -0
  351. package/dist/src/transform/transform-parameters.js +201 -0
  352. package/dist/src/transform/transform-parameters.js.map +1 -0
  353. package/dist/src/transform/transform-paths.d.ts +5 -0
  354. package/dist/src/transform/transform-paths.d.ts.map +1 -0
  355. package/dist/src/transform/transform-paths.js +102 -0
  356. package/dist/src/transform/transform-paths.js.map +1 -0
  357. package/dist/src/transform/transform-responses.d.ts +5 -0
  358. package/dist/src/transform/transform-responses.d.ts.map +1 -0
  359. package/dist/src/transform/transform-responses.js +171 -0
  360. package/dist/src/transform/transform-responses.js.map +1 -0
  361. package/dist/src/transform/transform-schemas.d.ts +4 -0
  362. package/dist/src/transform/transform-schemas.d.ts.map +1 -0
  363. package/dist/src/transform/transform-schemas.js +191 -0
  364. package/dist/src/transform/transform-schemas.js.map +1 -0
  365. package/dist/src/transform/transform-telemetry-info.d.ts +4 -0
  366. package/dist/src/transform/transform-telemetry-info.d.ts.map +1 -0
  367. package/dist/src/transform/transform-telemetry-info.js +22 -0
  368. package/dist/src/transform/transform-telemetry-info.js.map +1 -0
  369. package/dist/src/transform/transform.js +10 -10
  370. package/dist/src/transform/transform.js.map +1 -1
  371. package/dist/src/transform/transfrom-rlc-options.d.ts +14 -0
  372. package/dist/src/transform/transfrom-rlc-options.d.ts.map +1 -0
  373. package/dist/src/transform/transfrom-rlc-options.js +369 -0
  374. package/dist/src/transform/transfrom-rlc-options.js.map +1 -0
  375. package/dist/src/utils/client-utils.d.ts +10 -0
  376. package/dist/src/utils/client-utils.d.ts.map +1 -0
  377. package/dist/src/utils/client-utils.js +124 -0
  378. package/dist/src/utils/client-utils.js.map +1 -0
  379. package/dist/src/utils/credential-utils.d.ts +15 -0
  380. package/dist/src/utils/credential-utils.d.ts.map +1 -0
  381. package/dist/src/utils/credential-utils.js +68 -0
  382. package/dist/src/utils/credential-utils.js.map +1 -0
  383. package/dist/src/utils/cross-language-def.d.ts +6 -0
  384. package/dist/src/utils/cross-language-def.d.ts.map +1 -0
  385. package/dist/src/utils/cross-language-def.js +59 -0
  386. package/dist/src/utils/cross-language-def.js.map +1 -0
  387. package/dist/src/utils/emit-util.d.ts +5 -0
  388. package/dist/src/utils/emit-util.d.ts.map +1 -0
  389. package/dist/src/utils/emit-util.js +71 -0
  390. package/dist/src/utils/emit-util.js.map +1 -0
  391. package/dist/src/utils/file-system-utils.d.ts +5 -0
  392. package/dist/src/utils/file-system-utils.d.ts.map +1 -0
  393. package/dist/src/utils/file-system-utils.js +59 -0
  394. package/dist/src/utils/file-system-utils.js.map +1 -0
  395. package/dist/src/utils/import-helper.d.ts +10 -0
  396. package/dist/src/utils/import-helper.d.ts.map +1 -0
  397. package/dist/src/utils/import-helper.js +51 -0
  398. package/dist/src/utils/import-helper.js.map +1 -0
  399. package/dist/src/utils/interfaces.d.ts +1 -1
  400. package/dist/src/utils/interfaces.d.ts.map +1 -1
  401. package/dist/src/utils/media-types.d.ts +28 -0
  402. package/dist/src/utils/media-types.d.ts.map +1 -0
  403. package/dist/src/utils/media-types.js +124 -0
  404. package/dist/src/utils/media-types.js.map +1 -0
  405. package/dist/src/utils/model-utils.d.ts +60 -0
  406. package/dist/src/utils/model-utils.d.ts.map +1 -0
  407. package/dist/src/utils/model-utils.js +1480 -0
  408. package/dist/src/utils/model-utils.js.map +1 -0
  409. package/dist/src/utils/namespace-utils.d.ts +6 -0
  410. package/dist/src/utils/namespace-utils.d.ts.map +1 -0
  411. package/dist/src/utils/namespace-utils.js +69 -0
  412. package/dist/src/utils/namespace-utils.js.map +1 -0
  413. package/dist/src/utils/operation-util.d.ts +97 -0
  414. package/dist/src/utils/operation-util.d.ts.map +1 -0
  415. package/dist/src/utils/operation-util.js +547 -0
  416. package/dist/src/utils/operation-util.js.map +1 -0
  417. package/dist/src/utils/parameter-utils.d.ts +9 -0
  418. package/dist/src/utils/parameter-utils.d.ts.map +1 -0
  419. package/dist/src/utils/parameter-utils.js +147 -0
  420. package/dist/src/utils/parameter-utils.js.map +1 -0
  421. package/dist/tsconfig.tsbuildinfo +1 -1
  422. package/package.json +3 -7
  423. package/src/context-manager.ts +101 -0
  424. package/src/framework/hooks/binder.ts +3 -3
  425. package/src/framework/hooks/sdk-types.ts +218 -0
  426. package/src/framework/hooks/use-dependencies.ts +16 -0
  427. package/src/index.ts +23 -23
  428. package/src/modular/build-classical-client.ts +434 -0
  429. package/src/modular/build-classical-operation-groups.ts +69 -0
  430. package/src/modular/build-client-context.ts +325 -0
  431. package/src/modular/build-operations.ts +248 -0
  432. package/src/modular/build-project-files.ts +111 -0
  433. package/src/modular/build-restore-poller.ts +242 -0
  434. package/src/modular/build-root-index.ts +407 -0
  435. package/src/modular/build-subpath-index.ts +152 -0
  436. package/src/modular/emit-logger-file.ts +23 -0
  437. package/src/modular/emit-models-options.ts +56 -0
  438. package/src/modular/emit-models.ts +1081 -0
  439. package/src/modular/emit-samples.ts +675 -0
  440. package/src/modular/emit-tests.ts +194 -0
  441. package/src/modular/helpers/classical-operation-helpers.ts +375 -0
  442. package/src/modular/helpers/client-helpers.ts +362 -0
  443. package/src/modular/helpers/example-value-helpers.ts +851 -0
  444. package/src/modular/helpers/naming-helpers.ts +84 -0
  445. package/src/modular/helpers/operation-helpers.ts +3035 -0
  446. package/src/modular/helpers/type-helpers.ts +134 -0
  447. package/src/modular/serialization/build-deserializer-function.ts +564 -0
  448. package/src/modular/serialization/build-serializer-function.ts +614 -0
  449. package/src/modular/serialization/build-xml-serializer-function.ts +951 -0
  450. package/src/modular/serialization/serialize-utils.ts +217 -0
  451. package/src/modular/type-expressions/get-credential-expression.ts +1 -1
  452. package/src/modular/type-expressions/get-model-expression.ts +1 -1
  453. package/src/rlc-common/build-client-definitions.ts +235 -0
  454. package/src/rlc-common/build-client.ts +490 -0
  455. package/src/rlc-common/build-index-file.ts +344 -0
  456. package/src/rlc-common/build-is-unexpected-helper.ts +248 -0
  457. package/src/rlc-common/build-logger.ts +43 -0
  458. package/src/rlc-common/build-method-shortcuts.ts +71 -0
  459. package/src/rlc-common/build-object-types.ts +603 -0
  460. package/src/rlc-common/build-paginate-helper.ts +31 -0
  461. package/src/rlc-common/build-parameter-types.ts +554 -0
  462. package/src/rlc-common/build-polling-helper.ts +83 -0
  463. package/src/rlc-common/build-response-types.ts +180 -0
  464. package/src/rlc-common/build-samples.ts +32 -0
  465. package/src/rlc-common/build-schema-type.ts +89 -0
  466. package/src/rlc-common/build-serialize-helper.ts +49 -0
  467. package/src/rlc-common/build-top-level-index-file.ts +58 -0
  468. package/src/rlc-common/helpers/name-constructors.ts +110 -0
  469. package/src/rlc-common/helpers/operation-helpers.ts +138 -0
  470. package/src/rlc-common/helpers/shortcut-methods.ts +58 -0
  471. package/src/rlc-common/helpers/value-generation-util.ts +234 -0
  472. package/src/rlc-common/index.ts +39 -39
  473. package/src/rlc-common/metadata/build-package-file.ts +242 -0
  474. package/src/rlc-common/metadata/build-readme-file.ts +515 -0
  475. package/src/rlc-common/metadata/build-rollup-config.ts +147 -0
  476. package/src/rlc-common/metadata/package-json/azure-package-common.ts +152 -0
  477. package/src/rlc-common/metadata/package-json/build-azure-monorepo-package.ts +199 -0
  478. package/src/rlc-common/metadata/package-json/build-azure-standalone-package.ts +123 -0
  479. package/src/rlc-common/metadata/package-json/build-flavorless-package.ts +68 -0
  480. package/src/rlc-common/test/build-snippets.ts +29 -0
  481. package/src/rlc-common/transform-sample-groups.ts +407 -0
  482. package/src/transform/transform-api-version-info.ts +103 -0
  483. package/src/transform/transform-helper-function-details.ts +88 -0
  484. package/src/transform/transform-parameters.ts +321 -0
  485. package/src/transform/transform-paths.ts +157 -0
  486. package/src/transform/transform-responses.ts +237 -0
  487. package/src/transform/transform-schemas.ts +212 -0
  488. package/src/transform/transform-telemetry-info.ts +33 -0
  489. package/src/transform/transform.ts +10 -10
  490. package/src/transform/transfrom-rlc-options.ts +461 -0
  491. package/src/utils/cross-language-def.ts +66 -0
  492. package/src/utils/import-helper.ts +59 -0
  493. package/src/utils/interfaces.ts +1 -1
  494. package/src/utils/model-utils.ts +1727 -0
  495. package/src/utils/operation-util.ts +763 -0
  496. package/src/utils/parameter-utils.ts +192 -0
  497. package/static/static-helpers/serialization/serializers.ts +1 -0
  498. package/dist/src/contextManager.d.ts +0 -75
  499. package/dist/src/contextManager.d.ts.map +0 -1
  500. package/dist/src/contextManager.js +0 -59
  501. package/dist/src/contextManager.js.map +0 -1
  502. package/dist/src/framework/hooks/sdkTypes.d.ts +0 -26
  503. package/dist/src/framework/hooks/sdkTypes.d.ts.map +0 -1
  504. package/dist/src/framework/hooks/sdkTypes.js +0 -157
  505. package/dist/src/framework/hooks/sdkTypes.js.map +0 -1
  506. package/dist/src/framework/hooks/useDependencies.d.ts +0 -4
  507. package/dist/src/framework/hooks/useDependencies.d.ts.map +0 -1
  508. package/dist/src/framework/hooks/useDependencies.js +0 -13
  509. package/dist/src/framework/hooks/useDependencies.js.map +0 -1
  510. package/dist/src/metaTree.d.ts +0 -7
  511. package/dist/src/metaTree.d.ts.map +0 -1
  512. package/dist/src/metaTree.js +0 -2
  513. package/dist/src/metaTree.js.map +0 -1
  514. package/dist/src/modular/buildClassicalClient.d.ts +0 -6
  515. package/dist/src/modular/buildClassicalClient.d.ts.map +0 -1
  516. package/dist/src/modular/buildClassicalClient.js +0 -345
  517. package/dist/src/modular/buildClassicalClient.js.map +0 -1
  518. package/dist/src/modular/buildClassicalOperationGroups.d.ts +0 -6
  519. package/dist/src/modular/buildClassicalOperationGroups.d.ts.map +0 -1
  520. package/dist/src/modular/buildClassicalOperationGroups.js +0 -48
  521. package/dist/src/modular/buildClassicalOperationGroups.js.map +0 -1
  522. package/dist/src/modular/buildClientContext.d.ts +0 -13
  523. package/dist/src/modular/buildClientContext.d.ts.map +0 -1
  524. package/dist/src/modular/buildClientContext.js +0 -246
  525. package/dist/src/modular/buildClientContext.js.map +0 -1
  526. package/dist/src/modular/buildModularOptions.d.ts +0 -6
  527. package/dist/src/modular/buildModularOptions.d.ts.map +0 -1
  528. package/dist/src/modular/buildModularOptions.js +0 -14
  529. package/dist/src/modular/buildModularOptions.js.map +0 -1
  530. package/dist/src/modular/buildOperations.d.ts +0 -21
  531. package/dist/src/modular/buildOperations.d.ts.map +0 -1
  532. package/dist/src/modular/buildOperations.js +0 -172
  533. package/dist/src/modular/buildOperations.js.map +0 -1
  534. package/dist/src/modular/buildProjectFiles.d.ts +0 -4
  535. package/dist/src/modular/buildProjectFiles.d.ts.map +0 -1
  536. package/dist/src/modular/buildProjectFiles.js +0 -91
  537. package/dist/src/modular/buildProjectFiles.js.map +0 -1
  538. package/dist/src/modular/buildRestorePoller.d.ts +0 -5
  539. package/dist/src/modular/buildRestorePoller.d.ts.map +0 -1
  540. package/dist/src/modular/buildRestorePoller.js +0 -216
  541. package/dist/src/modular/buildRestorePoller.js.map +0 -1
  542. package/dist/src/modular/buildRootIndex.d.ts +0 -13
  543. package/dist/src/modular/buildRootIndex.d.ts.map +0 -1
  544. package/dist/src/modular/buildRootIndex.js +0 -279
  545. package/dist/src/modular/buildRootIndex.js.map +0 -1
  546. package/dist/src/modular/buildSubpathIndex.d.ts +0 -16
  547. package/dist/src/modular/buildSubpathIndex.d.ts.map +0 -1
  548. package/dist/src/modular/buildSubpathIndex.js +0 -119
  549. package/dist/src/modular/buildSubpathIndex.js.map +0 -1
  550. package/dist/src/modular/emitLoggerFile.d.ts +0 -3
  551. package/dist/src/modular/emitLoggerFile.d.ts.map +0 -1
  552. package/dist/src/modular/emitLoggerFile.js +0 -18
  553. package/dist/src/modular/emitLoggerFile.js.map +0 -1
  554. package/dist/src/modular/emitModels.d.ts +0 -23
  555. package/dist/src/modular/emitModels.d.ts.map +0 -1
  556. package/dist/src/modular/emitModels.js +0 -850
  557. package/dist/src/modular/emitModels.js.map +0 -1
  558. package/dist/src/modular/emitModelsOptions.d.ts +0 -5
  559. package/dist/src/modular/emitModelsOptions.d.ts.map +0 -1
  560. package/dist/src/modular/emitModelsOptions.js +0 -35
  561. package/dist/src/modular/emitModelsOptions.js.map +0 -1
  562. package/dist/src/modular/emitSamples.d.ts +0 -7
  563. package/dist/src/modular/emitSamples.d.ts.map +0 -1
  564. package/dist/src/modular/emitSamples.js +0 -500
  565. package/dist/src/modular/emitSamples.js.map +0 -1
  566. package/dist/src/modular/emitTests.d.ts +0 -7
  567. package/dist/src/modular/emitTests.d.ts.map +0 -1
  568. package/dist/src/modular/emitTests.js +0 -155
  569. package/dist/src/modular/emitTests.js.map +0 -1
  570. package/dist/src/modular/helpers/classicalOperationHelpers.d.ts +0 -7
  571. package/dist/src/modular/helpers/classicalOperationHelpers.d.ts.map +0 -1
  572. package/dist/src/modular/helpers/classicalOperationHelpers.js +0 -258
  573. package/dist/src/modular/helpers/classicalOperationHelpers.js.map +0 -1
  574. package/dist/src/modular/helpers/clientHelpers.d.ts +0 -34
  575. package/dist/src/modular/helpers/clientHelpers.d.ts.map +0 -1
  576. package/dist/src/modular/helpers/clientHelpers.js +0 -259
  577. package/dist/src/modular/helpers/clientHelpers.js.map +0 -1
  578. package/dist/src/modular/helpers/clientOptionHelpers.d.ts +0 -43
  579. package/dist/src/modular/helpers/clientOptionHelpers.d.ts.map +0 -1
  580. package/dist/src/modular/helpers/clientOptionHelpers.js +0 -103
  581. package/dist/src/modular/helpers/clientOptionHelpers.js.map +0 -1
  582. package/dist/src/modular/helpers/docsHelpers.d.ts +0 -3
  583. package/dist/src/modular/helpers/docsHelpers.d.ts.map +0 -1
  584. package/dist/src/modular/helpers/docsHelpers.js +0 -10
  585. package/dist/src/modular/helpers/docsHelpers.js.map +0 -1
  586. package/dist/src/modular/helpers/exampleValueHelpers.d.ts +0 -83
  587. package/dist/src/modular/helpers/exampleValueHelpers.d.ts.map +0 -1
  588. package/dist/src/modular/helpers/exampleValueHelpers.js +0 -639
  589. package/dist/src/modular/helpers/exampleValueHelpers.js.map +0 -1
  590. package/dist/src/modular/helpers/namingHelpers.d.ts +0 -22
  591. package/dist/src/modular/helpers/namingHelpers.d.ts.map +0 -1
  592. package/dist/src/modular/helpers/namingHelpers.js +0 -59
  593. package/dist/src/modular/helpers/namingHelpers.js.map +0 -1
  594. package/dist/src/modular/helpers/operationHelpers.d.ts +0 -105
  595. package/dist/src/modular/helpers/operationHelpers.d.ts.map +0 -1
  596. package/dist/src/modular/helpers/operationHelpers.js +0 -2328
  597. package/dist/src/modular/helpers/operationHelpers.js.map +0 -1
  598. package/dist/src/modular/helpers/typeHelpers.d.ts +0 -22
  599. package/dist/src/modular/helpers/typeHelpers.d.ts.map +0 -1
  600. package/dist/src/modular/helpers/typeHelpers.js +0 -94
  601. package/dist/src/modular/helpers/typeHelpers.js.map +0 -1
  602. package/dist/src/modular/serialization/buildDeserializerFunction.d.ts +0 -7
  603. package/dist/src/modular/serialization/buildDeserializerFunction.d.ts.map +0 -1
  604. package/dist/src/modular/serialization/buildDeserializerFunction.js +0 -401
  605. package/dist/src/modular/serialization/buildDeserializerFunction.js.map +0 -1
  606. package/dist/src/modular/serialization/buildSerializerFunction.d.ts +0 -7
  607. package/dist/src/modular/serialization/buildSerializerFunction.d.ts.map +0 -1
  608. package/dist/src/modular/serialization/buildSerializerFunction.js +0 -444
  609. package/dist/src/modular/serialization/buildSerializerFunction.js.map +0 -1
  610. package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts +0 -44
  611. package/dist/src/modular/serialization/buildXmlSerializerFunction.d.ts.map +0 -1
  612. package/dist/src/modular/serialization/buildXmlSerializerFunction.js +0 -729
  613. package/dist/src/modular/serialization/buildXmlSerializerFunction.js.map +0 -1
  614. package/dist/src/modular/serialization/serializeUtils.d.ts +0 -37
  615. package/dist/src/modular/serialization/serializeUtils.d.ts.map +0 -1
  616. package/dist/src/modular/serialization/serializeUtils.js +0 -145
  617. package/dist/src/modular/serialization/serializeUtils.js.map +0 -1
  618. package/dist/src/rlc-common/buildClient.d.ts +0 -9
  619. package/dist/src/rlc-common/buildClient.d.ts.map +0 -1
  620. package/dist/src/rlc-common/buildClient.js +0 -391
  621. package/dist/src/rlc-common/buildClient.js.map +0 -1
  622. package/dist/src/rlc-common/buildClientDefinitions.d.ts +0 -6
  623. package/dist/src/rlc-common/buildClientDefinitions.d.ts.map +0 -1
  624. package/dist/src/rlc-common/buildClientDefinitions.js +0 -157
  625. package/dist/src/rlc-common/buildClientDefinitions.js.map +0 -1
  626. package/dist/src/rlc-common/buildIndexFile.d.ts +0 -6
  627. package/dist/src/rlc-common/buildIndexFile.d.ts.map +0 -1
  628. package/dist/src/rlc-common/buildIndexFile.js +0 -241
  629. package/dist/src/rlc-common/buildIndexFile.js.map +0 -1
  630. package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts +0 -6
  631. package/dist/src/rlc-common/buildIsUnexpectedHelper.d.ts.map +0 -1
  632. package/dist/src/rlc-common/buildIsUnexpectedHelper.js +0 -223
  633. package/dist/src/rlc-common/buildIsUnexpectedHelper.js.map +0 -1
  634. package/dist/src/rlc-common/buildLogger.d.ts +0 -6
  635. package/dist/src/rlc-common/buildLogger.d.ts.map +0 -1
  636. package/dist/src/rlc-common/buildLogger.js +0 -31
  637. package/dist/src/rlc-common/buildLogger.js.map +0 -1
  638. package/dist/src/rlc-common/buildMethodShortcuts.d.ts +0 -5
  639. package/dist/src/rlc-common/buildMethodShortcuts.d.ts.map +0 -1
  640. package/dist/src/rlc-common/buildMethodShortcuts.js +0 -54
  641. package/dist/src/rlc-common/buildMethodShortcuts.js.map +0 -1
  642. package/dist/src/rlc-common/buildObjectTypes.d.ts +0 -29
  643. package/dist/src/rlc-common/buildObjectTypes.d.ts.map +0 -1
  644. package/dist/src/rlc-common/buildObjectTypes.js +0 -412
  645. package/dist/src/rlc-common/buildObjectTypes.js.map +0 -1
  646. package/dist/src/rlc-common/buildPaginateHelper.d.ts +0 -6
  647. package/dist/src/rlc-common/buildPaginateHelper.d.ts.map +0 -1
  648. package/dist/src/rlc-common/buildPaginateHelper.js +0 -27
  649. package/dist/src/rlc-common/buildPaginateHelper.js.map +0 -1
  650. package/dist/src/rlc-common/buildParameterTypes.d.ts +0 -14
  651. package/dist/src/rlc-common/buildParameterTypes.d.ts.map +0 -1
  652. package/dist/src/rlc-common/buildParameterTypes.js +0 -391
  653. package/dist/src/rlc-common/buildParameterTypes.js.map +0 -1
  654. package/dist/src/rlc-common/buildPollingHelper.d.ts +0 -6
  655. package/dist/src/rlc-common/buildPollingHelper.d.ts.map +0 -1
  656. package/dist/src/rlc-common/buildPollingHelper.js +0 -61
  657. package/dist/src/rlc-common/buildPollingHelper.js.map +0 -1
  658. package/dist/src/rlc-common/buildResponseTypes.d.ts +0 -6
  659. package/dist/src/rlc-common/buildResponseTypes.d.ts.map +0 -1
  660. package/dist/src/rlc-common/buildResponseTypes.js +0 -143
  661. package/dist/src/rlc-common/buildResponseTypes.js.map +0 -1
  662. package/dist/src/rlc-common/buildSamples.d.ts +0 -3
  663. package/dist/src/rlc-common/buildSamples.d.ts.map +0 -1
  664. package/dist/src/rlc-common/buildSamples.js +0 -30
  665. package/dist/src/rlc-common/buildSamples.js.map +0 -1
  666. package/dist/src/rlc-common/buildSchemaType.d.ts +0 -20
  667. package/dist/src/rlc-common/buildSchemaType.d.ts.map +0 -1
  668. package/dist/src/rlc-common/buildSchemaType.js +0 -71
  669. package/dist/src/rlc-common/buildSchemaType.js.map +0 -1
  670. package/dist/src/rlc-common/buildSerializeHelper.d.ts +0 -6
  671. package/dist/src/rlc-common/buildSerializeHelper.d.ts.map +0 -1
  672. package/dist/src/rlc-common/buildSerializeHelper.js +0 -36
  673. package/dist/src/rlc-common/buildSerializeHelper.js.map +0 -1
  674. package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts +0 -6
  675. package/dist/src/rlc-common/buildTopLevelIndexFile.d.ts.map +0 -1
  676. package/dist/src/rlc-common/buildTopLevelIndexFile.js +0 -48
  677. package/dist/src/rlc-common/buildTopLevelIndexFile.js.map +0 -1
  678. package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts +0 -17
  679. package/dist/src/rlc-common/helpers/apiVersionUtil.d.ts.map +0 -1
  680. package/dist/src/rlc-common/helpers/apiVersionUtil.js +0 -43
  681. package/dist/src/rlc-common/helpers/apiVersionUtil.js.map +0 -1
  682. package/dist/src/rlc-common/helpers/importsUtil.d.ts +0 -18
  683. package/dist/src/rlc-common/helpers/importsUtil.d.ts.map +0 -1
  684. package/dist/src/rlc-common/helpers/importsUtil.js +0 -164
  685. package/dist/src/rlc-common/helpers/importsUtil.js.map +0 -1
  686. package/dist/src/rlc-common/helpers/nameConstructors.d.ts +0 -42
  687. package/dist/src/rlc-common/helpers/nameConstructors.d.ts.map +0 -1
  688. package/dist/src/rlc-common/helpers/nameConstructors.js +0 -61
  689. package/dist/src/rlc-common/helpers/nameConstructors.js.map +0 -1
  690. package/dist/src/rlc-common/helpers/nameUtils.d.ts +0 -37
  691. package/dist/src/rlc-common/helpers/nameUtils.d.ts.map +0 -1
  692. package/dist/src/rlc-common/helpers/nameUtils.js +0 -240
  693. package/dist/src/rlc-common/helpers/nameUtils.js.map +0 -1
  694. package/dist/src/rlc-common/helpers/operationHelpers.d.ts +0 -16
  695. package/dist/src/rlc-common/helpers/operationHelpers.d.ts.map +0 -1
  696. package/dist/src/rlc-common/helpers/operationHelpers.js +0 -104
  697. package/dist/src/rlc-common/helpers/operationHelpers.js.map +0 -1
  698. package/dist/src/rlc-common/helpers/packageUtil.d.ts +0 -7
  699. package/dist/src/rlc-common/helpers/packageUtil.d.ts.map +0 -1
  700. package/dist/src/rlc-common/helpers/packageUtil.js +0 -10
  701. package/dist/src/rlc-common/helpers/packageUtil.js.map +0 -1
  702. package/dist/src/rlc-common/helpers/pathUtils.d.ts +0 -2
  703. package/dist/src/rlc-common/helpers/pathUtils.d.ts.map +0 -1
  704. package/dist/src/rlc-common/helpers/pathUtils.js +0 -10
  705. package/dist/src/rlc-common/helpers/pathUtils.js.map +0 -1
  706. package/dist/src/rlc-common/helpers/schemaHelpers.d.ts +0 -10
  707. package/dist/src/rlc-common/helpers/schemaHelpers.d.ts.map +0 -1
  708. package/dist/src/rlc-common/helpers/schemaHelpers.js +0 -37
  709. package/dist/src/rlc-common/helpers/schemaHelpers.js.map +0 -1
  710. package/dist/src/rlc-common/helpers/shortcutMethods.d.ts +0 -4
  711. package/dist/src/rlc-common/helpers/shortcutMethods.d.ts.map +0 -1
  712. package/dist/src/rlc-common/helpers/shortcutMethods.js +0 -49
  713. package/dist/src/rlc-common/helpers/shortcutMethods.js.map +0 -1
  714. package/dist/src/rlc-common/helpers/typeUtil.d.ts +0 -32
  715. package/dist/src/rlc-common/helpers/typeUtil.d.ts.map +0 -1
  716. package/dist/src/rlc-common/helpers/typeUtil.js +0 -162
  717. package/dist/src/rlc-common/helpers/typeUtil.js.map +0 -1
  718. package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts +0 -12
  719. package/dist/src/rlc-common/helpers/valueGenerationUtil.d.ts.map +0 -1
  720. package/dist/src/rlc-common/helpers/valueGenerationUtil.js +0 -161
  721. package/dist/src/rlc-common/helpers/valueGenerationUtil.js.map +0 -1
  722. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts +0 -6
  723. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.d.ts.map +0 -1
  724. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js +0 -55
  725. package/dist/src/rlc-common/metadata/buildApiExtractorConfig.js.map +0 -1
  726. package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts +0 -6
  727. package/dist/src/rlc-common/metadata/buildChangelogFile.d.ts.map +0 -1
  728. package/dist/src/rlc-common/metadata/buildChangelogFile.js +0 -25
  729. package/dist/src/rlc-common/metadata/buildChangelogFile.js.map +0 -1
  730. package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts +0 -6
  731. package/dist/src/rlc-common/metadata/buildESLintConfig.d.ts.map +0 -1
  732. package/dist/src/rlc-common/metadata/buildESLintConfig.js +0 -79
  733. package/dist/src/rlc-common/metadata/buildESLintConfig.js.map +0 -1
  734. package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts +0 -5
  735. package/dist/src/rlc-common/metadata/buildLicenseFile.d.ts.map +0 -1
  736. package/dist/src/rlc-common/metadata/buildLicenseFile.js +0 -32
  737. package/dist/src/rlc-common/metadata/buildLicenseFile.js.map +0 -1
  738. package/dist/src/rlc-common/metadata/buildPackageFile.d.ts +0 -25
  739. package/dist/src/rlc-common/metadata/buildPackageFile.d.ts.map +0 -1
  740. package/dist/src/rlc-common/metadata/buildPackageFile.js +0 -197
  741. package/dist/src/rlc-common/metadata/buildPackageFile.js.map +0 -1
  742. package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts +0 -11
  743. package/dist/src/rlc-common/metadata/buildReadmeFile.d.ts.map +0 -1
  744. package/dist/src/rlc-common/metadata/buildReadmeFile.js +0 -418
  745. package/dist/src/rlc-common/metadata/buildReadmeFile.js.map +0 -1
  746. package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts +0 -6
  747. package/dist/src/rlc-common/metadata/buildRollupConfig.d.ts.map +0 -1
  748. package/dist/src/rlc-common/metadata/buildRollupConfig.js +0 -140
  749. package/dist/src/rlc-common/metadata/buildRollupConfig.js.map +0 -1
  750. package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts +0 -6
  751. package/dist/src/rlc-common/metadata/buildSampleEnvFile.d.ts.map +0 -1
  752. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js +0 -15
  753. package/dist/src/rlc-common/metadata/buildSampleEnvFile.js.map +0 -1
  754. package/dist/src/rlc-common/metadata/buildTestConfig.d.ts +0 -16
  755. package/dist/src/rlc-common/metadata/buildTestConfig.d.ts.map +0 -1
  756. package/dist/src/rlc-common/metadata/buildTestConfig.js +0 -54
  757. package/dist/src/rlc-common/metadata/buildTestConfig.js.map +0 -1
  758. package/dist/src/rlc-common/metadata/buildTsConfig.d.ts +0 -61
  759. package/dist/src/rlc-common/metadata/buildTsConfig.d.ts.map +0 -1
  760. package/dist/src/rlc-common/metadata/buildTsConfig.js +0 -170
  761. package/dist/src/rlc-common/metadata/buildTsConfig.js.map +0 -1
  762. package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts +0 -6
  763. package/dist/src/rlc-common/metadata/buildVitestConfig.d.ts.map +0 -1
  764. package/dist/src/rlc-common/metadata/buildVitestConfig.js +0 -26
  765. package/dist/src/rlc-common/metadata/buildVitestConfig.js.map +0 -1
  766. package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts +0 -20
  767. package/dist/src/rlc-common/metadata/buildWarpConfig.d.ts.map +0 -1
  768. package/dist/src/rlc-common/metadata/buildWarpConfig.js +0 -76
  769. package/dist/src/rlc-common/metadata/buildWarpConfig.js.map +0 -1
  770. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts +0 -51
  771. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.d.ts.map +0 -1
  772. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js +0 -121
  773. package/dist/src/rlc-common/metadata/packageJson/azurePackageCommon.js.map +0 -1
  774. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts +0 -242
  775. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.d.ts.map +0 -1
  776. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js +0 -171
  777. package/dist/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.js.map +0 -1
  778. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts +0 -8
  779. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.d.ts.map +0 -1
  780. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js +0 -101
  781. package/dist/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.js.map +0 -1
  782. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts +0 -57
  783. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.d.ts.map +0 -1
  784. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js +0 -53
  785. package/dist/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.js.map +0 -1
  786. package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts +0 -64
  787. package/dist/src/rlc-common/metadata/packageJson/packageCommon.d.ts.map +0 -1
  788. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js +0 -180
  789. package/dist/src/rlc-common/metadata/packageJson/packageCommon.js.map +0 -1
  790. package/dist/src/rlc-common/static/paginateContent.d.ts +0 -2
  791. package/dist/src/rlc-common/static/paginateContent.d.ts.map +0 -1
  792. package/dist/src/rlc-common/static/paginateContent.js +0 -345
  793. package/dist/src/rlc-common/static/paginateContent.js.map +0 -1
  794. package/dist/src/rlc-common/static/pollingContent.d.ts +0 -2
  795. package/dist/src/rlc-common/static/pollingContent.d.ts.map +0 -1
  796. package/dist/src/rlc-common/static/pollingContent.js +0 -225
  797. package/dist/src/rlc-common/static/pollingContent.js.map +0 -1
  798. package/dist/src/rlc-common/static/sampleTemplate.d.ts +0 -2
  799. package/dist/src/rlc-common/static/sampleTemplate.d.ts.map +0 -1
  800. package/dist/src/rlc-common/static/sampleTemplate.js +0 -56
  801. package/dist/src/rlc-common/static/sampleTemplate.js.map +0 -1
  802. package/dist/src/rlc-common/static/serializeHelper.d.ts +0 -6
  803. package/dist/src/rlc-common/static/serializeHelper.d.ts.map +0 -1
  804. package/dist/src/rlc-common/static/serializeHelper.js +0 -31
  805. package/dist/src/rlc-common/static/serializeHelper.js.map +0 -1
  806. package/dist/src/rlc-common/test/buildKarmaConfig.d.ts +0 -6
  807. package/dist/src/rlc-common/test/buildKarmaConfig.d.ts.map +0 -1
  808. package/dist/src/rlc-common/test/buildKarmaConfig.js +0 -11
  809. package/dist/src/rlc-common/test/buildKarmaConfig.js.map +0 -1
  810. package/dist/src/rlc-common/test/buildRecordedClient.d.ts +0 -6
  811. package/dist/src/rlc-common/test/buildRecordedClient.d.ts.map +0 -1
  812. package/dist/src/rlc-common/test/buildRecordedClient.js +0 -17
  813. package/dist/src/rlc-common/test/buildRecordedClient.js.map +0 -1
  814. package/dist/src/rlc-common/test/buildSampleTest.d.ts +0 -6
  815. package/dist/src/rlc-common/test/buildSampleTest.d.ts.map +0 -1
  816. package/dist/src/rlc-common/test/buildSampleTest.js +0 -14
  817. package/dist/src/rlc-common/test/buildSampleTest.js.map +0 -1
  818. package/dist/src/rlc-common/test/buildSnippets.d.ts +0 -6
  819. package/dist/src/rlc-common/test/buildSnippets.d.ts.map +0 -1
  820. package/dist/src/rlc-common/test/buildSnippets.js +0 -26
  821. package/dist/src/rlc-common/test/buildSnippets.js.map +0 -1
  822. package/dist/src/rlc-common/transformSampleGroups.d.ts +0 -9
  823. package/dist/src/rlc-common/transformSampleGroups.d.ts.map +0 -1
  824. package/dist/src/rlc-common/transformSampleGroups.js +0 -313
  825. package/dist/src/rlc-common/transformSampleGroups.js.map +0 -1
  826. package/dist/src/transform/transformApiVersionInfo.d.ts +0 -6
  827. package/dist/src/transform/transformApiVersionInfo.d.ts.map +0 -1
  828. package/dist/src/transform/transformApiVersionInfo.js +0 -78
  829. package/dist/src/transform/transformApiVersionInfo.js.map +0 -1
  830. package/dist/src/transform/transformHelperFunctionDetails.d.ts +0 -5
  831. package/dist/src/transform/transformHelperFunctionDetails.d.ts.map +0 -1
  832. package/dist/src/transform/transformHelperFunctionDetails.js +0 -74
  833. package/dist/src/transform/transformHelperFunctionDetails.js.map +0 -1
  834. package/dist/src/transform/transformParameters.d.ts +0 -14
  835. package/dist/src/transform/transformParameters.d.ts.map +0 -1
  836. package/dist/src/transform/transformParameters.js +0 -201
  837. package/dist/src/transform/transformParameters.js.map +0 -1
  838. package/dist/src/transform/transformPaths.d.ts +0 -5
  839. package/dist/src/transform/transformPaths.d.ts.map +0 -1
  840. package/dist/src/transform/transformPaths.js +0 -102
  841. package/dist/src/transform/transformPaths.js.map +0 -1
  842. package/dist/src/transform/transformResponses.d.ts +0 -5
  843. package/dist/src/transform/transformResponses.d.ts.map +0 -1
  844. package/dist/src/transform/transformResponses.js +0 -171
  845. package/dist/src/transform/transformResponses.js.map +0 -1
  846. package/dist/src/transform/transformSchemas.d.ts +0 -4
  847. package/dist/src/transform/transformSchemas.d.ts.map +0 -1
  848. package/dist/src/transform/transformSchemas.js +0 -191
  849. package/dist/src/transform/transformSchemas.js.map +0 -1
  850. package/dist/src/transform/transformTelemetryInfo.d.ts +0 -4
  851. package/dist/src/transform/transformTelemetryInfo.d.ts.map +0 -1
  852. package/dist/src/transform/transformTelemetryInfo.js +0 -22
  853. package/dist/src/transform/transformTelemetryInfo.js.map +0 -1
  854. package/dist/src/transform/transfromRLCOptions.d.ts +0 -14
  855. package/dist/src/transform/transfromRLCOptions.d.ts.map +0 -1
  856. package/dist/src/transform/transfromRLCOptions.js +0 -369
  857. package/dist/src/transform/transfromRLCOptions.js.map +0 -1
  858. package/dist/src/utils/clientUtils.d.ts +0 -10
  859. package/dist/src/utils/clientUtils.d.ts.map +0 -1
  860. package/dist/src/utils/clientUtils.js +0 -124
  861. package/dist/src/utils/clientUtils.js.map +0 -1
  862. package/dist/src/utils/credentialUtils.d.ts +0 -15
  863. package/dist/src/utils/credentialUtils.d.ts.map +0 -1
  864. package/dist/src/utils/credentialUtils.js +0 -68
  865. package/dist/src/utils/credentialUtils.js.map +0 -1
  866. package/dist/src/utils/crossLanguageDef.d.ts +0 -6
  867. package/dist/src/utils/crossLanguageDef.d.ts.map +0 -1
  868. package/dist/src/utils/crossLanguageDef.js +0 -59
  869. package/dist/src/utils/crossLanguageDef.js.map +0 -1
  870. package/dist/src/utils/emitUtil.d.ts +0 -5
  871. package/dist/src/utils/emitUtil.d.ts.map +0 -1
  872. package/dist/src/utils/emitUtil.js +0 -71
  873. package/dist/src/utils/emitUtil.js.map +0 -1
  874. package/dist/src/utils/fileSystemUtils.d.ts +0 -5
  875. package/dist/src/utils/fileSystemUtils.d.ts.map +0 -1
  876. package/dist/src/utils/fileSystemUtils.js +0 -59
  877. package/dist/src/utils/fileSystemUtils.js.map +0 -1
  878. package/dist/src/utils/importHelper.d.ts +0 -10
  879. package/dist/src/utils/importHelper.d.ts.map +0 -1
  880. package/dist/src/utils/importHelper.js +0 -51
  881. package/dist/src/utils/importHelper.js.map +0 -1
  882. package/dist/src/utils/mediaTypes.d.ts +0 -28
  883. package/dist/src/utils/mediaTypes.d.ts.map +0 -1
  884. package/dist/src/utils/mediaTypes.js +0 -124
  885. package/dist/src/utils/mediaTypes.js.map +0 -1
  886. package/dist/src/utils/modelUtils.d.ts +0 -60
  887. package/dist/src/utils/modelUtils.d.ts.map +0 -1
  888. package/dist/src/utils/modelUtils.js +0 -1488
  889. package/dist/src/utils/modelUtils.js.map +0 -1
  890. package/dist/src/utils/namespaceUtils.d.ts +0 -6
  891. package/dist/src/utils/namespaceUtils.d.ts.map +0 -1
  892. package/dist/src/utils/namespaceUtils.js +0 -69
  893. package/dist/src/utils/namespaceUtils.js.map +0 -1
  894. package/dist/src/utils/operationUtil.d.ts +0 -97
  895. package/dist/src/utils/operationUtil.d.ts.map +0 -1
  896. package/dist/src/utils/operationUtil.js +0 -547
  897. package/dist/src/utils/operationUtil.js.map +0 -1
  898. package/dist/src/utils/parameterUtils.d.ts +0 -9
  899. package/dist/src/utils/parameterUtils.d.ts.map +0 -1
  900. package/dist/src/utils/parameterUtils.js +0 -147
  901. package/dist/src/utils/parameterUtils.js.map +0 -1
  902. package/src/contextManager.ts +0 -101
  903. package/src/framework/hooks/sdkTypes.ts +0 -218
  904. package/src/framework/hooks/useDependencies.ts +0 -16
  905. package/src/modular/buildClassicalClient.ts +0 -434
  906. package/src/modular/buildClassicalOperationGroups.ts +0 -69
  907. package/src/modular/buildClientContext.ts +0 -325
  908. package/src/modular/buildOperations.ts +0 -248
  909. package/src/modular/buildProjectFiles.ts +0 -111
  910. package/src/modular/buildRestorePoller.ts +0 -242
  911. package/src/modular/buildRootIndex.ts +0 -407
  912. package/src/modular/buildSubpathIndex.ts +0 -152
  913. package/src/modular/emitLoggerFile.ts +0 -23
  914. package/src/modular/emitModels.ts +0 -1081
  915. package/src/modular/emitModelsOptions.ts +0 -56
  916. package/src/modular/emitSamples.ts +0 -675
  917. package/src/modular/emitTests.ts +0 -194
  918. package/src/modular/helpers/classicalOperationHelpers.ts +0 -375
  919. package/src/modular/helpers/clientHelpers.ts +0 -362
  920. package/src/modular/helpers/exampleValueHelpers.ts +0 -851
  921. package/src/modular/helpers/namingHelpers.ts +0 -84
  922. package/src/modular/helpers/operationHelpers.ts +0 -3035
  923. package/src/modular/helpers/typeHelpers.ts +0 -131
  924. package/src/modular/serialization/buildDeserializerFunction.ts +0 -564
  925. package/src/modular/serialization/buildSerializerFunction.ts +0 -616
  926. package/src/modular/serialization/buildXmlSerializerFunction.ts +0 -951
  927. package/src/modular/serialization/serializeUtils.ts +0 -217
  928. package/src/rlc-common/buildClient.ts +0 -490
  929. package/src/rlc-common/buildClientDefinitions.ts +0 -235
  930. package/src/rlc-common/buildIndexFile.ts +0 -344
  931. package/src/rlc-common/buildIsUnexpectedHelper.ts +0 -248
  932. package/src/rlc-common/buildLogger.ts +0 -43
  933. package/src/rlc-common/buildMethodShortcuts.ts +0 -71
  934. package/src/rlc-common/buildObjectTypes.ts +0 -603
  935. package/src/rlc-common/buildPaginateHelper.ts +0 -31
  936. package/src/rlc-common/buildParameterTypes.ts +0 -554
  937. package/src/rlc-common/buildPollingHelper.ts +0 -83
  938. package/src/rlc-common/buildResponseTypes.ts +0 -180
  939. package/src/rlc-common/buildSamples.ts +0 -32
  940. package/src/rlc-common/buildSchemaType.ts +0 -89
  941. package/src/rlc-common/buildSerializeHelper.ts +0 -49
  942. package/src/rlc-common/buildTopLevelIndexFile.ts +0 -58
  943. package/src/rlc-common/helpers/nameConstructors.ts +0 -110
  944. package/src/rlc-common/helpers/operationHelpers.ts +0 -138
  945. package/src/rlc-common/helpers/shortcutMethods.ts +0 -58
  946. package/src/rlc-common/helpers/valueGenerationUtil.ts +0 -234
  947. package/src/rlc-common/metadata/buildPackageFile.ts +0 -242
  948. package/src/rlc-common/metadata/buildReadmeFile.ts +0 -515
  949. package/src/rlc-common/metadata/buildRollupConfig.ts +0 -147
  950. package/src/rlc-common/metadata/packageJson/azurePackageCommon.ts +0 -152
  951. package/src/rlc-common/metadata/packageJson/buildAzureMonorepoPackage.ts +0 -199
  952. package/src/rlc-common/metadata/packageJson/buildAzureStandalonePackage.ts +0 -123
  953. package/src/rlc-common/metadata/packageJson/buildFlavorlessPackage.ts +0 -68
  954. package/src/rlc-common/test/buildSnippets.ts +0 -29
  955. package/src/rlc-common/transformSampleGroups.ts +0 -407
  956. package/src/transform/transformApiVersionInfo.ts +0 -103
  957. package/src/transform/transformHelperFunctionDetails.ts +0 -88
  958. package/src/transform/transformParameters.ts +0 -321
  959. package/src/transform/transformPaths.ts +0 -157
  960. package/src/transform/transformResponses.ts +0 -237
  961. package/src/transform/transformSchemas.ts +0 -212
  962. package/src/transform/transformTelemetryInfo.ts +0 -33
  963. package/src/transform/transfromRLCOptions.ts +0 -461
  964. package/src/utils/crossLanguageDef.ts +0 -66
  965. package/src/utils/importHelper.ts +0 -59
  966. package/src/utils/modelUtils.ts +0 -1737
  967. package/src/utils/operationUtil.ts +0 -763
  968. package/src/utils/parameterUtils.ts +0 -192
  969. /package/src/{metaTree.ts → meta-tree.ts} +0 -0
  970. /package/src/modular/{buildModularOptions.ts → build-modular-options.ts} +0 -0
  971. /package/src/modular/helpers/{clientOptionHelpers.ts → client-option-helpers.ts} +0 -0
  972. /package/src/modular/helpers/{docsHelpers.ts → docs-helpers.ts} +0 -0
  973. /package/src/rlc-common/helpers/{apiVersionUtil.ts → api-version-util.ts} +0 -0
  974. /package/src/rlc-common/helpers/{importsUtil.ts → imports-util.ts} +0 -0
  975. /package/src/rlc-common/helpers/{nameUtils.ts → name-utils.ts} +0 -0
  976. /package/src/rlc-common/helpers/{packageUtil.ts → package-util.ts} +0 -0
  977. /package/src/rlc-common/helpers/{pathUtils.ts → path-utils.ts} +0 -0
  978. /package/src/rlc-common/helpers/{schemaHelpers.ts → schema-helpers.ts} +0 -0
  979. /package/src/rlc-common/helpers/{typeUtil.ts → type-util.ts} +0 -0
  980. /package/src/rlc-common/metadata/{buildApiExtractorConfig.ts → build-api-extractor-config.ts} +0 -0
  981. /package/src/rlc-common/metadata/{buildChangelogFile.ts → build-changelog-file.ts} +0 -0
  982. /package/src/rlc-common/metadata/{buildESLintConfig.ts → build-es-lint-config.ts} +0 -0
  983. /package/src/rlc-common/metadata/{buildLicenseFile.ts → build-license-file.ts} +0 -0
  984. /package/src/rlc-common/metadata/{buildSampleEnvFile.ts → build-sample-env-file.ts} +0 -0
  985. /package/src/rlc-common/metadata/{buildTestConfig.ts → build-test-config.ts} +0 -0
  986. /package/src/rlc-common/metadata/{buildTsConfig.ts → build-ts-config.ts} +0 -0
  987. /package/src/rlc-common/metadata/{buildVitestConfig.ts → build-vitest-config.ts} +0 -0
  988. /package/src/rlc-common/metadata/{buildWarpConfig.ts → build-warp-config.ts} +0 -0
  989. /package/src/rlc-common/metadata/{packageJson/packageCommon.ts → package-json/package-common.ts} +0 -0
  990. /package/src/rlc-common/static/{paginateContent.ts → paginate-content.ts} +0 -0
  991. /package/src/rlc-common/static/{pollingContent.ts → polling-content.ts} +0 -0
  992. /package/src/rlc-common/static/{sampleTemplate.ts → sample-template.ts} +0 -0
  993. /package/src/rlc-common/static/{serializeHelper.ts → serialize-helper.ts} +0 -0
  994. /package/src/rlc-common/test/{buildKarmaConfig.ts → build-karma-config.ts} +0 -0
  995. /package/src/rlc-common/test/{buildRecordedClient.ts → build-recorded-client.ts} +0 -0
  996. /package/src/rlc-common/test/{buildSampleTest.ts → build-sample-test.ts} +0 -0
  997. /package/src/utils/{clientUtils.ts → client-utils.ts} +0 -0
  998. /package/src/utils/{credentialUtils.ts → credential-utils.ts} +0 -0
  999. /package/src/utils/{emitUtil.ts → emit-util.ts} +0 -0
  1000. /package/src/utils/{fileSystemUtils.ts → file-system-utils.ts} +0 -0
  1001. /package/src/utils/{mediaTypes.ts → media-types.ts} +0 -0
  1002. /package/src/utils/{namespaceUtils.ts → namespace-utils.ts} +0 -0
@@ -0,0 +1,3035 @@
1
+ import {
2
+ getClientOptions,
3
+ isHttpMetadata,
4
+ isReadOnly,
5
+ SdkBodyParameter,
6
+ SdkClientType,
7
+ SdkConstantType,
8
+ SdkEnumType,
9
+ SdkHttpOperation,
10
+ SdkHttpParameter,
11
+ SdkLroPagingServiceMethod,
12
+ SdkLroServiceMethod,
13
+ SdkMethod,
14
+ SdkMethodParameter,
15
+ SdkModelPropertyType,
16
+ SdkModelType,
17
+ SdkPagingServiceMethod,
18
+ SdkServiceResponseHeader,
19
+ SdkType,
20
+ } from "@azure-tools/typespec-client-generator-core";
21
+ import { NoTarget, Program } from "@typespec/compiler";
22
+ import { isHeader, isMetadata } from "@typespec/http";
23
+ import {
24
+ FunctionDeclarationStructure,
25
+ OptionalKind,
26
+ ParameterDeclarationStructure,
27
+ StructureKind,
28
+ TypeAliasDeclarationStructure,
29
+ } from "ts-morph";
30
+ import { useContext } from "../../context-manager.js";
31
+ import { useSdkTypes } from "../../framework/hooks/sdk-types.js";
32
+ import { useDependencies } from "../../framework/hooks/use-dependencies.js";
33
+ import { resolveReference } from "../../framework/reference.js";
34
+ import { refkey } from "../../framework/refkey.js";
35
+ import { reportDiagnostic } from "../../lib.js";
36
+ import { NameType, normalizeName } from "../../rlc-common/index.js";
37
+ import { SdkContext } from "../../utils/interfaces.js";
38
+ import { isAzureCoreErrorType } from "../../utils/model-utils.js";
39
+ import {
40
+ getCollectionFormatFromArrayEncoding,
41
+ getCollectionFormatHelper,
42
+ getCollectionFormatParseHelper,
43
+ hasCollectionFormatInfo,
44
+ hasDualFormatSupport,
45
+ isBinaryPayload,
46
+ isMultipartPayload,
47
+ isXmlPayload,
48
+ KnownCollectionFormat,
49
+ ServiceOperation,
50
+ } from "../../utils/operation-util.js";
51
+ import { AzurePollingDependencies } from "../external-dependencies.js";
52
+ import {
53
+ buildModelDeserializer,
54
+ buildPropertyDeserializer,
55
+ } from "../serialization/build-deserializer-function.js";
56
+ import {
57
+ buildModelSerializer,
58
+ buildPropertySerializer,
59
+ } from "../serialization/build-serializer-function.js";
60
+ import {
61
+ buildXmlModelDeserializer,
62
+ buildXmlModelSerializer,
63
+ hasXmlSerialization,
64
+ } from "../serialization/build-xml-serializer-function.js";
65
+ import {
66
+ getPropertyWithOverrides,
67
+ isNormalUnion,
68
+ isSpecialHandledUnion,
69
+ ModelOverrideOptions,
70
+ } from "../serialization/serialize-utils.js";
71
+ import {
72
+ PagingHelpers,
73
+ PlatformTypeHelpers,
74
+ PollingHelpers,
75
+ SerializationHelpers,
76
+ StorageCompatHelpers,
77
+ UrlTemplateHelpers,
78
+ XmlHelpers,
79
+ } from "../static-helpers-metadata.js";
80
+ import { isExtensibleEnum } from "../type-expressions/get-enum-expression.js";
81
+ import { emitInlineModel } from "../type-expressions/get-model-expression.js";
82
+ import {
83
+ getTypeExpression,
84
+ normalizeModelPropertyName,
85
+ } from "../type-expressions/get-type-expression.js";
86
+ import { getClientParameterName } from "./client-helpers.js";
87
+ import { getHeaderClientOptions, getRestErrorCodeHeader } from "./client-option-helpers.js";
88
+ import { getDocsFromDescription, getFixmeForMultilineDocs } from "./docs-helpers.js";
89
+ import {
90
+ generateLocallyUniqueName,
91
+ getClassicalLayerPrefix,
92
+ getOperationName,
93
+ } from "./naming-helpers.js";
94
+ import { getNullableValidType, isSpreadBodyParameter, isTypeNullable } from "./type-helpers.js";
95
+
96
+ /**
97
+ * Checks whether a header should be skipped during serialization/deserialization.
98
+ * A header is skipped when it has the "headerCollectionPrefix" client option set,
99
+ * which indicates it uses a prefix-based dictionary pattern not handled by standard ser/deser.
100
+ */
101
+ function shouldSkipHeaderSerialization(
102
+ header: SdkHttpParameter | SdkServiceResponseHeader,
103
+ ): boolean {
104
+ return getClientOptions(header, "headerCollectionPrefix") !== undefined;
105
+ }
106
+
107
+ export function getSendPrivateFunction(
108
+ dpgContext: SdkContext,
109
+ method: [string[], ServiceOperation],
110
+ clientType: string,
111
+ client?: SdkClientType<SdkHttpOperation>,
112
+ ): OptionalKind<FunctionDeclarationStructure> {
113
+ const operation = method[1];
114
+ const parameters = getOperationSignatureParameters(dpgContext, method, clientType);
115
+ const { name } = getOperationName(operation);
116
+ const dependencies = useDependencies();
117
+
118
+ const functionStatement: OptionalKind<FunctionDeclarationStructure> = {
119
+ isAsync: false,
120
+ isExported: true,
121
+ name: `_${name}Send`,
122
+ parameters,
123
+ returnType: resolveReference(dependencies.StreamableMethod),
124
+ };
125
+
126
+ const operationPath = operation.operation.path;
127
+ const operationMethod = operation.operation.verb.toLowerCase();
128
+ const optionalParamName = getOptionalParamsName(parameters);
129
+ const statements: string[] = [];
130
+ let pathStr = `"${operationPath}"`;
131
+ const urlTemplateParams = [
132
+ ...getPathParameters(operation),
133
+ ...getQueryParameters(dpgContext, operation),
134
+ ];
135
+ if (urlTemplateParams.length > 0) {
136
+ // Generate a unique local variable name that doesn't conflict with parameter names
137
+ const paramNames = new Set(parameters.map((p) => p.name));
138
+ const pathVarName = generateLocallyUniqueName("path", paramNames);
139
+ const includeRootSlash = client ? getClientOptions(client, "includeRootSlash") !== false : true;
140
+
141
+ const uriTemplate = includeRootSlash
142
+ ? operation.operation.uriTemplate
143
+ : operation.operation.uriTemplate.replace(/^\//, "");
144
+
145
+ statements.push(`const ${pathVarName} = ${resolveReference(UrlTemplateHelpers.parseTemplate)}("${uriTemplate}", {
146
+ ${urlTemplateParams.join(",\n")}
147
+ },{
148
+ allowReserved: ${optionalParamName}?.requestOptions?.skipUrlEncoding
149
+ });`);
150
+ pathStr = pathVarName;
151
+ }
152
+
153
+ statements.push(
154
+ `return context.path(${pathStr}).${operationMethod}({...${resolveReference(dependencies.operationOptionsToRequestParameters)}(${optionalParamName}), ${getHeaderAndBodyParameters(
155
+ dpgContext,
156
+ operation,
157
+ optionalParamName,
158
+ )}});`,
159
+ );
160
+
161
+ return {
162
+ ...functionStatement,
163
+ statements,
164
+ };
165
+ }
166
+
167
+ export function getDeserializePrivateFunction(
168
+ context: SdkContext,
169
+ method: [string[], ServiceOperation],
170
+ ): OptionalKind<FunctionDeclarationStructure> {
171
+ const operation = method[1];
172
+ const { name } = getOperationName(operation);
173
+ const dependencies = useDependencies();
174
+ const PathUncheckedResponseReference = resolveReference(dependencies.PathUncheckedResponse);
175
+
176
+ // Check if we need to wrap the non-model return type
177
+ const { shouldWrap, isBinary } = checkWrapNonModelReturn(context, operation);
178
+ // For binary wrap, the deserializer receives PathUncheckedResponse & { blobBody, readableStreamBody }
179
+ // which is returned by getBinaryStreamResponse.
180
+ const isBinaryWrap = shouldWrap && isBinary;
181
+ const isLroOnly = isLroOnlyOperation(operation);
182
+ const isLroAndPaging = isLroAndPagingOperation(operation);
183
+ const isPagingOnly = isPagingOnlyOperation(operation);
184
+
185
+ // TODO: Support operation overloads
186
+ // TODO: Support multiple responses
187
+ const response = operation.response;
188
+ const restResponse = operation.operation.responses[0];
189
+ let returnType;
190
+
191
+ if (isLroOnly || isLroAndPaging) {
192
+ if (isLroOnly && shouldWrap) {
193
+ // For LRO-only operations with non-model final result, wrap in a response type alias
194
+ returnType = {
195
+ name: getOperationResponseTypeName(method),
196
+ type: resolveReference(refkey(operation, "response")),
197
+ };
198
+ } else {
199
+ returnType = buildLroReturnType(context, operation);
200
+ }
201
+ } else if (isPagingOnly && restResponse?.type) {
202
+ // For paging operations, use the full response model (e.g., _OperationListResult)
203
+ // instead of just the array element type
204
+ returnType = {
205
+ name: (restResponse as any).name ?? "",
206
+ type: getTypeExpression(context, restResponse.type),
207
+ };
208
+ } else if (shouldWrap) {
209
+ // Use the wrapper response type name (resolved via binder for cross-file imports)
210
+ returnType = {
211
+ name: getOperationResponseTypeName(method),
212
+ type: resolveReference(refkey(operation, "response")),
213
+ };
214
+ } else if (response.type) {
215
+ // When response.optional is true, some HTTP responses have no body (e.g. 204), so
216
+ // the return type must include undefined to reflect that possibility.
217
+ const baseType = getTypeExpression(context, response.type);
218
+ returnType = {
219
+ name: (response as any).name ?? "",
220
+ type: response.optional ? `${baseType} | undefined` : baseType,
221
+ };
222
+ } else if (isHeadAsBooleanOperation(operation)) {
223
+ returnType = { name: "", type: "boolean" };
224
+ } else {
225
+ returnType = { name: "", type: "void" };
226
+ }
227
+
228
+ const resultParamName = "result";
229
+ const resultParamType = isBinaryWrap
230
+ ? `${PathUncheckedResponseReference} & ${returnType.type}`
231
+ : PathUncheckedResponseReference;
232
+ const parameters: OptionalKind<ParameterDeclarationStructure>[] = [
233
+ {
234
+ name: resultParamName,
235
+ type: resultParamType,
236
+ },
237
+ ];
238
+ const functionStatement: OptionalKind<FunctionDeclarationStructure> = {
239
+ isAsync: true,
240
+ isExported: true,
241
+ name: `_${name}Deserialize`,
242
+ parameters,
243
+ returnType: `Promise<${returnType.type}>`,
244
+ };
245
+ const statements: string[] = [];
246
+ const createRestErrorReference = resolveReference(dependencies.createRestError);
247
+ statements.push(`const expectedStatuses = ${getExpectedStatuses(operation)};`);
248
+ statements.push(
249
+ `if(!expectedStatuses.includes(result.status)){`,
250
+ `${getExceptionThrowStatement(context, operation)}`,
251
+ "}",
252
+ );
253
+ const deserializedType =
254
+ isLroOnly || isLroAndPaging
255
+ ? operation?.lroMetadata?.finalResponse?.result
256
+ : isPagingOnly && restResponse?.type
257
+ ? restResponse.type
258
+ : response.type;
259
+ const lroSubSegments = isLroOnly
260
+ ? operation?.lroMetadata?.finalResponse?.resultSegments
261
+ : undefined;
262
+
263
+ let lroSubPath;
264
+ if (lroSubSegments && lroSubSegments.length > 0) {
265
+ lroSubPath = lroSubSegments
266
+ .map((property) => {
267
+ return property.name;
268
+ })
269
+ .join(".");
270
+ }
271
+
272
+ const deserializePrefix = "result.body";
273
+
274
+ const deserializedRoot = `${deserializePrefix}${lroSubPath ? "." + lroSubPath : ""}`;
275
+ if (isLroOnly && lroSubPath) {
276
+ statements.push(
277
+ `if(${deserializedRoot.split(".").join("?.")} === undefined) {
278
+ throw ${createRestErrorReference}(\`Expected a result in the response at position "${deserializedRoot}"\`, result);
279
+ }
280
+ `,
281
+ );
282
+ }
283
+
284
+ if (deserializedType) {
285
+ // When the method response is optional (some HTTP responses have no body, e.g. 204),
286
+ // guard all body deserialization so we return undefined instead of throwing.
287
+ // This only applies to non-LRO, non-paging operations where the deserialized type
288
+ // comes from response.type (not from LRO metadata or paging).
289
+ const needsBodyGuard = response.optional && !isLroOnly && !isLroAndPaging && !isPagingOnly;
290
+
291
+ const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
292
+ const isXml = isXmlPayload(contentTypes);
293
+ const isDualFormat = hasDualFormatSupport(contentTypes);
294
+ const isMultipart = isMultipartPayload(contentTypes);
295
+ const useXmlDeserialization =
296
+ isXml && deserializedType.kind === "model" && hasXmlSerialization(deserializedType);
297
+
298
+ // Workaround for multipart response: cast return value as any due to lack of multipart response handling in core
299
+ const multipartCastSuffix = isMultipart ? " as any" : "";
300
+
301
+ // For dual-format responses, check content-type header at runtime
302
+ if (
303
+ isDualFormat &&
304
+ deserializedType.kind === "model" &&
305
+ hasXmlSerialization(deserializedType)
306
+ ) {
307
+ if (needsBodyGuard) {
308
+ statements.push(
309
+ `if (!result.body) {
310
+ return result.body as ${returnType.type};
311
+ }`,
312
+ );
313
+ }
314
+ const xmlDeserializerName = buildXmlModelDeserializer(context, deserializedType, {
315
+ nameOnly: true,
316
+ skipDiscriminatedUnionSuffix: false,
317
+ }) as string | undefined;
318
+ const jsonDeserializerName = buildModelDeserializer(context, deserializedType, {
319
+ nameOnly: true,
320
+ skipDiscriminatedUnionSuffix: false,
321
+ });
322
+
323
+ if (xmlDeserializerName && jsonDeserializerName) {
324
+ const isXmlContentTypeRef = resolveReference(XmlHelpers.isXmlContentType);
325
+ statements.push(
326
+ `const responseContentType = result.headers?.["content-type"] ?? "";
327
+ if (${isXmlContentTypeRef}(responseContentType)) {
328
+ return ${xmlDeserializerName}(${deserializedRoot});
329
+ }
330
+ return ${jsonDeserializerName}(${deserializedRoot});`,
331
+ );
332
+ } else {
333
+ // Fall back to JSON deserializer
334
+ const deserializeFunctionName = buildModelDeserializer(context, deserializedType, {
335
+ nameOnly: true,
336
+ skipDiscriminatedUnionSuffix: false,
337
+ });
338
+ if (deserializeFunctionName) {
339
+ statements.push(`return ${deserializeFunctionName}(${deserializedRoot})`);
340
+ }
341
+ }
342
+ } else if (useXmlDeserialization) {
343
+ // XML-only response
344
+ if (needsBodyGuard) {
345
+ statements.push(
346
+ `if (!result.body) {
347
+ return result.body as ${returnType.type};
348
+ }`,
349
+ );
350
+ }
351
+ const xmlDeserializerName = buildXmlModelDeserializer(context, deserializedType, {
352
+ nameOnly: true,
353
+ skipDiscriminatedUnionSuffix: false,
354
+ }) as string | undefined;
355
+
356
+ if (xmlDeserializerName) {
357
+ statements.push(`return ${xmlDeserializerName}(${deserializedRoot})`);
358
+ } else {
359
+ // Fall back to JSON deserializer if XML deserializer is not available
360
+ const deserializeFunctionName = buildModelDeserializer(context, deserializedType, {
361
+ nameOnly: true,
362
+ skipDiscriminatedUnionSuffix: false,
363
+ });
364
+ if (deserializeFunctionName) {
365
+ statements.push(`return ${deserializeFunctionName}(${deserializedRoot})`);
366
+ } else {
367
+ statements.push(`return ${deserializedRoot}`);
368
+ }
369
+ }
370
+ } else {
371
+ // JSON response (default) - also handles multipart responses
372
+ const deserializeFunctionName = buildModelDeserializer(context, deserializedType, {
373
+ nameOnly: true,
374
+ skipDiscriminatedUnionSuffix: false,
375
+ });
376
+ // Handle wrap-non-model-return for non-LRO, non-paging and LRO-only operations
377
+ if (shouldWrap) {
378
+ if (isBinary) {
379
+ // Binary wrap: getBinaryStream already resolved the stream,
380
+ // status check and error.details handling ran above.
381
+ // Return the platform-specific stream properties.
382
+ statements.push(
383
+ `return { blobBody: result.blobBody, readableStreamBody: result.readableStreamBody };`,
384
+ );
385
+ } else if (isHeadAsBooleanOperation(operation)) {
386
+ // HEAD has no body; derive boolean from status code
387
+ statements.push(`return { body: result.status.startsWith("2") };`);
388
+ } else {
389
+ // Non-model response: wrap with body property
390
+ // Generate the appropriate deserialization for the body value.
391
+ // For LRO operations, deserializedRoot may include the sub-path (e.g. result.body.someProperty).
392
+ const bodyValue = deserializeResponseValue(
393
+ context,
394
+ deserializedType,
395
+ deserializedRoot,
396
+ true,
397
+ getEncodeForType(deserializedType),
398
+ );
399
+ statements.push(`return { body: ${bodyValue} };`);
400
+ }
401
+ return {
402
+ ...functionStatement,
403
+ statements,
404
+ };
405
+ }
406
+ if (deserializeFunctionName) {
407
+ if (needsBodyGuard) {
408
+ // Use ternary form: return result.body ? deserializer(result.body) : undefined
409
+ statements.push(
410
+ `return ${deserializedRoot} ? ${deserializeFunctionName}(${deserializedRoot})${multipartCastSuffix} : undefined`,
411
+ );
412
+ } else {
413
+ statements.push(
414
+ `return ${deserializeFunctionName}(${deserializedRoot})${multipartCastSuffix}`,
415
+ );
416
+ }
417
+ } else if (isAzureCoreErrorType(context.program, deserializedType.__raw)) {
418
+ statements.push(`return ${deserializedRoot}${multipartCastSuffix}`);
419
+ } else if (isHeadAsBooleanOperation(operation)) {
420
+ // HEAD has no body; derive boolean from status code
421
+ statements.push(`return result.status.startsWith("2");`);
422
+ } else {
423
+ statements.push(
424
+ `return ${deserializeResponseValue(
425
+ context,
426
+ deserializedType,
427
+ deserializedRoot,
428
+ true,
429
+ isBinaryPayload(
430
+ context,
431
+ response.type!.__raw!,
432
+ contentTypes,
433
+ getEncodeForType(response.type!),
434
+ )
435
+ ? "binary"
436
+ : getEncodeForType(deserializedType),
437
+ )}${multipartCastSuffix}`,
438
+ );
439
+ }
440
+ }
441
+ } else if (isHeadAsBooleanOperation(operation)) {
442
+ if (shouldWrap) {
443
+ statements.push(`return { body: result.status.startsWith("2") };`);
444
+ } else {
445
+ statements.push(`return result.status.startsWith("2");`);
446
+ }
447
+ } else {
448
+ statements.push("return;");
449
+ }
450
+
451
+ return {
452
+ ...functionStatement,
453
+ statements,
454
+ };
455
+ }
456
+
457
+ /**
458
+ * Generates a private function to deserialize response headers.
459
+ * Only generated when response headers are present and include-headers-in-response
460
+ * or enable-storage-compat is enabled.
461
+ */
462
+ export function getDeserializeHeadersPrivateFunction(
463
+ context: SdkContext,
464
+ operation: ServiceOperation,
465
+ ): OptionalKind<FunctionDeclarationStructure> | undefined {
466
+ const responseHeaders = getResponseHeaders(operation.operation.responses);
467
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
468
+ const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
469
+
470
+ // Only generate if headers exist and a relevant feature is enabled
471
+ if (responseHeaders.length === 0 || (!isResponseHeadersEnabled && !isStorageCompatEnabled)) {
472
+ return undefined;
473
+ }
474
+
475
+ const { name } = getOperationName(operation);
476
+ const dependencies = useDependencies();
477
+ const PathUncheckedResponseReference = resolveReference(dependencies.PathUncheckedResponse);
478
+
479
+ const parameters: OptionalKind<ParameterDeclarationStructure>[] = [
480
+ {
481
+ name: "result",
482
+ type: PathUncheckedResponseReference,
483
+ },
484
+ ];
485
+
486
+ const returnType = buildHeaderOnlyResponseType(context, responseHeaders);
487
+
488
+ const functionStatement: OptionalKind<FunctionDeclarationStructure> = {
489
+ isAsync: false,
490
+ isExported: true,
491
+ name: `_${name}DeserializeHeaders`,
492
+ parameters,
493
+ returnType,
494
+ };
495
+
496
+ const statements: string[] = [];
497
+ statements.push(`return ${buildHeaderOnlyResponseValue(context, responseHeaders)};`);
498
+
499
+ return {
500
+ ...functionStatement,
501
+ statements,
502
+ };
503
+ }
504
+
505
+ interface ExceptionThrowDetail {
506
+ start: number;
507
+ end?: number;
508
+ deserializer: string;
509
+ xmlDeserializer?: string;
510
+ /** Whether the exception response is XML-only (no JSON content type) */
511
+ isXmlOnly?: boolean;
512
+ }
513
+
514
+ interface OperationExceptionDetails {
515
+ customized: ExceptionThrowDetail[];
516
+ defaultDeserializer?: string;
517
+ defaultXmlDeserializer?: string;
518
+ /** Whether the default exception response is XML-only */
519
+ defaultIsXmlOnly?: boolean;
520
+ }
521
+
522
+ function getExceptionDetails(
523
+ context: SdkContext,
524
+ operation: ServiceOperation,
525
+ ): OperationExceptionDetails {
526
+ const customized: ExceptionThrowDetail[] = [];
527
+ let defaultDeserializer: string | undefined;
528
+ let defaultXmlDeserializer: string | undefined;
529
+ let defaultIsXmlOnly: boolean | undefined;
530
+ for (const exception of operation.operation.exceptions) {
531
+ if (!exception.type) {
532
+ continue;
533
+ }
534
+ const statusCode = exception.statusCodes;
535
+ const deserializeFunctionName = buildModelDeserializer(context, exception.type, {
536
+ nameOnly: true,
537
+ skipDiscriminatedUnionSuffix: false,
538
+ });
539
+ if (!deserializeFunctionName || typeof deserializeFunctionName !== "string") {
540
+ continue;
541
+ }
542
+
543
+ // Check if the exception type has XML serialization support
544
+ // Use exception contentTypes when available, otherwise check the type itself
545
+ const exceptionContentTypes = exception.contentTypes ?? [];
546
+ const exceptionIsXml = isXmlPayload(exceptionContentTypes);
547
+ const exceptionIsDualFormat = hasDualFormatSupport(exceptionContentTypes);
548
+ const typeHasXml = exception.type.kind === "model" && hasXmlSerialization(exception.type);
549
+
550
+ let xmlDeserializerName: string | undefined;
551
+ if (exception.type.kind === "model" && (typeHasXml || exceptionIsXml)) {
552
+ const xmlName = buildXmlModelDeserializer(context, exception.type, {
553
+ nameOnly: true,
554
+ skipDiscriminatedUnionSuffix: false,
555
+ });
556
+ if (typeof xmlName === "string") {
557
+ xmlDeserializerName = xmlName;
558
+ }
559
+ }
560
+
561
+ // XML-only when all content types are XML (no JSON support)
562
+ const isXmlOnly = xmlDeserializerName !== undefined && exceptionIsXml && !exceptionIsDualFormat;
563
+
564
+ if (statusCode === "*") {
565
+ defaultDeserializer = deserializeFunctionName;
566
+ defaultXmlDeserializer = xmlDeserializerName;
567
+ defaultIsXmlOnly = isXmlOnly;
568
+ } else if (typeof statusCode === "number") {
569
+ customized.push({
570
+ start: statusCode,
571
+ deserializer: deserializeFunctionName,
572
+ xmlDeserializer: xmlDeserializerName,
573
+ isXmlOnly,
574
+ });
575
+ } else {
576
+ customized.push({
577
+ start: statusCode.start,
578
+ end: statusCode.end,
579
+ deserializer: deserializeFunctionName,
580
+ xmlDeserializer: xmlDeserializerName,
581
+ isXmlOnly,
582
+ });
583
+ }
584
+ }
585
+ return {
586
+ customized,
587
+ defaultDeserializer,
588
+ defaultXmlDeserializer,
589
+ defaultIsXmlOnly,
590
+ };
591
+ }
592
+
593
+ /**
594
+ * Collects and deduplicates all response headers from operation exceptions.
595
+ */
596
+ function getExceptionResponseHeaders(
597
+ exceptions: SdkHttpOperation["exceptions"],
598
+ ): SdkServiceResponseHeader[] {
599
+ const headerMap = new Map<string, SdkServiceResponseHeader>();
600
+ for (const exception of exceptions ?? []) {
601
+ for (const header of exception.headers ?? []) {
602
+ if (shouldSkipHeaderSerialization(header)) continue;
603
+ const key = header.serializedName ?? header.name;
604
+ if (!headerMap.has(key)) {
605
+ headerMap.set(key, header);
606
+ }
607
+ }
608
+ }
609
+ return Array.from(headerMap.values());
610
+ }
611
+
612
+ /**
613
+ * Generates a private function to deserialize exception response headers.
614
+ * Only generated when exception headers are present and include-headers-in-response is enabled.
615
+ */
616
+ export function getDeserializeExceptionHeadersPrivateFunction(
617
+ context: SdkContext,
618
+ operation: ServiceOperation,
619
+ ): OptionalKind<FunctionDeclarationStructure> | undefined {
620
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
621
+ if (!isResponseHeadersEnabled) {
622
+ return undefined;
623
+ }
624
+
625
+ const exceptionHeaders = getExceptionResponseHeaders(operation.operation.exceptions);
626
+ if (exceptionHeaders.length === 0) {
627
+ return undefined;
628
+ }
629
+
630
+ const { name } = getOperationName(operation);
631
+ const dependencies = useDependencies();
632
+ const PathUncheckedResponseReference = resolveReference(dependencies.PathUncheckedResponse);
633
+
634
+ const parameters: OptionalKind<ParameterDeclarationStructure>[] = [
635
+ {
636
+ name: "result",
637
+ type: PathUncheckedResponseReference,
638
+ },
639
+ ];
640
+
641
+ const returnType = buildHeaderOnlyResponseType(context, exceptionHeaders);
642
+
643
+ const functionStatement: OptionalKind<FunctionDeclarationStructure> = {
644
+ isAsync: false,
645
+ isExported: true,
646
+ name: `_${name}DeserializeExceptionHeaders`,
647
+ parameters,
648
+ returnType,
649
+ };
650
+
651
+ const statements: string[] = [];
652
+ statements.push(`return ${buildHeaderOnlyResponseValue(context, exceptionHeaders)};`);
653
+
654
+ return {
655
+ ...functionStatement,
656
+ statements,
657
+ };
658
+ }
659
+
660
+ function getExceptionDeserializeExpr(exception: ExceptionThrowDetail): string {
661
+ if (!exception.xmlDeserializer) {
662
+ return `${exception.deserializer}(result.body)`;
663
+ }
664
+ if (exception.isXmlOnly) {
665
+ return `${exception.xmlDeserializer}(result.body)`;
666
+ }
667
+ return `isXml ? ${exception.xmlDeserializer}(result.body) : ${exception.deserializer}(result.body)`;
668
+ }
669
+
670
+ function getExceptionThrowStatement(context: SdkContext, operation: ServiceOperation) {
671
+ const statements = [];
672
+ const createRestErrorReference = resolveReference(useDependencies().createRestError);
673
+ const { customized, defaultDeserializer, defaultXmlDeserializer, defaultIsXmlOnly } =
674
+ getExceptionDetails(context, operation);
675
+
676
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
677
+
678
+ // Check if exception headers function exists and build the call
679
+ const exceptionHeaders = getExceptionResponseHeaders(operation.operation.exceptions);
680
+ const hasExceptionHeaders = isResponseHeadersEnabled && exceptionHeaders.length > 0;
681
+ const { name: opName } = getOperationName(operation);
682
+ const exceptionHeadersCall = hasExceptionHeaders
683
+ ? `error.details = {...(error.details as any), ..._${opName}DeserializeExceptionHeaders(result)};`
684
+ : undefined;
685
+
686
+ // Build @clientOption("header", ...) extraction code (independent of include-headers-in-response)
687
+ const clientOptionHeadersCall = buildClientOptionHeadersCall(operation.operation.exceptions);
688
+
689
+ // Build @clientOption("restErrorCodeHeader", ...) code to set error.code from a header
690
+ const restErrorCodeAssignment = buildRestErrorCodeAssignment(operation.operation.exceptions);
691
+
692
+ const allHeaderCalls = [exceptionHeadersCall, clientOptionHeadersCall, restErrorCodeAssignment]
693
+ .filter(Boolean)
694
+ .join("\n");
695
+
696
+ // Check if any exception has XML deserialization support that requires runtime content-type check
697
+ const hasAnyDualFormatXml =
698
+ (defaultXmlDeserializer !== undefined && !defaultIsXmlOnly) ||
699
+ customized.some((e) => e.xmlDeserializer !== undefined && !e.isXmlOnly);
700
+
701
+ if (customized.length > 0) {
702
+ statements.push(`const error = ${createRestErrorReference}(result);`);
703
+ if (hasAnyDualFormatXml) {
704
+ const isXmlContentTypeRef = resolveReference(XmlHelpers.isXmlContentType);
705
+ statements.push(`const responseContentType = result.headers?.["content-type"] ?? "";`);
706
+ statements.push(`const isXml = ${isXmlContentTypeRef}(responseContentType);`);
707
+ }
708
+ statements.push(`const statusCode = Number.parseInt(result.status);`);
709
+ const stats: string[] = customized.map((exception) => {
710
+ const deserializeExpr = getExceptionDeserializeExpr(exception);
711
+ const headerStmt = allHeaderCalls;
712
+ if (exception.end) {
713
+ return `if(statusCode >= ${exception.start} && statusCode <= ${exception.end}) {
714
+ if(result.body) { error.details = ${deserializeExpr}; }
715
+ ${headerStmt}
716
+ }`;
717
+ } else {
718
+ return `if(statusCode === ${exception.start}) {
719
+ if(result.body) { error.details = ${deserializeExpr}; }
720
+ ${headerStmt}
721
+ }`;
722
+ }
723
+ });
724
+ statements.push(stats.join("\nelse "));
725
+ if (defaultDeserializer) {
726
+ const defaultDeserializeExpr = !defaultXmlDeserializer
727
+ ? `${defaultDeserializer}(result.body)`
728
+ : defaultIsXmlOnly
729
+ ? `${defaultXmlDeserializer}(result.body)`
730
+ : `isXml ? ${defaultXmlDeserializer}(result.body) : ${defaultDeserializer}(result.body)`;
731
+ statements.push(`else {
732
+ if(result.body) { error.details = ${defaultDeserializeExpr}; }
733
+ ${allHeaderCalls}
734
+ }`);
735
+ }
736
+ statements.push("throw error;");
737
+ } else {
738
+ if (defaultDeserializer) {
739
+ if (defaultXmlDeserializer) {
740
+ if (defaultIsXmlOnly) {
741
+ statements.push(`const error = ${createRestErrorReference}(result);
742
+ if(result.body) { error.details = ${defaultXmlDeserializer}(result.body); }
743
+ ${allHeaderCalls}`);
744
+ } else {
745
+ const isXmlContentTypeRef = resolveReference(XmlHelpers.isXmlContentType);
746
+ statements.push(`const error = ${createRestErrorReference}(result);
747
+ const responseContentType = result.headers?.["content-type"] ?? "";
748
+ if(result.body) { error.details = ${isXmlContentTypeRef}(responseContentType) ? ${defaultXmlDeserializer}(result.body) : ${defaultDeserializer}(result.body); }
749
+ ${allHeaderCalls}`);
750
+ }
751
+ } else {
752
+ statements.push(`const error = ${createRestErrorReference}(result);
753
+ if(result.body) { error.details = ${defaultDeserializer}(result.body); }
754
+ ${allHeaderCalls}`);
755
+ }
756
+ statements.push("throw error;");
757
+ } else {
758
+ statements.push(`throw ${createRestErrorReference}(result);`);
759
+ }
760
+ }
761
+ return statements.join("\n");
762
+ }
763
+
764
+ /**
765
+ * Builds the code to extract header values from @clientOption("header", ...) decorators
766
+ * on exception model types. This is independent of include-headers-in-response.
767
+ */
768
+ function buildClientOptionHeadersCall(
769
+ exceptions: SdkHttpOperation["exceptions"],
770
+ ): string | undefined {
771
+ const seenProperties = new Set<string>();
772
+ const assignments: string[] = [];
773
+
774
+ for (const exception of exceptions ?? []) {
775
+ if (!exception.type || exception.type.kind !== "model") {
776
+ continue;
777
+ }
778
+ const headerOptions = getHeaderClientOptions(exception.type);
779
+ for (const opt of headerOptions) {
780
+ if (seenProperties.has(opt.propertyName)) {
781
+ continue;
782
+ }
783
+ seenProperties.add(opt.propertyName);
784
+ assignments.push(`${opt.propertyName}: result.headers[${JSON.stringify(opt.headerName)}]`);
785
+ }
786
+ }
787
+
788
+ if (assignments.length === 0) {
789
+ return undefined;
790
+ }
791
+
792
+ return `error.details = {...(error.details as any), ${assignments.join(", ")}};`;
793
+ }
794
+
795
+ /**
796
+ * Builds the code to conditionally set error.code from a response header,
797
+ * based on @clientOption("restErrorCodeHeader", ...) on exception model types.
798
+ */
799
+ function buildRestErrorCodeAssignment(
800
+ exceptions: SdkHttpOperation["exceptions"],
801
+ ): string | undefined {
802
+ for (const exception of exceptions ?? []) {
803
+ if (!exception.type || exception.type.kind !== "model") {
804
+ continue;
805
+ }
806
+ const headerName = getRestErrorCodeHeader(exception.type);
807
+ if (headerName) {
808
+ return `const restErrorCodeValue = result.headers[${JSON.stringify(headerName)}];
809
+ if (restErrorCodeValue !== undefined) { error.code = restErrorCodeValue; }`;
810
+ }
811
+ }
812
+ return undefined;
813
+ }
814
+
815
+ function getOptionalParamsName(parameters: OptionalKind<ParameterDeclarationStructure>[]) {
816
+ return (
817
+ parameters.filter((p) => p.type?.toString().endsWith("operationOptions__"))[0]?.name ??
818
+ "options"
819
+ );
820
+ }
821
+
822
+ function getOperationSignatureParameters(
823
+ context: SdkContext,
824
+ method: [string[], ServiceOperation],
825
+ clientType: string,
826
+ ): OptionalKind<ParameterDeclarationStructure>[] {
827
+ const operation = method[1];
828
+ const optionsType = resolveReference(refkey(method[1], "operationOptions"));
829
+ const parameters: Map<string, OptionalKind<ParameterDeclarationStructure>> = new Map();
830
+
831
+ operation.parameters
832
+ .filter(
833
+ (p) =>
834
+ p.onClient === false &&
835
+ p.type.kind !== "constant" &&
836
+ operation.operation.parameters.filter((param) => {
837
+ return (
838
+ param.methodParameterSegments.length === 1 &&
839
+ param.methodParameterSegments[0]?.length === 1 &&
840
+ param.methodParameterSegments[0]?.[0] === p
841
+ );
842
+ })[0]?.kind !== "cookie" &&
843
+ !p.optional &&
844
+ !(p.isGeneratedName && (p.name === "contentType" || p.name === "accept")) && // skip tcgc generated contentType and accept header parameter
845
+ getClientOptions(p, "headerCollectionPrefix") === undefined, // skip headers with collection prefix
846
+ )
847
+ .map((p) => {
848
+ return {
849
+ name: p.name,
850
+ type: getTypeExpression(context, p.type),
851
+ };
852
+ })
853
+ .forEach((p) => {
854
+ parameters.set(p.name, p);
855
+ });
856
+
857
+ // Add context as the first parameter
858
+ const contextParam = { name: "context", type: clientType };
859
+
860
+ // Add the options parameter
861
+ const optionsParam = {
862
+ name: parameters.has("options") ? "optionalParams" : "options",
863
+ type: optionsType,
864
+ initializer: "{ requestOptions: {} }",
865
+ };
866
+
867
+ const finalParameters = [contextParam, ...parameters.values(), optionsParam];
868
+
869
+ return finalParameters;
870
+ }
871
+
872
+ /**
873
+ * This operation builds and returns the function declaration for an operation.
874
+ */
875
+ export function getOperationFunction(
876
+ context: SdkContext,
877
+ method: [string[], ServiceOperation],
878
+ clientType: string,
879
+ ): FunctionDeclarationStructure & {
880
+ propertyName?: string;
881
+ isLro?: boolean;
882
+ lroFinalReturnType?: string;
883
+ isLroPaging?: boolean;
884
+ lropagingFinalReturnType?: string;
885
+ } {
886
+ const operation = method[1];
887
+ // Extract required parameters
888
+ const parameters: OptionalKind<ParameterDeclarationStructure>[] = getOperationSignatureParameters(
889
+ context,
890
+ method,
891
+ clientType,
892
+ );
893
+ const optionalParamName = getOptionalParamsName(parameters);
894
+ if (isPagingOnlyOperation(operation)) {
895
+ // Case 1: paging-only operation
896
+ return getPagingOnlyOperationFunction(context, [method[0], operation], clientType);
897
+ } else if (isLroOnlyOperation(operation)) {
898
+ // Case 2: lro-only operation
899
+ return getLroOnlyOperationFunction(
900
+ context,
901
+ [method[0], operation],
902
+ clientType,
903
+ optionalParamName,
904
+ );
905
+ } else if (isLroAndPagingOperation(operation)) {
906
+ // Case 3: both paging + lro operation
907
+ return getLroAndPagingOperationFunction(
908
+ context,
909
+ [method[0], operation],
910
+ clientType,
911
+ optionalParamName,
912
+ );
913
+ }
914
+
915
+ // TODO: Support operation overloads
916
+ const response = operation.response;
917
+ const responseHeaders = getResponseHeaders(operation.operation.responses);
918
+ const hasHeaderOnlyResponse = !response.type && responseHeaders.length > 0;
919
+ const isResponseHeadersEnabled = context.rlcOptions?.includeHeadersInResponse === true;
920
+ const isStorageCompatEnabled = context.rlcOptions?.enableStorageCompat === true;
921
+
922
+ // Track the raw body type separately for storage-compat (before header merging)
923
+ const hasResponseBody = !!response.type;
924
+ let bodyType = "void";
925
+ if (response.type) {
926
+ bodyType = getTypeExpression(context, response.type!);
927
+ }
928
+
929
+ // Check if we need to wrap the non-model return type
930
+ const { shouldWrap: wrapReturn, isBinary: wrapReturnIsBinary } = checkWrapNonModelReturn(
931
+ context,
932
+ operation,
933
+ );
934
+
935
+ let returnType = { name: "", type: "void" };
936
+ if (wrapReturn) {
937
+ // Use the wrapper response type name (resolved via binder for cross-file imports)
938
+ returnType = {
939
+ name: getOperationResponseTypeName(method),
940
+ type: resolveReference(refkey(operation, "response")),
941
+ };
942
+ bodyType = returnType.type;
943
+ } else if (response.type) {
944
+ const type = response.type;
945
+
946
+ // If feature flag enabled, we'll append the response headers to the operation response type.
947
+ if (type.kind === "model" && responseHeaders.length > 0 && isResponseHeadersEnabled) {
948
+ // Build a composite type that includes both model and additional header properties
949
+ const baseCompositeType = buildCompositeResponseType(context, type, responseHeaders);
950
+ returnType = {
951
+ name: (type as any).name ?? "",
952
+ type: response.optional ? `${baseCompositeType} | undefined` : baseCompositeType,
953
+ };
954
+ } else {
955
+ const baseType = getTypeExpression(context, type!);
956
+ returnType = {
957
+ name: (type as any).name ?? "",
958
+ type: response.optional ? `${baseType} | undefined` : baseType,
959
+ };
960
+ }
961
+ } else if (hasHeaderOnlyResponse && isResponseHeadersEnabled) {
962
+ // Here we handle returning headers when the operation return type is void
963
+ returnType = {
964
+ name: "",
965
+ type: `${buildHeaderOnlyResponseType(context, responseHeaders)}`,
966
+ };
967
+ } else if (isHeadAsBooleanOperation(operation)) {
968
+ returnType = { name: "", type: "boolean" };
969
+ }
970
+
971
+ // When storage-compat is enabled, wrap the return type with StorageCompatResponseInfo
972
+ // Use the raw body type (not the header-augmented return type) for TBody
973
+ let finalReturnType = returnType.type;
974
+ if (isStorageCompatEnabled) {
975
+ const storageCompatInfoRef = resolveReference(StorageCompatHelpers.StorageCompatResponseInfo);
976
+ const headersType =
977
+ responseHeaders.length > 0
978
+ ? buildHeaderOnlyResponseType(context, responseHeaders)
979
+ : "Record<string, unknown>";
980
+ if (!hasResponseBody) {
981
+ if (responseHeaders.length > 0) {
982
+ // Void with headers — headers at top level + StorageCompatResponseInfo
983
+ finalReturnType = `${headersType} & ${storageCompatInfoRef}<undefined, ${headersType}>`;
984
+ } else {
985
+ // Void without headers — just StorageCompatResponseInfo
986
+ finalReturnType = `${storageCompatInfoRef}<undefined, ${headersType}>`;
987
+ }
988
+ } else {
989
+ if (responseHeaders.length > 0) {
990
+ // Body with headers — headers + body + StorageCompatResponseInfo at top level
991
+ finalReturnType = `${headersType} & ${bodyType} & ${storageCompatInfoRef}<${bodyType}, ${headersType}>`;
992
+ } else {
993
+ // Body without headers — body + StorageCompatResponseInfo
994
+ finalReturnType = `${bodyType} & ${storageCompatInfoRef}<${bodyType}, ${headersType}>`;
995
+ }
996
+ }
997
+ }
998
+
999
+ const { name, fixme = [] } = getOperationName(operation, context);
1000
+ const functionStatement = {
1001
+ kind: StructureKind.Function,
1002
+ docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
1003
+ isAsync: true,
1004
+ isExported: true,
1005
+ name,
1006
+ propertyName: normalizeName(operation.name, NameType.Property),
1007
+ parameters,
1008
+ returnType: `Promise<${finalReturnType}>`,
1009
+ };
1010
+
1011
+ const statements: string[] = [];
1012
+
1013
+ // Generate unique local variable names that don't conflict with parameter names
1014
+ const paramNames = new Set(parameters.map((p) => p.name));
1015
+ const resultVarName = generateLocallyUniqueName("result", paramNames);
1016
+
1017
+ const parameterList = parameters.map((p) => p.name).join(", ");
1018
+ // When storage-compat is enabled, set up the onResponse interceptor before sending
1019
+ const storageCompatVarName = generateLocallyUniqueName("_storageCompat", paramNames);
1020
+ if (isStorageCompatEnabled) {
1021
+ const createOnResponseRef = resolveReference(
1022
+ StorageCompatHelpers.createStorageCompatOnResponse,
1023
+ );
1024
+ statements.push(
1025
+ `const ${storageCompatVarName} = ${createOnResponseRef}(${optionalParamName}.onResponse);`,
1026
+ );
1027
+ }
1028
+
1029
+ // Build the parameterList for the send call, injecting onResponse when storage-compat is enabled
1030
+ const sendParameterList = isStorageCompatEnabled
1031
+ ? parameterList.replace(
1032
+ optionalParamName,
1033
+ `{...${optionalParamName}, onResponse: ${storageCompatVarName}.onResponse}`,
1034
+ )
1035
+ : parameterList;
1036
+
1037
+ // Special case for binary-only bodies: use helper to call streaming methods so that Core doesn't poison the response body by
1038
+ // doing a UTF-8 decode on the raw bytes.
1039
+ // For binary wrap, use getBinaryStreamResponse which preserves blobBody/readableStreamBody properties.
1040
+ // For non-wrapped binary, use getBinaryResponse which buffers the body into Uint8Array.
1041
+ if (response?.type?.kind === "bytes" && response.type.encode === "bytes") {
1042
+ const streamableMethodVarName = generateLocallyUniqueName("streamableMethod", paramNames);
1043
+ statements.push(`const ${streamableMethodVarName} = _${name}Send(${sendParameterList});`);
1044
+ const binaryHelper =
1045
+ wrapReturn && wrapReturnIsBinary
1046
+ ? SerializationHelpers.getBinaryStreamResponse
1047
+ : SerializationHelpers.getBinaryResponse;
1048
+ statements.push(
1049
+ `const ${resultVarName} = await ${resolveReference(binaryHelper)}(${streamableMethodVarName});`,
1050
+ );
1051
+ } else {
1052
+ statements.push(`const ${resultVarName} = await _${name}Send(${sendParameterList});`);
1053
+ }
1054
+
1055
+ // If the response has headers and the feature flag to include headers in response is enabled, build the headers object and include it in the return value
1056
+ if (isStorageCompatEnabled) {
1057
+ // Storage-compat mode: wrap the return value with _response metadata using captured PipelineResponse
1058
+ const addStorageCompatRef = resolveReference(StorageCompatHelpers.addStorageCompatResponse);
1059
+ const parsedBodyVarName = generateLocallyUniqueName("parsedBody", paramNames);
1060
+ const parsedHeadersVarName = generateLocallyUniqueName("parsedHeaders", paramNames);
1061
+
1062
+ // Deserialize body
1063
+ if (!hasResponseBody) {
1064
+ statements.push(`await _${name}Deserialize(${resultVarName});`);
1065
+ } else {
1066
+ statements.push(`const ${parsedBodyVarName} = await _${name}Deserialize(${resultVarName});`);
1067
+ }
1068
+
1069
+ // Deserialize headers if present
1070
+ if (responseHeaders.length > 0) {
1071
+ statements.push(
1072
+ `const ${parsedHeadersVarName} = _${name}DeserializeHeaders(${resultVarName});`,
1073
+ );
1074
+ }
1075
+
1076
+ // Build the return statement using captured PipelineResponse
1077
+ const bodyArg = !hasResponseBody ? "undefined" : parsedBodyVarName;
1078
+ const headersArg = responseHeaders.length > 0 ? parsedHeadersVarName : "{}";
1079
+ statements.push(
1080
+ `return ${addStorageCompatRef}(${storageCompatVarName}.getRawResponse()!, ${bodyArg}, ${headersArg});`,
1081
+ );
1082
+ } else if (responseHeaders.length > 0 && isResponseHeadersEnabled) {
1083
+ const headersVarName = generateLocallyUniqueName("headers", paramNames);
1084
+ statements.push(`const ${headersVarName} = _${name}DeserializeHeaders(result);`);
1085
+
1086
+ // If there is no body payload just return the headers
1087
+ if (hasHeaderOnlyResponse) {
1088
+ statements.push(`await _${name}Deserialize(${resultVarName});`);
1089
+ statements.push(`return {...${headersVarName} };`);
1090
+ } else {
1091
+ const payloadVarName = generateLocallyUniqueName("payload", paramNames);
1092
+ statements.push(`const ${payloadVarName} = await _${name}Deserialize(${resultVarName});`);
1093
+ statements.push(`return { ...${payloadVarName}, ...${headersVarName} };`);
1094
+ }
1095
+ } else {
1096
+ statements.push(`return _${name}Deserialize(${resultVarName});`);
1097
+ }
1098
+
1099
+ return {
1100
+ ...functionStatement,
1101
+ statements,
1102
+ } as FunctionDeclarationStructure & { propertyName?: string };
1103
+ }
1104
+
1105
+ function getLroOnlyOperationFunction(
1106
+ context: SdkContext,
1107
+ method: [string[], SdkLroServiceMethod<SdkHttpOperation>],
1108
+ clientType: string,
1109
+ optionalParamName: string = "options",
1110
+ ): FunctionDeclarationStructure & {
1111
+ propertyName?: string;
1112
+ isLro?: boolean;
1113
+ lroFinalReturnType?: string;
1114
+ } {
1115
+ const operation = method[1];
1116
+ // Extract required parameters
1117
+ const parameters: OptionalKind<ParameterDeclarationStructure>[] = getOperationSignatureParameters(
1118
+ context,
1119
+ method,
1120
+ clientType,
1121
+ );
1122
+ const returnType = buildLroReturnType(context, operation);
1123
+ const { name, fixme = [] } = getOperationName(operation, context);
1124
+ const pollerLikeReference = resolveReference(AzurePollingDependencies.PollerLike);
1125
+ const operationStateReference = resolveReference(AzurePollingDependencies.OperationState);
1126
+
1127
+ // When wrap-non-model-return is enabled and the LRO final result is a non-model type,
1128
+ // use the wrapper response type (e.g. GetIkeSasResponse) instead of the raw type (e.g. string).
1129
+ const { shouldWrap } = checkWrapNonModelReturn(context, operation as ServiceOperation);
1130
+ const effectiveReturnTypeStr = shouldWrap
1131
+ ? (resolveReference(refkey(operation, "response")) as string)
1132
+ : returnType.type;
1133
+ const effectiveReturnTypeName = shouldWrap
1134
+ ? getOperationResponseTypeName(method as [string[], ServiceOperation])
1135
+ : returnType.type;
1136
+
1137
+ const functionStatement = {
1138
+ kind: StructureKind.Function,
1139
+ docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
1140
+ isAsync: false,
1141
+ isExported: true,
1142
+ name,
1143
+ propertyName: normalizeName(operation.name, NameType.Property),
1144
+ isLro: true,
1145
+ lroFinalReturnType: effectiveReturnTypeName,
1146
+ parameters,
1147
+ returnType: `${pollerLikeReference}<${operationStateReference}<${effectiveReturnTypeStr}>, ${effectiveReturnTypeStr}>`,
1148
+ };
1149
+
1150
+ const getLongRunningPollerReference = resolveReference(PollingHelpers.GetLongRunningPoller);
1151
+ const lroMetadata =
1152
+ operation.kind === "lro" || operation.kind === "lropaging" ? operation.lroMetadata : undefined;
1153
+ const allowedFinalLocation = [
1154
+ "azure-async-operation",
1155
+ "location",
1156
+ "original-uri",
1157
+ "operation-location",
1158
+ ];
1159
+ const resourceLocationConfig =
1160
+ lroMetadata?.finalStateVia && allowedFinalLocation.includes(lroMetadata?.finalStateVia)
1161
+ ? `resourceLocationConfig: "${lroMetadata?.finalStateVia}",`
1162
+ : "";
1163
+ const apiVersion = getApiVersionExpression(context, operation);
1164
+ const statements: string[] = [];
1165
+
1166
+ statements.push(`
1167
+
1168
+ return ${getLongRunningPollerReference}(context, _${name}Deserialize, ${getExpectedStatuses(
1169
+ operation,
1170
+ )}, {
1171
+ updateIntervalInMs: ${optionalParamName}?.updateIntervalInMs,
1172
+ abortSignal: ${optionalParamName}?.abortSignal,
1173
+ getInitialResponse: () => _${name}Send(${parameters.map((p) => p.name).join(", ")}),
1174
+ ${resourceLocationConfig}
1175
+ ${apiVersion ? `apiVersion: ${apiVersion}` : ""}
1176
+ }) as ${pollerLikeReference}<${operationStateReference}<${effectiveReturnTypeStr}>, ${effectiveReturnTypeStr}>;
1177
+ `);
1178
+
1179
+ return {
1180
+ ...functionStatement,
1181
+ statements,
1182
+ } as FunctionDeclarationStructure & { propertyName?: string };
1183
+ }
1184
+
1185
+ function getLroAndPagingOperationFunction(
1186
+ context: SdkContext,
1187
+ method: [string[], SdkLroPagingServiceMethod<SdkHttpOperation>],
1188
+ clientType: string,
1189
+ optionalParamName: string = "options",
1190
+ ): FunctionDeclarationStructure & {
1191
+ isLroPaging?: boolean;
1192
+ propertyName?: string;
1193
+ lropagingFinalReturnType?: string;
1194
+ } {
1195
+ const operation = method[1];
1196
+ const parameters = getOperationSignatureParameters(context, method, clientType);
1197
+ const { name, fixme = [] } = getOperationName(operation, context);
1198
+
1199
+ const returnType = buildLroPagingReturnType(context, operation);
1200
+
1201
+ // Get apiVersion expression for both LRO poller and paging options
1202
+ const apiVersion = getApiVersionExpression(context, operation);
1203
+
1204
+ // Build paging options from metadata
1205
+ const pagingOptions = [
1206
+ operation.response.resultSegments &&
1207
+ `itemName: "${operation.response.resultSegments.map((p) => p.name).join(".")}"`,
1208
+ operation.pagingMetadata.nextLinkSegments &&
1209
+ `nextLinkName: "${operation.pagingMetadata.nextLinkSegments.map((p) => p.name).join(".")}"`,
1210
+ operation.pagingMetadata.nextLinkVerb !== "GET" &&
1211
+ `nextLinkMethod: "${operation.pagingMetadata.nextLinkVerb}"`,
1212
+ apiVersion && `apiVersion: ${apiVersion}`,
1213
+ ].filter(Boolean);
1214
+
1215
+ // Build LRO resource location config
1216
+ const allowedLocations = [
1217
+ "azure-async-operation",
1218
+ "location",
1219
+ "original-uri",
1220
+ "operation-location",
1221
+ ];
1222
+ const resourceLocationConfig =
1223
+ operation.lroMetadata?.finalStateVia &&
1224
+ allowedLocations.includes(operation.lroMetadata.finalStateVia)
1225
+ ? `resourceLocationConfig: "${operation.lroMetadata.finalStateVia}",`
1226
+ : "";
1227
+
1228
+ // Resolve references
1229
+ const refs = {
1230
+ pagedIterator: resolveReference(PagingHelpers.PagedAsyncIterableIterator),
1231
+ buildPaging: resolveReference(PagingHelpers.BuildPagedAsyncIterator),
1232
+ getLroPoller: resolveReference(PollingHelpers.GetLongRunningPoller),
1233
+ pollerLike: resolveReference(AzurePollingDependencies.PollerLike),
1234
+ operationState: resolveReference(AzurePollingDependencies.OperationState),
1235
+ pathResponse: resolveReference(useDependencies().PathUncheckedResponse),
1236
+ };
1237
+
1238
+ const expectedStatuses = getExpectedStatuses(operation);
1239
+ const paramList = parameters.map((p) => p.name).join(", ");
1240
+ const pagingOptionsStr = pagingOptions.length > 0 ? `,\n {${pagingOptions.join(", ")}}` : "";
1241
+
1242
+ return {
1243
+ kind: StructureKind.Function,
1244
+ docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
1245
+ isAsync: false,
1246
+ isExported: true,
1247
+ isLroPaging: true,
1248
+ lropagingFinalReturnType: returnType.type,
1249
+ name,
1250
+ propertyName: normalizeName(operation.name, NameType.Property),
1251
+ parameters,
1252
+ returnType: `${refs.pagedIterator}<${returnType.type}>`,
1253
+ statements: [
1254
+ `
1255
+ const initialPagingPoller = ${refs.getLroPoller}(context,
1256
+ async (result: ${refs.pathResponse}) => result,
1257
+ ${expectedStatuses}, {
1258
+ updateIntervalInMs: ${optionalParamName}?.updateIntervalInMs,
1259
+ abortSignal: ${optionalParamName}?.abortSignal,
1260
+ getInitialResponse: () => _${name}Send(${paramList}),
1261
+ ${resourceLocationConfig}
1262
+ ${apiVersion ? `apiVersion: ${apiVersion}` : ""}
1263
+ }) as ${refs.pollerLike}<${refs.operationState}<${refs.pathResponse}>, ${refs.pathResponse}>;
1264
+
1265
+ return ${refs.buildPaging}(
1266
+ context,
1267
+ async () => await initialPagingPoller,
1268
+ _${name}Deserialize,
1269
+ ${expectedStatuses}${pagingOptionsStr}
1270
+ );
1271
+ `,
1272
+ ],
1273
+ };
1274
+ }
1275
+
1276
+ function buildLroReturnType(
1277
+ context: SdkContext,
1278
+ operation: SdkLroServiceMethod<SdkHttpOperation> | SdkLroPagingServiceMethod<SdkHttpOperation>,
1279
+ ) {
1280
+ const metadata = operation.lroMetadata;
1281
+ if (metadata !== undefined && metadata.finalResponse !== undefined) {
1282
+ const type = metadata.finalResponse.result;
1283
+ return {
1284
+ name: type.name,
1285
+ type: getTypeExpression(context, type),
1286
+ };
1287
+ }
1288
+ return { name: "", type: "void" };
1289
+ }
1290
+
1291
+ function buildLroPagingReturnType(
1292
+ context: SdkContext,
1293
+ operation: SdkLroPagingServiceMethod<SdkHttpOperation>,
1294
+ ) {
1295
+ if (operation.response.type?.kind === "array") {
1296
+ return {
1297
+ name: (operation.response.type.valueType as any).name ?? "",
1298
+ type: getTypeExpression(context, operation.response.type.valueType),
1299
+ };
1300
+ }
1301
+ return { name: "", type: "void" };
1302
+ }
1303
+
1304
+ function getPagingOnlyOperationFunction(
1305
+ context: SdkContext,
1306
+ method: [string[], SdkPagingServiceMethod<SdkHttpOperation>],
1307
+ clientType: string,
1308
+ ): FunctionDeclarationStructure & { propertyName?: string } {
1309
+ const operation = method[1];
1310
+ // Extract required parameters
1311
+ const parameters: OptionalKind<ParameterDeclarationStructure>[] = getOperationSignatureParameters(
1312
+ context,
1313
+ method,
1314
+ clientType,
1315
+ );
1316
+
1317
+ // TODO: Support operation overloads
1318
+ const response = operation.response;
1319
+ let returnType = { name: "", type: "void" };
1320
+ if (response.type && response.type.kind === "array") {
1321
+ const type = response.type;
1322
+ returnType = {
1323
+ name: (type.valueType as any).name ?? "",
1324
+ type: getTypeExpression(context, type.valueType),
1325
+ };
1326
+ }
1327
+ const { name, fixme = [] } = getOperationName(operation, context);
1328
+ const pagedAsyncIterableIteratorReference = resolveReference(
1329
+ PagingHelpers.PagedAsyncIterableIterator,
1330
+ );
1331
+ const buildPagedAsyncIteratorReference = resolveReference(PagingHelpers.BuildPagedAsyncIterator);
1332
+ const functionStatement = {
1333
+ kind: StructureKind.Function,
1334
+ docs: [...getDocsFromDescription(operation.doc), ...getFixmeForMultilineDocs(fixme)],
1335
+ isAsync: false,
1336
+ isExported: true,
1337
+ name,
1338
+ propertyName: normalizeName(operation.name, NameType.Property),
1339
+ parameters,
1340
+ returnType: `${pagedAsyncIterableIteratorReference}<${returnType.type}>`,
1341
+ };
1342
+
1343
+ const statements: string[] = [];
1344
+ const options = [];
1345
+ // TODO: follow up on https://github.com/Azure/typespec-azure/issues/2103
1346
+ const nextLinkSegments = operation.pagingMetadata.nextLinkSegments;
1347
+ const nextLinkName = nextLinkSegments
1348
+ ?.map((property) => {
1349
+ return property.name;
1350
+ })
1351
+ .join(".");
1352
+ const itemSegments = operation.response.resultSegments;
1353
+ const itemName = itemSegments
1354
+ ?.map((property) => {
1355
+ return property.name;
1356
+ })
1357
+ .join(".");
1358
+
1359
+ // Check for nextLinkVerb from TCGC pagingMetadata (supports @Legacy.nextLinkVerb decorator)
1360
+ const nextLinkMethod = operation.pagingMetadata.nextLinkVerb;
1361
+
1362
+ const apiVersion = getApiVersionExpression(context, operation);
1363
+
1364
+ if (itemName) {
1365
+ options.push(`itemName: "${itemName}"`);
1366
+ }
1367
+ if (nextLinkName) {
1368
+ options.push(`nextLinkName: "${nextLinkName}"`);
1369
+ }
1370
+ if (nextLinkMethod && nextLinkMethod !== "GET") {
1371
+ options.push(`nextLinkMethod: "${nextLinkMethod}"`);
1372
+ }
1373
+ if (apiVersion) {
1374
+ options.push(`apiVersion: ${apiVersion}`);
1375
+ }
1376
+ statements.push(
1377
+ `return ${buildPagedAsyncIteratorReference}(
1378
+ context,
1379
+ () => _${name}Send(${parameters.map((p) => p.name).join(", ")}),
1380
+ _${name}Deserialize,
1381
+ ${getExpectedStatuses(operation)}${options.length > 0 ? `,\n {${options.join(", ")}}` : ""}
1382
+ );`,
1383
+ );
1384
+
1385
+ return {
1386
+ ...functionStatement,
1387
+ statements,
1388
+ } as FunctionDeclarationStructure & { propertyName?: string };
1389
+ }
1390
+
1391
+ export function getOperationOptionsName(
1392
+ method: [string[], ServiceOperation],
1393
+ includeGroupName = false,
1394
+ ) {
1395
+ const prefixes = method[0];
1396
+ const operation = method[1];
1397
+ const prefix =
1398
+ includeGroupName && operation.name.indexOf("_") === -1
1399
+ ? getClassicalLayerPrefix(prefixes, NameType.Interface)
1400
+ : "";
1401
+ const optionName = `${prefix}${normalizeName(operation.name, NameType.Interface)}OptionalParams`;
1402
+ return optionName;
1403
+ }
1404
+
1405
+ /**
1406
+ * This function build the request parameters that we will provide to the
1407
+ * RLC internally. This will translate High Level parameters into the RLC ones.
1408
+ * Figuring out what goes in headers, body, path and qsp.
1409
+ */
1410
+ function getHeaderAndBodyParameters(
1411
+ dpgContext: SdkContext,
1412
+ operation: ServiceOperation,
1413
+ optionalParamName: string = "options",
1414
+ ): string {
1415
+ if (!operation.operation.parameters) {
1416
+ return "";
1417
+ }
1418
+ const operationParameters = operation.operation.parameters.filter((p) => !isContentType(p));
1419
+
1420
+ const contentTypeParameter = operation.operation.parameters.find(isContentType);
1421
+
1422
+ const parametersImplementation: Record<
1423
+ "header" | "body",
1424
+ { paramMap: string; param: SdkHttpParameter; paramAccessor: string }[]
1425
+ > = {
1426
+ header: [],
1427
+ body: [],
1428
+ };
1429
+
1430
+ for (const param of operationParameters) {
1431
+ if (param.kind === "header") {
1432
+ // skip tcgc generated contentType and accept non constant type header parameter
1433
+ if (
1434
+ param.isGeneratedName &&
1435
+ !isConstant(param.type) &&
1436
+ (param.name === "contentType" || param.name === "accept")
1437
+ ) {
1438
+ continue;
1439
+ }
1440
+ // Skip headers marked with headerCollectionPrefix client option
1441
+ if (shouldSkipHeaderSerialization(param)) {
1442
+ continue;
1443
+ }
1444
+ // Check if this parameter still exists in the corresponding method params (after override)
1445
+ if (param.methodParameterSegments && param.methodParameterSegments.length > 0) {
1446
+ const paramAccessor = getParamAccessor(param, optionalParamName);
1447
+ parametersImplementation[param.kind].push({
1448
+ paramMap: getParameterMap(dpgContext, param, paramAccessor),
1449
+ param,
1450
+ paramAccessor,
1451
+ });
1452
+ }
1453
+ }
1454
+ }
1455
+
1456
+ let paramStr = "";
1457
+
1458
+ if (contentTypeParameter) {
1459
+ paramStr = `${getContentTypeValue(contentTypeParameter, optionalParamName)},`;
1460
+ }
1461
+
1462
+ if (parametersImplementation.header.length) {
1463
+ paramStr = `${paramStr}\nheaders: {${parametersImplementation.header
1464
+ .map((i) => buildHeaderParameter(dpgContext.program, i.paramMap, i.param, i.paramAccessor))
1465
+ .join(",\n")}, ...${optionalParamName}.requestOptions?.headers },`;
1466
+ }
1467
+ if (operation.operation.bodyParam === undefined && parametersImplementation.body.length) {
1468
+ paramStr = `${paramStr}\nbody: {${parametersImplementation.body
1469
+ .map((i) => i.paramMap)
1470
+ .join(",\n")}}`;
1471
+ } else if (operation.operation.bodyParam !== undefined) {
1472
+ paramStr = `${paramStr}${buildBodyParameter(dpgContext, operation.operation.bodyParam)}`;
1473
+ }
1474
+ return paramStr;
1475
+ }
1476
+
1477
+ // Specially handle the type for headers because we only allow string/number/boolean values
1478
+ function buildHeaderParameter(
1479
+ program: Program,
1480
+ paramMap: string,
1481
+ param: SdkHttpParameter,
1482
+ paramAccessor: string,
1483
+ ): string {
1484
+ const effectiveOptional = getEffectiveOptional(param);
1485
+ if (!effectiveOptional && isTypeNullable(param.type) === true) {
1486
+ reportDiagnostic(program, {
1487
+ code: "nullable-required-header",
1488
+ target: NoTarget,
1489
+ });
1490
+ return paramMap;
1491
+ }
1492
+
1493
+ // If the param has a clientDefaultValue that type-matches, the paramMap already contains
1494
+ // `?? defaultValue` from getOptional(). In this case, always send the header (do not
1495
+ // conditionally omit it when the accessor is undefined) so the default is always applied.
1496
+ const hasEffectiveDefaultValue = effectiveOptional && hasEffectiveClientDefaultValue(param);
1497
+
1498
+ const conditions = [];
1499
+ if (effectiveOptional && !hasEffectiveDefaultValue) {
1500
+ conditions.push(`${paramAccessor} !== undefined`);
1501
+ }
1502
+ if (isTypeNullable(param.type) === true) {
1503
+ conditions.push(`${paramAccessor} !== null`);
1504
+ }
1505
+ return conditions.length > 0 ? `...(${conditions.join(" && ")} ? {${paramMap}} : {})` : paramMap;
1506
+ }
1507
+
1508
+ function buildBodyParameter(
1509
+ context: SdkContext,
1510
+ bodyParameter: SdkBodyParameter | undefined,
1511
+ optionalParamName: string = "options",
1512
+ ) {
1513
+ if (!bodyParameter || !bodyParameter.type) {
1514
+ return "";
1515
+ }
1516
+
1517
+ const contentTypes = bodyParameter.contentTypes;
1518
+ const isXml = isXmlPayload(contentTypes);
1519
+ const isDualFormat = hasDualFormatSupport(contentTypes);
1520
+ const bodyType = getNullableValidType(bodyParameter.type);
1521
+
1522
+ // Check if XML serialization is needed and available
1523
+ const useXmlSerialization = isXml && bodyType.kind === "model" && hasXmlSerialization(bodyType);
1524
+
1525
+ let serializerFunctionName: string | undefined;
1526
+
1527
+ if (useXmlSerialization) {
1528
+ // Use XML serializer
1529
+ serializerFunctionName = buildXmlModelSerializer(context, bodyType, {
1530
+ nameOnly: true,
1531
+ skipDiscriminatedUnionSuffix: false,
1532
+ }) as string | undefined;
1533
+ } else {
1534
+ // Use JSON serializer (default)
1535
+ serializerFunctionName = buildModelSerializer(context, bodyType, {
1536
+ nameOnly: true,
1537
+ skipDiscriminatedUnionSuffix: false,
1538
+ }) as string | undefined;
1539
+ }
1540
+
1541
+ let bodyNameExpression = getParamAccessor(bodyParameter, optionalParamName);
1542
+
1543
+ // Check if body parameter has a client default value with matching type
1544
+ const hasClientDefault = bodyParameter.optional && hasEffectiveClientDefaultValue(bodyParameter);
1545
+
1546
+ // Apply client default value if present for optional body parameters
1547
+ if (hasClientDefault) {
1548
+ const formattedDefault = formatDefaultValue(bodyParameter.clientDefaultValue);
1549
+ bodyNameExpression = `(${bodyNameExpression} ?? ${formattedDefault})`;
1550
+ }
1551
+
1552
+ // Build null guard using bodyNameExpression so it stays consistent with the
1553
+ // accessor path (especially for nested body parameters like options?.body?.x).
1554
+ // Skip when there's a client default value since it already handles null/undefined.
1555
+ const needsNullGuard =
1556
+ !hasClientDefault &&
1557
+ (bodyParameter.optional ||
1558
+ isTypeNullable(bodyParameter.type) ||
1559
+ bodyNameExpression.includes("?."));
1560
+ const nullOrUndefinedPrefix = needsNullGuard
1561
+ ? `!${bodyNameExpression}? ${bodyNameExpression}:`
1562
+ : "";
1563
+
1564
+ // For dual-format operations, check the contentType option at runtime
1565
+ if (isDualFormat && bodyType.kind === "model" && hasXmlSerialization(bodyType)) {
1566
+ const xmlSerializerName = buildXmlModelSerializer(context, bodyType, {
1567
+ nameOnly: true,
1568
+ skipDiscriminatedUnionSuffix: false,
1569
+ }) as string | undefined;
1570
+ const jsonSerializerName = buildModelSerializer(context, bodyType, {
1571
+ nameOnly: true,
1572
+ skipDiscriminatedUnionSuffix: false,
1573
+ }) as string | undefined;
1574
+
1575
+ if (xmlSerializerName && jsonSerializerName) {
1576
+ const isXmlContentTypeRef = resolveReference(XmlHelpers.isXmlContentType);
1577
+ return `\nbody: ${nullOrUndefinedPrefix}(${isXmlContentTypeRef}(${optionalParamName}?.contentType ?? "application/json") ? ${xmlSerializerName}(${bodyNameExpression}) : ${jsonSerializerName}(${bodyNameExpression})),`;
1578
+ }
1579
+ }
1580
+
1581
+ // if a model being used in both spread and non spread operation, we should only leverage the deserializer in non spread operation
1582
+ if (serializerFunctionName && !isSpreadBodyParameter(bodyParameter)) {
1583
+ return `\nbody: ${nullOrUndefinedPrefix}${serializerFunctionName}(${bodyNameExpression}),`;
1584
+ } else if (isAzureCoreErrorType(context.program, bodyParameter.type.__raw)) {
1585
+ return `\nbody: ${nullOrUndefinedPrefix}${bodyNameExpression},`;
1586
+ }
1587
+ const serializedBody = serializeRequestValue(
1588
+ context,
1589
+ bodyParameter.type,
1590
+ bodyNameExpression,
1591
+ !bodyParameter.optional,
1592
+ isBinaryPayload(
1593
+ context,
1594
+ bodyParameter.__raw!,
1595
+ bodyParameter.contentTypes,
1596
+ getEncodeForType(bodyParameter.type),
1597
+ )
1598
+ ? "binary"
1599
+ : getEncodeForType(bodyParameter.type),
1600
+ undefined,
1601
+ true,
1602
+ );
1603
+ return `\nbody: ${serializedBody.startsWith(nullOrUndefinedPrefix) ? "" : nullOrUndefinedPrefix}${serializedBody},`;
1604
+ }
1605
+
1606
+ function getEncodingFormat(type: { format?: string }) {
1607
+ const supportedFormats = ["base64url", "base64", "byte"];
1608
+
1609
+ if (!supportedFormats.includes(type.format ?? "")) {
1610
+ return "base64";
1611
+ }
1612
+
1613
+ return type.format;
1614
+ }
1615
+
1616
+ /**
1617
+ * This function helps with renames, translating client names to rest api names
1618
+ */
1619
+ export function getParameterMap(
1620
+ context: SdkContext,
1621
+ param: SdkHttpParameter,
1622
+ paramAccessor: string,
1623
+ ): string {
1624
+ // Use lowercase for header names since HTTP headers are case-insensitive
1625
+ const serializedName =
1626
+ param.kind === "header" ? getHeaderSerializedName(param) : getPropertySerializedName(param);
1627
+
1628
+ if (isConstant(param.type) && !isOptional(param)) {
1629
+ return `"${serializedName}": ${getConstantValue(param.type)}`;
1630
+ }
1631
+
1632
+ // Special case for api-version parameters with default values
1633
+ if (param.isApiVersionParam && param.clientDefaultValue) {
1634
+ // For multi-service, use only the default value (don't reference context.apiVersion)
1635
+ if (context.rlcOptions?.isMultiService) {
1636
+ return `"${serializedName}": "${param.clientDefaultValue}"`;
1637
+ }
1638
+ return `"${serializedName}": ${param.onClient ? "context." : ""}${param.name} ?? "${param.clientDefaultValue}"`;
1639
+ }
1640
+
1641
+ if (hasCollectionFormatInfo(param.kind, (param as any).collectionFormat)) {
1642
+ return getCollectionFormatForParam(context, param, paramAccessor, serializedName);
1643
+ }
1644
+
1645
+ // if the parameter or property is optional, we don't need to handle the default value
1646
+ if (isOptional(param)) {
1647
+ return getOptional(context, param, serializedName, paramAccessor);
1648
+ }
1649
+
1650
+ if (isRequired(param)) {
1651
+ return getRequired(context, param, serializedName, paramAccessor);
1652
+ }
1653
+
1654
+ reportDiagnostic(context.program, {
1655
+ code: "unsupported-parameter-type",
1656
+ format: {
1657
+ paramName: param.name,
1658
+ paramKind: param.kind,
1659
+ },
1660
+ target: param.__raw || NoTarget,
1661
+ });
1662
+
1663
+ // Return a fallback value to allow the emitter to continue
1664
+ return `"${param.name}": undefined`;
1665
+ }
1666
+
1667
+ function getCollectionFormatForParam(
1668
+ context: SdkContext,
1669
+ param: SdkHttpParameter,
1670
+ paramAccessor: string,
1671
+ serializedName: string,
1672
+ ) {
1673
+ const format = (param as any).collectionFormat;
1674
+ return `"${serializedName}": ${serializeRequestValue(
1675
+ context,
1676
+ param.type,
1677
+ paramAccessor,
1678
+ !param.optional,
1679
+ format,
1680
+ serializedName,
1681
+ true,
1682
+ )}`;
1683
+ }
1684
+
1685
+ function isContentType(param: SdkHttpParameter): boolean {
1686
+ return param.kind === "header" && param.serializedName.toLowerCase() === "content-type";
1687
+ }
1688
+
1689
+ function getContentTypeValue(param: SdkHttpParameter, optionalParamName: string = "options") {
1690
+ const defaultValue = param.clientDefaultValue;
1691
+ // allow customers to customize the content type if it's guessed by tcgc.
1692
+ if (isConstant(param.type)) {
1693
+ return `contentType: ${getConstantValue(param.type)}`;
1694
+ }
1695
+ if (defaultValue) {
1696
+ return `contentType: ${optionalParamName}.${param.name} as any ?? "${defaultValue}"`;
1697
+ } else {
1698
+ return `contentType: ${
1699
+ !param.optional
1700
+ ? normalizeName(param.name, NameType.Property)
1701
+ : `${optionalParamName}.` + param.name + " as any"
1702
+ }`;
1703
+ }
1704
+ }
1705
+
1706
+ /**
1707
+ * Gets the effective optionality for an HTTP parameter by checking
1708
+ * the linked method parameter via methodParameterSegments.
1709
+ * This is needed because @@override can change a method parameter's
1710
+ * optionality without updating the HTTP parameter's optional flag.
1711
+ * For client-level parameters (onClient), preserve the HTTP parameter's own flag.
1712
+ */
1713
+ function getEffectiveOptional(param: SdkHttpParameter): boolean {
1714
+ // For client-level parameters, the HTTP parameter's optional flag is authoritative
1715
+ if (param.onClient) {
1716
+ return Boolean(param.optional);
1717
+ }
1718
+ // For method-level parameters with a direct mapping to a single method param,
1719
+ // use the method parameter's optional flag (correctly reflects @@override changes)
1720
+ if (
1721
+ param.methodParameterSegments?.length === 1 &&
1722
+ param.methodParameterSegments[0]?.length === 1
1723
+ ) {
1724
+ const methodParam = param.methodParameterSegments[0]![0];
1725
+ if (methodParam) {
1726
+ return Boolean(methodParam.optional);
1727
+ }
1728
+ }
1729
+ return Boolean(param.optional);
1730
+ }
1731
+
1732
+ function isRequired(param: SdkHttpParameter) {
1733
+ return !getEffectiveOptional(param);
1734
+ }
1735
+
1736
+ function getRequired(
1737
+ context: SdkContext,
1738
+ param: SdkHttpParameter,
1739
+ serializedName: string,
1740
+ paramAccessor: string,
1741
+ ) {
1742
+ if (param.type.kind === "model") {
1743
+ const propertiesStr = getRequestModelMapping(
1744
+ context,
1745
+ { ...param.type, optional: param.optional },
1746
+ paramAccessor,
1747
+ );
1748
+ return `"${serializedName}": { ${propertiesStr.join(",")} }`;
1749
+ }
1750
+ return `"${serializedName}": ${serializeRequestValue(
1751
+ context,
1752
+ param.type,
1753
+ paramAccessor,
1754
+ true,
1755
+ getEncodeForType(param.type),
1756
+ serializedName,
1757
+ true,
1758
+ )}`;
1759
+ }
1760
+
1761
+ function getConstantValue(param: SdkConstantType) {
1762
+ if (typeof param.value === "string") {
1763
+ return `"${param.value}"`;
1764
+ }
1765
+ return `${param.value}`;
1766
+ }
1767
+
1768
+ function isConstant(param: SdkType): param is SdkConstantType {
1769
+ return param.kind === "constant";
1770
+ }
1771
+
1772
+ function isOptional(param: SdkHttpParameter) {
1773
+ return getEffectiveOptional(param);
1774
+ }
1775
+
1776
+ function getOptional(
1777
+ context: SdkContext,
1778
+ param: SdkHttpParameter,
1779
+ serializedName: string,
1780
+ paramAccessor: string,
1781
+ ) {
1782
+ // Apply client default value if present and type matches
1783
+ const defaultSuffix = hasEffectiveClientDefaultValue(param)
1784
+ ? ` ?? ${formatDefaultValue(param.clientDefaultValue)}`
1785
+ : "";
1786
+
1787
+ if (param.type.kind === "model") {
1788
+ const propertiesStr = getRequestModelMapping(
1789
+ context,
1790
+ { ...param.type, optional: param.optional },
1791
+ paramAccessor + "?.",
1792
+ );
1793
+ const serializeContent = `{${propertiesStr.join(",")}}`;
1794
+ return `"${serializedName}": ${serializeContent}`;
1795
+ }
1796
+ const serializedValue = serializeRequestValue(
1797
+ context,
1798
+ param.type,
1799
+ paramAccessor,
1800
+ false,
1801
+ getEncodeForType(param.type),
1802
+ serializedName,
1803
+ true,
1804
+ );
1805
+ return `"${serializedName}": ${serializedValue}${defaultSuffix}`;
1806
+ }
1807
+
1808
+ /**
1809
+ * Get the encode for SDK type
1810
+ */
1811
+ function getEncodeForType(type: SdkType | SdkHttpParameter | SdkModelPropertyType) {
1812
+ return (type as any).encode;
1813
+ }
1814
+
1815
+ /**
1816
+ * Get the optionality for SDK type
1817
+ */
1818
+ function getOptionalForType(type: SdkType | SdkHttpParameter | SdkModelPropertyType) {
1819
+ return (type as any).optional;
1820
+ }
1821
+
1822
+ /**
1823
+ * Builds the assignment for when a property or parameter has a default value
1824
+ */
1825
+ function getDefaultValue(param: SdkHttpParameter) {
1826
+ return param.clientDefaultValue;
1827
+ }
1828
+
1829
+ /**
1830
+ * Extracts the path parameters
1831
+ */
1832
+ function getPathParameters(operation: ServiceOperation, optionalParamName: string = "options") {
1833
+ if (!operation.operation.parameters) {
1834
+ return [];
1835
+ }
1836
+
1837
+ const pathParams: string[] = [];
1838
+ for (const param of operation.operation.parameters) {
1839
+ if (param.kind === "path") {
1840
+ const methodParam = param.methodParameterSegments[0]?.[0];
1841
+ if (methodParam) {
1842
+ pathParams.push(
1843
+ `"${param.serializedName}": ${getPathParamExpr(param, getDefaultValue(param) as string, optionalParamName)}`,
1844
+ );
1845
+ }
1846
+ }
1847
+ }
1848
+
1849
+ return pathParams;
1850
+ }
1851
+
1852
+ /**
1853
+ * Extract the query parameters
1854
+ */
1855
+ function getQueryParameters(dpgContext: SdkContext, operation: ServiceOperation): string[] {
1856
+ if (!operation.parameters) {
1857
+ return [];
1858
+ }
1859
+ const operationParameters = operation.operation.parameters.filter((p) => !isContentType(p));
1860
+ const parametersImplementation: Record<"query", { paramMap: string; param: SdkHttpParameter }[]> =
1861
+ {
1862
+ query: [],
1863
+ };
1864
+
1865
+ for (const param of operationParameters) {
1866
+ if (param.kind === "query") {
1867
+ // Check if this parameter still exists in the corresponding method params (after override)
1868
+ if (param.methodParameterSegments && param.methodParameterSegments.length > 0) {
1869
+ const paramAccessor = getParamAccessor(param);
1870
+ parametersImplementation[param.kind].push({
1871
+ paramMap: getParameterMap(
1872
+ dpgContext,
1873
+ {
1874
+ ...param,
1875
+ // TODO: remember to remove this hack once compiler gives us a name
1876
+ // https://github.com/microsoft/typespec/issues/6743
1877
+ serializedName: getUriTemplateQueryParamName(param.serializedName),
1878
+ },
1879
+ paramAccessor,
1880
+ ),
1881
+ param,
1882
+ });
1883
+ }
1884
+ }
1885
+ }
1886
+
1887
+ const paramStr: string[] = parametersImplementation.query.map((i) => i.paramMap);
1888
+
1889
+ return paramStr;
1890
+ }
1891
+
1892
+ function getUriTemplateQueryParamName(name: string) {
1893
+ return `${escapeUriTemplateParamName(name)}`;
1894
+ }
1895
+ function escapeUriTemplateParamName(name: string) {
1896
+ return encodeURIComponent(name).replace(/[:-]/g, function (c) {
1897
+ return "%" + c.charCodeAt(0).toString(16).toUpperCase();
1898
+ });
1899
+ }
1900
+
1901
+ /**
1902
+ * Returns the parameter expression matching the operation signature for an HTTP parameter.
1903
+ * 1. Client-level parameter (`param.onClient`): returns `context.<paramName>`.
1904
+ * 2. Method-level parameter with `methodParameterSegments`: returns the expression
1905
+ * built from those segments (e.g. `options?.ocpDate`, `body.nested`).
1906
+ * 3. Fallback: returns the parameter name directly, with optional chaining if optional.
1907
+ */
1908
+ function getParamAccessor(param: SdkHttpParameter, optionalParamName: string = "options"): string {
1909
+ if (param.isGeneratedName) {
1910
+ return param.name;
1911
+ }
1912
+ const methodParamExpr = getMethodParamExpr(param, optionalParamName);
1913
+ const clientPrefix = "context.";
1914
+ if (methodParamExpr) {
1915
+ return param.onClient ? `${clientPrefix}${methodParamExpr}` : methodParamExpr;
1916
+ }
1917
+ if (param.onClient) {
1918
+ return `${clientPrefix}${getClientParameterName(param)}`;
1919
+ }
1920
+ if (getEffectiveOptional(param)) {
1921
+ return `${optionalParamName}?.${param.name}`;
1922
+ }
1923
+ return param.name;
1924
+ }
1925
+
1926
+ /**
1927
+ * Builds a property accessor expression from the param's `methodParameterSegments`.
1928
+ * Each segment represents a level of property access (e.g. `options?.nested.value`).
1929
+ * Returns `undefined` when no segments are available, so the caller can fall back.
1930
+ */
1931
+ function getMethodParamExpr(
1932
+ param: SdkHttpParameter,
1933
+ optionalParamName: string = "options",
1934
+ ): string | undefined {
1935
+ const segments = param.methodParameterSegments;
1936
+ if (segments.length === 0) {
1937
+ return undefined;
1938
+ }
1939
+ // When there are multiple paths (e.g., a composite body from multiple method
1940
+ // params), we cannot resolve a single accessor — fall back to the caller's logic.
1941
+ if (segments.length > 1) {
1942
+ return undefined;
1943
+ }
1944
+ const path = segments[0];
1945
+ if (!path || path.length < 1) {
1946
+ return undefined;
1947
+ }
1948
+
1949
+ const parts: string[] = [];
1950
+ for (let i = 0; i < path.length; i++) {
1951
+ const segment = path[i]!;
1952
+ if (i === 0) {
1953
+ // Normalize names for client-level segments to match the context interface property names
1954
+ const segmentName = segment.onClient
1955
+ ? getClientParameterName(segment as SdkMethodParameter)
1956
+ : segment.name;
1957
+ if (segment.optional && !segment.onClient) {
1958
+ // If the first segment is optional and not on the client, we need to start with the optionalParamName
1959
+ parts.push(`${optionalParamName}?.`);
1960
+ }
1961
+ parts.push(segmentName);
1962
+ } else {
1963
+ const needsOptionalChain = path[i - 1]!.optional;
1964
+ parts.push(`${needsOptionalChain ? "?." : "."}${segment.name}`);
1965
+ }
1966
+ }
1967
+ return parts.join("");
1968
+ }
1969
+
1970
+ function getPathParamExpr(
1971
+ param: SdkHttpParameter,
1972
+ defaultValue?: string,
1973
+ optionalParamName: string = "options",
1974
+ ) {
1975
+ if (isConstant(param.type)) {
1976
+ return getConstantValue(param.type);
1977
+ }
1978
+
1979
+ const paramName = getParamAccessor(param, optionalParamName);
1980
+
1981
+ return defaultValue
1982
+ ? typeof defaultValue === "string"
1983
+ ? `${paramName} ?? "${defaultValue}"`
1984
+ : `${paramName} ?? ${defaultValue}`
1985
+ : paramName;
1986
+ }
1987
+
1988
+ function getNullableCheck(name: string, type: SdkType) {
1989
+ if (!isTypeNullable(type)) {
1990
+ return "";
1991
+ }
1992
+
1993
+ return `${name} === null ? null :`;
1994
+ }
1995
+
1996
+ /**
1997
+ * Determines the appropriate encoding format for a model property, especially for arrays with collection format encoding.
1998
+ * For example, returns "csv" for comma-delimited arrays or the property's type encoding for regular properties.
1999
+ */
2000
+ function getEncodeForModelProperty(
2001
+ context: SdkContext,
2002
+ property: SdkModelPropertyType,
2003
+ ): string | undefined {
2004
+ if (property.encode && property.type.kind === "array") {
2005
+ // Only arrays of string type or string-based enum type can have collectionFormat encoding
2006
+ if (!isStringEncodableArrayValueType(property.type.valueType)) {
2007
+ reportDiagnostic(context.program, {
2008
+ code: "un-supported-array-encoding",
2009
+ format: {
2010
+ arrayName: property.name,
2011
+ arrayType: property.type.valueType.kind,
2012
+ },
2013
+ target: NoTarget,
2014
+ });
2015
+ return getEncodeForType(property.type);
2016
+ }
2017
+
2018
+ const collectionFormat = getCollectionFormatFromArrayEncoding(property.encode);
2019
+ if (collectionFormat && hasCollectionFormatInfo(property.kind, collectionFormat)) {
2020
+ return collectionFormat;
2021
+ }
2022
+ }
2023
+ return getEncodeForType(property.type);
2024
+ }
2025
+
2026
+ /**
2027
+ * Checks if an array value type is string-encodable for collection format encoding.
2028
+ * This includes both string type and string-based enum types.
2029
+ */
2030
+ function isStringEncodableArrayValueType(valueType: SdkType): boolean {
2031
+ // Direct string type
2032
+ if (valueType.kind === "string") {
2033
+ return true;
2034
+ }
2035
+ // String-based enum type
2036
+ if (valueType.kind === "enum" && (valueType as SdkEnumType).valueType.kind === "string") {
2037
+ return true;
2038
+ }
2039
+ return false;
2040
+ }
2041
+
2042
+ function getSerializationExpressionForFlatten(
2043
+ context: SdkContext,
2044
+ property: SdkModelPropertyType,
2045
+ propertyPath: string,
2046
+ ): string {
2047
+ const serializeFunctionName = buildPropertySerializer(context, property, {
2048
+ nameOnly: true,
2049
+ skipDiscriminatedUnionSuffix: false,
2050
+ });
2051
+ if (!serializeFunctionName) {
2052
+ return property.optional ? `undefined` : `{}`;
2053
+ }
2054
+ const validProps = getAllProperties(
2055
+ context,
2056
+ property.type,
2057
+ getAllAncestors(property.type),
2058
+ ).filter(
2059
+ (p) => p.kind === "property" && !isReadOnly(p) && !isMetadata(context.program, p.__raw!),
2060
+ );
2061
+ const optionalPrefix = property.optional
2062
+ ? `${resolveReference(SerializationHelpers.areAllPropsUndefined)}(${propertyPath}, [${validProps
2063
+ .map((p) => `"${p.name}"`)
2064
+ .join(", ")}]) ? undefined : `
2065
+ : "";
2066
+ return `${optionalPrefix}${serializeFunctionName}(${propertyPath})`;
2067
+ }
2068
+
2069
+ export function getSerializationExpression(
2070
+ context: SdkContext,
2071
+ property: SdkModelPropertyType,
2072
+ propertyPath: string,
2073
+ enableFlatten: boolean = true,
2074
+ ): string {
2075
+ if (property.flatten && property.type.kind === "model" && enableFlatten) {
2076
+ return getSerializationExpressionForFlatten(context, property, "item");
2077
+ }
2078
+ const dot = propertyPath.endsWith("?") ? "." : "";
2079
+ const propertyPathWithDot = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}`;
2080
+ const nullOrUndefinedPrefix = getPropertySerializationPrefix(context, property, propertyPath);
2081
+
2082
+ const propertyFullName = getPropertyFullName(context, property, propertyPathWithDot);
2083
+ const serializeFunctionName = buildModelSerializer(context, getNullableValidType(property.type), {
2084
+ nameOnly: true,
2085
+ skipDiscriminatedUnionSuffix: false,
2086
+ });
2087
+
2088
+ // Apply clientDefaultValue for model properties that have one
2089
+ const defaultValueSuffix = hasEffectiveClientDefaultValue(property)
2090
+ ? ` ?? ${formatDefaultValue(property.clientDefaultValue)}`
2091
+ : "";
2092
+
2093
+ if (serializeFunctionName) {
2094
+ return `${nullOrUndefinedPrefix}${serializeFunctionName}(${propertyFullName})${defaultValueSuffix}`;
2095
+ } else if (isAzureCoreErrorType(context.program, property.type.__raw)) {
2096
+ return `${nullOrUndefinedPrefix}${propertyFullName}${defaultValueSuffix}`;
2097
+ } else {
2098
+ const baseExpr = serializeRequestValue(
2099
+ context,
2100
+ property.type,
2101
+ propertyFullName,
2102
+ !property.optional,
2103
+ getEncodeForModelProperty(context, property),
2104
+ getPropertySerializedName(property),
2105
+ propertyPath === "" ? true : false,
2106
+ );
2107
+ return `${baseExpr}${defaultValueSuffix}`;
2108
+ }
2109
+ }
2110
+
2111
+ export function getRequestModelProperties(
2112
+ context: SdkContext,
2113
+ modelPropertyType: SdkModelType & { optional?: boolean },
2114
+ propertyPath: string = "body",
2115
+ overrides?: ModelOverrideOptions,
2116
+ enableFlatten: boolean = true,
2117
+ ): Array<[string, string]> {
2118
+ const props: [string, string][] = [];
2119
+ const allParents = getAllAncestors(modelPropertyType);
2120
+ const properties: SdkModelPropertyType[] =
2121
+ getAllProperties(context, modelPropertyType, allParents) ?? [];
2122
+ if (properties.length <= 0) {
2123
+ return [];
2124
+ }
2125
+ for (const prop of properties) {
2126
+ if (prop.kind === "property" && isReadOnly(prop)) {
2127
+ continue;
2128
+ }
2129
+ if (isMetadata(context.program, prop.__raw!)) {
2130
+ continue;
2131
+ }
2132
+ const property = getPropertyWithOverrides(prop, overrides);
2133
+ props.push([
2134
+ getPropertySerializedName(property)!,
2135
+ getSerializationExpression(context, property, propertyPath, enableFlatten),
2136
+ ]);
2137
+ }
2138
+
2139
+ return props;
2140
+ }
2141
+
2142
+ /**
2143
+ *
2144
+ * This function helps translating an HLC request to RLC request,
2145
+ * extracting properties from body and headers and building the RLC response object
2146
+ */
2147
+ export function getRequestModelMapping(
2148
+ context: SdkContext,
2149
+ modelPropertyType: SdkModelType & { optional?: boolean },
2150
+ propertyPath: string = "body",
2151
+ overrides?: ModelOverrideOptions,
2152
+ enableFlatten: boolean = true,
2153
+ ): string[] {
2154
+ return getRequestModelProperties(
2155
+ context,
2156
+ modelPropertyType,
2157
+ propertyPath,
2158
+ overrides,
2159
+ enableFlatten,
2160
+ ).map(([name, value]) => `"${name}": ${value}`);
2161
+ }
2162
+
2163
+ export function getPropertySerializedName(property: SdkHttpParameter | SdkModelPropertyType) {
2164
+ return (
2165
+ (property.kind === "property"
2166
+ ? property.serializationOptions.json?.name
2167
+ : property.serializedName) ?? property.name
2168
+ );
2169
+ }
2170
+
2171
+ /**
2172
+ * Get the serialized name for a header parameter, normalized to lowercase.
2173
+ * HTTP headers are case-insensitive, so we normalize to lowercase for consistency.
2174
+ */
2175
+ function getHeaderSerializedName(param: SdkHttpParameter) {
2176
+ return getPropertySerializedName(param).toLowerCase();
2177
+ }
2178
+
2179
+ /**
2180
+ * This function helps translating an RLC response to an HLC response,
2181
+ * extracting properties from body and headers and building the HLC response object
2182
+ */
2183
+ export function getResponseMapping(
2184
+ context: SdkContext,
2185
+ type: SdkType,
2186
+ propertyPath: string = "result.body",
2187
+ overrides?: ModelOverrideOptions,
2188
+ enableFlatten: boolean = true,
2189
+ ) {
2190
+ const allParents = type.kind === "model" ? getAllAncestors(type) : [];
2191
+ const properties = type.kind === "model" ? getAllProperties(context, type, allParents) : [];
2192
+ const props: string[] = [];
2193
+ for (const prop of properties) {
2194
+ if (isMetadata(context.program, prop.__raw!)) {
2195
+ continue;
2196
+ }
2197
+ const property = getPropertyWithOverrides(prop, overrides);
2198
+ const dot = propertyPath.endsWith("?") ? "." : "";
2199
+ const serializedName = getPropertySerializedName(property);
2200
+ const restValue = `${propertyPath ? `${propertyPath}${dot}` : `${dot}`}["${serializedName}"]`;
2201
+
2202
+ const nullOrUndefinedPrefix =
2203
+ property.optional || isTypeNullable(property.type) ? `!${restValue}? ${restValue}: ` : "";
2204
+ const flattenContext = useContext("sdkTypes").flattenProperties.get(property);
2205
+ const isSupportedFlatten = flattenContext && enableFlatten;
2206
+ const deserializeFunctionName = isSupportedFlatten
2207
+ ? buildPropertyDeserializer(context, property, {
2208
+ nameOnly: true,
2209
+ skipDiscriminatedUnionSuffix: false,
2210
+ })
2211
+ : buildModelDeserializer(context, getNullableValidType(property.type), {
2212
+ nameOnly: true,
2213
+ skipDiscriminatedUnionSuffix: false,
2214
+ });
2215
+ const propertyName = normalizeModelPropertyName(context, property);
2216
+ if (deserializeFunctionName) {
2217
+ if (isSupportedFlatten) {
2218
+ props.push(`...${nullOrUndefinedPrefix}${deserializeFunctionName}(${restValue})`);
2219
+ } else {
2220
+ props.push(
2221
+ `${propertyName}: ${nullOrUndefinedPrefix}${deserializeFunctionName}(${restValue})`,
2222
+ );
2223
+ }
2224
+ } else if (isAzureCoreErrorType(context.program, property.type.__raw)) {
2225
+ props.push(`${propertyName}: ${nullOrUndefinedPrefix}${restValue}`);
2226
+ } else {
2227
+ const deserializeValue = deserializeResponseValue(
2228
+ context,
2229
+ property.type,
2230
+ `${propertyPath}${dot}["${serializedName}"]`,
2231
+ !property.optional,
2232
+ getEncodeForModelProperty(context, property),
2233
+ );
2234
+ props.push(`${propertyName}: ${deserializeValue}`);
2235
+ }
2236
+ }
2237
+ return props;
2238
+ }
2239
+
2240
+ /**
2241
+ * Converts JavaScript values to their serialized wire format for HTTP requests.
2242
+ */
2243
+ export function serializeRequestValue(
2244
+ context: SdkContext,
2245
+ type: SdkType,
2246
+ clientValue: string,
2247
+ required: boolean,
2248
+ format?: string,
2249
+ serializedName?: string,
2250
+ isTopLevel: boolean = false,
2251
+ ): string {
2252
+ const getSdkType = useSdkTypes();
2253
+ const dependencies = useDependencies();
2254
+ const nullOrUndefinedPrefix =
2255
+ isTypeNullable(type) || getOptionalForType(type) || !required
2256
+ ? `!${clientValue}? ${clientValue}: `
2257
+ : "";
2258
+ switch (type.kind) {
2259
+ case "plainDate":
2260
+ // plainDate always uses ISO8601 format (YYYY-MM-DD)
2261
+ return `${nullOrUndefinedPrefix}${clientValue}.toISOString().split('T')[0]`;
2262
+ case "utcDateTime":
2263
+ switch (type.encode ?? format) {
2264
+ case "rfc7231":
2265
+ return `${nullOrUndefinedPrefix}${clientValue}.toUTCString()`;
2266
+ case "unixTimestamp":
2267
+ return `${nullOrUndefinedPrefix}((${clientValue}.getTime() / 1000) | 0)`;
2268
+ case "rfc3339":
2269
+ default:
2270
+ return `${nullOrUndefinedPrefix}${clientValue}.toISOString()`;
2271
+ }
2272
+ case "array": {
2273
+ if (type.valueType) {
2274
+ const prefix = nullOrUndefinedPrefix + clientValue;
2275
+ const elementNullOrUndefinedPrefix =
2276
+ isTypeNullable(type.valueType) || getOptionalForType(type.valueType) ? "!p ? p : " : "";
2277
+ const serializeFunctionName = buildModelSerializer(
2278
+ context,
2279
+ getNullableValidType(type.valueType),
2280
+ {
2281
+ nameOnly: true,
2282
+ skipDiscriminatedUnionSuffix: false,
2283
+ },
2284
+ );
2285
+ if (serializeFunctionName) {
2286
+ return `${prefix}.map((p: any) => { return ${elementNullOrUndefinedPrefix}${serializeFunctionName}(p)})`;
2287
+ } else if (isAzureCoreErrorType(context.program, type.valueType.__raw)) {
2288
+ return `${prefix}.map((p: any) => { return ${elementNullOrUndefinedPrefix}p})`;
2289
+ } else {
2290
+ const serializedValue = `${clientValue}.map((p: any) => { return ${elementNullOrUndefinedPrefix}${serializeRequestValue(context, type.valueType, "p", true, getEncodeForType(type.valueType))}})`;
2291
+ if (format) {
2292
+ const formatHelper = getCollectionFormatHelper(format);
2293
+ if (formatHelper) {
2294
+ if (format?.toLowerCase() === KnownCollectionFormat.Multi) {
2295
+ return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue}, "${serializedName}")`;
2296
+ }
2297
+ return `${nullOrUndefinedPrefix}${formatHelper}(${serializedValue})`;
2298
+ }
2299
+ }
2300
+ return `${nullOrUndefinedPrefix}${serializedValue}`;
2301
+ }
2302
+ }
2303
+ return clientValue;
2304
+ }
2305
+ case "bytes":
2306
+ // TODO https://github.com/Azure/typespec-azure/issues/1999
2307
+ if (format !== "binary" && format !== "bytes") {
2308
+ const uint8ArrayToStringReference = resolveReference(dependencies.uint8ArrayToString);
2309
+ return required
2310
+ ? `${getNullableCheck(
2311
+ clientValue,
2312
+ type,
2313
+ )} ${uint8ArrayToStringReference}(${clientValue}, "${
2314
+ getEncodingFormat({ format }) ?? "base64"
2315
+ }")`
2316
+ : `${nullOrUndefinedPrefix} ${uint8ArrayToStringReference}(${clientValue}, "${
2317
+ getEncodingFormat({ format }) ?? "base64"
2318
+ }")`;
2319
+ }
2320
+ return clientValue;
2321
+ case "union":
2322
+ if (isNormalUnion(type)) {
2323
+ return `${clientValue}`;
2324
+ } else if (
2325
+ isSpecialHandledUnion({
2326
+ ...type,
2327
+ isNonExhaustive: context.rlcOptions?.experimentalExtensibleEnums ?? false,
2328
+ })
2329
+ ) {
2330
+ const sdkType = getSdkType(type.__raw!);
2331
+ const serializerRefkey = refkey(sdkType, "serializer");
2332
+ const serializeFunctionName = resolveReference(serializerRefkey);
2333
+ return `${serializeFunctionName}(${clientValue})`;
2334
+ } else {
2335
+ return `${clientValue} as any`;
2336
+ }
2337
+ case "model": // this is to build serialization logic for spread model types
2338
+ return `{${getRequestModelMapping(context, type, "").join(",")}}`;
2339
+ case "constant":
2340
+ if (isTopLevel) {
2341
+ return `${nullOrUndefinedPrefix}${getConstantValue(type)}`;
2342
+ }
2343
+ return clientValue;
2344
+ case "nullable":
2345
+ return serializeRequestValue(
2346
+ context,
2347
+ type.type,
2348
+ clientValue,
2349
+ false,
2350
+ getEncodeForType(type.type),
2351
+ );
2352
+ default:
2353
+ if (clientValue === "constructorParam") {
2354
+ return `${clientValue} as any`;
2355
+ }
2356
+ return clientValue;
2357
+ }
2358
+ }
2359
+
2360
+ /**
2361
+ * Wrapper of deserializeResponseValue, this is used to handle the special cases for response header deserialization, since response header only supports primitive types, we will have a simpler deserialization logic comparing to response body, and we also need to handle the null/undefined cases differently since if a header is missing, the value will be undefined instead of null.
2362
+ * Note: that this has been added to isolate these changes behind the feature flag. Once the feature flag is removed, we can consider merging this back to deserializeResponseValue if the special handling logic is not needed anymore.
2363
+ */
2364
+ export function deserializeResponseHeadersValue(
2365
+ context: SdkContext,
2366
+ type: SdkType,
2367
+ restValue: string,
2368
+ required: boolean,
2369
+ format?: string,
2370
+ recursionDepth: number = 0,
2371
+ ) {
2372
+ const nullOrUndefinedPrefix =
2373
+ isTypeNullable(type) || getOptionalForType(type) || !required
2374
+ ? `${restValue} === undefined || ${restValue} === null ? ${restValue}: `
2375
+ : "";
2376
+
2377
+ switch (type.kind) {
2378
+ case "constant":
2379
+ return `${restValue} as any`;
2380
+ case "boolean":
2381
+ return `${nullOrUndefinedPrefix} ${restValue}.trim().toLowerCase() === "true"`;
2382
+ case "int16":
2383
+ case "int32":
2384
+ case "int64":
2385
+ case "uint16":
2386
+ case "uint32":
2387
+ case "uint64":
2388
+ case "float":
2389
+ case "decimal":
2390
+ case "decimal128":
2391
+ case "float32":
2392
+ case "float64":
2393
+ case "int8":
2394
+ case "integer":
2395
+ case "numeric":
2396
+ case "safeint":
2397
+ case "uint8":
2398
+ return `${nullOrUndefinedPrefix} Number(${restValue})`;
2399
+ case "enum":
2400
+ if (isNormalUnion(type)) {
2401
+ return `${restValue}`;
2402
+ } else if (isSpecialHandledUnion(type)) {
2403
+ const deserializeFunctionName = type
2404
+ ? buildModelDeserializer(context, getNullableValidType(type), {
2405
+ nameOnly: true,
2406
+ skipDiscriminatedUnionSuffix: false,
2407
+ })
2408
+ : undefined;
2409
+ if (deserializeFunctionName) {
2410
+ return `${deserializeFunctionName}(${restValue})`;
2411
+ } else {
2412
+ return `${restValue} as any`;
2413
+ }
2414
+ } else {
2415
+ return `${restValue} as any`;
2416
+ }
2417
+ default: {
2418
+ const val = deserializeResponseValue(context, type, restValue, true, format, recursionDepth);
2419
+ return `${nullOrUndefinedPrefix} ${val}`;
2420
+ }
2421
+ }
2422
+ }
2423
+
2424
+ /**
2425
+ * This function helps converting strings into JS complex types recursively.
2426
+ * We need to drill down into Array elements to make sure that the element type is
2427
+ * deserialized correctly
2428
+ */
2429
+ export function deserializeResponseValue(
2430
+ context: SdkContext,
2431
+ type: SdkType,
2432
+ restValue: string,
2433
+ required: boolean,
2434
+ format?: string,
2435
+ recursionDepth: number = 0,
2436
+ ): string {
2437
+ const dependencies = useDependencies();
2438
+ const stringToUint8ArrayReference = resolveReference(dependencies.stringToUint8Array);
2439
+ const nullOrUndefinedPrefix =
2440
+ isTypeNullable(type) || getOptionalForType(type) || !required
2441
+ ? `!${restValue}? ${restValue}: `
2442
+ : "";
2443
+ switch (type.kind) {
2444
+ case "plainDate":
2445
+ // plainDate deserializes from YYYY-MM-DD string to Date
2446
+ return `${nullOrUndefinedPrefix} new Date(${restValue})`;
2447
+ case "utcDateTime":
2448
+ return `${nullOrUndefinedPrefix} new Date(${type.encode === "unixTimestamp" ? `${restValue} * 1000` : restValue})`;
2449
+ case "array": {
2450
+ const prefix = nullOrUndefinedPrefix + restValue;
2451
+ const varName = recursionDepth > 0 ? `p${recursionDepth}` : "p";
2452
+ let elementNullOrUndefinedPrefix = "";
2453
+ if (
2454
+ type.valueType &&
2455
+ (isTypeNullable(type.valueType) || getOptionalForType(type.valueType))
2456
+ ) {
2457
+ elementNullOrUndefinedPrefix = `!${varName} ? ${varName} :`;
2458
+ }
2459
+ const deserializeFunctionName = type.valueType
2460
+ ? buildModelDeserializer(context, getNullableValidType(type.valueType), {
2461
+ nameOnly: true,
2462
+ skipDiscriminatedUnionSuffix: false,
2463
+ })
2464
+ : undefined;
2465
+ if (deserializeFunctionName) {
2466
+ return `${prefix}.map((${varName}: any) => { return ${elementNullOrUndefinedPrefix}${deserializeFunctionName}(${varName})})`;
2467
+ } else if (type.valueType && isAzureCoreErrorType(context.program, type.valueType.__raw)) {
2468
+ return `${prefix}.map((${varName}: any) => { return ${elementNullOrUndefinedPrefix}${varName}})`;
2469
+ } else if (type.valueType) {
2470
+ if (format) {
2471
+ const parseHelper = getCollectionFormatParseHelper(format);
2472
+ if (parseHelper) {
2473
+ // We shouldn't check for an empty string here since an empty string should be parsed as an empty array
2474
+ const optionalPrefixForString =
2475
+ isTypeNullable(type) || getOptionalForType(type) || !required
2476
+ ? `${restValue} === null || ${restValue} === undefined ? ${restValue}: `
2477
+ : "";
2478
+ if (type.valueType.kind === "enum" && !isExtensibleEnum(context, type.valueType)) {
2479
+ // Special handling for non-extensible enums to cast the result to the correct type
2480
+ return `${optionalPrefixForString}${parseHelper}(${restValue}) as ${getTypeExpression(context, type)}`;
2481
+ } else {
2482
+ return `${optionalPrefixForString}${parseHelper}(${restValue})`;
2483
+ }
2484
+ }
2485
+ }
2486
+ return `${prefix}.map((${varName}: any) => { return ${elementNullOrUndefinedPrefix}${deserializeResponseValue(context, type.valueType, varName, true, getEncodeForType(type.valueType), recursionDepth + 1)}})`;
2487
+ } else {
2488
+ return restValue;
2489
+ }
2490
+ }
2491
+ case "dict": {
2492
+ const keyVar = recursionDepth > 0 ? `k${recursionDepth}` : "k";
2493
+ const valueVar = recursionDepth > 0 ? `p${recursionDepth}` : "p";
2494
+ let elementNullOrUndefinedPrefix = "";
2495
+ if (
2496
+ type.valueType &&
2497
+ (isTypeNullable(type.valueType) || getOptionalForType(type.valueType))
2498
+ ) {
2499
+ elementNullOrUndefinedPrefix = `!${valueVar} ? ${valueVar} :`;
2500
+ }
2501
+ const deserializeFunctionName = type.valueType
2502
+ ? buildModelDeserializer(context, getNullableValidType(type.valueType), {
2503
+ nameOnly: true,
2504
+ skipDiscriminatedUnionSuffix: false,
2505
+ })
2506
+ : undefined;
2507
+ if (deserializeFunctionName) {
2508
+ return `${nullOrUndefinedPrefix}Object.fromEntries(Object.entries(${restValue}).map(([${keyVar}, ${valueVar}]: [string, any]) => [${keyVar}, ${elementNullOrUndefinedPrefix}${deserializeFunctionName}(${valueVar})]))`;
2509
+ } else if (type.valueType && isAzureCoreErrorType(context.program, type.valueType.__raw)) {
2510
+ return `${nullOrUndefinedPrefix}Object.fromEntries(Object.entries(${restValue}).map(([${keyVar}, ${valueVar}]: [string, any]) => [${keyVar}, ${elementNullOrUndefinedPrefix}${valueVar}]))`;
2511
+ } else if (type.valueType) {
2512
+ return `${nullOrUndefinedPrefix}Object.fromEntries(Object.entries(${restValue}).map(([${keyVar}, ${valueVar}]: [string, any]) => [${keyVar}, ${elementNullOrUndefinedPrefix}${deserializeResponseValue(context, type.valueType, valueVar, true, getEncodeForType(type.valueType), recursionDepth + 1)}]))`;
2513
+ } else {
2514
+ return restValue;
2515
+ }
2516
+ }
2517
+ case "bytes":
2518
+ if (format !== "binary" && format !== "bytes") {
2519
+ return `${nullOrUndefinedPrefix}typeof ${restValue} === 'string'
2520
+ ? ${stringToUint8ArrayReference}(${restValue}, "${format ?? "base64"}")
2521
+ : ${restValue}`;
2522
+ }
2523
+ return restValue;
2524
+ case "union":
2525
+ if (isNormalUnion(type)) {
2526
+ return `${restValue}`;
2527
+ } else if (isSpecialHandledUnion(type)) {
2528
+ const deserializeFunctionName = type
2529
+ ? buildModelDeserializer(context, getNullableValidType(type), {
2530
+ nameOnly: true,
2531
+ skipDiscriminatedUnionSuffix: false,
2532
+ })
2533
+ : undefined;
2534
+ if (deserializeFunctionName) {
2535
+ return `${deserializeFunctionName}(${restValue})`;
2536
+ } else {
2537
+ return `${restValue} as any`;
2538
+ }
2539
+ } else {
2540
+ return `${restValue} as any`;
2541
+ }
2542
+ case "model": // generate deserialize logic for spread model types
2543
+ return `{${getResponseMapping(context, type, "").join(",")}}`;
2544
+ case "nullable":
2545
+ return deserializeResponseValue(
2546
+ context,
2547
+ type.type,
2548
+ restValue,
2549
+ false,
2550
+ getEncodeForType(type.type),
2551
+ recursionDepth + 1,
2552
+ );
2553
+ default:
2554
+ return restValue;
2555
+ }
2556
+ }
2557
+
2558
+ export function isLroAndPagingOperation(
2559
+ op: SdkMethod<SdkHttpOperation>,
2560
+ ): op is SdkLroPagingServiceMethod<SdkHttpOperation> {
2561
+ return op.kind === "lropaging";
2562
+ }
2563
+
2564
+ export function isLroOnlyOperation(
2565
+ op: SdkMethod<SdkHttpOperation>,
2566
+ ): op is SdkLroServiceMethod<SdkHttpOperation> {
2567
+ return op.kind === "lro";
2568
+ }
2569
+
2570
+ export function isPagingOnlyOperation(
2571
+ op: SdkMethod<SdkHttpOperation>,
2572
+ ): op is SdkPagingServiceMethod<SdkHttpOperation> {
2573
+ return op.kind === "paging";
2574
+ }
2575
+
2576
+ export function getAllProperties(
2577
+ context: SdkContext,
2578
+ type: SdkType,
2579
+ parents?: SdkType[],
2580
+ ): SdkModelPropertyType[] {
2581
+ const propertiesMap: Map<string, SdkModelPropertyType> = new Map();
2582
+ if (!type) {
2583
+ return [];
2584
+ }
2585
+ parents?.forEach((p) => {
2586
+ getAllProperties(context, p).forEach((prop) => {
2587
+ propertiesMap.set(prop.name, prop);
2588
+ });
2589
+ });
2590
+ if (type.kind === "model" && type.properties) {
2591
+ type.properties
2592
+ .filter((p) => {
2593
+ return p.kind === "property" && !isHttpMetadata(context, p);
2594
+ })
2595
+ .forEach((p) => {
2596
+ propertiesMap.set(p.name, p);
2597
+ });
2598
+ }
2599
+
2600
+ return [...propertiesMap.values()];
2601
+ }
2602
+
2603
+ export function getAllAncestors(type: SdkType): SdkType[] {
2604
+ const ancestors: SdkType[] = [];
2605
+ if (type.kind === "model" && type.baseModel) {
2606
+ ancestors.push(type.baseModel);
2607
+ ancestors.push(...getAllAncestors(type.baseModel));
2608
+ }
2609
+ return ancestors;
2610
+ }
2611
+
2612
+ /**
2613
+ * Returns true when a param/property has a clientDefaultValue whose JavaScript type
2614
+ * is compatible with the declared TypeSpec type, meaning the default can be emitted
2615
+ * safely into generated code.
2616
+ */
2617
+ function hasEffectiveClientDefaultValue(
2618
+ param: SdkHttpParameter | SdkBodyParameter | SdkModelPropertyType,
2619
+ ): boolean {
2620
+ return (
2621
+ param.clientDefaultValue !== undefined &&
2622
+ isDefaultValueTypeMatch(param, param.clientDefaultValue)
2623
+ );
2624
+ }
2625
+
2626
+ /**
2627
+ * Checks if a clientDefaultValue type matches a parameter or model property type.
2628
+ * Returns true if the default value type is compatible with the target type.
2629
+ */
2630
+ function isDefaultValueTypeMatch(
2631
+ param: SdkHttpParameter | SdkBodyParameter | SdkModelPropertyType,
2632
+ defaultValue: unknown,
2633
+ ): boolean {
2634
+ const defaultType = typeof defaultValue;
2635
+ const paramType = param.type;
2636
+
2637
+ // Map JavaScript types to TypeSpec types
2638
+ if (defaultType === "string") {
2639
+ return paramType.kind === "string" || paramType.kind === "enum";
2640
+ }
2641
+ if (defaultType === "number") {
2642
+ return (
2643
+ paramType.kind === "int32" ||
2644
+ paramType.kind === "int64" ||
2645
+ paramType.kind === "float32" ||
2646
+ paramType.kind === "float64" ||
2647
+ paramType.kind === "numeric" ||
2648
+ paramType.kind === "integer" ||
2649
+ paramType.kind === "float" ||
2650
+ paramType.kind === "decimal"
2651
+ );
2652
+ }
2653
+ if (defaultType === "boolean") {
2654
+ return paramType.kind === "boolean";
2655
+ }
2656
+
2657
+ // For other types, don't apply the default
2658
+ return false;
2659
+ }
2660
+
2661
+ /**
2662
+ * Formats a default value for code generation.
2663
+ * Strings are wrapped in quotes, other values are used as-is.
2664
+ */
2665
+ function formatDefaultValue(defaultValue: unknown): string {
2666
+ if (typeof defaultValue === "string") {
2667
+ return `"${defaultValue}"`;
2668
+ }
2669
+ return String(defaultValue);
2670
+ }
2671
+
2672
+ export function getPropertySerializationPrefix(
2673
+ context: SdkContext,
2674
+ property: SdkHttpParameter | SdkModelPropertyType,
2675
+ propertyPath?: string,
2676
+ ) {
2677
+ const propertyFullName = getPropertyFullName(context, property, propertyPath);
2678
+
2679
+ if (property.optional || isTypeNullable(property.type)) {
2680
+ return `!${propertyFullName}? ${propertyFullName}:`;
2681
+ }
2682
+
2683
+ return "";
2684
+ }
2685
+
2686
+ export function getPropertyFullName(
2687
+ context: SdkContext,
2688
+ property: SdkHttpParameter | SdkModelPropertyType,
2689
+ propertyPath?: string,
2690
+ ) {
2691
+ const normalizedPropertyName =
2692
+ propertyPath === ""
2693
+ ? normalizeName(property.name, NameType.Parameter, true)
2694
+ : normalizeModelPropertyName(context, property).replace(/^"/g, "").replace(/"$/g, "");
2695
+
2696
+ let fullName = normalizedPropertyName;
2697
+ if (propertyPath === "" && property.optional) {
2698
+ fullName = `options?.${normalizedPropertyName}`;
2699
+ } else if (propertyPath) {
2700
+ fullName = `${propertyPath}["${normalizedPropertyName}"]`;
2701
+ }
2702
+
2703
+ return fullName;
2704
+ }
2705
+
2706
+ /**
2707
+ * Get an expression representing an array of expected status codes for the operation
2708
+ * @param operation The operation
2709
+ */
2710
+ export function getExpectedStatuses(operation: ServiceOperation): string {
2711
+ let statusCodes = operation.operation.responses.map((x) => x.statusCodes);
2712
+ // For HEAD + @responseAsBool, 404 is a valid "false" response.
2713
+ if (isHeadAsBooleanOperation(operation) && !statusCodes.includes(404)) {
2714
+ statusCodes = [...statusCodes, 404];
2715
+ }
2716
+ // LROs may call the same path but with GET to get the operation status.
2717
+ if (
2718
+ (isLroOnlyOperation(operation) || isLroAndPagingOperation(operation)) &&
2719
+ operation.operation.verb !== "get"
2720
+ ) {
2721
+ // DELETE: Add 200, 202 for polling
2722
+ // POST/PUT/PATCH: Add 200, 201, 202 for polling
2723
+ const verb = operation.operation.verb.toLowerCase();
2724
+ if (verb === "delete") {
2725
+ statusCodes = [...statusCodes, 200, 202];
2726
+ } else {
2727
+ statusCodes = [...statusCodes, 200, 201, 202];
2728
+ }
2729
+ }
2730
+
2731
+ statusCodes = Array.from(new Set(statusCodes));
2732
+
2733
+ return `[${statusCodes.map((x) => `"${x}"`).join(", ")}]`;
2734
+ }
2735
+
2736
+ /**
2737
+ * Gets the apiVersion expression with default value fallback for query parameters.
2738
+ * @param dpgContext - The SDK context
2739
+ * @param operation - The operation to get the apiVersion parameter from
2740
+ * @returns The apiVersion expression string, or undefined if no apiVersion query param exists
2741
+ */
2742
+ function getApiVersionExpression(
2743
+ dpgContext: SdkContext,
2744
+ operation: ServiceOperation,
2745
+ ): string | undefined {
2746
+ const queryApiVersionParam = operation.operation.parameters.find(
2747
+ (p) => p.kind === "query" && p.isApiVersionParam,
2748
+ );
2749
+ if (!queryApiVersionParam) {
2750
+ return undefined;
2751
+ }
2752
+ // For multi-service, use only the default value (don't reference context.apiVersion)
2753
+ if (dpgContext.rlcOptions?.isMultiService) {
2754
+ return queryApiVersionParam.clientDefaultValue
2755
+ ? `"${queryApiVersionParam.clientDefaultValue}"`
2756
+ : undefined;
2757
+ }
2758
+ const paramAccess = `${queryApiVersionParam.onClient ? "context." : ""}${queryApiVersionParam.name}`;
2759
+ const defaultValueSuffix = queryApiVersionParam.clientDefaultValue
2760
+ ? ` ?? "${queryApiVersionParam.clientDefaultValue}"`
2761
+ : "";
2762
+ return `${paramAccess}${defaultValueSuffix}`;
2763
+ }
2764
+
2765
+ /**
2766
+ * Extracts and deduplicates all response headers from operation responses.
2767
+ * @param responses - The operation responses
2768
+ * @returns Array of unique response headers
2769
+ */
2770
+ export function getResponseHeaders(
2771
+ responses: SdkHttpOperation["responses"],
2772
+ ): SdkServiceResponseHeader[] {
2773
+ const headerMap = new Map<string, SdkServiceResponseHeader>();
2774
+ for (const response of responses ?? []) {
2775
+ for (const header of response.headers ?? []) {
2776
+ if (shouldSkipHeaderSerialization(header)) continue;
2777
+ const key = header.serializedName ?? header.name;
2778
+ if (!headerMap.has(key)) {
2779
+ headerMap.set(key, header);
2780
+ }
2781
+ }
2782
+ }
2783
+ return Array.from(headerMap.values());
2784
+ }
2785
+
2786
+ /**
2787
+ * Builds a composite return type for operations that return both a model and additional headers.
2788
+ * Combines model properties and header properties into an inline object type.
2789
+ * @param context - The SDK context
2790
+ * @param modelType - The model type
2791
+ * @param headers - The response headers that are NOT in the model
2792
+ * @returns The composite type expression as a string (e.g., "{ name: string; email: string; requestId: string }")
2793
+ */
2794
+ function buildCompositeResponseType(
2795
+ context: SdkContext,
2796
+ modelType: SdkModelType,
2797
+ headers: SdkServiceResponseHeader[],
2798
+ ): string {
2799
+ const allParents = getAllAncestors(modelType);
2800
+ const modelProps: (SdkModelPropertyType | SdkServiceResponseHeader)[] = getAllProperties(
2801
+ context,
2802
+ modelType,
2803
+ allParents,
2804
+ ).filter((property) => {
2805
+ // Skip model properties that are headers with headerCollectionPrefix
2806
+ if (
2807
+ property.__raw &&
2808
+ isHeader(context.program, property.__raw) &&
2809
+ shouldSkipHeaderSerialization(property as SdkModelPropertyType & SdkServiceResponseHeader)
2810
+ ) {
2811
+ return false;
2812
+ }
2813
+ return true;
2814
+ });
2815
+
2816
+ // Collect header property names already in the model to avoid duplicates
2817
+ const modelHeaderNames = new Set<string>();
2818
+ for (const property of modelProps) {
2819
+ if (isHeader(context.program, property.__raw!)) {
2820
+ modelHeaderNames.add(property.name.toLowerCase());
2821
+ }
2822
+ }
2823
+
2824
+ // Add only additional host response header properties not already in model
2825
+ for (const header of headers) {
2826
+ if (modelHeaderNames.has(header.name.toLowerCase())) {
2827
+ continue;
2828
+ }
2829
+ modelProps.push(header);
2830
+ }
2831
+
2832
+ return emitInlineModel(context, modelProps);
2833
+ }
2834
+
2835
+ /**
2836
+ * Builds an inline type string for header-only responses.
2837
+ * @param context - The SDK context
2838
+ * @param headers - The response headers
2839
+ * @returns The inline type expression as a string (e.g., "{ requestId: string; optionalHeader?: string }")
2840
+ */
2841
+ function buildHeaderOnlyResponseType(
2842
+ context: SdkContext,
2843
+ headers: SdkServiceResponseHeader[],
2844
+ ): string {
2845
+ const properties: string[] = [];
2846
+
2847
+ for (const header of headers) {
2848
+ const headerName = normalizeModelPropertyName(context, header);
2849
+ const headerType = getTypeExpression(context, header.type);
2850
+ const isOptional = header.optional ? "?" : "";
2851
+ properties.push(`${headerName}${isOptional}: ${headerType}`);
2852
+ }
2853
+
2854
+ return `{ ${properties.join("; ")} }`;
2855
+ }
2856
+
2857
+ /**
2858
+ * Builds the object literal expression for a header-only response.
2859
+ * Handles type conversions for headers (string to boolean, Date, number, Uint8Array).
2860
+ * @param operation - The service operation
2861
+ * @param headers - The response headers
2862
+ * @returns JavaScript expression string for the header-only response object
2863
+ */
2864
+ function buildHeaderOnlyResponseValue(
2865
+ context: SdkContext,
2866
+ headers: SdkServiceResponseHeader[],
2867
+ ): string {
2868
+ const props = headers.map((header) => {
2869
+ const headerName = (header.serializedName ?? header.name).toLowerCase();
2870
+ const key = normalizeModelPropertyName(context, header);
2871
+ const value = deserializeResponseHeadersValue(
2872
+ context,
2873
+ header.type,
2874
+ `result.headers[${JSON.stringify(headerName)}]`,
2875
+ !header.optional,
2876
+ getEncodeForType(header.type),
2877
+ 0,
2878
+ );
2879
+
2880
+ return `${key}: ${value}`;
2881
+ });
2882
+
2883
+ return `{ ${props.join(", ")} }`;
2884
+ }
2885
+
2886
+ /**
2887
+ * Returns the name for a non-model response wrapper type.
2888
+ * The name follows the pattern: {OperationGroupName}{MethodName}Response
2889
+ * @param method - The method tuple [prefixes, operation]
2890
+ */
2891
+ export function getOperationResponseTypeName(method: [string[], ServiceOperation]): string {
2892
+ const prefixes = method[0];
2893
+ const operation = method[1];
2894
+ const prefix = !operation.name.includes("_")
2895
+ ? getClassicalLayerPrefix(prefixes, NameType.Interface)
2896
+ : "";
2897
+ return `${prefix}${normalizeName(operation.name, NameType.Interface)}Response`;
2898
+ }
2899
+
2900
+ /**
2901
+ * Returns true when a type should be wrapped with a `body` property.
2902
+ * Wrapping is needed for primitive/enum types; composite (model, dict, model-array)
2903
+ * and unknown-as-record types map to the HLC PropertyKind.Composite / Dictionary
2904
+ * patterns which do NOT get a body wrapper.
2905
+ *
2906
+ * Covered cases (no wrap):
2907
+ * - model array (e.g. Foo[]) → HLC PropertyKind.Composite
2908
+ * - model → HLC PropertyKind.Composite
2909
+ * - dict / Record<string, unknown> → HLC PropertyKind.Dictionary
2910
+ * - unknown with treatUnknownAsRecord → treated as Dict
2911
+ *
2912
+ * Covered cases (wrap):
2913
+ * - string, boolean, number → HLC PropertyKind.Primitive
2914
+ * - string[] → HLC PropertyKind.Primitive (item kind)
2915
+ * - enum / KnownXxx | string → HLC PropertyKind.Enum
2916
+ * - any / unknown (no treatAsRecord) → HLC PropertyKind.Primitive
2917
+ */
2918
+ function isWrappableType(context: SdkContext, type: SdkType): boolean {
2919
+ if (type.kind === "array" && type.valueType.kind === "model") return false;
2920
+ if (type.kind === "dict" || type.kind === "model") return false;
2921
+ if (type.kind === "unknown" && context.rlcOptions?.treatUnknownAsRecord) return false;
2922
+ return true;
2923
+ }
2924
+
2925
+ /**
2926
+ * Returns true if the operation uses the HTTP HEAD method.
2927
+ */
2928
+ function isHeadOperation(operation: ServiceOperation): boolean {
2929
+ return operation.operation.verb.toLowerCase() === "head";
2930
+ }
2931
+
2932
+ function isHeadAsBooleanOperation(operation: ServiceOperation): boolean {
2933
+ if (!isHeadOperation(operation)) return false;
2934
+ // @responseAsBool: TCGC promotes response.type to SdkBuiltInType { kind: "boolean" }
2935
+ if ((operation.response.type as any)?.kind === "boolean") return true;
2936
+ return false;
2937
+ }
2938
+
2939
+ /**
2940
+ * Determines whether wrapping the non-model return type is needed for an operation.
2941
+ * Returns an object with `shouldWrap` (whether to wrap) and `isBinary` (whether it's a binary response).
2942
+ */
2943
+ export function checkWrapNonModelReturn(
2944
+ context: SdkContext,
2945
+ operation: ServiceOperation,
2946
+ ): { shouldWrap: boolean; isBinary: boolean } {
2947
+ const noWrap = { shouldWrap: false, isBinary: false };
2948
+
2949
+ // LRO+paging and paging-only operations are not wrapped
2950
+ if (isLroAndPagingOperation(operation) || isPagingOnlyOperation(operation)) {
2951
+ return noWrap;
2952
+ }
2953
+
2954
+ // Only if the feature flag is enabled
2955
+ if (!context.rlcOptions?.wrapNonModelReturn) {
2956
+ return noWrap;
2957
+ }
2958
+
2959
+ // For LRO-only operations, check the final result type from LRO metadata
2960
+ if (isLroOnlyOperation(operation)) {
2961
+ const lroResultType = operation.lroMetadata?.finalResponse?.result;
2962
+ if (!lroResultType) {
2963
+ return noWrap; // void LRO - no wrap needed
2964
+ }
2965
+ return {
2966
+ shouldWrap: isWrappableType(context, lroResultType),
2967
+ isBinary: false,
2968
+ };
2969
+ }
2970
+
2971
+ const { type } = operation.response;
2972
+ if (!type) {
2973
+ // Special case: HEAD operation with @responseAsBool and void response → wrap as boolean { body: boolean }
2974
+ if (isHeadAsBooleanOperation(operation)) {
2975
+ return { shouldWrap: true, isBinary: false };
2976
+ }
2977
+ return noWrap; // void return type - no wrap needed
2978
+ }
2979
+
2980
+ const contentTypes = operation.operation.responses[0]?.contentTypes ?? [];
2981
+
2982
+ // bytes with binary content type → binary wrap (isBinary=true)
2983
+ // HLC: bytes → binary payload → separate binary handling
2984
+ if (type.__raw && isBinaryPayload(context, type.__raw, contentTypes, getEncodeForType(type))) {
2985
+ return { shouldWrap: true, isBinary: true };
2986
+ }
2987
+
2988
+ return { shouldWrap: isWrappableType(context, type), isBinary: false };
2989
+ }
2990
+
2991
+ /**
2992
+ * Builds a TypeAliasDeclarationStructure for the non-model response wrapper type.
2993
+ * - For binary responses: { blobBody?: Promise<Blob>; readableStreamBody?: NodeReadableStream }
2994
+ * - For other non-model responses: { body: <type> }
2995
+ */
2996
+ export function buildNonModelResponseTypeDeclaration(
2997
+ context: SdkContext,
2998
+ method: [string[], ServiceOperation],
2999
+ isBinary: boolean,
3000
+ ): TypeAliasDeclarationStructure {
3001
+ const typeName = getOperationResponseTypeName(method);
3002
+ const operation = method[1];
3003
+ let typeBody: string;
3004
+
3005
+ if (isBinary) {
3006
+ const nodeReadableStreamRef = resolveReference(PlatformTypeHelpers.NodeReadableStream);
3007
+ typeBody = `{
3008
+ /**
3009
+ * BROWSER ONLY
3010
+ *
3011
+ * The response body as a browser Blob.
3012
+ * Always \`undefined\` in node.js.
3013
+ */
3014
+ blobBody?: Promise<Blob>;
3015
+ /**
3016
+ * NODEJS ONLY
3017
+ *
3018
+ * The response body as a node.js Readable stream.
3019
+ * Always \`undefined\` in the browser.
3020
+ */
3021
+ readableStreamBody?: ${nodeReadableStreamRef};
3022
+ }`;
3023
+ } else {
3024
+ const returnType = getTypeExpression(context, operation.response.type!);
3025
+ typeBody = `{ body: ${returnType} }`;
3026
+ }
3027
+
3028
+ return {
3029
+ kind: StructureKind.TypeAlias,
3030
+ name: typeName,
3031
+ type: typeBody,
3032
+ isExported: true,
3033
+ leadingTrivia: "\n",
3034
+ };
3035
+ }