@typespec/emitter-framework 0.15.0-dev.3 → 0.15.0-dev.4

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 +1 -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 +9 -1
  203. package/package.json.bak +10 -1
  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,25 @@
1
+ import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
2
+ import { Output } from "#core/components/index.js";
3
+ import * as py from "@alloy-js/python";
4
+ import { abcModule, datetimeModule, decimalModule, typingModule } from "./builtins.js";
5
+ export const renderOptions = {
6
+ printWidth: 80,
7
+ tabWidth: 4
8
+ };
9
+ export function getOutput(program, children) {
10
+ const policy = py.createPythonNamePolicy();
11
+ return _$createComponent(Output, {
12
+ program: program,
13
+ get externals() {
14
+ return [abcModule, datetimeModule, decimalModule, typingModule, py.abcModule, py.dataclassesModule, py.enumModule];
15
+ },
16
+ namePolicy: policy,
17
+ get children() {
18
+ return _$createComponent(py.SourceFile, {
19
+ path: "test.py",
20
+ children: children
21
+ });
22
+ }
23
+ });
24
+ }
25
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Output","py","abcModule","datetimeModule","decimalModule","typingModule","renderOptions","printWidth","tabWidth","getOutput","program","children","policy","createPythonNamePolicy","_$createComponent","externals","dataclassesModule","enumModule","namePolicy","SourceFile","path"],"sources":["../../../src/python/test-utils.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,QAAQ,2BAA2B;AAElD,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AAEtC,SAASC,SAAS,EAAEC,cAAc,EAAEC,aAAa,EAAEC,YAAY,QAAQ,eAAe;AAEtF,OAAO,MAAMC,aAAa,GAAG;EAC3BC,UAAU,EAAE,EAAE;EACdC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,SAASC,SAASA,CAACC,OAAgB,EAAEC,QAAoB,EAAY;EAC1E,MAAMC,MAAM,GAAGX,EAAE,CAACY,sBAAsB,CAAC,CAAC;EAC1C,OAAAC,iBAAA,CACGd,MAAM;IACLU,OAAO,EAAEA,OAAO;IAAA,IAChBK,SAASA,CAAA;MAAA,OAAE,CACTb,SAAS,EACTC,cAAc,EACdC,aAAa,EACbC,YAAY,EACZJ,EAAE,CAACC,SAAS,EACZD,EAAE,CAACe,iBAAiB,EACpBf,EAAE,CAACgB,UAAU,CACd;IAAA;IACDC,UAAU,EAAEN,MAAM;IAAA,IAAAD,SAAA;MAAA,OAAAG,iBAAA,CAEjBb,EAAE,CAACkB,UAAU;QAACC,IAAI;QAAAT,QAAA,EAAYA;MAAQ;IAAA;EAAA;AAG7C","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export * from "./operation.js";
2
+ export * from "./refkey.js";
3
+ export * from "./type.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./operation.js";
2
+ export * from "./refkey.js";
3
+ export * from "./type.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["../../../../src/python/utils/index.ts"],"sourcesContent":[null],"mappings":"AAAA,cAAc,gBAAgB;AAC9B,cAAc,aAAa;AAC3B,cAAc,WAAW","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ import { type Refkey } from "@alloy-js/core";
2
+ import * as py from "@alloy-js/python";
3
+ import type { Model, ModelProperty, Operation, Type } from "@typespec/compiler";
4
+ export declare function getReturnType(type: Operation, options?: {
5
+ skipErrorFiltering: boolean;
6
+ }): Type;
7
+ export interface BuildParameterDescriptorsOptions {
8
+ params?: (py.ParameterDescriptor | string)[];
9
+ suffixRefkey?: Refkey;
10
+ /** If true, params replaces operation parameters instead of adding to them */
11
+ replaceParameters?: boolean;
12
+ }
13
+ /**
14
+ * Build a parameter descriptor array from a TypeSpec Model.
15
+ *
16
+ * Parameter ordering (unless replaceParameters is true):
17
+ * - Operation params without defaults: positional (e.g., URL path params)
18
+ * - "*" marker (if any keyword-only params exist)
19
+ * - Operation params with defaults: keyword-only (e.g., query params)
20
+ * - Additional params: keyword-only
21
+ */
22
+ export declare function buildParameterDescriptors(type: Model, options?: BuildParameterDescriptorsOptions): (py.ParameterDescriptor | string)[] | undefined;
23
+ /**
24
+ * Convert a TypeSpec ModelProperty into a Python ParameterDescriptor.
25
+ */
26
+ export declare function buildParameterDescriptor(modelProperty: ModelProperty, suffixRefkey: Refkey): py.ParameterDescriptor;
27
+ //# sourceMappingURL=operation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/operation.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAMhF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,EACf,OAAO,GAAE;IAAE,kBAAkB,EAAE,OAAO,CAAA;CAAkC,GACvE,IAAI,CASN;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,KAAK,EACX,OAAO,GAAE,gCAAqC,GAC7C,CAAC,EAAE,CAAC,mBAAmB,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAwDjD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,GACnB,EAAE,CAAC,mBAAmB,CAsBxB"}
@@ -0,0 +1,139 @@
1
+ import { typingModule } from "#python/builtins.js";
2
+ import { refkey } from "@alloy-js/core";
3
+ import * as py from "@alloy-js/python";
4
+ import { useTsp } from "../../core/index.js";
5
+ import { Atom } from "../components/atom/atom.js";
6
+ import { TypeExpression } from "../components/type-expression/type-expression.js";
7
+ import { efRefkey } from "./refkey.js";
8
+ export function getReturnType(type, options = {
9
+ skipErrorFiltering: false
10
+ }) {
11
+ const {
12
+ $
13
+ } = useTsp();
14
+ let returnType = type.returnType;
15
+ if (!options.skipErrorFiltering && type.returnType.kind === "Union") {
16
+ returnType = $.union.filter(type.returnType, variant => !$.type.isError(variant.type));
17
+ }
18
+ return returnType;
19
+ }
20
+ /**
21
+ * Build a parameter descriptor array from a TypeSpec Model.
22
+ *
23
+ * Parameter ordering (unless replaceParameters is true):
24
+ * - Operation params without defaults: positional (e.g., URL path params)
25
+ * - "*" marker (if any keyword-only params exist)
26
+ * - Operation params with defaults: keyword-only (e.g., query params)
27
+ * - Additional params: keyword-only
28
+ */
29
+ export function buildParameterDescriptors(type, options = {}) {
30
+ const {
31
+ $
32
+ } = useTsp();
33
+ const suffixRefkey = options.suffixRefkey ?? refkey();
34
+ const optionsParams = normalizeParameters(options.params ?? []);
35
+
36
+ // If replaceParameters is true, ignore operation params and just return options params
37
+ // All replacement parameters are keyword-only (following "additional parameters are keyword-only" principle)
38
+ if (options.replaceParameters) {
39
+ const withoutDefaults = optionsParams.filter(p => p.default === undefined);
40
+ const withDefaults = optionsParams.filter(p => p.default !== undefined);
41
+
42
+ // Always add "*" marker since all replacement params should be keyword-only
43
+ const allParams = optionsParams.length > 0 ? ["*", ...withoutDefaults, ...withDefaults] : [];
44
+ return allParams;
45
+ }
46
+ const modelProperties = $.model.getProperties(type);
47
+ const operationParams = [...modelProperties.values()].map(m => buildParameterDescriptor(m, suffixRefkey));
48
+
49
+ // Split operation params: params without defaults are positional, params with defaults are keyword-only
50
+ const opParamsWithoutDefaults = operationParams.filter(p => p.default === undefined);
51
+ const opParamsWithDefaults = operationParams.filter(p => p.default !== undefined);
52
+
53
+ // Reorder additional params: params without defaults before params with defaults
54
+ const optionsWithoutDefaults = optionsParams.filter(p => p.default === undefined);
55
+ const optionsWithDefaults = optionsParams.filter(p => p.default !== undefined);
56
+
57
+ // Build final parameter list:
58
+ // - Operation params without defaults: positional (e.g., URL path params)
59
+ // - "*" marker (if there are keyword-only params)
60
+ // - Operation params with defaults: keyword-only (e.g., query params with defaults)
61
+ // - Additional params: keyword-only
62
+
63
+ // If there are no operation params at all, treat additional params without defaults as positional
64
+ const hasOperationParams = operationParams.length > 0;
65
+ const positionalParams = hasOperationParams ? opParamsWithoutDefaults : [...opParamsWithoutDefaults, ...optionsWithoutDefaults];
66
+ const keywordOnlyParams = hasOperationParams ? [...optionsWithoutDefaults, ...opParamsWithDefaults, ...optionsWithDefaults] : [...opParamsWithDefaults, ...optionsWithDefaults];
67
+
68
+ // Add "*" marker if we have keyword-only params
69
+ // This enforces that params with defaults are truly keyword-only
70
+ const allParams = keywordOnlyParams.length > 0 ? [...positionalParams, "*", ...keywordOnlyParams] : [...positionalParams];
71
+ return allParams;
72
+ }
73
+
74
+ /**
75
+ * Convert a TypeSpec ModelProperty into a Python ParameterDescriptor.
76
+ */
77
+ export function buildParameterDescriptor(modelProperty, suffixRefkey) {
78
+ const {
79
+ $
80
+ } = useTsp();
81
+ const namePolicy = py.usePythonNamePolicy();
82
+ const paramName = namePolicy.getName(modelProperty.name, "parameter");
83
+ const isOptional = modelProperty.optional || modelProperty.defaultValue !== undefined;
84
+ const doc = $.type.getDoc(modelProperty);
85
+ let defaultValueNode = undefined;
86
+ const hasDefault = modelProperty.defaultValue !== undefined && modelProperty.defaultValue !== null;
87
+ if (hasDefault) {
88
+ defaultValueNode = Atom({
89
+ value: modelProperty.defaultValue
90
+ });
91
+ } else if (isOptional) {
92
+ // Render Python None for optional parameters without explicit default
93
+ defaultValueNode = py.Atom({
94
+ jsValue: null
95
+ });
96
+ }
97
+ return {
98
+ doc,
99
+ name: paramName,
100
+ refkey: efRefkey(modelProperty, suffixRefkey),
101
+ type: TypeExpression({
102
+ type: modelProperty.type
103
+ }),
104
+ ...(defaultValueNode !== undefined ? {
105
+ default: defaultValueNode
106
+ } : {})
107
+ };
108
+ }
109
+ const rawTypeMap = {
110
+ string: "str",
111
+ number: "float",
112
+ boolean: "bool",
113
+ any: typingModule["."]["Any"],
114
+ never: typingModule["."]["Never"]
115
+ };
116
+
117
+ /**
118
+ * Convert a parameter descriptor array to normalized parameter descriptors.
119
+ * String parameter names are converted to basic parameter descriptors.
120
+ */
121
+ function normalizeParameters(params) {
122
+ if (!params) return [];
123
+ return params.map(param => {
124
+ if (typeof param === "string") {
125
+ // Convert string names to parameter descriptors
126
+ return {
127
+ name: param
128
+ };
129
+ }
130
+ if (typeof param.type === "string") {
131
+ return {
132
+ ...param,
133
+ type: rawTypeMap[param.type] ?? param.type
134
+ };
135
+ }
136
+ return param;
137
+ });
138
+ }
139
+ //# sourceMappingURL=operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["typingModule","refkey","py","useTsp","Atom","TypeExpression","efRefkey","getReturnType","type","options","skipErrorFiltering","$","returnType","kind","union","filter","variant","isError","buildParameterDescriptors","suffixRefkey","optionsParams","normalizeParameters","params","replaceParameters","withoutDefaults","p","default","undefined","withDefaults","allParams","length","modelProperties","model","getProperties","operationParams","values","map","m","buildParameterDescriptor","opParamsWithoutDefaults","opParamsWithDefaults","optionsWithoutDefaults","optionsWithDefaults","hasOperationParams","positionalParams","keywordOnlyParams","modelProperty","namePolicy","usePythonNamePolicy","paramName","getName","name","isOptional","optional","defaultValue","doc","getDoc","defaultValueNode","hasDefault","value","jsValue","rawTypeMap","string","number","boolean","any","never","param"],"sources":["../../../../src/python/utils/operation.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,YAAY,QAAQ,qBAAq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AI,EAAEsC,aAAa,CAACtC;IAAK,CAAC,CAAC;IAClD,IAAIiD,gBAAgB,KAAK9B,SAAS,GAAG;MAAED,OAAO,EAAE+B;IAAiB,CAAC,GAAG,CAAC,CAAC;EACzE,CAAC;AACH;AAEA,MAAMI,UAAU,GAAG;EACjBC,MAAM,EAAE,KAAK;EACbC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAE,MAAM;EACfC,GAAG,EAAEjE,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;EAC7BkE,KAAK,EAAElE,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO;AAClC,CAAC;;AAED;AACA;AACA;AACA;AACA,SAASqB,mBAAmBA,CAC1BC,MAA2C,EACjB;EAC1B,IAAI,CAACA,MAAM,EAAE,OAAO,EAAE;EAEtB,OAAOA,MAAM,CAACc,GAAG,CAAE+B,KAAK,IAAK;IAC3B,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B;MACA,OAAO;QAAEhB,IAAI,EAAEgB;MAAM,CAAC;IACxB;IACA,IAAI,OAAQA,KAAK,CAAS3D,IAAI,KAAK,QAAQ,EAAE;MAC3C,OAAO;QACL,GAAG2D,KAAK;QACR3D,IAAI,EAAEqD,UAAU,CAACM,KAAK,CAAC3D,IAAI,CAA4B,IAAI2D,KAAK,CAAC3D;MACnE,CAAC;IACH;IACA,OAAO2D,KAAK;EACd,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ import { type Refkey } from "@alloy-js/core";
2
+ /**
3
+ * A wrapper around `refkey` that uses a custom symbol to avoid collisions with
4
+ * other libraries that use `refkey`.
5
+ *
6
+ * @remarks
7
+ *
8
+ * The underlying refkey function is called with the {@link refKeyPrefix} symbol as the first argument.
9
+ *
10
+ * @param args The parameters of the refkey.
11
+ * @returns A refkey object that can be used to identify the value.
12
+ */
13
+ export declare function efRefkey(...args: unknown[]): Refkey;
14
+ /**
15
+ * Creates a refkey for a declaration by combining the provided refkey with an internal
16
+ * refkey generated from the provided arguments.
17
+ *
18
+ * @param refkey The refkey provided by the user to be passed as is.
19
+ * @param args The parameters of the refkey.
20
+ * @returns An array of refkeys that can be passed to an Alloy declaration.
21
+ */
22
+ export declare function declarationRefkeys(refkey?: Refkey | Refkey[], ...args: unknown[]): Refkey[];
23
+ //# sourceMappingURL=refkey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refkey.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/refkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAIjE;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,CAKnD;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAK3F"}
@@ -0,0 +1,36 @@
1
+ import { refkey as ayRefkey } from "@alloy-js/core";
2
+ const refKeyPrefix = Symbol.for("emitter-framework:python");
3
+
4
+ /**
5
+ * A wrapper around `refkey` that uses a custom symbol to avoid collisions with
6
+ * other libraries that use `refkey`.
7
+ *
8
+ * @remarks
9
+ *
10
+ * The underlying refkey function is called with the {@link refKeyPrefix} symbol as the first argument.
11
+ *
12
+ * @param args The parameters of the refkey.
13
+ * @returns A refkey object that can be used to identify the value.
14
+ */
15
+ export function efRefkey(...args) {
16
+ if (args.length === 0) {
17
+ return ayRefkey(); // Generates a unique refkey
18
+ }
19
+ return ayRefkey(refKeyPrefix, ...args);
20
+ }
21
+
22
+ /**
23
+ * Creates a refkey for a declaration by combining the provided refkey with an internal
24
+ * refkey generated from the provided arguments.
25
+ *
26
+ * @param refkey The refkey provided by the user to be passed as is.
27
+ * @param args The parameters of the refkey.
28
+ * @returns An array of refkeys that can be passed to an Alloy declaration.
29
+ */
30
+ export function declarationRefkeys(refkey, ...args) {
31
+ if (refkey) {
32
+ return [refkey, efRefkey(...args)].flat();
33
+ }
34
+ return [efRefkey(...args)];
35
+ }
36
+ //# sourceMappingURL=refkey.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["refkey","ayRefkey","refKeyPrefix","Symbol","for","efRefkey","args","length","declarationRefkeys","flat"],"sources":["../../../../src/python/utils/refkey.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,MAAM,IAAIC,QAAQ,QAAqB,gBAAgB;AAEhE,MAAMC,YAAY,GAAGC,MAAM,CAACC,GAAG,CAAC,0BAA0B,CAAC;;AAE3D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAC,GAAGC,IAAe,EAAU;EACnD,IAAIA,IAAI,CAACC,MAAM,KAAK,CAAC,EAAE;IACrB,OAAON,QAAQ,CAAC,CAAC,CAAC,CAAC;EACrB;EACA,OAAOA,QAAQ,CAACC,YAAY,EAAE,GAAGI,IAAI,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,kBAAkBA,CAACR,MAA0B,EAAE,GAAGM,IAAe,EAAY;EAC3F,IAAIN,MAAM,EAAE;IACV,OAAO,CAACA,MAAM,EAAEK,QAAQ,CAAC,GAAGC,IAAI,CAAC,CAAC,CAACG,IAAI,CAAC,CAAC;EAC3C;EACA,OAAO,CAACJ,QAAQ,CAAC,GAAGC,IAAI,CAAC,CAAC;AAC5B","ignoreList":[]}
@@ -0,0 +1,19 @@
1
+ import type { Typekit } from "@typespec/compiler/typekit";
2
+ /**
3
+ * Check if a type is a literal type (string, numeric, boolean, or union variant).
4
+ * This is useful for determining if a type can be used in a Python Literal[] type.
5
+ *
6
+ * @param $ - The Typekit instance
7
+ * @param type - The type to check
8
+ * @returns true if the type is a literal type
9
+ */
10
+ export declare function isLiteral($: Typekit, type: any): boolean;
11
+ /**
12
+ * Check if all types in an array are literal types.
13
+ *
14
+ * @param $ - The Typekit instance
15
+ * @param types - Array of types to check
16
+ * @returns true if all types are literals
17
+ */
18
+ export declare function areAllLiterals($: Typekit, types: any[]): boolean;
19
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../../src/python/utils/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,GAAG,OAAO,CASxD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,OAAO,CAEhE"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Check if a type is a literal type (string, numeric, boolean, or union variant).
3
+ * This is useful for determining if a type can be used in a Python Literal[] type.
4
+ *
5
+ * @param $ - The Typekit instance
6
+ * @param type - The type to check
7
+ * @returns true if the type is a literal type
8
+ */
9
+ export function isLiteral($, type) {
10
+ if (!type) return false;
11
+ return $.literal.isString(type) || $.literal.isNumeric(type) || $.literal.isBoolean(type) || type.kind === "UnionVariant";
12
+ }
13
+
14
+ /**
15
+ * Check if all types in an array are literal types.
16
+ *
17
+ * @param $ - The Typekit instance
18
+ * @param types - Array of types to check
19
+ * @returns true if all types are literals
20
+ */
21
+ export function areAllLiterals($, types) {
22
+ return types.every(type => isLiteral($, type));
23
+ }
24
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isLiteral","$","type","literal","isString","isNumeric","isBoolean","kind","areAllLiterals","types","every"],"sources":["../../../../src/python/utils/type.ts"],"sourcesContent":[null],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,SAASA,CAACC,CAAU,EAAEC,IAAS,EAAW;EACxD,IAAI,CAACA,IAAI,EAAE,OAAO,KAAK;EAEvB,OACED,CAAC,CAACE,OAAO,CAACC,QAAQ,CAACF,IAAI,CAAC,IACxBD,CAAC,CAACE,OAAO,CAACE,SAAS,CAACH,IAAI,CAAC,IACzBD,CAAC,CAACE,OAAO,CAACG,SAAS,CAACJ,IAAI,CAAC,IACzBA,IAAI,CAACK,IAAI,KAAK,cAAc;AAEhC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACP,CAAU,EAAEQ,KAAY,EAAW;EAChE,OAAOA,KAAK,CAACC,KAAK,CAAER,IAAI,IAAKF,SAAS,CAACC,CAAC,EAAEC,IAAI,CAAC,CAAC;AAClD","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/emitter-framework",
3
- "version": "0.15.0-dev.3",
3
+ "version": "0.15.0-dev.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -17,6 +17,9 @@
17
17
  "./typescript": {
18
18
  "import": "./dist/src/typescript/index.js"
19
19
  },
