@typespec/emitter-framework 0.15.0-dev.3 → 0.15.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 (253) hide show
  1. package/CHANGELOG.md +14 -16
  2. package/dist/src/python/builtins.d.ts +14 -0
  3. package/dist/src/python/builtins.d.ts.map +1 -0
  4. package/dist/src/python/builtins.js +29 -0
  5. package/dist/src/python/builtins.js.map +1 -0
  6. package/dist/src/python/components/array-expression/array-expression.d.ts +6 -0
  7. package/dist/src/python/components/array-expression/array-expression.d.ts.map +1 -0
  8. package/dist/src/python/components/array-expression/array-expression.js +11 -0
  9. package/dist/src/python/components/array-expression/array-expression.js.map +1 -0
  10. package/dist/src/python/components/array-expression/array-expression.test.d.ts +2 -0
  11. package/dist/src/python/components/array-expression/array-expression.test.d.ts.map +1 -0
  12. package/dist/src/python/components/array-expression/array-expression.test.js +19 -0
  13. package/dist/src/python/components/array-expression/array-expression.test.js.map +1 -0
  14. package/dist/src/python/components/array-expression/index.d.ts +2 -0
  15. package/dist/src/python/components/array-expression/index.d.ts.map +1 -0
  16. package/dist/src/python/components/array-expression/index.js +2 -0
  17. package/dist/src/python/components/array-expression/index.js.map +1 -0
  18. package/dist/src/python/components/atom/atom.d.ts +33 -0
  19. package/dist/src/python/components/atom/atom.d.ts.map +1 -0
  20. package/dist/src/python/components/atom/atom.js +88 -0
  21. package/dist/src/python/components/atom/atom.js.map +1 -0
  22. package/dist/src/python/components/atom/atom.test.d.ts +2 -0
  23. package/dist/src/python/components/atom/atom.test.d.ts.map +1 -0
  24. package/dist/src/python/components/atom/atom.test.js +224 -0
  25. package/dist/src/python/components/atom/atom.test.js.map +1 -0
  26. package/dist/src/python/components/atom/index.d.ts +2 -0
  27. package/dist/src/python/components/atom/index.d.ts.map +1 -0
  28. package/dist/src/python/components/atom/index.js +2 -0
  29. package/dist/src/python/components/atom/index.js.map +1 -0
  30. package/dist/src/python/components/class-declaration/class-bases.d.ts +45 -0
  31. package/dist/src/python/components/class-declaration/class-bases.d.ts.map +1 -0
  32. package/dist/src/python/components/class-declaration/class-bases.js +84 -0
  33. package/dist/src/python/components/class-declaration/class-bases.js.map +1 -0
  34. package/dist/src/python/components/class-declaration/class-body.d.ts +16 -0
  35. package/dist/src/python/components/class-declaration/class-body.d.ts.map +1 -0
  36. package/dist/src/python/components/class-declaration/class-body.js +52 -0
  37. package/dist/src/python/components/class-declaration/class-body.js.map +1 -0
  38. package/dist/src/python/components/class-declaration/class-declaration.d.ts +23 -0
  39. package/dist/src/python/components/class-declaration/class-declaration.d.ts.map +1 -0
  40. package/dist/src/python/components/class-declaration/class-declaration.js +118 -0
  41. package/dist/src/python/components/class-declaration/class-declaration.js.map +1 -0
  42. package/dist/src/python/components/class-declaration/class-declaration.test.d.ts +2 -0
  43. package/dist/src/python/components/class-declaration/class-declaration.test.d.ts.map +1 -0
  44. package/dist/src/python/components/class-declaration/class-declaration.test.js +1527 -0
  45. package/dist/src/python/components/class-declaration/class-declaration.test.js.map +1 -0
  46. package/dist/src/python/components/class-declaration/class-member.d.ts +16 -0
  47. package/dist/src/python/components/class-declaration/class-member.d.ts.map +1 -0
  48. package/dist/src/python/components/class-declaration/class-member.js +71 -0
  49. package/dist/src/python/components/class-declaration/class-member.js.map +1 -0
  50. package/dist/src/python/components/class-declaration/class-member.test.d.ts +2 -0
  51. package/dist/src/python/components/class-declaration/class-member.test.d.ts.map +1 -0
  52. package/dist/src/python/components/class-declaration/class-member.test.js +202 -0
  53. package/dist/src/python/components/class-declaration/class-member.test.js.map +1 -0
  54. package/dist/src/python/components/class-declaration/class-method.d.ts +22 -0
  55. package/dist/src/python/components/class-declaration/class-method.d.ts.map +1 -0
  56. package/dist/src/python/components/class-declaration/class-method.js +76 -0
  57. package/dist/src/python/components/class-declaration/class-method.js.map +1 -0
  58. package/dist/src/python/components/class-declaration/class-method.test.d.ts +2 -0
  59. package/dist/src/python/components/class-declaration/class-method.test.d.ts.map +1 -0
  60. package/dist/src/python/components/class-declaration/class-method.test.js +298 -0
  61. package/dist/src/python/components/class-declaration/class-method.test.js.map +1 -0
  62. package/dist/src/python/components/class-declaration/index.d.ts +7 -0
  63. package/dist/src/python/components/class-declaration/index.d.ts.map +1 -0
  64. package/dist/src/python/components/class-declaration/index.js +7 -0
  65. package/dist/src/python/components/class-declaration/index.js.map +1 -0
  66. package/dist/src/python/components/class-declaration/primitive-initializer.d.ts +22 -0
  67. package/dist/src/python/components/class-declaration/primitive-initializer.d.ts.map +1 -0
  68. package/dist/src/python/components/class-declaration/primitive-initializer.js +67 -0
  69. package/dist/src/python/components/class-declaration/primitive-initializer.js.map +1 -0
  70. package/dist/src/python/components/doc-element/doc-element.d.ts +46 -0
  71. package/dist/src/python/components/doc-element/doc-element.d.ts.map +1 -0
  72. package/dist/src/python/components/doc-element/doc-element.js +59 -0
  73. package/dist/src/python/components/doc-element/doc-element.js.map +1 -0
  74. package/dist/src/python/components/doc-element/index.d.ts +2 -0
  75. package/dist/src/python/components/doc-element/index.d.ts.map +1 -0
  76. package/dist/src/python/components/doc-element/index.js +2 -0
  77. package/dist/src/python/components/doc-element/index.js.map +1 -0
  78. package/dist/src/python/components/enum-declaration/enum-declaration.d.ts +8 -0
  79. package/dist/src/python/components/enum-declaration/enum-declaration.d.ts.map +1 -0
  80. package/dist/src/python/components/enum-declaration/enum-declaration.js +80 -0
  81. package/dist/src/python/components/enum-declaration/enum-declaration.js.map +1 -0
  82. package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts +2 -0
  83. package/dist/src/python/components/enum-declaration/enum-declaration.test.d.ts.map +1 -0
  84. package/dist/src/python/components/enum-declaration/enum-declaration.test.js +344 -0
  85. package/dist/src/python/components/enum-declaration/enum-declaration.test.js.map +1 -0
  86. package/dist/src/python/components/enum-declaration/enum-member.d.ts +9 -0
  87. package/dist/src/python/components/enum-declaration/enum-member.d.ts.map +1 -0
  88. package/dist/src/python/components/enum-declaration/enum-member.js +22 -0
  89. package/dist/src/python/components/enum-declaration/enum-member.js.map +1 -0
  90. package/dist/src/python/components/enum-declaration/index.d.ts +3 -0
  91. package/dist/src/python/components/enum-declaration/index.d.ts.map +1 -0
  92. package/dist/src/python/components/enum-declaration/index.js +3 -0
  93. package/dist/src/python/components/enum-declaration/index.js.map +1 -0
  94. package/dist/src/python/components/function-declaration/function-declaration.d.ts +24 -0
  95. package/dist/src/python/components/function-declaration/function-declaration.d.ts.map +1 -0
  96. package/dist/src/python/components/function-declaration/function-declaration.js +68 -0
  97. package/dist/src/python/components/function-declaration/function-declaration.js.map +1 -0
  98. package/dist/src/python/components/function-declaration/function-declaration.test.d.ts +2 -0
  99. package/dist/src/python/components/function-declaration/function-declaration.test.d.ts.map +1 -0
  100. package/dist/src/python/components/function-declaration/function-declaration.test.js +682 -0
  101. package/dist/src/python/components/function-declaration/function-declaration.test.js.map +1 -0
  102. package/dist/src/python/components/function-declaration/index.d.ts +2 -0
  103. package/dist/src/python/components/function-declaration/index.d.ts.map +1 -0
  104. package/dist/src/python/components/function-declaration/index.js +2 -0
  105. package/dist/src/python/components/function-declaration/index.js.map +1 -0
  106. package/dist/src/python/components/index.d.ts +12 -0
  107. package/dist/src/python/components/index.d.ts.map +1 -0
  108. package/dist/src/python/components/index.js +12 -0
  109. package/dist/src/python/components/index.js.map +1 -0
  110. package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts +25 -0
  111. package/dist/src/python/components/protocol-declaration/callable-parameters.d.ts.map +1 -0
  112. package/dist/src/python/components/protocol-declaration/callable-parameters.js +33 -0
  113. package/dist/src/python/components/protocol-declaration/callable-parameters.js.map +1 -0
  114. package/dist/src/python/components/protocol-declaration/index.d.ts +3 -0
  115. package/dist/src/python/components/protocol-declaration/index.d.ts.map +1 -0
  116. package/dist/src/python/components/protocol-declaration/index.js +3 -0
  117. package/dist/src/python/components/protocol-declaration/index.js.map +1 -0
  118. package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts +8 -0
  119. package/dist/src/python/components/protocol-declaration/protocol-declaration.d.ts.map +1 -0
  120. package/dist/src/python/components/protocol-declaration/protocol-declaration.js +86 -0
  121. package/dist/src/python/components/protocol-declaration/protocol-declaration.js.map +1 -0
  122. package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts +2 -0
  123. package/dist/src/python/components/protocol-declaration/protocol-declaration.test.d.ts.map +1 -0
  124. package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js +117 -0
  125. package/dist/src/python/components/protocol-declaration/protocol-declaration.test.js.map +1 -0
  126. package/dist/src/python/components/record-expression/index.d.ts +2 -0
  127. package/dist/src/python/components/record-expression/index.d.ts.map +1 -0
  128. package/dist/src/python/components/record-expression/index.js +2 -0
  129. package/dist/src/python/components/record-expression/index.js.map +1 -0
  130. package/dist/src/python/components/record-expression/record-expression.d.ts +6 -0
  131. package/dist/src/python/components/record-expression/record-expression.d.ts.map +1 -0
  132. package/dist/src/python/components/record-expression/record-expression.js +13 -0
  133. package/dist/src/python/components/record-expression/record-expression.js.map +1 -0
  134. package/dist/src/python/components/record-expression/record-expression.test.d.ts +2 -0
  135. package/dist/src/python/components/record-expression/record-expression.test.d.ts.map +1 -0
  136. package/dist/src/python/components/record-expression/record-expression.test.js +19 -0
  137. package/dist/src/python/components/record-expression/record-expression.test.js.map +1 -0
  138. package/dist/src/python/components/type-alias-declaration/index.d.ts +2 -0
  139. package/dist/src/python/components/type-alias-declaration/index.d.ts.map +1 -0
  140. package/dist/src/python/components/type-alias-declaration/index.js +2 -0
  141. package/dist/src/python/components/type-alias-declaration/index.js.map +1 -0
  142. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts +16 -0
  143. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.d.ts.map +1 -0
  144. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js +75 -0
  145. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.js.map +1 -0
  146. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts +2 -0
  147. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.d.ts.map +1 -0
  148. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js +140 -0
  149. package/dist/src/python/components/type-alias-declaration/type-alias-declaration.test.js.map +1 -0
  150. package/dist/src/python/components/type-declaration/index.d.ts +2 -0
  151. package/dist/src/python/components/type-declaration/index.d.ts.map +1 -0
  152. package/dist/src/python/components/type-declaration/index.js +2 -0
  153. package/dist/src/python/components/type-declaration/index.js.map +1 -0
  154. package/dist/src/python/components/type-declaration/type-declaration.d.ts +11 -0
  155. package/dist/src/python/components/type-declaration/type-declaration.d.ts.map +1 -0
  156. package/dist/src/python/components/type-declaration/type-declaration.js +31 -0
  157. package/dist/src/python/components/type-declaration/type-declaration.js.map +1 -0
  158. package/dist/src/python/components/type-declaration/type-declaration.test.d.ts +2 -0
  159. package/dist/src/python/components/type-declaration/type-declaration.test.d.ts.map +1 -0
  160. package/dist/src/python/components/type-declaration/type-declaration.test.js +69 -0
  161. package/dist/src/python/components/type-declaration/type-declaration.test.js.map +1 -0
  162. package/dist/src/python/components/type-expression/index.d.ts +2 -0
  163. package/dist/src/python/components/type-expression/index.d.ts.map +1 -0
  164. package/dist/src/python/components/type-expression/index.js +2 -0
  165. package/dist/src/python/components/type-expression/index.js.map +1 -0
  166. package/dist/src/python/components/type-expression/type-expression.d.ts +12 -0
  167. package/dist/src/python/components/type-expression/type-expression.d.ts.map +1 -0
  168. package/dist/src/python/components/type-expression/type-expression.js +348 -0
  169. package/dist/src/python/components/type-expression/type-expression.js.map +1 -0
  170. package/dist/src/python/components/type-expression/type-expression.test.d.ts +2 -0
  171. package/dist/src/python/components/type-expression/type-expression.test.d.ts.map +1 -0
  172. package/dist/src/python/components/type-expression/type-expression.test.js +503 -0
  173. package/dist/src/python/components/type-expression/type-expression.test.js.map +1 -0
  174. package/dist/src/python/index.d.ts +4 -0
  175. package/dist/src/python/index.d.ts.map +1 -0
  176. package/dist/src/python/index.js +4 -0
  177. package/dist/src/python/index.js.map +1 -0
  178. package/dist/src/python/lib.d.ts +68 -0
  179. package/dist/src/python/lib.d.ts.map +1 -0
  180. package/dist/src/python/lib.js +38 -0
  181. package/dist/src/python/lib.js.map +1 -0
  182. package/dist/src/python/test-utils.d.ts +8 -0
  183. package/dist/src/python/test-utils.d.ts.map +1 -0
  184. package/dist/src/python/test-utils.js +25 -0
  185. package/dist/src/python/test-utils.js.map +1 -0
  186. package/dist/src/python/utils/index.d.ts +4 -0
  187. package/dist/src/python/utils/index.d.ts.map +1 -0
  188. package/dist/src/python/utils/index.js +4 -0
  189. package/dist/src/python/utils/index.js.map +1 -0
  190. package/dist/src/python/utils/operation.d.ts +27 -0
  191. package/dist/src/python/utils/operation.d.ts.map +1 -0
  192. package/dist/src/python/utils/operation.js +139 -0
  193. package/dist/src/python/utils/operation.js.map +1 -0
  194. package/dist/src/python/utils/refkey.d.ts +23 -0
  195. package/dist/src/python/utils/refkey.d.ts.map +1 -0
  196. package/dist/src/python/utils/refkey.js +36 -0
  197. package/dist/src/python/utils/refkey.js.map +1 -0
  198. package/dist/src/python/utils/type.d.ts +19 -0
  199. package/dist/src/python/utils/type.d.ts.map +1 -0
  200. package/dist/src/python/utils/type.js +24 -0
  201. package/dist/src/python/utils/type.js.map +1 -0
  202. package/package.json +12 -5
  203. package/package.json.bak +14 -6
  204. package/src/python/builtins.ts +43 -0
  205. package/src/python/components/array-expression/array-expression.test.tsx +14 -0
  206. package/src/python/components/array-expression/array-expression.tsx +11 -0
  207. package/src/python/components/array-expression/index.ts +1 -0
  208. package/src/python/components/atom/atom.test.tsx +244 -0
  209. package/src/python/components/atom/atom.tsx +95 -0
  210. package/src/python/components/atom/index.ts +1 -0
  211. package/src/python/components/class-declaration/class-bases.tsx +92 -0
  212. package/src/python/components/class-declaration/class-body.tsx +56 -0
  213. package/src/python/components/class-declaration/class-declaration.test.tsx +1414 -0
  214. package/src/python/components/class-declaration/class-declaration.tsx +116 -0
  215. package/src/python/components/class-declaration/class-member.test.tsx +194 -0
  216. package/src/python/components/class-declaration/class-member.tsx +67 -0
  217. package/src/python/components/class-declaration/class-method.test.tsx +250 -0
  218. package/src/python/components/class-declaration/class-method.tsx +97 -0
  219. package/src/python/components/class-declaration/index.ts +6 -0
  220. package/src/python/components/class-declaration/primitive-initializer.tsx +62 -0
  221. package/src/python/components/doc-element/doc-element.tsx +83 -0
  222. package/src/python/components/doc-element/index.ts +1 -0
  223. package/src/python/components/enum-declaration/enum-declaration.test.tsx +319 -0
  224. package/src/python/components/enum-declaration/enum-declaration.tsx +77 -0
  225. package/src/python/components/enum-declaration/enum-member.tsx +21 -0
  226. package/src/python/components/enum-declaration/index.ts +2 -0
  227. package/src/python/components/function-declaration/function-declaration.test.tsx +582 -0
  228. package/src/python/components/function-declaration/function-declaration.tsx +90 -0
  229. package/src/python/components/function-declaration/index.ts +1 -0
  230. package/src/python/components/index.ts +11 -0
  231. package/src/python/components/protocol-declaration/callable-parameters.tsx +44 -0
  232. package/src/python/components/protocol-declaration/index.ts +2 -0
  233. package/src/python/components/protocol-declaration/protocol-declaration.test.tsx +106 -0
  234. package/src/python/components/protocol-declaration/protocol-declaration.tsx +73 -0
  235. package/src/python/components/record-expression/index.ts +1 -0
  236. package/src/python/components/record-expression/record-expression.test.tsx +14 -0
  237. package/src/python/components/record-expression/record-expression.tsx +13 -0
  238. package/src/python/components/type-alias-declaration/index.ts +1 -0
  239. package/src/python/components/type-alias-declaration/type-alias-declaration.test.tsx +117 -0
  240. package/src/python/components/type-alias-declaration/type-alias-declaration.tsx +67 -0
  241. package/src/python/components/type-declaration/index.ts +1 -0
  242. package/src/python/components/type-declaration/type-declaration.test.tsx +58 -0
  243. package/src/python/components/type-declaration/type-declaration.tsx +26 -0
  244. package/src/python/components/type-expression/index.ts +1 -0
  245. package/src/python/components/type-expression/type-expression.test.tsx +463 -0
  246. package/src/python/components/type-expression/type-expression.tsx +333 -0
  247. package/src/python/index.ts +3 -0
  248. package/src/python/lib.ts +40 -0
  249. package/src/python/test-utils.tsx +31 -0
  250. package/src/python/utils/index.ts +3 -0
  251. package/src/python/utils/operation.ts +161 -0
  252. package/src/python/utils/refkey.ts +36 -0
  253. package/src/python/utils/type.ts +31 -0
