jsii-rosetta 1.76.0 → 4.9.0-dev.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 (511) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +1 -0
  3. package/README.md +287 -388
  4. package/bin/jsii-rosetta +1 -1
  5. package/lib/ambient/semver-intersect.d.ts +13 -0
  6. package/lib/ambient/semver-intersect.js +2 -0
  7. package/lib/ambient/semver-intersect.js.map +1 -0
  8. package/lib/commands/convert.js.map +1 -0
  9. package/lib/commands/coverage.js.map +1 -0
  10. package/lib/commands/extract.js +2 -2
  11. package/lib/commands/extract.js.map +1 -0
  12. package/lib/commands/infuse.js +2 -2
  13. package/lib/commands/infuse.js.map +1 -0
  14. package/lib/commands/read.js +6 -6
  15. package/lib/commands/read.js.map +1 -0
  16. package/lib/commands/transliterate.js +4 -4
  17. package/lib/commands/transliterate.js.map +1 -0
  18. package/lib/commands/trim-cache.js.map +1 -0
  19. package/lib/find-utils.js +4 -4
  20. package/lib/find-utils.js.map +1 -0
  21. package/lib/fixtures.js +2 -2
  22. package/lib/fixtures.js.map +1 -0
  23. package/lib/index.js.map +1 -0
  24. package/lib/jsii/assemblies.d.ts +1 -1
  25. package/lib/jsii/assemblies.js +14 -11
  26. package/lib/jsii/assemblies.js.map +1 -0
  27. package/lib/jsii/fingerprinting.js +9 -9
  28. package/lib/jsii/fingerprinting.js.map +1 -0
  29. package/lib/jsii/jsii-types.d.ts +4 -4
  30. package/lib/jsii/jsii-types.js +9 -4
  31. package/lib/jsii/jsii-types.js.map +1 -0
  32. package/lib/jsii/jsii-utils.d.ts +1 -1
  33. package/lib/jsii/jsii-utils.js +2 -2
  34. package/lib/jsii/jsii-utils.js.map +1 -0
  35. package/lib/jsii/packages.js.map +1 -0
  36. package/lib/languages/csharp.d.ts +3 -3
  37. package/lib/languages/csharp.js +2 -2
  38. package/lib/languages/csharp.js.map +1 -0
  39. package/lib/languages/default.d.ts +2 -2
  40. package/lib/languages/default.js.map +1 -0
  41. package/lib/languages/go.d.ts +3 -3
  42. package/lib/languages/go.js +20 -16
  43. package/lib/languages/go.js.map +1 -0
  44. package/lib/languages/index.d.ts +1 -1
  45. package/lib/languages/index.js +4 -4
  46. package/lib/languages/index.js.map +1 -0
  47. package/lib/languages/java.d.ts +2 -2
  48. package/lib/languages/java.js +2 -2
  49. package/lib/languages/java.js.map +1 -0
  50. package/lib/languages/python.d.ts +3 -3
  51. package/lib/languages/python.js +1 -1
  52. package/lib/languages/python.js.map +1 -0
  53. package/lib/languages/record-references-version.d.ts +2 -0
  54. package/lib/languages/record-references-version.js +6 -0
  55. package/lib/languages/record-references-version.js.map +1 -0
  56. package/lib/languages/record-references.d.ts +2 -2
  57. package/lib/languages/record-references.js +3 -2
  58. package/lib/languages/record-references.js.map +1 -0
  59. package/lib/languages/target-language.d.ts +0 -2
  60. package/lib/languages/target-language.js +2 -1
  61. package/lib/languages/target-language.js.map +1 -0
  62. package/lib/languages/visualize.d.ts +1 -1
  63. package/lib/languages/visualize.js +1 -1
  64. package/lib/languages/visualize.js.map +1 -0
  65. package/lib/logging.js +1 -1
  66. package/lib/logging.js.map +1 -0
  67. package/lib/main.d.ts +2 -0
  68. package/{bin/jsii-rosetta.js → lib/main.js} +21 -21
  69. package/lib/main.js.map +1 -0
  70. package/lib/markdown/escapes.js.map +1 -0
  71. package/lib/markdown/extract-snippets.d.ts +2 -2
  72. package/lib/markdown/extract-snippets.js +1 -1
  73. package/lib/markdown/extract-snippets.js.map +1 -0
  74. package/lib/markdown/index.js.map +1 -0
  75. package/lib/markdown/javadoc-renderer.js.map +1 -0
  76. package/lib/markdown/markdown-renderer.js.map +1 -0
  77. package/lib/markdown/markdown.js.map +1 -0
  78. package/lib/markdown/replace-code-renderer.d.ts +1 -1
  79. package/lib/markdown/replace-code-renderer.js.map +1 -0
  80. package/lib/markdown/replace-typescript-transform.d.ts +2 -2
  81. package/lib/markdown/replace-typescript-transform.js +1 -1
  82. package/lib/markdown/replace-typescript-transform.js.map +1 -0
  83. package/lib/markdown/structure-renderer.js.map +1 -0
  84. package/lib/markdown/types.js.map +1 -0
  85. package/lib/markdown/xml-comment-renderer.js.map +1 -0
  86. package/lib/o-tree.js +3 -3
  87. package/lib/o-tree.js.map +1 -0
  88. package/lib/renderer.js.map +1 -0
  89. package/lib/rosetta-reader.js.map +1 -0
  90. package/lib/rosetta-translator.d.ts +1 -1
  91. package/lib/rosetta-translator.js +2 -2
  92. package/lib/rosetta-translator.js.map +1 -0
  93. package/lib/snippet-dependencies.js +12 -12
  94. package/lib/snippet-dependencies.js.map +1 -0
  95. package/lib/snippet-selectors.d.ts +1 -1
  96. package/lib/snippet-selectors.js +2 -2
  97. package/lib/snippet-selectors.js.map +1 -0
  98. package/lib/snippet.d.ts +3 -3
  99. package/lib/snippet.js +5 -5
  100. package/lib/snippet.js.map +1 -0
  101. package/lib/strict.js.map +1 -0
  102. package/lib/submodule-reference.d.ts +1 -1
  103. package/lib/submodule-reference.js +11 -11
  104. package/lib/submodule-reference.js.map +1 -0
  105. package/lib/tablets/key.js +3 -3
  106. package/lib/tablets/key.js.map +1 -0
  107. package/lib/tablets/schema.js.map +1 -0
  108. package/lib/tablets/tablets.d.ts +1 -1
  109. package/lib/tablets/tablets.js +13 -13
  110. package/lib/tablets/tablets.js.map +1 -0
  111. package/lib/translate.d.ts +1 -1
  112. package/lib/translate.js +9 -7
  113. package/lib/translate.js.map +1 -0
  114. package/lib/translate_all.js +2 -2
  115. package/lib/translate_all.js.map +1 -0
  116. package/lib/translate_all_worker.js.map +1 -0
  117. package/lib/typescript/ast-utils.d.ts +2 -2
  118. package/lib/typescript/ast-utils.js +2 -4
  119. package/lib/typescript/ast-utils.js.map +1 -0
  120. package/lib/typescript/imports.d.ts +2 -2
  121. package/lib/typescript/imports.js +3 -3
  122. package/lib/typescript/imports.js.map +1 -0
  123. package/lib/typescript/syntax-kind-counter.d.ts +1 -1
  124. package/lib/typescript/syntax-kind-counter.js +1 -2
  125. package/lib/typescript/syntax-kind-counter.js.map +1 -0
  126. package/lib/typescript/ts-compiler.js.map +1 -0
  127. package/lib/typescript/types.d.ts +2 -2
  128. package/lib/typescript/types.js +1 -1
  129. package/lib/typescript/types.js.map +1 -0
  130. package/lib/typescript/visible-spans.js +6 -6
  131. package/lib/typescript/visible-spans.js.map +1 -0
  132. package/lib/util.d.ts +1 -1
  133. package/lib/util.js +2 -2
  134. package/lib/util.js.map +1 -0
  135. package/package.json +68 -37
  136. package/temp.tabl.json +48 -0
  137. package/bin/jsii-rosetta.d.ts +0 -2
  138. package/jest.config.mjs +0 -8
  139. package/jestsetup.js +0 -4
  140. package/test/commands/extract.test.d.ts +0 -2
  141. package/test/commands/extract.test.js +0 -698
  142. package/test/commands/infuse.test.d.ts +0 -2
  143. package/test/commands/infuse.test.js +0 -165
  144. package/test/commands/transliterate.test.d.ts +0 -2
  145. package/test/commands/transliterate.test.js +0 -1636
  146. package/test/commands/trim-cache.test.d.ts +0 -2
  147. package/test/commands/trim-cache.test.js +0 -85
  148. package/test/fixtures.test.d.ts +0 -2
  149. package/test/fixtures.test.js +0 -49
  150. package/test/jsii/assemblies.test.d.ts +0 -2
  151. package/test/jsii/assemblies.test.js +0 -230
  152. package/test/jsii/fake-assembly.d.ts +0 -3
  153. package/test/jsii/fake-assembly.js +0 -21
  154. package/test/jsii/fixtures/rosetta/explicit.ts-fixture +0 -7
  155. package/test/jsii/visible-spans.test.d.ts +0 -2
  156. package/test/jsii/visible-spans.test.js +0 -40
  157. package/test/jsii-imports.test.d.ts +0 -2
  158. package/test/jsii-imports.test.js +0 -438
  159. package/test/markdown/javadoc.test.d.ts +0 -2
  160. package/test/markdown/javadoc.test.js +0 -110
  161. package/test/markdown/roundtrip.test.d.ts +0 -2
  162. package/test/markdown/roundtrip.test.js +0 -126
  163. package/test/markdown/xmldoccomments.test.d.ts +0 -2
  164. package/test/markdown/xmldoccomments.test.js +0 -89
  165. package/test/otree.test.d.ts +0 -2
  166. package/test/otree.test.js +0 -36
  167. package/test/record-references.test.d.ts +0 -2
  168. package/test/record-references.test.js +0 -88
  169. package/test/rosetta/default.ts-fixture +0 -1
  170. package/test/rosetta-translator.test.d.ts +0 -2
  171. package/test/rosetta-translator.test.js +0 -33
  172. package/test/rosetta.test.d.ts +0 -2
  173. package/test/rosetta.test.js +0 -221
  174. package/test/snippet-selectors.test.d.ts +0 -2
  175. package/test/snippet-selectors.test.js +0 -57
  176. package/test/snippet.test.d.ts +0 -2
  177. package/test/snippet.test.js +0 -18
  178. package/test/syntax-counter.test.d.ts +0 -2
  179. package/test/syntax-counter.test.js +0 -60
  180. package/test/testutil.d.ts +0 -64
  181. package/test/testutil.js +0 -104
  182. package/test/translate.test.d.ts +0 -2
  183. package/test/translate.test.js +0 -175
  184. package/test/translations/calls/declaring_default_arguments.cs +0 -4
  185. package/test/translations/calls/declaring_default_arguments.go +0 -6
  186. package/test/translations/calls/declaring_default_arguments.java +0 -11
  187. package/test/translations/calls/declaring_default_arguments.py +0 -2
  188. package/test/translations/calls/default_struct_fields.cs +0 -9
  189. package/test/translations/calls/default_struct_fields.go +0 -7
  190. package/test/translations/calls/default_struct_fields.java +0 -21
  191. package/test/translations/calls/default_struct_fields.py +0 -2
  192. package/test/translations/calls/function_call.cs +0 -1
  193. package/test/translations/calls/function_call.go +0 -1
  194. package/test/translations/calls/function_call.java +0 -1
  195. package/test/translations/calls/function_call.py +0 -1
  196. package/test/translations/calls/list_of_anonymous_structs.cs +0 -9
  197. package/test/translations/calls/list_of_anonymous_structs.go +0 -12
  198. package/test/translations/calls/list_of_anonymous_structs.java +0 -6
  199. package/test/translations/calls/list_of_anonymous_structs.py +0 -9
  200. package/test/translations/calls/literal_map_argument.cs +0 -5
  201. package/test/translations/calls/literal_map_argument.go +0 -7
  202. package/test/translations/calls/literal_map_argument.java +0 -4
  203. package/test/translations/calls/literal_map_argument.py +0 -4
  204. package/test/translations/calls/method_call.cs +0 -1
  205. package/test/translations/calls/method_call.go +0 -1
  206. package/test/translations/calls/method_call.java +0 -1
  207. package/test/translations/calls/method_call.py +0 -1
  208. package/test/translations/calls/self_method_call.cs +0 -1
  209. package/test/translations/calls/self_method_call.go +0 -1
  210. package/test/translations/calls/self_method_call.java +0 -1
  211. package/test/translations/calls/self_method_call.py +0 -1
  212. package/test/translations/calls/shorthand_property.cs +0 -2
  213. package/test/translations/calls/shorthand_property.go +0 -4
  214. package/test/translations/calls/shorthand_property.java +0 -2
  215. package/test/translations/calls/shorthand_property.py +0 -2
  216. package/test/translations/calls/static_function_call.cs +0 -1
  217. package/test/translations/calls/static_function_call.go +0 -1
  218. package/test/translations/calls/static_function_call.java +0 -1
  219. package/test/translations/calls/static_function_call.py +0 -1
  220. package/test/translations/calls/this_argument.cs +0 -1
  221. package/test/translations/calls/this_argument.go +0 -1
  222. package/test/translations/calls/this_argument.java +0 -1
  223. package/test/translations/calls/this_argument.py +0 -1
  224. package/test/translations/calls/translate_object_literals_in_function_call.cs +0 -1
  225. package/test/translations/calls/translate_object_literals_in_function_call.go +0 -4
  226. package/test/translations/calls/translate_object_literals_in_function_call.java +0 -1
  227. package/test/translations/calls/translate_object_literals_in_function_call.py +0 -1
  228. package/test/translations/calls/translate_object_literals_only_one_level_deep.cs +0 -1
  229. package/test/translations/calls/translate_object_literals_only_one_level_deep.go +0 -7
  230. package/test/translations/calls/translate_object_literals_only_one_level_deep.java +0 -1
  231. package/test/translations/calls/translate_object_literals_only_one_level_deep.py +0 -1
  232. package/test/translations/calls/translate_object_literals_second_level_with_newlines.cs +0 -4
  233. package/test/translations/calls/translate_object_literals_second_level_with_newlines.go +0 -7
  234. package/test/translations/calls/translate_object_literals_second_level_with_newlines.java +0 -3
  235. package/test/translations/calls/translate_object_literals_second_level_with_newlines.py +0 -4
  236. package/test/translations/calls/translate_object_literals_with_multiple_newlines.cs +0 -5
  237. package/test/translations/calls/translate_object_literals_with_multiple_newlines.go +0 -5
  238. package/test/translations/calls/translate_object_literals_with_multiple_newlines.java +0 -4
  239. package/test/translations/calls/translate_object_literals_with_multiple_newlines.py +0 -5
  240. package/test/translations/calls/translate_object_literals_with_newlines.cs +0 -4
  241. package/test/translations/calls/translate_object_literals_with_newlines.go +0 -4
  242. package/test/translations/calls/translate_object_literals_with_newlines.java +0 -3
  243. package/test/translations/calls/translate_object_literals_with_newlines.py +0 -4
  244. package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.cs +0 -24
  245. package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.go +0 -24
  246. package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.java +0 -48
  247. package/test/translations/calls/will_type_deep_structs_directly_if_type_info_is_available.py +0 -7
  248. package/test/translations/classes/class_declaration_with_private_fields_and_constructor.cs +0 -9
  249. package/test/translations/classes/class_declaration_with_private_fields_and_constructor.go +0 -9
  250. package/test/translations/classes/class_declaration_with_private_fields_and_constructor.java +0 -7
  251. package/test/translations/classes/class_declaration_with_private_fields_and_constructor.py +0 -4
  252. package/test/translations/classes/class_declaration_with_public_fields_and_constructor.cs +0 -9
  253. package/test/translations/classes/class_declaration_with_public_fields_and_constructor.go +0 -9
  254. package/test/translations/classes/class_declaration_with_public_fields_and_constructor.java +0 -7
  255. package/test/translations/classes/class_declaration_with_public_fields_and_constructor.py +0 -4
  256. package/test/translations/classes/class_implementing_jsii_interface.cs +0 -7
  257. package/test/translations/classes/class_implementing_jsii_interface.go +0 -6
  258. package/test/translations/classes/class_implementing_jsii_interface.java +0 -5
  259. package/test/translations/classes/class_implementing_jsii_interface.py +0 -4
  260. package/test/translations/classes/class_with_different_name.cs +0 -6
  261. package/test/translations/classes/class_with_different_name.go +0 -7
  262. package/test/translations/classes/class_with_different_name.java +0 -4
  263. package/test/translations/classes/class_with_different_name.py +0 -3
  264. package/test/translations/classes/class_with_extends_and_implements.cs +0 -3
  265. package/test/translations/classes/class_with_extends_and_implements.go +0 -3
  266. package/test/translations/classes/class_with_extends_and_implements.java +0 -2
  267. package/test/translations/classes/class_with_inheritance.cs +0 -3
  268. package/test/translations/classes/class_with_inheritance.go +0 -3
  269. package/test/translations/classes/class_with_inheritance.java +0 -2
  270. package/test/translations/classes/class_with_inheritance.py +0 -2
  271. package/test/translations/classes/class_with_inheritance_and_super_class.cs +0 -6
  272. package/test/translations/classes/class_with_inheritance_and_super_class.go +0 -9
  273. package/test/translations/classes/class_with_inheritance_and_super_class.java +0 -5
  274. package/test/translations/classes/class_with_inheritance_and_super_class.py +0 -3
  275. package/test/translations/classes/class_with_method.cs +0 -7
  276. package/test/translations/classes/class_with_method.go +0 -7
  277. package/test/translations/classes/class_with_method.java +0 -5
  278. package/test/translations/classes/class_with_method.py +0 -3
  279. package/test/translations/classes/class_with_props_argument.cs +0 -14
  280. package/test/translations/classes/class_with_props_argument.go +0 -16
  281. package/test/translations/classes/class_with_props_argument.java +0 -26
  282. package/test/translations/classes/class_with_props_argument.py +0 -5
  283. package/test/translations/classes/constructor_with_optional_params.go +0 -10
  284. package/test/translations/classes/constructor_with_optional_params.java +0 -12
  285. package/test/translations/classes/empty_class.cs +0 -3
  286. package/test/translations/classes/empty_class.go +0 -2
  287. package/test/translations/classes/empty_class.java +0 -2
  288. package/test/translations/classes/empty_class.py +0 -2
  289. package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.cs +0 -11
  290. package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.go +0 -8
  291. package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.java +0 -8
  292. package/test/translations/classes/invisible_interfaces_do_not_affect_whitespace.py +0 -5
  293. package/test/translations/classes/whitespace_between_multiple_empty_members.cs +0 -15
  294. package/test/translations/classes/whitespace_between_multiple_empty_members.go +0 -12
  295. package/test/translations/classes/whitespace_between_multiple_empty_members.java +0 -11
  296. package/test/translations/classes/whitespace_between_multiple_empty_members.py +0 -9
  297. package/test/translations/classes/whitespace_between_multiple_members.cs +0 -17
  298. package/test/translations/classes/whitespace_between_multiple_members.go +0 -16
  299. package/test/translations/classes/whitespace_between_multiple_members.java +0 -13
  300. package/test/translations/classes/whitespace_between_multiple_members.py +0 -9
  301. package/test/translations/comments/empty_lines_in_comments.cs +0 -4
  302. package/test/translations/comments/empty_lines_in_comments.go +0 -4
  303. package/test/translations/comments/empty_lines_in_comments.java +0 -4
  304. package/test/translations/comments/empty_lines_in_comments.py +0 -4
  305. package/test/translations/comments/interleave_multiline_comments_with_function_call.cs +0 -7
  306. package/test/translations/comments/interleave_multiline_comments_with_function_call.go +0 -7
  307. package/test/translations/comments/interleave_multiline_comments_with_function_call.java +0 -6
  308. package/test/translations/comments/interleave_multiline_comments_with_function_call.py +0 -7
  309. package/test/translations/comments/interleave_single_line_comments_with_function_call.cs +0 -7
  310. package/test/translations/comments/interleave_single_line_comments_with_function_call.go +0 -7
  311. package/test/translations/comments/interleave_single_line_comments_with_function_call.java +0 -6
  312. package/test/translations/comments/interleave_single_line_comments_with_function_call.py +0 -7
  313. package/test/translations/comments/no_duplication_of_comments.cs +0 -2
  314. package/test/translations/comments/no_duplication_of_comments.go +0 -2
  315. package/test/translations/comments/no_duplication_of_comments.java +0 -2
  316. package/test/translations/comments/no_duplication_of_comments.py +0 -2
  317. package/test/translations/expressions/array_index.cs +0 -3
  318. package/test/translations/expressions/array_index.go +0 -3
  319. package/test/translations/expressions/array_index.java +0 -3
  320. package/test/translations/expressions/array_index.py +0 -3
  321. package/test/translations/expressions/as_expression.cs +0 -1
  322. package/test/translations/expressions/as_expression.go +0 -1
  323. package/test/translations/expressions/as_expression.java +0 -1
  324. package/test/translations/expressions/as_expression.py +0 -1
  325. package/test/translations/expressions/await.cs +0 -1
  326. package/test/translations/expressions/await.go +0 -1
  327. package/test/translations/expressions/await.java +0 -1
  328. package/test/translations/expressions/await.py +0 -1
  329. package/test/translations/expressions/backtick_string_w_o_substitutions.cs +0 -1
  330. package/test/translations/expressions/backtick_string_w_o_substitutions.go +0 -1
  331. package/test/translations/expressions/backtick_string_w_o_substitutions.java +0 -1
  332. package/test/translations/expressions/backtick_string_w_o_substitutions.py +0 -1
  333. package/test/translations/expressions/computed_key.cs +0 -4
  334. package/test/translations/expressions/computed_key.go +0 -8
  335. package/test/translations/expressions/computed_key.java +0 -4
  336. package/test/translations/expressions/computed_key.py +0 -4
  337. package/test/translations/expressions/double_quoted_dict_keys.cs +0 -1
  338. package/test/translations/expressions/double_quoted_dict_keys.go +0 -3
  339. package/test/translations/expressions/double_quoted_dict_keys.java +0 -1
  340. package/test/translations/expressions/double_quoted_dict_keys.py +0 -1
  341. package/test/translations/expressions/ellipsis_at_a_random_place.cs +0 -1
  342. package/test/translations/expressions/ellipsis_at_a_random_place.go +0 -1
  343. package/test/translations/expressions/ellipsis_at_a_random_place.java +0 -1
  344. package/test/translations/expressions/ellipsis_at_a_random_place.py +0 -1
  345. package/test/translations/expressions/enum_access.cs +0 -1
  346. package/test/translations/expressions/enum_access.go +0 -1
  347. package/test/translations/expressions/enum_access.java +0 -1
  348. package/test/translations/expressions/enum_access.py +0 -1
  349. package/test/translations/expressions/enum_like_access.cs +0 -1
  350. package/test/translations/expressions/enum_like_access.go +0 -1
  351. package/test/translations/expressions/enum_like_access.java +0 -1
  352. package/test/translations/expressions/enum_like_access.py +0 -1
  353. package/test/translations/expressions/map-literal.cs +0 -3
  354. package/test/translations/expressions/map-literal.go +0 -3
  355. package/test/translations/expressions/map-literal.java +0 -2
  356. package/test/translations/expressions/map-literal.py +0 -3
  357. package/test/translations/expressions/non_null_expression.cs +0 -1
  358. package/test/translations/expressions/non_null_expression.go +0 -1
  359. package/test/translations/expressions/non_null_expression.java +0 -1
  360. package/test/translations/expressions/non_null_expression.py +0 -1
  361. package/test/translations/expressions/string_interpolation.cs +0 -10
  362. package/test/translations/expressions/string_interpolation.go +0 -6
  363. package/test/translations/expressions/string_interpolation.java +0 -6
  364. package/test/translations/expressions/string_interpolation.py +0 -10
  365. package/test/translations/expressions/string_literal.cs +0 -9
  366. package/test/translations/expressions/string_literal.go +0 -9
  367. package/test/translations/expressions/string_literal.java +0 -1
  368. package/test/translations/expressions/string_literal.py +0 -9
  369. package/test/translations/expressions/struct_assignment.cs +0 -6
  370. package/test/translations/expressions/struct_assignment.go +0 -7
  371. package/test/translations/expressions/struct_assignment.java +0 -12
  372. package/test/translations/expressions/struct_assignment.py +0 -1
  373. package/test/translations/expressions/unary_and_binary_operators.cs +0 -3
  374. package/test/translations/expressions/unary_and_binary_operators.go +0 -3
  375. package/test/translations/expressions/unary_and_binary_operators.java +0 -3
  376. package/test/translations/expressions/unary_and_binary_operators.py +0 -3
  377. package/test/translations/hiding/hide_block_level_statements_using_void_directive.cs +0 -6
  378. package/test/translations/hiding/hide_block_level_statements_using_void_directive.go +0 -5
  379. package/test/translations/hiding/hide_block_level_statements_using_void_directive.java +0 -5
  380. package/test/translations/hiding/hide_block_level_statements_using_void_directive.py +0 -4
  381. package/test/translations/hiding/hide_expression_with_explicit_ellipsis.cs +0 -1
  382. package/test/translations/hiding/hide_expression_with_explicit_ellipsis.go +0 -1
  383. package/test/translations/hiding/hide_expression_with_explicit_ellipsis.java +0 -1
  384. package/test/translations/hiding/hide_expression_with_explicit_ellipsis.py +0 -1
  385. package/test/translations/hiding/hide_halfway_into_class_using_comments.cs +0 -3
  386. package/test/translations/hiding/hide_halfway_into_class_using_comments.go +0 -3
  387. package/test/translations/hiding/hide_halfway_into_class_using_comments.java +0 -3
  388. package/test/translations/hiding/hide_halfway_into_class_using_comments.py +0 -3
  389. package/test/translations/hiding/hide_parameter_sequence.cs +0 -1
  390. package/test/translations/hiding/hide_parameter_sequence.go +0 -1
  391. package/test/translations/hiding/hide_parameter_sequence.java +0 -1
  392. package/test/translations/hiding/hide_parameter_sequence.py +0 -1
  393. package/test/translations/hiding/hide_statements_with_explicit_ellipsis.cs +0 -3
  394. package/test/translations/hiding/hide_statements_with_explicit_ellipsis.go +0 -3
  395. package/test/translations/hiding/hide_statements_with_explicit_ellipsis.java +0 -3
  396. package/test/translations/hiding/hide_statements_with_explicit_ellipsis.py +0 -3
  397. package/test/translations/hiding/hide_top_level_statements_using_void_directive.cs +0 -1
  398. package/test/translations/hiding/hide_top_level_statements_using_void_directive.go +0 -1
  399. package/test/translations/hiding/hide_top_level_statements_using_void_directive.java +0 -1
  400. package/test/translations/hiding/hide_top_level_statements_using_void_directive.py +0 -1
  401. package/test/translations/identifiers/keyword.cs +0 -4
  402. package/test/translations/identifiers/keyword.go +0 -4
  403. package/test/translations/identifiers/keyword.java +0 -4
  404. package/test/translations/identifiers/keyword.py +0 -4
  405. package/test/translations/imports/import_require.cs +0 -2
  406. package/test/translations/imports/import_require.go +0 -2
  407. package/test/translations/imports/import_require.java +0 -2
  408. package/test/translations/imports/import_require.py +0 -2
  409. package/test/translations/imports/import_star_as.cs +0 -2
  410. package/test/translations/imports/import_star_as.go +0 -2
  411. package/test/translations/imports/import_star_as.java +0 -2
  412. package/test/translations/imports/import_star_as.py +0 -2
  413. package/test/translations/imports/multiple-imports.cs +0 -2
  414. package/test/translations/imports/multiple-imports.go +0 -2
  415. package/test/translations/imports/multiple-imports.java +0 -3
  416. package/test/translations/imports/multiple-imports.py +0 -2
  417. package/test/translations/imports/selective_import.cs +0 -4
  418. package/test/translations/imports/selective_import.go +0 -3
  419. package/test/translations/imports/selective_import.java +0 -6
  420. package/test/translations/imports/selective_import.py +0 -3
  421. package/test/translations/imports/submodule-import.cs +0 -15
  422. package/test/translations/imports/submodule-import.go +0 -23
  423. package/test/translations/imports/submodule-import.java +0 -17
  424. package/test/translations/imports/submodule-import.py +0 -15
  425. package/test/translations/interfaces/interface_with_method.cs +0 -4
  426. package/test/translations/interfaces/interface_with_method.go +0 -3
  427. package/test/translations/interfaces/interface_with_method.java +0 -3
  428. package/test/translations/interfaces/interface_with_props.cs +0 -4
  429. package/test/translations/interfaces/interface_with_props.go +0 -3
  430. package/test/translations/interfaces/interface_with_props.java +0 -3
  431. package/test/translations/misc/booleans_render_to_right_primitives.cs +0 -1
  432. package/test/translations/misc/booleans_render_to_right_primitives.go +0 -1
  433. package/test/translations/misc/booleans_render_to_right_primitives.java +0 -1
  434. package/test/translations/misc/booleans_render_to_right_primitives.py +0 -1
  435. package/test/translations/statements/block_without_braces.cs +0 -1
  436. package/test/translations/statements/block_without_braces.go +0 -3
  437. package/test/translations/statements/block_without_braces.java +0 -1
  438. package/test/translations/statements/block_without_braces.py +0 -1
  439. package/test/translations/statements/declare_var.cs +0 -1
  440. package/test/translations/statements/declare_var.go +0 -1
  441. package/test/translations/statements/declare_var.java +0 -1
  442. package/test/translations/statements/declare_var.py +0 -1
  443. package/test/translations/statements/empty_control_block.cs +0 -3
  444. package/test/translations/statements/empty_control_block.go +0 -1
  445. package/test/translations/statements/empty_control_block.java +0 -2
  446. package/test/translations/statements/empty_control_block.py +0 -2
  447. package/test/translations/statements/for_of_loop.cs +0 -4
  448. package/test/translations/statements/for_of_loop.go +0 -3
  449. package/test/translations/statements/for_of_loop.java +0 -3
  450. package/test/translations/statements/for_of_loop.py +0 -2
  451. package/test/translations/statements/if.cs +0 -4
  452. package/test/translations/statements/if.go +0 -3
  453. package/test/translations/statements/if.java +0 -3
  454. package/test/translations/statements/if.py +0 -2
  455. package/test/translations/statements/if_then_else.cs +0 -8
  456. package/test/translations/statements/if_then_else.go +0 -5
  457. package/test/translations/statements/if_then_else.java +0 -5
  458. package/test/translations/statements/if_then_else.py +0 -4
  459. package/test/translations/statements/initialize_object_literal.cs +0 -5
  460. package/test/translations/statements/initialize_object_literal.go +0 -8
  461. package/test/translations/statements/initialize_object_literal.java +0 -4
  462. package/test/translations/statements/initialize_object_literal.py +0 -5
  463. package/test/translations/statements/multiline_if_then_else.cs +0 -9
  464. package/test/translations/statements/multiline_if_then_else.go +0 -6
  465. package/test/translations/statements/multiline_if_then_else.java +0 -6
  466. package/test/translations/statements/multiline_if_then_else.py +0 -5
  467. package/test/translations/statements/statements_and_newlines.cs +0 -26
  468. package/test/translations/statements/statements_and_newlines.go +0 -21
  469. package/test/translations/statements/statements_and_newlines.java +0 -21
  470. package/test/translations/statements/statements_and_newlines.py +0 -16
  471. package/test/translations/statements/vararg_any_call.cs +0 -7
  472. package/test/translations/statements/vararg_any_call.go +0 -13
  473. package/test/translations/statements/vararg_any_call.java +0 -6
  474. package/test/translations/statements/vararg_any_call.py +0 -6
  475. package/test/translations/statements/whitespace_between_statements.cs +0 -3
  476. package/test/translations/statements/whitespace_between_statements.go +0 -3
  477. package/test/translations/statements/whitespace_between_statements.java +0 -3
  478. package/test/translations/statements/whitespace_between_statements.py +0 -3
  479. package/test/translations/statements/whitespace_between_statements_in_a_block.cs +0 -6
  480. package/test/translations/statements/whitespace_between_statements_in_a_block.go +0 -5
  481. package/test/translations/statements/whitespace_between_statements_in_a_block.java +0 -5
  482. package/test/translations/statements/whitespace_between_statements_in_a_block.py +0 -4
  483. package/test/translations/structs/any_type_never_a_struct.cs +0 -3
  484. package/test/translations/structs/any_type_never_a_struct.go +0 -3
  485. package/test/translations/structs/any_type_never_a_struct.java +0 -2
  486. package/test/translations/structs/any_type_never_a_struct.py +0 -3
  487. package/test/translations/structs/infer_struct_from_union.cs +0 -6
  488. package/test/translations/structs/infer_struct_from_union.go +0 -8
  489. package/test/translations/structs/infer_struct_from_union.java +0 -6
  490. package/test/translations/structs/infer_struct_from_union.py +0 -6
  491. package/test/translations/structs/optional_known_struct.cs +0 -3
  492. package/test/translations/structs/optional_known_struct.go +0 -3
  493. package/test/translations/structs/optional_known_struct.java +0 -3
  494. package/test/translations/structs/optional_known_struct.py +0 -3
  495. package/test/translations/structs/struct_starting_with_i.cs +0 -3
  496. package/test/translations/structs/struct_starting_with_i.go +0 -3
  497. package/test/translations/structs/struct_starting_with_i.java +0 -3
  498. package/test/translations/structs/struct_starting_with_i.py +0 -3
  499. package/test/translations/structs/var_new_class_known_struct.cs +0 -3
  500. package/test/translations/structs/var_new_class_known_struct.go +0 -3
  501. package/test/translations/structs/var_new_class_known_struct.java +0 -3
  502. package/test/translations/structs/var_new_class_known_struct.py +0 -3
  503. package/test/translations/structs/var_new_class_unknown_struct.cs +0 -3
  504. package/test/translations/structs/var_new_class_unknown_struct.go +0 -3
  505. package/test/translations/structs/var_new_class_unknown_struct.java +0 -3
  506. package/test/translations/structs/var_new_class_unknown_struct.py +0 -3
  507. package/test/translations.test.d.ts +0 -9
  508. package/test/translations.test.js +0 -112
  509. package/test/util.test.d.ts +0 -2
  510. package/test/util.test.js +0 -25
  511. package/vendor/semver-intersect.d.ts +0 -13