20
+ "./python": {
21
+ "import": "./dist/src/python/index.js"
22
+ },
20
23
  "./testing": {
21
24
  "import": "./dist/src/testing/index.js"
22
25
  }
@@ -31,6 +34,9 @@
31
34
  },
32
35
  "#typescript/*": {
33
36
  "default": "./dist/src/typescript/*"
37
+ },
38
+ "#python/*": {
39
+ "default": "./dist/src/python/*"
34
40
  }
35
41
  },
36
42
  "keywords": [],
@@ -40,12 +46,14 @@
40
46
  "peerDependencies": {
41
47
  "@alloy-js/core": "^0.22.0",
42
48
  "@alloy-js/csharp": "^0.22.0",
49
+ "@alloy-js/python": "^0.3.0",
43
50
  "@alloy-js/typescript": "^0.22.0",
44
51
  "@typespec/compiler": "^1.7.1"
45
52
  },
46
53
  "devDependencies": {
47
54
  "@alloy-js/cli": "^0.22.0",
48
55
  "@alloy-js/core": "^0.22.0",
56
+ "@alloy-js/python": "^0.3.0",
49
57
  "@alloy-js/rollup-plugin": "^0.1.0",
50
58
  "@alloy-js/typescript": "^0.22.0",
51
59
  "@typespec/compiler": "^1.7.1",
package/package.json.bak CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/emitter-framework",
3
- "version": "0.15.0-dev.3",
3
+ "version": "0.15.0-dev.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -31,6 +31,9 @@
31
31
  "./typescript": {
32
32
  "import": "./dist/src/typescript/index.js"
33
33
  },
34
+ "./python": {
35
+ "import": "./dist/src/python/index.js"
36
+ },
34
37
  "./testing": {
35
38
  "import": "./dist/src/testing/index.js"
36
39
  }
@@ -48,6 +51,10 @@
48
51
  "#typescript/*": {
49
52
  "development": "./src/typescript/*",
50
53
  "default": "./dist/src/typescript/*"
54
+ },
55
+ "#python/*": {
56
+ "development": "./src/python/*",
57
+ "default": "./dist/src/python/*"
51
58
  }
52
59
  },