@@ -0,0 +1,2 @@
1
+ export * from "./function-declaration.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/function-declaration/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./function-declaration.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../../src/python/components/function-declaration/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,2BAA2B","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ export * from "./array-expression/index.js";
2
+ export * from "./atom/index.js";
3
+ export * from "./class-declaration/index.js";
4
+ export * from "./doc-element/index.js";
5
+ export * from "./enum-declaration/index.js";
6
+ export * from "./function-declaration/index.js";
7
+ export * from "./protocol-declaration/index.js";
8
+ export * from "./record-expression/index.js";
9
+ export * from "./type-alias-declaration/index.js";
10
+ export * from "./type-declaration/index.js";
11
+ export * from "./type-expression/index.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/python/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from "./array-expression/index.js";
2
+ export * from "./atom/index.js";
3
+ export * from "./class-declaration/index.js";
4
+ export * from "./doc-element/index.js";
5
+ export * from "./enum-declaration/index.js";
6
+ export * from "./function-declaration/index.js";
7
+ export * from "./protocol-declaration/index.js";
8
+ export * from "./record-expression/index.js";
9
+ export * from "./type-alias-declaration/index.js";
10
+ export * from "./type-declaration/index.js";
11
+ export * from "./type-expression/index.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../src/python/components/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,6BAA6B;AAC3C,cAAc,iBAAiB;AAC/B,cAAc,8BAA8B;AAC5C,cAAc,wBAAwB;AACtC,cAAc,6BAA6B;AAC3C,cAAc,iCAAiC;AAC/C,cAAc,iCAAiC;AAC/C,cAAc,8BAA8B;AAC5C,cAAc,mCAAmC;AACjD,cAAc,6BAA6B;AAC3C,cAAc,4BAA4B","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ import * as py from "@alloy-js/python";
2
+ import type { Operation } from "@typespec/compiler";
3
+ export interface CallableParametersProps {
4
+ /**
5
+ * The operation to extract parameters from.
6
+ */
7
+ type: Operation;
8
+ }
9
+ /**
10
+ * Builds parameter descriptors for a callable (method/function) from an Operation's parameters.
11
+ *
12
+ * Iterates over the operation's parameters model and creates ParameterDescriptor objects
13
+ * with name, type expression, and default value (handles both explicit defaults and
14
+ * optional parameters without defaults which get `= None`).
15
+ *
16
+ * @returns Array of ParameterDescriptor objects for use with py.MethodDeclaration or similar.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * const params = CallableParameters({ type: operation });
21
+ * <py.MethodDeclaration name="foo" parameters={params} />
22
+ * ```
23
+ */
24
+ export declare function CallableParameters(props: CallableParametersProps): py.ParameterDescriptor[];
25
+ //# sourceMappingURL=callable-parameters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callable-parameters.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/protocol-declaration/callable-parameters.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,IAAI,EAAE,SAAS,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAe3F"}
@@ -0,0 +1,33 @@
1
+ import { refkey } from "@alloy-js/core";
2
+ import { useTsp } from "../../../core/context/tsp-context.js";
3
+ import { buildParameterDescriptor } from "../../utils/operation.js";
4
+ /**
5
+ * Builds parameter descriptors for a callable (method/function) from an Operation's parameters.
6
+ *
7
+ * Iterates over the operation's parameters model and creates ParameterDescriptor objects
8
+ * with name, type expression, and default value (handles both explicit defaults and
9
+ * optional parameters without defaults which get `= None`).
10
+ *
11
+ * @returns Array of ParameterDescriptor objects for use with py.MethodDeclaration or similar.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * const params = CallableParameters({ type: operation });
16
+ * <py.MethodDeclaration name="foo" parameters={params} />
17
+ * ```
18
+ */
19
+ export function CallableParameters(props) {
20
+ const {
21
+ $
22
+ } = useTsp();
23
+ const paramsModel = props.type.parameters;
24
+ if (!paramsModel) {
25
+ return [];
26
+ }
27
+ const parameters = [];
28
+ for (const prop of $.model.getProperties(paramsModel).values()) {
29
+ parameters.push(buildParameterDescriptor(prop, refkey()));
30
+ }
31
+ return parameters;
32
+ }
33
+ //# sourceMappingURL=callable-parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["refkey","useTsp","buildParameterDescriptor","CallableParameters","props","$","paramsModel","type","parameters","prop","model","getProperties","values","push"],"sources":["../../../../../src/python/components/protocol-declaration/callable-parameters.tsx"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,QAAQ,gBAAgB;AAGvC,SAASC,MAAM,QAAQ,sCAAsC;AAC7D,SAASC,wBAAwB,QAAQ,0BAA0B;AASnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,KAA8B,EAA4B;EAC3F,MAAM;IAAEC;EAAE,CAAC,GAAGJ,MAAM,CAAC,CAAC;EACtB,MAAMK,WAAW,GAAGF,KAAK,CAACG,IAAI,CAACC,UAAU;EAEzC,IAAI,CAACF,WAAW,EAAE;IAChB,OAAO,EAAE;EACX;EAEA,MAAME,UAAoC,GAAG,EAAE;EAE/C,KAAK,MAAMC,IAAI,IAAIJ,CAAC,CAACK,KAAK,CAACC,aAAa,CAACL,WAAW,CAAC,CAACM,MAAM,CAAC,CAAC,EAAE;IAC9DJ,UAAU,CAACK,IAAI,CAACX,wBAAwB,CAACO,IAAI,EAAET,MAAM,CAAC,CAAC,CAAC,CAAC;EAC3D;EAEA,OAAOQ,UAAU;AACnB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export * from "./callable-parameters.js";
2
+ export * from "./protocol-declaration.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/protocol-declaration/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./callable-parameters.js";
2
+ export * from "./protocol-declaration.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../../src/python/components/protocol-declaration/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,0BAA0B;AACxC,cAAc,2BAA2B","ignoreList":[]}
@@ -0,0 +1,8 @@
1
+ import * as py from "@alloy-js/python";
2
+ import type { Interface, Operation } from "@typespec/compiler";
3
+ export interface ProtocolDeclarationProps extends Omit<py.ClassDeclarationProps, "name"> {
4
+ type: Interface | Operation;
5
+ name?: string;
6
+ }
7
+ export declare function ProtocolDeclaration(props: ProtocolDeclarationProps): import("@alloy-js/core").Children;
8
+ //# sourceMappingURL=protocol-declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-declaration.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/protocol-declaration/protocol-declaration.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAQ,MAAM,oBAAoB,CAAC;AAGrE,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CAAC,EAAE,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACtF,IAAI,EAAE,SAAS,GAAG,SAAS,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qCAyDlE"}
@@ -0,0 +1,86 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { useTsp } from "#core/context/tsp-context.js";
3
+ import { typingModule } from "#python/builtins.js";
4
+ import { TypeExpression } from "#python/components/type-expression/type-expression.js";
5
+ import { reportPythonDiagnostic } from "#python/lib.js";
6
+ import { declarationRefkeys } from "#python/utils/refkey.js";
7
+ import { mapJoin } from "@alloy-js/core";
8
+ import * as py from "@alloy-js/python";
9
+ import { CallableParameters } from "./callable-parameters.js";
10
+ export function ProtocolDeclaration(props) {
11
+ const {
12
+ $
13
+ } = useTsp();
14
+ const refkeys = declarationRefkeys(props.refkey, props.type);
15
+ const protocolBase = typingModule["."]["Protocol"];
16
+ const namePolicy = py.usePythonNamePolicy();
17
+ const originalName = props.name ?? props.type?.name ?? "";
18
+ const name = namePolicy.getName(originalName, "class");
19
+
20
+ // Interfaces will be converted to Protocols with method stubs for operations
21
+ if (props.type?.kind === "Interface") {
22
+ const iface = props.type;
23
+ const operations = iface.operations ?? new Map();
24
+ const methods = mapJoin(() => Array.from(operations.values()), op => {
25
+ const methodName = namePolicy.getName(op.name, "function");
26
+ const prm = CallableParameters({
27
+ type: op
28
+ }); // self injected by MethodDeclaration
29
+ const ret = op?.returnType ? _$createComponent(TypeExpression, {
30
+ get type() {
31
+ return op.returnType;
32
+ }
33
+ }) : undefined;
34
+ return _$createComponent(py.MethodDeclaration, {
35
+ name: methodName,
36
+ parameters: prm,
37
+ returnType: ret,
38
+ children: "..."
39
+ });
40
+ });
41
+ return _$createComponent(py.ClassDeclaration, {
42
+ name: name,
43
+ bases: [protocolBase],
44
+ refkey: refkeys,
45
+ get doc() {
46
+ return props.doc;
47
+ },
48
+ children: methods
49
+ });
50
+ }
51
+ if (props.type?.kind !== "Operation") {
52
+ reportPythonDiagnostic($.program, {
53
+ code: "python-unsupported-type",
54
+ target: props.type
55
+ });
56
+ return [];
57
+ }
58
+
59
+ // Operations will be converted to Callback protocol using a dunder __call__ method
60
+ const op = props.type;
61
+ const cbParams = CallableParameters({
62
+ type: op
63
+ });
64
+ const cbReturn = op?.returnType ? _$createComponent(TypeExpression, {
65
+ get type() {
66
+ return op.returnType;
67
+ }
68
+ }) : undefined;
69
+ return _$createComponent(py.ClassDeclaration, {
70
+ name: name,
71
+ bases: [protocolBase],
72
+ refkey: refkeys,
73
+ get doc() {
74
+ return props.doc;
75
+ },
76
+ get children() {
77
+ return _$createComponent(py.DunderMethodDeclaration, {
78
+ name: "__call__",
79
+ returnType: cbReturn,
80
+ parameters: cbParams,
81
+ children: "..."
82
+ });
83
+ }
84
+ });
85
+ }
86
+ //# sourceMappingURL=protocol-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useTsp","typingModule","TypeExpression","reportPythonDiagnostic","declarationRefkeys","mapJoin","py","CallableParameters","ProtocolDeclaration","props","$","refkeys","refkey","type","protocolBase","namePolicy","usePythonNamePolicy","originalName","name","getName","kind","iface","operations","Map","methods","Array","from","values","op","methodName","prm","ret","returnType","_$createComponent","undefined","MethodDeclaration","parameters","children","ClassDeclaration","bases","doc","program","code","target","cbParams","cbReturn","DunderMethodDeclaration"],"sources":["../../../../../src/python/components/protocol-declaration/protocol-declaration.tsx"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=protocol-declaration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol-declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/protocol-declaration/protocol-declaration.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,117 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { TypeExpression } from "#python/components/type-expression/type-expression.js";
3
+ import { Tester } from "#test/test-host.js";
4
+ import { t } from "@typespec/compiler/testing";
5
+ import { describe, expect, it } from "vitest";
6
+ import { getOutput } from "../../test-utils.js";
7
+ import { ProtocolDeclaration } from "./protocol-declaration.js";
8
+ describe("Python ProtocolDeclaration", () => {
9
+ it("emits a callback Protocol for an operation", async () => {
10
+ const {
11
+ program,
12
+ getName,
13
+ getOtherName
14
+ } = await Tester.compile(t.code`
15
+ op ${t.op("getName")}(id: string): string;
16
+ op ${t.op("getOtherName")}(id: string): string;
17
+ `);
18
+ expect(getOutput(program, [_$createComponent(ProtocolDeclaration, {
19
+ type: getName
20
+ }), _$createComponent(ProtocolDeclaration, {
21
+ type: getOtherName
22
+ })])).toRenderTo(`
23
+ from typing import Protocol
24
+
25
+
26
+ class GetName(Protocol):
27
+ def __call__(self, id: str) -> str:
28
+ ...
29
+
30
+
31
+
32
+ class GetOtherName(Protocol):
33
+ def __call__(self, id: str) -> str:
34
+ ...
35
+
36
+
37
+ `);
38
+ });
39
+ it("emits no return annotation when return type omitted", async () => {
40
+ const {
41
+ program,
42
+ getName
43
+ } = await Tester.compile(t.code`
44
+ op ${t.op("getName")}(id: string): string;
45
+ `);
46
+
47
+ // Create a shallow clone without returnType to simulate missing return info
48
+ const getNameNoReturn = {
49
+ ...getName
50
+ };
51
+ delete getNameNoReturn.returnType;
52
+ expect(getOutput(program, [_$createComponent(ProtocolDeclaration, {
53
+ type: getNameNoReturn
54
+ })])).toRenderTo(`
55
+ from typing import Protocol
56
+
57
+
58
+ class GetName(Protocol):
59
+ def __call__(self, id: str):
60
+ ...
61
+
62
+
63
+ `);
64
+ });
65
+ it("emits a Protocol for a TypeSpec interface (methods only)", async () => {
66
+ const {
67
+ program,
68
+ Greeter
69
+ } = await Tester.compile(t.code`
70
+ interface ${t.interface("Greeter")} {
71
+ op getName(id: string): string;
72
+ op getOtherName(id: string): string;
73
+ }
74
+ `);
75
+ expect(getOutput(program, [_$createComponent(ProtocolDeclaration, {
76
+ type: Greeter
77
+ })])).toRenderTo(`
78
+ from typing import Protocol
79
+
80
+
81
+ class Greeter(Protocol):
82
+ def get_name(self, id: str) -> str:
83
+ ...
84
+
85
+ def get_other_name(self, id: str) -> str:
86
+ ...
87
+
88
+
89
+ `);
90
+ });
91
+ it("emits both a Protocol and a Callable for the same operation", async () => {
92
+ const {
93
+ program,
94
+ getName
95
+ } = await Tester.compile(t.code`
96
+ op ${t.op("getName")}(id: string): string;
97
+ `);
98
+ expect(getOutput(program, [_$createComponent(ProtocolDeclaration, {
99
+ type: getName
100
+ }), _$createComponent(TypeExpression, {
101
+ type: getName
102
+ })])).toRenderTo(`
103
+ from typing import Callable
104
+ from typing import Protocol
105
+
106
+
107
+ class GetName(Protocol):
108
+ def __call__(self, id: str) -> str:
109
+ ...
110
+
111
+
112
+
113
+ Callable[[str], str]
114
+ `);
115
+ });
116
+ });
117
+ //# sourceMappingURL=protocol-declaration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TypeExpression","Tester","t","describe","expect","it","getOutput","ProtocolDeclaration","program","getName","getOtherName","compile","code","op","_$createComponent","type","toRenderTo","getNameNoReturn","returnType","Greeter","interface"],"sources":["../../../../../src/python/components/protocol-declaration/protocol-declaration.test.tsx"],"sourcesContent":[null],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./record-expression.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/record-expression/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./record-expression.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../../src/python/components/record-expression/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,wBAAwB","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import type { Type } from "@typespec/compiler";
2
+ export interface RecordExpressionProps {
3
+ elementType: Type;
4
+ }
5
+ export declare function RecordExpression({ elementType }: RecordExpressionProps): import("@alloy-js/core").Children;
6
+ //# sourceMappingURL=record-expression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-expression.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/record-expression/record-expression.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAG/C,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,IAAI,CAAC;CACnB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,WAAW,EAAE,EAAE,qBAAqB,qCAItE"}
@@ -0,0 +1,13 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { code } from "@alloy-js/core";
3
+ import { TypeExpression } from "../type-expression/type-expression.js";
4
+ export function RecordExpression({
5
+ elementType
6
+ }) {
7
+ return code`
8
+ dict[str, ${_$createComponent(TypeExpression, {
9
+ type: elementType
10
+ })}]
11
+ `;
12
+ }
13
+ //# sourceMappingURL=record-expression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["code","TypeExpression","RecordExpression","elementType","_$createComponent","type"],"sources":["../../../../../src/python/components/record-expression/record-expression.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,IAAI,QAAQ,gBAAgB;AAErC,SAASC,cAAc,QAAQ,uCAAuC;AAMtE,OAAO,SAASC,gBAAgBA,CAAC;EAAEC;AAAmC,CAAC,EAAE;EACvE,OAAOH,IAAI;AACb,cADaI,iBAAA,CACGH,cAAc;IAACI,IAAI,EAAEF;EAAW;AAChD,GAAG;AACH","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=record-expression.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-expression.test.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/record-expression/record-expression.test.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { Tester } from "#test/test-host.js";
3
+ import { d } from "@alloy-js/core/testing";
4
+ import { t } from "@typespec/compiler/testing";
5
+ import { expect, it } from "vitest";
6
+ import { getOutput } from "../../test-utils.js";
7
+ import { TypeExpression } from "../type-expression/type-expression.js";
8
+ it("maps Record to Python dict", async () => {
9
+ const {
10
+ program,
11
+ TestRecord
12
+ } = await Tester.compile(t.code`
13
+ alias ${t.type("TestRecord")} = Record<boolean>;
14
+ `);
15
+ expect(getOutput(program, [_$createComponent(TypeExpression, {
16
+ type: TestRecord
17
+ })])).toRenderTo(d`dict[str, bool]`);
18
+ });
19
+ //# sourceMappingURL=record-expression.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Tester","d","t","expect","it","getOutput","TypeExpression","program","TestRecord","compile","code","type","_$createComponent","toRenderTo"],"sources":["../../../../../src/python/components/record-expression/record-expression.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C,SAASC,CAAC,QAAQ,wBAAwB;AAC1C,SAASC,CAAC,QAAQ,4BAA4B;AAC9C,SAASC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AACnC,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,cAAc,QAAQ,uCAAuC;AAEtEF,EAAE,CAAC,4BAA4B,EAAE,YAAY;EAC3C,MAAM;IAAEG,OAAO;IAAEC;EAAW,CAAC,GAAG,MAAMR,MAAM,CAACS,OAAO,CAACP,CAAC,CAACQ,IAAI;AAC7D,YAAYR,CAAC,CAACS,IAAI,CAAC,YAAY,CAAC;AAChC,GAAG,CAAC;EAEFR,MAAM,CAACE,SAAS,CAACE,OAAO,EAAE,CAAAK,iBAAA,CAAEN,cAAc;IAACK,IAAI,EAAEH;EAAU,GAAK,CAAC,CAAC,CAACK,UAAU,CAACZ,CAAC,iBAAiB,CAAC;AACnG,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export * from "./type-alias-declaration.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/type-alias-declaration/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./type-alias-declaration.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../../src/python/components/type-alias-declaration/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,6BAA6B","ignoreList":[]}
@@ -0,0 +1,16 @@
1
+ import * as py from "@alloy-js/python";
2
+ import { type Type } from "@typespec/compiler";
3
+ export interface TypedAliasDeclarationProps extends Omit<py.BaseDeclarationProps, "name"> {
4
+ type: Type;
5
+ name?: string;
6
+ }
7
+ /**
8
+ * Create a Python type alias declaration. Pass the `type` prop to emit the
9
+ * type alias as the provided TypeSpec type.
10
+ *
11
+ * For template instances (e.g., `alias StringResponse = Response<string>`),
12
+ * this emits a dataclass instead of a type alias, since Python doesn't support
13
+ * parameterized type aliases the way TypeScript does.
14
+ */
15
+ export declare function TypeAliasDeclaration(props: TypedAliasDeclarationProps): import("@alloy-js/core").Children;
16
+ //# sourceMappingURL=type-alias-declaration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-alias-declaration.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/type-alias-declaration/type-alias-declaration.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAkC,KAAK,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAO/E,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CAAC,EAAE,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACvF,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,0BAA0B,qCA4CrE"}
@@ -0,0 +1,75 @@
1
+ import { memo as _$memo, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { useTsp } from "#core/context/index.js";
3
+ import * as py from "@alloy-js/python";
4
+ import { isTemplateInstance } from "@typespec/compiler";
5
+ import { reportDiagnostic } from "../../../lib.js";
6
+ import { typingModule } from "../../builtins.js";
7
+ import { declarationRefkeys } from "../../utils/refkey.js";
8
+ import { ClassDeclaration } from "../class-declaration/class-declaration.js";
9
+ import { TypeExpression } from "../type-expression/type-expression.js";
10
+ /**
11
+ * Create a Python type alias declaration. Pass the `type` prop to emit the
12
+ * type alias as the provided TypeSpec type.
13
+ *
14
+ * For template instances (e.g., `alias StringResponse = Response<string>`),
15
+ * this emits a dataclass instead of a type alias, since Python doesn't support
16
+ * parameterized type aliases the way TypeScript does.
17
+ */
18
+ export function TypeAliasDeclaration(props) {
19
+ const {
20
+ $
21
+ } = useTsp();
22
+ const originalName = props.name ?? ("name" in props.type && typeof props.type.name === "string" ? props.type.name : "");
23
+ if (!originalName || originalName === "") {
24
+ reportDiagnostic($.program, {
25
+ code: "type-declaration-missing-name",
26
+ target: props.type
27
+ });
28
+ }
29
+ const doc = props.doc ?? $.type.getDoc(props.type);
30
+ const refkeys = declarationRefkeys(props.refkey, props.type);
31
+
32
+ // For Model template instances (e.g., alias StringResponse = Response<string>),
33
+ // emit as a dataclass since Python doesn't support parameterized type aliases.
34
+ // TypeSpec templates are macros that expand to concrete types.
35
+ if ($.model.is(props.type) && isTemplateInstance(props.type)) {
36
+ const namePolicy = py.usePythonNamePolicy();
37
+ const plausibleName = $.type.getPlausibleName(props.type);
38
+ const name = props.name ?? namePolicy.getName(plausibleName, "class");
39
+ return _$createComponent(ClassDeclaration, {
40
+ doc: doc,
41
+ get type() {
42
+ return props.type;
43
+ },
44
+ name: name,
45
+ refkey: refkeys,
46
+ get children() {
47
+ return props.children;
48
+ }
49
+ });
50
+ }
51
+
52
+ // For other types (scalars, unions, operations), emit as a type alias
53
+ const name = py.usePythonNamePolicy().getName(originalName, "variable");
54
+ return _$createComponent(py.VariableDeclaration, {
55
+ doc: doc,
56
+ name: name,
57
+ refkey: refkeys,
58
+ omitNone: true,
59
+ get type() {
60
+ return typingModule["."]["TypeAlias"];
61
+ },
62
+ get initializer() {
63
+ return _$createComponent(TypeExpression, {
64
+ get type() {
65
+ return props.type;
66
+ },
67
+ noReference: true
68
+ });
69
+ },
70
+ get children() {
71
+ return props.children;
72
+ }
73
+ });
74
+ }
75
+ //# sourceMappingURL=type-alias-declaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useTsp","py","isTemplateInstance","reportDiagnostic","typingModule","declarationRefkeys","ClassDeclaration","TypeExpression","TypeAliasDeclaration","props","$","originalName","name","type","program","code","target","doc","getDoc","refkeys","refkey","model","is","namePolicy","usePythonNamePolicy","plausibleName","getPlausibleName","getName","_$createComponent","children","VariableDeclaration","omitNone","initializer","noReference"],"sources":["../../../../../src/python/components/type-alias-declaration/type-alias-declaration.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,wBAAwB;AAC/C,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,SAASC,kBAAkB,QAA+B,oBAAoB;AAC9E,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,kBAAkB,QAAQ,uBAAuB;AAC1D,SAASC,gBAAgB,QAAQ,2CAA2C;AAC5E,SAASC,cAAc,QAAQ,uCAAuC;AAOtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,oBAAoBA,CAACC,KAAiC,EAAE;EACtE,MAAM;IAAEC;EAAE,CAAC,GAAGV,MAAM,CAAC,CAAC;EAEtB,MAAMW,YAAY,GAChBF,KAAK,CAACG,IAAI,KACT,MAAM,IAAIH,KAAK,CAACI,IAAI,IAAI,OAAOJ,KAAK,CAACI,IAAI,CAACD,IAAI,KAAK,QAAQ,GAAGH,KAAK,CAACI,IAAI,CAACD,IAAI,GAAG,EAAE,CAAC;EAEtF,IAAI,CAACD,YAAY,IAAIA,YAAY,KAAK,EAAE,EAAE;IACxCR,gBAAgB,CAACO,CAAC,CAACI,OAAO,EAAE;MAAEC,IAAI,EAAE,+BAA+B;MAAEC,MAAM,EAAEP,KAAK,CAACI;IAAK,CAAC,CAAC;EAC5F;EAEA,MAAMI,GAAG,GAAGR,KAAK,CAACQ,GAAG,IAAIP,CAAC,CAACG,IAAI,CAACK,MAAM,CAACT,KAAK,CAACI,IAAI,CAAC;EAClD,MAAMM,OAAO,GAAGd,kBAAkB,CAACI,KAAK,CAACW,MAAM,EAAEX,KAAK,CAACI,IAAI,CAAC;;EAE5D;EACA;EACA;EACA,IAAIH,CAAC,CAACW,KAAK,CAACC,EAAE,CAACb,KAAK,CAACI,IAAI,CAAC,IAAIX,kBAAkB,CAACO,KAAK,CAACI,IAAI,CAAC,EAAE;IAC5D,MAAMU,UAAU,GAAGtB,EAAE,CAACuB,mBAAmB,CAAC,CAAC;IAC3C,MAAMC,aAAa,GAAGf,CAAC,CAACG,IAAI,CAACa,gBAAgB,CAACjB,KAAK,CAACI,IAAa,CAAC;IAClE,MAAMD,IAAI,GAAGH,KAAK,CAACG,IAAI,IAAIW,UAAU,CAACI,OAAO,CAACF,aAAa,EAAE,OAAO,CAAC;IAErE,OAAAG,iBAAA,CACGtB,gBAAgB;MAACW,GAAG,EAAEA,GAAG;MAAA,IAAEJ,IAAIA,CAAA;QAAA,OAAEJ,KAAK,CAACI,IAAI;MAAA;MAAED,IAAI,EAAEA,IAAI;MAAEQ,MAAM,EAAED,OAAO;MAAA,IAAAU,SAAA;QAAA,OACtEpB,KAAK,CAACoB,QAAQ;MAAA;IAAA;EAGrB;;EAEA;EACA,MAAMjB,IAAI,GAAGX,EAAE,CAACuB,mBAAmB,CAAC,CAAC,CAACG,OAAO,CAAChB,YAAY,EAAE,UAAU,CAAC;EAEvE,OAAAiB,iBAAA,CACG3B,EAAE,CAAC6B,mBAAmB;IACrBb,GAAG,EAAEA,GAAG;IACRL,IAAI,EAAEA,IAAI;IACVQ,MAAM,EAAED,OAAO;IACfY,QAAQ,EAAE,IAAI;IAAA,IACdlB,IAAIA,CAAA;MAAA,OAAET,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC;IAAA;IAAA,IACpC4B,WAAWA,CAAA;MAAA,OAAAJ,iBAAA,CAAGrB,cAAc;QAAA,IAACM,IAAIA,CAAA;UAAA,OAAEJ,KAAK,CAACI,IAAI;QAAA;QAAEoB,WAAW;MAAA;IAAA;IAAA,IAAAJ,SAAA;MAAA,OAEzDpB,KAAK,CAACoB,QAAQ;IAAA;EAAA;AAGrB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type-alias-declaration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-alias-declaration.test.d.ts","sourceRoot":"","sources":["../../../../../src/python/components/type-alias-declaration/type-alias-declaration.test.tsx"],"names":[],"mappings":""}