@typespec/http-client-js 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/.testignore +2 -0
  2. package/LICENSE +21 -0
  3. package/README.md +26 -0
  4. package/babel.config.js +4 -0
  5. package/dist/src/components/client-context/client-context-declaration.d.ts +8 -0
  6. package/dist/src/components/client-context/client-context-declaration.d.ts.map +1 -0
  7. package/dist/src/components/client-context/client-context-declaration.js +21 -0
  8. package/dist/src/components/client-context/client-context-declaration.js.map +1 -0
  9. package/dist/src/components/client-context/client-context-factory.d.ts +8 -0
  10. package/dist/src/components/client-context/client-context-factory.d.ts.map +1 -0
  11. package/dist/src/components/client-context/client-context-factory.js +154 -0
  12. package/dist/src/components/client-context/client-context-factory.js.map +1 -0
  13. package/dist/src/components/client-context/client-context-options.d.ts +8 -0
  14. package/dist/src/components/client-context/client-context-options.d.ts.map +1 -0
  15. package/dist/src/components/client-context/client-context-options.js +42 -0
  16. package/dist/src/components/client-context/client-context-options.js.map +1 -0
  17. package/dist/src/components/client-context/client-context.d.ts +8 -0
  18. package/dist/src/components/client-context/client-context.d.ts.map +1 -0
  19. package/dist/src/components/client-context/client-context.js +33 -0
  20. package/dist/src/components/client-context/client-context.js.map +1 -0
  21. package/dist/src/components/client-context/parametrized-endpoint.d.ts +9 -0
  22. package/dist/src/components/client-context/parametrized-endpoint.d.ts.map +1 -0
  23. package/dist/src/components/client-context/parametrized-endpoint.js +48 -0
  24. package/dist/src/components/client-context/parametrized-endpoint.js.map +1 -0
  25. package/dist/src/components/client-directory.d.ts +11 -0
  26. package/dist/src/components/client-directory.d.ts.map +1 -0
  27. package/dist/src/components/client-directory.js +39 -0
  28. package/dist/src/components/client-directory.js.map +1 -0
  29. package/dist/src/components/client-operation.d.ts +11 -0
  30. package/dist/src/components/client-operation.d.ts.map +1 -0
  31. package/dist/src/components/client-operation.js +74 -0
  32. package/dist/src/components/client-operation.js.map +1 -0
  33. package/dist/src/components/client.d.ts +15 -0
  34. package/dist/src/components/client.d.ts.map +1 -0
  35. package/dist/src/components/client.js +153 -0
  36. package/dist/src/components/client.js.map +1 -0
  37. package/dist/src/components/encoding-provider.d.ts +8 -0
  38. package/dist/src/components/encoding-provider.d.ts.map +1 -0
  39. package/dist/src/components/encoding-provider.js +17 -0
  40. package/dist/src/components/encoding-provider.js.map +1 -0
  41. package/dist/src/components/external-packages/ts-http-runtime.d.ts +13 -0
  42. package/dist/src/components/external-packages/ts-http-runtime.d.ts.map +1 -0
  43. package/dist/src/components/external-packages/ts-http-runtime.js +11 -0
  44. package/dist/src/components/external-packages/ts-http-runtime.js.map +1 -0
  45. package/dist/src/components/external-packages/uri-template.d.ts +4 -0
  46. package/dist/src/components/external-packages/uri-template.d.ts.map +1 -0
  47. package/dist/src/components/external-packages/uri-template.js +11 -0
  48. package/dist/src/components/external-packages/uri-template.js.map +1 -0
  49. package/dist/src/components/http-request-options.d.ts +25 -0
  50. package/dist/src/components/http-request-options.d.ts.map +1 -0
  51. package/dist/src/components/http-request-options.js +74 -0
  52. package/dist/src/components/http-request-options.js.map +1 -0
  53. package/dist/src/components/http-request-parameters-expression.d.ts +10 -0
  54. package/dist/src/components/http-request-parameters-expression.d.ts.map +1 -0
  55. package/dist/src/components/http-request-parameters-expression.js +62 -0
  56. package/dist/src/components/http-request-parameters-expression.js.map +1 -0
  57. package/dist/src/components/http-request.d.ts +16 -0
  58. package/dist/src/components/http-request.d.ts.map +1 -0
  59. package/dist/src/components/http-request.js +70 -0
  60. package/dist/src/components/http-request.js.map +1 -0
  61. package/dist/src/components/http-response.d.ts +14 -0
  62. package/dist/src/components/http-response.d.ts.map +1 -0
  63. package/dist/src/components/http-response.js +61 -0
  64. package/dist/src/components/http-response.js.map +1 -0
  65. package/dist/src/components/models.d.ts +5 -0
  66. package/dist/src/components/models.d.ts.map +1 -0
  67. package/dist/src/components/models.js +41 -0
  68. package/dist/src/components/models.js.map +1 -0
  69. package/dist/src/components/operation-options.d.ts +8 -0
  70. package/dist/src/components/operation-options.d.ts.map +1 -0
  71. package/dist/src/components/operation-options.js +41 -0
  72. package/dist/src/components/operation-options.js.map +1 -0
  73. package/dist/src/components/operation-parameters.d.ts +9 -0
  74. package/dist/src/components/operation-parameters.d.ts.map +1 -0
  75. package/dist/src/components/operation-parameters.js +33 -0
  76. package/dist/src/components/operation-parameters.js.map +1 -0
  77. package/dist/src/components/output.d.ts +6 -0
  78. package/dist/src/components/output.d.ts.map +1 -0
  79. package/dist/src/components/output.js +35 -0
  80. package/dist/src/components/output.js.map +1 -0
  81. package/dist/src/components/serializers.d.ts +5 -0
  82. package/dist/src/components/serializers.d.ts.map +1 -0
  83. package/dist/src/components/serializers.js +43 -0
  84. package/dist/src/components/serializers.js.map +1 -0
  85. package/dist/src/components/static-helpers/bytes-encoding.d.ts +6 -0
  86. package/dist/src/components/static-helpers/bytes-encoding.d.ts.map +1 -0
  87. package/dist/src/components/static-helpers/bytes-encoding.js +68 -0
  88. package/dist/src/components/static-helpers/bytes-encoding.js.map +1 -0
  89. package/dist/src/components/static-helpers/interfaces.d.ts +5 -0
  90. package/dist/src/components/static-helpers/interfaces.d.ts.map +1 -0
  91. package/dist/src/components/static-helpers/interfaces.js +41 -0
  92. package/dist/src/components/static-helpers/interfaces.js.map +1 -0
  93. package/dist/src/components/static-helpers/multipart-helpers.d.ts +8 -0
  94. package/dist/src/components/static-helpers/multipart-helpers.d.ts.map +1 -0
  95. package/dist/src/components/static-helpers/multipart-helpers.js +83 -0
  96. package/dist/src/components/static-helpers/multipart-helpers.js.map +1 -0
  97. package/dist/src/components/static-helpers/rest-error.d.ts +5 -0
  98. package/dist/src/components/static-helpers/rest-error.d.ts.map +1 -0
  99. package/dist/src/components/static-helpers/rest-error.js +127 -0
  100. package/dist/src/components/static-helpers/rest-error.js.map +1 -0
  101. package/dist/src/components/testing/client-options.d.ts +8 -0
  102. package/dist/src/components/testing/client-options.d.ts.map +1 -0
  103. package/dist/src/components/testing/client-options.js +27 -0
  104. package/dist/src/components/testing/client-options.js.map +1 -0
  105. package/dist/src/components/transforms/content-type-encoding-provider.d.ts +7 -0
  106. package/dist/src/components/transforms/content-type-encoding-provider.d.ts.map +1 -0
  107. package/dist/src/components/transforms/content-type-encoding-provider.js +25 -0
  108. package/dist/src/components/transforms/content-type-encoding-provider.js.map +1 -0
  109. package/dist/src/components/transforms/data-transform.d.ts +9 -0
  110. package/dist/src/components/transforms/data-transform.d.ts.map +1 -0
  111. package/dist/src/components/transforms/data-transform.js +31 -0
  112. package/dist/src/components/transforms/data-transform.js.map +1 -0
  113. package/dist/src/components/transforms/json/json-array-transform.d.ts +15 -0
  114. package/dist/src/components/transforms/json/json-array-transform.d.ts.map +1 -0
  115. package/dist/src/components/transforms/json/json-array-transform.js +71 -0
  116. package/dist/src/components/transforms/json/json-array-transform.js.map +1 -0
  117. package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts +9 -0
  118. package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts.map +1 -0
  119. package/dist/src/components/transforms/json/json-model-additional-properties-transform.js +35 -0
  120. package/dist/src/components/transforms/json/json-model-additional-properties-transform.js.map +1 -0
  121. package/dist/src/components/transforms/json/json-model-base-transform.d.ts +9 -0
  122. package/dist/src/components/transforms/json/json-model-base-transform.d.ts.map +1 -0
  123. package/dist/src/components/transforms/json/json-model-base-transform.js +13 -0
  124. package/dist/src/components/transforms/json/json-model-base-transform.js.map +1 -0
  125. package/dist/src/components/transforms/json/json-model-property-transform.d.ts +9 -0
  126. package/dist/src/components/transforms/json/json-model-property-transform.d.ts.map +1 -0
  127. package/dist/src/components/transforms/json/json-model-property-transform.js +44 -0
  128. package/dist/src/components/transforms/json/json-model-property-transform.js.map +1 -0
  129. package/dist/src/components/transforms/json/json-model-transform.d.ts +15 -0
  130. package/dist/src/components/transforms/json/json-model-transform.d.ts.map +1 -0
  131. package/dist/src/components/transforms/json/json-model-transform.js +96 -0
  132. package/dist/src/components/transforms/json/json-model-transform.js.map +1 -0
  133. package/dist/src/components/transforms/json/json-record-transform.d.ts +15 -0
  134. package/dist/src/components/transforms/json/json-record-transform.d.ts.map +1 -0
  135. package/dist/src/components/transforms/json/json-record-transform.js +71 -0
  136. package/dist/src/components/transforms/json/json-record-transform.js.map +1 -0
  137. package/dist/src/components/transforms/json/json-transform-discriminator.d.ts +16 -0
  138. package/dist/src/components/transforms/json/json-transform-discriminator.d.ts.map +1 -0
  139. package/dist/src/components/transforms/json/json-transform-discriminator.js +82 -0
  140. package/dist/src/components/transforms/json/json-transform-discriminator.js.map +1 -0
  141. package/dist/src/components/transforms/json/json-transform.d.ts +14 -0
  142. package/dist/src/components/transforms/json/json-transform.d.ts.map +1 -0
  143. package/dist/src/components/transforms/json/json-transform.js +149 -0
  144. package/dist/src/components/transforms/json/json-transform.js.map +1 -0
  145. package/dist/src/components/transforms/json/union-transform.d.ts +15 -0
  146. package/dist/src/components/transforms/json/union-transform.d.ts.map +1 -0
  147. package/dist/src/components/transforms/json/union-transform.js +67 -0
  148. package/dist/src/components/transforms/json/union-transform.js.map +1 -0
  149. package/dist/src/components/transforms/json/utils/transport-namer.d.ts +3 -0
  150. package/dist/src/components/transforms/json/utils/transport-namer.d.ts.map +1 -0
  151. package/dist/src/components/transforms/json/utils/transport-namer.js +13 -0
  152. package/dist/src/components/transforms/json/utils/transport-namer.js.map +1 -0
  153. package/dist/src/components/transforms/multipart/array-part-transform.d.ts +8 -0
  154. package/dist/src/components/transforms/multipart/array-part-transform.d.ts.map +1 -0
  155. package/dist/src/components/transforms/multipart/array-part-transform.js +29 -0
  156. package/dist/src/components/transforms/multipart/array-part-transform.js.map +1 -0
  157. package/dist/src/components/transforms/multipart/file-part-transform.d.ts +8 -0
  158. package/dist/src/components/transforms/multipart/file-part-transform.d.ts.map +1 -0
  159. package/dist/src/components/transforms/multipart/file-part-transform.js +40 -0
  160. package/dist/src/components/transforms/multipart/file-part-transform.js.map +1 -0
  161. package/dist/src/components/transforms/multipart/multipart-transform.d.ts +7 -0
  162. package/dist/src/components/transforms/multipart/multipart-transform.d.ts.map +1 -0
  163. package/dist/src/components/transforms/multipart/multipart-transform.js +26 -0
  164. package/dist/src/components/transforms/multipart/multipart-transform.js.map +1 -0
  165. package/dist/src/components/transforms/multipart/part-transform.d.ts +8 -0
  166. package/dist/src/components/transforms/multipart/part-transform.d.ts.map +1 -0
  167. package/dist/src/components/transforms/multipart/part-transform.js +35 -0
  168. package/dist/src/components/transforms/multipart/part-transform.js.map +1 -0
  169. package/dist/src/components/transforms/multipart/simple-part-transform.d.ts +8 -0
  170. package/dist/src/components/transforms/multipart/simple-part-transform.d.ts.map +1 -0
  171. package/dist/src/components/transforms/multipart/simple-part-transform.js +48 -0
  172. package/dist/src/components/transforms/multipart/simple-part-transform.js.map +1 -0
  173. package/dist/src/components/transforms/operation-transform-declaration.d.ts +17 -0
  174. package/dist/src/components/transforms/operation-transform-declaration.d.ts.map +1 -0
  175. package/dist/src/components/transforms/operation-transform-declaration.js +74 -0
  176. package/dist/src/components/transforms/operation-transform-declaration.js.map +1 -0
  177. package/dist/src/components/transforms/operation-transform-expression.d.ts +6 -0
  178. package/dist/src/components/transforms/operation-transform-expression.d.ts.map +1 -0
  179. package/dist/src/components/transforms/operation-transform-expression.js +60 -0
  180. package/dist/src/components/transforms/operation-transform-expression.js.map +1 -0
  181. package/dist/src/components/transforms/scalar-transform.d.ts +15 -0
  182. package/dist/src/components/transforms/scalar-transform.d.ts.map +1 -0
  183. package/dist/src/components/transforms/scalar-transform.js +317 -0
  184. package/dist/src/components/transforms/scalar-transform.js.map +1 -0
  185. package/dist/src/components/transforms/transform-name-policy.d.ts +71 -0
  186. package/dist/src/components/transforms/transform-name-policy.d.ts.map +1 -0
  187. package/dist/src/components/transforms/transform-name-policy.js +111 -0
  188. package/dist/src/components/transforms/transform-name-policy.js.map +1 -0
  189. package/dist/src/components/utils/unpack-model-property.d.ts +8 -0
  190. package/dist/src/components/utils/unpack-model-property.d.ts.map +1 -0
  191. package/dist/src/components/utils/unpack-model-property.js +33 -0
  192. package/dist/src/components/utils/unpack-model-property.js.map +1 -0
  193. package/dist/src/components/utils/url-template.d.ts +7 -0
  194. package/dist/src/components/utils/url-template.d.ts.map +1 -0
  195. package/dist/src/components/utils/url-template.js +23 -0
  196. package/dist/src/components/utils/url-template.js.map +1 -0
  197. package/dist/src/context/encoding/encoding-context.d.ts +6 -0
  198. package/dist/src/context/encoding/encoding-context.d.ts.map +1 -0
  199. package/dist/src/context/encoding/encoding-context.js +20 -0
  200. package/dist/src/context/encoding/encoding-context.js.map +1 -0
  201. package/dist/src/context/encoding/types.d.ts +6 -0
  202. package/dist/src/context/encoding/types.d.ts.map +1 -0
  203. package/dist/src/context/encoding/types.js +1 -0
  204. package/dist/src/context/encoding/types.js.map +1 -0
  205. package/dist/src/emitter.d.ts +8 -0
  206. package/dist/src/emitter.d.ts.map +1 -0
  207. package/dist/src/emitter.js +68 -0
  208. package/dist/src/emitter.js.map +1 -0
  209. package/dist/src/index.d.ts +5 -0
  210. package/dist/src/index.d.ts.map +1 -0
  211. package/dist/src/index.js +5 -0
  212. package/dist/src/index.js.map +1 -0
  213. package/dist/src/lib.d.ts +206 -0
  214. package/dist/src/lib.d.ts.map +1 -0
  215. package/dist/src/lib.js +107 -0
  216. package/dist/src/lib.js.map +1 -0
  217. package/dist/src/testing/index.d.ts +3 -0
  218. package/dist/src/testing/index.d.ts.map +1 -0
  219. package/dist/src/testing/index.js +8 -0
  220. package/dist/src/testing/index.js.map +1 -0
  221. package/dist/src/utils/client-discovery.d.ts +7 -0
  222. package/dist/src/utils/client-discovery.d.ts.map +1 -0
  223. package/dist/src/utils/client-discovery.js +26 -0
  224. package/dist/src/utils/client-discovery.js.map +1 -0
  225. package/dist/src/utils/multipart.d.ts +3 -0
  226. package/dist/src/utils/multipart.d.ts.map +1 -0
  227. package/dist/src/utils/multipart.js +26 -0
  228. package/dist/src/utils/multipart.js.map +1 -0
  229. package/dist/src/utils/operations.d.ts +3 -0
  230. package/dist/src/utils/operations.d.ts.map +1 -0
  231. package/dist/src/utils/operations.js +11 -0
  232. package/dist/src/utils/operations.js.map +1 -0
  233. package/dist/src/utils/parameters.d.ts +14 -0
  234. package/dist/src/utils/parameters.d.ts.map +1 -0
  235. package/dist/src/utils/parameters.js +98 -0
  236. package/dist/src/utils/parameters.js.map +1 -0
  237. package/dist/tsconfig.tsbuildinfo +1 -0
  238. package/eng/scripts/calculate-coverage.js +36 -0
  239. package/eng/scripts/emit-e2e.js +329 -0
  240. package/eng/scripts/run-e2e-tests.js +162 -0
  241. package/eng/scripts/tspconfig.yaml +6 -0
  242. package/eng/scripts/upload-spector-results.js +120 -0
  243. package/package.json +83 -0
  244. package/src/components/client-context/client-context-declaration.tsx +19 -0
  245. package/src/components/client-context/client-context-factory.tsx +142 -0
  246. package/src/components/client-context/client-context-options.tsx +28 -0
  247. package/src/components/client-context/client-context.tsx +21 -0
  248. package/src/components/client-context/parametrized-endpoint.tsx +39 -0
  249. package/src/components/client-directory.tsx +40 -0
  250. package/src/components/client-operation.tsx +52 -0
  251. package/src/components/client.tsx +137 -0
  252. package/src/components/encoding-provider.tsx +19 -0
  253. package/src/components/external-packages/ts-http-runtime.ts +22 -0
  254. package/src/components/external-packages/uri-template.ts +11 -0
  255. package/src/components/http-request-options.tsx +69 -0
  256. package/src/components/http-request-parameters-expression.tsx +69 -0
  257. package/src/components/http-request.tsx +58 -0
  258. package/src/components/http-response.tsx +68 -0
  259. package/src/components/models.tsx +29 -0
  260. package/src/components/operation-options.tsx +26 -0
  261. package/src/components/operation-parameters.tsx +43 -0
  262. package/src/components/output.tsx +26 -0
  263. package/src/components/serializers.tsx +47 -0
  264. package/src/components/static-helpers/bytes-encoding.tsx +41 -0
  265. package/src/components/static-helpers/interfaces.tsx +26 -0
  266. package/src/components/static-helpers/multipart-helpers.tsx +59 -0
  267. package/src/components/static-helpers/rest-error.tsx +61 -0
  268. package/src/components/testing/client-options.tsx +32 -0
  269. package/src/components/transforms/content-type-encoding-provider.tsx +28 -0
  270. package/src/components/transforms/data-transform.tsx +39 -0
  271. package/src/components/transforms/json/json-array-transform.tsx +83 -0
  272. package/src/components/transforms/json/json-model-additional-properties-transform.tsx +47 -0
  273. package/src/components/transforms/json/json-model-base-transform.tsx +19 -0
  274. package/src/components/transforms/json/json-model-property-transform.tsx +41 -0
  275. package/src/components/transforms/json/json-model-transform.tsx +87 -0
  276. package/src/components/transforms/json/json-record-transform.tsx +84 -0
  277. package/src/components/transforms/json/json-transform-discriminator.tsx +114 -0
  278. package/src/components/transforms/json/json-transform.tsx +113 -0
  279. package/src/components/transforms/json/union-transform.tsx +73 -0
  280. package/src/components/transforms/json/utils/transport-namer.ts +12 -0
  281. package/src/components/transforms/multipart/array-part-transform.tsx +40 -0
  282. package/src/components/transforms/multipart/file-part-transform.tsx +44 -0
  283. package/src/components/transforms/multipart/multipart-transform.tsx +32 -0
  284. package/src/components/transforms/multipart/part-transform.tsx +22 -0
  285. package/src/components/transforms/multipart/simple-part-transform.tsx +49 -0
  286. package/src/components/transforms/operation-transform-declaration.tsx +64 -0
  287. package/src/components/transforms/operation-transform-expression.tsx +54 -0
  288. package/src/components/transforms/scalar-transform.tsx +289 -0
  289. package/src/components/transforms/transform-name-policy.ts +133 -0
  290. package/src/components/utils/unpack-model-property.ts +31 -0
  291. package/src/components/utils/url-template.tsx +21 -0
  292. package/src/context/encoding/encoding-context.tsx +26 -0
  293. package/src/context/encoding/types.ts +6 -0
  294. package/src/emitter.tsx +53 -0
  295. package/src/index.ts +5 -0
  296. package/src/lib.ts +108 -0
  297. package/src/testing/index.ts +8 -0
  298. package/src/utils/client-discovery.ts +28 -0
  299. package/src/utils/multipart.ts +28 -0
  300. package/src/utils/operations.ts +14 -0
  301. package/src/utils/parameters.tsx +129 -0
  302. package/test/e2e/assets/image.jpg +0 -0
  303. package/test/e2e/assets/image.png +0 -0
  304. package/test/e2e/http/authentication/api-key/main.test.ts +38 -0
  305. package/test/e2e/http/authentication/oauth2/main.test.ts +41 -0
  306. package/test/e2e/http/authentication/union/main.test.ts +29 -0
  307. package/test/e2e/http/encode/bytes/main.test.ts +191 -0
  308. package/test/e2e/http/encode/datetime/main.test.ts +176 -0
  309. package/test/e2e/http/encode/duration/main.test.ts +126 -0
  310. package/test/e2e/http/encode/numeric/main.test.ts +26 -0
  311. package/test/e2e/http/parameters/basic/main.test.ts +35 -0
  312. package/test/e2e/http/parameters/body-optionality/main.test.ts +43 -0
  313. package/test/e2e/http/parameters/collection-format/main.test.ts +45 -0
  314. package/test/e2e/http/parameters/spread/main.test.ts +56 -0
  315. package/test/e2e/http/payload/content-negotiation/main.test.ts +40 -0
  316. package/test/e2e/http/payload/json-merge-patch/main.test.ts +122 -0
  317. package/test/e2e/http/payload/media-type/main.test.ts +28 -0
  318. package/test/e2e/http/payload/multipart/main.test.ts +164 -0
  319. package/test/e2e/http/payload/pageable/main.test.ts +24 -0
  320. package/test/e2e/http/payload/xml/main.test.ts +287 -0
  321. package/test/e2e/http/routes/main.test.ts +284 -0
  322. package/test/e2e/http/serialization/encoded-name/json/main.test.ts +20 -0
  323. package/test/e2e/http/server/endpoint/not-defined/main.test.ts +11 -0
  324. package/test/e2e/http/server/path/multiple/main.test.ts +22 -0
  325. package/test/e2e/http/server/path/single/main.test.ts +11 -0
  326. package/test/e2e/http/server/versions/not-versioned/main.test.ts +22 -0
  327. package/test/e2e/http/server/versions/versioned/main.test.ts +28 -0
  328. package/test/e2e/http/special-headers/conditional-request/main.test.ts +35 -0
  329. package/test/e2e/http/special-headers/repeatability/main.test.ts +18 -0
  330. package/test/e2e/http/special-words/main.test.ts +434 -0
  331. package/test/e2e/http/type/array/array.test.ts +256 -0
  332. package/test/e2e/http/type/dictionary/main.test.ts +229 -0
  333. package/test/e2e/http/type/enum/extensible/main.test.ts +34 -0
  334. package/test/e2e/http/type/enum/fixed/main.test.ts +29 -0
  335. package/test/e2e/http/type/model/empty/main.test.ts +21 -0
  336. package/test/e2e/http/type/model/inheritance/enum-discriminator/main.test.ts +51 -0
  337. package/test/e2e/http/type/model/inheritance/nested-discriminator/main.test.ts +168 -0
  338. package/test/e2e/http/type/model/inheritance/not-discriminated/main.test.ts +42 -0
  339. package/test/e2e/http/type/model/inheritance/recursive/main.test.ts +46 -0
  340. package/test/e2e/http/type/model/inheritance/single-discriminator/main.test.ts +101 -0
  341. package/test/e2e/http/type/model/visibility/main.test.ts +64 -0
  342. package/test/e2e/http/type/property/additional-properties/main.test.ts +185 -0
  343. package/test/e2e/http/type/property/additional-properties/spreads.test.ts +470 -0
  344. package/test/e2e/http/type/property/nullable/main.test.ts +275 -0
  345. package/test/e2e/http/type/property/optionality/main.test.ts +256 -0
  346. package/test/e2e/http/type/property/value-types/main.test.ts +193 -0
  347. package/test/e2e/http/type/scalar/main.test.ts +133 -0
  348. package/test/e2e/http/type/scalar/scalar.test.ts +95 -0
  349. package/test/e2e/http/type/union/main.test.ts +207 -0
  350. package/test/e2e/http/versioning/added/main.test.ts +61 -0
  351. package/test/e2e/http/versioning/madeOptional/main.test.ts +34 -0
  352. package/test/e2e/http/versioning/removed/main.test.ts +75 -0
  353. package/test/e2e/http/versioning/renamedFrom/main.test.ts +52 -0
  354. package/test/e2e/http/versioning/returnTypeChangedFrom/main.test.ts +22 -0
  355. package/test/e2e/http/versioning/typeChangedFrom/main.test.ts +31 -0
  356. package/test/scenarios/additional-properties/extends.md +71 -0
  357. package/test/scenarios/additional-properties/is.md +46 -0
  358. package/test/scenarios/additional-properties/spread.md +72 -0
  359. package/test/scenarios/auth/basic_auth.md +67 -0
  360. package/test/scenarios/auth/bearer.md +67 -0
  361. package/test/scenarios/auth/client_parameters.md +68 -0
  362. package/test/scenarios/auth/client_structure.md +38 -0
  363. package/test/scenarios/auth/key_credential.md +67 -0
  364. package/test/scenarios/auth/sub_client_override.md +114 -0
  365. package/test/scenarios/client/client_context.md +36 -0
  366. package/test/scenarios/client/dotted_namespace.md +30 -0
  367. package/test/scenarios/client/global_namespace.md +74 -0
  368. package/test/scenarios/client/multiple_top_level_clients.md +74 -0
  369. package/test/scenarios/client/nested_client.md +106 -0
  370. package/test/scenarios/client/wrapping_namespace.md +43 -0
  371. package/test/scenarios/encoding/bytes_body.md +48 -0
  372. package/test/scenarios/encoding/bytes_json_property.md +60 -0
  373. package/test/scenarios/encoding/bytes_nullable.md +153 -0
  374. package/test/scenarios/encoding/header_bytes.md +142 -0
  375. package/test/scenarios/encoding/header_date.md +236 -0
  376. package/test/scenarios/encoding/model_with_bytes_property.md +50 -0
  377. package/test/scenarios/encoding/query_bytes.md +46 -0
  378. package/test/scenarios/encoding/query_date.md +236 -0
  379. package/test/scenarios/http-operations/basic-request.md +162 -0
  380. package/test/scenarios/http-operations/basic-response.md +246 -0
  381. package/test/scenarios/http-operations/basic.md +134 -0
  382. package/test/scenarios/http-operations/constant-header.md +37 -0
  383. package/test/scenarios/http-operations/create-operation.md +62 -0
  384. package/test/scenarios/http-operations/on_response.md +56 -0
  385. package/test/scenarios/http-operations/optional-request-body.md +55 -0
  386. package/test/scenarios/http-operations/path-parameter-in-model.md +59 -0
  387. package/test/scenarios/http-operations/path-parameter.md +54 -0
  388. package/test/scenarios/http-operations/scalar-payload.md +63 -0
  389. package/test/scenarios/http-operations/with-parameters.md +85 -0
  390. package/test/scenarios/models/array-properties.md +47 -0
  391. package/test/scenarios/models/basic.md +118 -0
  392. package/test/scenarios/models/dictionary-properties.md +44 -0
  393. package/test/scenarios/models/inheritance_2_discriminators.md +370 -0
  394. package/test/scenarios/models/inheritance_discriminator.md +92 -0
  395. package/test/scenarios/models/inline-models.md +29 -0
  396. package/test/scenarios/models/model_additional_properties.md +79 -0
  397. package/test/scenarios/models/model_extends.md +101 -0
  398. package/test/scenarios/models/model_spread.md +65 -0
  399. package/test/scenarios/models/nested_property.md +45 -0
  400. package/test/scenarios/models/property_references_property.md +156 -0
  401. package/test/scenarios/multipart/anonymous_part.md +57 -0
  402. package/test/scenarios/multipart/file.md +166 -0
  403. package/test/scenarios/multipart/file_content_type.md +67 -0
  404. package/test/scenarios/multipart/simple_part.md +69 -0
  405. package/test/scenarios/operation-parameters/body_root_anonymous.md +92 -0
  406. package/test/scenarios/operation-parameters/constant_as_optional.md +59 -0
  407. package/test/scenarios/operation-parameters/default_value_as_optional.md +59 -0
  408. package/test/scenarios/operation-parameters/no_content_type.md +67 -0
  409. package/test/scenarios/operation-parameters/no_parameters.md +55 -0
  410. package/test/scenarios/operation-parameters/only_optional.md +67 -0
  411. package/test/scenarios/operation-parameters/only_required.md +63 -0
  412. package/test/scenarios/operation-parameters/reserved_names.md +65 -0
  413. package/test/scenarios/operation-parameters/spread_body.md +75 -0
  414. package/test/scenarios/operation-parameters/spread_with_nested.md +87 -0
  415. package/test/scenarios/operation-parameters/union_body.md +92 -0
  416. package/test/scenarios/operation-parameters/with_body_property.md +72 -0
  417. package/test/scenarios/operation-parameters/with_body_root.md +74 -0
  418. package/test/scenarios/serializers/arrays.md +199 -0
  419. package/test/scenarios/serializers/basic_model.md +115 -0
  420. package/test/scenarios/serializers/basic_model_wire_name.md +50 -0
  421. package/test/scenarios/serializers/discriminated_union.md +86 -0
  422. package/test/scenarios/serializers/discriminated_union_spread.md +119 -0
  423. package/test/scenarios/serializers/model_date_time.md +65 -0
  424. package/test/scenarios/serializers/multipart.md +66 -0
  425. package/test/scenarios/serializers/polymorphic_single_level_inheritance.md +164 -0
  426. package/test/scenarios/serializers/record.md +101 -0
  427. package/test/scenarios/serializers/scalars.md +33 -0
  428. package/test/scenarios/serializers/spread.md +75 -0
  429. package/test/scenarios/serializers/string_union.md +61 -0
  430. package/test/scenarios/server/default_url.md +45 -0
  431. package/test/scenarios/server/multiple-parameters.md +57 -0
  432. package/test/scenarios/server/no-server.md +37 -0
  433. package/test/scenarios/server/parametrized-endpoint.md +53 -0
  434. package/test/scenarios.test.ts +18 -0
  435. package/test/test-host.ts +76 -0
  436. package/tsconfig.json +16 -0
  437. package/tsconfig.test.json +7 -0
  438. package/vitest.config.js +23 -0