53
60
  "keywords": [],
@@ -57,12 +64,14 @@
57
64
  "peerDependencies": {
58
65
  "@alloy-js/core": "^0.22.0",
59
66
  "@alloy-js/csharp": "^0.22.0",
67
+ "@alloy-js/python": "^0.3.0",
60
68
  "@alloy-js/typescript": "^0.22.0",
61
69
  "@typespec/compiler": "^1.7.1"
62
70
  },
63
71
  "devDependencies": {
64
72
  "@alloy-js/cli": "^0.22.0",
65
73
  "@alloy-js/core": "^0.22.0",
74
+ "@alloy-js/python": "^0.3.0",
66
75
  "@alloy-js/rollup-plugin": "^0.1.0",
67
76
  "@alloy-js/typescript": "^0.22.0",
68
77
  "@typespec/compiler": "^1.7.1",
@@ -0,0 +1,43 @@
1
+ import type { SymbolCreator } from "@alloy-js/core";
2
+ import { createModule } from "@alloy-js/python";
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ type dummy = SymbolCreator;
6
+
7
+ export const abcModule = createModule({
8
+ name: "abc",
9
+ descriptor: {
10
+ ".": ["ABC"],
11
+ },
12
+ });
13
+
14
+ export const datetimeModule = createModule({
15
+ name: "datetime",
16
+ descriptor: {
17
+ ".": ["datetime", "date", "time", "timedelta", "timezone"],
18
+ },
19
+ });
20
+
21
+ export const decimalModule = createModule({
22
+ name: "decimal",
23
+ descriptor: {
24
+ ".": ["Decimal"],
25
+ },
26
+ });
27
+
28
+ export const typingModule = createModule({
29
+ name: "typing",
30
+ descriptor: {
31
+ ".": [
32
+ "Any",
33
+ "Callable",
34
+ "Generic",
35
+ "Literal",
36
+ "Never",
37
+ "Optional",
38
+ "Protocol",
39
+ "TypeAlias",
40
+ "TypeVar",
41
+ ],
42
+ },
43
+ });
@@ -0,0 +1,14 @@
1
+ import { Tester } from "#test/test-host.js";
2
+ import { d } from "@alloy-js/core/testing";
3
+ import { t } from "@typespec/compiler/testing";
4
+ import { expect, it } from "vitest";
5
+ import { getOutput } from "../../test-utils.js";
6
+ import { TypeExpression } from "../type-expression/type-expression.js";
7
+
8
+ it("maps array expression to Python list", async () => {
9
+ const { program, TestArray } = await Tester.compile(t.code`
10
+ alias ${t.type("TestArray")} = string[];
11
+ `);
12
+
13
+ expect(getOutput(program, [<TypeExpression type={TestArray} />])).toRenderTo(d`list[str]`);
14
+ });
@@ -0,0 +1,11 @@
1
+ import { code } from "@alloy-js/core";
2
+ import type { Type } from "@typespec/compiler";
3
+ import { TypeExpression } from "../type-expression/type-expression.js";
4
+
5
+ export interface ArrayExpressionProps {
6
+ elementType: Type;
7
+ }
8
+
9
+ export function ArrayExpression({ elementType }: ArrayExpressionProps) {
10
+ return code`list[${(<TypeExpression type={elementType} />)}]`;
11
+ }
@@ -0,0 +1 @@
1
+ export * from "./array-expression.js";