@@ -1,1636 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const spec_1 = require("@jsii/spec");
4
- const fs = require("fs");
5
- const jsii = require("jsii");
6
- const path = require("path");
7
- const extract_1 = require("../../lib/commands/extract");
8
- const transliterate_1 = require("../../lib/commands/transliterate");
9
- const target_language_1 = require("../../lib/languages/target-language");
10
- const testutil_1 = require("../testutil");
11
- jest.setTimeout(60000);
12
- // A targets configuration block with ALL targets enabled (although with phony configuration).
13
- const targets = Object.values(target_language_1.TargetLanguage).reduce((tgt, lang) => {
14
- tgt[(0, target_language_1.targetName)(lang)] = { phony: true };
15
- return tgt;
16
- }, {});
17
- test('single assembly, all languages', () => (0, testutil_1.withTemporaryDirectory)(async (tmpDir) => {
18
- // GIVEN
19
- const compilationResult = jsii.compileJsiiForTest({
20
- 'README.md': `
21
- # README
22
- \`\`\`ts
23
- const object: IInterface = new ClassName('this', 1337, { foo: 'bar' });
24
- object.property = EnumType.OPTION_A;
25
- object.methodCall();
26
-
27
- ClassName.staticMethod(EnumType.OPTION_B);
28
- \`\`\`
29
- `,
30
- 'index.ts': `
31
- /**
32
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
33
- */
34
- export enum EnumType {
35
- /**
36
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_A });
37
- */
38
- OPTION_A = 1,
39
-
40
- /**
41
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
42
- */
43
- OPTION_B = 2,
44
- }
45
-
46
- export interface IInterface {
47
- /**
48
- * A property value.
49
- *
50
- * @example
51
- * iface.property = EnumType.OPTION_B;
52
- */
53
- property: EnumType;
54
-
55
- /**
56
- * An instance method call.
57
- *
58
- * @example
59
- * iface.methodCall();
60
- */
61
- methodCall(): void;
62
- }
63
-
64
- export interface ClassNameProps {
65
- readonly property?: EnumType;
66
- readonly foo?: string;
67
- }
68
-
69
- export class ClassName implements IInterface {
70
- /**
71
- * A static method. It can be invoked easily.
72
- *
73
- * @example ClassName.staticMethod();
74
- */
75
- public static staticMethod(_enm?: EnumType): void {
76
- // ...
77
- }
78
-
79
- public property: EnumType;
80
-
81
- /**
82
- * Create a new instance of ClassName.
83
- *
84
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
85
- */
86
- public constructor(_this: string, _elite: number, props: ClassNameProps) {
87
- this.property = props.property ?? EnumType.OPTION_A;
88
- }
89
-
90
- public methodCall(): void {
91
- // ...
92
- }
93
- }`,
94
- });
95
- fs.writeFileSync(path.join(tmpDir, spec_1.SPEC_FILE_NAME), JSON.stringify({ ...compilationResult.assembly, targets }, null, 2));
96
- for (const [file, content] of Object.entries(compilationResult.files)) {
97
- fs.writeFileSync(path.resolve(tmpDir, file), content, 'utf-8');
98
- }
99
- fs.mkdirSync(path.resolve(tmpDir, 'rosetta'));
100
- fs.writeFileSync(path.resolve(tmpDir, 'rosetta', 'default.ts-fixture'), `import { EnumType, IInterface, ClassName } from '.';\ndeclare const iface: IInterface\n/// here`, 'utf-8');
101
- // WHEN
102
- await expect((0, transliterate_1.transliterateAssembly)([tmpDir], Object.values(target_language_1.TargetLanguage), {
103
- strict: true,
104
- })).resolves.not.toThrow();
105
- // THEN
106
- expect(JSON.parse(fs.readFileSync(path.join(tmpDir, `${spec_1.SPEC_FILE_NAME}.csharp`), 'utf-8'))).toMatchInlineSnapshot({
107
- fingerprint: expect.any(String),
108
- jsiiVersion: expect.any(String),
109
- targets: expect.any(Object),
110
- }, `
111
- {
112
- "author": {
113
- "name": "John Doe",
114
- "roles": [
115
- "author",
116
- ],
117
- },
118
- "description": "testpkg",
119
- "fingerprint": Any<String>,
120
- "homepage": "https://github.com/aws/jsii.git",
121
- "jsiiVersion": Any<String>,
122
- "license": "Apache-2.0",
123
- "metadata": {
124
- "jsii": {
125
- "pacmak": {
126
- "hasDefaultInterfaces": true,
127
- },
128
- },
129
- },
130
- "name": "testpkg",
131
- "readme": {
132
- "markdown": "# README
133
-
134
- \`\`\`csharp
135
- var object = new ClassName("this", 1337, new ClassNameProps { Foo = "bar" });
136
- object.Property = EnumType.OPTION_A;
137
- object.MethodCall();
138
-
139
- ClassName.StaticMethod(EnumType.OPTION_B);
140
- \`\`\`",
141
- },
142
- "repository": {
143
- "type": "git",
144
- "url": "https://github.com/aws/jsii.git",
145
- },
146
- "schema": "jsii/0.10.0",
147
- "targets": Any<Object>,
148
- "types": {
149
- "testpkg.ClassName": {
150
- "assembly": "testpkg",
151
- "fqn": "testpkg.ClassName",
152
- "initializer": {
153
- "docs": {
154
- "example": "new ClassName("this", 1337, new ClassNameProps { Property = EnumType.OPTION_B });",
155
- "summary": "Create a new instance of ClassName.",
156
- },
157
- "locationInModule": {
158
- "filename": "index.ts",
159
- "line": 57,
160
- },
161
- "parameters": [
162
- {
163
- "name": "_this",
164
- "type": {
165
- "primitive": "string",
166
- },
167
- },
168
- {
169
- "name": "_elite",
170
- "type": {
171
- "primitive": "number",
172
- },
173
- },
174
- {
175
- "name": "props",
176
- "type": {
177
- "fqn": "testpkg.ClassNameProps",
178
- },
179
- },
180
- ],
181
- },
182
- "interfaces": [
183
- "testpkg.IInterface",
184
- ],
185
- "kind": "class",
186
- "locationInModule": {
187
- "filename": "index.ts",
188
- "line": 40,
189
- },
190
- "methods": [
191
- {
192
- "docs": {
193
- "example": "ClassName.StaticMethod();",
194
- "remarks": "It can be invoked easily.",
195
- "summary": "A static method.",
196
- },
197
- "locationInModule": {
198
- "filename": "index.ts",
199
- "line": 46,
200
- },
201
- "name": "staticMethod",
202
- "parameters": [
203
- {
204
- "name": "_enm",
205
- "optional": true,
206
- "type": {
207
- "fqn": "testpkg.EnumType",
208
- },
209
- },
210
- ],
211
- "static": true,
212
- },
213
- {
214
- "docs": {
215
- "summary": "An instance method call.",
216
- },
217
- "locationInModule": {
218
- "filename": "index.ts",
219
- "line": 61,
220
- },
221
- "name": "methodCall",
222
- "overrides": "testpkg.IInterface",
223
- },
224
- ],
225
- "name": "ClassName",
226
- "properties": [
227
- {
228
- "docs": {
229
- "summary": "A property value.",
230
- },
231
- "locationInModule": {
232
- "filename": "index.ts",
233
- "line": 50,
234
- },
235
- "name": "property",
236
- "overrides": "testpkg.IInterface",
237
- "type": {
238
- "fqn": "testpkg.EnumType",
239
- },
240
- },
241
- ],
242
- "symbolId": "index:ClassName",
243
- },
244
- "testpkg.ClassNameProps": {
245
- "assembly": "testpkg",
246
- "datatype": true,
247
- "fqn": "testpkg.ClassNameProps",
248
- "kind": "interface",
249
- "locationInModule": {
250
- "filename": "index.ts",
251
- "line": 35,
252
- },
253
- "name": "ClassNameProps",
254
- "properties": [
255
- {
256
- "abstract": true,
257
- "immutable": true,
258
- "locationInModule": {
259
- "filename": "index.ts",
260
- "line": 37,
261
- },
262
- "name": "foo",
263
- "optional": true,
264
- "type": {
265
- "primitive": "string",
266
- },
267
- },
268
- {
269
- "abstract": true,
270
- "immutable": true,
271
- "locationInModule": {
272
- "filename": "index.ts",
273
- "line": 36,
274
- },
275
- "name": "property",
276
- "optional": true,
277
- "type": {
278
- "fqn": "testpkg.EnumType",
279
- },
280
- },
281
- ],
282
- "symbolId": "index:ClassNameProps",
283
- },
284
- "testpkg.EnumType": {
285
- "assembly": "testpkg",
286
- "docs": {
287
- "example": "new ClassName("this", 1337, new ClassNameProps { Property = EnumType.OPTION_B });",
288
- },
289
- "fqn": "testpkg.EnumType",
290
- "kind": "enum",
291
- "locationInModule": {
292
- "filename": "index.ts",
293
- "line": 5,
294
- },
295
- "members": [
296
- {
297
- "docs": {
298
- "example": "new ClassName("this", 1337, new ClassNameProps { Property = EnumType.OPTION_A });",
299
- },
300
- "name": "OPTION_A",
301
- },
302
- {
303
- "docs": {
304
- "example": "new ClassName("this", 1337, new ClassNameProps { Property = EnumType.OPTION_B });",
305
- },
306
- "name": "OPTION_B",
307
- },
308
- ],
309
- "name": "EnumType",
310
- "symbolId": "index:EnumType",
311
- },
312
- "testpkg.IInterface": {
313
- "assembly": "testpkg",
314
- "fqn": "testpkg.IInterface",
315
- "kind": "interface",
316
- "locationInModule": {
317
- "filename": "index.ts",
318
- "line": 17,
319
- },
320
- "methods": [
321
- {
322
- "abstract": true,
323
- "docs": {
324
- "example": "iface.MethodCall();",
325
- "summary": "An instance method call.",
326
- },
327
- "locationInModule": {
328
- "filename": "index.ts",
329
- "line": 32,
330
- },
331
- "name": "methodCall",
332
- },
333
- ],
334
- "name": "IInterface",
335
- "properties": [
336
- {
337
- "abstract": true,
338
- "docs": {
339
- "example": "iface.Property = EnumType.OPTION_B;",
340
- "summary": "A property value.",
341
- },
342
- "locationInModule": {
343
- "filename": "index.ts",
344
- "line": 24,
345
- },
346
- "name": "property",
347
- "type": {
348
- "fqn": "testpkg.EnumType",
349
- },
350
- },
351
- ],
352
- "symbolId": "index:IInterface",
353
- },
354
- },
355
- "version": "0.0.1",
356
- }
357
- `);
358
- expect(JSON.parse(fs.readFileSync(path.join(tmpDir, `${spec_1.SPEC_FILE_NAME}.java`), 'utf-8'))).toMatchInlineSnapshot({
359
- fingerprint: expect.any(String),
360
- jsiiVersion: expect.any(String),
361
- targets: expect.any(Object),
362
- }, `
363
- {
364
- "author": {
365
- "name": "John Doe",
366
- "roles": [
367
- "author",
368
- ],
369
- },
370
- "description": "testpkg",
371
- "fingerprint": Any<String>,
372
- "homepage": "https://github.com/aws/jsii.git",
373
- "jsiiVersion": Any<String>,
374
- "license": "Apache-2.0",
375
- "metadata": {
376
- "jsii": {
377
- "pacmak": {
378
- "hasDefaultInterfaces": true,
379
- },
380
- },
381
- },
382
- "name": "testpkg",
383
- "readme": {
384
- "markdown": "# README
385
-
386
- \`\`\`java
387
- IInterface object = new ClassName("this", 1337, new ClassNameProps().foo("bar"));
388
- object.getProperty() = EnumType.OPTION_A;
389
- object.methodCall();
390
-
391
- ClassName.staticMethod(EnumType.OPTION_B);
392
- \`\`\`",
393
- },
394
- "repository": {
395
- "type": "git",
396
- "url": "https://github.com/aws/jsii.git",
397
- },
398
- "schema": "jsii/0.10.0",
399
- "targets": Any<Object>,
400
- "types": {
401
- "testpkg.ClassName": {
402
- "assembly": "testpkg",
403
- "fqn": "testpkg.ClassName",
404
- "initializer": {
405
- "docs": {
406
- "example": "new ClassName("this", 1337, new ClassNameProps().property(EnumType.OPTION_B));",
407
- "summary": "Create a new instance of ClassName.",
408
- },
409
- "locationInModule": {
410
- "filename": "index.ts",
411
- "line": 57,
412
- },
413
- "parameters": [
414
- {
415
- "name": "_this",
416
- "type": {
417
- "primitive": "string",
418
- },
419
- },
420
- {
421
- "name": "_elite",
422
- "type": {
423
- "primitive": "number",
424
- },
425
- },
426
- {
427
- "name": "props",
428
- "type": {
429
- "fqn": "testpkg.ClassNameProps",
430
- },
431
- },
432
- ],
433
- },
434
- "interfaces": [
435
- "testpkg.IInterface",
436
- ],
437
- "kind": "class",
438
- "locationInModule": {
439
- "filename": "index.ts",
440
- "line": 40,
441
- },
442
- "methods": [
443
- {
444
- "docs": {
445
- "example": "ClassName.staticMethod();",
446
- "remarks": "It can be invoked easily.",
447
- "summary": "A static method.",
448
- },
449
- "locationInModule": {
450
- "filename": "index.ts",
451
- "line": 46,
452
- },
453
- "name": "staticMethod",
454
- "parameters": [
455
- {
456
- "name": "_enm",
457
- "optional": true,
458
- "type": {
459
- "fqn": "testpkg.EnumType",
460
- },
461
- },
462
- ],
463
- "static": true,
464
- },
465
- {
466
- "docs": {
467
- "summary": "An instance method call.",
468
- },
469
- "locationInModule": {
470
- "filename": "index.ts",
471
- "line": 61,
472
- },
473
- "name": "methodCall",
474
- "overrides": "testpkg.IInterface",
475
- },
476
- ],
477
- "name": "ClassName",
478
- "properties": [
479
- {
480
- "docs": {
481
- "summary": "A property value.",
482
- },
483
- "locationInModule": {
484
- "filename": "index.ts",
485
- "line": 50,
486
- },
487
- "name": "property",
488
- "overrides": "testpkg.IInterface",
489
- "type": {
490
- "fqn": "testpkg.EnumType",
491
- },
492
- },
493
- ],
494
- "symbolId": "index:ClassName",
495
- },
496
- "testpkg.ClassNameProps": {
497
- "assembly": "testpkg",
498
- "datatype": true,
499
- "fqn": "testpkg.ClassNameProps",
500
- "kind": "interface",
501
- "locationInModule": {
502
- "filename": "index.ts",
503
- "line": 35,
504
- },
505
- "name": "ClassNameProps",
506
- "properties": [
507
- {
508
- "abstract": true,
509
- "immutable": true,
510
- "locationInModule": {
511
- "filename": "index.ts",
512
- "line": 37,
513
- },
514
- "name": "foo",
515
- "optional": true,
516
- "type": {
517
- "primitive": "string",
518
- },
519
- },
520
- {
521
- "abstract": true,
522
- "immutable": true,
523
- "locationInModule": {
524
- "filename": "index.ts",
525
- "line": 36,
526
- },
527
- "name": "property",
528
- "optional": true,
529
- "type": {
530
- "fqn": "testpkg.EnumType",
531
- },
532
- },
533
- ],
534
- "symbolId": "index:ClassNameProps",
535
- },
536
- "testpkg.EnumType": {
537
- "assembly": "testpkg",
538
- "docs": {
539
- "example": "new ClassName("this", 1337, new ClassNameProps().property(EnumType.OPTION_B));",
540
- },
541
- "fqn": "testpkg.EnumType",
542
- "kind": "enum",
543
- "locationInModule": {
544
- "filename": "index.ts",
545
- "line": 5,
546
- },
547
- "members": [
548
- {
549
- "docs": {
550
- "example": "new ClassName("this", 1337, new ClassNameProps().property(EnumType.OPTION_A));",
551
- },
552
- "name": "OPTION_A",
553
- },
554
- {
555
- "docs": {
556
- "example": "new ClassName("this", 1337, new ClassNameProps().property(EnumType.OPTION_B));",
557
- },
558
- "name": "OPTION_B",
559
- },
560
- ],
561
- "name": "EnumType",
562
- "symbolId": "index:EnumType",
563
- },
564
- "testpkg.IInterface": {
565
- "assembly": "testpkg",
566
- "fqn": "testpkg.IInterface",
567
- "kind": "interface",
568
- "locationInModule": {
569
- "filename": "index.ts",
570
- "line": 17,
571
- },
572
- "methods": [
573
- {
574
- "abstract": true,
575
- "docs": {
576
- "example": "iface.methodCall();",
577
- "summary": "An instance method call.",
578
- },
579
- "locationInModule": {
580
- "filename": "index.ts",
581
- "line": 32,
582
- },
583
- "name": "methodCall",
584
- },
585
- ],
586
- "name": "IInterface",
587
- "properties": [
588
- {
589
- "abstract": true,
590
- "docs": {
591
- "example": "iface.getProperty() = EnumType.OPTION_B;",
592
- "summary": "A property value.",
593
- },
594
- "locationInModule": {
595
- "filename": "index.ts",
596
- "line": 24,
597
- },
598
- "name": "property",
599
- "type": {
600
- "fqn": "testpkg.EnumType",
601
- },
602
- },
603
- ],
604
- "symbolId": "index:IInterface",
605
- },
606
- },
607
- "version": "0.0.1",
608
- }
609
- `);
610
- expect(JSON.parse(fs.readFileSync(path.join(tmpDir, `${spec_1.SPEC_FILE_NAME}.python`), 'utf-8'))).toMatchInlineSnapshot({
611
- fingerprint: expect.any(String),
612
- jsiiVersion: expect.any(String),
613
- targets: expect.any(Object),
614
- }, `
615
- {
616
- "author": {
617
- "name": "John Doe",
618
- "roles": [
619
- "author",
620
- ],
621
- },
622
- "description": "testpkg",
623
- "fingerprint": Any<String>,
624
- "homepage": "https://github.com/aws/jsii.git",
625
- "jsiiVersion": Any<String>,
626
- "license": "Apache-2.0",
627
- "metadata": {
628
- "jsii": {
629
- "pacmak": {
630
- "hasDefaultInterfaces": true,
631
- },
632
- },
633
- },
634
- "name": "testpkg",
635
- "readme": {
636
- "markdown": "# README
637
-
638
- \`\`\`python
639
- object = ClassName("this", 1337, foo="bar")
640
- object.property = EnumType.OPTION_A
641
- object.method_call()
642
-
643
- ClassName.static_method(EnumType.OPTION_B)
644
- \`\`\`",
645
- },
646
- "repository": {
647
- "type": "git",
648
- "url": "https://github.com/aws/jsii.git",
649
- },
650
- "schema": "jsii/0.10.0",
651
- "targets": Any<Object>,
652
- "types": {
653
- "testpkg.ClassName": {
654
- "assembly": "testpkg",
655
- "fqn": "testpkg.ClassName",
656
- "initializer": {
657
- "docs": {
658
- "example": "ClassName("this", 1337, property=EnumType.OPTION_B)",
659
- "summary": "Create a new instance of ClassName.",
660
- },
661
- "locationInModule": {
662
- "filename": "index.ts",
663
- "line": 57,
664
- },
665
- "parameters": [
666
- {
667
- "name": "_this",
668
- "type": {
669
- "primitive": "string",
670
- },
671
- },
672
- {
673
- "name": "_elite",
674
- "type": {
675
- "primitive": "number",
676
- },
677
- },
678
- {
679
- "name": "props",
680
- "type": {
681
- "fqn": "testpkg.ClassNameProps",
682
- },
683
- },
684
- ],
685
- },
686
- "interfaces": [
687
- "testpkg.IInterface",
688
- ],
689
- "kind": "class",
690
- "locationInModule": {
691
- "filename": "index.ts",
692
- "line": 40,
693
- },
694
- "methods": [
695
- {
696
- "docs": {
697
- "example": "ClassName.static_method()",
698
- "remarks": "It can be invoked easily.",
699
- "summary": "A static method.",
700
- },
701
- "locationInModule": {
702
- "filename": "index.ts",
703
- "line": 46,
704
- },
705
- "name": "staticMethod",
706
- "parameters": [
707
- {
708
- "name": "_enm",
709
- "optional": true,
710
- "type": {
711
- "fqn": "testpkg.EnumType",
712
- },
713
- },
714
- ],
715
- "static": true,
716
- },
717
- {
718
- "docs": {
719
- "summary": "An instance method call.",
720
- },
721
- "locationInModule": {
722
- "filename": "index.ts",
723
- "line": 61,
724
- },
725
- "name": "methodCall",
726
- "overrides": "testpkg.IInterface",
727
- },
728
- ],
729
- "name": "ClassName",
730
- "properties": [
731
- {
732
- "docs": {
733
- "summary": "A property value.",
734
- },
735
- "locationInModule": {
736
- "filename": "index.ts",
737
- "line": 50,
738
- },
739
- "name": "property",
740
- "overrides": "testpkg.IInterface",
741
- "type": {
742
- "fqn": "testpkg.EnumType",
743
- },
744
- },
745
- ],
746
- "symbolId": "index:ClassName",
747
- },
748
- "testpkg.ClassNameProps": {
749
- "assembly": "testpkg",
750
- "datatype": true,
751
- "fqn": "testpkg.ClassNameProps",
752
- "kind": "interface",
753
- "locationInModule": {
754
- "filename": "index.ts",
755
- "line": 35,
756
- },
757
- "name": "ClassNameProps",
758
- "properties": [
759
- {
760
- "abstract": true,
761
- "immutable": true,
762
- "locationInModule": {
763
- "filename": "index.ts",
764
- "line": 37,
765
- },
766
- "name": "foo",
767
- "optional": true,
768
- "type": {
769
- "primitive": "string",
770
- },
771
- },
772
- {
773
- "abstract": true,
774
- "immutable": true,
775
- "locationInModule": {
776
- "filename": "index.ts",
777
- "line": 36,
778
- },
779
- "name": "property",
780
- "optional": true,
781
- "type": {
782
- "fqn": "testpkg.EnumType",
783
- },
784
- },
785
- ],
786
- "symbolId": "index:ClassNameProps",
787
- },
788
- "testpkg.EnumType": {
789
- "assembly": "testpkg",
790
- "docs": {
791
- "example": "ClassName("this", 1337, property=EnumType.OPTION_B)",
792
- },
793
- "fqn": "testpkg.EnumType",
794
- "kind": "enum",
795
- "locationInModule": {
796
- "filename": "index.ts",
797
- "line": 5,
798
- },
799
- "members": [
800
- {
801
- "docs": {
802
- "example": "ClassName("this", 1337, property=EnumType.OPTION_A)",
803
- },
804
- "name": "OPTION_A",
805
- },
806
- {
807
- "docs": {
808
- "example": "ClassName("this", 1337, property=EnumType.OPTION_B)",
809
- },
810
- "name": "OPTION_B",
811
- },
812
- ],
813
- "name": "EnumType",
814
- "symbolId": "index:EnumType",
815
- },
816
- "testpkg.IInterface": {
817
- "assembly": "testpkg",
818
- "fqn": "testpkg.IInterface",
819
- "kind": "interface",
820
- "locationInModule": {
821
- "filename": "index.ts",
822
- "line": 17,
823
- },
824
- "methods": [
825
- {
826
- "abstract": true,
827
- "docs": {
828
- "example": "iface.method_call()",
829
- "summary": "An instance method call.",
830
- },
831
- "locationInModule": {
832
- "filename": "index.ts",
833
- "line": 32,
834
- },
835
- "name": "methodCall",
836
- },
837
- ],
838
- "name": "IInterface",
839
- "properties": [
840
- {
841
- "abstract": true,
842
- "docs": {
843
- "example": "iface.property = EnumType.OPTION_B",
844
- "summary": "A property value.",
845
- },
846
- "locationInModule": {
847
- "filename": "index.ts",
848
- "line": 24,
849
- },
850
- "name": "property",
851
- "type": {
852
- "fqn": "testpkg.EnumType",
853
- },
854
- },
855
- ],
856
- "symbolId": "index:IInterface",
857
- },
858
- },
859
- "version": "0.0.1",
860
- }
861
- `);
862
- }));
863
- test('single assembly, loose mode', () => (0, testutil_1.withTemporaryDirectory)(async (tmpDir) => {
864
- // GIVEN
865
- const compilationResult = jsii.compileJsiiForTest({
866
- 'README.md': `
867
- # Missing literate source
868
-
869
- [ts source is not found](missing-example.lit.ts)
870
-
871
- # Missing literate source and fallback
872
-
873
- [example is not found](omit-example.lit.ts)
874
-
875
- # Missing fixture
876
-
877
- \`\`\`ts fixture=not-found
878
- new SampleClass('README.md');
879
- \`\`\`
880
- `,
881
- 'index.ts': `
882
- /**
883
- * @example
884
- * /// fixture=not-found
885
- * new DoesNotCompile(this, 'That', { foo: 1337 });
886
- */
887
- export class SampleClass {
888
- public constructor(_source: string){ }
889
- }
890
- `,
891
- // The `lit.ts` source file will not be there in packaged form...
892
- 'missing-example.lit.ts': `
893
- import { SampleClass } from './index';
894
-
895
- /// !show
896
- /// ## This is a heading within the literate file!
897
- new SampleClass('literate');
898
- `,
899
- // The `lit.ts` source file and `lit.js` output will not be there in packaged form...
900
- 'omit-example.lit.ts': `
901
- import { SampleClass } from './index';
902
-
903
- /// !show
904
- /// ## This is a heading within the omitted literate file!
905
- new SampleClass('omitted-literate');
906
- `,
907
- });
908
- fs.writeFileSync(path.join(tmpDir, spec_1.SPEC_FILE_NAME), JSON.stringify({ ...compilationResult.assembly, targets }, null, 2));
909
- for (const [file, content] of Object.entries(compilationResult.files)) {
910
- if (file.startsWith('omit-')) {
911
- continue;
912
- }
913
- fs.writeFileSync(path.resolve(tmpDir, file), content, 'utf-8');
914
- }
915
- // WHEN
916
- await expect((0, transliterate_1.transliterateAssembly)([tmpDir], Object.values(target_language_1.TargetLanguage), {
917
- loose: true,
918
- })).resolves.not.toThrow();
919
- // THEN
920
- expect(JSON.parse(fs.readFileSync(path.join(tmpDir, `${spec_1.SPEC_FILE_NAME}.csharp`), 'utf-8'))).toMatchInlineSnapshot({
921
- fingerprint: expect.any(String),
922
- jsiiVersion: expect.any(String),
923
- targets: expect.any(Object),
924
- }, `
925
- {
926
- "author": {
927
- "name": "John Doe",
928
- "roles": [
929
- "author",
930
- ],
931
- },
932
- "description": "testpkg",
933
- "fingerprint": Any<String>,
934
- "homepage": "https://github.com/aws/jsii.git",
935
- "jsiiVersion": Any<String>,
936
- "license": "Apache-2.0",
937
- "metadata": {
938
- "jsii": {
939
- "pacmak": {
940
- "hasDefaultInterfaces": true,
941
- },
942
- },
943
- },
944
- "name": "testpkg",
945
- "readme": {
946
- "markdown": "# Missing literate source
947
-
948
- ## This is a heading within the literate file!
949
-
950
- \`\`\`csharp
951
- // Example automatically generated from non-compiling source. May contain errors.
952
- new SampleClass("literate");
953
- \`\`\`
954
-
955
- # Missing literate source and fallback
956
-
957
- ## This is a heading within the omitted literate file!
958
-
959
- \`\`\`csharp
960
- // Example automatically generated from non-compiling source. May contain errors.
961
- new SampleClass("omitted-literate");
962
- \`\`\`
963
-
964
- # Missing fixture
965
-
966
- \`\`\`csharp
967
- // Example automatically generated from non-compiling source. May contain errors.
968
- new SampleClass("README.md");
969
- \`\`\`",
970
- },
971
- "repository": {
972
- "type": "git",
973
- "url": "https://github.com/aws/jsii.git",
974
- },
975
- "schema": "jsii/0.10.0",
976
- "targets": Any<Object>,
977
- "types": {
978
- "testpkg.SampleClass": {
979
- "assembly": "testpkg",
980
- "docs": {
981
- "example": "// Example automatically generated from non-compiling source. May contain errors.
982
- new DoesNotCompile(this, "That", new Struct { Foo = 1337 });",
983
- },
984
- "fqn": "testpkg.SampleClass",
985
- "initializer": {
986
- "locationInModule": {
987
- "filename": "index.ts",
988
- "line": 8,
989
- },
990
- "parameters": [
991
- {
992
- "name": "_source",
993
- "type": {
994
- "primitive": "string",
995
- },
996
- },
997
- ],
998
- },
999
- "kind": "class",
1000
- "locationInModule": {
1001
- "filename": "index.ts",
1002
- "line": 7,
1003
- },
1004
- "name": "SampleClass",
1005
- "symbolId": "index:SampleClass",
1006
- },
1007
- },
1008
- "version": "0.0.1",
1009
- }
1010
- `);
1011
- expect(JSON.parse(fs.readFileSync(path.join(tmpDir, `${spec_1.SPEC_FILE_NAME}.java`), 'utf-8'))).toMatchInlineSnapshot({
1012
- fingerprint: expect.any(String),
1013
- jsiiVersion: expect.any(String),
1014
- targets: expect.any(Object),
1015
- }, `
1016
- {
1017
- "author": {
1018
- "name": "John Doe",
1019
- "roles": [
1020
- "author",
1021
- ],
1022
- },
1023
- "description": "testpkg",
1024
- "fingerprint": Any<String>,
1025
- "homepage": "https://github.com/aws/jsii.git",
1026
- "jsiiVersion": Any<String>,
1027
- "license": "Apache-2.0",
1028
- "metadata": {
1029
- "jsii": {
1030
- "pacmak": {
1031
- "hasDefaultInterfaces": true,
1032
- },
1033
- },
1034
- },
1035
- "name": "testpkg",
1036
- "readme": {
1037
- "markdown": "# Missing literate source
1038
-
1039
- ## This is a heading within the literate file!
1040
-
1041
- \`\`\`java
1042
- // Example automatically generated from non-compiling source. May contain errors.
1043
- new SampleClass("literate");
1044
- \`\`\`
1045
-
1046
- # Missing literate source and fallback
1047
-
1048
- ## This is a heading within the omitted literate file!
1049
-
1050
- \`\`\`java
1051
- // Example automatically generated from non-compiling source. May contain errors.
1052
- new SampleClass("omitted-literate");
1053
- \`\`\`
1054
-
1055
- # Missing fixture
1056
-
1057
- \`\`\`java
1058
- // Example automatically generated from non-compiling source. May contain errors.
1059
- new SampleClass("README.md");
1060
- \`\`\`",
1061
- },
1062
- "repository": {
1063
- "type": "git",
1064
- "url": "https://github.com/aws/jsii.git",
1065
- },
1066
- "schema": "jsii/0.10.0",
1067
- "targets": Any<Object>,
1068
- "types": {
1069
- "testpkg.SampleClass": {
1070
- "assembly": "testpkg",
1071
- "docs": {
1072
- "example": "// Example automatically generated from non-compiling source. May contain errors.
1073
- DoesNotCompile.Builder.create(this, "That").foo(1337).build();",
1074
- },
1075
- "fqn": "testpkg.SampleClass",
1076
- "initializer": {
1077
- "locationInModule": {
1078
- "filename": "index.ts",
1079
- "line": 8,
1080
- },
1081
- "parameters": [
1082
- {
1083
- "name": "_source",
1084
- "type": {
1085
- "primitive": "string",
1086
- },
1087
- },
1088
- ],
1089
- },
1090
- "kind": "class",
1091
- "locationInModule": {
1092
- "filename": "index.ts",
1093
- "line": 7,
1094
- },
1095
- "name": "SampleClass",
1096
- "symbolId": "index:SampleClass",
1097
- },
1098
- },
1099
- "version": "0.0.1",
1100
- }
1101
- `);
1102
- expect(JSON.parse(fs.readFileSync(path.join(tmpDir, `${spec_1.SPEC_FILE_NAME}.python`), 'utf-8'))).toMatchInlineSnapshot({
1103
- fingerprint: expect.any(String),
1104
- jsiiVersion: expect.any(String),
1105
- targets: expect.any(Object),
1106
- }, `
1107
- {
1108
- "author": {
1109
- "name": "John Doe",
1110
- "roles": [
1111
- "author",
1112
- ],
1113
- },
1114
- "description": "testpkg",
1115
- "fingerprint": Any<String>,
1116
- "homepage": "https://github.com/aws/jsii.git",
1117
- "jsiiVersion": Any<String>,
1118
- "license": "Apache-2.0",
1119
- "metadata": {
1120
- "jsii": {
1121
- "pacmak": {
1122
- "hasDefaultInterfaces": true,
1123
- },
1124
- },
1125
- },
1126
- "name": "testpkg",
1127
- "readme": {
1128
- "markdown": "# Missing literate source
1129
-
1130
- ## This is a heading within the literate file!
1131
-
1132
- \`\`\`python
1133
- # Example automatically generated from non-compiling source. May contain errors.
1134
- SampleClass("literate")
1135
- \`\`\`
1136
-
1137
- # Missing literate source and fallback
1138
-
1139
- ## This is a heading within the omitted literate file!
1140
-
1141
- \`\`\`python
1142
- # Example automatically generated from non-compiling source. May contain errors.
1143
- SampleClass("omitted-literate")
1144
- \`\`\`
1145
-
1146
- # Missing fixture
1147
-
1148
- \`\`\`python
1149
- # Example automatically generated from non-compiling source. May contain errors.
1150
- SampleClass("README.md")
1151
- \`\`\`",
1152
- },
1153
- "repository": {
1154
- "type": "git",
1155
- "url": "https://github.com/aws/jsii.git",
1156
- },
1157
- "schema": "jsii/0.10.0",
1158
- "targets": Any<Object>,
1159
- "types": {
1160
- "testpkg.SampleClass": {
1161
- "assembly": "testpkg",
1162
- "docs": {
1163
- "example": "# Example automatically generated from non-compiling source. May contain errors.
1164
- DoesNotCompile(self, "That", foo=1337)",
1165
- },
1166
- "fqn": "testpkg.SampleClass",
1167
- "initializer": {
1168
- "locationInModule": {
1169
- "filename": "index.ts",
1170
- "line": 8,
1171
- },
1172
- "parameters": [
1173
- {
1174
- "name": "_source",
1175
- "type": {
1176
- "primitive": "string",
1177
- },
1178
- },
1179
- ],
1180
- },
1181
- "kind": "class",
1182
- "locationInModule": {
1183
- "filename": "index.ts",
1184
- "line": 7,
1185
- },
1186
- "name": "SampleClass",
1187
- "symbolId": "index:SampleClass",
1188
- },
1189
- },
1190
- "version": "0.0.1",
1191
- }
1192
- `);
1193
- }));
1194
- test('single assembly with example metadata', () => (0, testutil_1.withTemporaryDirectory)(async (tmpDir) => {
1195
- // GIVEN
1196
- const compilationResult = jsii.compileJsiiForTest({
1197
- 'index.ts': `
1198
- /**
1199
- * @exampleMetadata fixture=custom
1200
- * @example
1201
- * const object: IInterface = new ClassName('this', 1337, { foo: 'bar' });
1202
- * object.property = EnumType.OPTION_A;
1203
- * object.methodCall();
1204
- */
1205
- export enum EnumType {
1206
- /**
1207
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_A });
1208
- */
1209
- OPTION_A = 1,
1210
-
1211
- /**
1212
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1213
- */
1214
- OPTION_B = 2,
1215
- }
1216
-
1217
- export interface IInterface {
1218
- /**
1219
- * A property value.
1220
- *
1221
- * @exampleMetadata nofixture
1222
- * @example
1223
- * import { EnumType, IInterface, ClassName } from '.';
1224
- * declare const iface: IInterface;
1225
- * iface.property = EnumType.OPTION_A;
1226
- */
1227
- property: EnumType;
1228
-
1229
- /**
1230
- * An instance method call.
1231
- *
1232
- * @example
1233
- * iface.methodCall();
1234
- */
1235
- methodCall(): void;
1236
- }
1237
-
1238
- export interface ClassNameProps {
1239
- readonly property?: EnumType;
1240
- readonly foo?: string;
1241
- }
1242
-
1243
- export class ClassName implements IInterface {
1244
- /**
1245
- * A static method. It can be invoked easily.
1246
- *
1247
- * @example ClassName.staticMethod();
1248
- */
1249
- public static staticMethod(_enm?: EnumType): void {
1250
- // ...
1251
- }
1252
-
1253
- public property: EnumType;
1254
-
1255
- /**
1256
- * Create a new instance of ClassName.
1257
- *
1258
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1259
- */
1260
- public constructor(_this: string, _elite: number, props: ClassNameProps) {
1261
- this.property = props.property ?? EnumType.OPTION_A;
1262
- }
1263
-
1264
- public methodCall(): void {
1265
- // ...
1266
- }
1267
- }`,
1268
- });
1269
- fs.writeFileSync(path.join(tmpDir, spec_1.SPEC_FILE_NAME), JSON.stringify({ ...compilationResult.assembly, targets }, null, 2));
1270
- for (const [file, content] of Object.entries(compilationResult.files)) {
1271
- fs.writeFileSync(path.resolve(tmpDir, file), content, 'utf-8');
1272
- }
1273
- fs.mkdirSync(path.resolve(tmpDir, 'rosetta'));
1274
- fs.writeFileSync(path.resolve(tmpDir, 'rosetta', 'default.ts-fixture'), `import { EnumType, IInterface, ClassName } from '.';\ndeclare const iface: IInterface;\n/// here`, 'utf-8');
1275
- fs.writeFileSync(path.resolve(tmpDir, 'rosetta', 'custom.ts-fixture'), `import { EnumType, IInterface, ClassName } from '.';/// here`, 'utf-8');
1276
- // THEN
1277
- await expect((0, transliterate_1.transliterateAssembly)([tmpDir], Object.values(target_language_1.TargetLanguage), {
1278
- strict: true,
1279
- })).resolves.not.toThrow();
1280
- }));
1281
- test('will read translations from cache even if they are dirty', async () => {
1282
- const infusedAssembly = testutil_1.TestJsiiModule.fromSource({
1283
- 'index.ts': `
1284
- /**
1285
- * ClassA
1286
- *
1287
- * @example x
1288
- */
1289
- export class ClassA {
1290
- public someMethod() {
1291
- }
1292
- }
1293
- `,
1294
- }, {
1295
- name: 'my_assembly',
1296
- jsii: testutil_1.DUMMY_JSII_CONFIG,
1297
- });
1298
- try {
1299
- // Run an extract
1300
- await (0, extract_1.extractSnippets)([infusedAssembly.moduleDirectory]);
1301
- // Mess up the extracted source file
1302
- const schema = JSON.parse(await fs.promises.readFile(path.join(infusedAssembly.moduleDirectory, '.jsii.tabl.json'), 'utf-8'));
1303
- for (const snippet of Object.values(schema.snippets)) {
1304
- snippet.translations[target_language_1.TargetLanguage.PYTHON] = {
1305
- source: 'oops',
1306
- version: '999',
1307
- };
1308
- }
1309
- await fs.promises.writeFile(path.join(infusedAssembly.moduleDirectory, '.jsii.tabl.json'), JSON.stringify(schema));
1310
- // Run a transliterate, should have used the translation from the cache even though the version is wrong
1311
- await (0, transliterate_1.transliterateAssembly)([infusedAssembly.moduleDirectory], [target_language_1.TargetLanguage.PYTHON]);
1312
- const translated = JSON.parse(await fs.promises.readFile(path.join(infusedAssembly.moduleDirectory, '.jsii.python'), 'utf-8'));
1313
- expect(translated.types?.['my_assembly.ClassA'].docs?.example).toEqual('oops');
1314
- }
1315
- finally {
1316
- infusedAssembly.cleanup();
1317
- }
1318
- });
1319
- test('will read translations from cache when tablet is compressed', async () => {
1320
- const infusedAssembly = testutil_1.TestJsiiModule.fromSource({
1321
- 'index.ts': `
1322
- /**
1323
- * ClassA
1324
- *
1325
- * @example x
1326
- */
1327
- export class ClassA {
1328
- public someMethod() {
1329
- }
1330
- }
1331
- `,
1332
- }, {
1333
- name: 'my_assembly',
1334
- jsii: testutil_1.DUMMY_JSII_CONFIG,
1335
- });
1336
- try {
1337
- // Run an extract and tell it to compress the tablet
1338
- await (0, extract_1.extractSnippets)([infusedAssembly.moduleDirectory], {
1339
- compressTablet: true,
1340
- });
1341
- await (0, transliterate_1.transliterateAssembly)([infusedAssembly.moduleDirectory], [target_language_1.TargetLanguage.PYTHON]);
1342
- const translated = JSON.parse(await fs.promises.readFile(path.join(infusedAssembly.moduleDirectory, '.jsii.python'), 'utf-8'));
1343
- expect(translated.types?.['my_assembly.ClassA'].docs?.example).toEqual('x');
1344
- }
1345
- finally {
1346
- infusedAssembly.cleanup();
1347
- }
1348
- });
1349
- test('will output to specified directory', async () => (0, testutil_1.withTemporaryDirectory)(async (tmpDir) => {
1350
- // GIVEN
1351
- const compilationResult = jsii.compileJsiiForTest({
1352
- 'README.md': `
1353
- # README
1354
- \`\`\`ts
1355
- const object: IInterface = new ClassName('this', 1337, { foo: 'bar' });
1356
- object.property = EnumType.OPTION_A;
1357
- object.methodCall();
1358
-
1359
- ClassName.staticMethod(EnumType.OPTION_B);
1360
- \`\`\`
1361
- `,
1362
- 'index.ts': `
1363
- /**
1364
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1365
- */
1366
- export enum EnumType {
1367
- /**
1368
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_A });
1369
- */
1370
- OPTION_A = 1,
1371
-
1372
- /**
1373
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1374
- */
1375
- OPTION_B = 2,
1376
- }
1377
-
1378
- export interface IInterface {
1379
- /**
1380
- * A property value.
1381
- *
1382
- * @example
1383
- * iface.property = EnumType.OPTION_B;
1384
- */
1385
- property: EnumType;
1386
-
1387
- /**
1388
- * An instance method call.
1389
- *
1390
- * @example
1391
- * iface.methodCall();
1392
- */
1393
- methodCall(): void;
1394
- }
1395
-
1396
- export interface ClassNameProps {
1397
- readonly property?: EnumType;
1398
- readonly foo?: string;
1399
- }
1400
-
1401
- export class ClassName implements IInterface {
1402
- /**
1403
- * A static method. It can be invoked easily.
1404
- *
1405
- * @example ClassName.staticMethod();
1406
- */
1407
- public static staticMethod(_enm?: EnumType): void {
1408
- // ...
1409
- }
1410
-
1411
- public property: EnumType;
1412
-
1413
- /**
1414
- * Create a new instance of ClassName.
1415
- *
1416
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1417
- */
1418
- public constructor(_this: string, _elite: number, props: ClassNameProps) {
1419
- this.property = props.property ?? EnumType.OPTION_A;
1420
- }
1421
-
1422
- public methodCall(): void {
1423
- // ...
1424
- }
1425
- }`,
1426
- });
1427
- fs.writeFileSync(path.join(tmpDir, spec_1.SPEC_FILE_NAME), JSON.stringify({ ...compilationResult.assembly, targets }, null, 2));
1428
- for (const [file, content] of Object.entries(compilationResult.files)) {
1429
- fs.writeFileSync(path.resolve(tmpDir, file), content, 'utf-8');
1430
- }
1431
- fs.mkdirSync(path.resolve(tmpDir, 'rosetta'));
1432
- fs.writeFileSync(path.resolve(tmpDir, 'rosetta', 'default.ts-fixture'), `import { EnumType, IInterface, ClassName } from '.';\ndeclare const iface: IInterface\n/// here`, 'utf-8');
1433
- // WHEN
1434
- // create outdir
1435
- const outdir = path.resolve(tmpDir, 'out');
1436
- fs.mkdirSync(outdir);
1437
- await expect((0, transliterate_1.transliterateAssembly)([tmpDir], Object.values(target_language_1.TargetLanguage), {
1438
- strict: true,
1439
- outdir,
1440
- })).resolves.not.toThrow();
1441
- Object.values(target_language_1.TargetLanguage).forEach((lang) => {
1442
- expect(fs.statSync(path.join(outdir, `${spec_1.SPEC_FILE_NAME}.${lang}`)).isFile()).toBe(true);
1443
- });
1444
- }));
1445
- test('will not attempt to produce output for an unsupported language', async () => (0, testutil_1.withTemporaryDirectory)(async (tmpDir) => {
1446
- // GIVEN
1447
- const compilationResult = jsii.compileJsiiForTest({
1448
- 'README.md': `
1449
- # README
1450
- \`\`\`ts
1451
- const object: IInterface = new ClassName('this', 1337, { foo: 'bar' });
1452
- object.property = EnumType.OPTION_A;
1453
- object.methodCall();
1454
-
1455
- ClassName.staticMethod(EnumType.OPTION_B);
1456
- \`\`\`
1457
- `,
1458
- 'index.ts': `
1459
- /**
1460
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1461
- */
1462
- export enum EnumType {
1463
- /**
1464
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_A });
1465
- */
1466
- OPTION_A = 1,
1467
-
1468
- /**
1469
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1470
- */
1471
- OPTION_B = 2,
1472
- }
1473
-
1474
- export interface IInterface {
1475
- /**
1476
- * A property value.
1477
- *
1478
- * @example
1479
- * iface.property = EnumType.OPTION_B;
1480
- */
1481
- property: EnumType;
1482
-
1483
- /**
1484
- * An instance method call.
1485
- *
1486
- * @example
1487
- * iface.methodCall();
1488
- */
1489
- methodCall(): void;
1490
- }
1491
-
1492
- export interface ClassNameProps {
1493
- readonly property?: EnumType;
1494
- readonly foo?: string;
1495
- }
1496
-
1497
- export class ClassName implements IInterface {
1498
- /**
1499
- * A static method. It can be invoked easily.
1500
- *
1501
- * @example ClassName.staticMethod();
1502
- */
1503
- public static staticMethod(_enm?: EnumType): void {
1504
- // ...
1505
- }
1506
-
1507
- public property: EnumType;
1508
-
1509
- /**
1510
- * Create a new instance of ClassName.
1511
- *
1512
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1513
- */
1514
- public constructor(_this: string, _elite: number, props: ClassNameProps) {
1515
- this.property = props.property ?? EnumType.OPTION_A;
1516
- }
1517
-
1518
- public methodCall(): void {
1519
- // ...
1520
- }
1521
- }`,
1522
- });
1523
- fs.writeFileSync(path.join(tmpDir, spec_1.SPEC_FILE_NAME), JSON.stringify({ ...compilationResult.assembly, targets: { ...targets, [(0, target_language_1.targetName)(target_language_1.TargetLanguage.GO)]: undefined } }, null, 2));
1524
- for (const [file, content] of Object.entries(compilationResult.files)) {
1525
- fs.writeFileSync(path.resolve(tmpDir, file), content, 'utf-8');
1526
- }
1527
- fs.mkdirSync(path.resolve(tmpDir, 'rosetta'));
1528
- fs.writeFileSync(path.resolve(tmpDir, 'rosetta', 'default.ts-fixture'), `import { EnumType, IInterface, ClassName } from '.';\ndeclare const iface: IInterface\n/// here`, 'utf-8');
1529
- // WHEN
1530
- // create outdir
1531
- const outdir = path.resolve(tmpDir, 'out');
1532
- fs.mkdirSync(outdir);
1533
- await expect((0, transliterate_1.transliterateAssembly)([tmpDir], Object.values(target_language_1.TargetLanguage), {
1534
- strict: true,
1535
- outdir,
1536
- })).resolves.not.toThrow();
1537
- Object.values(target_language_1.TargetLanguage).forEach((lang) => {
1538
- if (lang === target_language_1.TargetLanguage.GO) {
1539
- expect(fs.existsSync(path.join(outdir, `${spec_1.SPEC_FILE_NAME}.${lang}`))).toBe(false);
1540
- }
1541
- else {
1542
- expect(fs.statSync(path.join(outdir, `${spec_1.SPEC_FILE_NAME}.${lang}`)).isFile()).toBe(true);
1543
- }
1544
- });
1545
- }));
1546
- test('transliterate works with zipped assembly files', async () => (0, testutil_1.withTemporaryDirectory)(async (tmpDir) => {
1547
- // GIVEN
1548
- const compilationResult = jsii.compileJsiiForTest({
1549
- 'README.md': `
1550
- # README
1551
- \`\`\`ts
1552
- const object: IInterface = new ClassName('this', 1337, { foo: 'bar' });
1553
- object.property = EnumType.OPTION_A;
1554
- object.methodCall();
1555
- ClassName.staticMethod(EnumType.OPTION_B);
1556
- \`\`\`
1557
- `,
1558
- 'index.ts': `
1559
- /**
1560
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1561
- */
1562
- export enum EnumType {
1563
- /**
1564
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_A });
1565
- */
1566
- OPTION_A = 1,
1567
- /**
1568
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1569
- */
1570
- OPTION_B = 2,
1571
- }
1572
- export interface IInterface {
1573
- /**
1574
- * A property value.
1575
- *
1576
- * @example
1577
- * iface.property = EnumType.OPTION_B;
1578
- */
1579
- property: EnumType;
1580
- /**
1581
- * An instance method call.
1582
- *
1583
- * @example
1584
- * iface.methodCall();
1585
- */
1586
- methodCall(): void;
1587
- }
1588
- export interface ClassNameProps {
1589
- readonly property?: EnumType;
1590
- readonly foo?: string;
1591
- }
1592
- export class ClassName implements IInterface {
1593
- /**
1594
- * A static method. It can be invoked easily.
1595
- *
1596
- * @example ClassName.staticMethod();
1597
- */
1598
- public static staticMethod(_enm?: EnumType): void {
1599
- // ...
1600
- }
1601
- public property: EnumType;
1602
- /**
1603
- * Create a new instance of ClassName.
1604
- *
1605
- * @example new ClassName('this', 1337, { property: EnumType.OPTION_B });
1606
- */
1607
- public constructor(_this: string, _elite: number, props: ClassNameProps) {
1608
- this.property = props.property ?? EnumType.OPTION_A;
1609
- }
1610
- public methodCall(): void {
1611
- // ...
1612
- }
1613
- }`,
1614
- });
1615
- (0, spec_1.writeAssembly)(tmpDir, {
1616
- ...compilationResult.assembly,
1617
- targets: { ...targets },
1618
- }, { compress: true });
1619
- for (const [file, content] of Object.entries(compilationResult.files)) {
1620
- fs.writeFileSync(path.resolve(tmpDir, file), content, 'utf-8');
1621
- }
1622
- fs.mkdirSync(path.resolve(tmpDir, 'rosetta'));
1623
- fs.writeFileSync(path.resolve(tmpDir, 'rosetta', 'default.ts-fixture'), `import { EnumType, IInterface, ClassName } from '.';\ndeclare const iface: IInterface\n/// here`, 'utf-8');
1624
- // WHEN
1625
- // create outdir
1626
- const outdir = path.resolve(tmpDir, 'out');
1627
- fs.mkdirSync(outdir);
1628
- await expect((0, transliterate_1.transliterateAssembly)([tmpDir], Object.values(target_language_1.TargetLanguage), {
1629
- strict: true,
1630
- outdir,
1631
- })).resolves.not.toThrow();
1632
- Object.values(target_language_1.TargetLanguage).forEach((lang) => {
1633
- expect(fs.statSync(path.join(outdir, `${spec_1.SPEC_FILE_NAME}.${lang}`)).isFile()).toBe(true);
1634
- });
1635
- }));
1636
- //# sourceMappingURL=transliterate.test.js.map