package/.testignore ADDED
@@ -0,0 +1,2 @@
1
+ # Shadowing issue
2
+ type/model/usage
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Http Client JavaScript
2
+
3
+ ## Environment Variables
4
+
5
+ ### `TYPESPEC_JS_EMITTER_TESTING`
6
+
7
+ This environment variable is used to enable testing-specific options in the TypeSpec JavaScript emitter.
8
+
9
+ - **Name:** `TYPESPEC_JS_EMITTER_TESTING`
10
+ - **Type:** `boolean`
11
+ - **Default:** `false`
12
+ - **Description:** When set to `true`, enables testing-specific options in the TypeSpec JavaScript emitter. This is used to configure the client for testing purposes, such as allowing insecure connections and setting retry options.
13
+
14
+ #### Usage
15
+
16
+ To enable testing-specific options, set the environment variable before running your tests:
17
+
18
+ ```sh
19
+ export TYPESPEC_JS_EMITTER_TESTING=true
20
+ ```
21
+
22
+ Or, if you are using a script, you can set it inline:
23
+
24
+ ```sh
25
+ TYPESPEC_JS_EMITTER_TESTING=true node your-script.js
26
+ ```
@@ -0,0 +1,4 @@
1
+ export default {
2
+ sourceMaps: true,
3
+ presets: ["@babel/preset-typescript", "@alloy-js/babel-preset"],
4
+ };
@@ -0,0 +1,8 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import * as cl from "@typespec/http-client";
3
+ export interface ClientContextDeclarationProps {
4
+ client: cl.Client;
5
+ }
6
+ export declare function getClientcontextDeclarationRef(client: cl.Client): ay.Refkey;
7
+ export declare function ClientContextDeclaration(props: ClientContextDeclarationProps): ay.Children;
8
+ //# sourceMappingURL=client-context-declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context-declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/client-context/client-context-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;CACnB;AAED,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,aAE/D;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,eAK5E"}
@@ -0,0 +1,21 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as ay from "@alloy-js/core";
3
+ import * as ts from "@alloy-js/typescript";
4
+ import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
5
+ export function getClientcontextDeclarationRef(client) {
6
+ return ay.refkey(client, "declaration");
7
+ }
8
+ export function ClientContextDeclaration(props) {
9
+ const ref = getClientcontextDeclarationRef(props.client);
10
+ const namePolicy = ts.useTSNamePolicy();
11
+ const name = namePolicy.getName(`${props.client.name}Context`, "class");
12
+ return _$createComponent(ts.InterfaceDeclaration, {
13
+ "export": true,
14
+ name: name,
15
+ refkey: ref,
16
+ get ["extends"]() {
17
+ return httpRuntimeTemplateLib.Client;
18
+ }
19
+ });
20
+ }
21
+ //# sourceMappingURL=client-context-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context-declaration.js","names":["ay","ts","httpRuntimeTemplateLib","getClientcontextDeclarationRef","client","refkey","ClientContextDeclaration","props","ref","namePolicy","useTSNamePolicy","name","getName","_$createComponent","InterfaceDeclaration","extends","Client"],"sources":["../../../../src/components/client-context/client-context-declaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,sBAAsB,QAAQ,yCAAyC;AAMhF,OAAO,SAASC,8BAA8BA,CAACC,MAAiB,EAAE;EAChE,OAAOJ,EAAE,CAACK,MAAM,CAACD,MAAM,EAAE,aAAa,CAAC;AACzC;AAEA,OAAO,SAASE,wBAAwBA,CAACC,KAAoC,EAAE;EAC7E,MAAMC,GAAG,GAAGL,8BAA8B,CAACI,KAAK,CAACH,MAAM,CAAC;EACxD,MAAMK,UAAU,GAAGR,EAAE,CAACS,eAAe,CAAC,CAAC;EACvC,MAAMC,IAAI,GAAGF,UAAU,CAACG,OAAO,CAAC,GAAGL,KAAK,CAACH,MAAM,CAACO,IAAI,SAAS,EAAE,OAAO,CAAC;EACvE,OAAAE,iBAAA,CAAQZ,EAAE,CAACa,oBAAoB;IAAA;IAAQH,IAAI,EAAEA,IAAI;IAAEN,MAAM,EAAEG,GAAG;IAAA,eAAAO,CAAA;MAAA,OAAWb,sBAAsB,CAACc,MAAM;IAAA;EAAA;AACxG","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import * as cl from "@typespec/http-client";
3
+ export interface ClientContextFactoryProps {
4
+ client: cl.Client;
5
+ }
6
+ export declare function getClientContextFactoryRef(client: cl.Client): ay.Refkey;
7
+ export declare function ClientContextFactoryDeclaration(props: ClientContextFactoryProps): ay.Children;
8
+ //# sourceMappingURL=client-context-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context-factory.d.ts","sourceRoot":"","sources":["../../../../src/components/client-context/client-context-factory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIrC,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQ5C,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;CACnB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,aAE3D;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,yBAAyB,eAkC/E"}
@@ -0,0 +1,154 @@
1
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
2
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
3
+ import * as ay from "@alloy-js/core";
4
+ import * as ts from "@alloy-js/typescript";
5
+ import { $ } from "@typespec/compiler/experimental/typekit";
6
+ import { FunctionDeclaration } from "@typespec/emitter-framework/typescript";
7
+ import { reportDiagnostic } from "../../lib.js";
8
+ import { buildClientParameters } from "../../utils/parameters.js";
9
+ import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
10
+ import { addClientTestOptions } from "../testing/client-options.js";
11
+ import { getClientcontextDeclarationRef } from "./client-context-declaration.js";
12
+ import { ParametrizedEndpoint } from "./parametrized-endpoint.js";
13
+ export function getClientContextFactoryRef(client) {
14
+ return ay.refkey(client, "contextFactory");
15
+ }
16
+ export function ClientContextFactoryDeclaration(props) {
17
+ const ref = getClientContextFactoryRef(props.client);
18
+ const contextDeclarationRef = getClientcontextDeclarationRef(props.client);
19
+ const namePolicy = ts.useTSNamePolicy();
20
+ const factoryFunctionName = namePolicy.getName(`create_${props.client.name}Context`, "function");
21
+ const clientConstructor = $.client.getConstructor(props.client);
22
+ const parameters = buildClientParameters(props.client);
23
+ const urlTemplate = $.client.getUrlTemplate(props.client);
24
+ const endpointRef = ay.refkey();
25
+ const resolvedEndpoint = _$createComponent(ParametrizedEndpoint, {
26
+ refkey: endpointRef,
27
+ get template() {
28
+ return urlTemplate.url;
29
+ },
30
+ get params() {
31
+ return urlTemplate.parameters;
32
+ }
33
+ });
34
+ let credentialsRef;
35
+ if (clientConstructor.parameters.properties.has("credential")) {
36
+ credentialsRef = "credential";
37
+ }
38
+
39
+ // Filter out optional parameters, they will be passed as options
40
+ const args = _$createComponent(ClientFactoryArguments, {
41
+ get client() {
42
+ return props.client;
43
+ },
44
+ endpointRef: endpointRef,
45
+ credentialsRef: credentialsRef
46
+ });
47
+ return _$createComponent(FunctionDeclaration, {
48
+ "export": true,
49
+ name: factoryFunctionName,
50
+ type: clientConstructor,
51
+ returnType: contextDeclarationRef,
52
+ refkey: ref,
53
+ parametersMode: "replace",
54
+ parameters: parameters,
55
+ get children() {
56
+ return [resolvedEndpoint, "\nreturn ", _$createComponent(ts.FunctionCallExpression, {
57
+ get refkey() {
58
+ return httpRuntimeTemplateLib.getClient;
59
+ },
60
+ args: [args]
61
+ })];
62
+ }
63
+ });
64
+ }
65
+ function ClientFactoryArguments(props) {
66
+ const params = [[_$memo(() => props.endpointRef), ","]];
67
+ if (props.credentialsRef) {
68
+ params.push([_$memo(() => props.credentialsRef), ","]);
69
+ }
70
+ return [...params, _$createComponent(ClientOptionsExpression, {
71
+ get children() {
72
+ return _$createComponent(CredentialOptions, {
73
+ get client() {
74
+ return props.client;
75
+ }
76
+ });
77
+ }
78
+ })];
79
+ }
80
+ function CredentialOptions(props) {
81
+ const clientCredential = $.client.getAuth(props.client);
82
+ if (clientCredential.schemes.length === 0) {
83
+ return null;
84
+ }
85
+ if (clientCredential.schemes.length !== 1) {
86
+ reportDiagnostic($.program, {
87
+ code: "multiple-auth-schemes-not-yet-supported",
88
+ target: props.client.type
89
+ });
90
+ }
91
+ const scheme = clientCredential.schemes[0];
92
+ switch (scheme.type) {
93
+ case "http":
94
+ // Todo: handle scopes?
95
+ return _$createComponent(ts.ObjectProperty, {
96
+ name: "credentials",
97
+ get children() {
98
+ return _$createComponent(ts.ObjectExpression, {
99
+ get children() {
100
+ return _$createComponent(ts.ObjectProperty, {
101
+ name: "apiKeyHeaderName",
102
+ jsValue: "Authorization"
103
+ });
104
+ }
105
+ });
106
+ }
107
+ });
108
+ case "apiKey":
109
+ if (scheme.in !== "header") {
110
+ reportDiagnostic($.program, {
111
+ code: "non-model-parts",
112
+ target: props.client.service
113
+ });
114
+ return null;
115
+ }
116
+ return _$createComponent(ts.ObjectProperty, {
117
+ name: "credentials",
118
+ get children() {
119
+ return _$createComponent(ts.ObjectExpression, {
120
+ get children() {
121
+ return _$createComponent(ts.ObjectProperty, {
122
+ name: "apiKeyHeaderName",
123
+ get jsValue() {
124
+ return scheme.name;
125
+ }
126
+ });
127
+ }
128
+ });
129
+ }
130
+ });
131
+ default:
132
+ return null;
133
+ }
134
+ }
135
+ function ClientOptionsExpression(props) {
136
+ const options = ["...options"];
137
+
138
+ // Conditionally add test options
139
+ // based on the environment variable TYPESPEC_JS_EMITTER_TESTING
140
+ addClientTestOptions(options);
141
+ const children = Array.isArray(props.children) ? props.children : [props.children];
142
+ if (children.length) {
143
+ const children = Array.isArray(props.children) ? props.children : [props.children];
144
+ options.push(...children);
145
+ }
146
+ return _$createComponent(ts.ObjectExpression, {
147
+ get children() {
148
+ return ay.mapJoin(options, child => child, {
149
+ joiner: ", "
150
+ });
151
+ }
152
+ });
153
+ }
154
+ //# sourceMappingURL=client-context-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context-factory.js","names":["ay","ts","$","FunctionDeclaration","reportDiagnostic","buildClientParameters","httpRuntimeTemplateLib","addClientTestOptions","getClientcontextDeclarationRef","ParametrizedEndpoint","getClientContextFactoryRef","client","refkey","ClientContextFactoryDeclaration","props","ref","contextDeclarationRef","namePolicy","useTSNamePolicy","factoryFunctionName","getName","name","clientConstructor","getConstructor","parameters","urlTemplate","getUrlTemplate","endpointRef","resolvedEndpoint","_$createComponent","template","url","params","credentialsRef","properties","has","args","ClientFactoryArguments","type","returnType","parametersMode","children","FunctionCallExpression","getClient","_$memo","push","ClientOptionsExpression","CredentialOptions","clientCredential","getAuth","schemes","length","program","code","target","scheme","ObjectProperty","ObjectExpression","jsValue","in","service","options","Array","isArray","mapJoin","child","joiner"],"sources":["../../../../src/components/client-context/client-context-factory.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAC1C,SAASC,CAAC,QAAQ,yCAAyC;AAC3D,SAASC,mBAAmB,QAAQ,wCAAwC;AAE5E,SAASC,gBAAgB,QAAQ,cAAc;AAC/C,SAASC,qBAAqB;AAC9B,SAASC,sBAAsB,QAAQ,yCAAyC;AAChF,SAASC,oBAAoB;AAC7B,SAASC,8BAA8B;AACvC,SAASC,oBAAoB;AAM7B,OAAO,SAASC,0BAA0BA,CAACC,MAAiB,EAAE;EAC5D,OAAOX,EAAE,CAACY,MAAM,CAACD,MAAM,EAAE,gBAAgB,CAAC;AAC5C;AAEA,OAAO,SAASE,+BAA+BA,CAACC,KAAgC,EAAE;EAChF,MAAMC,GAAG,GAAGL,0BAA0B,CAACI,KAAK,CAACH,MAAM,CAAC;EACpD,MAAMK,qBAAqB,GAAGR,8BAA8B,CAACM,KAAK,CAACH,MAAM,CAAC;EAC1E,MAAMM,UAAU,GAAGhB,EAAE,CAACiB,eAAe,CAAC,CAAC;EACvC,MAAMC,mBAAmB,GAAGF,UAAU,CAACG,OAAO,CAAC,UAAUN,KAAK,CAACH,MAAM,CAACU,IAAI,SAAS,EAAE,UAAU,CAAC;EAEhG,MAAMC,iBAAiB,GAAGpB,CAAC,CAACS,MAAM,CAACY,cAAc,CAACT,KAAK,CAACH,MAAM,CAAC;EAC/D,MAAMa,UAAU,GAAGnB,qBAAqB,CAAC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AAK,EAAE;QAAEC,MAAM,EAAE;MAAK,CAAC,CAAC;IAAA;EAAA;AAE5D","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import * as cl from "@typespec/http-client";
3
+ export interface ClientContextOptionsDeclarationProps {
4
+ client: cl.Client;
5
+ }
6
+ export declare function getClientContextOptionsRef(client: cl.Client): ay.Refkey;
7
+ export declare function ClientContextOptionsDeclaration(props: ClientContextOptionsDeclarationProps): ay.Children;
8
+ //# sourceMappingURL=client-context-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context-options.d.ts","sourceRoot":"","sources":["../../../../src/components/client-context/client-context-options.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,WAAW,oCAAoC;IACnD,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;CACnB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,aAE3D;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,oCAAoC,eAc1F"}
@@ -0,0 +1,42 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
+ import * as ay from "@alloy-js/core";
4
+ import * as ts from "@alloy-js/typescript";
5
+ import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
6
+ export function getClientContextOptionsRef(client) {
7
+ return ay.refkey(client, "options");
8
+ }
9
+ export function ClientContextOptionsDeclaration(props) {
10
+ const ref = getClientContextOptionsRef(props.client);
11
+ const namePolicy = ts.useTSNamePolicy();
12
+ const name = namePolicy.getName(`${props.client.name}Options`, "interface");
13
+
14
+ // TODO: Here we will calculate and include all the options that the client can accept
15
+ const clientOptions = new Map();
16
+ return _$createComponent(ts.InterfaceDeclaration, {
17
+ "export": true,
18
+ name: name,
19
+ refkey: ref,
20
+ get ["extends"]() {
21
+ return _$createComponent(ts.Reference, {
22
+ get refkey() {
23
+ return httpRuntimeTemplateLib.ClientOptions;
24
+ }
25
+ });
26
+ },
27
+ get children() {
28
+ return [_$memo(() => ay.mapJoin(clientOptions, (key, value) => _$createComponent(ts.InterfaceMember, {
29
+ optional: true,
30
+ name: key,
31
+ type: value
32
+ }), {
33
+ joiner: ";\n"
34
+ })), "\n", _$createComponent(ts.InterfaceMember, {
35
+ optional: true,
36
+ name: "endpoint",
37
+ type: "string"
38
+ })];
39
+ }
40
+ });
41
+ }
42
+ //# sourceMappingURL=client-context-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context-options.js","names":["ay","ts","httpRuntimeTemplateLib","getClientContextOptionsRef","client","refkey","ClientContextOptionsDeclaration","props","ref","namePolicy","useTSNamePolicy","name","getName","clientOptions","Map","_$createComponent","InterfaceDeclaration","extends","Reference","ClientOptions","children","_$memo","mapJoin","key","value","InterfaceMember","optional","type","joiner"],"sources":["../../../../src/components/client-context/client-context-options.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,sBAAsB,QAAQ,yCAAyC;AAMhF,OAAO,SAASC,0BAA0BA,CAACC,MAAiB,EAAE;EAC5D,OAAOJ,EAAE,CAACK,MAAM,CAACD,MAAM,EAAE,SAAS,CAAC;AACrC;AAEA,OAAO,SAASE,+BAA+BA,CAACC,KAA2C,EAAE;EAC3F,MAAMC,GAAG,GAAGL,0BAA0B,CAACI,KAAK,CAACH,MAAM,CAAC;EACpD,MAAMK,UAAU,GAAGR,EAAE,CAACS,eAAe,CAAC,CAAC;EACvC,MAAMC,IAAI,GAAGF,UAAU,CAACG,OAAO,CAAC,GAAGL,KAAK,CAACH,MAAM,CAACO,IAAI,SAAS,EAAE,WAAW,CAAC;;EAE3E;EACA,MAAME,aAAuC,GAAG,IAAIC,GAAG,CAAC,CAAC;EAEzD,OAAAC,iBAAA,CAAQd,EAAE,CAACe,oBAAoB;IAAA;IAAQL,IAAI,EAAEA,IAAI;IAAEN,MAAM,EAAEG,GAAG;IAAA,eAAAS,CAAA;MAAA,OAAAF,iBAAA,CAAYd,EAAE,CAACiB,SAAS;QAAA,IAACb,MAAMA,CAAA;UAAA,OAAEH,sBAAsB,CAACiB,aAAa;QAAA;MAAA;IAAA;IAAA,IAAAC,SAAA;MAAA,QAAAC,MAAA,OAC5HrB,EAAE,CAACsB,OAAO,CAACT,aAAa,EAAE,CAACU,GAAG,EAAEC,KAAK,KAAAT,iBAAA,CACnCd,EAAE,CAACwB,eAAe;QAACC,QAAQ;QAACf,IAAI,EAAEY,GAAG;QAAEI,IAAI,EAAEH;MAAK,EACpD,EAAE;QAAEI,MAAM,EAAE;MAAM,CAAC,CAAC,SAAAb,iBAAA,CACpBd,EAAE,CAACwB,eAAe;QAACC,QAAQ;QAACf,IAAI;QAAYgB,IAAI;MAAA;IAAA;EAAA;AAEzD","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import * as cl from "@typespec/http-client";
3
+ export interface ClientContextProps {
4
+ client: cl.Client;
5
+ children?: ay.Children;
6
+ }
7
+ export declare function ClientContext(props: ClientContextProps): ay.Children;
8
+ //# sourceMappingURL=client-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context.d.ts","sourceRoot":"","sources":["../../../../src/components/client-context/client-context.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC;CACxB;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eAQtD"}
@@ -0,0 +1,33 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { Indent as _$Indent } from "@alloy-js/core";
3
+ import * as ts from "@alloy-js/typescript";
4
+ import { ClientContextDeclaration } from "./client-context-declaration.js";
5
+ import { ClientContextFactoryDeclaration } from "./client-context-factory.js";
6
+ import { ClientContextOptionsDeclaration } from "./client-context-options.js";
7
+ export function ClientContext(props) {
8
+ const namePolicy = ts.useTSNamePolicy();
9
+ const fileName = namePolicy.getName(props.client.name + "Context", "variable");
10
+ return _$createComponent(ts.SourceFile, {
11
+ path: `${fileName}.ts`,
12
+ get children() {
13
+ return [_$createComponent(ClientContextDeclaration, {
14
+ get client() {
15
+ return props.client;
16
+ }
17
+ }), _$createComponent(_$Indent, {
18
+ get children() {
19
+ return ["\n", _$createComponent(ClientContextOptionsDeclaration, {
20
+ get client() {
21
+ return props.client;
22
+ }
23
+ }), "\n", _$createComponent(ClientContextFactoryDeclaration, {
24
+ get client() {
25
+ return props.client;
26
+ }
27
+ })];
28
+ }
29
+ })];
30
+ }
31
+ });
32
+ }
33
+ //# sourceMappingURL=client-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-context.js","names":["ts","ClientContextDeclaration","ClientContextFactoryDeclaration","ClientContextOptionsDeclaration","ClientContext","props","namePolicy","useTSNamePolicy","fileName","getName","client","name","_$createComponent","SourceFile","path","children","_$Indent"],"sources":["../../../../src/components/client-context/client-context.tsx"],"sourcesContent":[null],"mappings":";;AACA,OAAO,KAAKA,EAAE,MAAM,sBAAsB;AAE1C,SAASC,wBAAwB;AACjC,SAASC,+BAA+B;AACxC,SAASC,+BAA+B;AAOxC,OAAO,SAASC,aAAaA,CAACC,KAAyB,EAAE;EACvD,MAAMC,UAAU,GAAGN,EAAE,CAACO,eAAe,CAAC,CAAC;EACvC,MAAMC,QAAQ,GAAGF,UAAU,CAACG,OAAO,CAACJ,KAAK,CAACK,MAAM,CAACC,IAAI,GAAG,SAAS,EAAE,UAAU,CAAC;EAC9E,OAAAC,iBAAA,CAAQZ,EAAE,CAACa,UAAU;IAACC,IAAI,EAAE,GAAGN,QAAQ,KAAK;IAAA,IAAAO,SAAA;MAAA,QAAAH,iBAAA,CACxCX,wBAAwB;QAAA,IAACS,MAAMA,CAAA;UAAA,OAAEL,KAAK,CAACK,MAAM;QAAA;MAAA,IAAAE,iBAAA,CAAAI,QAAA;QAAA,IAAAD,SAAA;UAAA,cAAAH,iBAAA,CAC5CT,+BAA+B;YAAA,IAACO,MAAMA,CAAA;cAAA,OAAEL,KAAK,CAACK,MAAM;YAAA;UAAA,UAAAE,iBAAA,CACpDV,+BAA+B;YAAA,IAACQ,MAAMA,CAAA;cAAA,OAAEL,KAAK,CAACK,MAAM;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAE3D","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import { ModelProperty } from "@typespec/compiler";
3
+ export interface ParametrizedEndpointProps {
4
+ refkey: ay.Refkey;
5
+ template: string;
6
+ params: ModelProperty[];
7
+ }
8
+ export declare function ParametrizedEndpoint(props: ParametrizedEndpointProps): ay.Children[];
9
+ //# sourceMappingURL=parametrized-endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parametrized-endpoint.d.ts","sourceRoot":"","sources":["../../../../src/components/client-context/parametrized-endpoint.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,EAAE,CAAC;CACzB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,iBA0BpE"}
@@ -0,0 +1,48 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
+ import * as ay from "@alloy-js/core";
4
+ import * as ts from "@alloy-js/typescript";
5
+ import { useTransformNamePolicy } from "@typespec/emitter-framework";
6
+ import { getDefaultValue } from "../../utils/parameters.js";
7
+ export function ParametrizedEndpoint(props) {
8
+ const propNamer = useTransformNamePolicy();
9
+ const paramsRef = ay.refkey();
10
+ const params = _$createComponent(ts.VarDeclaration, {
11
+ name: "params",
12
+ type: "Record<string, any>",
13
+ refkey: paramsRef,
14
+ get children() {
15
+ return _$createComponent(ts.ObjectExpression, {
16
+ get children() {
17
+ return ay.mapJoin(props.params, p => {
18
+ const applicationName = propNamer.getApplicationName(p);
19
+ const transportName = propNamer.getTransportName(p);
20
+ const defaultValue = p.defaultValue ? ` ?? ${getDefaultValue(p)}` : "";
21
+ const itemRef = p.optional ? `options?.${applicationName}${defaultValue}` : applicationName;
22
+ return _$createComponent(ts.ObjectProperty, {
23
+ name: transportName,
24
+ value: itemRef
25
+ });
26
+ }, {
27
+ joiner: ",\n"
28
+ });
29
+ }
30
+ });
31
+ }
32
+ });
33
+ const resolvedEndpoint = _$createComponent(ts.VarDeclaration, {
34
+ name: "resolvedEndpoint",
35
+ get refkey() {
36
+ return props.refkey;
37
+ },
38
+ get children() {
39
+ return ay.code`
40
+ "${props.template}".replace(/{([^}]+)}/g, (_, key) =>
41
+ key in ${paramsRef} ? String(params[key]) : (() => { throw new Error(\`Missing parameter: $\{key}\`); })()
42
+ );
43
+ `;
44
+ }
45
+ });
46
+ return [params, resolvedEndpoint];
47
+ }
48
+ //# sourceMappingURL=parametrized-endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parametrized-endpoint.js","names":["ay","ts","useTransformNamePolicy","getDefaultValue","ParametrizedEndpoint","props","propNamer","paramsRef","refkey","params","_$createComponent","VarDeclaration","name","type","children","ObjectExpression","mapJoin","p","applicationName","getApplicationName","transportName","getTransportName","defaultValue","itemRef","optional","ObjectProperty","value","joiner","resolvedEndpoint","code","template"],"sources":["../../../../src/components/client-context/parametrized-endpoint.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,sBAAsB,QAAQ,6BAA6B;AACpE,SAASC,eAAe;AAQxB,OAAO,SAASC,oBAAoBA,CAACC,KAAgC,EAAE;EACrE,MAAMC,SAAS,GAAGJ,sBAAsB,CAAC,CAAC;EAC1C,MAAMK,SAAS,GAAGP,EAAE,CAACQ,MAAM,CAAC,CAAC;EAC7B,MAAMC,MAAM,GAAAC,iBAAA,CACTT,EAAE,CAACU,cAAc;IAACC,IAAI;IAAUC,IAAI,EAAE,qBAAqB;IAAEL,MAAM,EAAED,SAAS;IAAA,IAAAO,SAAA;MAAA,OAAAJ,iBAAA,CAC9ET,EAAE,CAACc,gBAAgB;QAAA,IAAAD,SAAA;UAAA,OACjBd,EAAE,CAACgB,OAAO,CAACX,KAAK,CAACI,MAAM,EAAGQ,CAAC,IAAK;YAC/B,MAAMC,eAAe,GAAGZ,SAAS,CAACa,kBAAkB,CAACF,CAAC,CAAC;YACvD,MAAMG,aAAa,GAAGd,SAAS,CAACe,gBAAgB,CAACJ,CAAC,CAAC;YACnD,MAAMK,YAAY,GAAGL,CAAC,CAACK,YAAY,GAAG,OAAOnB,eAAe,CAACc,CAAC,CAAC,EAAE,GAAG,EAAE;YACtE,MAAMM,OAAO,GAAGN,CAAC,CAACO,QAAQ,GAAG,YAAYN,eAAe,GAAGI,YAAY,EAAE,GAAGJ,eAAe;YAC3F,OAAAR,iBAAA,CAAQT,EAAE,CAACwB,cAAc;cAACb,IAAI,EAAEQ,aAAa;cAAEM,KAAK,EAAEH;YAAO;UAC/D,CAAC,EAAE;YAACI,MAAM,EAAE;UAAK,CAAC,CAAC;QAAA;MAAA;IAAA;EAAA,EAEH;EAEpB,MAAMC,gBAAgB,GAAAlB,iBAAA,CACnBT,EAAE,CAACU,cAAc;IAACC,IAAI;IAAA,IAAoBJ,MAAMA,CAAA;MAAA,OAAEH,KAAK,CAACG,MAAM;IAAA;IAAA,IAAAM,SAAA;MAAA,OAC9Dd,EAAE,CAAC6B,IAAI;AACZ,SAASxB,KAAK,CAACyB,QAAQ;AACvB,iBAAiBvB,SAAS;AAC1B;AACA,KAAK;IAAA;EAAA,EACiB;EAEpB,OAAO,CAACE,MAAM,EAAEmB,gBAAgB,CAAC;AACnC","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import * as cl from "@typespec/http-client";
3
+ export interface OperationsDirectoryProps {
4
+ children?: ay.Children;
5
+ }
6
+ export declare function OperationsDirectory(props: OperationsDirectoryProps): ay.Children[];
7
+ export interface SubClientsProps {
8
+ client: cl.Client;
9
+ }
10
+ export declare function SubClients(props: SubClientsProps): ay.Children[];
11
+ //# sourceMappingURL=client-directory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-directory.d.ts","sourceRoot":"","sources":["../../../src/components/client-directory.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC;CACxB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,iBAUlE;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,iBAYhD"}
@@ -0,0 +1,39 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import * as ay from "@alloy-js/core";
3
+ import * as ts from "@alloy-js/typescript";
4
+ import { useClientLibrary } from "@typespec/http-client";
5
+ import { ClientContext } from "./client-context/client-context.js";
6
+ import { ClientOperations } from "./client-operation.js";
7
+ export function OperationsDirectory(props) {
8
+ const {
9
+ topLevel: clients
10
+ } = useClientLibrary();
11
+ // If it is the root client, we don't need to create a directory
12
+ return ay.mapJoin(clients, client => [_$createComponent(ClientOperations, {
13
+ client: client
14
+ }), "\n", _$createComponent(ClientContext, {
15
+ client: client
16
+ }), "\n", _$createComponent(SubClients, {
17
+ client: client
18
+ })]);
19
+ }
20
+ export function SubClients(props) {
21
+ const subClients = props.client.subClients;
22
+ return ay.mapJoin(subClients, subClient => {
23
+ const namePolicy = ts.useTSNamePolicy();
24
+ const subClientName = namePolicy.getName(subClient.name, "variable");
25
+ return _$createComponent(ay.SourceDirectory, {
26
+ path: subClientName,
27
+ get children() {
28
+ return [_$createComponent(ClientOperations, {
29
+ client: subClient
30
+ }), "\n", _$createComponent(ClientContext, {
31
+ client: subClient
32
+ }), "\n", _$createComponent(SubClients, {
33
+ client: subClient
34
+ })];
35
+ }
36
+ });
37
+ });
38
+ }
39
+ //# sourceMappingURL=client-directory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-directory.js","names":["ay","ts","useClientLibrary","ClientContext","ClientOperations","OperationsDirectory","props","topLevel","clients","mapJoin","client","_$createComponent","SubClients","subClients","subClient","namePolicy","useTSNamePolicy","subClientName","getName","name","SourceDirectory","path","children"],"sources":["../../../src/components/client-directory.tsx"],"sourcesContent":[null],"mappings":";AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAE1C,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASC,aAAa;AACtB,SAASC,gBAAgB;AAMzB,OAAO,SAASC,mBAAmBA,CAACC,KAA+B,EAAE;EACnE,MAAM;IAAEC,QAAQ,EAAEC;EAAQ,CAAC,GAAGN,gBAAgB,CAAC,CAAC;EAChD;EACA,OAAOF,EAAE,CAACS,OAAO,CAACD,OAAO,EACvBE,MAAM,KAAAC,iBAAA,CAEFP,gBAAgB;IAACM,MAAM,EAAEA;EAAM,UAAAC,iBAAA,CAC/BR,aAAa;IAACO,MAAM,EAAEA;EAAM,UAAAC,iBAAA,CAC5BC,UAAU;IAACF,MAAM,EAAEA;EAAM,GAC1B,CAAC;AACR;AAMA,OAAO,SAASE,UAAUA,CAACN,KAAsB,EAAE;EACjD,MAAMO,UAAU,GAAGP,KAAK,CAACI,MAAM,CAACG,UAAU;EAE1C,OAAOb,EAAE,CAACS,OAAO,CAACI,UAAU,EAAGC,SAAS,IAAK;IAC3C,MAAMC,UAAU,GAAGd,EAAE,CAACe,eAAe,CAAC,CAAC;IACvC,MAAMC,aAAa,GAAGF,UAAU,CAACG,OAAO,CAACJ,SAAS,CAACK,IAAI,EAAE,UAAU,CAAC;IACpE,OAAAR,iBAAA,CAAQX,EAAE,CAACoB,eAAe;MAACC,IAAI,EAAEJ,aAAa;MAAA,IAAAK,SAAA;QAAA,QAAAX,iBAAA,CACzCP,gBAAgB;UAACM,MAAM,EAAEI;QAAS,UAAAH,iBAAA,CAClCR,aAAa;UAACO,MAAM,EAAEI;QAAS,UAAAH,iBAAA,CAC/BC,UAAU;UAACF,MAAM,EAAEI;QAAS;MAAA;IAAA;EAEnC,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import * as ay from "@alloy-js/core";
2
+ import * as cl from "@typespec/http-client";
3
+ export interface ClientOperationsProps {
4
+ client: cl.Client;
5
+ }
6
+ export declare function ClientOperations(props: ClientOperationsProps): ay.Children;
7
+ export interface ClientOperationProps {
8
+ clientOperation: cl.ClientOperation;
9
+ }
10
+ export declare function ClientOperation(props: ClientOperationProps): ay.Children;
11
+ //# sourceMappingURL=client-operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-operation.d.ts","sourceRoot":"","sources":["../../../src/components/client-operation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAIrC,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAO5C,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAc5D;AAED,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC;CACrC;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAgB1D"}
@@ -0,0 +1,74 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { memo as _$memo } from "@alloy-js/core/jsx-runtime";
3
+ import * as ay from "@alloy-js/core";
4
+ import * as ts from "@alloy-js/typescript";
5
+ import { $ } from "@typespec/compiler/experimental/typekit";
6
+ import { FunctionDeclaration, TypeExpression } from "@typespec/emitter-framework/typescript";
7
+ import { getClientcontextDeclarationRef } from "./client-context/client-context-declaration.js";
8
+ import { HttpRequest } from "./http-request.js";
9
+ import { HttpResponse } from "./http-response.js";
10
+ import { OperationOptionsDeclaration } from "./operation-options.js";
11
+ import { getOperationParameters } from "./operation-parameters.js";
12
+ export function ClientOperations(props) {
13
+ const namePolicy = ts.useTSNamePolicy();
14
+ const clientOperations = props.client.operations;
15
+ const fileName = namePolicy.getName(props.client.name + "Operations", "variable");
16
+ if (clientOperations.length === 0) {
17
+ return null;
18
+ }
19
+ return _$createComponent(ts.SourceFile, {
20
+ path: `${fileName}.ts`,
21
+ get children() {
22
+ return ay.mapJoin(clientOperations, operation => {
23
+ return _$createComponent(ClientOperation, {
24
+ clientOperation: operation
25
+ });
26
+ });
27
+ }
28
+ });
29
+ }
30
+ export function ClientOperation(props) {
31
+ const client = props.clientOperation.client;
32
+ const returnType = $.httpOperation.getReturnType(props.clientOperation.httpOperation);
33
+ const responseRefkey = ay.refkey(props.clientOperation, "http-response");
34
+ const clientContextInterfaceRef = getClientcontextDeclarationRef(client);
35
+ const signatureParams = {
36
+ client: {
37
+ type: clientContextInterfaceRef,
38
+ refkey: ay.refkey(client, "client")
39
+ },
40
+ ...getOperationParameters(props.clientOperation.httpOperation)
41
+ };
42
+ return [_$createComponent(OperationOptionsDeclaration, {
43
+ get operation() {
44
+ return props.clientOperation.httpOperation;
45
+ }
46
+ }), "\n", _$createComponent(FunctionDeclaration, {
47
+ "export": true,
48
+ async: true,
49
+ get type() {
50
+ return props.clientOperation.httpOperation.operation;
51
+ },
52
+ get returnType() {
53
+ return _$createComponent(TypeExpression, {
54
+ type: returnType
55
+ });
56
+ },
57
+ parametersMode: "replace",
58
+ parameters: signatureParams,
59
+ get children() {
60
+ return [_$createComponent(HttpRequest, {
61
+ get operation() {
62
+ return props.clientOperation;
63
+ },
64
+ responseRefkey: responseRefkey
65
+ }), "\n", _$createComponent(HttpResponse, {
66
+ get operation() {
67
+ return props.clientOperation;
68
+ },
69
+ responseRefkey: responseRefkey
70
+ })];
71
+ }
72
+ }), ";"];
73
+ }
74
+ //# sourceMappingURL=client-operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-operation.js","names":["ay","ts","$","FunctionDeclaration","TypeExpression","getClientcontextDeclarationRef","HttpRequest","HttpResponse","OperationOptionsDeclaration","getOperationParameters","ClientOperations","props","namePolicy","useTSNamePolicy","clientOperations","client","operations","fileName","getName","name","length","_$createComponent","SourceFile","path","children","mapJoin","operation","ClientOperation","clientOperation","returnType","httpOperation","getReturnType","responseRefkey","refkey","clientContextInterfaceRef","signatureParams","type","async","parametersMode","parameters"],"sources":["../../../src/components/client-operation.tsx"],"sourcesContent":[null],"mappings":";;AAAA,OAAO,KAAKA,EAAE,MAAM,gBAAgB;AACpC,OAAO,KAAKC,EAAE,MAAM,sBAAsB;AAC1C,SAASC,CAAC,QAAQ,yCAAyC;AAC3D,SAASC,mBAAmB,EAAEC,cAAc,QAAQ,wCAAwC;AAE5F,SAASC,8BAA8B;AACvC,SAASC,WAAW;AACpB,SAASC,YAAY;AACrB,SAASC,2BAA2B;AACpC,SAASC,sBAAsB;AAM/B,OAAO,SAAS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