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